@posthog/wizard 2.80.0 → 2.80.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.
Files changed (227) hide show
  1. package/README.md +187 -57
  2. package/dist/{PickerMenu-m4CCPX4f.js → PickerMenu-BGGeYqd-.js} +104 -4
  3. package/dist/PickerMenu-BGGeYqd-.js.map +1 -0
  4. package/dist/README.md +9 -6
  5. package/dist/{agent-interface-CzyCmp7q.js → agent-interface-CemBvTAA.js} +115 -346
  6. package/dist/agent-interface-CemBvTAA.js.map +1 -0
  7. package/dist/{agent-prompt-loader-4wMxlYSX.js → agent-prompt-loader-DPnj6SwU.js} +6 -5
  8. package/dist/agent-prompt-loader-DPnj6SwU.js.map +1 -0
  9. package/dist/analytics-B3ROGuIr.js +2 -0
  10. package/dist/analytics-D21z3E5l.js +732 -0
  11. package/dist/analytics-D21z3E5l.js.map +1 -0
  12. package/dist/{api-C3Dc4LFl.js → api-DtGIqQ2U.js} +2 -3
  13. package/dist/api-DtGIqQ2U.js.map +1 -0
  14. package/dist/api-IhROOQNv.js +2 -0
  15. package/dist/api-key-login-OEntFvu5.js +2 -0
  16. package/dist/api-key-login-h3E2G3zu.js +55 -0
  17. package/dist/api-key-login-h3E2G3zu.js.map +1 -0
  18. package/dist/bin.js +2 -2
  19. package/dist/bin.js.map +1 -1
  20. package/dist/{bounded-fs-CC_NDtoP.js → bounded-fs-CAsuF6al.js} +3 -3
  21. package/dist/{bounded-fs-CC_NDtoP.js.map → bounded-fs-CAsuF6al.js.map} +1 -1
  22. package/dist/{ci-install-DfcAMhlu.js → ci-install-CEYE02t-.js} +21 -25
  23. package/dist/ci-install-CEYE02t-.js.map +1 -0
  24. package/dist/console-log-O828zyiq.js +32 -0
  25. package/dist/console-log-O828zyiq.js.map +1 -0
  26. package/dist/{debug-DyARf5TF.js → debug-BfQPD2Hg.js} +18 -52
  27. package/dist/debug-BfQPD2Hg.js.map +1 -0
  28. package/dist/{defaults-DpfMnH2q.js → defaults-DDVl3tKN.js} +2 -51
  29. package/dist/defaults-DDVl3tKN.js.map +1 -0
  30. package/dist/{emit-BSetXzDV.js → emit-RfAewcWv.js} +1 -1
  31. package/dist/{emit-BSetXzDV.js.map → emit-RfAewcWv.js.map} +1 -1
  32. package/dist/{errors-C2domSkK.js → errors-CHrJzAZb.js} +4 -4
  33. package/dist/{errors-C2domSkK.js.map → errors-CHrJzAZb.js.map} +1 -1
  34. package/dist/family-picker-BKs-tTyu.js +46 -0
  35. package/dist/family-picker-BKs-tTyu.js.map +1 -0
  36. package/dist/{gateway-BmjYUSua.js → gateway-D3gIlR6b.js} +122 -11
  37. package/dist/gateway-D3gIlR6b.js.map +1 -0
  38. package/dist/headless-BJjhP0SI.js +10 -0
  39. package/dist/headless-BJjhP0SI.js.map +1 -0
  40. package/dist/headless-DIX68UUA.js +3 -0
  41. package/dist/{host-resolution-DVSb7kXb.js → host-resolution-D8GhEVoX.js} +4 -4
  42. package/dist/{host-resolution-DVSb7kXb.js.map → host-resolution-D8GhEVoX.js.map} +1 -1
  43. package/dist/install-Bw8tvDvS.js +2 -0
  44. package/dist/{install-Bk5TNk27.js → install-paPCzPHI.js} +26 -93
  45. package/dist/install-paPCzPHI.js.map +1 -0
  46. package/dist/interactive-tdxZKWax.js +11 -0
  47. package/dist/interactive-tdxZKWax.js.map +1 -0
  48. package/dist/{links-9LWZPSCq.js → links-Cyj6v8kg.js} +3 -3
  49. package/dist/{links-9LWZPSCq.js.map → links-Cyj6v8kg.js.map} +1 -1
  50. package/dist/{main-DKPjFHEV.js → main-0p-YxUNa.js} +204 -469
  51. package/dist/main-0p-YxUNa.js.map +1 -0
  52. package/dist/{mcp-Co8VRF62.js → mcp-D3Z5MXhA.js} +3 -4
  53. package/dist/{mcp-Co8VRF62.js.map → mcp-D3Z5MXhA.js.map} +1 -1
  54. package/dist/mcp-install-smoke-test.ts +2 -2
  55. package/dist/{mcp-prompt-streaming-ljCVoQ9I.js → mcp-prompt-streaming-COVbWnHt.js} +12 -12
  56. package/dist/mcp-prompt-streaming-COVbWnHt.js.map +1 -0
  57. package/dist/mode-label-DB3ol_sj.js +9 -0
  58. package/dist/mode-label-DB3ol_sj.js.map +1 -0
  59. package/dist/{models-Dba8ITeo.js → models-D1SnCzvl.js} +2 -2
  60. package/dist/{models-Dba8ITeo.js.map → models-D1SnCzvl.js.map} +1 -1
  61. package/dist/non-interactive-DxRBc73O.js +18 -0
  62. package/dist/non-interactive-DxRBc73O.js.map +1 -0
  63. package/dist/{oauth-session-D-RfcVmr.js → oauth-session-Dde79Ycm.js} +3 -3
  64. package/dist/{oauth-session-D-RfcVmr.js.map → oauth-session-Dde79Ycm.js.map} +1 -1
  65. package/dist/{orchestrator-tools-CVJ1F9Ub.js → orchestrator-tools-BSNhzzkT.js} +3 -3
  66. package/dist/{orchestrator-tools-CVJ1F9Ub.js.map → orchestrator-tools-BSNhzzkT.js.map} +1 -1
  67. package/dist/{package-json-Cowya9-3.js → package-json-2UrhE6kP.js} +1 -1
  68. package/dist/{package-json-Cowya9-3.js.map → package-json-2UrhE6kP.js.map} +1 -1
  69. package/dist/package-json-Dblip2_X.js +2 -0
  70. package/dist/package-manager-BRXlXo0p.js +105 -0
  71. package/dist/package-manager-BRXlXo0p.js.map +1 -0
  72. package/dist/{pi-B5YTBRDv.js → pi-cM_4Gd_9.js} +16 -18
  73. package/dist/pi-cM_4Gd_9.js.map +1 -0
  74. package/dist/playground-DTKy0XHT.js +12 -0
  75. package/dist/playground-DTKy0XHT.js.map +1 -0
  76. package/dist/posthog-integration-bwHwE87a.js +10291 -0
  77. package/dist/posthog-integration-bwHwE87a.js.map +1 -0
  78. package/dist/programs-BhtyA3lE.js +3 -0
  79. package/dist/programs-SeT1qNik.js +5348 -0
  80. package/dist/programs-SeT1qNik.js.map +1 -0
  81. package/dist/provisioning-BcXfeCMc.js +2 -0
  82. package/dist/{provisioning-CLhuKqXH.js → provisioning-JbJtq7hq.js} +4 -5
  83. package/dist/{provisioning-CLhuKqXH.js.map → provisioning-JbJtq7hq.js.map} +1 -1
  84. package/dist/{queue-tools-knnPQP0e.js → queue-tools-BIZSJyt6.js} +6 -8
  85. package/dist/queue-tools-BIZSJyt6.js.map +1 -0
  86. package/dist/results-DtKICAdz.js +55 -0
  87. package/dist/results-DtKICAdz.js.map +1 -0
  88. package/dist/run-CDurA5tO.js +248 -0
  89. package/dist/run-CDurA5tO.js.map +1 -0
  90. package/dist/run-DDCvLILJ.js +246 -0
  91. package/dist/run-DDCvLILJ.js.map +1 -0
  92. package/dist/run-tool-CTq9OOdT.js +2 -0
  93. package/dist/run-tool-DML8JJvt.js +2420 -0
  94. package/dist/run-tool-DML8JJvt.js.map +1 -0
  95. package/dist/runners-Dhu4pZTN.js +253 -0
  96. package/dist/runners-Dhu4pZTN.js.map +1 -0
  97. package/dist/{security-BvdSFDuM.js → security-DEH8Rn0_.js} +5 -5
  98. package/dist/security-DEH8Rn0_.js.map +1 -0
  99. package/dist/setup-utils-C5-WM-hS.js +118 -0
  100. package/dist/setup-utils-C5-WM-hS.js.map +1 -0
  101. package/dist/smoke-test.sh +1 -1
  102. package/dist/{playground-BLsCfHmQ.js → start-playground-DL4mVEUx.js} +43 -34
  103. package/dist/start-playground-DL4mVEUx.js.map +1 -0
  104. package/dist/{subagent-D_Sqak94.js → subagent-CnFvAq6E.js} +3 -3
  105. package/dist/{subagent-D_Sqak94.js.map → subagent-CnFvAq6E.js.map} +1 -1
  106. package/dist/{task-DiTI6Sak.js → task-BOScSm4W.js} +16 -17
  107. package/dist/task-BOScSm4W.js.map +1 -0
  108. package/dist/{tasks-ChZ_F1YP.js → tasks-BfJhVky2.js} +1 -1
  109. package/dist/tasks-BfJhVky2.js.map +1 -0
  110. package/dist/{telemetry-BNKsDxNS.js → telemetry-CP4rGicd.js} +2 -2
  111. package/dist/{telemetry-BNKsDxNS.js.map → telemetry-CP4rGicd.js.map} +1 -1
  112. package/dist/terminal-J3OD3dN0.js +16162 -0
  113. package/dist/terminal-J3OD3dN0.js.map +1 -0
  114. package/dist/tools-CCMV3DmB.js +544 -0
  115. package/dist/tools-CCMV3DmB.js.map +1 -0
  116. package/dist/{tools-C8LQ8QFz.js → tools-Cz8tDptL.js} +9 -9
  117. package/dist/tools-Cz8tDptL.js.map +1 -0
  118. package/dist/tui-BUZ2PWqN.js +2 -0
  119. package/dist/tui-Csf7VJxt.js +25 -0
  120. package/dist/tui-Csf7VJxt.js.map +1 -0
  121. package/dist/{steps-Hc28zVc_.js → upload-step-CEacB2RV.js} +14 -16
  122. package/dist/upload-step-CEacB2RV.js.map +1 -0
  123. package/dist/{urls-BI4kJ4qQ.js → urls-BDELGZHq.js} +2 -2
  124. package/dist/{urls-BI4kJ4qQ.js.map → urls-BDELGZHq.js.map} +1 -1
  125. package/dist/warlock-smoke-test.ts +1 -2
  126. package/dist/{wizard-abort-DBKtfnBR.js → wizard-abort-D3-75KyV.js} +40 -33
  127. package/dist/wizard-abort-D3-75KyV.js.map +1 -0
  128. package/dist/yara-hooks-CZ1tKxy_.js +2 -0
  129. package/dist/{yara-hooks-C3L6lBij.js → yara-hooks-D8YDyX7o.js} +283 -21
  130. package/dist/yara-hooks-D8YDyX7o.js.map +1 -0
  131. package/package.json +6 -6
  132. package/dist/PickerMenu-m4CCPX4f.js.map +0 -1
  133. package/dist/agent-BkBbVuNq.js +0 -3189
  134. package/dist/agent-BkBbVuNq.js.map +0 -1
  135. package/dist/agent-QGK2YzlX.js +0 -6
  136. package/dist/agent-interface-CzyCmp7q.js.map +0 -1
  137. package/dist/agent-prompt-loader-4wMxlYSX.js.map +0 -1
  138. package/dist/analytics-B6q5PN7a.js +0 -301
  139. package/dist/analytics-B6q5PN7a.js.map +0 -1
  140. package/dist/analytics-BXtfK9o7.js +0 -2
  141. package/dist/api-C3Dc4LFl.js.map +0 -1
  142. package/dist/api-yNjrfZs2.js +0 -2
  143. package/dist/check-screens.tsx +0 -190
  144. package/dist/ci-install-DfcAMhlu.js.map +0 -1
  145. package/dist/constants-DO4X70po.js +0 -260
  146. package/dist/constants-DO4X70po.js.map +0 -1
  147. package/dist/debug-BueK5mRR.js +0 -2
  148. package/dist/debug-DyARf5TF.js.map +0 -1
  149. package/dist/defaults-DpfMnH2q.js.map +0 -1
  150. package/dist/endpoints-D-4KxZiB.js +0 -108
  151. package/dist/endpoints-D-4KxZiB.js.map +0 -1
  152. package/dist/env-api-key-CHGLe0iz.js +0 -2
  153. package/dist/env-api-key-COf0U-Au.js +0 -17
  154. package/dist/env-api-key-COf0U-Au.js.map +0 -1
  155. package/dist/environment-DrLaSsA8.js +0 -39
  156. package/dist/environment-DrLaSsA8.js.map +0 -1
  157. package/dist/environment-hBj7ngmO.js +0 -2
  158. package/dist/file-CVA9ocIC.js +0 -60
  159. package/dist/file-CVA9ocIC.js.map +0 -1
  160. package/dist/file-CmoKK_Pp.js +0 -2
  161. package/dist/file-watcher-C3Su8vXm.js +0 -123
  162. package/dist/file-watcher-C3Su8vXm.js.map +0 -1
  163. package/dist/gateway-BmjYUSua.js.map +0 -1
  164. package/dist/headless-ui-CUbv12Yx.js +0 -44
  165. package/dist/headless-ui-CUbv12Yx.js.map +0 -1
  166. package/dist/install-Bk5TNk27.js.map +0 -1
  167. package/dist/install-F4wm3RSl.js +0 -2
  168. package/dist/interactive-C5LNvDj6.js +0 -11
  169. package/dist/interactive-C5LNvDj6.js.map +0 -1
  170. package/dist/local-dev-McsurOC-.js +0 -135
  171. package/dist/local-dev-McsurOC-.js.map +0 -1
  172. package/dist/logging-ui-p6XKVmTx.js +0 -226
  173. package/dist/logging-ui-p6XKVmTx.js.map +0 -1
  174. package/dist/main-DKPjFHEV.js.map +0 -1
  175. package/dist/mcp-prompt-streaming-ljCVoQ9I.js.map +0 -1
  176. package/dist/mint-failure-C0HyvEwO.js +0 -6403
  177. package/dist/mint-failure-C0HyvEwO.js.map +0 -1
  178. package/dist/non-interactive-CLMJrj_7.js +0 -18
  179. package/dist/non-interactive-CLMJrj_7.js.map +0 -1
  180. package/dist/package-json--ppioh2F.js +0 -2
  181. package/dist/pi-B5YTBRDv.js.map +0 -1
  182. package/dist/playground-BLsCfHmQ.js.map +0 -1
  183. package/dist/posthog-B2E0hpZt.js +0 -2
  184. package/dist/posthog-B42rt_1S.js +0 -124
  185. package/dist/posthog-B42rt_1S.js.map +0 -1
  186. package/dist/project-data--L-WZyvj.js +0 -2
  187. package/dist/project-data-BO9IXn9y.js +0 -1131
  188. package/dist/project-data-BO9IXn9y.js.map +0 -1
  189. package/dist/provisioning-C01REIU2.js +0 -2
  190. package/dist/queue-tools-knnPQP0e.js.map +0 -1
  191. package/dist/registry-B3rC5U4b.js +0 -3464
  192. package/dist/registry-B3rC5U4b.js.map +0 -1
  193. package/dist/registry-BamsM7J9.js +0 -2
  194. package/dist/run-agent-legacy-CwUmPfQF.js +0 -2
  195. package/dist/run-agent-legacy-DWBajsMh.js +0 -3467
  196. package/dist/run-agent-legacy-DWBajsMh.js.map +0 -1
  197. package/dist/runners-D1PqqpjA.js +0 -834
  198. package/dist/runners-D1PqqpjA.js.map +0 -1
  199. package/dist/security-BvdSFDuM.js.map +0 -1
  200. package/dist/setup-utils-ChXXTi1m.js +0 -301
  201. package/dist/setup-utils-ChXXTi1m.js.map +0 -1
  202. package/dist/start-tui-DicLfgsj.js +0 -6964
  203. package/dist/start-tui-DicLfgsj.js.map +0 -1
  204. package/dist/steps-Hc28zVc_.js.map +0 -1
  205. package/dist/store-COCO6U0P.js +0 -5
  206. package/dist/store-D3509G87.js +0 -1030
  207. package/dist/store-D3509G87.js.map +0 -1
  208. package/dist/task-DiTI6Sak.js.map +0 -1
  209. package/dist/task-status-CmrrR7zo.js +0 -16
  210. package/dist/task-status-CmrrR7zo.js.map +0 -1
  211. package/dist/task-stream-BckhG_cB.js +0 -363
  212. package/dist/task-stream-BckhG_cB.js.map +0 -1
  213. package/dist/tasks-ChZ_F1YP.js.map +0 -1
  214. package/dist/terminal-PK9bCLRi.js +0 -7222
  215. package/dist/terminal-PK9bCLRi.js.map +0 -1
  216. package/dist/tools-C8LQ8QFz.js.map +0 -1
  217. package/dist/ui-tPNpM6vj.js +0 -15
  218. package/dist/ui-tPNpM6vj.js.map +0 -1
  219. package/dist/version-5_ydHkM6.js +0 -6
  220. package/dist/version-5_ydHkM6.js.map +0 -1
  221. package/dist/wizard-abort-BVjqLyeA.js +0 -3
  222. package/dist/wizard-abort-DBKtfnBR.js.map +0 -1
  223. package/dist/wizard-session-B7BHnay0.js +0 -2
  224. package/dist/wizard-session-BYw6LzpS.js +0 -133
  225. package/dist/wizard-session-BYw6LzpS.js.map +0 -1
  226. package/dist/yara-hooks-C3L6lBij.js.map +0 -1
  227. package/dist/yara-hooks-CF_IsoaA.js +0 -2
@@ -1,28 +1,18 @@
1
- import { I as WIZARD_TOOL_NAMES, et as fetchSkillMenu, u as recoverOrphanedSettingsBackups } from "./agent-interface-CzyCmp7q.js";
2
- import { n as ErrorCodes, t as emitWizardError } from "./emit-BSetXzDV.js";
3
- import { b as isHeadless, x as regionOption, y as headlessOption } from "./debug-DyARf5TF.js";
4
- import { t as VERSION } from "./version-5_ydHkM6.js";
5
- import { o as initLocalDev, s as localMcpSkillsNotice } from "./local-dev-McsurOC-.js";
6
- import { $ as getSkillsBaseUrl, k as POSTHOG_DOCS_URL } from "./constants-DO4X70po.js";
7
- import { n as analytics } from "./analytics-B6q5PN7a.js";
8
- import { n as setEntryCommand } from "./links-9LWZPSCq.js";
9
- import "./errors-C2domSkK.js";
10
- import { t as LoggingUI } from "./logging-ui-p6XKVmTx.js";
11
- import { n as setUI, t as getUI } from "./ui-tPNpM6vj.js";
12
- import { t as isNonInteractiveEnvironment } from "./environment-DrLaSsA8.js";
13
- import "./agent-BkBbVuNq.js";
14
- import { h as AUDIT_CHECKS_FILE } from "./yara-hooks-C3L6lBij.js";
15
- import { A as installOrUpdatePostHogCli, B as webAnalyticsDoctorConfig, D as CLI_STEERING_TARGETS, E as errorTrackingUploadSourceMapsConfig, G as createSkillProgram, H as getKindMeta, K as warehouseSourceConfig, O as detectTargets, S as errorTrackingConfig, T as replayVisionConfig, U as fetchHealthIssues, V as posthogDoctorConfig, W as auditConfig, d as metricsConfig, f as aiObservabilityConfig, j as installSteeringSnippet, k as findTarget, m as selfDrivingConfig, o as Program, p as mcpAnalyticsConfig, q as revenueAnalyticsConfig, rt as Colors, s as agentSkillConfig, z as migrationConfig } from "./mint-failure-C0HyvEwO.js";
16
- import { i as runWizard, n as runWizardCI, t as runWizardHeadless } from "./runners-D1PqqpjA.js";
17
- import { t as PickerMenu } from "./PickerMenu-m4CCPX4f.js";
18
- import { t as readApiKeyFromEnv } from "./env-api-key-COf0U-Au.js";
1
+ import { n as ErrorCodes, t as emitWizardError } from "./emit-RfAewcWv.js";
2
+ import { t as configureLogFile } from "./debug-BfQPD2Hg.js";
3
+ import { M as POSTHOG_DOCS_URL, lt as initLocalDev, n as analytics, rt as getSkillsBaseUrl, ut as localMcpSkillsNotice } from "./analytics-D21z3E5l.js";
4
+ import { $ as config$4, I as config$10, M as config$5, N as config$11, Q as config$6, T as Program, V as config$9, X as config$8, Z as config$7, _t as regionOption, at as config$3, ct as config, gt as isHeadless, ht as headlessOption, k as getProgramConfig, lt as createSkillProgram, ot as config$2, st as config$1, ut as CLI_STEERING_TARGETS } from "./programs-SeT1qNik.js";
5
+ import { n as setEntryCommand } from "./links-Cyj6v8kg.js";
6
+ import "./errors-CHrJzAZb.js";
7
+ import { a as runWizard, c as underSignals, i as readApiKeyFromEnv, l as withSignals, n as runWizardCI, o as tuiSessionArgs, s as exitWith, t as runWizardHeadless, u as isNonInteractiveEnvironment } from "./runners-Dhu4pZTN.js";
8
+ import { t as consoleLog } from "./console-log-O828zyiq.js";
9
+ import { R as WIZARD_TOOL_NAMES, u as recoverOrphanedSettingsBackups } from "./agent-interface-CemBvTAA.js";
10
+ import "./posthog-integration-bwHwE87a.js";
11
+ import { x as AUDIT_CHECKS_FILE, y as fetchSkillMenu } from "./yara-hooks-D8YDyX7o.js";
12
+ import { a as runCliAdd, d as runDoctorReport, i as runProvision, o as addMCPServerToClientsStep, r as listSkills, s as removeMCPServerFromClientsStep, t as Tool, u as DOCTOR } from "./tools-CCMV3DmB.js";
19
13
  import { Agent, setGlobalDispatcher } from "undici";
20
14
  import yargs from "yargs";
21
15
  import { hideBin } from "yargs/helpers";
22
- import * as path$1 from "node:path";
23
- import { Box, Text, render } from "ink";
24
- import { createElement } from "react";
25
- import * as readline from "node:readline/promises";
26
16
  //#region src/cli/commands/command.ts
27
17
  /** Extract the bare command word(s) from a yargs name spec, dropping positionals and aliases' arg syntax. */
28
18
  function commandKeys(name) {
@@ -66,6 +56,10 @@ const GLOBAL_OPTIONS = {
66
56
  describe: "Enable verbose logging\nenv: POSTHOG_WIZARD_DEBUG",
67
57
  type: "boolean"
68
58
  },
59
+ "log-file": {
60
+ describe: "Write the debug log to this file (default: posthog-wizard.log in the temp dir)\nenv: POSTHOG_WIZARD_LOG_FILE",
61
+ type: "string"
62
+ },
69
63
  signup: {
70
64
  default: false,
71
65
  describe: "Create a new PostHog account during setup\nenv: POSTHOG_WIZARD_SIGNUP",
@@ -116,6 +110,10 @@ var Wizard = class Wizard {
116
110
  constructor() {
117
111
  let cli = yargs(hideBin(process.argv)).env("POSTHOG_WIZARD").options(GLOBAL_OPTIONS);
118
112
  this.cli = cli.middleware((argv) => {
113
+ if (typeof argv.logFile === "string" && argv.logFile) configureLogFile({
114
+ path: argv.logFile,
115
+ pin: true
116
+ });
119
117
  initLocalDev(argv);
120
118
  const notice = localMcpSkillsNotice({
121
119
  localDev: argv.localDev,
@@ -220,55 +218,17 @@ const provisionCommand = {
220
218
  }
221
219
  },
222
220
  examples: [["wizard provision --email matt+test@posthog.com --region us", ""], ["wizard provision --email user@example.com --region eu --json", ""]],
223
- handler: runProvision
221
+ handler: provision
224
222
  };
225
- function runProvision(argv) {
223
+ function provision(argv) {
226
224
  const jsonMode = argv.json === void 0 ? !process.stdout.isTTY : Boolean(argv.json);
227
- if (!jsonMode) setUI(new LoggingUI());
228
- provision({
225
+ exitWith(() => runProvision({
229
226
  email: argv.email,
230
227
  region: argv.region.toUpperCase(),
231
228
  name: argv.name ?? "",
232
229
  baseUrl: argv.baseUrl,
233
230
  jsonMode
234
- });
235
- }
236
- async function provision({ email, region, name, baseUrl, jsonMode }) {
237
- try {
238
- const { provisionNewAccount } = await import("./provisioning-C01REIU2.js");
239
- if (!jsonMode) getUI().log.info(`Provisioning account for ${email} in ${region}...`);
240
- emitResult(await provisionNewAccount(email, name, region, { baseUrl }), jsonMode);
241
- process.exit(0);
242
- } catch (error) {
243
- emitError(error, jsonMode);
244
- process.exit(1);
245
- }
246
- }
247
- function emitResult(result, jsonMode) {
248
- if (jsonMode) {
249
- process.stdout.write(`${JSON.stringify(result)}\n`);
250
- return;
251
- }
252
- getUI().log.success("Account provisioned successfully:");
253
- getUI().log.info(` API Key: ${result.projectApiKey}`);
254
- getUI().log.info(` Host: ${result.host}`);
255
- getUI().log.info(` Project ID: ${result.projectId}`);
256
- getUI().log.info(` Account ID: ${result.accountId}`);
257
- getUI().log.info(` Access Token: ${result.accessToken}`);
258
- getUI().log.info(` Refresh Token: ${result.refreshToken}`);
259
- if (result.personalApiKey) getUI().log.info(` Personal API Key: ${result.personalApiKey}`);
260
- }
261
- function emitError(error, jsonMode) {
262
- const msg = error instanceof Error ? error.message : String(error);
263
- const code = msg.includes("already associated") ? "email_exists" : "provisioning_failed";
264
- if (jsonMode) {
265
- process.stderr.write(`${JSON.stringify({
266
- error: msg,
267
- code
268
- })}\n`);
269
- return;
270
- }
271
- getUI().log.error(`Provisioning failed: ${msg}`);
231
+ }, { log: consoleLog }));
272
232
  }
273
233
  //#endregion
274
234
  //#region src/cli/commands/basic-integration/index.ts
@@ -302,22 +262,22 @@ const basicIntegrationCommand = {
302
262
  setEntryCommand("integrate");
303
263
  (async () => {
304
264
  if (isHeadless(argv)) {
305
- const { runHeadlessInstall } = await import("./ci-install-DfcAMhlu.js");
265
+ const { runHeadlessInstall } = await import("./ci-install-CEYE02t-.js");
306
266
  return runHeadlessInstall(argv);
307
267
  }
308
268
  if (argv.ci) {
309
- const { runCIInstall } = await import("./ci-install-DfcAMhlu.js");
269
+ const { runCIInstall } = await import("./ci-install-CEYE02t-.js");
310
270
  return runCIInstall(argv);
311
271
  }
312
272
  if (isNonInteractiveEnvironment()) {
313
- const { failNonInteractive } = await import("./non-interactive-CLMJrj_7.js");
273
+ const { failNonInteractive } = await import("./non-interactive-DxRBc73O.js");
314
274
  return failNonInteractive();
315
275
  }
316
276
  if (argv.playground) {
317
- const { runPlayground } = await import("./playground-BLsCfHmQ.js");
277
+ const { runPlayground } = await import("./playground-DTKy0XHT.js");
318
278
  return runPlayground();
319
279
  }
320
- const { runInteractive } = await import("./interactive-C5LNvDj6.js");
280
+ const { runInteractive } = await import("./interactive-tdxZKWax.js");
321
281
  runInteractive(argv);
322
282
  })();
323
283
  }
@@ -327,9 +287,9 @@ const basicIntegrationCommand = {
327
287
  /**
328
288
  * startTUI throws CliInteractiveRequired, and Ink throws "Raw mode is not
329
289
  * supported", when stdin has no TTY (piped input, CI, some IDE terminals).
330
- * That is the only TUI failure the mcp commands
331
- * degrade to LoggingUI for — any other error from the TUI path is a real bug
332
- * and must surface rather than be silently swallowed.
290
+ * That is the only TUI failure the mcp commands degrade to console output for
291
+ * — any other error from the TUI path is a real bug and must surface rather
292
+ * than be silently swallowed.
333
293
  */
334
294
  function isTUIUnavailable(error) {
335
295
  if (!(error instanceof Error)) return false;
@@ -360,42 +320,35 @@ const mcpAddCommand = {
360
320
  };
361
321
  function runMcpAdd(argv) {
362
322
  const features = parseFeatures(argv.features);
363
- (async () => {
364
- const { readApiKeyFromEnv } = await import("./env-api-key-CHGLe0iz.js");
365
- const apiKey = argv.apiKey || readApiKeyFromEnv();
366
- const debug = argv.debug;
367
- const localMcp = argv.local;
368
- const args = {
369
- local: localMcp,
370
- features,
371
- apiKey
372
- };
373
- if (isHeadless(argv)) {
374
- await runHeadlessAdd(args);
375
- return;
376
- }
323
+ const apiKey = argv.apiKey || readApiKeyFromEnv();
324
+ const localMcp = argv.local;
325
+ const headless = () => addMCPServerToClientsStep({
326
+ local: localMcp,
327
+ features,
328
+ apiKey
329
+ }, { log: consoleLog.log });
330
+ if (isHeadless(argv)) {
331
+ exitWith(headless);
332
+ return;
333
+ }
334
+ exitWith(async () => {
377
335
  try {
378
- const { startTUI } = await import("./start-tui-DicLfgsj.js");
379
- const { buildSession } = await import("./wizard-session-B7BHnay0.js");
380
- const tui = startTUI(VERSION, Program.McpAdd);
381
- tui.store.session = buildSession({
382
- debug,
383
- localMcp,
384
- mcpFeatures: features,
385
- apiKey,
386
- baseUrl: argv.baseUrl
387
- });
336
+ const { runTuiTool } = await import("./tui-BUZ2PWqN.js");
337
+ return await underSignals((signal) => runTuiTool(Tool.McpAdd, {
338
+ session: {
339
+ debug: argv.debug,
340
+ localMcp,
341
+ mcpFeatures: features,
342
+ apiKey,
343
+ baseUrl: argv.baseUrl
344
+ },
345
+ signal
346
+ }));
388
347
  } catch (error) {
389
348
  if (!isTUIUnavailable(error)) throw error;
390
- await runHeadlessAdd(args);
349
+ return headless();
391
350
  }
392
- })();
393
- }
394
- async function runHeadlessAdd(args) {
395
- setUI(new LoggingUI());
396
- const { addMCPServerToClientsStep } = await import("./install-F4wm3RSl.js");
397
- const { installed, failed } = await addMCPServerToClientsStep(args);
398
- if (failed.length > 0 || installed.length === 0) process.exitCode = 1;
351
+ });
399
352
  }
400
353
  function parseFeatures(raw) {
401
354
  if (typeof raw !== "string") return void 0;
@@ -417,33 +370,28 @@ const mcpRemoveCommand = {
417
370
  handler: runMcpRemove
418
371
  };
419
372
  function runMcpRemove(argv) {
420
- (async () => {
421
- const debug = argv.debug;
422
- const localMcp = argv.local;
423
- if (isHeadless(argv)) {
424
- await runHeadlessRemove(localMcp);
425
- return;
426
- }
373
+ const localMcp = argv.local;
374
+ const headless = () => removeMCPServerFromClientsStep({ local: localMcp }, { log: consoleLog.log });
375
+ if (isHeadless(argv)) {
376
+ exitWith(headless);
377
+ return;
378
+ }
379
+ exitWith(async () => {
427
380
  try {
428
- const { startTUI } = await import("./start-tui-DicLfgsj.js");
429
- const { buildSession } = await import("./wizard-session-B7BHnay0.js");
430
- const tui = startTUI(VERSION, Program.McpRemove);
431
- tui.store.session = buildSession({
432
- debug,
433
- localMcp,
434
- baseUrl: argv.baseUrl
435
- });
381
+ const { runTuiTool } = await import("./tui-BUZ2PWqN.js");
382
+ return await underSignals((signal) => runTuiTool(Tool.McpRemove, {
383
+ session: {
384
+ debug: argv.debug,
385
+ localMcp,
386
+ baseUrl: argv.baseUrl
387
+ },
388
+ signal
389
+ }));
436
390
  } catch (error) {
437
391
  if (!isTUIUnavailable(error)) throw error;
438
- await runHeadlessRemove(localMcp);
392
+ return headless();
439
393
  }
440
- })();
441
- }
442
- /** No exit code on an empty result: nothing to remove is the requested end state. */
443
- async function runHeadlessRemove(local) {
444
- setUI(new LoggingUI());
445
- const { removeMCPServerFromClientsStep } = await import("./install-F4wm3RSl.js");
446
- await removeMCPServerFromClientsStep({ local });
394
+ });
447
395
  }
448
396
  //#endregion
449
397
  //#region src/cli/commands/mcp/tutorial.ts
@@ -458,28 +406,26 @@ const mcpTutorialCommand = {
458
406
  handler: runMcpTutorial
459
407
  };
460
408
  function runMcpTutorial(argv) {
461
- (async () => {
462
- const debug = argv.debug;
463
- const localMcp = argv.local;
409
+ exitWith(async () => {
464
410
  try {
465
- const { startTUI } = await import("./start-tui-DicLfgsj.js");
466
- const { buildSession } = await import("./wizard-session-B7BHnay0.js");
467
- const tui = startTUI(VERSION, Program.McpTutorial);
468
- tui.store.session = buildSession({
469
- debug,
470
- localMcp,
471
- baseUrl: argv.baseUrl
472
- });
411
+ const { runTuiTool } = await import("./tui-BUZ2PWqN.js");
412
+ return await underSignals((signal) => runTuiTool(Tool.McpTutorial, {
413
+ session: {
414
+ debug: argv.debug,
415
+ localMcp: argv.local,
416
+ baseUrl: argv.baseUrl
417
+ },
418
+ signal
419
+ }));
473
420
  } catch (err) {
474
- setUI(new LoggingUI());
475
- getUI().log.error(`The MCP tutorial requires an interactive terminal. ${err instanceof Error ? err.message : String(err)}`);
421
+ consoleLog.log.error(`The MCP tutorial requires an interactive terminal. ${err instanceof Error ? err.message : String(err)}`);
476
422
  emitWizardError({
477
423
  code: ErrorCodes.CliInteractiveRequired,
478
424
  message: "The MCP tutorial requires an interactive terminal."
479
425
  });
480
- process.exit(1);
426
+ return 1;
481
427
  }
482
- })();
428
+ });
483
429
  }
484
430
  //#endregion
485
431
  //#region src/cli/commands/mcp/index.ts
@@ -589,7 +535,7 @@ function nativeCommandFactory(config, opts = {}) {
589
535
  * with the `@posthog/mcp` SDK, rather than installing the PostHog MCP server
590
536
  * into a coding agent. Stays flat while instrumenting is the only action.
591
537
  */
592
- const mcpAnalyticsCommand = nativeCommandFactory(mcpAnalyticsConfig);
538
+ const mcpAnalyticsCommand = nativeCommandFactory(config);
593
539
  //#endregion
594
540
  //#region src/cli/commands/replay-vision.ts
595
541
  /**
@@ -600,7 +546,7 @@ const mcpAnalyticsCommand = nativeCommandFactory(mcpAnalyticsConfig);
600
546
  * reuses the integration-v2 install/init mini-agents when the repo has no
601
547
  * PostHog integration yet.
602
548
  */
603
- const replayVisionCommand = nativeCommandFactory(replayVisionConfig);
549
+ const replayVisionCommand = nativeCommandFactory(config$1);
604
550
  //#endregion
605
551
  //#region src/cli/commands/ai-observability.ts
606
552
  /**
@@ -614,7 +560,7 @@ const replayVisionCommand = nativeCommandFactory(replayVisionConfig);
614
560
  * project's manifest and (when ambiguous) asking the user via `wizard_ask`.
615
561
  * Stays flat while a single "add AIO to a project" flow is the only action.
616
562
  */
617
- const aiObservabilityCommand = nativeCommandFactory(aiObservabilityConfig);
563
+ const aiObservabilityCommand = nativeCommandFactory(config$2);
618
564
  //#endregion
619
565
  //#region src/cli/commands/metrics.ts
620
566
  /**
@@ -627,7 +573,50 @@ const aiObservabilityCommand = nativeCommandFactory(aiObservabilityConfig);
627
573
  * the user via `wizard_ask`. Stays flat while a single "add metrics to a
628
574
  * project" flow is the only action.
629
575
  */
630
- const metricsCommand = nativeCommandFactory(metricsConfig);
576
+ const metricsCommand = nativeCommandFactory(config$3);
577
+ //#endregion
578
+ //#region src/cli/commands/cli/index.ts
579
+ const cliCommand = {
580
+ name: "cli",
581
+ description: "PostHog CLI agent integration commands",
582
+ children: [{
583
+ name: "add",
584
+ description: "Install or update PostHog CLI and add steering instructions to your coding agent's global instructions file",
585
+ options: {
586
+ agent: {
587
+ describe: "Agent to install the instructions for",
588
+ choices: CLI_STEERING_TARGETS.map((target) => target.id),
589
+ type: "string"
590
+ },
591
+ path: {
592
+ describe: "Write to an explicit instructions file instead of a detected agent",
593
+ type: "string"
594
+ },
595
+ all: {
596
+ default: false,
597
+ describe: "Install for every detected agent without prompting",
598
+ type: "boolean"
599
+ }
600
+ },
601
+ examples: [
602
+ ["wizard cli add", "Detect your coding agents and pick one"],
603
+ ["wizard cli add --agent claude-code", "Install for Claude Code (~/.claude/CLAUDE.md)"],
604
+ ["wizard cli add --all", "Install for every detected agent"],
605
+ ["wizard cli add --path ./AGENTS.md", "Install into a specific instructions file"]
606
+ ],
607
+ check: (argv) => {
608
+ if (argv.all && (argv.agent || argv.path)) throw new Error("--all cannot be combined with --agent or --path");
609
+ return true;
610
+ },
611
+ handler: (argv) => {
612
+ exitWith(() => runCliAdd({
613
+ agent: typeof argv.agent === "string" ? argv.agent : void 0,
614
+ path: typeof argv.path === "string" ? argv.path : void 0,
615
+ all: argv.all === true
616
+ }, { log: consoleLog }));
617
+ }
618
+ }]
619
+ };
631
620
  //#endregion
632
621
  //#region src/cli/commands/dispatch-family.ts
633
622
  /**
@@ -661,27 +650,27 @@ async function exitDispatchError(reason, properties, message, code = 1) {
661
650
  * without touching the registry. Adding a native is a wizard PR.
662
651
  */
663
652
  /** Wizard-native subcommands keyed by family. */
664
- const NATIVE_HANDLERS = { audit: { "web-analytics": webAnalyticsDoctorConfig } };
653
+ const NATIVE_HANDLERS = { audit: { "web-analytics": config$4 } };
665
654
  /**
666
655
  * Resolve a fetched CliEntry to the ProgramConfig that actually runs it.
667
656
  * Most entries run via the generic agent-skill program with the entry's
668
657
  * `skillId` injected. The comprehensive `audit all` is the one exception —
669
- * skillId 'audit' triggers the specialized auditConfig (custom hooks,
658
+ * skillId 'audit' triggers the specialized `audit` program (custom hooks,
670
659
  * content blocks, screens).
671
660
  *
672
661
  * This is the one place that knows a subcommand belongs to `audit`, so the
673
662
  * generic skill program picks up the ledger here rather than for every skill.
674
663
  */
675
664
  function configForCliEntry(entry, family) {
676
- if (entry.skillId === "audit") return auditConfig;
665
+ if (entry.skillId === "audit") return getProgramConfig(Program.Audit);
677
666
  return {
678
- ...agentSkillConfig,
667
+ ...config$5,
679
668
  skillId: entry.skillId,
680
669
  ...family === "audit" ? {
681
670
  auditLedgerFile: AUDIT_CHECKS_FILE,
682
671
  streamWorkflowId: family,
683
672
  allowedTools: [
684
- ...agentSkillConfig.allowedTools ?? [],
673
+ ...config$5.allowedTools ?? [],
685
674
  WIZARD_TOOL_NAMES.auditSeedChecks,
686
675
  WIZARD_TOOL_NAMES.auditAddChecks,
687
676
  WIZARD_TOOL_NAMES.auditResolveChecks
@@ -767,24 +756,6 @@ function pickerChildrenToShow(children) {
767
756
  }
768
757
  //#endregion
769
758
  //#region src/cli/commands/factories/family-picker.ts
770
- function FamilyPickerApp(props) {
771
- return createElement(Box, {
772
- flexDirection: "column",
773
- paddingX: 1,
774
- paddingY: 1
775
- }, createElement(Text, {
776
- bold: true,
777
- color: Colors.accent
778
- }, props.parentLabel), createElement(Box, { height: 1 }), createElement(PickerMenu, {
779
- message: "Pick a subcommand",
780
- options: props.options,
781
- optionMarginBottom: 1,
782
- onSelect: (value) => {
783
- const cmd = Array.isArray(value) ? value[0] : value;
784
- if (cmd) props.onSelect(cmd);
785
- }
786
- }));
787
- }
788
759
  function describe(child) {
789
760
  return commandKeys(child.name)[0] ?? "";
790
761
  }
@@ -804,30 +775,19 @@ function orderFamilyChildren(children) {
804
775
  return [...defaults, ...rest];
805
776
  }
806
777
  /**
807
- * Render the picker. Resolves once the user has selected a child;
808
- * dispatching the child's handler is the caller's responsibility (so this
809
- * function stays pure-UI and easy to test by stubbing `render`).
778
+ * Render the picker over a family's children. Resolves once the user has
779
+ * selected a child; dispatching the child's handler is the caller's
780
+ * responsibility.
810
781
  */
811
- function chooseFamilyChild(parentLabel, children) {
782
+ async function chooseFamilyChild(parentLabel, children) {
812
783
  const ordered = orderFamilyChildren(children);
813
- if (ordered.length === 0) return Promise.resolve(null);
814
- const options = ordered.map((child) => ({
784
+ if (ordered.length === 0) return null;
785
+ const { renderFamilyPicker } = await import("./tui-BUZ2PWqN.js");
786
+ return renderFamilyPicker(parentLabel, ordered.map((child) => ({
815
787
  label: describe(child),
816
788
  value: child,
817
789
  hint: child.description
818
- }));
819
- return new Promise((resolve) => {
820
- let app = null;
821
- const handleSelect = (cmd) => {
822
- app?.unmount();
823
- resolve(cmd);
824
- };
825
- app = render(createElement(FamilyPickerApp, {
826
- parentLabel,
827
- options,
828
- onSelect: handleSelect
829
- }));
830
- });
790
+ })));
831
791
  }
832
792
  /**
833
793
  * Returns an `interactiveDefault` handler for a family parent's no-leaf
@@ -907,78 +867,37 @@ function familyCommandFactory({ family, description, optionsFrom }) {
907
867
  * Adding a new skill-backed audit subcommand is a context-mill release —
908
868
  * no wizard release needed.
909
869
  */
870
+ const audit = getProgramConfig(Program.Audit);
910
871
  const auditCommand = familyCommandFactory({
911
872
  family: "audit",
912
- description: auditConfig.description,
913
- optionsFrom: auditConfig
873
+ description: audit.description,
874
+ optionsFrom: audit
914
875
  });
915
876
  //#endregion
916
- //#region src/tools/doctor/report.ts
877
+ //#region src/cli/commands/doctor.ts
917
878
  const doctorCommand = {
918
879
  name: "doctor",
919
- description: posthogDoctorConfig.description,
920
- options: {
921
- ...skillProgramOptions,
922
- ...posthogDoctorConfig.cliOptions ?? {}
923
- },
880
+ description: DOCTOR.description,
881
+ options: { ...skillProgramOptions },
924
882
  handler: (argv) => {
925
- const extras = posthogDoctorConfig.mapCliOptions?.(argv) ?? {};
926
- const options = {
927
- ...argv,
928
- ...extras
929
- };
930
- if (options.ci) runDoctorCI(options);
931
- else runWizard(posthogDoctorConfig, options);
932
- }
933
- };
934
- const SEVERITY_ORDER = {
935
- critical: 0,
936
- warning: 1,
937
- info: 2
938
- };
939
- async function runDoctorCI(options) {
940
- setUI(new LoggingUI());
941
- const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? void 0;
942
- if (!apiKey) {
943
- getUI().intro("PostHog Wizard");
944
- getUI().log.error("CI mode requires --api-key (personal API key phx_xxx)");
945
- emitWizardError({
946
- code: ErrorCodes.ArgsMissingApiKey,
947
- message: "CI mode requires --api-key (personal API key phx_xxx)"
948
- });
949
- process.exit(1);
950
- }
951
- getUI().intro("Welcome to the PostHog setup wizard");
952
- getUI().log.info("Running posthog-doctor in CI mode");
953
- try {
954
- const { getOrAskForProjectData } = await import("./project-data--L-WZyvj.js");
955
- const { host, accessToken, projectId } = await getOrAskForProjectData({
956
- signup: false,
957
- ci: true,
958
- apiKey,
959
- projectId: options.projectId ? Number(options.projectId) : void 0,
960
- baseUrl: options.baseUrl
961
- });
962
- const issues = await fetchHealthIssues(accessToken, host.apiHost, projectId);
963
- if (issues.length === 0) {
964
- getUI().log.success("No active issues — your project looks healthy.");
965
- process.exit(0);
883
+ const options = { ...argv };
884
+ if (options.ci) {
885
+ exitWith(() => runDoctorReport({
886
+ apiKey: options.apiKey ?? readApiKeyFromEnv() ?? void 0,
887
+ projectId: options.projectId ? Number(options.projectId) : void 0,
888
+ baseUrl: options.baseUrl
889
+ }, { log: consoleLog }));
890
+ return;
966
891
  }
967
- const sorted = [...issues].sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity]);
968
- getUI().log.warn(`${issues.length} active issue${issues.length === 1 ? "" : "s"} found:`);
969
- for (const issue of sorted) getUI().log.info(` • [${issue.severity}] ${getKindMeta(issue.kind).title}`);
970
- process.exit(1);
971
- } catch (error) {
972
- const { ApiError } = await import("./api-yNjrfZs2.js");
973
- const message = error instanceof ApiError && error.statusCode === 401 ? "Your PostHog API key is invalid or expired." : error instanceof Error ? error.message : String(error);
974
- getUI().log.error(`Doctor failed: ${message}`);
975
- emitWizardError({
976
- code: error instanceof ApiError && error.statusCode === 401 ? ErrorCodes.AuthInvalidOrExpired : ErrorCodes.InternalUnhandled,
977
- message
892
+ withSignals(async (signal) => {
893
+ const { runTuiTool } = await import("./tui-BUZ2PWqN.js");
894
+ return runTuiTool(Tool.PosthogDoctor, {
895
+ session: tuiSessionArgs(options),
896
+ signal
897
+ });
978
898
  });
979
- process.exit(1);
980
899
  }
981
- }
900
+ };
982
901
  //#endregion
983
902
  //#region src/cli/commands/migrate.ts
984
903
  /**
@@ -991,7 +910,7 @@ async function runDoctorCI(options) {
991
910
  * (`wizard migrate` stops running Statsig directly), so do it explicitly
992
911
  * when the second vendor arrives, not pre-emptively.
993
912
  */
994
- const migrateCommand = nativeCommandFactory(migrationConfig);
913
+ const migrateCommand = nativeCommandFactory(config$6);
995
914
  //#endregion
996
915
  //#region src/cli/commands/revenue.ts
997
916
  /**
@@ -1000,7 +919,7 @@ const migrateCommand = nativeCommandFactory(migrationConfig);
1000
919
  * Stays flat while there's only one provider. Restructure into a family
1001
920
  * if/when a second provider lands.
1002
921
  */
1003
- const revenueCommand = nativeCommandFactory(revenueAnalyticsConfig);
922
+ const revenueCommand = nativeCommandFactory(config$7);
1004
923
  //#endregion
1005
924
  //#region src/cli/commands/warehouse.ts
1006
925
  /**
@@ -1009,12 +928,12 @@ const revenueCommand = nativeCommandFactory(revenueAnalyticsConfig);
1009
928
  * Mirrors `revenue-analytics`: flat skill command driven by the
1010
929
  * warehouse-source program.
1011
930
  */
1012
- const warehouseCommand = nativeCommandFactory(warehouseSourceConfig);
931
+ const warehouseCommand = nativeCommandFactory(config$8);
1013
932
  //#endregion
1014
933
  //#region src/cli/commands/self-driving.ts
1015
934
  const selfDrivingCommand = {
1016
935
  name: "self-driving",
1017
- description: selfDrivingConfig.description,
936
+ description: config$9.description,
1018
937
  options: {
1019
938
  ...skillProgramOptions,
1020
939
  integrate: {
@@ -1022,7 +941,7 @@ const selfDrivingCommand = {
1022
941
  type: "boolean",
1023
942
  default: false
1024
943
  },
1025
- ...selfDrivingConfig.cliOptions ?? {}
944
+ ...config$9.cliOptions ?? {}
1026
945
  },
1027
946
  check: (argv) => {
1028
947
  if (argv.signup) throw new Error("`self-driving` cannot run with --signup. Just run `wizard self-driving`: when your project has no PostHog, it asks whether you already have an account and offers to create one for you (no flag needed).");
@@ -1030,13 +949,13 @@ const selfDrivingCommand = {
1030
949
  return true;
1031
950
  },
1032
951
  handler: (argv) => {
1033
- const extras = selfDrivingConfig.mapCliOptions?.(argv) ?? {};
952
+ const extras = config$9.mapCliOptions?.(argv) ?? {};
1034
953
  const options = {
1035
954
  ...argv,
1036
955
  ...extras
1037
956
  };
1038
- if (options.ci) runWizardCI(selfDrivingConfig, options);
1039
- else runWizard(selfDrivingConfig, options);
957
+ if (options.ci) runWizardCI(config$9, options);
958
+ else runWizard(config$9, options);
1040
959
  }
1041
960
  };
1042
961
  //#endregion
@@ -1052,44 +971,43 @@ const slackCommand = {
1052
971
  }]
1053
972
  };
1054
973
  function runSlackConnect(argv) {
1055
- (async () => {
1056
- const debug = argv.debug;
974
+ exitWith(async () => {
1057
975
  try {
1058
- const { startTUI } = await import("./start-tui-DicLfgsj.js");
1059
- const { buildSession } = await import("./wizard-session-B7BHnay0.js");
1060
- const tui = startTUI(VERSION, Program.SlackConnect);
1061
- tui.store.session = buildSession({
1062
- debug,
1063
- baseUrl: argv.baseUrl
1064
- });
976
+ const { runTuiTool } = await import("./tui-BUZ2PWqN.js");
977
+ return await underSignals((signal) => runTuiTool(Tool.SlackConnect, {
978
+ session: {
979
+ debug: argv.debug,
980
+ baseUrl: argv.baseUrl
981
+ },
982
+ signal
983
+ }));
1065
984
  } catch (err) {
1066
- setUI(new LoggingUI());
1067
- getUI().log.error(`Connecting Slack requires an interactive terminal. ${err instanceof Error ? err.message : String(err)}`);
985
+ consoleLog.log.error(`Connecting Slack requires an interactive terminal. ${err instanceof Error ? err.message : String(err)}`);
1068
986
  emitWizardError({
1069
987
  code: ErrorCodes.CliInteractiveRequired,
1070
988
  message: "Connecting Slack requires an interactive terminal."
1071
989
  });
1072
- process.exit(1);
990
+ return 1;
1073
991
  }
1074
- })();
992
+ });
1075
993
  }
1076
994
  //#endregion
1077
995
  //#region src/cli/commands/upload-sourcemaps.ts
1078
996
  const uploadSourcemapsCommand = {
1079
- name: [errorTrackingUploadSourceMapsConfig.command, "upload-sourcemaps"],
1080
- description: errorTrackingUploadSourceMapsConfig.description,
997
+ name: [config$10.command, "upload-sourcemaps"],
998
+ description: config$10.description,
1081
999
  options: {
1082
1000
  ...skillProgramOptions,
1083
- ...errorTrackingUploadSourceMapsConfig.cliOptions ?? {}
1001
+ ...config$10.cliOptions ?? {}
1084
1002
  },
1085
1003
  handler: (argv) => {
1086
- const extras = errorTrackingUploadSourceMapsConfig.mapCliOptions?.(argv) ?? {};
1004
+ const extras = config$10.mapCliOptions?.(argv) ?? {};
1087
1005
  const options = {
1088
1006
  ...argv,
1089
1007
  ...extras
1090
1008
  };
1091
- if (options.ci) runWizardCI(errorTrackingUploadSourceMapsConfig, options);
1092
- else runWizard(errorTrackingUploadSourceMapsConfig, options);
1009
+ if (options.ci) runWizardCI(config$10, options);
1010
+ else runWizard(config$10, options);
1093
1011
  }
1094
1012
  };
1095
1013
  //#endregion
@@ -1102,55 +1020,7 @@ const uploadSourcemapsCommand = {
1102
1020
  * reuses the integration-v2 install/init mini-agents when the repo has no
1103
1021
  * PostHog integration yet, so it works on uninstrumented projects too.
1104
1022
  */
1105
- const errorTrackingCommand = nativeCommandFactory(errorTrackingConfig);
1106
- //#endregion
1107
- //#region src/tools/skill-list/index.ts
1108
- const BROWSABLE_ROLES = new Set(["command", "skill"]);
1109
- function formatEntry(entry) {
1110
- const path = entry.parentCommand ? `wizard ${entry.parentCommand} ${entry.command}` : entry.command ? `wizard ${entry.command}` : `wizard skill ${entry.skillId}`;
1111
- return ` ${entry.skillId.padEnd(38)} ${path.padEnd(36)} ${entry.description}`;
1112
- }
1113
- /**
1114
- * `wizard skill list` — fetch and print every browsable skill in the catalog.
1115
- *
1116
- * Reads the live `skill-menu.json` so new skills appear immediately after a
1117
- * context-mill release. `internal` skills are excluded from the listing.
1118
- */
1119
- const listCommand = {
1120
- name: "list",
1121
- description: "List every browsable skill in the catalog",
1122
- handler: () => {
1123
- runCommandHandler(async () => {
1124
- const skillsBaseUrl = getSkillsBaseUrl();
1125
- const menu = await fetchSkillMenu(skillsBaseUrl);
1126
- if (!menu) {
1127
- analytics.wizardCapture("cli dispatch error", {
1128
- reason: "registry unreachable",
1129
- family: "skill",
1130
- sub: "list",
1131
- skillsBaseUrl
1132
- });
1133
- try {
1134
- await analytics.flush();
1135
- } catch {}
1136
- process.stderr.write("\n\x1B[1;91m✖ Couldn't reach the skill registry.\x1B[0m\n Check your network connection and try again.\n\n");
1137
- emitWizardError({
1138
- code: ErrorCodes.SkillMenuFetchFailed,
1139
- message: "Couldn't reach the skill registry."
1140
- });
1141
- process.exit(1);
1142
- }
1143
- const entries = (menu.cliEntries ?? []).filter((e) => BROWSABLE_ROLES.has(e.role));
1144
- if (entries.length === 0) {
1145
- process.stdout.write("No skills found.\n");
1146
- return;
1147
- }
1148
- process.stdout.write(`${entries.length} skill${entries.length === 1 ? "" : "s"}:\n`);
1149
- process.stdout.write(` ${"SKILL ID".padEnd(38)} ${"COMMAND".padEnd(36)} DESCRIPTION\n`);
1150
- for (const entry of entries) process.stdout.write(`${formatEntry(entry)}\n`);
1151
- });
1152
- }
1153
- };
1023
+ const errorTrackingCommand = nativeCommandFactory(config$11);
1154
1024
  //#endregion
1155
1025
  //#region src/cli/commands/basic-integration/skill.ts
1156
1026
  /** Run an arbitrary context-mill skill by id (`wizard skill <id>`, headless with `--ci`). */
@@ -1222,18 +1092,17 @@ async function assertSkillExists(skillName) {
1222
1092
  const skillCommand = {
1223
1093
  name: "skill <skill-name>",
1224
1094
  description: "Run a specific context-mill skill by name (or `list` them)",
1225
- children: [listCommand],
1226
1095
  options: { ...skillProgramOptions },
1227
1096
  positionals: { "skill-name": {
1228
1097
  type: "string",
1229
1098
  describe: "Skill id to run (e.g. audit-events), or `list`"
1230
1099
  } },
1231
1100
  check: (argv) => {
1232
- if (argv.skillName == null && argv["skill-name"] == null) return true;
1233
1101
  if (!readSkillName(argv)) throw new Error("skill needs a skill name, e.g. `wizard skill audit-events`");
1234
1102
  return true;
1235
1103
  },
1236
1104
  handler: (argv) => {
1105
+ if (readSkillName(argv) === "list") return exitWith(listSkills);
1237
1106
  runCommandHandler(async () => {
1238
1107
  const skillName = readSkillName(argv);
1239
1108
  await assertSkillExists(skillName);
@@ -1245,147 +1114,13 @@ const skillCommand = {
1245
1114
  }
1246
1115
  };
1247
1116
  //#endregion
1248
- //#region src/tools/cli-steering/index.ts
1249
- async function runCliAdd(argv) {
1250
- setUI(new LoggingUI());
1251
- const ui = getUI();
1252
- ui.intro("PostHog CLI setup");
1253
- const files = await resolveTargetFiles(argv);
1254
- if (files.length === 0) {
1255
- process.exit(1);
1256
- return;
1257
- }
1258
- ui.log.info("Installing or updating PostHog CLI...");
1259
- const cliInstallResult = installOrUpdatePostHogCli();
1260
- if (!cliInstallResult.success) {
1261
- ui.log.error(`Failed to install or update PostHog CLI: ${cliInstallResult.error ?? ""}`);
1262
- analytics.wizardCapture("cli steering installed", {
1263
- files: files.length,
1264
- failures: files.length,
1265
- cli_install_failed: true,
1266
- agent: typeof argv.agent === "string" ? argv.agent : void 0
1267
- });
1268
- process.exit(1);
1269
- return;
1270
- }
1271
- ui.log.success("Installed or updated PostHog CLI.");
1272
- let failures = 0;
1273
- for (const file of files) {
1274
- const result = installSteeringSnippet(file);
1275
- if (result.success) ui.log.success(`Installed PostHog steering instructions in ${file}`);
1276
- else {
1277
- failures += 1;
1278
- ui.log.error(`Failed to update ${file}: ${result.error ?? ""}`);
1279
- }
1280
- }
1281
- analytics.wizardCapture("cli steering installed", {
1282
- files: files.length,
1283
- failures,
1284
- agent: typeof argv.agent === "string" ? argv.agent : void 0
1285
- });
1286
- if (failures > 0) {
1287
- process.exit(1);
1288
- return;
1289
- }
1290
- ui.outro("Done. PostHog CLI is installed and your agent will now use `posthog-cli api` for PostHog tasks.");
1291
- process.exit(0);
1292
- }
1293
- /** Resolve which instruction files to write, from flags, detection, or a prompt. */
1294
- async function resolveTargetFiles(argv) {
1295
- const ui = getUI();
1296
- if (typeof argv.path === "string" && argv.path.trim()) return [path$1.resolve(argv.path.trim())];
1297
- if (typeof argv.agent === "string") {
1298
- const target = findTarget(argv.agent);
1299
- if (!target) {
1300
- ui.log.error(`Unsupported agent: ${argv.agent}`);
1301
- return [];
1302
- }
1303
- return [target.instructionsPath()];
1304
- }
1305
- const detected = detectTargets();
1306
- if (detected.length === 0) {
1307
- ui.log.error("No supported coding agents detected. Pass --agent <id> or --path <file> to choose a target.");
1308
- ui.log.info(`Supported agents: ${CLI_STEERING_TARGETS.map((t) => t.id).join(", ")}`);
1309
- return [];
1310
- }
1311
- if (argv.all === true) {
1312
- ui.log.info(`Installing for all detected agents: ${detected.map((t) => t.name).join(", ")}`);
1313
- return detected.map((target) => target.instructionsPath());
1314
- }
1315
- if (detected.length === 1) {
1316
- ui.log.info(`Detected ${detected[0].name} (${detected[0].instructionsPath()})`);
1317
- return [detected[0].instructionsPath()];
1318
- }
1319
- if (!process.stdin.isTTY || !process.stdout.isTTY) {
1320
- ui.log.info(`Installing for all detected agents: ${detected.map((t) => t.name).join(", ")}`);
1321
- return detected.map((target) => target.instructionsPath());
1322
- }
1323
- return (await promptForTargets(detected)).map((target) => target.instructionsPath());
1324
- }
1325
- /** Minimal numbered selection — this command is intentionally not a TUI flow. */
1326
- async function promptForTargets(detected) {
1327
- const ui = getUI();
1328
- ui.log.info("Which coding agent are you using?");
1329
- detected.forEach((target, index) => {
1330
- ui.log.info(` ${index + 1}) ${target.name} (${target.instructionsPath()})`);
1331
- });
1332
- ui.log.info(` ${detected.length + 1}) All of the above`);
1333
- const rl = readline.createInterface({
1334
- input: process.stdin,
1335
- output: process.stdout
1336
- });
1337
- try {
1338
- for (;;) {
1339
- const answer = (await rl.question(`Select 1-${detected.length + 1}: `)).trim();
1340
- const choice = Number(answer);
1341
- if (Number.isInteger(choice) && choice >= 1 && choice <= detected.length) return [detected[choice - 1]];
1342
- if (choice === detected.length + 1) return detected;
1343
- ui.log.warn(`Enter a number between 1 and ${detected.length + 1}.`);
1344
- }
1345
- } finally {
1346
- rl.close();
1347
- }
1117
+ //#region src/cli/index.ts
1118
+ /** The CLI's one entry: `main.ts` runs the `wizard` command line through it. */
1119
+ /** Register every command and run the one `process.argv` names. */
1120
+ function runCli() {
1121
+ Wizard.use(basicIntegrationCommand).use(mcpCommand).use(mcpAnalyticsCommand).use(replayVisionCommand).use(aiObservabilityCommand).use(metricsCommand).use(cliCommand).use(auditCommand).use(doctorCommand).use(migrateCommand).use(revenueCommand).use(warehouseCommand).use(selfDrivingCommand).use(slackCommand).use(uploadSourcemapsCommand).use(errorTrackingCommand).use(skillCommand).init();
1348
1122
  }
1349
1123
  //#endregion
1350
- //#region src/cli/commands/cli/index.ts
1351
- const cliCommand = {
1352
- name: "cli",
1353
- description: "PostHog CLI agent integration commands",
1354
- children: [{
1355
- name: "add",
1356
- description: "Install or update PostHog CLI and add steering instructions to your coding agent's global instructions file",
1357
- options: {
1358
- agent: {
1359
- describe: "Agent to install the instructions for",
1360
- choices: CLI_STEERING_TARGETS.map((target) => target.id),
1361
- type: "string"
1362
- },
1363
- path: {
1364
- describe: "Write to an explicit instructions file instead of a detected agent",
1365
- type: "string"
1366
- },
1367
- all: {
1368
- default: false,
1369
- describe: "Install for every detected agent without prompting",
1370
- type: "boolean"
1371
- }
1372
- },
1373
- examples: [
1374
- ["wizard cli add", "Detect your coding agents and pick one"],
1375
- ["wizard cli add --agent claude-code", "Install for Claude Code (~/.claude/CLAUDE.md)"],
1376
- ["wizard cli add --all", "Install for every detected agent"],
1377
- ["wizard cli add --path ./AGENTS.md", "Install into a specific instructions file"]
1378
- ],
1379
- check: (argv) => {
1380
- if (argv.all && (argv.agent || argv.path)) throw new Error("--all cannot be combined with --agent or --path");
1381
- return true;
1382
- },
1383
- handler: (argv) => {
1384
- runCliAdd(argv);
1385
- }
1386
- }]
1387
- };
1388
- //#endregion
1389
1124
  //#region main.ts
1390
1125
  setGlobalDispatcher(new Agent({ allowH2: false }));
1391
1126
  recoverOrphanedSettingsBackups(resolveInstallDir());
@@ -1397,8 +1132,8 @@ function resolveInstallDir() {
1397
1132
  if (inline) return inline.slice(14);
1398
1133
  return process.env.POSTHOG_WIZARD_INSTALL_DIR ?? process.cwd();
1399
1134
  }
1400
- Wizard.use(basicIntegrationCommand).use(mcpCommand).use(mcpAnalyticsCommand).use(replayVisionCommand).use(aiObservabilityCommand).use(metricsCommand).use(cliCommand).use(auditCommand).use(doctorCommand).use(migrateCommand).use(revenueCommand).use(warehouseCommand).use(selfDrivingCommand).use(slackCommand).use(uploadSourcemapsCommand).use(errorTrackingCommand).use(skillCommand).init();
1135
+ runCli();
1401
1136
  //#endregion
1402
1137
  export {};
1403
1138
 
1404
- //# sourceMappingURL=main-DKPjFHEV.js.map
1139
+ //# sourceMappingURL=main-0p-YxUNa.js.map