@posthog/wizard 2.17.0 → 2.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/{add-mcp-server-to-clients-D4PK6ulR.js → add-mcp-server-to-clients-CjnvTVj0.js} +72 -13
  2. package/dist/add-mcp-server-to-clients-CjnvTVj0.js.map +1 -0
  3. package/dist/{agent-interface-7t5DBo2A.js → agent-interface-CQU6x4Hj.js} +112 -54
  4. package/dist/agent-interface-CQU6x4Hj.js.map +1 -0
  5. package/dist/{agent-runner-CTkKLVhp.js → agent-runner-Cj7saDkL.js} +17 -11
  6. package/dist/{agent-runner-CTkKLVhp.js.map → agent-runner-Cj7saDkL.js.map} +1 -1
  7. package/dist/{analytics-DN_Gy87F.js → analytics-Df-Xb81i.js} +26 -4
  8. package/dist/analytics-Df-Xb81i.js.map +1 -0
  9. package/dist/{api-serd0SMY.js → api-Dw6_orDE.js} +3 -3
  10. package/dist/{api-serd0SMY.js.map → api-Dw6_orDE.js.map} +1 -1
  11. package/dist/bin.js +236 -79
  12. package/dist/bin.js.map +1 -1
  13. package/dist/{ci-install-BbJ7c3WK.js → ci-install-BKAvFfK6.js} +4 -4
  14. package/dist/{ci-install-BbJ7c3WK.js.map → ci-install-BKAvFfK6.js.map} +1 -1
  15. package/dist/{debug-BI-Js0PB.js → debug-Cp_wNn8i.js} +1 -1
  16. package/dist/{debug-Bx7nvCWW.js → debug-DnMO6O8O.js} +36 -21
  17. package/dist/debug-DnMO6O8O.js.map +1 -0
  18. package/dist/{defaults-CPH6eWhN.js → defaults-BNWIWzjc.js} +34 -8
  19. package/dist/defaults-BNWIWzjc.js.map +1 -0
  20. package/dist/{env-api-key-B3gE9Un0.js → env-api-key-MlzJYAvt.js} +1 -1
  21. package/dist/{env-api-key-B3gE9Un0.js.map → env-api-key-MlzJYAvt.js.map} +1 -1
  22. package/dist/{environment-CiZVSSYt.js → environment-Ls0H9ljT.js} +3 -3
  23. package/dist/{environment-CiZVSSYt.js.map → environment-Ls0H9ljT.js.map} +1 -1
  24. package/dist/{file-utils-Dy9JncCo.js → file-utils-VAXoyXVA.js} +1 -1
  25. package/dist/{file-utils-Dy9JncCo.js.map → file-utils-VAXoyXVA.js.map} +1 -1
  26. package/dist/{interactive-BwIzklw0.js → interactive-D15byhpc.js} +2 -2
  27. package/dist/{interactive-BwIzklw0.js.map → interactive-D15byhpc.js.map} +1 -1
  28. package/dist/{mcp-prompt-streaming-8U9Qs9EV.js → mcp-prompt-streaming-DQOTQfW1.js} +4 -4
  29. package/dist/{mcp-prompt-streaming-8U9Qs9EV.js.map → mcp-prompt-streaming-DQOTQfW1.js.map} +1 -1
  30. package/dist/{non-interactive-DTaZnVq_.js → non-interactive-DcFLJtl_.js} +2 -2
  31. package/dist/{non-interactive-DTaZnVq_.js.map → non-interactive-DcFLJtl_.js.map} +1 -1
  32. package/dist/{package-manager-CKQLR20D.js → package-manager-DUPgLGpQ.js} +2 -2
  33. package/dist/{package-manager-CKQLR20D.js.map → package-manager-DUPgLGpQ.js.map} +1 -1
  34. package/dist/{playground-CR81Mwe3.js → playground-BZ0hGjbL.js} +12 -4
  35. package/dist/playground-BZ0hGjbL.js.map +1 -0
  36. package/dist/{posthog-BrLFkaji.js → posthog-Cr37rnla.js} +1 -1
  37. package/dist/{posthog-BrLFkaji.js.map → posthog-Cr37rnla.js.map} +1 -1
  38. package/dist/{posthog-integration-Bv7987YJ.js → posthog-integration-C8qhJnI3.js} +282 -13
  39. package/dist/posthog-integration-C8qhJnI3.js.map +1 -0
  40. package/dist/{provisioning-C96Kw-9D.js → provisioning-C-2ExcqY.js} +3 -3
  41. package/dist/{provisioning-C96Kw-9D.js.map → provisioning-C-2ExcqY.js.map} +1 -1
  42. package/dist/{registry-B9k73FKR.js → registry-hBUgaWFx.js} +4 -4
  43. package/dist/{registry-B9k73FKR.js.map → registry-hBUgaWFx.js.map} +1 -1
  44. package/dist/{setup-utils-Bpfsap9L.js → setup-utils-DetnhXo0.js} +65 -44
  45. package/dist/setup-utils-DetnhXo0.js.map +1 -0
  46. package/dist/{slides-DRbBgsdd.js → slides-mT2s9wM_.js} +180 -71
  47. package/dist/slides-mT2s9wM_.js.map +1 -0
  48. package/dist/{start-tui-BZ7rEf3e.js → start-tui-BfXoErKg.js} +16 -16
  49. package/dist/start-tui-BfXoErKg.js.map +1 -0
  50. package/dist/{steps-DDx35170.js → steps-SoDXSUxe.js} +6 -6
  51. package/dist/{steps-DDx35170.js.map → steps-SoDXSUxe.js.map} +1 -1
  52. package/dist/{task-stream-BI8rJg9H.js → task-stream-CZRj6auI.js} +2 -2
  53. package/dist/{task-stream-BI8rJg9H.js.map → task-stream-CZRj6auI.js.map} +1 -1
  54. package/dist/{telemetry-ByYtIfW0.js → telemetry-CPcMFxcO.js} +2 -2
  55. package/dist/{telemetry-ByYtIfW0.js.map → telemetry-CPcMFxcO.js.map} +1 -1
  56. package/dist/{urls-CTCJIxbR.js → urls-BO7doNJG.js} +2 -2
  57. package/dist/{urls-CTCJIxbR.js.map → urls-BO7doNJG.js.map} +1 -1
  58. package/dist/{wizard-abort-CY0ibdq1.js → wizard-abort-CDXufkqJ.js} +5 -3
  59. package/dist/wizard-abort-CDXufkqJ.js.map +1 -0
  60. package/dist/{wizard-abort-QdRxGQp_.js → wizard-abort-CtMY57ZE.js} +1 -1
  61. package/package.json +1 -1
  62. package/dist/TextBlock-D0Ep3zC9.js +0 -275
  63. package/dist/TextBlock-D0Ep3zC9.js.map +0 -1
  64. package/dist/add-mcp-server-to-clients-D4PK6ulR.js.map +0 -1
  65. package/dist/agent-interface-7t5DBo2A.js.map +0 -1
  66. package/dist/analytics-DN_Gy87F.js.map +0 -1
  67. package/dist/debug-Bx7nvCWW.js.map +0 -1
  68. package/dist/defaults-CPH6eWhN.js.map +0 -1
  69. package/dist/playground-CR81Mwe3.js.map +0 -1
  70. package/dist/posthog-integration-Bv7987YJ.js.map +0 -1
  71. package/dist/setup-utils-Bpfsap9L.js.map +0 -1
  72. package/dist/skill-CPqcV8zp.js +0 -29
  73. package/dist/skill-CPqcV8zp.js.map +0 -1
  74. package/dist/slides-DRbBgsdd.js.map +0 -1
  75. package/dist/start-tui-BZ7rEf3e.js.map +0 -1
  76. package/dist/wizard-abort-CY0ibdq1.js.map +0 -1
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","names":["POSTHOG_SDKS","getContentBlocks","baseConfig","DOCS_URL","getContentBlocks","agentSkillContentBlocks"],"sources":["../src/commands/command.ts","../src/wizard.ts","../src/commands/provision.ts","../src/commands/basic-integration/index.ts","../src/lib/programs/revenue-analytics/detect.ts","../src/lib/programs/revenue-analytics/steps.ts","../src/lib/programs/agent-skill/content/index.tsx","../src/lib/programs/revenue-analytics/index.ts","../src/lib/programs/agent-skill/steps.ts","../src/lib/programs/agent-skill/index.ts","../src/lib/programs/audit/detect.ts","../src/lib/programs/audit/seed.ts","../src/lib/programs/audit/index.ts","../src/lib/programs/events-audit/steps.ts","../src/lib/programs/events-audit/seed.ts","../src/lib/programs/events-audit/index.ts","../src/lib/programs/audit-3000/index.ts","../src/lib/programs/posthog-doctor/steps.ts","../src/lib/programs/posthog-doctor/types.ts","../src/lib/programs/posthog-doctor/fetch.ts","../src/lib/programs/posthog-doctor/kind-metadata.ts","../src/lib/programs/posthog-doctor/index.ts","../src/lib/programs/migration/steps.ts","../src/lib/programs/migration/content/vendor-stack.tsx","../src/lib/programs/migration/content/free-tier.tsx","../src/lib/programs/migration/content/pricing-structure.tsx","../src/lib/programs/migration/content/index.tsx","../src/lib/programs/migration/index.ts","../src/lib/programs/error-tracking-upload-source-maps/detect.ts","../src/lib/programs/error-tracking-upload-source-maps/steps.ts","../src/lib/programs/error-tracking-upload-source-maps/prompt.ts","../src/lib/programs/error-tracking-upload-source-maps/content/index.tsx","../src/lib/programs/error-tracking-upload-source-maps/index.ts","../src/lib/programs/mcp/index.ts","../src/lib/programs/program-registry.ts","../src/commands/mcp/add.ts","../src/commands/mcp/remove.ts","../src/commands/mcp/tutorial.ts","../src/commands/mcp/index.ts","../src/lib/runners/resolve-no-telemetry.ts","../src/lib/runners/run-wizard.ts","../src/lib/runners/run-wizard-ci.ts","../src/commands/skill-program-options.ts","../src/commands/integrate.ts","../src/commands/audit.ts","../src/commands/audit-3000.ts","../src/commands/doctor.ts","../src/commands/migrate.ts","../src/commands/events-audit.ts","../src/commands/revenue.ts","../src/commands/upload-sourcemaps.ts","../bin.ts"],"sourcesContent":["import type { Arguments, Argv, CommandModule, Options } from 'yargs';\n\nexport interface Command {\n /** Yargs command name. Use `['$0']` for the default command. */\n name: string | readonly string[];\n description: string;\n /** Flags exposed by this command. Same shape as yargs `.options()`. */\n options?: Record<string, Options>;\n /** Nested subcommands. */\n children?: readonly Command[];\n /** `--help` examples shown for this command. */\n examples?: ReadonlyArray<readonly [string, string]>;\n /**\n * Called synchronously by yargs when the command matches. Wrap async work in\n * `void (async () => { ... })()`. Optional only when `children` is set — in\n * that case yargs requires the user to pick a subcommand.\n */\n handler?: (argv: Arguments) => void;\n /**\n * Cross-flag validation run by yargs after parsing. Throw to reject (yargs\n * prints the message and exits non-zero); return `true` to accept. Prefer\n * this over per-option `conflicts` for mutually exclusive flags: yargs\n * counts a `default`-valued flag as \"present\", so `conflicts` misfires on\n * boolean flags that default to `false` — a hand-written predicate only\n * sees what you test for (e.g. truthiness).\n */\n check?: (argv: Arguments) => boolean;\n}\n\n/** Extract the bare command word(s) from a yargs name spec, dropping positionals and aliases' arg syntax. */\nexport function commandKeys(name: string | readonly string[]): string[] {\n const list: readonly string[] = typeof name === 'string' ? [name] : name;\n return list.map((n) => n.trim().split(/\\s+/)[0]);\n}\n\nexport function toCommandModule(\n cmd: Command,\n parentPath: readonly string[],\n): CommandModule {\n return {\n command: cmd.name,\n describe: cmd.description,\n builder: (y: Argv) => {\n let next = cmd.options ? y.options(cmd.options) : y;\n if (cmd.check) next = next.check(cmd.check);\n for (const [usage, description] of cmd.examples ?? []) {\n next = next.example(usage, description);\n }\n const ownPath = [...parentPath, commandKeys(cmd.name)[0]];\n for (const child of cmd.children ?? []) {\n next = next.command(toCommandModule(child, ownPath));\n }\n if (cmd.children?.length && !cmd.handler) {\n next = next.demandCommand(1);\n }\n return next;\n },\n handler: cmd.handler ?? (() => undefined),\n };\n}\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport type { Argv } from 'yargs';\nimport { IS_PRODUCTION_BUILD } from '@env';\nimport { toCommandModule, type Command } from './commands/command';\n\n/**\n * Global yargs options applied to every command. These are read from the\n * `POSTHOG_WIZARD` env prefix as well as flags.\n */\nexport const GLOBAL_OPTIONS = {\n debug: {\n default: false,\n describe: 'Enable verbose logging\\nenv: POSTHOG_WIZARD_DEBUG',\n type: 'boolean' as const,\n },\n region: {\n describe: 'PostHog cloud region\\nenv: POSTHOG_WIZARD_REGION',\n choices: ['us', 'eu'] as const,\n type: 'string' as const,\n },\n signup: {\n default: false,\n describe:\n 'Create a new PostHog account during setup\\nenv: POSTHOG_WIZARD_SIGNUP',\n type: 'boolean' as const,\n },\n 'local-mcp': {\n default: false,\n describe:\n 'Use local MCP server at http://localhost:8787/mcp\\nenv: POSTHOG_WIZARD_LOCAL_MCP',\n type: 'boolean' as const,\n },\n telemetry: {\n default: true,\n describe:\n 'Send wizard run state to PostHog (pass --no-telemetry to disable)\\nenv: POSTHOG_WIZARD_TELEMETRY',\n type: 'boolean' as const,\n },\n 'api-key': {\n describe:\n 'PostHog personal API key (phx_xxx) for authentication\\nenv: POSTHOG_WIZARD_API_KEY',\n type: 'string' as const,\n },\n 'project-id': {\n describe:\n 'PostHog project ID to use (optional; when not set, uses default from API key or OAuth)\\nenv: POSTHOG_WIZARD_PROJECT_ID',\n type: 'string' as const,\n },\n email: {\n describe:\n 'Email address for signup (used with --signup)\\nenv: POSTHOG_WIZARD_EMAIL',\n type: 'string' as const,\n },\n};\n\nexport class Wizard {\n private cli: Argv;\n\n private constructor() {\n let cli = yargs(hideBin(process.argv))\n .env('POSTHOG_WIZARD')\n .options(GLOBAL_OPTIONS);\n\n // CI mode (--ci) is only supported in dev/test. It is left undeclared in\n // published builds (NODE_ENV==='production'), so .strictOptions() rejects\n // it there as an unknown argument — exactly like any other unrecognized\n // flag. init() additionally detects it up front to print a clearer message.\n if (!IS_PRODUCTION_BUILD) {\n cli = cli.option('ci', {\n default: false,\n describe:\n 'Enable CI mode for non-interactive execution\\nenv: POSTHOG_WIZARD_CI',\n type: 'boolean',\n });\n }\n\n this.cli = cli\n .strictOptions()\n // Print the error first (bright red) and the usage below it, instead of\n // yargs' default of burying the message under the full help output.\n .fail((msg, err, parser) => {\n const text = msg || (err && err.message) || 'Invalid arguments';\n process.stderr.write(`\\n\\x1b[1;91m✖ ${text}\\x1b[0m\\n\\n`);\n parser.showHelp();\n process.exit(1);\n })\n .help()\n .alias('help', 'h')\n .version()\n .alias('version', 'v');\n }\n\n /** Start a chain; equivalent to `new Wizard().use(...cmds)`. */\n static use(...cmds: Command[]): Wizard {\n return new Wizard().use(...cmds);\n }\n\n /** Register one or more commands with yargs. */\n use(...cmds: Command[]): this {\n for (const cmd of cmds) {\n this.cli = this.cli.command(toCommandModule(cmd, []));\n }\n return this;\n }\n\n /** Parse argv and dispatch to the matching registered command. */\n init(): void {\n // In published builds, `--ci` is undeclared, so yargs would reject it as\n // an unknown argument — accurate but unhelpful, since --help doesn't list\n // --ci either and the user has no path forward. POSTHOG_WIZARD_CI silently\n // no-ops for the same reason (yargs only resolves env vars for declared\n // options). Detect both up front and exit with a message that explains why.\n if (IS_PRODUCTION_BUILD) {\n const args = process.argv.slice(2);\n const argvHasCI = args.some(\n (a) => a === '--ci' || a === '--no-ci' || a.startsWith('--ci='),\n );\n const envHasCI =\n process.env.POSTHOG_WIZARD_CI != null &&\n process.env.POSTHOG_WIZARD_CI !== '';\n if (argvHasCI || envHasCI) {\n process.stderr.write(\n `\\n\\x1b[1;91m✖ CI mode is not currently supported in published builds.\\x1b[0m\\n\\n`,\n );\n process.exit(1);\n }\n }\n void this.cli.wrap(process.stdout.isTTY ? this.cli.terminalWidth() : 80)\n .argv;\n }\n}\n","import type { Arguments } from 'yargs';\nimport { getUI, setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport type { ProvisioningResult } from '@utils/provisioning';\nimport type { Command } from './command';\n\nexport const provisionCommand: Command = {\n name: 'provision',\n description: 'Create a new PostHog account (headless, no TUI)',\n options: {\n email: {\n describe: 'Email address for the new account',\n type: 'string',\n demandOption: true,\n },\n region: {\n describe: 'Cloud region (us or eu)',\n choices: ['us', 'eu'] as const,\n default: 'us',\n },\n name: {\n describe: 'Name for the new account',\n type: 'string',\n default: '',\n },\n json: {\n describe:\n 'Emit JSON result to stdout (defaults to true when stdout is not a TTY)',\n type: 'boolean',\n },\n },\n examples: [\n ['wizard provision --email matt+test@posthog.com --region us', ''],\n ['wizard provision --email user@example.com --region eu --json', ''],\n ],\n handler: runProvision,\n};\n\nfunction runProvision(argv: Arguments): void {\n const jsonMode =\n argv.json === undefined ? !process.stdout.isTTY : Boolean(argv.json);\n if (!jsonMode) setUI(new LoggingUI());\n\n void provision({\n email: argv.email as string,\n region: (argv.region as string).toUpperCase() as 'US' | 'EU',\n name: (argv.name as string) ?? '',\n jsonMode,\n });\n}\n\ntype ProvisionArgs = {\n email: string;\n region: 'US' | 'EU';\n name: string;\n jsonMode: boolean;\n};\n\nasync function provision({\n email,\n region,\n name,\n jsonMode,\n}: ProvisionArgs): Promise<void> {\n try {\n const { provisionNewAccount } = await import('@utils/provisioning');\n if (!jsonMode) {\n getUI().log.info(`Provisioning account for ${email} in ${region}...`);\n }\n const result = await provisionNewAccount(email, name, region);\n emitResult(result, jsonMode);\n process.exit(0);\n } catch (error) {\n emitError(error, jsonMode);\n process.exit(1);\n }\n}\n\nfunction emitResult(result: ProvisioningResult, jsonMode: boolean): void {\n if (jsonMode) {\n process.stdout.write(`${JSON.stringify(result)}\\n`);\n return;\n }\n getUI().log.success('Account provisioned successfully:');\n getUI().log.info(` API Key: ${result.projectApiKey}`);\n getUI().log.info(` Host: ${result.host}`);\n getUI().log.info(` Project ID: ${result.projectId}`);\n getUI().log.info(` Account ID: ${result.accountId}`);\n getUI().log.info(` Access Token: ${result.accessToken}`);\n getUI().log.info(` Refresh Token: ${result.refreshToken}`);\n if (result.personalApiKey) {\n getUI().log.info(` Personal API Key: ${result.personalApiKey}`);\n }\n}\n\nfunction emitError(error: unknown, jsonMode: boolean): void {\n const msg = error instanceof Error ? error.message : String(error);\n const code = msg.includes('already associated')\n ? 'email_exists'\n : 'provisioning_failed';\n if (jsonMode) {\n process.stderr.write(`${JSON.stringify({ error: msg, code })}\\n`);\n return;\n }\n getUI().log.error(`Provisioning failed: ${msg}`);\n}\n","import { isNonInteractiveEnvironment } from '@utils/environment';\nimport { provisionCommand } from '../provision';\nimport type { Command } from '../command';\n\nexport const basicIntegrationCommand: Command = {\n name: ['$0'],\n description: 'Run the PostHog setup wizard',\n // provision is a one-shot HTTP call tied to the base flow, not a wizard\n // program — it rides under the base command rather than as a peer.\n children: [provisionCommand],\n options: {\n 'install-dir': {\n describe:\n 'Directory to install PostHog in\\nenv: POSTHOG_WIZARD_INSTALL_DIR',\n type: 'string',\n },\n playground: {\n default: false,\n describe: 'Launch the TUI primitives playground',\n type: 'boolean',\n },\n benchmark: {\n default: false,\n describe:\n 'Run in benchmark mode with per-phase token tracking\\nenv: POSTHOG_WIZARD_BENCHMARK',\n type: 'boolean',\n },\n 'yara-report': {\n default: false,\n describe:\n 'Print YARA scanner summary after the agent run\\nenv: POSTHOG_WIZARD_YARA_REPORT',\n type: 'boolean',\n hidden: true,\n },\n skill: {\n describe:\n 'Run a specific context-mill skill by ID\\nenv: POSTHOG_WIZARD_SKILL',\n type: 'string',\n },\n name: {\n describe:\n 'Name for account creation with --ci --signup\\nenv: POSTHOG_WIZARD_NAME',\n type: 'string',\n },\n },\n check: (argv) => {\n // --playground is the standalone TUI demo; it can't combine with the other\n // run modes. (--ci + --skill IS valid — run a skill headlessly.)\n if (argv.playground && (argv.ci || argv.skill)) {\n throw new Error('--playground cannot be combined with --ci or --skill.');\n }\n // --skill with no ID would otherwise fall through to the interactive flow.\n if (typeof argv.skill === 'string' && argv.skill.trim() === '') {\n throw new Error('--skill needs a skill ID, e.g. --skill=\"foo\"');\n }\n return true;\n },\n handler: (argv) => {\n // Each mode file is loaded only when its branch is taken, so a plain\n // `npx @posthog/wizard` never pulls in the CI, playground, or skill paths.\n void (async () => {\n // --ci --skill runs the skill headlessly (skill takes precedence over the\n // default CI integration); --ci alone runs the integration.\n if (argv.ci && argv.skill) {\n const { runSkillMode } = await import('./skill');\n return runSkillMode(argv);\n }\n if (argv.ci) {\n const { runCIInstall } = await import('./ci-install');\n return runCIInstall(argv);\n }\n if (isNonInteractiveEnvironment()) {\n const { failNonInteractive } = await import('./non-interactive');\n return failNonInteractive();\n }\n if (argv.playground) {\n const { runPlayground } = await import('./playground');\n return runPlayground();\n }\n if (argv.skill) {\n const { runSkillMode } = await import('./skill');\n return runSkillMode(argv);\n }\n const { runInteractive } = await import('./interactive');\n runInteractive(argv);\n })();\n },\n};\n","/**\n * Revenue analytics prerequisite detection.\n *\n * Scans the project for PostHog + Stripe SDKs and writes results\n * into frameworkContext for the intro screen to render.\n */\n\nimport type { Dirent } from 'fs';\nimport { readFileSync, readdirSync, existsSync, statSync } from 'fs';\nimport { join, relative } from 'path';\nimport { IGNORED_DIRS } from '@utils/file-utils';\nimport type { WizardSession } from '@lib/wizard-session';\nimport type { AbortCase } from '@lib/agent/agent-runner';\n\nexport const POSTHOG_SDKS = [\n 'posthog-js',\n 'posthog-node',\n 'posthog-react-native',\n 'posthog-android',\n 'posthog-ios',\n];\n\nexport const STRIPE_SDKS = [\n 'stripe',\n '@stripe/stripe-js',\n '@stripe/react-stripe-js',\n];\n\ninterface PackageMatch {\n /** Path to the package.json relative to installDir */\n path: string;\n posthogSdks: string[];\n stripeSdks: string[];\n}\n\n/**\n * Structured detection errors. The screen renders each kind into JSX\n * with proper formatting — keeps error data separate from presentation.\n */\nexport type RevenueDetectError =\n | {\n kind: 'bad-directory';\n path: string;\n reason: 'missing' | 'not-dir' | 'unreadable';\n }\n | { kind: 'no-package-json' }\n | { kind: 'no-sdks'; scannedCount: number }\n | { kind: 'missing-posthog'; foundStripe: string[] }\n | { kind: 'missing-stripe'; foundPosthog: string[] };\n\n/** `[ABORT] <reason>` cases the revenue analytics skill can emit. */\nexport const REVENUE_ABORT_CASES: AbortCase[] = [\n {\n // Skill emits: [ABORT] Could not find a PostHog distinct_id\n match: /^could not find a posthog distinct_id$/i,\n message: 'Could not find a PostHog distinct_id',\n body:\n 'The agent could not find PostHog distinct_id usage in your codebase. ' +\n 'Your users must be identified in PostHog before they can be tagged in Stripe. ' +\n 'Please identify your users and try again.',\n docsUrl: 'https://posthog.com/docs/product-analytics/identify',\n },\n {\n // Skill emits: [ABORT] Could not find a Stripe integration\n match: /^could not find a stripe integration$/i,\n message: 'Could not find a Stripe integration',\n body:\n 'The Wizard could not find an existing Stripe customer, charge, ' +\n 'subscription, or other Stripe operations. Please run the Revenue ' +\n 'Analytics Wizard on a project with an existing Stripe integration.',\n docsUrl: 'https://posthog.com/docs/revenue-analytics',\n },\n];\n\n/**\n * Recursively find all package.json files under installDir (max depth 3),\n * skipping common ignored directories. Returns matches with detected SDKs.\n */\nfunction findPackageJsons(installDir: string, maxDepth = 3): PackageMatch[] {\n const matches: PackageMatch[] = [];\n\n function scan(dir: string, depth: number): void {\n if (depth > maxDepth) return;\n\n let entries: Dirent[];\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (entry.name.startsWith('.') && entry.name !== '.') continue;\n if (IGNORED_DIRS.has(entry.name)) continue;\n\n const fullPath = join(dir, entry.name);\n\n if (entry.isFile() && entry.name === 'package.json') {\n try {\n const pkg = JSON.parse(readFileSync(fullPath, 'utf-8')) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n const depNames = [\n ...Object.keys(pkg.dependencies ?? {}),\n ...Object.keys(pkg.devDependencies ?? {}),\n ];\n const posthogSdks = depNames.filter((d) => POSTHOG_SDKS.includes(d));\n const stripeSdks = depNames.filter((d) => STRIPE_SDKS.includes(d));\n matches.push({\n path: relative(installDir, fullPath) || 'package.json',\n posthogSdks,\n stripeSdks,\n });\n } catch {\n // Skip malformed package.json\n }\n } else if (entry.isDirectory()) {\n scan(fullPath, depth + 1);\n }\n }\n }\n\n scan(installDir, 0);\n return matches;\n}\n\n/**\n * Scan `session.installDir` for PostHog + Stripe SDKs. Writes detection\n * results into frameworkContext via the callback — either the detected\n * SDK lists (for the intro screen) or a `RevenueDetectError` on failure.\n *\n * The skill install happens later in the bootstrap runner, not here.\n */\nexport function detectRevenuePrerequisites(\n session: WizardSession,\n setFrameworkContext: (key: string, value: unknown) => void,\n): void {\n const fail = (error: RevenueDetectError) =>\n setFrameworkContext('detectError', error);\n\n const installDir = session.installDir;\n\n // Verify the install directory exists and is readable\n if (!existsSync(installDir)) {\n fail({ kind: 'bad-directory', path: installDir, reason: 'missing' });\n return;\n }\n try {\n if (!statSync(installDir).isDirectory()) {\n fail({ kind: 'bad-directory', path: installDir, reason: 'not-dir' });\n return;\n }\n } catch {\n fail({ kind: 'bad-directory', path: installDir, reason: 'unreadable' });\n return;\n }\n\n // Find all package.json files (root + monorepo subpackages)\n const matches = findPackageJsons(installDir);\n\n if (matches.length === 0) {\n fail({ kind: 'no-package-json' });\n return;\n }\n\n // Aggregate detected SDKs across all package.json files\n const allPosthogSdks = new Set<string>();\n const allStripeSdks = new Set<string>();\n for (const match of matches) {\n for (const sdk of match.posthogSdks) allPosthogSdks.add(sdk);\n for (const sdk of match.stripeSdks) allStripeSdks.add(sdk);\n }\n\n const detectedPosthogSdks = [...allPosthogSdks];\n const detectedStripeSdks = [...allStripeSdks];\n\n if (detectedPosthogSdks.length === 0 && detectedStripeSdks.length === 0) {\n fail({ kind: 'no-sdks', scannedCount: matches.length });\n return;\n }\n\n if (detectedPosthogSdks.length === 0) {\n fail({ kind: 'missing-posthog', foundStripe: detectedStripeSdks });\n return;\n }\n\n if (detectedStripeSdks.length === 0) {\n fail({ kind: 'missing-stripe', foundPosthog: detectedPosthogSdks });\n return;\n }\n\n setFrameworkContext('detectedPosthogSdks', detectedPosthogSdks);\n setFrameworkContext('detectedStripeSdks', detectedStripeSdks);\n setFrameworkContext(\n 'detectedPackagePaths',\n matches\n .filter((m) => m.posthogSdks.length > 0 || m.stripeSdks.length > 0)\n .map((m) => m.path),\n );\n}\n","/**\n * Revenue analytics program step list.\n *\n * The detect step checks for PostHog + Stripe SDKs. The skill install\n * and agent run live in the program runner (see agent-runner.ts).\n */\n\nimport type { ProgramStep } from '@lib/programs/program-step';\nimport { RunPhase } from '@lib/wizard-session';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\nimport { detectRevenuePrerequisites } from './detect.js';\n\nexport const REVENUE_ANALYTICS_PROGRAM: ProgramStep[] = [\n {\n id: 'detect',\n label: 'Detecting prerequisites',\n // Headless step: no screen, no gate. onReady fires after bin.ts\n // assigns the session — the hook scans for PostHog + Stripe SDKs\n // and writes the results (or a detectError) to frameworkContext\n // for the intro screen to render.\n onReady: (ctx) =>\n detectRevenuePrerequisites(ctx.session, ctx.setFrameworkContext),\n },\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'revenue-intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Revenue analytics',\n screenId: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screenId: 'keep-skills',\n },\n];\n","/**\n * Agent-skill learn-deck — the short three-line sequence shown while a\n * skill-based program (audit, revenue-analytics, agent-skill, etc.)\n * runs. Skill programs don't need the full PostHog onboarding narrative.\n */\n\nimport { Text } from 'ink';\nimport type { WizardStore } from '@ui/tui/store';\nimport { TextRevealMode } from '@ui/tui/primitives/TextBlock';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const getContentBlocks = (store?: WizardStore): ContentBlock[] => {\n const skillId = store?.session.skillId ?? 'unknown';\n return [\n {\n content: 'Welcome.',\n pause: 3000,\n mode: TextRevealMode.Typewriter,\n animationInterval: 160,\n },\n { content: 'The Wizard is an agent.', pause: 4000 },\n {\n pause: 60000,\n content: (\n <Text>\n Running the <Text color=\"cyan\">{skillId}</Text> skill...\n </Text>\n ),\n },\n ];\n};\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { REVENUE_ANALYTICS_PROGRAM } from './steps.js';\nimport { REVENUE_ABORT_CASES } from './detect.js';\nimport { getContentBlocks } from './content/index.js';\n\nexport const revenueAnalyticsConfig: ProgramConfig = {\n command: 'revenue',\n description: 'Set up PostHog revenue analytics (e.g. Stripe integration)',\n id: 'revenue-analytics-setup',\n steps: REVENUE_ANALYTICS_PROGRAM,\n getContentBlocks,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n run: {\n skillId: 'revenue-analytics-setup',\n integrationLabel: 'revenue-analytics-setup',\n customPrompt: () => 'Set up revenue analytics for this project.',\n successMessage: 'Revenue analytics configured!',\n reportFile: 'posthog-revenue-report.md',\n docsUrl: 'https://posthog.com/docs/revenue-analytics',\n spinnerMessage: 'Setting up revenue analytics...',\n estimatedDurationMinutes: 5,\n abortCases: REVENUE_ABORT_CASES,\n },\n requires: ['posthog-integration'],\n};\n\nexport { REVENUE_ANALYTICS_PROGRAM } from './steps.js';\nexport {\n detectRevenuePrerequisites,\n POSTHOG_SDKS,\n STRIPE_SDKS,\n type RevenueDetectError,\n} from './detect.js';\n","/**\n * Generic agent skill step list.\n *\n * Minimal flow: intro → health-check → auth → run → outro → skills.\n * No detection, no setup, no MCP.\n */\n\nimport type { ProgramStep } from '@lib/programs/program-step';\nimport { RunPhase } from '@lib/wizard-session';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\n\nexport const AGENT_SKILL_STEPS: ProgramStep[] = [\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'agent-skill-intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Running',\n screenId: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screenId: 'keep-skills',\n },\n];\n","/**\n * Generic agent skill program factory.\n *\n * Creates a ProgramConfig for any context-mill skill. Provide a\n * skill ID and basic UI config — the factory handles the rest.\n *\n * Usage:\n * createSkillProgram({\n * skillId: 'error-tracking-setup',\n * command: 'errors',\n * id: 'error-tracking',\n * description: 'Set up PostHog error tracking',\n * integrationLabel: 'error-tracking',\n * successMessage: 'Error tracking configured!',\n * reportFile: 'posthog-error-tracking-report.md',\n * docsUrl: 'https://posthog.com/docs/error-tracking',\n * spinnerMessage: 'Setting up error tracking...',\n * estimatedDurationMinutes: 5,\n * })\n */\n\nimport type { ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun, AbortCase } from '@lib/agent/agent-runner';\nimport { AGENT_SKILL_STEPS } from './steps.js';\nimport { getContentBlocks } from './content/index.js';\n\nexport interface SkillProgramOptions {\n /** Context-mill skill ID to install */\n skillId: string;\n /** CLI subcommand name */\n command: string;\n /** Unique flow key — must match a Program enum entry */\n id: string;\n /** CLI description shown in --help */\n description: string;\n /** Analytics integration label */\n integrationLabel: string;\n /** Custom prompt instruction. Appended after default project prompt. */\n customPrompt?: string;\n successMessage: string;\n reportFile: string;\n docsUrl: string;\n spinnerMessage: string;\n estimatedDurationMinutes: number;\n /** Other program ids that must be satisfied first */\n requires?: string[];\n /** Override the default outro. Receives the same args as ProgramRun.buildOutroData. */\n buildOutroData?: ProgramRun['buildOutroData'];\n /** Known `[ABORT] <reason>` cases the skill can emit. */\n abortCases?: AbortCase[];\n}\n\nexport function createSkillProgram(opts: SkillProgramOptions): ProgramConfig {\n return {\n command: opts.command,\n description: opts.description,\n id: opts.id,\n skillId: opts.skillId,\n steps: AGENT_SKILL_STEPS,\n reportFile: opts.reportFile,\n getContentBlocks,\n run: {\n skillId: opts.skillId,\n integrationLabel: opts.integrationLabel,\n customPrompt: opts.customPrompt ? () => opts.customPrompt! : undefined,\n successMessage: opts.successMessage,\n reportFile: opts.reportFile,\n docsUrl: opts.docsUrl,\n spinnerMessage: opts.spinnerMessage,\n estimatedDurationMinutes: opts.estimatedDurationMinutes,\n buildOutroData: opts.buildOutroData,\n abortCases: opts.abortCases,\n },\n requires: opts.requires,\n };\n}\n\nexport { AGENT_SKILL_STEPS } from './steps.js';\n","import type { AbortCase } from '@lib/agent/agent-runner';\n\n/** `[ABORT] <reason>` cases the audit skill can emit. Reason strings are\n * defined in the skill's `Abort statuses` section. */\nexport const AUDIT_ABORT_CASES: AbortCase[] = [\n {\n match: /^no posthog sdk found$/i,\n message: 'No PostHog SDK found',\n body:\n 'The audit needs an existing PostHog integration to review. No PostHog ' +\n 'SDK appears in this project’s dependency manifests. Run the basic ' +\n 'integration program to install PostHog first, then re-run the audit.',\n docsUrl: 'https://posthog.com/docs/getting-started/install',\n },\n];\n","import fs from 'fs';\nimport path from 'path';\nimport { logToFile } from '@utils/debug';\nimport { AUDIT_CHECKS_FILE, type AuditCheck } from './types.js';\n\n/**\n * The 10 data-integrity checks the audit runs, plus one workflow row for the\n * notebook upload at the end (so the skill's `audit_resolve_checks` call for\n * `upload-notebook` succeeds — the skill writes the report to a PostHog\n * notebook as its final step).\n */\nexport const AUDIT_SEED_CHECKS: AuditCheck[] = [\n {\n id: 'sdk-installed',\n area: 'Installation',\n label: 'PostHog SDK installed',\n status: 'pending',\n },\n {\n id: 'sdk-up-to-date',\n area: 'Installation',\n label: 'SDK version up to date',\n status: 'pending',\n },\n {\n id: 'init-correct',\n area: 'Installation',\n label: 'Initialization is correct',\n status: 'pending',\n },\n {\n id: 'identify-stable-distinct-id',\n area: 'Identification',\n label: 'Stable distinct_id (not session UUID)',\n status: 'pending',\n },\n {\n id: 'identify-not-late',\n area: 'Identification',\n label: 'identify() called before captures / flag evals',\n status: 'pending',\n },\n {\n id: 'cross-runtime-distinct-id',\n area: 'Identification',\n label: 'Same distinct_id across client and server',\n status: 'pending',\n },\n {\n id: 'identify-reset-on-logout',\n area: 'Identification',\n label: 'reset() called on logout / account switch',\n status: 'pending',\n },\n {\n id: 'capture-event-names-static',\n area: 'Event Capture',\n label: 'Event names are static and consistent',\n status: 'pending',\n },\n {\n id: 'capture-uses-proxy',\n area: 'Event Capture',\n label: 'Captures route through a reverse proxy',\n status: 'pending',\n },\n {\n id: 'capture-growth-events',\n area: 'Event Capture',\n label: 'Key activation events captured',\n status: 'pending',\n },\n {\n id: 'write-report',\n area: 'Write report',\n label: 'Create posthog-audit-report.md',\n status: 'pending',\n },\n {\n id: 'upload-notebook',\n area: 'Upload notebook',\n label: 'Write the report into a PostHog notebook',\n status: 'pending',\n },\n];\n\n/**\n * Atomically write a seeded ledger to the project's audit checks file.\n *\n * Each audit-flavored program (doctor, events-audit) owns its own seed\n * shape — pass the seed in so this writer stays program-agnostic.\n */\nexport function seedAuditLedger(\n installDir: string,\n checks: AuditCheck[] = AUDIT_SEED_CHECKS,\n): void {\n const target = path.join(installDir, AUDIT_CHECKS_FILE);\n const tmp = `${target}.tmp`;\n fs.writeFileSync(tmp, JSON.stringify(checks, null, 2), 'utf8');\n fs.renameSync(tmp, target);\n logToFile(`seedAuditLedger: wrote ${checks.length} entries to ${target}`);\n}\n","import {\n AGENT_SKILL_STEPS,\n createSkillProgram,\n} from '@lib/programs/agent-skill/index';\nimport type { ProgramStep, ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun } from '@lib/agent/agent-runner';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { OutroKind } from '@lib/wizard-session';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { getCloudUrlFromRegion } from '@utils/urls';\nimport { AUDIT_ABORT_CASES } from './detect.js';\nimport { AUDIT_CHECKS_KEY, AUDIT_REPORT_FILE } from './types.js';\nimport { AUDIT_SEED_CHECKS, seedAuditLedger } from './seed.js';\n\n/** Audit-specific screens for the shared agent-skill pipeline. */\nconst AUDIT_SCREEN_BY_STEP: Record<string, string> = {\n intro: 'audit-intro',\n run: 'audit-run',\n outro: 'audit-outro',\n};\n\nconst seedBeforeAuditRun = (session: WizardSession): void => {\n seedAuditLedger(session.installDir);\n session.frameworkContext[AUDIT_CHECKS_KEY] = AUDIT_SEED_CHECKS;\n};\n\nconst withAuditScreens = (steps: ProgramStep[]): ProgramStep[] =>\n steps.map((step) => {\n const override = AUDIT_SCREEN_BY_STEP[step.id];\n return override ? { ...step, screenId: override } : step;\n });\n\nconst auditSteps: ProgramStep[] = withAuditScreens(AGENT_SKILL_STEPS);\n\nconst baseConfig = createSkillProgram({\n skillId: 'audit',\n command: 'audit',\n id: 'audit',\n description:\n 'Audit an existing PostHog integration for correctness and best practices',\n integrationLabel: 'audit',\n customPrompt:\n 'Run a comprehensive audit of the existing PostHog integration. Follow the skill program steps in order. Do not modify any project files — only create the final audit report.',\n successMessage:\n 'Audit complete! You can view the audit report at ./posthog-audit-report.md',\n reportFile: AUDIT_REPORT_FILE,\n docsUrl: 'https://posthog.com/docs/product-analytics/best-practices',\n spinnerMessage: 'Auditing PostHog integration...',\n estimatedDurationMinutes: 5,\n requires: ['posthog-integration'],\n abortCases: AUDIT_ABORT_CASES,\n});\n\nconst auditRun = async (session: WizardSession): Promise<ProgramRun> => {\n seedBeforeAuditRun(session);\n\n if (!baseConfig.run) {\n throw new Error('Audit program has no run configuration.');\n }\n\n const baseRun =\n typeof baseConfig.run === 'function'\n ? await baseConfig.run(session)\n : baseConfig.run;\n\n return {\n ...baseRun,\n // Override the default outro so the dashboard + notebook URLs the\n // agent emits via `[DASHBOARD_URL]` / `[NOTEBOOK_URL]` are surfaced\n // on the post-run screen.\n buildOutroData: (sess, _credentials, cloudRegion) => {\n const cloudUrl = cloudRegion\n ? getCloudUrlFromRegion(cloudRegion)\n : undefined;\n const continueUrl =\n sess.signup && cloudUrl\n ? `${cloudUrl}/products?source=wizard`\n : undefined;\n\n // Note: `sess` here is the agent-runner's snapshot of session at\n // runAgent() invocation time. Any URL emissions during the run land\n // on the live store, NOT on this snapshot. The UI layer\n // (InkUI.setOutroData) merges live URLs in on top of this return\n // value, so it's safe to leave dashboardUrl/notebookUrl as undefined\n // here when the snapshot doesn't have them.\n return {\n kind: OutroKind.Success as const,\n message: baseRun.successMessage,\n reportFile: baseRun.reportFile,\n docsUrl: baseRun.docsUrl,\n continueUrl,\n dashboardUrl: sess.dashboardUrl ?? undefined,\n notebookUrl: sess.notebookUrl ?? undefined,\n };\n },\n };\n};\n\nexport const auditConfig: ProgramConfig = {\n ...baseConfig,\n steps: auditSteps,\n run: auditRun,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n};\n","/**\n * Events-audit program.\n *\n * Mirrors the posthog-integration step list, except:\n * - The initial framework detection step is omitted — the events-audit\n * skill handles detection at agent run time.\n * - The intro step uses the audit intro screen (no framework selection\n * logic) instead of the integration intro.\n */\n\nimport type { ProgramStep } from '@lib/programs/program-step';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { RunPhase } from '@lib/wizard-session';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\n\nfunction needsSetup(session: WizardSession): boolean {\n const config = session.frameworkConfig;\n if (!config?.metadata.setup?.questions) return false;\n\n return config.metadata.setup.questions.some(\n (q: { key: string }) => !(q.key in session.frameworkContext),\n );\n}\n\nexport const EVENTS_AUDIT_PROGRAM: ProgramStep[] = [\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'audit-intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'setup',\n label: 'Setup',\n screenId: 'setup',\n show: needsSetup,\n isComplete: (session) => !needsSetup(session),\n },\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Events audit',\n screenId: 'audit-run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'mcp',\n label: 'MCP servers',\n screenId: 'mcp',\n isComplete: (session) => session.mcpComplete,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'audit-outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'keep-skills',\n label: 'Keep Skills',\n screenId: 'keep-skills',\n },\n];\n","import type { AuditCheck } from '@lib/programs/audit/types';\n\n/**\n * The 7 phases the events-audit skill marches through. One check per area\n * so PendingChecksList renders a clean linear pipeline (area = bold header,\n * single row = the active spinner).\n *\n * Phase ids match what the skill's step files resolve via\n * `mcp__wizard-tools__audit_resolve_checks` as each phase completes. The\n * skill's step 1 also seeds these same ids — keep both in sync so the\n * wizard pre-seed and the skill's MCP seed agree.\n */\nexport const EVENTS_AUDIT_SEED_CHECKS: AuditCheck[] = [\n {\n id: 'detect-sdk',\n area: 'Detect SDK',\n label: 'Identify PostHog SDK(s) in dependencies',\n status: 'pending',\n },\n {\n id: 'scan-sites',\n area: 'Scan capture sites',\n label: 'Grep capture/identify/group call sites',\n status: 'pending',\n },\n {\n id: 'enrich-sites',\n area: 'Enrich',\n label: 'Subagent fan-out to read capture files',\n status: 'pending',\n },\n {\n id: 'query-volume',\n area: 'Query PostHog',\n label: '30-day volume + last_seen via MCP',\n status: 'pending',\n },\n {\n id: 'write-report',\n area: 'Write report',\n label: 'Create posthog-events-audit-report.md',\n status: 'pending',\n },\n {\n id: 'create-dashboard',\n area: 'Create dashboard',\n label: 'Optional: dashboard for resolved events',\n status: 'pending',\n },\n {\n id: 'upload-notebook',\n area: 'Upload notebook',\n label: 'Write the report into a PostHog notebook',\n status: 'pending',\n },\n];\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun } from '@lib/agent/agent-runner';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { OutroKind } from '@lib/wizard-session';\nimport { SPINNER_MESSAGE } from '@lib/framework-config';\nimport { isUsingTypeScript } from '@utils/setup-utils';\nimport { getCloudUrlFromRegion } from '@utils/urls';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { EVENTS_AUDIT_PROGRAM } from './steps.js';\nimport { AUDIT_CHECKS_KEY } from '@lib/programs/audit/types';\nimport { seedAuditLedger } from '@lib/programs/audit/seed';\nimport { EVENTS_AUDIT_SEED_CHECKS } from './seed.js';\n\nexport const SETUP_REPORT_FILE = 'posthog-events-audit-report.md';\n\nconst DOCS_URL = 'https://posthog.com/docs/product-analytics/best-practices';\n\nexport const eventsAuditConfig: ProgramConfig = {\n command: 'events-audit',\n description: 'Audit PostHog event tracking in this project',\n id: 'events-audit',\n skillId: 'events-audit',\n steps: EVENTS_AUDIT_PROGRAM,\n // Top-level reportFile so AuditRunScreen can resolve the report path\n // synchronously without unwrapping the deferred `run` function.\n reportFile: SETUP_REPORT_FILE,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n\n run: (session: WizardSession): Promise<ProgramRun> => {\n const typeScriptDetected = isUsingTypeScript({\n installDir: session.installDir,\n });\n session.typescript = typeScriptDetected;\n\n // Seed the audit ledger so AuditRunScreen has something to render\n // before the agent emits its first check update. The events-audit\n // ledger is the 6-phase pipeline, not the doctor's 10 integrity checks.\n seedAuditLedger(session.installDir, EVENTS_AUDIT_SEED_CHECKS);\n session.frameworkContext[AUDIT_CHECKS_KEY] = EVENTS_AUDIT_SEED_CHECKS;\n\n return Promise.resolve({\n skillId: 'events-audit',\n integrationLabel: 'events-audit',\n spinnerMessage: SPINNER_MESSAGE,\n successMessage:\n 'Events audit complete! You can view the report at ./posthog-events-audit-report.md',\n estimatedDurationMinutes: 5,\n reportFile: SETUP_REPORT_FILE,\n docsUrl: DOCS_URL,\n errorMessage: 'Events audit failed',\n additionalFeatureQueue: session.additionalFeatureQueue,\n\n customPrompt: (ctx) =>\n `Audit PostHog event capture in this project. Do not modify any project files — produce a read-only report only.\n\nProject context:\n- PostHog Project ID: ${ctx.projectId}\n- TypeScript: ${typeScriptDetected ? 'Yes' : 'No'}\n- PostHog public token: ${ctx.projectApiKey}\n- PostHog Host: ${ctx.host}\n`,\n\n buildOutroData: (sess, _credentials, cloudRegion) => {\n const cloudUrl = cloudRegion\n ? getCloudUrlFromRegion(cloudRegion)\n : undefined;\n const continueUrl =\n sess.signup && cloudUrl\n ? `${cloudUrl}/products?source=wizard`\n : undefined;\n // The agent emits `[DASHBOARD_URL] <url>` once it creates the\n // dashboard; the SDK-message interceptor stores it on the session.\n // Fall back to the dashboards index if nothing was emitted.\n const dashboardUrl =\n sess.dashboardUrl ?? (cloudUrl ? `${cloudUrl}/dashboard` : undefined);\n\n // The agent emits `[NOTEBOOK_URL] <url>` once it uploads the report\n // to a PostHog notebook. No fallback: if the notebook upload was\n // skipped (e.g. MCP unavailable) we just don't show a link.\n const notebookUrl = sess.notebookUrl ?? undefined;\n\n return {\n kind: OutroKind.Success as const,\n message: 'Your events audit was successful',\n reportFile: SETUP_REPORT_FILE,\n changes: [],\n docsUrl: DOCS_URL,\n continueUrl,\n dashboardUrl,\n notebookUrl,\n };\n },\n });\n },\n};\n\nexport { EVENTS_AUDIT_PROGRAM } from './steps.js';\n","import fs from 'fs';\nimport path from 'path';\nimport {\n AGENT_SKILL_STEPS,\n createSkillProgram,\n} from '@lib/programs/agent-skill/index';\nimport type { ProgramStep, ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun } from '@lib/agent/agent-runner';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { AUDIT_ABORT_CASES } from '@lib/programs/audit/detect';\nimport {\n AUDIT_CHECKS_FILE,\n AUDIT_CHECKS_KEY,\n type AuditCheck,\n} from '@lib/programs/audit/types';\nimport { AUDIT_SEED_CHECKS } from '@lib/programs/audit/seed';\nimport { logToFile } from '@utils/debug';\n\nconst AUDIT3000_REPORT_FILE = 'posthog-audit-3000-report.md';\n\n// Extra checks the v3000 audit adds on top of the base 10. IDs must match\n// those referenced in the audit-3000 skill's step files (Event Quality,\n// stale feature-flag review, session replay [fix + optimize], per-product\n// use-case expansion, and phase markers for the post-flags chain).\nconst AUDIT3000_EXTRA_CHECKS: AuditCheck[] = [\n // ── Event Quality (Step 5) ──\n {\n id: 'event-naming-standardization',\n area: 'Event Quality',\n label: 'Event naming convention is consistent',\n status: 'pending',\n },\n {\n id: 'event-duplicates-and-bloat',\n area: 'Event Quality',\n label: 'No duplicate or bloated event capture',\n status: 'pending',\n },\n {\n id: 'event-quality-context-review',\n area: 'Event Quality',\n label: 'Event property context reviewed',\n status: 'pending',\n },\n {\n id: 'event-usage-coverage',\n area: 'Event Quality',\n label: 'Captured events match insights / dashboards usage',\n status: 'pending',\n },\n // ── Feature Flags (Step 6) ──\n {\n id: 'stale-feature-flags-reviewed',\n area: 'Feature Flags',\n label: 'Stale feature flags reviewed',\n status: 'pending',\n },\n // ── Session Replay — fix (Step 6b) ──\n {\n id: 'replay-minimum-duration-set',\n area: 'Session Replay',\n label: 'Minimum duration set on init',\n status: 'pending',\n },\n {\n id: 'replay-mask-config',\n area: 'Session Replay',\n label: 'Mask config covers sensitive surfaces',\n status: 'pending',\n },\n {\n id: 'replay-disabled-in-test-envs',\n area: 'Session Replay',\n label: 'Disabled in test / CI environments',\n status: 'pending',\n },\n {\n id: 'replay-strict-minimum-duration',\n area: 'Session Replay',\n label: 'Strict minimum duration enforced',\n status: 'pending',\n },\n // ── Session Replay — optimize (Step 6b cost wave) ──\n {\n id: 'replay-sampling-rate',\n area: 'Session Replay — Optimize',\n label: 'Sampling rate tuned for cost',\n status: 'pending',\n },\n {\n id: 'replay-triggers-configured',\n area: 'Session Replay — Optimize',\n label: 'Triggers configured (event / URL / flag)',\n status: 'pending',\n },\n {\n id: 'replay-network-recording-filtered',\n area: 'Session Replay — Optimize',\n label: 'Network recording filtered',\n status: 'pending',\n },\n {\n id: 'replay-mobile-sampling',\n area: 'Session Replay — Optimize',\n label: 'Mobile sampling configured',\n status: 'pending',\n },\n // ── Use Case: Expansion (Step 9) ──\n {\n id: 'expansion-product-analytics',\n area: 'Use Case: Expansion',\n label: 'Product analytics coverage',\n status: 'pending',\n },\n {\n id: 'expansion-error-tracking',\n area: 'Use Case: Expansion',\n label: 'Error tracking coverage',\n status: 'pending',\n },\n {\n id: 'expansion-llm-observability',\n area: 'Use Case: Expansion',\n label: 'LLM observability coverage',\n status: 'pending',\n },\n {\n id: 'expansion-session-replay',\n area: 'Use Case: Expansion',\n label: 'Session replay coverage',\n status: 'pending',\n },\n {\n id: 'expansion-feature-flags',\n area: 'Use Case: Expansion',\n label: 'Feature flags coverage',\n status: 'pending',\n },\n {\n id: 'expansion-surveys',\n area: 'Use Case: Expansion',\n label: 'Surveys coverage',\n status: 'pending',\n },\n {\n id: 'expansion-logs',\n area: 'Use Case: Expansion',\n label: 'Logs coverage',\n status: 'pending',\n },\n {\n id: 'expansion-web-analytics',\n area: 'Use Case: Expansion',\n label: 'Web analytics coverage',\n status: 'pending',\n },\n // ── Additional Sections (Steps 7, 8, 10 phase markers) ──\n // Tracked in the ledger so the UI can surface \"did it run / was it\n // skipped\" alongside the regular checks. use-case-expansion is omitted\n // because the eight `expansion-*` checks above cover that phase.\n {\n id: 'customer-enrichment',\n area: 'Additional Sections',\n label: 'Customer enrichment (Harmonic + PDL)',\n status: 'pending',\n },\n {\n id: 'use-case-match',\n area: 'Additional Sections',\n label: 'Use-case match',\n status: 'pending',\n },\n {\n id: 'final-report',\n area: 'Additional Sections',\n label: 'Final audit report written',\n status: 'pending',\n },\n];\n\nconst AUDIT3000_SEED_CHECKS: AuditCheck[] = [\n ...AUDIT_SEED_CHECKS,\n ...AUDIT3000_EXTRA_CHECKS,\n];\n\n// Audit-3000 has its own arcade-flavoured intro / run / outro screens. The\n// shared audit screens stay reserved for the original `audit` program.\nconst AUDIT3000_SCREEN_BY_STEP: Record<string, string> = {\n intro: 'audit-3000-intro',\n run: 'audit-3000-run',\n outro: 'audit-3000-outro',\n};\n\nconst seedAudit3000Ledger = (installDir: string): void => {\n const target = path.join(installDir, AUDIT_CHECKS_FILE);\n const tmp = `${target}.tmp`;\n fs.writeFileSync(tmp, JSON.stringify(AUDIT3000_SEED_CHECKS, null, 2), 'utf8');\n fs.renameSync(tmp, target);\n logToFile(\n `seedAudit3000Ledger: wrote ${AUDIT3000_SEED_CHECKS.length} entries to ${target}`,\n );\n};\n\nconst seedBeforeAudit3000Run = (session: WizardSession): void => {\n seedAudit3000Ledger(session.installDir);\n session.frameworkContext[AUDIT_CHECKS_KEY] = AUDIT3000_SEED_CHECKS;\n};\n\nconst withAudit3000Screens = (steps: ProgramStep[]): ProgramStep[] =>\n steps.map((step) => {\n const override = AUDIT3000_SCREEN_BY_STEP[step.id];\n return override ? { ...step, screenId: override } : step;\n });\n\nconst audit3000Steps: ProgramStep[] = withAudit3000Screens(AGENT_SKILL_STEPS);\n\nconst baseConfig = createSkillProgram({\n skillId: 'audit-3000',\n command: 'audit-3000',\n id: 'audit-3000',\n description:\n 'Audit an existing PostHog integration (v3000 — adds event quality, stale-flag hygiene, customer enrichment, use-case match)',\n integrationLabel: 'audit-3000',\n customPrompt:\n 'Run the audit-3000 skill end-to-end. Follow the step chain starting at references/1-version.md. Do not modify any project files — only create the final audit report and (when enrichment is enabled) the enrichment report.',\n successMessage: `Audit complete! View the report at ./${AUDIT3000_REPORT_FILE}`,\n reportFile: AUDIT3000_REPORT_FILE,\n docsUrl: 'https://posthog.com/docs/product-analytics/best-practices',\n spinnerMessage: 'Running PostHog Audit 3000...',\n estimatedDurationMinutes: 6,\n requires: ['posthog-integration'],\n abortCases: AUDIT_ABORT_CASES,\n});\n\nconst audit3000Run = async (session: WizardSession): Promise<ProgramRun> => {\n seedBeforeAudit3000Run(session);\n\n if (!baseConfig.run) {\n throw new Error('audit-3000 program has no run configuration.');\n }\n\n return typeof baseConfig.run === 'function'\n ? baseConfig.run(session)\n : baseConfig.run;\n};\n\nexport const audit3000Config: ProgramConfig = {\n ...baseConfig,\n steps: audit3000Steps,\n run: audit3000Run,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n};\n","import type { ProgramStep } from '@lib/programs/program-step';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\n\nexport const POSTHOG_DOCTOR_PROGRAM: ProgramStep[] = [\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'doctor-intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'report',\n label: 'Doctor report',\n screenId: 'doctor-report',\n isComplete: (session) => session.outroData !== null,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n];\n","import { z } from 'zod';\n\nexport const HealthIssueSeveritySchema = z.enum([\n 'critical',\n 'warning',\n 'info',\n]);\nexport type HealthIssueSeverity = z.infer<typeof HealthIssueSeveritySchema>;\n\nexport const HealthIssueStatusSchema = z.enum(['active', 'resolved']);\n\nexport const HealthIssueSchema = z.object({\n id: z.string(),\n kind: z.string(),\n severity: HealthIssueSeveritySchema,\n status: HealthIssueStatusSchema,\n dismissed: z.boolean(),\n created_at: z.string(),\n updated_at: z.string(),\n resolved_at: z.string().nullable().optional(),\n});\nexport type HealthIssue = z.infer<typeof HealthIssueSchema>;\n\nexport const HealthIssueListResponseSchema = z.object({\n results: z.array(HealthIssueSchema),\n count: z.number().optional(),\n next: z.string().nullable().optional(),\n previous: z.string().nullable().optional(),\n});\nexport type HealthIssueListResponse = z.infer<\n typeof HealthIssueListResponseSchema\n>;\n\nexport interface HealthIssueSummary {\n total: number;\n by_severity: Record<HealthIssueSeverity, number>;\n}\n","import axios from 'axios';\nimport { analytics } from '@utils/analytics';\nimport { handleApiError } from '@lib/api';\nimport { WIZARD_USER_AGENT } from '@lib/constants';\nimport { HealthIssueListResponseSchema, type HealthIssue } from './types';\n\nexport async function fetchHealthIssues(\n accessToken: string,\n baseUrl: string,\n projectId: number,\n): Promise<HealthIssue[]> {\n const endpoint = `/api/environments/${projectId}/health_issues/`;\n const url = `${baseUrl}${endpoint}?status=active&dismissed=false&limit=250`;\n try {\n const response = await axios.get(url, {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n });\n return HealthIssueListResponseSchema.parse(response.data).results;\n } catch (error) {\n const apiError = handleApiError(error, 'fetch health issues');\n analytics.captureException(apiError, { endpoint, baseUrl, projectId });\n throw apiError;\n }\n}\n","import { POSTHOG_DOCS_URL } from '@lib/constants';\n\nexport interface KindMeta {\n title: string;\n description: string;\n docsUrl: string;\n}\n\nexport const KIND_METADATA: Record<string, KindMeta> = {\n ingestion_lag: {\n title: 'Ingestion is delayed',\n description:\n 'Events are being received but are taking longer than usual to appear.',\n docsUrl: `${POSTHOG_DOCS_URL}/support/troubleshooting`,\n },\n ingestion_warning: {\n title: 'Ingestion warnings on recent events',\n description:\n 'Some recent events were rejected or flagged by the ingestion pipeline.',\n docsUrl: `${POSTHOG_DOCS_URL}/support/troubleshooting`,\n },\n sdk_outdated: {\n title: 'SDK version is out of date',\n description:\n 'One or more SDKs are running an old version. Upgrade to get the latest fixes.',\n docsUrl: `${POSTHOG_DOCS_URL}/libraries`,\n },\n no_live_events: {\n title: 'No $pageview or $screen events in the last 30 days',\n description:\n 'PostHog is not receiving page or screen events from this project.',\n docsUrl: `${POSTHOG_DOCS_URL}/getting-started/install`,\n },\n no_pageleave_events: {\n title: '$pageleave events not being sent',\n description:\n 'Enable pageleave tracking to power bounce rate and session duration.',\n docsUrl: `${POSTHOG_DOCS_URL}/libraries/js#config`,\n },\n scroll_depth: {\n title: 'Scroll depth tracking disabled',\n description:\n 'Turn on scroll depth to capture how far users read each page.',\n docsUrl: `${POSTHOG_DOCS_URL}/libraries/js#config`,\n },\n authorized_urls: {\n title: 'No authorized URLs configured',\n description:\n 'Some web analytics filters require at least one authorized URL to work.',\n docsUrl: `${POSTHOG_DOCS_URL}/web-analytics/faq`,\n },\n reverse_proxy: {\n title: 'No reverse proxy detected',\n description: 'A reverse proxy reduces data loss from ad blockers.',\n docsUrl: `${POSTHOG_DOCS_URL}/advanced/proxy`,\n },\n web_vitals: {\n title: 'Web Vitals tracking disabled',\n description:\n 'Enable Web Vitals to capture LCP, CLS and other performance metrics.',\n docsUrl: `${POSTHOG_DOCS_URL}/web-analytics/web-vitals`,\n },\n materialized_view_failure: {\n title: 'A materialized view is failing',\n description: 'A data modeling pipeline failed its most recent run.',\n docsUrl: `${POSTHOG_DOCS_URL}/data-warehouse`,\n },\n external_data_failure: {\n title: 'External data source is failing',\n description: 'An external data source sync failed and data may be stale.',\n docsUrl: `${POSTHOG_DOCS_URL}/data-warehouse/sources`,\n },\n};\n\nexport const UNKNOWN_KIND_META: KindMeta = {\n title: 'Unknown issue',\n description:\n 'PostHog reported an issue kind the wizard does not yet recognize.',\n docsUrl: POSTHOG_DOCS_URL,\n};\n\nexport function getKindMeta(kind: string): KindMeta {\n return KIND_METADATA[kind] ?? { ...UNKNOWN_KIND_META, title: kind };\n}\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { POSTHOG_DOCTOR_PROGRAM } from './steps.js';\n\nexport const posthogDoctorConfig: ProgramConfig = {\n command: 'doctor',\n description:\n 'Diagnose your PostHog project for configuration issues and setup warnings',\n id: 'posthog-doctor',\n steps: POSTHOG_DOCTOR_PROGRAM,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n};\n\nexport { POSTHOG_DOCTOR_PROGRAM } from './steps.js';\nexport { fetchHealthIssues } from './fetch.js';\nexport { getKindMeta, KIND_METADATA } from './kind-metadata.js';\nexport type { KindMeta } from './kind-metadata.js';\nexport type {\n HealthIssue,\n HealthIssueSeverity,\n HealthIssueSummary,\n} from './types.js';\n","import type { ProgramStep } from '@lib/programs/program-step';\nimport { RunPhase } from '@lib/wizard-session';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\n\nexport const MIGRATION_PROGRAM: ProgramStep[] = [\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'migration-intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Migration',\n screenId: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screenId: 'keep-skills',\n },\n];\n","/**\n * Vendor cost stack — the multi-tool baseline a typical migration target has\n * before consolidating onto PostHog. Numbers from each vendor's published\n * starter pricing.\n */\n\nimport { Text } from 'ink';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const VENDOR_STACK_BLOCK: ContentBlock = {\n type: 'lines',\n interval: 600,\n pause: 9000,\n lines: [\n <Text bold>{' Typical pre-migration stack'}</Text>,\n <Text> </Text>,\n <Text>\n <Text color=\"gray\">{' Sentry'}</Text>\n <Text>{' error tracking '}</Text>\n <Text color=\"red\">{'$26/mo+'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' LaunchDarkly'}</Text>\n <Text>{' feature flags '}</Text>\n <Text color=\"red\">{'$8.33/mo+'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' Amplitude'}</Text>\n <Text>{' product analytics '}</Text>\n <Text color=\"red\">{'$49/mo+'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' Braintrust'}</Text>\n <Text>{' LLM analytics '}</Text>\n <Text color=\"red\">{'$50/mo+'}</Text>\n </Text>,\n <Text color=\"gray\">{' ─────────────────────────────────────'}</Text>,\n <Text>\n <Text>{' Total'}</Text>\n <Text>{' '}</Text>\n <Text bold color=\"red\">\n {'$133/mo+'}\n </Text>\n </Text>,\n <Text dimColor>{' plus ~450KB of JavaScript SDKs'}</Text>,\n ],\n};\n","/**\n * PostHog free-tier highlights — the numbers a migrating team gets back when\n * they consolidate. Sourced from posthog.com/pricing.md.\n */\n\nimport { Text } from 'ink';\nimport { Colors } from '@ui/tui/styles';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const FREE_TIER_BLOCK: ContentBlock = {\n type: 'lines',\n interval: 400,\n pause: 9000,\n lines: [\n <Text bold>{' Free every month, on every product'}</Text>,\n <Text> </Text>,\n <Text>\n <Text color={Colors.accent}>{' 1,000,000 '}</Text>\n <Text>events </Text>\n <Text dimColor>product analytics</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 1,000,000 '}</Text>\n <Text>requests </Text>\n <Text dimColor>feature flags + experiments</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 5,000 '}</Text>\n <Text>recordings </Text>\n <Text dimColor>session replay</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 100,000 '}</Text>\n <Text>exceptions </Text>\n <Text dimColor>error tracking</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 100,000 '}</Text>\n <Text>events </Text>\n <Text dimColor>LLM analytics</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 50 GB '}</Text>\n <Text>logs </Text>\n <Text dimColor>logs</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 1,500 '}</Text>\n <Text>responses </Text>\n <Text dimColor>surveys</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 1,000,000 '}</Text>\n <Text>rows </Text>\n <Text dimColor>data warehouse</Text>\n </Text>,\n ],\n};\n","/**\n * Pricing structure block — what happens after the free tier.\n */\n\nimport { Text } from 'ink';\nimport { Colors } from '@ui/tui/styles';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const PRICING_STRUCTURE_BLOCK: ContentBlock = {\n type: 'lines',\n interval: 500,\n pause: 8000,\n lines: [\n <Text bold>{' After the free tier'}</Text>,\n <Text> </Text>,\n <Text>\n <Text color={Colors.accent}>{' $0 '}</Text>\n <Text>base price · pay only for what you use</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' ◆ '}</Text>\n <Text>per-event prices decrease with volume</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' ◆ '}</Text>\n <Text>no per-seat charges — your whole team is included</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' ◆ '}</Text>\n <Text>web analytics bundled with product analytics</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' ◆ '}</Text>\n <Text>experiments bundled with feature flags</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' ◆ '}</Text>\n <Text>revenue analytics bundled with data warehouse</Text>\n </Text>,\n ],\n};\n","/**\n * Migration learn deck (statsig variant). Statsig is the only `migrate`\n * variant today, so this deck plays as-is when the wizard runs\n * `migrate --product=statsig`. Three movements:\n *\n * 1. Welcome and reassure.\n * 2. What to expect — the migration is replacement-only, takes a few\n * minutes, leaves the build green.\n * 3. What's a little different — how flags and experiments work in\n * PostHog, presented as right-way guidance rather than gotchas.\n *\n * FF/experiments guidance paraphrased from PostHog public docs:\n * - posthog.com/docs/feature-flags/best-practices\n * - posthog.com/docs/feature-flags/common-questions\n * - posthog.com/docs/experiments/best-practices\n */\n\nimport { Text } from 'ink';\nimport type { WizardStore } from '@ui/tui/store';\nimport { Colors } from '@ui/tui/styles';\nimport { TextRevealMode } from '@ui/tui/primitives/TextBlock';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\nimport { StatusPeekTrigger } from '@ui/tui/components/StatusPeekTrigger';\nimport { PRODUCT_SUITE_BLOCK } from '@lib/programs/posthog-integration/content/product-suite';\nimport { LINE_CHART_BLOCK } from '@lib/programs/posthog-integration/content/line-chart';\nimport { FUNNEL_BLOCK } from '@lib/programs/posthog-integration/content/funnel';\nimport { VENDOR_STACK_BLOCK } from './vendor-stack.js';\nimport { FREE_TIER_BLOCK } from './free-tier.js';\nimport { PRICING_STRUCTURE_BLOCK } from './pricing-structure.js';\n\nexport const getContentBlocks = (store?: WizardStore): ContentBlock[] => [\n // ── Welcome ────────────────────────────────────────────────────────────\n {\n content: 'Hello.',\n pause: 3000,\n mode: TextRevealMode.Typewriter,\n animationInterval: 160,\n },\n\n { content: 'The Wizard is an agent.', pause: 4000 },\n\n {\n content:\n 'As we speak, it’s making a plan to migrate from Statsig to PostHog.',\n pause: 6000,\n },\n\n {\n content: 'PostHog covers the cost of running this agent.',\n pause: 4000,\n },\n\n { type: 'clear', pause: 2000 },\n\n {\n pause: 5000,\n persist: true,\n content: <StatusPeekTrigger store={store} />,\n },\n\n {\n pause: 6000,\n persist: true,\n content: (\n <Text>\n Press{' '}\n <Text color={Colors.accent} bold>\n S\n </Text>{' '}\n to expand or collapse the status.\n </Text>\n ),\n },\n\n { type: 'clear', pause: 2000 },\n\n // ── What to expect ─────────────────────────────────────────────────────\n { content: 'Here’s what to expect.', pause: 3000 },\n\n { content: 'The migration takes about ten minutes.', pause: 3000 },\n\n {\n content:\n 'Every Statsig call gets replaced in place with its PostHog equivalent.',\n pause: 5500,\n },\n\n {\n content:\n 'Nothing new gets added. No extra captures, no surprise instrumentation.',\n pause: 5500,\n },\n\n {\n content:\n 'The Statsig package gets removed at the end. We’ll run build and lint to clean up after ourselves.',\n pause: 6500,\n },\n\n { type: 'clear', pause: 2000 },\n\n // ── What's a little different ─────────────────────────────────────────\n {\n content: 'A few things work a little differently in PostHog.',\n pause: 4500,\n },\n\n {\n content: (\n <Text>\n Flags evaluate against a stable user. Call{' '}\n <Text bold color={Colors.accent}>\n identify()\n </Text>{' '}\n first, then check the flag.\n </Text>\n ),\n pause: 6000,\n persist: true,\n },\n\n {\n content:\n 'For anything in the first paint, evaluate server-side and bootstrap the values into the client.',\n pause: 6500,\n },\n\n {\n content: (\n <Text>\n In production, route requests through a reverse proxy to avoid ad\n blockers breaking your flags.{'\\n'}\n <Text dimColor>https://posthog.com/docs/advanced/proxy</Text>\n </Text>\n ),\n pause: 6500,\n persist: true,\n },\n\n {\n content:\n 'When a flag reaches 100% rollout, retire it. Flags are signals, not switches.',\n pause: 5500,\n },\n\n {\n content: (\n <Text>\n Name flags descriptively. No double negatives. Reflect the return type.{' '}\n <Text dimColor>For example </Text>\n <Text bold>show-new-checkout</Text>\n <Text dimColor>.</Text>\n </Text>\n ),\n pause: 6500,\n persist: true,\n },\n\n { type: 'clear', pause: 1500 },\n\n // ── Experiments ────────────────────────────────────────────────────────\n {\n content: (\n <Text bold color={Colors.accent}>\n Experiments\n </Text>\n ),\n pause: 2500,\n persist: true,\n },\n\n {\n content:\n 'Change one thing per variant. Multiple changes in one variant blur the result.',\n pause: 5500,\n },\n\n {\n content:\n 'Decide the running time up front. PostHog includes a sample-size and duration calculator in the setup flow.',\n pause: 6500,\n },\n\n {\n content: 'Roll out to 5–10% first. Watch the metrics. Then increase.',\n pause: 5000,\n },\n\n {\n content:\n 'Exclude users who already completed the flow. They can’t be affected by the test.',\n pause: 5500,\n },\n\n { type: 'clear', pause: 1500 },\n\n // ── Close ──────────────────────────────────────────────────────────────\n {\n content: 'Flags and experiments live alongside the rest of your data.',\n pause: 4500,\n },\n\n {\n content: 'Ship behind a flag, watch replays, check analytics for impact.',\n pause: 4500,\n },\n\n { type: 'clear', pause: 1500 },\n\n {\n content:\n 'PostHog also provides every other analytics and AI tool to build your product.',\n pause: 4500,\n },\n\n PRODUCT_SUITE_BLOCK,\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'And consolidating onto one platform saves real money.',\n pause: 4500,\n },\n\n { content: 'Here’s the math.', pause: 1500 },\n\n VENDOR_STACK_BLOCK,\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'Pricing is usage-based, with a generous free tier.',\n pause: 4000,\n },\n\n FREE_TIER_BLOCK,\n\n { type: 'clear', pause: 1500 },\n\n PRICING_STRUCTURE_BLOCK,\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'Gain clarity and really understand your users.',\n pause: 4000,\n },\n\n { content: 'Use trends to measure growth.', pause: 2500 },\n\n LINE_CHART_BLOCK,\n\n { type: 'clear', pause: 500 },\n\n { content: 'Use funnels to reveal bottlenecks.', pause: 2500 },\n\n FUNNEL_BLOCK,\n];\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport type { AbortCase } from '@lib/agent/agent-runner';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { MIGRATION_PROGRAM } from './steps.js';\nimport { getContentBlocks } from './content/index.js';\n\nconst MIGRATION_REPORT_FILE = 'migration-report.md';\n\nconst MIGRATION_ABORT_CASES: AbortCase[] = [\n {\n match: /^no source-sdk calls found$/i,\n message: 'No source-SDK calls found',\n body:\n 'The migration needs an existing third-party SDK to migrate from. No ' +\n 'calls to the source SDK appear anywhere in this project. If you ' +\n \"haven't installed PostHog yet, you don't need this command — run \" +\n '`npx @posthog/wizard@latest` to add PostHog from scratch.',\n },\n];\n\n/**\n * Map each `--product=<id>` choice to the context-mill skill ID that handles\n * it. Adding a variant: drop a new row here. The CLI `choices` and the\n * runtime lookup both read from this map, so the two stay in sync.\n */\nconst PRODUCT_TO_SKILL_ID = {\n statsig: 'migrate-statsig',\n} as const;\n\ntype MigrateProduct = keyof typeof PRODUCT_TO_SKILL_ID;\nconst MIGRATE_PRODUCTS = Object.keys(PRODUCT_TO_SKILL_ID) as MigrateProduct[];\n\nexport const migrationConfig: ProgramConfig = {\n command: 'migrate',\n description: 'Migrate to PostHog from another analytics provider',\n id: 'migration',\n skillId: PRODUCT_TO_SKILL_ID.statsig,\n steps: MIGRATION_PROGRAM,\n reportFile: MIGRATION_REPORT_FILE,\n getContentBlocks,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n cliOptions: {\n product: {\n describe: 'Source SDK to migrate from',\n type: 'string',\n choices: MIGRATE_PRODUCTS,\n demandOption: true,\n },\n },\n mapCliOptions: (argv) => ({\n skillId: PRODUCT_TO_SKILL_ID[argv.product as MigrateProduct],\n }),\n run: {\n skillId: PRODUCT_TO_SKILL_ID.statsig,\n integrationLabel: 'migration',\n customPrompt: () =>\n 'Migrate this project from its existing third-party analytics, ' +\n 'feature-flag, and observability tools to PostHog. Run the `migrate` ' +\n 'skill end-to-end: follow the step chain starting at ' +\n 'references/1-presence.md. Only replace existing source-SDK call sites ' +\n 'with PostHog equivalents — make zero unrelated changes and no ' +\n `net-new instrumentation. The final report is written to ./${MIGRATION_REPORT_FILE}.`,\n successMessage: `Migration complete! View the report at ./${MIGRATION_REPORT_FILE}`,\n reportFile: MIGRATION_REPORT_FILE,\n docsUrl: '',\n spinnerMessage: 'Migrating to PostHog...',\n estimatedDurationMinutes: 8,\n abortCases: MIGRATION_ABORT_CASES,\n },\n requires: ['posthog-integration'],\n};\n\nexport { MIGRATION_PROGRAM } from './steps.js';\n","/**\n * Source maps upload prerequisite detection.\n *\n * Scans the project for signals that identify the platform and build system,\n * then maps to one of the context-mill `error-tracking-upload-source-maps-*`\n * skill variants. Results are written to frameworkContext for the intro\n * screen to render and for the agent prompt to consume.\n */\n\nimport type { Dirent } from 'fs';\nimport { readFileSync, readdirSync, existsSync, statSync } from 'fs';\nimport { join, relative } from 'path';\nimport { IGNORED_DIRS } from '@utils/file-utils';\nimport type { WizardSession } from '@lib/wizard-session';\nimport type { AbortCase } from '@lib/agent/agent-runner';\n\n/**\n * Skill variants published under the `error-tracking-upload-source-maps`\n * category in context-mill. The agent loads\n * `error-tracking-upload-source-maps-<variant>`.\n */\nexport type SkillVariant =\n | 'web'\n | 'nextjs'\n | 'node'\n | 'react'\n | 'angular'\n | 'nuxt'\n | 'react-native'\n | 'android'\n | 'flutter'\n | 'ios'\n | 'vite'\n | 'webpack'\n | 'rollup';\n\nconst DISPLAY_NAME: Record<SkillVariant, string> = {\n web: 'Web (JavaScript)',\n nextjs: 'Next.js',\n node: 'Node.js',\n react: 'React',\n angular: 'Angular',\n nuxt: 'Nuxt',\n 'react-native': 'React Native',\n android: 'Android',\n flutter: 'Flutter',\n ios: 'iOS',\n vite: 'Vite',\n webpack: 'Webpack',\n rollup: 'Rollup',\n};\n\nconst POSTHOG_SDKS = [\n 'posthog-js',\n 'posthog-node',\n 'posthog-react-native',\n 'posthog-android',\n 'posthog-ios',\n];\n\n/**\n * Structured detection errors. The screen renders each kind into JSX\n * with proper formatting — keeps error data separate from presentation.\n */\nexport type SourceMapsDetectError =\n | {\n kind: 'bad-directory';\n path: string;\n reason: 'missing' | 'not-dir' | 'unreadable';\n }\n | { kind: 'no-project-files' }\n | { kind: 'unsupported-platform'; detected: string }\n | { kind: 'no-posthog-sdk'; platform: SkillVariant };\n\n/** `[ABORT] <reason>` cases the source maps skill can emit. */\nexport const SOURCE_MAPS_ABORT_CASES: AbortCase[] = [\n {\n match: /^no posthog sdk detected$/i,\n message: 'No PostHog SDK detected',\n body:\n 'The agent could not find a PostHog SDK in your project. ' +\n 'Source map upload requires the SDK to already be installed so it can ' +\n 'report errors. Run `npx @posthog/wizard` first to install the SDK.',\n docsUrl: 'https://posthog.com/docs/error-tracking',\n },\n {\n match: /^build command not found$/i,\n message: 'Build command not found',\n body:\n 'The agent could not identify how to build your project. Source map ' +\n 'upload runs as part of the production build. Add a build script to ' +\n 'your project and run this wizard again.',\n docsUrl: 'https://posthog.com/docs/error-tracking/upload-source-maps',\n },\n];\n\n// ── File / dependency probes ─────────────────────────────────────────\n\ninterface ProjectSignals {\n packageJsons: Array<{ path: string; deps: Set<string> }>;\n hasXcodeProject: boolean;\n hasPodfile: boolean;\n hasSwiftPackage: boolean;\n hasGradle: boolean;\n hasPubspec: boolean;\n scannedFileCount: number;\n}\n\nfunction collectSignals(installDir: string, maxDepth = 3): ProjectSignals {\n const signals: ProjectSignals = {\n packageJsons: [],\n hasXcodeProject: false,\n hasPodfile: false,\n hasSwiftPackage: false,\n hasGradle: false,\n hasPubspec: false,\n scannedFileCount: 0,\n };\n\n function scan(dir: string, depth: number): void {\n if (depth > maxDepth) return;\n\n let entries: Dirent[];\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (entry.name.startsWith('.') && entry.name !== '.') continue;\n if (IGNORED_DIRS.has(entry.name)) continue;\n\n const fullPath = join(dir, entry.name);\n\n if (entry.isFile()) {\n signals.scannedFileCount += 1;\n if (entry.name === 'package.json') {\n try {\n const pkg = JSON.parse(readFileSync(fullPath, 'utf-8')) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n const deps = new Set([\n ...Object.keys(pkg.dependencies ?? {}),\n ...Object.keys(pkg.devDependencies ?? {}),\n ]);\n signals.packageJsons.push({\n path: relative(installDir, fullPath) || 'package.json',\n deps,\n });\n } catch {\n // skip malformed package.json\n }\n } else if (entry.name === 'Podfile') {\n signals.hasPodfile = true;\n } else if (entry.name === 'Package.swift') {\n signals.hasSwiftPackage = true;\n } else if (entry.name === 'pubspec.yaml') {\n signals.hasPubspec = true;\n } else if (\n entry.name === 'build.gradle' ||\n entry.name === 'build.gradle.kts' ||\n entry.name === 'settings.gradle' ||\n entry.name === 'settings.gradle.kts'\n ) {\n signals.hasGradle = true;\n }\n } else if (entry.isDirectory()) {\n if (entry.name.endsWith('.xcodeproj')) {\n signals.hasXcodeProject = true;\n } else {\n scan(fullPath, depth + 1);\n }\n }\n }\n }\n\n scan(installDir, 0);\n return signals;\n}\n\n// ── Skill selection ──────────────────────────────────────────────────\n\nfunction pickJsVariant(deps: Set<string>): SkillVariant {\n // Opinionated full-stack frameworks first — they own their build pipeline\n // and have dedicated skill variants, so bundler detection underneath\n // them is irrelevant.\n if (deps.has('react-native')) return 'react-native';\n if (deps.has('nuxt')) return 'nuxt';\n if (deps.has('next')) return 'nextjs';\n if (deps.has('@angular/core')) return 'angular';\n // Bundlers next — prefer these over the bare `react` variant because\n // their skills are simpler (one bundler-plugin config) than wiring\n // posthog-cli into an arbitrary React setup.\n if (deps.has('vite')) return 'vite';\n if (deps.has('webpack')) return 'webpack';\n if (deps.has('rollup')) return 'rollup';\n // Plain React with no recognised bundler.\n if (deps.has('react')) return 'react';\n // Server-only Node project\n if (deps.has('posthog-node')) return 'node';\n // Fallback: generic web\n return 'web';\n}\n\nfunction selectVariant(signals: ProjectSignals): SkillVariant | null {\n // Mobile / native first — they don't coexist with JS bundlers in the\n // detection signals we look at.\n if (signals.hasPubspec) return 'flutter';\n if (signals.hasXcodeProject || signals.hasPodfile || signals.hasSwiftPackage)\n return 'ios';\n if (signals.hasGradle) return 'android';\n\n if (signals.packageJsons.length > 0) {\n // Union all deps across package.json files (covers monorepos)\n const allDeps = new Set<string>();\n for (const pkg of signals.packageJsons) {\n for (const dep of pkg.deps) allDeps.add(dep);\n }\n return pickJsVariant(allDeps);\n }\n\n return null;\n}\n\nfunction hasPostHogSdk(signals: ProjectSignals): boolean {\n for (const pkg of signals.packageJsons) {\n for (const sdk of POSTHOG_SDKS) {\n if (pkg.deps.has(sdk)) return true;\n }\n }\n // For native platforms the PostHog SDK lives outside package.json and\n // is detected by the agent during the skill run. Assume present here.\n return (\n signals.hasXcodeProject ||\n signals.hasPodfile ||\n signals.hasSwiftPackage ||\n signals.hasGradle ||\n signals.hasPubspec\n );\n}\n\n// ── Entry point ──────────────────────────────────────────────────────\n\nexport const SOURCE_MAPS_CONTEXT_KEYS = {\n skillVariant: 'sourceMapsSkillVariant',\n displayName: 'sourceMapsDisplayName',\n packagePaths: 'sourceMapsPackagePaths',\n detectError: 'detectError',\n} as const;\n\n/**\n * Scan `session.installDir` for platform / build-system signals. Writes\n * detection results into frameworkContext via the callback — either the\n * picked skill variant + display name, or a `SourceMapsDetectError`.\n *\n * The skill install happens later in the agent run, not here. This step\n * only picks which variant the prompt should ask the agent to load.\n */\nexport function detectSourceMapsPrerequisites(\n session: WizardSession,\n setFrameworkContext: (key: string, value: unknown) => void,\n): void {\n const fail = (error: SourceMapsDetectError) =>\n setFrameworkContext(SOURCE_MAPS_CONTEXT_KEYS.detectError, error);\n\n const installDir = session.installDir;\n\n if (!existsSync(installDir)) {\n fail({ kind: 'bad-directory', path: installDir, reason: 'missing' });\n return;\n }\n try {\n if (!statSync(installDir).isDirectory()) {\n fail({ kind: 'bad-directory', path: installDir, reason: 'not-dir' });\n return;\n }\n } catch {\n fail({ kind: 'bad-directory', path: installDir, reason: 'unreadable' });\n return;\n }\n\n const signals = collectSignals(installDir);\n const variant = selectVariant(signals);\n\n // This program currently targets JS-like stacks only. Avoid selecting native\n // platforms until dedicated skill variants are available.\n if (\n variant &&\n ['react-native', 'flutter', 'ios', 'android'].includes(variant)\n ) {\n fail({ kind: 'unsupported-platform', detected: variant });\n return;\n }\n\n if (!variant) {\n if (signals.scannedFileCount === 0) {\n fail({ kind: 'no-project-files' });\n } else {\n fail({ kind: 'unsupported-platform', detected: 'unknown' });\n }\n return;\n }\n\n if (!hasPostHogSdk(signals)) {\n fail({ kind: 'no-posthog-sdk', platform: variant });\n return;\n }\n\n setFrameworkContext(SOURCE_MAPS_CONTEXT_KEYS.skillVariant, variant);\n setFrameworkContext(\n SOURCE_MAPS_CONTEXT_KEYS.displayName,\n DISPLAY_NAME[variant],\n );\n setFrameworkContext(\n SOURCE_MAPS_CONTEXT_KEYS.packagePaths,\n signals.packageJsons.map((p) => p.path),\n );\n}\n\nexport { DISPLAY_NAME as VARIANT_DISPLAY_NAME };\n","/**\n * Error tracking source maps upload program step list.\n *\n * Detection runs headless via onReady, then the user sees a custom intro\n * showing the picked skill variant. Auth → agent run → outro mirrors the\n * other programs.\n */\n\nimport type { ProgramStep } from '@lib/programs/program-step';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { RunPhase } from '@lib/wizard-session';\nimport {\n evaluateWizardReadiness,\n WizardReadiness,\n SIGNUP_WIZARD_READINESS_CONFIG,\n getBlockingServiceKeys,\n} from '@lib/health-checks/readiness';\nimport { detectSourceMapsPrerequisites } from './detect.js';\n\nfunction healthCheckReady(session: WizardSession): boolean {\n if (!session.readinessResult) return false;\n\n if (session.signup) {\n const hardBlocking = getBlockingServiceKeys(\n session.readinessResult.health,\n SIGNUP_WIZARD_READINESS_CONFIG,\n );\n const defaultBlocking = getBlockingServiceKeys(\n session.readinessResult.health,\n );\n if (hardBlocking.length === 0 && defaultBlocking.length === 0) return true;\n return session.outageDismissed;\n }\n\n if (session.readinessResult.decision === WizardReadiness.No) {\n return session.outageDismissed;\n }\n return true;\n}\n\nexport const ERROR_TRACKING_UPLOAD_SOURCE_MAPS_PROGRAM: ProgramStep[] = [\n {\n id: 'detect',\n label: 'Detecting platform',\n // Headless: scans for platform / build-system signals and picks the\n // matching context-mill skill variant. Writes either the variant or\n // a detectError to frameworkContext.\n onReady: (ctx) =>\n detectSourceMapsPrerequisites(ctx.session, ctx.setFrameworkContext),\n },\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'source-maps-intro',\n gate: (session) => session.setupConfirmed,\n },\n {\n id: 'health-check',\n label: 'Health check',\n screenId: 'health-check',\n gate: healthCheckReady,\n onInit: (ctx) => {\n evaluateWizardReadiness()\n .then((readiness) => {\n ctx.setReadinessResult(readiness);\n })\n .catch(() => {\n ctx.setReadinessResult({\n decision: WizardReadiness.Yes,\n health: {} as never,\n reasons: [],\n });\n });\n },\n },\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Upload source maps',\n screenId: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'source-maps-outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screenId: 'keep-skills',\n },\n];\n","import { AgentSignals } from '@lib/agent/agent-interface';\nimport type { SkillVariant } from './detect.js';\n\nexport type SourceMapsUploadPromptParams = {\n displayName: string | undefined;\n variant: SkillVariant;\n skillId: string;\n projectId: number;\n host: string;\n settingsUrl: string;\n uiHost: string;\n};\n\nexport const SOURCE_MAPS_DETECTION_FAILED_PROMPT = `Detection did not pick a source maps skill variant for this project.\nEmit: ${AgentSignals.ABORT} unsupported-platform\nThen halt.`;\n\nexport function buildSourceMapsUploadPrompt(\n params: SourceMapsUploadPromptParams,\n): string {\n const {\n displayName,\n variant,\n skillId,\n projectId,\n host,\n settingsUrl,\n uiHost,\n } = params;\n const platformLabel = displayName ?? variant;\n\n return `You are wiring up PostHog Error Tracking source map upload for this ${platformLabel} project.\n\nProject context:\n- PostHog Project ID: ${projectId}\n- PostHog Host: ${host}\n- Detected platform: ${platformLabel}\n- Skill to use: ${skillId}\n- Personal API keys settings page: ${settingsUrl}\n\nThe skill you install in STEP 2 is the source of truth for the HOW of every\nstep: its \"## Steps\" section has an overview, tips and per-technology\nexamples for each named step, and its reference files carry the exact\nper-framework API. The STEPS below give the order, the conditionals, and the\nwizard-specific mechanics (which MCP tool to call, signals to emit) — read\nthe matching skill step (named in parentheses) before doing the work, and do\nnot invent steps the skill doesn't describe.\n\nFollow these steps IN ORDER. Do not skip or reorder.\n\nBefore doing any work, create your FULL task list in a single TaskCreate\ncall so the user can follow your progress in the TUI. Use exactly these\ntasks, in this order — do not collapse, rename, or omit any of them:\n 1. Get personal API key\n 2. Install source maps skill\n 3. Apply build-config changes (per skill)\n 4. Make credentials readable at build time\n 5. Write keys to .env\n 6. Identify build & run commands\n 7. Test the local setup\n 8. Summarise & hand off\nDrive the list with TaskUpdate — mark a task in_progress when you start it\nand completed when done. ALWAYS keep task 7 (\"Test the local setup\") in the\nlist even if the user declines testing in STEP 7: mark it completed rather\nthan deleting it, so the user can see testing was offered.\n\nSTEP 1 — Get a personal API key from the user. (skill: \"Get a personal API key\")\n The wizard cannot mint keys — never call the PostHog API or any tool to\n create one. Ask the user with the wizard_ask MCP tool; you receive the\n answer as a vaulted secretRef (never the raw value), which you reuse in\n STEP 5:\n {\n id: \"api-key\",\n prompt: \"Paste your PostHog personal API key below.\\\\n\\\\nDon't have one yet? Create one here:\\\\n${settingsUrl}\\\\n\\\\nWhen creating the key, choose the 'Source map upload' preset, then come back and paste it here.\",\n kind: \"text\",\n sensitive: true\n }\n Keep the \\\\n line breaks exactly as written — Ink's <Text> renders them\n as separate lines. The answer is { secretRef: \"secret:...\" }.\n If wizard_ask is unavailable (CI / non-interactive), emit\n ${AgentSignals.ABORT} requires-interactive-mode and halt.\n\nSTEP 2 — Install the skill.\n Call install_skill (wizard-tools MCP server) with skillId \"${skillId}\".\n Do NOT run shell commands to install skills. Then read the installed\n SKILL.md and its reference files — they drive STEPS 3-8.\n If install fails, emit ${AgentSignals.ERROR_RESOURCE_MISSING} skill ${skillId} could not be installed.\n\nSTEP 3 — Apply build-config changes. (skill: \"Apply build-config changes\")\n Make the bundler / build-config changes the skill's step instructs. The\n skill and its reference are the source of truth for this platform.\n\nSTEP 4 — Make the credentials readable at build time. (skill: \"Make credentials available at build time\")\n Follow the skill's step. Wizard-specific: if it calls for a loader (e.g.\n \\`dotenv\\`), install it SILENTLY — do NOT ask the user or call wizard_ask.\n Skip this step entirely if the platform already auto-loads .env.\n\nSTEP 5 — Write the credentials to the env file. (skill: \"Write credentials to the env file\")\n Use the wizard-tools MCP server. Reuse the env file the skill tells you to\n pick — the prerequisite PostHog integration usually already wrote\n POSTHOG_* vars to one, so seed your keys alongside them.\n - First call check_env_keys on that file (returns present/absent, never\n values — don't read the file directly).\n - Then call set_env_values, passing the STEP 1 secretRef as a value\n object, not a literal string:\n values: {\n \"POSTHOG_CLI_API_KEY\": { secretRef: \"<the ref from STEP 1>\" },\n \"POSTHOG_CLI_PROJECT_ID\": \"${projectId}\",\n \"POSTHOG_CLI_HOST\": \"${host}\"\n }\n Variable names follow the skill's per-uploader conventions. The wizard\n resolves the ref locally before writing, so you never see the key value.\n\nSTEP 6 — Identify the build AND run commands. (skill: \"Identify the build and run commands\")\n Per the skill, resolve the production BUILD command and the RUN command\n for THIS project (use detect_package_manager for the package manager). Do\n NOT run either yourself — the user runs them. If you cannot identify a\n build command, emit ${AgentSignals.ABORT} build command not found.\n\nSTEP 7 — Offer to test the local setup. (skill: \"Test the local setup\")\n Call wizard_ask:\n {\n id: \"test-affordance\",\n prompt: \"Want me to help you test your local setup? I'll add a temporary test button (or route) to your app so you can confirm errors show up in Error Tracking with readable stack traces after your next build. I'll remove it once you've confirmed it works.\",\n kind: \"single\",\n options: [\n { label: \"Yes, help me test it\", value: \"yes\" },\n { label: \"No, I'll test on my own later\", value: \"no\" }\n ]\n }\n\n If \"no\", skip to STEP 8.\n\n If \"yes\", follow the skill's \"Test the local setup\" step for the\n platform-appropriate affordance, the captureException shape, the\n placement, and the read-before-edit / always-revert rules. Then pause for\n the user with wizard_ask, baking the EXACT build and run commands from\n STEP 6 (and the exact button label / route) into the prompt as literal,\n copy-pasteable steps. Separate each numbered step with \\\\n\\\\n so the TUI\n renders them as distinct lines:\n {\n id: \"test-done\",\n prompt: \"1) Run \\`<your detected build command>\\` to upload source maps and build the app with the test affordance.\\\\n\\\\n2) Start the app with \\`<your detected run command>\\`, then click the \\\\\"<your test button label>\\\\\" button (or hit \\`<your test route>\\`).\\\\n\\\\n3) Open Error Tracking in PostHog (${uiHost}/project/${projectId}/error_tracking) and confirm the test error appears with a source-resolved stack trace pointing at real source files (not minified bundle paths).\\\\n\\\\nWhen you're done, select Continue and I'll revert the test code.\",\n kind: \"single\",\n options: [{ label: \"Continue (revert test code)\", value: \"continue\" }]\n }\n After the user continues, revert the test code per the skill's rules and\n surface any failure in STEP 8.\n\nSTEP 8 — Summarise and hand off. (skill: \"Verify and hand off\")\n Follow the skill's \"Verify and hand off\" step. The Symbol sets page for\n this project — where the user confirms the upload landed — is:\n ${uiHost}/project/${projectId}/error_tracking/configuration\n`;\n}\n","/**\n * Source-maps learn-deck — the narrative played in the run screen's left\n * pane (LearnCard) while the agent wires source-map upload into the build.\n *\n * It educates the user on what source maps are and why uploading them\n * matters, built around a before/after stack-trace contrast: a minified\n * production trace nobody can read, then the same trace resolved back to\n * real source. Program-owned; wired onto the program's getContentBlocks.\n *\n * Lines stay narrow (~36 cols) because this renders in the left half of a\n * split pane — see LearnCard's paneWidth math.\n */\n\nimport { Text } from 'ink';\nimport { Colors } from '@ui/tui/styles';\nimport type { WizardStore } from '@ui/tui/store';\nimport { TextRevealMode } from '@ui/tui/primitives/TextBlock';\nimport {\n isClearBlock,\n type ContentBlock,\n} from '@ui/tui/primitives/content-types';\nimport { StatusPeekTrigger } from '@ui/tui/components/StatusPeekTrigger';\n\n/**\n * Per-slide dwell multiplier. Each block stays on screen for `pause * SLIDE_PACE`\n * ms after it finishes animating, before the deck advances. Bump this single\n * knob to give every slide more reading time. Clear (page-break) blocks are\n * left untouched so the blank gap between slides stays snappy.\n */\nconst SLIDE_PACE = 1.5;\n\nconst withPace = (block: ContentBlock): ContentBlock => {\n if (typeof block === 'string' || isClearBlock(block) || block.pause == null) {\n return block;\n }\n return { ...block, pause: Math.round(block.pause * SLIDE_PACE) };\n};\n\n/** Apply the dwell multiplier to every block in a deck. */\nconst pace = (blocks: ContentBlock[]): ContentBlock[] => blocks.map(withPace);\n\n/**\n * A minified production stack trace — the problem source maps solve. Framed as\n * a labelled, muted example (no error-red ✘) so a glance reads it as\n * illustrative content, not as the wizard itself having errored mid-run.\n */\nconst MINIFIED_TRACE: ContentBlock = {\n type: 'lines',\n interval: 400,\n pause: 7000,\n lines: [\n <Text dimColor>{'example — minified production trace'}</Text>,\n <Text color={Colors.muted}>{' TypeError: cart is undefined'}</Text>,\n <Text dimColor>{' at t.min.js:1:48213'}</Text>,\n <Text dimColor>{' at t.min.js:1:9402'}</Text>,\n <Text dimColor>{' at t.min.js:1:71150'}</Text>,\n ],\n};\n\n/** The same trace, resolved through uploaded source maps. */\nconst RESOLVED_TRACE: ContentBlock = {\n type: 'lines',\n interval: 400,\n pause: 8000,\n lines: [\n <Text dimColor>{'example — resolved with source maps'}</Text>,\n <Text color={Colors.success}>{' ✔ TypeError: cart is undefined'}</Text>,\n <Text>\n <Text dimColor>{' at '}</Text>\n <Text color=\"cyan\">Cart.tsx:42</Text>\n <Text dimColor>{' loadCart'}</Text>\n </Text>,\n <Text>\n <Text dimColor>{' at '}</Text>\n <Text color=\"cyan\">App.tsx:88</Text>\n <Text dimColor>{' render'}</Text>\n </Text>,\n <Text>\n <Text dimColor>{' at '}</Text>\n <Text color=\"cyan\">index.tsx:5</Text>\n <Text dimColor>{' main'}</Text>\n </Text>,\n ],\n};\n\n/**\n * How a bundle is tied to its map: PostHog injects a chunk-ID marker into the\n * built JS and stamps the matching source map with the same ID.\n */\nconst CHUNK_ID_LINK: ContentBlock = {\n type: 'lines',\n interval: 450,\n pause: 7500,\n lines: [\n <Text dimColor>app.min.js</Text>,\n <Text dimColor>{' …minified code…'}</Text>,\n <Text>\n <Text color=\"cyan\">{' //# chunkId=a1b2c3d4'}</Text>\n <Text dimColor>{' ← injected'}</Text>\n </Text>,\n <Text dimColor>{' ↕ matched by id'}</Text>,\n <Text>\n <Text dimColor>app.min.js.map</Text>\n <Text dimColor>{' ← uploaded'}</Text>\n </Text>,\n ],\n};\n\n/** Many similar exceptions collapse into a single issue. */\nconst GROUPING: ContentBlock = {\n type: 'lines',\n interval: 450,\n pause: 7000,\n lines: [\n <Text dimColor>{'exception ─┐'}</Text>,\n <Text>\n <Text dimColor>{'exception ─┼──→ '}</Text>\n <Text color={Colors.accent} bold>\n 1 issue\n </Text>\n </Text>,\n <Text dimColor>{'exception ─┘'}</Text>,\n ],\n};\n\nexport const getContentBlocks = (store?: WizardStore): ContentBlock[] =>\n pace([\n {\n content: 'Welcome.',\n pause: 3000,\n mode: TextRevealMode.Typewriter,\n animationInterval: 160,\n },\n\n {\n content: \"I'm wiring PostHog Error Tracking into your build.\",\n pause: 5000,\n },\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'When you ship to production, your code gets minified.',\n pause: 5000,\n },\n {\n content: 'Thousands of readable lines collapse into one dense bundle.',\n pause: 5000,\n },\n {\n content: 'So a thrown error gives you a stack trace like this:',\n pause: 2000,\n },\n\n MINIFIED_TRACE,\n\n { content: 'Just offsets into a file no human can read.', pause: 5000 },\n\n { type: 'clear', pause: 1500 },\n\n { content: 'Source maps are the key.', pause: 3500 },\n {\n content:\n 'They map every position in that bundle back to your original source — the real file, line, and function.',\n pause: 6000,\n },\n {\n content:\n \"Right now I'm hooking source-map generation and upload into your build, tied to each release you ship.\",\n pause: 6000,\n },\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'But how does PostHog know which map belongs to which build?',\n pause: 4500,\n },\n {\n content:\n 'During the build, it injects a unique chunk ID into each bundle:',\n pause: 2500,\n },\n\n CHUNK_ID_LINK,\n\n {\n content:\n 'The matching source map is stamped with that same ID before it ships to PostHog.',\n pause: 6000,\n },\n {\n content:\n 'When an error comes in, PostHog reads the chunk ID off the bundle, finds the map with the exact same ID, and uses it to map each frame back to your source — even for a release you shipped weeks ago.',\n pause: 8000,\n },\n\n { type: 'clear', pause: 1500 },\n\n { content: 'So that same error becomes:', pause: 2000 },\n\n RESOLVED_TRACE,\n\n {\n content: 'Readable stack traces, straight from production.',\n pause: 5000,\n },\n {\n content: 'You debug a live error like it happened on your own machine.',\n pause: 6000,\n },\n\n { type: 'clear', pause: 1500 },\n\n { content: 'Zooming out — this is how Error Tracking works.', pause: 4000 },\n {\n content: 'Every error your app throws is captured as an exception.',\n pause: 5000,\n },\n {\n content: 'PostHog groups similar exceptions into a single issue:',\n pause: 2500,\n },\n\n GROUPING,\n\n {\n content:\n 'So a bug that fires ten thousand times is one issue to triage — not ten thousand alerts.',\n pause: 6500,\n },\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'And this is where source maps earn their keep again.',\n pause: 4500,\n },\n {\n content:\n 'Grouping reads the stack trace. Minified frames all look alike — so unrelated crashes get merged, and one real bug scatters across many issues.',\n pause: 8000,\n },\n {\n content:\n 'With source maps, PostHog groups on your real frames — so each distinct bug lands as one clean issue.',\n pause: 7000,\n },\n\n { type: 'clear', pause: 1500 },\n\n {\n pause: 5000,\n persist: true,\n content: <StatusPeekTrigger store={store} />,\n },\n {\n pause: 90000,\n content: (\n <Text>\n Press{' '}\n <Text color={Colors.accent} bold>\n S\n </Text>{' '}\n to follow along — or sit tight, I'll let you know when it's done.\n </Text>\n ),\n },\n ]);\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun } from '@lib/agent/agent-runner';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { OutroKind } from '@lib/wizard-session';\nimport { ERROR_TRACKING_UPLOAD_SOURCE_MAPS_PROGRAM } from './steps.js';\nimport {\n buildSourceMapsUploadPrompt,\n SOURCE_MAPS_DETECTION_FAILED_PROMPT,\n} from './prompt.js';\nimport {\n SOURCE_MAPS_ABORT_CASES,\n SOURCE_MAPS_CONTEXT_KEYS,\n type SkillVariant,\n} from './detect.js';\nimport { getContentBlocks } from './content/index.js';\nimport { getUiHostFromHost } from '@utils/urls';\n\nconst REPORT_FILE = 'posthog-source-maps-report.md';\nconst DOCS_URL = 'https://posthog.com/docs/error-tracking/upload-source-maps';\n\nexport const errorTrackingUploadSourceMapsConfig: ProgramConfig = {\n command: 'upload-source-maps',\n description: 'Upload source maps to PostHog Error Tracking',\n id: 'error-tracking-upload-source-maps',\n steps: ERROR_TRACKING_UPLOAD_SOURCE_MAPS_PROGRAM,\n reportFile: REPORT_FILE,\n getContentBlocks,\n requires: ['posthog-integration'],\n\n run: (session: WizardSession): Promise<ProgramRun> => {\n const variant = session.frameworkContext[\n SOURCE_MAPS_CONTEXT_KEYS.skillVariant\n ] as SkillVariant | undefined;\n const displayName = session.frameworkContext[\n SOURCE_MAPS_CONTEXT_KEYS.displayName\n ] as string | undefined;\n\n const skillId = variant\n ? `error-tracking-upload-source-maps-${variant}`\n : undefined;\n\n return Promise.resolve({\n integrationLabel: 'error-tracking-upload-source-maps',\n // Skill is installed by the agent (after the API-key choice is made)\n // rather than pre-installed by the runner, so leave skillId unset.\n successMessage: 'Source maps wired up!',\n reportFile: REPORT_FILE,\n docsUrl: DOCS_URL,\n spinnerMessage: 'Wiring up source maps...',\n estimatedDurationMinutes: 3,\n abortCases: SOURCE_MAPS_ABORT_CASES,\n\n customPrompt: (ctx) => {\n if (!skillId || !variant) {\n // Detection failed but the user got past the intro somehow.\n // Tell the agent to abort with a structured signal so the runner\n // renders a friendly outro.\n return SOURCE_MAPS_DETECTION_FAILED_PROMPT;\n }\n\n const uiHost = getUiHostFromHost(ctx.host).replace(/\\/$/, '');\n\n return buildSourceMapsUploadPrompt({\n displayName,\n variant,\n skillId,\n projectId: ctx.projectId,\n host: ctx.host,\n settingsUrl: `${uiHost}/project/${ctx.projectId}/settings/user-api-keys`,\n uiHost,\n });\n },\n\n postRun: (sess) => {\n // Stash a hint for the outro about what variant we shipped.\n if (variant) {\n sess.frameworkContext['sourceMapsCompletedVariant'] = variant;\n }\n return Promise.resolve();\n },\n\n buildOutroData: () => {\n // SourceMapsOutroScreen renders static \"what we did + how it works\"\n // guidance, so no per-run `changes` list is needed here.\n return {\n kind: OutroKind.Success as const,\n message: 'Source maps wired up!',\n reportFile: REPORT_FILE,\n docsUrl: DOCS_URL,\n };\n },\n });\n },\n};\n\nexport { ERROR_TRACKING_UPLOAD_SOURCE_MAPS_PROGRAM } from './steps.js';\nexport {\n detectSourceMapsPrerequisites,\n SOURCE_MAPS_ABORT_CASES,\n SOURCE_MAPS_CONTEXT_KEYS,\n VARIANT_DISPLAY_NAME,\n type SkillVariant,\n type SourceMapsDetectError,\n} from './detect.js';\n","/**\n * MCP add / remove / tutorial programs.\n *\n * None of these run the agent pipeline — they're TUI-only flows invoked\n * by the `mcp add` / `mcp remove` / `mcp tutorial` subcommands in\n * bin.ts. They live in the program registry so the screen sequence is\n * derived alongside every other program (no special-cases in\n * screen-sequences.ts).\n */\n\nimport type { ProgramConfig } from '@lib/programs/program-step';\nimport { McpOutcome } from '@lib/wizard-session';\n\nexport const mcpAddConfig: ProgramConfig = {\n id: 'mcp-add',\n description: 'Add PostHog MCP server to supported clients',\n steps: [\n {\n id: 'mcp-add',\n label: 'Add MCP server',\n screenId: 'mcp-add',\n isComplete: (s) => s.mcpComplete,\n },\n {\n id: 'mcp-suggested-prompts',\n label: 'Suggested prompts',\n screenId: 'mcp-suggested-prompts',\n // Only render after a successful install — no-clients, skipped,\n // and failed outcomes go straight to program end. The screen has\n // no value without a working MCP for the user to log in against.\n show: (s) => s.mcpOutcome === McpOutcome.Installed,\n isComplete: (s) => s.mcpSuggestedPromptsDismissed,\n },\n ],\n};\n\n/**\n * `wizard mcp remove` — single-step uninstall flow.\n *\n * DO NOT append `mcp-suggested-prompts` (or any other tutorial-shaped\n * step) here. A user who just removed MCP is opting OUT of the agent\n * having access to PostHog; immediately pivoting into a tutorial that\n * asks them to log in and try prompts is wrong on intent and confusing\n * on UX. The screen also reads `session.mcpInstalledClients` for its\n * Choose-phase copy (\"MCP is installed for X\") — that array is empty\n * post-remove, so the copy would be a lie.\n *\n * If you want a \"did you mean to keep it?\" confirmation, build that as\n * a screen earlier in this program — don't reuse the tutorial.\n */\nexport const mcpRemoveConfig: ProgramConfig = {\n id: 'mcp-remove',\n description: 'Remove PostHog MCP server from supported clients',\n steps: [\n {\n id: 'mcp-remove',\n label: 'Remove MCP server',\n screenId: 'mcp-remove',\n isComplete: (s) => s.mcpComplete,\n },\n ],\n};\n\n/**\n * Standalone tutorial flow — boots directly into the Choose phase of\n * McpSuggestedPromptsScreen without going through MCP install first.\n * Useful for users who already installed MCP and want to revisit the\n * tutorial, or anyone who just wants to try the agent against PostHog\n * without touching their IDE config.\n *\n * The screen handles its own OAuth (via services.performLogin) so this\n * program doesn't pre-populate credentials.\n */\nexport const mcpTutorialConfig: ProgramConfig = {\n id: 'mcp-tutorial',\n description: 'Try the PostHog MCP with your agent — no install needed',\n steps: [\n {\n id: 'mcp-suggested-prompts',\n label: 'MCP tutorial',\n screenId: 'mcp-suggested-prompts',\n isComplete: (s) => s.mcpSuggestedPromptsDismissed,\n },\n ],\n};\n","/**\n * Central registry of all wizard programs.\n *\n * Adding a new program:\n * 1. Create src/lib/programs/<name>/ with index.ts exporting a ProgramConfig\n * 2. Import and add it to PROGRAM_REGISTRY below\n * 3. (If custom intro screen) add to src/ui/tui/screen-registry.tsx\n *\n * screen-sequences.ts, store.ts, and bin.ts all derive their wiring from\n * this array — no need to touch those files when adding a program.\n */\n\nimport type { ProgramConfig } from './program-step.js';\nimport { posthogIntegrationConfig } from './posthog-integration/index.js';\nimport { revenueAnalyticsConfig } from './revenue-analytics/index.js';\nimport { auditConfig } from './audit/index.js';\nimport { eventsAuditConfig } from './events-audit/index.js';\nimport { audit3000Config } from './audit-3000/index.js';\nimport { posthogDoctorConfig } from './posthog-doctor/index.js';\nimport { migrationConfig } from './migration/index.js';\nimport { errorTrackingUploadSourceMapsConfig } from './error-tracking-upload-source-maps/index.js';\nimport { AGENT_SKILL_STEPS } from './agent-skill/index.js';\nimport { getContentBlocks as agentSkillContentBlocks } from './agent-skill/content/index.js';\nimport {\n mcpAddConfig,\n mcpRemoveConfig,\n mcpTutorialConfig,\n} from './mcp/index.js';\n\n// Generic skill program — invoked when the wizard runs an arbitrary\n// context-mill skill chosen at runtime (session.skillId) rather than a\n// registered named program. No CLI command, no run config.\nconst agentSkillConfig: ProgramConfig = {\n id: 'agent-skill',\n description: 'Run an arbitrary context-mill skill',\n steps: AGENT_SKILL_STEPS,\n getContentBlocks: agentSkillContentBlocks,\n allowedTools: ['Agent'],\n};\n\nexport const PROGRAM_REGISTRY = [\n posthogIntegrationConfig,\n revenueAnalyticsConfig,\n errorTrackingUploadSourceMapsConfig,\n auditConfig,\n eventsAuditConfig,\n audit3000Config,\n posthogDoctorConfig,\n migrationConfig,\n agentSkillConfig,\n mcpAddConfig,\n mcpRemoveConfig,\n mcpTutorialConfig,\n] as const satisfies readonly ProgramConfig[];\n\n/**\n * Typed program names. Values come from each config's `id`, so there's\n * no parallel string list to keep in sync — adding `Program.Foo` here is\n * just exposing `fooConfig.id` under a friendly name for call sites.\n */\nexport const Program = {\n PostHogIntegration: posthogIntegrationConfig.id,\n RevenueAnalyticsSetup: revenueAnalyticsConfig.id,\n ErrorTrackingUploadSourceMaps: errorTrackingUploadSourceMapsConfig.id,\n Migration: migrationConfig.id,\n Audit: auditConfig.id,\n EventsAudit: eventsAuditConfig.id,\n Audit3000: audit3000Config.id,\n PosthogDoctor: posthogDoctorConfig.id,\n AgentSkill: agentSkillConfig.id,\n McpAdd: mcpAddConfig.id,\n McpRemove: mcpRemoveConfig.id,\n McpTutorial: mcpTutorialConfig.id,\n} as const;\n\n/** Compile-time union of every registered program id. */\nexport type ProgramId = (typeof PROGRAM_REGISTRY)[number]['id'];\n\n/**\n * Look up a program config by its id. `ProgramId` is a union of every\n * registered id, so the lookup is statically guaranteed to find a match\n * — the `!` is a load-bearing assertion of that invariant, not a hope.\n */\nexport function getProgramConfig(id: ProgramId): ProgramConfig {\n return PROGRAM_REGISTRY.find((c) => c.id === id)!;\n}\n\n/** A program config that is exposed as a CLI subcommand. */\nexport type SubcommandProgram = ProgramConfig & { command: string };\n\n/** All program configs that are exposed as CLI subcommands. */\nexport function getSubcommandPrograms(): SubcommandProgram[] {\n return PROGRAM_REGISTRY.filter(\n (c): c is SubcommandProgram => c.command != null,\n );\n}\n","import type { Arguments } from 'yargs';\nimport { setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport { Program } from '@lib/programs/program-registry';\nimport { VERSION } from '@lib/version';\nimport type { Command } from '../command';\n\nexport const mcpAddCommand: Command = {\n name: 'add',\n description: 'Install PostHog MCP server to supported clients',\n options: {\n local: {\n default: false,\n describe: 'Add local development MCP server (http://localhost:8787)',\n type: 'boolean',\n },\n features: {\n describe: 'Comma-separated list of features to enable (default: all)',\n type: 'string',\n },\n 'api-key': {\n describe: 'PostHog personal API key (phx_xxx) for MCP authentication',\n type: 'string',\n },\n },\n handler: runMcpAdd,\n};\n\nfunction runMcpAdd(argv: Arguments): void {\n const features = parseFeatures(argv.features);\n void (async () => {\n const { readApiKeyFromEnv } = await import('@utils/env-api-key');\n const apiKey = (argv.apiKey as string | undefined) || readApiKeyFromEnv();\n const debug = argv.debug as boolean | undefined;\n const localMcp = argv.local as boolean | undefined;\n\n try {\n const { startTUI } = await import('@ui/tui/start-tui');\n const { buildSession } = await import('@lib/wizard-session');\n const tui = startTUI(VERSION, Program.McpAdd);\n tui.store.session = buildSession({\n debug,\n localMcp,\n mcpFeatures: features,\n apiKey,\n });\n } catch (error) {\n if (!isTUIUnavailable(error)) throw error;\n setUI(new LoggingUI());\n const { addMCPServerToClientsStep } = await import(\n '@steps/add-mcp-server-to-clients/index'\n );\n await addMCPServerToClientsStep({ local: localMcp, features, apiKey });\n }\n })();\n}\n\n/**\n * Ink throws \"Raw mode is not supported\" when stdin has no TTY (piped input,\n * CI, some IDE terminals). That is the only TUI failure we degrade to\n * LoggingUI for — any other error from the TUI path is a real bug and must\n * surface rather than be silently swallowed.\n */\nfunction isTUIUnavailable(error: unknown): boolean {\n return (\n error instanceof Error && /raw mode is not supported/i.test(error.message)\n );\n}\n\nfunction parseFeatures(raw: unknown): string[] | undefined {\n if (typeof raw !== 'string') return undefined;\n return raw\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n}\n","import type { Arguments } from 'yargs';\nimport { setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport { Program } from '@lib/programs/program-registry';\nimport { VERSION } from '@lib/version';\nimport type { Command } from '../command';\n\nexport const mcpRemoveCommand: Command = {\n name: 'remove',\n description: 'Remove PostHog MCP server from supported clients',\n options: {\n local: {\n default: false,\n describe: 'Remove local development MCP server (http://localhost:8787)',\n type: 'boolean',\n },\n },\n handler: runMcpRemove,\n};\n\nfunction runMcpRemove(argv: Arguments): void {\n void (async () => {\n const debug = argv.debug as boolean | undefined;\n const localMcp = argv.local as boolean | undefined;\n\n try {\n const { startTUI } = await import('@ui/tui/start-tui');\n const { buildSession } = await import('@lib/wizard-session');\n const tui = startTUI(VERSION, Program.McpRemove);\n tui.store.session = buildSession({ debug, localMcp });\n } catch {\n setUI(new LoggingUI());\n const { removeMCPServerFromClientsStep } = await import(\n '@steps/add-mcp-server-to-clients/index'\n );\n await removeMCPServerFromClientsStep({ local: localMcp });\n }\n })();\n}\n","import type { Arguments } from 'yargs';\nimport { getUI, setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport { Program } from '@lib/programs/program-registry';\nimport { VERSION } from '@lib/version';\nimport type { Command } from '../command';\n\nexport const mcpTutorialCommand: Command = {\n name: 'tutorial',\n description: 'Try the PostHog MCP with your agent (no install needed)',\n options: {\n local: {\n default: false,\n describe:\n 'Point the tutorial at the local MCP server (http://localhost:8787)',\n type: 'boolean',\n },\n },\n handler: runMcpTutorial,\n};\n\nfunction runMcpTutorial(argv: Arguments): void {\n void (async () => {\n const debug = argv.debug as boolean | undefined;\n const localMcp = argv.local as boolean | undefined;\n\n try {\n const { startTUI } = await import('@ui/tui/start-tui');\n const { buildSession } = await import('@lib/wizard-session');\n const tui = startTUI(VERSION, Program.McpTutorial);\n tui.store.session = buildSession({ debug, localMcp });\n } catch (err) {\n // TUI unavailable — the tutorial has no headless fallback.\n setUI(new LoggingUI());\n getUI().log.error(\n `The MCP tutorial requires an interactive terminal. ${\n err instanceof Error ? err.message : String(err)\n }`,\n );\n process.exit(1);\n }\n })();\n}\n","import { mcpAddCommand } from './add';\nimport { mcpRemoveCommand } from './remove';\nimport { mcpTutorialCommand } from './tutorial';\nimport type { Command } from '../command';\n\nexport const mcpCommand: Command = {\n name: 'mcp',\n description: 'MCP server management commands',\n children: [mcpAddCommand, mcpRemoveCommand, mcpTutorialCommand],\n};\n","/**\n * `--no-telemetry` flips `telemetry: false` via yargs negation;\n * `POSTHOG_WIZARD_NO_TELEMETRY` is honoured separately so the env-var\n * form documented in the README keeps working.\n */\nexport function resolveNoTelemetry(options: Record<string, unknown>): boolean {\n if (options.telemetry === false) return true;\n const env = process.env.POSTHOG_WIZARD_NO_TELEMETRY;\n if (env == null || env === '') return false;\n const norm = env.toLowerCase();\n return norm !== '0' && norm !== 'false';\n}\n","import { VERSION } from '@lib/version';\nimport { runtimeEnv } from '@env';\nimport type { ProgramConfig } from '@lib/programs/program-step';\nimport type { startTUI as StartTUIFn } from '@ui/tui/start-tui';\nimport type { TaskStreamPush as TaskStreamPushClass } from '@lib/task-stream/task-stream-push';\nimport { resolveNoTelemetry } from './resolve-no-telemetry';\n\nconst WIZARD_VERSION = VERSION;\n\n/**\n * Run a full wizard program in the TUI. Handles the full lifecycle: start TUI,\n * build session, run detection, wait for intro gate, execute the\n * agent pipeline, wait for outro dismissal, then exit.\n */\nexport function runWizard(\n config: ProgramConfig,\n options: Record<string, unknown>,\n): void {\n let tui: ReturnType<typeof StartTUIFn> | null = null;\n let taskStream: TaskStreamPushClass | null = null;\n let onSignal: (() => void) | null = null;\n let exitInProgress = false;\n\n void (async () => {\n try {\n const installDir = (options.installDir as string) || process.cwd();\n\n const { startTUI } = await import('@ui/tui/start-tui');\n const { buildSession, RunPhase } = await import('@lib/wizard-session');\n const { TaskStreamPush } = await import('@lib/task-stream/index');\n const { PostHogDestination } = await import(\n '@lib/task-stream/destinations/posthog'\n );\n const { logToFile } = await import('@utils/debug');\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n tui = startTUI(WIZARD_VERSION, config.id as any);\n const activeTui = tui;\n\n const session = buildSession({\n debug: options.debug as boolean | undefined,\n localMcp: options.localMcp as boolean | undefined,\n installDir,\n ci: false,\n signup: options.signup as boolean | undefined,\n apiKey: options.apiKey as string | undefined,\n projectId: options.projectId as string | undefined,\n email: options.email as string | undefined,\n benchmark: options.benchmark as boolean | undefined,\n yaraReport: options.yaraReport as boolean | undefined,\n noTelemetry: resolveNoTelemetry(options),\n });\n session.programLabel = config.id;\n if (options.skillId) {\n session.skillId = options.skillId as string;\n } else if (config.skillId) {\n session.skillId = config.skillId;\n }\n\n activeTui.store.session = session;\n\n const taskStreamEnabled = !session.noTelemetry;\n taskStream = new TaskStreamPush({\n store: activeTui.store,\n programId: config.id,\n destinations: [\n new PostHogDestination({\n getCredentials: () => activeTui.store.session.credentials,\n onError: (err) => logToFile('[task-stream-push]', err.message),\n }),\n ],\n enabled: taskStreamEnabled,\n });\n const activeStream = taskStream;\n activeStream.attach();\n\n // Flush a terminal-phase push on Ctrl-C so the web app sees the\n // run ended in error rather than hanging on the last \"running\"\n // snapshot.\n let signalled = false;\n onSignal = (): void => {\n if (signalled || exitInProgress) return;\n signalled = true;\n if (activeTui.store.session.runPhase === RunPhase.Running) {\n activeTui.store.setRunPhase(RunPhase.Error);\n }\n void activeStream.shutdown(2000).finally(() => {\n try {\n activeTui.unmount();\n } catch {\n // terminal may already be torn down\n }\n process.exit(130);\n });\n };\n process.on('SIGINT', onSignal);\n process.on('SIGTERM', onSignal);\n\n await activeTui.store.runReadyHooks();\n await activeTui.store.getGate('intro');\n await activeTui.store.getGate('health-check');\n\n const skipAgent = config.run == null;\n\n if (skipAgent) {\n const { getOrAskForProjectData } = await import('@utils/setup-utils');\n const { projectApiKey, host, accessToken, projectId } =\n await getOrAskForProjectData({\n signup: session.signup,\n ci: session.ci,\n apiKey: session.apiKey,\n projectId: session.projectId,\n });\n activeTui.store.setCredentials({\n accessToken,\n projectApiKey,\n host,\n projectId,\n });\n } else {\n const { runAgent } = await import('@lib/agent/agent-runner');\n await runAgent(config, activeTui.store.session);\n }\n\n const isDone = (): boolean =>\n skipAgent\n ? activeTui.store.session.outroDismissed\n : activeTui.store.session.skillsComplete;\n\n await new Promise<void>((resolve) => {\n const unsub = activeTui.store.subscribe(() => {\n if (isDone()) {\n unsub();\n resolve();\n }\n });\n if (isDone()) {\n unsub();\n resolve();\n }\n });\n\n exitInProgress = true;\n await activeStream.shutdown(2000);\n process.off('SIGINT', onSignal);\n process.off('SIGTERM', onSignal);\n activeTui.unmount();\n process.exit(0);\n } catch (err) {\n if (runtimeEnv('DEBUG') || runtimeEnv('POSTHOG_WIZARD_DEBUG')) {\n // eslint-disable-next-line no-console\n console.error('TUI init failed:', err);\n }\n // The task-stream debounce timer keeps the event loop alive, so\n // we have to drain it before exiting on the error path.\n exitInProgress = true;\n if (onSignal) {\n process.off('SIGINT', onSignal);\n process.off('SIGTERM', onSignal);\n }\n if (taskStream) {\n try {\n await taskStream.shutdown(2000);\n } catch {\n // ignore\n }\n }\n if (tui) {\n try {\n tui.unmount();\n } catch {\n // ignore\n }\n }\n process.exit(1);\n }\n })();\n}\n","import { POSTHOG_DOCS_URL } from '@lib/constants';\nimport { getUI, setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport type { ProgramConfig } from '@lib/programs/program-step';\nimport { resolveNoTelemetry } from './resolve-no-telemetry';\n\n/**\n * The single CI validation layer: defaults region and requires api-key and\n * install-dir. Every CI entry point routes through `runWizardCI`, so this is\n * the one place these checks live. UI must be initialized before calling.\n */\nexport function validateCiOptions(options: Record<string, unknown>): void {\n if (!options.region) options.region = 'us';\n if (!options.apiKey) {\n getUI().intro('PostHog Wizard');\n getUI().log.error('CI mode requires --api-key (personal API key phx_xxx)');\n process.exit(1);\n }\n if (!options.installDir) {\n getUI().intro('PostHog Wizard');\n getUI().log.error(\n 'CI mode requires --install-dir (directory to install in)',\n );\n process.exit(1);\n }\n}\n\n/**\n * CI-mode pipeline shared by every non-interactive entry point.\n *\n * Validates flags, builds a `ci:true` session, runs `config.ciPreRun` (or the\n * program's `onReady` hooks by default), executes `runAgent`, and routes any\n * failure through `wizardAbort`. `wizardAbort` owns all exits — never add a\n * raw `process.exit` here.\n */\nexport function runWizardCI(\n config: ProgramConfig,\n options: Record<string, unknown>,\n): void {\n setUI(new LoggingUI());\n validateCiOptions(options);\n\n void (async () => {\n const path = await import('path');\n const { buildSession } = await import('@lib/wizard-session');\n const { readEnvironment } = await import('@utils/environment');\n const { readApiKeyFromEnv } = await import('@utils/env-api-key');\n const { configureLogFileFromEnvironment, logToFile } = await import(\n '@utils/debug'\n );\n const { wizardAbort, WizardError } = await import('@utils/wizard-abort');\n\n configureLogFileFromEnvironment();\n\n const env = readEnvironment();\n const apiKey =\n (options.apiKey as string) ?? readApiKeyFromEnv() ?? undefined;\n const installDir = path.isAbsolute(options.installDir as string)\n ? (options.installDir as string)\n : path.join(process.cwd(), options.installDir as string);\n\n const session = buildSession({\n debug: options.debug as boolean | undefined,\n installDir,\n ci: true,\n signup: options.signup as boolean | undefined,\n localMcp: options.localMcp as boolean | undefined,\n apiKey,\n email: options.email as string | undefined,\n projectId: options.projectId as string | undefined,\n benchmark: options.benchmark as boolean | undefined,\n yaraReport: options.yaraReport as boolean | undefined,\n noTelemetry: resolveNoTelemetry(options),\n ...env,\n });\n session.programLabel = config.id;\n if (config.skillId) {\n session.skillId = config.skillId;\n }\n const runDef = typeof config.run === 'object' ? config.run : null;\n\n getUI().intro('Welcome to the PostHog setup wizard');\n getUI().log.info(`Running ${config.id} in CI mode`);\n\n try {\n if (config.ciPreRun) {\n await config.ciPreRun(session);\n } else {\n const readyCtx = {\n session,\n setFrameworkContext: (key: string, value: unknown) => {\n session.frameworkContext[key] = value;\n },\n setFrameworkConfig: () => undefined,\n setDetectedFramework: () => undefined,\n setUnsupportedVersion: () => undefined,\n addDiscoveredFeature: () => undefined,\n setDetectionComplete: () => undefined,\n };\n for (const step of config.steps) {\n if (step.onReady) {\n await step.onReady(readyCtx);\n }\n }\n\n const detectError = session.frameworkContext.detectError as\n | { kind: string; [k: string]: unknown }\n | undefined;\n if (detectError) {\n await wizardAbort({\n message: `Prerequisites not met: ${detectError.kind}\\n\\nSee ${\n runDef?.docsUrl ?? POSTHOG_DOCS_URL\n }`,\n error: new WizardError(`${config.id} prerequisites failed`, {\n integration: config.id,\n detect_error_kind: detectError.kind,\n }),\n });\n }\n }\n\n const { runAgent } = await import('@lib/agent/agent-runner');\n await runAgent(config, session);\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const errorStack =\n error instanceof Error && error.stack ? error.stack : undefined;\n\n logToFile(`[bin.ts CI] ERROR: ${errorMessage}`);\n if (errorStack) logToFile(`[bin.ts CI] STACK: ${errorStack}`);\n\n const debugInfo = session.debug && errorStack ? `\\n\\n${errorStack}` : '';\n const docsUrl =\n session.frameworkConfig?.metadata.docsUrl ??\n runDef?.docsUrl ??\n POSTHOG_DOCS_URL;\n await wizardAbort({\n message: `Something went wrong: ${errorMessage}\\n\\nYou can read the documentation at ${docsUrl} to set up manually.${debugInfo}`,\n error: error as Error,\n });\n }\n })().catch(() => {\n process.exit(1);\n });\n}\n","/** Flags shared by every skill-based program command (integrate, audit, …). */\nexport const skillProgramOptions = {\n debug: {\n default: false,\n describe: 'Enable verbose logging',\n type: 'boolean' as const,\n },\n 'install-dir': {\n describe: 'Directory to install in',\n type: 'string' as const,\n },\n 'local-mcp': {\n default: false,\n describe: 'Use local MCP server',\n type: 'boolean' as const,\n },\n benchmark: {\n default: false,\n describe: 'Run in benchmark mode',\n type: 'boolean' as const,\n },\n 'yara-report': {\n default: false,\n describe: 'Print YARA scanner summary',\n type: 'boolean' as const,\n hidden: true,\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const integrateCommand: Command = {\n name: 'integrate',\n description: posthogIntegrationConfig.description,\n options: {\n ...skillProgramOptions,\n ...(posthogIntegrationConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n posthogIntegrationConfig.mapCliOptions?.(\n argv as Record<string, unknown>,\n ) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(posthogIntegrationConfig, options);\n } else {\n runWizard(posthogIntegrationConfig, options);\n }\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { auditConfig } from '@lib/programs/audit/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const auditCommand: Command = {\n name: 'audit',\n description: auditConfig.description,\n options: {\n ...skillProgramOptions,\n ...(auditConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n auditConfig.mapCliOptions?.(argv as Record<string, unknown>) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(auditConfig, options);\n } else {\n runWizard(auditConfig, options);\n }\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { audit3000Config } from '@lib/programs/audit-3000/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const audit3000Command: Command = {\n name: 'audit-3000',\n description: audit3000Config.description,\n options: {\n ...skillProgramOptions,\n ...(audit3000Config.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n audit3000Config.mapCliOptions?.(argv as Record<string, unknown>) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(audit3000Config, options);\n } else {\n runWizard(audit3000Config, options);\n }\n },\n};\n","import { getUI, setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport { readApiKeyFromEnv } from '@utils/env-api-key';\nimport { runWizard } from '@lib/runners';\nimport {\n posthogDoctorConfig,\n fetchHealthIssues,\n getKindMeta,\n} from '@lib/programs/posthog-doctor/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const doctorCommand: Command = {\n name: 'doctor',\n description: posthogDoctorConfig.description,\n options: {\n ...skillProgramOptions,\n ...(posthogDoctorConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n posthogDoctorConfig.mapCliOptions?.(argv as Record<string, unknown>) ??\n {};\n const options = { ...argv, ...extras };\n // doctor is otherwise a TUI-only diagnostic (it has no agent run); in CI we\n // fetch the project's health issues headlessly and report them instead.\n if (options.ci) {\n void runDoctorCI(options);\n } else {\n runWizard(posthogDoctorConfig, options);\n }\n },\n};\n\nconst SEVERITY_ORDER = { critical: 0, warning: 1, info: 2 } as const;\n\nasync function runDoctorCI(options: Record<string, unknown>): Promise<void> {\n setUI(new LoggingUI());\n const apiKey = (options.apiKey as string) ?? readApiKeyFromEnv() ?? undefined;\n if (!apiKey) {\n getUI().intro('PostHog Wizard');\n getUI().log.error('CI mode requires --api-key (personal API key phx_xxx)');\n process.exit(1);\n }\n\n getUI().intro('Welcome to the PostHog setup wizard');\n getUI().log.info('Running posthog-doctor in CI mode');\n\n try {\n const { getOrAskForProjectData } = await import('@utils/setup-utils');\n const { host, accessToken, projectId } = await getOrAskForProjectData({\n signup: false,\n ci: true,\n apiKey,\n projectId: options.projectId\n ? Number(options.projectId as string)\n : undefined,\n });\n\n const issues = await fetchHealthIssues(accessToken, host, projectId);\n if (issues.length === 0) {\n getUI().log.success('No active issues — your project looks healthy.');\n process.exit(0);\n }\n\n const sorted = [...issues].sort(\n (a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity],\n );\n getUI().log.warn(\n `${issues.length} active issue${issues.length === 1 ? '' : 's'} found:`,\n );\n for (const issue of sorted) {\n getUI().log.info(\n ` • [${issue.severity}] ${getKindMeta(issue.kind).title}`,\n );\n }\n process.exit(1);\n } catch (error) {\n const { ApiError } = await import('@lib/api');\n const message =\n error instanceof ApiError && error.statusCode === 401\n ? 'Your PostHog API key is invalid or expired.'\n : error instanceof Error\n ? error.message\n : String(error);\n getUI().log.error(`Doctor failed: ${message}`);\n process.exit(1);\n }\n}\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { migrationConfig } from '@lib/programs/migration/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const migrateCommand: Command = {\n name: 'migrate',\n description: migrationConfig.description,\n options: {\n ...skillProgramOptions,\n ...(migrationConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n migrationConfig.mapCliOptions?.(argv as Record<string, unknown>) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(migrationConfig, options);\n } else {\n runWizard(migrationConfig, options);\n }\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { eventsAuditConfig } from '@lib/programs/events-audit/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const eventsAuditCommand: Command = {\n name: 'events-audit',\n description: eventsAuditConfig.description,\n options: {\n ...skillProgramOptions,\n ...(eventsAuditConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n eventsAuditConfig.mapCliOptions?.(argv as Record<string, unknown>) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(eventsAuditConfig, options);\n } else {\n runWizard(eventsAuditConfig, options);\n }\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { revenueAnalyticsConfig } from '@lib/programs/revenue-analytics/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const revenueCommand: Command = {\n name: 'revenue',\n description: revenueAnalyticsConfig.description,\n options: {\n ...skillProgramOptions,\n ...(revenueAnalyticsConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n revenueAnalyticsConfig.mapCliOptions?.(argv as Record<string, unknown>) ??\n {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(revenueAnalyticsConfig, options);\n } else {\n runWizard(revenueAnalyticsConfig, options);\n }\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { errorTrackingUploadSourceMapsConfig } from '@lib/programs/error-tracking-upload-source-maps/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const uploadSourcemapsCommand: Command = {\n name: 'upload-sourcemaps',\n description: errorTrackingUploadSourceMapsConfig.description,\n options: {\n ...skillProgramOptions,\n ...(errorTrackingUploadSourceMapsConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n errorTrackingUploadSourceMapsConfig.mapCliOptions?.(\n argv as Record<string, unknown>,\n ) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(errorTrackingUploadSourceMapsConfig, options);\n } else {\n runWizard(errorTrackingUploadSourceMapsConfig, options);\n }\n },\n};\n","#!/usr/bin/env node\nimport { satisfies } from 'semver';\n\nconst NODE_VERSION_RANGE = '>=18.17.0';\n\n// Have to run this above the other imports because they are importing clack that\n// has the problematic imports.\nif (!satisfies(process.version, NODE_VERSION_RANGE)) {\n // eslint-disable-next-line no-console\n console.log(\n `PostHog wizard requires Node.js ${NODE_VERSION_RANGE}. You are using Node.js ${process.version}. Please upgrade your Node.js version.`,\n );\n process.exit(1);\n}\n\n// Test mock server — only loaded when NODE_ENV is 'test'.\n// In production builds, tsdown replaces process.env.NODE_ENV with 'production',\n// making this block dead code.\nif (process.env.NODE_ENV === 'test') {\n void (async () => {\n try {\n const { server } = await import('./e2e-tests/mocks/server.js');\n server.listen({\n onUnhandledRequest: 'bypass',\n });\n } catch (error) {\n // Mock server import failed - this can happen during non-E2E tests\n }\n })();\n}\n\nimport { Wizard } from './src/wizard';\nimport { basicIntegrationCommand } from './src/commands/basic-integration';\nimport { mcpCommand } from './src/commands/mcp';\nimport { integrateCommand } from './src/commands/integrate';\nimport { auditCommand } from './src/commands/audit';\nimport { audit3000Command } from './src/commands/audit-3000';\nimport { doctorCommand } from './src/commands/doctor';\nimport { migrateCommand } from './src/commands/migrate';\nimport { eventsAuditCommand } from './src/commands/events-audit';\nimport { revenueCommand } from './src/commands/revenue';\nimport { uploadSourcemapsCommand } from './src/commands/upload-sourcemaps';\n\nWizard.use(basicIntegrationCommand)\n .use(mcpCommand)\n .use(integrateCommand)\n .use(auditCommand)\n .use(audit3000Command)\n .use(doctorCommand)\n .use(migrateCommand)\n .use(eventsAuditCommand)\n .use(revenueCommand)\n .use(uploadSourcemapsCommand)\n .init();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,YAAY,MAA4C;AAEtE,SADgC,OAAO,SAAS,WAAW,CAAC,KAAK,GAAG,MACxD,KAAK,MAAM,EAAE,MAAM,CAAC,MAAM,MAAM,CAAC,GAAG;;AAGlD,SAAgB,gBACd,KACA,YACe;AACf,QAAO;EACL,SAAS,IAAI;EACb,UAAU,IAAI;EACd,UAAU,MAAY;GACpB,IAAI,OAAO,IAAI,UAAU,EAAE,QAAQ,IAAI,QAAQ,GAAG;AAClD,OAAI,IAAI,MAAO,QAAO,KAAK,MAAM,IAAI,MAAM;AAC3C,QAAK,MAAM,CAAC,OAAO,gBAAgB,IAAI,YAAY,EAAE,CACnD,QAAO,KAAK,QAAQ,OAAO,YAAY;GAEzC,MAAM,UAAU,CAAC,GAAG,YAAY,YAAY,IAAI,KAAK,CAAC,GAAG;AACzD,QAAK,MAAM,SAAS,IAAI,YAAY,EAAE,CACpC,QAAO,KAAK,QAAQ,gBAAgB,OAAO,QAAQ,CAAC;AAEtD,OAAI,IAAI,UAAU,UAAU,CAAC,IAAI,QAC/B,QAAO,KAAK,cAAc,EAAE;AAE9B,UAAO;;EAET,SAAS,IAAI,kBAAkB,KAAA;EAChC;;;;;;;;AChDH,MAAa,iBAAiB;CAC5B,OAAO;EACL,SAAS;EACT,UAAU;EACV,MAAM;EACP;CACD,QAAQ;EACN,UAAU;EACV,SAAS,CAAC,MAAM,KAAK;EACrB,MAAM;EACP;CACD,QAAQ;EACN,SAAS;EACT,UACE;EACF,MAAM;EACP;CACD,aAAa;EACX,SAAS;EACT,UACE;EACF,MAAM;EACP;CACD,WAAW;EACT,SAAS;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POSTHOG_SDKS","getContentBlocks","baseConfig","DOCS_URL","REPORT_FILE","DOCS_URL","getContentBlocks","agentSkillContentBlocks"],"sources":["../src/commands/command.ts","../src/wizard.ts","../src/commands/provision.ts","../src/commands/basic-integration/index.ts","../src/lib/programs/shared/package-scanning.ts","../src/lib/programs/revenue-analytics/detect.ts","../src/lib/programs/revenue-analytics/steps.ts","../src/lib/programs/agent-skill/content/index.tsx","../src/lib/programs/revenue-analytics/index.ts","../src/lib/programs/agent-skill/steps.ts","../src/lib/programs/agent-skill/index.ts","../src/lib/programs/audit/detect.ts","../src/lib/programs/audit/seed.ts","../src/lib/programs/audit/index.ts","../src/lib/programs/events-audit/steps.ts","../src/lib/programs/events-audit/seed.ts","../src/lib/programs/events-audit/index.ts","../src/lib/programs/audit-3000/index.ts","../src/lib/programs/posthog-doctor/steps.ts","../src/lib/programs/posthog-doctor/types.ts","../src/lib/programs/posthog-doctor/fetch.ts","../src/lib/programs/posthog-doctor/kind-metadata.ts","../src/lib/programs/posthog-doctor/index.ts","../src/lib/programs/web-analytics-doctor/detect.ts","../src/lib/programs/web-analytics-doctor/steps.ts","../src/lib/programs/web-analytics-doctor/index.ts","../src/lib/programs/migration/steps.ts","../src/lib/programs/migration/content/vendor-stack.tsx","../src/lib/programs/migration/content/free-tier.tsx","../src/lib/programs/migration/content/pricing-structure.tsx","../src/lib/programs/migration/content/index.tsx","../src/lib/programs/migration/index.ts","../src/lib/programs/error-tracking-upload-source-maps/detect.ts","../src/lib/programs/error-tracking-upload-source-maps/steps.ts","../src/lib/programs/error-tracking-upload-source-maps/prompt.ts","../src/lib/programs/error-tracking-upload-source-maps/content/index.tsx","../src/lib/programs/error-tracking-upload-source-maps/index.ts","../src/lib/programs/mcp/index.ts","../src/lib/programs/program-registry.ts","../src/commands/mcp/add.ts","../src/commands/mcp/remove.ts","../src/commands/mcp/tutorial.ts","../src/commands/mcp/index.ts","../src/lib/runners/resolve-no-telemetry.ts","../src/lib/runners/run-wizard.ts","../src/lib/runners/run-wizard-ci.ts","../src/commands/skill-program-options.ts","../src/commands/integrate.ts","../src/commands/audit.ts","../src/commands/audit-3000.ts","../src/commands/doctor.ts","../src/commands/migrate.ts","../src/commands/events-audit.ts","../src/commands/revenue.ts","../src/commands/upload-sourcemaps.ts","../src/commands/basic-integration/skill.ts","../src/commands/skill.ts","../bin.ts"],"sourcesContent":["import type { Arguments, Argv, CommandModule, Options } from 'yargs';\n\nexport interface Command {\n /** Yargs command name. Use `['$0']` for the default command. */\n name: string | readonly string[];\n description: string;\n /** Flags exposed by this command. Same shape as yargs `.options()`. */\n options?: Record<string, Options>;\n /** Nested subcommands. */\n children?: readonly Command[];\n /** `--help` examples shown for this command. */\n examples?: ReadonlyArray<readonly [string, string]>;\n /**\n * Called synchronously by yargs when the command matches. Wrap async work in\n * `void (async () => { ... })()`. Optional only when `children` is set — in\n * that case yargs requires the user to pick a subcommand.\n */\n handler?: (argv: Arguments) => void;\n /**\n * Cross-flag validation run by yargs after parsing. Throw to reject (yargs\n * prints the message and exits non-zero); return `true` to accept. Prefer\n * this over per-option `conflicts` for mutually exclusive flags: yargs\n * counts a `default`-valued flag as \"present\", so `conflicts` misfires on\n * boolean flags that default to `false` — a hand-written predicate only\n * sees what you test for (e.g. truthiness).\n */\n check?: (argv: Arguments) => boolean;\n}\n\n/** Extract the bare command word(s) from a yargs name spec, dropping positionals and aliases' arg syntax. */\nexport function commandKeys(name: string | readonly string[]): string[] {\n const list: readonly string[] = typeof name === 'string' ? [name] : name;\n return list.map((n) => n.trim().split(/\\s+/)[0]);\n}\n\nexport function toCommandModule(\n cmd: Command,\n parentPath: readonly string[],\n): CommandModule {\n return {\n command: cmd.name,\n describe: cmd.description,\n builder: (y: Argv) => {\n let next = cmd.options ? y.options(cmd.options) : y;\n if (cmd.check) next = next.check(cmd.check);\n for (const [usage, description] of cmd.examples ?? []) {\n next = next.example(usage, description);\n }\n const ownPath = [...parentPath, commandKeys(cmd.name)[0]];\n for (const child of cmd.children ?? []) {\n next = next.command(toCommandModule(child, ownPath));\n }\n if (cmd.children?.length && !cmd.handler) {\n next = next.demandCommand(1);\n }\n return next;\n },\n handler: cmd.handler ?? (() => undefined),\n };\n}\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport type { Argv } from 'yargs';\nimport { IS_PRODUCTION_BUILD } from '@env';\nimport { toCommandModule, type Command } from './commands/command';\n\n/**\n * Global yargs options applied to every command. These are read from the\n * `POSTHOG_WIZARD` env prefix as well as flags.\n */\nexport const GLOBAL_OPTIONS = {\n debug: {\n default: false,\n describe: 'Enable verbose logging\\nenv: POSTHOG_WIZARD_DEBUG',\n type: 'boolean' as const,\n },\n region: {\n describe: 'PostHog cloud region\\nenv: POSTHOG_WIZARD_REGION',\n choices: ['us', 'eu'] as const,\n type: 'string' as const,\n },\n signup: {\n default: false,\n describe:\n 'Create a new PostHog account during setup\\nenv: POSTHOG_WIZARD_SIGNUP',\n type: 'boolean' as const,\n },\n 'local-mcp': {\n default: false,\n describe:\n 'Use local MCP server at http://localhost:8787/mcp\\nenv: POSTHOG_WIZARD_LOCAL_MCP',\n type: 'boolean' as const,\n },\n telemetry: {\n default: true,\n describe:\n 'Send wizard run state to PostHog (pass --no-telemetry to disable)\\nenv: POSTHOG_WIZARD_TELEMETRY',\n type: 'boolean' as const,\n },\n 'api-key': {\n describe:\n 'PostHog personal API key (phx_xxx) for authentication\\nenv: POSTHOG_WIZARD_API_KEY',\n type: 'string' as const,\n },\n 'project-id': {\n describe:\n 'PostHog project ID to use (optional; when not set, uses default from API key or OAuth)\\nenv: POSTHOG_WIZARD_PROJECT_ID',\n type: 'string' as const,\n },\n email: {\n describe:\n 'Email address for signup (used with --signup)\\nenv: POSTHOG_WIZARD_EMAIL',\n type: 'string' as const,\n },\n};\n\nexport class Wizard {\n private cli: Argv;\n\n private constructor() {\n let cli = yargs(hideBin(process.argv))\n .env('POSTHOG_WIZARD')\n .options(GLOBAL_OPTIONS);\n\n // CI mode (--ci) is only supported in dev/test. It is left undeclared in\n // published builds (NODE_ENV==='production'), so .strictOptions() rejects\n // it there as an unknown argument — exactly like any other unrecognized\n // flag. init() additionally detects it up front to print a clearer message.\n if (!IS_PRODUCTION_BUILD) {\n cli = cli.option('ci', {\n default: false,\n describe:\n 'Enable CI mode for non-interactive execution\\nenv: POSTHOG_WIZARD_CI',\n type: 'boolean',\n });\n }\n\n this.cli = cli\n .strictOptions()\n // Print the error first (bright red) and the usage below it, instead of\n // yargs' default of burying the message under the full help output.\n .fail((msg, err, parser) => {\n const text = msg || (err && err.message) || 'Invalid arguments';\n process.stderr.write(`\\n\\x1b[1;91m✖ ${text}\\x1b[0m\\n\\n`);\n parser.showHelp();\n process.exit(1);\n })\n .help()\n .alias('help', 'h')\n .version()\n .alias('version', 'v');\n }\n\n /** Start a chain; equivalent to `new Wizard().use(...cmds)`. */\n static use(...cmds: Command[]): Wizard {\n return new Wizard().use(...cmds);\n }\n\n /** Register one or more commands with yargs. */\n use(...cmds: Command[]): this {\n for (const cmd of cmds) {\n this.cli = this.cli.command(toCommandModule(cmd, []));\n }\n return this;\n }\n\n /** Parse argv and dispatch to the matching registered command. */\n init(): void {\n // In published builds, `--ci` is undeclared, so yargs would reject it as\n // an unknown argument — accurate but unhelpful, since --help doesn't list\n // --ci either and the user has no path forward. POSTHOG_WIZARD_CI silently\n // no-ops for the same reason (yargs only resolves env vars for declared\n // options). Detect both up front and exit with a message that explains why.\n if (IS_PRODUCTION_BUILD) {\n const args = process.argv.slice(2);\n const argvHasCI = args.some(\n (a) => a === '--ci' || a === '--no-ci' || a.startsWith('--ci='),\n );\n const envHasCI =\n process.env.POSTHOG_WIZARD_CI != null &&\n process.env.POSTHOG_WIZARD_CI !== '';\n if (argvHasCI || envHasCI) {\n process.stderr.write(\n `\\n\\x1b[1;91m✖ CI mode is not currently supported in published builds.\\x1b[0m\\n\\n`,\n );\n process.exit(1);\n }\n }\n void this.cli.wrap(process.stdout.isTTY ? this.cli.terminalWidth() : 80)\n .argv;\n }\n}\n","import type { Arguments } from 'yargs';\nimport { getUI, setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport type { ProvisioningResult } from '@utils/provisioning';\nimport type { Command } from './command';\n\nexport const provisionCommand: Command = {\n name: 'provision',\n description: 'Create a new PostHog account (headless, no TUI)',\n options: {\n email: {\n describe: 'Email address for the new account',\n type: 'string',\n demandOption: true,\n },\n region: {\n describe: 'Cloud region (us or eu)',\n choices: ['us', 'eu'] as const,\n default: 'us',\n },\n name: {\n describe: 'Name for the new account',\n type: 'string',\n default: '',\n },\n json: {\n describe:\n 'Emit JSON result to stdout (defaults to true when stdout is not a TTY)',\n type: 'boolean',\n },\n },\n examples: [\n ['wizard provision --email matt+test@posthog.com --region us', ''],\n ['wizard provision --email user@example.com --region eu --json', ''],\n ],\n handler: runProvision,\n};\n\nfunction runProvision(argv: Arguments): void {\n const jsonMode =\n argv.json === undefined ? !process.stdout.isTTY : Boolean(argv.json);\n if (!jsonMode) setUI(new LoggingUI());\n\n void provision({\n email: argv.email as string,\n region: (argv.region as string).toUpperCase() as 'US' | 'EU',\n name: (argv.name as string) ?? '',\n jsonMode,\n });\n}\n\ntype ProvisionArgs = {\n email: string;\n region: 'US' | 'EU';\n name: string;\n jsonMode: boolean;\n};\n\nasync function provision({\n email,\n region,\n name,\n jsonMode,\n}: ProvisionArgs): Promise<void> {\n try {\n const { provisionNewAccount } = await import('@utils/provisioning');\n if (!jsonMode) {\n getUI().log.info(`Provisioning account for ${email} in ${region}...`);\n }\n const result = await provisionNewAccount(email, name, region);\n emitResult(result, jsonMode);\n process.exit(0);\n } catch (error) {\n emitError(error, jsonMode);\n process.exit(1);\n }\n}\n\nfunction emitResult(result: ProvisioningResult, jsonMode: boolean): void {\n if (jsonMode) {\n process.stdout.write(`${JSON.stringify(result)}\\n`);\n return;\n }\n getUI().log.success('Account provisioned successfully:');\n getUI().log.info(` API Key: ${result.projectApiKey}`);\n getUI().log.info(` Host: ${result.host}`);\n getUI().log.info(` Project ID: ${result.projectId}`);\n getUI().log.info(` Account ID: ${result.accountId}`);\n getUI().log.info(` Access Token: ${result.accessToken}`);\n getUI().log.info(` Refresh Token: ${result.refreshToken}`);\n if (result.personalApiKey) {\n getUI().log.info(` Personal API Key: ${result.personalApiKey}`);\n }\n}\n\nfunction emitError(error: unknown, jsonMode: boolean): void {\n const msg = error instanceof Error ? error.message : String(error);\n const code = msg.includes('already associated')\n ? 'email_exists'\n : 'provisioning_failed';\n if (jsonMode) {\n process.stderr.write(`${JSON.stringify({ error: msg, code })}\\n`);\n return;\n }\n getUI().log.error(`Provisioning failed: ${msg}`);\n}\n","import { isNonInteractiveEnvironment } from '@utils/environment';\nimport { provisionCommand } from '../provision';\nimport type { Command } from '../command';\n\nexport const basicIntegrationCommand: Command = {\n name: ['$0'],\n description: 'Run the PostHog setup wizard',\n // provision is a one-shot HTTP call tied to the base flow, not a wizard\n // program — it rides under the base command rather than as a peer.\n children: [provisionCommand],\n options: {\n 'install-dir': {\n describe:\n 'Directory to install PostHog in\\nenv: POSTHOG_WIZARD_INSTALL_DIR',\n type: 'string',\n },\n playground: {\n default: false,\n describe: 'Launch the TUI primitives playground',\n type: 'boolean',\n },\n benchmark: {\n default: false,\n describe:\n 'Run in benchmark mode with per-phase token tracking\\nenv: POSTHOG_WIZARD_BENCHMARK',\n type: 'boolean',\n },\n 'yara-report': {\n default: false,\n describe:\n 'Print YARA scanner summary after the agent run\\nenv: POSTHOG_WIZARD_YARA_REPORT',\n type: 'boolean',\n hidden: true,\n },\n name: {\n describe:\n 'Name for account creation with --ci --signup\\nenv: POSTHOG_WIZARD_NAME',\n type: 'string',\n },\n },\n check: (argv) => {\n // --playground is the standalone TUI demo; it can't combine with --ci.\n if (argv.playground && argv.ci) {\n throw new Error('--playground cannot be combined with --ci.');\n }\n return true;\n },\n handler: (argv) => {\n // Each mode file is loaded only when its branch is taken, so a plain\n // `npx @posthog/wizard` never pulls in the CI or playground paths.\n void (async () => {\n if (argv.ci) {\n const { runCIInstall } = await import('./ci-install');\n return runCIInstall(argv);\n }\n if (isNonInteractiveEnvironment()) {\n const { failNonInteractive } = await import('./non-interactive');\n return failNonInteractive();\n }\n if (argv.playground) {\n const { runPlayground } = await import('./playground');\n return runPlayground();\n }\n const { runInteractive } = await import('./interactive');\n runInteractive(argv);\n })();\n },\n};\n","import type { Dirent } from 'fs';\nimport { readFileSync, readdirSync } from 'fs';\nimport { join, relative } from 'path';\nimport { IGNORED_DIRS } from '@utils/file-utils';\n\nexport const POSTHOG_SDKS = [\n 'posthog-js',\n 'posthog-node',\n 'posthog-react-native',\n 'posthog-android',\n 'posthog-ios',\n];\n\nexport const STRIPE_SDKS = [\n 'stripe',\n '@stripe/stripe-js',\n '@stripe/react-stripe-js',\n];\n\nexport interface PackageMatch {\n /** Path to the package.json relative to installDir */\n path: string;\n posthogSdks: string[];\n stripeSdks: string[];\n}\n\n/**\n * Recursively find all package.json files under installDir (max depth 3),\n * skipping common ignored directories. Returns matches with detected SDKs.\n */\nexport function findPackageJsons(\n installDir: string,\n maxDepth = 3,\n): PackageMatch[] {\n const matches: PackageMatch[] = [];\n\n function scan(dir: string, depth: number): void {\n if (depth > maxDepth) return;\n\n let entries: Dirent[];\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (entry.name.startsWith('.') && entry.name !== '.') continue;\n if (IGNORED_DIRS.has(entry.name)) continue;\n\n const fullPath = join(dir, entry.name);\n\n if (entry.isFile() && entry.name === 'package.json') {\n try {\n const pkg = JSON.parse(readFileSync(fullPath, 'utf-8')) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n const depNames = [\n ...Object.keys(pkg.dependencies ?? {}),\n ...Object.keys(pkg.devDependencies ?? {}),\n ];\n const posthogSdks = depNames.filter((d) => POSTHOG_SDKS.includes(d));\n const stripeSdks = depNames.filter((d) => STRIPE_SDKS.includes(d));\n matches.push({\n path: relative(installDir, fullPath) || 'package.json',\n posthogSdks,\n stripeSdks,\n });\n } catch {\n // Skip malformed package.json\n }\n } else if (entry.isDirectory()) {\n scan(fullPath, depth + 1);\n }\n }\n }\n\n scan(installDir, 0);\n return matches;\n}\n","/**\n * Revenue analytics prerequisite detection.\n *\n * Scans the project for PostHog + Stripe SDKs and writes results\n * into frameworkContext for the intro screen to render.\n */\n\nimport { existsSync, statSync } from 'fs';\nimport type { WizardSession } from '@lib/wizard-session';\nimport type { AbortCase } from '@lib/agent/agent-runner';\nimport { findPackageJsons } from '@lib/programs/shared/package-scanning';\n\nexport {\n findPackageJsons,\n POSTHOG_SDKS,\n STRIPE_SDKS,\n type PackageMatch,\n} from '@lib/programs/shared/package-scanning';\n\n/**\n * Structured detection errors. The screen renders each kind into JSX\n * with proper formatting — keeps error data separate from presentation.\n */\nexport type RevenueDetectError =\n | {\n kind: 'bad-directory';\n path: string;\n reason: 'missing' | 'not-dir' | 'unreadable';\n }\n | { kind: 'no-package-json' }\n | { kind: 'no-sdks'; scannedCount: number }\n | { kind: 'missing-posthog'; foundStripe: string[] }\n | { kind: 'missing-stripe'; foundPosthog: string[] };\n\n/** `[ABORT] <reason>` cases the revenue analytics skill can emit. */\nexport const REVENUE_ABORT_CASES: AbortCase[] = [\n {\n // Skill emits: [ABORT] Could not find a PostHog distinct_id\n match: /^could not find a posthog distinct_id$/i,\n message: 'Could not find a PostHog distinct_id',\n body:\n 'The agent could not find PostHog distinct_id usage in your codebase. ' +\n 'Your users must be identified in PostHog before they can be tagged in Stripe. ' +\n 'Please identify your users and try again.',\n docsUrl: 'https://posthog.com/docs/product-analytics/identify',\n },\n {\n // Skill emits: [ABORT] Could not find a Stripe integration\n match: /^could not find a stripe integration$/i,\n message: 'Could not find a Stripe integration',\n body:\n 'The Wizard could not find an existing Stripe customer, charge, ' +\n 'subscription, or other Stripe operations. Please run the Revenue ' +\n 'Analytics Wizard on a project with an existing Stripe integration.',\n docsUrl: 'https://posthog.com/docs/revenue-analytics',\n },\n];\n\n/**\n * Scan `session.installDir` for PostHog + Stripe SDKs. Writes detection\n * results into frameworkContext via the callback — either the detected\n * SDK lists (for the intro screen) or a `RevenueDetectError` on failure.\n *\n * The skill install happens later in the bootstrap runner, not here.\n */\nexport function detectRevenuePrerequisites(\n session: WizardSession,\n setFrameworkContext: (key: string, value: unknown) => void,\n): void {\n const fail = (error: RevenueDetectError) =>\n setFrameworkContext('detectError', error);\n\n const installDir = session.installDir;\n\n // Verify the install directory exists and is readable\n if (!existsSync(installDir)) {\n fail({ kind: 'bad-directory', path: installDir, reason: 'missing' });\n return;\n }\n try {\n if (!statSync(installDir).isDirectory()) {\n fail({ kind: 'bad-directory', path: installDir, reason: 'not-dir' });\n return;\n }\n } catch {\n fail({ kind: 'bad-directory', path: installDir, reason: 'unreadable' });\n return;\n }\n\n // Find all package.json files (root + monorepo subpackages)\n const matches = findPackageJsons(installDir);\n\n if (matches.length === 0) {\n fail({ kind: 'no-package-json' });\n return;\n }\n\n // Aggregate detected SDKs across all package.json files\n const allPosthogSdks = new Set<string>();\n const allStripeSdks = new Set<string>();\n for (const match of matches) {\n for (const sdk of match.posthogSdks) allPosthogSdks.add(sdk);\n for (const sdk of match.stripeSdks) allStripeSdks.add(sdk);\n }\n\n const detectedPosthogSdks = [...allPosthogSdks];\n const detectedStripeSdks = [...allStripeSdks];\n\n if (detectedPosthogSdks.length === 0 && detectedStripeSdks.length === 0) {\n fail({ kind: 'no-sdks', scannedCount: matches.length });\n return;\n }\n\n if (detectedPosthogSdks.length === 0) {\n fail({ kind: 'missing-posthog', foundStripe: detectedStripeSdks });\n return;\n }\n\n if (detectedStripeSdks.length === 0) {\n fail({ kind: 'missing-stripe', foundPosthog: detectedPosthogSdks });\n return;\n }\n\n setFrameworkContext('detectedPosthogSdks', detectedPosthogSdks);\n setFrameworkContext('detectedStripeSdks', detectedStripeSdks);\n setFrameworkContext(\n 'detectedPackagePaths',\n matches\n .filter((m) => m.posthogSdks.length > 0 || m.stripeSdks.length > 0)\n .map((m) => m.path),\n );\n}\n","/**\n * Revenue analytics program step list.\n *\n * The detect step checks for PostHog + Stripe SDKs. The skill install\n * and agent run live in the program runner (see agent-runner.ts).\n */\n\nimport type { ProgramStep } from '@lib/programs/program-step';\nimport { RunPhase } from '@lib/wizard-session';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\nimport { detectRevenuePrerequisites } from './detect.js';\n\nexport const REVENUE_ANALYTICS_PROGRAM: ProgramStep[] = [\n {\n id: 'detect',\n label: 'Detecting prerequisites',\n // Headless step: no screen, no gate. onReady fires after bin.ts\n // assigns the session — the hook scans for PostHog + Stripe SDKs\n // and writes the results (or a detectError) to frameworkContext\n // for the intro screen to render.\n onReady: (ctx) =>\n detectRevenuePrerequisites(ctx.session, ctx.setFrameworkContext),\n },\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'revenue-intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Revenue analytics',\n screenId: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screenId: 'keep-skills',\n },\n];\n","/**\n * Agent-skill learn-deck — the short three-line sequence shown while a\n * skill-based program (audit, revenue-analytics, agent-skill, etc.)\n * runs. Skill programs don't need the full PostHog onboarding narrative.\n */\n\nimport { Text } from 'ink';\nimport type { WizardStore } from '@ui/tui/store';\nimport { TextRevealMode } from '@ui/tui/primitives/TextBlock';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const getContentBlocks = (store?: WizardStore): ContentBlock[] => {\n const skillId = store?.session.skillId ?? 'unknown';\n return [\n {\n content: 'Welcome.',\n pause: 3000,\n mode: TextRevealMode.Typewriter,\n animationInterval: 160,\n },\n { content: 'The Wizard is an agent.', pause: 4000 },\n {\n pause: 60000,\n content: (\n <Text>\n Running the <Text color=\"cyan\">{skillId}</Text> skill...\n </Text>\n ),\n },\n ];\n};\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { REVENUE_ANALYTICS_PROGRAM } from './steps.js';\nimport { REVENUE_ABORT_CASES } from './detect.js';\nimport { getContentBlocks } from './content/index.js';\n\nexport const revenueAnalyticsConfig: ProgramConfig = {\n command: 'revenue',\n description: 'Set up PostHog revenue analytics (e.g. Stripe integration)',\n id: 'revenue-analytics-setup',\n steps: REVENUE_ANALYTICS_PROGRAM,\n getContentBlocks,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n run: {\n skillId: 'revenue-analytics-setup',\n integrationLabel: 'revenue-analytics-setup',\n customPrompt: () => 'Set up revenue analytics for this project.',\n successMessage: 'Revenue analytics configured!',\n reportFile: 'posthog-revenue-report.md',\n docsUrl: 'https://posthog.com/docs/revenue-analytics',\n spinnerMessage: 'Setting up revenue analytics...',\n estimatedDurationMinutes: 5,\n abortCases: REVENUE_ABORT_CASES,\n },\n requires: ['posthog-integration'],\n};\n\nexport { REVENUE_ANALYTICS_PROGRAM } from './steps.js';\nexport {\n detectRevenuePrerequisites,\n POSTHOG_SDKS,\n STRIPE_SDKS,\n type RevenueDetectError,\n} from './detect.js';\n","/**\n * Generic agent skill step list.\n *\n * Minimal flow: intro → health-check → auth → run → outro → skills.\n * No detection, no setup, no MCP.\n */\n\nimport type { ProgramStep } from '@lib/programs/program-step';\nimport { RunPhase } from '@lib/wizard-session';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\n\nexport const AGENT_SKILL_STEPS: ProgramStep[] = [\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'agent-skill-intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Running',\n screenId: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screenId: 'keep-skills',\n },\n];\n","/**\n * Generic agent skill program factory.\n *\n * Creates a ProgramConfig for any context-mill skill. Provide a\n * skill ID and basic UI config — the factory handles the rest.\n *\n * Usage:\n * createSkillProgram({\n * skillId: 'error-tracking-setup',\n * command: 'errors',\n * id: 'error-tracking',\n * description: 'Set up PostHog error tracking',\n * integrationLabel: 'error-tracking',\n * successMessage: 'Error tracking configured!',\n * reportFile: 'posthog-error-tracking-report.md',\n * docsUrl: 'https://posthog.com/docs/error-tracking',\n * spinnerMessage: 'Setting up error tracking...',\n * estimatedDurationMinutes: 5,\n * })\n */\n\nimport type { ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun, AbortCase } from '@lib/agent/agent-runner';\nimport { AGENT_SKILL_STEPS } from './steps.js';\nimport { getContentBlocks } from './content/index.js';\n\nexport interface SkillProgramOptions {\n /** Context-mill skill ID to install */\n skillId: string;\n /** CLI subcommand name */\n command: string;\n /** Unique flow key — must match a Program enum entry */\n id: string;\n /** CLI description shown in --help */\n description: string;\n /** Analytics integration label */\n integrationLabel: string;\n /** Custom prompt instruction. Appended after default project prompt. */\n customPrompt?: string;\n successMessage: string;\n reportFile: string;\n docsUrl: string;\n spinnerMessage: string;\n estimatedDurationMinutes: number;\n /** Other program ids that must be satisfied first */\n requires?: string[];\n /** Override the default outro. Receives the same args as ProgramRun.buildOutroData. */\n buildOutroData?: ProgramRun['buildOutroData'];\n /** Known `[ABORT] <reason>` cases the skill can emit. */\n abortCases?: AbortCase[];\n}\n\nexport function createSkillProgram(opts: SkillProgramOptions): ProgramConfig {\n return {\n command: opts.command,\n description: opts.description,\n id: opts.id,\n skillId: opts.skillId,\n steps: AGENT_SKILL_STEPS,\n reportFile: opts.reportFile,\n getContentBlocks,\n run: {\n skillId: opts.skillId,\n integrationLabel: opts.integrationLabel,\n customPrompt: opts.customPrompt ? () => opts.customPrompt! : undefined,\n successMessage: opts.successMessage,\n reportFile: opts.reportFile,\n docsUrl: opts.docsUrl,\n spinnerMessage: opts.spinnerMessage,\n estimatedDurationMinutes: opts.estimatedDurationMinutes,\n buildOutroData: opts.buildOutroData,\n abortCases: opts.abortCases,\n },\n requires: opts.requires,\n };\n}\n\nexport { AGENT_SKILL_STEPS } from './steps.js';\n","import type { AbortCase } from '@lib/agent/agent-runner';\n\n/** `[ABORT] <reason>` cases the audit skill can emit. Reason strings are\n * defined in the skill's `Abort statuses` section. */\nexport const AUDIT_ABORT_CASES: AbortCase[] = [\n {\n match: /^no posthog sdk found$/i,\n message: 'No PostHog SDK found',\n body:\n 'The audit needs an existing PostHog integration to review. No PostHog ' +\n 'SDK appears in this project’s dependency manifests. Run the basic ' +\n 'integration program to install PostHog first, then re-run the audit.',\n docsUrl: 'https://posthog.com/docs/getting-started/install',\n },\n];\n","import fs from 'fs';\nimport path from 'path';\nimport { logToFile } from '@utils/debug';\nimport { AUDIT_CHECKS_FILE, type AuditCheck } from './types.js';\n\n/**\n * The 10 data-integrity checks the audit runs, plus one workflow row for the\n * notebook upload at the end (so the skill's `audit_resolve_checks` call for\n * `upload-notebook` succeeds — the skill writes the report to a PostHog\n * notebook as its final step).\n */\nexport const AUDIT_SEED_CHECKS: AuditCheck[] = [\n {\n id: 'sdk-installed',\n area: 'Installation',\n label: 'PostHog SDK installed',\n status: 'pending',\n },\n {\n id: 'sdk-up-to-date',\n area: 'Installation',\n label: 'SDK version up to date',\n status: 'pending',\n },\n {\n id: 'init-correct',\n area: 'Installation',\n label: 'Initialization is correct',\n status: 'pending',\n },\n {\n id: 'identify-stable-distinct-id',\n area: 'Identification',\n label: 'Stable distinct_id (not session UUID)',\n status: 'pending',\n },\n {\n id: 'identify-not-late',\n area: 'Identification',\n label: 'identify() called before captures / flag evals',\n status: 'pending',\n },\n {\n id: 'cross-runtime-distinct-id',\n area: 'Identification',\n label: 'Same distinct_id across client and server',\n status: 'pending',\n },\n {\n id: 'identify-reset-on-logout',\n area: 'Identification',\n label: 'reset() called on logout / account switch',\n status: 'pending',\n },\n {\n id: 'capture-event-names-static',\n area: 'Event Capture',\n label: 'Event names are static and consistent',\n status: 'pending',\n },\n {\n id: 'capture-uses-proxy',\n area: 'Event Capture',\n label: 'Captures route through a reverse proxy',\n status: 'pending',\n },\n {\n id: 'capture-growth-events',\n area: 'Event Capture',\n label: 'Key activation events captured',\n status: 'pending',\n },\n {\n id: 'write-report',\n area: 'Write report',\n label: 'Create posthog-audit-report.md',\n status: 'pending',\n },\n {\n id: 'upload-notebook',\n area: 'Upload notebook',\n label: 'Write the report into a PostHog notebook',\n status: 'pending',\n },\n];\n\n/**\n * Atomically write a seeded ledger to the project's audit checks file.\n *\n * Each audit-flavored program (doctor, events-audit) owns its own seed\n * shape — pass the seed in so this writer stays program-agnostic.\n */\nexport function seedAuditLedger(\n installDir: string,\n checks: AuditCheck[] = AUDIT_SEED_CHECKS,\n): void {\n const target = path.join(installDir, AUDIT_CHECKS_FILE);\n const tmp = `${target}.tmp`;\n fs.writeFileSync(tmp, JSON.stringify(checks, null, 2), 'utf8');\n fs.renameSync(tmp, target);\n logToFile(`seedAuditLedger: wrote ${checks.length} entries to ${target}`);\n}\n","import {\n AGENT_SKILL_STEPS,\n createSkillProgram,\n} from '@lib/programs/agent-skill/index';\nimport type { ProgramStep, ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun } from '@lib/agent/agent-runner';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { OutroKind } from '@lib/wizard-session';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { getCloudUrlFromRegion } from '@utils/urls';\nimport { AUDIT_ABORT_CASES } from './detect.js';\nimport { AUDIT_CHECKS_KEY, AUDIT_REPORT_FILE } from './types.js';\nimport { AUDIT_SEED_CHECKS, seedAuditLedger } from './seed.js';\n\n/** Audit-specific screens for the shared agent-skill pipeline. */\nconst AUDIT_SCREEN_BY_STEP: Record<string, string> = {\n intro: 'audit-intro',\n run: 'audit-run',\n outro: 'audit-outro',\n};\n\nconst seedBeforeAuditRun = (session: WizardSession): void => {\n seedAuditLedger(session.installDir);\n session.frameworkContext[AUDIT_CHECKS_KEY] = AUDIT_SEED_CHECKS;\n};\n\nconst withAuditScreens = (steps: ProgramStep[]): ProgramStep[] =>\n steps.map((step) => {\n const override = AUDIT_SCREEN_BY_STEP[step.id];\n return override ? { ...step, screenId: override } : step;\n });\n\nconst auditSteps: ProgramStep[] = withAuditScreens(AGENT_SKILL_STEPS);\n\nconst baseConfig = createSkillProgram({\n skillId: 'audit',\n command: 'audit',\n id: 'audit',\n description:\n 'Audit an existing PostHog integration for correctness and best practices',\n integrationLabel: 'audit',\n customPrompt:\n 'Run a comprehensive audit of the existing PostHog integration. Follow the skill program steps in order. Do not modify any project files — only create the final audit report.',\n successMessage:\n 'Audit complete! You can view the audit report at ./posthog-audit-report.md',\n reportFile: AUDIT_REPORT_FILE,\n docsUrl: 'https://posthog.com/docs/product-analytics/best-practices',\n spinnerMessage: 'Auditing PostHog integration...',\n estimatedDurationMinutes: 5,\n requires: ['posthog-integration'],\n abortCases: AUDIT_ABORT_CASES,\n});\n\nconst auditRun = async (session: WizardSession): Promise<ProgramRun> => {\n seedBeforeAuditRun(session);\n\n if (!baseConfig.run) {\n throw new Error('Audit program has no run configuration.');\n }\n\n const baseRun =\n typeof baseConfig.run === 'function'\n ? await baseConfig.run(session)\n : baseConfig.run;\n\n return {\n ...baseRun,\n // Override the default outro so the dashboard + notebook URLs the\n // agent emits via `[DASHBOARD_URL]` / `[NOTEBOOK_URL]` are surfaced\n // on the post-run screen.\n buildOutroData: (sess, _credentials, cloudRegion) => {\n const cloudUrl = cloudRegion\n ? getCloudUrlFromRegion(cloudRegion)\n : undefined;\n const continueUrl =\n sess.signup && cloudUrl\n ? `${cloudUrl}/products?source=wizard`\n : undefined;\n\n // Note: `sess` here is the agent-runner's snapshot of session at\n // runAgent() invocation time. Any URL emissions during the run land\n // on the live store, NOT on this snapshot. The UI layer\n // (InkUI.setOutroData) merges live URLs in on top of this return\n // value, so it's safe to leave dashboardUrl/notebookUrl as undefined\n // here when the snapshot doesn't have them.\n return {\n kind: OutroKind.Success as const,\n message: baseRun.successMessage,\n reportFile: baseRun.reportFile,\n docsUrl: baseRun.docsUrl,\n continueUrl,\n dashboardUrl: sess.dashboardUrl ?? undefined,\n notebookUrl: sess.notebookUrl ?? undefined,\n };\n },\n };\n};\n\nexport const auditConfig: ProgramConfig = {\n ...baseConfig,\n steps: auditSteps,\n run: auditRun,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n};\n","/**\n * Events-audit program.\n *\n * Mirrors the posthog-integration step list, except:\n * - The initial framework detection step is omitted — the events-audit\n * skill handles detection at agent run time.\n * - The intro step uses the audit intro screen (no framework selection\n * logic) instead of the integration intro.\n */\n\nimport type { ProgramStep } from '@lib/programs/program-step';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { RunPhase } from '@lib/wizard-session';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\n\nfunction needsSetup(session: WizardSession): boolean {\n const config = session.frameworkConfig;\n if (!config?.metadata.setup?.questions) return false;\n\n return config.metadata.setup.questions.some(\n (q: { key: string }) => !(q.key in session.frameworkContext),\n );\n}\n\nexport const EVENTS_AUDIT_PROGRAM: ProgramStep[] = [\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'audit-intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'setup',\n label: 'Setup',\n screenId: 'setup',\n show: needsSetup,\n isComplete: (session) => !needsSetup(session),\n },\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Events audit',\n screenId: 'audit-run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'mcp',\n label: 'MCP servers',\n screenId: 'mcp',\n isComplete: (session) => session.mcpComplete,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'audit-outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'keep-skills',\n label: 'Keep Skills',\n screenId: 'keep-skills',\n },\n];\n","import type { AuditCheck } from '@lib/programs/audit/types';\n\n/**\n * The 7 phases the events-audit skill marches through. One check per area\n * so PendingChecksList renders a clean linear pipeline (area = bold header,\n * single row = the active spinner).\n *\n * Phase ids match what the skill's step files resolve via\n * `mcp__wizard-tools__audit_resolve_checks` as each phase completes. The\n * skill's step 1 also seeds these same ids — keep both in sync so the\n * wizard pre-seed and the skill's MCP seed agree.\n */\nexport const EVENTS_AUDIT_SEED_CHECKS: AuditCheck[] = [\n {\n id: 'detect-sdk',\n area: 'Detect SDK',\n label: 'Identify PostHog SDK(s) in dependencies',\n status: 'pending',\n },\n {\n id: 'scan-sites',\n area: 'Scan capture sites',\n label: 'Grep capture/identify/group call sites',\n status: 'pending',\n },\n {\n id: 'enrich-sites',\n area: 'Enrich',\n label: 'Subagent fan-out to read capture files',\n status: 'pending',\n },\n {\n id: 'query-volume',\n area: 'Query PostHog',\n label: '30-day volume + last_seen via MCP',\n status: 'pending',\n },\n {\n id: 'write-report',\n area: 'Write report',\n label: 'Create posthog-events-audit-report.md',\n status: 'pending',\n },\n {\n id: 'create-dashboard',\n area: 'Create dashboard',\n label: 'Optional: dashboard for resolved events',\n status: 'pending',\n },\n {\n id: 'upload-notebook',\n area: 'Upload notebook',\n label: 'Write the report into a PostHog notebook',\n status: 'pending',\n },\n];\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun } from '@lib/agent/agent-runner';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { OutroKind } from '@lib/wizard-session';\nimport { SPINNER_MESSAGE } from '@lib/framework-config';\nimport { isUsingTypeScript } from '@utils/setup-utils';\nimport { getCloudUrlFromRegion } from '@utils/urls';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { EVENTS_AUDIT_PROGRAM } from './steps.js';\nimport { AUDIT_CHECKS_KEY } from '@lib/programs/audit/types';\nimport { seedAuditLedger } from '@lib/programs/audit/seed';\nimport { EVENTS_AUDIT_SEED_CHECKS } from './seed.js';\n\nexport const SETUP_REPORT_FILE = 'posthog-events-audit-report.md';\n\nconst DOCS_URL = 'https://posthog.com/docs/product-analytics/best-practices';\n\nexport const eventsAuditConfig: ProgramConfig = {\n command: 'events-audit',\n description: 'Audit PostHog event tracking in this project',\n id: 'events-audit',\n skillId: 'events-audit',\n steps: EVENTS_AUDIT_PROGRAM,\n // Top-level reportFile so AuditRunScreen can resolve the report path\n // synchronously without unwrapping the deferred `run` function.\n reportFile: SETUP_REPORT_FILE,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n\n run: (session: WizardSession): Promise<ProgramRun> => {\n const typeScriptDetected = isUsingTypeScript({\n installDir: session.installDir,\n });\n session.typescript = typeScriptDetected;\n\n // Seed the audit ledger so AuditRunScreen has something to render\n // before the agent emits its first check update. The events-audit\n // ledger is the 6-phase pipeline, not the doctor's 10 integrity checks.\n seedAuditLedger(session.installDir, EVENTS_AUDIT_SEED_CHECKS);\n session.frameworkContext[AUDIT_CHECKS_KEY] = EVENTS_AUDIT_SEED_CHECKS;\n\n return Promise.resolve({\n skillId: 'events-audit',\n integrationLabel: 'events-audit',\n spinnerMessage: SPINNER_MESSAGE,\n successMessage:\n 'Events audit complete! You can view the report at ./posthog-events-audit-report.md',\n estimatedDurationMinutes: 5,\n reportFile: SETUP_REPORT_FILE,\n docsUrl: DOCS_URL,\n errorMessage: 'Events audit failed',\n additionalFeatureQueue: session.additionalFeatureQueue,\n\n customPrompt: (ctx) =>\n `Audit PostHog event capture in this project. Do not modify any project files — produce a read-only report only.\n\nProject context:\n- PostHog Project ID: ${ctx.projectId}\n- TypeScript: ${typeScriptDetected ? 'Yes' : 'No'}\n- PostHog public token: ${ctx.projectApiKey}\n- PostHog Host: ${ctx.host}\n`,\n\n buildOutroData: (sess, _credentials, cloudRegion) => {\n const cloudUrl = cloudRegion\n ? getCloudUrlFromRegion(cloudRegion)\n : undefined;\n const continueUrl =\n sess.signup && cloudUrl\n ? `${cloudUrl}/products?source=wizard`\n : undefined;\n // The agent emits `[DASHBOARD_URL] <url>` once it creates the\n // dashboard; the SDK-message interceptor stores it on the session.\n // Fall back to the dashboards index if nothing was emitted.\n const dashboardUrl =\n sess.dashboardUrl ?? (cloudUrl ? `${cloudUrl}/dashboard` : undefined);\n\n // The agent emits `[NOTEBOOK_URL] <url>` once it uploads the report\n // to a PostHog notebook. No fallback: if the notebook upload was\n // skipped (e.g. MCP unavailable) we just don't show a link.\n const notebookUrl = sess.notebookUrl ?? undefined;\n\n return {\n kind: OutroKind.Success as const,\n message: 'Your events audit was successful',\n reportFile: SETUP_REPORT_FILE,\n changes: [],\n docsUrl: DOCS_URL,\n continueUrl,\n dashboardUrl,\n notebookUrl,\n };\n },\n });\n },\n};\n\nexport { EVENTS_AUDIT_PROGRAM } from './steps.js';\n","import fs from 'fs';\nimport path from 'path';\nimport {\n AGENT_SKILL_STEPS,\n createSkillProgram,\n} from '@lib/programs/agent-skill/index';\nimport type { ProgramStep, ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun } from '@lib/agent/agent-runner';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { AUDIT_ABORT_CASES } from '@lib/programs/audit/detect';\nimport {\n AUDIT_CHECKS_FILE,\n AUDIT_CHECKS_KEY,\n type AuditCheck,\n} from '@lib/programs/audit/types';\nimport { AUDIT_SEED_CHECKS } from '@lib/programs/audit/seed';\nimport { logToFile } from '@utils/debug';\n\nconst AUDIT3000_REPORT_FILE = 'posthog-audit-3000-report.md';\n\n// Extra checks the v3000 audit adds on top of the base 10. IDs must match\n// those referenced in the audit-3000 skill's step files (Event Quality,\n// stale feature-flag review, session replay [fix + optimize], per-product\n// use-case expansion, and phase markers for the post-flags chain).\nconst AUDIT3000_EXTRA_CHECKS: AuditCheck[] = [\n // ── Event Quality (Step 5) ──\n {\n id: 'event-naming-standardization',\n area: 'Event Quality',\n label: 'Event naming convention is consistent',\n status: 'pending',\n },\n {\n id: 'event-duplicates-and-bloat',\n area: 'Event Quality',\n label: 'No duplicate or bloated event capture',\n status: 'pending',\n },\n {\n id: 'event-quality-context-review',\n area: 'Event Quality',\n label: 'Event property context reviewed',\n status: 'pending',\n },\n {\n id: 'event-usage-coverage',\n area: 'Event Quality',\n label: 'Captured events match insights / dashboards usage',\n status: 'pending',\n },\n // ── Feature Flags (Step 6) ──\n {\n id: 'stale-feature-flags-reviewed',\n area: 'Feature Flags',\n label: 'Stale feature flags reviewed',\n status: 'pending',\n },\n // ── Session Replay — fix (Step 6b) ──\n {\n id: 'replay-minimum-duration-set',\n area: 'Session Replay',\n label: 'Minimum duration set on init',\n status: 'pending',\n },\n {\n id: 'replay-mask-config',\n area: 'Session Replay',\n label: 'Mask config covers sensitive surfaces',\n status: 'pending',\n },\n {\n id: 'replay-disabled-in-test-envs',\n area: 'Session Replay',\n label: 'Disabled in test / CI environments',\n status: 'pending',\n },\n {\n id: 'replay-strict-minimum-duration',\n area: 'Session Replay',\n label: 'Strict minimum duration enforced',\n status: 'pending',\n },\n // ── Session Replay — optimize (Step 6b cost wave) ──\n {\n id: 'replay-sampling-rate',\n area: 'Session Replay — Optimize',\n label: 'Sampling rate tuned for cost',\n status: 'pending',\n },\n {\n id: 'replay-triggers-configured',\n area: 'Session Replay — Optimize',\n label: 'Triggers configured (event / URL / flag)',\n status: 'pending',\n },\n {\n id: 'replay-network-recording-filtered',\n area: 'Session Replay — Optimize',\n label: 'Network recording filtered',\n status: 'pending',\n },\n {\n id: 'replay-mobile-sampling',\n area: 'Session Replay — Optimize',\n label: 'Mobile sampling configured',\n status: 'pending',\n },\n // ── Use Case: Expansion (Step 9) ──\n {\n id: 'expansion-product-analytics',\n area: 'Use Case: Expansion',\n label: 'Product analytics coverage',\n status: 'pending',\n },\n {\n id: 'expansion-error-tracking',\n area: 'Use Case: Expansion',\n label: 'Error tracking coverage',\n status: 'pending',\n },\n {\n id: 'expansion-llm-observability',\n area: 'Use Case: Expansion',\n label: 'LLM observability coverage',\n status: 'pending',\n },\n {\n id: 'expansion-session-replay',\n area: 'Use Case: Expansion',\n label: 'Session replay coverage',\n status: 'pending',\n },\n {\n id: 'expansion-feature-flags',\n area: 'Use Case: Expansion',\n label: 'Feature flags coverage',\n status: 'pending',\n },\n {\n id: 'expansion-surveys',\n area: 'Use Case: Expansion',\n label: 'Surveys coverage',\n status: 'pending',\n },\n {\n id: 'expansion-logs',\n area: 'Use Case: Expansion',\n label: 'Logs coverage',\n status: 'pending',\n },\n {\n id: 'expansion-web-analytics',\n area: 'Use Case: Expansion',\n label: 'Web analytics coverage',\n status: 'pending',\n },\n // ── Additional Sections (Steps 7, 8, 10 phase markers) ──\n // Tracked in the ledger so the UI can surface \"did it run / was it\n // skipped\" alongside the regular checks. use-case-expansion is omitted\n // because the eight `expansion-*` checks above cover that phase.\n {\n id: 'customer-enrichment',\n area: 'Additional Sections',\n label: 'Customer enrichment (Harmonic + PDL)',\n status: 'pending',\n },\n {\n id: 'use-case-match',\n area: 'Additional Sections',\n label: 'Use-case match',\n status: 'pending',\n },\n {\n id: 'final-report',\n area: 'Additional Sections',\n label: 'Final audit report written',\n status: 'pending',\n },\n];\n\nconst AUDIT3000_SEED_CHECKS: AuditCheck[] = [\n ...AUDIT_SEED_CHECKS,\n ...AUDIT3000_EXTRA_CHECKS,\n];\n\n// Audit-3000 has its own arcade-flavoured intro / run / outro screens. The\n// shared audit screens stay reserved for the original `audit` program.\nconst AUDIT3000_SCREEN_BY_STEP: Record<string, string> = {\n intro: 'audit-3000-intro',\n run: 'audit-3000-run',\n outro: 'audit-3000-outro',\n};\n\nconst seedAudit3000Ledger = (installDir: string): void => {\n const target = path.join(installDir, AUDIT_CHECKS_FILE);\n const tmp = `${target}.tmp`;\n fs.writeFileSync(tmp, JSON.stringify(AUDIT3000_SEED_CHECKS, null, 2), 'utf8');\n fs.renameSync(tmp, target);\n logToFile(\n `seedAudit3000Ledger: wrote ${AUDIT3000_SEED_CHECKS.length} entries to ${target}`,\n );\n};\n\nconst seedBeforeAudit3000Run = (session: WizardSession): void => {\n seedAudit3000Ledger(session.installDir);\n session.frameworkContext[AUDIT_CHECKS_KEY] = AUDIT3000_SEED_CHECKS;\n};\n\nconst withAudit3000Screens = (steps: ProgramStep[]): ProgramStep[] =>\n steps.map((step) => {\n const override = AUDIT3000_SCREEN_BY_STEP[step.id];\n return override ? { ...step, screenId: override } : step;\n });\n\nconst audit3000Steps: ProgramStep[] = withAudit3000Screens(AGENT_SKILL_STEPS);\n\nconst baseConfig = createSkillProgram({\n skillId: 'audit-3000',\n command: 'audit-3000',\n id: 'audit-3000',\n description:\n 'Audit an existing PostHog integration (v3000 — adds event quality, stale-flag hygiene, customer enrichment, use-case match)',\n integrationLabel: 'audit-3000',\n customPrompt:\n 'Run the audit-3000 skill end-to-end. Follow the step chain starting at references/1-version.md. Do not modify any project files — only create the final audit report and (when enrichment is enabled) the enrichment report.',\n successMessage: `Audit complete! View the report at ./${AUDIT3000_REPORT_FILE}`,\n reportFile: AUDIT3000_REPORT_FILE,\n docsUrl: 'https://posthog.com/docs/product-analytics/best-practices',\n spinnerMessage: 'Running PostHog Audit 3000...',\n estimatedDurationMinutes: 6,\n requires: ['posthog-integration'],\n abortCases: AUDIT_ABORT_CASES,\n});\n\nconst audit3000Run = async (session: WizardSession): Promise<ProgramRun> => {\n seedBeforeAudit3000Run(session);\n\n if (!baseConfig.run) {\n throw new Error('audit-3000 program has no run configuration.');\n }\n\n return typeof baseConfig.run === 'function'\n ? baseConfig.run(session)\n : baseConfig.run;\n};\n\nexport const audit3000Config: ProgramConfig = {\n ...baseConfig,\n steps: audit3000Steps,\n run: audit3000Run,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n};\n","import type { ProgramStep } from '@lib/programs/program-step';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\n\nexport const POSTHOG_DOCTOR_PROGRAM: ProgramStep[] = [\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'doctor-intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'report',\n label: 'Doctor report',\n screenId: 'doctor-report',\n isComplete: (session) => session.outroData !== null,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n];\n","import { z } from 'zod';\n\nexport const HealthIssueSeveritySchema = z.enum([\n 'critical',\n 'warning',\n 'info',\n]);\nexport type HealthIssueSeverity = z.infer<typeof HealthIssueSeveritySchema>;\n\nexport const HealthIssueStatusSchema = z.enum(['active', 'resolved']);\n\nexport const HealthIssueSchema = z.object({\n id: z.string(),\n kind: z.string(),\n severity: HealthIssueSeveritySchema,\n status: HealthIssueStatusSchema,\n dismissed: z.boolean(),\n created_at: z.string(),\n updated_at: z.string(),\n resolved_at: z.string().nullable().optional(),\n});\nexport type HealthIssue = z.infer<typeof HealthIssueSchema>;\n\nexport const HealthIssueListResponseSchema = z.object({\n results: z.array(HealthIssueSchema),\n count: z.number().optional(),\n next: z.string().nullable().optional(),\n previous: z.string().nullable().optional(),\n});\nexport type HealthIssueListResponse = z.infer<\n typeof HealthIssueListResponseSchema\n>;\n\nexport interface HealthIssueSummary {\n total: number;\n by_severity: Record<HealthIssueSeverity, number>;\n}\n","import axios from 'axios';\nimport { analytics } from '@utils/analytics';\nimport { handleApiError } from '@lib/api';\nimport { WIZARD_USER_AGENT } from '@lib/constants';\nimport { HealthIssueListResponseSchema, type HealthIssue } from './types';\n\nexport async function fetchHealthIssues(\n accessToken: string,\n baseUrl: string,\n projectId: number,\n): Promise<HealthIssue[]> {\n const endpoint = `/api/environments/${projectId}/health_issues/`;\n const url = `${baseUrl}${endpoint}?status=active&dismissed=false&limit=250`;\n try {\n const response = await axios.get(url, {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n });\n return HealthIssueListResponseSchema.parse(response.data).results;\n } catch (error) {\n const apiError = handleApiError(error, 'fetch health issues');\n analytics.captureException(apiError, { endpoint, baseUrl, projectId });\n throw apiError;\n }\n}\n","import { POSTHOG_DOCS_URL } from '@lib/constants';\n\nexport interface KindMeta {\n title: string;\n description: string;\n docsUrl: string;\n}\n\nexport const KIND_METADATA: Record<string, KindMeta> = {\n ingestion_lag: {\n title: 'Ingestion is delayed',\n description:\n 'Events are being received but are taking longer than usual to appear.',\n docsUrl: `${POSTHOG_DOCS_URL}/support/troubleshooting`,\n },\n ingestion_warning: {\n title: 'Ingestion warnings on recent events',\n description:\n 'Some recent events were rejected or flagged by the ingestion pipeline.',\n docsUrl: `${POSTHOG_DOCS_URL}/support/troubleshooting`,\n },\n sdk_outdated: {\n title: 'SDK version is out of date',\n description:\n 'One or more SDKs are running an old version. Upgrade to get the latest fixes.',\n docsUrl: `${POSTHOG_DOCS_URL}/libraries`,\n },\n no_live_events: {\n title: 'No $pageview or $screen events in the last 30 days',\n description:\n 'PostHog is not receiving page or screen events from this project.',\n docsUrl: `${POSTHOG_DOCS_URL}/getting-started/install`,\n },\n no_pageleave_events: {\n title: '$pageleave events not being sent',\n description:\n 'Enable pageleave tracking to power bounce rate and session duration.',\n docsUrl: `${POSTHOG_DOCS_URL}/libraries/js#config`,\n },\n scroll_depth: {\n title: 'Scroll depth tracking disabled',\n description:\n 'Turn on scroll depth to capture how far users read each page.',\n docsUrl: `${POSTHOG_DOCS_URL}/libraries/js#config`,\n },\n authorized_urls: {\n title: 'No authorized URLs configured',\n description:\n 'Some web analytics filters require at least one authorized URL to work.',\n docsUrl: `${POSTHOG_DOCS_URL}/web-analytics/faq`,\n },\n reverse_proxy: {\n title: 'No reverse proxy detected',\n description: 'A reverse proxy reduces data loss from ad blockers.',\n docsUrl: `${POSTHOG_DOCS_URL}/advanced/proxy`,\n },\n web_vitals: {\n title: 'Web Vitals tracking disabled',\n description:\n 'Enable Web Vitals to capture LCP, CLS and other performance metrics.',\n docsUrl: `${POSTHOG_DOCS_URL}/web-analytics/web-vitals`,\n },\n materialized_view_failure: {\n title: 'A materialized view is failing',\n description: 'A data modeling pipeline failed its most recent run.',\n docsUrl: `${POSTHOG_DOCS_URL}/data-warehouse`,\n },\n external_data_failure: {\n title: 'External data source is failing',\n description: 'An external data source sync failed and data may be stale.',\n docsUrl: `${POSTHOG_DOCS_URL}/data-warehouse/sources`,\n },\n};\n\nexport const UNKNOWN_KIND_META: KindMeta = {\n title: 'Unknown issue',\n description:\n 'PostHog reported an issue kind the wizard does not yet recognize.',\n docsUrl: POSTHOG_DOCS_URL,\n};\n\nexport function getKindMeta(kind: string): KindMeta {\n return KIND_METADATA[kind] ?? { ...UNKNOWN_KIND_META, title: kind };\n}\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { POSTHOG_DOCTOR_PROGRAM } from './steps.js';\n\nexport const posthogDoctorConfig: ProgramConfig = {\n command: 'doctor',\n description:\n 'Diagnose your PostHog project for configuration issues and setup warnings',\n id: 'posthog-doctor',\n steps: POSTHOG_DOCTOR_PROGRAM,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n};\n\nexport { POSTHOG_DOCTOR_PROGRAM } from './steps.js';\nexport { fetchHealthIssues } from './fetch.js';\nexport { getKindMeta, KIND_METADATA } from './kind-metadata.js';\nexport type { KindMeta } from './kind-metadata.js';\nexport type {\n HealthIssue,\n HealthIssueSeverity,\n HealthIssueSummary,\n} from './types.js';\n","import { existsSync, statSync } from 'fs';\nimport type { WizardSession } from '@lib/wizard-session';\nimport type { AbortCase } from '@lib/agent/agent-runner';\nimport { findPackageJsons } from '@lib/programs/shared/package-scanning';\n\nexport type WebAnalyticsDetectError =\n | {\n kind: 'bad-directory';\n path: string;\n reason: 'missing' | 'not-dir' | 'unreadable';\n }\n | { kind: 'no-package-json' }\n | { kind: 'no-posthog'; scannedCount: number };\n\nexport const WEB_ANALYTICS_ABORT_CASES: AbortCase[] = [\n {\n match: /^no web analytics events$/i,\n message: 'No web analytics events',\n body:\n 'The doctor found no $pageview events in the last 30 days, so there is ' +\n 'nothing to audit yet. Make sure PostHog is initialized and capturing ' +\n 'pageviews, then run the doctor again.',\n docsUrl: 'https://posthog.com/docs/web-analytics/getting-started',\n },\n {\n match: /^insufficient permissions$/i,\n message: 'Insufficient permissions',\n body:\n 'The doctor could not query your project — the authenticated token is ' +\n 'missing query access. Re-run the wizard to sign in again, or use a key ' +\n 'with read access to your events.',\n docsUrl: 'https://posthog.com/docs/web-analytics',\n },\n {\n match: /^posthog sdk not installed$/i,\n message: 'PostHog SDK not installed',\n body:\n 'The doctor could not find a PostHog SDK in this project. Install and ' +\n 'configure PostHog first (run `npx @posthog/wizard`), then run the ' +\n 'doctor to check your web analytics setup.',\n docsUrl: 'https://posthog.com/docs/libraries/js',\n },\n];\n\nexport function detectWebAnalyticsPrerequisites(\n session: WizardSession,\n setFrameworkContext: (key: string, value: unknown) => void,\n): void {\n const fail = (error: WebAnalyticsDetectError) =>\n setFrameworkContext('detectError', error);\n\n const installDir = session.installDir;\n\n if (!existsSync(installDir)) {\n fail({ kind: 'bad-directory', path: installDir, reason: 'missing' });\n return;\n }\n try {\n if (!statSync(installDir).isDirectory()) {\n fail({ kind: 'bad-directory', path: installDir, reason: 'not-dir' });\n return;\n }\n } catch {\n fail({ kind: 'bad-directory', path: installDir, reason: 'unreadable' });\n return;\n }\n\n const matches = findPackageJsons(installDir);\n\n if (matches.length === 0) {\n fail({ kind: 'no-package-json' });\n return;\n }\n\n const sdks = [...new Set(matches.flatMap((m) => m.posthogSdks))];\n\n if (sdks.length === 0) {\n fail({ kind: 'no-posthog', scannedCount: matches.length });\n return;\n }\n\n setFrameworkContext('detectedPosthogSdks', sdks);\n}\n","import type { ProgramStep } from '@lib/programs/program-step';\nimport { AGENT_SKILL_STEPS } from '@lib/programs/agent-skill/steps';\nimport { detectWebAnalyticsPrerequisites } from './detect.js';\n\nexport const WEB_ANALYTICS_DOCTOR_PROGRAM: ProgramStep[] = [\n {\n id: 'detect',\n label: 'Detecting prerequisites',\n onReady: (ctx) =>\n detectWebAnalyticsPrerequisites(ctx.session, ctx.setFrameworkContext),\n },\n ...AGENT_SKILL_STEPS,\n];\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport { createSkillProgram } from '../agent-skill/index.js';\nimport { WEB_ANALYTICS_DOCTOR_PROGRAM } from './steps.js';\nimport { WEB_ANALYTICS_ABORT_CASES } from './detect.js';\n\nconst REPORT_FILE = 'posthog-web-analytics-report.md';\nconst DOCS_URL = 'https://posthog.com/docs/web-analytics';\n\nexport const webAnalyticsDoctorConfig: ProgramConfig = {\n ...createSkillProgram({\n skillId: 'web-analytics-doctor',\n command: 'web-analytics',\n id: 'web-analytics-doctor',\n description: 'Audit and fix your PostHog web analytics setup',\n integrationLabel: 'web-analytics-doctor',\n customPrompt:\n \"Run the web-analytics-doctor skill to check this project's PostHog web \" +\n 'analytics setup. Audit read-only first, then present the findings to the ' +\n 'user with a single wizard_ask multi-select and apply only the fixes they ' +\n 'choose — editing project code and/or PostHog project settings via the ' +\n 'MCP — before writing the report.',\n successMessage:\n 'Web analytics check complete! You can view the report at ./posthog-web-analytics-report.md',\n reportFile: REPORT_FILE,\n docsUrl: DOCS_URL,\n spinnerMessage: 'Checking your web analytics setup...',\n estimatedDurationMinutes: 5,\n requires: ['posthog-integration'],\n abortCases: WEB_ANALYTICS_ABORT_CASES,\n }),\n steps: WEB_ANALYTICS_DOCTOR_PROGRAM,\n parentCommand: 'audit',\n};\n\nexport { WEB_ANALYTICS_DOCTOR_PROGRAM } from './steps.js';\nexport {\n detectWebAnalyticsPrerequisites,\n WEB_ANALYTICS_ABORT_CASES,\n type WebAnalyticsDetectError,\n} from './detect.js';\n","import type { ProgramStep } from '@lib/programs/program-step';\nimport { RunPhase } from '@lib/wizard-session';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\n\nexport const MIGRATION_PROGRAM: ProgramStep[] = [\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'migration-intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Migration',\n screenId: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screenId: 'keep-skills',\n },\n];\n","/**\n * Vendor cost stack — the multi-tool baseline a typical migration target has\n * before consolidating onto PostHog. Numbers from each vendor's published\n * starter pricing.\n */\n\nimport { Text } from 'ink';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const VENDOR_STACK_BLOCK: ContentBlock = {\n type: 'lines',\n interval: 600,\n pause: 9000,\n lines: [\n <Text bold>{' Typical pre-migration stack'}</Text>,\n <Text> </Text>,\n <Text>\n <Text color=\"gray\">{' Sentry'}</Text>\n <Text>{' error tracking '}</Text>\n <Text color=\"red\">{'$26/mo+'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' LaunchDarkly'}</Text>\n <Text>{' feature flags '}</Text>\n <Text color=\"red\">{'$8.33/mo+'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' Amplitude'}</Text>\n <Text>{' product analytics '}</Text>\n <Text color=\"red\">{'$49/mo+'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' Braintrust'}</Text>\n <Text>{' LLM analytics '}</Text>\n <Text color=\"red\">{'$50/mo+'}</Text>\n </Text>,\n <Text color=\"gray\">{' ─────────────────────────────────────'}</Text>,\n <Text>\n <Text>{' Total'}</Text>\n <Text>{' '}</Text>\n <Text bold color=\"red\">\n {'$133/mo+'}\n </Text>\n </Text>,\n <Text dimColor>{' plus ~450KB of JavaScript SDKs'}</Text>,\n ],\n};\n","/**\n * PostHog free-tier highlights — the numbers a migrating team gets back when\n * they consolidate. Sourced from posthog.com/pricing.md.\n */\n\nimport { Text } from 'ink';\nimport { Colors } from '@ui/tui/styles';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const FREE_TIER_BLOCK: ContentBlock = {\n type: 'lines',\n interval: 400,\n pause: 9000,\n lines: [\n <Text bold>{' Free every month, on every product'}</Text>,\n <Text> </Text>,\n <Text>\n <Text color={Colors.accent}>{' 1,000,000 '}</Text>\n <Text>events </Text>\n <Text dimColor>product analytics</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 1,000,000 '}</Text>\n <Text>requests </Text>\n <Text dimColor>feature flags + experiments</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 5,000 '}</Text>\n <Text>recordings </Text>\n <Text dimColor>session replay</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 100,000 '}</Text>\n <Text>exceptions </Text>\n <Text dimColor>error tracking</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 100,000 '}</Text>\n <Text>events </Text>\n <Text dimColor>LLM analytics</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 50 GB '}</Text>\n <Text>logs </Text>\n <Text dimColor>logs</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 1,500 '}</Text>\n <Text>responses </Text>\n <Text dimColor>surveys</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' 1,000,000 '}</Text>\n <Text>rows </Text>\n <Text dimColor>data warehouse</Text>\n </Text>,\n ],\n};\n","/**\n * Pricing structure block — what happens after the free tier.\n */\n\nimport { Text } from 'ink';\nimport { Colors } from '@ui/tui/styles';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const PRICING_STRUCTURE_BLOCK: ContentBlock = {\n type: 'lines',\n interval: 500,\n pause: 8000,\n lines: [\n <Text bold>{' After the free tier'}</Text>,\n <Text> </Text>,\n <Text>\n <Text color={Colors.accent}>{' $0 '}</Text>\n <Text>base price · pay only for what you use</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' ◆ '}</Text>\n <Text>per-event prices decrease with volume</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' ◆ '}</Text>\n <Text>no per-seat charges — your whole team is included</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' ◆ '}</Text>\n <Text>web analytics bundled with product analytics</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' ◆ '}</Text>\n <Text>experiments bundled with feature flags</Text>\n </Text>,\n <Text>\n <Text color={Colors.accent}>{' ◆ '}</Text>\n <Text>revenue analytics bundled with data warehouse</Text>\n </Text>,\n ],\n};\n","/**\n * Migration learn deck (statsig variant). Statsig is the only `migrate`\n * variant today, so this deck plays as-is when the wizard runs\n * `migrate --product=statsig`. Three movements:\n *\n * 1. Welcome and reassure.\n * 2. What to expect — the migration is replacement-only, takes a few\n * minutes, leaves the build green.\n * 3. What's a little different — how flags and experiments work in\n * PostHog, presented as right-way guidance rather than gotchas.\n *\n * FF/experiments guidance paraphrased from PostHog public docs:\n * - posthog.com/docs/feature-flags/best-practices\n * - posthog.com/docs/feature-flags/common-questions\n * - posthog.com/docs/experiments/best-practices\n */\n\nimport { Text } from 'ink';\nimport type { WizardStore } from '@ui/tui/store';\nimport { Colors } from '@ui/tui/styles';\nimport { TextRevealMode } from '@ui/tui/primitives/TextBlock';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\nimport { StatusPeekTrigger } from '@ui/tui/components/StatusPeekTrigger';\nimport { PRODUCT_SUITE_BLOCK } from '@lib/programs/posthog-integration/content/product-suite';\nimport { LINE_CHART_BLOCK } from '@lib/programs/posthog-integration/content/line-chart';\nimport { FUNNEL_BLOCK } from '@lib/programs/posthog-integration/content/funnel';\nimport { VENDOR_STACK_BLOCK } from './vendor-stack.js';\nimport { FREE_TIER_BLOCK } from './free-tier.js';\nimport { PRICING_STRUCTURE_BLOCK } from './pricing-structure.js';\n\nexport const getContentBlocks = (store?: WizardStore): ContentBlock[] => [\n // ── Welcome ────────────────────────────────────────────────────────────\n {\n content: 'Hello.',\n pause: 3000,\n mode: TextRevealMode.Typewriter,\n animationInterval: 160,\n },\n\n { content: 'The Wizard is an agent.', pause: 4000 },\n\n {\n content:\n 'As we speak, it’s making a plan to migrate from Statsig to PostHog.',\n pause: 6000,\n },\n\n {\n content: 'PostHog covers the cost of running this agent.',\n pause: 4000,\n },\n\n { type: 'clear', pause: 2000 },\n\n {\n pause: 5000,\n persist: true,\n content: <StatusPeekTrigger store={store} />,\n },\n\n {\n pause: 6000,\n persist: true,\n content: (\n <Text>\n Press{' '}\n <Text color={Colors.accent} bold>\n S\n </Text>{' '}\n to expand or collapse the status.\n </Text>\n ),\n },\n\n { type: 'clear', pause: 2000 },\n\n // ── What to expect ─────────────────────────────────────────────────────\n { content: 'Here’s what to expect.', pause: 3000 },\n\n { content: 'The migration takes about ten minutes.', pause: 3000 },\n\n {\n content:\n 'Every Statsig call gets replaced in place with its PostHog equivalent.',\n pause: 5500,\n },\n\n {\n content:\n 'Nothing new gets added. No extra captures, no surprise instrumentation.',\n pause: 5500,\n },\n\n {\n content:\n 'The Statsig package gets removed at the end. We’ll run build and lint to clean up after ourselves.',\n pause: 6500,\n },\n\n { type: 'clear', pause: 2000 },\n\n // ── What's a little different ─────────────────────────────────────────\n {\n content: 'A few things work a little differently in PostHog.',\n pause: 4500,\n },\n\n {\n content: (\n <Text>\n Flags evaluate against a stable user. Call{' '}\n <Text bold color={Colors.accent}>\n identify()\n </Text>{' '}\n first, then check the flag.\n </Text>\n ),\n pause: 6000,\n persist: true,\n },\n\n {\n content:\n 'For anything in the first paint, evaluate server-side and bootstrap the values into the client.',\n pause: 6500,\n },\n\n {\n content: (\n <Text>\n In production, route requests through a reverse proxy to avoid ad\n blockers breaking your flags.{'\\n'}\n <Text dimColor>https://posthog.com/docs/advanced/proxy</Text>\n </Text>\n ),\n pause: 6500,\n persist: true,\n },\n\n {\n content:\n 'When a flag reaches 100% rollout, retire it. Flags are signals, not switches.',\n pause: 5500,\n },\n\n {\n content: (\n <Text>\n Name flags descriptively. No double negatives. Reflect the return type.{' '}\n <Text dimColor>For example </Text>\n <Text bold>show-new-checkout</Text>\n <Text dimColor>.</Text>\n </Text>\n ),\n pause: 6500,\n persist: true,\n },\n\n { type: 'clear', pause: 1500 },\n\n // ── Experiments ────────────────────────────────────────────────────────\n {\n content: (\n <Text bold color={Colors.accent}>\n Experiments\n </Text>\n ),\n pause: 2500,\n persist: true,\n },\n\n {\n content:\n 'Change one thing per variant. Multiple changes in one variant blur the result.',\n pause: 5500,\n },\n\n {\n content:\n 'Decide the running time up front. PostHog includes a sample-size and duration calculator in the setup flow.',\n pause: 6500,\n },\n\n {\n content: 'Roll out to 5–10% first. Watch the metrics. Then increase.',\n pause: 5000,\n },\n\n {\n content:\n 'Exclude users who already completed the flow. They can’t be affected by the test.',\n pause: 5500,\n },\n\n { type: 'clear', pause: 1500 },\n\n // ── Close ──────────────────────────────────────────────────────────────\n {\n content: 'Flags and experiments live alongside the rest of your data.',\n pause: 4500,\n },\n\n {\n content: 'Ship behind a flag, watch replays, check analytics for impact.',\n pause: 4500,\n },\n\n { type: 'clear', pause: 1500 },\n\n {\n content:\n 'PostHog also provides every other analytics and AI tool to build your product.',\n pause: 4500,\n },\n\n PRODUCT_SUITE_BLOCK,\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'And consolidating onto one platform saves real money.',\n pause: 4500,\n },\n\n { content: 'Here’s the math.', pause: 1500 },\n\n VENDOR_STACK_BLOCK,\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'Pricing is usage-based, with a generous free tier.',\n pause: 4000,\n },\n\n FREE_TIER_BLOCK,\n\n { type: 'clear', pause: 1500 },\n\n PRICING_STRUCTURE_BLOCK,\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'Gain clarity and really understand your users.',\n pause: 4000,\n },\n\n { content: 'Use trends to measure growth.', pause: 2500 },\n\n LINE_CHART_BLOCK,\n\n { type: 'clear', pause: 500 },\n\n { content: 'Use funnels to reveal bottlenecks.', pause: 2500 },\n\n FUNNEL_BLOCK,\n];\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport type { AbortCase } from '@lib/agent/agent-runner';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport { MIGRATION_PROGRAM } from './steps.js';\nimport { getContentBlocks } from './content/index.js';\n\nconst MIGRATION_REPORT_FILE = 'migration-report.md';\n\nconst MIGRATION_ABORT_CASES: AbortCase[] = [\n {\n match: /^no source-sdk calls found$/i,\n message: 'No source-SDK calls found',\n body:\n 'The migration needs an existing third-party SDK to migrate from. No ' +\n 'calls to the source SDK appear anywhere in this project. If you ' +\n \"haven't installed PostHog yet, you don't need this command — run \" +\n '`npx @posthog/wizard@latest` to add PostHog from scratch.',\n },\n];\n\n/**\n * Map each `--product=<id>` choice to the context-mill skill ID that handles\n * it. Adding a variant: drop a new row here. The CLI `choices` and the\n * runtime lookup both read from this map, so the two stay in sync.\n */\nconst PRODUCT_TO_SKILL_ID = {\n statsig: 'migrate-statsig',\n} as const;\n\ntype MigrateProduct = keyof typeof PRODUCT_TO_SKILL_ID;\nconst MIGRATE_PRODUCTS = Object.keys(PRODUCT_TO_SKILL_ID) as MigrateProduct[];\n\nexport const migrationConfig: ProgramConfig = {\n command: 'migrate',\n description: 'Migrate to PostHog from another analytics provider',\n id: 'migration',\n skillId: PRODUCT_TO_SKILL_ID.statsig,\n steps: MIGRATION_PROGRAM,\n reportFile: MIGRATION_REPORT_FILE,\n getContentBlocks,\n allowedTools: ['Agent'],\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n cliOptions: {\n product: {\n describe: 'Source SDK to migrate from',\n type: 'string',\n choices: MIGRATE_PRODUCTS,\n demandOption: true,\n },\n },\n mapCliOptions: (argv) => ({\n skillId: PRODUCT_TO_SKILL_ID[argv.product as MigrateProduct],\n }),\n run: {\n skillId: PRODUCT_TO_SKILL_ID.statsig,\n integrationLabel: 'migration',\n customPrompt: () =>\n 'Migrate this project from its existing third-party analytics, ' +\n 'feature-flag, and observability tools to PostHog. Run the `migrate` ' +\n 'skill end-to-end: follow the step chain starting at ' +\n 'references/1-presence.md. Only replace existing source-SDK call sites ' +\n 'with PostHog equivalents — make zero unrelated changes and no ' +\n `net-new instrumentation. The final report is written to ./${MIGRATION_REPORT_FILE}.`,\n successMessage: `Migration complete! View the report at ./${MIGRATION_REPORT_FILE}`,\n reportFile: MIGRATION_REPORT_FILE,\n docsUrl: '',\n spinnerMessage: 'Migrating to PostHog...',\n estimatedDurationMinutes: 8,\n abortCases: MIGRATION_ABORT_CASES,\n },\n requires: ['posthog-integration'],\n};\n\nexport { MIGRATION_PROGRAM } from './steps.js';\n","/**\n * Source maps upload prerequisite detection.\n *\n * Scans the project for signals that identify the platform and build system,\n * then maps to one of the context-mill `error-tracking-upload-source-maps-*`\n * skill variants. Results are written to frameworkContext for the intro\n * screen to render and for the agent prompt to consume.\n */\n\nimport type { Dirent } from 'fs';\nimport { readFileSync, readdirSync, existsSync, statSync } from 'fs';\nimport { join, relative } from 'path';\nimport { IGNORED_DIRS } from '@utils/file-utils';\nimport type { WizardSession } from '@lib/wizard-session';\nimport type { AbortCase } from '@lib/agent/agent-runner';\n\n/**\n * Skill variants published under the `error-tracking-upload-source-maps`\n * category in context-mill. The agent loads\n * `error-tracking-upload-source-maps-<variant>`.\n */\nexport type SkillVariant =\n | 'web'\n | 'nextjs'\n | 'node'\n | 'react'\n | 'angular'\n | 'nuxt'\n | 'react-native'\n | 'android'\n | 'flutter'\n | 'ios'\n | 'vite'\n | 'webpack'\n | 'rollup';\n\nconst DISPLAY_NAME: Record<SkillVariant, string> = {\n web: 'Web (JavaScript)',\n nextjs: 'Next.js',\n node: 'Node.js',\n react: 'React',\n angular: 'Angular',\n nuxt: 'Nuxt',\n 'react-native': 'React Native',\n android: 'Android',\n flutter: 'Flutter',\n ios: 'iOS',\n vite: 'Vite',\n webpack: 'Webpack',\n rollup: 'Rollup',\n};\n\nconst POSTHOG_SDKS = [\n 'posthog-js',\n 'posthog-node',\n 'posthog-react-native',\n 'posthog-android',\n 'posthog-ios',\n];\n\n/**\n * Structured detection errors. The screen renders each kind into JSX\n * with proper formatting — keeps error data separate from presentation.\n */\nexport type SourceMapsDetectError =\n | {\n kind: 'bad-directory';\n path: string;\n reason: 'missing' | 'not-dir' | 'unreadable';\n }\n | { kind: 'no-project-files' }\n | { kind: 'unsupported-platform'; detected: string }\n | { kind: 'no-posthog-sdk'; platform: SkillVariant };\n\n/** `[ABORT] <reason>` cases the source maps skill can emit. */\nexport const SOURCE_MAPS_ABORT_CASES: AbortCase[] = [\n {\n match: /^no posthog sdk detected$/i,\n message: 'No PostHog SDK detected',\n body:\n 'The agent could not find a PostHog SDK in your project. ' +\n 'Source map upload requires the SDK to already be installed so it can ' +\n 'report errors. Run `npx @posthog/wizard` first to install the SDK.',\n docsUrl: 'https://posthog.com/docs/error-tracking',\n },\n {\n match: /^build command not found$/i,\n message: 'Build command not found',\n body:\n 'The agent could not identify how to build your project. Source map ' +\n 'upload runs as part of the production build. Add a build script to ' +\n 'your project and run this wizard again.',\n docsUrl: 'https://posthog.com/docs/error-tracking/upload-source-maps',\n },\n];\n\n// ── File / dependency probes ─────────────────────────────────────────\n\ninterface ProjectSignals {\n packageJsons: Array<{ path: string; deps: Set<string> }>;\n hasXcodeProject: boolean;\n hasPodfile: boolean;\n hasSwiftPackage: boolean;\n hasGradle: boolean;\n hasPubspec: boolean;\n scannedFileCount: number;\n}\n\nfunction collectSignals(installDir: string, maxDepth = 3): ProjectSignals {\n const signals: ProjectSignals = {\n packageJsons: [],\n hasXcodeProject: false,\n hasPodfile: false,\n hasSwiftPackage: false,\n hasGradle: false,\n hasPubspec: false,\n scannedFileCount: 0,\n };\n\n function scan(dir: string, depth: number): void {\n if (depth > maxDepth) return;\n\n let entries: Dirent[];\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (entry.name.startsWith('.') && entry.name !== '.') continue;\n if (IGNORED_DIRS.has(entry.name)) continue;\n\n const fullPath = join(dir, entry.name);\n\n if (entry.isFile()) {\n signals.scannedFileCount += 1;\n if (entry.name === 'package.json') {\n try {\n const pkg = JSON.parse(readFileSync(fullPath, 'utf-8')) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n const deps = new Set([\n ...Object.keys(pkg.dependencies ?? {}),\n ...Object.keys(pkg.devDependencies ?? {}),\n ]);\n signals.packageJsons.push({\n path: relative(installDir, fullPath) || 'package.json',\n deps,\n });\n } catch {\n // skip malformed package.json\n }\n } else if (entry.name === 'Podfile') {\n signals.hasPodfile = true;\n } else if (entry.name === 'Package.swift') {\n signals.hasSwiftPackage = true;\n } else if (entry.name === 'pubspec.yaml') {\n signals.hasPubspec = true;\n } else if (\n entry.name === 'build.gradle' ||\n entry.name === 'build.gradle.kts' ||\n entry.name === 'settings.gradle' ||\n entry.name === 'settings.gradle.kts'\n ) {\n signals.hasGradle = true;\n }\n } else if (entry.isDirectory()) {\n if (entry.name.endsWith('.xcodeproj')) {\n signals.hasXcodeProject = true;\n } else {\n scan(fullPath, depth + 1);\n }\n }\n }\n }\n\n scan(installDir, 0);\n return signals;\n}\n\n// ── Skill selection ──────────────────────────────────────────────────\n\nfunction pickJsVariant(deps: Set<string>): SkillVariant {\n // Opinionated full-stack frameworks first — they own their build pipeline\n // and have dedicated skill variants, so bundler detection underneath\n // them is irrelevant.\n if (deps.has('react-native')) return 'react-native';\n if (deps.has('nuxt')) return 'nuxt';\n if (deps.has('next')) return 'nextjs';\n if (deps.has('@angular/core')) return 'angular';\n // Bundlers next — prefer these over the bare `react` variant because\n // their skills are simpler (one bundler-plugin config) than wiring\n // posthog-cli into an arbitrary React setup.\n if (deps.has('vite')) return 'vite';\n if (deps.has('webpack')) return 'webpack';\n if (deps.has('rollup')) return 'rollup';\n // Plain React with no recognised bundler.\n if (deps.has('react')) return 'react';\n // Server-only Node project\n if (deps.has('posthog-node')) return 'node';\n // Fallback: generic web\n return 'web';\n}\n\nfunction selectVariant(signals: ProjectSignals): SkillVariant | null {\n // Mobile / native first — they don't coexist with JS bundlers in the\n // detection signals we look at.\n if (signals.hasPubspec) return 'flutter';\n if (signals.hasXcodeProject || signals.hasPodfile || signals.hasSwiftPackage)\n return 'ios';\n if (signals.hasGradle) return 'android';\n\n if (signals.packageJsons.length > 0) {\n // Union all deps across package.json files (covers monorepos)\n const allDeps = new Set<string>();\n for (const pkg of signals.packageJsons) {\n for (const dep of pkg.deps) allDeps.add(dep);\n }\n return pickJsVariant(allDeps);\n }\n\n return null;\n}\n\nfunction hasPostHogSdk(signals: ProjectSignals): boolean {\n for (const pkg of signals.packageJsons) {\n for (const sdk of POSTHOG_SDKS) {\n if (pkg.deps.has(sdk)) return true;\n }\n }\n // For native platforms the PostHog SDK lives outside package.json and\n // is detected by the agent during the skill run. Assume present here.\n return (\n signals.hasXcodeProject ||\n signals.hasPodfile ||\n signals.hasSwiftPackage ||\n signals.hasGradle ||\n signals.hasPubspec\n );\n}\n\n// ── Entry point ──────────────────────────────────────────────────────\n\nexport const SOURCE_MAPS_CONTEXT_KEYS = {\n skillVariant: 'sourceMapsSkillVariant',\n displayName: 'sourceMapsDisplayName',\n packagePaths: 'sourceMapsPackagePaths',\n detectError: 'detectError',\n} as const;\n\n/**\n * Scan `session.installDir` for platform / build-system signals. Writes\n * detection results into frameworkContext via the callback — either the\n * picked skill variant + display name, or a `SourceMapsDetectError`.\n *\n * The skill install happens later in the agent run, not here. This step\n * only picks which variant the prompt should ask the agent to load.\n */\nexport function detectSourceMapsPrerequisites(\n session: WizardSession,\n setFrameworkContext: (key: string, value: unknown) => void,\n): void {\n const fail = (error: SourceMapsDetectError) =>\n setFrameworkContext(SOURCE_MAPS_CONTEXT_KEYS.detectError, error);\n\n const installDir = session.installDir;\n\n if (!existsSync(installDir)) {\n fail({ kind: 'bad-directory', path: installDir, reason: 'missing' });\n return;\n }\n try {\n if (!statSync(installDir).isDirectory()) {\n fail({ kind: 'bad-directory', path: installDir, reason: 'not-dir' });\n return;\n }\n } catch {\n fail({ kind: 'bad-directory', path: installDir, reason: 'unreadable' });\n return;\n }\n\n const signals = collectSignals(installDir);\n const variant = selectVariant(signals);\n\n // This program currently targets JS-like stacks only. Avoid selecting native\n // platforms until dedicated skill variants are available.\n if (\n variant &&\n ['react-native', 'flutter', 'ios', 'android'].includes(variant)\n ) {\n fail({ kind: 'unsupported-platform', detected: variant });\n return;\n }\n\n if (!variant) {\n if (signals.scannedFileCount === 0) {\n fail({ kind: 'no-project-files' });\n } else {\n fail({ kind: 'unsupported-platform', detected: 'unknown' });\n }\n return;\n }\n\n if (!hasPostHogSdk(signals)) {\n fail({ kind: 'no-posthog-sdk', platform: variant });\n return;\n }\n\n setFrameworkContext(SOURCE_MAPS_CONTEXT_KEYS.skillVariant, variant);\n setFrameworkContext(\n SOURCE_MAPS_CONTEXT_KEYS.displayName,\n DISPLAY_NAME[variant],\n );\n setFrameworkContext(\n SOURCE_MAPS_CONTEXT_KEYS.packagePaths,\n signals.packageJsons.map((p) => p.path),\n );\n}\n\nexport { DISPLAY_NAME as VARIANT_DISPLAY_NAME };\n","/**\n * Error tracking source maps upload program step list.\n *\n * Detection runs headless via onReady, then the user sees a custom intro\n * showing the picked skill variant. Auth → agent run → outro mirrors the\n * other programs.\n */\n\nimport type { ProgramStep } from '@lib/programs/program-step';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { RunPhase } from '@lib/wizard-session';\nimport {\n evaluateWizardReadiness,\n WizardReadiness,\n SIGNUP_WIZARD_READINESS_CONFIG,\n getBlockingServiceKeys,\n} from '@lib/health-checks/readiness';\nimport { detectSourceMapsPrerequisites } from './detect.js';\n\nfunction healthCheckReady(session: WizardSession): boolean {\n if (!session.readinessResult) return false;\n\n if (session.signup) {\n const hardBlocking = getBlockingServiceKeys(\n session.readinessResult.health,\n SIGNUP_WIZARD_READINESS_CONFIG,\n );\n const defaultBlocking = getBlockingServiceKeys(\n session.readinessResult.health,\n );\n if (hardBlocking.length === 0 && defaultBlocking.length === 0) return true;\n return session.outageDismissed;\n }\n\n if (session.readinessResult.decision === WizardReadiness.No) {\n return session.outageDismissed;\n }\n return true;\n}\n\nexport const ERROR_TRACKING_UPLOAD_SOURCE_MAPS_PROGRAM: ProgramStep[] = [\n {\n id: 'detect',\n label: 'Detecting platform',\n // Headless: scans for platform / build-system signals and picks the\n // matching context-mill skill variant. Writes either the variant or\n // a detectError to frameworkContext.\n onReady: (ctx) =>\n detectSourceMapsPrerequisites(ctx.session, ctx.setFrameworkContext),\n },\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'source-maps-intro',\n gate: (session) => session.setupConfirmed,\n },\n {\n id: 'health-check',\n label: 'Health check',\n screenId: 'health-check',\n gate: healthCheckReady,\n onInit: (ctx) => {\n evaluateWizardReadiness()\n .then((readiness) => {\n ctx.setReadinessResult(readiness);\n })\n .catch(() => {\n ctx.setReadinessResult({\n decision: WizardReadiness.Yes,\n health: {} as never,\n reasons: [],\n });\n });\n },\n },\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Upload source maps',\n screenId: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'source-maps-outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screenId: 'keep-skills',\n },\n];\n","import { AgentSignals } from '@lib/agent/agent-interface';\nimport type { SkillVariant } from './detect.js';\n\nexport type SourceMapsUploadPromptParams = {\n displayName: string | undefined;\n variant: SkillVariant;\n skillId: string;\n projectId: number;\n host: string;\n settingsUrl: string;\n uiHost: string;\n};\n\nexport const SOURCE_MAPS_DETECTION_FAILED_PROMPT = `Detection did not pick a source maps skill variant for this project.\nEmit: ${AgentSignals.ABORT} unsupported-platform\nThen halt.`;\n\nexport function buildSourceMapsUploadPrompt(\n params: SourceMapsUploadPromptParams,\n): string {\n const {\n displayName,\n variant,\n skillId,\n projectId,\n host,\n settingsUrl,\n uiHost,\n } = params;\n const platformLabel = displayName ?? variant;\n\n return `You are wiring up PostHog Error Tracking source map upload for this ${platformLabel} project.\n\nProject context:\n- PostHog Project ID: ${projectId}\n- PostHog Host: ${host}\n- Detected platform: ${platformLabel}\n- Skill to use: ${skillId}\n- Personal API keys settings page: ${settingsUrl}\n\nThe skill you install in STEP 2 is the source of truth for the HOW of every\nstep: its \"## Steps\" section has an overview, tips and per-technology\nexamples for each named step, and its reference files carry the exact\nper-framework API. The STEPS below give the order, the conditionals, and the\nwizard-specific mechanics (which MCP tool to call, signals to emit) — read\nthe matching skill step (named in parentheses) before doing the work, and do\nnot invent steps the skill doesn't describe.\n\nFollow these steps IN ORDER. Do not skip or reorder.\n\nBefore doing any work, create your FULL task list in a single TaskCreate\ncall so the user can follow your progress in the TUI. Use exactly these\ntasks, in this order — do not collapse, rename, or omit any of them:\n 1. Get personal API key\n 2. Install source maps skill\n 3. Apply build-config changes (per skill)\n 4. Make credentials readable at build time\n 5. Write keys to .env\n 6. Identify build & run commands\n 7. Test the local setup\n 8. Summarise & hand off\nDrive the list with TaskUpdate — mark a task in_progress when you start it\nand completed when done. ALWAYS keep task 7 (\"Test the local setup\") in the\nlist even if the user declines testing in STEP 7: mark it completed rather\nthan deleting it, so the user can see testing was offered.\n\nSTEP 1 — Get a personal API key from the user. (skill: \"Get a personal API key\")\n The wizard cannot mint keys — never call the PostHog API or any tool to\n create one. Ask the user with the wizard_ask MCP tool; you receive the\n answer as a vaulted secretRef (never the raw value), which you reuse in\n STEP 5:\n {\n id: \"api-key\",\n prompt: \"Paste your PostHog personal API key below.\\\\n\\\\nDon't have one yet? Create one here:\\\\n${settingsUrl}\\\\n\\\\nWhen creating the key, choose the 'Source map upload' preset, then come back and paste it here.\",\n kind: \"text\",\n sensitive: true\n }\n Keep the \\\\n line breaks exactly as written — Ink's <Text> renders them\n as separate lines. The answer is { secretRef: \"secret:...\" }.\n If wizard_ask is unavailable (CI / non-interactive), emit\n ${AgentSignals.ABORT} requires-interactive-mode and halt.\n\nSTEP 2 — Install the skill.\n Call install_skill (wizard-tools MCP server) with skillId \"${skillId}\".\n Do NOT run shell commands to install skills. Then read the installed\n SKILL.md and its reference files — they drive STEPS 3-8.\n If install fails, emit ${AgentSignals.ERROR_RESOURCE_MISSING} skill ${skillId} could not be installed.\n\nSTEP 3 — Apply build-config changes. (skill: \"Apply build-config changes\")\n Make the bundler / build-config changes the skill's step instructs. The\n skill and its reference are the source of truth for this platform.\n\nSTEP 4 — Make the credentials readable at build time. (skill: \"Make credentials available at build time\")\n Follow the skill's step. Wizard-specific: if it calls for a loader (e.g.\n \\`dotenv\\`), install it SILENTLY — do NOT ask the user or call wizard_ask.\n Skip this step entirely if the platform already auto-loads .env.\n\nSTEP 5 — Write the credentials to the env file. (skill: \"Write credentials to the env file\")\n Use the wizard-tools MCP server. Reuse the env file the skill tells you to\n pick — the prerequisite PostHog integration usually already wrote\n POSTHOG_* vars to one, so seed your keys alongside them.\n - First call check_env_keys on that file (returns present/absent, never\n values — don't read the file directly).\n - Then call set_env_values, passing the STEP 1 secretRef as a value\n object, not a literal string:\n values: {\n \"POSTHOG_CLI_API_KEY\": { secretRef: \"<the ref from STEP 1>\" },\n \"POSTHOG_CLI_PROJECT_ID\": \"${projectId}\",\n \"POSTHOG_CLI_HOST\": \"${host}\"\n }\n Variable names follow the skill's per-uploader conventions. The wizard\n resolves the ref locally before writing, so you never see the key value.\n\nSTEP 6 — Identify the build AND run commands. (skill: \"Identify the build and run commands\")\n Per the skill, resolve the production BUILD command and the RUN command\n for THIS project (use detect_package_manager for the package manager). Do\n NOT run either yourself — the user runs them. If you cannot identify a\n build command, emit ${AgentSignals.ABORT} build command not found.\n\nSTEP 7 — Offer to test the local setup. (skill: \"Test the local setup\")\n Call wizard_ask:\n {\n id: \"test-affordance\",\n prompt: \"Want me to help you test your local setup? I'll add a temporary test button (or route) to your app so you can confirm errors show up in Error Tracking with readable stack traces after your next build. I'll remove it once you've confirmed it works.\",\n kind: \"single\",\n options: [\n { label: \"Yes, help me test it\", value: \"yes\" },\n { label: \"No, I'll test on my own later\", value: \"no\" }\n ]\n }\n\n If \"no\", skip to STEP 8.\n\n If \"yes\", follow the skill's \"Test the local setup\" step for the\n platform-appropriate affordance, the captureException shape, the\n placement, and the read-before-edit / always-revert rules. Then pause for\n the user with wizard_ask, baking the EXACT build and run commands from\n STEP 6 (and the exact button label / route) into the prompt as literal,\n copy-pasteable steps. Separate each numbered step with \\\\n\\\\n so the TUI\n renders them as distinct lines:\n {\n id: \"test-done\",\n prompt: \"1) Run \\`<your detected build command>\\` to upload source maps and build the app with the test affordance.\\\\n\\\\n2) Start the app with \\`<your detected run command>\\`, then click the \\\\\"<your test button label>\\\\\" button (or hit \\`<your test route>\\`).\\\\n\\\\n3) Open Error Tracking in PostHog (${uiHost}/project/${projectId}/error_tracking) and confirm the test error appears with a source-resolved stack trace pointing at real source files (not minified bundle paths).\\\\n\\\\nWhen you're done, select Continue and I'll revert the test code.\",\n kind: \"single\",\n options: [{ label: \"Continue (revert test code)\", value: \"continue\" }]\n }\n After the user continues, revert the test code per the skill's rules and\n surface any failure in STEP 8.\n\nSTEP 8 — Summarise and hand off. (skill: \"Verify and hand off\")\n Follow the skill's \"Verify and hand off\" step. The Symbol sets page for\n this project — where the user confirms the upload landed — is:\n ${uiHost}/project/${projectId}/error_tracking/configuration\n`;\n}\n","/**\n * Source-maps learn-deck — the narrative played in the run screen's left\n * pane (LearnCard) while the agent wires source-map upload into the build.\n *\n * It educates the user on what source maps are and why uploading them\n * matters, built around a before/after stack-trace contrast: a minified\n * production trace nobody can read, then the same trace resolved back to\n * real source. Program-owned; wired onto the program's getContentBlocks.\n *\n * Lines stay narrow (~36 cols) because this renders in the left half of a\n * split pane — see LearnCard's paneWidth math.\n */\n\nimport { Text } from 'ink';\nimport { Colors } from '@ui/tui/styles';\nimport type { WizardStore } from '@ui/tui/store';\nimport { TextRevealMode } from '@ui/tui/primitives/TextBlock';\nimport {\n isClearBlock,\n type ContentBlock,\n} from '@ui/tui/primitives/content-types';\nimport { StatusPeekTrigger } from '@ui/tui/components/StatusPeekTrigger';\n\n/**\n * Per-slide dwell multiplier. Each block stays on screen for `pause * SLIDE_PACE`\n * ms after it finishes animating, before the deck advances. Bump this single\n * knob to give every slide more reading time. Clear (page-break) blocks are\n * left untouched so the blank gap between slides stays snappy.\n */\nconst SLIDE_PACE = 1.5;\n\nconst withPace = (block: ContentBlock): ContentBlock => {\n if (typeof block === 'string' || isClearBlock(block) || block.pause == null) {\n return block;\n }\n return { ...block, pause: Math.round(block.pause * SLIDE_PACE) };\n};\n\n/** Apply the dwell multiplier to every block in a deck. */\nconst pace = (blocks: ContentBlock[]): ContentBlock[] => blocks.map(withPace);\n\n/**\n * A minified production stack trace — the problem source maps solve. Framed as\n * a labelled, muted example (no error-red ✘) so a glance reads it as\n * illustrative content, not as the wizard itself having errored mid-run.\n */\nconst MINIFIED_TRACE: ContentBlock = {\n type: 'lines',\n interval: 400,\n pause: 7000,\n lines: [\n <Text dimColor>{'example — minified production trace'}</Text>,\n <Text color={Colors.muted}>{' TypeError: cart is undefined'}</Text>,\n <Text dimColor>{' at t.min.js:1:48213'}</Text>,\n <Text dimColor>{' at t.min.js:1:9402'}</Text>,\n <Text dimColor>{' at t.min.js:1:71150'}</Text>,\n ],\n};\n\n/** The same trace, resolved through uploaded source maps. */\nconst RESOLVED_TRACE: ContentBlock = {\n type: 'lines',\n interval: 400,\n pause: 8000,\n lines: [\n <Text dimColor>{'example — resolved with source maps'}</Text>,\n <Text color={Colors.success}>{' ✔ TypeError: cart is undefined'}</Text>,\n <Text>\n <Text dimColor>{' at '}</Text>\n <Text color=\"cyan\">Cart.tsx:42</Text>\n <Text dimColor>{' loadCart'}</Text>\n </Text>,\n <Text>\n <Text dimColor>{' at '}</Text>\n <Text color=\"cyan\">App.tsx:88</Text>\n <Text dimColor>{' render'}</Text>\n </Text>,\n <Text>\n <Text dimColor>{' at '}</Text>\n <Text color=\"cyan\">index.tsx:5</Text>\n <Text dimColor>{' main'}</Text>\n </Text>,\n ],\n};\n\n/**\n * How a bundle is tied to its map: PostHog injects a chunk-ID marker into the\n * built JS and stamps the matching source map with the same ID.\n */\nconst CHUNK_ID_LINK: ContentBlock = {\n type: 'lines',\n interval: 450,\n pause: 7500,\n lines: [\n <Text dimColor>app.min.js</Text>,\n <Text dimColor>{' …minified code…'}</Text>,\n <Text>\n <Text color=\"cyan\">{' //# chunkId=a1b2c3d4'}</Text>\n <Text dimColor>{' ← injected'}</Text>\n </Text>,\n <Text dimColor>{' ↕ matched by id'}</Text>,\n <Text>\n <Text dimColor>app.min.js.map</Text>\n <Text dimColor>{' ← uploaded'}</Text>\n </Text>,\n ],\n};\n\n/** Many similar exceptions collapse into a single issue. */\nconst GROUPING: ContentBlock = {\n type: 'lines',\n interval: 450,\n pause: 7000,\n lines: [\n <Text dimColor>{'exception ─┐'}</Text>,\n <Text>\n <Text dimColor>{'exception ─┼──→ '}</Text>\n <Text color={Colors.accent} bold>\n 1 issue\n </Text>\n </Text>,\n <Text dimColor>{'exception ─┘'}</Text>,\n ],\n};\n\nexport const getContentBlocks = (store?: WizardStore): ContentBlock[] =>\n pace([\n {\n content: 'Welcome.',\n pause: 3000,\n mode: TextRevealMode.Typewriter,\n animationInterval: 160,\n },\n\n {\n content: \"I'm wiring PostHog Error Tracking into your build.\",\n pause: 5000,\n },\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'When you ship to production, your code gets minified.',\n pause: 5000,\n },\n {\n content: 'Thousands of readable lines collapse into one dense bundle.',\n pause: 5000,\n },\n {\n content: 'So a thrown error gives you a stack trace like this:',\n pause: 2000,\n },\n\n MINIFIED_TRACE,\n\n { content: 'Just offsets into a file no human can read.', pause: 5000 },\n\n { type: 'clear', pause: 1500 },\n\n { content: 'Source maps are the key.', pause: 3500 },\n {\n content:\n 'They map every position in that bundle back to your original source — the real file, line, and function.',\n pause: 6000,\n },\n {\n content:\n \"Right now I'm hooking source-map generation and upload into your build, tied to each release you ship.\",\n pause: 6000,\n },\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'But how does PostHog know which map belongs to which build?',\n pause: 4500,\n },\n {\n content:\n 'During the build, it injects a unique chunk ID into each bundle:',\n pause: 2500,\n },\n\n CHUNK_ID_LINK,\n\n {\n content:\n 'The matching source map is stamped with that same ID before it ships to PostHog.',\n pause: 6000,\n },\n {\n content:\n 'When an error comes in, PostHog reads the chunk ID off the bundle, finds the map with the exact same ID, and uses it to map each frame back to your source — even for a release you shipped weeks ago.',\n pause: 8000,\n },\n\n { type: 'clear', pause: 1500 },\n\n { content: 'So that same error becomes:', pause: 2000 },\n\n RESOLVED_TRACE,\n\n {\n content: 'Readable stack traces, straight from production.',\n pause: 5000,\n },\n {\n content: 'You debug a live error like it happened on your own machine.',\n pause: 6000,\n },\n\n { type: 'clear', pause: 1500 },\n\n { content: 'Zooming out — this is how Error Tracking works.', pause: 4000 },\n {\n content: 'Every error your app throws is captured as an exception.',\n pause: 5000,\n },\n {\n content: 'PostHog groups similar exceptions into a single issue:',\n pause: 2500,\n },\n\n GROUPING,\n\n {\n content:\n 'So a bug that fires ten thousand times is one issue to triage — not ten thousand alerts.',\n pause: 6500,\n },\n\n { type: 'clear', pause: 1500 },\n\n {\n content: 'And this is where source maps earn their keep again.',\n pause: 4500,\n },\n {\n content:\n 'Grouping reads the stack trace. Minified frames all look alike — so unrelated crashes get merged, and one real bug scatters across many issues.',\n pause: 8000,\n },\n {\n content:\n 'With source maps, PostHog groups on your real frames — so each distinct bug lands as one clean issue.',\n pause: 7000,\n },\n\n { type: 'clear', pause: 1500 },\n\n {\n pause: 5000,\n persist: true,\n content: <StatusPeekTrigger store={store} />,\n },\n {\n pause: 90000,\n content: (\n <Text>\n Press{' '}\n <Text color={Colors.accent} bold>\n S\n </Text>{' '}\n to follow along — or sit tight, I'll let you know when it's done.\n </Text>\n ),\n },\n ]);\n","import type { ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun } from '@lib/agent/agent-runner';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { OutroKind } from '@lib/wizard-session';\nimport { ERROR_TRACKING_UPLOAD_SOURCE_MAPS_PROGRAM } from './steps.js';\nimport {\n buildSourceMapsUploadPrompt,\n SOURCE_MAPS_DETECTION_FAILED_PROMPT,\n} from './prompt.js';\nimport {\n SOURCE_MAPS_ABORT_CASES,\n SOURCE_MAPS_CONTEXT_KEYS,\n type SkillVariant,\n} from './detect.js';\nimport { getContentBlocks } from './content/index.js';\nimport { getUiHostFromHost } from '@utils/urls';\n\nconst REPORT_FILE = 'posthog-source-maps-report.md';\nconst DOCS_URL = 'https://posthog.com/docs/error-tracking/upload-source-maps';\n\nexport const errorTrackingUploadSourceMapsConfig: ProgramConfig = {\n command: 'upload-source-maps',\n description: 'Upload source maps to PostHog Error Tracking',\n id: 'error-tracking-upload-source-maps',\n steps: ERROR_TRACKING_UPLOAD_SOURCE_MAPS_PROGRAM,\n reportFile: REPORT_FILE,\n getContentBlocks,\n requires: ['posthog-integration'],\n\n run: (session: WizardSession): Promise<ProgramRun> => {\n const variant = session.frameworkContext[\n SOURCE_MAPS_CONTEXT_KEYS.skillVariant\n ] as SkillVariant | undefined;\n const displayName = session.frameworkContext[\n SOURCE_MAPS_CONTEXT_KEYS.displayName\n ] as string | undefined;\n\n const skillId = variant\n ? `error-tracking-upload-source-maps-${variant}`\n : undefined;\n\n return Promise.resolve({\n integrationLabel: 'error-tracking-upload-source-maps',\n // Skill is installed by the agent (after the API-key choice is made)\n // rather than pre-installed by the runner, so leave skillId unset.\n successMessage: 'Source maps wired up!',\n reportFile: REPORT_FILE,\n docsUrl: DOCS_URL,\n spinnerMessage: 'Wiring up source maps...',\n estimatedDurationMinutes: 3,\n abortCases: SOURCE_MAPS_ABORT_CASES,\n\n customPrompt: (ctx) => {\n if (!skillId || !variant) {\n // Detection failed but the user got past the intro somehow.\n // Tell the agent to abort with a structured signal so the runner\n // renders a friendly outro.\n return SOURCE_MAPS_DETECTION_FAILED_PROMPT;\n }\n\n const uiHost = getUiHostFromHost(ctx.host).replace(/\\/$/, '');\n\n return buildSourceMapsUploadPrompt({\n displayName,\n variant,\n skillId,\n projectId: ctx.projectId,\n host: ctx.host,\n settingsUrl: `${uiHost}/project/${ctx.projectId}/settings/user-api-keys`,\n uiHost,\n });\n },\n\n postRun: (sess) => {\n // Stash a hint for the outro about what variant we shipped.\n if (variant) {\n sess.frameworkContext['sourceMapsCompletedVariant'] = variant;\n }\n return Promise.resolve();\n },\n\n buildOutroData: () => {\n // SourceMapsOutroScreen renders static \"what we did + how it works\"\n // guidance, so no per-run `changes` list is needed here.\n return {\n kind: OutroKind.Success as const,\n message: 'Source maps wired up!',\n reportFile: REPORT_FILE,\n docsUrl: DOCS_URL,\n };\n },\n });\n },\n};\n\nexport { ERROR_TRACKING_UPLOAD_SOURCE_MAPS_PROGRAM } from './steps.js';\nexport {\n detectSourceMapsPrerequisites,\n SOURCE_MAPS_ABORT_CASES,\n SOURCE_MAPS_CONTEXT_KEYS,\n VARIANT_DISPLAY_NAME,\n type SkillVariant,\n type SourceMapsDetectError,\n} from './detect.js';\n","/**\n * MCP add / remove / tutorial programs.\n *\n * None of these run the agent pipeline — they're TUI-only flows invoked\n * by the `mcp add` / `mcp remove` / `mcp tutorial` subcommands in\n * bin.ts. They live in the program registry so the screen sequence is\n * derived alongside every other program (no special-cases in\n * screen-sequences.ts).\n */\n\nimport type { ProgramConfig } from '@lib/programs/program-step';\nimport { McpOutcome } from '@lib/wizard-session';\n\nexport const mcpAddConfig: ProgramConfig = {\n id: 'mcp-add',\n description: 'Add PostHog MCP server to supported clients',\n steps: [\n {\n id: 'mcp-add',\n label: 'Add MCP server',\n screenId: 'mcp-add',\n isComplete: (s) => s.mcpComplete,\n },\n {\n id: 'mcp-suggested-prompts',\n label: 'Suggested prompts',\n screenId: 'mcp-suggested-prompts',\n // Only render after a successful install — no-clients, skipped,\n // and failed outcomes go straight to program end. The screen has\n // no value without a working MCP for the user to log in against.\n show: (s) => s.mcpOutcome === McpOutcome.Installed,\n isComplete: (s) => s.mcpSuggestedPromptsDismissed,\n },\n ],\n};\n\n/**\n * `wizard mcp remove` — single-step uninstall flow.\n *\n * DO NOT append `mcp-suggested-prompts` (or any other tutorial-shaped\n * step) here. A user who just removed MCP is opting OUT of the agent\n * having access to PostHog; immediately pivoting into a tutorial that\n * asks them to log in and try prompts is wrong on intent and confusing\n * on UX. The screen also reads `session.mcpInstalledClients` for its\n * Choose-phase copy (\"MCP is installed for X\") — that array is empty\n * post-remove, so the copy would be a lie.\n *\n * If you want a \"did you mean to keep it?\" confirmation, build that as\n * a screen earlier in this program — don't reuse the tutorial.\n */\nexport const mcpRemoveConfig: ProgramConfig = {\n id: 'mcp-remove',\n description: 'Remove PostHog MCP server from supported clients',\n steps: [\n {\n id: 'mcp-remove',\n label: 'Remove MCP server',\n screenId: 'mcp-remove',\n isComplete: (s) => s.mcpComplete,\n },\n ],\n};\n\n/**\n * Standalone tutorial flow — boots directly into the Choose phase of\n * McpSuggestedPromptsScreen without going through MCP install first.\n * Useful for users who already installed MCP and want to revisit the\n * tutorial, or anyone who just wants to try the agent against PostHog\n * without touching their IDE config.\n *\n * The screen handles its own OAuth (via services.performLogin) so this\n * program doesn't pre-populate credentials.\n */\nexport const mcpTutorialConfig: ProgramConfig = {\n id: 'mcp-tutorial',\n description: 'Try the PostHog MCP with your agent — no install needed',\n steps: [\n {\n id: 'mcp-suggested-prompts',\n label: 'MCP tutorial',\n screenId: 'mcp-suggested-prompts',\n isComplete: (s) => s.mcpSuggestedPromptsDismissed,\n },\n ],\n};\n","/**\n * Central registry of all wizard programs.\n *\n * Adding a new program:\n * 1. Create src/lib/programs/<name>/ with index.ts exporting a ProgramConfig\n * 2. Import and add it to PROGRAM_REGISTRY below\n * 3. (If custom intro screen) add to src/ui/tui/screen-registry.tsx\n *\n * screen-sequences.ts, store.ts, and bin.ts all derive their wiring from\n * this array — no need to touch those files when adding a program.\n */\n\nimport type { ProgramConfig } from './program-step.js';\nimport { posthogIntegrationConfig } from './posthog-integration/index.js';\nimport { revenueAnalyticsConfig } from './revenue-analytics/index.js';\nimport { auditConfig } from './audit/index.js';\nimport { eventsAuditConfig } from './events-audit/index.js';\nimport { audit3000Config } from './audit-3000/index.js';\nimport { posthogDoctorConfig } from './posthog-doctor/index.js';\nimport { webAnalyticsDoctorConfig } from './web-analytics-doctor/index.js';\nimport { migrationConfig } from './migration/index.js';\nimport { errorTrackingUploadSourceMapsConfig } from './error-tracking-upload-source-maps/index.js';\nimport { AGENT_SKILL_STEPS } from './agent-skill/index.js';\nimport { getContentBlocks as agentSkillContentBlocks } from './agent-skill/content/index.js';\nimport {\n mcpAddConfig,\n mcpRemoveConfig,\n mcpTutorialConfig,\n} from './mcp/index.js';\n\n// Generic skill program — invoked when the wizard runs an arbitrary\n// context-mill skill chosen at runtime (session.skillId) rather than a\n// registered named program. No CLI command, no run config.\nconst agentSkillConfig: ProgramConfig = {\n id: 'agent-skill',\n description: 'Run an arbitrary context-mill skill',\n steps: AGENT_SKILL_STEPS,\n getContentBlocks: agentSkillContentBlocks,\n allowedTools: ['Agent'],\n};\n\nexport const PROGRAM_REGISTRY = [\n posthogIntegrationConfig,\n revenueAnalyticsConfig,\n errorTrackingUploadSourceMapsConfig,\n auditConfig,\n eventsAuditConfig,\n audit3000Config,\n posthogDoctorConfig,\n webAnalyticsDoctorConfig,\n migrationConfig,\n agentSkillConfig,\n mcpAddConfig,\n mcpRemoveConfig,\n mcpTutorialConfig,\n] as const satisfies readonly ProgramConfig[];\n\n/**\n * Typed program names. Values come from each config's `id`, so there's\n * no parallel string list to keep in sync — adding `Program.Foo` here is\n * just exposing `fooConfig.id` under a friendly name for call sites.\n */\nexport const Program = {\n PostHogIntegration: posthogIntegrationConfig.id,\n RevenueAnalyticsSetup: revenueAnalyticsConfig.id,\n ErrorTrackingUploadSourceMaps: errorTrackingUploadSourceMapsConfig.id,\n Migration: migrationConfig.id,\n Audit: auditConfig.id,\n EventsAudit: eventsAuditConfig.id,\n Audit3000: audit3000Config.id,\n PosthogDoctor: posthogDoctorConfig.id,\n WebAnalyticsDoctor: webAnalyticsDoctorConfig.id,\n AgentSkill: agentSkillConfig.id,\n McpAdd: mcpAddConfig.id,\n McpRemove: mcpRemoveConfig.id,\n McpTutorial: mcpTutorialConfig.id,\n} as const;\n\n/** Compile-time union of every registered program id. */\nexport type ProgramId = (typeof PROGRAM_REGISTRY)[number]['id'];\n\n/**\n * Look up a program config by its id. `ProgramId` is a union of every\n * registered id, so the lookup is statically guaranteed to find a match\n * — the `!` is a load-bearing assertion of that invariant, not a hope.\n */\nexport function getProgramConfig(id: ProgramId): ProgramConfig {\n return PROGRAM_REGISTRY.find((c) => c.id === id)!;\n}\n\n/** A program config that is exposed as a CLI subcommand. */\nexport type SubcommandProgram = ProgramConfig & { command: string };\n\n/** All program configs that are exposed as CLI subcommands. */\nexport function getSubcommandPrograms(): SubcommandProgram[] {\n return PROGRAM_REGISTRY.filter(\n (c): c is SubcommandProgram => c.command != null,\n );\n}\n","import type { Arguments } from 'yargs';\nimport { setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport { Program } from '@lib/programs/program-registry';\nimport { VERSION } from '@lib/version';\nimport type { Command } from '../command';\n\nexport const mcpAddCommand: Command = {\n name: 'add',\n description: 'Install PostHog MCP server to supported clients',\n options: {\n local: {\n default: false,\n describe: 'Add local development MCP server (http://localhost:8787)',\n type: 'boolean',\n },\n features: {\n describe: 'Comma-separated list of features to enable (default: all)',\n type: 'string',\n },\n 'api-key': {\n describe: 'PostHog personal API key (phx_xxx) for MCP authentication',\n type: 'string',\n },\n },\n handler: runMcpAdd,\n};\n\nfunction runMcpAdd(argv: Arguments): void {\n const features = parseFeatures(argv.features);\n void (async () => {\n const { readApiKeyFromEnv } = await import('@utils/env-api-key');\n const apiKey = (argv.apiKey as string | undefined) || readApiKeyFromEnv();\n const debug = argv.debug as boolean | undefined;\n const localMcp = argv.local as boolean | undefined;\n\n try {\n const { startTUI } = await import('@ui/tui/start-tui');\n const { buildSession } = await import('@lib/wizard-session');\n const tui = startTUI(VERSION, Program.McpAdd);\n tui.store.session = buildSession({\n debug,\n localMcp,\n mcpFeatures: features,\n apiKey,\n });\n } catch (error) {\n if (!isTUIUnavailable(error)) throw error;\n setUI(new LoggingUI());\n const { addMCPServerToClientsStep } = await import(\n '@steps/add-mcp-server-to-clients/index'\n );\n await addMCPServerToClientsStep({ local: localMcp, features, apiKey });\n }\n })();\n}\n\n/**\n * Ink throws \"Raw mode is not supported\" when stdin has no TTY (piped input,\n * CI, some IDE terminals). That is the only TUI failure we degrade to\n * LoggingUI for — any other error from the TUI path is a real bug and must\n * surface rather than be silently swallowed.\n */\nfunction isTUIUnavailable(error: unknown): boolean {\n return (\n error instanceof Error && /raw mode is not supported/i.test(error.message)\n );\n}\n\nfunction parseFeatures(raw: unknown): string[] | undefined {\n if (typeof raw !== 'string') return undefined;\n return raw\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n}\n","import type { Arguments } from 'yargs';\nimport { setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport { Program } from '@lib/programs/program-registry';\nimport { VERSION } from '@lib/version';\nimport type { Command } from '../command';\n\nexport const mcpRemoveCommand: Command = {\n name: 'remove',\n description: 'Remove PostHog MCP server from supported clients',\n options: {\n local: {\n default: false,\n describe: 'Remove local development MCP server (http://localhost:8787)',\n type: 'boolean',\n },\n },\n handler: runMcpRemove,\n};\n\nfunction runMcpRemove(argv: Arguments): void {\n void (async () => {\n const debug = argv.debug as boolean | undefined;\n const localMcp = argv.local as boolean | undefined;\n\n try {\n const { startTUI } = await import('@ui/tui/start-tui');\n const { buildSession } = await import('@lib/wizard-session');\n const tui = startTUI(VERSION, Program.McpRemove);\n tui.store.session = buildSession({ debug, localMcp });\n } catch {\n setUI(new LoggingUI());\n const { removeMCPServerFromClientsStep } = await import(\n '@steps/add-mcp-server-to-clients/index'\n );\n await removeMCPServerFromClientsStep({ local: localMcp });\n }\n })();\n}\n","import type { Arguments } from 'yargs';\nimport { getUI, setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport { Program } from '@lib/programs/program-registry';\nimport { VERSION } from '@lib/version';\nimport type { Command } from '../command';\n\nexport const mcpTutorialCommand: Command = {\n name: 'tutorial',\n description: 'Try the PostHog MCP with your agent (no install needed)',\n options: {\n local: {\n default: false,\n describe:\n 'Point the tutorial at the local MCP server (http://localhost:8787)',\n type: 'boolean',\n },\n },\n handler: runMcpTutorial,\n};\n\nfunction runMcpTutorial(argv: Arguments): void {\n void (async () => {\n const debug = argv.debug as boolean | undefined;\n const localMcp = argv.local as boolean | undefined;\n\n try {\n const { startTUI } = await import('@ui/tui/start-tui');\n const { buildSession } = await import('@lib/wizard-session');\n const tui = startTUI(VERSION, Program.McpTutorial);\n tui.store.session = buildSession({ debug, localMcp });\n } catch (err) {\n // TUI unavailable — the tutorial has no headless fallback.\n setUI(new LoggingUI());\n getUI().log.error(\n `The MCP tutorial requires an interactive terminal. ${\n err instanceof Error ? err.message : String(err)\n }`,\n );\n process.exit(1);\n }\n })();\n}\n","import { mcpAddCommand } from './add';\nimport { mcpRemoveCommand } from './remove';\nimport { mcpTutorialCommand } from './tutorial';\nimport type { Command } from '../command';\n\nexport const mcpCommand: Command = {\n name: 'mcp',\n description: 'MCP server management commands',\n children: [mcpAddCommand, mcpRemoveCommand, mcpTutorialCommand],\n};\n","/**\n * `--no-telemetry` flips `telemetry: false` via yargs negation;\n * `POSTHOG_WIZARD_NO_TELEMETRY` is honoured separately so the env-var\n * form documented in the README keeps working.\n */\nexport function resolveNoTelemetry(options: Record<string, unknown>): boolean {\n if (options.telemetry === false) return true;\n const env = process.env.POSTHOG_WIZARD_NO_TELEMETRY;\n if (env == null || env === '') return false;\n const norm = env.toLowerCase();\n return norm !== '0' && norm !== 'false';\n}\n","import { VERSION } from '@lib/version';\nimport { logToFile, getLogFilePath } from '@utils/debug';\nimport type { ProgramConfig } from '@lib/programs/program-step';\nimport type { startTUI as StartTUIFn } from '@ui/tui/start-tui';\nimport type { TaskStreamPush as TaskStreamPushClass } from '@lib/task-stream/task-stream-push';\nimport { resolveNoTelemetry } from './resolve-no-telemetry';\n\nconst WIZARD_VERSION = VERSION;\n\n/**\n * Run a full wizard program in the TUI. Handles the full lifecycle: start TUI,\n * build session, run detection, wait for intro gate, execute the\n * agent pipeline, wait for outro dismissal, then exit.\n */\nexport function runWizard(\n config: ProgramConfig,\n options: Record<string, unknown>,\n): void {\n let tui: ReturnType<typeof StartTUIFn> | null = null;\n let taskStream: TaskStreamPushClass | null = null;\n let onSignal: (() => void) | null = null;\n let exitInProgress = false;\n\n void (async () => {\n try {\n const installDir = (options.installDir as string) || process.cwd();\n\n const { startTUI } = await import('@ui/tui/start-tui');\n const { buildSession, RunPhase } = await import('@lib/wizard-session');\n const { TaskStreamPush } = await import('@lib/task-stream/index');\n const { PostHogDestination } = await import(\n '@lib/task-stream/destinations/posthog'\n );\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n tui = startTUI(WIZARD_VERSION, config.id as any);\n const activeTui = tui;\n\n const session = buildSession({\n debug: options.debug as boolean | undefined,\n localMcp: options.localMcp as boolean | undefined,\n installDir,\n ci: false,\n signup: options.signup as boolean | undefined,\n apiKey: options.apiKey as string | undefined,\n projectId: options.projectId as string | undefined,\n email: options.email as string | undefined,\n benchmark: options.benchmark as boolean | undefined,\n yaraReport: options.yaraReport as boolean | undefined,\n noTelemetry: resolveNoTelemetry(options),\n });\n session.programLabel = config.id;\n if (options.skillId) {\n session.skillId = options.skillId as string;\n } else if (config.skillId) {\n session.skillId = config.skillId;\n }\n\n activeTui.store.session = session;\n\n const taskStreamEnabled = !session.noTelemetry;\n taskStream = new TaskStreamPush({\n store: activeTui.store,\n programId: config.id,\n destinations: [\n new PostHogDestination({\n getCredentials: () => activeTui.store.session.credentials,\n onError: (err) => logToFile('[task-stream-push]', err.message),\n }),\n ],\n enabled: taskStreamEnabled,\n });\n const activeStream = taskStream;\n activeStream.attach();\n\n // Flush a terminal-phase push on Ctrl-C so the web app sees the\n // run ended in error rather than hanging on the last \"running\"\n // snapshot.\n let signalled = false;\n onSignal = (): void => {\n if (signalled || exitInProgress) return;\n signalled = true;\n logToFile('[run-wizard] signal received, flushing task stream');\n if (activeTui.store.session.runPhase === RunPhase.Running) {\n activeTui.store.setRunPhase(RunPhase.Error);\n }\n void activeStream\n .shutdown(2000)\n .catch((e) =>\n logToFile('[run-wizard] task stream shutdown error on signal:', e),\n )\n .finally(() => {\n try {\n activeTui.unmount();\n } catch {\n // terminal may already be torn down\n }\n process.exit(130);\n });\n };\n process.on('SIGINT', onSignal);\n process.on('SIGTERM', onSignal);\n\n await activeTui.store.runReadyHooks();\n await activeTui.store.getGate('intro');\n await activeTui.store.getGate('health-check');\n\n const skipAgent = config.run == null;\n\n if (skipAgent) {\n const { getOrAskForProjectData } = await import('@utils/setup-utils');\n const { projectApiKey, host, accessToken, projectId } =\n await getOrAskForProjectData({\n signup: session.signup,\n ci: session.ci,\n apiKey: session.apiKey,\n projectId: session.projectId,\n programId: config.id,\n });\n activeTui.store.setCredentials({\n accessToken,\n projectApiKey,\n host,\n projectId,\n });\n } else {\n const { runAgent } = await import('@lib/agent/agent-runner');\n await runAgent(config, activeTui.store.session);\n }\n\n const isDone = (): boolean =>\n skipAgent\n ? activeTui.store.session.outroDismissed\n : activeTui.store.session.skillsComplete;\n\n await new Promise<void>((resolve) => {\n const unsub = activeTui.store.subscribe(() => {\n if (isDone()) {\n unsub();\n resolve();\n }\n });\n if (isDone()) {\n unsub();\n resolve();\n }\n });\n\n exitInProgress = true;\n await activeStream.shutdown(2000);\n process.off('SIGINT', onSignal);\n process.off('SIGTERM', onSignal);\n activeTui.unmount();\n process.exit(0);\n } catch (err) {\n // File-log first — the cleanup below can throw or exit.\n logToFile('[run-wizard] FATAL:', err);\n // The task-stream debounce timer keeps the event loop alive, so\n // we have to drain it before exiting on the error path.\n exitInProgress = true;\n if (onSignal) {\n process.off('SIGINT', onSignal);\n process.off('SIGTERM', onSignal);\n }\n if (taskStream) {\n try {\n await taskStream.shutdown(2000);\n } catch {\n // ignore\n }\n }\n if (tui) {\n try {\n tui.unmount();\n } catch {\n // ignore\n }\n }\n // Print after unmount — anything printed into the alt screen is wiped.\n // eslint-disable-next-line no-console\n console.error('Wizard run failed:', err);\n // eslint-disable-next-line no-console\n console.error(`Full logs: ${getLogFilePath()}`);\n process.exit(1);\n }\n })();\n}\n","import { POSTHOG_DOCS_URL } from '@lib/constants';\nimport { getUI, setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport type { ProgramConfig } from '@lib/programs/program-step';\nimport { resolveNoTelemetry } from './resolve-no-telemetry';\n\n/**\n * The single CI validation layer: defaults region and requires api-key and\n * install-dir. Every CI entry point routes through `runWizardCI`, so this is\n * the one place these checks live. UI must be initialized before calling.\n */\nexport function validateCiOptions(options: Record<string, unknown>): void {\n if (!options.region) options.region = 'us';\n if (!options.apiKey) {\n getUI().intro('PostHog Wizard');\n getUI().log.error('CI mode requires --api-key (personal API key phx_xxx)');\n process.exit(1);\n }\n if (!options.installDir) {\n getUI().intro('PostHog Wizard');\n getUI().log.error(\n 'CI mode requires --install-dir (directory to install in)',\n );\n process.exit(1);\n }\n}\n\n/**\n * CI-mode pipeline shared by every non-interactive entry point.\n *\n * Validates flags, builds a `ci:true` session, runs `config.ciPreRun` (or the\n * program's `onReady` hooks by default), executes `runAgent`, and routes any\n * failure through `wizardAbort`. `wizardAbort` owns all exits — never add a\n * raw `process.exit` here.\n */\nexport function runWizardCI(\n config: ProgramConfig,\n options: Record<string, unknown>,\n): void {\n setUI(new LoggingUI());\n validateCiOptions(options);\n\n void (async () => {\n const path = await import('path');\n const { buildSession } = await import('@lib/wizard-session');\n const { readEnvironment } = await import('@utils/environment');\n const { readApiKeyFromEnv } = await import('@utils/env-api-key');\n const { configureLogFileFromEnvironment, logToFile } = await import(\n '@utils/debug'\n );\n const { wizardAbort, WizardError } = await import('@utils/wizard-abort');\n\n configureLogFileFromEnvironment();\n\n const env = readEnvironment();\n const apiKey =\n (options.apiKey as string) ?? readApiKeyFromEnv() ?? undefined;\n const installDir = path.isAbsolute(options.installDir as string)\n ? (options.installDir as string)\n : path.join(process.cwd(), options.installDir as string);\n\n const session = buildSession({\n debug: options.debug as boolean | undefined,\n installDir,\n ci: true,\n signup: options.signup as boolean | undefined,\n localMcp: options.localMcp as boolean | undefined,\n apiKey,\n email: options.email as string | undefined,\n projectId: options.projectId as string | undefined,\n benchmark: options.benchmark as boolean | undefined,\n yaraReport: options.yaraReport as boolean | undefined,\n noTelemetry: resolveNoTelemetry(options),\n ...env,\n });\n session.programLabel = config.id;\n if (config.skillId) {\n session.skillId = config.skillId;\n }\n const runDef = typeof config.run === 'object' ? config.run : null;\n\n getUI().intro('Welcome to the PostHog setup wizard');\n getUI().log.info(`Running ${config.id} in CI mode`);\n\n try {\n if (config.ciPreRun) {\n await config.ciPreRun(session);\n } else {\n const readyCtx = {\n session,\n setFrameworkContext: (key: string, value: unknown) => {\n session.frameworkContext[key] = value;\n },\n setFrameworkConfig: () => undefined,\n setDetectedFramework: () => undefined,\n setUnsupportedVersion: () => undefined,\n addDiscoveredFeature: () => undefined,\n setDetectionComplete: () => undefined,\n };\n for (const step of config.steps) {\n if (step.onReady) {\n await step.onReady(readyCtx);\n }\n }\n\n const detectError = session.frameworkContext.detectError as\n | { kind: string; [k: string]: unknown }\n | undefined;\n if (detectError) {\n await wizardAbort({\n message: `Prerequisites not met: ${detectError.kind}\\n\\nSee ${\n runDef?.docsUrl ?? POSTHOG_DOCS_URL\n }`,\n error: new WizardError(`${config.id} prerequisites failed`, {\n integration: config.id,\n detect_error_kind: detectError.kind,\n }),\n });\n }\n }\n\n const { runAgent } = await import('@lib/agent/agent-runner');\n await runAgent(config, session);\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const errorStack =\n error instanceof Error && error.stack ? error.stack : undefined;\n\n logToFile(`[bin.ts CI] ERROR: ${errorMessage}`);\n if (errorStack) logToFile(`[bin.ts CI] STACK: ${errorStack}`);\n\n const debugInfo = session.debug && errorStack ? `\\n\\n${errorStack}` : '';\n const docsUrl =\n session.frameworkConfig?.metadata.docsUrl ??\n runDef?.docsUrl ??\n POSTHOG_DOCS_URL;\n await wizardAbort({\n message: `Something went wrong: ${errorMessage}\\n\\nYou can read the documentation at ${docsUrl} to set up manually.${debugInfo}`,\n error: error as Error,\n });\n }\n })().catch(() => {\n process.exit(1);\n });\n}\n","/** Flags shared by every skill-based program command (integrate, audit, …). */\nexport const skillProgramOptions = {\n debug: {\n default: false,\n describe: 'Enable verbose logging',\n type: 'boolean' as const,\n },\n 'install-dir': {\n describe: 'Directory to install in',\n type: 'string' as const,\n },\n 'local-mcp': {\n default: false,\n describe: 'Use local MCP server',\n type: 'boolean' as const,\n },\n benchmark: {\n default: false,\n describe: 'Run in benchmark mode',\n type: 'boolean' as const,\n },\n 'yara-report': {\n default: false,\n describe: 'Print YARA scanner summary',\n type: 'boolean' as const,\n hidden: true,\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const integrateCommand: Command = {\n name: 'integrate',\n description: posthogIntegrationConfig.description,\n options: {\n ...skillProgramOptions,\n ...(posthogIntegrationConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n posthogIntegrationConfig.mapCliOptions?.(\n argv as Record<string, unknown>,\n ) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(posthogIntegrationConfig, options);\n } else {\n runWizard(posthogIntegrationConfig, options);\n }\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { auditConfig } from '@lib/programs/audit/index';\nimport { webAnalyticsDoctorConfig } from '@lib/programs/web-analytics-doctor/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nconst dispatchProgram = (\n config: typeof auditConfig | typeof webAnalyticsDoctorConfig,\n argv: Record<string, unknown>,\n): void => {\n const extras = config.mapCliOptions?.(argv) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(config, options);\n } else {\n runWizard(config, options);\n }\n};\n\nconst webAnalyticsCommand: Command = {\n name: webAnalyticsDoctorConfig.command!,\n description: webAnalyticsDoctorConfig.description,\n options: {\n ...skillProgramOptions,\n ...(webAnalyticsDoctorConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n dispatchProgram(webAnalyticsDoctorConfig, argv as Record<string, unknown>);\n },\n};\n\nexport const auditCommand: Command = {\n name: 'audit',\n description: auditConfig.description,\n children: [webAnalyticsCommand],\n options: {\n ...skillProgramOptions,\n ...(auditConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n dispatchProgram(auditConfig, argv as Record<string, unknown>);\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { audit3000Config } from '@lib/programs/audit-3000/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const audit3000Command: Command = {\n name: 'audit-3000',\n description: audit3000Config.description,\n options: {\n ...skillProgramOptions,\n ...(audit3000Config.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n audit3000Config.mapCliOptions?.(argv as Record<string, unknown>) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(audit3000Config, options);\n } else {\n runWizard(audit3000Config, options);\n }\n },\n};\n","import { getUI, setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport { readApiKeyFromEnv } from '@utils/env-api-key';\nimport { runWizard } from '@lib/runners';\nimport {\n posthogDoctorConfig,\n fetchHealthIssues,\n getKindMeta,\n} from '@lib/programs/posthog-doctor/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const doctorCommand: Command = {\n name: 'doctor',\n description: posthogDoctorConfig.description,\n options: {\n ...skillProgramOptions,\n ...(posthogDoctorConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n posthogDoctorConfig.mapCliOptions?.(argv as Record<string, unknown>) ??\n {};\n const options = { ...argv, ...extras };\n // doctor is otherwise a TUI-only diagnostic (it has no agent run); in CI we\n // fetch the project's health issues headlessly and report them instead.\n if (options.ci) {\n void runDoctorCI(options);\n } else {\n runWizard(posthogDoctorConfig, options);\n }\n },\n};\n\nconst SEVERITY_ORDER = { critical: 0, warning: 1, info: 2 } as const;\n\nasync function runDoctorCI(options: Record<string, unknown>): Promise<void> {\n setUI(new LoggingUI());\n const apiKey = (options.apiKey as string) ?? readApiKeyFromEnv() ?? undefined;\n if (!apiKey) {\n getUI().intro('PostHog Wizard');\n getUI().log.error('CI mode requires --api-key (personal API key phx_xxx)');\n process.exit(1);\n }\n\n getUI().intro('Welcome to the PostHog setup wizard');\n getUI().log.info('Running posthog-doctor in CI mode');\n\n try {\n const { getOrAskForProjectData } = await import('@utils/setup-utils');\n const { host, accessToken, projectId } = await getOrAskForProjectData({\n signup: false,\n ci: true,\n apiKey,\n projectId: options.projectId\n ? Number(options.projectId as string)\n : undefined,\n });\n\n const issues = await fetchHealthIssues(accessToken, host, projectId);\n if (issues.length === 0) {\n getUI().log.success('No active issues — your project looks healthy.');\n process.exit(0);\n }\n\n const sorted = [...issues].sort(\n (a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity],\n );\n getUI().log.warn(\n `${issues.length} active issue${issues.length === 1 ? '' : 's'} found:`,\n );\n for (const issue of sorted) {\n getUI().log.info(\n ` • [${issue.severity}] ${getKindMeta(issue.kind).title}`,\n );\n }\n process.exit(1);\n } catch (error) {\n const { ApiError } = await import('@lib/api');\n const message =\n error instanceof ApiError && error.statusCode === 401\n ? 'Your PostHog API key is invalid or expired.'\n : error instanceof Error\n ? error.message\n : String(error);\n getUI().log.error(`Doctor failed: ${message}`);\n process.exit(1);\n }\n}\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { migrationConfig } from '@lib/programs/migration/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const migrateCommand: Command = {\n name: 'migrate',\n description: migrationConfig.description,\n options: {\n ...skillProgramOptions,\n ...(migrationConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n migrationConfig.mapCliOptions?.(argv as Record<string, unknown>) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(migrationConfig, options);\n } else {\n runWizard(migrationConfig, options);\n }\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { eventsAuditConfig } from '@lib/programs/events-audit/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const eventsAuditCommand: Command = {\n name: 'events-audit',\n description: eventsAuditConfig.description,\n options: {\n ...skillProgramOptions,\n ...(eventsAuditConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n eventsAuditConfig.mapCliOptions?.(argv as Record<string, unknown>) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(eventsAuditConfig, options);\n } else {\n runWizard(eventsAuditConfig, options);\n }\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { revenueAnalyticsConfig } from '@lib/programs/revenue-analytics/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const revenueCommand: Command = {\n name: 'revenue',\n description: revenueAnalyticsConfig.description,\n options: {\n ...skillProgramOptions,\n ...(revenueAnalyticsConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n revenueAnalyticsConfig.mapCliOptions?.(argv as Record<string, unknown>) ??\n {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(revenueAnalyticsConfig, options);\n } else {\n runWizard(revenueAnalyticsConfig, options);\n }\n },\n};\n","import { runWizard, runWizardCI } from '@lib/runners';\nimport { errorTrackingUploadSourceMapsConfig } from '@lib/programs/error-tracking-upload-source-maps/index';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\nexport const uploadSourcemapsCommand: Command = {\n // Must match ProgramConfig.command; legacy alias kept for #489 regression.\n name: [errorTrackingUploadSourceMapsConfig.command!, 'upload-sourcemaps'],\n description: errorTrackingUploadSourceMapsConfig.description,\n options: {\n ...skillProgramOptions,\n ...(errorTrackingUploadSourceMapsConfig.cliOptions ?? {}),\n },\n handler: (argv) => {\n const extras =\n errorTrackingUploadSourceMapsConfig.mapCliOptions?.(\n argv as Record<string, unknown>,\n ) ?? {};\n const options = { ...argv, ...extras };\n if (options.ci) {\n runWizardCI(errorTrackingUploadSourceMapsConfig, options);\n } else {\n runWizard(errorTrackingUploadSourceMapsConfig, options);\n }\n },\n};\n","import type { Arguments } from 'yargs';\nimport { POSTHOG_DOCS_URL } from '@lib/constants';\nimport { runWizard, runWizardCI } from '@lib/runners';\nimport { createSkillProgram } from '@lib/programs/agent-skill/index';\n\n/** Run an arbitrary context-mill skill by id (`wizard skill <id>`, headless with `--ci`). */\nexport function runSkillMode(argv: Arguments): void {\n const skillId = argv.skill as string;\n const config = createSkillProgram({\n skillId,\n command: 'skill',\n id: 'agent-skill',\n description: `Run skill: ${skillId}`,\n integrationLabel: skillId,\n successMessage: `${skillId} completed!`,\n reportFile: `posthog-${skillId}-report.md`,\n docsUrl: POSTHOG_DOCS_URL,\n spinnerMessage: `Running ${skillId}...`,\n estimatedDurationMinutes: 5,\n });\n const options = { ...argv, skillId };\n if (argv.ci) {\n runWizardCI(config, options);\n } else {\n runWizard(config, options);\n }\n}\n","import type { Arguments } from 'yargs';\nimport { runSkillMode } from './basic-integration/skill';\nimport { skillProgramOptions } from './skill-program-options';\nimport type { Command } from './command';\n\n/** Read the `<skill-name>` positional (yargs camelCases the hyphenated key). */\nfunction readSkillName(argv: Arguments): string {\n return String(argv.skillName ?? argv['skill-name'] ?? '').trim();\n}\n\n/**\n * `wizard skill <skill-name>` — run a single context-mill skill by id.\n *\n * Replaces the old `--skill=<id>` flag on the default command. The skill id\n * is fetched from context-mill's release at runtime (same mechanism the flag\n * used), so any published skill id works. Pass `--ci` to run headlessly.\n */\nexport const skillCommand: Command = {\n name: 'skill <skill-name>',\n description: 'Run a specific context-mill skill by name',\n options: {\n ...skillProgramOptions,\n },\n // yargs already requires the positional, but an explicitly-empty value\n // (`wizard skill \"\"`) would otherwise slip through to a broken run with no\n // skill id. Reject it with the same friendly message the old flag gave.\n check: (argv) => {\n if (!readSkillName(argv)) {\n throw new Error(\n 'skill needs a skill name, e.g. `wizard skill audit-events`',\n );\n }\n return true;\n },\n handler: (argv) => {\n // runSkillMode reads `argv.skill`; bridge the positional onto it.\n runSkillMode({ ...argv, skill: readSkillName(argv) });\n },\n};\n","#!/usr/bin/env node\nimport { satisfies } from 'semver';\n\nconst NODE_VERSION_RANGE = '>=18.17.0';\n\n// Have to run this above the other imports because they are importing clack that\n// has the problematic imports.\nif (!satisfies(process.version, NODE_VERSION_RANGE)) {\n // eslint-disable-next-line no-console\n console.log(\n `PostHog wizard requires Node.js ${NODE_VERSION_RANGE}. You are using Node.js ${process.version}. Please upgrade your Node.js version.`,\n );\n process.exit(1);\n}\n\n// Test mock server — only loaded when NODE_ENV is 'test'.\n// In production builds, tsdown replaces process.env.NODE_ENV with 'production',\n// making this block dead code.\nif (process.env.NODE_ENV === 'test') {\n void (async () => {\n try {\n const { server } = await import('./e2e-tests/mocks/server.js');\n server.listen({\n onUnhandledRequest: 'bypass',\n });\n } catch (error) {\n // Mock server import failed - this can happen during non-E2E tests\n }\n })();\n}\n\nimport { Wizard } from './src/wizard';\nimport { basicIntegrationCommand } from './src/commands/basic-integration';\nimport { mcpCommand } from './src/commands/mcp';\nimport { integrateCommand } from './src/commands/integrate';\nimport { auditCommand } from './src/commands/audit';\nimport { audit3000Command } from './src/commands/audit-3000';\nimport { doctorCommand } from './src/commands/doctor';\nimport { migrateCommand } from './src/commands/migrate';\nimport { eventsAuditCommand } from './src/commands/events-audit';\nimport { revenueCommand } from './src/commands/revenue';\nimport { uploadSourcemapsCommand } from './src/commands/upload-sourcemaps';\nimport { skillCommand } from './src/commands/skill';\n\nWizard.use(basicIntegrationCommand)\n .use(mcpCommand)\n .use(integrateCommand)\n .use(auditCommand)\n .use(audit3000Command)\n .use(doctorCommand)\n .use(migrateCommand)\n .use(eventsAuditCommand)\n .use(revenueCommand)\n .use(uploadSourcemapsCommand)\n .use(skillCommand)\n .init();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,YAAY,MAA4C;AAEtE,SADgC,OAAO,SAAS,WAAW,CAAC,KAAK,GAAG,MACxD,KAAK,MAAM,EAAE,MAAM,CAAC,MAAM,MAAM,CAAC,GAAG;;AAGlD,SAAgB,gBACd,KACA,YACe;AACf,QAAO;EACL,SAAS,IAAI;EACb,UAAU,IAAI;EACd,UAAU,MAAY;GACpB,IAAI,OAAO,IAAI,UAAU,EAAE,QAAQ,IAAI,QAAQ,GAAG;AAClD,OAAI,IAAI,MAAO,QAAO,KAAK,MAAM,IAAI,MAAM;AAC3C,QAAK,MAAM,CAAC,OAAO,gBAAgB,IAAI,YAAY,EAAE,CACnD,QAAO,KAAK,QAAQ,OAAO,YAAY;GAEzC,MAAM,UAAU,CAAC,GAAG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