@posthog/wizard 2.11.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +48 -7
  2. package/dist/{McpScreen-DvUncZBi.js → AuditChecksViewer-B0J7zcY2.js} +434 -22
  3. package/dist/AuditChecksViewer-B0J7zcY2.js.map +1 -0
  4. package/dist/{add-mcp-server-to-clients-Br1hDRiB.js → add-mcp-server-to-clients-CUNR00bB.js} +5 -5
  5. package/dist/{add-mcp-server-to-clients-Br1hDRiB.js.map → add-mcp-server-to-clients-CUNR00bB.js.map} +1 -1
  6. package/dist/{readiness-gQvQNCeL.js → agent-interface-CV0-vtxj.js} +328 -462
  7. package/dist/agent-interface-CV0-vtxj.js.map +1 -0
  8. package/dist/{agent-runner-fWYFO4H0.js → agent-runner-LvVQH31D.js} +21 -31
  9. package/dist/{agent-runner-fWYFO4H0.js.map → agent-runner-LvVQH31D.js.map} +1 -1
  10. package/dist/analytics-BH7bEHQR.js +2 -0
  11. package/dist/analytics-VM7laaFx.js +123 -0
  12. package/dist/analytics-VM7laaFx.js.map +1 -0
  13. package/dist/bin.js +529 -42
  14. package/dist/bin.js.map +1 -1
  15. package/dist/{debug-D-0xueVl.js → debug-BdcTB7EF.js} +1 -1
  16. package/dist/debug-Cqi6nVfX.js +686 -0
  17. package/dist/debug-Cqi6nVfX.js.map +1 -0
  18. package/dist/{defaults-CPH6eWhN.js → defaults-GbLPuHxj.js} +1 -1
  19. package/dist/{defaults-CPH6eWhN.js.map → defaults-GbLPuHxj.js.map} +1 -1
  20. package/dist/{detection-B7GNzve-.js → detection-CSjmal-X.js} +3 -3
  21. package/dist/{detection-B7GNzve-.js.map → detection-CSjmal-X.js.map} +1 -1
  22. package/dist/{env-api-key-DU8uIEvo.js → env-api-key-D5G2PrXW.js} +1 -1
  23. package/dist/{env-api-key-DU8uIEvo.js.map → env-api-key-D5G2PrXW.js.map} +1 -1
  24. package/dist/{file-DhSBlq-x.js → file-8iNrXHkG.js} +2 -2
  25. package/dist/{file-DhSBlq-x.js.map → file-8iNrXHkG.js.map} +1 -1
  26. package/dist/{file-utils-Dy9JncCo.js → file-utils-DnTSiTJw.js} +1 -1
  27. package/dist/{file-utils-Dy9JncCo.js.map → file-utils-DnTSiTJw.js.map} +1 -1
  28. package/dist/{package-manager-D3Lo6nXf.js → package-manager-CD8RQW-e.js} +2 -2
  29. package/dist/{package-manager-D3Lo6nXf.js.map → package-manager-CD8RQW-e.js.map} +1 -1
  30. package/dist/paths-DJS47p5x.js +26 -0
  31. package/dist/paths-DJS47p5x.js.map +1 -0
  32. package/dist/{posthog-integration-D4SRhJIQ.js → posthog-integration-BL21S3T6.js} +41 -13
  33. package/dist/posthog-integration-BL21S3T6.js.map +1 -0
  34. package/dist/{posthog-ByrpqEjN.js → posthog-vm0k9PKS.js} +1 -1
  35. package/dist/{posthog-ByrpqEjN.js.map → posthog-vm0k9PKS.js.map} +1 -1
  36. package/dist/provisioning-BdQ1ONIg.js +2 -0
  37. package/dist/provisioning-g9aoVIEd.js +166 -0
  38. package/dist/provisioning-g9aoVIEd.js.map +1 -0
  39. package/dist/{registry-DaPKstG3.js → registry-BaMEaAKd.js} +4 -5
  40. package/dist/{registry-DaPKstG3.js.map → registry-BaMEaAKd.js.map} +1 -1
  41. package/dist/{router-SgzmfLGi.js → router-COhhuIW3.js} +4 -3
  42. package/dist/router-COhhuIW3.js.map +1 -0
  43. package/dist/{setup-utils-y4s-3uKT.js → setup-utils-CNV7FSlY.js} +11 -150
  44. package/dist/setup-utils-CNV7FSlY.js.map +1 -0
  45. package/dist/setup-utils-CU4FIqjB.js +2 -0
  46. package/dist/{start-playground-g1TxpCZ5.js → start-playground-C9GWnVdM.js} +102 -7
  47. package/dist/start-playground-C9GWnVdM.js.map +1 -0
  48. package/dist/start-tui-B_zwutLe.js +4195 -0
  49. package/dist/start-tui-B_zwutLe.js.map +1 -0
  50. package/dist/{steps-D1zKDqAo.js → steps-Dawz7k3T.js} +8 -8
  51. package/dist/steps-Dawz7k3T.js.map +1 -0
  52. package/dist/{task-stream-DX_jKDQu.js → task-stream-CX7Uf6EM.js} +4 -4
  53. package/dist/{task-stream-DX_jKDQu.js.map → task-stream-CX7Uf6EM.js.map} +1 -1
  54. package/dist/{telemetry-CyUUSAYy.js → telemetry-D6bjWA-A.js} +2 -2
  55. package/dist/{telemetry-CyUUSAYy.js.map → telemetry-D6bjWA-A.js.map} +1 -1
  56. package/dist/{wizard-abort-Buodno3f.js → wizard-abort-CJkNkSjT.js} +6 -4
  57. package/dist/{wizard-abort-Buodno3f.js.map → wizard-abort-CJkNkSjT.js.map} +1 -1
  58. package/dist/{wizard-abort-DZmO_sIZ.js → wizard-abort-Dl0BkqhT.js} +1 -1
  59. package/dist/wizard-session-BQC9vy9Z.js +2 -0
  60. package/dist/{wizard-session-D5bggSsu.js → wizard-session-BcNJTl2I.js} +1 -1
  61. package/dist/{wizard-session-D5bggSsu.js.map → wizard-session-BcNJTl2I.js.map} +1 -1
  62. package/dist/{wizard-ui-BExOjdjA.js → wizard-ui-YdGFRyu_.js} +1 -1
  63. package/dist/wizard-ui-YdGFRyu_.js.map +1 -0
  64. package/npm-shrinkwrap.json +2 -2
  65. package/package.json +1 -1
  66. package/dist/McpScreen-DvUncZBi.js.map +0 -1
  67. package/dist/agent-skill-DJOzDaQV.js +0 -59
  68. package/dist/agent-skill-DJOzDaQV.js.map +0 -1
  69. package/dist/analytics-CfAUlt6-.js +0 -2
  70. package/dist/analytics-D3rY3TaN.js +0 -210
  71. package/dist/analytics-D3rY3TaN.js.map +0 -1
  72. package/dist/debug-gWEjmYVV.js +0 -203
  73. package/dist/debug-gWEjmYVV.js.map +0 -1
  74. package/dist/paths-BL-x2rFy.js +0 -16
  75. package/dist/paths-BL-x2rFy.js.map +0 -1
  76. package/dist/posthog-integration-D4SRhJIQ.js.map +0 -1
  77. package/dist/readiness-gQvQNCeL.js.map +0 -1
  78. package/dist/router-SgzmfLGi.js.map +0 -1
  79. package/dist/setup-utils-_ONxN-TT.js +0 -2
  80. package/dist/setup-utils-y4s-3uKT.js.map +0 -1
  81. package/dist/start-playground-g1TxpCZ5.js.map +0 -1
  82. package/dist/start-tui-CQef69NR.js +0 -2167
  83. package/dist/start-tui-CQef69NR.js.map +0 -1
  84. package/dist/steps-D1zKDqAo.js.map +0 -1
  85. package/dist/wizard-session-COhklXAF.js +0 -2
  86. package/dist/wizard-ui-BExOjdjA.js.map +0 -1
package/dist/bin.js 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-Cqi6nVfX.js";
4
+ import { n as analytics } from "./analytics-VM7laaFx.js";
5
+ import { u as handleApiError } from "./setup-utils-CNV7FSlY.js";
6
+ import { h as AUDIT_REPORT_FILE, m as AUDIT_CHECKS_KEY, p as AUDIT_CHECKS_FILE } from "./agent-interface-CV0-vtxj.js";
7
+ import { n as posthogIntegrationConfig } from "./posthog-integration-BL21S3T6.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,391 @@ 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
+ reportFile: opts.reportFile,
263
+ run: {
264
+ skillId: opts.skillId,
265
+ integrationLabel: opts.integrationLabel,
266
+ customPrompt: opts.customPrompt ? () => opts.customPrompt : void 0,
267
+ successMessage: opts.successMessage,
268
+ reportFile: opts.reportFile,
269
+ docsUrl: opts.docsUrl,
270
+ spinnerMessage: opts.spinnerMessage,
271
+ estimatedDurationMinutes: opts.estimatedDurationMinutes,
272
+ buildOutroData: opts.buildOutroData,
273
+ abortCases: opts.abortCases
274
+ },
275
+ requires: opts.requires
276
+ };
277
+ }
278
+ //#endregion
279
+ //#region src/lib/workflows/audit/detect.ts
280
+ /** `[ABORT] <reason>` cases the audit skill can emit. Reason strings are
281
+ * defined in the skill's `Abort statuses` section. */
282
+ const AUDIT_ABORT_CASES = [{
283
+ match: /^no posthog sdk found$/i,
284
+ message: "No PostHog SDK found",
285
+ 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.",
286
+ docsUrl: "https://posthog.com/docs/getting-started/install"
287
+ }];
288
+ //#endregion
289
+ //#region src/lib/workflows/audit/seed.ts
290
+ /** The 10 data-integrity checks the audit runs. */
291
+ const AUDIT_SEED_CHECKS = [
292
+ {
293
+ id: "sdk-installed",
294
+ area: "Installation",
295
+ label: "PostHog SDK installed",
296
+ status: "pending"
297
+ },
298
+ {
299
+ id: "sdk-up-to-date",
300
+ area: "Installation",
301
+ label: "SDK version up to date",
302
+ status: "pending"
303
+ },
304
+ {
305
+ id: "init-correct",
306
+ area: "Installation",
307
+ label: "Initialization is correct",
308
+ status: "pending"
309
+ },
310
+ {
311
+ id: "identify-stable-distinct-id",
312
+ area: "Identification",
313
+ label: "Stable distinct_id (not session UUID)",
314
+ status: "pending"
315
+ },
316
+ {
317
+ id: "identify-not-late",
318
+ area: "Identification",
319
+ label: "identify() called before captures / flag evals",
320
+ status: "pending"
321
+ },
322
+ {
323
+ id: "cross-runtime-distinct-id",
324
+ area: "Identification",
325
+ label: "Same distinct_id across client and server",
326
+ status: "pending"
327
+ },
328
+ {
329
+ id: "identify-reset-on-logout",
330
+ area: "Identification",
331
+ label: "reset() called on logout / account switch",
332
+ status: "pending"
333
+ },
334
+ {
335
+ id: "capture-event-names-static",
336
+ area: "Event Capture",
337
+ label: "Event names are static and consistent",
338
+ status: "pending"
339
+ },
340
+ {
341
+ id: "capture-uses-proxy",
342
+ area: "Event Capture",
343
+ label: "Captures route through a reverse proxy",
344
+ status: "pending"
345
+ },
346
+ {
347
+ id: "capture-growth-events",
348
+ area: "Event Capture",
349
+ label: "Key activation events captured",
350
+ status: "pending"
351
+ }
352
+ ];
353
+ /** Atomically write the seeded ledger to the project's audit checks file. */
354
+ function seedAuditLedger(installDir) {
355
+ const target = path.join(installDir, AUDIT_CHECKS_FILE);
356
+ const tmp = `${target}.tmp`;
357
+ fs.writeFileSync(tmp, JSON.stringify(AUDIT_SEED_CHECKS, null, 2), "utf8");
358
+ fs.renameSync(tmp, target);
359
+ logToFile(`seedAuditLedger: wrote ${AUDIT_SEED_CHECKS.length} entries to ${target}`);
360
+ }
361
+ //#endregion
362
+ //#region src/lib/workflows/audit/index.ts
363
+ /** Audit-specific screens for the shared agent-skill pipeline. */
364
+ const AUDIT_SCREEN_BY_STEP = {
365
+ intro: "audit-intro",
366
+ run: "audit-run",
367
+ outro: "audit-outro"
368
+ };
369
+ const seedBeforeAuditRun = (session) => {
370
+ seedAuditLedger(session.installDir);
371
+ session.frameworkContext[AUDIT_CHECKS_KEY] = AUDIT_SEED_CHECKS;
372
+ };
373
+ const withAuditScreens = (steps) => steps.map((step) => {
374
+ const override = AUDIT_SCREEN_BY_STEP[step.id];
375
+ return override ? {
376
+ ...step,
377
+ screen: override
378
+ } : step;
379
+ });
380
+ const auditSteps = withAuditScreens(AGENT_SKILL_STEPS);
381
+ const baseConfig$1 = createSkillWorkflow({
382
+ skillId: "audit",
383
+ command: "audit",
384
+ flowKey: "audit",
385
+ description: "Audit an existing PostHog integration for correctness and best practices",
386
+ integrationLabel: "audit",
387
+ 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.",
388
+ successMessage: "Audit complete! You can view the audit report at ./posthog-audit-report.md",
389
+ reportFile: AUDIT_REPORT_FILE,
390
+ docsUrl: "https://posthog.com/docs/product-analytics/best-practices",
391
+ spinnerMessage: "Auditing PostHog integration...",
392
+ estimatedDurationMinutes: 5,
393
+ requires: ["posthog-integration"],
394
+ abortCases: AUDIT_ABORT_CASES
395
+ });
396
+ const auditRun = async (session) => {
397
+ seedBeforeAuditRun(session);
398
+ if (!baseConfig$1.run) throw new Error("Audit workflow has no run configuration.");
399
+ return typeof baseConfig$1.run === "function" ? baseConfig$1.run(session) : baseConfig$1.run;
400
+ };
401
+ const auditConfig = {
402
+ ...baseConfig$1,
403
+ steps: auditSteps,
404
+ run: auditRun
405
+ };
406
+ //#endregion
407
+ //#region src/lib/workflows/audit-3000/index.ts
408
+ const AUDIT3000_REPORT_FILE = "posthog-audit-3000-report.md";
409
+ const AUDIT3000_EXTRA_CHECKS = [
410
+ {
411
+ id: "event-naming-standardization",
412
+ area: "Event Quality",
413
+ label: "Event naming convention is consistent",
414
+ status: "pending"
415
+ },
416
+ {
417
+ id: "event-duplicates-and-bloat",
418
+ area: "Event Quality",
419
+ label: "No duplicate or bloated event capture",
420
+ status: "pending"
421
+ },
422
+ {
423
+ id: "event-quality-context-review",
424
+ area: "Event Quality",
425
+ label: "Event property context reviewed",
426
+ status: "pending"
427
+ },
428
+ {
429
+ id: "event-usage-coverage",
430
+ area: "Event Quality",
431
+ label: "Captured events match insights / dashboards usage",
432
+ status: "pending"
433
+ },
434
+ {
435
+ id: "stale-feature-flags-reviewed",
436
+ area: "Feature Flags",
437
+ label: "Stale feature flags reviewed",
438
+ status: "pending"
439
+ },
440
+ {
441
+ id: "replay-minimum-duration-set",
442
+ area: "Session Replay",
443
+ label: "Minimum duration set on init",
444
+ status: "pending"
445
+ },
446
+ {
447
+ id: "replay-mask-config",
448
+ area: "Session Replay",
449
+ label: "Mask config covers sensitive surfaces",
450
+ status: "pending"
451
+ },
452
+ {
453
+ id: "replay-disabled-in-test-envs",
454
+ area: "Session Replay",
455
+ label: "Disabled in test / CI environments",
456
+ status: "pending"
457
+ },
458
+ {
459
+ id: "replay-strict-minimum-duration",
460
+ area: "Session Replay",
461
+ label: "Strict minimum duration enforced",
462
+ status: "pending"
463
+ },
464
+ {
465
+ id: "replay-sampling-rate",
466
+ area: "Session Replay — Optimize",
467
+ label: "Sampling rate tuned for cost",
468
+ status: "pending"
469
+ },
470
+ {
471
+ id: "replay-triggers-configured",
472
+ area: "Session Replay — Optimize",
473
+ label: "Triggers configured (event / URL / flag)",
474
+ status: "pending"
475
+ },
476
+ {
477
+ id: "replay-network-recording-filtered",
478
+ area: "Session Replay — Optimize",
479
+ label: "Network recording filtered",
480
+ status: "pending"
481
+ },
482
+ {
483
+ id: "replay-mobile-sampling",
484
+ area: "Session Replay — Optimize",
485
+ label: "Mobile sampling configured",
486
+ status: "pending"
487
+ },
488
+ {
489
+ id: "expansion-product-analytics",
490
+ area: "Use Case: Expansion",
491
+ label: "Product analytics coverage",
492
+ status: "pending"
493
+ },
494
+ {
495
+ id: "expansion-error-tracking",
496
+ area: "Use Case: Expansion",
497
+ label: "Error tracking coverage",
498
+ status: "pending"
499
+ },
500
+ {
501
+ id: "expansion-llm-observability",
502
+ area: "Use Case: Expansion",
503
+ label: "LLM observability coverage",
504
+ status: "pending"
505
+ },
506
+ {
507
+ id: "expansion-session-replay",
508
+ area: "Use Case: Expansion",
509
+ label: "Session replay coverage",
510
+ status: "pending"
511
+ },
512
+ {
513
+ id: "expansion-feature-flags",
514
+ area: "Use Case: Expansion",
515
+ label: "Feature flags coverage",
516
+ status: "pending"
517
+ },
518
+ {
519
+ id: "expansion-surveys",
520
+ area: "Use Case: Expansion",
521
+ label: "Surveys coverage",
522
+ status: "pending"
523
+ },
524
+ {
525
+ id: "expansion-logs",
526
+ area: "Use Case: Expansion",
527
+ label: "Logs coverage",
528
+ status: "pending"
529
+ },
530
+ {
531
+ id: "expansion-web-analytics",
532
+ area: "Use Case: Expansion",
533
+ label: "Web analytics coverage",
534
+ status: "pending"
535
+ },
536
+ {
537
+ id: "customer-enrichment",
538
+ area: "Additional Sections",
539
+ label: "Customer enrichment (Harmonic + PDL)",
540
+ status: "pending"
541
+ },
542
+ {
543
+ id: "use-case-match",
544
+ area: "Additional Sections",
545
+ label: "Use-case match",
546
+ status: "pending"
547
+ },
548
+ {
549
+ id: "final-report",
550
+ area: "Additional Sections",
551
+ label: "Final audit report written",
552
+ status: "pending"
553
+ }
554
+ ];
555
+ const AUDIT3000_SEED_CHECKS = [...AUDIT_SEED_CHECKS, ...AUDIT3000_EXTRA_CHECKS];
556
+ const AUDIT3000_SCREEN_BY_STEP = {
557
+ intro: "audit-3000-intro",
558
+ run: "audit-3000-run",
559
+ outro: "audit-3000-outro"
560
+ };
561
+ const seedAudit3000Ledger = (installDir) => {
562
+ const target = path.join(installDir, AUDIT_CHECKS_FILE);
563
+ const tmp = `${target}.tmp`;
564
+ fs.writeFileSync(tmp, JSON.stringify(AUDIT3000_SEED_CHECKS, null, 2), "utf8");
565
+ fs.renameSync(tmp, target);
566
+ logToFile(`seedAudit3000Ledger: wrote ${AUDIT3000_SEED_CHECKS.length} entries to ${target}`);
567
+ };
568
+ const seedBeforeAudit3000Run = (session) => {
569
+ seedAudit3000Ledger(session.installDir);
570
+ session.frameworkContext[AUDIT_CHECKS_KEY] = AUDIT3000_SEED_CHECKS;
571
+ };
572
+ const withAudit3000Screens = (steps) => steps.map((step) => {
573
+ const override = AUDIT3000_SCREEN_BY_STEP[step.id];
574
+ return override ? {
575
+ ...step,
576
+ screen: override
577
+ } : step;
578
+ });
579
+ const audit3000Steps = withAudit3000Screens(AGENT_SKILL_STEPS);
580
+ const baseConfig = createSkillWorkflow({
581
+ skillId: "audit-3000",
582
+ command: "audit-3000",
583
+ flowKey: "audit-3000",
584
+ description: "Audit an existing PostHog integration (v3000 — adds event quality, stale-flag hygiene, customer enrichment, use-case match)",
585
+ integrationLabel: "audit-3000",
586
+ customPrompt: "Run the audit-3000 skill end-to-end. Follow the step chain starting at references/1-version.md. Do not modify any project files — only create the final audit report and (when enrichment is enabled) the enrichment report.",
587
+ successMessage: `Audit complete! View the report at ./${AUDIT3000_REPORT_FILE}`,
588
+ reportFile: AUDIT3000_REPORT_FILE,
589
+ docsUrl: "https://posthog.com/docs/product-analytics/best-practices",
590
+ spinnerMessage: "Running PostHog Audit 3000...",
591
+ estimatedDurationMinutes: 6,
592
+ requires: ["posthog-integration"],
593
+ abortCases: AUDIT_ABORT_CASES
594
+ });
595
+ const audit3000Run = async (session) => {
596
+ seedBeforeAudit3000Run(session);
597
+ if (!baseConfig.run) throw new Error("audit-3000 workflow has no run configuration.");
598
+ return typeof baseConfig.run === "function" ? baseConfig.run(session) : baseConfig.run;
599
+ };
600
+ const audit3000Config = {
601
+ ...baseConfig,
602
+ steps: audit3000Steps,
603
+ run: audit3000Run
604
+ };
605
+ //#endregion
220
606
  //#region src/lib/workflows/posthog-doctor/steps.ts
221
607
  const POSTHOG_DOCTOR_WORKFLOW = [
222
608
  {
@@ -364,6 +750,8 @@ function getKindMeta(kind) {
364
750
  const WORKFLOW_REGISTRY = [
365
751
  posthogIntegrationConfig,
366
752
  revenueAnalyticsConfig,
753
+ auditConfig,
754
+ audit3000Config,
367
755
  {
368
756
  command: "doctor",
369
757
  description: "Diagnose your PostHog project for configuration issues and setup warnings",
@@ -371,6 +759,10 @@ const WORKFLOW_REGISTRY = [
371
759
  steps: POSTHOG_DOCTOR_WORKFLOW
372
760
  }
373
761
  ];
762
+ /** Look up a workflow config by its flowKey. */
763
+ function getWorkflowConfig(flowKey) {
764
+ return WORKFLOW_REGISTRY.find((c) => c.flowKey === flowKey);
765
+ }
374
766
  /** All workflow configs that are exposed as CLI subcommands. */
375
767
  function getSubcommandWorkflows() {
376
768
  return WORKFLOW_REGISTRY.filter((c) => c.command != null);
@@ -502,32 +894,69 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
502
894
  skill: {
503
895
  describe: "Run a specific context-mill skill by ID\nenv: POSTHOG_WIZARD_SKILL",
504
896
  type: "string"
897
+ },
898
+ name: {
899
+ describe: "Name for account creation with --ci --signup\nenv: POSTHOG_WIZARD_NAME",
900
+ type: "string"
505
901
  }
506
902
  });
507
903
  }, (argv) => {
508
904
  const options = { ...argv };
509
905
  if (options.ci) {
510
906
  if (!options.region) options.region = "us";
511
- if (!options.apiKey) {
907
+ if (!options.installDir) {
512
908
  setUI(new LoggingUI());
513
909
  getUI().intro("PostHog Wizard");
514
- getUI().log.error("CI mode requires --api-key (personal API key phx_xxx)");
910
+ getUI().log.error("CI mode requires --install-dir (directory to install in)");
515
911
  process.exit(1);
516
912
  return;
517
913
  }
518
- if (!options.installDir) {
914
+ if (!options.apiKey && !options.signup) {
519
915
  setUI(new LoggingUI());
520
916
  getUI().intro("PostHog Wizard");
521
- getUI().log.error("CI mode requires --install-dir (directory to install in)");
917
+ 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.");
918
+ process.exit(1);
919
+ return;
920
+ }
921
+ if (!options.apiKey && options.signup && !options.email) {
922
+ setUI(new LoggingUI());
923
+ getUI().intro("PostHog Wizard");
924
+ getUI().log.error("CI --signup requires --email to create a new account.");
522
925
  process.exit(1);
523
926
  return;
524
927
  }
525
928
  (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");
929
+ if (!options.apiKey && options.signup) {
930
+ setUI(new LoggingUI());
931
+ getUI().intro("PostHog Wizard");
932
+ try {
933
+ const { provisionNewAccount } = await import("./provisioning-BdQ1ONIg.js");
934
+ const signupRegion = options.region.toUpperCase();
935
+ getUI().log.info(`Provisioning new PostHog account for ${String(options.email)} in ${signupRegion}...`);
936
+ const result = await provisionNewAccount(options.email, options.name ?? "", signupRegion);
937
+ if (!result.personalApiKey) {
938
+ getUI().log.error("Provisioning succeeded but no personal API key was returned — cannot continue install.");
939
+ process.exit(1);
940
+ return;
941
+ }
942
+ getUI().log.success("Account ready.");
943
+ getUI().log.info(` Project API Key: ${result.projectApiKey}`);
944
+ getUI().log.info(` Personal API Key: ${result.personalApiKey}`);
945
+ getUI().log.info(` Host: ${result.host}`);
946
+ options.apiKey = result.personalApiKey;
947
+ if (options.projectId == null) options.projectId = result.projectId;
948
+ } catch (error) {
949
+ const msg = error instanceof Error ? error.message : String(error);
950
+ getUI().log.error(`Provisioning failed: ${msg}`);
951
+ process.exit(1);
952
+ return;
953
+ }
954
+ }
955
+ const { posthogIntegrationConfig } = await import("./posthog-integration-BL21S3T6.js").then((n) => n.r);
956
+ const { FRAMEWORK_REGISTRY } = await import("./registry-BaMEaAKd.js").then((n) => n.n);
957
+ const { detectFramework, gatherFrameworkContext } = await import("./detection-CSjmal-X.js").then((n) => n.t);
958
+ const { analytics } = await import("./analytics-BH7bEHQR.js");
959
+ const { wizardAbort } = await import("./wizard-abort-Dl0BkqhT.js");
531
960
  runWizardCI(posthogIntegrationConfig, options, async (session) => {
532
961
  const integration = session.integration ?? await detectFramework(session.installDir);
533
962
  if (!integration) {
@@ -560,11 +989,11 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
560
989
  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
990
  process.exit(1);
562
991
  } else if (options.playground) (async () => {
563
- const { startPlayground } = await import("./start-playground-g1TxpCZ5.js");
992
+ const { startPlayground } = await import("./start-playground-C9GWnVdM.js");
564
993
  startPlayground(WIZARD_VERSION);
565
994
  })();
566
995
  else if (options.skill) (async () => {
567
- const { createSkillWorkflow } = await import("./agent-skill-DJOzDaQV.js").then((n) => n.t);
996
+ const { createSkillWorkflow } = await Promise.resolve().then(() => agent_skill_exports);
568
997
  const skillId = options.skill;
569
998
  runWizard(createSkillWorkflow({
570
999
  skillId,
@@ -583,7 +1012,7 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
583
1012
  });
584
1013
  })();
585
1014
  else (async () => {
586
- const { posthogIntegrationConfig } = await import("./posthog-integration-D4SRhJIQ.js").then((n) => n.n);
1015
+ const { posthogIntegrationConfig } = await import("./posthog-integration-BL21S3T6.js").then((n) => n.r);
587
1016
  runWizard(posthogIntegrationConfig, options);
588
1017
  })();
589
1018
  }).command("mcp <command>", "MCP server management commands", (yargs) => {
@@ -607,12 +1036,12 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
607
1036
  const options = { ...argv };
608
1037
  const mcpFeatures = options.features?.split(",").map((s) => s.trim()).filter(Boolean);
609
1038
  (async () => {
610
- const { readApiKeyFromEnv } = await import("./env-api-key-DU8uIEvo.js");
1039
+ const { readApiKeyFromEnv } = await import("./env-api-key-D5G2PrXW.js");
611
1040
  const apiKey = options.apiKey || readApiKeyFromEnv();
612
1041
  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);
1042
+ const { startTUI } = await import("./start-tui-B_zwutLe.js");
1043
+ const { buildSession } = await import("./wizard-session-BQC9vy9Z.js");
1044
+ const { Flow } = await import("./router-COhhuIW3.js").then((n) => n.n);
616
1045
  const tui = startTUI(WIZARD_VERSION, Flow.McpAdd);
617
1046
  const session = buildSession({
618
1047
  debug: options.debug,
@@ -623,7 +1052,7 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
623
1052
  tui.store.session = session;
624
1053
  } catch {
625
1054
  setUI(new LoggingUI());
626
- const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-Br1hDRiB.js").then((n) => n.r);
1055
+ const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-CUNR00bB.js").then((n) => n.r);
627
1056
  await addMCPServerToClientsStep({
628
1057
  local: options.local,
629
1058
  features: mcpFeatures,
@@ -641,9 +1070,9 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
641
1070
  const options = { ...argv };
642
1071
  (async () => {
643
1072
  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);
1073
+ const { startTUI } = await import("./start-tui-B_zwutLe.js");
1074
+ const { buildSession } = await import("./wizard-session-BQC9vy9Z.js");
1075
+ const { Flow } = await import("./router-COhhuIW3.js").then((n) => n.n);
647
1076
  const tui = startTUI(WIZARD_VERSION, Flow.McpRemove);
648
1077
  const session = buildSession({
649
1078
  debug: options.debug,
@@ -652,12 +1081,69 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
652
1081
  tui.store.session = session;
653
1082
  } catch {
654
1083
  setUI(new LoggingUI());
655
- const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-Br1hDRiB.js").then((n) => n.r);
1084
+ const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-CUNR00bB.js").then((n) => n.r);
656
1085
  await removeMCPServerFromClientsStep({ local: options.local });
657
1086
  }
658
1087
  })();
659
1088
  }).demandCommand(1, "You must specify a subcommand (add or remove)").help();
660
1089
  });
1090
+ cli.command("provision", "Create a new PostHog account (headless, no TUI)", (yargs) => {
1091
+ return yargs.options({
1092
+ email: {
1093
+ describe: "Email address for the new account",
1094
+ type: "string",
1095
+ demandOption: true
1096
+ },
1097
+ region: {
1098
+ describe: "Cloud region (us or eu)",
1099
+ choices: ["us", "eu"],
1100
+ default: "us"
1101
+ },
1102
+ name: {
1103
+ describe: "Name for the new account",
1104
+ type: "string",
1105
+ default: ""
1106
+ },
1107
+ json: {
1108
+ describe: "Emit JSON result to stdout (defaults to true when stdout is not a TTY)",
1109
+ type: "boolean"
1110
+ }
1111
+ }).example("wizard provision --email matt+test@posthog.com --region us", "").example("wizard provision --email user@example.com --region eu --json", "");
1112
+ }, (argv) => {
1113
+ const email = argv.email;
1114
+ const region = argv.region.toUpperCase();
1115
+ const name = argv.name ?? "";
1116
+ const jsonMode = argv.json === void 0 ? !process.stdout.isTTY : argv.json;
1117
+ if (!jsonMode) setUI(new LoggingUI());
1118
+ (async () => {
1119
+ try {
1120
+ const { provisionNewAccount } = await import("./provisioning-BdQ1ONIg.js");
1121
+ if (!jsonMode) getUI().log.info(`Provisioning account for ${email} in ${region}...`);
1122
+ const result = await provisionNewAccount(email, name, region);
1123
+ if (jsonMode) process.stdout.write(`${JSON.stringify(result)}\n`);
1124
+ else {
1125
+ getUI().log.success("Account provisioned successfully:");
1126
+ getUI().log.info(` API Key: ${result.projectApiKey}`);
1127
+ getUI().log.info(` Host: ${result.host}`);
1128
+ getUI().log.info(` Project ID: ${result.projectId}`);
1129
+ getUI().log.info(` Account ID: ${result.accountId}`);
1130
+ getUI().log.info(` Access Token: ${result.accessToken}`);
1131
+ getUI().log.info(` Refresh Token: ${result.refreshToken}`);
1132
+ if (result.personalApiKey) getUI().log.info(` Personal API Key: ${result.personalApiKey}`);
1133
+ }
1134
+ process.exit(0);
1135
+ } catch (error) {
1136
+ const msg = error instanceof Error ? error.message : String(error);
1137
+ const code = msg.includes("already associated") ? "email_exists" : "provisioning_failed";
1138
+ if (jsonMode) process.stderr.write(`${JSON.stringify({
1139
+ error: msg,
1140
+ code
1141
+ })}\n`);
1142
+ else getUI().log.error(`Provisioning failed: ${msg}`);
1143
+ process.exit(1);
1144
+ }
1145
+ })();
1146
+ });
661
1147
  for (const wfConfig of getSubcommandWorkflows()) cli.command(wfConfig.command, wfConfig.description, (y) => y.options(skillSubcommandOptions), (argv) => {
662
1148
  const options = { ...argv };
663
1149
  if (options.ci) runWizardCI(wfConfig, options);
@@ -673,12 +1159,12 @@ function runWizard(config, options) {
673
1159
  (async () => {
674
1160
  try {
675
1161
  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");
1162
+ const { startTUI } = await import("./start-tui-B_zwutLe.js");
1163
+ const { buildSession } = await import("./wizard-session-BQC9vy9Z.js");
1164
+ const { TaskStreamPush } = await import("./task-stream-CX7Uf6EM.js");
1165
+ const { FileDestination } = await import("./file-8iNrXHkG.js");
1166
+ const { PostHogDestination } = await import("./posthog-vm0k9PKS.js");
1167
+ const { analytics } = await import("./analytics-BH7bEHQR.js");
682
1168
  const tui = startTUI(WIZARD_VERSION, config.flowKey);
683
1169
  const session = buildSession({
684
1170
  debug: options.debug,
@@ -706,9 +1192,10 @@ function runWizard(config, options) {
706
1192
  tui.store.onTasksChanged = () => void taskStream.push();
707
1193
  await tui.store.runReadyHooks();
708
1194
  await tui.store.getGate("intro");
1195
+ await tui.store.getGate("health-check");
709
1196
  const skipAgent = config.run == null;
710
1197
  if (skipAgent) {
711
- const { getOrAskForProjectData } = await import("./setup-utils-_ONxN-TT.js");
1198
+ const { getOrAskForProjectData } = await import("./setup-utils-CU4FIqjB.js");
712
1199
  const { projectApiKey, host, accessToken, projectId } = await getOrAskForProjectData({
713
1200
  signup: session.signup,
714
1201
  ci: session.ci,
@@ -722,7 +1209,7 @@ function runWizard(config, options) {
722
1209
  projectId
723
1210
  });
724
1211
  } else {
725
- const { runAgent } = await import("./agent-runner-fWYFO4H0.js");
1212
+ const { runAgent } = await import("./agent-runner-LvVQH31D.js");
726
1213
  await runAgent(config, tui.store.session);
727
1214
  }
728
1215
  const isDone = () => skipAgent ? tui.store.session.outroDismissed : tui.store.session.skillsComplete;
@@ -773,11 +1260,11 @@ function runWizardCI(config, options, preRun) {
773
1260
  }
774
1261
  (async () => {
775
1262
  const path = await import("path");
776
- const { buildSession } = await import("./wizard-session-COhklXAF.js");
1263
+ const { buildSession } = await import("./wizard-session-BQC9vy9Z.js");
777
1264
  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");
1265
+ const { readApiKeyFromEnv } = await import("./env-api-key-D5G2PrXW.js");
1266
+ const { configureLogFileFromEnvironment, logToFile } = await import("./debug-BdcTB7EF.js");
1267
+ const { wizardAbort, WizardError } = await import("./wizard-abort-Dl0BkqhT.js");
781
1268
  configureLogFileFromEnvironment();
782
1269
  const env = readEnvironment();
783
1270
  const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? void 0;
@@ -826,7 +1313,7 @@ function runWizardCI(config, options, preRun) {
826
1313
  })
827
1314
  });
828
1315
  }
829
- const { runAgent } = await import("./agent-runner-fWYFO4H0.js");
1316
+ const { runAgent } = await import("./agent-runner-LvVQH31D.js");
830
1317
  await runAgent(config, session);
831
1318
  } catch (error) {
832
1319
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -844,6 +1331,6 @@ function runWizardCI(config, options, preRun) {
844
1331
  });
845
1332
  }
846
1333
  //#endregion
847
- export { STRIPE_SDKS as a, POSTHOG_SDKS as i, getKindMeta as n, fetchHealthIssues as r, WORKFLOW_REGISTRY as t };
1334
+ export { AGENT_SKILL_STEPS as a, fetchHealthIssues as i, getWorkflowConfig as n, POSTHOG_SDKS as o, getKindMeta as r, STRIPE_SDKS as s, WORKFLOW_REGISTRY as t };
848
1335
 
849
1336
  //# sourceMappingURL=bin.js.map