Skip to content

refactor: move every file into its layer - #1375

Merged
gewenyu99 merged 1 commit into
posthog/functional-r9-01-remove-the-import-boundary-scannerfrom
posthog/functional-r9-02-move-every-file-into-its-layer
Sep 30, 2026
Merged

gewenyu99 merged 1 commit into
posthog/functional-r9-01-remove-the-import-boundary-scannerfrom
posthog/functional-r9-02-move-every-file-into-its-layer

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Phase 1 of Release C (#1320), PR 2 of 2, after #1374. Green on its own.

Problem

Many files sit in folders that do not match their layer: the TUI under src/ui/tui, CLI code under src/commands and src/lib/runners, tools under src/programs. Some files also mix code from more than one layer. If the later PRs also moved code, every diff would mix moves with real changes.

Changes

Moves only: file renames plus verbatim block moves, with import and export edits only. No behavior changes. 596 files changed, 2,614 insertions and 2,438 deletions: 468 renames, 26 new files that receive moved blocks, and 102 files edited for imports.

  • src/ui/tui moves to src/tui, with each program's screens in src/tui/programs/<id> and tool screens in src/tui/tools/<id>.
  • src/wizard.ts, src/commands and the CI and headless runners move under src/cli. Tool code moves to src/tools, and MCP client code moves to src/shared/mcp-clients.
  • 16 renames split a file's old role from its new home, for example src/lib/wizard-session.ts to src/programs/session/, src/ui/logging-ui.ts to src/headless/renderers/, and program steps.ts files to src/tui/programs/<id>/flow.ts.
  • 28 block moves lift code out of a mixed file into its layer, unchanged: per-program OAuth scopes out of program-scopes.ts, screen ids, run state, task status, ask policy, cleanup, and the audit and error-tracking flows.
  • New folder aliases @host/*, @tools/*, @tui/*, @headless/* and @cli/* in tsconfig.build.json and vitest.config.ts.
  • The only other edits: export added on 8 moved symbols, one restriction path in .eslintrc.cjs, and the path filter in mcp-install.yml.
  • Paths that follow the moves: the tui, cli and new tools Vitest projects read src/tui, src/cli and src/tools, and the four deck owners in CODEOWNERS point at src/tui/programs/<program>/.

Test plan

  • pnpm typecheck: 0 errors.
  • pnpm lint: 0 errors.
  • vitest run: 205 test files, 3,446 tests pass.
  • pnpm build succeeds.

Created with PostHog Desktop

@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci feature-flags
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/google-adk
  • /wizard-ci ai-observability/groq
Show more apps
  • /wizard-ci ai-observability/manual-capture
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/opentelemetry
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci feature-flags/django
  • /wizard-ci feature-flags/next-js
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

@gewenyu99
gewenyu99 added this pull request to stack #1393 September 29, 2026 09:40
@gewenyu99
gewenyu99 marked this pull request as ready for review September 29, 2026 10:21
@gewenyu99
gewenyu99 requested review from a team as code owners September 29, 2026 10:21
@gewenyu99
gewenyu99 requested review from TueHaulund, ablaszkiewicz, arnohillen, fasyy612, hpouillot and ksvat and removed request for a team September 29, 2026 10:21

@edwinyjlim edwinyjlim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. vitest project globs point at the old folders. vitest.config.ts:37 and :38
    TUI_TESTS still reads src/ui/tui/, and CLI_TESTS still reads src/commands/ and src/lib/runners/. On this head the tui project has no files, so pnpm test:tui exits 1 with "No test files found". The cli project drops from 14 files to 2 and legacy grows from 52 to 93. vitest run stays green only because legacy is the catch-all. This file already changes in the PR, so point the globs at src/tui/** and src/cli/** here, and decide where src/tools, src/host and src/headless tests belong.

  2. CODEOWNERS deck paths moved. .github/CODEOWNERS:23
    Lines 23 to 26 own /src/ui/tui/decks//, which no longer exists. The decks now live at /src/tui/programs//deck/, so after merge those four teams stop being requested on changes to their own decks. Update the four paths; the /src/programs/ entries above them still match.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-02-move-every-file-into-its-layer branch from d38e293 to b8f1f7a Compare September 30, 2026 08:44
@gewenyu99

Copy link
Copy Markdown
Collaborator Author

@edwinyjlim thanks, both fixed in b8f1f7a:

  1. Vitest projects. tui now reads src/tui/** and cli reads src/cli/**, which also picks up mcp-cli.test.ts, now moved to src/cli/__tests__. src/tools gets its own tools project. src/host tests stay in the catch-all project, which refactor: add the session store, run contract and run helpers #1376 renames shared. src/headless has no tests until phase 2, where refactor: add the session store, run contract and run helpers #1376 adds its headless project. pnpm test:tui finds 758 tests and the cli project finds 140.
  2. CODEOWNERS. The four deck lines now own /src/tui/programs/<program>/.

The stack is also rebased on main 2.79.1.

@gewenyu99
gewenyu99 merged commit ddb5b9c into main Sep 30, 2026
31 checks passed
johncwaters added a commit that referenced this pull request Oct 2, 2026
Point the feature-flags program, deck, intro screen and test at the
paths #1375 moved them to, and register the command in main.ts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants