@posthog/wizard 2.10.3 → 2.11.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 (81) hide show
  1. package/dist/{McpScreen-23GY1pWz.js → McpScreen-DvUncZBi.js} +153 -23
  2. package/dist/McpScreen-DvUncZBi.js.map +1 -0
  3. package/dist/{add-mcp-server-to-clients-B6baHy_h.js → add-mcp-server-to-clients-Br1hDRiB.js} +157 -125
  4. package/dist/add-mcp-server-to-clients-Br1hDRiB.js.map +1 -0
  5. package/dist/{agent-runner-CBPBefLt.js → agent-runner-fWYFO4H0.js} +11 -9
  6. package/dist/agent-runner-fWYFO4H0.js.map +1 -0
  7. package/dist/{agent-skill-BVjJqol6.js → agent-skill-DJOzDaQV.js} +1 -1
  8. package/dist/{agent-skill-BVjJqol6.js.map → agent-skill-DJOzDaQV.js.map} +1 -1
  9. package/dist/analytics-CfAUlt6-.js +2 -0
  10. package/dist/{analytics-xANpxdVL.js → analytics-D3rY3TaN.js} +7 -4
  11. package/dist/analytics-D3rY3TaN.js.map +1 -0
  12. package/dist/bin.js +234 -41
  13. package/dist/bin.js.map +1 -1
  14. package/dist/{debug-CIyf0ZGx.js → debug-D-0xueVl.js} +1 -1
  15. package/dist/{debug-CyJ_3dTP.js → debug-gWEjmYVV.js} +4 -2
  16. package/dist/{debug-CyJ_3dTP.js.map → debug-gWEjmYVV.js.map} +1 -1
  17. package/dist/{defaults-DoVkE0gW.js → defaults-CPH6eWhN.js} +8 -8
  18. package/dist/defaults-CPH6eWhN.js.map +1 -0
  19. package/dist/{detection-Drfq0l8n.js → detection-B7GNzve-.js} +103 -19
  20. package/dist/detection-B7GNzve-.js.map +1 -0
  21. package/dist/{env-api-key-K8TdTDII.js → env-api-key-DU8uIEvo.js} +1 -1
  22. package/dist/{env-api-key-K8TdTDII.js.map → env-api-key-DU8uIEvo.js.map} +1 -1
  23. package/dist/file-DhSBlq-x.js +16 -0
  24. package/dist/file-DhSBlq-x.js.map +1 -0
  25. package/dist/{file-utils-BWneZy6p.js → file-utils-Dy9JncCo.js} +1 -1
  26. package/dist/{file-utils-BWneZy6p.js.map → file-utils-Dy9JncCo.js.map} +1 -1
  27. package/dist/package-json-BzVey4Bd.js +2 -0
  28. package/dist/{package-json-Ctq6LSl8.js → package-json-F_7oktsp.js} +1 -1
  29. package/dist/{package-json-Ctq6LSl8.js.map → package-json-F_7oktsp.js.map} +1 -1
  30. package/dist/{package-manager-Ls_8r9Ot.js → package-manager-D3Lo6nXf.js} +2 -2
  31. package/dist/{package-manager-Ls_8r9Ot.js.map → package-manager-D3Lo6nXf.js.map} +1 -1
  32. package/dist/paths-BL-x2rFy.js +16 -0
  33. package/dist/paths-BL-x2rFy.js.map +1 -0
  34. package/dist/posthog-ByrpqEjN.js +11 -0
  35. package/dist/posthog-ByrpqEjN.js.map +1 -0
  36. package/dist/{posthog-integration-DUZpiyxg.js → posthog-integration-D4SRhJIQ.js} +10 -9
  37. package/dist/posthog-integration-D4SRhJIQ.js.map +1 -0
  38. package/dist/{readiness-BAgN8xAg.js → readiness-gQvQNCeL.js} +10 -10
  39. package/dist/readiness-gQvQNCeL.js.map +1 -0
  40. package/dist/{registry-qfhSxTjo.js → registry-DaPKstG3.js} +6 -6
  41. package/dist/{registry-qfhSxTjo.js.map → registry-DaPKstG3.js.map} +1 -1
  42. package/dist/{router-D5A1Sb4p.js → router-SgzmfLGi.js} +11 -18
  43. package/dist/router-SgzmfLGi.js.map +1 -0
  44. package/dist/setup-utils-_ONxN-TT.js +2 -0
  45. package/dist/{setup-utils-C1h1QDiG.js → setup-utils-y4s-3uKT.js} +13 -7
  46. package/dist/setup-utils-y4s-3uKT.js.map +1 -0
  47. package/dist/{start-playground-xOLMYzst.js → start-playground-g1TxpCZ5.js} +84 -7
  48. package/dist/start-playground-g1TxpCZ5.js.map +1 -0
  49. package/dist/{start-tui-Ddo4TI9T.js → start-tui-CQef69NR.js} +305 -23
  50. package/dist/start-tui-CQef69NR.js.map +1 -0
  51. package/dist/{steps-BjvFG--8.js → steps-D1zKDqAo.js} +6 -6
  52. package/dist/{steps-BjvFG--8.js.map → steps-D1zKDqAo.js.map} +1 -1
  53. package/dist/task-stream-DX_jKDQu.js +61 -0
  54. package/dist/task-stream-DX_jKDQu.js.map +1 -0
  55. package/dist/{telemetry-CC6zPKJg.js → telemetry-CyUUSAYy.js} +2 -2
  56. package/dist/{telemetry-CC6zPKJg.js.map → telemetry-CyUUSAYy.js.map} +1 -1
  57. package/dist/{wizard-abort-XhapT0Ly.js → wizard-abort-Buodno3f.js} +3 -3
  58. package/dist/{wizard-abort-XhapT0Ly.js.map → wizard-abort-Buodno3f.js.map} +1 -1
  59. package/dist/{wizard-abort-Bc3lWNLb.js → wizard-abort-DZmO_sIZ.js} +1 -1
  60. package/dist/wizard-session-COhklXAF.js +2 -0
  61. package/dist/{wizard-session-Db6R023m.js → wizard-session-D5bggSsu.js} +1 -1
  62. package/dist/{wizard-session-Db6R023m.js.map → wizard-session-D5bggSsu.js.map} +1 -1
  63. package/dist/wizard-ui-BExOjdjA.js +14 -0
  64. package/dist/wizard-ui-BExOjdjA.js.map +1 -0
  65. package/npm-shrinkwrap.json +2 -2
  66. package/package.json +1 -1
  67. package/dist/McpScreen-23GY1pWz.js.map +0 -1
  68. package/dist/add-mcp-server-to-clients-B6baHy_h.js.map +0 -1
  69. package/dist/agent-runner-CBPBefLt.js.map +0 -1
  70. package/dist/analytics-DdTDVjqs.js +0 -2
  71. package/dist/analytics-xANpxdVL.js.map +0 -1
  72. package/dist/defaults-DoVkE0gW.js.map +0 -1
  73. package/dist/detection-Drfq0l8n.js.map +0 -1
  74. package/dist/package-json-BQgl5C3Z.js +0 -2
  75. package/dist/posthog-integration-DUZpiyxg.js.map +0 -1
  76. package/dist/readiness-BAgN8xAg.js.map +0 -1
  77. package/dist/router-D5A1Sb4p.js.map +0 -1
  78. package/dist/setup-utils-C1h1QDiG.js.map +0 -1
  79. package/dist/start-playground-xOLMYzst.js.map +0 -1
  80. package/dist/start-tui-Ddo4TI9T.js.map +0 -1
  81. package/dist/wizard-session-y7nf6aKH.js +0 -2
package/dist/bin.js CHANGED
@@ -1,16 +1,18 @@
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-CyJ_3dTP.js";
4
- import { T as VERSION } from "./analytics-xANpxdVL.js";
5
- import "./setup-utils-C1h1QDiG.js";
6
- import { t as posthogIntegrationConfig } from "./posthog-integration-DUZpiyxg.js";
7
- import { t as IGNORED_DIRS } from "./file-utils-BWneZy6p.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";
8
8
  import { satisfies } from "semver";
9
9
  import yargs from "yargs";
10
10
  import { hideBin } from "yargs/helpers";
11
11
  import readEnvModule from "read-env";
12
12
  import { existsSync, readFileSync, readdirSync, statSync } from "fs";
13
13
  import { join, relative } from "path";
14
+ import axios from "axios";
15
+ import { z } from "zod";
14
16
  import "fast-glob";
15
17
  //#region src/utils/environment.ts
16
18
  var environment_exports = /* @__PURE__ */ __exportAll({
@@ -160,8 +162,8 @@ function detectRevenuePrerequisites(session, setFrameworkContext) {
160
162
  setFrameworkContext("detectedPackagePaths", matches.filter((m) => m.posthogSdks.length > 0 || m.stripeSdks.length > 0).map((m) => m.path));
161
163
  }
162
164
  //#endregion
163
- //#region src/lib/workflows/workflow-registry.ts
164
- const WORKFLOW_REGISTRY = [posthogIntegrationConfig, {
165
+ //#region src/lib/workflows/revenue-analytics/index.ts
166
+ const revenueAnalyticsConfig = {
165
167
  command: "revenue",
166
168
  description: "Set up PostHog revenue analytics (e.g. Stripe integration)",
167
169
  flowKey: "revenue-analytics-setup",
@@ -213,7 +215,162 @@ const WORKFLOW_REGISTRY = [posthogIntegrationConfig, {
213
215
  abortCases: REVENUE_ABORT_CASES
214
216
  },
215
217
  requires: ["posthog-integration"]
216
- }];
218
+ };
219
+ //#endregion
220
+ //#region src/lib/workflows/posthog-doctor/steps.ts
221
+ const POSTHOG_DOCTOR_WORKFLOW = [
222
+ {
223
+ id: "intro",
224
+ label: "Welcome",
225
+ screen: "doctor-intro",
226
+ gate: (session) => session.setupConfirmed
227
+ },
228
+ {
229
+ id: "auth",
230
+ label: "Authentication",
231
+ screen: "auth",
232
+ isComplete: (session) => session.credentials !== null
233
+ },
234
+ {
235
+ id: "report",
236
+ label: "Doctor report",
237
+ screen: "doctor-report",
238
+ isComplete: (session) => session.outroData !== null
239
+ },
240
+ {
241
+ id: "outro",
242
+ label: "Done",
243
+ screen: "outro",
244
+ isComplete: (session) => session.outroDismissed
245
+ }
246
+ ];
247
+ //#endregion
248
+ //#region src/lib/workflows/posthog-doctor/types.ts
249
+ const HealthIssueSeveritySchema = z.enum([
250
+ "critical",
251
+ "warning",
252
+ "info"
253
+ ]);
254
+ const HealthIssueStatusSchema = z.enum(["active", "resolved"]);
255
+ const HealthIssueSchema = z.object({
256
+ id: z.string(),
257
+ kind: z.string(),
258
+ severity: HealthIssueSeveritySchema,
259
+ status: HealthIssueStatusSchema,
260
+ dismissed: z.boolean(),
261
+ created_at: z.string(),
262
+ updated_at: z.string(),
263
+ resolved_at: z.string().nullable().optional()
264
+ });
265
+ const HealthIssueListResponseSchema = z.object({
266
+ results: z.array(HealthIssueSchema),
267
+ count: z.number().optional(),
268
+ next: z.string().nullable().optional(),
269
+ previous: z.string().nullable().optional()
270
+ });
271
+ //#endregion
272
+ //#region src/lib/workflows/posthog-doctor/fetch.ts
273
+ async function fetchHealthIssues(accessToken, baseUrl, projectId) {
274
+ const endpoint = `/api/environments/${projectId}/health_issues/`;
275
+ const url = `${baseUrl}${endpoint}?status=active&dismissed=false&limit=250`;
276
+ try {
277
+ const response = await axios.get(url, { headers: {
278
+ Authorization: `Bearer ${accessToken}`,
279
+ "User-Agent": WIZARD_USER_AGENT
280
+ } });
281
+ return HealthIssueListResponseSchema.parse(response.data).results;
282
+ } catch (error) {
283
+ const apiError = handleApiError(error, "fetch health issues");
284
+ analytics.captureException(apiError, {
285
+ endpoint,
286
+ baseUrl,
287
+ projectId
288
+ });
289
+ throw apiError;
290
+ }
291
+ }
292
+ //#endregion
293
+ //#region src/lib/workflows/posthog-doctor/kind-metadata.ts
294
+ const KIND_METADATA = {
295
+ ingestion_lag: {
296
+ title: "Ingestion is delayed",
297
+ description: "Events are being received but are taking longer than usual to appear.",
298
+ docsUrl: `${POSTHOG_DOCS_URL}/support/troubleshooting`
299
+ },
300
+ ingestion_warning: {
301
+ title: "Ingestion warnings on recent events",
302
+ description: "Some recent events were rejected or flagged by the ingestion pipeline.",
303
+ docsUrl: `${POSTHOG_DOCS_URL}/support/troubleshooting`
304
+ },
305
+ sdk_outdated: {
306
+ title: "SDK version is out of date",
307
+ description: "One or more SDKs are running an old version. Upgrade to get the latest fixes.",
308
+ docsUrl: `${POSTHOG_DOCS_URL}/libraries`
309
+ },
310
+ no_live_events: {
311
+ title: "No $pageview or $screen events in the last 30 days",
312
+ description: "PostHog is not receiving page or screen events from this project.",
313
+ docsUrl: `${POSTHOG_DOCS_URL}/getting-started/install`
314
+ },
315
+ no_pageleave_events: {
316
+ title: "$pageleave events not being sent",
317
+ description: "Enable pageleave tracking to power bounce rate and session duration.",
318
+ docsUrl: `${POSTHOG_DOCS_URL}/libraries/js#config`
319
+ },
320
+ scroll_depth: {
321
+ title: "Scroll depth tracking disabled",
322
+ description: "Turn on scroll depth to capture how far users read each page.",
323
+ docsUrl: `${POSTHOG_DOCS_URL}/libraries/js#config`
324
+ },
325
+ authorized_urls: {
326
+ title: "No authorized URLs configured",
327
+ description: "Some web analytics filters require at least one authorized URL to work.",
328
+ docsUrl: `${POSTHOG_DOCS_URL}/web-analytics/faq`
329
+ },
330
+ reverse_proxy: {
331
+ title: "No reverse proxy detected",
332
+ description: "A reverse proxy reduces data loss from ad blockers.",
333
+ docsUrl: `${POSTHOG_DOCS_URL}/advanced/proxy`
334
+ },
335
+ web_vitals: {
336
+ title: "Web Vitals tracking disabled",
337
+ description: "Enable Web Vitals to capture LCP, CLS and other performance metrics.",
338
+ docsUrl: `${POSTHOG_DOCS_URL}/web-analytics/web-vitals`
339
+ },
340
+ materialized_view_failure: {
341
+ title: "A materialized view is failing",
342
+ description: "A data modeling pipeline failed its most recent run.",
343
+ docsUrl: `${POSTHOG_DOCS_URL}/data-warehouse`
344
+ },
345
+ external_data_failure: {
346
+ title: "External data source is failing",
347
+ description: "An external data source sync failed and data may be stale.",
348
+ docsUrl: `${POSTHOG_DOCS_URL}/data-warehouse/sources`
349
+ }
350
+ };
351
+ const UNKNOWN_KIND_META = {
352
+ title: "Unknown issue",
353
+ description: "PostHog reported an issue kind the wizard does not yet recognize.",
354
+ docsUrl: POSTHOG_DOCS_URL
355
+ };
356
+ function getKindMeta(kind) {
357
+ return KIND_METADATA[kind] ?? {
358
+ ...UNKNOWN_KIND_META,
359
+ title: kind
360
+ };
361
+ }
362
+ //#endregion
363
+ //#region src/lib/workflows/workflow-registry.ts
364
+ const WORKFLOW_REGISTRY = [
365
+ posthogIntegrationConfig,
366
+ revenueAnalyticsConfig,
367
+ {
368
+ command: "doctor",
369
+ description: "Diagnose your PostHog project for configuration issues and setup warnings",
370
+ flowKey: "posthog-doctor",
371
+ steps: POSTHOG_DOCTOR_WORKFLOW
372
+ }
373
+ ];
217
374
  /** All workflow configs that are exposed as CLI subcommands. */
218
375
  function getSubcommandWorkflows() {
219
376
  return WORKFLOW_REGISTRY.filter((c) => c.command != null);
@@ -366,11 +523,11 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
366
523
  return;
367
524
  }
368
525
  (async () => {
369
- const { posthogIntegrationConfig } = await import("./posthog-integration-DUZpiyxg.js").then((n) => n.n);
370
- const { FRAMEWORK_REGISTRY } = await import("./registry-qfhSxTjo.js").then((n) => n.n);
371
- const { detectFramework, gatherFrameworkContext } = await import("./detection-Drfq0l8n.js").then((n) => n.t);
372
- const { analytics } = await import("./analytics-DdTDVjqs.js");
373
- const { wizardAbort } = await import("./wizard-abort-Bc3lWNLb.js");
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");
374
531
  runWizardCI(posthogIntegrationConfig, options, async (session) => {
375
532
  const integration = session.integration ?? await detectFramework(session.installDir);
376
533
  if (!integration) {
@@ -403,11 +560,11 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
403
560
  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");
404
561
  process.exit(1);
405
562
  } else if (options.playground) (async () => {
406
- const { startPlayground } = await import("./start-playground-xOLMYzst.js");
563
+ const { startPlayground } = await import("./start-playground-g1TxpCZ5.js");
407
564
  startPlayground(WIZARD_VERSION);
408
565
  })();
409
566
  else if (options.skill) (async () => {
410
- const { createSkillWorkflow } = await import("./agent-skill-BVjJqol6.js").then((n) => n.t);
567
+ const { createSkillWorkflow } = await import("./agent-skill-DJOzDaQV.js").then((n) => n.t);
411
568
  const skillId = options.skill;
412
569
  runWizard(createSkillWorkflow({
413
570
  skillId,
@@ -417,13 +574,16 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
417
574
  integrationLabel: skillId,
418
575
  successMessage: `${skillId} completed!`,
419
576
  reportFile: `posthog-${skillId}-report.md`,
420
- docsUrl: "https://posthog.com/docs",
577
+ docsUrl: POSTHOG_DOCS_URL,
421
578
  spinnerMessage: `Running ${skillId}...`,
422
579
  estimatedDurationMinutes: 5
423
- }), options);
580
+ }), {
581
+ ...options,
582
+ skillId
583
+ });
424
584
  })();
425
585
  else (async () => {
426
- const { posthogIntegrationConfig } = await import("./posthog-integration-DUZpiyxg.js").then((n) => n.n);
586
+ const { posthogIntegrationConfig } = await import("./posthog-integration-D4SRhJIQ.js").then((n) => n.n);
427
587
  runWizard(posthogIntegrationConfig, options);
428
588
  })();
429
589
  }).command("mcp <command>", "MCP server management commands", (yargs) => {
@@ -447,12 +607,12 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
447
607
  const options = { ...argv };
448
608
  const mcpFeatures = options.features?.split(",").map((s) => s.trim()).filter(Boolean);
449
609
  (async () => {
450
- const { readApiKeyFromEnv } = await import("./env-api-key-K8TdTDII.js");
610
+ const { readApiKeyFromEnv } = await import("./env-api-key-DU8uIEvo.js");
451
611
  const apiKey = options.apiKey || readApiKeyFromEnv();
452
612
  try {
453
- const { startTUI } = await import("./start-tui-Ddo4TI9T.js");
454
- const { buildSession } = await import("./wizard-session-y7nf6aKH.js");
455
- const { Flow } = await import("./router-D5A1Sb4p.js").then((n) => n.n);
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);
456
616
  const tui = startTUI(WIZARD_VERSION, Flow.McpAdd);
457
617
  const session = buildSession({
458
618
  debug: options.debug,
@@ -463,7 +623,7 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
463
623
  tui.store.session = session;
464
624
  } catch {
465
625
  setUI(new LoggingUI());
466
- const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-B6baHy_h.js").then((n) => n.r);
626
+ const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-Br1hDRiB.js").then((n) => n.r);
467
627
  await addMCPServerToClientsStep({
468
628
  local: options.local,
469
629
  features: mcpFeatures,
@@ -481,9 +641,9 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
481
641
  const options = { ...argv };
482
642
  (async () => {
483
643
  try {
484
- const { startTUI } = await import("./start-tui-Ddo4TI9T.js");
485
- const { buildSession } = await import("./wizard-session-y7nf6aKH.js");
486
- const { Flow } = await import("./router-D5A1Sb4p.js").then((n) => n.n);
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);
487
647
  const tui = startTUI(WIZARD_VERSION, Flow.McpRemove);
488
648
  const session = buildSession({
489
649
  debug: options.debug,
@@ -492,7 +652,7 @@ const cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options({
492
652
  tui.store.session = session;
493
653
  } catch {
494
654
  setUI(new LoggingUI());
495
- const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-B6baHy_h.js").then((n) => n.r);
655
+ const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-Br1hDRiB.js").then((n) => n.r);
496
656
  await removeMCPServerFromClientsStep({ local: options.local });
497
657
  }
498
658
  })();
@@ -513,8 +673,12 @@ function runWizard(config, options) {
513
673
  (async () => {
514
674
  try {
515
675
  const installDir = options.installDir || process.cwd();
516
- const { startTUI } = await import("./start-tui-Ddo4TI9T.js");
517
- const { buildSession } = await import("./wizard-session-y7nf6aKH.js");
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");
518
682
  const tui = startTUI(WIZARD_VERSION, config.flowKey);
519
683
  const session = buildSession({
520
684
  debug: options.debug,
@@ -532,24 +696,54 @@ function runWizard(config, options) {
532
696
  yaraReport: options.yaraReport
533
697
  });
534
698
  session.workflowLabel = config.flowKey;
535
- session.skillId = (typeof config.run === "object" ? config.run : null)?.skillId ?? null;
699
+ if (options.skillId) session.skillId = options.skillId;
536
700
  tui.store.session = session;
701
+ const taskStream = new TaskStreamPush({
702
+ store: tui.store,
703
+ workflowId: config.flowKey,
704
+ destinations: [new FileDestination(), new PostHogDestination()]
705
+ });
706
+ tui.store.onTasksChanged = () => void taskStream.push();
537
707
  await tui.store.runReadyHooks();
538
708
  await tui.store.getGate("intro");
539
- const { runAgent } = await import("./agent-runner-CBPBefLt.js");
540
- await runAgent(config, tui.store.session);
709
+ const skipAgent = config.run == null;
710
+ if (skipAgent) {
711
+ const { getOrAskForProjectData } = await import("./setup-utils-_ONxN-TT.js");
712
+ const { projectApiKey, host, accessToken, projectId } = await getOrAskForProjectData({
713
+ signup: session.signup,
714
+ ci: session.ci,
715
+ apiKey: session.apiKey,
716
+ projectId: session.projectId
717
+ });
718
+ tui.store.setCredentials({
719
+ accessToken,
720
+ projectApiKey,
721
+ host,
722
+ projectId
723
+ });
724
+ } else {
725
+ const { runAgent } = await import("./agent-runner-fWYFO4H0.js");
726
+ await runAgent(config, tui.store.session);
727
+ }
728
+ const isDone = () => skipAgent ? tui.store.session.outroDismissed : tui.store.session.skillsComplete;
541
729
  await new Promise((resolve) => {
542
730
  const unsub = tui.store.subscribe(() => {
543
- if (tui.store.session.skillsComplete) {
731
+ if (isDone()) {
544
732
  unsub();
545
733
  resolve();
546
734
  }
547
735
  });
548
- if (tui.store.session.skillsComplete) {
736
+ if (isDone()) {
549
737
  unsub();
550
738
  resolve();
551
739
  }
552
740
  });
741
+ try {
742
+ await taskStream.dispose();
743
+ } catch (error) {
744
+ analytics.captureException(error);
745
+ }
746
+ tui.unmount();
553
747
  process.exit(0);
554
748
  } catch (err) {
555
749
  if (runtimeEnv("DEBUG") || runtimeEnv("POSTHOG_WIZARD_DEBUG")) console.error("TUI init failed:", err);
@@ -579,11 +773,11 @@ function runWizardCI(config, options, preRun) {
579
773
  }
580
774
  (async () => {
581
775
  const path = await import("path");
582
- const { buildSession } = await import("./wizard-session-y7nf6aKH.js");
776
+ const { buildSession } = await import("./wizard-session-COhklXAF.js");
583
777
  const { readEnvironment } = await Promise.resolve().then(() => environment_exports);
584
- const { readApiKeyFromEnv } = await import("./env-api-key-K8TdTDII.js");
585
- const { configureLogFileFromEnvironment, logToFile } = await import("./debug-CIyf0ZGx.js");
586
- const { wizardAbort, WizardError } = await import("./wizard-abort-Bc3lWNLb.js");
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");
587
781
  configureLogFileFromEnvironment();
588
782
  const env = readEnvironment();
589
783
  const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? void 0;
@@ -606,7 +800,6 @@ function runWizardCI(config, options, preRun) {
606
800
  });
607
801
  session.workflowLabel = config.flowKey;
608
802
  const runDef = typeof config.run === "object" ? config.run : null;
609
- session.skillId = runDef?.skillId ?? null;
610
803
  getUI().intro("Welcome to the PostHog setup wizard");
611
804
  getUI().log.info(`Running ${config.flowKey} in CI mode`);
612
805
  try {
@@ -633,7 +826,7 @@ function runWizardCI(config, options, preRun) {
633
826
  })
634
827
  });
635
828
  }
636
- const { runAgent } = await import("./agent-runner-CBPBefLt.js");
829
+ const { runAgent } = await import("./agent-runner-fWYFO4H0.js");
637
830
  await runAgent(config, session);
638
831
  } catch (error) {
639
832
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -651,6 +844,6 @@ function runWizardCI(config, options, preRun) {
651
844
  });
652
845
  }
653
846
  //#endregion
654
- export { POSTHOG_SDKS as n, STRIPE_SDKS as r, WORKFLOW_REGISTRY as t };
847
+ export { STRIPE_SDKS as a, POSTHOG_SDKS as i, getKindMeta as n, fetchHealthIssues as r, WORKFLOW_REGISTRY as t };
655
848
 
656
849
  //# sourceMappingURL=bin.js.map