@posthog/wizard 2.78.0 → 2.79.1
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 +20 -11
- package/dist/PickerMenu-dG5DQCZA.js +758 -0
- package/dist/PickerMenu-dG5DQCZA.js.map +1 -0
- package/dist/{add-mcp-server-to-clients-JMv8LP-O.js → add-mcp-server-to-clients-DIaTRWMY.js} +7 -18
- package/dist/{add-mcp-server-to-clients-JMv8LP-O.js.map → add-mcp-server-to-clients-DIaTRWMY.js.map} +1 -1
- package/dist/add-mcp-server-to-clients-artmN7mz.js +2 -0
- package/dist/agent-BEjARD2a.js +6 -0
- package/dist/{agent-bCZ3i3fh.js → agent-BWFhuLgo.js} +131 -38
- package/dist/agent-BWFhuLgo.js.map +1 -0
- package/dist/{agent-interface-BAOIHuXS.js → agent-interface-FkbaBJwz.js} +66 -28
- package/dist/agent-interface-FkbaBJwz.js.map +1 -0
- package/dist/{agent-prompt-loader-7Pd4CfZO.js → agent-prompt-loader-D0weQ-7k.js} +5 -5
- package/dist/{agent-prompt-loader-7Pd4CfZO.js.map → agent-prompt-loader-D0weQ-7k.js.map} +1 -1
- package/dist/analytics-DFtbRjYh.js +2 -0
- package/dist/{analytics-CHCZ_qUR.js → analytics-DXK1gc12.js} +4 -4
- package/dist/{analytics-CHCZ_qUR.js.map → analytics-DXK1gc12.js.map} +1 -1
- package/dist/api-Cm9UtKZh.js +2 -0
- package/dist/{api-Diy_2fp8.js → api-CrbCIQOz.js} +4 -16
- package/dist/{api-Diy_2fp8.js.map → api-CrbCIQOz.js.map} +1 -1
- package/dist/bin.js +5 -2957
- package/dist/bin.js.map +1 -1
- package/dist/{bounded-fs-Bx9zTe6m.js → bounded-fs-vAq-T-K7.js} +3 -3
- package/dist/{bounded-fs-Bx9zTe6m.js.map → bounded-fs-vAq-T-K7.js.map} +1 -1
- package/dist/{ci-install-CDdQYsPe.js → ci-install-COcV8SY2.js} +8 -7
- package/dist/ci-install-COcV8SY2.js.map +1 -0
- package/dist/{constants-jFI2SaE1.js → constants-DHCBSfnx.js} +3 -3
- package/dist/{constants-jFI2SaE1.js.map → constants-DHCBSfnx.js.map} +1 -1
- package/dist/{debug-M2gV2iDq.js → debug-BuYHGr6_.js} +1 -1
- package/dist/{debug-Ch4BDOtD.js → debug-kAHwWGg7.js} +2 -2
- package/dist/{debug-Ch4BDOtD.js.map → debug-kAHwWGg7.js.map} +1 -1
- package/dist/{defaults-C6J7yL4O.js → defaults-a9TelDhJ.js} +1 -1
- package/dist/{defaults-C6J7yL4O.js.map → defaults-a9TelDhJ.js.map} +1 -1
- package/dist/emit-BSetXzDV.js +69 -0
- package/dist/emit-BSetXzDV.js.map +1 -0
- package/dist/{endpoints-DCVbM06L.js → endpoints-BVMYm9F4.js} +3 -3
- package/dist/{endpoints-DCVbM06L.js.map → endpoints-BVMYm9F4.js.map} +1 -1
- package/dist/{env-api-key-Qx8NnYHm.js → env-api-key-BP-NFFXt.js} +3 -5
- package/dist/{env-api-key-Qx8NnYHm.js.map → env-api-key-BP-NFFXt.js.map} +1 -1
- package/dist/env-api-key-CaWEDj_9.js +2 -0
- package/dist/{environment-B07Bmxae.js → environment-BATlQxcQ.js} +5 -10
- package/dist/{environment-B07Bmxae.js.map → environment-BATlQxcQ.js.map} +1 -1
- package/dist/environment-CwD8OPYj.js +2 -0
- package/dist/errors-C2domSkK.js +79 -0
- package/dist/errors-C2domSkK.js.map +1 -0
- package/dist/file-C5JMsyR1.js +2 -0
- package/dist/{file-BcLTjU16.js → file-DcRKycV8.js} +4 -4
- package/dist/file-DcRKycV8.js.map +1 -0
- package/dist/{file-watcher-DWc_bTs6.js → file-watcher-Brq2nnHV.js} +2 -2
- package/dist/{file-watcher-DWc_bTs6.js.map → file-watcher-Brq2nnHV.js.map} +1 -1
- package/dist/{gateway-CjoShdLa.js → gateway-C9-GlLO9.js} +39 -8
- package/dist/gateway-C9-GlLO9.js.map +1 -0
- package/dist/{headless-ui-BFFmYC4v.js → headless-ui-CqI2gXlD.js} +2 -2
- package/dist/{headless-ui-BFFmYC4v.js.map → headless-ui-CqI2gXlD.js.map} +1 -1
- package/dist/{interactive-D6zV7brJ.js → interactive-B_Ti_CsS.js} +3 -3
- package/dist/interactive-B_Ti_CsS.js.map +1 -0
- package/dist/{logging-ui-_TwoMNbG.js → logging-ui-Dza4D0MK.js} +5 -5
- package/dist/{logging-ui-_TwoMNbG.js.map → logging-ui-Dza4D0MK.js.map} +1 -1
- package/dist/main-CgKxbwMP.js +1396 -0
- package/dist/main-CgKxbwMP.js.map +1 -0
- package/dist/{mcp-DAgaoGk5.js → mcp-DnAyW0-w.js} +4 -4
- package/dist/{mcp-DAgaoGk5.js.map → mcp-DnAyW0-w.js.map} +1 -1
- package/dist/{mcp-prompt-streaming-I2U_X7BC.js → mcp-prompt-streaming-DDWQ-FCA.js} +6 -6
- package/dist/mcp-prompt-streaming-DDWQ-FCA.js.map +1 -0
- package/dist/{mint-failure-D4nd2XmZ.js → mint-failure-u8xQKNOn.js} +689 -126
- package/dist/mint-failure-u8xQKNOn.js.map +1 -0
- package/dist/{models-DDdBJKwT.js → models-WcwUnSKb.js} +2 -2
- package/dist/{models-DDdBJKwT.js.map → models-WcwUnSKb.js.map} +1 -1
- package/dist/{non-interactive-Dzow7YKY.js → non-interactive-DyVC1AGc.js} +4 -3
- package/dist/{non-interactive-Dzow7YKY.js.map → non-interactive-DyVC1AGc.js.map} +1 -1
- package/dist/{oauth-session-DJ8h6GFa.js → oauth-session-DYM2Hrl2.js} +2 -2
- package/dist/{oauth-session-DJ8h6GFa.js.map → oauth-session-DYM2Hrl2.js.map} +1 -1
- package/dist/{orchestrator-tools-szcdscwn.js → orchestrator-tools-DbgNBFGA.js} +3 -3
- package/dist/{orchestrator-tools-szcdscwn.js.map → orchestrator-tools-DbgNBFGA.js.map} +1 -1
- package/dist/{package-json-DY70kkNp.js → package-json-Atg34fa4.js} +2 -8
- package/dist/{package-json-DY70kkNp.js.map → package-json-Atg34fa4.js.map} +1 -1
- package/dist/package-json-D8Ga03tK.js +2 -0
- package/dist/{pi-D3h5Ok0i.js → pi-8KsYsPmM.js} +145 -45
- package/dist/pi-8KsYsPmM.js.map +1 -0
- package/dist/{playground-5AB4WgNF.js → playground-BlYRBMj7.js} +11 -11
- package/dist/playground-BlYRBMj7.js.map +1 -0
- package/dist/{posthog-DNn574nW.js → posthog-Bt0Aplb8.js} +4 -9
- package/dist/posthog-Bt0Aplb8.js.map +1 -0
- package/dist/posthog-CUgCEhH0.js +2 -0
- package/dist/{provisioning-B8uSqRZk.js → provisioning-Bo2NRxFz.js} +5 -11
- package/dist/{provisioning-B8uSqRZk.js.map → provisioning-Bo2NRxFz.js.map} +1 -1
- package/dist/provisioning-OGFGlzf7.js +2 -0
- package/dist/{queue-tools-9OOVx5TE.js → queue-tools-C8mXOh7e.js} +3 -3
- package/dist/{queue-tools-9OOVx5TE.js.map → queue-tools-C8mXOh7e.js.map} +1 -1
- package/dist/registry-C06e_x-p.js +2 -0
- package/dist/{registry-8YG-kuXk.js → registry-CD5RQt38.js} +51 -53
- package/dist/registry-CD5RQt38.js.map +1 -0
- package/dist/run-agent-legacy-ChacZImU.js +2 -0
- package/dist/{run-agent-legacy-d7rWlzQR.js → run-agent-legacy-DOlM6DQu.js} +823 -1022
- package/dist/run-agent-legacy-DOlM6DQu.js.map +1 -0
- package/dist/runners-ov3EXF1n.js +834 -0
- package/dist/runners-ov3EXF1n.js.map +1 -0
- package/dist/{security-Cg_4a7vB.js → security-C71pkwqH.js} +16 -6
- package/dist/security-C71pkwqH.js.map +1 -0
- package/dist/{setup-utils-CmTCTPkX.js → setup-utils-B26Lf2yF.js} +12 -22
- package/dist/setup-utils-B26Lf2yF.js.map +1 -0
- package/dist/setup-utils-CVS86NYR.js +2 -0
- package/dist/{start-tui-CB2PZs1x.js → start-tui-Bo2L0bar.js} +30 -28
- package/dist/start-tui-Bo2L0bar.js.map +1 -0
- package/dist/{steps-BZcXRJNY.js → steps-BPcg3_3Q.js} +7 -7
- package/dist/{steps-BZcXRJNY.js.map → steps-BPcg3_3Q.js.map} +1 -1
- package/dist/{store-UN7c-ASf.js → store-BTzcvRGT.js} +12 -18
- package/dist/store-BTzcvRGT.js.map +1 -0
- package/dist/store-BpqySPXm.js +5 -0
- package/dist/{subagent-BofIDK-O.js → subagent-D1TrTchE.js} +3 -3
- package/dist/{subagent-BofIDK-O.js.map → subagent-D1TrTchE.js.map} +1 -1
- package/dist/{task-r9t1UhQP.js → task-DqRlQBfs.js} +18 -16
- package/dist/task-DqRlQBfs.js.map +1 -0
- package/dist/{task-stream-CMUilu54.js → task-stream-Bw6JaLCX.js} +10 -10
- package/dist/task-stream-Bw6JaLCX.js.map +1 -0
- package/dist/{tasks-Bbv_lOBG.js → tasks-ChWufsdO.js} +1 -1
- package/dist/{tasks-Bbv_lOBG.js.map → tasks-ChWufsdO.js.map} +1 -1
- package/dist/{telemetry-D6ruCtnv.js → telemetry-B7zJdRmA.js} +3 -3
- package/dist/{telemetry-D6ruCtnv.js.map → telemetry-B7zJdRmA.js.map} +1 -1
- package/dist/{terminal-DrGyci_a.js → terminal-zgkEfoCL.js} +17 -17
- package/dist/terminal-zgkEfoCL.js.map +1 -0
- package/dist/{tools-Dyfh9aCD.js → tools-CkJ2y9Wt.js} +9 -9
- package/dist/tools-CkJ2y9Wt.js.map +1 -0
- package/dist/{ui-BBVuTM1v.js → ui-Q6-RvERF.js} +3 -3
- package/dist/{ui-BBVuTM1v.js.map → ui-Q6-RvERF.js.map} +1 -1
- package/dist/{version-aXxpgRKx.js → version-CHhJjz_H.js} +2 -2
- package/dist/{version-aXxpgRKx.js.map → version-CHhJjz_H.js.map} +1 -1
- package/dist/{wizard-abort-BBkiUxfS.js → wizard-abort-BPdv07np.js} +7 -6
- package/dist/{wizard-abort-BBkiUxfS.js.map → wizard-abort-BPdv07np.js.map} +1 -1
- package/dist/wizard-abort-Br1qMDNa.js +3 -0
- package/dist/wizard-session-2w4Ru-Wz.js.map +1 -1
- package/dist/{wizard-ui-DoyOZxK8.js → wizard-ui-DVqrYaOM.js} +1 -1
- package/dist/{wizard-ui-DoyOZxK8.js.map → wizard-ui-DVqrYaOM.js.map} +1 -1
- package/dist/{yara-hooks-DCeMDd1o.js → yara-hooks-BnxejtXK.js} +5 -5
- package/dist/{yara-hooks-DCeMDd1o.js.map → yara-hooks-BnxejtXK.js.map} +1 -1
- package/dist/yara-hooks-DSuExwb4.js +2 -0
- package/package.json +2 -1
- package/dist/agent-bCZ3i3fh.js.map +0 -1
- package/dist/agent-interface-BAOIHuXS.js.map +0 -1
- package/dist/analytics-BcV-WCM4.js +0 -2
- package/dist/ci-install-CDdQYsPe.js.map +0 -1
- package/dist/errors-CQ9kttJD.js +0 -185
- package/dist/errors-CQ9kttJD.js.map +0 -1
- package/dist/file-BcLTjU16.js.map +0 -1
- package/dist/gateway-CjoShdLa.js.map +0 -1
- package/dist/interactive-D6zV7brJ.js.map +0 -1
- package/dist/mcp-prompt-streaming-I2U_X7BC.js.map +0 -1
- package/dist/mint-failure-D4nd2XmZ.js.map +0 -1
- package/dist/pi-D3h5Ok0i.js.map +0 -1
- package/dist/playground-5AB4WgNF.js.map +0 -1
- package/dist/posthog-DNn574nW.js.map +0 -1
- package/dist/registry-8YG-kuXk.js.map +0 -1
- package/dist/rolldown-runtime-B_-DWIq7.js +0 -15
- package/dist/run-agent-legacy-d7rWlzQR.js.map +0 -1
- package/dist/security-Cg_4a7vB.js.map +0 -1
- package/dist/setup-utils-CmTCTPkX.js.map +0 -1
- package/dist/start-tui-CB2PZs1x.js.map +0 -1
- package/dist/store-UN7c-ASf.js.map +0 -1
- package/dist/task-r9t1UhQP.js.map +0 -1
- package/dist/task-stream-CMUilu54.js.map +0 -1
- package/dist/terminal-DrGyci_a.js.map +0 -1
- package/dist/tools-Dyfh9aCD.js.map +0 -1
- package/dist/wizard-abort-BU4aLyvh.js +0 -3
- package/dist/yara-hooks-DSGuCU9A.js +0 -2
|
@@ -1,35 +1,434 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { I as WIZARD_TOOL_NAMES, n as buildRunTags, nt as LONGER_ASK_TIMEOUT_MS } from "./agent-interface-FkbaBJwz.js";
|
|
2
|
+
import { n as ErrorCodes } from "./emit-BSetXzDV.js";
|
|
3
|
+
import { r as debug, s as logToFile, x as regionOption, y as headlessOption } from "./debug-kAHwWGg7.js";
|
|
4
|
+
import { $ as getSkillsBaseUrl, Q as WIZARD_USER_AGENT, U as WIZARD_INTERACTION_EVENT_NAME, f as EVENTS_AUDIT_REPORT_FILE, h as EVENT_PLAN_FILE, k as POSTHOG_DOCS_URL, n as AGENTIC_DETECTION_RETRY_TIMEOUT_MS, t as AGENTIC_DETECTION_FIRST_ATTEMPT_TIMEOUT_MS, u as DETECTION_TIMEOUT_MS, w as Integration } from "./constants-DHCBSfnx.js";
|
|
4
5
|
import { r as mayReportScanResults } from "./wizard-session-2w4Ru-Wz.js";
|
|
5
|
-
import { n as analytics } from "./analytics-
|
|
6
|
-
import { i as withUtm, n as openTrackedLink } from "./telemetry-
|
|
7
|
-
import "./
|
|
8
|
-
import {
|
|
9
|
-
import { a as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { g as AUDIT_REPORT_FILE, h as AUDIT_CHECKS_FILE } from "./yara-hooks-
|
|
18
|
-
import { y as writeJsonAtomic } from "./queue-tools-
|
|
19
|
-
import { i as
|
|
6
|
+
import { n as analytics } from "./analytics-DXK1gc12.js";
|
|
7
|
+
import { i as withUtm, n as openTrackedLink } from "./telemetry-B7zJdRmA.js";
|
|
8
|
+
import "./errors-C2domSkK.js";
|
|
9
|
+
import { a as safeReadFile, o as walkProjectFiles } from "./bounded-fs-vAq-T-K7.js";
|
|
10
|
+
import { a as isUsingTypeScript, g as detectNodePackageManagers, o as tryGetPackageJson } from "./setup-utils-B26Lf2yF.js";
|
|
11
|
+
import { a as getBlockingServiceKeys, i as evaluateWizardReadiness, r as SIGNUP_WIZARD_READINESS_CONFIG } from "./logging-ui-Dza4D0MK.js";
|
|
12
|
+
import { t as getUI } from "./ui-Q6-RvERF.js";
|
|
13
|
+
import { r as requestDeepLink } from "./provisioning-Bo2NRxFz.js";
|
|
14
|
+
import { l as handleApiError } from "./api-CrbCIQOz.js";
|
|
15
|
+
import { i as wizardAbort } from "./wizard-abort-BPdv07np.js";
|
|
16
|
+
import { s as AgentSignals } from "./gateway-C9-GlLO9.js";
|
|
17
|
+
import { c as shouldDisableAsk, i as resolveScanBindings, n as runAgent } from "./agent-BWFhuLgo.js";
|
|
18
|
+
import { g as AUDIT_REPORT_FILE, h as AUDIT_CHECKS_FILE } from "./yara-hooks-BnxejtXK.js";
|
|
19
|
+
import { y as writeJsonAtomic } from "./queue-tools-C8mXOh7e.js";
|
|
20
|
+
import { a as getDetectedWarehouseSources, c as AUDIT_CHECKS_KEY, d as authenticate, i as detectWarehousePrerequisites, m as stampAiSdkDetected, n as DETECTED_WAREHOUSE_SOURCES_KEY, o as detectWarehouseSources, p as createUiReducer, r as WAREHOUSE_ABORT_CASES, s as discoverFeatures, t as runProgramAgent } from "./run-agent-legacy-DOlM6DQu.js";
|
|
21
|
+
import { r as SPINNER_MESSAGE, t as FRAMEWORK_REGISTRY } from "./registry-CD5RQt38.js";
|
|
22
|
+
import * as semver from "semver";
|
|
20
23
|
import { existsSync, readFileSync, readdirSync, statSync } from "fs";
|
|
21
|
-
import path, { join } from "path";
|
|
24
|
+
import path, { isAbsolute, join, relative, resolve, sep } from "path";
|
|
22
25
|
import * as os from "node:os";
|
|
23
26
|
import * as path$2 from "node:path";
|
|
24
27
|
import { spawnSync } from "node:child_process";
|
|
25
28
|
import * as fs$1 from "node:fs";
|
|
26
29
|
import axios from "axios";
|
|
27
30
|
import { z } from "zod";
|
|
31
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
28
32
|
import { Text } from "ink";
|
|
29
33
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
30
34
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
31
35
|
import { access, rm } from "node:fs/promises";
|
|
32
|
-
//#region src/
|
|
36
|
+
//#region src/programs/detection/framework.ts
|
|
37
|
+
/**
|
|
38
|
+
* Framework detection — identify which PostHog-supported framework
|
|
39
|
+
* is present in the project directory.
|
|
40
|
+
*
|
|
41
|
+
* Pure function: takes an install dir, returns the detected integration
|
|
42
|
+
* (or undefined). No store mutations, no UI calls.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Loop through all registered frameworks and return the first one
|
|
46
|
+
* whose `detect()` predicate matches the given directory.
|
|
47
|
+
* Returns undefined if no framework is detected or detection times out.
|
|
48
|
+
*/
|
|
49
|
+
async function detectFramework(installDir) {
|
|
50
|
+
for (const integration of Object.values(Integration)) {
|
|
51
|
+
const config = FRAMEWORK_REGISTRY[integration];
|
|
52
|
+
try {
|
|
53
|
+
if (await Promise.race([config.detection.detect({ installDir }), new Promise((resolve) => setTimeout(() => resolve(false), 1e4))])) return integration;
|
|
54
|
+
} catch {}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/programs/detection/context.ts
|
|
59
|
+
/**
|
|
60
|
+
* Framework context gathering — run gatherContext and version checks
|
|
61
|
+
* for a detected framework.
|
|
62
|
+
*
|
|
63
|
+
* Pure functions: take a framework config and options, return results.
|
|
64
|
+
* No store mutations, no UI calls.
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* Run a framework's `gatherContext()` to collect variant-specific
|
|
68
|
+
* metadata (e.g., router type for Next.js, Expo vs bare for React Native).
|
|
69
|
+
*
|
|
70
|
+
* Returns the gathered context, or an empty object on failure/timeout.
|
|
71
|
+
*/
|
|
72
|
+
async function gatherFrameworkContext(config, options) {
|
|
73
|
+
if (!config.metadata.gatherContext) return {};
|
|
74
|
+
try {
|
|
75
|
+
return await Promise.race([config.metadata.gatherContext(options), new Promise((resolve) => setTimeout(() => resolve({}), DETECTION_TIMEOUT_MS))]);
|
|
76
|
+
} catch {
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Check whether the installed framework version meets the minimum requirement.
|
|
82
|
+
*
|
|
83
|
+
* Returns `{ supported: true }` if the version is fine (or no check is needed).
|
|
84
|
+
* Returns the version details if unsupported.
|
|
85
|
+
*/
|
|
86
|
+
async function checkFrameworkVersion(config, options) {
|
|
87
|
+
if (!config.detection.minimumVersion || !config.detection.getInstalledVersion) return { supported: true };
|
|
88
|
+
const version = await config.detection.getInstalledVersion(options);
|
|
89
|
+
if (!version) return { supported: true };
|
|
90
|
+
const coerced = semver.coerce(version);
|
|
91
|
+
if (coerced && semver.lt(coerced, config.detection.minimumVersion)) return { supported: {
|
|
92
|
+
current: version,
|
|
93
|
+
minimum: config.detection.minimumVersion,
|
|
94
|
+
docsUrl: config.metadata.unsupportedVersionDocsUrl ?? config.metadata.docsUrl
|
|
95
|
+
} };
|
|
96
|
+
return { supported: true };
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/programs/detection/agentic.ts
|
|
100
|
+
/**
|
|
101
|
+
* Agentic project detection.
|
|
102
|
+
*
|
|
103
|
+
* A reusable detection tool that drives an agent over the repo: it finds
|
|
104
|
+
* project roots, resolves monorepo/workspace markers, reads package manifests,
|
|
105
|
+
* classifies each project against a caller-supplied set of targets, and reports
|
|
106
|
+
* which projects already have a PostHog SDK installed.
|
|
107
|
+
*
|
|
108
|
+
* Product-knowledge-free by design — the caller passes the targets to classify
|
|
109
|
+
* into (e.g. source-map skill variants) and maps the result back. Sits next to
|
|
110
|
+
* the other detection tools (framework, features, package-manager) so it's
|
|
111
|
+
* discoverable. Runs AFTER auth: it goes through the same `runAgent` every
|
|
112
|
+
* program uses, which needs credentials.
|
|
113
|
+
*/
|
|
114
|
+
var AgenticDetectionTimeoutError = class extends Error {
|
|
115
|
+
constructor(attempt, timeoutMs) {
|
|
116
|
+
super(`Project scan attempt ${attempt} timed out after ${timeoutMs / 1e3}s`);
|
|
117
|
+
this.name = "AgenticDetectionTimeoutError";
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Every project-manifest / workspace-marker filename the wizard's frameworks
|
|
122
|
+
* are identified by. One brace-expansion Glob over all of these locates every
|
|
123
|
+
* project root in the repo in a single call, regardless of language.
|
|
124
|
+
*
|
|
125
|
+
* Counterpart: POSTHOG_MANIFESTS in @programs/self-driving/detect (SDK
|
|
126
|
+
* grep); keep the two in sync.
|
|
127
|
+
*/
|
|
128
|
+
const PROJECT_MANIFESTS = [
|
|
129
|
+
"package.json",
|
|
130
|
+
"pnpm-workspace.yaml",
|
|
131
|
+
"turbo.json",
|
|
132
|
+
"nx.json",
|
|
133
|
+
"lerna.json",
|
|
134
|
+
"requirements.txt",
|
|
135
|
+
"pyproject.toml",
|
|
136
|
+
"setup.py",
|
|
137
|
+
"Pipfile",
|
|
138
|
+
"manage.py",
|
|
139
|
+
"Gemfile",
|
|
140
|
+
"composer.json",
|
|
141
|
+
"pom.xml",
|
|
142
|
+
"Cargo.toml",
|
|
143
|
+
"mix.exs",
|
|
144
|
+
"go.mod",
|
|
145
|
+
"*.csproj",
|
|
146
|
+
"Package.swift",
|
|
147
|
+
"Podfile",
|
|
148
|
+
"project.yml",
|
|
149
|
+
"project.pbxproj",
|
|
150
|
+
"pubspec.yaml",
|
|
151
|
+
"build.gradle",
|
|
152
|
+
"build.gradle.kts",
|
|
153
|
+
"settings.gradle",
|
|
154
|
+
"settings.gradle.kts",
|
|
155
|
+
"gradle/libs.versions.toml"
|
|
156
|
+
];
|
|
157
|
+
/** The single brace-expansion glob covering every supported manifest. */
|
|
158
|
+
function manifestGlob() {
|
|
159
|
+
return `**/{${PROJECT_MANIFESTS.join(",")}}`;
|
|
160
|
+
}
|
|
161
|
+
function buildPrompt$1(cwd, targets, purpose, recommend) {
|
|
162
|
+
const targetList = targets.map((t) => `- ${t.id} → ${t.name}`).join("\n");
|
|
163
|
+
const projectShape = `{"path":string,"framework":string,"matchingTargets":string[],"targetId":string|null,"hasPostHog":boolean,"evidence":string${recommend ? ",\"recommended\":boolean" : ""}}`;
|
|
164
|
+
return [
|
|
165
|
+
`You are scanning a code repository to ${purpose}. Be fast and mechanical — do not over-explore. Keep any reasoning to one short sentence, then run the tool calls and output the JSON.`,
|
|
166
|
+
"",
|
|
167
|
+
`Working directory: ${cwd}`,
|
|
168
|
+
"",
|
|
169
|
+
"A \"project\" is a directory containing one or more of the manifest files below. Find projects by their manifests, NOT by walking directories — never report a directory that has no manifest.",
|
|
170
|
+
"",
|
|
171
|
+
"Do exactly this:",
|
|
172
|
+
`1. Run Glob ONCE with this pattern to find every project manifest in the repo in a single call: "${manifestGlob()}". Discard any result whose path contains node_modules/, dist/, build/, .next/, out/, coverage/, vendor/, .venv/, site-packages/, target/, Pods/, Carthage/, or DerivedData/. Group the remaining results by directory — each directory is one project. Three exceptions to "directory = project": a project.pbxproj lives inside a "<Name>.xcodeproj/" wrapper, so the project root is the PARENT of that .xcodeproj directory; a project.yml at a directory root is an XcodeGen-generated Xcode app rooted at that directory; a gradle/libs.versions.toml is a version catalog belonging to the gradle project rooted at the PARENT of that gradle/ directory (read it alongside the build.gradle when deciding hasPostHog), never its own project.`,
|
|
173
|
+
"2. Decide repoType: \"monorepo\" if the root package.json has a \"workspaces\" field OR a pnpm-workspace.yaml / turbo.json / nx.json / lerna.json was found at the root, else \"single\".",
|
|
174
|
+
`3. For EACH project directory, ONE AT A TIME: Read its manifest(s) ONCE, decide the fields below, then IMMEDIATELY — before reading any other project — write that project's verdict as one JSON line of shape ${projectShape}. Never write a verdict from memory of an earlier Read; the manifest you just read is the only source. Decide from its dependency lists:`,
|
|
175
|
+
" - the human-readable framework name (e.g. \"Next.js\", \"Django\", \"Rails\"),",
|
|
176
|
+
" - matchingTargets: EVERY target id from the list below whose technology appears in THIS manifest, in the priority order of the list. An id belongs here only if you can point at the dependency or setting in the manifest you just read — never carry one over from another project,",
|
|
177
|
+
" - targetId: the FIRST entry of matchingTargets (the list is ordered by priority, most specific first). null when matchingTargets is empty,",
|
|
178
|
+
` - hasPostHog: true if any dependency is a PostHog SDK. This includes: a name containing "posthog" in any ecosystem (e.g. posthog-js, posthog-node, @posthog/*, posthog for pip/gem/hex, a com.posthog:* gradle/maven coordinate, a PostHog NuGet PackageReference); an SPM package named "PostHog" or a repositoryURL of github.com/PostHog/posthog-ios (in Package.swift or a .pbxproj); or a "pod 'PostHog'" line in a Podfile. Else false.`,
|
|
179
|
+
" - evidence: the manifest fact that decided targetId, with the file it came from (e.g. \"rollup in devDependencies of backend/package.json\"). When targetId is null, name the closest fact you saw. One short clause, quoted from the manifest you just read.",
|
|
180
|
+
" Do NOT read any file other than these manifests.",
|
|
181
|
+
...recommend ? ["4. Pick exactly ONE project as recommended — the main user-facing client application. Prefer a frontend web app or a mobile app over backend servers/APIs, libraries, CLIs, tooling, and example/demo/docs apps. If several client apps exist, pick the primary production app; if no client app exists, pick the primary application project."] : [],
|
|
182
|
+
"",
|
|
183
|
+
"Target ids (id → name), in priority order — most specific first; if several match a project, keep the one listed earliest:",
|
|
184
|
+
targetList,
|
|
185
|
+
"",
|
|
186
|
+
"Output requirements:",
|
|
187
|
+
"- After the last verdict line, respond with ONLY a single JSON object assembling the verdict lines you wrote, copied VERBATIM — same path, framework, targetId and evidence per project. No prose, no markdown code fences.",
|
|
188
|
+
`- Shape: {"repoType":"monorepo"|"single","projects":[${projectShape}]}`,
|
|
189
|
+
"- \"path\" is the project directory relative to the working directory; use \".\" for the repo root.",
|
|
190
|
+
"- \"targetId\" MUST be exactly one of the target ids above when it matches; if several match, use the one listed earliest; otherwise null.",
|
|
191
|
+
"- Include projects whose stack matches no target too (targetId: null).",
|
|
192
|
+
...recommend ? ["- Exactly one project has \"recommended\": true; every other project has \"recommended\": false."] : [],
|
|
193
|
+
"- If there are no manifests at all, return {\"repoType\":\"single\",\"projects\":[]}."
|
|
194
|
+
].join("\n");
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Build the detection report from the agent's output, or null when it holds
|
|
198
|
+
* neither a project verdict nor a `projects` array. Exported for testing.
|
|
199
|
+
*
|
|
200
|
+
* The verdict lines are far more reliable than the model's final assembly
|
|
201
|
+
* (prose, pretty-printing, per-object fences), so every parseable line
|
|
202
|
+
* contributes: objects with a `path` merge by path (last wins), and a
|
|
203
|
+
* one-line assembly's `projects` merge the same way. `repoType` is
|
|
204
|
+
* approximated from the count — it only feeds telemetry and display.
|
|
205
|
+
*/
|
|
206
|
+
function deriveReportJson(text) {
|
|
207
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
208
|
+
let sawReport = false;
|
|
209
|
+
for (const line of text.split("\n")) {
|
|
210
|
+
const start = line.indexOf("{");
|
|
211
|
+
const end = line.lastIndexOf("}");
|
|
212
|
+
if (start === -1 || end <= start) continue;
|
|
213
|
+
let parsed;
|
|
214
|
+
try {
|
|
215
|
+
parsed = JSON.parse(line.slice(start, end + 1));
|
|
216
|
+
} catch {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
const obj = parsed ?? {};
|
|
220
|
+
sawReport ||= Array.isArray(obj.projects);
|
|
221
|
+
const candidates = Array.isArray(obj.projects) ? obj.projects : [obj];
|
|
222
|
+
for (const candidate of candidates) {
|
|
223
|
+
const p = candidate ?? {};
|
|
224
|
+
if (typeof p.path === "string") byPath.set(p.path, p);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (byPath.size === 0 && !sawReport) return null;
|
|
228
|
+
const projects = [...byPath.values()];
|
|
229
|
+
return {
|
|
230
|
+
repoType: projects.length > 1 ? "monorepo" : "single",
|
|
231
|
+
projects
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Clamp an agent-reported project path to a safe repo-relative dir. The path
|
|
236
|
+
* is LLM output: absolute paths or `..` segments could steer later phases
|
|
237
|
+
* (e.g. integrate-run's targetDir) outside the repo, so they clamp to '.'.
|
|
238
|
+
*/
|
|
239
|
+
function coercePath(raw) {
|
|
240
|
+
if (typeof raw !== "string" || raw.length === 0) return ".";
|
|
241
|
+
if (isAbsolute(raw) || raw.split(/[\\/]/).includes("..")) return ".";
|
|
242
|
+
return raw;
|
|
243
|
+
}
|
|
244
|
+
/** Resolve an agent-reported path to an absolute dir clamped to the root — the caller-side counterpart of coercePath. */
|
|
245
|
+
function resolveProjectDir(installDir, rel) {
|
|
246
|
+
if (typeof rel !== "string" || rel === ".") return installDir;
|
|
247
|
+
const root = resolve(installDir);
|
|
248
|
+
const dir = resolve(root, rel);
|
|
249
|
+
return dir === root || dir.startsWith(root + sep) ? dir : root;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Validate the agent's raw JSON into a report, clamping each targetId to the
|
|
253
|
+
* supplied set and each path to a repo-relative dir. Exported for testing.
|
|
254
|
+
* `recommended` is stripped unless requested; at most one (the first) survives.
|
|
255
|
+
*/
|
|
256
|
+
function coerceAgenticReport(parsed, validTargetIds, options) {
|
|
257
|
+
const recommend = options?.recommend === true;
|
|
258
|
+
const rerankIds = options?.rerankIds ?? [];
|
|
259
|
+
const obj = parsed ?? {};
|
|
260
|
+
const repoType = obj.repoType === "monorepo" ? "monorepo" : "single";
|
|
261
|
+
const rawProjects = Array.isArray(obj.projects) ? obj.projects : [];
|
|
262
|
+
let recommendedSeen = false;
|
|
263
|
+
return {
|
|
264
|
+
repoType,
|
|
265
|
+
projects: rawProjects.map((raw) => {
|
|
266
|
+
const p = raw ?? {};
|
|
267
|
+
const pick = typeof p.targetId === "string" && validTargetIds.includes(p.targetId) ? p.targetId : null;
|
|
268
|
+
const enumerated = Array.isArray(p.matchingTargets) ? validTargetIds.find((id) => p.matchingTargets.includes(id)) ?? null : null;
|
|
269
|
+
const targetId = pick === null ? enumerated : enumerated !== null && rerankIds.includes(enumerated) && rerankIds.includes(pick) ? enumerated : pick;
|
|
270
|
+
const recommended = recommend && !recommendedSeen && p.recommended === true;
|
|
271
|
+
recommendedSeen ||= recommended;
|
|
272
|
+
return {
|
|
273
|
+
path: coercePath(p.path),
|
|
274
|
+
framework: typeof p.framework === "string" ? p.framework : "Unknown",
|
|
275
|
+
targetId,
|
|
276
|
+
hasPostHog: p.hasPostHog === true,
|
|
277
|
+
...recommend ? { recommended } : {}
|
|
278
|
+
};
|
|
279
|
+
})
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function detectionReportSchema(recommend) {
|
|
283
|
+
return z.object({
|
|
284
|
+
repoType: z.enum(["monorepo", "single"]),
|
|
285
|
+
projects: z.array(z.object({
|
|
286
|
+
path: z.string(),
|
|
287
|
+
framework: z.string(),
|
|
288
|
+
matchingTargets: z.array(z.string()),
|
|
289
|
+
targetId: z.string().nullable(),
|
|
290
|
+
hasPostHog: z.boolean(),
|
|
291
|
+
evidence: z.string(),
|
|
292
|
+
...recommend ? { recommended: z.boolean() } : {}
|
|
293
|
+
}).strict())
|
|
294
|
+
}).strict();
|
|
295
|
+
}
|
|
296
|
+
/** Read-only scan with a typed result and transcript recovery. */
|
|
297
|
+
function detectionRunDefinition(prompt) {
|
|
298
|
+
return {
|
|
299
|
+
integrationLabel: "agentic-detect",
|
|
300
|
+
readOnly: true,
|
|
301
|
+
prompt: () => prompt,
|
|
302
|
+
collectTranscript: true,
|
|
303
|
+
requestRemark: false,
|
|
304
|
+
detectPackageManager: detectNodePackageManagers,
|
|
305
|
+
spinnerMessage: "Scanning the repo...",
|
|
306
|
+
successMessage: "Detection complete",
|
|
307
|
+
errorMessage: "Detection failed",
|
|
308
|
+
estimatedDurationMinutes: 1,
|
|
309
|
+
reportFile: "",
|
|
310
|
+
docsUrl: POSTHOG_DOCS_URL
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
/** What the UI saw before `runAgent`: no run lifecycle, spinner, outro, or setup logs below warn. */
|
|
314
|
+
function reachesUi(event) {
|
|
315
|
+
switch (event.kind) {
|
|
316
|
+
case "lifecycle":
|
|
317
|
+
case "completion":
|
|
318
|
+
case "spinner": return false;
|
|
319
|
+
case "log": return event.level === "warn" || event.level === "error";
|
|
320
|
+
default: return true;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/** Scan through `runAgent` with the bound triage model, then the SDK fallback. */
|
|
324
|
+
async function detectProjectsWithAgent(session, options) {
|
|
325
|
+
if (!session.credentials) throw new Error("Detection requires authenticated credentials.");
|
|
326
|
+
const { targets, programId, purpose = "set up a PostHog integration", recommend = false, rerankIds, onEvent } = options;
|
|
327
|
+
const wizardMetadata = {
|
|
328
|
+
...buildRunTags({
|
|
329
|
+
programId,
|
|
330
|
+
integration: "agentic-detect",
|
|
331
|
+
runId: analytics.runId,
|
|
332
|
+
build: analytics.build
|
|
333
|
+
}),
|
|
334
|
+
call_type: "detection"
|
|
335
|
+
};
|
|
336
|
+
const wizardFlags = await analytics.getAllFlagsForWizard();
|
|
337
|
+
const wizardFlagPayloads = analytics.getWizardFlagPayloads();
|
|
338
|
+
const switchboard = {
|
|
339
|
+
program: programId,
|
|
340
|
+
composed: true,
|
|
341
|
+
flags: wizardFlags,
|
|
342
|
+
flagPayloads: wizardFlagPayloads,
|
|
343
|
+
cliHarness: session.harness
|
|
344
|
+
};
|
|
345
|
+
const bindings = resolveScanBindings(switchboard);
|
|
346
|
+
const reportSchema = detectionReportSchema(recommend);
|
|
347
|
+
const schema = zodToJsonSchema(reportSchema);
|
|
348
|
+
const config = {
|
|
349
|
+
programId,
|
|
350
|
+
run: detectionRunDefinition(buildPrompt$1(session.installDir, targets, purpose, recommend)),
|
|
351
|
+
composed: true,
|
|
352
|
+
binding: bindings[0],
|
|
353
|
+
switchboard,
|
|
354
|
+
skillsBaseUrl: getSkillsBaseUrl(),
|
|
355
|
+
wizardFlags,
|
|
356
|
+
wizardFlagPayloads,
|
|
357
|
+
wizardMetadata,
|
|
358
|
+
scanReport: "defer"
|
|
359
|
+
};
|
|
360
|
+
const input = {
|
|
361
|
+
installDir: session.installDir,
|
|
362
|
+
credentials: session.credentials,
|
|
363
|
+
project: null,
|
|
364
|
+
apiUser: null,
|
|
365
|
+
flags: {
|
|
366
|
+
ci: session.ci,
|
|
367
|
+
signup: session.signup,
|
|
368
|
+
debug: session.debug,
|
|
369
|
+
e2eAsk: false,
|
|
370
|
+
localMcp: session.localMcp,
|
|
371
|
+
captureAio: false,
|
|
372
|
+
benchmark: false,
|
|
373
|
+
yaraReport: session.yaraReport
|
|
374
|
+
},
|
|
375
|
+
host: {
|
|
376
|
+
projectId: session.projectId,
|
|
377
|
+
apiKey: session.apiKey
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
const reduceUi = createUiReducer(getUI());
|
|
381
|
+
const forward = (event) => {
|
|
382
|
+
if (event.kind === "activity") onEvent?.(event.line);
|
|
383
|
+
if (reachesUi(event)) reduceUi(event);
|
|
384
|
+
};
|
|
385
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
386
|
+
const timeoutMs = attempt === 0 ? AGENTIC_DETECTION_FIRST_ATTEMPT_TIMEOUT_MS : AGENTIC_DETECTION_RETRY_TIMEOUT_MS;
|
|
387
|
+
const result = await runAgent({
|
|
388
|
+
...config,
|
|
389
|
+
binding: bindings[attempt],
|
|
390
|
+
run: {
|
|
391
|
+
...config.run,
|
|
392
|
+
structured: {
|
|
393
|
+
schema,
|
|
394
|
+
timeoutMs
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}, input, { onProgress: forward });
|
|
398
|
+
if (result.outcome !== "success" && result.failure.code === ErrorCodes.AgenticDetectionTimeout) {
|
|
399
|
+
if (attempt === 0) {
|
|
400
|
+
onEvent?.("Project scan timed out; retrying...");
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
throw new AgenticDetectionTimeoutError(attempt + 1, timeoutMs);
|
|
404
|
+
}
|
|
405
|
+
if (result.outcome !== "success") {
|
|
406
|
+
if (result.failure.code === ErrorCodes.AgentInvalidStructuredOutput && attempt === 0) {
|
|
407
|
+
onEvent?.("Project scan returned invalid output; retrying...");
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
throw result.failure.error ?? new Error(result.failure.message);
|
|
411
|
+
}
|
|
412
|
+
if (result.structuredOutput !== void 0) {
|
|
413
|
+
const structured = reportSchema.safeParse(result.structuredOutput);
|
|
414
|
+
if (structured.success) return coerceAgenticReport(structured.data, targets.map((t) => t.id), {
|
|
415
|
+
recommend,
|
|
416
|
+
rerankIds
|
|
417
|
+
});
|
|
418
|
+
if (attempt === 0) onEvent?.("Project scan returned invalid output; retrying...");
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
const derived = deriveReportJson(result.snapshot.transcriptTail ?? "");
|
|
422
|
+
if (derived !== null) return coerceAgenticReport(derived, targets.map((t) => t.id), {
|
|
423
|
+
recommend,
|
|
424
|
+
rerankIds
|
|
425
|
+
});
|
|
426
|
+
if (attempt === 0) onEvent?.("Retrying project scan...");
|
|
427
|
+
}
|
|
428
|
+
throw new Error("Agent did not return a JSON object after retry");
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/programs/detection/project-scope.ts
|
|
33
432
|
/** Non-interactive project scoping — scan the repo agentically and pick which project the run integrates. */
|
|
34
433
|
/** Integration framework targets for the agentic detector (id → display name). */
|
|
35
434
|
const INTEGRATION_TARGETS = Object.entries(FRAMEWORK_REGISTRY).map(([id, config]) => ({
|
|
@@ -66,13 +465,13 @@ function captureOutcome(outcome, properties = {}) {
|
|
|
66
465
|
});
|
|
67
466
|
}
|
|
68
467
|
/** Flag-gated non-interactive monorepo phase: scan, auto-choose the recommended project, re-point session.installDir; every failure leaves the session untouched. */
|
|
69
|
-
async function scopeInstallDirToProject(session) {
|
|
468
|
+
async function scopeInstallDirToProject(session, runner) {
|
|
70
469
|
await authenticate(session, "posthog-integration");
|
|
71
470
|
if ((await analytics.getAllFlagsForWizard())["wizard-basic-integration-agentic-detection"] !== "true") {
|
|
72
471
|
captureOutcome("flag-off");
|
|
73
472
|
return;
|
|
74
473
|
}
|
|
75
|
-
|
|
474
|
+
runner.log.info("Scanning the repo for projects...");
|
|
76
475
|
const startedAt = Date.now();
|
|
77
476
|
let report;
|
|
78
477
|
try {
|
|
@@ -85,7 +484,7 @@ async function scopeInstallDirToProject(session) {
|
|
|
85
484
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
86
485
|
if (error instanceof AgenticDetectionTimeoutError) {
|
|
87
486
|
captureOutcome("timeout", { duration_ms: Date.now() - startedAt });
|
|
88
|
-
|
|
487
|
+
runner.log.warn(`${error.message}; continuing with the install dir as-is.`);
|
|
89
488
|
return;
|
|
90
489
|
}
|
|
91
490
|
analytics.captureException(error, { step: "agentic_detection" });
|
|
@@ -93,7 +492,7 @@ async function scopeInstallDirToProject(session) {
|
|
|
93
492
|
duration_ms: Date.now() - startedAt,
|
|
94
493
|
error_message: error.message
|
|
95
494
|
});
|
|
96
|
-
|
|
495
|
+
runner.log.warn(`Project scan failed (${error.message}); continuing with the install dir as-is.`);
|
|
97
496
|
return;
|
|
98
497
|
}
|
|
99
498
|
const { projects } = report;
|
|
@@ -110,7 +509,7 @@ async function scopeInstallDirToProject(session) {
|
|
|
110
509
|
const project = chooseIntegrationProject(projects);
|
|
111
510
|
if (!project) {
|
|
112
511
|
captureOutcome("no-project", scanProperties);
|
|
113
|
-
|
|
512
|
+
runner.log.info("The scan found no supported project; continuing with the install dir as-is.");
|
|
114
513
|
return;
|
|
115
514
|
}
|
|
116
515
|
session.installDir = resolveProjectDir(session.installDir, project.path);
|
|
@@ -119,10 +518,10 @@ async function scopeInstallDirToProject(session) {
|
|
|
119
518
|
chosen_framework: project.targetId,
|
|
120
519
|
chosen_path: project.path
|
|
121
520
|
});
|
|
122
|
-
|
|
521
|
+
runner.log.info(`Continuing with ${project.path} (${project.framework}).`);
|
|
123
522
|
}
|
|
124
523
|
//#endregion
|
|
125
|
-
//#region src/
|
|
524
|
+
//#region src/programs/shared/health-check-step.ts
|
|
126
525
|
function healthCheckReady(session) {
|
|
127
526
|
if (!session.readinessResult) return false;
|
|
128
527
|
if (session.signup) {
|
|
@@ -154,7 +553,180 @@ const HEALTH_CHECK_STEP = {
|
|
|
154
553
|
}
|
|
155
554
|
};
|
|
156
555
|
//#endregion
|
|
157
|
-
//#region src/
|
|
556
|
+
//#region src/programs/shared/package-scanning.ts
|
|
557
|
+
const POSTHOG_SDKS = new Set([
|
|
558
|
+
"posthog-js",
|
|
559
|
+
"posthog-node",
|
|
560
|
+
"posthog-react-native",
|
|
561
|
+
"posthog-android",
|
|
562
|
+
"posthog-ios"
|
|
563
|
+
]);
|
|
564
|
+
const STRIPE_SDKS = new Set([
|
|
565
|
+
"stripe",
|
|
566
|
+
"@stripe/stripe-js",
|
|
567
|
+
"@stripe/react-stripe-js"
|
|
568
|
+
]);
|
|
569
|
+
const MAX_PACKAGE_MATCHES = 500;
|
|
570
|
+
/**
|
|
571
|
+
* Find all package.json files under installDir via the shared bounded walk
|
|
572
|
+
* (depth cap, ignored dirs, symlink-loop protection, per-dir entry cap).
|
|
573
|
+
* Returns matches with detected SDKs.
|
|
574
|
+
*/
|
|
575
|
+
function findPackageJsons(installDir, maxDepth = 3) {
|
|
576
|
+
const matches = [];
|
|
577
|
+
walkProjectFiles(installDir, (name, fullPath) => {
|
|
578
|
+
if (name !== "package.json" || matches.length >= MAX_PACKAGE_MATCHES) return;
|
|
579
|
+
const content = safeReadFile(fullPath);
|
|
580
|
+
if (content === null) return;
|
|
581
|
+
try {
|
|
582
|
+
const pkg = JSON.parse(content);
|
|
583
|
+
const depNames = [...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.devDependencies ?? {})];
|
|
584
|
+
const posthogSdks = depNames.filter((d) => POSTHOG_SDKS.has(d));
|
|
585
|
+
const stripeSdks = depNames.filter((d) => STRIPE_SDKS.has(d));
|
|
586
|
+
matches.push({
|
|
587
|
+
path: relative(installDir, fullPath) || "package.json",
|
|
588
|
+
posthogSdks,
|
|
589
|
+
stripeSdks
|
|
590
|
+
});
|
|
591
|
+
} catch {}
|
|
592
|
+
}, maxDepth);
|
|
593
|
+
return matches;
|
|
594
|
+
}
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region src/programs/posthog-integration/detect.ts
|
|
597
|
+
async function detectPostHogIntegration(ctx) {
|
|
598
|
+
const session = ctx.session;
|
|
599
|
+
const installDir = session.installDir;
|
|
600
|
+
const detectedIntegration = await detectFramework(installDir);
|
|
601
|
+
if (detectedIntegration) {
|
|
602
|
+
const config = FRAMEWORK_REGISTRY[detectedIntegration];
|
|
603
|
+
const sessionOptions = {
|
|
604
|
+
installDir,
|
|
605
|
+
debug: session.debug,
|
|
606
|
+
signup: session.signup,
|
|
607
|
+
ci: session.ci,
|
|
608
|
+
benchmark: session.benchmark,
|
|
609
|
+
yaraReport: session.yaraReport
|
|
610
|
+
};
|
|
611
|
+
const context = await gatherFrameworkContext(config, sessionOptions);
|
|
612
|
+
for (const [key, value] of Object.entries(context)) if (!(key in session.frameworkContext)) ctx.setFrameworkContext(key, value);
|
|
613
|
+
ctx.setFrameworkConfig(detectedIntegration, config);
|
|
614
|
+
ctx.setSkillId(detectedIntegration);
|
|
615
|
+
if (!session.detectedFrameworkLabel) ctx.setDetectedFramework(config.metadata.name);
|
|
616
|
+
const versionResult = await checkFrameworkVersion(config, sessionOptions);
|
|
617
|
+
if (versionResult.supported !== true) ctx.setUnsupportedVersion(versionResult.supported);
|
|
618
|
+
}
|
|
619
|
+
for (const feature of discoverFeatures(installDir)) ctx.addDiscoveredFeature(feature);
|
|
620
|
+
detectWarehouseSourcesForSuggestion(ctx, installDir);
|
|
621
|
+
detectExistingPostHog(ctx, installDir);
|
|
622
|
+
ctx.setDetectionComplete();
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* How the scan went, for the reporter to read later. Three states, and the
|
|
626
|
+
* absent one carries the most weight:
|
|
627
|
+
*
|
|
628
|
+
* absent this program never scanned. Only `posthog-integration` runs the
|
|
629
|
+
* scan below, but every program's intro screen resolves consent
|
|
630
|
+
* through the same store method, so the reporter is reached on runs
|
|
631
|
+
* where no scan ever happened.
|
|
632
|
+
* 'failed' the scan threw. A zero-count row would read as "scanned, found
|
|
633
|
+
* nothing", which is a different fact.
|
|
634
|
+
* 'ok' the scan ran. Zero sources is a real result and gets reported.
|
|
635
|
+
*/
|
|
636
|
+
const WAREHOUSE_SCAN_STATE_KEY = "warehouseScanState";
|
|
637
|
+
/**
|
|
638
|
+
* Scan for data warehouse source signals (Postgres, Stripe, Hubspot, …) and,
|
|
639
|
+
* when found, stash them for a `wizard warehouse` suggestion on the outro.
|
|
640
|
+
* Runs unconditionally during `detect`, before the intro screen has asked
|
|
641
|
+
* about sharing. Reporting what this finds is a separate, later concern.
|
|
642
|
+
* See `reportWarehouseSourcesDetected` below.
|
|
643
|
+
*
|
|
644
|
+
* Deliberately a suggestion, not an inline agent run: a second credential-
|
|
645
|
+
* collecting agent run before the outro could `process.exit()` on any of its
|
|
646
|
+
* failure paths and cost the user the success outro on a run where PostHog
|
|
647
|
+
* installed fine.
|
|
648
|
+
*
|
|
649
|
+
* Calls `detectWarehouseSources` (a pure scan) rather than the warehouse
|
|
650
|
+
* program's `detectWarehousePrerequisites`, which writes a `detectError` when
|
|
651
|
+
* it finds nothing — that's right for `wizard warehouse` but here would show a
|
|
652
|
+
* spurious error and trip the CI prerequisites abort. No sources is a no-op.
|
|
653
|
+
*
|
|
654
|
+
* Best-effort: never let a scan failure break the wizard flow.
|
|
655
|
+
*/
|
|
656
|
+
function detectWarehouseSourcesForSuggestion(ctx, installDir) {
|
|
657
|
+
try {
|
|
658
|
+
const sources = detectWarehouseSources(installDir);
|
|
659
|
+
ctx.setFrameworkContext(WAREHOUSE_SCAN_STATE_KEY, "ok");
|
|
660
|
+
if (sources.length === 0) return;
|
|
661
|
+
ctx.setFrameworkContext(DETECTED_WAREHOUSE_SOURCES_KEY, sources);
|
|
662
|
+
} catch (error) {
|
|
663
|
+
ctx.setFrameworkContext(WAREHOUSE_SCAN_STATE_KEY, "failed");
|
|
664
|
+
analytics.captureException(error instanceof Error ? error : new Error(String(error)), { step: "detectWarehouseSourcesForSuggestion" });
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Fires the org stamp once per session, right after `authenticate()` succeeds
|
|
669
|
+
* — never from the consent path, since consent on the intro screen resolves
|
|
670
|
+
* before login and `session.apiUser` is unset there. Called right after
|
|
671
|
+
* `authenticate()` from run-wizard.ts's auth step and from bootstrap.ts,
|
|
672
|
+
* whichever completes it first for a given program; a no-op on every call
|
|
673
|
+
* after that. In the `--ci` path, project-scope.ts authenticates first as a
|
|
674
|
+
* prerequisite (no evidence gathered yet, so nothing would stamp there
|
|
675
|
+
* anyway) and this only ever runs from the later, idempotent bootstrap.ts
|
|
676
|
+
* call — still correctly finding no evidence, since CI skips the detect step.
|
|
677
|
+
*/
|
|
678
|
+
function maybeStampAiSdkDetected(session) {
|
|
679
|
+
if (session.aiSdkStampReported) return;
|
|
680
|
+
session.aiSdkStampReported = true;
|
|
681
|
+
stampAiSdkDetected({
|
|
682
|
+
apiUser: session.apiUser,
|
|
683
|
+
discoveredFeatures: session.discoveredFeatures,
|
|
684
|
+
warehouseSources: getDetectedWarehouseSources(session),
|
|
685
|
+
mayReportScanResults: mayReportScanResults(session)
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* The single place scan results become telemetry. Called from
|
|
690
|
+
* `WizardStore.completeSetup()`, the point consent becomes final — the privacy
|
|
691
|
+
* panel's choice is reversible until then, so nothing may report earlier.
|
|
692
|
+
* The org stamp is a separate concern: see `maybeStampAiSdkDetected`, which
|
|
693
|
+
* runs post-auth rather than at consent resolution.
|
|
694
|
+
*
|
|
695
|
+
* Returns true when consent has resolved and the caller should latch
|
|
696
|
+
* `warehouseSourcesReported`, which is not the same as "this sent something":
|
|
697
|
+
* a decline, a failed scan, and a program that never scanned all resolve
|
|
698
|
+
* without sending.
|
|
699
|
+
*/
|
|
700
|
+
function reportWarehouseSourcesDetected(session) {
|
|
701
|
+
if (session.warehouseSourcesReported) return false;
|
|
702
|
+
if (session.scanConsent === "undecided") return false;
|
|
703
|
+
if (mayReportScanResults(session)) {
|
|
704
|
+
const sources = getDetectedWarehouseSources(session);
|
|
705
|
+
if (session.frameworkContext[WAREHOUSE_SCAN_STATE_KEY] !== "ok") return true;
|
|
706
|
+
analytics.wizardCapture("warehouse sources detected", {
|
|
707
|
+
warehouse_source_count: sources.length,
|
|
708
|
+
warehouse_source_kinds: sources.map((s) => s.kind),
|
|
709
|
+
warehouse_source_modes: sources.map((s) => s.mode)
|
|
710
|
+
});
|
|
711
|
+
if (sources.length > 0) {
|
|
712
|
+
analytics.setTag("warehouse_source_kinds", sources.map((s) => s.kind).join(","));
|
|
713
|
+
analytics.setTag("warehouse_source_count", sources.length);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return true;
|
|
717
|
+
}
|
|
718
|
+
/** Dependency-level signal, not a verified install. A failed scan reports false. */
|
|
719
|
+
function detectExistingPostHog(ctx, installDir) {
|
|
720
|
+
try {
|
|
721
|
+
const pkgJsons = findPackageJsons(installDir);
|
|
722
|
+
ctx.setPosthogSdkDetected(pkgJsons.some((p) => p.posthogSdks.length > 0));
|
|
723
|
+
} catch (error) {
|
|
724
|
+
analytics.captureException(error instanceof Error ? error : new Error(String(error)), { step: "detectExistingPosthog" });
|
|
725
|
+
ctx.setPosthogSdkDetected(false);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
//#endregion
|
|
729
|
+
//#region src/programs/posthog-integration/steps.ts
|
|
158
730
|
function needsSetup$1(session) {
|
|
159
731
|
const config = session.frameworkConfig;
|
|
160
732
|
if (!config?.metadata.setup?.questions) return false;
|
|
@@ -475,7 +1047,7 @@ const StatusPeekTrigger = ({ store, duration = 1e4 }) => {
|
|
|
475
1047
|
return /* @__PURE__ */ jsx(Text, { children: "You can view the Wizard's status below." });
|
|
476
1048
|
};
|
|
477
1049
|
//#endregion
|
|
478
|
-
//#region src/
|
|
1050
|
+
//#region src/ui/tui/decks/posthog-integration/data-flow.tsx
|
|
479
1051
|
/**
|
|
480
1052
|
* POSTHOG_DATA_FLOW — ASCII diagram of the PostHog event ingestion flow.
|
|
481
1053
|
*/
|
|
@@ -644,7 +1216,7 @@ const POSTHOG_DATA_FLOW = {
|
|
|
644
1216
|
]
|
|
645
1217
|
};
|
|
646
1218
|
//#endregion
|
|
647
|
-
//#region src/
|
|
1219
|
+
//#region src/ui/tui/decks/posthog-integration/product-suite.tsx
|
|
648
1220
|
/**
|
|
649
1221
|
* PRODUCT_SUITE_BLOCK — Two-column listing of PostHog products.
|
|
650
1222
|
*/
|
|
@@ -764,7 +1336,7 @@ const PRODUCT_SUITE_BLOCK = {
|
|
|
764
1336
|
]
|
|
765
1337
|
};
|
|
766
1338
|
//#endregion
|
|
767
|
-
//#region src/
|
|
1339
|
+
//#region src/ui/tui/decks/posthog-integration/line-chart.tsx
|
|
768
1340
|
/**
|
|
769
1341
|
* LINE_CHART_BLOCK — ASCII trends chart illustrating an insight.
|
|
770
1342
|
*/
|
|
@@ -888,7 +1460,7 @@ const LINE_CHART_BLOCK = {
|
|
|
888
1460
|
]
|
|
889
1461
|
};
|
|
890
1462
|
//#endregion
|
|
891
|
-
//#region src/
|
|
1463
|
+
//#region src/ui/tui/decks/posthog-integration/funnel.tsx
|
|
892
1464
|
/**
|
|
893
1465
|
* FUNNEL_BLOCK — ASCII funnel illustrating step conversion.
|
|
894
1466
|
*/
|
|
@@ -1068,7 +1640,7 @@ const FUNNEL_BLOCK = {
|
|
|
1068
1640
|
]
|
|
1069
1641
|
};
|
|
1070
1642
|
//#endregion
|
|
1071
|
-
//#region src/
|
|
1643
|
+
//#region src/ui/tui/decks/posthog-integration/index.tsx
|
|
1072
1644
|
/**
|
|
1073
1645
|
* Integration learn-deck — the narrative script played while the agent
|
|
1074
1646
|
* runs the PostHog integration flow. Weaves typewriter lines, pauses,
|
|
@@ -1257,7 +1829,7 @@ const getContentBlocks$5 = (store) => [
|
|
|
1257
1829
|
}
|
|
1258
1830
|
];
|
|
1259
1831
|
//#endregion
|
|
1260
|
-
//#region src/
|
|
1832
|
+
//#region src/programs/posthog-integration/handoff.ts
|
|
1261
1833
|
/**
|
|
1262
1834
|
* The one-line prompt the operator pastes into their own coding agent after a
|
|
1263
1835
|
* run: open the setup-report notebook, work its "Verify before merging"
|
|
@@ -1271,7 +1843,7 @@ function buildCodingAgentPrompt(notebookUrl) {
|
|
|
1271
1843
|
return `Open ${notebookUrl} (the PostHog setup report) and work through its "Verify before merging" checklist: investigate each item, then list the changes you'd make and get my approval before applying any of them.`;
|
|
1272
1844
|
}
|
|
1273
1845
|
//#endregion
|
|
1274
|
-
//#region src/
|
|
1846
|
+
//#region src/programs/posthog-integration/index.ts
|
|
1275
1847
|
const DASHBOARD_DEEP_LINK_KEY = "dashboardDeepLink";
|
|
1276
1848
|
const WAREHOUSE_SOURCES_DOCS_URL = "https://posthog.com/docs/data-warehouse/sources";
|
|
1277
1849
|
/** Task type of the seeded step below, matched against the drain's result. */
|
|
@@ -1428,8 +2000,8 @@ const posthogIntegrationConfig = {
|
|
|
1428
2000
|
disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk],
|
|
1429
2001
|
seedTasks: warehouseSeedTasks,
|
|
1430
2002
|
excludedTaskTypes: (flags) => flags["wizard-default-aio-logs"] === "false" ? ["ai-observability", "logs"] : [],
|
|
1431
|
-
ciPreRun: async (session) => {
|
|
1432
|
-
await scopeInstallDirToProject(session);
|
|
2003
|
+
ciPreRun: async (session, runner) => {
|
|
2004
|
+
await scopeInstallDirToProject(session, runner);
|
|
1433
2005
|
const integration = await detectFramework(session.installDir);
|
|
1434
2006
|
if (!integration) {
|
|
1435
2007
|
await wizardAbort({
|
|
@@ -1452,7 +2024,7 @@ const posthogIntegrationConfig = {
|
|
|
1452
2024
|
});
|
|
1453
2025
|
for (const [key, value] of Object.entries(context)) if (!(key in session.frameworkContext)) session.frameworkContext[key] = value;
|
|
1454
2026
|
},
|
|
1455
|
-
run: async (session) => {
|
|
2027
|
+
run: async (session, runner) => {
|
|
1456
2028
|
const config = session.frameworkConfig;
|
|
1457
2029
|
const typeScriptDetected = isUsingTypeScript({ installDir: session.installDir });
|
|
1458
2030
|
session.typescript = typeScriptDetected;
|
|
@@ -1462,10 +2034,10 @@ const posthogIntegrationConfig = {
|
|
|
1462
2034
|
if (usesPackageJson) {
|
|
1463
2035
|
const packageJson = await tryGetPackageJson({ installDir: session.installDir });
|
|
1464
2036
|
if (packageJson) {
|
|
1465
|
-
const { hasDeclaredDependency } = await import("./package-json-
|
|
1466
|
-
if (!hasDeclaredDependency(config.detection.packageName, packageJson))
|
|
2037
|
+
const { hasDeclaredDependency } = await import("./package-json-D8Ga03tK.js");
|
|
2038
|
+
if (!hasDeclaredDependency(config.detection.packageName, packageJson)) runner.log.warn(`${config.detection.packageDisplayName} does not seem to be installed. Continuing anyway — the agent will handle it.`);
|
|
1467
2039
|
frameworkVersion = config.detection.getVersion(packageJson);
|
|
1468
|
-
} else
|
|
2040
|
+
} else runner.log.warn("Could not find package.json. Continuing anyway — the agent will handle it.");
|
|
1469
2041
|
} else frameworkVersion = config.detection.getVersion(null);
|
|
1470
2042
|
if (frameworkVersion && config.detection.getVersionBucket) {
|
|
1471
2043
|
const versionBucket = config.detection.getVersionBucket(frameworkVersion);
|
|
@@ -1531,7 +2103,7 @@ ${warehouseReportInstruction(session)}
|
|
|
1531
2103
|
postRun: async (sess, credentials) => {
|
|
1532
2104
|
const envVars = config.environment.getEnvVars(credentials.projectApiKey, credentials.host.apiHost);
|
|
1533
2105
|
if (config.environment.uploadToHosting) {
|
|
1534
|
-
const { uploadEnvironmentVariablesStep } = await import("./steps-
|
|
2106
|
+
const { uploadEnvironmentVariablesStep } = await import("./steps-BPcg3_3Q.js");
|
|
1535
2107
|
const uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {
|
|
1536
2108
|
integration: config.metadata.integration,
|
|
1537
2109
|
session: sess
|
|
@@ -1586,7 +2158,7 @@ const integrationRunStep = {
|
|
|
1586
2158
|
isComplete: (session) => session.runPhase === "completed" || session.runPhase === "error"
|
|
1587
2159
|
};
|
|
1588
2160
|
//#endregion
|
|
1589
|
-
//#region src/
|
|
2161
|
+
//#region src/programs/revenue-analytics/detect.ts
|
|
1590
2162
|
/**
|
|
1591
2163
|
* Revenue analytics prerequisite detection.
|
|
1592
2164
|
*
|
|
@@ -1679,7 +2251,7 @@ function detectRevenuePrerequisites(session, setFrameworkContext) {
|
|
|
1679
2251
|
setFrameworkContext("detectedPackagePaths", matches.filter((m) => m.posthogSdks.length > 0 || m.stripeSdks.length > 0).map((m) => m.path));
|
|
1680
2252
|
}
|
|
1681
2253
|
//#endregion
|
|
1682
|
-
//#region src/
|
|
2254
|
+
//#region src/programs/revenue-analytics/steps.ts
|
|
1683
2255
|
const REVENUE_ANALYTICS_PROGRAM = [
|
|
1684
2256
|
{
|
|
1685
2257
|
id: "detect",
|
|
@@ -1718,7 +2290,7 @@ const REVENUE_ANALYTICS_PROGRAM = [
|
|
|
1718
2290
|
}
|
|
1719
2291
|
];
|
|
1720
2292
|
//#endregion
|
|
1721
|
-
//#region src/
|
|
2293
|
+
//#region src/ui/tui/decks/agent-skill/index.tsx
|
|
1722
2294
|
/**
|
|
1723
2295
|
* Agent-skill learn-deck — the short three-line sequence shown while a
|
|
1724
2296
|
* skill-based program (audit, revenue-analytics, agent-skill, etc.)
|
|
@@ -1750,7 +2322,7 @@ const getContentBlocks$4 = (store) => {
|
|
|
1750
2322
|
];
|
|
1751
2323
|
};
|
|
1752
2324
|
//#endregion
|
|
1753
|
-
//#region src/
|
|
2325
|
+
//#region src/programs/revenue-analytics/index.ts
|
|
1754
2326
|
const revenueAnalyticsConfig = {
|
|
1755
2327
|
command: "revenue-analytics",
|
|
1756
2328
|
description: "Set up PostHog for Revenue Analytics",
|
|
@@ -1774,7 +2346,7 @@ const revenueAnalyticsConfig = {
|
|
|
1774
2346
|
requires: ["posthog-integration"]
|
|
1775
2347
|
};
|
|
1776
2348
|
//#endregion
|
|
1777
|
-
//#region src/
|
|
2349
|
+
//#region src/programs/warehouse-source/steps.ts
|
|
1778
2350
|
const WAREHOUSE_SOURCE_PROGRAM = [
|
|
1779
2351
|
{
|
|
1780
2352
|
id: "detect",
|
|
@@ -1812,7 +2384,7 @@ const WAREHOUSE_SOURCE_PROGRAM = [
|
|
|
1812
2384
|
}
|
|
1813
2385
|
];
|
|
1814
2386
|
//#endregion
|
|
1815
|
-
//#region src/
|
|
2387
|
+
//#region src/programs/warehouse-source/index.ts
|
|
1816
2388
|
/**
|
|
1817
2389
|
* Inject the detected sources (and their creation mode) into the prompt so the
|
|
1818
2390
|
* skill knows what to set up. The *how* — in-CLI creation vs deep-link, field
|
|
@@ -1855,7 +2427,7 @@ const warehouseSourceConfig = {
|
|
|
1855
2427
|
requires: ["posthog-integration"]
|
|
1856
2428
|
};
|
|
1857
2429
|
//#endregion
|
|
1858
|
-
//#region src/
|
|
2430
|
+
//#region src/programs/agent-skill/steps.ts
|
|
1859
2431
|
const AGENT_SKILL_STEPS = [
|
|
1860
2432
|
{
|
|
1861
2433
|
id: "intro",
|
|
@@ -1889,7 +2461,7 @@ const AGENT_SKILL_STEPS = [
|
|
|
1889
2461
|
}
|
|
1890
2462
|
];
|
|
1891
2463
|
//#endregion
|
|
1892
|
-
//#region src/
|
|
2464
|
+
//#region src/programs/agent-skill/index.ts
|
|
1893
2465
|
function createSkillProgram(opts) {
|
|
1894
2466
|
return {
|
|
1895
2467
|
command: opts.command,
|
|
@@ -1915,7 +2487,7 @@ function createSkillProgram(opts) {
|
|
|
1915
2487
|
};
|
|
1916
2488
|
}
|
|
1917
2489
|
//#endregion
|
|
1918
|
-
//#region src/
|
|
2490
|
+
//#region src/programs/audit/detect.ts
|
|
1919
2491
|
/** `[ABORT] <reason>` cases the audit skill can emit. Reason strings are
|
|
1920
2492
|
* defined in the skill's `Abort statuses` section. */
|
|
1921
2493
|
const AUDIT_ABORT_CASES = [{
|
|
@@ -1926,7 +2498,7 @@ const AUDIT_ABORT_CASES = [{
|
|
|
1926
2498
|
docsUrl: "https://posthog.com/docs/getting-started/install"
|
|
1927
2499
|
}];
|
|
1928
2500
|
//#endregion
|
|
1929
|
-
//#region src/
|
|
2501
|
+
//#region src/programs/audit/seed.ts
|
|
1930
2502
|
/**
|
|
1931
2503
|
* The 10 source-tree checks the audit runs, plus one row for the PostHog-side
|
|
1932
2504
|
* sweep and two workflow rows at the end (so the skill's
|
|
@@ -2042,7 +2614,7 @@ function seedAuditLedger(installDir, checks = AUDIT_SEED_CHECKS) {
|
|
|
2042
2614
|
logToFile(`seedAuditLedger: wrote ${checks.length} entries to ${target}`);
|
|
2043
2615
|
}
|
|
2044
2616
|
//#endregion
|
|
2045
|
-
//#region src/
|
|
2617
|
+
//#region src/programs/audit/index.ts
|
|
2046
2618
|
/** Audit-specific screens for the shared agent-skill pipeline. */
|
|
2047
2619
|
const AUDIT_SCREEN_BY_STEP = {
|
|
2048
2620
|
intro: "audit-intro",
|
|
@@ -2076,10 +2648,10 @@ const baseConfig = createSkillProgram({
|
|
|
2076
2648
|
requires: ["posthog-integration"],
|
|
2077
2649
|
abortCases: AUDIT_ABORT_CASES
|
|
2078
2650
|
});
|
|
2079
|
-
const auditRun = async (session) => {
|
|
2651
|
+
const auditRun = async (session, runner) => {
|
|
2080
2652
|
seedBeforeAuditRun(session);
|
|
2081
2653
|
if (!baseConfig.run) throw new Error("Audit program has no run configuration.");
|
|
2082
|
-
const baseRun = typeof baseConfig.run === "function" ? await baseConfig.run(session) : baseConfig.run;
|
|
2654
|
+
const baseRun = typeof baseConfig.run === "function" ? await baseConfig.run(session, runner) : baseConfig.run;
|
|
2083
2655
|
return {
|
|
2084
2656
|
...baseRun,
|
|
2085
2657
|
buildOutroData: (sess, credentials) => {
|
|
@@ -2115,7 +2687,7 @@ const auditConfig = {
|
|
|
2115
2687
|
}
|
|
2116
2688
|
};
|
|
2117
2689
|
//#endregion
|
|
2118
|
-
//#region src/
|
|
2690
|
+
//#region src/programs/events-audit/steps.ts
|
|
2119
2691
|
function needsSetup(session) {
|
|
2120
2692
|
const config = session.frameworkConfig;
|
|
2121
2693
|
if (!config?.metadata.setup?.questions) return false;
|
|
@@ -2167,7 +2739,7 @@ const EVENTS_AUDIT_PROGRAM = [
|
|
|
2167
2739
|
}
|
|
2168
2740
|
];
|
|
2169
2741
|
//#endregion
|
|
2170
|
-
//#region src/
|
|
2742
|
+
//#region src/programs/events-audit/seed.ts
|
|
2171
2743
|
/**
|
|
2172
2744
|
* The 7 phases the events-audit skill marches through. One check per area
|
|
2173
2745
|
* so PendingChecksList renders a clean linear pipeline (area = bold header,
|
|
@@ -2223,7 +2795,7 @@ const EVENTS_AUDIT_SEED_CHECKS = [
|
|
|
2223
2795
|
}
|
|
2224
2796
|
];
|
|
2225
2797
|
//#endregion
|
|
2226
|
-
//#region src/
|
|
2798
|
+
//#region src/programs/events-audit/index.ts
|
|
2227
2799
|
const DOCS_URL$3 = "https://posthog.com/docs/product-analytics/best-practices";
|
|
2228
2800
|
/**
|
|
2229
2801
|
* No CLI word of its own since the audit family took over: `wizard audit
|
|
@@ -2284,7 +2856,7 @@ Project context:
|
|
|
2284
2856
|
}
|
|
2285
2857
|
};
|
|
2286
2858
|
//#endregion
|
|
2287
|
-
//#region src/
|
|
2859
|
+
//#region src/programs/posthog-doctor/steps.ts
|
|
2288
2860
|
const POSTHOG_DOCTOR_PROGRAM = [
|
|
2289
2861
|
{
|
|
2290
2862
|
id: "intro",
|
|
@@ -2313,7 +2885,7 @@ const POSTHOG_DOCTOR_PROGRAM = [
|
|
|
2313
2885
|
}
|
|
2314
2886
|
];
|
|
2315
2887
|
//#endregion
|
|
2316
|
-
//#region src/
|
|
2888
|
+
//#region src/programs/posthog-doctor/types.ts
|
|
2317
2889
|
const HealthIssueSeveritySchema = z.enum([
|
|
2318
2890
|
"critical",
|
|
2319
2891
|
"warning",
|
|
@@ -2337,7 +2909,7 @@ const HealthIssueListResponseSchema = z.object({
|
|
|
2337
2909
|
previous: z.string().nullable().optional()
|
|
2338
2910
|
});
|
|
2339
2911
|
//#endregion
|
|
2340
|
-
//#region src/
|
|
2912
|
+
//#region src/programs/posthog-doctor/fetch.ts
|
|
2341
2913
|
async function fetchHealthIssues(accessToken, baseUrl, projectId) {
|
|
2342
2914
|
const endpoint = `/api/environments/${projectId}/health_issues/`;
|
|
2343
2915
|
const url = `${baseUrl}${endpoint}?status=active&dismissed=false&limit=250`;
|
|
@@ -2358,7 +2930,7 @@ async function fetchHealthIssues(accessToken, baseUrl, projectId) {
|
|
|
2358
2930
|
}
|
|
2359
2931
|
}
|
|
2360
2932
|
//#endregion
|
|
2361
|
-
//#region src/
|
|
2933
|
+
//#region src/programs/posthog-doctor/kind-metadata.ts
|
|
2362
2934
|
const KIND_METADATA = {
|
|
2363
2935
|
ingestion_lag: {
|
|
2364
2936
|
title: "Ingestion is delayed",
|
|
@@ -2428,7 +3000,7 @@ function getKindMeta(kind) {
|
|
|
2428
3000
|
};
|
|
2429
3001
|
}
|
|
2430
3002
|
//#endregion
|
|
2431
|
-
//#region src/
|
|
3003
|
+
//#region src/programs/posthog-doctor/index.ts
|
|
2432
3004
|
const posthogDoctorConfig = {
|
|
2433
3005
|
command: "doctor",
|
|
2434
3006
|
description: "Diagnose your PostHog project setup",
|
|
@@ -2439,7 +3011,7 @@ const posthogDoctorConfig = {
|
|
|
2439
3011
|
disallowedTools: [WIZARD_TOOL_NAMES.wizardAsk]
|
|
2440
3012
|
};
|
|
2441
3013
|
//#endregion
|
|
2442
|
-
//#region src/
|
|
3014
|
+
//#region src/programs/web-analytics-doctor/detect.ts
|
|
2443
3015
|
const WEB_ANALYTICS_ABORT_CASES = [
|
|
2444
3016
|
{
|
|
2445
3017
|
match: /^no web analytics events$/i,
|
|
@@ -2506,7 +3078,7 @@ function detectWebAnalyticsPrerequisites(session, setFrameworkContext) {
|
|
|
2506
3078
|
setFrameworkContext("detectedPosthogSdks", sdks);
|
|
2507
3079
|
}
|
|
2508
3080
|
//#endregion
|
|
2509
|
-
//#region src/
|
|
3081
|
+
//#region src/programs/web-analytics-doctor/steps.ts
|
|
2510
3082
|
const WEB_ANALYTICS_DOCTOR_PROGRAM = [{
|
|
2511
3083
|
id: "detect",
|
|
2512
3084
|
label: "Detecting prerequisites",
|
|
@@ -2532,7 +3104,7 @@ const webAnalyticsDoctorConfig = {
|
|
|
2532
3104
|
parentCommand: "audit"
|
|
2533
3105
|
};
|
|
2534
3106
|
//#endregion
|
|
2535
|
-
//#region src/
|
|
3107
|
+
//#region src/programs/migration/steps.ts
|
|
2536
3108
|
const MIGRATION_PROGRAM = [
|
|
2537
3109
|
{
|
|
2538
3110
|
id: "intro",
|
|
@@ -2566,7 +3138,7 @@ const MIGRATION_PROGRAM = [
|
|
|
2566
3138
|
}
|
|
2567
3139
|
];
|
|
2568
3140
|
//#endregion
|
|
2569
|
-
//#region src/
|
|
3141
|
+
//#region src/ui/tui/decks/migration/vendor-stack.tsx
|
|
2570
3142
|
/**
|
|
2571
3143
|
* Vendor cost stack — the multi-tool baseline a typical migration target has
|
|
2572
3144
|
* before consolidating onto PostHog. Numbers from each vendor's published
|
|
@@ -2646,7 +3218,7 @@ const VENDOR_STACK_BLOCK = {
|
|
|
2646
3218
|
]
|
|
2647
3219
|
};
|
|
2648
3220
|
//#endregion
|
|
2649
|
-
//#region src/
|
|
3221
|
+
//#region src/ui/tui/decks/migration/free-tier.tsx
|
|
2650
3222
|
/**
|
|
2651
3223
|
* PostHog free-tier highlights — the numbers a migrating team gets back when
|
|
2652
3224
|
* they consolidate. Sourced from posthog.com/pricing.md.
|
|
@@ -2752,7 +3324,7 @@ const FREE_TIER_BLOCK = {
|
|
|
2752
3324
|
]
|
|
2753
3325
|
};
|
|
2754
3326
|
//#endregion
|
|
2755
|
-
//#region src/
|
|
3327
|
+
//#region src/ui/tui/decks/migration/pricing-structure.tsx
|
|
2756
3328
|
/**
|
|
2757
3329
|
* Pricing structure block — what happens after the free tier.
|
|
2758
3330
|
*/
|
|
@@ -2793,7 +3365,7 @@ const PRICING_STRUCTURE_BLOCK = {
|
|
|
2793
3365
|
]
|
|
2794
3366
|
};
|
|
2795
3367
|
//#endregion
|
|
2796
|
-
//#region src/
|
|
3368
|
+
//#region src/ui/tui/decks/migration/index.tsx
|
|
2797
3369
|
/**
|
|
2798
3370
|
* Migration learn deck (statsig variant). Statsig is the only `migrate`
|
|
2799
3371
|
* variant today, so this deck plays as-is when the wizard runs
|
|
@@ -3041,7 +3613,7 @@ const getContentBlocks$3 = (store) => [
|
|
|
3041
3613
|
FUNNEL_BLOCK
|
|
3042
3614
|
];
|
|
3043
3615
|
//#endregion
|
|
3044
|
-
//#region src/
|
|
3616
|
+
//#region src/programs/migration/index.ts
|
|
3045
3617
|
const MIGRATION_REPORT_FILE = "migration-report.md";
|
|
3046
3618
|
const MIGRATION_ABORT_CASES = [{
|
|
3047
3619
|
match: /^no source-sdk calls found$/i,
|
|
@@ -3073,7 +3645,7 @@ const migrationConfig = {
|
|
|
3073
3645
|
requires: ["posthog-integration"]
|
|
3074
3646
|
};
|
|
3075
3647
|
//#endregion
|
|
3076
|
-
//#region src/
|
|
3648
|
+
//#region src/programs/error-tracking-upload-source-maps/detect.ts
|
|
3077
3649
|
const DISPLAY_NAME = {
|
|
3078
3650
|
web: "Web (JavaScript)",
|
|
3079
3651
|
nextjs: "Next.js",
|
|
@@ -3182,7 +3754,7 @@ const SOURCE_MAPS_CONTEXT_KEYS = {
|
|
|
3182
3754
|
selectedPath: "sourceMapsSelectedPath"
|
|
3183
3755
|
};
|
|
3184
3756
|
//#endregion
|
|
3185
|
-
//#region src/
|
|
3757
|
+
//#region src/programs/error-tracking-upload-source-maps/steps.ts
|
|
3186
3758
|
function projectSelected(session) {
|
|
3187
3759
|
return session.frameworkContext[SOURCE_MAPS_CONTEXT_KEYS.selectedVariant] != null;
|
|
3188
3760
|
}
|
|
@@ -3225,7 +3797,7 @@ const ERROR_TRACKING_UPLOAD_SOURCE_MAPS_PROGRAM = [
|
|
|
3225
3797
|
}
|
|
3226
3798
|
];
|
|
3227
3799
|
//#endregion
|
|
3228
|
-
//#region src/
|
|
3800
|
+
//#region src/programs/error-tracking-upload-source-maps/prompt.ts
|
|
3229
3801
|
const SOURCE_MAPS_DETECTION_FAILED_PROMPT = `Detection did not pick a source maps skill variant for this project.
|
|
3230
3802
|
Emit: ${AgentSignals.ABORT} unsupported-platform
|
|
3231
3803
|
Then halt.`;
|
|
@@ -3423,7 +3995,7 @@ STEP 9 — Summarise and hand off. (skill: "Verify and hand off")
|
|
|
3423
3995
|
`;
|
|
3424
3996
|
}
|
|
3425
3997
|
//#endregion
|
|
3426
|
-
//#region src/
|
|
3998
|
+
//#region src/ui/tui/decks/error-tracking-upload-source-maps/index.tsx
|
|
3427
3999
|
/**
|
|
3428
4000
|
* Source-maps learn-deck — the narrative played in the run screen's left
|
|
3429
4001
|
* pane (LearnCard) while the agent wires source-map upload into the build.
|
|
@@ -3860,18 +4432,9 @@ function installSteeringSnippet(filePath) {
|
|
|
3860
4432
|
};
|
|
3861
4433
|
}
|
|
3862
4434
|
//#endregion
|
|
3863
|
-
//#region src/
|
|
3864
|
-
/**
|
|
3865
|
-
* Machine-global posthog-cli pre-install, shared by the programs whose symbol
|
|
3866
|
-
* upload shells out to it (error-tracking and error-tracking-upload-source-maps).
|
|
3867
|
-
*
|
|
3868
|
-
* The agent cannot install a global package — warlock blocks `npm install -g`
|
|
3869
|
-
* — so the wizard does it in-process, at most once per process. Warn, don't
|
|
3870
|
-
* fail: the run still instruments capture, and only the release build's upload
|
|
3871
|
-
* needs the CLI.
|
|
3872
|
-
*/
|
|
4435
|
+
//#region src/programs/shared/posthog-cli-preinstall.ts
|
|
3873
4436
|
let attempted = false;
|
|
3874
|
-
function preinstallPostHogCliOnce(failureEvent, properties) {
|
|
4437
|
+
function preinstallPostHogCliOnce(failureEvent, properties, log) {
|
|
3875
4438
|
if (attempted) return;
|
|
3876
4439
|
attempted = true;
|
|
3877
4440
|
const result = installOrUpdatePostHogCli();
|
|
@@ -3880,10 +4443,10 @@ function preinstallPostHogCliOnce(failureEvent, properties) {
|
|
|
3880
4443
|
...properties,
|
|
3881
4444
|
error: String(result.error).slice(0, 500)
|
|
3882
4445
|
});
|
|
3883
|
-
|
|
4446
|
+
log.warn(`Could not pre-install posthog-cli (${result.error}). Your release build will fail to upload debug symbols until it's installed: npm install -g @posthog/cli@latest`);
|
|
3884
4447
|
}
|
|
3885
4448
|
//#endregion
|
|
3886
|
-
//#region src/
|
|
4449
|
+
//#region src/programs/error-tracking-upload-source-maps/index.ts
|
|
3887
4450
|
const REPORT_FILE$1 = "posthog-source-maps-report.md";
|
|
3888
4451
|
const DOCS_URL$1 = "https://posthog.com/docs/error-tracking/upload-source-maps";
|
|
3889
4452
|
/**
|
|
@@ -3891,8 +4454,8 @@ const DOCS_URL$1 = "https://posthog.com/docs/error-tracking/upload-source-maps";
|
|
|
3891
4454
|
* (`VARIANTS_REQUIRING_POSTHOG_CLI`). See `preinstallPostHogCliOnce` for the
|
|
3892
4455
|
* once-per-process guard and the warn-don't-fail handling.
|
|
3893
4456
|
*/
|
|
3894
|
-
function ensurePostHogCli(variant) {
|
|
3895
|
-
preinstallPostHogCliOnce("source maps posthog-cli preinstall failed", { variant });
|
|
4457
|
+
function ensurePostHogCli(variant, log) {
|
|
4458
|
+
preinstallPostHogCliOnce("source maps posthog-cli preinstall failed", { variant }, log);
|
|
3896
4459
|
}
|
|
3897
4460
|
const errorTrackingUploadSourceMapsConfig = {
|
|
3898
4461
|
command: "upload-source-maps",
|
|
@@ -3903,13 +4466,13 @@ const errorTrackingUploadSourceMapsConfig = {
|
|
|
3903
4466
|
reportFile: REPORT_FILE$1,
|
|
3904
4467
|
getContentBlocks: getContentBlocks$2,
|
|
3905
4468
|
requires: ["posthog-integration"],
|
|
3906
|
-
run: (_session) => {
|
|
4469
|
+
run: (_session, runner) => {
|
|
3907
4470
|
const readSelection = () => {
|
|
3908
|
-
const variant =
|
|
4471
|
+
const variant = runner.getFrameworkContext(SOURCE_MAPS_CONTEXT_KEYS.selectedVariant);
|
|
3909
4472
|
return {
|
|
3910
4473
|
variant,
|
|
3911
|
-
displayName:
|
|
3912
|
-
projectPath:
|
|
4474
|
+
displayName: runner.getFrameworkContext(SOURCE_MAPS_CONTEXT_KEYS.selectedDisplayName),
|
|
4475
|
+
projectPath: runner.getFrameworkContext(SOURCE_MAPS_CONTEXT_KEYS.selectedPath),
|
|
3913
4476
|
skillId: variant ? `error-tracking-upload-source-maps-${variant}` : void 0
|
|
3914
4477
|
};
|
|
3915
4478
|
};
|
|
@@ -3925,7 +4488,7 @@ const errorTrackingUploadSourceMapsConfig = {
|
|
|
3925
4488
|
customPrompt: (ctx) => {
|
|
3926
4489
|
const { variant, displayName, projectPath, skillId } = readSelection();
|
|
3927
4490
|
if (!skillId || !variant) return SOURCE_MAPS_DETECTION_FAILED_PROMPT;
|
|
3928
|
-
if (VARIANTS_REQUIRING_POSTHOG_CLI.has(variant)) ensurePostHogCli(variant);
|
|
4491
|
+
if (VARIANTS_REQUIRING_POSTHOG_CLI.has(variant)) ensurePostHogCli(variant, runner.log);
|
|
3929
4492
|
const uiHost = ctx.host.appHost.replace(/\/$/, "");
|
|
3930
4493
|
return buildSourceMapsUploadPrompt({
|
|
3931
4494
|
displayName,
|
|
@@ -3941,7 +4504,7 @@ const errorTrackingUploadSourceMapsConfig = {
|
|
|
3941
4504
|
},
|
|
3942
4505
|
postRun: () => {
|
|
3943
4506
|
const { variant } = readSelection();
|
|
3944
|
-
if (variant)
|
|
4507
|
+
if (variant) runner.setFrameworkContext("sourceMapsCompletedVariant", variant);
|
|
3945
4508
|
return Promise.resolve();
|
|
3946
4509
|
},
|
|
3947
4510
|
buildOutroData: () => {
|
|
@@ -3956,13 +4519,13 @@ const errorTrackingUploadSourceMapsConfig = {
|
|
|
3956
4519
|
}
|
|
3957
4520
|
};
|
|
3958
4521
|
//#endregion
|
|
3959
|
-
//#region src/
|
|
4522
|
+
//#region src/ui/tui/decks/error-tracking/index.tsx
|
|
3960
4523
|
const getContentBlocks$1 = (store) => buildSourceMapsDeck(store, {
|
|
3961
4524
|
intro: "I'm wiring PostHog Error Tracking into your project.",
|
|
3962
4525
|
wiring: "If your platform ships minified code or stripped binaries, I also hook source-map or debug-symbol upload into your build, tied to each release you ship."
|
|
3963
4526
|
});
|
|
3964
4527
|
//#endregion
|
|
3965
|
-
//#region src/
|
|
4528
|
+
//#region src/programs/replay-vision/index.ts
|
|
3966
4529
|
const REPLAY_VISION_REPORT_FILE = "posthog-replay-vision-report.md";
|
|
3967
4530
|
/**
|
|
3968
4531
|
* The platforms session replay can actually record on. Replay vision watches
|
|
@@ -4075,8 +4638,8 @@ const replayVisionConfig = {
|
|
|
4075
4638
|
}),
|
|
4076
4639
|
agentFlow: "replay-vision",
|
|
4077
4640
|
steps: [DETECT_STEP, ...AGENT_SKILL_STEPS],
|
|
4078
|
-
ciPreRun: async (session) => {
|
|
4079
|
-
await scopeInstallDirToProject(session);
|
|
4641
|
+
ciPreRun: async (session, runner) => {
|
|
4642
|
+
await scopeInstallDirToProject(session, runner);
|
|
4080
4643
|
const integration = await detectFramework(session.installDir);
|
|
4081
4644
|
if (!integration) {
|
|
4082
4645
|
await wizardAbort({
|
|
@@ -4106,7 +4669,7 @@ const replayVisionConfig = {
|
|
|
4106
4669
|
}
|
|
4107
4670
|
};
|
|
4108
4671
|
//#endregion
|
|
4109
|
-
//#region src/
|
|
4672
|
+
//#region src/ui/tui/decks/error-tracking/tips.ts
|
|
4110
4673
|
const ERROR_TRACKING_TIPS = [
|
|
4111
4674
|
{
|
|
4112
4675
|
id: "session-replay",
|
|
@@ -4130,7 +4693,7 @@ const ERROR_TRACKING_TIPS = [
|
|
|
4130
4693
|
];
|
|
4131
4694
|
const getTips$1 = () => ERROR_TRACKING_TIPS;
|
|
4132
4695
|
//#endregion
|
|
4133
|
-
//#region src/
|
|
4696
|
+
//#region src/programs/error-tracking/detect-agentic.ts
|
|
4134
4697
|
/** frameworkContext key for the picked project's path, relative to the repo root. */
|
|
4135
4698
|
const ERROR_TRACKING_PROJECT_PATH_KEY = "errorTrackingProjectPath";
|
|
4136
4699
|
/** KMP skill variants carry no `framework` tag, so orchestrator preflight aborts every KMP run. */
|
|
@@ -4175,7 +4738,7 @@ async function gatherErrorTrackingContext(session) {
|
|
|
4175
4738
|
for (const [key, value] of Object.entries(context)) if (!(key in session.frameworkContext)) session.frameworkContext[key] = value;
|
|
4176
4739
|
}
|
|
4177
4740
|
//#endregion
|
|
4178
|
-
//#region src/
|
|
4741
|
+
//#region src/programs/error-tracking/index.ts
|
|
4179
4742
|
const ERROR_TRACKING_REPORT_FILE = "posthog-error-tracking-report.md";
|
|
4180
4743
|
const ERROR_TRACKING_DOCS_URL = "https://posthog.com/docs/error-tracking";
|
|
4181
4744
|
/**
|
|
@@ -4207,9 +4770,9 @@ async function abortUnsupportedPlatform(integration) {
|
|
|
4207
4770
|
* shell out to it. See `preinstallPostHogCliOnce` for the once-per-process
|
|
4208
4771
|
* guard and the warn-don't-fail handling.
|
|
4209
4772
|
*/
|
|
4210
|
-
function maybePreinstallPostHogCli(integration) {
|
|
4773
|
+
function maybePreinstallPostHogCli(integration, log) {
|
|
4211
4774
|
if (!integration || !SYMBOL_UPLOAD_CLI_FRAMEWORKS.has(integration)) return;
|
|
4212
|
-
preinstallPostHogCliOnce("error tracking posthog-cli preinstall failed", { integration });
|
|
4775
|
+
preinstallPostHogCliOnce("error tracking posthog-cli preinstall failed", { integration }, log);
|
|
4213
4776
|
}
|
|
4214
4777
|
/**
|
|
4215
4778
|
* After login, the scan lists the repo's projects and the user picks one, as in
|
|
@@ -4304,12 +4867,12 @@ const errorTrackingConfig = {
|
|
|
4304
4867
|
reportFile: ERROR_TRACKING_REPORT_FILE,
|
|
4305
4868
|
getContentBlocks: getContentBlocks$1,
|
|
4306
4869
|
getTips: getTips$1,
|
|
4307
|
-
run: (session) => {
|
|
4308
|
-
maybePreinstallPostHogCli(session.integration);
|
|
4870
|
+
run: (session, runner) => {
|
|
4871
|
+
maybePreinstallPostHogCli(session.integration, runner.log);
|
|
4309
4872
|
return Promise.resolve(ERROR_TRACKING_RUN);
|
|
4310
4873
|
},
|
|
4311
|
-
ciPreRun: async (session) => {
|
|
4312
|
-
await scopeInstallDirToProject(session);
|
|
4874
|
+
ciPreRun: async (session, runner) => {
|
|
4875
|
+
await scopeInstallDirToProject(session, runner);
|
|
4313
4876
|
const integration = await detectFramework(session.installDir);
|
|
4314
4877
|
if (!integration) {
|
|
4315
4878
|
await wizardAbort({
|
|
@@ -4330,7 +4893,7 @@ const errorTrackingConfig = {
|
|
|
4330
4893
|
}
|
|
4331
4894
|
};
|
|
4332
4895
|
//#endregion
|
|
4333
|
-
//#region src/
|
|
4896
|
+
//#region src/programs/self-driving/detect.ts
|
|
4334
4897
|
/**
|
|
4335
4898
|
* Self-driving prerequisite detection + abort vocabulary.
|
|
4336
4899
|
*
|
|
@@ -4596,7 +5159,7 @@ function detectConnectedTools(installDir, setFrameworkContext) {
|
|
|
4596
5159
|
}
|
|
4597
5160
|
}
|
|
4598
5161
|
//#endregion
|
|
4599
|
-
//#region src/
|
|
5162
|
+
//#region src/programs/self-driving/detect-agentic.ts
|
|
4600
5163
|
function classify(integration, hasPostHog) {
|
|
4601
5164
|
if (integration == null) return {
|
|
4602
5165
|
instrumentable: false,
|
|
@@ -4651,7 +5214,7 @@ async function prepSelfDrivingIntegration(session) {
|
|
|
4651
5214
|
for (const [key, value] of Object.entries(context)) if (!(key in session.frameworkContext)) session.frameworkContext[key] = value;
|
|
4652
5215
|
}
|
|
4653
5216
|
//#endregion
|
|
4654
|
-
//#region src/
|
|
5217
|
+
//#region src/programs/self-driving/steps.ts
|
|
4655
5218
|
/** True once detection found PostHog already present in the project. */
|
|
4656
5219
|
const postHogPresent = (session) => session.frameworkContext[POSTHOG_PRESENT_KEY] === true;
|
|
4657
5220
|
/** Absolute dir to integrate into: the picked sub-app (LLM output — the shared resolver clamps escapes), else the repo root. */
|
|
@@ -4727,7 +5290,7 @@ const SELF_DRIVING_PROGRAM = [
|
|
|
4727
5290
|
}
|
|
4728
5291
|
];
|
|
4729
5292
|
//#endregion
|
|
4730
|
-
//#region src/
|
|
5293
|
+
//#region src/programs/self-driving/prompt.ts
|
|
4731
5294
|
/**
|
|
4732
5295
|
* Render the deterministic codebase-tool scan for the prompt. STEP 4 and
|
|
4733
5296
|
* STEP 5 read this instead of the agent doing its own flaky "light scan":
|
|
@@ -4930,7 +5493,7 @@ STEP 7 — Write the report and hand off. (skill: "Report")
|
|
|
4930
5493
|
at ${inboxUrl} within about 30 minutes.`;
|
|
4931
5494
|
}
|
|
4932
5495
|
//#endregion
|
|
4933
|
-
//#region src/
|
|
5496
|
+
//#region src/programs/self-driving/step-keys.ts
|
|
4934
5497
|
/**
|
|
4935
5498
|
* First match wins, so order is the rule. Entity words come before verbs: "Checking GitHub
|
|
4936
5499
|
* connection" is the GitHub step, not the access-check step, and "Connecting issue trackers" must
|
|
@@ -4999,7 +5562,7 @@ const PRICING_LONG = `A report that ships a pull request costs a flat $15. Every
|
|
|
4999
5562
|
*/
|
|
5000
5563
|
const NO_DEFAULT_LIMIT = "A paid plan has no monthly cap until you set one. Add a PR limit in your inbox sidebar, and agents pause when they hit it.";
|
|
5001
5564
|
//#endregion
|
|
5002
|
-
//#region src/
|
|
5565
|
+
//#region src/ui/tui/decks/self-driving/tips.ts
|
|
5003
5566
|
const SELF_DRIVING_TIPS = [
|
|
5004
5567
|
{
|
|
5005
5568
|
id: "signal-source",
|
|
@@ -5039,7 +5602,7 @@ const SELF_DRIVING_TIPS = [
|
|
|
5039
5602
|
];
|
|
5040
5603
|
const getTips = () => SELF_DRIVING_TIPS;
|
|
5041
5604
|
//#endregion
|
|
5042
|
-
//#region src/
|
|
5605
|
+
//#region src/ui/tui/decks/self-driving/pipeline-diagram.tsx
|
|
5043
5606
|
/**
|
|
5044
5607
|
* PIPELINE_BLOCK — ASCII diagram of the Self-driving loop: sources feed
|
|
5045
5608
|
* scouts, scouts raise signals, signals group into reports, reports land
|
|
@@ -5127,7 +5690,7 @@ const PIPELINE_BLOCK = {
|
|
|
5127
5690
|
]
|
|
5128
5691
|
};
|
|
5129
5692
|
//#endregion
|
|
5130
|
-
//#region src/
|
|
5693
|
+
//#region src/ui/tui/decks/self-driving/index.tsx
|
|
5131
5694
|
/**
|
|
5132
5695
|
* Self-driving learn-deck — the narrative script played while the agent
|
|
5133
5696
|
* sets up Self-driving. Teaches the vocabulary ladder (signal source →
|
|
@@ -5353,7 +5916,7 @@ const getContentBlocks = (store) => {
|
|
|
5353
5916
|
];
|
|
5354
5917
|
};
|
|
5355
5918
|
//#endregion
|
|
5356
|
-
//#region src/
|
|
5919
|
+
//#region src/programs/self-driving/index.ts
|
|
5357
5920
|
const SELF_DRIVING_SKILL_ID = "self-driving-setup";
|
|
5358
5921
|
const REPORT_FILE = "posthog-self-driving-report.md";
|
|
5359
5922
|
const DOCS_URL = "https://posthog.com/docs";
|
|
@@ -5440,7 +6003,7 @@ const selfDrivingConfig = {
|
|
|
5440
6003
|
getContentBlocks
|
|
5441
6004
|
};
|
|
5442
6005
|
//#endregion
|
|
5443
|
-
//#region src/
|
|
6006
|
+
//#region src/programs/mcp/index.ts
|
|
5444
6007
|
const mcpAddConfig = {
|
|
5445
6008
|
id: "mcp-add",
|
|
5446
6009
|
requiresAi: false,
|
|
@@ -5521,7 +6084,7 @@ const mcpTutorialConfig = {
|
|
|
5521
6084
|
}]
|
|
5522
6085
|
};
|
|
5523
6086
|
//#endregion
|
|
5524
|
-
//#region src/
|
|
6087
|
+
//#region src/programs/mcp-analytics/index.ts
|
|
5525
6088
|
const MCP_ANALYTICS_REPORT_FILE = "posthog-mcp-analytics-report.md";
|
|
5526
6089
|
/**
|
|
5527
6090
|
* `[ABORT]` reasons the mcp-analytics skill emits when the project can't be
|
|
@@ -5575,7 +6138,7 @@ const mcpAnalyticsConfig = createSkillProgram({
|
|
|
5575
6138
|
abortCases: MCP_ANALYTICS_ABORT_CASES
|
|
5576
6139
|
});
|
|
5577
6140
|
//#endregion
|
|
5578
|
-
//#region src/
|
|
6141
|
+
//#region src/programs/ai-observability/index.ts
|
|
5579
6142
|
const AI_OBSERVABILITY_STEPS = AGENT_SKILL_STEPS.map((step) => step.id === "intro" ? {
|
|
5580
6143
|
...step,
|
|
5581
6144
|
screenId: "ai-observability-intro"
|
|
@@ -5634,7 +6197,7 @@ final report is written to ./${AI_OBSERVABILITY_REPORT_FILE}.`,
|
|
|
5634
6197
|
}
|
|
5635
6198
|
};
|
|
5636
6199
|
//#endregion
|
|
5637
|
-
//#region src/
|
|
6200
|
+
//#region src/programs/metrics/index.ts
|
|
5638
6201
|
const METRICS_STEPS = AGENT_SKILL_STEPS.map((step) => step.id === "intro" ? {
|
|
5639
6202
|
...step,
|
|
5640
6203
|
screenId: "metrics-intro"
|
|
@@ -5698,7 +6261,7 @@ is written to ./${METRICS_REPORT_FILE}.`,
|
|
|
5698
6261
|
}
|
|
5699
6262
|
};
|
|
5700
6263
|
//#endregion
|
|
5701
|
-
//#region src/
|
|
6264
|
+
//#region src/programs/slack/index.ts
|
|
5702
6265
|
const slackConnectConfig = {
|
|
5703
6266
|
id: "slack",
|
|
5704
6267
|
description: "Connect PostHog to your Slack",
|
|
@@ -5710,7 +6273,7 @@ const slackConnectConfig = {
|
|
|
5710
6273
|
}]
|
|
5711
6274
|
};
|
|
5712
6275
|
//#endregion
|
|
5713
|
-
//#region src/
|
|
6276
|
+
//#region src/programs/program-registry.ts
|
|
5714
6277
|
const agentSkillConfig = {
|
|
5715
6278
|
id: "agent-skill",
|
|
5716
6279
|
description: "Run an arbitrary context-mill skill",
|
|
@@ -5824,6 +6387,6 @@ function isRunFailure(session) {
|
|
|
5824
6387
|
return session.outroData?.kind === "error" && session.credentials !== null;
|
|
5825
6388
|
}
|
|
5826
6389
|
//#endregion
|
|
5827
|
-
export { wordWrap as $, installOrUpdatePostHogCli as A, webAnalyticsDoctorConfig as B, ERROR_TRACKING_PROJECT_PATH_KEY as C, CLI_STEERING_TARGETS as D, errorTrackingUploadSourceMapsConfig as E, MANUAL_SDK_INSTALL as F, createSkillProgram as G, getKindMeta as H, MANUAL_SDK_VARIANTS as I, getContentBlocks$4 as J, warehouseSourceConfig as K, RUST_SDK_CRATE as L, AUTOMATABLE_VARIANTS as M, DISPLAY_NAME as N, detectTargets as O, GO_SDK_MODULE as P, computeVisibleRange as Q, SOURCE_MAPS_CONTEXT_KEYS as R, errorTrackingConfig as S, replayVisionConfig as T, fetchHealthIssues as U, posthogDoctorConfig as V, auditConfig as W, posthogIntegrationConfig as X, SETUP_REPORT_FILE as Y, TextBlock as Z, PRICING_SHORT as _, PROGRAM_REGISTRY as a, GITHUB_REQUIRED_MESSAGE as b, getCommandPath as c, metricsConfig as d, isClearBlock as et, aiObservabilityConfig as f, PRICING_LONG as g, NO_DEFAULT_LIMIT as h, isRunFailure as i, Icons as it, installSteeringSnippet as j, findTarget as k, getLaunchablePrograms as l, selfDrivingConfig as m, MINT_FAILURE_CONTACT as n, isObjectBlock as nt, Program as o, mcpAnalyticsConfig as p, revenueAnalyticsConfig as q, MINT_FAILURE_MESSAGE as r, Colors as rt, agentSkillConfig as s, MINT_FAILURE_BODY as t, isLinesBlock as tt, getProgramConfig as u, detectSelfDrivingIntegrationProjects as v, detectErrorTrackingProjects as w, SELF_DRIVING_INTEGRATE_PATH_KEY as x, GITHUB_REQUIRED_BODY as y, migrationConfig as z };
|
|
6390
|
+
export { wordWrap as $, installOrUpdatePostHogCli as A, webAnalyticsDoctorConfig as B, ERROR_TRACKING_PROJECT_PATH_KEY as C, CLI_STEERING_TARGETS as D, errorTrackingUploadSourceMapsConfig as E, MANUAL_SDK_INSTALL as F, createSkillProgram as G, getKindMeta as H, MANUAL_SDK_VARIANTS as I, getContentBlocks$4 as J, warehouseSourceConfig as K, RUST_SDK_CRATE as L, AUTOMATABLE_VARIANTS as M, DISPLAY_NAME as N, detectTargets as O, GO_SDK_MODULE as P, computeVisibleRange as Q, SOURCE_MAPS_CONTEXT_KEYS as R, errorTrackingConfig as S, replayVisionConfig as T, fetchHealthIssues as U, posthogDoctorConfig as V, auditConfig as W, posthogIntegrationConfig as X, SETUP_REPORT_FILE as Y, TextBlock as Z, PRICING_SHORT as _, PROGRAM_REGISTRY as a, maybeStampAiSdkDetected as at, GITHUB_REQUIRED_MESSAGE as b, getCommandPath as c, STRIPE_SDKS as ct, metricsConfig as d, isClearBlock as et, aiObservabilityConfig as f, PRICING_LONG as g, NO_DEFAULT_LIMIT as h, isRunFailure as i, Icons as it, installSteeringSnippet as j, findTarget as k, getLaunchablePrograms as l, detectProjectsWithAgent as lt, selfDrivingConfig as m, MINT_FAILURE_CONTACT as n, isObjectBlock as nt, Program as o, reportWarehouseSourcesDetected as ot, mcpAnalyticsConfig as p, revenueAnalyticsConfig as q, MINT_FAILURE_MESSAGE as r, Colors as rt, agentSkillConfig as s, POSTHOG_SDKS as st, MINT_FAILURE_BODY as t, isLinesBlock as tt, getProgramConfig as u, detectSelfDrivingIntegrationProjects as v, detectErrorTrackingProjects as w, SELF_DRIVING_INTEGRATE_PATH_KEY as x, GITHUB_REQUIRED_BODY as y, migrationConfig as z };
|
|
5828
6391
|
|
|
5829
|
-
//# sourceMappingURL=mint-failure-
|
|
6392
|
+
//# sourceMappingURL=mint-failure-u8xQKNOn.js.map
|