@posthog/wizard 2.8.0 → 2.9.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 +11 -0
- package/dist/bin.js +289 -167
- package/dist/bin.js.map +1 -1
- package/dist/src/__tests__/cli.test.js +92 -59
- package/dist/src/__tests__/cli.test.js.map +1 -1
- package/dist/src/__tests__/wizard-abort.test.js +34 -13
- package/dist/src/__tests__/wizard-abort.test.js.map +1 -1
- package/dist/src/frameworks/android/android-wizard-agent.js +2 -2
- package/dist/src/frameworks/android/android-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/angular/angular-wizard-agent.js +2 -2
- package/dist/src/frameworks/angular/angular-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/astro/astro-wizard-agent.js +2 -2
- package/dist/src/frameworks/astro/astro-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/django/django-wizard-agent.js +2 -2
- package/dist/src/frameworks/django/django-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/fastapi/fastapi-wizard-agent.js +2 -2
- package/dist/src/frameworks/fastapi/fastapi-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/flask/flask-wizard-agent.js +2 -2
- package/dist/src/frameworks/flask/flask-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.js +2 -2
- package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.js +2 -2
- package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/laravel/laravel-wizard-agent.js +2 -2
- package/dist/src/frameworks/laravel/laravel-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/nextjs/nextjs-wizard-agent.js +2 -2
- package/dist/src/frameworks/nextjs/nextjs-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/nuxt/nuxt-wizard-agent.js +2 -2
- package/dist/src/frameworks/nuxt/nuxt-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/python/python-wizard-agent.js +2 -2
- package/dist/src/frameworks/python/python-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/rails/rails-wizard-agent.js +2 -2
- package/dist/src/frameworks/rails/rails-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/react-native/react-native-wizard-agent.js +2 -2
- package/dist/src/frameworks/react-native/react-native-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/react-router/react-router-wizard-agent.js +2 -2
- package/dist/src/frameworks/react-router/react-router-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/ruby/ruby-wizard-agent.js +2 -2
- package/dist/src/frameworks/ruby/ruby-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/svelte/svelte-wizard-agent.js +2 -2
- package/dist/src/frameworks/svelte/svelte-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/swift/swift-wizard-agent.js +2 -2
- package/dist/src/frameworks/swift/swift-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/tanstack-router/tanstack-router-wizard-agent.js +2 -2
- package/dist/src/frameworks/tanstack-router/tanstack-router-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/tanstack-start/tanstack-start-wizard-agent.js +2 -2
- package/dist/src/frameworks/tanstack-start/tanstack-start-wizard-agent.js.map +1 -1
- package/dist/src/frameworks/vue/vue-wizard-agent.js +2 -2
- package/dist/src/frameworks/vue/vue-wizard-agent.js.map +1 -1
- package/dist/src/lib/__tests__/agent-interface.test.js +29 -1
- package/dist/src/lib/__tests__/agent-interface.test.js.map +1 -1
- package/dist/src/lib/agent/__tests__/agent-prompt.test.js +57 -0
- package/dist/src/lib/agent/__tests__/agent-prompt.test.js.map +1 -0
- package/dist/src/lib/{agent-interface.d.ts → agent/agent-interface.d.ts} +18 -6
- package/dist/src/lib/{agent-interface.js → agent/agent-interface.js} +63 -13
- package/dist/src/lib/agent/agent-interface.js.map +1 -0
- package/dist/src/lib/agent/agent-prompt.d.ts +23 -0
- package/dist/src/lib/agent/agent-prompt.js +47 -0
- package/dist/src/lib/agent/agent-prompt.js.map +1 -0
- package/dist/src/lib/agent/agent-runner.d.ts +78 -0
- package/dist/src/lib/agent/agent-runner.js +323 -0
- package/dist/src/lib/agent/agent-runner.js.map +1 -0
- package/dist/src/lib/agent/commandments.js.map +1 -0
- package/dist/src/lib/constants.d.ts +10 -1
- package/dist/src/lib/constants.js +13 -1
- package/dist/src/lib/constants.js.map +1 -1
- package/dist/src/lib/detection/__tests__/context.test.js +72 -0
- package/dist/src/lib/detection/__tests__/context.test.js.map +1 -0
- package/dist/src/lib/detection/__tests__/features.test.d.ts +1 -0
- package/dist/src/lib/detection/__tests__/features.test.js +75 -0
- package/dist/src/lib/detection/__tests__/features.test.js.map +1 -0
- package/dist/src/lib/detection/__tests__/package-manager.test.d.ts +1 -0
- package/dist/src/lib/{__tests__/package-manager-detection.test.js → detection/__tests__/package-manager.test.js} +25 -25
- package/dist/src/lib/detection/__tests__/package-manager.test.js.map +1 -0
- package/dist/src/lib/detection/context.d.ts +31 -0
- package/dist/src/lib/detection/context.js +92 -0
- package/dist/src/lib/detection/context.js.map +1 -0
- package/dist/src/lib/detection/features.d.ts +16 -0
- package/dist/src/lib/detection/features.js +56 -0
- package/dist/src/lib/detection/features.js.map +1 -0
- package/dist/src/lib/detection/framework.d.ts +14 -0
- package/dist/src/lib/detection/framework.js +35 -0
- package/dist/src/lib/detection/framework.js.map +1 -0
- package/dist/src/lib/detection/index.d.ts +3 -0
- package/dist/src/lib/detection/index.js +11 -0
- package/dist/src/lib/detection/index.js.map +1 -0
- package/dist/src/lib/{package-manager-detection.js → detection/package-manager.js} +3 -3
- package/dist/src/lib/detection/package-manager.js.map +1 -0
- package/dist/src/lib/framework-config.d.ts +1 -1
- package/dist/src/lib/framework-config.js.map +1 -1
- package/dist/src/lib/health-checks/endpoints.js +2 -1
- package/dist/src/lib/health-checks/endpoints.js.map +1 -1
- package/dist/src/lib/middleware/benchmark.js +1 -1
- package/dist/src/lib/middleware/benchmark.js.map +1 -1
- package/dist/src/lib/middleware/benchmarks/compaction-tracker.js +1 -1
- package/dist/src/lib/middleware/benchmarks/compaction-tracker.js.map +1 -1
- package/dist/src/lib/middleware/benchmarks/json-writer.js +1 -1
- package/dist/src/lib/middleware/benchmarks/json-writer.js.map +1 -1
- package/dist/src/lib/middleware/benchmarks/summary.js +1 -1
- package/dist/src/lib/middleware/benchmarks/summary.js.map +1 -1
- package/dist/src/lib/middleware/config.js +1 -1
- package/dist/src/lib/middleware/config.js.map +1 -1
- package/dist/src/lib/version.d.ts +1 -1
- package/dist/src/lib/version.js +1 -1
- package/dist/src/lib/version.js.map +1 -1
- package/dist/src/lib/wizard-session.d.ts +16 -7
- package/dist/src/lib/wizard-session.js +2 -0
- package/dist/src/lib/wizard-session.js.map +1 -1
- package/dist/src/lib/wizard-tools.d.ts +28 -1
- package/dist/src/lib/wizard-tools.js +24 -0
- package/dist/src/lib/wizard-tools.js.map +1 -1
- package/dist/src/lib/workflows/__tests__/agent-skill.test.d.ts +1 -0
- package/dist/src/lib/workflows/__tests__/agent-skill.test.js +66 -0
- package/dist/src/lib/workflows/__tests__/agent-skill.test.js.map +1 -0
- package/dist/src/lib/workflows/__tests__/revenue-analytics-detect.test.d.ts +1 -0
- package/dist/src/lib/workflows/__tests__/revenue-analytics-detect.test.js +101 -0
- package/dist/src/lib/workflows/__tests__/revenue-analytics-detect.test.js.map +1 -0
- package/dist/src/lib/workflows/__tests__/workflow-registry.test.d.ts +1 -0
- package/dist/src/lib/workflows/__tests__/workflow-registry.test.js +32 -0
- package/dist/src/lib/workflows/__tests__/workflow-registry.test.js.map +1 -0
- package/dist/src/lib/workflows/__tests__/workflow-step.test.d.ts +1 -0
- package/dist/src/lib/workflows/__tests__/workflow-step.test.js +54 -0
- package/dist/src/lib/workflows/__tests__/workflow-step.test.js.map +1 -0
- package/dist/src/lib/workflows/agent-skill/index.d.ts +44 -0
- package/dist/src/lib/workflows/agent-skill/index.js +47 -0
- package/dist/src/lib/workflows/agent-skill/index.js.map +1 -0
- package/dist/src/lib/workflows/agent-skill/steps.d.ts +8 -0
- package/dist/src/lib/workflows/agent-skill/steps.js +32 -0
- package/dist/src/lib/workflows/agent-skill/steps.js.map +1 -0
- package/dist/src/lib/workflows/posthog-integration/detect.d.ts +12 -0
- package/dist/src/lib/workflows/posthog-integration/detect.js +57 -0
- package/dist/src/lib/workflows/posthog-integration/detect.js.map +1 -0
- package/dist/src/lib/workflows/posthog-integration/index.d.ts +3 -0
- package/dist/src/lib/workflows/posthog-integration/index.js +152 -0
- package/dist/src/lib/workflows/posthog-integration/index.js.map +1 -0
- package/dist/src/lib/workflows/posthog-integration/steps.d.ts +9 -0
- package/dist/src/lib/workflows/posthog-integration/steps.js +100 -0
- package/dist/src/lib/workflows/posthog-integration/steps.js.map +1 -0
- package/dist/src/lib/workflows/revenue-analytics/detect.d.ts +40 -0
- package/dist/src/lib/workflows/revenue-analytics/detect.js +156 -0
- package/dist/src/lib/workflows/revenue-analytics/detect.js.map +1 -0
- package/dist/src/lib/workflows/revenue-analytics/index.d.ts +4 -0
- package/dist/src/lib/workflows/revenue-analytics/index.js +30 -0
- package/dist/src/lib/workflows/revenue-analytics/index.js.map +1 -0
- package/dist/src/lib/workflows/revenue-analytics/steps.d.ts +8 -0
- package/dist/src/lib/workflows/revenue-analytics/steps.js +48 -0
- package/dist/src/lib/workflows/revenue-analytics/steps.js.map +1 -0
- package/dist/src/lib/workflows/workflow-registry.d.ts +18 -0
- package/dist/src/lib/workflows/workflow-registry.js +32 -0
- package/dist/src/lib/workflows/workflow-registry.js.map +1 -0
- package/dist/src/lib/workflows/workflow-step.d.ts +126 -0
- package/dist/src/lib/workflows/workflow-step.js +28 -0
- package/dist/src/lib/workflows/workflow-step.js.map +1 -0
- package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +2 -1
- package/dist/src/steps/add-mcp-server-to-clients/index.js.map +1 -1
- package/dist/src/ui/logging-ui.d.ts +6 -3
- package/dist/src/ui/logging-ui.js +7 -0
- package/dist/src/ui/logging-ui.js.map +1 -1
- package/dist/src/ui/tui/__tests__/flows.test.d.ts +1 -0
- package/dist/src/ui/tui/__tests__/flows.test.js +115 -0
- package/dist/src/ui/tui/__tests__/flows.test.js.map +1 -0
- package/dist/src/ui/tui/__tests__/router.test.d.ts +1 -0
- package/dist/src/ui/tui/__tests__/router.test.js +87 -0
- package/dist/src/ui/tui/__tests__/router.test.js.map +1 -0
- package/dist/src/ui/tui/__tests__/store.test.js +100 -10
- package/dist/src/ui/tui/__tests__/store.test.js.map +1 -1
- package/dist/src/ui/tui/flows.d.ts +17 -6
- package/dist/src/ui/tui/flows.js +28 -52
- package/dist/src/ui/tui/flows.js.map +1 -1
- package/dist/src/ui/tui/ink-ui.d.ts +6 -3
- package/dist/src/ui/tui/ink-ui.js +7 -0
- package/dist/src/ui/tui/ink-ui.js.map +1 -1
- package/dist/src/ui/tui/primitives/ProgressList.d.ts +3 -1
- package/dist/src/ui/tui/primitives/ProgressList.js +2 -2
- package/dist/src/ui/tui/primitives/ProgressList.js.map +1 -1
- package/dist/src/ui/tui/router.js +1 -1
- package/dist/src/ui/tui/router.js.map +1 -1
- package/dist/src/ui/tui/screen-registry.js +2 -0
- package/dist/src/ui/tui/screen-registry.js.map +1 -1
- package/dist/src/ui/tui/screens/ManagedSettingsScreen.js.map +1 -1
- package/dist/src/ui/tui/screens/OutroScreen.js +1 -1
- package/dist/src/ui/tui/screens/OutroScreen.js.map +1 -1
- package/dist/src/ui/tui/screens/RevenueIntroScreen.d.ts +16 -0
- package/dist/src/ui/tui/screens/RevenueIntroScreen.js +64 -0
- package/dist/src/ui/tui/screens/RevenueIntroScreen.js.map +1 -0
- package/dist/src/ui/tui/screens/RunScreen.js +1 -1
- package/dist/src/ui/tui/screens/RunScreen.js.map +1 -1
- package/dist/src/ui/tui/screens/SettingsOverrideScreen.js.map +1 -1
- package/dist/src/ui/tui/screens/health/HealthCheckScreen.js +2 -2
- package/dist/src/ui/tui/screens/health/HealthCheckScreen.js.map +1 -1
- package/dist/src/ui/tui/start-tui.js +2 -2
- package/dist/src/ui/tui/start-tui.js.map +1 -1
- package/dist/src/ui/tui/store.d.ts +46 -21
- package/dist/src/ui/tui/store.js +105 -47
- package/dist/src/ui/tui/store.js.map +1 -1
- package/dist/src/ui/wizard-ui.d.ts +13 -3
- package/dist/src/ui/wizard-ui.js.map +1 -1
- package/dist/src/utils/file-utils.d.ts +8 -0
- package/dist/src/utils/file-utils.js +32 -0
- package/dist/src/utils/file-utils.js.map +1 -1
- package/dist/src/utils/wizard-abort.d.ts +3 -0
- package/dist/src/utils/wizard-abort.js +5 -3
- package/dist/src/utils/wizard-abort.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/src/__tests__/run.test.js +0 -95
- package/dist/src/__tests__/run.test.js.map +0 -1
- package/dist/src/lib/__tests__/package-manager-detection.test.js.map +0 -1
- package/dist/src/lib/agent-interface.js.map +0 -1
- package/dist/src/lib/agent-runner.d.ts +0 -9
- package/dist/src/lib/agent-runner.js +0 -385
- package/dist/src/lib/agent-runner.js.map +0 -1
- package/dist/src/lib/commandments.js.map +0 -1
- package/dist/src/lib/package-manager-detection.js.map +0 -1
- package/dist/src/run.d.ts +0 -23
- package/dist/src/run.js +0 -154
- package/dist/src/run.js.map +0 -1
- /package/dist/src/{__tests__/run.test.d.ts → lib/agent/__tests__/agent-prompt.test.d.ts} +0 -0
- /package/dist/src/lib/{commandments.d.ts → agent/commandments.d.ts} +0 -0
- /package/dist/src/lib/{commandments.js → agent/commandments.js} +0 -0
- /package/dist/src/lib/{__tests__/package-manager-detection.test.d.ts → detection/__tests__/context.test.d.ts} +0 -0
- /package/dist/src/lib/{package-manager-detection.d.ts → detection/package-manager.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -33,6 +33,17 @@ npx @posthog/wizard mcp add
|
|
|
33
33
|
npx @posthog/wizard mcp remove
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
## Revenue Analytics
|
|
37
|
+
|
|
38
|
+
Wire up an existing PostHog + Stripe project for revenue analytics:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx @posthog/wizard revenue
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Requires PostHog and Stripe SDKs already installed. Supports `--ci` with the
|
|
45
|
+
same flags as the main wizard.
|
|
46
|
+
|
|
36
47
|
# Options
|
|
37
48
|
|
|
38
49
|
The following CLI arguments are available:
|
package/dist/bin.js
CHANGED
|
@@ -17,10 +17,10 @@ if (!(0, semver_1.satisfies)(process.version, NODE_VERSION_RANGE)) {
|
|
|
17
17
|
(0, logging_1.red)(`PostHog wizard requires Node.js ${NODE_VERSION_RANGE}. You are using Node.js ${process.version}. Please upgrade your Node.js version.`);
|
|
18
18
|
process.exit(1);
|
|
19
19
|
}
|
|
20
|
-
const run_1 = require("./src/run");
|
|
21
20
|
const environment_1 = require("./src/utils/environment");
|
|
22
21
|
const ui_1 = require("./src/ui");
|
|
23
22
|
const logging_ui_1 = require("./src/ui/logging-ui");
|
|
23
|
+
const workflow_registry_1 = require("./src/lib/workflows/workflow-registry");
|
|
24
24
|
if (process.env.NODE_ENV === 'test') {
|
|
25
25
|
void (async () => {
|
|
26
26
|
try {
|
|
@@ -34,7 +34,35 @@ if (process.env.NODE_ENV === 'test') {
|
|
|
34
34
|
}
|
|
35
35
|
})();
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
/** Shared yargs options for skill-based workflow subcommands. */
|
|
38
|
+
const skillSubcommandOptions = {
|
|
39
|
+
debug: {
|
|
40
|
+
default: false,
|
|
41
|
+
describe: 'Enable verbose logging',
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
},
|
|
44
|
+
'install-dir': {
|
|
45
|
+
describe: 'Directory to install in',
|
|
46
|
+
type: 'string',
|
|
47
|
+
},
|
|
48
|
+
'local-mcp': {
|
|
49
|
+
default: false,
|
|
50
|
+
describe: 'Use local MCP server',
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
},
|
|
53
|
+
benchmark: {
|
|
54
|
+
default: false,
|
|
55
|
+
describe: 'Run in benchmark mode',
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
},
|
|
58
|
+
'yara-report': {
|
|
59
|
+
default: false,
|
|
60
|
+
describe: 'Print YARA scanner summary',
|
|
61
|
+
type: 'boolean',
|
|
62
|
+
hidden: true,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
const cli = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
38
66
|
.env('POSTHOG_WIZARD')
|
|
39
67
|
// global options
|
|
40
68
|
.options({
|
|
@@ -76,10 +104,6 @@ if (process.env.NODE_ENV === 'test') {
|
|
|
76
104
|
describe: 'PostHog project ID to use (optional; when not set, uses default from API key or OAuth)\nenv: POSTHOG_WIZARD_PROJECT_ID',
|
|
77
105
|
type: 'string',
|
|
78
106
|
},
|
|
79
|
-
email: {
|
|
80
|
-
describe: 'Email address for account creation (used with --signup)\nenv: POSTHOG_WIZARD_EMAIL',
|
|
81
|
-
type: 'string',
|
|
82
|
-
},
|
|
83
107
|
})
|
|
84
108
|
.command(['$0'], 'Run the PostHog setup wizard', (yargs) => {
|
|
85
109
|
return yargs.options({
|
|
@@ -126,28 +150,71 @@ if (process.env.NODE_ENV === 'test') {
|
|
|
126
150
|
type: 'boolean',
|
|
127
151
|
hidden: true,
|
|
128
152
|
},
|
|
153
|
+
skill: {
|
|
154
|
+
describe: 'Run a specific context-mill skill by ID\nenv: POSTHOG_WIZARD_SKILL',
|
|
155
|
+
type: 'string',
|
|
156
|
+
},
|
|
129
157
|
});
|
|
130
158
|
}, (argv) => {
|
|
131
159
|
const options = { ...argv };
|
|
132
160
|
// CI mode validation and TTY check
|
|
133
161
|
if (options.ci) {
|
|
134
|
-
|
|
135
|
-
(0, ui_1.setUI)(new logging_ui_1.LoggingUI());
|
|
136
|
-
// Default region to 'us' if not specified
|
|
137
|
-
if (!options.region) {
|
|
162
|
+
if (!options.region)
|
|
138
163
|
options.region = 'us';
|
|
139
|
-
}
|
|
140
164
|
if (!options.apiKey) {
|
|
141
|
-
(0, ui_1.
|
|
165
|
+
(0, ui_1.setUI)(new logging_ui_1.LoggingUI());
|
|
166
|
+
(0, ui_1.getUI)().intro('PostHog Wizard');
|
|
142
167
|
(0, ui_1.getUI)().log.error('CI mode requires --api-key (personal API key phx_xxx)');
|
|
143
168
|
process.exit(1);
|
|
169
|
+
return;
|
|
144
170
|
}
|
|
145
171
|
if (!options.installDir) {
|
|
146
|
-
(0, ui_1.
|
|
147
|
-
(0, ui_1.getUI)().
|
|
172
|
+
(0, ui_1.setUI)(new logging_ui_1.LoggingUI());
|
|
173
|
+
(0, ui_1.getUI)().intro('PostHog Wizard');
|
|
174
|
+
(0, ui_1.getUI)().log.error('CI mode requires --install-dir (directory to install in)');
|
|
148
175
|
process.exit(1);
|
|
176
|
+
return;
|
|
149
177
|
}
|
|
150
|
-
void (
|
|
178
|
+
void (async () => {
|
|
179
|
+
const { posthogIntegrationConfig } = await import('./src/lib/workflows/posthog-integration/index.js');
|
|
180
|
+
const { FRAMEWORK_REGISTRY } = await import('./src/lib/registry.js');
|
|
181
|
+
const { detectFramework, gatherFrameworkContext } = await import('./src/lib/detection/index.js');
|
|
182
|
+
const { analytics } = await import('./src/utils/analytics.js');
|
|
183
|
+
const { wizardAbort } = await import('./src/utils/wizard-abort.js');
|
|
184
|
+
// preRun: honor --integration, else auto-detect, then gather
|
|
185
|
+
// framework context. Bypasses onReady hooks by design.
|
|
186
|
+
runWizardCI(posthogIntegrationConfig, options, async (session) => {
|
|
187
|
+
const integration = session.integration ??
|
|
188
|
+
(await detectFramework(session.installDir));
|
|
189
|
+
if (!integration) {
|
|
190
|
+
await wizardAbort({
|
|
191
|
+
message: 'Could not auto-detect your framework. Please specify --integration on the command line.',
|
|
192
|
+
});
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
session.integration = integration;
|
|
196
|
+
analytics.setTag('integration', integration);
|
|
197
|
+
const frameworkConfig = FRAMEWORK_REGISTRY[integration];
|
|
198
|
+
session.frameworkConfig = frameworkConfig;
|
|
199
|
+
const context = await gatherFrameworkContext(frameworkConfig, {
|
|
200
|
+
installDir: session.installDir,
|
|
201
|
+
debug: session.debug,
|
|
202
|
+
forceInstall: session.forceInstall,
|
|
203
|
+
default: false,
|
|
204
|
+
signup: session.signup,
|
|
205
|
+
localMcp: session.localMcp,
|
|
206
|
+
ci: true,
|
|
207
|
+
menu: session.menu,
|
|
208
|
+
benchmark: session.benchmark,
|
|
209
|
+
yaraReport: session.yaraReport,
|
|
210
|
+
});
|
|
211
|
+
for (const [key, value] of Object.entries(context)) {
|
|
212
|
+
if (!(key in session.frameworkContext)) {
|
|
213
|
+
session.frameworkContext[key] = value;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
})();
|
|
151
218
|
}
|
|
152
219
|
else if ((0, environment_1.isNonInteractiveEnvironment)()) {
|
|
153
220
|
// Non-interactive non-CI: error out
|
|
@@ -166,159 +233,32 @@ if (process.env.NODE_ENV === 'test') {
|
|
|
166
233
|
startPlayground(WIZARD_VERSION);
|
|
167
234
|
})();
|
|
168
235
|
}
|
|
236
|
+
else if (options.skill) {
|
|
237
|
+
// Run a specific skill by ID
|
|
238
|
+
void (async () => {
|
|
239
|
+
const { createSkillWorkflow } = await import('./src/lib/workflows/agent-skill/index.js');
|
|
240
|
+
const skillId = options.skill;
|
|
241
|
+
const config = createSkillWorkflow({
|
|
242
|
+
skillId,
|
|
243
|
+
command: 'skill',
|
|
244
|
+
flowKey: 'agent-skill',
|
|
245
|
+
description: `Run skill: ${skillId}`,
|
|
246
|
+
integrationLabel: skillId,
|
|
247
|
+
successMessage: `${skillId} completed!`,
|
|
248
|
+
reportFile: `posthog-${skillId}-report.md`,
|
|
249
|
+
docsUrl: 'https://posthog.com/docs',
|
|
250
|
+
spinnerMessage: `Running ${skillId}...`,
|
|
251
|
+
estimatedDurationMinutes: 5,
|
|
252
|
+
});
|
|
253
|
+
runWizard(config, options);
|
|
254
|
+
})();
|
|
255
|
+
}
|
|
169
256
|
else {
|
|
170
|
-
// Interactive TTY:
|
|
257
|
+
// Interactive TTY: run core-integration through the unified workflow path.
|
|
258
|
+
// Same codepath as `npx @posthog/wizard integrate`.
|
|
171
259
|
void (async () => {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const { buildSession } = await import('./src/lib/wizard-session.js');
|
|
175
|
-
const tui = startTUI(WIZARD_VERSION);
|
|
176
|
-
// Build session from CLI args and attach to store
|
|
177
|
-
const session = buildSession({
|
|
178
|
-
debug: options.debug,
|
|
179
|
-
forceInstall: options.forceInstall,
|
|
180
|
-
installDir: options.installDir,
|
|
181
|
-
ci: false,
|
|
182
|
-
signup: options.signup,
|
|
183
|
-
localMcp: options.localMcp,
|
|
184
|
-
apiKey: options.apiKey,
|
|
185
|
-
email: options.email,
|
|
186
|
-
menu: options.menu,
|
|
187
|
-
integration: options.integration,
|
|
188
|
-
benchmark: options.benchmark,
|
|
189
|
-
yaraReport: options.yaraReport,
|
|
190
|
-
projectId: options.projectId,
|
|
191
|
-
});
|
|
192
|
-
tui.store.session = session;
|
|
193
|
-
// Detect framework while IntroScreen shows its spinner.
|
|
194
|
-
// Runs concurrently — IntroScreen reacts when detection completes.
|
|
195
|
-
const { FRAMEWORK_REGISTRY } = (await import('./src/lib/registry.js'));
|
|
196
|
-
const { detectIntegration } = (await import('./src/run.js'));
|
|
197
|
-
const installDir = session.installDir ?? process.cwd();
|
|
198
|
-
const { DETECTION_TIMEOUT_MS } = (await import('./src/lib/constants.js'));
|
|
199
|
-
const detectedIntegration = await Promise.race([
|
|
200
|
-
detectIntegration(installDir),
|
|
201
|
-
new Promise((resolve) => setTimeout(() => resolve(undefined), DETECTION_TIMEOUT_MS)),
|
|
202
|
-
]);
|
|
203
|
-
if (detectedIntegration) {
|
|
204
|
-
const config = FRAMEWORK_REGISTRY[detectedIntegration];
|
|
205
|
-
// Run gatherContext for the friendly variant label
|
|
206
|
-
if (config.metadata.gatherContext) {
|
|
207
|
-
try {
|
|
208
|
-
const context = await Promise.race([
|
|
209
|
-
config.metadata.gatherContext({
|
|
210
|
-
installDir,
|
|
211
|
-
debug: session.debug,
|
|
212
|
-
forceInstall: session.forceInstall,
|
|
213
|
-
default: false,
|
|
214
|
-
signup: session.signup,
|
|
215
|
-
localMcp: session.localMcp,
|
|
216
|
-
ci: session.ci,
|
|
217
|
-
menu: session.menu,
|
|
218
|
-
benchmark: session.benchmark,
|
|
219
|
-
yaraReport: session.yaraReport,
|
|
220
|
-
}),
|
|
221
|
-
new Promise((resolve) => setTimeout(() => resolve({}), DETECTION_TIMEOUT_MS)),
|
|
222
|
-
]);
|
|
223
|
-
for (const [key, value] of Object.entries(context)) {
|
|
224
|
-
if (!(key in session.frameworkContext)) {
|
|
225
|
-
tui.store.setFrameworkContext(key, value);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
catch {
|
|
230
|
-
// Detection failed — will show generic name
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
tui.store.setFrameworkConfig(detectedIntegration, config);
|
|
234
|
-
if (!session.detectedFrameworkLabel) {
|
|
235
|
-
tui.store.setDetectedFramework(config.metadata.name);
|
|
236
|
-
}
|
|
237
|
-
// Early version check — surface on IntroScreen before user proceeds
|
|
238
|
-
if (config.detection.minimumVersion &&
|
|
239
|
-
config.detection.getInstalledVersion) {
|
|
240
|
-
const semver = await import('semver');
|
|
241
|
-
const version = await config.detection.getInstalledVersion({
|
|
242
|
-
installDir,
|
|
243
|
-
debug: session.debug,
|
|
244
|
-
forceInstall: session.forceInstall,
|
|
245
|
-
default: false,
|
|
246
|
-
signup: session.signup,
|
|
247
|
-
localMcp: session.localMcp,
|
|
248
|
-
ci: session.ci,
|
|
249
|
-
menu: session.menu,
|
|
250
|
-
benchmark: session.benchmark,
|
|
251
|
-
yaraReport: session.yaraReport,
|
|
252
|
-
});
|
|
253
|
-
if (version) {
|
|
254
|
-
const coerced = semver.coerce(version);
|
|
255
|
-
if (coerced &&
|
|
256
|
-
semver.lt(coerced, config.detection.minimumVersion)) {
|
|
257
|
-
tui.store.setUnsupportedVersion({
|
|
258
|
-
current: version,
|
|
259
|
-
minimum: config.detection.minimumVersion,
|
|
260
|
-
docsUrl: config.metadata.unsupportedVersionDocsUrl ??
|
|
261
|
-
config.metadata.docsUrl,
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
// Feature discovery — deterministic scan of package.json deps
|
|
268
|
-
try {
|
|
269
|
-
const { readFileSync } = await import('fs');
|
|
270
|
-
const pkgPath = require('path').join(installDir, 'package.json');
|
|
271
|
-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
272
|
-
const allDeps = {
|
|
273
|
-
...pkg.dependencies,
|
|
274
|
-
...pkg.devDependencies,
|
|
275
|
-
};
|
|
276
|
-
const depNames = Object.keys(allDeps);
|
|
277
|
-
const { DiscoveredFeature } = await import('./src/lib/wizard-session.js');
|
|
278
|
-
if (depNames.some((d) => ['stripe', '@stripe/stripe-js'].includes(d))) {
|
|
279
|
-
tui.store.addDiscoveredFeature(DiscoveredFeature.Stripe);
|
|
280
|
-
}
|
|
281
|
-
// LLM SDK detection — sourced from PostHog LLM analytics skill
|
|
282
|
-
const LLM_PACKAGES = [
|
|
283
|
-
'openai',
|
|
284
|
-
'@anthropic-ai/sdk',
|
|
285
|
-
'ai',
|
|
286
|
-
'@ai-sdk/openai',
|
|
287
|
-
'langchain',
|
|
288
|
-
'@langchain/openai',
|
|
289
|
-
'@langchain/langgraph',
|
|
290
|
-
'@google/generative-ai',
|
|
291
|
-
'@google/genai',
|
|
292
|
-
'@instructor-ai/instructor',
|
|
293
|
-
'@mastra/core',
|
|
294
|
-
'portkey-ai',
|
|
295
|
-
];
|
|
296
|
-
if (depNames.some((d) => LLM_PACKAGES.includes(d))) {
|
|
297
|
-
tui.store.addDiscoveredFeature(DiscoveredFeature.LLM);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
catch {
|
|
301
|
-
// No package.json or parse error — skip feature discovery
|
|
302
|
-
}
|
|
303
|
-
// Signal detection is done — IntroScreen shows picker or results
|
|
304
|
-
tui.store.setDetectionComplete();
|
|
305
|
-
// Wait for IntroScreen confirmation
|
|
306
|
-
await tui.waitForSetup();
|
|
307
|
-
// Ensure health check has completed before starting the wizard.
|
|
308
|
-
// The flow gate on Intro (readinessResult !== null) keeps the
|
|
309
|
-
// TUI on IntroScreen until this resolves. If blocking, the
|
|
310
|
-
// outage overlay was already pushed in the .then() callback.
|
|
311
|
-
await tui.store.healthGateComplete;
|
|
312
|
-
await (0, run_1.runWizard)(options, tui.store.session);
|
|
313
|
-
// Keep the outro screen visible — let process.exit() handle cleanup
|
|
314
|
-
}
|
|
315
|
-
catch (err) {
|
|
316
|
-
// TUI unavailable (e.g., in test environment) — continue with default UI
|
|
317
|
-
if (process.env.DEBUG || process.env.POSTHOG_WIZARD_DEBUG) {
|
|
318
|
-
console.error('TUI init failed:', err); // eslint-disable-line no-console
|
|
319
|
-
}
|
|
320
|
-
await (0, run_1.runWizard)(options);
|
|
321
|
-
}
|
|
260
|
+
const { posthogIntegrationConfig } = await import('./src/lib/workflows/posthog-integration/index.js');
|
|
261
|
+
runWizard(posthogIntegrationConfig, options);
|
|
322
262
|
})();
|
|
323
263
|
}
|
|
324
264
|
})
|
|
@@ -408,10 +348,192 @@ if (process.env.NODE_ENV === 'test') {
|
|
|
408
348
|
})
|
|
409
349
|
.demandCommand(1, 'You must specify a subcommand (add or remove)')
|
|
410
350
|
.help();
|
|
411
|
-
})
|
|
351
|
+
});
|
|
352
|
+
// ── Skill-based workflow subcommands (derived from registry) ─────────
|
|
353
|
+
for (const wfConfig of (0, workflow_registry_1.getSubcommandWorkflows)()) {
|
|
354
|
+
cli.command(wfConfig.command, wfConfig.description, (y) => y.options(skillSubcommandOptions), (argv) => {
|
|
355
|
+
const options = { ...argv };
|
|
356
|
+
if (options.ci) {
|
|
357
|
+
runWizardCI(wfConfig, options);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
runWizard(wfConfig, options);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
cli
|
|
412
365
|
.help()
|
|
413
366
|
.alias('help', 'h')
|
|
414
367
|
.version()
|
|
415
368
|
.alias('version', 'v')
|
|
416
369
|
.wrap(process.stdout.isTTY ? yargs_1.default.terminalWidth() : 80).argv;
|
|
370
|
+
/**
|
|
371
|
+
* Run a full wizard workflow in the TUI. Handles the full lifecycle: start TUI,
|
|
372
|
+
* build session, run detection, wait for intro gate, execute the
|
|
373
|
+
* agent pipeline, wait for outro dismissal, then exit.
|
|
374
|
+
*/
|
|
375
|
+
function runWizard(config, options) {
|
|
376
|
+
void (async () => {
|
|
377
|
+
try {
|
|
378
|
+
const installDir = options.installDir || process.cwd();
|
|
379
|
+
const { startTUI } = await import('./src/ui/tui/start-tui.js');
|
|
380
|
+
const { buildSession } = await import('./src/lib/wizard-session.js');
|
|
381
|
+
// flowKey values match Flow enum values by convention
|
|
382
|
+
const tui = startTUI(WIZARD_VERSION, config.flowKey);
|
|
383
|
+
const session = buildSession({
|
|
384
|
+
debug: options.debug,
|
|
385
|
+
forceInstall: options.forceInstall,
|
|
386
|
+
localMcp: options.localMcp,
|
|
387
|
+
installDir,
|
|
388
|
+
ci: false,
|
|
389
|
+
signup: options.signup,
|
|
390
|
+
apiKey: options.apiKey,
|
|
391
|
+
projectId: options.projectId,
|
|
392
|
+
menu: options.menu,
|
|
393
|
+
integration: options.integration,
|
|
394
|
+
benchmark: options.benchmark,
|
|
395
|
+
yaraReport: options.yaraReport,
|
|
396
|
+
});
|
|
397
|
+
// Set workflow metadata for TUI display
|
|
398
|
+
session.workflowLabel = config.flowKey;
|
|
399
|
+
const runDef = typeof config.run === 'object' ? config.run : null;
|
|
400
|
+
session.skillId = runDef?.skillId ?? null;
|
|
401
|
+
tui.store.session = session;
|
|
402
|
+
await tui.store.runReadyHooks();
|
|
403
|
+
await tui.store.getGate('intro');
|
|
404
|
+
const { runAgent } = await import('./src/lib/agent/agent-runner.js');
|
|
405
|
+
await runAgent(config, tui.store.session);
|
|
406
|
+
tui.store.onEnterScreen('outro', () => {
|
|
407
|
+
// Screen is already outro — listen for dismissal
|
|
408
|
+
});
|
|
409
|
+
await new Promise((resolve) => {
|
|
410
|
+
const unsub = tui.store.subscribe(() => {
|
|
411
|
+
if (tui.store.session.outroDismissed) {
|
|
412
|
+
unsub();
|
|
413
|
+
resolve();
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
if (tui.store.session.outroDismissed) {
|
|
417
|
+
unsub();
|
|
418
|
+
resolve();
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
process.exit(0);
|
|
422
|
+
}
|
|
423
|
+
catch (err) {
|
|
424
|
+
if (process.env.DEBUG || process.env.POSTHOG_WIZARD_DEBUG) {
|
|
425
|
+
console.error('TUI init failed:', err); // eslint-disable-line no-console
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
})();
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* CI-mode pipeline shared by every non-interactive entry point.
|
|
432
|
+
*
|
|
433
|
+
* Validates flags, builds a `ci:true` session, runs `preRun` (or the
|
|
434
|
+
* workflow's `onReady` hooks by default), executes `runAgent`, and
|
|
435
|
+
* routes any failure through `wizardAbort`. `wizardAbort` owns all
|
|
436
|
+
* exits — never add a raw `process.exit` here.
|
|
437
|
+
*/
|
|
438
|
+
function runWizardCI(config, options, preRun) {
|
|
439
|
+
(0, ui_1.setUI)(new logging_ui_1.LoggingUI());
|
|
440
|
+
if (!options.region)
|
|
441
|
+
options.region = 'us';
|
|
442
|
+
if (!options.apiKey) {
|
|
443
|
+
(0, ui_1.getUI)().intro('PostHog Wizard');
|
|
444
|
+
(0, ui_1.getUI)().log.error('CI mode requires --api-key (personal API key phx_xxx)');
|
|
445
|
+
process.exit(1);
|
|
446
|
+
}
|
|
447
|
+
if (!options.installDir) {
|
|
448
|
+
(0, ui_1.getUI)().intro('PostHog Wizard');
|
|
449
|
+
(0, ui_1.getUI)().log.error('CI mode requires --install-dir (directory to install in)');
|
|
450
|
+
process.exit(1);
|
|
451
|
+
}
|
|
452
|
+
void (async () => {
|
|
453
|
+
const path = await import('path');
|
|
454
|
+
const { buildSession } = await import('./src/lib/wizard-session.js');
|
|
455
|
+
const { readEnvironment } = await import('./src/utils/environment.js');
|
|
456
|
+
const { readApiKeyFromEnv } = await import('./src/utils/env-api-key.js');
|
|
457
|
+
const { configureLogFileFromEnvironment, logToFile } = await import('./src/utils/debug.js');
|
|
458
|
+
const { wizardAbort, WizardError } = await import('./src/utils/wizard-abort.js');
|
|
459
|
+
configureLogFileFromEnvironment();
|
|
460
|
+
const env = readEnvironment();
|
|
461
|
+
const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? undefined;
|
|
462
|
+
const installDir = path.isAbsolute(options.installDir)
|
|
463
|
+
? options.installDir
|
|
464
|
+
: path.join(process.cwd(), options.installDir);
|
|
465
|
+
const session = buildSession({
|
|
466
|
+
debug: options.debug,
|
|
467
|
+
forceInstall: options.forceInstall,
|
|
468
|
+
installDir,
|
|
469
|
+
ci: true,
|
|
470
|
+
signup: options.signup,
|
|
471
|
+
localMcp: options.localMcp,
|
|
472
|
+
apiKey,
|
|
473
|
+
menu: options.menu,
|
|
474
|
+
integration: options.integration, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
475
|
+
projectId: options.projectId,
|
|
476
|
+
benchmark: options.benchmark,
|
|
477
|
+
yaraReport: options.yaraReport,
|
|
478
|
+
...env,
|
|
479
|
+
});
|
|
480
|
+
session.workflowLabel = config.flowKey;
|
|
481
|
+
const runDef = typeof config.run === 'object' ? config.run : null;
|
|
482
|
+
session.skillId = runDef?.skillId ?? null;
|
|
483
|
+
(0, ui_1.getUI)().intro('Welcome to the PostHog setup wizard');
|
|
484
|
+
(0, ui_1.getUI)().log.info(`Running ${config.flowKey} in CI mode`);
|
|
485
|
+
try {
|
|
486
|
+
if (preRun) {
|
|
487
|
+
await preRun(session);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
// Run onReady hooks against a minimal store-less context.
|
|
491
|
+
const readyCtx = {
|
|
492
|
+
session,
|
|
493
|
+
setFrameworkContext: (key, value) => {
|
|
494
|
+
session.frameworkContext[key] = value;
|
|
495
|
+
},
|
|
496
|
+
setFrameworkConfig: () => undefined,
|
|
497
|
+
setDetectedFramework: () => undefined,
|
|
498
|
+
setUnsupportedVersion: () => undefined,
|
|
499
|
+
addDiscoveredFeature: () => undefined,
|
|
500
|
+
setDetectionComplete: () => undefined,
|
|
501
|
+
};
|
|
502
|
+
for (const step of config.steps) {
|
|
503
|
+
if (step.onReady) {
|
|
504
|
+
await step.onReady(readyCtx);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
// Surface detectError written by the workflow's detect hook.
|
|
508
|
+
const detectError = session.frameworkContext.detectError;
|
|
509
|
+
if (detectError) {
|
|
510
|
+
await wizardAbort({
|
|
511
|
+
message: `Prerequisites not met: ${detectError.kind}\n\nSee ${runDef?.docsUrl ?? 'https://posthog.com/docs'}`,
|
|
512
|
+
error: new WizardError(`${config.flowKey} prerequisites failed`, {
|
|
513
|
+
integration: config.flowKey,
|
|
514
|
+
detect_error_kind: detectError.kind,
|
|
515
|
+
}),
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const { runAgent } = await import('./src/lib/agent/agent-runner.js');
|
|
520
|
+
await runAgent(config, session);
|
|
521
|
+
}
|
|
522
|
+
catch (error) {
|
|
523
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
524
|
+
const errorStack = error instanceof Error && error.stack ? error.stack : undefined;
|
|
525
|
+
logToFile(`[bin.ts CI] ERROR: ${errorMessage}`);
|
|
526
|
+
if (errorStack)
|
|
527
|
+
logToFile(`[bin.ts CI] STACK: ${errorStack}`);
|
|
528
|
+
const debugInfo = session.debug && errorStack ? `\n\n${errorStack}` : '';
|
|
529
|
+
const docsUrl = session.frameworkConfig?.metadata.docsUrl ??
|
|
530
|
+
runDef?.docsUrl ??
|
|
531
|
+
'https://posthog.com/docs';
|
|
532
|
+
await wizardAbort({
|
|
533
|
+
message: `Something went wrong: ${errorMessage}\n\nYou can read the documentation at ${docsUrl} to set up manually.${debugInfo}`,
|
|
534
|
+
error: error,
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
})();
|
|
538
|
+
}
|
|
417
539
|
//# sourceMappingURL=bin.js.map
|