@posthog/wizard 2.66.0 → 2.68.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 (120) hide show
  1. package/dist/{add-mcp-server-to-clients-DWDEuDUR.js → add-mcp-server-to-clients-y0swAr9I.js} +25 -25
  2. package/dist/{add-mcp-server-to-clients-DWDEuDUR.js.map → add-mcp-server-to-clients-y0swAr9I.js.map} +1 -1
  3. package/dist/{agent-interface-D3MNaDp3.js → agent-interface-CaEptZuu.js} +404 -73
  4. package/dist/agent-interface-CaEptZuu.js.map +1 -0
  5. package/dist/{agent-prompt-loader-D8Bajo-L.js → agent-prompt-loader-DZHc9tIG.js} +5 -5
  6. package/dist/{agent-prompt-loader-D8Bajo-L.js.map → agent-prompt-loader-DZHc9tIG.js.map} +1 -1
  7. package/dist/{agent-runner-DEeMqJxy.js → agent-runner-Do5kyhPo.js} +85 -39
  8. package/dist/agent-runner-Do5kyhPo.js.map +1 -0
  9. package/dist/analytics-BNCWoTKa.js +2 -0
  10. package/dist/{analytics-D8JNuPAT.js → analytics-tF06lcmE.js} +2 -2
  11. package/dist/{analytics-D8JNuPAT.js.map → analytics-tF06lcmE.js.map} +1 -1
  12. package/dist/{api-CemGgyBv.js → api-D7-8R4xx.js} +3 -3
  13. package/dist/{api-CemGgyBv.js.map → api-D7-8R4xx.js.map} +1 -1
  14. package/dist/bin.js +200 -85
  15. package/dist/bin.js.map +1 -1
  16. package/dist/{bounded-fs-C6OjqZst.js → bounded-fs-BwuqKpBH.js} +3 -3
  17. package/dist/{bounded-fs-C6OjqZst.js.map → bounded-fs-BwuqKpBH.js.map} +1 -1
  18. package/dist/{ci-install-DIB2n4Ju.js → ci-install-CrqqhXAw.js} +18 -9
  19. package/dist/ci-install-CrqqhXAw.js.map +1 -0
  20. package/dist/{debug-H-GTKvvU.js → debug-CWn7PsPd.js} +1 -1
  21. package/dist/{debug-BKqv-yfT.js → debug-aA5dm2MR.js} +4 -4
  22. package/dist/debug-aA5dm2MR.js.map +1 -0
  23. package/dist/{defaults-BHhXrX9F.js → defaults-DI642M3n.js} +1 -1
  24. package/dist/{defaults-BHhXrX9F.js.map → defaults-DI642M3n.js.map} +1 -1
  25. package/dist/{env-api-key-CzHDwfV2.js → env-api-key-CwkRyrgi.js} +2 -2
  26. package/dist/{env-api-key-CzHDwfV2.js.map → env-api-key-CwkRyrgi.js.map} +1 -1
  27. package/dist/environment-BGUJxuvj.js +44 -0
  28. package/dist/environment-BGUJxuvj.js.map +1 -0
  29. package/dist/errors-BHervYGs.js +156 -0
  30. package/dist/errors-BHervYGs.js.map +1 -0
  31. package/dist/{file-watcher-Cr-4tA-e.js → file-watcher-Cn7tD95m.js} +2 -2
  32. package/dist/{file-watcher-Cr-4tA-e.js.map → file-watcher-Cn7tD95m.js.map} +1 -1
  33. package/dist/{headless-ui-DT3Db1bk.js → headless-ui-DtIYZNVv.js} +2 -2
  34. package/dist/{headless-ui-DT3Db1bk.js.map → headless-ui-DtIYZNVv.js.map} +1 -1
  35. package/dist/{interactive-D3LdFxZG.js → interactive-BRB6w6KG.js} +2 -2
  36. package/dist/{interactive-D3LdFxZG.js.map → interactive-BRB6w6KG.js.map} +1 -1
  37. package/dist/{local-dev-BN6NKQ0B.js → local-dev-DPZiIPCK.js} +1 -1
  38. package/dist/{local-dev-BN6NKQ0B.js.map → local-dev-DPZiIPCK.js.map} +1 -1
  39. package/dist/{mcp-BjckYQmP.js → mcp-BXdSTZe6.js} +2 -2
  40. package/dist/{mcp-BjckYQmP.js.map → mcp-BXdSTZe6.js.map} +1 -1
  41. package/dist/{mcp-prompt-streaming--sRErHKv.js → mcp-prompt-streaming-DhOT15Jj.js} +13 -12
  42. package/dist/mcp-prompt-streaming-DhOT15Jj.js.map +1 -0
  43. package/dist/{non-interactive-CNoYoEZp.js → non-interactive-ezilF3PY.js} +7 -2
  44. package/dist/non-interactive-ezilF3PY.js.map +1 -0
  45. package/dist/{orchestrator-tools-8bGyDDhn.js → orchestrator-tools-D82843t_.js} +3 -3
  46. package/dist/{orchestrator-tools-8bGyDDhn.js.map → orchestrator-tools-D82843t_.js.map} +1 -1
  47. package/dist/{package-json-D0DCWpe5.js → package-json-GEU2VZlS.js} +1 -1
  48. package/dist/{package-json-D0DCWpe5.js.map → package-json-GEU2VZlS.js.map} +1 -1
  49. package/dist/{package-manager-BQDHm7ER.js → package-manager-BPoVLj7W.js} +4 -4
  50. package/dist/package-manager-BPoVLj7W.js.map +1 -0
  51. package/dist/{pi-W-4RUPFY.js → pi-CKyt4bcu.js} +17 -13
  52. package/dist/pi-CKyt4bcu.js.map +1 -0
  53. package/dist/{playground-uHHgZChe.js → playground-Dnyb4jLu.js} +7 -7
  54. package/dist/{playground-uHHgZChe.js.map → playground-Dnyb4jLu.js.map} +1 -1
  55. package/dist/{posthog-ChzdlmCs.js → posthog-BHyJiU05.js} +2 -2
  56. package/dist/{posthog-ChzdlmCs.js.map → posthog-BHyJiU05.js.map} +1 -1
  57. package/dist/{posthog-integration-LxEBGkoe.js → posthog-integration-DJX4qTDQ.js} +22 -17
  58. package/dist/posthog-integration-DJX4qTDQ.js.map +1 -0
  59. package/dist/{provisioning-BHTl91OZ.js → provisioning-DEEt9xl4.js} +3 -3
  60. package/dist/{provisioning-BHTl91OZ.js.map → provisioning-DEEt9xl4.js.map} +1 -1
  61. package/dist/{queue-tools-DABh1Ssc.js → queue-tools-i_TmeI02.js} +3 -3
  62. package/dist/{queue-tools-DABh1Ssc.js.map → queue-tools-i_TmeI02.js.map} +1 -1
  63. package/dist/{registry-CxNpCNAj.js → registry-CbXqxcX0.js} +81 -81
  64. package/dist/{registry-CxNpCNAj.js.map → registry-CbXqxcX0.js.map} +1 -1
  65. package/dist/{security-B4jU_-7q.js → security-DZ1rkONB.js} +21 -9
  66. package/dist/security-DZ1rkONB.js.map +1 -0
  67. package/dist/{setup-utils-aWZEdfwh.js → setup-utils-BLKhAx6g.js} +13 -13
  68. package/dist/{setup-utils-aWZEdfwh.js.map → setup-utils-BLKhAx6g.js.map} +1 -1
  69. package/dist/{start-tui-BQH4mQIZ.js → start-tui-D1MqJVT1.js} +33 -23
  70. package/dist/start-tui-D1MqJVT1.js.map +1 -0
  71. package/dist/{steps-5HAqjUvn.js → steps-Dsw-zBET.js} +7 -7
  72. package/dist/{steps-5HAqjUvn.js.map → steps-Dsw-zBET.js.map} +1 -1
  73. package/dist/{store-P_7zUfbj.js → store-OGBMWp3H.js} +5 -5
  74. package/dist/{store-P_7zUfbj.js.map → store-OGBMWp3H.js.map} +1 -1
  75. package/dist/{subagent-uGPDXPfS.js → subagent-DrnKYgvu.js} +2 -2
  76. package/dist/{subagent-uGPDXPfS.js.map → subagent-DrnKYgvu.js.map} +1 -1
  77. package/dist/{task-oh8OAnvR.js → task-DyvLyDsO.js} +18 -14
  78. package/dist/task-DyvLyDsO.js.map +1 -0
  79. package/dist/{task-stream-jUARpyB5.js → task-stream-CLXzeuPO.js} +16 -9
  80. package/dist/task-stream-CLXzeuPO.js.map +1 -0
  81. package/dist/{tasks-2mu3lAvm.js → tasks-D77GNdOU.js} +2 -2
  82. package/dist/{tasks-2mu3lAvm.js.map → tasks-D77GNdOU.js.map} +1 -1
  83. package/dist/{telemetry-BllPiBKw.js → telemetry-wp-z9LXH.js} +3 -3
  84. package/dist/{telemetry-BllPiBKw.js.map → telemetry-wp-z9LXH.js.map} +1 -1
  85. package/dist/{terminal-aWQrDy8s.js → terminal-D9j4wbpD.js} +13 -13
  86. package/dist/{terminal-aWQrDy8s.js.map → terminal-D9j4wbpD.js.map} +1 -1
  87. package/dist/{tools-u8TaJFqa.js → tools-D0r4e-Vu.js} +10 -7
  88. package/dist/tools-D0r4e-Vu.js.map +1 -0
  89. package/dist/wizard-abort-Bv87YVSp.js +71 -0
  90. package/dist/wizard-abort-Bv87YVSp.js.map +1 -0
  91. package/dist/{wizard-abort-pFFH7dcx.js → wizard-abort-oazJA1Jb.js} +1 -1
  92. package/dist/{wizard-session-DTyLMPsX.js → wizard-session-C_7r3-rO.js} +3 -2
  93. package/dist/wizard-session-C_7r3-rO.js.map +1 -0
  94. package/dist/{wizard-session-Cw7-_OcZ.js → wizard-session-D1KQqUml.js} +1 -1
  95. package/dist/yara-hooks-Bl-FeANN.js +2 -0
  96. package/dist/{yara-hooks-BXDBIOBq.js → yara-hooks-DeonKbE_.js} +57 -8
  97. package/dist/yara-hooks-DeonKbE_.js.map +1 -0
  98. package/package.json +1 -1
  99. package/dist/agent-interface-D3MNaDp3.js.map +0 -1
  100. package/dist/agent-runner-DEeMqJxy.js.map +0 -1
  101. package/dist/analytics-DN3Kzf7H.js +0 -2
  102. package/dist/ci-install-DIB2n4Ju.js.map +0 -1
  103. package/dist/debug-BKqv-yfT.js.map +0 -1
  104. package/dist/environment-Cl-fIQku.js +0 -22
  105. package/dist/environment-Cl-fIQku.js.map +0 -1
  106. package/dist/mcp-prompt-streaming--sRErHKv.js.map +0 -1
  107. package/dist/non-interactive-CNoYoEZp.js.map +0 -1
  108. package/dist/package-manager-BQDHm7ER.js.map +0 -1
  109. package/dist/pi-W-4RUPFY.js.map +0 -1
  110. package/dist/posthog-integration-LxEBGkoe.js.map +0 -1
  111. package/dist/security-B4jU_-7q.js.map +0 -1
  112. package/dist/start-tui-BQH4mQIZ.js.map +0 -1
  113. package/dist/task-oh8OAnvR.js.map +0 -1
  114. package/dist/task-stream-jUARpyB5.js.map +0 -1
  115. package/dist/tools-u8TaJFqa.js.map +0 -1
  116. package/dist/wizard-abort-D9jiMkZA.js +0 -49
  117. package/dist/wizard-abort-D9jiMkZA.js.map +0 -1
  118. package/dist/wizard-session-DTyLMPsX.js.map +0 -1
  119. package/dist/yara-hooks-BXDBIOBq.js.map +0 -1
  120. package/dist/yara-hooks-i2jOabhI.js +0 -2
package/dist/bin.js CHANGED
@@ -1,28 +1,29 @@
1
1
  #!/usr/bin/env node
2
- import { Ct as isHeadless, L as Integration, St as headlessOption, U as POSTHOG_DOCS_URL, a as getLogFilePath, f as getUI, gt as VERSION, m as LoggingUI, mt as getSkillsBaseUrl, p as setUI, pt as WIZARD_USER_AGENT, r as debug, s as logToFile, wt as regionOption } from "./debug-BKqv-yfT.js";
3
- import { a as getLocalDev, i as checkLocalServices, o as initLocalDev, r as POSTHOG_LOCAL_URL, s as localMcpSkillsNotice } from "./local-dev-BN6NKQ0B.js";
4
- import { n as analytics } from "./analytics-D8JNuPAT.js";
5
- import { r as setEntryCommand } from "./telemetry-BllPiBKw.js";
6
- import { a as safeReadFile, o as walkProjectFiles } from "./bounded-fs-C6OjqZst.js";
7
- import { n as isUsingTypeScript } from "./setup-utils-aWZEdfwh.js";
8
- import { o as handleApiError } from "./api-CemGgyBv.js";
9
- import "./wizard-session-DTyLMPsX.js";
10
- import { i as wizardAbort, r as runCleanups } from "./wizard-abort-D9jiMkZA.js";
11
- import { n as isNonInteractiveEnvironment } from "./environment-Cl-fIQku.js";
12
- import { n as runAgent, s as authenticate } from "./agent-runner-DEeMqJxy.js";
13
- import { m as writeJsonAtomic } from "./queue-tools-DABh1Ssc.js";
14
- import { D as WIZARD_TOOL_NAMES, j as fetchSkillMenu, l as recoverOrphanedSettingsBackups, p as AgentSignals } from "./agent-interface-D3MNaDp3.js";
15
- import { S as SETUP_REPORT_FILE, _ as AUDIT_CHECKS_KEY, g as AUDIT_CHECKS_FILE, v as AUDIT_REPORT_FILE } from "./yara-hooks-BXDBIOBq.js";
16
- import { i as SPINNER_MESSAGE, t as FRAMEWORK_REGISTRY } from "./registry-CxNpCNAj.js";
17
- import { C as scopeInstallDirToProject, D as detectFramework, E as gatherFrameworkContext, S as detectIntegrationProjects, T as resolveProjectDir, _ as HEALTH_CHECK_STEP, a as LINE_CHART_BLOCK, b as getDetectedWarehouseSources, d as isClearBlock, g as detectPostHogIntegration, h as Icons, i as FUNNEL_BLOCK, m as Colors, n as integrationRunStep, o as PRODUCT_SUITE_BLOCK, r as posthogIntegrationConfig, s as StatusPeekTrigger, u as wordWrap, v as WAREHOUSE_ABORT_CASES, x as detectWarehouseSources, y as detectWarehousePrerequisites } from "./posthog-integration-LxEBGkoe.js";
18
- import { n as readApiKeyFromEnv } from "./env-api-key-CzHDwfV2.js";
2
+ import { a as AgentSignals, c as emitWizardError, l as ErrorCodes, r as detectErrorCode } from "./errors-BHervYGs.js";
3
+ import { Ct as isHeadless, L as Integration, St as headlessOption, U as POSTHOG_DOCS_URL, a as getLogFilePath, f as getUI, gt as VERSION, m as LoggingUI, mt as getSkillsBaseUrl, p as setUI, pt as WIZARD_USER_AGENT, r as debug, s as logToFile, wt as regionOption } from "./debug-aA5dm2MR.js";
4
+ import { a as getLocalDev, i as checkLocalServices, o as initLocalDev, r as POSTHOG_LOCAL_URL, s as localMcpSkillsNotice } from "./local-dev-DPZiIPCK.js";
5
+ import { n as analytics } from "./analytics-tF06lcmE.js";
6
+ import { r as setEntryCommand } from "./telemetry-wp-z9LXH.js";
7
+ import { a as safeReadFile, o as walkProjectFiles } from "./bounded-fs-BwuqKpBH.js";
8
+ import { n as isUsingTypeScript } from "./setup-utils-BLKhAx6g.js";
9
+ import { o as handleApiError } from "./api-D7-8R4xx.js";
10
+ import "./wizard-session-C_7r3-rO.js";
11
+ import { i as wizardAbort, r as runCleanups } from "./wizard-abort-Bv87YVSp.js";
12
+ import { n as isNonInteractiveEnvironment } from "./environment-BGUJxuvj.js";
13
+ import { n as runAgent, s as authenticate } from "./agent-runner-Do5kyhPo.js";
14
+ import { T as WIZARD_TOOL_NAMES, k as fetchSkillMenu, l as recoverOrphanedSettingsBackups } from "./agent-interface-CaEptZuu.js";
15
+ import { m as writeJsonAtomic } from "./queue-tools-i_TmeI02.js";
16
+ import { S as SETUP_REPORT_FILE, _ as AUDIT_CHECKS_KEY, g as AUDIT_CHECKS_FILE, v as AUDIT_REPORT_FILE } from "./yara-hooks-DeonKbE_.js";
17
+ import { i as SPINNER_MESSAGE, t as FRAMEWORK_REGISTRY } from "./registry-CbXqxcX0.js";
18
+ import { C as scopeInstallDirToProject, D as detectFramework, E as gatherFrameworkContext, S as detectIntegrationProjects, T as resolveProjectDir, _ as HEALTH_CHECK_STEP, a as LINE_CHART_BLOCK, b as getDetectedWarehouseSources, d as isClearBlock, g as detectPostHogIntegration, h as Icons, i as FUNNEL_BLOCK, m as Colors, n as integrationRunStep, o as PRODUCT_SUITE_BLOCK, r as posthogIntegrationConfig, s as StatusPeekTrigger, u as wordWrap, v as WAREHOUSE_ABORT_CASES, x as detectWarehouseSources, y as detectWarehousePrerequisites } from "./posthog-integration-DJX4qTDQ.js";
19
+ import { n as readApiKeyFromEnv } from "./env-api-key-CwkRyrgi.js";
19
20
  import { satisfies } from "semver";
20
21
  import yargs from "yargs";
21
22
  import { hideBin } from "yargs/helpers";
22
23
  import { existsSync, readFileSync, readdirSync, statSync } from "fs";
23
24
  import path, { join, relative } from "path";
24
25
  import * as os from "node:os";
25
- import * as path$1 from "node:path";
26
+ import * as path$2 from "node:path";
26
27
  import { join as join$1 } from "node:path";
27
28
  import { spawnSync } from "node:child_process";
28
29
  import * as fs$1 from "node:fs";
@@ -132,6 +133,10 @@ var Wizard = class Wizard {
132
133
  }).strictOptions().strictCommands().fail((msg, err) => {
133
134
  const text = msg || err && err.message || "Invalid arguments";
134
135
  process.stderr.write(`\n\x1b[1;91m✖ ${text}\x1b[0m\n Run \`wizard --help\` to see available commands and options.\n\n`);
136
+ emitWizardError({
137
+ code: ErrorCodes.CliBadArgs,
138
+ message: text
139
+ });
135
140
  process.exit(1);
136
141
  }).help().alias("help", "h").version().alias("version", "v");
137
142
  }
@@ -152,18 +157,30 @@ var Wizard = class Wizard {
152
157
  const envHasCI = process.env.POSTHOG_WIZARD_CI != null && process.env.POSTHOG_WIZARD_CI !== "";
153
158
  if (argvHasCI || envHasCI) {
154
159
  process.stderr.write(`\n\x1b[1;91m✖ CI mode is not currently supported in published builds.\x1b[0m\n\n`);
160
+ emitWizardError({
161
+ code: ErrorCodes.CliFlagUnavailable,
162
+ message: "CI mode is not supported in published builds."
163
+ });
155
164
  process.exit(1);
156
165
  }
157
166
  const argvHasOverride = args.some((a) => a === "--harness" || a.startsWith("--harness=") || a === "--sequence" || a.startsWith("--sequence=") || a === "--model" || a.startsWith("--model=") || a === "--capture-aio" || a === "--no-capture-aio" || a.startsWith("--capture-aio="));
158
167
  const envHasOverride = process.env.POSTHOG_WIZARD_HARNESS != null && process.env.POSTHOG_WIZARD_HARNESS !== "" || process.env.POSTHOG_WIZARD_SEQUENCE != null && process.env.POSTHOG_WIZARD_SEQUENCE !== "" || process.env.POSTHOG_WIZARD_MODEL != null && process.env.POSTHOG_WIZARD_MODEL !== "" || process.env.POSTHOG_WIZARD_CAPTURE_AIO != null && process.env.POSTHOG_WIZARD_CAPTURE_AIO !== "";
159
168
  if (argvHasOverride || envHasOverride) {
160
169
  process.stderr.write(`\n\x1b[1;91m✖ The --harness, --sequence, --model, and --capture-aio overrides are not available in published builds.\x1b[0m\n\n`);
170
+ emitWizardError({
171
+ code: ErrorCodes.CliFlagUnavailable,
172
+ message: "The --harness, --sequence, --model, and --capture-aio overrides are not available in published builds."
173
+ });
161
174
  process.exit(1);
162
175
  }
163
176
  const argvHasLocalTarget = args.some((a) => LOCAL_TARGET_FLAGS.some((f) => a === `--${f}` || a === `--no-${f}` || a.startsWith(`--${f}=`)));
164
177
  const envHasLocalTarget = LOCAL_TARGET_ENV_VARS.some((k) => process.env[k] != null && process.env[k] !== "");
165
178
  if (argvHasLocalTarget || envHasLocalTarget) {
166
179
  process.stderr.write("\n\x1B[1;91m✖ The --local-dev, --local-context-mill, --local-mcp, and --local-posthog targets are not available in published builds.\x1B[0m\n They point the wizard at development servers on localhost.\n\n");
180
+ emitWizardError({
181
+ code: ErrorCodes.CliFlagUnavailable,
182
+ message: "The --local-dev, --local-context-mill, --local-mcp, and --local-posthog targets are not available in published builds."
183
+ });
167
184
  process.exit(1);
168
185
  }
169
186
  }
@@ -225,7 +242,7 @@ function runProvision(argv) {
225
242
  }
226
243
  async function provision({ email, region, name, baseUrl, jsonMode }) {
227
244
  try {
228
- const { provisionNewAccount } = await import("./provisioning-BHTl91OZ.js").then((n) => n.r);
245
+ const { provisionNewAccount } = await import("./provisioning-DEEt9xl4.js").then((n) => n.r);
229
246
  if (!jsonMode) getUI().log.info(`Provisioning account for ${email} in ${region}...`);
230
247
  emitResult(await provisionNewAccount(email, name, region, { baseUrl }), jsonMode);
231
248
  process.exit(0);
@@ -292,22 +309,22 @@ const basicIntegrationCommand = {
292
309
  setEntryCommand("integrate");
293
310
  (async () => {
294
311
  if (isHeadless(argv)) {
295
- const { runHeadlessInstall } = await import("./ci-install-DIB2n4Ju.js");
312
+ const { runHeadlessInstall } = await import("./ci-install-CrqqhXAw.js");
296
313
  return runHeadlessInstall(argv);
297
314
  }
298
315
  if (argv.ci) {
299
- const { runCIInstall } = await import("./ci-install-DIB2n4Ju.js");
316
+ const { runCIInstall } = await import("./ci-install-CrqqhXAw.js");
300
317
  return runCIInstall(argv);
301
318
  }
302
319
  if (isNonInteractiveEnvironment()) {
303
- const { failNonInteractive } = await import("./non-interactive-CNoYoEZp.js");
320
+ const { failNonInteractive } = await import("./non-interactive-ezilF3PY.js");
304
321
  return failNonInteractive();
305
322
  }
306
323
  if (argv.playground) {
307
- const { runPlayground } = await import("./playground-uHHgZChe.js");
324
+ const { runPlayground } = await import("./playground-Dnyb4jLu.js");
308
325
  return runPlayground();
309
326
  }
310
- const { runInteractive } = await import("./interactive-D3LdFxZG.js");
327
+ const { runInteractive } = await import("./interactive-BRB6w6KG.js");
311
328
  runInteractive(argv);
312
329
  })();
313
330
  }
@@ -686,6 +703,7 @@ function createSkillProgram(opts) {
686
703
  * defined in the skill's `Abort statuses` section. */
687
704
  const AUDIT_ABORT_CASES = [{
688
705
  match: /^no posthog sdk found$/i,
706
+ errorCode: ErrorCodes.DetectNoPosthogSdk,
689
707
  message: "No PostHog SDK found",
690
708
  body: "The audit needs an existing PostHog integration to review. No PostHog SDK appears in this project’s dependency manifests. Run the basic integration program to install PostHog first, then re-run the audit.",
691
709
  docsUrl: "https://posthog.com/docs/getting-started/install"
@@ -1189,12 +1207,14 @@ const WEB_ANALYTICS_ABORT_CASES = [
1189
1207
  },
1190
1208
  {
1191
1209
  match: /^insufficient permissions$/i,
1210
+ errorCode: ErrorCodes.AuthMissingScope,
1192
1211
  message: "Insufficient permissions",
1193
1212
  body: "The doctor could not query your project — the authenticated token is missing query access. Re-run the wizard to sign in again, or use a key with read access to your events.",
1194
1213
  docsUrl: "https://posthog.com/docs/web-analytics"
1195
1214
  },
1196
1215
  {
1197
1216
  match: /^posthog sdk not installed$/i,
1217
+ errorCode: ErrorCodes.DetectNoPosthogSdk,
1198
1218
  message: "PostHog SDK not installed",
1199
1219
  body: "The doctor could not find a PostHog SDK in this project. Install and configure PostHog first (run `npx @posthog/wizard`), then run the doctor to check your web analytics setup.",
1200
1220
  docsUrl: "https://posthog.com/docs/libraries/js"
@@ -1891,6 +1911,7 @@ const GO_SDK_MODULE = "github.com/posthog/posthog-go";
1891
1911
  const SOURCE_MAPS_ABORT_CASES = [
1892
1912
  {
1893
1913
  match: /^no posthog sdk detected$/i,
1914
+ errorCode: ErrorCodes.DetectNoPosthogSdk,
1894
1915
  message: "No PostHog SDK detected",
1895
1916
  body: "The agent could not find a PostHog SDK in your project. Source map upload requires the SDK to already be installed so it can report errors. Run `npx @posthog/wizard` first to install the SDK (for Go and Rust, add posthog-go / posthog-rs by hand first — the wizard cannot install the SDK for those stacks yet).",
1896
1917
  docsUrl: "https://posthog.com/docs/error-tracking"
@@ -1903,6 +1924,7 @@ const SOURCE_MAPS_ABORT_CASES = [
1903
1924
  },
1904
1925
  {
1905
1926
  match: /^bare react native not supported$/i,
1927
+ errorCode: ErrorCodes.DetectUnsupportedPlatform,
1906
1928
  message: "Bare React Native is not supported",
1907
1929
  body: "Source-map upload for React Native requires Expo, and this project has no `expo` package. Bare React Native builds cannot inject the chunk IDs PostHog needs to resolve stack traces.",
1908
1930
  docsUrl: "https://posthog.com/docs/error-tracking/upload-source-maps/react-native"
@@ -2485,7 +2507,7 @@ const getContentBlocks$1 = (store) => pace([
2485
2507
  //#region src/steps/install-cli-steering/index.ts
2486
2508
  const dirExists = (...segments) => {
2487
2509
  try {
2488
- return fs$1.existsSync(path$1.join(os.homedir(), ...segments));
2510
+ return fs$1.existsSync(path$2.join(os.homedir(), ...segments));
2489
2511
  } catch {
2490
2512
  return false;
2491
2513
  }
@@ -2494,19 +2516,19 @@ const CLI_STEERING_TARGETS = [
2494
2516
  {
2495
2517
  id: "claude-code",
2496
2518
  name: "Claude Code",
2497
- instructionsPath: () => path$1.join(os.homedir(), ".claude", "CLAUDE.md"),
2519
+ instructionsPath: () => path$2.join(os.homedir(), ".claude", "CLAUDE.md"),
2498
2520
  isDetected: () => dirExists(".claude")
2499
2521
  },
2500
2522
  {
2501
2523
  id: "codex",
2502
2524
  name: "Codex",
2503
- instructionsPath: () => path$1.join(os.homedir(), ".codex", "AGENTS.md"),
2525
+ instructionsPath: () => path$2.join(os.homedir(), ".codex", "AGENTS.md"),
2504
2526
  isDetected: () => dirExists(".codex")
2505
2527
  },
2506
2528
  {
2507
2529
  id: "gemini",
2508
2530
  name: "Gemini CLI",
2509
- instructionsPath: () => path$1.join(os.homedir(), ".gemini", "GEMINI.md"),
2531
+ instructionsPath: () => path$2.join(os.homedir(), ".gemini", "GEMINI.md"),
2510
2532
  isDetected: () => dirExists(".gemini")
2511
2533
  }
2512
2534
  ];
@@ -2851,6 +2873,7 @@ const SELF_DRIVING_ABORT_CASES = [
2851
2873
  },
2852
2874
  {
2853
2875
  match: /^requires-interactive-mode$/i,
2876
+ errorCode: ErrorCodes.CliInteractiveRequired,
2854
2877
  message: "Interactive terminal required",
2855
2878
  body: "Self-driving setup asks questions along the way (GitHub and issue trackers), so it needs an interactive terminal. Run the wizard outside CI / non-interactive mode."
2856
2879
  },
@@ -3864,6 +3887,29 @@ const mcpTutorialConfig = {
3864
3887
  //#region src/lib/programs/mcp-analytics/index.ts
3865
3888
  const MCP_ANALYTICS_REPORT_FILE = "posthog-mcp-analytics-report.md";
3866
3889
  /**
3890
+ * `[ABORT]` reasons the mcp-analytics skill emits when the project can't be
3891
+ * instrumented. Kept in sync with the stop conditions in the skill's
3892
+ * `description.md` (context-mill `context/skills/mcp-analytics`).
3893
+ */
3894
+ const MCP_ANALYTICS_ABORT_CASES = [
3895
+ {
3896
+ match: /^unsupported language for mcp analytics$/i,
3897
+ errorCode: ErrorCodes.DetectUnsupportedPlatform,
3898
+ message: "Unsupported language for MCP analytics",
3899
+ body: "MCP analytics supports TypeScript/JavaScript (`@posthog/mcp`) and Python (`posthog.mcp`, shipped inside the `posthog` package). This project doesn't look like either, so there's nothing to instrument. See https://posthog.com/docs/mcp-analytics for the supported setups."
3900
+ },
3901
+ {
3902
+ match: /^no mcp server found$/i,
3903
+ message: "No MCP server found",
3904
+ body: "This command instruments an existing MCP server with PostHog analytics, but no MCP server was found in this project. If you just want PostHog product analytics, run `npx @posthog/wizard` instead."
3905
+ },
3906
+ {
3907
+ match: /^could not locate the server entry point$/i,
3908
+ message: "Could not locate the MCP server entry point",
3909
+ body: "This project has MCP signals, but the agent couldn't find where the server is constructed or requests are dispatched, so there's nowhere safe to add instrumentation. See https://posthog.com/docs/mcp-analytics for the supported server styles, or point the wizard at the package that defines the server if it's in a monorepo subdirectory."
3910
+ }
3911
+ ];
3912
+ /**
3867
3913
  * `wizard mcp-analytics` — flat skill command.
3868
3914
  *
3869
3915
  * Instruments the user's own MCP server with the `@posthog/mcp` SDK so it
@@ -3889,23 +3935,7 @@ const mcpAnalyticsConfig = createSkillProgram({
3889
3935
  docsUrl: "https://posthog.com/docs/mcp-analytics",
3890
3936
  spinnerMessage: "Setting up MCP analytics...",
3891
3937
  estimatedDurationMinutes: 5,
3892
- abortCases: [
3893
- {
3894
- match: /^unsupported language for mcp analytics$/i,
3895
- message: "Unsupported language for MCP analytics",
3896
- body: "MCP analytics supports TypeScript/JavaScript (`@posthog/mcp`) and Python (`posthog.mcp`, shipped inside the `posthog` package). This project doesn't look like either, so there's nothing to instrument. See https://posthog.com/docs/mcp-analytics for the supported setups."
3897
- },
3898
- {
3899
- match: /^no mcp server found$/i,
3900
- message: "No MCP server found",
3901
- body: "This command instruments an existing MCP server with PostHog analytics, but no MCP server was found in this project. If you just want PostHog product analytics, run `npx @posthog/wizard` instead."
3902
- },
3903
- {
3904
- match: /^could not locate the server entry point$/i,
3905
- message: "Could not locate the MCP server entry point",
3906
- body: "This project has MCP signals, but the agent couldn't find where the server is constructed or requests are dispatched, so there's nowhere safe to add instrumentation. See https://posthog.com/docs/mcp-analytics for the supported server styles, or point the wizard at the package that defines the server if it's in a monorepo subdirectory."
3907
- }
3908
- ]
3938
+ abortCases: MCP_ANALYTICS_ABORT_CASES
3909
3939
  });
3910
3940
  //#endregion
3911
3941
  //#region src/lib/programs/replay-vision/index.ts
@@ -3943,8 +3973,10 @@ const REPLAY_VISION_SUPPORTED = new Set([
3943
3973
  "flutter"
3944
3974
  ]);
3945
3975
  async function abortUnsupportedPlatform(integration) {
3976
+ const name = FRAMEWORK_REGISTRY[integration]?.metadata.name ?? integration;
3946
3977
  await wizardAbort({
3947
- message: `Session replay isn't available for ${FRAMEWORK_REGISTRY[integration]?.metadata.name ?? integration} projects, and Replay vision needs session recordings to watch — so there is nothing to set up here.
3978
+ code: ErrorCodes.DetectUnsupportedPlatform,
3979
+ message: `Session replay isn't available for ${name} projects, and Replay vision needs session recordings to watch — so there is nothing to set up here.
3948
3980
 
3949
3981
  If this repo also contains a web or mobile app, run the command from that project directory instead. See what replay supports at:
3950
3982
  https://posthog.com/docs/session-replay`,
@@ -4023,7 +4055,10 @@ const replayVisionConfig = {
4023
4055
  await scopeInstallDirToProject(session);
4024
4056
  const integration = await detectFramework(session.installDir);
4025
4057
  if (!integration) {
4026
- await wizardAbort({ message: "Could not auto-detect your framework for this project." });
4058
+ await wizardAbort({
4059
+ code: ErrorCodes.DetectNoFramework,
4060
+ message: "Could not auto-detect your framework for this project."
4061
+ });
4027
4062
  return;
4028
4063
  }
4029
4064
  if (!REPLAY_VISION_SUPPORTED.has(integration)) {
@@ -4290,7 +4325,7 @@ const mcpAddCommand = {
4290
4325
  function runMcpAdd(argv) {
4291
4326
  const features = parseFeatures(argv.features);
4292
4327
  (async () => {
4293
- const { readApiKeyFromEnv } = await import("./env-api-key-CzHDwfV2.js").then((n) => n.t);
4328
+ const { readApiKeyFromEnv } = await import("./env-api-key-CwkRyrgi.js").then((n) => n.t);
4294
4329
  const apiKey = argv.apiKey || readApiKeyFromEnv();
4295
4330
  const debug = argv.debug;
4296
4331
  const localMcp = argv.local;
@@ -4304,8 +4339,8 @@ function runMcpAdd(argv) {
4304
4339
  return;
4305
4340
  }
4306
4341
  try {
4307
- const { startTUI } = await import("./start-tui-BQH4mQIZ.js");
4308
- const { buildSession } = await import("./wizard-session-Cw7-_OcZ.js");
4342
+ const { startTUI } = await import("./start-tui-D1MqJVT1.js");
4343
+ const { buildSession } = await import("./wizard-session-D1KQqUml.js");
4309
4344
  const tui = startTUI(VERSION, Program.McpAdd);
4310
4345
  tui.store.session = buildSession({
4311
4346
  debug,
@@ -4322,7 +4357,7 @@ function runMcpAdd(argv) {
4322
4357
  }
4323
4358
  async function runHeadlessAdd(args) {
4324
4359
  setUI(new LoggingUI());
4325
- const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-DWDEuDUR.js").then((n) => n.r);
4360
+ const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-y0swAr9I.js").then((n) => n.r);
4326
4361
  const { installed, failed } = await addMCPServerToClientsStep(args);
4327
4362
  if (failed.length > 0 || installed.length === 0) process.exitCode = 1;
4328
4363
  }
@@ -4354,8 +4389,8 @@ function runMcpRemove(argv) {
4354
4389
  return;
4355
4390
  }
4356
4391
  try {
4357
- const { startTUI } = await import("./start-tui-BQH4mQIZ.js");
4358
- const { buildSession } = await import("./wizard-session-Cw7-_OcZ.js");
4392
+ const { startTUI } = await import("./start-tui-D1MqJVT1.js");
4393
+ const { buildSession } = await import("./wizard-session-D1KQqUml.js");
4359
4394
  const tui = startTUI(VERSION, Program.McpRemove);
4360
4395
  tui.store.session = buildSession({
4361
4396
  debug,
@@ -4371,7 +4406,7 @@ function runMcpRemove(argv) {
4371
4406
  /** No exit code on an empty result: nothing to remove is the requested end state. */
4372
4407
  async function runHeadlessRemove(local) {
4373
4408
  setUI(new LoggingUI());
4374
- const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-DWDEuDUR.js").then((n) => n.r);
4409
+ const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-y0swAr9I.js").then((n) => n.r);
4375
4410
  await removeMCPServerFromClientsStep({ local });
4376
4411
  }
4377
4412
  //#endregion
@@ -4391,8 +4426,8 @@ function runMcpTutorial(argv) {
4391
4426
  const debug = argv.debug;
4392
4427
  const localMcp = argv.local;
4393
4428
  try {
4394
- const { startTUI } = await import("./start-tui-BQH4mQIZ.js");
4395
- const { buildSession } = await import("./wizard-session-Cw7-_OcZ.js");
4429
+ const { startTUI } = await import("./start-tui-D1MqJVT1.js");
4430
+ const { buildSession } = await import("./wizard-session-D1KQqUml.js");
4396
4431
  const tui = startTUI(VERSION, Program.McpTutorial);
4397
4432
  tui.store.session = buildSession({
4398
4433
  debug,
@@ -4402,6 +4437,10 @@ function runMcpTutorial(argv) {
4402
4437
  } catch (err) {
4403
4438
  setUI(new LoggingUI());
4404
4439
  getUI().log.error(`The MCP tutorial requires an interactive terminal. ${err instanceof Error ? err.message : String(err)}`);
4440
+ emitWizardError({
4441
+ code: ErrorCodes.CliInteractiveRequired,
4442
+ message: "The MCP tutorial requires an interactive terminal."
4443
+ });
4405
4444
  process.exit(1);
4406
4445
  }
4407
4446
  })();
@@ -4473,17 +4512,17 @@ function runWizard(config, options) {
4473
4512
  (async () => {
4474
4513
  try {
4475
4514
  const installDir = options.installDir || process.cwd();
4476
- const { startTUI } = await import("./start-tui-BQH4mQIZ.js");
4477
- const { buildSession, RunPhase } = await import("./wizard-session-Cw7-_OcZ.js");
4478
- const { TaskStreamPush } = await import("./task-stream-jUARpyB5.js");
4479
- const { PostHogDestination } = await import("./posthog-ChzdlmCs.js");
4515
+ const { startTUI } = await import("./start-tui-D1MqJVT1.js");
4516
+ const { buildSession, RunPhase } = await import("./wizard-session-D1KQqUml.js");
4517
+ const { TaskStreamPush } = await import("./task-stream-CLXzeuPO.js");
4518
+ const { PostHogDestination } = await import("./posthog-BHyJiU05.js");
4480
4519
  const local = getLocalDev();
4481
4520
  const localServicesError = await checkLocalServices({
4482
4521
  ...local,
4483
4522
  localPosthog: local.localPosthog && !options.baseUrl
4484
4523
  });
4485
4524
  if (localServicesError) {
4486
- const { wizardAbort } = await import("./wizard-abort-pFFH7dcx.js");
4525
+ const { wizardAbort } = await import("./wizard-abort-oazJA1Jb.js");
4487
4526
  await wizardAbort({ message: localServicesError });
4488
4527
  return;
4489
4528
  }
@@ -4554,7 +4593,7 @@ function runWizard(config, options) {
4554
4593
  if (shown(step)) await advanceStep(step, activeTui.store, config);
4555
4594
  }
4556
4595
  else if (skipAgent) {
4557
- const { getOrAskForProjectData } = await import("./setup-utils-aWZEdfwh.js").then((n) => n.r);
4596
+ const { getOrAskForProjectData } = await import("./setup-utils-BLKhAx6g.js").then((n) => n.r);
4558
4597
  const { projectApiKey, host, accessToken, projectId } = await getOrAskForProjectData({
4559
4598
  signup: session.signup,
4560
4599
  ci: session.ci,
@@ -4605,6 +4644,10 @@ function runWizard(config, options) {
4605
4644
  } catch {}
4606
4645
  console.error("Wizard run failed:", err);
4607
4646
  console.error(`Full logs: ${getLogFilePath()}`);
4647
+ emitWizardError({
4648
+ code: ErrorCodes.InternalUnhandled,
4649
+ message: err instanceof Error ? err.message : String(err)
4650
+ });
4608
4651
  process.exit(1);
4609
4652
  }
4610
4653
  })();
@@ -4627,11 +4670,19 @@ function validateNonInteractiveOptions(options, mode) {
4627
4670
  if (!options.apiKey) {
4628
4671
  getUI().intro("PostHog Wizard");
4629
4672
  getUI().log.error(`${label} mode requires --api-key (${keyHint})`);
4673
+ emitWizardError({
4674
+ code: ErrorCodes.ArgsMissingApiKey,
4675
+ message: `${label} mode requires --api-key (${keyHint})`
4676
+ });
4630
4677
  process.exit(1);
4631
4678
  }
4632
4679
  if (!options.installDir) {
4633
4680
  getUI().intro("PostHog Wizard");
4634
4681
  getUI().log.error(`${label} mode requires --install-dir (directory to install in)`);
4682
+ emitWizardError({
4683
+ code: ErrorCodes.ArgsMissingInstallDir,
4684
+ message: `${label} mode requires --install-dir`
4685
+ });
4635
4686
  process.exit(1);
4636
4687
  }
4637
4688
  }
@@ -4655,11 +4706,11 @@ function runNonInteractive(config, options, mode) {
4655
4706
  analytics.setTag("build", mode);
4656
4707
  (async () => {
4657
4708
  const path = await import("path");
4658
- const { buildSession, RunPhase, OutroKind } = await import("./wizard-session-Cw7-_OcZ.js");
4659
- const { readEnvironment } = await import("./environment-Cl-fIQku.js").then((n) => n.t);
4660
- const { readApiKeyFromEnv } = await import("./env-api-key-CzHDwfV2.js").then((n) => n.t);
4661
- const { configureLogFileFromEnvironment, logToFile } = await import("./debug-H-GTKvvU.js");
4662
- const { wizardAbort, WizardError } = await import("./wizard-abort-pFFH7dcx.js");
4709
+ const { buildSession, RunPhase, OutroKind } = await import("./wizard-session-D1KQqUml.js");
4710
+ const { readEnvironment } = await import("./environment-BGUJxuvj.js").then((n) => n.t);
4711
+ const { readApiKeyFromEnv } = await import("./env-api-key-CwkRyrgi.js").then((n) => n.t);
4712
+ const { configureLogFileFromEnvironment, logToFile } = await import("./debug-CWn7PsPd.js");
4713
+ const { wizardAbort, WizardError } = await import("./wizard-abort-oazJA1Jb.js");
4663
4714
  configureLogFileFromEnvironment();
4664
4715
  const env = readEnvironment();
4665
4716
  const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? void 0;
@@ -4697,15 +4748,18 @@ function runNonInteractive(config, options, mode) {
4697
4748
  localPosthog: session.baseUrl === POSTHOG_LOCAL_URL
4698
4749
  });
4699
4750
  if (localServicesError) {
4700
- await wizardAbort({ message: localServicesError });
4751
+ await wizardAbort({
4752
+ code: ErrorCodes.EnvLocalServicesDown,
4753
+ message: localServicesError
4754
+ });
4701
4755
  return;
4702
4756
  }
4703
4757
  let store = null;
4704
4758
  let taskStream = null;
4705
4759
  if (mode === "headless") {
4706
- const { WizardStore } = await import("./store-P_7zUfbj.js").then((n) => n.n);
4707
- const { HeadlessUI } = await import("./headless-ui-DT3Db1bk.js");
4708
- const { TaskStreamPush, PostHogDestination } = await import("./task-stream-jUARpyB5.js");
4760
+ const { WizardStore } = await import("./store-OGBMWp3H.js").then((n) => n.n);
4761
+ const { HeadlessUI } = await import("./headless-ui-DtIYZNVv.js");
4762
+ const { TaskStreamPush, PostHogDestination } = await import("./task-stream-CLXzeuPO.js");
4709
4763
  store = new WizardStore(config.id);
4710
4764
  store.session = session;
4711
4765
  setUI(new HeadlessUI(store));
@@ -4741,27 +4795,54 @@ function runNonInteractive(config, options, mode) {
4741
4795
  setSkillId: (skillId) => {
4742
4796
  session.skillId = skillId;
4743
4797
  },
4744
- setUnsupportedVersion: () => void 0,
4798
+ setUnsupportedVersion: (info) => {
4799
+ session.unsupportedVersion = info;
4800
+ },
4745
4801
  addDiscoveredFeature: () => void 0,
4746
4802
  setDetectionComplete: () => void 0
4747
4803
  };
4748
4804
  for (const step of config.steps) if (step.onReady) await step.onReady(readyCtx);
4749
4805
  const detectError = session.frameworkContext.detectError;
4806
+ if (session.unsupportedVersion) {
4807
+ const { current, minimum, docsUrl } = session.unsupportedVersion;
4808
+ const message = `Detected framework version ${current} is not supported. Minimum supported version is ${minimum}.`;
4809
+ await settleStream(RunPhase.Error, {
4810
+ kind: OutroKind.Error,
4811
+ message,
4812
+ errorCode: ErrorCodes.DetectUnsupportedVersion
4813
+ });
4814
+ await wizardAbort({
4815
+ code: ErrorCodes.DetectUnsupportedVersion,
4816
+ message: `${message}\n\nSee ${docsUrl}`,
4817
+ error: new WizardError(`${config.id} unsupported framework version`, {
4818
+ integration: config.id,
4819
+ current,
4820
+ minimum
4821
+ }, ErrorCodes.DetectUnsupportedVersion)
4822
+ });
4823
+ }
4750
4824
  if (detectError) {
4825
+ const code = detectErrorCode(detectError.kind);
4826
+ const detectKind = detectError.kind;
4827
+ const detail = { ...detectError };
4751
4828
  await settleStream(RunPhase.Error, {
4752
4829
  kind: OutroKind.Error,
4753
- message: `Prerequisites not met: ${detectError.kind}`
4830
+ message: `Prerequisites not met: ${detectKind}`,
4831
+ errorCode: code,
4832
+ errorDetail: detail
4754
4833
  });
4755
4834
  await wizardAbort({
4756
- message: `Prerequisites not met: ${detectError.kind}\n\nSee ${runDef?.docsUrl ?? "https://posthog.com/docs"}`,
4835
+ code,
4836
+ detail,
4837
+ message: `Prerequisites not met: ${detectKind}\n\nSee ${runDef?.docsUrl ?? "https://posthog.com/docs"}`,
4757
4838
  error: new WizardError(`${config.id} prerequisites failed`, {
4758
4839
  integration: config.id,
4759
- detect_error_kind: detectError.kind
4760
- })
4840
+ detect_error_kind: detectKind
4841
+ }, code)
4761
4842
  });
4762
4843
  }
4763
4844
  }
4764
- const { runAgent } = await import("./agent-runner-DEeMqJxy.js").then((n) => n.t);
4845
+ const { runAgent } = await import("./agent-runner-Do5kyhPo.js").then((n) => n.t);
4765
4846
  await runAgent(config, session);
4766
4847
  await settleStream(RunPhase.Completed);
4767
4848
  } catch (error) {
@@ -4773,14 +4854,20 @@ function runNonInteractive(config, options, mode) {
4773
4854
  const docsUrl = session.frameworkConfig?.metadata.docsUrl ?? runDef?.docsUrl ?? "https://posthog.com/docs";
4774
4855
  await settleStream(RunPhase.Error, {
4775
4856
  kind: OutroKind.Error,
4776
- message: errorMessage
4857
+ message: errorMessage,
4858
+ errorCode: ErrorCodes.InternalUnhandled
4777
4859
  });
4778
4860
  await wizardAbort({
4861
+ code: ErrorCodes.InternalUnhandled,
4779
4862
  message: `Something went wrong: ${errorMessage}\n\nYou can read the documentation at ${docsUrl} to set up manually.${debugInfo}`,
4780
4863
  error
4781
4864
  });
4782
4865
  }
4783
- })().catch(() => {
4866
+ })().catch((error) => {
4867
+ emitWizardError({
4868
+ code: ErrorCodes.InternalUnhandled,
4869
+ message: error instanceof Error ? error.message : String(error)
4870
+ });
4784
4871
  process.exit(1);
4785
4872
  });
4786
4873
  }
@@ -4846,12 +4933,16 @@ function runCommandHandler(work) {
4846
4933
  } catch (err) {
4847
4934
  const msg = err instanceof Error ? err.message : String(err);
4848
4935
  process.stderr.write(`\n\x1b[1;91m✖ ${msg}\x1b[0m\n\n`);
4936
+ emitWizardError({
4937
+ code: ErrorCodes.InternalUnhandled,
4938
+ message: msg
4939
+ });
4849
4940
  process.exit(1);
4850
4941
  }
4851
4942
  })();
4852
4943
  }
4853
4944
  function dispatchProgram(config, argv) {
4854
- const argvRecord = argv;
4945
+ const argvRecord = { ...argv };
4855
4946
  const extras = config.mapCliOptions?.(argvRecord) ?? {};
4856
4947
  const options = {
4857
4948
  ...argvRecord,
@@ -4957,6 +5048,10 @@ async function exitDispatchError(reason, properties, message, code = 1) {
4957
5048
  await analytics.flush();
4958
5049
  } catch {}
4959
5050
  process.stderr.write(message);
5051
+ emitWizardError({
5052
+ code: ErrorCodes.CliBadArgs,
5053
+ message: reason
5054
+ });
4960
5055
  return process.exit(code);
4961
5056
  }
4962
5057
  /**
@@ -5985,12 +6080,16 @@ async function runDoctorCI(options) {
5985
6080
  if (!apiKey) {
5986
6081
  getUI().intro("PostHog Wizard");
5987
6082
  getUI().log.error("CI mode requires --api-key (personal API key phx_xxx)");
6083
+ emitWizardError({
6084
+ code: ErrorCodes.ArgsMissingApiKey,
6085
+ message: "CI mode requires --api-key (personal API key phx_xxx)"
6086
+ });
5988
6087
  process.exit(1);
5989
6088
  }
5990
6089
  getUI().intro("Welcome to the PostHog setup wizard");
5991
6090
  getUI().log.info("Running posthog-doctor in CI mode");
5992
6091
  try {
5993
- const { getOrAskForProjectData } = await import("./setup-utils-aWZEdfwh.js").then((n) => n.r);
6092
+ const { getOrAskForProjectData } = await import("./setup-utils-BLKhAx6g.js").then((n) => n.r);
5994
6093
  const { host, accessToken, projectId } = await getOrAskForProjectData({
5995
6094
  signup: false,
5996
6095
  ci: true,
@@ -6008,9 +6107,13 @@ async function runDoctorCI(options) {
6008
6107
  for (const issue of sorted) getUI().log.info(` • [${issue.severity}] ${getKindMeta(issue.kind).title}`);
6009
6108
  process.exit(1);
6010
6109
  } catch (error) {
6011
- const { ApiError } = await import("./api-CemGgyBv.js").then((n) => n.n);
6110
+ const { ApiError } = await import("./api-D7-8R4xx.js").then((n) => n.n);
6012
6111
  const message = error instanceof ApiError && error.statusCode === 401 ? "Your PostHog API key is invalid or expired." : error instanceof Error ? error.message : String(error);
6013
6112
  getUI().log.error(`Doctor failed: ${message}`);
6113
+ emitWizardError({
6114
+ code: error instanceof ApiError && error.statusCode === 401 ? ErrorCodes.AuthInvalidOrExpired : ErrorCodes.InternalUnhandled,
6115
+ message
6116
+ });
6014
6117
  process.exit(1);
6015
6118
  }
6016
6119
  }
@@ -6090,8 +6193,8 @@ function runSlackConnect(argv) {
6090
6193
  (async () => {
6091
6194
  const debug = argv.debug;
6092
6195
  try {
6093
- const { startTUI } = await import("./start-tui-BQH4mQIZ.js");
6094
- const { buildSession } = await import("./wizard-session-Cw7-_OcZ.js");
6196
+ const { startTUI } = await import("./start-tui-D1MqJVT1.js");
6197
+ const { buildSession } = await import("./wizard-session-D1KQqUml.js");
6095
6198
  const tui = startTUI(VERSION, Program.SlackConnect);
6096
6199
  tui.store.session = buildSession({
6097
6200
  debug,
@@ -6100,6 +6203,10 @@ function runSlackConnect(argv) {
6100
6203
  } catch (err) {
6101
6204
  setUI(new LoggingUI());
6102
6205
  getUI().log.error(`Connecting Slack requires an interactive terminal. ${err instanceof Error ? err.message : String(err)}`);
6206
+ emitWizardError({
6207
+ code: ErrorCodes.CliInteractiveRequired,
6208
+ message: "Connecting Slack requires an interactive terminal."
6209
+ });
6103
6210
  process.exit(1);
6104
6211
  }
6105
6212
  })();
@@ -6217,6 +6324,10 @@ const skillCommand = {
6217
6324
  await analytics.flush();
6218
6325
  } catch {}
6219
6326
  process.stderr.write("\n\x1B[1;91m✖ Couldn't reach the skill registry.\x1B[0m\n Check your network connection and try again.\n\n");
6327
+ emitWizardError({
6328
+ code: ErrorCodes.SkillMenuFetchFailed,
6329
+ message: "Couldn't reach the skill registry."
6330
+ });
6220
6331
  process.exit(1);
6221
6332
  }
6222
6333
  const entries = (menu.cliEntries ?? []).filter((e) => BROWSABLE_ROLES.has(e.role));
@@ -6333,7 +6444,7 @@ async function runCliAdd(argv) {
6333
6444
  /** Resolve which instruction files to write, from flags, detection, or a prompt. */
6334
6445
  async function resolveTargetFiles(argv) {
6335
6446
  const ui = getUI();
6336
- if (typeof argv.path === "string" && argv.path.trim()) return [path$1.resolve(argv.path.trim())];
6447
+ if (typeof argv.path === "string" && argv.path.trim()) return [path$2.resolve(argv.path.trim())];
6337
6448
  if (typeof argv.agent === "string") {
6338
6449
  const target = findTarget(argv.agent);
6339
6450
  if (!target) {
@@ -6410,6 +6521,10 @@ if (!satisfies(process.version, NODE_VERSION_RANGE)) {
6410
6521
  ``,
6411
6522
  `Then run the wizard again. Stuck? Email wizard@posthog.com and we'll help.`
6412
6523
  ].join("\n"));
6524
+ emitWizardError({
6525
+ code: ErrorCodes.CliNodeVersion,
6526
+ message: `Node ${process.version} is below the required range ${NODE_VERSION_RANGE}`
6527
+ });
6413
6528
  process.exit(1);
6414
6529
  }
6415
6530
  recoverOrphanedSettingsBackups(resolveInstallDir());