@posthog/wizard 2.16.0 → 2.17.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 (88) hide show
  1. package/README.md +0 -4
  2. package/dist/{TextBlock-DJVhBkr3.js → TextBlock-D0Ep3zC9.js} +2 -2
  3. package/dist/{TextBlock-DJVhBkr3.js.map → TextBlock-D0Ep3zC9.js.map} +1 -1
  4. package/dist/{add-mcp-server-to-clients-9jQjc-CO.js → add-mcp-server-to-clients-D4PK6ulR.js} +39 -6
  5. package/dist/add-mcp-server-to-clients-D4PK6ulR.js.map +1 -0
  6. package/dist/{agent-interface-pBnqJL8P.js → agent-interface-7t5DBo2A.js} +34 -8
  7. package/dist/agent-interface-7t5DBo2A.js.map +1 -0
  8. package/dist/{agent-runner-H1FP6XTc.js → agent-runner-CTkKLVhp.js} +17 -21
  9. package/dist/{agent-runner-H1FP6XTc.js.map → agent-runner-CTkKLVhp.js.map} +1 -1
  10. package/dist/{analytics-DZaUgJte.js → analytics-DN_Gy87F.js} +3 -3
  11. package/dist/{analytics-DZaUgJte.js.map → analytics-DN_Gy87F.js.map} +1 -1
  12. package/dist/api-serd0SMY.js +148 -0
  13. package/dist/api-serd0SMY.js.map +1 -0
  14. package/dist/bin.js +764 -497
  15. package/dist/bin.js.map +1 -1
  16. package/dist/ci-install-BbJ7c3WK.js +73 -0
  17. package/dist/ci-install-BbJ7c3WK.js.map +1 -0
  18. package/dist/{debug-B6rX6xye.js → debug-BI-Js0PB.js} +1 -1
  19. package/dist/{debug-C4jRuzny.js → debug-Bx7nvCWW.js} +12 -6
  20. package/dist/debug-Bx7nvCWW.js.map +1 -0
  21. package/dist/{defaults-GbLPuHxj.js → defaults-CPH6eWhN.js} +1 -1
  22. package/dist/{defaults-GbLPuHxj.js.map → defaults-CPH6eWhN.js.map} +1 -1
  23. package/dist/{env-api-key-DU8uIEvo.js → env-api-key-B3gE9Un0.js} +4 -2
  24. package/dist/{env-api-key-DU8uIEvo.js.map → env-api-key-B3gE9Un0.js.map} +1 -1
  25. package/dist/environment-CiZVSSYt.js +22 -0
  26. package/dist/environment-CiZVSSYt.js.map +1 -0
  27. package/dist/{file-utils-DnTSiTJw.js → file-utils-Dy9JncCo.js} +1 -1
  28. package/dist/{file-utils-DnTSiTJw.js.map → file-utils-Dy9JncCo.js.map} +1 -1
  29. package/dist/interactive-BwIzklw0.js +11 -0
  30. package/dist/interactive-BwIzklw0.js.map +1 -0
  31. package/dist/{mcp-prompt-streaming-DKiaymMt.js → mcp-prompt-streaming-8U9Qs9EV.js} +62 -12
  32. package/dist/mcp-prompt-streaming-8U9Qs9EV.js.map +1 -0
  33. package/dist/non-interactive-DTaZnVq_.js +12 -0
  34. package/dist/non-interactive-DTaZnVq_.js.map +1 -0
  35. package/dist/{package-json-v_g2YlN1.js → package-json-DCuoye-H.js} +8 -2
  36. package/dist/{package-json-v_g2YlN1.js.map → package-json-DCuoye-H.js.map} +1 -1
  37. package/dist/{package-manager-DLt75bit.js → package-manager-CKQLR20D.js} +2 -2
  38. package/dist/{package-manager-DLt75bit.js.map → package-manager-CKQLR20D.js.map} +1 -1
  39. package/dist/{start-playground-B40O4tye.js → playground-CR81Mwe3.js} +31 -14
  40. package/dist/playground-CR81Mwe3.js.map +1 -0
  41. package/dist/{posthog-7B92c2Ed.js → posthog-BrLFkaji.js} +1 -1
  42. package/dist/{posthog-7B92c2Ed.js.map → posthog-BrLFkaji.js.map} +1 -1
  43. package/dist/{posthog-integration-CukaeYil.js → posthog-integration-Bv7987YJ.js} +230 -21
  44. package/dist/posthog-integration-Bv7987YJ.js.map +1 -0
  45. package/dist/{provisioning-C_ETLiZE.js → provisioning-C96Kw-9D.js} +9 -4
  46. package/dist/{provisioning-C_ETLiZE.js.map → provisioning-C96Kw-9D.js.map} +1 -1
  47. package/dist/{registry-DqbwO5EL.js → registry-B9k73FKR.js} +5 -5
  48. package/dist/{registry-DqbwO5EL.js.map → registry-B9k73FKR.js.map} +1 -1
  49. package/dist/{setup-utils-DdAdxUTV.js → setup-utils-Bpfsap9L.js} +80 -175
  50. package/dist/setup-utils-Bpfsap9L.js.map +1 -0
  51. package/dist/skill-CPqcV8zp.js +29 -0
  52. package/dist/skill-CPqcV8zp.js.map +1 -0
  53. package/dist/{slides-Dpj4j0w_.js → slides-DRbBgsdd.js} +1733 -384
  54. package/dist/slides-DRbBgsdd.js.map +1 -0
  55. package/dist/{start-tui-CH_ZzQXx.js → start-tui-BZ7rEf3e.js} +432 -31
  56. package/dist/start-tui-BZ7rEf3e.js.map +1 -0
  57. package/dist/{steps-0d9XqvI6.js → steps-DDx35170.js} +6 -6
  58. package/dist/{steps-0d9XqvI6.js.map → steps-DDx35170.js.map} +1 -1
  59. package/dist/{task-stream-CoEsidgG.js → task-stream-BI8rJg9H.js} +3 -3
  60. package/dist/{task-stream-CoEsidgG.js.map → task-stream-BI8rJg9H.js.map} +1 -1
  61. package/dist/{telemetry-jn2Daxl2.js → telemetry-ByYtIfW0.js} +2 -2
  62. package/dist/{telemetry-jn2Daxl2.js.map → telemetry-ByYtIfW0.js.map} +1 -1
  63. package/dist/urls-CTCJIxbR.js +35 -0
  64. package/dist/urls-CTCJIxbR.js.map +1 -0
  65. package/dist/{wizard-abort-BjLIgu2s.js → wizard-abort-CY0ibdq1.js} +3 -3
  66. package/dist/{wizard-abort-BjLIgu2s.js.map → wizard-abort-CY0ibdq1.js.map} +1 -1
  67. package/dist/{wizard-abort-BlYGA1Jk.js → wizard-abort-QdRxGQp_.js} +1 -1
  68. package/dist/{wizard-session-Bi95IYca.js → wizard-session-d27JGRGi.js} +2 -3
  69. package/dist/wizard-session-d27JGRGi.js.map +1 -0
  70. package/dist/{wizard-session-DPGTaJ4W.js → wizard-session-y304gEEI.js} +1 -1
  71. package/dist/wizard-ui-YdGFRyu_.js.map +1 -1
  72. package/package.json +1 -1
  73. package/dist/add-mcp-server-to-clients-9jQjc-CO.js.map +0 -1
  74. package/dist/agent-interface-pBnqJL8P.js.map +0 -1
  75. package/dist/analytics-DqeW7XYt.js +0 -2
  76. package/dist/debug-C4jRuzny.js.map +0 -1
  77. package/dist/detection-4eukp9HD.js +0 -206
  78. package/dist/detection-4eukp9HD.js.map +0 -1
  79. package/dist/mcp-prompt-streaming-DKiaymMt.js.map +0 -1
  80. package/dist/package-json-Cttzi3C8.js +0 -2
  81. package/dist/posthog-integration-CukaeYil.js.map +0 -1
  82. package/dist/provisioning-Ch6i8dRV.js +0 -2
  83. package/dist/setup-utils-C5uZ9g60.js +0 -2
  84. package/dist/setup-utils-DdAdxUTV.js.map +0 -1
  85. package/dist/slides-Dpj4j0w_.js.map +0 -1
  86. package/dist/start-playground-B40O4tye.js.map +0 -1
  87. package/dist/start-tui-CH_ZzQXx.js.map +0 -1
  88. package/dist/wizard-session-Bi95IYca.js.map +0 -1
package/dist/bin.js CHANGED
@@ -1,39 +1,270 @@
1
1
  #!/usr/bin/env node
2
- import { t as __exportAll } from "./rolldown-runtime-B_-DWIq7.js";
3
- import { M as POSTHOG_DOCS_URL, W as WIZARD_USER_AGENT, X as VERSION, Y as runtimeEnv, _ as SIGNUP_WIZARD_READINESS_CONFIG, h as LoggingUI, m as setUI, p as getUI, s as logToFile, v as evaluateWizardReadiness, y as getBlockingServiceKeys } from "./debug-C4jRuzny.js";
4
- import { n as analytics } from "./analytics-DZaUgJte.js";
5
- import { a as isUsingTypeScript, f as getCloudUrlFromRegion, m as getUiHostFromHost, u as handleApiError } from "./setup-utils-DdAdxUTV.js";
6
- import "./wizard-session-Bi95IYca.js";
7
- import { g as AUDIT_REPORT_FILE, h as AUDIT_CHECKS_KEY, m as AUDIT_CHECKS_FILE, t as AgentSignals, u as WIZARD_TOOL_NAMES } from "./agent-interface-pBnqJL8P.js";
8
- import { i as SPINNER_MESSAGE } from "./registry-DqbwO5EL.js";
9
- import { c as HEALTH_CHECK_STEP, o as Colors, r as isClearBlock } from "./TextBlock-DJVhBkr3.js";
10
- import { a as LINE_CHART_BLOCK, i as FUNNEL_BLOCK, n as posthogIntegrationConfig, o as PRODUCT_SUITE_BLOCK, s as StatusPeekTrigger } from "./posthog-integration-CukaeYil.js";
11
- import { t as IGNORED_DIRS } from "./file-utils-DnTSiTJw.js";
2
+ import { J as VERSION, M as POSTHOG_DOCS_URL, W as WIZARD_USER_AGENT, X as runtimeEnv, _ as SIGNUP_WIZARD_READINESS_CONFIG, h as LoggingUI, m as setUI, p as getUI, s as logToFile, v as evaluateWizardReadiness, y as getBlockingServiceKeys } from "./debug-Bx7nvCWW.js";
3
+ import { t as analytics } from "./analytics-DN_Gy87F.js";
4
+ import { n as isUsingTypeScript } from "./setup-utils-Bpfsap9L.js";
5
+ import { a as getUiHostFromHost, n as getCloudUrlFromRegion } from "./urls-CTCJIxbR.js";
6
+ import { a as handleApiError } from "./api-serd0SMY.js";
7
+ import "./wizard-session-d27JGRGi.js";
8
+ import { n as isNonInteractiveEnvironment } from "./environment-CiZVSSYt.js";
9
+ import { _ as AUDIT_REPORT_FILE, d as WIZARD_TOOL_NAMES, g as AUDIT_CHECKS_KEY, h as AUDIT_CHECKS_FILE, t as AgentSignals } from "./agent-interface-7t5DBo2A.js";
10
+ import { i as SPINNER_MESSAGE } from "./registry-B9k73FKR.js";
11
+ import { a as PRODUCT_SUITE_BLOCK, i as LINE_CHART_BLOCK, n as posthogIntegrationConfig, o as StatusPeekTrigger, r as FUNNEL_BLOCK } from "./posthog-integration-Bv7987YJ.js";
12
+ import { c as HEALTH_CHECK_STEP, o as Colors, r as isClearBlock } from "./TextBlock-D0Ep3zC9.js";
13
+ import { t as IGNORED_DIRS } from "./file-utils-Dy9JncCo.js";
14
+ import { n as readApiKeyFromEnv } from "./env-api-key-B3gE9Un0.js";
12
15
  import { satisfies } from "semver";
13
16
  import yargs from "yargs";
14
17
  import { hideBin } from "yargs/helpers";
15
- import readEnvModule from "read-env";
16
18
  import fs, { existsSync, readFileSync, readdirSync, statSync } from "fs";
17
19
  import path, { join, relative } from "path";
18
20
  import axios from "axios";
19
21
  import { z } from "zod";
20
- import "fast-glob";
21
22
  import { Text } from "ink";
22
23
  import { jsx, jsxs } from "react/jsx-runtime";
23
- //#region src/utils/environment.ts
24
- var environment_exports = /* @__PURE__ */ __exportAll({
25
- isNonInteractiveEnvironment: () => isNonInteractiveEnvironment,
26
- readEnvironment: () => readEnvironment
27
- });
28
- const readEnv = typeof readEnvModule === "function" ? readEnvModule : readEnvModule.default;
29
- function isNonInteractiveEnvironment() {
30
- if (!process.stdout.isTTY || !process.stderr.isTTY) return true;
31
- return false;
24
+ //#region src/commands/command.ts
25
+ /** Extract the bare command word(s) from a yargs name spec, dropping positionals and aliases' arg syntax. */
26
+ function commandKeys(name) {
27
+ return (typeof name === "string" ? [name] : name).map((n) => n.trim().split(/\s+/)[0]);
32
28
  }
33
- function readEnvironment() {
34
- return readEnv("POSTHOG_WIZARD");
29
+ function toCommandModule(cmd, parentPath) {
30
+ return {
31
+ command: cmd.name,
32
+ describe: cmd.description,
33
+ builder: (y) => {
34
+ let next = cmd.options ? y.options(cmd.options) : y;
35
+ if (cmd.check) next = next.check(cmd.check);
36
+ for (const [usage, description] of cmd.examples ?? []) next = next.example(usage, description);
37
+ const ownPath = [...parentPath, commandKeys(cmd.name)[0]];
38
+ for (const child of cmd.children ?? []) next = next.command(toCommandModule(child, ownPath));
39
+ if (cmd.children?.length && !cmd.handler) next = next.demandCommand(1);
40
+ return next;
41
+ },
42
+ handler: cmd.handler ?? (() => void 0)
43
+ };
35
44
  }
36
45
  //#endregion
46
+ //#region src/wizard.ts
47
+ /**
48
+ * Global yargs options applied to every command. These are read from the
49
+ * `POSTHOG_WIZARD` env prefix as well as flags.
50
+ */
51
+ const GLOBAL_OPTIONS = {
52
+ debug: {
53
+ default: false,
54
+ describe: "Enable verbose logging\nenv: POSTHOG_WIZARD_DEBUG",
55
+ type: "boolean"
56
+ },
57
+ region: {
58
+ describe: "PostHog cloud region\nenv: POSTHOG_WIZARD_REGION",
59
+ choices: ["us", "eu"],
60
+ type: "string"
61
+ },
62
+ signup: {
63
+ default: false,
64
+ describe: "Create a new PostHog account during setup\nenv: POSTHOG_WIZARD_SIGNUP",
65
+ type: "boolean"
66
+ },
67
+ "local-mcp": {
68
+ default: false,
69
+ describe: "Use local MCP server at http://localhost:8787/mcp\nenv: POSTHOG_WIZARD_LOCAL_MCP",
70
+ type: "boolean"
71
+ },
72
+ telemetry: {
73
+ default: true,
74
+ describe: "Send wizard run state to PostHog (pass --no-telemetry to disable)\nenv: POSTHOG_WIZARD_TELEMETRY",
75
+ type: "boolean"
76
+ },
77
+ "api-key": {
78
+ describe: "PostHog personal API key (phx_xxx) for authentication\nenv: POSTHOG_WIZARD_API_KEY",
79
+ type: "string"
80
+ },
81
+ "project-id": {
82
+ describe: "PostHog project ID to use (optional; when not set, uses default from API key or OAuth)\nenv: POSTHOG_WIZARD_PROJECT_ID",
83
+ type: "string"
84
+ },
85
+ email: {
86
+ describe: "Email address for signup (used with --signup)\nenv: POSTHOG_WIZARD_EMAIL",
87
+ type: "string"
88
+ }
89
+ };
90
+ var Wizard = class Wizard {
91
+ cli;
92
+ constructor() {
93
+ let cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options(GLOBAL_OPTIONS);
94
+ this.cli = cli.strictOptions().fail((msg, err, parser) => {
95
+ const text = msg || err && err.message || "Invalid arguments";
96
+ process.stderr.write(`\n\x1b[1;91m✖ ${text}\x1b[0m\n\n`);
97
+ parser.showHelp();
98
+ process.exit(1);
99
+ }).help().alias("help", "h").version().alias("version", "v");
100
+ }
101
+ /** Start a chain; equivalent to `new Wizard().use(...cmds)`. */
102
+ static use(...cmds) {
103
+ return new Wizard().use(...cmds);
104
+ }
105
+ /** Register one or more commands with yargs. */
106
+ use(...cmds) {
107
+ for (const cmd of cmds) this.cli = this.cli.command(toCommandModule(cmd, []));
108
+ return this;
109
+ }
110
+ /** Parse argv and dispatch to the matching registered command. */
111
+ init() {
112
+ {
113
+ const argvHasCI = process.argv.slice(2).some((a) => a === "--ci" || a === "--no-ci" || a.startsWith("--ci="));
114
+ const envHasCI = process.env.POSTHOG_WIZARD_CI != null && process.env.POSTHOG_WIZARD_CI !== "";
115
+ if (argvHasCI || envHasCI) {
116
+ process.stderr.write(`\n\x1b[1;91m✖ CI mode is not currently supported in published builds.\x1b[0m\n\n`);
117
+ process.exit(1);
118
+ }
119
+ }
120
+ this.cli.wrap(process.stdout.isTTY ? this.cli.terminalWidth() : 80).argv;
121
+ }
122
+ };
123
+ //#endregion
124
+ //#region src/commands/provision.ts
125
+ const provisionCommand = {
126
+ name: "provision",
127
+ description: "Create a new PostHog account (headless, no TUI)",
128
+ options: {
129
+ email: {
130
+ describe: "Email address for the new account",
131
+ type: "string",
132
+ demandOption: true
133
+ },
134
+ region: {
135
+ describe: "Cloud region (us or eu)",
136
+ choices: ["us", "eu"],
137
+ default: "us"
138
+ },
139
+ name: {
140
+ describe: "Name for the new account",
141
+ type: "string",
142
+ default: ""
143
+ },
144
+ json: {
145
+ describe: "Emit JSON result to stdout (defaults to true when stdout is not a TTY)",
146
+ type: "boolean"
147
+ }
148
+ },
149
+ examples: [["wizard provision --email matt+test@posthog.com --region us", ""], ["wizard provision --email user@example.com --region eu --json", ""]],
150
+ handler: runProvision
151
+ };
152
+ function runProvision(argv) {
153
+ const jsonMode = argv.json === void 0 ? !process.stdout.isTTY : Boolean(argv.json);
154
+ if (!jsonMode) setUI(new LoggingUI());
155
+ provision({
156
+ email: argv.email,
157
+ region: argv.region.toUpperCase(),
158
+ name: argv.name ?? "",
159
+ jsonMode
160
+ });
161
+ }
162
+ async function provision({ email, region, name, jsonMode }) {
163
+ try {
164
+ const { provisionNewAccount } = await import("./provisioning-C96Kw-9D.js").then((n) => n.n);
165
+ if (!jsonMode) getUI().log.info(`Provisioning account for ${email} in ${region}...`);
166
+ emitResult(await provisionNewAccount(email, name, region), jsonMode);
167
+ process.exit(0);
168
+ } catch (error) {
169
+ emitError(error, jsonMode);
170
+ process.exit(1);
171
+ }
172
+ }
173
+ function emitResult(result, jsonMode) {
174
+ if (jsonMode) {
175
+ process.stdout.write(`${JSON.stringify(result)}\n`);
176
+ return;
177
+ }
178
+ getUI().log.success("Account provisioned successfully:");
179
+ getUI().log.info(` API Key: ${result.projectApiKey}`);
180
+ getUI().log.info(` Host: ${result.host}`);
181
+ getUI().log.info(` Project ID: ${result.projectId}`);
182
+ getUI().log.info(` Account ID: ${result.accountId}`);
183
+ getUI().log.info(` Access Token: ${result.accessToken}`);
184
+ getUI().log.info(` Refresh Token: ${result.refreshToken}`);
185
+ if (result.personalApiKey) getUI().log.info(` Personal API Key: ${result.personalApiKey}`);
186
+ }
187
+ function emitError(error, jsonMode) {
188
+ const msg = error instanceof Error ? error.message : String(error);
189
+ const code = msg.includes("already associated") ? "email_exists" : "provisioning_failed";
190
+ if (jsonMode) {
191
+ process.stderr.write(`${JSON.stringify({
192
+ error: msg,
193
+ code
194
+ })}\n`);
195
+ return;
196
+ }
197
+ getUI().log.error(`Provisioning failed: ${msg}`);
198
+ }
199
+ //#endregion
200
+ //#region src/commands/basic-integration/index.ts
201
+ const basicIntegrationCommand = {
202
+ name: ["$0"],
203
+ description: "Run the PostHog setup wizard",
204
+ children: [provisionCommand],
205
+ options: {
206
+ "install-dir": {
207
+ describe: "Directory to install PostHog in\nenv: POSTHOG_WIZARD_INSTALL_DIR",
208
+ type: "string"
209
+ },
210
+ playground: {
211
+ default: false,
212
+ describe: "Launch the TUI primitives playground",
213
+ type: "boolean"
214
+ },
215
+ benchmark: {
216
+ default: false,
217
+ describe: "Run in benchmark mode with per-phase token tracking\nenv: POSTHOG_WIZARD_BENCHMARK",
218
+ type: "boolean"
219
+ },
220
+ "yara-report": {
221
+ default: false,
222
+ describe: "Print YARA scanner summary after the agent run\nenv: POSTHOG_WIZARD_YARA_REPORT",
223
+ type: "boolean",
224
+ hidden: true
225
+ },
226
+ skill: {
227
+ describe: "Run a specific context-mill skill by ID\nenv: POSTHOG_WIZARD_SKILL",
228
+ type: "string"
229
+ },
230
+ name: {
231
+ describe: "Name for account creation with --ci --signup\nenv: POSTHOG_WIZARD_NAME",
232
+ type: "string"
233
+ }
234
+ },
235
+ check: (argv) => {
236
+ if (argv.playground && (argv.ci || argv.skill)) throw new Error("--playground cannot be combined with --ci or --skill.");
237
+ if (typeof argv.skill === "string" && argv.skill.trim() === "") throw new Error("--skill needs a skill ID, e.g. --skill=\"foo\"");
238
+ return true;
239
+ },
240
+ handler: (argv) => {
241
+ (async () => {
242
+ if (argv.ci && argv.skill) {
243
+ const { runSkillMode } = await import("./skill-CPqcV8zp.js");
244
+ return runSkillMode(argv);
245
+ }
246
+ if (argv.ci) {
247
+ const { runCIInstall } = await import("./ci-install-BbJ7c3WK.js");
248
+ return runCIInstall(argv);
249
+ }
250
+ if (isNonInteractiveEnvironment()) {
251
+ const { failNonInteractive } = await import("./non-interactive-DTaZnVq_.js");
252
+ return failNonInteractive();
253
+ }
254
+ if (argv.playground) {
255
+ const { runPlayground } = await import("./playground-CR81Mwe3.js");
256
+ return runPlayground();
257
+ }
258
+ if (argv.skill) {
259
+ const { runSkillMode } = await import("./skill-CPqcV8zp.js");
260
+ return runSkillMode(argv);
261
+ }
262
+ const { runInteractive } = await import("./interactive-BwIzklw0.js");
263
+ runInteractive(argv);
264
+ })();
265
+ }
266
+ };
267
+ //#endregion
37
268
  //#region src/lib/programs/revenue-analytics/detect.ts
38
269
  const POSTHOG_SDKS$1 = [
39
270
  "posthog-js",
@@ -297,7 +528,6 @@ const AGENT_SKILL_STEPS = [
297
528
  ];
298
529
  //#endregion
299
530
  //#region src/lib/programs/agent-skill/index.ts
300
- var agent_skill_exports = /* @__PURE__ */ __exportAll({ createSkillProgram: () => createSkillProgram });
301
531
  function createSkillProgram(opts) {
302
532
  return {
303
533
  command: opts.command,
@@ -334,7 +564,12 @@ const AUDIT_ABORT_CASES = [{
334
564
  }];
335
565
  //#endregion
336
566
  //#region src/lib/programs/audit/seed.ts
337
- /** The 10 data-integrity checks the audit runs. */
567
+ /**
568
+ * The 10 data-integrity checks the audit runs, plus one workflow row for the
569
+ * notebook upload at the end (so the skill's `audit_resolve_checks` call for
570
+ * `upload-notebook` succeeds — the skill writes the report to a PostHog
571
+ * notebook as its final step).
572
+ */
338
573
  const AUDIT_SEED_CHECKS = [
339
574
  {
340
575
  id: "sdk-installed",
@@ -395,15 +630,32 @@ const AUDIT_SEED_CHECKS = [
395
630
  area: "Event Capture",
396
631
  label: "Key activation events captured",
397
632
  status: "pending"
633
+ },
634
+ {
635
+ id: "write-report",
636
+ area: "Write report",
637
+ label: "Create posthog-audit-report.md",
638
+ status: "pending"
639
+ },
640
+ {
641
+ id: "upload-notebook",
642
+ area: "Upload notebook",
643
+ label: "Write the report into a PostHog notebook",
644
+ status: "pending"
398
645
  }
399
646
  ];
400
- /** Atomically write the seeded ledger to the project's audit checks file. */
401
- function seedAuditLedger(installDir) {
647
+ /**
648
+ * Atomically write a seeded ledger to the project's audit checks file.
649
+ *
650
+ * Each audit-flavored program (doctor, events-audit) owns its own seed
651
+ * shape — pass the seed in so this writer stays program-agnostic.
652
+ */
653
+ function seedAuditLedger(installDir, checks = AUDIT_SEED_CHECKS) {
402
654
  const target = path.join(installDir, AUDIT_CHECKS_FILE);
403
655
  const tmp = `${target}.tmp`;
404
- fs.writeFileSync(tmp, JSON.stringify(AUDIT_SEED_CHECKS, null, 2), "utf8");
656
+ fs.writeFileSync(tmp, JSON.stringify(checks, null, 2), "utf8");
405
657
  fs.renameSync(tmp, target);
406
- logToFile(`seedAuditLedger: wrote ${AUDIT_SEED_CHECKS.length} entries to ${target}`);
658
+ logToFile(`seedAuditLedger: wrote ${checks.length} entries to ${target}`);
407
659
  }
408
660
  //#endregion
409
661
  //#region src/lib/programs/audit/index.ts
@@ -443,7 +695,23 @@ const baseConfig$1 = createSkillProgram({
443
695
  const auditRun = async (session) => {
444
696
  seedBeforeAuditRun(session);
445
697
  if (!baseConfig$1.run) throw new Error("Audit program has no run configuration.");
446
- return typeof baseConfig$1.run === "function" ? baseConfig$1.run(session) : baseConfig$1.run;
698
+ const baseRun = typeof baseConfig$1.run === "function" ? await baseConfig$1.run(session) : baseConfig$1.run;
699
+ return {
700
+ ...baseRun,
701
+ buildOutroData: (sess, _credentials, cloudRegion) => {
702
+ const cloudUrl = cloudRegion ? getCloudUrlFromRegion(cloudRegion) : void 0;
703
+ const continueUrl = sess.signup && cloudUrl ? `${cloudUrl}/products?source=wizard` : void 0;
704
+ return {
705
+ kind: "success",
706
+ message: baseRun.successMessage,
707
+ reportFile: baseRun.reportFile,
708
+ docsUrl: baseRun.docsUrl,
709
+ continueUrl,
710
+ dashboardUrl: sess.dashboardUrl ?? void 0,
711
+ notebookUrl: sess.notebookUrl ?? void 0
712
+ };
713
+ }
714
+ };
447
715
  };
448
716
  const auditConfig = {
449
717
  ...baseConfig$1,
@@ -505,6 +773,62 @@ const EVENTS_AUDIT_PROGRAM = [
505
773
  }
506
774
  ];
507
775
  //#endregion
776
+ //#region src/lib/programs/events-audit/seed.ts
777
+ /**
778
+ * The 7 phases the events-audit skill marches through. One check per area
779
+ * so PendingChecksList renders a clean linear pipeline (area = bold header,
780
+ * single row = the active spinner).
781
+ *
782
+ * Phase ids match what the skill's step files resolve via
783
+ * `mcp__wizard-tools__audit_resolve_checks` as each phase completes. The
784
+ * skill's step 1 also seeds these same ids — keep both in sync so the
785
+ * wizard pre-seed and the skill's MCP seed agree.
786
+ */
787
+ const EVENTS_AUDIT_SEED_CHECKS = [
788
+ {
789
+ id: "detect-sdk",
790
+ area: "Detect SDK",
791
+ label: "Identify PostHog SDK(s) in dependencies",
792
+ status: "pending"
793
+ },
794
+ {
795
+ id: "scan-sites",
796
+ area: "Scan capture sites",
797
+ label: "Grep capture/identify/group call sites",
798
+ status: "pending"
799
+ },
800
+ {
801
+ id: "enrich-sites",
802
+ area: "Enrich",
803
+ label: "Subagent fan-out to read capture files",
804
+ status: "pending"
805
+ },
806
+ {
807
+ id: "query-volume",
808
+ area: "Query PostHog",
809
+ label: "30-day volume + last_seen via MCP",
810
+ status: "pending"
811
+ },
812
+ {
813
+ id: "write-report",
814
+ area: "Write report",
815
+ label: "Create posthog-events-audit-report.md",
816
+ status: "pending"
817
+ },
818
+ {
819
+ id: "create-dashboard",
820
+ area: "Create dashboard",
821
+ label: "Optional: dashboard for resolved events",
822
+ status: "pending"
823
+ },
824
+ {
825
+ id: "upload-notebook",
826
+ area: "Upload notebook",
827
+ label: "Write the report into a PostHog notebook",
828
+ status: "pending"
829
+ }
830
+ ];
831
+ //#endregion
508
832
  //#region src/lib/programs/events-audit/index.ts
509
833
  const SETUP_REPORT_FILE = "posthog-events-audit-report.md";
510
834
  const DOCS_URL$1 = "https://posthog.com/docs/product-analytics/best-practices";
@@ -520,8 +844,8 @@ const eventsAuditConfig = {
520
844
  run: (session) => {
521
845
  const typeScriptDetected = isUsingTypeScript({ installDir: session.installDir });
522
846
  session.typescript = typeScriptDetected;
523
- seedAuditLedger(session.installDir);
524
- session.frameworkContext[AUDIT_CHECKS_KEY] = AUDIT_SEED_CHECKS;
847
+ seedAuditLedger(session.installDir, EVENTS_AUDIT_SEED_CHECKS);
848
+ session.frameworkContext[AUDIT_CHECKS_KEY] = EVENTS_AUDIT_SEED_CHECKS;
525
849
  return Promise.resolve({
526
850
  skillId: "events-audit",
527
851
  integrationLabel: "events-audit",
@@ -549,7 +873,8 @@ Project context:
549
873
  changes: [],
550
874
  docsUrl: DOCS_URL$1,
551
875
  continueUrl: sess.signup && cloudUrl ? `${cloudUrl}/products?source=wizard` : void 0,
552
- dashboardUrl: sess.dashboardUrl ?? (cloudUrl ? `${cloudUrl}/dashboard` : void 0)
876
+ dashboardUrl: sess.dashboardUrl ?? (cloudUrl ? `${cloudUrl}/dashboard` : void 0),
877
+ notebookUrl: sess.notebookUrl ?? void 0
553
878
  };
554
879
  }
555
880
  });
@@ -1873,15 +2198,23 @@ const withPace = (block) => {
1873
2198
  };
1874
2199
  /** Apply the dwell multiplier to every block in a deck. */
1875
2200
  const pace = (blocks) => blocks.map(withPace);
1876
- /** A minified production stack trace — the problem source maps solve. */
2201
+ /**
2202
+ * A minified production stack trace — the problem source maps solve. Framed as
2203
+ * a labelled, muted example (no error-red ✘) so a glance reads it as
2204
+ * illustrative content, not as the wizard itself having errored mid-run.
2205
+ */
1877
2206
  const MINIFIED_TRACE = {
1878
2207
  type: "lines",
1879
2208
  interval: 400,
1880
2209
  pause: 7e3,
1881
2210
  lines: [
1882
2211
  /* @__PURE__ */ jsx(Text, {
1883
- color: Colors.error,
1884
- children: " TypeError: cart is undefined"
2212
+ dimColor: true,
2213
+ children: "example minified production trace"
2214
+ }),
2215
+ /* @__PURE__ */ jsx(Text, {
2216
+ color: Colors.muted,
2217
+ children: " TypeError: cart is undefined"
1885
2218
  }),
1886
2219
  /* @__PURE__ */ jsx(Text, {
1887
2220
  dimColor: true,
@@ -1903,9 +2236,13 @@ const RESOLVED_TRACE = {
1903
2236
  interval: 400,
1904
2237
  pause: 8e3,
1905
2238
  lines: [
2239
+ /* @__PURE__ */ jsx(Text, {
2240
+ dimColor: true,
2241
+ children: "example — resolved with source maps"
2242
+ }),
1906
2243
  /* @__PURE__ */ jsx(Text, {
1907
2244
  color: Colors.success,
1908
- children: "✔ TypeError: cart is undefined"
2245
+ children: " ✔ TypeError: cart is undefined"
1909
2246
  }),
1910
2247
  /* @__PURE__ */ jsxs(Text, { children: [
1911
2248
  /* @__PURE__ */ jsx(Text, {
@@ -2323,456 +2660,150 @@ const Program = {
2323
2660
  function getProgramConfig(id) {
2324
2661
  return PROGRAM_REGISTRY.find((c) => c.id === id);
2325
2662
  }
2326
- /** All program configs that are exposed as CLI subcommands. */
2327
- function getSubcommandPrograms() {
2328
- return PROGRAM_REGISTRY.filter((c) => c.command != null);
2329
- }
2330
2663
  //#endregion
2331
- //#region bin.ts
2332
- const MIN_NODE_VERSION = ">=18.17.0";
2333
- if (!satisfies(process.version, MIN_NODE_VERSION)) {
2334
- console.log(`PostHog wizard needs Node.js ${MIN_NODE_VERSION}. Detected ${process.version} — please upgrade Node and re-run.`);
2335
- process.exit(1);
2336
- }
2337
- const WIZARD_VERSION = VERSION;
2338
- /** Shared yargs options for skill-based program subcommands. */
2339
- const skillSubcommandOptions = {
2340
- debug: {
2341
- default: false,
2342
- describe: "Enable verbose logging",
2343
- type: "boolean"
2344
- },
2345
- "install-dir": {
2346
- describe: "Directory to install in",
2347
- type: "string"
2348
- },
2349
- "local-mcp": {
2350
- default: false,
2351
- describe: "Use local MCP server",
2352
- type: "boolean"
2353
- },
2354
- benchmark: {
2355
- default: false,
2356
- describe: "Run in benchmark mode",
2357
- type: "boolean"
2358
- },
2359
- "yara-report": {
2360
- default: false,
2361
- describe: "Print YARA scanner summary",
2362
- type: "boolean",
2363
- hidden: true
2364
- }
2365
- };
2366
- const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
2367
- debug: {
2368
- default: false,
2369
- describe: "Enable verbose logging\nenv: POSTHOG_WIZARD_DEBUG",
2370
- type: "boolean"
2371
- },
2372
- region: {
2373
- describe: "PostHog cloud region\nenv: POSTHOG_WIZARD_REGION",
2374
- choices: ["us", "eu"],
2375
- type: "string"
2376
- },
2377
- default: {
2378
- default: true,
2379
- describe: "Use default options for all prompts\nenv: POSTHOG_WIZARD_DEFAULT",
2380
- type: "boolean"
2381
- },
2382
- signup: {
2383
- default: false,
2384
- describe: "Create a new PostHog account during setup\nenv: POSTHOG_WIZARD_SIGNUP",
2385
- type: "boolean"
2386
- },
2387
- "local-mcp": {
2388
- default: false,
2389
- describe: "Use local MCP server at http://localhost:8787/mcp\nenv: POSTHOG_WIZARD_LOCAL_MCP",
2390
- type: "boolean"
2391
- },
2392
- "api-key": {
2393
- describe: "PostHog personal API key (phx_xxx) for authentication\nenv: POSTHOG_WIZARD_API_KEY",
2394
- type: "string"
2395
- },
2396
- "project-id": {
2397
- describe: "PostHog project ID to use (optional; when not set, uses default from API key or OAuth)\nenv: POSTHOG_WIZARD_PROJECT_ID",
2398
- type: "string"
2399
- },
2400
- email: {
2401
- describe: "Email address for signup (used with --signup)\nenv: POSTHOG_WIZARD_EMAIL",
2402
- type: "string"
2403
- },
2404
- telemetry: {
2405
- default: true,
2406
- describe: "Send wizard run state to PostHog (pass --no-telemetry to disable)\nenv: POSTHOG_WIZARD_TELEMETRY",
2407
- type: "boolean"
2408
- }
2409
- }).command(["$0"], "Run the PostHog setup wizard", (yargs) => {
2410
- return yargs.options({
2411
- "force-install": {
2664
+ //#region src/commands/mcp/add.ts
2665
+ const mcpAddCommand = {
2666
+ name: "add",
2667
+ description: "Install PostHog MCP server to supported clients",
2668
+ options: {
2669
+ local: {
2412
2670
  default: false,
2413
- describe: "Force install packages even if peer dependency checks fail\nenv: POSTHOG_WIZARD_FORCE_INSTALL",
2671
+ describe: "Add local development MCP server (http://localhost:8787)",
2414
2672
  type: "boolean"
2415
2673
  },
2416
- "install-dir": {
2417
- describe: "Directory to install PostHog in\nenv: POSTHOG_WIZARD_INSTALL_DIR",
2674
+ features: {
2675
+ describe: "Comma-separated list of features to enable (default: all)",
2418
2676
  type: "string"
2419
2677
  },
2420
- playground: {
2421
- default: false,
2422
- describe: "Launch the TUI primitives playground",
2423
- type: "boolean"
2424
- },
2425
- integration: {
2426
- describe: "Integration to set up",
2427
- choices: [
2428
- "nextjs",
2429
- "astro",
2430
- "react",
2431
- "svelte",
2432
- "react-native",
2433
- "tanstack-router",
2434
- "tanstack-start"
2435
- ],
2436
- type: "string"
2437
- },
2438
- menu: {
2439
- default: false,
2440
- describe: "Show menu for manual integration selection instead of auto-detecting\nenv: POSTHOG_WIZARD_MENU",
2441
- type: "boolean"
2442
- },
2443
- benchmark: {
2444
- default: false,
2445
- describe: "Run in benchmark mode with per-phase token tracking\nenv: POSTHOG_WIZARD_BENCHMARK",
2446
- type: "boolean"
2447
- },
2448
- "yara-report": {
2449
- default: false,
2450
- describe: "Print YARA scanner summary after the agent run\nenv: POSTHOG_WIZARD_YARA_REPORT",
2451
- type: "boolean",
2452
- hidden: true
2453
- },
2454
- skill: {
2455
- describe: "Run a specific context-mill skill by ID\nenv: POSTHOG_WIZARD_SKILL",
2456
- type: "string"
2457
- },
2458
- name: {
2459
- describe: "Name for account creation with --ci --signup\nenv: POSTHOG_WIZARD_NAME",
2678
+ "api-key": {
2679
+ describe: "PostHog personal API key (phx_xxx) for MCP authentication",
2460
2680
  type: "string"
2461
2681
  }
2462
- });
2463
- }, (argv) => {
2464
- const options = { ...argv };
2465
- if (options.ci) {
2466
- if (!options.region) options.region = "us";
2467
- if (!options.installDir) {
2468
- setUI(new LoggingUI());
2469
- getUI().intro("PostHog Wizard");
2470
- getUI().log.error("CI mode requires --install-dir (directory to install in)");
2471
- process.exit(1);
2472
- return;
2473
- }
2474
- if (!options.apiKey && !options.signup) {
2682
+ },
2683
+ handler: runMcpAdd
2684
+ };
2685
+ function runMcpAdd(argv) {
2686
+ const features = parseFeatures(argv.features);
2687
+ (async () => {
2688
+ const { readApiKeyFromEnv } = await import("./env-api-key-B3gE9Un0.js").then((n) => n.t);
2689
+ const apiKey = argv.apiKey || readApiKeyFromEnv();
2690
+ const debug = argv.debug;
2691
+ const localMcp = argv.local;
2692
+ try {
2693
+ const { startTUI } = await import("./start-tui-BZ7rEf3e.js");
2694
+ const { buildSession } = await import("./wizard-session-y304gEEI.js");
2695
+ const tui = startTUI(VERSION, Program.McpAdd);
2696
+ tui.store.session = buildSession({
2697
+ debug,
2698
+ localMcp,
2699
+ mcpFeatures: features,
2700
+ apiKey
2701
+ });
2702
+ } catch (error) {
2703
+ if (!isTUIUnavailable(error)) throw error;
2475
2704
  setUI(new LoggingUI());
2476
- getUI().intro("PostHog Wizard");
2477
- getUI().log.error("CI mode requires --api-key (personal API key phx_xxx). To create a new account instead, use --signup --email you@example.com.");
2478
- process.exit(1);
2479
- return;
2705
+ const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-D4PK6ulR.js").then((n) => n.r);
2706
+ await addMCPServerToClientsStep({
2707
+ local: localMcp,
2708
+ features,
2709
+ apiKey
2710
+ });
2480
2711
  }
2481
- if (!options.apiKey && options.signup && !options.email) {
2712
+ })();
2713
+ }
2714
+ /**
2715
+ * Ink throws "Raw mode is not supported" when stdin has no TTY (piped input,
2716
+ * CI, some IDE terminals). That is the only TUI failure we degrade to
2717
+ * LoggingUI for — any other error from the TUI path is a real bug and must
2718
+ * surface rather than be silently swallowed.
2719
+ */
2720
+ function isTUIUnavailable(error) {
2721
+ return error instanceof Error && /raw mode is not supported/i.test(error.message);
2722
+ }
2723
+ function parseFeatures(raw) {
2724
+ if (typeof raw !== "string") return void 0;
2725
+ return raw.split(",").map((s) => s.trim()).filter(Boolean);
2726
+ }
2727
+ //#endregion
2728
+ //#region src/commands/mcp/remove.ts
2729
+ const mcpRemoveCommand = {
2730
+ name: "remove",
2731
+ description: "Remove PostHog MCP server from supported clients",
2732
+ options: { local: {
2733
+ default: false,
2734
+ describe: "Remove local development MCP server (http://localhost:8787)",
2735
+ type: "boolean"
2736
+ } },
2737
+ handler: runMcpRemove
2738
+ };
2739
+ function runMcpRemove(argv) {
2740
+ (async () => {
2741
+ const debug = argv.debug;
2742
+ const localMcp = argv.local;
2743
+ try {
2744
+ const { startTUI } = await import("./start-tui-BZ7rEf3e.js");
2745
+ const { buildSession } = await import("./wizard-session-y304gEEI.js");
2746
+ const tui = startTUI(VERSION, Program.McpRemove);
2747
+ tui.store.session = buildSession({
2748
+ debug,
2749
+ localMcp
2750
+ });
2751
+ } catch {
2482
2752
  setUI(new LoggingUI());
2483
- getUI().intro("PostHog Wizard");
2484
- getUI().log.error("CI --signup requires --email to create a new account.");
2485
- process.exit(1);
2486
- return;
2487
- }
2488
- if (options.apiKey) {
2489
- const apiKeyValue = String(options.apiKey);
2490
- if (!apiKeyValue.startsWith("phx_")) {
2491
- setUI(new LoggingUI());
2492
- getUI().intro("PostHog Wizard");
2493
- const prefix = apiKeyValue.slice(0, 4);
2494
- let hint = "";
2495
- if (prefix === "pha_") hint = " (pha_ is an OAuth access token — CI mode expects a personal API key)";
2496
- else if (prefix === "phc_") hint = " (phc_ is a project/client key — CI mode expects a personal API key)";
2497
- getUI().log.warn(`--api-key does not start with "phx_"${hint}. Continuing anyway, but the LLM Gateway may reject it with a 401.`);
2498
- }
2753
+ const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-D4PK6ulR.js").then((n) => n.r);
2754
+ await removeMCPServerFromClientsStep({ local: localMcp });
2499
2755
  }
2500
- (async () => {
2501
- if (!options.apiKey && options.signup) {
2502
- setUI(new LoggingUI());
2503
- getUI().intro("PostHog Wizard");
2504
- try {
2505
- const { provisionNewAccount } = await import("./provisioning-Ch6i8dRV.js");
2506
- const signupRegion = options.region.toUpperCase();
2507
- getUI().log.info(`Provisioning new PostHog account for ${String(options.email)} in ${signupRegion}...`);
2508
- const result = await provisionNewAccount(options.email, options.name ?? "", signupRegion);
2509
- if (!result.personalApiKey) {
2510
- getUI().log.error("Provisioning succeeded but no personal API key was returned — cannot continue install.");
2511
- process.exit(1);
2512
- return;
2513
- }
2514
- getUI().log.success("Account ready.");
2515
- getUI().log.info(` Project API Key: ${result.projectApiKey}`);
2516
- getUI().log.info(` Personal API Key: ${result.personalApiKey}`);
2517
- getUI().log.info(` Host: ${result.host}`);
2518
- options.apiKey = result.personalApiKey;
2519
- if (options.projectId == null) options.projectId = result.projectId;
2520
- } catch (error) {
2521
- const msg = error instanceof Error ? error.message : String(error);
2522
- getUI().log.error(`Provisioning failed: ${msg}`);
2523
- process.exit(1);
2524
- return;
2525
- }
2526
- }
2527
- const { posthogIntegrationConfig } = await import("./posthog-integration-CukaeYil.js").then((n) => n.r);
2528
- const { FRAMEWORK_REGISTRY } = await import("./registry-DqbwO5EL.js").then((n) => n.n);
2529
- const { detectFramework, gatherFrameworkContext } = await import("./detection-4eukp9HD.js").then((n) => n.t);
2530
- const { analytics } = await import("./analytics-DqeW7XYt.js");
2531
- const { wizardAbort } = await import("./wizard-abort-BlYGA1Jk.js");
2532
- runWizardCI(posthogIntegrationConfig, options, async (session) => {
2533
- const integration = session.integration ?? await detectFramework(session.installDir);
2534
- if (!integration) {
2535
- await wizardAbort({ message: "Could not auto-detect your framework. Please specify --integration on the command line." });
2536
- return;
2537
- }
2538
- session.integration = integration;
2539
- analytics.setTag("integration", integration);
2540
- const frameworkConfig = FRAMEWORK_REGISTRY[integration];
2541
- session.frameworkConfig = frameworkConfig;
2542
- const context = await gatherFrameworkContext(frameworkConfig, {
2543
- installDir: session.installDir,
2544
- debug: session.debug,
2545
- forceInstall: session.forceInstall,
2546
- default: false,
2547
- signup: session.signup,
2548
- localMcp: session.localMcp,
2549
- ci: true,
2550
- menu: session.menu,
2551
- benchmark: session.benchmark,
2552
- yaraReport: session.yaraReport
2553
- });
2554
- for (const [key, value] of Object.entries(context)) if (!(key in session.frameworkContext)) session.frameworkContext[key] = value;
2555
- });
2556
- })().catch(() => {
2557
- process.exit(1);
2558
- });
2559
- } else if (isNonInteractiveEnvironment()) {
2560
- getUI().intro(`PostHog Wizard`);
2561
- getUI().log.error("This installer requires an interactive terminal (TTY) to run.\nIt appears you are running in a non-interactive environment.\n\nNon-interactive (CI) mode is not supported in published builds.\n");
2562
- process.exit(1);
2563
- } else if (options.playground) (async () => {
2564
- const { startPlayground } = await import("./start-playground-B40O4tye.js");
2565
- startPlayground(WIZARD_VERSION);
2566
2756
  })();
2567
- else if (options.skill) (async () => {
2568
- const { createSkillProgram } = await Promise.resolve().then(() => agent_skill_exports);
2569
- const skillId = options.skill;
2570
- runWizard(createSkillProgram({
2571
- skillId,
2572
- command: "skill",
2573
- id: "agent-skill",
2574
- description: `Run skill: ${skillId}`,
2575
- integrationLabel: skillId,
2576
- successMessage: `${skillId} completed!`,
2577
- reportFile: `posthog-${skillId}-report.md`,
2578
- docsUrl: POSTHOG_DOCS_URL,
2579
- spinnerMessage: `Running ${skillId}...`,
2580
- estimatedDurationMinutes: 5
2581
- }), {
2582
- ...options,
2583
- skillId
2584
- });
2585
- })();
2586
- else (async () => {
2587
- const { posthogIntegrationConfig } = await import("./posthog-integration-CukaeYil.js").then((n) => n.r);
2588
- runWizard(posthogIntegrationConfig, options);
2589
- })();
2590
- }).command("mcp <command>", "MCP server management commands", (yargs) => {
2591
- return yargs.command("add", "Install PostHog MCP server to supported clients", (yargs) => {
2592
- return yargs.options({
2593
- local: {
2594
- default: false,
2595
- describe: "Add local development MCP server (http://localhost:8787)",
2596
- type: "boolean"
2597
- },
2598
- features: {
2599
- describe: "Comma-separated list of features to enable (default: all)",
2600
- type: "string"
2601
- },
2602
- "api-key": {
2603
- describe: "PostHog personal API key (phx_xxx) for MCP authentication",
2604
- type: "string"
2605
- }
2606
- });
2607
- }, (argv) => {
2608
- const options = { ...argv };
2609
- const mcpFeatures = options.features?.split(",").map((s) => s.trim()).filter(Boolean);
2610
- (async () => {
2611
- const { readApiKeyFromEnv } = await import("./env-api-key-DU8uIEvo.js");
2612
- const apiKey = options.apiKey || readApiKeyFromEnv();
2613
- try {
2614
- const { startTUI } = await import("./start-tui-CH_ZzQXx.js");
2615
- const { buildSession } = await import("./wizard-session-DPGTaJ4W.js");
2616
- const tui = startTUI(WIZARD_VERSION, Program.McpAdd);
2617
- const session = buildSession({
2618
- debug: options.debug,
2619
- localMcp: options.local,
2620
- mcpFeatures,
2621
- apiKey
2622
- });
2623
- tui.store.session = session;
2624
- } catch {
2625
- setUI(new LoggingUI());
2626
- const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-9jQjc-CO.js").then((n) => n.r);
2627
- await addMCPServerToClientsStep({
2628
- local: options.local,
2629
- features: mcpFeatures,
2630
- apiKey
2631
- });
2632
- }
2633
- })();
2634
- }).command("remove", "Remove PostHog MCP server from supported clients", (yargs) => {
2635
- return yargs.options({ local: {
2636
- default: false,
2637
- describe: "Remove local development MCP server (http://localhost:8787)",
2638
- type: "boolean"
2639
- } });
2640
- }, (argv) => {
2641
- const options = { ...argv };
2642
- (async () => {
2643
- try {
2644
- const { startTUI } = await import("./start-tui-CH_ZzQXx.js");
2645
- const { buildSession } = await import("./wizard-session-DPGTaJ4W.js");
2646
- const tui = startTUI(WIZARD_VERSION, Program.McpRemove);
2647
- const session = buildSession({
2648
- debug: options.debug,
2649
- localMcp: options.local
2650
- });
2651
- tui.store.session = session;
2652
- } catch {
2653
- setUI(new LoggingUI());
2654
- const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-9jQjc-CO.js").then((n) => n.r);
2655
- await removeMCPServerFromClientsStep({ local: options.local });
2656
- }
2657
- })();
2658
- }).command("tutorial", "Try the PostHog MCP with your agent (no install needed)", (yargs) => {
2659
- return yargs.options({ local: {
2660
- default: false,
2661
- describe: "Point the tutorial at the local MCP server (http://localhost:8787)",
2662
- type: "boolean"
2663
- } });
2664
- }, (argv) => {
2665
- const options = { ...argv };
2666
- (async () => {
2667
- try {
2668
- const { startTUI } = await import("./start-tui-CH_ZzQXx.js");
2669
- const { buildSession } = await import("./wizard-session-DPGTaJ4W.js");
2670
- const tui = startTUI(WIZARD_VERSION, Program.McpTutorial);
2671
- const session = buildSession({
2672
- debug: options.debug,
2673
- localMcp: options.local
2674
- });
2675
- tui.store.session = session;
2676
- } catch (err) {
2677
- setUI(new LoggingUI());
2678
- getUI().log.error(`The MCP tutorial requires an interactive terminal. ${err instanceof Error ? err.message : String(err)}`);
2679
- process.exit(1);
2680
- }
2681
- })();
2682
- }).demandCommand(1, "You must specify a subcommand (add, remove, or tutorial)").help();
2683
- });
2684
- cli.command("provision", "Create a new PostHog account (headless, no TUI)", (yargs) => {
2685
- return yargs.options({
2686
- email: {
2687
- describe: "Email address for the new account",
2688
- type: "string",
2689
- demandOption: true
2690
- },
2691
- region: {
2692
- describe: "Cloud region (us or eu)",
2693
- choices: ["us", "eu"],
2694
- default: "us"
2695
- },
2696
- name: {
2697
- describe: "Name for the new account",
2698
- type: "string",
2699
- default: ""
2700
- },
2701
- json: {
2702
- describe: "Emit JSON result to stdout (defaults to true when stdout is not a TTY)",
2703
- type: "boolean"
2704
- }
2705
- }).example("wizard provision --email matt+test@posthog.com --region us", "").example("wizard provision --email user@example.com --region eu --json", "");
2706
- }, (argv) => {
2707
- const email = argv.email;
2708
- const region = argv.region.toUpperCase();
2709
- const name = argv.name ?? "";
2710
- const jsonMode = argv.json === void 0 ? !process.stdout.isTTY : argv.json;
2711
- if (!jsonMode) setUI(new LoggingUI());
2757
+ }
2758
+ //#endregion
2759
+ //#region src/commands/mcp/tutorial.ts
2760
+ const mcpTutorialCommand = {
2761
+ name: "tutorial",
2762
+ description: "Try the PostHog MCP with your agent (no install needed)",
2763
+ options: { local: {
2764
+ default: false,
2765
+ describe: "Point the tutorial at the local MCP server (http://localhost:8787)",
2766
+ type: "boolean"
2767
+ } },
2768
+ handler: runMcpTutorial
2769
+ };
2770
+ function runMcpTutorial(argv) {
2712
2771
  (async () => {
2772
+ const debug = argv.debug;
2773
+ const localMcp = argv.local;
2713
2774
  try {
2714
- const { provisionNewAccount } = await import("./provisioning-Ch6i8dRV.js");
2715
- if (!jsonMode) getUI().log.info(`Provisioning account for ${email} in ${region}...`);
2716
- const result = await provisionNewAccount(email, name, region);
2717
- if (jsonMode) process.stdout.write(`${JSON.stringify(result)}\n`);
2718
- else {
2719
- getUI().log.success("Account provisioned successfully:");
2720
- getUI().log.info(` API Key: ${result.projectApiKey}`);
2721
- getUI().log.info(` Host: ${result.host}`);
2722
- getUI().log.info(` Project ID: ${result.projectId}`);
2723
- getUI().log.info(` Account ID: ${result.accountId}`);
2724
- getUI().log.info(` Access Token: ${result.accessToken}`);
2725
- getUI().log.info(` Refresh Token: ${result.refreshToken}`);
2726
- if (result.personalApiKey) getUI().log.info(` Personal API Key: ${result.personalApiKey}`);
2727
- }
2728
- process.exit(0);
2729
- } catch (error) {
2730
- const msg = error instanceof Error ? error.message : String(error);
2731
- const code = msg.includes("already associated") ? "email_exists" : "provisioning_failed";
2732
- if (jsonMode) process.stderr.write(`${JSON.stringify({
2733
- error: msg,
2734
- code
2735
- })}\n`);
2736
- else getUI().log.error(`Provisioning failed: ${msg}`);
2775
+ const { startTUI } = await import("./start-tui-BZ7rEf3e.js");
2776
+ const { buildSession } = await import("./wizard-session-y304gEEI.js");
2777
+ const tui = startTUI(VERSION, Program.McpTutorial);
2778
+ tui.store.session = buildSession({
2779
+ debug,
2780
+ localMcp
2781
+ });
2782
+ } catch (err) {
2783
+ setUI(new LoggingUI());
2784
+ getUI().log.error(`The MCP tutorial requires an interactive terminal. ${err instanceof Error ? err.message : String(err)}`);
2737
2785
  process.exit(1);
2738
2786
  }
2739
2787
  })();
2740
- });
2741
- for (const programConfig of getSubcommandPrograms()) cli.command(programConfig.command, programConfig.description, (y) => y.options({
2742
- ...skillSubcommandOptions,
2743
- ...programConfig.cliOptions ?? {}
2744
- }), (argv) => {
2745
- const extras = programConfig.mapCliOptions?.(argv) ?? {};
2746
- const options = {
2747
- ...argv,
2748
- ...extras
2749
- };
2750
- if (options.ci) runWizardCI(programConfig, options);
2751
- else runWizard(programConfig, options);
2752
- });
2753
- cli.strictOptions().fail((msg, err) => {
2754
- throw err || new Error(msg);
2755
- }).help().alias("help", "h").version().alias("version", "v").wrap(process.stdout.isTTY ? cli.terminalWidth() : 80);
2756
- {
2757
- const argvHasCI = process.argv.slice(2).some((a) => a === "--ci" || a === "--no-ci" || a.startsWith("--ci="));
2758
- const envHasCI = process.env.POSTHOG_WIZARD_CI != null && process.env.POSTHOG_WIZARD_CI !== "";
2759
- if (argvHasCI || envHasCI) exitWithProductionCIError();
2760
- }
2761
- try {
2762
- cli.parse();
2763
- } catch (err) {
2764
- const RED = "\x1B[31m";
2765
- const BOLD = "\x1B[1m";
2766
- const RESET = "\x1B[0m";
2767
- const message = err instanceof Error ? err.message : String(err);
2768
- process.stderr.write(`${RED}${BOLD}✖ ${message}${RESET}\n`);
2769
- process.stderr.write("Run with --help to see available options.\n");
2770
- process.exit(1);
2771
- }
2772
- function exitWithProductionCIError() {
2773
- process.stderr.write(`✖ CI mode is not currently supported in published builds.\n`);
2774
- process.exit(1);
2775
2788
  }
2789
+ //#endregion
2790
+ //#region src/commands/mcp/index.ts
2791
+ const mcpCommand = {
2792
+ name: "mcp",
2793
+ description: "MCP server management commands",
2794
+ children: [
2795
+ mcpAddCommand,
2796
+ mcpRemoveCommand,
2797
+ mcpTutorialCommand
2798
+ ]
2799
+ };
2800
+ //#endregion
2801
+ //#region src/lib/runners/resolve-no-telemetry.ts
2802
+ /**
2803
+ * `--no-telemetry` flips `telemetry: false` via yargs negation;
2804
+ * `POSTHOG_WIZARD_NO_TELEMETRY` is honoured separately so the env-var
2805
+ * form documented in the README keeps working.
2806
+ */
2776
2807
  function resolveNoTelemetry(options) {
2777
2808
  if (options.telemetry === false) return true;
2778
2809
  const env = process.env.POSTHOG_WIZARD_NO_TELEMETRY;
@@ -2780,6 +2811,9 @@ function resolveNoTelemetry(options) {
2780
2811
  const norm = env.toLowerCase();
2781
2812
  return norm !== "0" && norm !== "false";
2782
2813
  }
2814
+ //#endregion
2815
+ //#region src/lib/runners/run-wizard.ts
2816
+ const WIZARD_VERSION = VERSION;
2783
2817
  /**
2784
2818
  * Run a full wizard program in the TUI. Handles the full lifecycle: start TUI,
2785
2819
  * build session, run detection, wait for intro gate, execute the
@@ -2793,16 +2827,15 @@ function runWizard(config, options) {
2793
2827
  (async () => {
2794
2828
  try {
2795
2829
  const installDir = options.installDir || process.cwd();
2796
- const { startTUI } = await import("./start-tui-CH_ZzQXx.js");
2797
- const { buildSession, RunPhase } = await import("./wizard-session-DPGTaJ4W.js");
2798
- const { TaskStreamPush } = await import("./task-stream-CoEsidgG.js");
2799
- const { PostHogDestination } = await import("./posthog-7B92c2Ed.js");
2800
- const { logToFile } = await import("./debug-B6rX6xye.js");
2830
+ const { startTUI } = await import("./start-tui-BZ7rEf3e.js");
2831
+ const { buildSession, RunPhase } = await import("./wizard-session-y304gEEI.js");
2832
+ const { TaskStreamPush } = await import("./task-stream-BI8rJg9H.js");
2833
+ const { PostHogDestination } = await import("./posthog-BrLFkaji.js");
2834
+ const { logToFile } = await import("./debug-BI-Js0PB.js");
2801
2835
  tui = startTUI(WIZARD_VERSION, config.id);
2802
2836
  const activeTui = tui;
2803
2837
  const session = buildSession({
2804
2838
  debug: options.debug,
2805
- forceInstall: options.forceInstall,
2806
2839
  localMcp: options.localMcp,
2807
2840
  installDir,
2808
2841
  ci: false,
@@ -2810,8 +2843,6 @@ function runWizard(config, options) {
2810
2843
  apiKey: options.apiKey,
2811
2844
  projectId: options.projectId,
2812
2845
  email: options.email,
2813
- menu: options.menu,
2814
- integration: options.integration,
2815
2846
  benchmark: options.benchmark,
2816
2847
  yaraReport: options.yaraReport,
2817
2848
  noTelemetry: resolveNoTelemetry(options)
@@ -2851,7 +2882,7 @@ function runWizard(config, options) {
2851
2882
  await activeTui.store.getGate("health-check");
2852
2883
  const skipAgent = config.run == null;
2853
2884
  if (skipAgent) {
2854
- const { getOrAskForProjectData } = await import("./setup-utils-C5uZ9g60.js");
2885
+ const { getOrAskForProjectData } = await import("./setup-utils-Bpfsap9L.js").then((n) => n.r);
2855
2886
  const { projectApiKey, host, accessToken, projectId } = await getOrAskForProjectData({
2856
2887
  signup: session.signup,
2857
2888
  ci: session.ci,
@@ -2865,7 +2896,7 @@ function runWizard(config, options) {
2865
2896
  projectId
2866
2897
  });
2867
2898
  } else {
2868
- const { runAgent } = await import("./agent-runner-H1FP6XTc.js");
2899
+ const { runAgent } = await import("./agent-runner-CTkKLVhp.js");
2869
2900
  await runAgent(config, activeTui.store.session);
2870
2901
  }
2871
2902
  const isDone = () => skipAgent ? activeTui.store.session.outroDismissed : activeTui.store.session.skillsComplete;
@@ -2904,16 +2935,14 @@ function runWizard(config, options) {
2904
2935
  }
2905
2936
  })();
2906
2937
  }
2938
+ //#endregion
2939
+ //#region src/lib/runners/run-wizard-ci.ts
2907
2940
  /**
2908
- * CI-mode pipeline shared by every non-interactive entry point.
2909
- *
2910
- * Validates flags, builds a `ci:true` session, runs `preRun` (or the
2911
- * program's `onReady` hooks by default), executes `runAgent`, and
2912
- * routes any failure through `wizardAbort`. `wizardAbort` owns all
2913
- * exits — never add a raw `process.exit` here.
2941
+ * The single CI validation layer: defaults region and requires api-key and
2942
+ * install-dir. Every CI entry point routes through `runWizardCI`, so this is
2943
+ * the one place these checks live. UI must be initialized before calling.
2914
2944
  */
2915
- function runWizardCI(config, options, preRun) {
2916
- setUI(new LoggingUI());
2945
+ function validateCiOptions(options) {
2917
2946
  if (!options.region) options.region = "us";
2918
2947
  if (!options.apiKey) {
2919
2948
  getUI().intro("PostHog Wizard");
@@ -2925,28 +2954,37 @@ function runWizardCI(config, options, preRun) {
2925
2954
  getUI().log.error("CI mode requires --install-dir (directory to install in)");
2926
2955
  process.exit(1);
2927
2956
  }
2957
+ }
2958
+ /**
2959
+ * CI-mode pipeline shared by every non-interactive entry point.
2960
+ *
2961
+ * Validates flags, builds a `ci:true` session, runs `config.ciPreRun` (or the
2962
+ * program's `onReady` hooks by default), executes `runAgent`, and routes any
2963
+ * failure through `wizardAbort`. `wizardAbort` owns all exits — never add a
2964
+ * raw `process.exit` here.
2965
+ */
2966
+ function runWizardCI(config, options) {
2967
+ setUI(new LoggingUI());
2968
+ validateCiOptions(options);
2928
2969
  (async () => {
2929
2970
  const path = await import("path");
2930
- const { buildSession } = await import("./wizard-session-DPGTaJ4W.js");
2931
- const { readEnvironment } = await Promise.resolve().then(() => environment_exports);
2932
- const { readApiKeyFromEnv } = await import("./env-api-key-DU8uIEvo.js");
2933
- const { configureLogFileFromEnvironment, logToFile } = await import("./debug-B6rX6xye.js");
2934
- const { wizardAbort, WizardError } = await import("./wizard-abort-BlYGA1Jk.js");
2971
+ const { buildSession } = await import("./wizard-session-y304gEEI.js");
2972
+ const { readEnvironment } = await import("./environment-CiZVSSYt.js").then((n) => n.t);
2973
+ const { readApiKeyFromEnv } = await import("./env-api-key-B3gE9Un0.js").then((n) => n.t);
2974
+ const { configureLogFileFromEnvironment, logToFile } = await import("./debug-BI-Js0PB.js");
2975
+ const { wizardAbort, WizardError } = await import("./wizard-abort-QdRxGQp_.js");
2935
2976
  configureLogFileFromEnvironment();
2936
2977
  const env = readEnvironment();
2937
2978
  const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? void 0;
2938
2979
  const installDir = path.isAbsolute(options.installDir) ? options.installDir : path.join(process.cwd(), options.installDir);
2939
2980
  const session = buildSession({
2940
2981
  debug: options.debug,
2941
- forceInstall: options.forceInstall,
2942
2982
  installDir,
2943
2983
  ci: true,
2944
2984
  signup: options.signup,
2945
2985
  localMcp: options.localMcp,
2946
2986
  apiKey,
2947
2987
  email: options.email,
2948
- menu: options.menu,
2949
- integration: options.integration,
2950
2988
  projectId: options.projectId,
2951
2989
  benchmark: options.benchmark,
2952
2990
  yaraReport: options.yaraReport,
@@ -2959,7 +2997,7 @@ function runWizardCI(config, options, preRun) {
2959
2997
  getUI().intro("Welcome to the PostHog setup wizard");
2960
2998
  getUI().log.info(`Running ${config.id} in CI mode`);
2961
2999
  try {
2962
- if (preRun) await preRun(session);
3000
+ if (config.ciPreRun) await config.ciPreRun(session);
2963
3001
  else {
2964
3002
  const readyCtx = {
2965
3003
  session,
@@ -2982,7 +3020,7 @@ function runWizardCI(config, options, preRun) {
2982
3020
  })
2983
3021
  });
2984
3022
  }
2985
- const { runAgent } = await import("./agent-runner-H1FP6XTc.js");
3023
+ const { runAgent } = await import("./agent-runner-CTkKLVhp.js");
2986
3024
  await runAgent(config, session);
2987
3025
  } catch (error) {
2988
3026
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -3000,6 +3038,235 @@ function runWizardCI(config, options, preRun) {
3000
3038
  });
3001
3039
  }
3002
3040
  //#endregion
3003
- export { SOURCE_MAPS_CONTEXT_KEYS as a, fetchHealthIssues as c, STRIPE_SDKS as d, DISPLAY_NAME as i, getContentBlocks$2 as l, Program as n, getContentBlocks$1 as o, getProgramConfig as r, getKindMeta as s, PROGRAM_REGISTRY as t, POSTHOG_SDKS$1 as u };
3041
+ //#region src/commands/skill-program-options.ts
3042
+ /** Flags shared by every skill-based program command (integrate, audit, …). */
3043
+ const skillProgramOptions = {
3044
+ debug: {
3045
+ default: false,
3046
+ describe: "Enable verbose logging",
3047
+ type: "boolean"
3048
+ },
3049
+ "install-dir": {
3050
+ describe: "Directory to install in",
3051
+ type: "string"
3052
+ },
3053
+ "local-mcp": {
3054
+ default: false,
3055
+ describe: "Use local MCP server",
3056
+ type: "boolean"
3057
+ },
3058
+ benchmark: {
3059
+ default: false,
3060
+ describe: "Run in benchmark mode",
3061
+ type: "boolean"
3062
+ },
3063
+ "yara-report": {
3064
+ default: false,
3065
+ describe: "Print YARA scanner summary",
3066
+ type: "boolean",
3067
+ hidden: true
3068
+ }
3069
+ };
3070
+ //#endregion
3071
+ //#region src/commands/integrate.ts
3072
+ const integrateCommand = {
3073
+ name: "integrate",
3074
+ description: posthogIntegrationConfig.description,
3075
+ options: {
3076
+ ...skillProgramOptions,
3077
+ ...posthogIntegrationConfig.cliOptions ?? {}
3078
+ },
3079
+ handler: (argv) => {
3080
+ const extras = posthogIntegrationConfig.mapCliOptions?.(argv) ?? {};
3081
+ const options = {
3082
+ ...argv,
3083
+ ...extras
3084
+ };
3085
+ if (options.ci) runWizardCI(posthogIntegrationConfig, options);
3086
+ else runWizard(posthogIntegrationConfig, options);
3087
+ }
3088
+ };
3089
+ //#endregion
3090
+ //#region src/commands/audit.ts
3091
+ const auditCommand = {
3092
+ name: "audit",
3093
+ description: auditConfig.description,
3094
+ options: {
3095
+ ...skillProgramOptions,
3096
+ ...auditConfig.cliOptions ?? {}
3097
+ },
3098
+ handler: (argv) => {
3099
+ const extras = auditConfig.mapCliOptions?.(argv) ?? {};
3100
+ const options = {
3101
+ ...argv,
3102
+ ...extras
3103
+ };
3104
+ if (options.ci) runWizardCI(auditConfig, options);
3105
+ else runWizard(auditConfig, options);
3106
+ }
3107
+ };
3108
+ //#endregion
3109
+ //#region src/commands/audit-3000.ts
3110
+ const audit3000Command = {
3111
+ name: "audit-3000",
3112
+ description: audit3000Config.description,
3113
+ options: {
3114
+ ...skillProgramOptions,
3115
+ ...audit3000Config.cliOptions ?? {}
3116
+ },
3117
+ handler: (argv) => {
3118
+ const extras = audit3000Config.mapCliOptions?.(argv) ?? {};
3119
+ const options = {
3120
+ ...argv,
3121
+ ...extras
3122
+ };
3123
+ if (options.ci) runWizardCI(audit3000Config, options);
3124
+ else runWizard(audit3000Config, options);
3125
+ }
3126
+ };
3127
+ //#endregion
3128
+ //#region src/commands/doctor.ts
3129
+ const doctorCommand = {
3130
+ name: "doctor",
3131
+ description: posthogDoctorConfig.description,
3132
+ options: {
3133
+ ...skillProgramOptions,
3134
+ ...posthogDoctorConfig.cliOptions ?? {}
3135
+ },
3136
+ handler: (argv) => {
3137
+ const extras = posthogDoctorConfig.mapCliOptions?.(argv) ?? {};
3138
+ const options = {
3139
+ ...argv,
3140
+ ...extras
3141
+ };
3142
+ if (options.ci) runDoctorCI(options);
3143
+ else runWizard(posthogDoctorConfig, options);
3144
+ }
3145
+ };
3146
+ const SEVERITY_ORDER = {
3147
+ critical: 0,
3148
+ warning: 1,
3149
+ info: 2
3150
+ };
3151
+ async function runDoctorCI(options) {
3152
+ setUI(new LoggingUI());
3153
+ const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? void 0;
3154
+ if (!apiKey) {
3155
+ getUI().intro("PostHog Wizard");
3156
+ getUI().log.error("CI mode requires --api-key (personal API key phx_xxx)");
3157
+ process.exit(1);
3158
+ }
3159
+ getUI().intro("Welcome to the PostHog setup wizard");
3160
+ getUI().log.info("Running posthog-doctor in CI mode");
3161
+ try {
3162
+ const { getOrAskForProjectData } = await import("./setup-utils-Bpfsap9L.js").then((n) => n.r);
3163
+ const { host, accessToken, projectId } = await getOrAskForProjectData({
3164
+ signup: false,
3165
+ ci: true,
3166
+ apiKey,
3167
+ projectId: options.projectId ? Number(options.projectId) : void 0
3168
+ });
3169
+ const issues = await fetchHealthIssues(accessToken, host, projectId);
3170
+ if (issues.length === 0) {
3171
+ getUI().log.success("No active issues — your project looks healthy.");
3172
+ process.exit(0);
3173
+ }
3174
+ const sorted = [...issues].sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity]);
3175
+ getUI().log.warn(`${issues.length} active issue${issues.length === 1 ? "" : "s"} found:`);
3176
+ for (const issue of sorted) getUI().log.info(` • [${issue.severity}] ${getKindMeta(issue.kind).title}`);
3177
+ process.exit(1);
3178
+ } catch (error) {
3179
+ const { ApiError } = await import("./api-serd0SMY.js").then((n) => n.n);
3180
+ const message = error instanceof ApiError && error.statusCode === 401 ? "Your PostHog API key is invalid or expired." : error instanceof Error ? error.message : String(error);
3181
+ getUI().log.error(`Doctor failed: ${message}`);
3182
+ process.exit(1);
3183
+ }
3184
+ }
3185
+ //#endregion
3186
+ //#region src/commands/migrate.ts
3187
+ const migrateCommand = {
3188
+ name: "migrate",
3189
+ description: migrationConfig.description,
3190
+ options: {
3191
+ ...skillProgramOptions,
3192
+ ...migrationConfig.cliOptions ?? {}
3193
+ },
3194
+ handler: (argv) => {
3195
+ const extras = migrationConfig.mapCliOptions?.(argv) ?? {};
3196
+ const options = {
3197
+ ...argv,
3198
+ ...extras
3199
+ };
3200
+ if (options.ci) runWizardCI(migrationConfig, options);
3201
+ else runWizard(migrationConfig, options);
3202
+ }
3203
+ };
3204
+ //#endregion
3205
+ //#region src/commands/events-audit.ts
3206
+ const eventsAuditCommand = {
3207
+ name: "events-audit",
3208
+ description: eventsAuditConfig.description,
3209
+ options: {
3210
+ ...skillProgramOptions,
3211
+ ...eventsAuditConfig.cliOptions ?? {}
3212
+ },
3213
+ handler: (argv) => {
3214
+ const extras = eventsAuditConfig.mapCliOptions?.(argv) ?? {};
3215
+ const options = {
3216
+ ...argv,
3217
+ ...extras
3218
+ };
3219
+ if (options.ci) runWizardCI(eventsAuditConfig, options);
3220
+ else runWizard(eventsAuditConfig, options);
3221
+ }
3222
+ };
3223
+ //#endregion
3224
+ //#region src/commands/revenue.ts
3225
+ const revenueCommand = {
3226
+ name: "revenue",
3227
+ description: revenueAnalyticsConfig.description,
3228
+ options: {
3229
+ ...skillProgramOptions,
3230
+ ...revenueAnalyticsConfig.cliOptions ?? {}
3231
+ },
3232
+ handler: (argv) => {
3233
+ const extras = revenueAnalyticsConfig.mapCliOptions?.(argv) ?? {};
3234
+ const options = {
3235
+ ...argv,
3236
+ ...extras
3237
+ };
3238
+ if (options.ci) runWizardCI(revenueAnalyticsConfig, options);
3239
+ else runWizard(revenueAnalyticsConfig, options);
3240
+ }
3241
+ };
3242
+ //#endregion
3243
+ //#region src/commands/upload-sourcemaps.ts
3244
+ const uploadSourcemapsCommand = {
3245
+ name: "upload-sourcemaps",
3246
+ description: errorTrackingUploadSourceMapsConfig.description,
3247
+ options: {
3248
+ ...skillProgramOptions,
3249
+ ...errorTrackingUploadSourceMapsConfig.cliOptions ?? {}
3250
+ },
3251
+ handler: (argv) => {
3252
+ const extras = errorTrackingUploadSourceMapsConfig.mapCliOptions?.(argv) ?? {};
3253
+ const options = {
3254
+ ...argv,
3255
+ ...extras
3256
+ };
3257
+ if (options.ci) runWizardCI(errorTrackingUploadSourceMapsConfig, options);
3258
+ else runWizard(errorTrackingUploadSourceMapsConfig, options);
3259
+ }
3260
+ };
3261
+ //#endregion
3262
+ //#region bin.ts
3263
+ const NODE_VERSION_RANGE = ">=18.17.0";
3264
+ if (!satisfies(process.version, NODE_VERSION_RANGE)) {
3265
+ console.log(`PostHog wizard requires Node.js ${NODE_VERSION_RANGE}. You are using Node.js ${process.version}. Please upgrade your Node.js version.`);
3266
+ process.exit(1);
3267
+ }
3268
+ Wizard.use(basicIntegrationCommand).use(mcpCommand).use(integrateCommand).use(auditCommand).use(audit3000Command).use(doctorCommand).use(migrateCommand).use(eventsAuditCommand).use(revenueCommand).use(uploadSourcemapsCommand).init();
3269
+ //#endregion
3270
+ export { getProgramConfig as a, getContentBlocks$1 as c, createSkillProgram as d, getContentBlocks$2 as f, Program as i, getKindMeta as l, STRIPE_SDKS as m, runWizard as n, DISPLAY_NAME as o, POSTHOG_SDKS$1 as p, PROGRAM_REGISTRY as r, SOURCE_MAPS_CONTEXT_KEYS as s, runWizardCI as t, fetchHealthIssues as u };
3004
3271
 
3005
3272
  //# sourceMappingURL=bin.js.map