@posthog/wizard 2.31.0 → 2.33.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 (72) hide show
  1. package/dist/{add-mcp-server-to-clients-BPBRx_Nz.js → add-mcp-server-to-clients-Dhq75Hda.js} +5 -5
  2. package/dist/{add-mcp-server-to-clients-BPBRx_Nz.js.map → add-mcp-server-to-clients-Dhq75Hda.js.map} +1 -1
  3. package/dist/{agent-interface-DT_uyR45.js → agent-interface-DCeQ5Oiw.js} +6 -6
  4. package/dist/{agent-interface-DT_uyR45.js.map → agent-interface-DCeQ5Oiw.js.map} +1 -1
  5. package/dist/{agent-runner-DfRka7f7.js → agent-runner-BRajaO84.js} +10 -9
  6. package/dist/{agent-runner-DfRka7f7.js.map → agent-runner-BRajaO84.js.map} +1 -1
  7. package/dist/{analytics-3GR9OyE9.js → analytics-CU4o3eF8.js} +3 -3
  8. package/dist/analytics-CU4o3eF8.js.map +1 -0
  9. package/dist/{api-Dmc76exl.js → api-BBRfHEZ-.js} +3 -3
  10. package/dist/{api-Dmc76exl.js.map → api-BBRfHEZ-.js.map} +1 -1
  11. package/dist/bin.js +274 -95
  12. package/dist/bin.js.map +1 -1
  13. package/dist/ci-install-D-otkGW6.js +113 -0
  14. package/dist/ci-install-D-otkGW6.js.map +1 -0
  15. package/dist/{debug-n42RObru.js → debug-BGMe1wP6.js} +2 -2
  16. package/dist/{debug-n42RObru.js.map → debug-BGMe1wP6.js.map} +1 -1
  17. package/dist/{debug-aqoKImO6.js → debug-BewTLNNr.js} +1 -1
  18. package/dist/{defaults-BNWIWzjc.js → defaults-DII5CAog.js} +1 -1
  19. package/dist/{defaults-BNWIWzjc.js.map → defaults-DII5CAog.js.map} +1 -1
  20. package/dist/{environment-BKPsjOXk.js → environment-G41UFzou.js} +3 -3
  21. package/dist/{environment-BKPsjOXk.js.map → environment-G41UFzou.js.map} +1 -1
  22. package/dist/{file-utils-ALRqLr0x.js → file-utils-D9InAvZd.js} +2 -2
  23. package/dist/{file-utils-ALRqLr0x.js.map → file-utils-D9InAvZd.js.map} +1 -1
  24. package/dist/headless-ui-xjHVVUqe.js +24 -0
  25. package/dist/headless-ui-xjHVVUqe.js.map +1 -0
  26. package/dist/{interactive-ChaxKwhe.js → interactive-D2CKikzz.js} +3 -3
  27. package/dist/{interactive-ChaxKwhe.js.map → interactive-D2CKikzz.js.map} +1 -1
  28. package/dist/{mcp-prompt-streaming-CNmYvvmk.js → mcp-prompt-streaming-FrArGwfv.js} +4 -4
  29. package/dist/{mcp-prompt-streaming-CNmYvvmk.js.map → mcp-prompt-streaming-FrArGwfv.js.map} +1 -1
  30. package/dist/{non-interactive-BM4hUmlI.js → non-interactive-BXx6Q-D0.js} +2 -2
  31. package/dist/{non-interactive-BM4hUmlI.js.map → non-interactive-BXx6Q-D0.js.map} +1 -1
  32. package/dist/{package-manager-l8N6VCPX.js → package-manager-D9ojA4jO.js} +2 -2
  33. package/dist/{package-manager-l8N6VCPX.js.map → package-manager-D9ojA4jO.js.map} +1 -1
  34. package/dist/{playground-C7SbDVI4.js → playground-Bgtxrusl.js} +7 -5
  35. package/dist/{playground-C7SbDVI4.js.map → playground-Bgtxrusl.js.map} +1 -1
  36. package/dist/{posthog-Cr37rnla.js → posthog-DU6JXG00.js} +1 -1
  37. package/dist/{posthog-Cr37rnla.js.map → posthog-DU6JXG00.js.map} +1 -1
  38. package/dist/{posthog-integration-YDzQBfhq.js → posthog-integration-gnC9v4kg.js} +13 -13
  39. package/dist/{posthog-integration-YDzQBfhq.js.map → posthog-integration-gnC9v4kg.js.map} +1 -1
  40. package/dist/{provisioning-ql6mjOVq.js → provisioning-C3qglLdc.js} +3 -3
  41. package/dist/{provisioning-ql6mjOVq.js.map → provisioning-C3qglLdc.js.map} +1 -1
  42. package/dist/{registry-5SphnyxS.js → registry-BVrvFTZ0.js} +4 -4
  43. package/dist/{registry-5SphnyxS.js.map → registry-BVrvFTZ0.js.map} +1 -1
  44. package/dist/{setup-utils-CoblNeRY.js → setup-utils-CanVlGbX.js} +8 -8
  45. package/dist/{setup-utils-CoblNeRY.js.map → setup-utils-CanVlGbX.js.map} +1 -1
  46. package/dist/smoke-test.sh +25 -0
  47. package/dist/{start-tui-D_woOYMc.js → start-tui-YE7bybIr.js} +17 -16
  48. package/dist/{start-tui-D_woOYMc.js.map → start-tui-YE7bybIr.js.map} +1 -1
  49. package/dist/{steps-2gR__rtG.js → steps-N20e4IoE.js} +7 -7
  50. package/dist/{steps-2gR__rtG.js.map → steps-N20e4IoE.js.map} +1 -1
  51. package/dist/store-D15C9YSW.js +763 -0
  52. package/dist/store-D15C9YSW.js.map +1 -0
  53. package/dist/{task-stream-BQNSp0qR.js → task-stream-CPjpHFhI.js} +4 -4
  54. package/dist/{task-stream-BQNSp0qR.js.map → task-stream-CPjpHFhI.js.map} +1 -1
  55. package/dist/{telemetry-CqysQT5U.js → telemetry-DknCDWP6.js} +3 -3
  56. package/dist/{telemetry-CqysQT5U.js.map → telemetry-DknCDWP6.js.map} +1 -1
  57. package/dist/{terminal-CeokeMGP.js → terminal-Cvv0a-7Q.js} +14 -764
  58. package/dist/terminal-Cvv0a-7Q.js.map +1 -0
  59. package/dist/{urls-BOcViDhS.js → urls-DrR6F_A3.js} +2 -2
  60. package/dist/{urls-BOcViDhS.js.map → urls-DrR6F_A3.js.map} +1 -1
  61. package/dist/{wizard-abort-DFL5Um-M.js → wizard-abort-Cw818xPr.js} +4 -3
  62. package/dist/{wizard-abort-DFL5Um-M.js.map → wizard-abort-Cw818xPr.js.map} +1 -1
  63. package/dist/{wizard-abort-C0siBgn5.js → wizard-abort-DMvS0YXD.js} +1 -1
  64. package/dist/wizard-session-BKEdX9mO.js +2 -0
  65. package/dist/{wizard-session-G3VWD6hv.js → wizard-session-CN55LYyZ.js} +9 -2
  66. package/dist/{wizard-session-G3VWD6hv.js.map → wizard-session-CN55LYyZ.js.map} +1 -1
  67. package/package.json +1 -1
  68. package/dist/analytics-3GR9OyE9.js.map +0 -1
  69. package/dist/ci-install-QWrT_cW8.js +0 -73
  70. package/dist/ci-install-QWrT_cW8.js.map +0 -1
  71. package/dist/terminal-CeokeMGP.js.map +0 -1
  72. package/dist/wizard-session-wPJtNl4c.js +0 -2
package/dist/bin.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { I as POSTHOG_DOCS_URL, Q as WIZARD_USER_AGENT, a as getLogFilePath, et as getSkillsBaseUrl, h as LoggingUI, m as setUI, p as getUI, r as debug, s as logToFile, tt as VERSION } from "./debug-n42RObru.js";
3
- import { t as analytics } from "./analytics-3GR9OyE9.js";
4
- import { r as setEntryCommand } from "./telemetry-CqysQT5U.js";
5
- import { n as isUsingTypeScript } from "./setup-utils-CoblNeRY.js";
6
- import { a as getUiHostFromHost, n as getCloudUrlFromRegion } from "./urls-BOcViDhS.js";
7
- import { o as handleApiError } from "./api-Dmc76exl.js";
8
- import "./wizard-session-G3VWD6hv.js";
9
- import { r as runCleanups } from "./wizard-abort-DFL5Um-M.js";
10
- import { n as isNonInteractiveEnvironment } from "./environment-BKPsjOXk.js";
11
- import { C as AUDIT_CHECKS_FILE, T as AUDIT_REPORT_FILE, c as recoverOrphanedSettingsBackups, g as WIZARD_TOOL_NAMES, h as SETUP_REPORT_FILE, u as AgentSignals, v as fetchSkillMenu, w as AUDIT_CHECKS_KEY } from "./agent-interface-DT_uyR45.js";
12
- import { i as SPINNER_MESSAGE } from "./registry-5SphnyxS.js";
13
- import { _ as parseRequirementsTxt, a as StatusPeekTrigger, c as isClearBlock, d as Colors, f as Icons, g as parsePyprojectToml, h as parsePipfile, i as PRODUCT_SUITE_BLOCK, n as FUNNEL_BLOCK, p as HEALTH_CHECK_STEP, r as LINE_CHART_BLOCK, t as posthogIntegrationConfig } from "./posthog-integration-YDzQBfhq.js";
14
- import { n as safeReadFile, r as walkProjectFiles, t as IGNORED_DIRS } from "./file-utils-ALRqLr0x.js";
2
+ import { I as POSTHOG_DOCS_URL, Q as WIZARD_USER_AGENT, a as getLogFilePath, et as getSkillsBaseUrl, h as LoggingUI, m as setUI, p as getUI, r as debug, s as logToFile, tt as VERSION } from "./debug-BGMe1wP6.js";
3
+ import { t as analytics } from "./analytics-CU4o3eF8.js";
4
+ import { r as setEntryCommand } from "./telemetry-DknCDWP6.js";
5
+ import { n as isUsingTypeScript } from "./setup-utils-CanVlGbX.js";
6
+ import { a as getUiHostFromHost, n as getCloudUrlFromRegion } from "./urls-DrR6F_A3.js";
7
+ import { o as handleApiError } from "./api-BBRfHEZ-.js";
8
+ import "./wizard-session-CN55LYyZ.js";
9
+ import { r as runCleanups } from "./wizard-abort-Cw818xPr.js";
10
+ import { n as isNonInteractiveEnvironment } from "./environment-G41UFzou.js";
11
+ import { C as AUDIT_CHECKS_FILE, T as AUDIT_REPORT_FILE, c as recoverOrphanedSettingsBackups, g as WIZARD_TOOL_NAMES, h as SETUP_REPORT_FILE, u as AgentSignals, v as fetchSkillMenu, w as AUDIT_CHECKS_KEY } from "./agent-interface-DCeQ5Oiw.js";
12
+ import { i as SPINNER_MESSAGE } from "./registry-BVrvFTZ0.js";
13
+ import { _ as parseRequirementsTxt, a as StatusPeekTrigger, c as isClearBlock, d as Colors, f as Icons, g as parsePyprojectToml, h as parsePipfile, i as PRODUCT_SUITE_BLOCK, n as FUNNEL_BLOCK, p as HEALTH_CHECK_STEP, r as LINE_CHART_BLOCK, t as posthogIntegrationConfig } from "./posthog-integration-gnC9v4kg.js";
14
+ import { n as safeReadFile, r as walkProjectFiles, t as IGNORED_DIRS } from "./file-utils-D9InAvZd.js";
15
15
  import { n as readApiKeyFromEnv } from "./env-api-key-MlzJYAvt.js";
16
16
  import { satisfies } from "semver";
17
17
  import yargs from "yargs";
@@ -29,6 +29,37 @@ import { createContext, createElement, useCallback, useContext, useEffect, useRe
29
29
  import { jsx, jsxs } from "react/jsx-runtime";
30
30
  import { access, rm } from "node:fs/promises";
31
31
  import * as readline from "node:readline/promises";
32
+ //#region src/lib/headless-mode.ts
33
+ /**
34
+ * Headless mode — the published-build, non-interactive run path.
35
+ *
36
+ * The headless flag and `--ci` both drive a non-interactive install
37
+ * (session.ci === true), but through dedicated entry points so they can
38
+ * diverge: runHeadlessInstall → runWizardHeadless for headless,
39
+ * runCIInstall → runWizardCI for `--ci`. Both delegate to one shared pipeline
40
+ * (runNonInteractive) today; the only forks are the api-key prefixes accepted
41
+ * (ci-install) and the analytics build tag (the mode passed to the runner).
42
+ *
43
+ * The flag is deliberately named `--headless-DONOTUSE-EXPERIMENTAL` and hidden
44
+ * from `--help`: the contract is still unstable and subject to breaking
45
+ * changes, so it must not be advertised or relied on by external callers. This
46
+ * module is the single source of truth for the flag's name and detection — keep
47
+ * the scary name out of every other file so a future rename is one edit here.
48
+ */
49
+ /**
50
+ * The on-CLI flag name. Intentionally ugly + undocumented; do not surface it in
51
+ * `--help`, the README, or user-facing error messages.
52
+ */
53
+ const HEADLESS_FLAG = "headless-DONOTUSE-EXPERIMENTAL";
54
+ /**
55
+ * Read the headless signal off a parsed argv / options bag. yargs always sets
56
+ * the value under the declared key (`HEADLESS_FLAG`), so reading that key is
57
+ * reliable regardless of camel-case expansion.
58
+ */
59
+ function isHeadless(options) {
60
+ return options[HEADLESS_FLAG] === true;
61
+ }
62
+ //#endregion
32
63
  //#region src/commands/command.ts
33
64
  /** Extract the bare command word(s) from a yargs name spec, dropping positionals and aliases' arg syntax. */
34
65
  function commandKeys(name) {
@@ -98,6 +129,12 @@ const GLOBAL_OPTIONS = {
98
129
  describe: "Email address for signup (used with --signup)\nenv: POSTHOG_WIZARD_EMAIL",
99
130
  type: "string"
100
131
  },
132
+ [HEADLESS_FLAG]: {
133
+ default: false,
134
+ describe: "EXPERIMENTAL — do not use. Unstable, subject to breaking changes.",
135
+ type: "boolean",
136
+ hidden: true
137
+ },
101
138
  "local-mcp": {
102
139
  default: false,
103
140
  describe: "Use local MCP server at http://localhost:8787/mcp\nenv: POSTHOG_WIZARD_LOCAL_MCP",
@@ -190,7 +227,7 @@ function runProvision(argv) {
190
227
  }
191
228
  async function provision({ email, region, name, jsonMode }) {
192
229
  try {
193
- const { provisionNewAccount } = await import("./provisioning-ql6mjOVq.js").then((n) => n.n);
230
+ const { provisionNewAccount } = await import("./provisioning-C3qglLdc.js").then((n) => n.n);
194
231
  if (!jsonMode) getUI().log.info(`Provisioning account for ${email} in ${region}...`);
195
232
  emitResult(await provisionNewAccount(email, name, region), jsonMode);
196
233
  process.exit(0);
@@ -248,25 +285,29 @@ const basicIntegrationCommand = {
248
285
  }
249
286
  },
250
287
  check: (argv) => {
251
- if (argv.playground && argv.ci) throw new Error("--playground cannot be combined with --ci.");
288
+ if (argv.playground && (argv.ci || isHeadless(argv))) throw new Error("--playground cannot be combined with a headless run.");
252
289
  return true;
253
290
  },
254
291
  handler: (argv) => {
255
292
  setEntryCommand("integrate");
256
293
  (async () => {
294
+ if (isHeadless(argv)) {
295
+ const { runHeadlessInstall } = await import("./ci-install-D-otkGW6.js");
296
+ return runHeadlessInstall(argv);
297
+ }
257
298
  if (argv.ci) {
258
- const { runCIInstall } = await import("./ci-install-QWrT_cW8.js");
299
+ const { runCIInstall } = await import("./ci-install-D-otkGW6.js");
259
300
  return runCIInstall(argv);
260
301
  }
261
302
  if (isNonInteractiveEnvironment()) {
262
- const { failNonInteractive } = await import("./non-interactive-BM4hUmlI.js");
303
+ const { failNonInteractive } = await import("./non-interactive-BXx6Q-D0.js");
263
304
  return failNonInteractive();
264
305
  }
265
306
  if (argv.playground) {
266
- const { runPlayground } = await import("./playground-C7SbDVI4.js");
307
+ const { runPlayground } = await import("./playground-Bgtxrusl.js");
267
308
  return runPlayground();
268
309
  }
269
- const { runInteractive } = await import("./interactive-ChaxKwhe.js");
310
+ const { runInteractive } = await import("./interactive-D2CKikzz.js");
270
311
  runInteractive(argv);
271
312
  })();
272
313
  }
@@ -3216,13 +3257,18 @@ const errorTrackingUploadSourceMapsConfig = {
3216
3257
  * `session.installDir` is a real, readable directory. We deliberately do
3217
3258
  * NOT require the base posthog-integration report to be present — it is a
3218
3259
  * report many users never commit, and `requires: ['posthog-integration']`
3219
- * is metadata, not a hard runtime gate. Real readiness (integration state
3220
- * + beta access) is established by the agent's STEP 1 Signals API probe at
3221
- * the start of the run. The beta gates (the `product-autonomy` access flag
3222
- * and `signals-scout` enrollment PostHog-side flag names, unchanged by
3223
- * the wizard-side "self-driving" rename) are PostHog-internal flags with no
3224
- * customer-facing read API, which is why that probe lives in the run and
3225
- * emits a structured `[ABORT]` when the product is not available.
3260
+ * is metadata, not a hard runtime gate.
3261
+ *
3262
+ * Self-driving is now in OPEN beta available to every team — so STEP 1
3263
+ * no longer probes the Signals API as an access gate; it completes
3264
+ * instantly so the run opens with a fast first checkmark. The
3265
+ * `self-driving is not available for this project` abort below is kept
3266
+ * only as a safety net: if the Signals API genuinely can't be reached
3267
+ * during the run (a hard error that is unexpected in open beta), the skill
3268
+ * emits it and the wizard renders a friendly "try again" screen — now with
3269
+ * open-beta wording, not the old closed, per-team "join the beta" copy. The
3270
+ * PostHog-side flags (`product-autonomy`, `signals-scout`) are unchanged by
3271
+ * the wizard-side "self-driving" rename.
3226
3272
  */
3227
3273
  /**
3228
3274
  * `[ABORT] <reason>` cases the self-driving skill can emit. The
@@ -3233,7 +3279,7 @@ const SELF_DRIVING_ABORT_CASES = [
3233
3279
  {
3234
3280
  match: /^self-driving is not available for this project$/i,
3235
3281
  message: "PostHog Self-driving is not available for this project",
3236
- body: "Self-driving is in beta and is enabled per team by PostHog. This project does not appear to have access yet. Reach out to your PostHog contact (or wizard@posthog.com) to join the beta, then run the wizard again."
3282
+ body: "Self-driving is in open beta and available to every team, so this is unexpected — the PostHog Signals API could not be reached for this project. Nothing was changed. Try again in a moment, and if it keeps happening reach out to wizard@posthog.com."
3237
3283
  },
3238
3284
  {
3239
3285
  match: /^github connection declined$/i,
@@ -3389,8 +3435,13 @@ Wizard mechanics:
3389
3435
  Follow these steps IN ORDER. Do not skip or reorder.
3390
3436
 
3391
3437
  STEP 1 — Check Self-driving access. (skill: "Check access")
3392
- Probe the Signals API as the skill describes. If the API is not
3393
- available for this project (permission or not-found errors), emit
3438
+ Self-driving is in open beta and available to every team, so there is
3439
+ no access gate to probe. Do NOT call any MCP tool here — mark this task
3440
+ in_progress and then completed right away and emit the
3441
+ ${AgentSignals.STATUS} line, so the user sees an immediate first step.
3442
+ Only if the Signals API later turns out to be genuinely unreachable for
3443
+ this project (a hard error on every Signals call, unexpected in open
3444
+ beta) should you emit
3394
3445
  ${AgentSignals.ABORT} self-driving is not available for this project
3395
3446
  and halt.
3396
3447
 
@@ -3640,6 +3691,45 @@ const mcpTutorialConfig = {
3640
3691
  }]
3641
3692
  };
3642
3693
  //#endregion
3694
+ //#region src/lib/programs/mcp-analytics/index.ts
3695
+ const MCP_ANALYTICS_REPORT_FILE = "posthog-mcp-analytics-report.md";
3696
+ /**
3697
+ * `wizard mcp-analytics` — flat skill command.
3698
+ *
3699
+ * Instruments the user's own MCP server with the `@posthog/mcp` SDK so it
3700
+ * reports `$mcp_*` analytics about itself. This is the opposite of
3701
+ * `wizard mcp add` (which installs the PostHog MCP *server* into a coding
3702
+ * agent) — keep the two distinct.
3703
+ *
3704
+ * Flat while instrumenting is the only action. If an uninstrument / `remove`
3705
+ * leaf ever lands, restructure into a family with `familyCommandFactory` and
3706
+ * publish each leaf as a `cliEntries` entry with `parentCommand:
3707
+ * 'mcp-analytics'` from context-mill — a deliberate breaking change, done then,
3708
+ * not pre-emptively.
3709
+ */
3710
+ const mcpAnalyticsConfig = createSkillProgram({
3711
+ skillId: "mcp-analytics",
3712
+ command: "mcp-analytics",
3713
+ id: "mcp-analytics",
3714
+ description: "Add PostHog MCP analytics to your MCP server",
3715
+ integrationLabel: "mcp-analytics",
3716
+ customPrompt: `Instrument this project's MCP server with PostHog MCP analytics. Run the \`mcp-analytics\` skill end-to-end: detect the server style, install \`@posthog/mcp\` and \`posthog-node\`, wrap the server (or use \`PostHogMCP\` for a custom dispatcher), wire the project API key and host, and verify. Make only additive changes — do not alter tool behavior. The final report is written to ./${MCP_ANALYTICS_REPORT_FILE}.`,
3717
+ successMessage: `MCP analytics configured! View the report at ./${MCP_ANALYTICS_REPORT_FILE}`,
3718
+ reportFile: MCP_ANALYTICS_REPORT_FILE,
3719
+ docsUrl: "https://posthog.com/docs/mcp-analytics",
3720
+ spinnerMessage: "Setting up MCP analytics...",
3721
+ estimatedDurationMinutes: 5,
3722
+ abortCases: [{
3723
+ match: /^not a javascript mcp server$/i,
3724
+ message: "Not a JavaScript/TypeScript MCP server",
3725
+ body: "MCP analytics is currently TypeScript/JavaScript-only — the `@posthog/mcp` SDK is a Node package (a Python SDK is on the roadmap). This project doesn't look like a JS/TS MCP server, so there's nothing to instrument. See https://posthog.com/docs/mcp-analytics for the supported setups."
3726
+ }, {
3727
+ match: /^no mcp server found$/i,
3728
+ message: "No MCP server found",
3729
+ 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."
3730
+ }]
3731
+ });
3732
+ //#endregion
3643
3733
  //#region src/lib/programs/slack/index.ts
3644
3734
  const slackConnectConfig = {
3645
3735
  id: "slack",
@@ -3687,6 +3777,7 @@ const PROGRAM_REGISTRY = [
3687
3777
  mcpAddConfig,
3688
3778
  mcpRemoveConfig,
3689
3779
  mcpTutorialConfig,
3780
+ mcpAnalyticsConfig,
3690
3781
  slackConnectConfig
3691
3782
  ];
3692
3783
  /**
@@ -3709,6 +3800,7 @@ const Program = {
3709
3800
  McpAdd: mcpAddConfig.id,
3710
3801
  McpRemove: mcpRemoveConfig.id,
3711
3802
  McpTutorial: mcpTutorialConfig.id,
3803
+ McpAnalytics: mcpAnalyticsConfig.id,
3712
3804
  SlackConnect: slackConnectConfig.id
3713
3805
  };
3714
3806
  /**
@@ -3749,8 +3841,8 @@ function runMcpAdd(argv) {
3749
3841
  const debug = argv.debug;
3750
3842
  const localMcp = argv.local;
3751
3843
  try {
3752
- const { startTUI } = await import("./start-tui-D_woOYMc.js");
3753
- const { buildSession } = await import("./wizard-session-wPJtNl4c.js");
3844
+ const { startTUI } = await import("./start-tui-YE7bybIr.js");
3845
+ const { buildSession } = await import("./wizard-session-BKEdX9mO.js");
3754
3846
  const tui = startTUI(VERSION, Program.McpAdd);
3755
3847
  tui.store.session = buildSession({
3756
3848
  debug,
@@ -3761,7 +3853,7 @@ function runMcpAdd(argv) {
3761
3853
  } catch (error) {
3762
3854
  if (!isTUIUnavailable(error)) throw error;
3763
3855
  setUI(new LoggingUI());
3764
- const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-BPBRx_Nz.js").then((n) => n.r);
3856
+ const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-Dhq75Hda.js").then((n) => n.r);
3765
3857
  await addMCPServerToClientsStep({
3766
3858
  local: localMcp,
3767
3859
  features,
@@ -3800,8 +3892,8 @@ function runMcpRemove(argv) {
3800
3892
  const debug = argv.debug;
3801
3893
  const localMcp = argv.local;
3802
3894
  try {
3803
- const { startTUI } = await import("./start-tui-D_woOYMc.js");
3804
- const { buildSession } = await import("./wizard-session-wPJtNl4c.js");
3895
+ const { startTUI } = await import("./start-tui-YE7bybIr.js");
3896
+ const { buildSession } = await import("./wizard-session-BKEdX9mO.js");
3805
3897
  const tui = startTUI(VERSION, Program.McpRemove);
3806
3898
  tui.store.session = buildSession({
3807
3899
  debug,
@@ -3809,7 +3901,7 @@ function runMcpRemove(argv) {
3809
3901
  });
3810
3902
  } catch {
3811
3903
  setUI(new LoggingUI());
3812
- const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-BPBRx_Nz.js").then((n) => n.r);
3904
+ const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-Dhq75Hda.js").then((n) => n.r);
3813
3905
  await removeMCPServerFromClientsStep({ local: localMcp });
3814
3906
  }
3815
3907
  })();
@@ -3831,8 +3923,8 @@ function runMcpTutorial(argv) {
3831
3923
  const debug = argv.debug;
3832
3924
  const localMcp = argv.local;
3833
3925
  try {
3834
- const { startTUI } = await import("./start-tui-D_woOYMc.js");
3835
- const { buildSession } = await import("./wizard-session-wPJtNl4c.js");
3926
+ const { startTUI } = await import("./start-tui-YE7bybIr.js");
3927
+ const { buildSession } = await import("./wizard-session-BKEdX9mO.js");
3836
3928
  const tui = startTUI(VERSION, Program.McpTutorial);
3837
3929
  tui.store.session = buildSession({
3838
3930
  debug,
@@ -3886,10 +3978,10 @@ function runWizard(config, options) {
3886
3978
  (async () => {
3887
3979
  try {
3888
3980
  const installDir = options.installDir || process.cwd();
3889
- const { startTUI } = await import("./start-tui-D_woOYMc.js");
3890
- const { buildSession, RunPhase } = await import("./wizard-session-wPJtNl4c.js");
3891
- const { TaskStreamPush } = await import("./task-stream-BQNSp0qR.js");
3892
- const { PostHogDestination } = await import("./posthog-Cr37rnla.js");
3981
+ const { startTUI } = await import("./start-tui-YE7bybIr.js");
3982
+ const { buildSession, RunPhase } = await import("./wizard-session-BKEdX9mO.js");
3983
+ const { TaskStreamPush } = await import("./task-stream-CPjpHFhI.js");
3984
+ const { PostHogDestination } = await import("./posthog-DU6JXG00.js");
3893
3985
  tui = startTUI(WIZARD_VERSION, config.id);
3894
3986
  const activeTui = tui;
3895
3987
  const session = buildSession({
@@ -3942,7 +4034,7 @@ function runWizard(config, options) {
3942
4034
  await activeTui.store.getGate("health-check");
3943
4035
  const skipAgent = config.run == null;
3944
4036
  if (skipAgent) {
3945
- const { getOrAskForProjectData } = await import("./setup-utils-CoblNeRY.js").then((n) => n.r);
4037
+ const { getOrAskForProjectData } = await import("./setup-utils-CanVlGbX.js").then((n) => n.r);
3946
4038
  const { projectApiKey, host, accessToken, projectId } = await getOrAskForProjectData({
3947
4039
  signup: session.signup,
3948
4040
  ci: session.ci,
@@ -3957,7 +4049,7 @@ function runWizard(config, options) {
3957
4049
  projectId
3958
4050
  });
3959
4051
  } else {
3960
- const { runAgent } = await import("./agent-runner-DfRka7f7.js");
4052
+ const { runAgent } = await import("./agent-runner-BRajaO84.js");
3961
4053
  await runAgent(config, activeTui.store.session);
3962
4054
  }
3963
4055
  const isDone = () => skipAgent ? activeTui.store.session.outroDismissed : activeTui.store.session.skillsComplete;
@@ -4000,44 +4092,57 @@ function runWizard(config, options) {
4000
4092
  })();
4001
4093
  }
4002
4094
  //#endregion
4003
- //#region src/lib/runners/run-wizard-ci.ts
4095
+ //#region src/lib/runners/run-non-interactive.ts
4096
+ /** User-facing label for a non-interactive mode. */
4097
+ function modeLabel(mode) {
4098
+ return mode === "headless" ? "Headless" : "CI";
4099
+ }
4004
4100
  /**
4005
- * The single CI validation layer: defaults region and requires api-key and
4006
- * install-dir. Every CI entry point routes through `runWizardCI`, so this is
4007
- * the one place these checks live. UI must be initialized before calling.
4101
+ * The single non-interactive validation layer: defaults region and requires
4102
+ * api-key and install-dir. Every non-interactive entry point routes through
4103
+ * `runNonInteractive`, so this is the one place these checks live. UI must be
4104
+ * initialized before calling.
4008
4105
  */
4009
- function validateCiOptions(options) {
4106
+ function validateNonInteractiveOptions(options, mode) {
4107
+ const label = modeLabel(mode);
4108
+ const keyHint = mode === "headless" ? "personal API key phx_xxx or pha_ OAuth access token" : "personal API key phx_xxx";
4010
4109
  if (!options.region) options.region = "us";
4011
4110
  if (!options.apiKey) {
4012
4111
  getUI().intro("PostHog Wizard");
4013
- getUI().log.error("CI mode requires --api-key (personal API key phx_xxx)");
4112
+ getUI().log.error(`${label} mode requires --api-key (${keyHint})`);
4014
4113
  process.exit(1);
4015
4114
  }
4016
4115
  if (!options.installDir) {
4017
4116
  getUI().intro("PostHog Wizard");
4018
- getUI().log.error("CI mode requires --install-dir (directory to install in)");
4117
+ getUI().log.error(`${label} mode requires --install-dir (directory to install in)`);
4019
4118
  process.exit(1);
4020
4119
  }
4021
4120
  }
4022
4121
  /**
4023
- * CI-mode pipeline shared by every non-interactive entry point.
4122
+ * Non-interactive pipeline shared by CI (`runWizardCI`) and headless
4123
+ * (`runWizardHeadless`) runs.
4024
4124
  *
4025
4125
  * Validates flags, builds a `ci:true` session, runs `config.ciPreRun` (or the
4026
4126
  * program's `onReady` hooks by default), executes `runAgent`, and routes any
4027
4127
  * failure through `wizardAbort`. `wizardAbort` owns all exits — never add a
4028
4128
  * raw `process.exit` here.
4129
+ *
4130
+ * `mode` is the only difference between the two callers today (it sets the
4131
+ * analytics build tag and the user-facing label). Keeping it a parameter is
4132
+ * what lets CI and headless share this body now and diverge later — branch on
4133
+ * `mode` here, or stop sharing this function entirely.
4029
4134
  */
4030
- function runWizardCI(config, options) {
4135
+ function runNonInteractive(config, options, mode) {
4031
4136
  setUI(new LoggingUI());
4032
- validateCiOptions(options);
4033
- analytics.setTag("build", "ci");
4137
+ validateNonInteractiveOptions(options, mode);
4138
+ analytics.setTag("build", mode);
4034
4139
  (async () => {
4035
4140
  const path = await import("path");
4036
- const { buildSession } = await import("./wizard-session-wPJtNl4c.js");
4037
- const { readEnvironment } = await import("./environment-BKPsjOXk.js").then((n) => n.t);
4141
+ const { buildSession, RunPhase, OutroKind } = await import("./wizard-session-BKEdX9mO.js");
4142
+ const { readEnvironment } = await import("./environment-G41UFzou.js").then((n) => n.t);
4038
4143
  const { readApiKeyFromEnv } = await import("./env-api-key-MlzJYAvt.js").then((n) => n.t);
4039
- const { configureLogFileFromEnvironment, logToFile } = await import("./debug-aqoKImO6.js");
4040
- const { wizardAbort, WizardError } = await import("./wizard-abort-C0siBgn5.js");
4144
+ const { configureLogFileFromEnvironment, logToFile } = await import("./debug-BewTLNNr.js");
4145
+ const { wizardAbort, WizardError } = await import("./wizard-abort-DMvS0YXD.js");
4041
4146
  configureLogFileFromEnvironment();
4042
4147
  const env = readEnvironment();
4043
4148
  const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? void 0;
@@ -4060,7 +4165,34 @@ function runWizardCI(config, options) {
4060
4165
  if (config.skillId) session.skillId = config.skillId;
4061
4166
  const runDef = typeof config.run === "object" ? config.run : null;
4062
4167
  getUI().intro("Welcome to the PostHog setup wizard");
4063
- getUI().log.info(`Running ${config.id} in CI mode`);
4168
+ getUI().log.info(`Running ${config.id} in ${modeLabel(mode)} mode`);
4169
+ let store = null;
4170
+ let taskStream = null;
4171
+ if (mode === "headless") {
4172
+ const { WizardStore } = await import("./store-D15C9YSW.js").then((n) => n.n);
4173
+ const { HeadlessUI } = await import("./headless-ui-xjHVVUqe.js");
4174
+ const { TaskStreamPush, PostHogDestination } = await import("./task-stream-CPjpHFhI.js");
4175
+ store = new WizardStore(config.id);
4176
+ store.session = session;
4177
+ setUI(new HeadlessUI(store));
4178
+ taskStream = new TaskStreamPush({
4179
+ store,
4180
+ programId: config.id,
4181
+ destinations: [new PostHogDestination({
4182
+ getCredentials: () => session.credentials,
4183
+ onError: (e) => logToFile("[headless task-stream]", e.message)
4184
+ })],
4185
+ enabled: !session.noTelemetry
4186
+ });
4187
+ taskStream.attach();
4188
+ store.setRunPhase(RunPhase.Running);
4189
+ }
4190
+ const settleStream = async (phase, outroData) => {
4191
+ if (!store || !taskStream) return;
4192
+ if (outroData) store.setOutroData(outroData);
4193
+ store.setRunPhase(phase);
4194
+ await taskStream.shutdown(2e3);
4195
+ };
4064
4196
  try {
4065
4197
  if (config.ciPreRun) await config.ciPreRun(session);
4066
4198
  else {
@@ -4080,24 +4212,36 @@ function runWizardCI(config, options) {
4080
4212
  };
4081
4213
  for (const step of config.steps) if (step.onReady) await step.onReady(readyCtx);
4082
4214
  const detectError = session.frameworkContext.detectError;
4083
- if (detectError) await wizardAbort({
4084
- message: `Prerequisites not met: ${detectError.kind}\n\nSee ${runDef?.docsUrl ?? "https://posthog.com/docs"}`,
4085
- error: new WizardError(`${config.id} prerequisites failed`, {
4086
- integration: config.id,
4087
- detect_error_kind: detectError.kind
4088
- })
4089
- });
4215
+ if (detectError) {
4216
+ await settleStream(RunPhase.Error, {
4217
+ kind: OutroKind.Error,
4218
+ message: `Prerequisites not met: ${detectError.kind}`
4219
+ });
4220
+ await wizardAbort({
4221
+ message: `Prerequisites not met: ${detectError.kind}\n\nSee ${runDef?.docsUrl ?? "https://posthog.com/docs"}`,
4222
+ error: new WizardError(`${config.id} prerequisites failed`, {
4223
+ integration: config.id,
4224
+ detect_error_kind: detectError.kind
4225
+ })
4226
+ });
4227
+ }
4090
4228
  }
4091
- const { runAgent } = await import("./agent-runner-DfRka7f7.js");
4229
+ const { runAgent } = await import("./agent-runner-BRajaO84.js");
4092
4230
  await runAgent(config, session);
4231
+ await settleStream(RunPhase.Completed);
4093
4232
  } catch (error) {
4094
4233
  const errorMessage = error instanceof Error ? error.message : String(error);
4095
4234
  const errorStack = error instanceof Error && error.stack ? error.stack : void 0;
4096
- logToFile(`[bin.ts CI] ERROR: ${errorMessage}`);
4097
- if (errorStack) logToFile(`[bin.ts CI] STACK: ${errorStack}`);
4235
+ logToFile(`[${mode}] ERROR: ${errorMessage}`);
4236
+ if (errorStack) logToFile(`[${mode}] STACK: ${errorStack}`);
4098
4237
  const debugInfo = session.debug && errorStack ? `\n\n${errorStack}` : "";
4238
+ const docsUrl = session.frameworkConfig?.metadata.docsUrl ?? runDef?.docsUrl ?? "https://posthog.com/docs";
4239
+ await settleStream(RunPhase.Error, {
4240
+ kind: OutroKind.Error,
4241
+ message: errorMessage
4242
+ });
4099
4243
  await wizardAbort({
4100
- message: `Something went wrong: ${errorMessage}\n\nYou can read the documentation at ${session.frameworkConfig?.metadata.docsUrl ?? runDef?.docsUrl ?? "https://posthog.com/docs"} to set up manually.${debugInfo}`,
4244
+ message: `Something went wrong: ${errorMessage}\n\nYou can read the documentation at ${docsUrl} to set up manually.${debugInfo}`,
4101
4245
  error
4102
4246
  });
4103
4247
  }
@@ -4106,6 +4250,31 @@ function runWizardCI(config, options) {
4106
4250
  });
4107
4251
  }
4108
4252
  //#endregion
4253
+ //#region src/lib/runners/run-wizard-ci.ts
4254
+ /**
4255
+ * CI-mode entry point (`--ci`, dev/test builds). A thin shell over the shared
4256
+ * non-interactive pipeline — see `runNonInteractive`. Kept as its own function
4257
+ * so CI and headless (`runWizardHeadless`) can diverge without re-threading the
4258
+ * many callers that route here.
4259
+ */
4260
+ function runWizardCI(config, options) {
4261
+ runNonInteractive(config, options, "ci");
4262
+ }
4263
+ //#endregion
4264
+ //#region src/lib/runners/run-wizard-headless.ts
4265
+ /**
4266
+ * Headless entry point (the experimental published-build, non-interactive run
4267
+ * path; see @lib/headless-mode). A thin shell over the shared non-interactive
4268
+ * pipeline — see `runNonInteractive`. Today it behaves exactly like
4269
+ * `runWizardCI`; it exists as a separate function so headless can diverge later
4270
+ * (its own auth handling, telemetry, prompts, …) without touching CI or its
4271
+ * callers. Diverge by branching on the mode inside `runNonInteractive`, or by
4272
+ * giving this function its own body.
4273
+ */
4274
+ function runWizardHeadless(config, options) {
4275
+ runNonInteractive(config, options, "headless");
4276
+ }
4277
+ //#endregion
4109
4278
  //#region src/commands/skill-program-options.ts
4110
4279
  /**
4111
4280
  * Per-command options shared by every skill-based program command
@@ -4171,6 +4340,35 @@ function mergeCommandOptions(config) {
4171
4340
  };
4172
4341
  }
4173
4342
  //#endregion
4343
+ //#region src/commands/factories/native-command-factory.ts
4344
+ /**
4345
+ * Build a yargs `Command` from a wizard-native `ProgramConfig`.
4346
+ *
4347
+ * Collapses the previously duplicated boilerplate (read `config.command`,
4348
+ * merge skill-program flags with program-specific options, dispatch via
4349
+ * `runWizard` / `runWizardCI`) into a single call.
4350
+ */
4351
+ function nativeCommandFactory(config, opts = {}) {
4352
+ if (!config.command) throw new Error(`nativeCommandFactory: program "${config.id}" has no \`command\` — wizard-native programs must declare a CLI name`);
4353
+ return {
4354
+ name: config.command,
4355
+ description: config.description,
4356
+ options: mergeCommandOptions(config),
4357
+ children: opts.children,
4358
+ handler: (argv) => dispatchProgram(config, argv)
4359
+ };
4360
+ }
4361
+ //#endregion
4362
+ //#region src/commands/mcp-analytics.ts
4363
+ /**
4364
+ * `wizard mcp-analytics` — flat skill command, instrument-an-MCP-server today.
4365
+ *
4366
+ * Distinct from `wizard mcp add`: this instruments the user's own MCP server
4367
+ * with the `@posthog/mcp` SDK, rather than installing the PostHog MCP server
4368
+ * into a coding agent. Stays flat while instrumenting is the only action.
4369
+ */
4370
+ const mcpAnalyticsCommand = nativeCommandFactory(mcpAnalyticsConfig);
4371
+ //#endregion
4174
4372
  //#region src/lib/programs/dispatch-family.ts
4175
4373
  /**
4176
4374
  * Capture a CLI dispatch error, flush analytics, and exit. The wizard never
@@ -4955,7 +5153,7 @@ async function runDoctorCI(options) {
4955
5153
  getUI().intro("Welcome to the PostHog setup wizard");
4956
5154
  getUI().log.info("Running posthog-doctor in CI mode");
4957
5155
  try {
4958
- const { getOrAskForProjectData } = await import("./setup-utils-CoblNeRY.js").then((n) => n.r);
5156
+ const { getOrAskForProjectData } = await import("./setup-utils-CanVlGbX.js").then((n) => n.r);
4959
5157
  const { host, accessToken, projectId } = await getOrAskForProjectData({
4960
5158
  signup: false,
4961
5159
  ci: true,
@@ -4972,32 +5170,13 @@ async function runDoctorCI(options) {
4972
5170
  for (const issue of sorted) getUI().log.info(` • [${issue.severity}] ${getKindMeta(issue.kind).title}`);
4973
5171
  process.exit(1);
4974
5172
  } catch (error) {
4975
- const { ApiError } = await import("./api-Dmc76exl.js").then((n) => n.n);
5173
+ const { ApiError } = await import("./api-BBRfHEZ-.js").then((n) => n.n);
4976
5174
  const message = error instanceof ApiError && error.statusCode === 401 ? "Your PostHog API key is invalid or expired." : error instanceof Error ? error.message : String(error);
4977
5175
  getUI().log.error(`Doctor failed: ${message}`);
4978
5176
  process.exit(1);
4979
5177
  }
4980
5178
  }
4981
5179
  //#endregion
4982
- //#region src/commands/factories/native-command-factory.ts
4983
- /**
4984
- * Build a yargs `Command` from a wizard-native `ProgramConfig`.
4985
- *
4986
- * Collapses the previously duplicated boilerplate (read `config.command`,
4987
- * merge skill-program flags with program-specific options, dispatch via
4988
- * `runWizard` / `runWizardCI`) into a single call.
4989
- */
4990
- function nativeCommandFactory(config, opts = {}) {
4991
- if (!config.command) throw new Error(`nativeCommandFactory: program "${config.id}" has no \`command\` — wizard-native programs must declare a CLI name`);
4992
- return {
4993
- name: config.command,
4994
- description: config.description,
4995
- options: mergeCommandOptions(config),
4996
- children: opts.children,
4997
- handler: (argv) => dispatchProgram(config, argv)
4998
- };
4999
- }
5000
- //#endregion
5001
5180
  //#region src/commands/migrate.ts
5002
5181
  /**
5003
5182
  * `wizard migrate` — flat skill command, Statsig today.
@@ -5068,8 +5247,8 @@ function runSlackConnect(argv) {
5068
5247
  (async () => {
5069
5248
  const debug = argv.debug;
5070
5249
  try {
5071
- const { startTUI } = await import("./start-tui-D_woOYMc.js");
5072
- const { buildSession } = await import("./wizard-session-wPJtNl4c.js");
5250
+ const { startTUI } = await import("./start-tui-YE7bybIr.js");
5251
+ const { buildSession } = await import("./wizard-session-BKEdX9mO.js");
5073
5252
  const tui = startTUI(VERSION, Program.SlackConnect);
5074
5253
  tui.store.session = buildSession({ debug });
5075
5254
  } catch (err) {
@@ -5445,8 +5624,8 @@ function resolveInstallDir() {
5445
5624
  if (inline) return inline.slice(14);
5446
5625
  return process.env.POSTHOG_WIZARD_INSTALL_DIR ?? process.cwd();
5447
5626
  }
5448
- Wizard.use(basicIntegrationCommand).use(mcpCommand).use(cliCommand).use(auditCommand).use(doctorCommand).use(migrateCommand).use(revenueCommand).use(warehouseCommand).use(selfDrivingCommand).use(slackCommand).use(uploadSourcemapsCommand).use(skillCommand).init();
5627
+ Wizard.use(basicIntegrationCommand).use(mcpCommand).use(mcpAnalyticsCommand).use(cliCommand).use(auditCommand).use(doctorCommand).use(migrateCommand).use(revenueCommand).use(warehouseCommand).use(selfDrivingCommand).use(slackCommand).use(uploadSourcemapsCommand).use(skillCommand).init();
5449
5628
  //#endregion
5450
- export { getDetectedWarehouseSources as _, ConfirmButton as a, STRIPE_SDKS as b, runWizard as c, getProgramConfig as d, AUTOMATABLE_VARIANTS as f, fetchHealthIssues as g, getKindMeta as h, useKeyboardHintsContext as i, PROGRAM_REGISTRY as l, SOURCE_MAPS_CONTEXT_KEYS as m, useKeyBindings as n, PromptLabel as o, DISPLAY_NAME as p, KeyboardHintsProvider as r, runWizardCI as s, PickerMenu as t, Program as u, getContentBlocks$2 as v, POSTHOG_SDKS as y };
5629
+ export { fetchHealthIssues as _, ConfirmButton as a, POSTHOG_SDKS as b, runWizardCI as c, Program as d, getProgramConfig as f, getKindMeta as g, SOURCE_MAPS_CONTEXT_KEYS as h, useKeyboardHintsContext as i, runWizard as l, DISPLAY_NAME as m, useKeyBindings as n, PromptLabel as o, AUTOMATABLE_VARIANTS as p, KeyboardHintsProvider as r, runWizardHeadless as s, PickerMenu as t, PROGRAM_REGISTRY as u, getDetectedWarehouseSources as v, STRIPE_SDKS as x, getContentBlocks$2 as y };
5451
5630
 
5452
5631
  //# sourceMappingURL=bin.js.map