@posthog/wizard 2.11.0 → 2.13.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 (86) hide show
  1. package/README.md +48 -7
  2. package/dist/{McpScreen-DvUncZBi.js → AuditChecksViewer-B0J7zcY2.js} +434 -22
  3. package/dist/AuditChecksViewer-B0J7zcY2.js.map +1 -0
  4. package/dist/{add-mcp-server-to-clients-Br1hDRiB.js → add-mcp-server-to-clients-CUNR00bB.js} +5 -5
  5. package/dist/{add-mcp-server-to-clients-Br1hDRiB.js.map → add-mcp-server-to-clients-CUNR00bB.js.map} +1 -1
  6. package/dist/{readiness-gQvQNCeL.js → agent-interface-CV0-vtxj.js} +328 -462
  7. package/dist/agent-interface-CV0-vtxj.js.map +1 -0
  8. package/dist/{agent-runner-fWYFO4H0.js → agent-runner-LvVQH31D.js} +21 -31
  9. package/dist/{agent-runner-fWYFO4H0.js.map → agent-runner-LvVQH31D.js.map} +1 -1
  10. package/dist/analytics-BH7bEHQR.js +2 -0
  11. package/dist/analytics-VM7laaFx.js +123 -0
  12. package/dist/analytics-VM7laaFx.js.map +1 -0
  13. package/dist/bin.js +529 -42
  14. package/dist/bin.js.map +1 -1
  15. package/dist/{debug-D-0xueVl.js → debug-BdcTB7EF.js} +1 -1
  16. package/dist/debug-Cqi6nVfX.js +686 -0
  17. package/dist/debug-Cqi6nVfX.js.map +1 -0
  18. package/dist/{defaults-CPH6eWhN.js → defaults-GbLPuHxj.js} +1 -1
  19. package/dist/{defaults-CPH6eWhN.js.map → defaults-GbLPuHxj.js.map} +1 -1
  20. package/dist/{detection-B7GNzve-.js → detection-CSjmal-X.js} +3 -3
  21. package/dist/{detection-B7GNzve-.js.map → detection-CSjmal-X.js.map} +1 -1
  22. package/dist/{env-api-key-DU8uIEvo.js → env-api-key-D5G2PrXW.js} +1 -1
  23. package/dist/{env-api-key-DU8uIEvo.js.map → env-api-key-D5G2PrXW.js.map} +1 -1
  24. package/dist/{file-DhSBlq-x.js → file-8iNrXHkG.js} +2 -2
  25. package/dist/{file-DhSBlq-x.js.map → file-8iNrXHkG.js.map} +1 -1
  26. package/dist/{file-utils-Dy9JncCo.js → file-utils-DnTSiTJw.js} +1 -1
  27. package/dist/{file-utils-Dy9JncCo.js.map → file-utils-DnTSiTJw.js.map} +1 -1
  28. package/dist/{package-manager-D3Lo6nXf.js → package-manager-CD8RQW-e.js} +2 -2
  29. package/dist/{package-manager-D3Lo6nXf.js.map → package-manager-CD8RQW-e.js.map} +1 -1
  30. package/dist/paths-DJS47p5x.js +26 -0
  31. package/dist/paths-DJS47p5x.js.map +1 -0
  32. package/dist/{posthog-integration-D4SRhJIQ.js → posthog-integration-BL21S3T6.js} +41 -13
  33. package/dist/posthog-integration-BL21S3T6.js.map +1 -0
  34. package/dist/{posthog-ByrpqEjN.js → posthog-vm0k9PKS.js} +1 -1
  35. package/dist/{posthog-ByrpqEjN.js.map → posthog-vm0k9PKS.js.map} +1 -1
  36. package/dist/provisioning-BdQ1ONIg.js +2 -0
  37. package/dist/provisioning-g9aoVIEd.js +166 -0
  38. package/dist/provisioning-g9aoVIEd.js.map +1 -0
  39. package/dist/{registry-DaPKstG3.js → registry-BaMEaAKd.js} +4 -5
  40. package/dist/{registry-DaPKstG3.js.map → registry-BaMEaAKd.js.map} +1 -1
  41. package/dist/{router-SgzmfLGi.js → router-COhhuIW3.js} +4 -3
  42. package/dist/router-COhhuIW3.js.map +1 -0
  43. package/dist/{setup-utils-y4s-3uKT.js → setup-utils-CNV7FSlY.js} +11 -150
  44. package/dist/setup-utils-CNV7FSlY.js.map +1 -0
  45. package/dist/setup-utils-CU4FIqjB.js +2 -0
  46. package/dist/{start-playground-g1TxpCZ5.js → start-playground-C9GWnVdM.js} +102 -7
  47. package/dist/start-playground-C9GWnVdM.js.map +1 -0
  48. package/dist/start-tui-B_zwutLe.js +4195 -0
  49. package/dist/start-tui-B_zwutLe.js.map +1 -0
  50. package/dist/{steps-D1zKDqAo.js → steps-Dawz7k3T.js} +8 -8
  51. package/dist/steps-Dawz7k3T.js.map +1 -0
  52. package/dist/{task-stream-DX_jKDQu.js → task-stream-CX7Uf6EM.js} +4 -4
  53. package/dist/{task-stream-DX_jKDQu.js.map → task-stream-CX7Uf6EM.js.map} +1 -1
  54. package/dist/{telemetry-CyUUSAYy.js → telemetry-D6bjWA-A.js} +2 -2
  55. package/dist/{telemetry-CyUUSAYy.js.map → telemetry-D6bjWA-A.js.map} +1 -1
  56. package/dist/{wizard-abort-Buodno3f.js → wizard-abort-CJkNkSjT.js} +6 -4
  57. package/dist/{wizard-abort-Buodno3f.js.map → wizard-abort-CJkNkSjT.js.map} +1 -1
  58. package/dist/{wizard-abort-DZmO_sIZ.js → wizard-abort-Dl0BkqhT.js} +1 -1
  59. package/dist/wizard-session-BQC9vy9Z.js +2 -0
  60. package/dist/{wizard-session-D5bggSsu.js → wizard-session-BcNJTl2I.js} +1 -1
  61. package/dist/{wizard-session-D5bggSsu.js.map → wizard-session-BcNJTl2I.js.map} +1 -1
  62. package/dist/{wizard-ui-BExOjdjA.js → wizard-ui-YdGFRyu_.js} +1 -1
  63. package/dist/wizard-ui-YdGFRyu_.js.map +1 -0
  64. package/npm-shrinkwrap.json +2 -2
  65. package/package.json +1 -1
  66. package/dist/McpScreen-DvUncZBi.js.map +0 -1
  67. package/dist/agent-skill-DJOzDaQV.js +0 -59
  68. package/dist/agent-skill-DJOzDaQV.js.map +0 -1
  69. package/dist/analytics-CfAUlt6-.js +0 -2
  70. package/dist/analytics-D3rY3TaN.js +0 -210
  71. package/dist/analytics-D3rY3TaN.js.map +0 -1
  72. package/dist/debug-gWEjmYVV.js +0 -203
  73. package/dist/debug-gWEjmYVV.js.map +0 -1
  74. package/dist/paths-BL-x2rFy.js +0 -16
  75. package/dist/paths-BL-x2rFy.js.map +0 -1
  76. package/dist/posthog-integration-D4SRhJIQ.js.map +0 -1
  77. package/dist/readiness-gQvQNCeL.js.map +0 -1
  78. package/dist/router-SgzmfLGi.js.map +0 -1
  79. package/dist/setup-utils-_ONxN-TT.js +0 -2
  80. package/dist/setup-utils-y4s-3uKT.js.map +0 -1
  81. package/dist/start-playground-g1TxpCZ5.js.map +0 -1
  82. package/dist/start-tui-CQef69NR.js +0 -2167
  83. package/dist/start-tui-CQef69NR.js.map +0 -1
  84. package/dist/steps-D1zKDqAo.js.map +0 -1
  85. package/dist/wizard-session-COhklXAF.js +0 -2
  86. package/dist/wizard-ui-BExOjdjA.js.map +0 -1
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","names":[],"sources":["../src/utils/environment.ts","../src/lib/workflows/revenue-analytics/detect.ts","../src/lib/workflows/revenue-analytics/steps.ts","../src/lib/workflows/revenue-analytics/index.ts","../src/lib/workflows/posthog-doctor/steps.ts","../src/lib/workflows/posthog-doctor/types.ts","../src/lib/workflows/posthog-doctor/fetch.ts","../src/lib/workflows/posthog-doctor/kind-metadata.ts","../src/lib/workflows/posthog-doctor/index.ts","../src/lib/workflows/workflow-registry.ts","../bin.ts"],"sourcesContent":["import readEnvModule from 'read-env';\n\nconst readEnv =\n typeof readEnvModule === 'function'\n ? readEnvModule\n : (readEnvModule as any).default;\nimport { tryGetPackageJson } from './setup-utils';\nimport type { WizardOptions } from './types';\nimport fg from 'fast-glob';\nimport { IS_DEV } from '../lib/constants';\n\nexport function isNonInteractiveEnvironment(): boolean {\n if (IS_DEV) {\n return false;\n }\n\n if (!process.stdout.isTTY || !process.stderr.isTTY) {\n return true;\n }\n\n return false;\n}\n\nexport function readEnvironment(): Record<string, unknown> {\n const result = readEnv('POSTHOG_WIZARD');\n\n return result;\n}\n\nexport async function detectEnvVarPrefix(\n options: WizardOptions,\n): Promise<string> {\n const packageJson = await tryGetPackageJson(options);\n if (!packageJson) return 'VITE_PUBLIC_';\n\n const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };\n const has = (name: string) => name in deps;\n const hasAnyFile = async (patterns: string[]) => {\n const matches = await fg(patterns, {\n cwd: options.installDir,\n absolute: false,\n onlyFiles: true,\n ignore: ['**/node_modules/**'],\n });\n return matches.length > 0;\n };\n\n // --- Next.js\n if (has('next') || (await hasAnyFile(['**/next.config.{js,ts,mjs,cjs}']))) {\n return 'NEXT_PUBLIC_';\n }\n\n // --- Create React App\n if (\n has('react-scripts') ||\n has('create-react-app') ||\n (await hasAnyFile(['**/config-overrides.js']))\n ) {\n return 'REACT_APP_';\n }\n\n // --- Vite (vanilla, TanStack, Solid, etc.)\n // Note: Vite does not need PUBLIC_ but we use it to follow the docs, to improve the chances of an LLM getting it right.\n if (has('vite') || (await hasAnyFile(['**/vite.config.{js,ts,mjs,cjs}']))) {\n return 'VITE_PUBLIC_';\n }\n\n // --- SvelteKit\n if (\n has('@sveltejs/kit') ||\n (await hasAnyFile(['**/svelte.config.{js,ts}']))\n ) {\n return 'PUBLIC_';\n }\n\n // --- TanStack Start (uses Vite)\n if (\n has('@tanstack/start') ||\n (await hasAnyFile(['**/tanstack.config.{js,ts}']))\n ) {\n return 'VITE_PUBLIC_';\n }\n\n // --- SolidStart (uses Vite)\n if (has('solid-start') || (await hasAnyFile(['**/solid.config.{js,ts}']))) {\n return 'VITE_PUBLIC_';\n }\n\n // --- Astro\n if (has('astro') || (await hasAnyFile(['**/astro.config.{js,ts,mjs}']))) {\n return 'PUBLIC_';\n }\n\n // We default to Vite if we can't detect a specific framework, since it's the most commonly used.\n return 'VITE_PUBLIC_';\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.js';\nimport type { WizardSession } from '../../wizard-session.js';\nimport type { AbortCase } from '../../agent/agent-runner.js';\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 workflow step list.\n *\n * The detect step checks for PostHog + Stripe SDKs. The skill install\n * and agent run live in the workflow runner (see agent-runner.ts).\n */\n\nimport type { Workflow } from '../workflow-step.js';\nimport { RunPhase } from '../../wizard-session.js';\nimport { detectRevenuePrerequisites } from './detect.js';\n\nexport const REVENUE_ANALYTICS_WORKFLOW: Workflow = [\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 screen: 'revenue-intro',\n gate: (session) => session.setupConfirmed,\n },\n {\n id: 'auth',\n label: 'Authentication',\n screen: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Revenue analytics',\n screen: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screen: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screen: 'keep-skills',\n },\n];\n","import type { WorkflowConfig } from '../workflow-step.js';\nimport { REVENUE_ANALYTICS_WORKFLOW } from './steps.js';\nimport { REVENUE_ABORT_CASES } from './detect.js';\n\nexport const revenueAnalyticsConfig: WorkflowConfig = {\n command: 'revenue',\n description: 'Set up PostHog revenue analytics (e.g. Stripe integration)',\n flowKey: 'revenue-analytics-setup',\n steps: REVENUE_ANALYTICS_WORKFLOW,\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_WORKFLOW } from './steps.js';\nexport {\n detectRevenuePrerequisites,\n POSTHOG_SDKS,\n STRIPE_SDKS,\n type RevenueDetectError,\n} from './detect.js';\n","import type { Workflow } from '../workflow-step.js';\n\nexport const POSTHOG_DOCTOR_WORKFLOW: Workflow = [\n {\n id: 'intro',\n label: 'Welcome',\n screen: 'doctor-intro',\n gate: (session) => session.setupConfirmed,\n },\n {\n id: 'auth',\n label: 'Authentication',\n screen: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'report',\n label: 'Doctor report',\n screen: 'doctor-report',\n isComplete: (session) => session.outroData !== null,\n },\n {\n id: 'outro',\n label: 'Done',\n screen: '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 '../../api';\nimport { WIZARD_USER_AGENT } from '../../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 '../../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 { WorkflowConfig } from '../workflow-step.js';\nimport { POSTHOG_DOCTOR_WORKFLOW } from './steps.js';\n\nexport const posthogDoctorConfig: WorkflowConfig = {\n command: 'doctor',\n description:\n 'Diagnose your PostHog project for configuration issues and setup warnings',\n flowKey: 'posthog-doctor',\n steps: POSTHOG_DOCTOR_WORKFLOW,\n};\n\nexport { POSTHOG_DOCTOR_WORKFLOW } 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","/**\n * Central registry of all wizard workflows.\n *\n * Adding a new workflow:\n * 1. Create src/lib/workflows/<name>/ with index.ts exporting a WorkflowConfig\n * 2. Import and add it to WORKFLOW_REGISTRY below\n * 3. Add a matching Flow enum entry in src/ui/tui/flows.ts\n * 4. (If custom intro screen) add to src/ui/tui/screen-registry.tsx\n *\n * flows.ts, store.ts, and bin.ts all derive their wiring from this array —\n * no need to touch those files when adding a workflow.\n */\n\nimport type { WorkflowConfig } from './workflow-step.js';\nimport { posthogIntegrationConfig } from './posthog-integration/index.js';\nimport { revenueAnalyticsConfig } from './revenue-analytics/index.js';\nimport { posthogDoctorConfig } from './posthog-doctor/index.js';\n\nexport const WORKFLOW_REGISTRY: WorkflowConfig[] = [\n posthogIntegrationConfig,\n revenueAnalyticsConfig,\n posthogDoctorConfig,\n];\n\n/** Look up a workflow config by its flowKey. */\nexport function getWorkflowConfig(flowKey: string): WorkflowConfig | undefined {\n return WORKFLOW_REGISTRY.find((c) => c.flowKey === flowKey);\n}\n\n/** All workflow configs that are exposed as CLI subcommands. */\nexport function getSubcommandWorkflows(): WorkflowConfig[] {\n return WORKFLOW_REGISTRY.filter((c) => c.command != null);\n}\n","#!/usr/bin/env node\nimport { satisfies } from 'semver';\nimport { red } from './src/utils/logging';\n\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { VERSION } from './src/lib/version.js';\n\nconst WIZARD_VERSION = VERSION;\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 red(\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\nimport { isNonInteractiveEnvironment } from './src/utils/environment';\nimport { getUI, setUI } from './src/ui';\nimport { LoggingUI } from './src/ui/logging-ui';\nimport { getSubcommandWorkflows } from './src/lib/workflows/workflow-registry';\nimport type { WorkflowConfig } from './src/lib/workflows/workflow-step';\nimport type { WizardSession } from './src/lib/wizard-session';\nimport { POSTHOG_DOCS_URL } from './src/lib/constants';\nimport { runtimeEnv } from '@env';\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\n/** Shared yargs options for skill-based workflow subcommands. */\nconst skillSubcommandOptions = {\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\nconst cli = yargs(hideBin(process.argv))\n .env('POSTHOG_WIZARD')\n // global options\n .options({\n debug: {\n default: false,\n describe: 'Enable verbose logging\\nenv: POSTHOG_WIZARD_DEBUG',\n type: 'boolean',\n },\n region: {\n describe: 'PostHog cloud region\\nenv: POSTHOG_WIZARD_REGION',\n choices: ['us', 'eu'],\n type: 'string',\n },\n default: {\n default: true,\n describe:\n 'Use default options for all prompts\\nenv: POSTHOG_WIZARD_DEFAULT',\n type: 'boolean',\n },\n signup: {\n default: false,\n describe:\n 'Create a new PostHog account during setup\\nenv: POSTHOG_WIZARD_SIGNUP',\n type: 'boolean',\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',\n },\n ci: {\n default: false,\n describe:\n 'Enable CI mode for non-interactive execution\\nenv: POSTHOG_WIZARD_CI',\n type: 'boolean',\n },\n 'api-key': {\n describe:\n 'PostHog personal API key (phx_xxx) for authentication\\nenv: POSTHOG_WIZARD_API_KEY',\n type: 'string',\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',\n },\n email: {\n describe:\n 'Email address for signup (used with --signup)\\nenv: POSTHOG_WIZARD_EMAIL',\n type: 'string',\n },\n })\n .command(\n ['$0'],\n 'Run the PostHog setup wizard',\n (yargs) => {\n return yargs.options({\n 'force-install': {\n default: false,\n describe:\n 'Force install packages even if peer dependency checks fail\\nenv: POSTHOG_WIZARD_FORCE_INSTALL',\n type: 'boolean',\n },\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 integration: {\n describe: 'Integration to set up',\n choices: [\n 'nextjs',\n 'astro',\n 'react',\n 'svelte',\n 'react-native',\n 'tanstack-router',\n 'tanstack-start',\n ],\n type: 'string',\n },\n menu: {\n default: false,\n describe:\n 'Show menu for manual integration selection instead of auto-detecting\\nenv: POSTHOG_WIZARD_MENU',\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 });\n },\n (argv) => {\n const options = { ...argv };\n\n // CI mode validation and TTY check\n if (options.ci) {\n if (!options.region) options.region = 'us';\n if (!options.apiKey) {\n setUI(new LoggingUI());\n getUI().intro('PostHog Wizard');\n getUI().log.error(\n 'CI mode requires --api-key (personal API key phx_xxx)',\n );\n process.exit(1);\n return;\n }\n if (!options.installDir) {\n setUI(new LoggingUI());\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 return;\n }\n void (async () => {\n const { posthogIntegrationConfig } = await import(\n './src/lib/workflows/posthog-integration/index.js'\n );\n const { FRAMEWORK_REGISTRY } = await import('./src/lib/registry.js');\n const { detectFramework, gatherFrameworkContext } = await import(\n './src/lib/detection/index.js'\n );\n const { analytics } = await import('./src/utils/analytics.js');\n const { wizardAbort } = await import('./src/utils/wizard-abort.js');\n\n // preRun: honor --integration, else auto-detect, then gather\n // framework context. Bypasses onReady hooks by design.\n runWizardCI(posthogIntegrationConfig, options, async (session) => {\n const integration =\n session.integration ??\n (await detectFramework(session.installDir));\n if (!integration) {\n await wizardAbort({\n message:\n 'Could not auto-detect your framework. Please specify --integration on the command line.',\n });\n return;\n }\n session.integration = integration;\n analytics.setTag('integration', integration);\n\n const frameworkConfig = FRAMEWORK_REGISTRY[integration];\n session.frameworkConfig = frameworkConfig;\n\n const context = await gatherFrameworkContext(frameworkConfig, {\n installDir: session.installDir,\n debug: session.debug,\n forceInstall: session.forceInstall,\n default: false,\n signup: session.signup,\n localMcp: session.localMcp,\n ci: true,\n menu: session.menu,\n benchmark: session.benchmark,\n yaraReport: session.yaraReport,\n });\n for (const [key, value] of Object.entries(context)) {\n if (!(key in session.frameworkContext)) {\n session.frameworkContext[key] = value;\n }\n }\n });\n })().catch(() => {\n process.exit(1);\n });\n } else if (isNonInteractiveEnvironment()) {\n // Non-interactive non-CI: error out\n getUI().intro(`PostHog Wizard`);\n getUI().log.error(\n 'This installer requires an interactive terminal (TTY) to run.\\n' +\n 'It appears you are running in a non-interactive environment.\\n' +\n 'Please run the wizard in an interactive terminal.\\n\\n' +\n 'For CI/CD environments, use --ci mode:\\n' +\n ' npx @posthog/wizard --ci --region us --api-key phx_xxx',\n );\n process.exit(1);\n } else if (options.playground) {\n // Playground mode: launch the TUI primitives playground\n void (async () => {\n const { startPlayground } = await import(\n './src/ui/tui/playground/start-playground.js'\n );\n (startPlayground as (version: string) => void)(WIZARD_VERSION);\n })();\n } else if (options.skill) {\n // Run a specific skill by ID\n void (async () => {\n const { createSkillWorkflow } = await import(\n './src/lib/workflows/agent-skill/index.js'\n );\n const skillId = options.skill as string;\n const config = createSkillWorkflow({\n skillId,\n command: 'skill',\n flowKey: '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 runWizard(config, { ...options, skillId });\n })();\n } else {\n // Interactive TTY: run core-integration through the unified workflow path.\n // Same codepath as `npx @posthog/wizard integrate`.\n void (async () => {\n const { posthogIntegrationConfig } = await import(\n './src/lib/workflows/posthog-integration/index.js'\n );\n runWizard(posthogIntegrationConfig, options);\n })();\n }\n },\n )\n .command('mcp <command>', 'MCP server management commands', (yargs) => {\n return yargs\n .command(\n 'add',\n 'Install PostHog MCP server to supported clients',\n (yargs) => {\n return yargs.options({\n local: {\n default: false,\n describe:\n 'Add local development MCP server (http://localhost:8787)',\n type: 'boolean',\n },\n features: {\n describe:\n 'Comma-separated list of features to enable (default: all)',\n type: 'string',\n },\n 'api-key': {\n describe:\n 'PostHog personal API key (phx_xxx) for MCP authentication',\n type: 'string',\n },\n });\n },\n (argv) => {\n const options = { ...argv };\n const mcpFeatures = options.features\n ?.split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n void (async () => {\n const { readApiKeyFromEnv } = await import(\n './src/utils/env-api-key.js'\n );\n const apiKey =\n (options.apiKey as string | undefined) || readApiKeyFromEnv();\n\n try {\n const { startTUI } = await import('./src/ui/tui/start-tui.js');\n const { buildSession } = await import(\n './src/lib/wizard-session.js'\n );\n\n const { Flow } = await import('./src/ui/tui/router.js');\n const tui = startTUI(WIZARD_VERSION, Flow.McpAdd);\n const session = buildSession({\n debug: options.debug,\n localMcp: options.local,\n mcpFeatures,\n apiKey,\n });\n tui.store.session = session;\n } catch {\n // TUI unavailable — fallback to logging\n setUI(new LoggingUI());\n const { addMCPServerToClientsStep } = await import(\n './src/steps/add-mcp-server-to-clients/index.js'\n );\n await addMCPServerToClientsStep({\n local: options.local,\n features: mcpFeatures,\n apiKey,\n });\n }\n })();\n },\n )\n .command(\n 'remove',\n 'Remove PostHog MCP server from supported clients',\n (yargs) => {\n return yargs.options({\n local: {\n default: false,\n describe:\n 'Remove local development MCP server (http://localhost:8787)',\n type: 'boolean',\n },\n });\n },\n (argv) => {\n const options = { ...argv };\n void (async () => {\n try {\n const { startTUI } = await import('./src/ui/tui/start-tui.js');\n const { buildSession } = await import(\n './src/lib/wizard-session.js'\n );\n\n const { Flow } = await import('./src/ui/tui/router.js');\n const tui = startTUI(WIZARD_VERSION, Flow.McpRemove);\n const session = buildSession({\n debug: options.debug,\n localMcp: options.local,\n });\n tui.store.session = session;\n } catch {\n // TUI unavailable — fallback to logging\n setUI(new LoggingUI());\n const { removeMCPServerFromClientsStep } = await import(\n './src/steps/add-mcp-server-to-clients/index.js'\n );\n await removeMCPServerFromClientsStep({\n local: options.local,\n });\n }\n })();\n },\n )\n .demandCommand(1, 'You must specify a subcommand (add or remove)')\n .help();\n });\n\n// ── Skill-based workflow subcommands (derived from registry) ─────────\nfor (const wfConfig of getSubcommandWorkflows()) {\n cli.command(\n wfConfig.command!,\n wfConfig.description,\n (y) => y.options(skillSubcommandOptions),\n (argv) => {\n const options = { ...argv };\n if (options.ci) {\n runWizardCI(wfConfig, options);\n } else {\n runWizard(wfConfig, options);\n }\n },\n );\n}\n\ncli\n .help()\n .alias('help', 'h')\n .version()\n .alias('version', 'v')\n .wrap(process.stdout.isTTY ? cli.terminalWidth() : 80).argv;\n\n/**\n * Run a full wizard workflow 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 */\nfunction runWizard(\n config: WorkflowConfig,\n options: Record<string, unknown>,\n): void {\n void (async () => {\n try {\n const installDir = (options.installDir as string) || process.cwd();\n\n const { startTUI } = await import('./src/ui/tui/start-tui.js');\n const { buildSession } = await import('./src/lib/wizard-session.js');\n const { TaskStreamPush } = await import('./src/lib/task-stream/index.js');\n const { FileDestination } = await import(\n './src/lib/task-stream/destinations/file.js'\n );\n const { PostHogDestination } = await import(\n './src/lib/task-stream/destinations/posthog.js'\n );\n const { analytics } = await import('./src/utils/analytics.js');\n\n const tui = startTUI(WIZARD_VERSION, config.flowKey as any);\n\n const session = buildSession({\n debug: options.debug as boolean | undefined,\n forceInstall: options.forceInstall 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 menu: options.menu as boolean | undefined,\n integration: options.integration as any,\n benchmark: options.benchmark as boolean | undefined,\n yaraReport: options.yaraReport as boolean | undefined,\n });\n session.workflowLabel = config.flowKey;\n if (options.skillId) {\n session.skillId = options.skillId as string;\n }\n\n tui.store.session = session;\n\n // Task stream — pushes state to external consumers on task changes\n const taskStream = new TaskStreamPush({\n store: tui.store,\n workflowId: config.flowKey,\n destinations: [new FileDestination(), new PostHogDestination()],\n });\n tui.store.onTasksChanged = () => void taskStream.push();\n\n await tui.store.runReadyHooks();\n await tui.store.getGate('intro');\n\n const skipAgent = config.run == null;\n\n if (skipAgent) {\n const { getOrAskForProjectData } = await import(\n './src/utils/setup-utils.js'\n );\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 tui.store.setCredentials({\n accessToken,\n projectApiKey,\n host,\n projectId,\n });\n } else {\n const { runAgent } = await import('./src/lib/agent/agent-runner.js');\n await runAgent(config, tui.store.session);\n }\n\n const isDone = (): boolean =>\n skipAgent\n ? tui.store.session.outroDismissed\n : tui.store.session.skillsComplete;\n\n await new Promise<void>((resolve) => {\n const unsub = tui.store.subscribe(() => {\n if (isDone()) {\n unsub();\n resolve();\n }\n });\n if (isDone()) {\n unsub();\n resolve();\n }\n });\n\n try {\n await taskStream.dispose();\n } catch (error) {\n analytics.captureException(error as Error);\n }\n tui.unmount();\n process.exit(0);\n } catch (err) {\n if (runtimeEnv('DEBUG') || runtimeEnv('POSTHOG_WIZARD_DEBUG')) {\n console.error('TUI init failed:', err); // eslint-disable-line no-console\n }\n }\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 `preRun` (or the\n * workflow's `onReady` hooks by default), executes `runAgent`, and\n * routes any failure through `wizardAbort`. `wizardAbort` owns all\n * exits — never add a raw `process.exit` here.\n */\nfunction runWizardCI(\n config: WorkflowConfig,\n options: Record<string, unknown>,\n preRun?: (session: WizardSession) => Promise<void>,\n): void {\n setUI(new LoggingUI());\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 void (async () => {\n const path = await import('path');\n const { buildSession } = await import('./src/lib/wizard-session.js');\n const { readEnvironment } = await import('./src/utils/environment.js');\n const { readApiKeyFromEnv } = await import('./src/utils/env-api-key.js');\n const { configureLogFileFromEnvironment, logToFile } = await import(\n './src/utils/debug.js'\n );\n const { wizardAbort, WizardError } = await import(\n './src/utils/wizard-abort.js'\n );\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 forceInstall: options.forceInstall 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 menu: options.menu as boolean | undefined,\n integration: options.integration as any, // eslint-disable-line @typescript-eslint/no-explicit-any\n projectId: options.projectId as string | undefined,\n benchmark: options.benchmark as boolean | undefined,\n yaraReport: options.yaraReport as boolean | undefined,\n ...env,\n });\n session.workflowLabel = config.flowKey;\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.flowKey} in CI mode`);\n\n try {\n if (preRun) {\n await preRun(session);\n } else {\n // Run onReady hooks against a minimal store-less context.\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 // Surface detectError written by the workflow's detect hook.\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.flowKey} prerequisites failed`, {\n integration: config.flowKey,\n detect_error_kind: detectError.kind,\n }),\n });\n }\n }\n\n const { runAgent } = await import('./src/lib/agent/agent-runner.js');\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,UACJ,OAAO,kBAAkB,aACrB,gBACC,cAAsB;AAM7B,SAAgB,8BAAuC;AAKrD,KAAI,CAAC,QAAQ,OAAO,SAAS,CAAC,QAAQ,OAAO,MAC3C,QAAO;AAGT,QAAO;;AAGT,SAAgB,kBAA2C;AAGzD,QAFe,QAAQ,iBAAiB;;;;ACV1C,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,cAAc;CACzB;CACA;CACA;CACD;;AAyBD,MAAa,sBAAmC,CAC9C;CAEE,OAAO;CACP,SAAS;CACT,MACE;CAGF,SAAS;CACV,EACD;CAEE,OAAO;CACP,SAAS;CACT,MACE;CAGF,SAAS;CACV,C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;AAC/C,OAAI,WAAY,WAAU,sBAAsB,aAAa;GAE7D,MAAM,YAAY,QAAQ,SAAS,aAAa,OAAO,eAAe;AAKtE,SAAM,YAAY;IAChB,SAAS,yBAAyB,aAAa,wCAJ/C,QAAQ,iBAAiB,SAAS,WAClC,QAAQ,WAAA,2BAGuF,sBAAsB;IAC9G;IACR,CAAC;;KAEF,CAAC,YAAY;AACf,UAAQ,KAAK,EAAE;GACf"}
1
+ {"version":3,"file":"bin.js","names":["baseConfig"],"sources":["../src/utils/environment.ts","../src/lib/workflows/revenue-analytics/detect.ts","../src/lib/workflows/revenue-analytics/steps.ts","../src/lib/workflows/revenue-analytics/index.ts","../src/lib/workflows/agent-skill/steps.ts","../src/lib/workflows/agent-skill/index.ts","../src/lib/workflows/audit/detect.ts","../src/lib/workflows/audit/seed.ts","../src/lib/workflows/audit/index.ts","../src/lib/workflows/audit-3000/index.ts","../src/lib/workflows/posthog-doctor/steps.ts","../src/lib/workflows/posthog-doctor/types.ts","../src/lib/workflows/posthog-doctor/fetch.ts","../src/lib/workflows/posthog-doctor/kind-metadata.ts","../src/lib/workflows/posthog-doctor/index.ts","../src/lib/workflows/workflow-registry.ts","../bin.ts"],"sourcesContent":["import readEnvModule from 'read-env';\n\nconst readEnv =\n typeof readEnvModule === 'function'\n ? readEnvModule\n : (readEnvModule as any).default;\nimport { tryGetPackageJson } from './setup-utils';\nimport type { WizardOptions } from './types';\nimport fg from 'fast-glob';\nimport { IS_DEV } from '../lib/constants';\n\nexport function isNonInteractiveEnvironment(): boolean {\n if (IS_DEV) {\n return false;\n }\n\n if (!process.stdout.isTTY || !process.stderr.isTTY) {\n return true;\n }\n\n return false;\n}\n\nexport function readEnvironment(): Record<string, unknown> {\n const result = readEnv('POSTHOG_WIZARD');\n\n return result;\n}\n\nexport async function detectEnvVarPrefix(\n options: WizardOptions,\n): Promise<string> {\n const packageJson = await tryGetPackageJson(options);\n if (!packageJson) return 'VITE_PUBLIC_';\n\n const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };\n const has = (name: string) => name in deps;\n const hasAnyFile = async (patterns: string[]) => {\n const matches = await fg(patterns, {\n cwd: options.installDir,\n absolute: false,\n onlyFiles: true,\n ignore: ['**/node_modules/**'],\n });\n return matches.length > 0;\n };\n\n // --- Next.js\n if (has('next') || (await hasAnyFile(['**/next.config.{js,ts,mjs,cjs}']))) {\n return 'NEXT_PUBLIC_';\n }\n\n // --- Create React App\n if (\n has('react-scripts') ||\n has('create-react-app') ||\n (await hasAnyFile(['**/config-overrides.js']))\n ) {\n return 'REACT_APP_';\n }\n\n // --- Vite (vanilla, TanStack, Solid, etc.)\n // Note: Vite does not need PUBLIC_ but we use it to follow the docs, to improve the chances of an LLM getting it right.\n if (has('vite') || (await hasAnyFile(['**/vite.config.{js,ts,mjs,cjs}']))) {\n return 'VITE_PUBLIC_';\n }\n\n // --- SvelteKit\n if (\n has('@sveltejs/kit') ||\n (await hasAnyFile(['**/svelte.config.{js,ts}']))\n ) {\n return 'PUBLIC_';\n }\n\n // --- TanStack Start (uses Vite)\n if (\n has('@tanstack/start') ||\n (await hasAnyFile(['**/tanstack.config.{js,ts}']))\n ) {\n return 'VITE_PUBLIC_';\n }\n\n // --- SolidStart (uses Vite)\n if (has('solid-start') || (await hasAnyFile(['**/solid.config.{js,ts}']))) {\n return 'VITE_PUBLIC_';\n }\n\n // --- Astro\n if (has('astro') || (await hasAnyFile(['**/astro.config.{js,ts,mjs}']))) {\n return 'PUBLIC_';\n }\n\n // We default to Vite if we can't detect a specific framework, since it's the most commonly used.\n return 'VITE_PUBLIC_';\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.js';\nimport type { WizardSession } from '../../wizard-session.js';\nimport type { AbortCase } from '../../agent/agent-runner.js';\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 workflow step list.\n *\n * The detect step checks for PostHog + Stripe SDKs. The skill install\n * and agent run live in the workflow runner (see agent-runner.ts).\n */\n\nimport type { Workflow } from '../workflow-step.js';\nimport { RunPhase } from '../../wizard-session.js';\nimport { detectRevenuePrerequisites } from './detect.js';\n\nexport const REVENUE_ANALYTICS_WORKFLOW: Workflow = [\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 screen: 'revenue-intro',\n gate: (session) => session.setupConfirmed,\n },\n {\n id: 'auth',\n label: 'Authentication',\n screen: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Revenue analytics',\n screen: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screen: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screen: 'keep-skills',\n },\n];\n","import type { WorkflowConfig } from '../workflow-step.js';\nimport { REVENUE_ANALYTICS_WORKFLOW } from './steps.js';\nimport { REVENUE_ABORT_CASES } from './detect.js';\n\nexport const revenueAnalyticsConfig: WorkflowConfig = {\n command: 'revenue',\n description: 'Set up PostHog revenue analytics (e.g. Stripe integration)',\n flowKey: 'revenue-analytics-setup',\n steps: REVENUE_ANALYTICS_WORKFLOW,\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_WORKFLOW } 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: auth → run → outro → skills.\n * No detection, no setup, no MCP.\n */\n\nimport type { Workflow } from '../workflow-step.js';\nimport { RunPhase } from '../../wizard-session.js';\n\nexport const AGENT_SKILL_STEPS: Workflow = [\n {\n id: 'intro',\n label: 'Welcome',\n screen: 'agent-skill-intro',\n gate: (session) => session.setupConfirmed,\n },\n {\n id: 'auth',\n label: 'Authentication',\n screen: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Running',\n screen: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'outro',\n label: 'Done',\n screen: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'skills',\n label: 'Skills',\n screen: 'keep-skills',\n },\n];\n","/**\n * Generic agent skill workflow factory.\n *\n * Creates a WorkflowConfig for any context-mill skill. Provide a\n * skill ID and basic UI config — the factory handles the rest.\n *\n * Usage:\n * createSkillWorkflow({\n * skillId: 'error-tracking-setup',\n * command: 'errors',\n * flowKey: '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 { WorkflowConfig } from '../workflow-step.js';\nimport type { WorkflowRun, AbortCase } from '../../agent/agent-runner.js';\nimport { AGENT_SKILL_STEPS } from './steps.js';\n\nexport interface SkillWorkflowOptions {\n /** Context-mill skill ID to install */\n skillId: string;\n /** CLI subcommand name */\n command: string;\n /** Unique flow key — must match a Flow enum entry */\n flowKey: 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 workflow flowKeys that must be satisfied first */\n requires?: string[];\n /** Override the default outro. Receives the same args as WorkflowRun.buildOutroData. */\n buildOutroData?: WorkflowRun['buildOutroData'];\n /** Known `[ABORT] <reason>` cases the skill can emit. */\n abortCases?: AbortCase[];\n}\n\nexport function createSkillWorkflow(\n opts: SkillWorkflowOptions,\n): WorkflowConfig {\n return {\n command: opts.command,\n description: opts.description,\n flowKey: opts.flowKey,\n steps: AGENT_SKILL_STEPS,\n reportFile: opts.reportFile,\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 '../../agent/agent-runner.js';\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 workflow 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/** The 10 data-integrity checks the audit runs. */\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\n/** Atomically write the seeded ledger to the project's audit checks file. */\nexport function seedAuditLedger(installDir: string): void {\n const target = path.join(installDir, AUDIT_CHECKS_FILE);\n const tmp = `${target}.tmp`;\n fs.writeFileSync(tmp, JSON.stringify(AUDIT_SEED_CHECKS, null, 2), 'utf8');\n fs.renameSync(tmp, target);\n logToFile(\n `seedAuditLedger: wrote ${AUDIT_SEED_CHECKS.length} entries to ${target}`,\n );\n}\n","import {\n AGENT_SKILL_STEPS,\n createSkillWorkflow,\n} from '../agent-skill/index.js';\nimport type { Workflow, WorkflowConfig } from '../workflow-step.js';\nimport type { WorkflowRun } from '../../agent/agent-runner.js';\nimport type { WizardSession } from '../../wizard-session.js';\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: Workflow): Workflow =>\n steps.map((step) => {\n const override = AUDIT_SCREEN_BY_STEP[step.id];\n return override ? { ...step, screen: override } : step;\n });\n\nconst auditSteps: Workflow = withAuditScreens(AGENT_SKILL_STEPS);\n\nconst baseConfig = createSkillWorkflow({\n skillId: 'audit',\n command: 'audit',\n flowKey: '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 workflow 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<WorkflowRun> => {\n seedBeforeAuditRun(session);\n\n if (!baseConfig.run) {\n throw new Error('Audit workflow has no run configuration.');\n }\n\n return typeof baseConfig.run === 'function'\n ? baseConfig.run(session)\n : baseConfig.run;\n};\n\nexport const auditConfig: WorkflowConfig = {\n ...baseConfig,\n steps: auditSteps,\n run: auditRun,\n};\n","import fs from 'fs';\nimport path from 'path';\nimport {\n AGENT_SKILL_STEPS,\n createSkillWorkflow,\n} from '../agent-skill/index.js';\nimport type { Workflow, WorkflowConfig } from '../workflow-step.js';\nimport type { WorkflowRun } from '../../agent/agent-runner.js';\nimport type { WizardSession } from '../../wizard-session.js';\nimport { AUDIT_ABORT_CASES } from '../audit/detect.js';\nimport {\n AUDIT_CHECKS_FILE,\n AUDIT_CHECKS_KEY,\n type AuditCheck,\n} from '../audit/types.js';\nimport { AUDIT_SEED_CHECKS } from '../audit/seed.js';\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` workflow.\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: Workflow): Workflow =>\n steps.map((step) => {\n const override = AUDIT3000_SCREEN_BY_STEP[step.id];\n return override ? { ...step, screen: override } : step;\n });\n\nconst audit3000Steps: Workflow = withAudit3000Screens(AGENT_SKILL_STEPS);\n\nconst baseConfig = createSkillWorkflow({\n skillId: 'audit-3000',\n command: 'audit-3000',\n flowKey: '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<WorkflowRun> => {\n seedBeforeAudit3000Run(session);\n\n if (!baseConfig.run) {\n throw new Error('audit-3000 workflow has no run configuration.');\n }\n\n return typeof baseConfig.run === 'function'\n ? baseConfig.run(session)\n : baseConfig.run;\n};\n\nexport const audit3000Config: WorkflowConfig = {\n ...baseConfig,\n steps: audit3000Steps,\n run: audit3000Run,\n};\n","import type { Workflow } from '../workflow-step.js';\n\nexport const POSTHOG_DOCTOR_WORKFLOW: Workflow = [\n {\n id: 'intro',\n label: 'Welcome',\n screen: 'doctor-intro',\n gate: (session) => session.setupConfirmed,\n },\n {\n id: 'auth',\n label: 'Authentication',\n screen: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'report',\n label: 'Doctor report',\n screen: 'doctor-report',\n isComplete: (session) => session.outroData !== null,\n },\n {\n id: 'outro',\n label: 'Done',\n screen: '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 '../../api';\nimport { WIZARD_USER_AGENT } from '../../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 '../../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 { WorkflowConfig } from '../workflow-step.js';\nimport { POSTHOG_DOCTOR_WORKFLOW } from './steps.js';\n\nexport const posthogDoctorConfig: WorkflowConfig = {\n command: 'doctor',\n description:\n 'Diagnose your PostHog project for configuration issues and setup warnings',\n flowKey: 'posthog-doctor',\n steps: POSTHOG_DOCTOR_WORKFLOW,\n};\n\nexport { POSTHOG_DOCTOR_WORKFLOW } 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","/**\n * Central registry of all wizard workflows.\n *\n * Adding a new workflow:\n * 1. Create src/lib/workflows/<name>/ with index.ts exporting a WorkflowConfig\n * 2. Import and add it to WORKFLOW_REGISTRY below\n * 3. Add a matching Flow enum entry in src/ui/tui/flows.ts\n * 4. (If custom intro screen) add to src/ui/tui/screen-registry.tsx\n *\n * flows.ts, store.ts, and bin.ts all derive their wiring from this array —\n * no need to touch those files when adding a workflow.\n */\n\nimport type { WorkflowConfig } from './workflow-step.js';\nimport { posthogIntegrationConfig } from './posthog-integration/index.js';\nimport { revenueAnalyticsConfig } from './revenue-analytics/index.js';\nimport { auditConfig } from './audit/index.js';\nimport { audit3000Config } from './audit-3000/index.js';\nimport { posthogDoctorConfig } from './posthog-doctor/index.js';\n\nexport const WORKFLOW_REGISTRY: WorkflowConfig[] = [\n posthogIntegrationConfig,\n revenueAnalyticsConfig,\n auditConfig,\n audit3000Config,\n posthogDoctorConfig,\n];\n\n/** Look up a workflow config by its flowKey. */\nexport function getWorkflowConfig(flowKey: string): WorkflowConfig | undefined {\n return WORKFLOW_REGISTRY.find((c) => c.flowKey === flowKey);\n}\n\n/** All workflow configs that are exposed as CLI subcommands. */\nexport function getSubcommandWorkflows(): WorkflowConfig[] {\n return WORKFLOW_REGISTRY.filter((c) => c.command != null);\n}\n","#!/usr/bin/env node\nimport { satisfies } from 'semver';\nimport { red } from './src/utils/logging';\n\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { VERSION } from './src/lib/version.js';\n\nconst WIZARD_VERSION = VERSION;\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 red(\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\nimport { isNonInteractiveEnvironment } from './src/utils/environment';\nimport { getUI, setUI } from './src/ui';\nimport { LoggingUI } from './src/ui/logging-ui';\nimport { getSubcommandWorkflows } from './src/lib/workflows/workflow-registry';\nimport type { WorkflowConfig } from './src/lib/workflows/workflow-step';\nimport type { WizardSession } from './src/lib/wizard-session';\nimport { POSTHOG_DOCS_URL } from './src/lib/constants';\nimport { runtimeEnv } from '@env';\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\n/** Shared yargs options for skill-based workflow subcommands. */\nconst skillSubcommandOptions = {\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\nconst cli = yargs(hideBin(process.argv))\n .env('POSTHOG_WIZARD')\n // global options\n .options({\n debug: {\n default: false,\n describe: 'Enable verbose logging\\nenv: POSTHOG_WIZARD_DEBUG',\n type: 'boolean',\n },\n region: {\n describe: 'PostHog cloud region\\nenv: POSTHOG_WIZARD_REGION',\n choices: ['us', 'eu'],\n type: 'string',\n },\n default: {\n default: true,\n describe:\n 'Use default options for all prompts\\nenv: POSTHOG_WIZARD_DEFAULT',\n type: 'boolean',\n },\n signup: {\n default: false,\n describe:\n 'Create a new PostHog account during setup\\nenv: POSTHOG_WIZARD_SIGNUP',\n type: 'boolean',\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',\n },\n ci: {\n default: false,\n describe:\n 'Enable CI mode for non-interactive execution\\nenv: POSTHOG_WIZARD_CI',\n type: 'boolean',\n },\n 'api-key': {\n describe:\n 'PostHog personal API key (phx_xxx) for authentication\\nenv: POSTHOG_WIZARD_API_KEY',\n type: 'string',\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',\n },\n email: {\n describe:\n 'Email address for signup (used with --signup)\\nenv: POSTHOG_WIZARD_EMAIL',\n type: 'string',\n },\n })\n .command(\n ['$0'],\n 'Run the PostHog setup wizard',\n (yargs) => {\n return yargs.options({\n 'force-install': {\n default: false,\n describe:\n 'Force install packages even if peer dependency checks fail\\nenv: POSTHOG_WIZARD_FORCE_INSTALL',\n type: 'boolean',\n },\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 integration: {\n describe: 'Integration to set up',\n choices: [\n 'nextjs',\n 'astro',\n 'react',\n 'svelte',\n 'react-native',\n 'tanstack-router',\n 'tanstack-start',\n ],\n type: 'string',\n },\n menu: {\n default: false,\n describe:\n 'Show menu for manual integration selection instead of auto-detecting\\nenv: POSTHOG_WIZARD_MENU',\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 },\n (argv) => {\n const options = { ...argv };\n\n // CI mode validation and TTY check\n if (options.ci) {\n if (!options.region) options.region = 'us';\n if (!options.installDir) {\n setUI(new LoggingUI());\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 return;\n }\n if (!options.apiKey && !options.signup) {\n setUI(new LoggingUI());\n getUI().intro('PostHog Wizard');\n getUI().log.error(\n 'CI mode requires --api-key (personal API key phx_xxx). ' +\n 'To create a new account instead, use --signup --email you@example.com.',\n );\n process.exit(1);\n return;\n }\n if (!options.apiKey && options.signup && !options.email) {\n setUI(new LoggingUI());\n getUI().intro('PostHog Wizard');\n getUI().log.error(\n 'CI --signup requires --email to create a new account.',\n );\n process.exit(1);\n return;\n }\n void (async () => {\n // If --signup but no existing key, provision a new account first and\n // use its personal API key for the rest of the CI install.\n if (!options.apiKey && options.signup) {\n setUI(new LoggingUI());\n getUI().intro('PostHog Wizard');\n try {\n const { provisionNewAccount } = await import(\n './src/utils/provisioning.js'\n );\n const signupRegion = (options.region as string).toUpperCase() as\n | 'US'\n | 'EU';\n getUI().log.info(\n `Provisioning new PostHog account for ${String(\n options.email,\n )} in ${signupRegion}...`,\n );\n const result = await provisionNewAccount(\n options.email as string,\n options.name ?? '',\n signupRegion,\n );\n if (!result.personalApiKey) {\n getUI().log.error(\n 'Provisioning succeeded but no personal API key was returned — cannot continue install.',\n );\n process.exit(1);\n return;\n }\n getUI().log.success('Account ready.');\n getUI().log.info(` Project API Key: ${result.projectApiKey}`);\n getUI().log.info(` Personal API Key: ${result.personalApiKey}`);\n getUI().log.info(` Host: ${result.host}`);\n options.apiKey = result.personalApiKey;\n if (options.projectId == null) {\n options.projectId = result.projectId;\n }\n } catch (error) {\n const msg =\n error instanceof Error ? error.message : String(error);\n getUI().log.error(`Provisioning failed: ${msg}`);\n process.exit(1);\n return;\n }\n }\n\n const { posthogIntegrationConfig } = await import(\n './src/lib/workflows/posthog-integration/index.js'\n );\n const { FRAMEWORK_REGISTRY } = await import('./src/lib/registry.js');\n const { detectFramework, gatherFrameworkContext } = await import(\n './src/lib/detection/index.js'\n );\n const { analytics } = await import('./src/utils/analytics.js');\n const { wizardAbort } = await import('./src/utils/wizard-abort.js');\n\n // preRun: honor --integration, else auto-detect, then gather\n // framework context. Bypasses onReady hooks by design.\n runWizardCI(posthogIntegrationConfig, options, async (session) => {\n const integration =\n session.integration ??\n (await detectFramework(session.installDir));\n if (!integration) {\n await wizardAbort({\n message:\n 'Could not auto-detect your framework. Please specify --integration on the command line.',\n });\n return;\n }\n session.integration = integration;\n analytics.setTag('integration', integration);\n\n const frameworkConfig = FRAMEWORK_REGISTRY[integration];\n session.frameworkConfig = frameworkConfig;\n\n const context = await gatherFrameworkContext(frameworkConfig, {\n installDir: session.installDir,\n debug: session.debug,\n forceInstall: session.forceInstall,\n default: false,\n signup: session.signup,\n localMcp: session.localMcp,\n ci: true,\n menu: session.menu,\n benchmark: session.benchmark,\n yaraReport: session.yaraReport,\n });\n for (const [key, value] of Object.entries(context)) {\n if (!(key in session.frameworkContext)) {\n session.frameworkContext[key] = value;\n }\n }\n });\n })().catch(() => {\n process.exit(1);\n });\n } else if (isNonInteractiveEnvironment()) {\n // Non-interactive non-CI: error out\n getUI().intro(`PostHog Wizard`);\n getUI().log.error(\n 'This installer requires an interactive terminal (TTY) to run.\\n' +\n 'It appears you are running in a non-interactive environment.\\n' +\n 'Please run the wizard in an interactive terminal.\\n\\n' +\n 'For CI/CD environments, use --ci mode:\\n' +\n ' npx @posthog/wizard --ci --region us --api-key phx_xxx',\n );\n process.exit(1);\n } else if (options.playground) {\n // Playground mode: launch the TUI primitives playground\n void (async () => {\n const { startPlayground } = await import(\n './src/ui/tui/playground/start-playground.js'\n );\n (startPlayground as (version: string) => void)(WIZARD_VERSION);\n })();\n } else if (options.skill) {\n // Run a specific skill by ID\n void (async () => {\n const { createSkillWorkflow } = await import(\n './src/lib/workflows/agent-skill/index.js'\n );\n const skillId = options.skill as string;\n const config = createSkillWorkflow({\n skillId,\n command: 'skill',\n flowKey: '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 runWizard(config, { ...options, skillId });\n })();\n } else {\n // Interactive TTY: run core-integration through the unified workflow path.\n // Same codepath as `npx @posthog/wizard integrate`.\n void (async () => {\n const { posthogIntegrationConfig } = await import(\n './src/lib/workflows/posthog-integration/index.js'\n );\n runWizard(posthogIntegrationConfig, options);\n })();\n }\n },\n )\n .command('mcp <command>', 'MCP server management commands', (yargs) => {\n return yargs\n .command(\n 'add',\n 'Install PostHog MCP server to supported clients',\n (yargs) => {\n return yargs.options({\n local: {\n default: false,\n describe:\n 'Add local development MCP server (http://localhost:8787)',\n type: 'boolean',\n },\n features: {\n describe:\n 'Comma-separated list of features to enable (default: all)',\n type: 'string',\n },\n 'api-key': {\n describe:\n 'PostHog personal API key (phx_xxx) for MCP authentication',\n type: 'string',\n },\n });\n },\n (argv) => {\n const options = { ...argv };\n const mcpFeatures = options.features\n ?.split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n void (async () => {\n const { readApiKeyFromEnv } = await import(\n './src/utils/env-api-key.js'\n );\n const apiKey =\n (options.apiKey as string | undefined) || readApiKeyFromEnv();\n\n try {\n const { startTUI } = await import('./src/ui/tui/start-tui.js');\n const { buildSession } = await import(\n './src/lib/wizard-session.js'\n );\n\n const { Flow } = await import('./src/ui/tui/router.js');\n const tui = startTUI(WIZARD_VERSION, Flow.McpAdd);\n const session = buildSession({\n debug: options.debug,\n localMcp: options.local,\n mcpFeatures,\n apiKey,\n });\n tui.store.session = session;\n } catch {\n // TUI unavailable — fallback to logging\n setUI(new LoggingUI());\n const { addMCPServerToClientsStep } = await import(\n './src/steps/add-mcp-server-to-clients/index.js'\n );\n await addMCPServerToClientsStep({\n local: options.local,\n features: mcpFeatures,\n apiKey,\n });\n }\n })();\n },\n )\n .command(\n 'remove',\n 'Remove PostHog MCP server from supported clients',\n (yargs) => {\n return yargs.options({\n local: {\n default: false,\n describe:\n 'Remove local development MCP server (http://localhost:8787)',\n type: 'boolean',\n },\n });\n },\n (argv) => {\n const options = { ...argv };\n void (async () => {\n try {\n const { startTUI } = await import('./src/ui/tui/start-tui.js');\n const { buildSession } = await import(\n './src/lib/wizard-session.js'\n );\n\n const { Flow } = await import('./src/ui/tui/router.js');\n const tui = startTUI(WIZARD_VERSION, Flow.McpRemove);\n const session = buildSession({\n debug: options.debug,\n localMcp: options.local,\n });\n tui.store.session = session;\n } catch {\n // TUI unavailable — fallback to logging\n setUI(new LoggingUI());\n const { removeMCPServerFromClientsStep } = await import(\n './src/steps/add-mcp-server-to-clients/index.js'\n );\n await removeMCPServerFromClientsStep({\n local: options.local,\n });\n }\n })();\n },\n )\n .demandCommand(1, 'You must specify a subcommand (add or remove)')\n .help();\n });\n\ncli.command(\n 'provision',\n 'Create a new PostHog account (headless, no TUI)',\n (yargs) => {\n return yargs\n .options({\n email: {\n describe: 'Email address for the new account',\n type: 'string' as const,\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' as const,\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' as const,\n },\n })\n .example('wizard provision --email matt+test@posthog.com --region us', '')\n .example(\n 'wizard provision --email user@example.com --region eu --json',\n '',\n );\n },\n (argv) => {\n const email = argv.email;\n const region = argv.region.toUpperCase() as 'US' | 'EU';\n const name = argv.name ?? '';\n const jsonMode =\n argv.json === undefined ? !process.stdout.isTTY : argv.json;\n\n if (!jsonMode) {\n setUI(new LoggingUI());\n }\n\n void (async () => {\n try {\n const { provisionNewAccount } = await import(\n './src/utils/provisioning.js'\n );\n if (!jsonMode) {\n getUI().log.info(`Provisioning account for ${email} in ${region}...`);\n }\n const result = await provisionNewAccount(email, name, region);\n if (jsonMode) {\n process.stdout.write(`${JSON.stringify(result)}\\n`);\n } else {\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 process.exit(0);\n } catch (error) {\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 } else {\n getUI().log.error(`Provisioning failed: ${msg}`);\n }\n process.exit(1);\n }\n })();\n },\n);\n\n// ── Skill-based workflow subcommands (derived from registry) ─────────\nfor (const wfConfig of getSubcommandWorkflows()) {\n cli.command(\n wfConfig.command!,\n wfConfig.description,\n (y) => y.options(skillSubcommandOptions),\n (argv) => {\n const options = { ...argv };\n if (options.ci) {\n runWizardCI(wfConfig, options);\n } else {\n runWizard(wfConfig, options);\n }\n },\n );\n}\n\ncli\n .help()\n .alias('help', 'h')\n .version()\n .alias('version', 'v')\n .wrap(process.stdout.isTTY ? cli.terminalWidth() : 80).argv;\n\n/**\n * Run a full wizard workflow 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 */\nfunction runWizard(\n config: WorkflowConfig,\n options: Record<string, unknown>,\n): void {\n void (async () => {\n try {\n const installDir = (options.installDir as string) || process.cwd();\n\n const { startTUI } = await import('./src/ui/tui/start-tui.js');\n const { buildSession } = await import('./src/lib/wizard-session.js');\n const { TaskStreamPush } = await import('./src/lib/task-stream/index.js');\n const { FileDestination } = await import(\n './src/lib/task-stream/destinations/file.js'\n );\n const { PostHogDestination } = await import(\n './src/lib/task-stream/destinations/posthog.js'\n );\n const { analytics } = await import('./src/utils/analytics.js');\n\n const tui = startTUI(WIZARD_VERSION, config.flowKey as any);\n\n const session = buildSession({\n debug: options.debug as boolean | undefined,\n forceInstall: options.forceInstall 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 menu: options.menu as boolean | undefined,\n integration: options.integration as any,\n benchmark: options.benchmark as boolean | undefined,\n yaraReport: options.yaraReport as boolean | undefined,\n });\n session.workflowLabel = config.flowKey;\n if (options.skillId) {\n session.skillId = options.skillId as string;\n }\n\n tui.store.session = session;\n\n // Task stream — pushes state to external consumers on task changes\n const taskStream = new TaskStreamPush({\n store: tui.store,\n workflowId: config.flowKey,\n destinations: [new FileDestination(), new PostHogDestination()],\n });\n tui.store.onTasksChanged = () => void taskStream.push();\n\n await tui.store.runReadyHooks();\n await tui.store.getGate('intro');\n await tui.store.getGate('health-check');\n\n const skipAgent = config.run == null;\n\n if (skipAgent) {\n const { getOrAskForProjectData } = await import(\n './src/utils/setup-utils.js'\n );\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 tui.store.setCredentials({\n accessToken,\n projectApiKey,\n host,\n projectId,\n });\n } else {\n const { runAgent } = await import('./src/lib/agent/agent-runner.js');\n await runAgent(config, tui.store.session);\n }\n\n const isDone = (): boolean =>\n skipAgent\n ? tui.store.session.outroDismissed\n : tui.store.session.skillsComplete;\n\n await new Promise<void>((resolve) => {\n const unsub = tui.store.subscribe(() => {\n if (isDone()) {\n unsub();\n resolve();\n }\n });\n if (isDone()) {\n unsub();\n resolve();\n }\n });\n\n try {\n await taskStream.dispose();\n } catch (error) {\n analytics.captureException(error as Error);\n }\n tui.unmount();\n process.exit(0);\n } catch (err) {\n if (runtimeEnv('DEBUG') || runtimeEnv('POSTHOG_WIZARD_DEBUG')) {\n console.error('TUI init failed:', err); // eslint-disable-line no-console\n }\n }\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 `preRun` (or the\n * workflow's `onReady` hooks by default), executes `runAgent`, and\n * routes any failure through `wizardAbort`. `wizardAbort` owns all\n * exits — never add a raw `process.exit` here.\n */\nfunction runWizardCI(\n config: WorkflowConfig,\n options: Record<string, unknown>,\n preRun?: (session: WizardSession) => Promise<void>,\n): void {\n setUI(new LoggingUI());\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 void (async () => {\n const path = await import('path');\n const { buildSession } = await import('./src/lib/wizard-session.js');\n const { readEnvironment } = await import('./src/utils/environment.js');\n const { readApiKeyFromEnv } = await import('./src/utils/env-api-key.js');\n const { configureLogFileFromEnvironment, logToFile } = await import(\n './src/utils/debug.js'\n );\n const { wizardAbort, WizardError } = await import(\n './src/utils/wizard-abort.js'\n );\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 forceInstall: options.forceInstall 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 menu: options.menu as boolean | undefined,\n integration: options.integration as any, // eslint-disable-line @typescript-eslint/no-explicit-any\n projectId: options.projectId as string | undefined,\n benchmark: options.benchmark as boolean | undefined,\n yaraReport: options.yaraReport as boolean | undefined,\n ...env,\n });\n session.workflowLabel = config.flowKey;\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.flowKey} in CI mode`);\n\n try {\n if (preRun) {\n await preRun(session);\n } else {\n // Run onReady hooks against a minimal store-less context.\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 // Surface detectError written by the workflow's detect hook.\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.flowKey} prerequisites failed`, {\n integration: config.flowKey,\n detect_error_kind: detectError.kind,\n }),\n });\n }\n }\n\n const { runAgent } = await import('./src/lib/agent/agent-runner.js');\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,UACJ,OAAO,kBAAkB,aACrB,gBACC,cAAsB;AAM7B,SAAgB,8BAAuC;AAKrD,KAAI,CAAC,QAAQ,OAAO,SAAS,CAAC,QAAQ,OAAO,MAC3C,QAAO;AAGT,QAAO;;AAGT,SAAgB,kBAA2C;AAGzD,QAFe,QAAQ,iBAAiB;;;;ACV1C,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,cAAc;CACzB;CACA;CACA;CACD;;AAyBD,MAAa,sBAAmC,CAC9C;CAEE,OAAO;CACP,SAAS;CACT,MACE;CAGF,SAAS;CACV,EACD;C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QAAI,YACF,OAAM,YAAY;KAChB,SAAS,0BAA0B,YAAY,KAAK,UAClD,QAAQ,WAAA;KAEV,OAAO,IAAI,YAAY,GAAG,OAAO,QAAQ,wBAAwB;MAC/D,aAAa,OAAO;MACpB,mBAAmB,YAAY;MAChC,CAAC;KACH,CAAC;;GAIN,MAAM,EAAE,aAAa,MAAM,OAAO;AAClC,SAAM,SAAS,QAAQ,QAAQ;WACxB,OAAO;GACd,MAAM,eACJ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;GACxD,MAAM,aACJ,iBAAiB,SAAS,MAAM,QAAQ,MAAM,QAAQ,KAAA;AAExD,aAAU,sBAAsB,eAAe;AAC/C,OAAI,WAAY,WAAU,sBAAsB,aAAa;GAE7D,MAAM,YAAY,QAAQ,SAAS,aAAa,OAAO,eAAe;AAKtE,SAAM,YAAY;IAChB,SAAS,yBAAyB,aAAa,wCAJ/C,QAAQ,iBAAiB,SAAS,WAClC,QAAQ,WAAA,2BAGuF,sBAAsB;IAC9G;IACR,CAAC;;KAEF,CAAC,YAAY;AACf,UAAQ,KAAK,EAAE;GACf"}
@@ -1,2 +1,2 @@
1
- import { n as configureLogFileFromEnvironment, s as logToFile } from "./debug-gWEjmYVV.js";
1
+ import { n as configureLogFileFromEnvironment, s as logToFile } from "./debug-Cqi6nVfX.js";
2
2
  export { configureLogFileFromEnvironment, logToFile };