@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
@@ -1,17 +1,211 @@
1
- import { t as __exportAll } from "./rolldown-runtime-B_-DWIq7.js";
2
- import { p as getUI, z as WIZARD_INTERACTION_EVENT_NAME } from "./debug-C4jRuzny.js";
3
- import { n as analytics } from "./analytics-DZaUgJte.js";
4
- import { a as isUsingTypeScript, f as getCloudUrlFromRegion, o as tryGetPackageJson } from "./setup-utils-DdAdxUTV.js";
5
- import { n as requestDeepLink } from "./provisioning-C_ETLiZE.js";
6
- import "./wizard-session-Bi95IYca.js";
7
- import { t as AgentSignals, u as WIZARD_TOOL_NAMES } from "./agent-interface-pBnqJL8P.js";
8
- import { i as SPINNER_MESSAGE, t as FRAMEWORK_REGISTRY } from "./registry-DqbwO5EL.js";
9
- import { c as HEALTH_CHECK_STEP, o as Colors } from "./TextBlock-DJVhBkr3.js";
10
- import { a as detectFramework, i as discoverFeatures, n as checkFrameworkVersion, r as gatherFrameworkContext } from "./detection-4eukp9HD.js";
1
+ import { O as Integration, T as DETECTION_TIMEOUT_MS, p as getUI, z as WIZARD_INTERACTION_EVENT_NAME } from "./debug-Bx7nvCWW.js";
2
+ import { t as analytics } from "./analytics-DN_Gy87F.js";
3
+ import { i as tryGetPackageJson, n as isUsingTypeScript } from "./setup-utils-Bpfsap9L.js";
4
+ import { n as getCloudUrlFromRegion } from "./urls-CTCJIxbR.js";
5
+ import { r as requestDeepLink } from "./provisioning-C96Kw-9D.js";
6
+ import "./wizard-session-d27JGRGi.js";
7
+ import { r as wizardAbort } from "./wizard-abort-CY0ibdq1.js";
8
+ import { d as WIZARD_TOOL_NAMES, t as AgentSignals } from "./agent-interface-7t5DBo2A.js";
9
+ import { i as SPINNER_MESSAGE, t as FRAMEWORK_REGISTRY } from "./registry-B9k73FKR.js";
10
+ import { c as HEALTH_CHECK_STEP, o as Colors } from "./TextBlock-D0Ep3zC9.js";
11
+ import * as semver from "semver";
12
+ import { readFileSync } from "fs";
13
+ import { join } from "path";
11
14
  import opn from "opn";
12
15
  import { Text } from "ink";
13
16
  import { useEffect } from "react";
14
17
  import { jsx, jsxs } from "react/jsx-runtime";
18
+ //#region src/lib/detection/framework.ts
19
+ /**
20
+ * Framework detection — identify which PostHog-supported framework
21
+ * is present in the project directory.
22
+ *
23
+ * Pure function: takes an install dir, returns the detected integration
24
+ * (or undefined). No store mutations, no UI calls.
25
+ */
26
+ /**
27
+ * Loop through all registered frameworks and return the first one
28
+ * whose `detect()` predicate matches the given directory.
29
+ * Returns undefined if no framework is detected or detection times out.
30
+ */
31
+ async function detectFramework(installDir) {
32
+ for (const integration of Object.values(Integration)) {
33
+ const config = FRAMEWORK_REGISTRY[integration];
34
+ try {
35
+ if (await Promise.race([config.detection.detect({ installDir }), new Promise((resolve) => setTimeout(() => resolve(false), 1e4))])) return integration;
36
+ } catch {}
37
+ }
38
+ }
39
+ //#endregion
40
+ //#region src/lib/detection/features.ts
41
+ /**
42
+ * Feature discovery — scan project dependencies for known SDK patterns
43
+ * that indicate additional PostHog programs are relevant.
44
+ *
45
+ * Pure function: takes an install dir, returns a set of discovered features.
46
+ * No store mutations, no UI calls.
47
+ */
48
+ const STRIPE_PACKAGES = ["stripe", "@stripe/stripe-js"];
49
+ const LLM_PACKAGES = [
50
+ "openai",
51
+ "@anthropic-ai/sdk",
52
+ "ai",
53
+ "@ai-sdk/openai",
54
+ "langchain",
55
+ "@langchain/openai",
56
+ "@langchain/langgraph",
57
+ "@google/generative-ai",
58
+ "@google/genai",
59
+ "@instructor-ai/instructor",
60
+ "@mastra/core",
61
+ "portkey-ai"
62
+ ];
63
+ const PYTHON_LLM_PACKAGES = [
64
+ "openai",
65
+ "anthropic",
66
+ "langchain",
67
+ "langchain-openai",
68
+ "langchain-anthropic",
69
+ "langchain-google-genai",
70
+ "langgraph",
71
+ "litellm",
72
+ "llama-index",
73
+ "pydantic-ai",
74
+ "crewai",
75
+ "instructor",
76
+ "dspy-ai",
77
+ "mistralai",
78
+ "cohere",
79
+ "google-generativeai",
80
+ "google-genai",
81
+ "portkey-ai"
82
+ ];
83
+ function discoverFeatures(installDir) {
84
+ const features = [];
85
+ discoverNodeFeatures(installDir, features);
86
+ discoverPythonFeatures(installDir, features);
87
+ return features;
88
+ }
89
+ function discoverNodeFeatures(installDir, features) {
90
+ const packageJsonText = safeRead(installDir, "package.json");
91
+ if (!packageJsonText) return;
92
+ let packageJson;
93
+ try {
94
+ packageJson = JSON.parse(packageJsonText);
95
+ } catch {
96
+ return;
97
+ }
98
+ const depNames = Object.keys({
99
+ ...packageJson.dependencies,
100
+ ...packageJson.devDependencies
101
+ });
102
+ if (depNames.some((depName) => STRIPE_PACKAGES.includes(depName))) features.push("stripe");
103
+ if (depNames.some((depName) => LLM_PACKAGES.includes(depName))) features.push("llm");
104
+ }
105
+ function discoverPythonFeatures(installDir, features) {
106
+ if (features.includes("llm")) return;
107
+ const depNames = [];
108
+ const requirementsTxt = safeRead(installDir, "requirements.txt");
109
+ if (requirementsTxt) depNames.push(...parseRequirementsTxt(requirementsTxt));
110
+ const pyprojectToml = safeRead(installDir, "pyproject.toml");
111
+ if (pyprojectToml) depNames.push(...parsePyprojectToml(pyprojectToml));
112
+ const pipfile = safeRead(installDir, "Pipfile");
113
+ if (pipfile) depNames.push(...parsePipfile(pipfile));
114
+ if (depNames.some((depName) => PYTHON_LLM_PACKAGES.includes(depName))) features.push("llm");
115
+ }
116
+ function safeRead(installDir, file) {
117
+ try {
118
+ return readFileSync(join(installDir, file), "utf-8");
119
+ } catch {
120
+ return null;
121
+ }
122
+ }
123
+ function normalizePyName(name) {
124
+ return name.toLowerCase().replace(/_/g, "-");
125
+ }
126
+ function parseRequirementsTxt(content) {
127
+ return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#") && !line.startsWith("-")).map((line) => line.replace(/\[[^\]]*\]/, "")).map((line) => line.split(/[<>=!~;\s]/)[0]).filter(Boolean).map(normalizePyName);
128
+ }
129
+ function parsePyprojectToml(content) {
130
+ const depNames = [];
131
+ for (const arrayMatch of content.matchAll(/dependencies\s*=\s*\[([^\]]*)\]/g)) {
132
+ const arrayBody = arrayMatch[1];
133
+ for (const quotedMatch of arrayBody.matchAll(/["']([^"']+)["']/g)) {
134
+ const name = quotedMatch[1].replace(/\[[^\]]*\]/, "").split(/[<>=!~;\s]/)[0];
135
+ if (name) depNames.push(normalizePyName(name));
136
+ }
137
+ }
138
+ for (const sectionMatch of content.matchAll(/\[tool\.poetry\.(?:dev-dependencies|dependencies|group\.[^.\]]+\.dependencies)\]([\s\S]*?)(?=\n\[|$)/g)) {
139
+ const sectionBody = sectionMatch[1];
140
+ depNames.push(...extractTomlSectionKeys(sectionBody, { skip: ["python"] }));
141
+ }
142
+ return depNames;
143
+ }
144
+ function parsePipfile(content) {
145
+ const depNames = [];
146
+ for (const sectionMatch of content.matchAll(/\[(packages|dev-packages)\]([\s\S]*?)(?=\n\[|$)/g)) {
147
+ const sectionBody = sectionMatch[2];
148
+ depNames.push(...extractTomlSectionKeys(sectionBody));
149
+ }
150
+ return depNames;
151
+ }
152
+ function extractTomlSectionKeys(sectionBody, opts = {}) {
153
+ const skipNames = new Set(opts.skip ?? []);
154
+ const depNames = [];
155
+ for (const line of sectionBody.split("\n")) {
156
+ const trimmed = line.trim();
157
+ if (!trimmed || trimmed.startsWith("#")) continue;
158
+ const equalsIndex = trimmed.indexOf("=");
159
+ if (equalsIndex <= 0) continue;
160
+ const name = trimmed.slice(0, equalsIndex).trim();
161
+ if (!/^[a-zA-Z0-9._-]+$/.test(name)) continue;
162
+ if (skipNames.has(name.toLowerCase())) continue;
163
+ depNames.push(normalizePyName(name));
164
+ }
165
+ return depNames;
166
+ }
167
+ //#endregion
168
+ //#region src/lib/detection/context.ts
169
+ /**
170
+ * Framework context gathering — run gatherContext and version checks
171
+ * for a detected framework.
172
+ *
173
+ * Pure functions: take a framework config and options, return results.
174
+ * No store mutations, no UI calls.
175
+ */
176
+ /**
177
+ * Run a framework's `gatherContext()` to collect variant-specific
178
+ * metadata (e.g., router type for Next.js, Expo vs bare for React Native).
179
+ *
180
+ * Returns the gathered context, or an empty object on failure/timeout.
181
+ */
182
+ async function gatherFrameworkContext(config, options) {
183
+ if (!config.metadata.gatherContext) return {};
184
+ try {
185
+ return await Promise.race([config.metadata.gatherContext(options), new Promise((resolve) => setTimeout(() => resolve({}), DETECTION_TIMEOUT_MS))]);
186
+ } catch {
187
+ return {};
188
+ }
189
+ }
190
+ /**
191
+ * Check whether the installed framework version meets the minimum requirement.
192
+ *
193
+ * Returns `{ supported: true }` if the version is fine (or no check is needed).
194
+ * Returns the version details if unsupported.
195
+ */
196
+ async function checkFrameworkVersion(config, options) {
197
+ if (!config.detection.minimumVersion || !config.detection.getInstalledVersion) return { supported: true };
198
+ const version = await config.detection.getInstalledVersion(options);
199
+ if (!version) return { supported: true };
200
+ const coerced = semver.coerce(version);
201
+ if (coerced && semver.lt(coerced, config.detection.minimumVersion)) return { supported: {
202
+ current: version,
203
+ minimum: config.detection.minimumVersion,
204
+ docsUrl: config.metadata.unsupportedVersionDocsUrl ?? config.metadata.docsUrl
205
+ } };
206
+ return { supported: true };
207
+ }
208
+ //#endregion
15
209
  //#region src/lib/programs/posthog-integration/detect.ts
16
210
  async function detectPostHogIntegration(ctx) {
17
211
  const session = ctx.session;
@@ -22,12 +216,10 @@ async function detectPostHogIntegration(ctx) {
22
216
  const sessionOptions = {
23
217
  installDir,
24
218
  debug: session.debug,
25
- forceInstall: session.forceInstall,
26
219
  default: false,
27
220
  signup: session.signup,
28
221
  localMcp: session.localMcp,
29
222
  ci: session.ci,
30
- menu: session.menu,
31
223
  benchmark: session.benchmark,
32
224
  yaraReport: session.yaraReport
33
225
  };
@@ -848,11 +1040,6 @@ const getContentBlocks = (store) => [
848
1040
  ];
849
1041
  //#endregion
850
1042
  //#region src/lib/programs/posthog-integration/index.ts
851
- var posthog_integration_exports = /* @__PURE__ */ __exportAll({
852
- EVENT_PLAN_FILE: () => EVENT_PLAN_FILE,
853
- SETUP_REPORT_FILE: () => SETUP_REPORT_FILE,
854
- posthogIntegrationConfig: () => posthogIntegrationConfig
855
- });
856
1043
  const DASHBOARD_DEEP_LINK_KEY = "dashboardDeepLink";
857
1044
  function resolveContinueUrl(sess, cloudRegion, deepLink) {
858
1045
  if (!sess.signup) return void 0;
@@ -868,6 +1055,28 @@ const posthogIntegrationConfig = {
868
1055
  steps: POSTHOG_INTEGRATION_PROGRAM,
869
1056
  getContentBlocks,
870
1057
  disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],
1058
+ ciPreRun: async (session) => {
1059
+ const integration = await detectFramework(session.installDir);
1060
+ if (!integration) {
1061
+ await wizardAbort({ message: "Could not auto-detect your framework for this project." });
1062
+ return;
1063
+ }
1064
+ session.integration = integration;
1065
+ analytics.setTag("integration", integration);
1066
+ const frameworkConfig = FRAMEWORK_REGISTRY[integration];
1067
+ session.frameworkConfig = frameworkConfig;
1068
+ const context = await gatherFrameworkContext(frameworkConfig, {
1069
+ installDir: session.installDir,
1070
+ debug: session.debug,
1071
+ default: false,
1072
+ signup: session.signup,
1073
+ localMcp: session.localMcp,
1074
+ ci: true,
1075
+ benchmark: session.benchmark,
1076
+ yaraReport: session.yaraReport
1077
+ });
1078
+ for (const [key, value] of Object.entries(context)) if (!(key in session.frameworkContext)) session.frameworkContext[key] = value;
1079
+ },
871
1080
  run: async (session) => {
872
1081
  const config = session.frameworkConfig;
873
1082
  const typeScriptDetected = isUsingTypeScript({ installDir: session.installDir });
@@ -877,7 +1086,7 @@ const posthogIntegrationConfig = {
877
1086
  if (usesPackageJson) {
878
1087
  const packageJson = await tryGetPackageJson({ installDir: session.installDir });
879
1088
  if (packageJson) {
880
- const { hasDeclaredDependency } = await import("./package-json-Cttzi3C8.js");
1089
+ const { hasDeclaredDependency } = await import("./package-json-DCuoye-H.js").then((n) => n.i);
881
1090
  if (!hasDeclaredDependency(config.detection.packageName, packageJson)) getUI().log.warn(`${config.detection.packageDisplayName} does not seem to be installed. Continuing anyway — the agent will handle it.`);
882
1091
  frameworkVersion = config.detection.getVersion(packageJson);
883
1092
  } else getUI().log.warn("Could not find package.json. Continuing anyway — the agent will handle it.");
@@ -944,7 +1153,7 @@ Important: Use the detect_package_manager tool (from the wizard-tools MCP server
944
1153
  postRun: async (sess, credentials) => {
945
1154
  const envVars = config.environment.getEnvVars(credentials.projectApiKey, credentials.host);
946
1155
  if (config.environment.uploadToHosting) {
947
- const { uploadEnvironmentVariablesStep } = await import("./steps-0d9XqvI6.js");
1156
+ const { uploadEnvironmentVariablesStep } = await import("./steps-DDx35170.js");
948
1157
  const uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {
949
1158
  integration: config.metadata.integration,
950
1159
  session: sess
@@ -981,6 +1190,6 @@ Important: Use the detect_package_manager tool (from the wizard-tools MCP server
981
1190
  }
982
1191
  };
983
1192
  //#endregion
984
- export { LINE_CHART_BLOCK as a, FUNNEL_BLOCK as i, posthogIntegrationConfig as n, PRODUCT_SUITE_BLOCK as o, posthog_integration_exports as r, StatusPeekTrigger as s, EVENT_PLAN_FILE as t };
1193
+ export { PRODUCT_SUITE_BLOCK as a, LINE_CHART_BLOCK as i, posthogIntegrationConfig as n, StatusPeekTrigger as o, FUNNEL_BLOCK as r, EVENT_PLAN_FILE as t };
985
1194
 
986
- //# sourceMappingURL=posthog-integration-CukaeYil.js.map
1195
+ //# sourceMappingURL=posthog-integration-Bv7987YJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"posthog-integration-Bv7987YJ.js","names":[],"sources":["../src/lib/detection/framework.ts","../src/lib/detection/features.ts","../src/lib/detection/context.ts","../src/lib/programs/posthog-integration/detect.ts","../src/lib/programs/posthog-integration/steps.ts","../src/ui/tui/components/StatusPeekTrigger.tsx","../src/lib/programs/posthog-integration/content/data-flow.tsx","../src/lib/programs/posthog-integration/content/product-suite.tsx","../src/lib/programs/posthog-integration/content/line-chart.tsx","../src/lib/programs/posthog-integration/content/funnel.tsx","../src/lib/programs/posthog-integration/content/index.tsx","../src/lib/programs/posthog-integration/index.ts"],"sourcesContent":["/**\n * Framework detection — identify which PostHog-supported framework\n * is present in the project directory.\n *\n * Pure function: takes an install dir, returns the detected integration\n * (or undefined). No store mutations, no UI calls.\n */\n\nimport { Integration, DETECTION_TIMEOUT_MS } from '@lib/constants';\nimport { FRAMEWORK_REGISTRY } from '@lib/registry';\n\n/**\n * Loop through all registered frameworks and return the first one\n * whose `detect()` predicate matches the given directory.\n * Returns undefined if no framework is detected or detection times out.\n */\nexport async function detectFramework(\n installDir: string,\n): Promise<Integration | undefined> {\n for (const integration of Object.values(Integration)) {\n const config = FRAMEWORK_REGISTRY[integration];\n try {\n const detected = await Promise.race([\n config.detection.detect({ installDir }),\n new Promise<false>((resolve) =>\n setTimeout(() => resolve(false), DETECTION_TIMEOUT_MS),\n ),\n ]);\n if (detected) {\n return integration;\n }\n } catch {\n // Skip frameworks whose detection throws\n }\n }\n}\n","/**\n * Feature discovery — scan project dependencies for known SDK patterns\n * that indicate additional PostHog programs are relevant.\n *\n * Pure function: takes an install dir, returns a set of discovered features.\n * No store mutations, no UI calls.\n */\n\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { DiscoveredFeature } from '@lib/wizard-session';\n\nconst STRIPE_PACKAGES = ['stripe', '@stripe/stripe-js'];\n\nconst LLM_PACKAGES = [\n 'openai',\n '@anthropic-ai/sdk',\n 'ai',\n '@ai-sdk/openai',\n 'langchain',\n '@langchain/openai',\n '@langchain/langgraph',\n '@google/generative-ai',\n '@google/genai',\n '@instructor-ai/instructor',\n '@mastra/core',\n 'portkey-ai',\n];\n\n// PyPI normalizes `_` to `-` and is case-insensitive; compare via normalizePyName.\nconst PYTHON_LLM_PACKAGES = [\n 'openai',\n 'anthropic',\n 'langchain',\n 'langchain-openai',\n 'langchain-anthropic',\n 'langchain-google-genai',\n 'langgraph',\n 'litellm',\n 'llama-index',\n 'pydantic-ai',\n 'crewai',\n 'instructor',\n 'dspy-ai',\n 'mistralai',\n 'cohere',\n 'google-generativeai',\n 'google-genai',\n 'portkey-ai',\n];\n\nexport function discoverFeatures(installDir: string): DiscoveredFeature[] {\n const features: DiscoveredFeature[] = [];\n discoverNodeFeatures(installDir, features);\n discoverPythonFeatures(installDir, features);\n return features;\n}\n\nfunction discoverNodeFeatures(\n installDir: string,\n features: DiscoveredFeature[],\n): void {\n const packageJsonText = safeRead(installDir, 'package.json');\n if (!packageJsonText) return;\n\n let packageJson: {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n try {\n packageJson = JSON.parse(packageJsonText);\n } catch {\n return;\n }\n\n const depNames = Object.keys({\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n });\n\n if (depNames.some((depName) => STRIPE_PACKAGES.includes(depName))) {\n features.push(DiscoveredFeature.Stripe);\n }\n if (depNames.some((depName) => LLM_PACKAGES.includes(depName))) {\n features.push(DiscoveredFeature.LLM);\n }\n}\n\nfunction discoverPythonFeatures(\n installDir: string,\n features: DiscoveredFeature[],\n): void {\n if (features.includes(DiscoveredFeature.LLM)) return;\n\n const depNames: string[] = [];\n\n const requirementsTxt = safeRead(installDir, 'requirements.txt');\n if (requirementsTxt) depNames.push(...parseRequirementsTxt(requirementsTxt));\n\n const pyprojectToml = safeRead(installDir, 'pyproject.toml');\n if (pyprojectToml) depNames.push(...parsePyprojectToml(pyprojectToml));\n\n const pipfile = safeRead(installDir, 'Pipfile');\n if (pipfile) depNames.push(...parsePipfile(pipfile));\n\n if (depNames.some((depName) => PYTHON_LLM_PACKAGES.includes(depName))) {\n features.push(DiscoveredFeature.LLM);\n }\n}\n\nfunction safeRead(installDir: string, file: string): string | null {\n try {\n return readFileSync(join(installDir, file), 'utf-8');\n } catch {\n return null;\n }\n}\n\nfunction normalizePyName(name: string): string {\n return name.toLowerCase().replace(/_/g, '-');\n}\n\nexport function parseRequirementsTxt(content: string): string[] {\n return content\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line && !line.startsWith('#') && !line.startsWith('-'))\n .map((line) => line.replace(/\\[[^\\]]*\\]/, ''))\n .map((line) => line.split(/[<>=!~;\\s]/)[0])\n .filter(Boolean)\n .map(normalizePyName);\n}\n\n// Pragmatic, not a full TOML parser — only the dep shapes we care about.\nexport function parsePyprojectToml(content: string): string[] {\n const depNames: string[] = [];\n\n for (const arrayMatch of content.matchAll(\n /dependencies\\s*=\\s*\\[([^\\]]*)\\]/g,\n )) {\n const arrayBody = arrayMatch[1];\n for (const quotedMatch of arrayBody.matchAll(/[\"']([^\"']+)[\"']/g)) {\n const depSpec = quotedMatch[1];\n const name = depSpec.replace(/\\[[^\\]]*\\]/, '').split(/[<>=!~;\\s]/)[0];\n if (name) depNames.push(normalizePyName(name));\n }\n }\n\n const poetrySectionRe =\n /\\[tool\\.poetry\\.(?:dev-dependencies|dependencies|group\\.[^.\\]]+\\.dependencies)\\]([\\s\\S]*?)(?=\\n\\[|$)/g;\n for (const sectionMatch of content.matchAll(poetrySectionRe)) {\n const sectionBody = sectionMatch[1];\n depNames.push(...extractTomlSectionKeys(sectionBody, { skip: ['python'] }));\n }\n\n return depNames;\n}\n\nexport function parsePipfile(content: string): string[] {\n const depNames: string[] = [];\n const sectionRe = /\\[(packages|dev-packages)\\]([\\s\\S]*?)(?=\\n\\[|$)/g;\n for (const sectionMatch of content.matchAll(sectionRe)) {\n const sectionBody = sectionMatch[2];\n depNames.push(...extractTomlSectionKeys(sectionBody));\n }\n return depNames;\n}\n\nfunction extractTomlSectionKeys(\n sectionBody: string,\n opts: { skip?: string[] } = {},\n): string[] {\n const skipNames = new Set(opts.skip ?? []);\n const depNames: string[] = [];\n for (const line of sectionBody.split('\\n')) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) continue;\n const equalsIndex = trimmed.indexOf('=');\n if (equalsIndex <= 0) continue;\n const name = trimmed.slice(0, equalsIndex).trim();\n if (!/^[a-zA-Z0-9._-]+$/.test(name)) continue;\n if (skipNames.has(name.toLowerCase())) continue;\n depNames.push(normalizePyName(name));\n }\n return depNames;\n}\n","/**\n * Framework context gathering — run gatherContext and version checks\n * for a detected framework.\n *\n * Pure functions: take a framework config and options, return results.\n * No store mutations, no UI calls.\n */\n\nimport * as semver from 'semver';\nimport { DETECTION_TIMEOUT_MS } from '@lib/constants';\nimport type { FrameworkConfig } from '@lib/framework-config';\nimport type { WizardRunOptions } from '@utils/types';\n\n/**\n * Run a framework's `gatherContext()` to collect variant-specific\n * metadata (e.g., router type for Next.js, Expo vs bare for React Native).\n *\n * Returns the gathered context, or an empty object on failure/timeout.\n */\nexport async function gatherFrameworkContext(\n config: FrameworkConfig,\n options: WizardRunOptions,\n): Promise<Record<string, unknown>> {\n if (!config.metadata.gatherContext) return {};\n\n try {\n return await Promise.race([\n config.metadata.gatherContext(options),\n new Promise<Record<string, never>>((resolve) =>\n setTimeout(() => resolve({}), DETECTION_TIMEOUT_MS),\n ),\n ]);\n } catch {\n return {};\n }\n}\n\nexport interface VersionCheckResult {\n /** Whether the installed version is supported */\n supported:\n | true\n | {\n current: string;\n minimum: string;\n docsUrl: string;\n };\n}\n\n/**\n * Check whether the installed framework version meets the minimum requirement.\n *\n * Returns `{ supported: true }` if the version is fine (or no check is needed).\n * Returns the version details if unsupported.\n */\nexport async function checkFrameworkVersion(\n config: FrameworkConfig,\n options: WizardRunOptions,\n): Promise<VersionCheckResult> {\n if (\n !config.detection.minimumVersion ||\n !config.detection.getInstalledVersion\n ) {\n return { supported: true };\n }\n\n const version = await config.detection.getInstalledVersion(options);\n if (!version) return { supported: true };\n\n const coerced = semver.coerce(version);\n if (coerced && semver.lt(coerced, config.detection.minimumVersion)) {\n return {\n supported: {\n current: version,\n minimum: config.detection.minimumVersion,\n docsUrl:\n config.metadata.unsupportedVersionDocsUrl ?? config.metadata.docsUrl,\n },\n };\n }\n\n return { supported: true };\n}\n","/**\n * Core integration detection step.\n *\n * Runs framework detection, context gathering, version checking,\n * and feature discovery. Writes results to the store via the\n * ProgramReadyContext so the IntroScreen can display them.\n *\n * This is the same work that bin.ts $0 handler does inline —\n * extracted here so the `integrate` subcommand can reuse it.\n */\n\nimport type { ProgramReadyContext } from '@lib/programs/program-step';\nimport { FRAMEWORK_REGISTRY } from '@lib/registry';\nimport {\n detectFramework,\n discoverFeatures,\n gatherFrameworkContext,\n checkFrameworkVersion,\n} from '@lib/detection/index';\n\nexport async function detectPostHogIntegration(\n ctx: ProgramReadyContext,\n): Promise<void> {\n const session = ctx.session;\n const installDir = session.installDir;\n\n const detectedIntegration = await detectFramework(installDir);\n\n if (detectedIntegration) {\n const config = FRAMEWORK_REGISTRY[detectedIntegration];\n\n const sessionOptions = {\n installDir,\n debug: session.debug,\n default: false,\n signup: session.signup,\n localMcp: session.localMcp,\n ci: session.ci,\n benchmark: session.benchmark,\n yaraReport: session.yaraReport,\n };\n\n // Gather framework-specific context (e.g., router type)\n const context = await gatherFrameworkContext(config, sessionOptions);\n for (const [key, value] of Object.entries(context)) {\n if (!(key in session.frameworkContext)) {\n ctx.setFrameworkContext(key, value);\n }\n }\n\n ctx.setFrameworkConfig(detectedIntegration, config);\n session.skillId = detectedIntegration;\n\n if (!session.detectedFrameworkLabel) {\n ctx.setDetectedFramework(config.metadata.name);\n }\n\n // Version check\n const versionResult = await checkFrameworkVersion(config, sessionOptions);\n if (versionResult.supported !== true) {\n ctx.setUnsupportedVersion(versionResult.supported);\n }\n }\n\n // Feature discovery\n for (const feature of discoverFeatures(installDir)) {\n ctx.addDiscoveredFeature(feature);\n }\n\n ctx.setDetectionComplete();\n}\n","/**\n * PostHog integration program — the default wizard flow.\n *\n * Steps define their own gate predicates and onInit callbacks.\n * The store derives gate promises and fires init work from these\n * definitions — no hardcoded per-flow logic in the store.\n */\n\nimport type { ProgramStep } from '@lib/programs/program-step';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { RunPhase } from '@lib/wizard-session';\nimport { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step';\nimport { detectPostHogIntegration } from './detect.js';\n\nfunction needsSetup(session: WizardSession): boolean {\n const config = session.frameworkConfig;\n if (!config?.metadata.setup?.questions) return false;\n\n return config.metadata.setup.questions.some(\n (q: { key: string }) => !(q.key in session.frameworkContext),\n );\n}\n\nexport const POSTHOG_INTEGRATION_PROGRAM: ProgramStep[] = [\n {\n id: 'detect',\n label: 'Detecting framework',\n // Headless step: no screen. onReady fires after bin.ts assigns the\n // session — runs framework detection, context gathering, version\n // check, and feature discovery. Results are written to the store\n // for the IntroScreen to render.\n onReady: (ctx) => detectPostHogIntegration(ctx),\n },\n {\n id: 'intro',\n label: 'Welcome',\n screenId: 'intro',\n gate: (session) => session.setupConfirmed,\n },\n HEALTH_CHECK_STEP,\n {\n id: 'setup',\n label: 'Setup',\n screenId: 'setup',\n show: needsSetup,\n isComplete: (session) => !needsSetup(session),\n },\n {\n id: 'auth',\n label: 'Authentication',\n screenId: 'auth',\n isComplete: (session) => session.credentials !== null,\n },\n {\n id: 'run',\n label: 'Integration',\n screenId: 'run',\n isComplete: (session) =>\n session.runPhase === RunPhase.Completed ||\n session.runPhase === RunPhase.Error,\n },\n {\n id: 'mcp',\n label: 'MCP servers',\n screenId: 'mcp',\n isComplete: (session) => session.mcpComplete,\n },\n {\n id: 'outro',\n label: 'Done',\n screenId: 'outro',\n isComplete: (session) => session.outroDismissed,\n },\n {\n id: 'keep-skills',\n label: 'Keep Skills',\n screenId: 'keep-skills',\n },\n];\n","/**\n * StatusPeekTrigger — Fires the status-bar expansion once, renders a hint.\n *\n * Module-level `peekedOnce` guards against re-mounts (resize, tab switch)\n * so the peek only happens a single time per process.\n */\n\nimport { Text } from 'ink';\nimport { useEffect } from 'react';\nimport type { WizardStore } from '@ui/tui/store';\n\nlet peekedOnce = false;\n\ninterface StatusPeekTriggerProps {\n store?: WizardStore;\n /** How long the status bar stays expanded, in ms. */\n duration?: number;\n}\n\nexport const StatusPeekTrigger = ({\n store,\n duration = 10000,\n}: StatusPeekTriggerProps) => {\n useEffect(() => {\n if (peekedOnce) return;\n peekedOnce = true;\n store?.setStatusExpanded(true);\n // No cleanup — the store call is safe after unmount and the component\n // may be evicted before the timer fires (non-persist NodeBlock).\n setTimeout(() => {\n store?.setStatusExpanded(false);\n }, duration);\n }, [store, duration]);\n\n return <Text>You can view the Wizard&apos;s status below.</Text>;\n};\n","/**\n * POSTHOG_DATA_FLOW — ASCII diagram of the PostHog event ingestion flow.\n */\n\nimport { Text } from 'ink';\nimport { Colors } from '@ui/tui/styles';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const POSTHOG_DATA_FLOW: ContentBlock = {\n type: 'lines',\n interval: 500,\n pause: 8000,\n // Box is 30 chars wide between │ borders.\n // Labels: 1-char indent. Arrows: \" ↓ \" (5). Sub-items: \" │ \" (7).\n lines: [\n <Text color=\"gray\">{' ┌──────────────────────────────┐'}</Text>,\n <Text>\n <Text color=\"gray\">{' │ '}</Text>\n <Text bold color=\"cyan\">\n Your App\n </Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │ │ '}</Text>\n <Text>posthog.capture()</Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │ │ '}</Text>\n <Text dimColor>custom events</Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │ │ '}</Text>\n <Text dimColor>custom properties</Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │ │ '}</Text>\n <Text dimColor>person profiles</Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │ ↓ '}</Text>\n <Text dimColor>groups</Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │ '}</Text>\n <Text bold color={Colors.accent}>\n PostHog SDK\n </Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │ ↓ '}</Text>\n <Text>HTTP</Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │ '}</Text>\n <Text bold color={Colors.accent}>\n PostHog Cloud\n </Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │ ↓ '}</Text>\n <Text>query + visualize</Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │ '}</Text>\n <Text bold color=\"green\">\n Dashboards & Insights\n </Text>\n <Text color=\"gray\">{' │'}</Text>\n </Text>,\n <Text color=\"gray\">{' └──────────────────────────────┘'}</Text>,\n ],\n};\n","/**\n * PRODUCT_SUITE_BLOCK — Two-column listing of PostHog products.\n */\n\nimport { Text } from 'ink';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const PRODUCT_SUITE_BLOCK: ContentBlock = {\n type: 'lines',\n interval: 1000,\n pause: 15000,\n lines: [\n <Text>\n <Text color=\"cyan\">{' ◆ '}</Text>\n {'Product Analytics '}\n <Text color=\"cyan\">{'◆ '}</Text>\n {'Error Tracking'}\n </Text>,\n <Text>\n <Text color=\"cyan\">{' ◆ '}</Text>\n {'Web Analytics '}\n <Text color=\"cyan\">{'◆ '}</Text>\n {'Session Replay'}\n </Text>,\n <Text>\n <Text color=\"cyan\">{' ◆ '}</Text>\n {'Feature Flags '}\n <Text color=\"cyan\">{'◆ '}</Text>\n {'Data Pipelines'}\n </Text>,\n <Text>\n <Text color=\"cyan\">{' ◆ '}</Text>\n {'Experiments '}\n <Text color=\"cyan\">{'◆ '}</Text>\n {'Data Warehouse'}\n </Text>,\n <Text>\n <Text color=\"cyan\">{' ◆ '}</Text>\n {'LLM Analytics '}\n <Text color=\"cyan\">{'◆ '}</Text>\n {'Surveys'}\n </Text>,\n <Text>\n <Text color=\"cyan\">{' ◆ '}</Text>\n {'Workflows '}\n <Text color=\"cyan\">{'◆ '}</Text>\n {'Logs'}\n </Text>,\n <Text>\n <Text color=\"cyan\">{' ◆ '}</Text>\n {'Product Tours '}\n <Text color=\"cyan\">{'◆ '}</Text>\n {'Support'}\n </Text>,\n <Text>\n <Text color=\"cyan\">{' ◆ '}</Text>\n {'Revenue Analytics '}\n <Text color=\"cyan\">{'◆ '}</Text>\n {'Endpoints'}\n </Text>,\n <Text>\n <Text color=\"cyan\">{' ◆ '}</Text>\n {'Customer Analytics '}\n <Text color=\"cyan\">{'◆ '}</Text>\n {'PostHog Code'}\n </Text>,\n ],\n};\n","/**\n * LINE_CHART_BLOCK — ASCII trends chart illustrating an insight.\n */\n\nimport { Text } from 'ink';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const LINE_CHART_BLOCK: ContentBlock = {\n type: 'lines',\n interval: 300,\n pause: 6000,\n lines: [\n <Text bold>{' Trends · user signups (monthly)'}</Text>,\n <Text> </Text>,\n // 10k\n <Text>\n <Text color=\"gray\">{' 10k ┤'}</Text>\n {' '}\n <Text color=\"cyan\">{'╭──'}</Text>\n <Text dimColor>{' 9,575'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │'}</Text>\n {' '}\n <Text color=\"cyan\">{'╭╯'}</Text>\n </Text>,\n // 7.5k\n <Text>\n <Text color=\"gray\">{' 7.5k ┤'}</Text>\n {' '}\n <Text color=\"cyan\">{'╭╯'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │'}</Text>\n {' '}\n <Text color=\"cyan\">{'╭─╯'}</Text>\n </Text>,\n // 5k\n <Text>\n <Text color=\"gray\">{' 5k ┤'}</Text>\n {' '}\n <Text color=\"cyan\">{'╭─╯'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │'}</Text>\n {' '}\n <Text color=\"cyan\">{'╭──╯'}</Text>\n </Text>,\n // 2.5k\n <Text>\n <Text color=\"gray\">{' 2.5k ┤'}</Text>\n {' '}\n <Text color=\"cyan\">{'╭───╯'}</Text>\n </Text>,\n <Text>\n <Text color=\"gray\">{' │'}</Text>\n {' '}\n <Text color=\"cyan\">{'╭──────╯'}</Text>\n </Text>,\n // 0\n <Text>\n <Text color=\"gray\">{' 0 ┤'}</Text>\n <Text color=\"cyan\">{'──────╯'}</Text>\n </Text>,\n // X-axis\n <Text color=\"gray\">{' └┬─────┬─────┬─────┬─────┬──'}</Text>,\n <Text dimColor>{' May Aug Nov Feb May'}</Text>,\n ],\n};\n","/**\n * FUNNEL_BLOCK — ASCII funnel illustrating step conversion.\n */\n\nimport { Text } from 'ink';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\n\nexport const FUNNEL_BLOCK: ContentBlock = {\n type: 'lines',\n interval: 200,\n pause: 8000,\n lines: [\n <Text bold>{' Funnel · ride conversion'}</Text>,\n <Text> </Text>,\n // Step 1\n <Text>\n {' '}\n <Text bold>1</Text>\n {' app_launched'}\n {' '}\n <Text bold color=\"green\">\n 100.00%\n </Text>\n </Text>,\n <Text color=\"cyan\">{' ██████████████████████████████'}</Text>,\n <Text dimColor>{' → 1,200 users'}</Text>,\n <Text> </Text>,\n // Step 2\n <Text>\n {' '}\n <Text bold>2</Text>\n {' ride_requested'}\n {' '}\n <Text dimColor>{'avg 2m 30s'}</Text>\n {' '}\n <Text bold color=\"green\">\n 72.00%\n </Text>\n </Text>,\n <Text>\n {' '}\n <Text color=\"cyan\">{'██████████████████████'}</Text>\n <Text dimColor>{'░░░░░░░░░'}</Text>\n </Text>,\n <Text>\n {' '}\n <Text dimColor>→ 864 users</Text>\n {' '}\n <Text color=\"red\">↘</Text>\n <Text dimColor>{' 336 (28%)'}</Text>\n </Text>,\n <Text> </Text>,\n // Step 3\n <Text>\n {' '}\n <Text bold>3</Text>\n {' ride_accepted'}\n {' '}\n <Text dimColor>{'avg 5m 12s'}</Text>\n {' '}\n <Text bold color=\"green\">\n 51.00%\n </Text>\n </Text>,\n <Text>\n {' '}\n <Text color=\"cyan\">{'██████████████████'}</Text>\n <Text dimColor>{'░░░░░░░░░░░░░'}</Text>\n </Text>,\n <Text>\n {' '}\n <Text dimColor>→ 612 users</Text>\n {' '}\n <Text color=\"red\">↘</Text>\n <Text dimColor>{' 252 (29%)'}</Text>\n </Text>,\n <Text> </Text>,\n // Step 4\n <Text>\n {' '}\n <Text bold>4</Text>\n {' ride_started'}\n {' '}\n <Text dimColor>{'avg 1m 45s'}</Text>\n {' '}\n <Text bold color=\"green\">\n 38.00%\n </Text>\n </Text>,\n <Text>\n {' '}\n <Text color=\"cyan\">{'█████████████'}</Text>\n <Text dimColor>{'░░░░░░░░░░░░░░░░░░'}</Text>\n </Text>,\n <Text>\n {' '}\n <Text dimColor>→ 456 users</Text>\n {' '}\n <Text color=\"red\">↘</Text>\n <Text dimColor>{' 156 (25%)'}</Text>\n </Text>,\n ],\n};\n","/**\n * Integration learn-deck — the narrative script played while the agent\n * runs the PostHog integration flow. Weaves typewriter lines, pauses,\n * `clear` markers, and the diagram blocks into one sequence.\n */\n\nimport { Text } from 'ink';\nimport { Colors } from '@ui/tui/styles';\nimport type { WizardStore } from '@ui/tui/store';\nimport { TextRevealMode } from '@ui/tui/primitives/TextBlock';\nimport type { ContentBlock } from '@ui/tui/primitives/content-types';\nimport { StatusPeekTrigger } from '@ui/tui/components/StatusPeekTrigger';\nimport { POSTHOG_DATA_FLOW } from './data-flow.js';\nimport { PRODUCT_SUITE_BLOCK } from './product-suite.js';\nimport { LINE_CHART_BLOCK } from './line-chart.js';\nimport { FUNNEL_BLOCK } from './funnel.js';\n\nexport const getContentBlocks = (store?: WizardStore): ContentBlock[] => [\n {\n content: 'Welcome.',\n pause: 3000,\n mode: TextRevealMode.Typewriter,\n animationInterval: 160,\n },\n\n { content: 'The Wizard is an agent.', pause: 4000 },\n\n {\n content: 'It handles the entire PostHog setup process on your behalf.',\n pause: 5000,\n },\n\n {\n content:\n \"As we speak, it's building a plan to set up PostHog in your project.\",\n pause: 6000,\n },\n\n { type: 'clear', pause: 2000 },\n\n {\n pause: 5000,\n persist: true,\n content: <StatusPeekTrigger store={store} />,\n },\n\n {\n pause: 6000,\n content: (\n <Text>\n Press{' '}\n <Text color={Colors.accent} bold>\n S\n </Text>{' '}\n to expand or collapse the status.\n </Text>\n ),\n },\n\n { type: 'clear', pause: 2000 },\n\n {\n content: 'It takes about eight minutes.',\n pause: 2000,\n },\n\n {\n content: 'So grab some coffee ☕️.',\n pause: 2000,\n },\n\n {\n content: 'Or stick around and learn about PostHog.',\n pause: 5000,\n },\n\n { type: 'clear', pause: 3000 },\n\n {\n content: 'Events are the foundation of the PostHog platform.',\n pause: 4000,\n },\n\n {\n content:\n 'Every time an action is performed in your codebase — like button clicks, function calls, or thrown errors — we can capture an event.',\n pause: 6000,\n },\n\n {\n content: 'Events are sent to PostHog and joined with other product data.',\n pause: 6000,\n },\n\n { type: 'clear', pause: 1000 },\n\n { content: \"Here's the flow.\", pause: 1000 },\n\n POSTHOG_DATA_FLOW,\n\n { type: 'clear', pause: 2000 },\n\n {\n content:\n 'With enough event data, you can answer powerful questions about your product.',\n pause: 4000,\n },\n\n { content: 'And create insights.', pause: 4000 },\n\n { type: 'clear', pause: 500 },\n\n { content: 'Like trends to measure growth.', pause: 2500 },\n\n LINE_CHART_BLOCK,\n\n { type: 'clear', pause: 500 },\n\n { content: 'Or funnels to reveal bottlenecks.', pause: 2500 },\n\n FUNNEL_BLOCK,\n\n { type: 'clear', pause: 1000 },\n\n {\n content: 'Use those signals to decide what to build next.',\n pause: 4000,\n },\n\n { content: 'PostHog has all the dev tools you need.', pause: 3000 },\n\n PRODUCT_SUITE_BLOCK,\n];\n","import opn from 'opn';\nimport type { ProgramConfig } from '@lib/programs/program-step';\nimport type { ProgramRun } from '@lib/agent/agent-runner';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools';\nimport type { WizardSession } from '@lib/wizard-session';\nimport { OutroKind } from '@lib/wizard-session';\nimport { AgentSignals } from '@lib/agent/agent-interface';\nimport {\n DEFAULT_PACKAGE_INSTALLATION,\n SPINNER_MESSAGE,\n} from '@lib/framework-config';\nimport { tryGetPackageJson, isUsingTypeScript } from '@utils/setup-utils';\nimport { analytics } from '@utils/analytics';\nimport { detectFramework, gatherFrameworkContext } from '@lib/detection/index';\nimport { FRAMEWORK_REGISTRY } from '@lib/registry';\nimport { wizardAbort } from '@utils/wizard-abort';\nimport { WIZARD_INTERACTION_EVENT_NAME } from '@lib/constants';\nimport { getUI } from '@ui/index';\nimport { getCloudUrlFromRegion } from '@utils/urls';\nimport { requestDeepLink } from '@utils/provisioning';\nimport type { CloudRegion } from '@utils/types';\nimport { POSTHOG_INTEGRATION_PROGRAM } from './steps.js';\nimport { getContentBlocks } from './content/index.js';\n\nconst DASHBOARD_DEEP_LINK_KEY = 'dashboardDeepLink';\n\nfunction resolveContinueUrl(\n sess: WizardSession,\n cloudRegion: CloudRegion | undefined,\n deepLink: unknown,\n): string | undefined {\n if (!sess.signup) return undefined;\n if (typeof deepLink === 'string' && deepLink) return deepLink;\n if (cloudRegion)\n return `${getCloudUrlFromRegion(cloudRegion)}/products?source=wizard`;\n return undefined;\n}\n\nexport const SETUP_REPORT_FILE = 'posthog-setup-report.md';\nexport const EVENT_PLAN_FILE = '.posthog-events.json';\n\nexport const posthogIntegrationConfig: ProgramConfig = {\n command: 'integrate',\n description: 'Set up PostHog SDK integration',\n id: 'posthog-integration',\n steps: POSTHOG_INTEGRATION_PROGRAM,\n getContentBlocks,\n // Basic integration runs without structured user input; drop wizard_ask\n // so the model can't pop modal prompts mid-run. The runner forwards this\n // list to the general-purpose subagent as well, so dispatched subagents\n // can't reach around the parent and ask either.\n disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],\n\n // CI-mode prerequisite work: the headless equivalent of the detect step's\n // onReady hook. Auto-detect the framework, then gather context.\n ciPreRun: async (session: WizardSession): Promise<void> => {\n const integration = await detectFramework(session.installDir);\n if (!integration) {\n await wizardAbort({\n message: 'Could not auto-detect your framework for this project.',\n });\n return;\n }\n session.integration = integration;\n analytics.setTag('integration', integration);\n\n const frameworkConfig = FRAMEWORK_REGISTRY[integration];\n session.frameworkConfig = frameworkConfig;\n\n const context = await gatherFrameworkContext(frameworkConfig, {\n installDir: session.installDir,\n debug: session.debug,\n // `default` is required by WizardRunOptions but unused by detection; the\n // --default CLI flag was removed, so this is always false here.\n default: false,\n signup: session.signup,\n localMcp: session.localMcp,\n ci: true,\n benchmark: session.benchmark,\n yaraReport: session.yaraReport,\n });\n for (const [key, value] of Object.entries(context)) {\n if (!(key in session.frameworkContext)) {\n session.frameworkContext[key] = value;\n }\n }\n },\n\n run: async (session: WizardSession): Promise<ProgramRun> => {\n const config = session.frameworkConfig!;\n\n const typeScriptDetected = isUsingTypeScript({\n installDir: session.installDir,\n });\n session.typescript = typeScriptDetected;\n\n // Read package.json and resolve framework version\n const usesPackageJson = config.detection.usesPackageJson !== false;\n let frameworkVersion: string | undefined;\n\n if (usesPackageJson) {\n const packageJson = await tryGetPackageJson({\n installDir: session.installDir,\n });\n if (packageJson) {\n const { hasDeclaredDependency } = await import('@utils/package-json');\n if (!hasDeclaredDependency(config.detection.packageName, packageJson)) {\n getUI().log.warn(\n `${config.detection.packageDisplayName} does not seem to be installed. Continuing anyway — the agent will handle it.`,\n );\n }\n frameworkVersion = config.detection.getVersion(packageJson);\n } else {\n getUI().log.warn(\n 'Could not find package.json. Continuing anyway — the agent will handle it.',\n );\n }\n } else {\n frameworkVersion = config.detection.getVersion(null);\n }\n\n // Analytics tags\n if (frameworkVersion && config.detection.getVersionBucket) {\n const versionBucket = config.detection.getVersionBucket(frameworkVersion);\n analytics.setTag(`${config.metadata.integration}-version`, versionBucket);\n }\n const frameworkContext = session.frameworkContext;\n const contextTags = config.analytics.getTags(frameworkContext);\n Object.entries(contextTags).forEach(([key, value]) => {\n analytics.setTag(key, value);\n });\n\n return {\n integrationLabel: config.metadata.integration,\n additionalMcpServers: config.metadata.additionalMcpServers,\n detectPackageManager: config.detection.detectPackageManager,\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: config.ui.successMessage,\n estimatedDurationMinutes: config.ui.estimatedDurationMinutes,\n reportFile: SETUP_REPORT_FILE,\n docsUrl: config.metadata.docsUrl,\n errorMessage: 'Integration failed',\n additionalFeatureQueue: session.additionalFeatureQueue,\n\n customPrompt: (ctx) => {\n const additionalLines = config.prompts.getAdditionalContextLines\n ? config.prompts.getAdditionalContextLines(frameworkContext)\n : [];\n const additionalContext =\n additionalLines.length > 0\n ? '\\n' + additionalLines.map((line) => `- ${line}`).join('\\n')\n : '';\n\n return `You have access to the PostHog MCP server which provides skills to integrate PostHog into this ${\n config.metadata.name\n } project.\n\nProject context:\n- PostHog Project ID: ${ctx.projectId}\n- Framework: ${config.metadata.name} ${frameworkVersion || 'latest'}\n- TypeScript: ${typeScriptDetected ? 'Yes' : 'No'}\n- PostHog public token: ${ctx.projectApiKey}\n- PostHog Host: ${ctx.host}\n- Project type: ${config.prompts.projectTypeDetection}\n- Package installation: ${\n config.prompts.packageInstallation ?? DEFAULT_PACKAGE_INSTALLATION\n }${additionalContext}\n\nInstructions (follow these steps IN ORDER - do not skip or reorder):\n\nSTEP 1: Call load_skill_menu (from the wizard-tools MCP server) to see available skills.\n If the tool fails, emit: ${\n AgentSignals.ERROR_MCP_MISSING\n } Could not load skill menu and halt.\n\n Choose a skill from the \\`integration\\` category that matches this project's framework. Do NOT pick skills from other categories (llm-analytics, error-tracking, feature-flags, omnibus, etc.) — those are handled separately.\n If no suitable integration skill is found, emit: ${\n AgentSignals.ERROR_RESOURCE_MISSING\n } Could not find a suitable skill for this project.\n\nSTEP 2: Call install_skill (from the wizard-tools MCP server) with the chosen skill ID (e.g., \"integration-nextjs-app-router\").\n Do NOT run any shell commands to install skills.\n\nSTEP 3: Load the installed skill's SKILL.md file to understand what references are available.\n\nSTEP 4: Follow the skill's program files in sequence. Look for numbered program files in the references (e.g., files with patterns like \"1.0-\", \"1.1-\", \"1.2-\"). Start with the first one and proceed through each step until completion. Each program file will tell you what to do and which file comes next. Never directly write PostHog tokens directly to code files; always use environment variables.\n\nSTEP 5: Set up environment variables for PostHog using the wizard-tools MCP server (this runs locally — secret values never leave the machine):\n - Use check_env_keys to see which keys already exist in the project's .env file (e.g. .env.local or .env).\n - Use set_env_values to create or update the PostHog public token and host, using the appropriate environment variable naming convention for ${\n config.metadata.name\n }, which you'll find in example code. The tool will also ensure .gitignore coverage. Don't assume the presence of keys means the value is up to date. Write the correct value each time.\n - Reference these environment variables in the code files you create instead of hardcoding the public token and host.\n\nImportant: Use the detect_package_manager tool (from the wizard-tools MCP server) to determine which package manager the project uses. Do not manually search for lockfiles or config files. Always install packages as a background task. Don't await completion; proceed with other work immediately after starting the installation. You must read a file immediately before attempting to write it, even if you have previously read it; failure to do so will cause a tool failure.\n\n\n`;\n },\n\n postRun: async (sess, credentials) => {\n const envVars = config.environment.getEnvVars(\n credentials.projectApiKey,\n credentials.host,\n );\n if (config.environment.uploadToHosting) {\n const { uploadEnvironmentVariablesStep } = await import(\n '@steps/index'\n );\n const uploadedEnvVars = await uploadEnvironmentVariablesStep(\n envVars,\n {\n integration: config.metadata.integration,\n session: sess,\n },\n );\n if (uploadedEnvVars.length > 0) {\n analytics.capture(WIZARD_INTERACTION_EVENT_NAME, {\n action: 'wizard_env_vars_uploaded',\n integration: config.metadata.integration,\n variable_count: uploadedEnvVars.length,\n variable_keys: uploadedEnvVars,\n });\n }\n }\n\n if (sess.signup) {\n const deepLink = await requestDeepLink(\n credentials.accessToken,\n credentials.host,\n );\n if (deepLink) {\n sess.frameworkContext[DASHBOARD_DEEP_LINK_KEY] = deepLink;\n if (process.env.NODE_ENV !== 'test') {\n opn(deepLink, { wait: false }).catch(() => {\n // opn throws in environments without a browser\n });\n }\n }\n }\n },\n\n buildOutroData: (sess, credentials, cloudRegion) => {\n const envVars = config.environment.getEnvVars(\n credentials.projectApiKey,\n credentials.host,\n );\n const deepLink = sess.frameworkContext[DASHBOARD_DEEP_LINK_KEY];\n const continueUrl = resolveContinueUrl(sess, cloudRegion, deepLink);\n\n const changes = [\n ...config.ui.getOutroChanges(frameworkContext),\n Object.keys(envVars).length > 0\n ? 'Added environment variables to .env file'\n : '',\n ].filter(Boolean);\n\n return {\n kind: OutroKind.Success as const,\n message: 'Successfully installed PostHog!',\n reportFile: SETUP_REPORT_FILE,\n changes,\n docsUrl: config.metadata.docsUrl,\n continueUrl,\n };\n },\n };\n },\n};\n\nexport { POSTHOG_INTEGRATION_PROGRAM } from './steps.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,eAAsB,gBACpB,YACkC;AAClC,MAAK,MAAM,eAAe,OAAO,OAAO,YAAY,EAAE;EACpD,MAAM,SAAS,mBAAmB;AAClC,MAAI;AAOF,OANiB,MAAM,QAAQ,KAAK,CAClC,OAAO,UAAU,OAAO,EAAE,YAAY,CAAC,EACvC,IAAI,SAAgB,YAClB,iBAAiB,QAAQ,MAAM,EAAA,IAAuB,CACvD,CACF,CAAC,CAEA,QAAO;UAEH;;;;;;;;;;;;ACnBZ,MAAM,kBAAkB,CAAC,UAAU,oBAAoB;AAEvD,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAGD,MAAM,sBAAsB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAA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,eACZ,YAAY,KACb;AACD,QAAI,OAAO,YAAY,iBAAiB;KACtC,MAAM,EAAE,mCAAmC,MAAM,OAC/C;KAEF,MAAM,kBAAkB,MAAM,+BAC5B,SACA;MACE,aAAa,OAAO,SAAS;MAC7B,SAAS;MACV,CACF;AACD,SAAI,gBAAgB,SAAS,EAC3B,WAAU,QAAQ,+BAA+B;MAC/C,QAAQ;MACR,aAAa,OAAO,SAAS;MAC7B,gBAAgB,gBAAgB;MAChC,eAAe;MAChB,CAAC;;AAIN,QAAI,KAAK,QAAQ;KACf,MAAM,WAAW,MAAM,gBACrB,YAAY,aACZ,YAAY,KACb;AACD,SAAI,UAAU;AACZ,WAAK,iBAAiB,2BAA2B;AAE/C,UAAI,UAAU,EAAE,MAAM,OAAO,CAAC,CAAC,YAAY,GAEzC;;;;GAMV,iBAAiB,MAAM,aAAa,gBAAgB;IAClD,MAAM,UAAU,OAAO,YAAY,WACjC,YAAY,eACZ,YAAY,KACb;IACD,MAAM,WAAW,KAAK,iBAAiB;IACvC,MAAM,cAAc,mBAAmB,MAAM,aAAa,SAAS;AASnE,WAAO;KACL,MAAA;KACA,SAAS;KACT,YAAY;KACZ,SAXc,CACd,GAAG,OAAO,GAAG,gBAAgB,iBAAiB,EAC9C,OAAO,KAAK,QAAQ,CAAC,SAAS,IAC1B,6CACA,GACL,CAAC,OAAO,QAAQ;KAOf,SAAS,OAAO,SAAS;KACzB;KACD;;GAEJ;;CAEJ"}
@@ -1,5 +1,6 @@
1
- import { L as POSTHOG_US_CLIENT_ID, V as WIZARD_PROVISIONING_SCOPES, W as WIZARD_USER_AGENT, s as logToFile } from "./debug-C4jRuzny.js";
2
- import { n as analytics } from "./analytics-DZaUgJte.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-B_-DWIq7.js";
2
+ import { L as POSTHOG_US_CLIENT_ID, V as WIZARD_PROVISIONING_SCOPES, W as WIZARD_USER_AGENT, s as logToFile } from "./debug-Bx7nvCWW.js";
3
+ import { t as analytics } from "./analytics-DN_Gy87F.js";
3
4
  import axios from "axios";
4
5
  import * as crypto from "node:crypto";
5
6
  import { z } from "zod";
@@ -12,6 +13,10 @@ import { z } from "zod";
12
13
  * 2. POST /oauth/token - exchange code for tokens (with PKCE)
13
14
  * 3. POST /resources - provision project, get API key
14
15
  */
16
+ var provisioning_exports = /* @__PURE__ */ __exportAll({
17
+ provisionNewAccount: () => provisionNewAccount,
18
+ requestDeepLink: () => requestDeepLink
19
+ });
15
20
  const WIZARD_CLIENT_ID = POSTHOG_US_CLIENT_ID;
16
21
  const API_VERSION = "0.1d";
17
22
  const PROVISIONING_BASE_URL = "https://us.posthog.com";
@@ -161,6 +166,6 @@ async function requestDeepLink(accessToken, host) {
161
166
  }
162
167
  }
163
168
  //#endregion
164
- export { requestDeepLink as n, provisionNewAccount as t };
169
+ export { provisioning_exports as n, requestDeepLink as r, provisionNewAccount as t };
165
170
 
166
- //# sourceMappingURL=provisioning-C_ETLiZE.js.map
171
+ //# sourceMappingURL=provisioning-C96Kw-9D.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"provisioning-C_ETLiZE.js","names":[],"sources":["../src/utils/provisioning.ts"],"sourcesContent":["/**\n * Provisioning API client for creating new PostHog accounts.\n *\n * Uses the agentic provisioning API with PKCE auth:\n * 1. POST /account_requests - create account, get auth code\n * 2. POST /oauth/token - exchange code for tokens (with PKCE)\n * 3. POST /resources - provision project, get API key\n */\n\nimport * as crypto from 'node:crypto';\nimport axios from 'axios';\nimport { z } from 'zod';\nimport {\n IS_DEV,\n POSTHOG_DEV_CLIENT_ID,\n POSTHOG_US_CLIENT_ID,\n WIZARD_PROVISIONING_SCOPES,\n WIZARD_USER_AGENT,\n} from '@lib/constants';\nimport { logToFile } from './debug';\nimport { analytics } from './analytics';\n\nconst WIZARD_CLIENT_ID = IS_DEV ? POSTHOG_DEV_CLIENT_ID : POSTHOG_US_CLIENT_ID;\nconst API_VERSION = '0.1d';\n\nconst PROVISIONING_BASE_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://us.posthog.com';\n\nfunction generateCodeVerifier(): string {\n return crypto.randomBytes(32).toString('base64url');\n}\n\nfunction generateCodeChallenge(verifier: string): string {\n return crypto.createHash('sha256').update(verifier).digest('base64url');\n}\n\n// --- Response schemas ---\n\nconst AccountRequestResponseSchema = z.object({\n id: z.string(),\n type: z.enum(['oauth', 'requires_auth', 'error']),\n oauth: z\n .object({\n code: z.string(),\n })\n .optional(),\n error: z\n .object({\n code: z.string(),\n message: z.string(),\n })\n .optional(),\n});\n\nconst TokenResponseSchema = z.object({\n token_type: z.string(),\n access_token: z.string(),\n refresh_token: z.string(),\n expires_in: z.number(),\n account: z\n .object({\n id: z.string(),\n })\n .optional(),\n});\n\nconst ResourceResponseSchema = z.object({\n status: z.string(),\n id: z.string(),\n service_id: z.string(),\n complete: z\n .object({\n access_configuration: z.object({\n api_key: z.string(),\n host: z.string(),\n personal_api_key: z.string().optional(),\n }),\n })\n .optional(),\n});\n\nexport interface ProvisioningResult {\n accessToken: string;\n refreshToken: string;\n projectApiKey: string;\n host: string;\n personalApiKey?: string;\n projectId: string;\n accountId: string;\n}\n\n/**\n * Create a new PostHog account and provision a project via the provisioning API.\n *\n * This is the \"no browser\" signup path: the wizard collects the email,\n * calls the provisioning API to create the account, and gets back\n * credentials without opening a browser.\n */\nexport async function provisionNewAccount(\n email: string,\n name: string,\n region: 'US' | 'EU' = 'US',\n opts?: { orgName?: string; projectName?: string },\n): Promise<ProvisioningResult> {\n const codeVerifier = generateCodeVerifier();\n const codeChallenge = generateCodeChallenge(codeVerifier);\n\n logToFile('[provisioning] starting account creation');\n\n // Step 1: Create account\n const accountRes = await axios.post(\n `${PROVISIONING_BASE_URL}/api/agentic/provisioning/account_requests`,\n {\n id: crypto.randomUUID(),\n email,\n name,\n client_id: WIZARD_CLIENT_ID,\n code_challenge: codeChallenge,\n code_challenge_method: 'S256',\n scopes: WIZARD_PROVISIONING_SCOPES,\n configuration: {\n region,\n ...(opts?.orgName ? { organization_name: opts.orgName } : {}),\n },\n },\n {\n headers: {\n 'Content-Type': 'application/json',\n 'API-Version': API_VERSION,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n timeout: 30_000,\n },\n );\n\n const accountData = AccountRequestResponseSchema.parse(accountRes.data);\n\n if (accountData.type === 'error') {\n const msg = accountData.error?.message ?? 'Account creation failed';\n analytics.captureException(new Error(msg), {\n step: 'provisioning_account_request',\n error_code: accountData.error?.code,\n });\n throw new Error(msg);\n }\n\n if (accountData.type === 'requires_auth') {\n throw new Error(\n 'This email is already associated with a PostHog account. Please use the login flow instead.',\n );\n }\n\n const code = accountData.oauth?.code;\n if (!code) {\n throw new Error('No authorization code received from account creation');\n }\n\n logToFile('[provisioning] account created, exchanging code for tokens');\n\n // Step 2: Exchange code for tokens\n const tokenRes = await axios.post(\n `${PROVISIONING_BASE_URL}/api/agentic/oauth/token`,\n new URLSearchParams({\n grant_type: 'authorization_code',\n code,\n code_verifier: codeVerifier,\n }).toString(),\n {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'API-Version': API_VERSION,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n timeout: 30_000,\n },\n );\n\n const tokenData = TokenResponseSchema.parse(tokenRes.data);\n\n logToFile('[provisioning] tokens received, provisioning resources');\n\n // Step 3: Provision resources\n const resourceRes = await axios.post(\n `${PROVISIONING_BASE_URL}/api/agentic/provisioning/resources`,\n {\n service_id: 'analytics',\n ...(opts?.projectName\n ? { configuration: { project_name: opts.projectName } }\n : {}),\n },\n {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${tokenData.access_token}`,\n 'API-Version': API_VERSION,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n timeout: 30_000,\n },\n );\n\n const resourceData = ResourceResponseSchema.parse(resourceRes.data);\n\n if (resourceData.status !== 'complete' || !resourceData.complete) {\n throw new Error('Resource provisioning did not complete');\n }\n\n logToFile('[provisioning] resources provisioned successfully');\n\n return {\n accessToken: tokenData.access_token,\n refreshToken: tokenData.refresh_token,\n projectApiKey: resourceData.complete.access_configuration.api_key,\n host: resourceData.complete.access_configuration.host,\n personalApiKey: resourceData.complete.access_configuration.personal_api_key,\n projectId: resourceData.id,\n accountId: tokenData.account?.id ?? '',\n };\n}\n\n/**\n * Request a one-time deep link URL that logs the user into PostHog\n * and redirects to their project dashboard.\n */\nexport async function requestDeepLink(\n accessToken: string,\n host: string,\n): Promise<string | null> {\n try {\n const baseUrl = host\n .replace('us.i.posthog.com', 'us.posthog.com')\n .replace('eu.i.posthog.com', 'eu.posthog.com');\n\n const res = await axios.post(\n `${baseUrl}/api/agentic/provisioning/deep_links`,\n { purpose: 'dashboard' },\n {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n 'API-Version': API_VERSION,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n timeout: 10_000,\n },\n );\n\n const url = res.data?.url;\n if (typeof url === 'string') {\n logToFile(`[provisioning] deep link created: ${url}`);\n return url;\n }\n return null;\n } catch {\n logToFile('[provisioning] deep link request failed, skipping');\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAM,mBAAoD;AAC1D,MAAM,cAAc;AAEpB,MAAM,wBAEF;AAEJ,SAAS,uBAA+B;AACtC,QAAO,OAAO,YAAY,GAAG,CAAC,SAAS,YAAY;;AAGrD,SAAS,sBAAsB,UAA0B;AACvD,QAAO,OAAO,WAAW,SAAS,CAAC,OAAO,SAAS,CAAC,OAAO,YAAY;;AAKzE,MAAM,+BAA+B,EAAE,OAAO;CAC5C,IAAI,EAAE,QAAQ;CACd,MAAM,EAAE,KAAK;EAAC;EAAS;EAAiB;EAAQ,CAAC;CACjD,OAAO,EACJ,OAAO,EACN,MAAM,EAAE,QAAQ,EACjB,CAAC,CACD,UAAU;CACb,OAAO,EACJ,OAAO;EACN,MAAM,EAAE,QAAQ;EAChB,SAAS,EAAE,QAAQ;EACpB,CAAC,CACD,UAAU;CACd,CAAC;AAEF,MAAM,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,eAAe;IACf,cAAc;IACf;GACD,SAAS;GACV,CACF,EAEe,MAAM;AACtB,MAAI,OAAO,QAAQ,UAAU;AAC3B,aAAU,qCAAqC,MAAM;AACrD,UAAO;;AAET,SAAO;SACD;AACN,YAAU,oDAAoD;AAC9D,SAAO"}
1
+ {"version":3,"file":"provisioning-C96Kw-9D.js","names":[],"sources":["../src/utils/provisioning.ts"],"sourcesContent":["/**\n * Provisioning API client for creating new PostHog accounts.\n *\n * Uses the agentic provisioning API with PKCE auth:\n * 1. POST /account_requests - create account, get auth code\n * 2. POST /oauth/token - exchange code for tokens (with PKCE)\n * 3. POST /resources - provision project, get API key\n */\n\nimport * as crypto from 'node:crypto';\nimport axios from 'axios';\nimport { z } from 'zod';\nimport {\n IS_DEV,\n POSTHOG_DEV_CLIENT_ID,\n POSTHOG_US_CLIENT_ID,\n WIZARD_PROVISIONING_SCOPES,\n WIZARD_USER_AGENT,\n} from '@lib/constants';\nimport { logToFile } from './debug';\nimport { analytics } from './analytics';\n\nconst WIZARD_CLIENT_ID = IS_DEV ? POSTHOG_DEV_CLIENT_ID : POSTHOG_US_CLIENT_ID;\nconst API_VERSION = '0.1d';\n\nconst PROVISIONING_BASE_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://us.posthog.com';\n\nfunction generateCodeVerifier(): string {\n return crypto.randomBytes(32).toString('base64url');\n}\n\nfunction generateCodeChallenge(verifier: string): string {\n return crypto.createHash('sha256').update(verifier).digest('base64url');\n}\n\n// --- Response schemas ---\n\nconst AccountRequestResponseSchema = z.object({\n id: z.string(),\n type: z.enum(['oauth', 'requires_auth', 'error']),\n oauth: z\n .object({\n code: z.string(),\n })\n .optional(),\n error: z\n .object({\n code: z.string(),\n message: z.string(),\n })\n .optional(),\n});\n\nconst TokenResponseSchema = z.object({\n token_type: z.string(),\n access_token: z.string(),\n refresh_token: z.string(),\n expires_in: z.number(),\n account: z\n .object({\n id: z.string(),\n })\n .optional(),\n});\n\nconst ResourceResponseSchema = z.object({\n status: z.string(),\n id: z.string(),\n service_id: z.string(),\n complete: z\n .object({\n access_configuration: z.object({\n api_key: z.string(),\n host: z.string(),\n personal_api_key: z.string().optional(),\n }),\n })\n .optional(),\n});\n\nexport interface ProvisioningResult {\n accessToken: string;\n refreshToken: string;\n projectApiKey: string;\n host: string;\n personalApiKey?: string;\n projectId: string;\n accountId: string;\n}\n\n/**\n * Create a new PostHog account and provision a project via the provisioning API.\n *\n * This is the \"no browser\" signup path: the wizard collects the email,\n * calls the provisioning API to create the account, and gets back\n * credentials without opening a browser.\n */\nexport async function provisionNewAccount(\n email: string,\n name: string,\n region: 'US' | 'EU' = 'US',\n opts?: { orgName?: string; projectName?: string },\n): Promise<ProvisioningResult> {\n const codeVerifier = generateCodeVerifier();\n const codeChallenge = generateCodeChallenge(codeVerifier);\n\n logToFile('[provisioning] starting account creation');\n\n // Step 1: Create account\n const accountRes = await axios.post(\n `${PROVISIONING_BASE_URL}/api/agentic/provisioning/account_requests`,\n {\n id: crypto.randomUUID(),\n email,\n name,\n client_id: WIZARD_CLIENT_ID,\n code_challenge: codeChallenge,\n code_challenge_method: 'S256',\n scopes: WIZARD_PROVISIONING_SCOPES,\n configuration: {\n region,\n ...(opts?.orgName ? { organization_name: opts.orgName } : {}),\n },\n },\n {\n headers: {\n 'Content-Type': 'application/json',\n 'API-Version': API_VERSION,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n timeout: 30_000,\n },\n );\n\n const accountData = AccountRequestResponseSchema.parse(accountRes.data);\n\n if (accountData.type === 'error') {\n const msg = accountData.error?.message ?? 'Account creation failed';\n analytics.captureException(new Error(msg), {\n step: 'provisioning_account_request',\n error_code: accountData.error?.code,\n });\n throw new Error(msg);\n }\n\n if (accountData.type === 'requires_auth') {\n throw new Error(\n 'This email is already associated with a PostHog account. Please use the login flow instead.',\n );\n }\n\n const code = accountData.oauth?.code;\n if (!code) {\n throw new Error('No authorization code received from account creation');\n }\n\n logToFile('[provisioning] account created, exchanging code for tokens');\n\n // Step 2: Exchange code for tokens\n const tokenRes = await axios.post(\n `${PROVISIONING_BASE_URL}/api/agentic/oauth/token`,\n new URLSearchParams({\n grant_type: 'authorization_code',\n code,\n code_verifier: codeVerifier,\n }).toString(),\n {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'API-Version': API_VERSION,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n timeout: 30_000,\n },\n );\n\n const tokenData = TokenResponseSchema.parse(tokenRes.data);\n\n logToFile('[provisioning] tokens received, provisioning resources');\n\n // Step 3: Provision resources\n const resourceRes = await axios.post(\n `${PROVISIONING_BASE_URL}/api/agentic/provisioning/resources`,\n {\n service_id: 'analytics',\n ...(opts?.projectName\n ? { configuration: { project_name: opts.projectName } }\n : {}),\n },\n {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${tokenData.access_token}`,\n 'API-Version': API_VERSION,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n timeout: 30_000,\n },\n );\n\n const resourceData = ResourceResponseSchema.parse(resourceRes.data);\n\n if (resourceData.status !== 'complete' || !resourceData.complete) {\n throw new Error('Resource provisioning did not complete');\n }\n\n logToFile('[provisioning] resources provisioned successfully');\n\n return {\n accessToken: tokenData.access_token,\n refreshToken: tokenData.refresh_token,\n projectApiKey: resourceData.complete.access_configuration.api_key,\n host: resourceData.complete.access_configuration.host,\n personalApiKey: resourceData.complete.access_configuration.personal_api_key,\n projectId: resourceData.id,\n accountId: tokenData.account?.id ?? '',\n };\n}\n\n/**\n * Request a one-time deep link URL that logs the user into PostHog\n * and redirects to their project dashboard.\n */\nexport async function requestDeepLink(\n accessToken: string,\n host: string,\n): Promise<string | null> {\n try {\n const baseUrl = host\n .replace('us.i.posthog.com', 'us.posthog.com')\n .replace('eu.i.posthog.com', 'eu.posthog.com');\n\n const res = await axios.post(\n `${baseUrl}/api/agentic/provisioning/deep_links`,\n { purpose: 'dashboard' },\n {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n 'API-Version': API_VERSION,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n timeout: 10_000,\n },\n );\n\n const url = res.data?.url;\n if (typeof url === 'string') {\n logToFile(`[provisioning] deep link created: ${url}`);\n return url;\n }\n return null;\n } catch {\n logToFile('[provisioning] deep link request failed, skipping');\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,MAAM,mBAAoD;AAC1D,MAAM,cAAc;AAEpB,MAAM,wBAEF;AAEJ,SAAS,uBAA+B;AACtC,QAAO,OAAO,YAAY,GAAG,CAAC,SAAS,YAAY;;AAGrD,SAAS,sBAAsB,UAA0B;AACvD,QAAO,OAAO,WAAW,SAAS,CAAC,OAAO,SAAS,CAAC,OAAO,YAAY;;AAKzE,MAAM,+BAA+B,EAAE,OAAO;CAC5C,IAAI,EAAE,QAAQ;CACd,MAAM,EAAE,KAAK;EAAC;EAAS;EAAiB;EAAQ,CAAC;CACjD,OAAO,EACJ,OAAO,EACN,MAAM,EAAE,QAAQ,EACjB,CAAC,CACD,UAAU;CACb,OAAO,EACJ,OAAO;EACN,MAAM,EAAE,QAAQ;EAChB,SAAS,EAAE,QAAQ;EACpB,CAAC,CACD,UAAU;CACd,CAAC;AAEF,MAAM,sBAAsB,EAAE,OAAO;CACnC,YAAY,EAAE,QAAQ;CACtB,cAAc,EAAE,QAAQ;CACxB,eAAe,EAAE,QAAQ;CACzB,YAAY,EAAE,QAAQ;CACtB,SAAS,EACN,OAAO,EACN,IAAI,EAAE,QAAQ,EACf,CAAC,CACD,UAAU;CACd,CAAC;AAEF,MAAM,yBAAyB,EAAE,OAAO;CACtC,QAAQ,EAAE,QAAQ;CAClB,IAAI,EAAE,QAAQ;CACd,YAAY,EAAE,QAAQ;CACtB,UAAU,EACP,OAAO,EACN,sBAAsB,EAAE,OAAO;EAC7B,SAAS,EAAE,QAAQ;EACnB,MAAM,EAAE,QAAQ;EAChB,kBAAkB,EAAE,QAAQ,CAAC,UAAU;EACxC,CAAC,EACH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M,cACN,EAAE,eAAe,EAAE,cAAc,KAAK,aAAa,EAAE,GACrD,EAAE;EACP,EACD;EACE,SAAS;GACP,gBAAgB;GAChB,eAAe,UAAU,UAAU;GACnC,eAAe;GACf,cAAc;GACf;EACD,SAAS;EACV,CACF;CAED,MAAM,eAAe,uBAAuB,MAAM,YAAY,KAAK;AAEnE,KAAI,aAAa,WAAW,cAAc,CAAC,aAAa,SACtD,OAAM,IAAI,MAAM,yCAAyC;AAG3D,WAAU,oDAAoD;AAE9D,QAAO;EACL,aAAa,UAAU;EACvB,cAAc,UAAU;EACxB,eAAe,aAAa,SAAS,qBAAqB;EAC1D,MAAM,aAAa,SAAS,qBAAqB;EACjD,gBAAgB,aAAa,SAAS,qBAAqB;EAC3D,WAAW,aAAa;EACxB,WAAW,UAAU,SAAS,MAAM;EACrC;;;;;;AAOH,eAAsB,gBACpB,aACA,MACwB;AACxB,KAAI;EACF,MAAM,UAAU,KACb,QAAQ,oBAAoB,iBAAiB,CAC7C,QAAQ,oBAAoB,iBAAiB;EAgBhD,MAAM,OAdM,MAAM,MAAM,KACtB,GAAG,QAAQ,uCACX,EAAE,SAAS,aAAa,EACxB;GACE,SAAS;IACP,gBAAgB;IAChB,eAAe,UAAU;IACzB,eAAe;IACf,cAAc;IACf;GACD,SAAS;GACV,CACF,EAEe,MAAM;AACtB,MAAI,OAAO,QAAQ,UAAU;AAC3B,aAAU,qCAAqC,MAAM;AACrD,UAAO;;AAET,SAAO;SACD;AACN,YAAU,oDAAoD;AAC9D,SAAO"}
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B_-DWIq7.js";
2
- import { p as getUI } from "./debug-C4jRuzny.js";
3
- import { c as createVersionBucket, h as detectAllPackageManagers, o as tryGetPackageJson } from "./setup-utils-DdAdxUTV.js";
4
- import { n as getInstalledPackageVersion, r as hasDeclaredDependency, t as getDeclaredVersion } from "./package-json-v_g2YlN1.js";
5
- import { a as gradlePackageManager, c as getPackageManagerName$1, i as detectPythonPackageManagers, l as getPythonVersion, n as composerPackageManager, o as swiftPackageManager, r as detectNodePackageManagers, s as detectPackageManager$1, t as bundlerPackageManager, u as getPythonVersionBucket } from "./package-manager-DLt75bit.js";
2
+ import { p as getUI } from "./debug-Bx7nvCWW.js";
3
+ import { a as createVersionBucket, i as tryGetPackageJson, s as detectAllPackageManagers } from "./setup-utils-Bpfsap9L.js";
4
+ import { n as getInstalledPackageVersion, r as hasDeclaredDependency, t as getDeclaredVersion } from "./package-json-DCuoye-H.js";
5
+ import { a as gradlePackageManager, c as getPackageManagerName$1, i as detectPythonPackageManagers, l as getPythonVersion, n as composerPackageManager, o as swiftPackageManager, r as detectNodePackageManagers, s as detectPackageManager$1, t as bundlerPackageManager, u as getPythonVersionBucket } from "./package-manager-CKQLR20D.js";
6
6
  import * as semver from "semver";
7
7
  import { major, minVersion } from "semver";
8
8
  import * as fs$1 from "node:fs";
@@ -2918,4 +2918,4 @@ const FRAMEWORK_REGISTRY = {
2918
2918
  //#endregion
2919
2919
  export { SPINNER_MESSAGE as i, registry_exports as n, DEFAULT_PACKAGE_INSTALLATION as r, FRAMEWORK_REGISTRY as t };
2920
2920
 
2921
- //# sourceMappingURL=registry-DqbwO5EL.js.map
2921
+ //# sourceMappingURL=registry-B9k73FKR.js.map