@posthog/wizard 2.11.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -7
- package/dist/{McpScreen-DvUncZBi.js → AuditChecksViewer-B0J7zcY2.js} +434 -22
- package/dist/AuditChecksViewer-B0J7zcY2.js.map +1 -0
- package/dist/{add-mcp-server-to-clients-Br1hDRiB.js → add-mcp-server-to-clients-CUNR00bB.js} +5 -5
- package/dist/{add-mcp-server-to-clients-Br1hDRiB.js.map → add-mcp-server-to-clients-CUNR00bB.js.map} +1 -1
- package/dist/{readiness-gQvQNCeL.js → agent-interface-CV0-vtxj.js} +328 -462
- package/dist/agent-interface-CV0-vtxj.js.map +1 -0
- package/dist/{agent-runner-fWYFO4H0.js → agent-runner-LvVQH31D.js} +21 -31
- package/dist/{agent-runner-fWYFO4H0.js.map → agent-runner-LvVQH31D.js.map} +1 -1
- package/dist/analytics-BH7bEHQR.js +2 -0
- package/dist/analytics-VM7laaFx.js +123 -0
- package/dist/analytics-VM7laaFx.js.map +1 -0
- package/dist/bin.js +529 -42
- package/dist/bin.js.map +1 -1
- package/dist/{debug-D-0xueVl.js → debug-BdcTB7EF.js} +1 -1
- package/dist/debug-Cqi6nVfX.js +686 -0
- package/dist/debug-Cqi6nVfX.js.map +1 -0
- package/dist/{defaults-CPH6eWhN.js → defaults-GbLPuHxj.js} +1 -1
- package/dist/{defaults-CPH6eWhN.js.map → defaults-GbLPuHxj.js.map} +1 -1
- package/dist/{detection-B7GNzve-.js → detection-CSjmal-X.js} +3 -3
- package/dist/{detection-B7GNzve-.js.map → detection-CSjmal-X.js.map} +1 -1
- package/dist/{env-api-key-DU8uIEvo.js → env-api-key-D5G2PrXW.js} +1 -1
- package/dist/{env-api-key-DU8uIEvo.js.map → env-api-key-D5G2PrXW.js.map} +1 -1
- package/dist/{file-DhSBlq-x.js → file-8iNrXHkG.js} +2 -2
- package/dist/{file-DhSBlq-x.js.map → file-8iNrXHkG.js.map} +1 -1
- package/dist/{file-utils-Dy9JncCo.js → file-utils-DnTSiTJw.js} +1 -1
- package/dist/{file-utils-Dy9JncCo.js.map → file-utils-DnTSiTJw.js.map} +1 -1
- package/dist/{package-manager-D3Lo6nXf.js → package-manager-CD8RQW-e.js} +2 -2
- package/dist/{package-manager-D3Lo6nXf.js.map → package-manager-CD8RQW-e.js.map} +1 -1
- package/dist/paths-DJS47p5x.js +26 -0
- package/dist/paths-DJS47p5x.js.map +1 -0
- package/dist/{posthog-integration-D4SRhJIQ.js → posthog-integration-BL21S3T6.js} +41 -13
- package/dist/posthog-integration-BL21S3T6.js.map +1 -0
- package/dist/{posthog-ByrpqEjN.js → posthog-vm0k9PKS.js} +1 -1
- package/dist/{posthog-ByrpqEjN.js.map → posthog-vm0k9PKS.js.map} +1 -1
- package/dist/provisioning-BdQ1ONIg.js +2 -0
- package/dist/provisioning-g9aoVIEd.js +166 -0
- package/dist/provisioning-g9aoVIEd.js.map +1 -0
- package/dist/{registry-DaPKstG3.js → registry-BaMEaAKd.js} +4 -5
- package/dist/{registry-DaPKstG3.js.map → registry-BaMEaAKd.js.map} +1 -1
- package/dist/{router-SgzmfLGi.js → router-COhhuIW3.js} +4 -3
- package/dist/router-COhhuIW3.js.map +1 -0
- package/dist/{setup-utils-y4s-3uKT.js → setup-utils-CNV7FSlY.js} +11 -150
- package/dist/setup-utils-CNV7FSlY.js.map +1 -0
- package/dist/setup-utils-CU4FIqjB.js +2 -0
- package/dist/{start-playground-g1TxpCZ5.js → start-playground-C9GWnVdM.js} +102 -7
- package/dist/start-playground-C9GWnVdM.js.map +1 -0
- package/dist/start-tui-B_zwutLe.js +4195 -0
- package/dist/start-tui-B_zwutLe.js.map +1 -0
- package/dist/{steps-D1zKDqAo.js → steps-Dawz7k3T.js} +8 -8
- package/dist/steps-Dawz7k3T.js.map +1 -0
- package/dist/{task-stream-DX_jKDQu.js → task-stream-CX7Uf6EM.js} +4 -4
- package/dist/{task-stream-DX_jKDQu.js.map → task-stream-CX7Uf6EM.js.map} +1 -1
- package/dist/{telemetry-CyUUSAYy.js → telemetry-D6bjWA-A.js} +2 -2
- package/dist/{telemetry-CyUUSAYy.js.map → telemetry-D6bjWA-A.js.map} +1 -1
- package/dist/{wizard-abort-Buodno3f.js → wizard-abort-CJkNkSjT.js} +6 -4
- package/dist/{wizard-abort-Buodno3f.js.map → wizard-abort-CJkNkSjT.js.map} +1 -1
- package/dist/{wizard-abort-DZmO_sIZ.js → wizard-abort-Dl0BkqhT.js} +1 -1
- package/dist/wizard-session-BQC9vy9Z.js +2 -0
- package/dist/{wizard-session-D5bggSsu.js → wizard-session-BcNJTl2I.js} +1 -1
- package/dist/{wizard-session-D5bggSsu.js.map → wizard-session-BcNJTl2I.js.map} +1 -1
- package/dist/{wizard-ui-BExOjdjA.js → wizard-ui-YdGFRyu_.js} +1 -1
- package/dist/wizard-ui-YdGFRyu_.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/McpScreen-DvUncZBi.js.map +0 -1
- package/dist/agent-skill-DJOzDaQV.js +0 -59
- package/dist/agent-skill-DJOzDaQV.js.map +0 -1
- package/dist/analytics-CfAUlt6-.js +0 -2
- package/dist/analytics-D3rY3TaN.js +0 -210
- package/dist/analytics-D3rY3TaN.js.map +0 -1
- package/dist/debug-gWEjmYVV.js +0 -203
- package/dist/debug-gWEjmYVV.js.map +0 -1
- package/dist/paths-BL-x2rFy.js +0 -16
- package/dist/paths-BL-x2rFy.js.map +0 -1
- package/dist/posthog-integration-D4SRhJIQ.js.map +0 -1
- package/dist/readiness-gQvQNCeL.js.map +0 -1
- package/dist/router-SgzmfLGi.js.map +0 -1
- package/dist/setup-utils-_ONxN-TT.js +0 -2
- package/dist/setup-utils-y4s-3uKT.js.map +0 -1
- package/dist/start-playground-g1TxpCZ5.js.map +0 -1
- package/dist/start-tui-CQef69NR.js +0 -2167
- package/dist/start-tui-CQef69NR.js.map +0 -1
- package/dist/steps-D1zKDqAo.js.map +0 -1
- package/dist/wizard-session-COhklXAF.js +0 -2
- package/dist/wizard-ui-BExOjdjA.js.map +0 -1
|
@@ -1,2167 +0,0 @@
|
|
|
1
|
-
import { l as setUI, s as logToFile } from "./debug-gWEjmYVV.js";
|
|
2
|
-
import { E as getSkillsBaseUrl, S as WIZARD_TOOLS_MENU_FLAG_KEY, i as CONTEXT_MILL_URL, l as Integration, n as analytics, p as POSTHOG_DOCS_URL, u as OAUTH_PORTS, y as REMOTE_SKILLS_BASE_URL } from "./analytics-D3rY3TaN.js";
|
|
3
|
-
import { n as WIZARD_LOG_FILE } from "./paths-BL-x2rFy.js";
|
|
4
|
-
import { l as ApiError, p as getUiHostFromHost } from "./setup-utils-y4s-3uKT.js";
|
|
5
|
-
import { t as ADDITIONAL_FEATURE_LABELS } from "./wizard-session-D5bggSsu.js";
|
|
6
|
-
import { r as wizardAbort } from "./wizard-abort-Buodno3f.js";
|
|
7
|
-
import { m as fetchSkillMenu, p as downloadSkill, r as getBlockingServiceKeys } from "./readiness-gQvQNCeL.js";
|
|
8
|
-
import { a as STRIPE_SDKS, i as POSTHOG_SDKS, r as fetchHealthIssues } from "./bin.js";
|
|
9
|
-
import { t as ALL_FEATURE_VALUES } from "./defaults-CPH6eWhN.js";
|
|
10
|
-
import { a as getSupportedClients, c as removeMCPServer, i as getInstalledClients, o as getSupportedPluginClients, s as installPlugins, u as isPluginCapable } from "./add-mcp-server-to-clients-Br1hDRiB.js";
|
|
11
|
-
import "./router-SgzmfLGi.js";
|
|
12
|
-
import { C as Icons, S as Colors, _ as PickerMenu, a as ServiceHealthList, b as SplitView, c as HNViewer, d as EventPlanViewer, f as LogViewer, g as useStdoutDimensions, i as SEVERITY_ORDER, l as TabContainer, m as ConfirmationInput, n as IssueTable, o as TipsCard, p as ModalOverlay, r as SEVERITY_LABEL, s as LearnCard, t as McpScreen, u as ScreenContainer, v as ProgressList, w as WizardStore, y as LoadingBox } from "./McpScreen-DvUncZBi.js";
|
|
13
|
-
import { spawnSync } from "node:child_process";
|
|
14
|
-
import { join } from "node:path";
|
|
15
|
-
import path from "path";
|
|
16
|
-
import { Box, Text, render, useInput } from "ink";
|
|
17
|
-
import { createElement, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
18
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
-
import { readdir, rm } from "node:fs/promises";
|
|
20
|
-
//#region src/ui/tui/ink-ui.ts
|
|
21
|
-
const ANSI_RE = /\x1b\[[0-9;]*m/g;
|
|
22
|
-
function stripAnsi(s) {
|
|
23
|
-
return s.replace(ANSI_RE, "");
|
|
24
|
-
}
|
|
25
|
-
var InkUI = class {
|
|
26
|
-
constructor(store) {
|
|
27
|
-
this.store = store;
|
|
28
|
-
}
|
|
29
|
-
intro(message) {
|
|
30
|
-
this.store.pushStatus(message);
|
|
31
|
-
}
|
|
32
|
-
outro(message) {
|
|
33
|
-
this.store.pushStatus(stripAnsi(message));
|
|
34
|
-
if (!this.store.session.outroData) this.store.setOutroData({
|
|
35
|
-
kind: "success",
|
|
36
|
-
message: stripAnsi(message)
|
|
37
|
-
});
|
|
38
|
-
if (this.store.session.runPhase === "running") this.store.setRunPhase("completed");
|
|
39
|
-
}
|
|
40
|
-
outroError(data) {
|
|
41
|
-
this.store.setOutroData(data);
|
|
42
|
-
if (this.store.session.runPhase !== "error") this.store.setRunPhase("error");
|
|
43
|
-
}
|
|
44
|
-
setCredentials(credentials) {
|
|
45
|
-
this.store.setCredentials(credentials);
|
|
46
|
-
}
|
|
47
|
-
setDetectedFramework(label) {
|
|
48
|
-
this.store.setDetectedFramework(label);
|
|
49
|
-
}
|
|
50
|
-
onEnterScreen(screen, fn) {
|
|
51
|
-
this.store.onEnterScreen(screen, fn);
|
|
52
|
-
}
|
|
53
|
-
setLoginUrl(url) {
|
|
54
|
-
this.store.setLoginUrl(url);
|
|
55
|
-
}
|
|
56
|
-
showBlockingOutage(result) {
|
|
57
|
-
this.store.setReadinessResult(result);
|
|
58
|
-
return Promise.resolve();
|
|
59
|
-
}
|
|
60
|
-
setReadinessWarnings(result) {
|
|
61
|
-
this.store.setReadinessResult(result);
|
|
62
|
-
}
|
|
63
|
-
showPortConflict(processInfo) {
|
|
64
|
-
return this.store.showPortConflict(processInfo);
|
|
65
|
-
}
|
|
66
|
-
showSettingsOverride(conflicts, backupAndFix) {
|
|
67
|
-
return this.store.showSettingsOverride(conflicts, backupAndFix);
|
|
68
|
-
}
|
|
69
|
-
showAuthError() {
|
|
70
|
-
this.store.showAuthError();
|
|
71
|
-
}
|
|
72
|
-
startRun() {
|
|
73
|
-
this.store.setRunPhase("running");
|
|
74
|
-
}
|
|
75
|
-
cancel(message) {
|
|
76
|
-
this.store.pushStatus(message);
|
|
77
|
-
}
|
|
78
|
-
log = {
|
|
79
|
-
info: (message) => {
|
|
80
|
-
this.store.pushStatus(message);
|
|
81
|
-
},
|
|
82
|
-
warn: (message) => {
|
|
83
|
-
this.store.pushStatus(message);
|
|
84
|
-
},
|
|
85
|
-
error: (message) => {
|
|
86
|
-
this.store.pushStatus(message);
|
|
87
|
-
},
|
|
88
|
-
success: (message) => {
|
|
89
|
-
this.store.pushStatus(message);
|
|
90
|
-
},
|
|
91
|
-
step: (message) => {
|
|
92
|
-
this.store.pushStatus(message);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
note(message) {
|
|
96
|
-
this.store.pushStatus(message);
|
|
97
|
-
}
|
|
98
|
-
spinner() {
|
|
99
|
-
return {
|
|
100
|
-
start: (message) => {
|
|
101
|
-
if (message) this.store.pushStatus(message);
|
|
102
|
-
},
|
|
103
|
-
stop: (message) => {
|
|
104
|
-
if (message) this.store.pushStatus(message);
|
|
105
|
-
},
|
|
106
|
-
message: (msg) => {
|
|
107
|
-
if (msg) this.store.pushStatus(msg);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
pushStatus(message) {
|
|
112
|
-
this.store.pushStatus(message);
|
|
113
|
-
}
|
|
114
|
-
syncTodos(todos) {
|
|
115
|
-
this.store.syncTodos(todos);
|
|
116
|
-
}
|
|
117
|
-
setEventPlan(events) {
|
|
118
|
-
this.store.setEventPlan(events);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region src/ui/tui/screens/health/HealthCheckScreen.tsx
|
|
123
|
-
/**
|
|
124
|
-
* HealthCheckScreen — Flow screen between Intro and Auth.
|
|
125
|
-
*
|
|
126
|
-
* Three states:
|
|
127
|
-
* 1. Checking: spinner while health check runs
|
|
128
|
-
* 2. Healthy: isComplete returns true, router auto-advances to Auth
|
|
129
|
-
* 3. Blocking outage: shows affected services with Continue/Exit
|
|
130
|
-
*/
|
|
131
|
-
const EXAMPLE_PROMPT = "Integrate PostHog into this project using the skill files in .posthog/skills/. Read SKILL.md first, then follow the numbered workflow files in order.";
|
|
132
|
-
const SkillsDownloadedScreen = () => {
|
|
133
|
-
useInput(() => {
|
|
134
|
-
process.exit(0);
|
|
135
|
-
});
|
|
136
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
137
|
-
flexDirection: "column",
|
|
138
|
-
flexGrow: 1,
|
|
139
|
-
children: [
|
|
140
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
141
|
-
color: "green",
|
|
142
|
-
bold: true,
|
|
143
|
-
children: [Icons.check, " Skills downloaded to .posthog/skills/"]
|
|
144
|
-
}),
|
|
145
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
146
|
-
marginTop: 1,
|
|
147
|
-
flexDirection: "column",
|
|
148
|
-
children: [/* @__PURE__ */ jsx(Text, { children: "You can continue setup with another agent using this prompt:" }), /* @__PURE__ */ jsx(Box, {
|
|
149
|
-
marginTop: 1,
|
|
150
|
-
paddingLeft: 2,
|
|
151
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
152
|
-
color: "cyan",
|
|
153
|
-
children: EXAMPLE_PROMPT
|
|
154
|
-
})
|
|
155
|
-
})]
|
|
156
|
-
}),
|
|
157
|
-
/* @__PURE__ */ jsx(Box, {
|
|
158
|
-
marginTop: 1,
|
|
159
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
160
|
-
color: Colors.muted,
|
|
161
|
-
children: "Press any key to exit"
|
|
162
|
-
})
|
|
163
|
-
})
|
|
164
|
-
]
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
const HealthCheckScreen = ({ store }) => {
|
|
168
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
169
|
-
const [downloaded, setDownloaded] = useState(false);
|
|
170
|
-
const [downloading, setDownloading] = useState(false);
|
|
171
|
-
const result = store.session.readinessResult;
|
|
172
|
-
if (downloaded) return /* @__PURE__ */ jsx(SkillsDownloadedScreen, {});
|
|
173
|
-
if (!result) return /* @__PURE__ */ jsx(Box, {
|
|
174
|
-
flexDirection: "column",
|
|
175
|
-
flexGrow: 1,
|
|
176
|
-
alignItems: "center",
|
|
177
|
-
justifyContent: "center",
|
|
178
|
-
children: /* @__PURE__ */ jsx(LoadingBox, { message: "Checking service status..." })
|
|
179
|
-
});
|
|
180
|
-
const blockingKeys = getBlockingServiceKeys(result.health);
|
|
181
|
-
if (blockingKeys.length === 0) return null;
|
|
182
|
-
const isGithubReleasesDown = blockingKeys.includes("githubReleases");
|
|
183
|
-
const canDownloadSkills = result.health.githubReleases.status === "healthy";
|
|
184
|
-
const integration = store.session.integration;
|
|
185
|
-
const title = `Ongoing service disruptions`;
|
|
186
|
-
const docsUrl = store.session.frameworkConfig?.metadata.docsUrl;
|
|
187
|
-
const description = isGithubReleasesDown ? "The Wizard can't download necessary skills from GitHub Releases right now." : "The Wizard may not work reliably while services are affected.";
|
|
188
|
-
const handleDownloadAndExit = async () => {
|
|
189
|
-
if (downloading) return;
|
|
190
|
-
setDownloading(true);
|
|
191
|
-
const menu = await fetchSkillMenu(REMOTE_SKILLS_BASE_URL);
|
|
192
|
-
if (menu) {
|
|
193
|
-
const prefix = `integration-${integration}`;
|
|
194
|
-
const skills = (menu.categories["integration"] ?? []).filter((s) => s.id.startsWith(prefix));
|
|
195
|
-
for (const skill of skills) downloadSkill(skill, store.session.installDir, ".posthog/skills");
|
|
196
|
-
}
|
|
197
|
-
setDownloaded(true);
|
|
198
|
-
};
|
|
199
|
-
return /* @__PURE__ */ jsxs(ModalOverlay, {
|
|
200
|
-
borderColor: "red",
|
|
201
|
-
title,
|
|
202
|
-
width: 72,
|
|
203
|
-
footer: isGithubReleasesDown ? /* @__PURE__ */ jsx(ConfirmationInput, {
|
|
204
|
-
message: "",
|
|
205
|
-
confirmLabel: "",
|
|
206
|
-
cancelLabel: "Exit [Esc]",
|
|
207
|
-
onConfirm: () => void wizardAbort({ message: "Exited due to service outage." }),
|
|
208
|
-
onCancel: () => void wizardAbort({ message: "Exited due to service outage." })
|
|
209
|
-
}) : /* @__PURE__ */ jsx(ConfirmationInput, {
|
|
210
|
-
message: "Continue anyway?",
|
|
211
|
-
confirmLabel: "Continue [Enter]",
|
|
212
|
-
cancelLabel: canDownloadSkills && !isGithubReleasesDown ? downloading ? "Downloading..." : "Download skills & Exit [Esc]" : "Exit [Esc]",
|
|
213
|
-
onConfirm: () => store.dismissOutage(),
|
|
214
|
-
onCancel: canDownloadSkills && !isGithubReleasesDown ? () => void handleDownloadAndExit() : () => void wizardAbort({ message: "Exited due to service outage." })
|
|
215
|
-
}),
|
|
216
|
-
children: [
|
|
217
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
218
|
-
flexDirection: "column",
|
|
219
|
-
marginBottom: 1,
|
|
220
|
-
children: [/* @__PURE__ */ jsx(Box, {
|
|
221
|
-
marginBottom: 1,
|
|
222
|
-
children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
223
|
-
/* @__PURE__ */ jsx(Text, {
|
|
224
|
-
color: "red",
|
|
225
|
-
children: Icons.squareFilled
|
|
226
|
-
}),
|
|
227
|
-
/* @__PURE__ */ jsx(Text, {
|
|
228
|
-
dimColor: true,
|
|
229
|
-
children: " Down "
|
|
230
|
-
}),
|
|
231
|
-
/* @__PURE__ */ jsx(Text, {
|
|
232
|
-
color: "#DC9300",
|
|
233
|
-
children: Icons.squareFilled
|
|
234
|
-
}),
|
|
235
|
-
/* @__PURE__ */ jsx(Text, {
|
|
236
|
-
dimColor: true,
|
|
237
|
-
children: " Degraded"
|
|
238
|
-
})
|
|
239
|
-
] })
|
|
240
|
-
}), /* @__PURE__ */ jsx(ServiceHealthList, {
|
|
241
|
-
health: result.health,
|
|
242
|
-
filterKeys: blockingKeys,
|
|
243
|
-
showHealthy: false
|
|
244
|
-
})]
|
|
245
|
-
}),
|
|
246
|
-
/* @__PURE__ */ jsx(Text, {
|
|
247
|
-
dimColor: true,
|
|
248
|
-
children: description
|
|
249
|
-
}),
|
|
250
|
-
isGithubReleasesDown && docsUrl && /* @__PURE__ */ jsx(Box, {
|
|
251
|
-
marginTop: 1,
|
|
252
|
-
children: /* @__PURE__ */ jsxs(Text, { children: ["Set up manually: ", /* @__PURE__ */ jsx(Text, {
|
|
253
|
-
color: "cyan",
|
|
254
|
-
children: docsUrl
|
|
255
|
-
})] })
|
|
256
|
-
}),
|
|
257
|
-
canDownloadSkills && !isGithubReleasesDown && /* @__PURE__ */ jsx(Box, {
|
|
258
|
-
marginTop: 1,
|
|
259
|
-
children: /* @__PURE__ */ jsx(Text, { children: "You can still download the PostHog integration skills and continue with another agent." })
|
|
260
|
-
})
|
|
261
|
-
]
|
|
262
|
-
});
|
|
263
|
-
};
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region src/ui/tui/screens/doctor/DoctorIntroScreen.tsx
|
|
266
|
-
const DoctorIntroScreen = ({ store }) => {
|
|
267
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
268
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
269
|
-
flexDirection: "column",
|
|
270
|
-
children: [
|
|
271
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
272
|
-
flexDirection: "column",
|
|
273
|
-
marginBottom: 1,
|
|
274
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
275
|
-
bold: true,
|
|
276
|
-
color: Colors.accent,
|
|
277
|
-
children: "PostHog Doctor"
|
|
278
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
279
|
-
dimColor: true,
|
|
280
|
-
children: "Scan your project configuration for issues that may need attention."
|
|
281
|
-
})]
|
|
282
|
-
}),
|
|
283
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
284
|
-
flexDirection: "column",
|
|
285
|
-
marginBottom: 1,
|
|
286
|
-
children: [/* @__PURE__ */ jsx(Text, { children: "The wizard will:" }), /* @__PURE__ */ jsxs(Box, {
|
|
287
|
-
paddingLeft: 2,
|
|
288
|
-
flexDirection: "column",
|
|
289
|
-
children: [
|
|
290
|
-
/* @__PURE__ */ jsxs(Text, { children: [Icons.bullet, " Sign you in to PostHog"] }),
|
|
291
|
-
/* @__PURE__ */ jsxs(Text, { children: [Icons.bullet, " Fetch active health issues for your project"] }),
|
|
292
|
-
/* @__PURE__ */ jsxs(Text, { children: [Icons.bullet, " Show you what needs to be resolved, with docs links"] })
|
|
293
|
-
]
|
|
294
|
-
})]
|
|
295
|
-
}),
|
|
296
|
-
/* @__PURE__ */ jsx(PickerMenu, {
|
|
297
|
-
options: [{
|
|
298
|
-
label: "Continue",
|
|
299
|
-
value: "continue"
|
|
300
|
-
}, {
|
|
301
|
-
label: "Cancel",
|
|
302
|
-
value: "cancel"
|
|
303
|
-
}],
|
|
304
|
-
onSelect: (value) => {
|
|
305
|
-
if (value === "cancel") process.exit(0);
|
|
306
|
-
else store.completeSetup();
|
|
307
|
-
}
|
|
308
|
-
})
|
|
309
|
-
]
|
|
310
|
-
});
|
|
311
|
-
};
|
|
312
|
-
//#endregion
|
|
313
|
-
//#region src/ui/tui/screens/doctor/DoctorReportScreen.tsx
|
|
314
|
-
const DoctorReportScreen = ({ store }) => {
|
|
315
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
316
|
-
const { credentials } = store.session;
|
|
317
|
-
const accessToken = credentials?.accessToken;
|
|
318
|
-
const host = credentials?.host;
|
|
319
|
-
const projectId = credentials?.projectId;
|
|
320
|
-
const [state, setState] = useState({ kind: "loading" });
|
|
321
|
-
useEffect(() => {
|
|
322
|
-
if (!accessToken || !host || projectId == null) return;
|
|
323
|
-
let cancelled = false;
|
|
324
|
-
(async () => {
|
|
325
|
-
try {
|
|
326
|
-
const issues = await fetchHealthIssues(accessToken, host, projectId);
|
|
327
|
-
if (!cancelled) setState({
|
|
328
|
-
kind: "ready",
|
|
329
|
-
issues
|
|
330
|
-
});
|
|
331
|
-
} catch (err) {
|
|
332
|
-
if (!cancelled) setState({
|
|
333
|
-
kind: "error",
|
|
334
|
-
message: err instanceof ApiError && err.statusCode === 401 ? "Your PostHog session has expired. Re-run the wizard to sign in again." : err instanceof Error ? err.message : String(err)
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
})();
|
|
338
|
-
return () => {
|
|
339
|
-
cancelled = true;
|
|
340
|
-
};
|
|
341
|
-
}, [
|
|
342
|
-
accessToken,
|
|
343
|
-
host,
|
|
344
|
-
projectId
|
|
345
|
-
]);
|
|
346
|
-
if (!credentials) return /* @__PURE__ */ jsx(LoadingBox, { message: "Waiting for authentication..." });
|
|
347
|
-
if (state.kind === "loading") return /* @__PURE__ */ jsxs(Box, {
|
|
348
|
-
flexDirection: "column",
|
|
349
|
-
children: [/* @__PURE__ */ jsx(Header, {
|
|
350
|
-
host: credentials.host,
|
|
351
|
-
projectId: credentials.projectId
|
|
352
|
-
}), /* @__PURE__ */ jsx(LoadingBox, { message: "Fetching health issues..." })]
|
|
353
|
-
});
|
|
354
|
-
const healthUrl = `${getUiHostFromHost(credentials.host)}/project/${credentials.projectId}/health`;
|
|
355
|
-
if (state.kind === "error") return /* @__PURE__ */ jsxs(Box, {
|
|
356
|
-
flexDirection: "column",
|
|
357
|
-
children: [
|
|
358
|
-
/* @__PURE__ */ jsx(Header, {
|
|
359
|
-
host: credentials.host,
|
|
360
|
-
projectId: credentials.projectId
|
|
361
|
-
}),
|
|
362
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
363
|
-
flexDirection: "column",
|
|
364
|
-
marginY: 1,
|
|
365
|
-
children: [/* @__PURE__ */ jsxs(Text, {
|
|
366
|
-
color: Colors.error,
|
|
367
|
-
bold: true,
|
|
368
|
-
children: [Icons.squareFilled, " Failed to fetch health issues"]
|
|
369
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
370
|
-
dimColor: true,
|
|
371
|
-
children: state.message
|
|
372
|
-
})]
|
|
373
|
-
}),
|
|
374
|
-
/* @__PURE__ */ jsx(PickerMenu, {
|
|
375
|
-
options: [{
|
|
376
|
-
label: "Continue",
|
|
377
|
-
value: "continue"
|
|
378
|
-
}],
|
|
379
|
-
onSelect: () => {
|
|
380
|
-
store.setOutroData({
|
|
381
|
-
kind: "error",
|
|
382
|
-
message: "Failed to fetch health issues",
|
|
383
|
-
body: state.message,
|
|
384
|
-
docsUrl: POSTHOG_DOCS_URL
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
})
|
|
388
|
-
]
|
|
389
|
-
});
|
|
390
|
-
const { issues } = state;
|
|
391
|
-
if (issues.length === 0) return /* @__PURE__ */ jsxs(Box, {
|
|
392
|
-
flexDirection: "column",
|
|
393
|
-
children: [
|
|
394
|
-
/* @__PURE__ */ jsx(Header, {
|
|
395
|
-
host: credentials.host,
|
|
396
|
-
projectId: credentials.projectId
|
|
397
|
-
}),
|
|
398
|
-
/* @__PURE__ */ jsx(Box, {
|
|
399
|
-
marginY: 1,
|
|
400
|
-
children: /* @__PURE__ */ jsxs(Text, {
|
|
401
|
-
color: Colors.success,
|
|
402
|
-
bold: true,
|
|
403
|
-
children: [Icons.check, " No active issues — you're all set!"]
|
|
404
|
-
})
|
|
405
|
-
}),
|
|
406
|
-
/* @__PURE__ */ jsx(PickerMenu, {
|
|
407
|
-
options: [{
|
|
408
|
-
label: "Continue",
|
|
409
|
-
value: "continue"
|
|
410
|
-
}],
|
|
411
|
-
onSelect: () => {
|
|
412
|
-
store.setOutroData({
|
|
413
|
-
kind: "success",
|
|
414
|
-
message: "No active issues — your project looks healthy.",
|
|
415
|
-
docsUrl: POSTHOG_DOCS_URL,
|
|
416
|
-
continueUrl: healthUrl
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
})
|
|
420
|
-
]
|
|
421
|
-
});
|
|
422
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
423
|
-
flexDirection: "column",
|
|
424
|
-
children: [
|
|
425
|
-
/* @__PURE__ */ jsx(Header, {
|
|
426
|
-
host: credentials.host,
|
|
427
|
-
projectId: credentials.projectId
|
|
428
|
-
}),
|
|
429
|
-
/* @__PURE__ */ jsx(Box, {
|
|
430
|
-
marginTop: 1,
|
|
431
|
-
children: /* @__PURE__ */ jsx(Text, { children: formatSummaryLine(issues) })
|
|
432
|
-
}),
|
|
433
|
-
/* @__PURE__ */ jsx(Box, {
|
|
434
|
-
flexDirection: "column",
|
|
435
|
-
marginBottom: 1,
|
|
436
|
-
children: /* @__PURE__ */ jsx(IssueTable, { issues })
|
|
437
|
-
}),
|
|
438
|
-
/* @__PURE__ */ jsx(PickerMenu, {
|
|
439
|
-
options: [{
|
|
440
|
-
label: "Continue",
|
|
441
|
-
value: "continue"
|
|
442
|
-
}],
|
|
443
|
-
onSelect: () => {
|
|
444
|
-
store.setOutroData({
|
|
445
|
-
kind: "success",
|
|
446
|
-
message: `Found ${issues.length} active issue${issues.length === 1 ? "" : "s"}.`,
|
|
447
|
-
body: "Open the dashboard in PostHog to dismiss or resolve issues.",
|
|
448
|
-
docsUrl: POSTHOG_DOCS_URL,
|
|
449
|
-
continueUrl: healthUrl
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
})
|
|
453
|
-
]
|
|
454
|
-
});
|
|
455
|
-
};
|
|
456
|
-
const Header = ({ host, projectId }) => /* @__PURE__ */ jsxs(Box, {
|
|
457
|
-
flexDirection: "column",
|
|
458
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
459
|
-
bold: true,
|
|
460
|
-
color: Colors.accent,
|
|
461
|
-
children: "PostHog Doctor Report"
|
|
462
|
-
}), /* @__PURE__ */ jsxs(Text, {
|
|
463
|
-
dimColor: true,
|
|
464
|
-
children: [
|
|
465
|
-
"Project ",
|
|
466
|
-
projectId,
|
|
467
|
-
" ",
|
|
468
|
-
Icons.bullet,
|
|
469
|
-
" ",
|
|
470
|
-
host
|
|
471
|
-
]
|
|
472
|
-
})]
|
|
473
|
-
});
|
|
474
|
-
function formatSummaryLine(issues) {
|
|
475
|
-
const parts = [];
|
|
476
|
-
for (const sev of SEVERITY_ORDER) {
|
|
477
|
-
const n = issues.filter((i) => i.severity === sev).length;
|
|
478
|
-
if (n > 0) parts.push(`${n} ${SEVERITY_LABEL[sev].toLowerCase()}`);
|
|
479
|
-
}
|
|
480
|
-
const suffix = parts.length > 0 ? `: ${parts.join(", ")}` : "";
|
|
481
|
-
return `${issues.length} active issue${issues.length === 1 ? "" : "s"}${suffix}`;
|
|
482
|
-
}
|
|
483
|
-
//#endregion
|
|
484
|
-
//#region src/ui/tui/screens/SettingsOverrideScreen.tsx
|
|
485
|
-
function sourcePath(source) {
|
|
486
|
-
switch (source) {
|
|
487
|
-
case "project": return ".claude/settings.json";
|
|
488
|
-
case "managed": return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
489
|
-
default: return source;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
const SettingsOverrideScreen = ({ store }) => {
|
|
493
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
494
|
-
const [feedback, setFeedback] = useState(null);
|
|
495
|
-
const conflicts = store.session.settingsConflicts?.filter((c) => c.writable);
|
|
496
|
-
if (!conflicts || conflicts.length === 0) return null;
|
|
497
|
-
return /* @__PURE__ */ jsxs(ModalOverlay, {
|
|
498
|
-
borderColor: "red",
|
|
499
|
-
title: `${Icons.warning} Settings conflict`,
|
|
500
|
-
width: 64,
|
|
501
|
-
feedback: feedback ? `${Icons.warning} ${feedback}` : null,
|
|
502
|
-
footer: /* @__PURE__ */ jsx(ConfirmationInput, {
|
|
503
|
-
message: "Back up to .wizard-backup and continue?",
|
|
504
|
-
confirmLabel: "Backup & continue [Enter]",
|
|
505
|
-
cancelLabel: "Exit [Esc]",
|
|
506
|
-
onConfirm: () => {
|
|
507
|
-
if (!store.backupAndFixSettingsOverride()) setFeedback("Could not back up the settings file.");
|
|
508
|
-
},
|
|
509
|
-
onCancel: () => process.exit(1)
|
|
510
|
-
}),
|
|
511
|
-
children: [conflicts.map((conflict) => /* @__PURE__ */ jsxs(Box, {
|
|
512
|
-
flexDirection: "column",
|
|
513
|
-
marginBottom: 1,
|
|
514
|
-
children: [/* @__PURE__ */ jsxs(Text, { children: [
|
|
515
|
-
"Your settings file at",
|
|
516
|
-
" ",
|
|
517
|
-
/* @__PURE__ */ jsx(Text, {
|
|
518
|
-
bold: true,
|
|
519
|
-
children: sourcePath(conflict.source)
|
|
520
|
-
}),
|
|
521
|
-
" sets:"
|
|
522
|
-
] }), /* @__PURE__ */ jsx(Box, {
|
|
523
|
-
flexDirection: "column",
|
|
524
|
-
paddingLeft: 2,
|
|
525
|
-
children: conflict.keys.map((key) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
526
|
-
Icons.bullet,
|
|
527
|
-
" ",
|
|
528
|
-
/* @__PURE__ */ jsx(Text, {
|
|
529
|
-
color: "yellow",
|
|
530
|
-
bold: true,
|
|
531
|
-
children: key
|
|
532
|
-
})
|
|
533
|
-
] }, key))
|
|
534
|
-
})]
|
|
535
|
-
}, conflict.source)), /* @__PURE__ */ jsx(Text, {
|
|
536
|
-
dimColor: true,
|
|
537
|
-
children: "These settings override credentials and prevent the Wizard from reaching the PostHog LLM Gateway. We can back up the file and continue."
|
|
538
|
-
})]
|
|
539
|
-
});
|
|
540
|
-
};
|
|
541
|
-
//#endregion
|
|
542
|
-
//#region src/ui/tui/screens/ManagedSettingsScreen.tsx
|
|
543
|
-
/**
|
|
544
|
-
* ManagedSettingsScreen — Modal when IT/org-managed settings contain overrides
|
|
545
|
-
* that block the Wizard from reaching the PostHog LLM Gateway.
|
|
546
|
-
*
|
|
547
|
-
* Unlike SettingsOverrideScreen, the wizard cannot back up or modify these files.
|
|
548
|
-
* The user must contact their IT administrator to resolve the conflict.
|
|
549
|
-
*/
|
|
550
|
-
function sourceLabel(source) {
|
|
551
|
-
switch (source) {
|
|
552
|
-
case "managed": return "Managed settings (IT/org-managed)";
|
|
553
|
-
case "project": return ".claude/settings.json";
|
|
554
|
-
default: return source;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
const ManagedSettingsScreen = ({ store }) => {
|
|
558
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
559
|
-
const readOnlyConflicts = store.session.settingsConflicts?.filter((c) => !c.writable);
|
|
560
|
-
if (!readOnlyConflicts || readOnlyConflicts.length === 0) return null;
|
|
561
|
-
return /* @__PURE__ */ jsxs(ModalOverlay, {
|
|
562
|
-
borderColor: "red",
|
|
563
|
-
title: `${Icons.warning} Organization settings conflict`,
|
|
564
|
-
width: 68,
|
|
565
|
-
footer: /* @__PURE__ */ jsx(ConfirmationInput, {
|
|
566
|
-
message: "Contact your IT administrator to resolve this.",
|
|
567
|
-
confirmLabel: "",
|
|
568
|
-
cancelLabel: "Exit [Esc]",
|
|
569
|
-
onConfirm: () => process.exit(1),
|
|
570
|
-
onCancel: () => process.exit(1)
|
|
571
|
-
}),
|
|
572
|
-
children: [
|
|
573
|
-
/* @__PURE__ */ jsx(Text, {
|
|
574
|
-
dimColor: true,
|
|
575
|
-
children: "Your organization's managed settings contain overrides that prevent the Wizard from reaching the PostHog LLM Gateway."
|
|
576
|
-
}),
|
|
577
|
-
readOnlyConflicts.map((conflict) => /* @__PURE__ */ jsxs(Box, {
|
|
578
|
-
flexDirection: "column",
|
|
579
|
-
marginTop: 1,
|
|
580
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
581
|
-
bold: true,
|
|
582
|
-
children: sourceLabel(conflict.source)
|
|
583
|
-
}), /* @__PURE__ */ jsx(Box, {
|
|
584
|
-
flexDirection: "column",
|
|
585
|
-
paddingLeft: 2,
|
|
586
|
-
children: conflict.keys.map((key) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
587
|
-
Icons.bullet,
|
|
588
|
-
" ",
|
|
589
|
-
/* @__PURE__ */ jsx(Text, {
|
|
590
|
-
color: "yellow",
|
|
591
|
-
bold: true,
|
|
592
|
-
children: key
|
|
593
|
-
})
|
|
594
|
-
] }, key))
|
|
595
|
-
})]
|
|
596
|
-
}, conflict.source)),
|
|
597
|
-
/* @__PURE__ */ jsx(Box, {
|
|
598
|
-
marginTop: 1,
|
|
599
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
600
|
-
dimColor: true,
|
|
601
|
-
children: "Try running \"claude auth logout\" or contact your IT administrator to resolve this."
|
|
602
|
-
})
|
|
603
|
-
})
|
|
604
|
-
]
|
|
605
|
-
});
|
|
606
|
-
};
|
|
607
|
-
//#endregion
|
|
608
|
-
//#region src/ui/tui/screens/PortConflictScreen.tsx
|
|
609
|
-
/**
|
|
610
|
-
* PortConflictScreen — Modal when all OAuth port candidates are occupied.
|
|
611
|
-
*
|
|
612
|
-
* Shows every port the wizard tried and asks the user to free them manually.
|
|
613
|
-
*/
|
|
614
|
-
const PortConflictScreen = ({ store }) => {
|
|
615
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
616
|
-
if (!store.session.portConflictProcess) return null;
|
|
617
|
-
return /* @__PURE__ */ jsxs(ModalOverlay, {
|
|
618
|
-
borderColor: "#DC9300",
|
|
619
|
-
title: "OAuth ports in use",
|
|
620
|
-
width: 72,
|
|
621
|
-
footer: /* @__PURE__ */ jsx(ConfirmationInput, {
|
|
622
|
-
message: "Retry after freeing ports?",
|
|
623
|
-
confirmLabel: "Retry [Enter]",
|
|
624
|
-
cancelLabel: "Exit [Esc]",
|
|
625
|
-
onConfirm: () => store.resolvePortConflict(),
|
|
626
|
-
onCancel: () => process.exit(1)
|
|
627
|
-
}),
|
|
628
|
-
children: [
|
|
629
|
-
/* @__PURE__ */ jsx(Text, { children: "The wizard needs a local port for OAuth. We tried these ports which are all in use:" }),
|
|
630
|
-
/* @__PURE__ */ jsx(Box, {
|
|
631
|
-
flexDirection: "column",
|
|
632
|
-
marginY: 1,
|
|
633
|
-
paddingLeft: 2,
|
|
634
|
-
gap: 0,
|
|
635
|
-
children: OAUTH_PORTS.map((port) => /* @__PURE__ */ jsxs(Text, { children: [/* @__PURE__ */ jsx(Text, {
|
|
636
|
-
dimColor: true,
|
|
637
|
-
children: "Port "
|
|
638
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
639
|
-
bold: true,
|
|
640
|
-
children: port
|
|
641
|
-
})] }, port))
|
|
642
|
-
}),
|
|
643
|
-
/* @__PURE__ */ jsx(Text, {
|
|
644
|
-
dimColor: true,
|
|
645
|
-
children: "Please free one of these ports and retry."
|
|
646
|
-
})
|
|
647
|
-
]
|
|
648
|
-
});
|
|
649
|
-
};
|
|
650
|
-
//#endregion
|
|
651
|
-
//#region src/ui/tui/screens/IntroScreenLayout.tsx
|
|
652
|
-
/**
|
|
653
|
-
* IntroScreenLayout ��� Shared visual shell for all workflow intro screens.
|
|
654
|
-
*
|
|
655
|
-
* Purely presentational — no store subscription. Parent components own
|
|
656
|
-
* the store subscription and pass derived data as props.
|
|
657
|
-
*
|
|
658
|
-
* Slots:
|
|
659
|
-
* body — free-form content below the title bar (copy, spinners, pickers, etc.)
|
|
660
|
-
* children — between detection rows and menu (extra info, warnings)
|
|
661
|
-
* errorView — replaces the entire body for fatal error states
|
|
662
|
-
*/
|
|
663
|
-
const WizardTitle = ({ title }) => /* @__PURE__ */ jsxs(Text, {
|
|
664
|
-
bold: true,
|
|
665
|
-
children: [
|
|
666
|
-
/* @__PURE__ */ jsx(Text, {
|
|
667
|
-
color: "#1D4AFF",
|
|
668
|
-
children: "█"
|
|
669
|
-
}),
|
|
670
|
-
/* @__PURE__ */ jsx(Text, {
|
|
671
|
-
color: "#F54E00",
|
|
672
|
-
children: "█"
|
|
673
|
-
}),
|
|
674
|
-
/* @__PURE__ */ jsx(Text, {
|
|
675
|
-
color: "#F9BD2B",
|
|
676
|
-
children: "█"
|
|
677
|
-
}),
|
|
678
|
-
" ",
|
|
679
|
-
title
|
|
680
|
-
]
|
|
681
|
-
});
|
|
682
|
-
const IntroScreenLayout = ({ installDir, title = "PostHog Wizard 🦔", showSubtitle = true, body, showDetection = true, detectionRows, children, menuOptions, onSelect, workflowLabel, skillId, errorView }) => {
|
|
683
|
-
const resolvedMenuOptions = menuOptions === void 0 ? [{
|
|
684
|
-
label: "Continue",
|
|
685
|
-
value: "continue"
|
|
686
|
-
}, {
|
|
687
|
-
label: "Cancel",
|
|
688
|
-
value: "cancel"
|
|
689
|
-
}] : menuOptions;
|
|
690
|
-
if (errorView) return /* @__PURE__ */ jsxs(Box, {
|
|
691
|
-
flexDirection: "column",
|
|
692
|
-
flexGrow: 1,
|
|
693
|
-
alignItems: "center",
|
|
694
|
-
justifyContent: "center",
|
|
695
|
-
children: [/* @__PURE__ */ jsx(Box, {
|
|
696
|
-
flexDirection: "column",
|
|
697
|
-
alignItems: "center",
|
|
698
|
-
marginBottom: 1,
|
|
699
|
-
children: /* @__PURE__ */ jsx(WizardTitle, { title })
|
|
700
|
-
}), errorView]
|
|
701
|
-
});
|
|
702
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, {
|
|
703
|
-
flexDirection: "column",
|
|
704
|
-
flexGrow: 1,
|
|
705
|
-
alignItems: "center",
|
|
706
|
-
justifyContent: "center",
|
|
707
|
-
children: [
|
|
708
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
709
|
-
flexDirection: "column",
|
|
710
|
-
alignItems: "center",
|
|
711
|
-
children: [
|
|
712
|
-
/* @__PURE__ */ jsx(WizardTitle, { title }),
|
|
713
|
-
showSubtitle && /* @__PURE__ */ jsxs(Box, {
|
|
714
|
-
flexDirection: "column",
|
|
715
|
-
alignItems: "center",
|
|
716
|
-
marginTop: 1,
|
|
717
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
718
|
-
dimColor: true,
|
|
719
|
-
children: "We'll use AI to analyze your project and complete work."
|
|
720
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
721
|
-
dimColor: true,
|
|
722
|
-
children: ".env* file contents will not leave your machine."
|
|
723
|
-
})]
|
|
724
|
-
}),
|
|
725
|
-
body && /* @__PURE__ */ jsx(Box, {
|
|
726
|
-
flexDirection: "column",
|
|
727
|
-
alignItems: "center",
|
|
728
|
-
marginTop: 1,
|
|
729
|
-
children: body
|
|
730
|
-
})
|
|
731
|
-
]
|
|
732
|
-
}),
|
|
733
|
-
children,
|
|
734
|
-
showDetection && /* @__PURE__ */ jsxs(Box, {
|
|
735
|
-
flexDirection: "column",
|
|
736
|
-
marginTop: 1,
|
|
737
|
-
children: [
|
|
738
|
-
/* @__PURE__ */ jsxs(Text, { children: [/* @__PURE__ */ jsxs(Text, { children: [
|
|
739
|
-
"Directory ",
|
|
740
|
-
/* @__PURE__ */ jsx(Text, {
|
|
741
|
-
color: "green",
|
|
742
|
-
children: "✔"
|
|
743
|
-
}),
|
|
744
|
-
" "
|
|
745
|
-
] }), /* @__PURE__ */ jsxs(Text, { children: ["/", path.basename(installDir)] })] }),
|
|
746
|
-
detectionRows?.map((row) => /* @__PURE__ */ jsxs(Text, { children: [/* @__PURE__ */ jsxs(Text, { children: [
|
|
747
|
-
row.label,
|
|
748
|
-
" ",
|
|
749
|
-
/* @__PURE__ */ jsx(Text, {
|
|
750
|
-
color: "green",
|
|
751
|
-
children: "✔"
|
|
752
|
-
}),
|
|
753
|
-
" "
|
|
754
|
-
] }), /* @__PURE__ */ jsxs(Text, { children: [row.value, row.suffix ? ` ${row.suffix}` : ""] })] }, row.label)),
|
|
755
|
-
workflowLabel && /* @__PURE__ */ jsxs(Text, { children: [
|
|
756
|
-
"Workflow",
|
|
757
|
-
" ",
|
|
758
|
-
/* @__PURE__ */ jsx(Text, {
|
|
759
|
-
color: "green",
|
|
760
|
-
children: "✔"
|
|
761
|
-
}),
|
|
762
|
-
" ",
|
|
763
|
-
workflowLabel
|
|
764
|
-
] }),
|
|
765
|
-
workflowLabel === "agent-skill" && skillId && /* @__PURE__ */ jsxs(Text, { children: [
|
|
766
|
-
"Skill",
|
|
767
|
-
" ",
|
|
768
|
-
/* @__PURE__ */ jsx(Text, {
|
|
769
|
-
color: "green",
|
|
770
|
-
children: "✔"
|
|
771
|
-
}),
|
|
772
|
-
" ",
|
|
773
|
-
skillId
|
|
774
|
-
] })
|
|
775
|
-
]
|
|
776
|
-
}),
|
|
777
|
-
/* @__PURE__ */ jsx(Box, {
|
|
778
|
-
width: 24,
|
|
779
|
-
children: resolvedMenuOptions && onSelect && /* @__PURE__ */ jsx(Box, {
|
|
780
|
-
justifyContent: "center",
|
|
781
|
-
children: /* @__PURE__ */ jsx(PickerMenu, {
|
|
782
|
-
options: resolvedMenuOptions,
|
|
783
|
-
onSelect: (value) => {
|
|
784
|
-
onSelect(Array.isArray(value) ? value[0] : value);
|
|
785
|
-
}
|
|
786
|
-
}, resolvedMenuOptions.map((o) => o.value).join(","))
|
|
787
|
-
})
|
|
788
|
-
})
|
|
789
|
-
]
|
|
790
|
-
}) });
|
|
791
|
-
};
|
|
792
|
-
//#endregion
|
|
793
|
-
//#region src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx
|
|
794
|
-
/**
|
|
795
|
-
* PostHogIntegrationIntroScreen — Intro screen for the core PostHog integration.
|
|
796
|
-
*
|
|
797
|
-
* Composes IntroScreenLayout with framework-detection-specific state:
|
|
798
|
-
* 1. Detecting: spinner while detection runs
|
|
799
|
-
* 2. Detection failed: framework picker
|
|
800
|
-
* 3. Unsupported version: upgrade prompt
|
|
801
|
-
* 4. Detection succeeded: continue/change-framework/cancel
|
|
802
|
-
*/
|
|
803
|
-
const TOOLS = [{
|
|
804
|
-
label: "Troubleshoot Integration",
|
|
805
|
-
command: "doctor"
|
|
806
|
-
}];
|
|
807
|
-
function launchTool(command, installDir) {
|
|
808
|
-
releaseTerminal();
|
|
809
|
-
const result = spawnSync(process.execPath, [
|
|
810
|
-
process.argv[1],
|
|
811
|
-
command,
|
|
812
|
-
`--install-dir=${installDir}`
|
|
813
|
-
], { stdio: "inherit" });
|
|
814
|
-
process.exit(result.status ?? 0);
|
|
815
|
-
}
|
|
816
|
-
/** Framework picker shown when auto-detection fails. */
|
|
817
|
-
const FrameworkPicker = ({ store, onComplete }) => {
|
|
818
|
-
return /* @__PURE__ */ jsx(PickerMenu, {
|
|
819
|
-
centered: true,
|
|
820
|
-
columns: 2,
|
|
821
|
-
message: "Select your framework",
|
|
822
|
-
options: Object.values(Integration).map((value) => ({
|
|
823
|
-
label: value,
|
|
824
|
-
value
|
|
825
|
-
})),
|
|
826
|
-
onSelect: (value) => {
|
|
827
|
-
const integration = Array.isArray(value) ? value[0] : value;
|
|
828
|
-
import("./registry-DaPKstG3.js").then((n) => n.n).then(({ FRAMEWORK_REGISTRY }) => {
|
|
829
|
-
const config = FRAMEWORK_REGISTRY[integration];
|
|
830
|
-
store.setFrameworkConfig(integration, config);
|
|
831
|
-
store.setDetectedFramework(config.metadata.name);
|
|
832
|
-
onComplete?.();
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
|
-
});
|
|
836
|
-
};
|
|
837
|
-
const PostHogIntegrationIntroScreen = ({ store }) => {
|
|
838
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
839
|
-
const [pickingFramework, setPickingFramework] = useState(false);
|
|
840
|
-
const [manuallySelected, setManuallySelected] = useState(false);
|
|
841
|
-
const [view, setView] = useState("default");
|
|
842
|
-
const [toolsEnabled, setToolsEnabled] = useState(false);
|
|
843
|
-
useEffect(() => {
|
|
844
|
-
let cancelled = false;
|
|
845
|
-
analytics.getAllFlagsForWizard().then((flags) => {
|
|
846
|
-
const value = flags[WIZARD_TOOLS_MENU_FLAG_KEY];
|
|
847
|
-
if (!cancelled && value && value !== "false") setToolsEnabled(true);
|
|
848
|
-
});
|
|
849
|
-
return () => {
|
|
850
|
-
cancelled = true;
|
|
851
|
-
};
|
|
852
|
-
}, []);
|
|
853
|
-
const { session } = store;
|
|
854
|
-
const config = session.frameworkConfig;
|
|
855
|
-
const frameworkLabel = session.detectedFrameworkLabel ?? config?.metadata.name;
|
|
856
|
-
const detecting = !session.detectionComplete;
|
|
857
|
-
const needsFrameworkPick = session.detectionComplete && !session.frameworkConfig;
|
|
858
|
-
const unsupported = session.unsupportedVersion;
|
|
859
|
-
const showContinue = session.frameworkConfig !== null && !detecting && !pickingFramework && view === "default" && !unsupported;
|
|
860
|
-
const title = detecting ? "PostHog Wizard starting up" : "PostHog Wizard 🦔";
|
|
861
|
-
let body = null;
|
|
862
|
-
if (detecting) body = /* @__PURE__ */ jsx(Box, {
|
|
863
|
-
marginY: 1,
|
|
864
|
-
children: /* @__PURE__ */ jsx(LoadingBox, { message: "Detecting project framework..." })
|
|
865
|
-
});
|
|
866
|
-
else if (needsFrameworkPick && !pickingFramework) body = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Box, {
|
|
867
|
-
marginY: 1,
|
|
868
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
869
|
-
dimColor: true,
|
|
870
|
-
children: "Could not auto-detect your framework."
|
|
871
|
-
})
|
|
872
|
-
}), /* @__PURE__ */ jsx(FrameworkPicker, {
|
|
873
|
-
store,
|
|
874
|
-
onComplete: () => setPickingFramework(false)
|
|
875
|
-
})] });
|
|
876
|
-
else if (pickingFramework) body = /* @__PURE__ */ jsx(FrameworkPicker, {
|
|
877
|
-
store,
|
|
878
|
-
onComplete: () => setPickingFramework(false)
|
|
879
|
-
});
|
|
880
|
-
else if (view === "more-info") body = /* @__PURE__ */ jsxs(Box, {
|
|
881
|
-
flexDirection: "column",
|
|
882
|
-
width: 56,
|
|
883
|
-
flexShrink: 0,
|
|
884
|
-
children: [
|
|
885
|
-
/* @__PURE__ */ jsxs(Text, { children: ["The wizard is an agent that executes PostHog tasks. Its code is open source: ", /* @__PURE__ */ jsx(Text, {
|
|
886
|
-
color: "cyan",
|
|
887
|
-
children: "https://github.com/PostHog/wizard"
|
|
888
|
-
})] }),
|
|
889
|
-
/* @__PURE__ */ jsx(Box, {
|
|
890
|
-
flexDirection: "column",
|
|
891
|
-
marginTop: 1,
|
|
892
|
-
children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
893
|
-
"The",
|
|
894
|
-
" ",
|
|
895
|
-
/* @__PURE__ */ jsx(Text, {
|
|
896
|
-
italic: true,
|
|
897
|
-
color: "cyan",
|
|
898
|
-
children: session.workflowLabel
|
|
899
|
-
}),
|
|
900
|
-
" ",
|
|
901
|
-
"workflow installs the PostHog SDKs, instruments event tracking, and integrates the following dev tools for your application:"
|
|
902
|
-
] })
|
|
903
|
-
}),
|
|
904
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
905
|
-
flexDirection: "column",
|
|
906
|
-
marginTop: 1,
|
|
907
|
-
paddingLeft: 4,
|
|
908
|
-
children: [
|
|
909
|
-
/* @__PURE__ */ jsxs(Text, { children: [`\u2022`, " Product Analytics"] }),
|
|
910
|
-
/* @__PURE__ */ jsxs(Text, { children: [`\u2022`, " Web Analytics"] }),
|
|
911
|
-
/* @__PURE__ */ jsxs(Text, { children: [`\u2022`, " Session Replay"] }),
|
|
912
|
-
/* @__PURE__ */ jsxs(Text, { children: [`\u2022`, " Error Tracking"] })
|
|
913
|
-
]
|
|
914
|
-
}),
|
|
915
|
-
/* @__PURE__ */ jsx(Box, {
|
|
916
|
-
flexDirection: "column",
|
|
917
|
-
marginTop: 1,
|
|
918
|
-
children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
919
|
-
"If you prefer your own AI setup, download the skill:",
|
|
920
|
-
" ",
|
|
921
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
922
|
-
color: "cyan",
|
|
923
|
-
children: [CONTEXT_MILL_URL, "/releases"]
|
|
924
|
-
})
|
|
925
|
-
] })
|
|
926
|
-
})
|
|
927
|
-
]
|
|
928
|
-
});
|
|
929
|
-
else if (showContinue) body = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { children: "Let's do two hours of work in eight minutes." }) }) });
|
|
930
|
-
const detectionRows = [];
|
|
931
|
-
if (frameworkLabel) {
|
|
932
|
-
const suffixParts = [];
|
|
933
|
-
if (!manuallySelected) suffixParts.push("(detected)");
|
|
934
|
-
if (config?.metadata.beta) suffixParts.push("[BETA]");
|
|
935
|
-
detectionRows.push({
|
|
936
|
-
label: "Framework",
|
|
937
|
-
value: frameworkLabel,
|
|
938
|
-
suffix: suffixParts.join(" ") || void 0
|
|
939
|
-
});
|
|
940
|
-
}
|
|
941
|
-
let bodyChildren = null;
|
|
942
|
-
if (config?.metadata.preRunNotice) bodyChildren = /* @__PURE__ */ jsx(Text, {
|
|
943
|
-
color: "yellow",
|
|
944
|
-
children: config.metadata.preRunNotice
|
|
945
|
-
});
|
|
946
|
-
if (unsupported) bodyChildren = /* @__PURE__ */ jsxs(Box, {
|
|
947
|
-
flexDirection: "column",
|
|
948
|
-
marginTop: 1,
|
|
949
|
-
children: [
|
|
950
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
951
|
-
color: "#DC9300",
|
|
952
|
-
children: [
|
|
953
|
-
"Version ",
|
|
954
|
-
unsupported.current,
|
|
955
|
-
" is not supported by the wizard. Please upgrade to ",
|
|
956
|
-
unsupported.minimum,
|
|
957
|
-
" or later."
|
|
958
|
-
]
|
|
959
|
-
}),
|
|
960
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
961
|
-
dimColor: true,
|
|
962
|
-
children: ["Manual setup guide: ", unsupported.docsUrl]
|
|
963
|
-
}),
|
|
964
|
-
/* @__PURE__ */ jsx(Box, {
|
|
965
|
-
marginTop: 1,
|
|
966
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
967
|
-
dimColor: true,
|
|
968
|
-
children: "Did we get this wrong? You can also select another framework."
|
|
969
|
-
})
|
|
970
|
-
}),
|
|
971
|
-
/* @__PURE__ */ jsx(PickerMenu, {
|
|
972
|
-
options: [{
|
|
973
|
-
label: "Select another framework",
|
|
974
|
-
value: "framework"
|
|
975
|
-
}, {
|
|
976
|
-
label: "Exit",
|
|
977
|
-
value: "exit"
|
|
978
|
-
}],
|
|
979
|
-
onSelect: (value) => {
|
|
980
|
-
if ((Array.isArray(value) ? value[0] : value) === "framework") {
|
|
981
|
-
setPickingFramework(true);
|
|
982
|
-
setManuallySelected(true);
|
|
983
|
-
} else process.exit(0);
|
|
984
|
-
}
|
|
985
|
-
})
|
|
986
|
-
]
|
|
987
|
-
});
|
|
988
|
-
let menuOptions = null;
|
|
989
|
-
if (view === "tools") menuOptions = [...TOOLS.map((t) => ({
|
|
990
|
-
label: t.label,
|
|
991
|
-
value: t.command
|
|
992
|
-
})), {
|
|
993
|
-
label: "Back",
|
|
994
|
-
value: "back"
|
|
995
|
-
}];
|
|
996
|
-
else if (view === "more-info") menuOptions = [{
|
|
997
|
-
label: "Back",
|
|
998
|
-
value: "back"
|
|
999
|
-
}];
|
|
1000
|
-
else if (showContinue) menuOptions = [
|
|
1001
|
-
{
|
|
1002
|
-
label: "Continue",
|
|
1003
|
-
value: "continue"
|
|
1004
|
-
},
|
|
1005
|
-
{
|
|
1006
|
-
label: "Change framework",
|
|
1007
|
-
value: "framework"
|
|
1008
|
-
},
|
|
1009
|
-
...toolsEnabled ? [{
|
|
1010
|
-
label: "Tools",
|
|
1011
|
-
value: "tools"
|
|
1012
|
-
}] : [],
|
|
1013
|
-
{
|
|
1014
|
-
label: "More info",
|
|
1015
|
-
value: "more-info"
|
|
1016
|
-
},
|
|
1017
|
-
{
|
|
1018
|
-
label: "Cancel",
|
|
1019
|
-
value: "cancel"
|
|
1020
|
-
}
|
|
1021
|
-
];
|
|
1022
|
-
const handleSelect = (value) => {
|
|
1023
|
-
if (view === "tools") {
|
|
1024
|
-
if (value === "back") setView("default");
|
|
1025
|
-
else launchTool(value, session.installDir);
|
|
1026
|
-
return;
|
|
1027
|
-
}
|
|
1028
|
-
if (value === "cancel") process.exit(0);
|
|
1029
|
-
else if (value === "framework") {
|
|
1030
|
-
setPickingFramework(true);
|
|
1031
|
-
setManuallySelected(true);
|
|
1032
|
-
} else if (value === "more-info") setView("more-info");
|
|
1033
|
-
else if (value === "tools") setView("tools");
|
|
1034
|
-
else if (value === "back") setView("default");
|
|
1035
|
-
else store.completeSetup();
|
|
1036
|
-
};
|
|
1037
|
-
return /* @__PURE__ */ jsx(IntroScreenLayout, {
|
|
1038
|
-
installDir: session.installDir,
|
|
1039
|
-
title,
|
|
1040
|
-
showSubtitle: view === "default",
|
|
1041
|
-
body,
|
|
1042
|
-
showDetection: showContinue,
|
|
1043
|
-
detectionRows,
|
|
1044
|
-
menuOptions: unsupported ? null : menuOptions,
|
|
1045
|
-
onSelect: handleSelect,
|
|
1046
|
-
workflowLabel: session.workflowLabel,
|
|
1047
|
-
skillId: session.skillId,
|
|
1048
|
-
children: bodyChildren
|
|
1049
|
-
});
|
|
1050
|
-
};
|
|
1051
|
-
//#endregion
|
|
1052
|
-
//#region src/ui/tui/screens/RevenueIntroScreen.tsx
|
|
1053
|
-
/**
|
|
1054
|
-
* RevenueIntroScreen — Welcome screen for the revenue analytics flow.
|
|
1055
|
-
*
|
|
1056
|
-
* Composes IntroScreenLayout with SDK-detection-specific state:
|
|
1057
|
-
* - Detection succeeded: shows detected PostHog + Stripe SDKs, continue/cancel
|
|
1058
|
-
* - Detection failed: shows the error via errorView + exit prompt
|
|
1059
|
-
*
|
|
1060
|
-
* Reads `frameworkContext.detectError` and `frameworkContext.detectedPosthogSdks`
|
|
1061
|
-
* / `detectedStripeSdks` set by detectRevenuePrerequisites().
|
|
1062
|
-
*/
|
|
1063
|
-
const RevenueIntroScreen = ({ store }) => {
|
|
1064
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
1065
|
-
const [showingMoreInfo, setShowingMoreInfo] = useState(false);
|
|
1066
|
-
const { session } = store;
|
|
1067
|
-
const detectError = session.frameworkContext.detectError;
|
|
1068
|
-
const detectedPosthogSdks = session.frameworkContext.detectedPosthogSdks ?? [];
|
|
1069
|
-
const detectedStripeSdks = session.frameworkContext.detectedStripeSdks ?? [];
|
|
1070
|
-
const detectedPackagePaths = session.frameworkContext.detectedPackagePaths ?? [];
|
|
1071
|
-
const detectionRows = [];
|
|
1072
|
-
if (detectedPosthogSdks.length > 0) detectionRows.push({
|
|
1073
|
-
label: "PostHog SDK",
|
|
1074
|
-
value: detectedPosthogSdks.join(", ")
|
|
1075
|
-
});
|
|
1076
|
-
if (detectedStripeSdks.length > 0) detectionRows.push({
|
|
1077
|
-
label: "Stripe SDK",
|
|
1078
|
-
value: detectedStripeSdks.join(", ")
|
|
1079
|
-
});
|
|
1080
|
-
const body = showingMoreInfo ? /* @__PURE__ */ jsxs(Box, {
|
|
1081
|
-
flexDirection: "column",
|
|
1082
|
-
width: 56,
|
|
1083
|
-
flexShrink: 0,
|
|
1084
|
-
children: [
|
|
1085
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
1086
|
-
"The wizard is an agent that executes PostHog tasks. Its code is open source: ",
|
|
1087
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1088
|
-
color: "cyan",
|
|
1089
|
-
children: "https://github.com/PostHog/wizard"
|
|
1090
|
-
}),
|
|
1091
|
-
"."
|
|
1092
|
-
] }),
|
|
1093
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1094
|
-
flexDirection: "column",
|
|
1095
|
-
marginTop: 1,
|
|
1096
|
-
children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
1097
|
-
"The",
|
|
1098
|
-
" ",
|
|
1099
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1100
|
-
italic: true,
|
|
1101
|
-
color: "cyan",
|
|
1102
|
-
children: session.workflowLabel
|
|
1103
|
-
}),
|
|
1104
|
-
" ",
|
|
1105
|
-
"workflow links Stripe customers and purchases to PostHog product data and persons. It unlocks insights like:"
|
|
1106
|
-
] })
|
|
1107
|
-
}),
|
|
1108
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
1109
|
-
flexDirection: "column",
|
|
1110
|
-
marginTop: 1,
|
|
1111
|
-
paddingLeft: 4,
|
|
1112
|
-
children: [
|
|
1113
|
-
/* @__PURE__ */ jsxs(Text, { children: ["•", " Revenue per user"] }),
|
|
1114
|
-
/* @__PURE__ */ jsxs(Text, { children: ["•", " Lifetime value"] }),
|
|
1115
|
-
/* @__PURE__ */ jsxs(Text, { children: ["•", " MRR / churn tracking"] })
|
|
1116
|
-
]
|
|
1117
|
-
})
|
|
1118
|
-
]
|
|
1119
|
-
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Box, {
|
|
1120
|
-
flexDirection: "column",
|
|
1121
|
-
alignItems: "center",
|
|
1122
|
-
children: [/* @__PURE__ */ jsx(Text, { children: "Let's create revenue analytics with Stripe and PostHog." }), /* @__PURE__ */ jsx(Box, {
|
|
1123
|
-
flexDirection: "column",
|
|
1124
|
-
marginTop: 1,
|
|
1125
|
-
children: /* @__PURE__ */ jsx(Text, { children: "Link purchases to product data." })
|
|
1126
|
-
})]
|
|
1127
|
-
}), detectedPackagePaths.length > 1 && /* @__PURE__ */ jsxs(Box, {
|
|
1128
|
-
flexDirection: "column",
|
|
1129
|
-
marginTop: 1,
|
|
1130
|
-
children: [/* @__PURE__ */ jsxs(Text, {
|
|
1131
|
-
dimColor: true,
|
|
1132
|
-
children: [
|
|
1133
|
-
"Found in ",
|
|
1134
|
-
detectedPackagePaths.length,
|
|
1135
|
-
" packages:"
|
|
1136
|
-
]
|
|
1137
|
-
}), detectedPackagePaths.map((p) => /* @__PURE__ */ jsxs(Text, {
|
|
1138
|
-
dimColor: true,
|
|
1139
|
-
children: [
|
|
1140
|
-
" ",
|
|
1141
|
-
"•",
|
|
1142
|
-
" ",
|
|
1143
|
-
p
|
|
1144
|
-
]
|
|
1145
|
-
}, p))]
|
|
1146
|
-
})] });
|
|
1147
|
-
const errorView = detectError ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Box, {
|
|
1148
|
-
flexDirection: "column",
|
|
1149
|
-
marginBottom: 1,
|
|
1150
|
-
children: [/* @__PURE__ */ jsxs(Text, {
|
|
1151
|
-
color: "red",
|
|
1152
|
-
bold: true,
|
|
1153
|
-
children: ["✘", " Cannot set up revenue analytics"]
|
|
1154
|
-
}), /* @__PURE__ */ jsx(Box, {
|
|
1155
|
-
marginTop: 1,
|
|
1156
|
-
flexDirection: "column",
|
|
1157
|
-
children: /* @__PURE__ */ jsx(DetectErrorBody, { error: detectError })
|
|
1158
|
-
})]
|
|
1159
|
-
}), /* @__PURE__ */ jsx(PickerMenu, {
|
|
1160
|
-
options: [{
|
|
1161
|
-
label: "Exit",
|
|
1162
|
-
value: "exit"
|
|
1163
|
-
}],
|
|
1164
|
-
onSelect: () => process.exit(1)
|
|
1165
|
-
})] }) : void 0;
|
|
1166
|
-
const menuOptions = showingMoreInfo ? [{
|
|
1167
|
-
label: "Back",
|
|
1168
|
-
value: "back"
|
|
1169
|
-
}] : [
|
|
1170
|
-
{
|
|
1171
|
-
label: "Continue",
|
|
1172
|
-
value: "continue"
|
|
1173
|
-
},
|
|
1174
|
-
{
|
|
1175
|
-
label: "More info",
|
|
1176
|
-
value: "more-info"
|
|
1177
|
-
},
|
|
1178
|
-
{
|
|
1179
|
-
label: "Cancel",
|
|
1180
|
-
value: "cancel"
|
|
1181
|
-
}
|
|
1182
|
-
];
|
|
1183
|
-
return /* @__PURE__ */ jsx(IntroScreenLayout, {
|
|
1184
|
-
installDir: session.installDir,
|
|
1185
|
-
showSubtitle: !showingMoreInfo,
|
|
1186
|
-
body,
|
|
1187
|
-
showDetection: !showingMoreInfo,
|
|
1188
|
-
detectionRows,
|
|
1189
|
-
errorView,
|
|
1190
|
-
workflowLabel: session.workflowLabel,
|
|
1191
|
-
skillId: session.skillId,
|
|
1192
|
-
menuOptions,
|
|
1193
|
-
onSelect: (value) => {
|
|
1194
|
-
if (value === "cancel") process.exit(0);
|
|
1195
|
-
else if (value === "more-info") setShowingMoreInfo(true);
|
|
1196
|
-
else if (value === "back") setShowingMoreInfo(false);
|
|
1197
|
-
else store.completeSetup();
|
|
1198
|
-
}
|
|
1199
|
-
});
|
|
1200
|
-
};
|
|
1201
|
-
const DetectErrorBody = ({ error }) => {
|
|
1202
|
-
switch (error.kind) {
|
|
1203
|
-
case "bad-directory": {
|
|
1204
|
-
const reasonText = {
|
|
1205
|
-
missing: "does not exist",
|
|
1206
|
-
"not-dir": "is not a directory",
|
|
1207
|
-
unreadable: "could not be accessed"
|
|
1208
|
-
}[error.reason];
|
|
1209
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Text, { children: [
|
|
1210
|
-
"This path ",
|
|
1211
|
-
reasonText,
|
|
1212
|
-
":"
|
|
1213
|
-
] }), /* @__PURE__ */ jsxs(Text, {
|
|
1214
|
-
dimColor: true,
|
|
1215
|
-
children: [" ", error.path]
|
|
1216
|
-
})] });
|
|
1217
|
-
}
|
|
1218
|
-
case "no-package-json": return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1219
|
-
/* @__PURE__ */ jsx(Text, { children: "No package.json found in this directory." }),
|
|
1220
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1221
|
-
dimColor: true,
|
|
1222
|
-
children: "Revenue analytics currently supports Node.js / TypeScript projects."
|
|
1223
|
-
}),
|
|
1224
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1225
|
-
dimColor: true,
|
|
1226
|
-
children: "Run this command from your project root."
|
|
1227
|
-
})
|
|
1228
|
-
] });
|
|
1229
|
-
case "no-sdks": return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1230
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
1231
|
-
"Neither PostHog nor Stripe SDKs detected (scanned",
|
|
1232
|
-
" ",
|
|
1233
|
-
error.scannedCount,
|
|
1234
|
-
" package.json file",
|
|
1235
|
-
error.scannedCount === 1 ? "" : "s",
|
|
1236
|
-
")."
|
|
1237
|
-
] }),
|
|
1238
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
1239
|
-
marginTop: 1,
|
|
1240
|
-
flexDirection: "column",
|
|
1241
|
-
children: [
|
|
1242
|
-
/* @__PURE__ */ jsx(Text, { children: "Revenue analytics requires:" }),
|
|
1243
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
1244
|
-
dimColor: true,
|
|
1245
|
-
children: [
|
|
1246
|
-
" •",
|
|
1247
|
-
" A PostHog SDK (",
|
|
1248
|
-
POSTHOG_SDKS.slice(0, 3).join(", "),
|
|
1249
|
-
", …)"
|
|
1250
|
-
]
|
|
1251
|
-
}),
|
|
1252
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
1253
|
-
dimColor: true,
|
|
1254
|
-
children: [
|
|
1255
|
-
" •",
|
|
1256
|
-
" A Stripe SDK (",
|
|
1257
|
-
STRIPE_SDKS.join(", "),
|
|
1258
|
-
")"
|
|
1259
|
-
]
|
|
1260
|
-
})
|
|
1261
|
-
]
|
|
1262
|
-
}),
|
|
1263
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1264
|
-
marginTop: 1,
|
|
1265
|
-
children: /* @__PURE__ */ jsxs(Text, {
|
|
1266
|
-
dimColor: true,
|
|
1267
|
-
children: [
|
|
1268
|
-
"Install Stripe and run ",
|
|
1269
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1270
|
-
bold: true,
|
|
1271
|
-
children: "npx @posthog/wizard"
|
|
1272
|
-
}),
|
|
1273
|
-
" to set up PostHog."
|
|
1274
|
-
]
|
|
1275
|
-
})
|
|
1276
|
-
})
|
|
1277
|
-
] });
|
|
1278
|
-
case "missing-posthog": return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Text, { children: [
|
|
1279
|
-
"Found Stripe (",
|
|
1280
|
-
error.foundStripe.join(", "),
|
|
1281
|
-
") but no PostHog SDK."
|
|
1282
|
-
] }), /* @__PURE__ */ jsx(Box, {
|
|
1283
|
-
marginTop: 1,
|
|
1284
|
-
children: /* @__PURE__ */ jsxs(Text, {
|
|
1285
|
-
dimColor: true,
|
|
1286
|
-
children: [
|
|
1287
|
-
"Run ",
|
|
1288
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1289
|
-
bold: true,
|
|
1290
|
-
children: "npx @posthog/wizard"
|
|
1291
|
-
}),
|
|
1292
|
-
" first to set up the base PostHog integration."
|
|
1293
|
-
]
|
|
1294
|
-
})
|
|
1295
|
-
})] });
|
|
1296
|
-
case "missing-stripe": return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1297
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
1298
|
-
"Found PostHog (",
|
|
1299
|
-
error.foundPosthog.join(", "),
|
|
1300
|
-
") but no Stripe SDK."
|
|
1301
|
-
] }),
|
|
1302
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1303
|
-
dimColor: true,
|
|
1304
|
-
children: "Revenue analytics currently supports Stripe only."
|
|
1305
|
-
}),
|
|
1306
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
1307
|
-
marginTop: 1,
|
|
1308
|
-
flexDirection: "column",
|
|
1309
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
1310
|
-
dimColor: true,
|
|
1311
|
-
children: "Install one of:"
|
|
1312
|
-
}), STRIPE_SDKS.map((sdk) => /* @__PURE__ */ jsxs(Text, {
|
|
1313
|
-
dimColor: true,
|
|
1314
|
-
children: [
|
|
1315
|
-
" •",
|
|
1316
|
-
" ",
|
|
1317
|
-
sdk
|
|
1318
|
-
]
|
|
1319
|
-
}, sdk))]
|
|
1320
|
-
})
|
|
1321
|
-
] });
|
|
1322
|
-
}
|
|
1323
|
-
};
|
|
1324
|
-
//#endregion
|
|
1325
|
-
//#region src/ui/tui/screens/AgentSkillIntroScreen.tsx
|
|
1326
|
-
/**
|
|
1327
|
-
* AgentSkillIntroScreen — Intro screen for the generic agent-skill workflow.
|
|
1328
|
-
*
|
|
1329
|
-
* Main menu: one-liner body, detection rows, continue/cancel.
|
|
1330
|
-
* More info: skill name, download URL fetched from the skill menu.
|
|
1331
|
-
*/
|
|
1332
|
-
const AgentSkillIntroScreen = ({ store }) => {
|
|
1333
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
1334
|
-
const [showingMoreInfo, setShowingMoreInfo] = useState(false);
|
|
1335
|
-
const [skillEntry, setSkillEntry] = useState(null);
|
|
1336
|
-
const [fetchFailed, setFetchFailed] = useState(false);
|
|
1337
|
-
const { session } = store;
|
|
1338
|
-
const skillId = session.skillId ?? "unknown";
|
|
1339
|
-
const isMainMenu = !showingMoreInfo;
|
|
1340
|
-
useEffect(() => {
|
|
1341
|
-
if (!showingMoreInfo || skillEntry || fetchFailed) return;
|
|
1342
|
-
fetchSkillMenu(getSkillsBaseUrl(session.localMcp)).then((menu) => {
|
|
1343
|
-
if (!menu) {
|
|
1344
|
-
setFetchFailed(true);
|
|
1345
|
-
return;
|
|
1346
|
-
}
|
|
1347
|
-
const match = Object.values(menu.categories).flat().find((s) => s.id === skillId);
|
|
1348
|
-
if (match) setSkillEntry(match);
|
|
1349
|
-
else setFetchFailed(true);
|
|
1350
|
-
});
|
|
1351
|
-
}, [
|
|
1352
|
-
showingMoreInfo,
|
|
1353
|
-
skillEntry,
|
|
1354
|
-
fetchFailed,
|
|
1355
|
-
skillId,
|
|
1356
|
-
session.localMcp
|
|
1357
|
-
]);
|
|
1358
|
-
let body;
|
|
1359
|
-
if (showingMoreInfo) body = /* @__PURE__ */ jsxs(Box, {
|
|
1360
|
-
flexDirection: "column",
|
|
1361
|
-
width: 56,
|
|
1362
|
-
flexShrink: 0,
|
|
1363
|
-
children: [
|
|
1364
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1365
|
-
flexDirection: "column",
|
|
1366
|
-
marginBottom: 1,
|
|
1367
|
-
children: /* @__PURE__ */ jsxs(Text, { children: ["The wizard is an agent that executes PostHog tasks. Its code is open source: ", /* @__PURE__ */ jsx(Text, {
|
|
1368
|
-
color: "cyan",
|
|
1369
|
-
children: "https://github.com/PostHog/wizard"
|
|
1370
|
-
})] })
|
|
1371
|
-
}),
|
|
1372
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
1373
|
-
"Skill:",
|
|
1374
|
-
" ",
|
|
1375
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1376
|
-
italic: true,
|
|
1377
|
-
color: "cyan",
|
|
1378
|
-
children: skillEntry?.id ?? skillId
|
|
1379
|
-
})
|
|
1380
|
-
] }),
|
|
1381
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
1382
|
-
"URL:",
|
|
1383
|
-
" ",
|
|
1384
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1385
|
-
color: "cyan",
|
|
1386
|
-
children: skillEntry?.downloadUrl ?? (fetchFailed ? "unavailable" : "Loading...")
|
|
1387
|
-
})
|
|
1388
|
-
] }),
|
|
1389
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1390
|
-
marginTop: 1,
|
|
1391
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
1392
|
-
dimColor: true,
|
|
1393
|
-
children: skillEntry?.name ?? (fetchFailed ? skillId : "Loading...")
|
|
1394
|
-
})
|
|
1395
|
-
})
|
|
1396
|
-
]
|
|
1397
|
-
});
|
|
1398
|
-
else body = /* @__PURE__ */ jsxs(Text, { children: [
|
|
1399
|
-
"Let's run the",
|
|
1400
|
-
" ",
|
|
1401
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1402
|
-
italic: true,
|
|
1403
|
-
color: "cyan",
|
|
1404
|
-
children: skillId
|
|
1405
|
-
}),
|
|
1406
|
-
" ",
|
|
1407
|
-
"skill."
|
|
1408
|
-
] });
|
|
1409
|
-
const menuOptions = showingMoreInfo ? [{
|
|
1410
|
-
label: "Back",
|
|
1411
|
-
value: "back"
|
|
1412
|
-
}] : [
|
|
1413
|
-
{
|
|
1414
|
-
label: "Continue",
|
|
1415
|
-
value: "continue"
|
|
1416
|
-
},
|
|
1417
|
-
{
|
|
1418
|
-
label: "More info",
|
|
1419
|
-
value: "more-info"
|
|
1420
|
-
},
|
|
1421
|
-
{
|
|
1422
|
-
label: "Cancel",
|
|
1423
|
-
value: "cancel"
|
|
1424
|
-
}
|
|
1425
|
-
];
|
|
1426
|
-
const handleSelect = (value) => {
|
|
1427
|
-
if (value === "cancel") process.exit(0);
|
|
1428
|
-
else if (value === "more-info") setShowingMoreInfo(true);
|
|
1429
|
-
else if (value === "back") setShowingMoreInfo(false);
|
|
1430
|
-
else store.completeSetup();
|
|
1431
|
-
};
|
|
1432
|
-
return /* @__PURE__ */ jsx(IntroScreenLayout, {
|
|
1433
|
-
installDir: session.installDir,
|
|
1434
|
-
showSubtitle: !showingMoreInfo,
|
|
1435
|
-
body,
|
|
1436
|
-
showDetection: isMainMenu,
|
|
1437
|
-
workflowLabel: session.workflowLabel,
|
|
1438
|
-
skillId: session.skillId,
|
|
1439
|
-
menuOptions,
|
|
1440
|
-
onSelect: handleSelect
|
|
1441
|
-
});
|
|
1442
|
-
};
|
|
1443
|
-
//#endregion
|
|
1444
|
-
//#region src/ui/tui/screens/SetupScreen.tsx
|
|
1445
|
-
/**
|
|
1446
|
-
* SetupScreen — Generic framework disambiguation.
|
|
1447
|
-
*
|
|
1448
|
-
* Iterates unresolved setup questions from the FrameworkConfig
|
|
1449
|
-
* and renders a PickerMenu for each. If all questions are auto-resolved,
|
|
1450
|
-
* this screen is skipped entirely (the router skips it via its show() predicate).
|
|
1451
|
-
*/
|
|
1452
|
-
const SetupScreen = ({ store }) => {
|
|
1453
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
1454
|
-
const config = store.session.frameworkConfig;
|
|
1455
|
-
const questions = config?.metadata.setup?.questions ?? [];
|
|
1456
|
-
const [currentIndex, setCurrentIndex] = useState(0);
|
|
1457
|
-
const [resolving, setResolving] = useState(true);
|
|
1458
|
-
useEffect(() => {
|
|
1459
|
-
(async () => {
|
|
1460
|
-
for (const q of questions) {
|
|
1461
|
-
if (q.key in store.session.frameworkContext) continue;
|
|
1462
|
-
try {
|
|
1463
|
-
const detected = await q.detect({ installDir: store.session.installDir });
|
|
1464
|
-
if (detected !== null) store.setFrameworkContext(q.key, detected);
|
|
1465
|
-
} catch {}
|
|
1466
|
-
}
|
|
1467
|
-
setResolving(false);
|
|
1468
|
-
})();
|
|
1469
|
-
}, []);
|
|
1470
|
-
if (resolving) return /* @__PURE__ */ jsx(Box, {
|
|
1471
|
-
flexDirection: "column",
|
|
1472
|
-
flexGrow: 1,
|
|
1473
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
1474
|
-
dimColor: true,
|
|
1475
|
-
children: "Detecting project configuration..."
|
|
1476
|
-
})
|
|
1477
|
-
});
|
|
1478
|
-
const unresolved = questions.filter((q) => !(q.key in store.session.frameworkContext));
|
|
1479
|
-
if (unresolved.length === 0) return null;
|
|
1480
|
-
const question = unresolved[currentIndex] ?? unresolved[0];
|
|
1481
|
-
if (!question) return null;
|
|
1482
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
1483
|
-
flexDirection: "column",
|
|
1484
|
-
flexGrow: 1,
|
|
1485
|
-
children: [/* @__PURE__ */ jsxs(Box, {
|
|
1486
|
-
flexDirection: "column",
|
|
1487
|
-
marginBottom: 1,
|
|
1488
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
1489
|
-
bold: true,
|
|
1490
|
-
color: Colors.accent,
|
|
1491
|
-
children: "Project Setup"
|
|
1492
|
-
}), config && /* @__PURE__ */ jsxs(Text, {
|
|
1493
|
-
dimColor: true,
|
|
1494
|
-
children: [
|
|
1495
|
-
"Configuring ",
|
|
1496
|
-
config.metadata.name,
|
|
1497
|
-
" integration"
|
|
1498
|
-
]
|
|
1499
|
-
})]
|
|
1500
|
-
}), /* @__PURE__ */ jsx(PickerMenu, {
|
|
1501
|
-
message: question.message,
|
|
1502
|
-
options: question.options.map((o) => ({
|
|
1503
|
-
label: o.label,
|
|
1504
|
-
value: o.value,
|
|
1505
|
-
hint: o.hint
|
|
1506
|
-
})),
|
|
1507
|
-
onSelect: (value) => {
|
|
1508
|
-
const selected = Array.isArray(value) ? value[0] : value;
|
|
1509
|
-
store.setFrameworkContext(question.key, selected);
|
|
1510
|
-
if (unresolved.filter((q) => q.key !== question.key && !(q.key in store.session.frameworkContext)).length > 0) setCurrentIndex((i) => i + 1);
|
|
1511
|
-
}
|
|
1512
|
-
})]
|
|
1513
|
-
});
|
|
1514
|
-
};
|
|
1515
|
-
//#endregion
|
|
1516
|
-
//#region src/ui/tui/screens/AuthScreen.tsx
|
|
1517
|
-
/**
|
|
1518
|
-
* AuthScreen — Shown while waiting for OAuth authentication.
|
|
1519
|
-
*
|
|
1520
|
-
* Displays framework detection results, beta/disclosure notices,
|
|
1521
|
-
* a waiting spinner, and the login URL when available.
|
|
1522
|
-
* The router resolves past this screen once session.credentials is set.
|
|
1523
|
-
*/
|
|
1524
|
-
const AuthScreen = ({ store }) => {
|
|
1525
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
1526
|
-
const { session } = store;
|
|
1527
|
-
const config = session.frameworkConfig;
|
|
1528
|
-
const frameworkLabel = session.detectedFrameworkLabel ?? config?.metadata.name;
|
|
1529
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
1530
|
-
flexDirection: "column",
|
|
1531
|
-
flexGrow: 1,
|
|
1532
|
-
children: [
|
|
1533
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
1534
|
-
flexDirection: "column",
|
|
1535
|
-
marginBottom: 1,
|
|
1536
|
-
children: [
|
|
1537
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1538
|
-
bold: true,
|
|
1539
|
-
color: Colors.accent,
|
|
1540
|
-
children: "PostHog Setup Wizard"
|
|
1541
|
-
}),
|
|
1542
|
-
frameworkLabel && /* @__PURE__ */ jsxs(Text, { children: [/* @__PURE__ */ jsxs(Text, {
|
|
1543
|
-
color: "green",
|
|
1544
|
-
children: ["✔", " "]
|
|
1545
|
-
}), /* @__PURE__ */ jsxs(Text, { children: ["Framework: ", frameworkLabel] })] }),
|
|
1546
|
-
config?.metadata.beta && /* @__PURE__ */ jsxs(Text, {
|
|
1547
|
-
color: "yellow",
|
|
1548
|
-
children: [
|
|
1549
|
-
"[BETA] The ",
|
|
1550
|
-
config.metadata.name,
|
|
1551
|
-
" wizard is in beta. Questions or feedback? Email wizard@posthog.com"
|
|
1552
|
-
]
|
|
1553
|
-
}),
|
|
1554
|
-
config?.metadata.preRunNotice && /* @__PURE__ */ jsx(Text, {
|
|
1555
|
-
color: "yellow",
|
|
1556
|
-
children: config.metadata.preRunNotice
|
|
1557
|
-
})
|
|
1558
|
-
]
|
|
1559
|
-
}),
|
|
1560
|
-
/* @__PURE__ */ jsx(LoadingBox, { message: "Waiting for authentication..." }),
|
|
1561
|
-
session.loginUrl && /* @__PURE__ */ jsxs(Box, {
|
|
1562
|
-
marginTop: 1,
|
|
1563
|
-
flexDirection: "column",
|
|
1564
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
1565
|
-
dimColor: true,
|
|
1566
|
-
children: "If the browser didn't open, copy and paste this URL:"
|
|
1567
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
1568
|
-
color: "cyan",
|
|
1569
|
-
children: session.loginUrl
|
|
1570
|
-
})]
|
|
1571
|
-
})
|
|
1572
|
-
]
|
|
1573
|
-
});
|
|
1574
|
-
};
|
|
1575
|
-
//#endregion
|
|
1576
|
-
//#region src/ui/tui/screens/RunScreen.tsx
|
|
1577
|
-
/**
|
|
1578
|
-
* RunScreen — Tabbed observational view of the agent run.
|
|
1579
|
-
*
|
|
1580
|
-
* Two tabs:
|
|
1581
|
-
* - Status: SplitView with LearnCard (left) + ProgressList (right)
|
|
1582
|
-
* - Logs: LogViewer tailing the wizard log file
|
|
1583
|
-
*
|
|
1584
|
-
* No prompts — the agent runs headlessly.
|
|
1585
|
-
* LearnCard shows animated educational content and reacts to discovered features.
|
|
1586
|
-
*/
|
|
1587
|
-
const RunScreen = ({ store }) => {
|
|
1588
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
1589
|
-
const [columns] = useStdoutDimensions();
|
|
1590
|
-
const progressItems = store.tasks.map((t) => ({
|
|
1591
|
-
label: t.label,
|
|
1592
|
-
activeForm: t.activeForm,
|
|
1593
|
-
status: t.status
|
|
1594
|
-
}));
|
|
1595
|
-
const queue = store.session.additionalFeatureQueue;
|
|
1596
|
-
if (progressItems.length > 0 && progressItems.every((t) => t.status === "completed") && queue.length > 0) {
|
|
1597
|
-
const nextLabel = ADDITIONAL_FEATURE_LABELS[queue[0]];
|
|
1598
|
-
progressItems.push({
|
|
1599
|
-
label: `Set up ${nextLabel}`,
|
|
1600
|
-
activeForm: `Setting up ${nextLabel}...`,
|
|
1601
|
-
status: "in_progress"
|
|
1602
|
-
});
|
|
1603
|
-
}
|
|
1604
|
-
const statuses = store.statusMessages.length > 0 ? store.statusMessages : void 0;
|
|
1605
|
-
const leftPane = store.learnCardComplete ? /* @__PURE__ */ jsx(TipsCard, { store }) : /* @__PURE__ */ jsx(LearnCard, {
|
|
1606
|
-
store,
|
|
1607
|
-
onComplete: () => store.setLearnCardComplete()
|
|
1608
|
-
});
|
|
1609
|
-
const progressList = /* @__PURE__ */ jsx(ProgressList, {
|
|
1610
|
-
items: progressItems,
|
|
1611
|
-
title: "Tasks"
|
|
1612
|
-
});
|
|
1613
|
-
return /* @__PURE__ */ jsx(TabContainer, {
|
|
1614
|
-
tabs: [
|
|
1615
|
-
{
|
|
1616
|
-
id: "status",
|
|
1617
|
-
label: "Status",
|
|
1618
|
-
component: columns < 80 ? /* @__PURE__ */ jsx(Box, {
|
|
1619
|
-
flexDirection: "column",
|
|
1620
|
-
flexGrow: 1,
|
|
1621
|
-
children: progressList
|
|
1622
|
-
}) : /* @__PURE__ */ jsx(SplitView, {
|
|
1623
|
-
left: leftPane,
|
|
1624
|
-
right: progressList
|
|
1625
|
-
})
|
|
1626
|
-
},
|
|
1627
|
-
...store.eventPlan.length > 0 ? [{
|
|
1628
|
-
id: "events",
|
|
1629
|
-
label: "Event plan",
|
|
1630
|
-
component: /* @__PURE__ */ jsx(EventPlanViewer, { events: store.eventPlan })
|
|
1631
|
-
}] : [],
|
|
1632
|
-
{
|
|
1633
|
-
id: "logs",
|
|
1634
|
-
label: "Tail logs",
|
|
1635
|
-
component: /* @__PURE__ */ jsx(LogViewer, { filePath: WIZARD_LOG_FILE })
|
|
1636
|
-
},
|
|
1637
|
-
{
|
|
1638
|
-
id: "hn",
|
|
1639
|
-
label: "HN",
|
|
1640
|
-
component: /* @__PURE__ */ jsx(HNViewer, {})
|
|
1641
|
-
}
|
|
1642
|
-
],
|
|
1643
|
-
statusMessage: statuses,
|
|
1644
|
-
expandableStatus: true,
|
|
1645
|
-
store
|
|
1646
|
-
});
|
|
1647
|
-
};
|
|
1648
|
-
//#endregion
|
|
1649
|
-
//#region src/ui/tui/screens/KeepSkillsScreen.tsx
|
|
1650
|
-
/**
|
|
1651
|
-
* KeepSkillsScreen — Ask whether to keep installed skills in .claude/skills/.
|
|
1652
|
-
*
|
|
1653
|
-
* Shown after the outro summary so users see the agent's output first,
|
|
1654
|
-
* then decide whether to keep the skills that powered it.
|
|
1655
|
-
*
|
|
1656
|
-
* When done, calls store.setSkillsComplete() and exits the process.
|
|
1657
|
-
*/
|
|
1658
|
-
const KeepSkillsScreen = ({ store }) => {
|
|
1659
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
1660
|
-
const [phase, setPhase] = useState("loading");
|
|
1661
|
-
const [skills, setSkills] = useState([]);
|
|
1662
|
-
const skillsDir = join(store.session.installDir, ".claude", "skills");
|
|
1663
|
-
useEffect(() => {
|
|
1664
|
-
(async () => {
|
|
1665
|
-
try {
|
|
1666
|
-
const dirs = (await readdir(skillsDir, { withFileTypes: true })).filter((e) => e.isDirectory());
|
|
1667
|
-
const result = [];
|
|
1668
|
-
for (const dir of dirs) {
|
|
1669
|
-
const children = await readdir(join(skillsDir, dir.name));
|
|
1670
|
-
result.push({
|
|
1671
|
-
name: dir.name,
|
|
1672
|
-
children
|
|
1673
|
-
});
|
|
1674
|
-
}
|
|
1675
|
-
if (result.length === 0) {
|
|
1676
|
-
store.setSkillsComplete(true);
|
|
1677
|
-
process.exit(0);
|
|
1678
|
-
}
|
|
1679
|
-
setSkills(result);
|
|
1680
|
-
setPhase("ask");
|
|
1681
|
-
} catch {
|
|
1682
|
-
store.setSkillsComplete(true);
|
|
1683
|
-
process.exit(0);
|
|
1684
|
-
}
|
|
1685
|
-
})();
|
|
1686
|
-
}, []);
|
|
1687
|
-
const handleKeep = () => {
|
|
1688
|
-
store.setSkillsComplete(true);
|
|
1689
|
-
process.exit(0);
|
|
1690
|
-
};
|
|
1691
|
-
const handleRemove = async () => {
|
|
1692
|
-
setPhase("removing");
|
|
1693
|
-
try {
|
|
1694
|
-
await rm(skillsDir, {
|
|
1695
|
-
recursive: true,
|
|
1696
|
-
force: true
|
|
1697
|
-
});
|
|
1698
|
-
} catch {}
|
|
1699
|
-
setPhase("done");
|
|
1700
|
-
setTimeout(() => {
|
|
1701
|
-
store.setSkillsComplete(false);
|
|
1702
|
-
process.exit(0);
|
|
1703
|
-
}, 600);
|
|
1704
|
-
};
|
|
1705
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
1706
|
-
flexDirection: "column",
|
|
1707
|
-
flexGrow: 1,
|
|
1708
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
1709
|
-
bold: true,
|
|
1710
|
-
color: Colors.accent,
|
|
1711
|
-
children: "Keep the skills?"
|
|
1712
|
-
}), /* @__PURE__ */ jsxs(Box, {
|
|
1713
|
-
marginTop: 1,
|
|
1714
|
-
flexDirection: "column",
|
|
1715
|
-
children: [
|
|
1716
|
-
phase === "loading" && /* @__PURE__ */ jsx(Text, {
|
|
1717
|
-
dimColor: true,
|
|
1718
|
-
children: "Checking installed skills..."
|
|
1719
|
-
}),
|
|
1720
|
-
phase === "ask" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1721
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1722
|
-
dimColor: true,
|
|
1723
|
-
children: "The wizard installed open-source skills that help AI coding agents integrate PostHog into your project:"
|
|
1724
|
-
}),
|
|
1725
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
1726
|
-
marginTop: 1,
|
|
1727
|
-
flexDirection: "column",
|
|
1728
|
-
marginLeft: 2,
|
|
1729
|
-
children: [
|
|
1730
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1731
|
-
dimColor: true,
|
|
1732
|
-
children: ".claude/"
|
|
1733
|
-
}),
|
|
1734
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1735
|
-
dimColor: true,
|
|
1736
|
-
children: " skills/"
|
|
1737
|
-
}),
|
|
1738
|
-
skills.map((skill) => /* @__PURE__ */ jsxs(Box, {
|
|
1739
|
-
flexDirection: "column",
|
|
1740
|
-
children: [/* @__PURE__ */ jsxs(Text, {
|
|
1741
|
-
dimColor: true,
|
|
1742
|
-
children: [
|
|
1743
|
-
" ",
|
|
1744
|
-
skill.name,
|
|
1745
|
-
"/"
|
|
1746
|
-
]
|
|
1747
|
-
}), skill.children.map((child) => /* @__PURE__ */ jsxs(Text, {
|
|
1748
|
-
dimColor: true,
|
|
1749
|
-
children: [" ", child]
|
|
1750
|
-
}, child))]
|
|
1751
|
-
}, skill.name))
|
|
1752
|
-
]
|
|
1753
|
-
}),
|
|
1754
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1755
|
-
marginTop: 1,
|
|
1756
|
-
children: /* @__PURE__ */ jsxs(Text, {
|
|
1757
|
-
dimColor: true,
|
|
1758
|
-
children: ["Source: ", /* @__PURE__ */ jsx(Text, {
|
|
1759
|
-
color: "cyan",
|
|
1760
|
-
children: "https://github.com/PostHog/context-mill"
|
|
1761
|
-
})]
|
|
1762
|
-
})
|
|
1763
|
-
}),
|
|
1764
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1765
|
-
marginTop: 1,
|
|
1766
|
-
children: /* @__PURE__ */ jsx(ConfirmationInput, {
|
|
1767
|
-
message: "Keep the installed skills?",
|
|
1768
|
-
confirmLabel: "Keep [Enter]",
|
|
1769
|
-
cancelLabel: "Remove [Esc]",
|
|
1770
|
-
onConfirm: handleKeep,
|
|
1771
|
-
onCancel: () => void handleRemove()
|
|
1772
|
-
})
|
|
1773
|
-
})
|
|
1774
|
-
] }),
|
|
1775
|
-
phase === "removing" && /* @__PURE__ */ jsx(Text, {
|
|
1776
|
-
dimColor: true,
|
|
1777
|
-
children: "Removing skills..."
|
|
1778
|
-
}),
|
|
1779
|
-
phase === "done" && /* @__PURE__ */ jsx(Text, {
|
|
1780
|
-
dimColor: true,
|
|
1781
|
-
children: "Skills removed."
|
|
1782
|
-
})
|
|
1783
|
-
]
|
|
1784
|
-
})]
|
|
1785
|
-
});
|
|
1786
|
-
};
|
|
1787
|
-
//#endregion
|
|
1788
|
-
//#region src/ui/tui/screens/OutroScreen.tsx
|
|
1789
|
-
/**
|
|
1790
|
-
* OutroScreen — Summary after the agent run.
|
|
1791
|
-
* Reads store.session.outroData to render success, error, or cancel view.
|
|
1792
|
-
* Keeps the process alive until the user presses a key to exit.
|
|
1793
|
-
*/
|
|
1794
|
-
const OutroScreen = ({ store }) => {
|
|
1795
|
-
useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
|
|
1796
|
-
useInput(() => {
|
|
1797
|
-
store.setOutroDismissed();
|
|
1798
|
-
});
|
|
1799
|
-
const outroData = store.session.outroData;
|
|
1800
|
-
if (!outroData) return /* @__PURE__ */ jsx(Box, {
|
|
1801
|
-
flexDirection: "column",
|
|
1802
|
-
flexGrow: 1,
|
|
1803
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
1804
|
-
dimColor: true,
|
|
1805
|
-
children: "Finishing up..."
|
|
1806
|
-
})
|
|
1807
|
-
});
|
|
1808
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
1809
|
-
flexDirection: "column",
|
|
1810
|
-
flexGrow: 1,
|
|
1811
|
-
children: [
|
|
1812
|
-
outroData.kind === "success" && /* @__PURE__ */ jsxs(Box, {
|
|
1813
|
-
flexDirection: "column",
|
|
1814
|
-
children: [
|
|
1815
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
1816
|
-
color: "green",
|
|
1817
|
-
bold: true,
|
|
1818
|
-
children: [
|
|
1819
|
-
"✔",
|
|
1820
|
-
" ",
|
|
1821
|
-
outroData.message || "Done!"
|
|
1822
|
-
]
|
|
1823
|
-
}),
|
|
1824
|
-
outroData.reportFile && /* @__PURE__ */ jsx(Box, {
|
|
1825
|
-
marginTop: 1,
|
|
1826
|
-
children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
1827
|
-
"Check ",
|
|
1828
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
1829
|
-
bold: true,
|
|
1830
|
-
children: ["./", outroData.reportFile]
|
|
1831
|
-
}),
|
|
1832
|
-
" for details"
|
|
1833
|
-
] })
|
|
1834
|
-
}),
|
|
1835
|
-
outroData.changes && outroData.changes.length > 0 && /* @__PURE__ */ jsxs(Box, {
|
|
1836
|
-
flexDirection: "column",
|
|
1837
|
-
marginTop: 1,
|
|
1838
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
1839
|
-
color: "cyan",
|
|
1840
|
-
bold: true,
|
|
1841
|
-
children: "What the agent did:"
|
|
1842
|
-
}), outroData.changes.map((change, i) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
1843
|
-
"•",
|
|
1844
|
-
" ",
|
|
1845
|
-
change
|
|
1846
|
-
] }, i))]
|
|
1847
|
-
}),
|
|
1848
|
-
store.eventPlan.length > 0 && /* @__PURE__ */ jsxs(Box, {
|
|
1849
|
-
flexDirection: "column",
|
|
1850
|
-
marginTop: 1,
|
|
1851
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
1852
|
-
color: "cyan",
|
|
1853
|
-
bold: true,
|
|
1854
|
-
children: "Events added:"
|
|
1855
|
-
}), store.eventPlan.map((event) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
1856
|
-
"•",
|
|
1857
|
-
" ",
|
|
1858
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1859
|
-
bold: true,
|
|
1860
|
-
children: event.name
|
|
1861
|
-
}),
|
|
1862
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
1863
|
-
dimColor: true,
|
|
1864
|
-
children: [" ", event.description]
|
|
1865
|
-
})
|
|
1866
|
-
] }, event.name))]
|
|
1867
|
-
}),
|
|
1868
|
-
outroData.docsUrl && /* @__PURE__ */ jsx(Box, {
|
|
1869
|
-
marginTop: 1,
|
|
1870
|
-
children: /* @__PURE__ */ jsxs(Text, { children: ["Learn more: ", /* @__PURE__ */ jsx(Text, {
|
|
1871
|
-
color: "cyan",
|
|
1872
|
-
children: outroData.docsUrl
|
|
1873
|
-
})] })
|
|
1874
|
-
}),
|
|
1875
|
-
outroData.continueUrl && /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
1876
|
-
"Continue onboarding:",
|
|
1877
|
-
" ",
|
|
1878
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1879
|
-
color: "cyan",
|
|
1880
|
-
children: outroData.continueUrl
|
|
1881
|
-
})
|
|
1882
|
-
] }) }),
|
|
1883
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1884
|
-
marginTop: 1,
|
|
1885
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
1886
|
-
dimColor: true,
|
|
1887
|
-
children: "Note: This wizard uses an LLM agent to analyze and modify your project. Please review the changes made."
|
|
1888
|
-
})
|
|
1889
|
-
}),
|
|
1890
|
-
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, {
|
|
1891
|
-
dimColor: true,
|
|
1892
|
-
children: "How did this work for you? Drop us a line: wizard@posthog.com"
|
|
1893
|
-
}) })
|
|
1894
|
-
]
|
|
1895
|
-
}),
|
|
1896
|
-
outroData.kind === "error" && /* @__PURE__ */ jsxs(Box, {
|
|
1897
|
-
flexDirection: "column",
|
|
1898
|
-
children: [
|
|
1899
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
1900
|
-
color: "red",
|
|
1901
|
-
bold: true,
|
|
1902
|
-
children: [
|
|
1903
|
-
"✘",
|
|
1904
|
-
" ",
|
|
1905
|
-
outroData.message || "An error occurred"
|
|
1906
|
-
]
|
|
1907
|
-
}),
|
|
1908
|
-
outroData.body && /* @__PURE__ */ jsx(Box, {
|
|
1909
|
-
marginTop: 1,
|
|
1910
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
1911
|
-
dimColor: true,
|
|
1912
|
-
children: outroData.body
|
|
1913
|
-
})
|
|
1914
|
-
}),
|
|
1915
|
-
outroData.docsUrl && /* @__PURE__ */ jsx(Box, {
|
|
1916
|
-
marginTop: 1,
|
|
1917
|
-
children: /* @__PURE__ */ jsxs(Text, { children: ["Docs: ", /* @__PURE__ */ jsx(Text, {
|
|
1918
|
-
color: "cyan",
|
|
1919
|
-
children: outroData.docsUrl
|
|
1920
|
-
})] })
|
|
1921
|
-
})
|
|
1922
|
-
]
|
|
1923
|
-
}),
|
|
1924
|
-
outroData.kind === "cancel" && /* @__PURE__ */ jsx(Box, {
|
|
1925
|
-
flexDirection: "column",
|
|
1926
|
-
children: /* @__PURE__ */ jsxs(Text, {
|
|
1927
|
-
color: "yellow",
|
|
1928
|
-
children: [
|
|
1929
|
-
"■",
|
|
1930
|
-
" ",
|
|
1931
|
-
outroData.message || "Cancelled"
|
|
1932
|
-
]
|
|
1933
|
-
})
|
|
1934
|
-
}),
|
|
1935
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1936
|
-
marginTop: 1,
|
|
1937
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
1938
|
-
color: Colors.muted,
|
|
1939
|
-
children: "Press any key to continue"
|
|
1940
|
-
})
|
|
1941
|
-
})
|
|
1942
|
-
]
|
|
1943
|
-
});
|
|
1944
|
-
};
|
|
1945
|
-
//#endregion
|
|
1946
|
-
//#region src/ui/tui/screens/ExitScreen.tsx
|
|
1947
|
-
/**
|
|
1948
|
-
* ExitScreen — Final step in every workflow.
|
|
1949
|
-
*
|
|
1950
|
-
* Renders nothing. Immediately exits the process.
|
|
1951
|
-
* The cleanup handler in start-tui.ts handles the exit summary line.
|
|
1952
|
-
*/
|
|
1953
|
-
const ExitScreen = () => {
|
|
1954
|
-
useEffect(() => {
|
|
1955
|
-
process.exit(0);
|
|
1956
|
-
}, []);
|
|
1957
|
-
return null;
|
|
1958
|
-
};
|
|
1959
|
-
//#endregion
|
|
1960
|
-
//#region src/ui/tui/screens/AuthErrorScreen.tsx
|
|
1961
|
-
/**
|
|
1962
|
-
* AuthErrorScreen — Shown when the Anthropic API returns a 401.
|
|
1963
|
-
*
|
|
1964
|
-
* Claude Code's own auth can conflict with the wizard's OAuth token.
|
|
1965
|
-
* This overlay tells the user to log out of Claude Code and retry.
|
|
1966
|
-
*/
|
|
1967
|
-
const AuthErrorScreen = () => {
|
|
1968
|
-
useInput(() => {
|
|
1969
|
-
process.exit(1);
|
|
1970
|
-
});
|
|
1971
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
1972
|
-
flexDirection: "column",
|
|
1973
|
-
flexGrow: 1,
|
|
1974
|
-
children: [
|
|
1975
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
1976
|
-
color: "red",
|
|
1977
|
-
bold: true,
|
|
1978
|
-
children: ["✘", " Authentication error"]
|
|
1979
|
-
}),
|
|
1980
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1981
|
-
flexDirection: "column",
|
|
1982
|
-
marginTop: 1,
|
|
1983
|
-
children: /* @__PURE__ */ jsx(Text, { children: "The Wizard couldn't connect to the PostHog LLM Gateway. If you use Claude Code, its credentials might conflict with the Wizard." })
|
|
1984
|
-
}),
|
|
1985
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1986
|
-
marginTop: 1,
|
|
1987
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
1988
|
-
dimColor: true,
|
|
1989
|
-
children: "Try logging out of Claude Code temporarily and re-running the Wizard by running:"
|
|
1990
|
-
})
|
|
1991
|
-
}),
|
|
1992
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1993
|
-
flexDirection: "column",
|
|
1994
|
-
marginTop: 1,
|
|
1995
|
-
paddingLeft: 2,
|
|
1996
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
1997
|
-
color: "cyan",
|
|
1998
|
-
children: "claude auth logout"
|
|
1999
|
-
})
|
|
2000
|
-
}),
|
|
2001
|
-
/* @__PURE__ */ jsx(Box, {
|
|
2002
|
-
marginTop: 1,
|
|
2003
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
2004
|
-
color: Colors.muted,
|
|
2005
|
-
children: "Press any key to exit"
|
|
2006
|
-
})
|
|
2007
|
-
})
|
|
2008
|
-
]
|
|
2009
|
-
});
|
|
2010
|
-
};
|
|
2011
|
-
//#endregion
|
|
2012
|
-
//#region src/ui/tui/services/mcp-installer.ts
|
|
2013
|
-
/**
|
|
2014
|
-
* McpInstaller — service layer between McpScreen and MCP business logic.
|
|
2015
|
-
*
|
|
2016
|
-
* Decouples the screen from step internals. Testable, swappable,
|
|
2017
|
-
* no dynamic imports in React components.
|
|
2018
|
-
*/
|
|
2019
|
-
/**
|
|
2020
|
-
* Production McpInstaller backed by real MCP client detection and installation.
|
|
2021
|
-
*/
|
|
2022
|
-
function createMcpInstaller() {
|
|
2023
|
-
let cachedClients = [];
|
|
2024
|
-
return {
|
|
2025
|
-
async detectClients() {
|
|
2026
|
-
const supported = await getSupportedClients();
|
|
2027
|
-
cachedClients = supported.map((c) => ({
|
|
2028
|
-
name: c.name,
|
|
2029
|
-
raw: c
|
|
2030
|
-
}));
|
|
2031
|
-
return supported.map((c) => ({
|
|
2032
|
-
name: c.name,
|
|
2033
|
-
supportsPlugin: isPluginCapable(c) && c.supportsPlugin()
|
|
2034
|
-
}));
|
|
2035
|
-
},
|
|
2036
|
-
async install(clientNames, features, apiKey) {
|
|
2037
|
-
const resolvedFeatures = features ?? [...ALL_FEATURE_VALUES];
|
|
2038
|
-
const toInstall = cachedClients.filter((c) => clientNames.includes(c.name)).map((c) => c.raw);
|
|
2039
|
-
if (toInstall.length === 0) {
|
|
2040
|
-
logToFile(`[McpInstaller] No clients matched. clientNames=${JSON.stringify(clientNames)}, cached=${JSON.stringify(cachedClients.map((c) => c.name))}`);
|
|
2041
|
-
return [];
|
|
2042
|
-
}
|
|
2043
|
-
const installed = [];
|
|
2044
|
-
for (const client of toInstall) try {
|
|
2045
|
-
if ((await client.addServer(apiKey, resolvedFeatures, false))?.success) installed.push(client.name);
|
|
2046
|
-
else logToFile(`[McpInstaller] addServer returned success=false for ${client.name}`);
|
|
2047
|
-
} catch (err) {
|
|
2048
|
-
logToFile(`[McpInstaller] addServer threw for ${client.name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
2049
|
-
}
|
|
2050
|
-
return installed;
|
|
2051
|
-
},
|
|
2052
|
-
async remove() {
|
|
2053
|
-
const installed = await getInstalledClients();
|
|
2054
|
-
if (installed.length === 0) return [];
|
|
2055
|
-
await removeMCPServer(installed);
|
|
2056
|
-
return installed.map((c) => c.name);
|
|
2057
|
-
},
|
|
2058
|
-
async installPlugins(clientNames) {
|
|
2059
|
-
const pluginClients = getSupportedPluginClients(cachedClients.filter((c) => clientNames.includes(c.name)).map((c) => c.raw));
|
|
2060
|
-
const installed = await installPlugins(pluginClients);
|
|
2061
|
-
analytics.wizardCapture("mcp plugins installed", {
|
|
2062
|
-
clients: installed,
|
|
2063
|
-
attempted: pluginClients.map((c) => c.name)
|
|
2064
|
-
});
|
|
2065
|
-
return installed;
|
|
2066
|
-
}
|
|
2067
|
-
};
|
|
2068
|
-
}
|
|
2069
|
-
//#endregion
|
|
2070
|
-
//#region src/ui/tui/screen-registry.tsx
|
|
2071
|
-
function createServices() {
|
|
2072
|
-
return { mcpInstaller: createMcpInstaller() };
|
|
2073
|
-
}
|
|
2074
|
-
function createScreens(store, services) {
|
|
2075
|
-
return {
|
|
2076
|
-
["settings-override"]: /* @__PURE__ */ jsx(SettingsOverrideScreen, { store }),
|
|
2077
|
-
["managed-settings"]: /* @__PURE__ */ jsx(ManagedSettingsScreen, { store }),
|
|
2078
|
-
["port-conflict"]: /* @__PURE__ */ jsx(PortConflictScreen, { store }),
|
|
2079
|
-
["auth-error"]: /* @__PURE__ */ jsx(AuthErrorScreen, {}),
|
|
2080
|
-
["intro"]: /* @__PURE__ */ jsx(PostHogIntegrationIntroScreen, { store }),
|
|
2081
|
-
["revenue-intro"]: /* @__PURE__ */ jsx(RevenueIntroScreen, { store }),
|
|
2082
|
-
["agent-skill-intro"]: /* @__PURE__ */ jsx(AgentSkillIntroScreen, { store }),
|
|
2083
|
-
["health-check"]: /* @__PURE__ */ jsx(HealthCheckScreen, { store }),
|
|
2084
|
-
["doctor-intro"]: /* @__PURE__ */ jsx(DoctorIntroScreen, { store }),
|
|
2085
|
-
["doctor-report"]: /* @__PURE__ */ jsx(DoctorReportScreen, { store }),
|
|
2086
|
-
["setup"]: /* @__PURE__ */ jsx(SetupScreen, { store }),
|
|
2087
|
-
["auth"]: /* @__PURE__ */ jsx(AuthScreen, { store }),
|
|
2088
|
-
["run"]: /* @__PURE__ */ jsx(RunScreen, { store }),
|
|
2089
|
-
["mcp"]: /* @__PURE__ */ jsx(McpScreen, {
|
|
2090
|
-
store,
|
|
2091
|
-
installer: services.mcpInstaller
|
|
2092
|
-
}),
|
|
2093
|
-
["keep-skills"]: /* @__PURE__ */ jsx(KeepSkillsScreen, { store }),
|
|
2094
|
-
["outro"]: /* @__PURE__ */ jsx(OutroScreen, { store }),
|
|
2095
|
-
["exit"]: /* @__PURE__ */ jsx(ExitScreen, {}),
|
|
2096
|
-
["mcp-add"]: /* @__PURE__ */ jsx(McpScreen, {
|
|
2097
|
-
store,
|
|
2098
|
-
installer: services.mcpInstaller
|
|
2099
|
-
}),
|
|
2100
|
-
["mcp-remove"]: /* @__PURE__ */ jsx(McpScreen, {
|
|
2101
|
-
store,
|
|
2102
|
-
installer: services.mcpInstaller,
|
|
2103
|
-
mode: "remove"
|
|
2104
|
-
})
|
|
2105
|
-
};
|
|
2106
|
-
}
|
|
2107
|
-
//#endregion
|
|
2108
|
-
//#region src/ui/tui/App.tsx
|
|
2109
|
-
const App = ({ store }) => {
|
|
2110
|
-
const services = useMemo(() => createServices(), []);
|
|
2111
|
-
return /* @__PURE__ */ jsx(ScreenContainer, {
|
|
2112
|
-
store,
|
|
2113
|
-
screens: useMemo(() => createScreens(store, services), [store, services])
|
|
2114
|
-
});
|
|
2115
|
-
};
|
|
2116
|
-
//#endregion
|
|
2117
|
-
//#region src/ui/tui/start-tui.ts
|
|
2118
|
-
/**
|
|
2119
|
-
* start-tui.ts — Sets up the Ink TUI renderer and InkUI.
|
|
2120
|
-
*
|
|
2121
|
-
* Renders in the terminal's alternate screen buffer so the wizard
|
|
2122
|
-
* doesn't pollute scrollback history. On exit, the previous terminal
|
|
2123
|
-
* content is restored and a single exit summary line is printed.
|
|
2124
|
-
*/
|
|
2125
|
-
const RESET_ATTRS = "\x1B[0m";
|
|
2126
|
-
const CLEAR_SCREEN = "\x1B[2J";
|
|
2127
|
-
const CURSOR_HOME = "\x1B[H";
|
|
2128
|
-
const BG_BLACK = "\x1B[48;2;0;0;0m";
|
|
2129
|
-
const ENTER_ALT_SCREEN = "\x1B[?1049h";
|
|
2130
|
-
const LEAVE_ALT_SCREEN = "\x1B[?1049l";
|
|
2131
|
-
const GREEN = "\x1B[32m";
|
|
2132
|
-
const BOLD = "\x1B[1m";
|
|
2133
|
-
const DIM = "\x1B[2m";
|
|
2134
|
-
function releaseTerminal() {
|
|
2135
|
-
process.stdout.write(RESET_ATTRS + LEAVE_ALT_SCREEN);
|
|
2136
|
-
}
|
|
2137
|
-
function getExitLine(store) {
|
|
2138
|
-
const outro = store.session.outroData;
|
|
2139
|
-
const label = store.session.workflowLabel ?? "Wizard";
|
|
2140
|
-
if (outro?.kind === "success") return `${GREEN}${BOLD}\u2714${RESET_ATTRS} ${outro.message ?? `${label} completed successfully.`}`;
|
|
2141
|
-
return `${DIM}${label} exited.${RESET_ATTRS}`;
|
|
2142
|
-
}
|
|
2143
|
-
function startTUI(version, flow = "posthog-integration") {
|
|
2144
|
-
process.stdout.write(ENTER_ALT_SCREEN + BG_BLACK + CLEAR_SCREEN + CURSOR_HOME);
|
|
2145
|
-
const store = new WizardStore(flow);
|
|
2146
|
-
store.version = version;
|
|
2147
|
-
setUI(new InkUI(store));
|
|
2148
|
-
const { unmount: inkUnmount } = render(createElement(App, { store }));
|
|
2149
|
-
let cleaned = false;
|
|
2150
|
-
const cleanup = () => {
|
|
2151
|
-
if (cleaned) return;
|
|
2152
|
-
cleaned = true;
|
|
2153
|
-
inkUnmount();
|
|
2154
|
-
releaseTerminal();
|
|
2155
|
-
process.stdout.write(getExitLine(store) + "\n");
|
|
2156
|
-
};
|
|
2157
|
-
process.on("exit", cleanup);
|
|
2158
|
-
return {
|
|
2159
|
-
unmount: cleanup,
|
|
2160
|
-
store,
|
|
2161
|
-
waitForSetup: () => store.getGate("intro")
|
|
2162
|
-
};
|
|
2163
|
-
}
|
|
2164
|
-
//#endregion
|
|
2165
|
-
export { startTUI };
|
|
2166
|
-
|
|
2167
|
-
//# sourceMappingURL=start-tui-CQef69NR.js.map
|