Skip to content

refactor: route the cli, e2e harness and examples through public entries - #1385

Closed
gewenyu99 wants to merge 1 commit into
posthog/functional-r9-11-split-the-tools-out-of-programsfrom
posthog/functional-r9-12-route-the-cli-e2e-harness-and-examples-t
Closed

gewenyu99 wants to merge 1 commit into
posthog/functional-r9-11-split-the-tools-out-of-programsfrom
posthog/functional-r9-12-route-the-cli-e2e-harness-and-examples-t

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Phase 2 of Release C (#1320), PR 9 of 16, after #1384. Review PR. PRs 1 to 14 of this phase split one change into reviewable pieces and compile only as a stack: review them one by one, then land the whole phase together.

Problem

On main, main.ts registers every command and starts the test mock server, and the CLI, the e2e harness, scripts and the docs examples import deep paths into other layers. With the hosts in place, each of them can go through public entries.

Changes

  • runCli (src/cli/index.ts) registers every command, and main.ts calls only runCli. bin.ts still checks the Node version before it loads main.ts. The MSW mock server moves from main.ts to e2e-tests/mocks/preload.ts, which startWizardInstance preloads into the wizard's process through tsx.
  • CLI commands take programs from @programs (getProgramConfig, each program's config) and print through consoleLog instead of setUI(new LoggingUI()). chooseFamilyChild draws through the TUI's renderFamilyPicker, so the CLI holds no Ink code.
  • New global option in src/cli/wizard.ts: --log-file (env POSTHOG_WIZARD_LOG_FILE), which sets the file the debug log goes to.
  • e2e harness: profiles.ts reads each program's test/e2e.json from disk, by its program id, so a new program needs no harness edit. e2e-profile.ts decides a program's own screen from the actions the state lists for it. action-registry.ts, wizard-ci-driver.ts and e2e-profile.ts take the store and every screen id from the @tui entry, and the run state from @shared.
  • vitest.config.ts maps the public entries (@tui, @cli, @headless, @tools), drops the @ui, @steps and @lib aliases, adds a headless test project, and renames the catch-all legacy project to shared.
  • docs/examples/run-agent-quack.ts, run-program-quack.ts and the smoke scripts import only public entries such as @programs, @agent and @env.
  • Focus on main.ts, runCli and the command handlers: every command must parse and dispatch as on main.

Test plan

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 #1394 September 29, 2026 09:41
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-11-split-the-tools-out-of-programs branch from f8c053f to f0d8c36 Compare September 30, 2026 08:06
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-12-route-the-cli-e2e-harness-and-examples-t branch from eeede8c to f70ef67 Compare September 30, 2026 08:06
@gewenyu99
gewenyu99 removed this pull request from stack #1394 September 30, 2026 08:07
@gewenyu99
gewenyu99 added this pull request to stack #1400 September 30, 2026 08:07
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-12-route-the-cli-e2e-harness-and-examples-t branch from f70ef67 to eaa3240 Compare September 30, 2026 08:44
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-11-split-the-tools-out-of-programs branch from f0d8c36 to c03101f Compare September 30, 2026 08:44
@gewenyu99
gewenyu99 marked this pull request as ready for review September 30, 2026 09:17
@gewenyu99
gewenyu99 requested a review from a team as a code owner September 30, 2026 09:17
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-12-route-the-cli-e2e-harness-and-examples-t branch 2 times, most recently from dfdc9c3 to 9c1d85d Compare October 1, 2026 06:43
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-11-split-the-tools-out-of-programs branch from 24a0712 to 95d85e8 Compare October 1, 2026 06:43
@gewenyu99
gewenyu99 removed this pull request from stack #1400 October 1, 2026 06:47
@gewenyu99
gewenyu99 added this pull request to stack #1403 October 1, 2026 06:47

@johncwaters johncwaters left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

Automated review. Not written by a human.

Comment thread src/cli/wizard.ts Outdated
// and it runs before any TUI takes the terminal.
.middleware((argv) => {
if (typeof argv.logFile === 'string' && argv.logFile) {
configureLogFile({ path: argv.logFile });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

Automated review. Not written by a human.

This path gets overwritten later without warning. With --benchmark, createBenchmarkPipeline (src/agent/middleware/benchmark.ts:77) calls configureLogFile({ path: config.output.logPath }). In --ci/headless runs, runNonInteractive calls configureLogFileFromEnvironment() (src/cli/runners/run-non-interactive.ts:59), so POSTHOG_WIZARD_LOG_DIR wins. In both cases --log-file is ignored.

Could an explicit --log-file take priority, e.g. through one resolver the benchmark and env-dir paths defer to? A test combining --log-file with --benchmark would pin it.

@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-11-split-the-tools-out-of-programs branch from 95d85e8 to 4be5b3f Compare October 2, 2026 16:47
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-12-route-the-cli-e2e-harness-and-examples-t branch 2 times, most recently from 602458a to e88b9e5 Compare October 2, 2026 20:50
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-11-split-the-tools-out-of-programs branch from 4be5b3f to 1b7941f Compare October 2, 2026 20:50
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-11-split-the-tools-out-of-programs branch from 1b7941f to 81ab207 Compare October 3, 2026 20:40
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-12-route-the-cli-e2e-harness-and-examples-t branch from e88b9e5 to 6b6345e Compare October 3, 2026 20:40

@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.

Review of #1385 at 6b6345e7. Comments inline.


Drafted with Claude Code from a review of the whole Release C stack, re-verified at the stack tip 2e31e438. Line numbers are at this PR's head.

Comment thread e2e-tests/utils/index.ts
'--import',
pathToFileURL(require.resolve('tsx')).href,
'--import',
pathToFileURL(path.join(__dirname, '../mocks/preload.ts')).href,

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.

[P2] The MSW relocation is the first time the mocks can reach the built wizard, and nothing runs the suite

The deleted main.ts block was gated on NODE_ENV === 'test', which tsdown inlines as production, so it was dead in every built output that test:e2e spawns. The new preload will intercept for the first time. No workflow runs e2e-tests/, the test plan lists only unit tests, and the recorded fixtures were last touched on 2026-03-31.

Suggested fix: Run pnpm test:e2e once on the stack tip and put the result in the test plan. If the suite is not maintained, say so in the body. Add a one-line comment in preload.ts that it replaced the env gate.

Comment thread src/cli/wizard.ts
describe: 'Enable verbose logging\nenv: POSTHOG_WIZARD_DEBUG',
type: 'boolean' as const,
},
'log-file': {

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.

[P3] A user-visible flag ships under a refactor: commit

release-please builds the changelog from commit types, so --log-file will not appear in the release notes.

Suggested fix: Split it into a feat(cli) commit ahead of this one, or add a feat body line.

ScreenId.SelfDrivingHandoff,
SelfDrivingScreenId.IntegrationDetect,
SelfDrivingScreenId.IntegrationCheck,
SelfDrivingScreenId.IntegrationDetect,

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.

[P3] SelfDrivingScreenId.IntegrationDetect is listed twice in NO_ACTION_SCREENS

Suggested fix: Delete line 100. Harmless in a set, but it reads as if a second screen was meant.

]);

/** Decide a program screen from the commits the state lists for it. */
function decideProgramScreen(

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.

[P3] No test names decideProgramScreen's contract

The drivable-screens list now holds only core screens, so the "no listed screen waits forever" test no longer covers intros, detection checks, handoffs or outros. A new program screen whose only action id is outside the commit set would stall a run with no unit test pointing at the cause.

Suggested fix: One table test: for every registry key not in the core set, build a state with actionsForScreen(screen) and assert an action when any id is in the commit set, otherwise wait.

@gewenyu99

Copy link
Copy Markdown
Collaborator Author

Folded into #1378 so the phase builds green PR by PR. This PR keeps its review; the code lands through #1378.

@gewenyu99 gewenyu99 closed this Oct 5, 2026
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.

3 participants