@posthog/wizard 2.11.0 → 2.12.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 (85) hide show
  1. package/README.md +48 -7
  2. package/dist/{McpScreen-DvUncZBi.js → AuditChecksViewer-DsfXIO9e.js} +330 -21
  3. package/dist/AuditChecksViewer-DsfXIO9e.js.map +1 -0
  4. package/dist/{add-mcp-server-to-clients-Br1hDRiB.js → add-mcp-server-to-clients-BKoew3aT.js} +5 -5
  5. package/dist/{add-mcp-server-to-clients-Br1hDRiB.js.map → add-mcp-server-to-clients-BKoew3aT.js.map} +1 -1
  6. package/dist/{readiness-gQvQNCeL.js → agent-interface-D5W9BAB2.js} +326 -461
  7. package/dist/agent-interface-D5W9BAB2.js.map +1 -0
  8. package/dist/{agent-runner-fWYFO4H0.js → agent-runner-B8Cx6X6x.js} +19 -30
  9. package/dist/{agent-runner-fWYFO4H0.js.map → agent-runner-B8Cx6X6x.js.map} +1 -1
  10. package/dist/analytics-DmD31Ssc.js +123 -0
  11. package/dist/analytics-DmD31Ssc.js.map +1 -0
  12. package/dist/analytics-JDitS2JI.js +2 -0
  13. package/dist/bin.js +324 -42
  14. package/dist/bin.js.map +1 -1
  15. package/dist/debug-Bkaqv1ab.js +686 -0
  16. package/dist/debug-Bkaqv1ab.js.map +1 -0
  17. package/dist/{debug-D-0xueVl.js → debug-I5sRZubJ.js} +1 -1
  18. package/dist/{defaults-CPH6eWhN.js → defaults-GbLPuHxj.js} +1 -1
  19. package/dist/{defaults-CPH6eWhN.js.map → defaults-GbLPuHxj.js.map} +1 -1
  20. package/dist/{detection-B7GNzve-.js → detection-C_RfYYDe.js} +3 -3
  21. package/dist/{detection-B7GNzve-.js.map → detection-C_RfYYDe.js.map} +1 -1
  22. package/dist/{env-api-key-DU8uIEvo.js → env-api-key-D5G2PrXW.js} +1 -1
  23. package/dist/{env-api-key-DU8uIEvo.js.map → env-api-key-D5G2PrXW.js.map} +1 -1
  24. package/dist/{file-DhSBlq-x.js → file-8iNrXHkG.js} +2 -2
  25. package/dist/{file-DhSBlq-x.js.map → file-8iNrXHkG.js.map} +1 -1
  26. package/dist/{file-utils-Dy9JncCo.js → file-utils-DnTSiTJw.js} +1 -1
  27. package/dist/{file-utils-Dy9JncCo.js.map → file-utils-DnTSiTJw.js.map} +1 -1
  28. package/dist/{package-manager-D3Lo6nXf.js → package-manager-qxP2PpM_.js} +2 -2
  29. package/dist/{package-manager-D3Lo6nXf.js.map → package-manager-qxP2PpM_.js.map} +1 -1
  30. package/dist/paths-DJS47p5x.js +26 -0
  31. package/dist/paths-DJS47p5x.js.map +1 -0
  32. package/dist/{posthog-integration-D4SRhJIQ.js → posthog-integration-DX77Msto.js} +41 -13
  33. package/dist/posthog-integration-DX77Msto.js.map +1 -0
  34. package/dist/{posthog-ByrpqEjN.js → posthog-vm0k9PKS.js} +1 -1
  35. package/dist/{posthog-ByrpqEjN.js.map → posthog-vm0k9PKS.js.map} +1 -1
  36. package/dist/provisioning-CHfTOEvg.js +2 -0
  37. package/dist/provisioning-DUj285NO.js +166 -0
  38. package/dist/provisioning-DUj285NO.js.map +1 -0
  39. package/dist/{registry-DaPKstG3.js → registry-CCtIsqb8.js} +4 -5
  40. package/dist/{registry-DaPKstG3.js.map → registry-CCtIsqb8.js.map} +1 -1
  41. package/dist/{router-SgzmfLGi.js → router-BTfmEDDJ.js} +3 -3
  42. package/dist/router-BTfmEDDJ.js.map +1 -0
  43. package/dist/{setup-utils-y4s-3uKT.js → setup-utils-Bv8z6HMb.js} +11 -150
  44. package/dist/setup-utils-Bv8z6HMb.js.map +1 -0
  45. package/dist/setup-utils-CoX-vLgw.js +2 -0
  46. package/dist/{start-playground-g1TxpCZ5.js → start-playground-DYNQ8rOz.js} +102 -7
  47. package/dist/start-playground-DYNQ8rOz.js.map +1 -0
  48. package/dist/{start-tui-CQef69NR.js → start-tui-DleQG3La.js} +969 -124
  49. package/dist/start-tui-DleQG3La.js.map +1 -0
  50. package/dist/{steps-D1zKDqAo.js → steps-C-syS8if.js} +8 -8
  51. package/dist/steps-C-syS8if.js.map +1 -0
  52. package/dist/{task-stream-DX_jKDQu.js → task-stream-CX7Uf6EM.js} +4 -4
  53. package/dist/{task-stream-DX_jKDQu.js.map → task-stream-CX7Uf6EM.js.map} +1 -1
  54. package/dist/{telemetry-CyUUSAYy.js → telemetry-DHZfjgqx.js} +2 -2
  55. package/dist/{telemetry-CyUUSAYy.js.map → telemetry-DHZfjgqx.js.map} +1 -1
  56. package/dist/{wizard-abort-DZmO_sIZ.js → wizard-abort-DIhFXJ5N.js} +1 -1
  57. package/dist/{wizard-abort-Buodno3f.js → wizard-abort-DfhWuzaw.js} +6 -4
  58. package/dist/{wizard-abort-Buodno3f.js.map → wizard-abort-DfhWuzaw.js.map} +1 -1
  59. package/dist/wizard-session-BQC9vy9Z.js +2 -0
  60. package/dist/{wizard-session-D5bggSsu.js → wizard-session-BcNJTl2I.js} +1 -1
  61. package/dist/{wizard-session-D5bggSsu.js.map → wizard-session-BcNJTl2I.js.map} +1 -1
  62. package/dist/{wizard-ui-BExOjdjA.js → wizard-ui-YdGFRyu_.js} +1 -1
  63. package/dist/wizard-ui-YdGFRyu_.js.map +1 -0
  64. package/npm-shrinkwrap.json +2 -2
  65. package/package.json +1 -1
  66. package/dist/McpScreen-DvUncZBi.js.map +0 -1
  67. package/dist/agent-skill-DJOzDaQV.js +0 -59
  68. package/dist/agent-skill-DJOzDaQV.js.map +0 -1
  69. package/dist/analytics-CfAUlt6-.js +0 -2
  70. package/dist/analytics-D3rY3TaN.js +0 -210
  71. package/dist/analytics-D3rY3TaN.js.map +0 -1
  72. package/dist/debug-gWEjmYVV.js +0 -203
  73. package/dist/debug-gWEjmYVV.js.map +0 -1
  74. package/dist/paths-BL-x2rFy.js +0 -16
  75. package/dist/paths-BL-x2rFy.js.map +0 -1
  76. package/dist/posthog-integration-D4SRhJIQ.js.map +0 -1
  77. package/dist/readiness-gQvQNCeL.js.map +0 -1
  78. package/dist/router-SgzmfLGi.js.map +0 -1
  79. package/dist/setup-utils-_ONxN-TT.js +0 -2
  80. package/dist/setup-utils-y4s-3uKT.js.map +0 -1
  81. package/dist/start-playground-g1TxpCZ5.js.map +0 -1
  82. package/dist/start-tui-CQef69NR.js.map +0 -1
  83. package/dist/steps-D1zKDqAo.js.map +0 -1
  84. package/dist/wizard-session-COhklXAF.js +0 -2
  85. package/dist/wizard-ui-BExOjdjA.js.map +0 -1
package/dist/bin.js CHANGED
@@ -1,16 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as __exportAll } from "./rolldown-runtime-B_-DWIq7.js";
3
- import { c as getUI, f as runtimeEnv, l as setUI, p as red, u as LoggingUI } from "./debug-gWEjmYVV.js";
4
- import { C as WIZARD_USER_AGENT, D as VERSION, n as analytics, p as POSTHOG_DOCS_URL } from "./analytics-D3rY3TaN.js";
5
- import { u as handleApiError } from "./setup-utils-y4s-3uKT.js";
6
- import { t as posthogIntegrationConfig } from "./posthog-integration-D4SRhJIQ.js";
7
- import { t as IGNORED_DIRS } from "./file-utils-Dy9JncCo.js";
3
+ import { D as POSTHOG_DOCS_URL, G as VERSION, K as red, W as runtimeEnv, c as getUI, l as setUI, s as logToFile, u as LoggingUI, z as WIZARD_USER_AGENT } from "./debug-Bkaqv1ab.js";
4
+ import { n as analytics } from "./analytics-DmD31Ssc.js";
5
+ import { u as handleApiError } from "./setup-utils-Bv8z6HMb.js";
6
+ import { h as AUDIT_REPORT_FILE, m as AUDIT_CHECKS_KEY, p as AUDIT_CHECKS_FILE } from "./agent-interface-D5W9BAB2.js";
7
+ import { n as posthogIntegrationConfig } from "./posthog-integration-DX77Msto.js";
8
+ import { t as IGNORED_DIRS } from "./file-utils-DnTSiTJw.js";
8
9
  import { satisfies } from "semver";
9
10
  import yargs from "yargs";
10
11
  import { hideBin } from "yargs/helpers";
11
12
  import readEnvModule from "read-env";
12
- import { existsSync, readFileSync, readdirSync, statSync } from "fs";
13
- import { join, relative } from "path";
13
+ import fs, { existsSync, readFileSync, readdirSync, statSync } from "fs";
14
+ import path, { join, relative } from "path";
14
15
  import axios from "axios";
15
16
  import { z } from "zod";
16
17
  import "fast-glob";
@@ -217,6 +218,191 @@ const revenueAnalyticsConfig = {
217
218
  requires: ["posthog-integration"]
218
219
  };
219
220
  //#endregion
221
+ //#region src/lib/workflows/agent-skill/steps.ts
222
+ const AGENT_SKILL_STEPS = [
223
+ {
224
+ id: "intro",
225
+ label: "Welcome",
226
+ screen: "agent-skill-intro",
227
+ gate: (session) => session.setupConfirmed
228
+ },
229
+ {
230
+ id: "auth",
231
+ label: "Authentication",
232
+ screen: "auth",
233
+ isComplete: (session) => session.credentials !== null
234
+ },
235
+ {
236
+ id: "run",
237
+ label: "Running",
238
+ screen: "run",
239
+ isComplete: (session) => session.runPhase === "completed" || session.runPhase === "error"
240
+ },
241
+ {
242
+ id: "outro",
243
+ label: "Done",
244
+ screen: "outro",
245
+ isComplete: (session) => session.outroDismissed
246
+ },
247
+ {
248
+ id: "skills",
249
+ label: "Skills",
250
+ screen: "keep-skills"
251
+ }
252
+ ];
253
+ //#endregion
254
+ //#region src/lib/workflows/agent-skill/index.ts
255
+ var agent_skill_exports = /* @__PURE__ */ __exportAll({ createSkillWorkflow: () => createSkillWorkflow });
256
+ function createSkillWorkflow(opts) {
257
+ return {
258
+ command: opts.command,
259
+ description: opts.description,
260
+ flowKey: opts.flowKey,
261
+ steps: AGENT_SKILL_STEPS,
262
+ run: {
263
+ skillId: opts.skillId,
264
+ integrationLabel: opts.integrationLabel,
265
+ customPrompt: opts.customPrompt ? () => opts.customPrompt : void 0,
266
+ successMessage: opts.successMessage,
267
+ reportFile: opts.reportFile,
268
+ docsUrl: opts.docsUrl,
269
+ spinnerMessage: opts.spinnerMessage,
270
+ estimatedDurationMinutes: opts.estimatedDurationMinutes,
271
+ buildOutroData: opts.buildOutroData,
272
+ abortCases: opts.abortCases
273
+ },
274
+ requires: opts.requires
275
+ };
276
+ }
277
+ //#endregion
278
+ //#region src/lib/workflows/audit/detect.ts
279
+ /** `[ABORT] <reason>` cases the audit skill can emit. Reason strings are
280
+ * defined in the skill's `Abort statuses` section. */
281
+ const AUDIT_ABORT_CASES = [{
282
+ match: /^no posthog sdk found$/i,
283
+ message: "No PostHog SDK found",
284
+ body: "The audit needs an existing PostHog integration to review. No PostHog SDK appears in this project’s dependency manifests. Run the basic integration workflow to install PostHog first, then re-run the audit.",
285
+ docsUrl: "https://posthog.com/docs/getting-started/install"
286
+ }];
287
+ //#endregion
288
+ //#region src/lib/workflows/audit/seed.ts
289
+ /** The 10 data-integrity checks the audit runs. */
290
+ const AUDIT_SEED_CHECKS = [
291
+ {
292
+ id: "sdk-installed",
293
+ area: "Installation",
294
+ label: "PostHog SDK installed",
295
+ status: "pending"
296
+ },
297
+ {
298
+ id: "sdk-up-to-date",
299
+ area: "Installation",
300
+ label: "SDK version up to date",
301
+ status: "pending"
302
+ },
303
+ {
304
+ id: "init-correct",
305
+ area: "Installation",
306
+ label: "Initialization is correct",
307
+ status: "pending"
308
+ },
309
+ {
310
+ id: "identify-stable-distinct-id",
311
+ area: "Identification",
312
+ label: "Stable distinct_id (not session UUID)",
313
+ status: "pending"
314
+ },
315
+ {
316
+ id: "identify-not-late",
317
+ area: "Identification",
318
+ label: "identify() called before captures / flag evals",
319
+ status: "pending"
320
+ },
321
+ {
322
+ id: "cross-runtime-distinct-id",
323
+ area: "Identification",
324
+ label: "Same distinct_id across client and server",
325
+ status: "pending"
326
+ },
327
+ {
328
+ id: "identify-reset-on-logout",
329
+ area: "Identification",
330
+ label: "reset() called on logout / account switch",
331
+ status: "pending"
332
+ },
333
+ {
334
+ id: "capture-event-names-static",
335
+ area: "Event Capture",
336
+ label: "Event names are static and consistent",
337
+ status: "pending"
338
+ },
339
+ {
340
+ id: "capture-uses-proxy",
341
+ area: "Event Capture",
342
+ label: "Captures route through a reverse proxy",
343
+ status: "pending"
344
+ },
345
+ {
346
+ id: "capture-growth-events",
347
+ area: "Event Capture",
348
+ label: "Key activation events captured",
349
+ status: "pending"
350
+ }
351
+ ];
352
+ /** Atomically write the seeded ledger to the project's audit checks file. */
353
+ function seedAuditLedger(installDir) {
354
+ const target = path.join(installDir, AUDIT_CHECKS_FILE);
355
+ const tmp = `${target}.tmp`;
356
+ fs.writeFileSync(tmp, JSON.stringify(AUDIT_SEED_CHECKS, null, 2), "utf8");
357
+ fs.renameSync(tmp, target);
358
+ logToFile(`seedAuditLedger: wrote ${AUDIT_SEED_CHECKS.length} entries to ${target}`);
359
+ }
360
+ //#endregion
361
+ //#region src/lib/workflows/audit/index.ts
362
+ /** Audit-specific screens for the shared agent-skill pipeline. */
363
+ const AUDIT_SCREEN_BY_STEP = {
364
+ intro: "audit-intro",
365
+ run: "audit-run",
366
+ outro: "audit-outro"
367
+ };
368
+ const seedBeforeAuditRun = (session) => {
369
+ seedAuditLedger(session.installDir);
370
+ session.frameworkContext[AUDIT_CHECKS_KEY] = AUDIT_SEED_CHECKS;
371
+ };
372
+ const withAuditScreens = (steps) => steps.map((step) => {
373
+ const override = AUDIT_SCREEN_BY_STEP[step.id];
374
+ return override ? {
375
+ ...step,
376
+ screen: override
377
+ } : step;
378
+ });
379
+ const auditSteps = withAuditScreens(AGENT_SKILL_STEPS);
380
+ const baseConfig = createSkillWorkflow({
381
+ skillId: "audit",
382
+ command: "audit",
383
+ flowKey: "audit",
384
+ description: "Audit an existing PostHog integration for correctness and best practices",
385
+ integrationLabel: "audit",
386
+ customPrompt: "Run a comprehensive audit of the existing PostHog integration. Follow the skill workflow steps in order. Do not modify any project files — only create the final audit report.",
387
+ successMessage: "Audit complete! You can view the audit report at ./posthog-audit-report.md",
388
+ reportFile: AUDIT_REPORT_FILE,
389
+ docsUrl: "https://posthog.com/docs/product-analytics/best-practices",
390
+ spinnerMessage: "Auditing PostHog integration...",
391
+ estimatedDurationMinutes: 5,
392
+ requires: ["posthog-integration"],
393
+ abortCases: AUDIT_ABORT_CASES
394
+ });
395
+ const auditRun = async (session) => {
396
+ seedBeforeAuditRun(session);
397
+ if (!baseConfig.run) throw new Error("Audit workflow has no run configuration.");
398
+ return typeof baseConfig.run === "function" ? baseConfig.run(session) : baseConfig.run;
399
+ };
400
+ const auditConfig = {
401
+ ...baseConfig,
402
+ steps: auditSteps,
403
+ run: auditRun
404
+ };
405
+ //#endregion
220
406
  //#region src/lib/workflows/posthog-doctor/steps.ts
221
407
  const POSTHOG_DOCTOR_WORKFLOW = [
222
408
  {
@@ -364,6 +550,7 @@ function getKindMeta(kind) {
364
550
  const WORKFLOW_REGISTRY = [
365
551
  posthogIntegrationConfig,
366
552
  revenueAnalyticsConfig,
553
+ auditConfig,
367
554
  {
368
555
  command: "doctor",
369
556
  description: "Diagnose your PostHog project for configuration issues and setup warnings",
@@ -502,32 +689,69 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
502
689
  skill: {
503
690
  describe: "Run a specific context-mill skill by ID\nenv: POSTHOG_WIZARD_SKILL",
504
691
  type: "string"
692
+ },
693
+ name: {
694
+ describe: "Name for account creation with --ci --signup\nenv: POSTHOG_WIZARD_NAME",
695
+ type: "string"
505
696
  }
506
697
  });
507
698
  }, (argv) => {
508
699
  const options = { ...argv };
509
700
  if (options.ci) {
510
701
  if (!options.region) options.region = "us";
511
- if (!options.apiKey) {
702
+ if (!options.installDir) {
512
703
  setUI(new LoggingUI());
513
704
  getUI().intro("PostHog Wizard");
514
- getUI().log.error("CI mode requires --api-key (personal API key phx_xxx)");
705
+ getUI().log.error("CI mode requires --install-dir (directory to install in)");
515
706
  process.exit(1);
516
707
  return;
517
708
  }
518
- if (!options.installDir) {
709
+ if (!options.apiKey && !options.signup) {
519
710
  setUI(new LoggingUI());
520
711
  getUI().intro("PostHog Wizard");
521
- getUI().log.error("CI mode requires --install-dir (directory to install in)");
712
+ 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.");
713
+ process.exit(1);
714
+ return;
715
+ }
716
+ if (!options.apiKey && options.signup && !options.email) {
717
+ setUI(new LoggingUI());
718
+ getUI().intro("PostHog Wizard");
719
+ getUI().log.error("CI --signup requires --email to create a new account.");
522
720
  process.exit(1);
523
721
  return;
524
722
  }
525
723
  (async () => {
526
- const { posthogIntegrationConfig } = await import("./posthog-integration-D4SRhJIQ.js").then((n) => n.n);
527
- const { FRAMEWORK_REGISTRY } = await import("./registry-DaPKstG3.js").then((n) => n.n);
528
- const { detectFramework, gatherFrameworkContext } = await import("./detection-B7GNzve-.js").then((n) => n.t);
529
- const { analytics } = await import("./analytics-CfAUlt6-.js");
530
- const { wizardAbort } = await import("./wizard-abort-DZmO_sIZ.js");
724
+ if (!options.apiKey && options.signup) {
725
+ setUI(new LoggingUI());
726
+ getUI().intro("PostHog Wizard");
727
+ try {
728
+ const { provisionNewAccount } = await import("./provisioning-CHfTOEvg.js");
729
+ const signupRegion = options.region.toUpperCase();
730
+ getUI().log.info(`Provisioning new PostHog account for ${String(options.email)} in ${signupRegion}...`);
731
+ const result = await provisionNewAccount(options.email, options.name ?? "", signupRegion);
732
+ if (!result.personalApiKey) {
733
+ getUI().log.error("Provisioning succeeded but no personal API key was returned — cannot continue install.");
734
+ process.exit(1);
735
+ return;
736
+ }
737
+ getUI().log.success("Account ready.");
738
+ getUI().log.info(` Project API Key: ${result.projectApiKey}`);
739
+ getUI().log.info(` Personal API Key: ${result.personalApiKey}`);
740
+ getUI().log.info(` Host: ${result.host}`);
741
+ options.apiKey = result.personalApiKey;
742
+ if (options.projectId == null) options.projectId = result.projectId;
743
+ } catch (error) {
744
+ const msg = error instanceof Error ? error.message : String(error);
745
+ getUI().log.error(`Provisioning failed: ${msg}`);
746
+ process.exit(1);
747
+ return;
748
+ }
749
+ }
750
+ const { posthogIntegrationConfig } = await import("./posthog-integration-DX77Msto.js").then((n) => n.r);
751
+ const { FRAMEWORK_REGISTRY } = await import("./registry-CCtIsqb8.js").then((n) => n.n);
752
+ const { detectFramework, gatherFrameworkContext } = await import("./detection-C_RfYYDe.js").then((n) => n.t);
753
+ const { analytics } = await import("./analytics-JDitS2JI.js");
754
+ const { wizardAbort } = await import("./wizard-abort-DIhFXJ5N.js");
531
755
  runWizardCI(posthogIntegrationConfig, options, async (session) => {
532
756
  const integration = session.integration ?? await detectFramework(session.installDir);
533
757
  if (!integration) {
@@ -560,11 +784,11 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
560
784
  getUI().log.error("This installer requires an interactive terminal (TTY) to run.\nIt appears you are running in a non-interactive environment.\nPlease run the wizard in an interactive terminal.\n\nFor CI/CD environments, use --ci mode:\n npx @posthog/wizard --ci --region us --api-key phx_xxx");
561
785
  process.exit(1);
562
786
  } else if (options.playground) (async () => {
563
- const { startPlayground } = await import("./start-playground-g1TxpCZ5.js");
787
+ const { startPlayground } = await import("./start-playground-DYNQ8rOz.js");
564
788
  startPlayground(WIZARD_VERSION);
565
789
  })();
566
790
  else if (options.skill) (async () => {
567
- const { createSkillWorkflow } = await import("./agent-skill-DJOzDaQV.js").then((n) => n.t);
791
+ const { createSkillWorkflow } = await Promise.resolve().then(() => agent_skill_exports);
568
792
  const skillId = options.skill;
569
793
  runWizard(createSkillWorkflow({
570
794
  skillId,
@@ -583,7 +807,7 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
583
807
  });
584
808
  })();
585
809
  else (async () => {
586
- const { posthogIntegrationConfig } = await import("./posthog-integration-D4SRhJIQ.js").then((n) => n.n);
810
+ const { posthogIntegrationConfig } = await import("./posthog-integration-DX77Msto.js").then((n) => n.r);
587
811
  runWizard(posthogIntegrationConfig, options);
588
812
  })();
589
813
  }).command("mcp <command>", "MCP server management commands", (yargs) => {
@@ -607,12 +831,12 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
607
831
  const options = { ...argv };
608
832
  const mcpFeatures = options.features?.split(",").map((s) => s.trim()).filter(Boolean);
609
833
  (async () => {
610
- const { readApiKeyFromEnv } = await import("./env-api-key-DU8uIEvo.js");
834
+ const { readApiKeyFromEnv } = await import("./env-api-key-D5G2PrXW.js");
611
835
  const apiKey = options.apiKey || readApiKeyFromEnv();
612
836
  try {
613
- const { startTUI } = await import("./start-tui-CQef69NR.js");
614
- const { buildSession } = await import("./wizard-session-COhklXAF.js");
615
- const { Flow } = await import("./router-SgzmfLGi.js").then((n) => n.n);
837
+ const { startTUI } = await import("./start-tui-DleQG3La.js");
838
+ const { buildSession } = await import("./wizard-session-BQC9vy9Z.js");
839
+ const { Flow } = await import("./router-BTfmEDDJ.js").then((n) => n.n);
616
840
  const tui = startTUI(WIZARD_VERSION, Flow.McpAdd);
617
841
  const session = buildSession({
618
842
  debug: options.debug,
@@ -623,7 +847,7 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
623
847
  tui.store.session = session;
624
848
  } catch {
625
849
  setUI(new LoggingUI());
626
- const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-Br1hDRiB.js").then((n) => n.r);
850
+ const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-BKoew3aT.js").then((n) => n.r);
627
851
  await addMCPServerToClientsStep({
628
852
  local: options.local,
629
853
  features: mcpFeatures,
@@ -641,9 +865,9 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
641
865
  const options = { ...argv };
642
866
  (async () => {
643
867
  try {
644
- const { startTUI } = await import("./start-tui-CQef69NR.js");
645
- const { buildSession } = await import("./wizard-session-COhklXAF.js");
646
- const { Flow } = await import("./router-SgzmfLGi.js").then((n) => n.n);
868
+ const { startTUI } = await import("./start-tui-DleQG3La.js");
869
+ const { buildSession } = await import("./wizard-session-BQC9vy9Z.js");
870
+ const { Flow } = await import("./router-BTfmEDDJ.js").then((n) => n.n);
647
871
  const tui = startTUI(WIZARD_VERSION, Flow.McpRemove);
648
872
  const session = buildSession({
649
873
  debug: options.debug,
@@ -652,12 +876,69 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
652
876
  tui.store.session = session;
653
877
  } catch {
654
878
  setUI(new LoggingUI());
655
- const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-Br1hDRiB.js").then((n) => n.r);
879
+ const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-BKoew3aT.js").then((n) => n.r);
656
880
  await removeMCPServerFromClientsStep({ local: options.local });
657
881
  }
658
882
  })();
659
883
  }).demandCommand(1, "You must specify a subcommand (add or remove)").help();
660
884
  });
885
+ cli.command("provision", "Create a new PostHog account (headless, no TUI)", (yargs) => {
886
+ return yargs.options({
887
+ email: {
888
+ describe: "Email address for the new account",
889
+ type: "string",
890
+ demandOption: true
891
+ },
892
+ region: {
893
+ describe: "Cloud region (us or eu)",
894
+ choices: ["us", "eu"],
895
+ default: "us"
896
+ },
897
+ name: {
898
+ describe: "Name for the new account",
899
+ type: "string",
900
+ default: ""
901
+ },
902
+ json: {
903
+ describe: "Emit JSON result to stdout (defaults to true when stdout is not a TTY)",
904
+ type: "boolean"
905
+ }
906
+ }).example("wizard provision --email matt+test@posthog.com --region us", "").example("wizard provision --email user@example.com --region eu --json", "");
907
+ }, (argv) => {
908
+ const email = argv.email;
909
+ const region = argv.region.toUpperCase();
910
+ const name = argv.name ?? "";
911
+ const jsonMode = argv.json === void 0 ? !process.stdout.isTTY : argv.json;
912
+ if (!jsonMode) setUI(new LoggingUI());
913
+ (async () => {
914
+ try {
915
+ const { provisionNewAccount } = await import("./provisioning-CHfTOEvg.js");
916
+ if (!jsonMode) getUI().log.info(`Provisioning account for ${email} in ${region}...`);
917
+ const result = await provisionNewAccount(email, name, region);
918
+ if (jsonMode) process.stdout.write(`${JSON.stringify(result)}\n`);
919
+ else {
920
+ getUI().log.success("Account provisioned successfully:");
921
+ getUI().log.info(` API Key: ${result.projectApiKey}`);
922
+ getUI().log.info(` Host: ${result.host}`);
923
+ getUI().log.info(` Project ID: ${result.projectId}`);
924
+ getUI().log.info(` Account ID: ${result.accountId}`);
925
+ getUI().log.info(` Access Token: ${result.accessToken}`);
926
+ getUI().log.info(` Refresh Token: ${result.refreshToken}`);
927
+ if (result.personalApiKey) getUI().log.info(` Personal API Key: ${result.personalApiKey}`);
928
+ }
929
+ process.exit(0);
930
+ } catch (error) {
931
+ const msg = error instanceof Error ? error.message : String(error);
932
+ const code = msg.includes("already associated") ? "email_exists" : "provisioning_failed";
933
+ if (jsonMode) process.stderr.write(`${JSON.stringify({
934
+ error: msg,
935
+ code
936
+ })}\n`);
937
+ else getUI().log.error(`Provisioning failed: ${msg}`);
938
+ process.exit(1);
939
+ }
940
+ })();
941
+ });
661
942
  for (const wfConfig of getSubcommandWorkflows()) cli.command(wfConfig.command, wfConfig.description, (y) => y.options(skillSubcommandOptions), (argv) => {
662
943
  const options = { ...argv };
663
944
  if (options.ci) runWizardCI(wfConfig, options);
@@ -673,12 +954,12 @@ function runWizard(config, options) {
673
954
  (async () => {
674
955
  try {
675
956
  const installDir = options.installDir || process.cwd();
676
- const { startTUI } = await import("./start-tui-CQef69NR.js");
677
- const { buildSession } = await import("./wizard-session-COhklXAF.js");
678
- const { TaskStreamPush } = await import("./task-stream-DX_jKDQu.js");
679
- const { FileDestination } = await import("./file-DhSBlq-x.js");
680
- const { PostHogDestination } = await import("./posthog-ByrpqEjN.js");
681
- const { analytics } = await import("./analytics-CfAUlt6-.js");
957
+ const { startTUI } = await import("./start-tui-DleQG3La.js");
958
+ const { buildSession } = await import("./wizard-session-BQC9vy9Z.js");
959
+ const { TaskStreamPush } = await import("./task-stream-CX7Uf6EM.js");
960
+ const { FileDestination } = await import("./file-8iNrXHkG.js");
961
+ const { PostHogDestination } = await import("./posthog-vm0k9PKS.js");
962
+ const { analytics } = await import("./analytics-JDitS2JI.js");
682
963
  const tui = startTUI(WIZARD_VERSION, config.flowKey);
683
964
  const session = buildSession({
684
965
  debug: options.debug,
@@ -706,9 +987,10 @@ function runWizard(config, options) {
706
987
  tui.store.onTasksChanged = () => void taskStream.push();
707
988
  await tui.store.runReadyHooks();
708
989
  await tui.store.getGate("intro");
990
+ await tui.store.getGate("health-check");
709
991
  const skipAgent = config.run == null;
710
992
  if (skipAgent) {
711
- const { getOrAskForProjectData } = await import("./setup-utils-_ONxN-TT.js");
993
+ const { getOrAskForProjectData } = await import("./setup-utils-CoX-vLgw.js");
712
994
  const { projectApiKey, host, accessToken, projectId } = await getOrAskForProjectData({
713
995
  signup: session.signup,
714
996
  ci: session.ci,
@@ -722,7 +1004,7 @@ function runWizard(config, options) {
722
1004
  projectId
723
1005
  });
724
1006
  } else {
725
- const { runAgent } = await import("./agent-runner-fWYFO4H0.js");
1007
+ const { runAgent } = await import("./agent-runner-B8Cx6X6x.js");
726
1008
  await runAgent(config, tui.store.session);
727
1009
  }
728
1010
  const isDone = () => skipAgent ? tui.store.session.outroDismissed : tui.store.session.skillsComplete;
@@ -773,11 +1055,11 @@ function runWizardCI(config, options, preRun) {
773
1055
  }
774
1056
  (async () => {
775
1057
  const path = await import("path");
776
- const { buildSession } = await import("./wizard-session-COhklXAF.js");
1058
+ const { buildSession } = await import("./wizard-session-BQC9vy9Z.js");
777
1059
  const { readEnvironment } = await Promise.resolve().then(() => environment_exports);
778
- const { readApiKeyFromEnv } = await import("./env-api-key-DU8uIEvo.js");
779
- const { configureLogFileFromEnvironment, logToFile } = await import("./debug-D-0xueVl.js");
780
- const { wizardAbort, WizardError } = await import("./wizard-abort-DZmO_sIZ.js");
1060
+ const { readApiKeyFromEnv } = await import("./env-api-key-D5G2PrXW.js");
1061
+ const { configureLogFileFromEnvironment, logToFile } = await import("./debug-I5sRZubJ.js");
1062
+ const { wizardAbort, WizardError } = await import("./wizard-abort-DIhFXJ5N.js");
781
1063
  configureLogFileFromEnvironment();
782
1064
  const env = readEnvironment();
783
1065
  const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? void 0;
@@ -826,7 +1108,7 @@ function runWizardCI(config, options, preRun) {
826
1108
  })
827
1109
  });
828
1110
  }
829
- const { runAgent } = await import("./agent-runner-fWYFO4H0.js");
1111
+ const { runAgent } = await import("./agent-runner-B8Cx6X6x.js");
830
1112
  await runAgent(config, session);
831
1113
  } catch (error) {
832
1114
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -844,6 +1126,6 @@ function runWizardCI(config, options, preRun) {
844
1126
  });
845
1127
  }
846
1128
  //#endregion
847
- export { STRIPE_SDKS as a, POSTHOG_SDKS as i, getKindMeta as n, fetchHealthIssues as r, WORKFLOW_REGISTRY as t };
1129
+ export { POSTHOG_SDKS as a, AGENT_SKILL_STEPS as i, getKindMeta as n, STRIPE_SDKS as o, fetchHealthIssues as r, WORKFLOW_REGISTRY as t };
848
1130
 
849
1131
  //# sourceMappingURL=bin.js.map