@posthog/wizard 2.79.1 → 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-dG5DQCZA.js → PickerMenu-BGGeYqd-.js} +112 -12
  3. package/dist/PickerMenu-BGGeYqd-.js.map +1 -0
  4. package/dist/README.md +9 -6
  5. package/dist/{agent-interface-FkbaBJwz.js → agent-interface-CemBvTAA.js} +130 -324
  6. package/dist/agent-interface-CemBvTAA.js.map +1 -0
  7. package/dist/{agent-prompt-loader-D0weQ-7k.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-CrbCIQOz.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-vAq-T-K7.js → bounded-fs-CAsuF6al.js} +3 -3
  21. package/dist/{bounded-fs-vAq-T-K7.js.map → bounded-fs-CAsuF6al.js.map} +1 -1
  22. package/dist/{ci-install-COcV8SY2.js → ci-install-CEYE02t-.js} +22 -26
  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-kAHwWGg7.js → debug-BfQPD2Hg.js} +18 -52
  27. package/dist/debug-BfQPD2Hg.js.map +1 -0
  28. package/dist/{defaults-a9TelDhJ.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-C9-GlLO9.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-D8GhEVoX.js +114 -0
  42. package/dist/host-resolution-D8GhEVoX.js.map +1 -0
  43. package/dist/install-Bw8tvDvS.js +2 -0
  44. package/dist/{add-mcp-server-to-clients-DIaTRWMY.js → install-paPCzPHI.js} +34 -100
  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/{telemetry-B7zJdRmA.js → links-Cyj6v8kg.js} +4 -13
  49. package/dist/links-Cyj6v8kg.js.map +1 -0
  50. package/dist/{main-CgKxbwMP.js → main-0p-YxUNa.js} +233 -490
  51. package/dist/main-0p-YxUNa.js.map +1 -0
  52. package/dist/{mcp-DnAyW0-w.js → mcp-D3Z5MXhA.js} +3 -4
  53. package/dist/{mcp-DnAyW0-w.js.map → mcp-D3Z5MXhA.js.map} +1 -1
  54. package/dist/mcp-install-smoke-test.ts +2 -2
  55. package/dist/{mcp-prompt-streaming-DDWQ-FCA.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-WcwUnSKb.js → models-D1SnCzvl.js} +2 -2
  60. package/dist/{models-WcwUnSKb.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-DYM2Hrl2.js → oauth-session-Dde79Ycm.js} +3 -3
  64. package/dist/{oauth-session-DYM2Hrl2.js.map → oauth-session-Dde79Ycm.js.map} +1 -1
  65. package/dist/{orchestrator-tools-DbgNBFGA.js → orchestrator-tools-BSNhzzkT.js} +3 -3
  66. package/dist/{orchestrator-tools-DbgNBFGA.js.map → orchestrator-tools-BSNhzzkT.js.map} +1 -1
  67. package/dist/{package-json-Atg34fa4.js → package-json-2UrhE6kP.js} +1 -1
  68. package/dist/{package-json-Atg34fa4.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-8KsYsPmM.js → pi-cM_4Gd_9.js} +19 -20
  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-Bo2NRxFz.js → provisioning-JbJtq7hq.js} +5 -67
  83. package/dist/provisioning-JbJtq7hq.js.map +1 -0
  84. package/dist/{queue-tools-C8mXOh7e.js → queue-tools-BIZSJyt6.js} +7 -9
  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-C71pkwqH.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-BlYRBMj7.js → start-playground-DL4mVEUx.js} +63 -54
  103. package/dist/start-playground-DL4mVEUx.js.map +1 -0
  104. package/dist/{subagent-D1TrTchE.js → subagent-CnFvAq6E.js} +3 -3
  105. package/dist/{subagent-D1TrTchE.js.map → subagent-CnFvAq6E.js.map} +1 -1
  106. package/dist/{task-DqRlQBfs.js → task-BOScSm4W.js} +17 -18
  107. package/dist/task-BOScSm4W.js.map +1 -0
  108. package/dist/{tasks-ChWufsdO.js → tasks-BfJhVky2.js} +1 -1
  109. package/dist/tasks-BfJhVky2.js.map +1 -0
  110. package/dist/telemetry-CP4rGicd.js +13 -0
  111. package/dist/telemetry-CP4rGicd.js.map +1 -0
  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-CkJ2y9Wt.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-BPcg3_3Q.js → upload-step-CEacB2RV.js} +17 -19
  122. package/dist/upload-step-CEacB2RV.js.map +1 -0
  123. package/dist/urls-BDELGZHq.js +67 -0
  124. package/dist/urls-BDELGZHq.js.map +1 -0
  125. package/dist/warlock-smoke-test.ts +1 -2
  126. package/dist/{wizard-abort-BPdv07np.js → wizard-abort-D3-75KyV.js} +41 -32
  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-BnxejtXK.js → yara-hooks-D8YDyX7o.js} +283 -21
  130. package/dist/yara-hooks-D8YDyX7o.js.map +1 -0
  131. package/package.json +7 -8
  132. package/dist/PickerMenu-dG5DQCZA.js.map +0 -1
  133. package/dist/add-mcp-server-to-clients-DIaTRWMY.js.map +0 -1
  134. package/dist/add-mcp-server-to-clients-artmN7mz.js +0 -2
  135. package/dist/agent-BEjARD2a.js +0 -6
  136. package/dist/agent-BWFhuLgo.js +0 -3178
  137. package/dist/agent-BWFhuLgo.js.map +0 -1
  138. package/dist/agent-interface-FkbaBJwz.js.map +0 -1
  139. package/dist/agent-prompt-loader-D0weQ-7k.js.map +0 -1
  140. package/dist/analytics-DFtbRjYh.js +0 -2
  141. package/dist/analytics-DXK1gc12.js +0 -301
  142. package/dist/analytics-DXK1gc12.js.map +0 -1
  143. package/dist/api-Cm9UtKZh.js +0 -2
  144. package/dist/api-CrbCIQOz.js.map +0 -1
  145. package/dist/check-screens.tsx +0 -190
  146. package/dist/ci-install-COcV8SY2.js.map +0 -1
  147. package/dist/constants-DHCBSfnx.js +0 -260
  148. package/dist/constants-DHCBSfnx.js.map +0 -1
  149. package/dist/debug-BuYHGr6_.js +0 -2
  150. package/dist/debug-kAHwWGg7.js.map +0 -1
  151. package/dist/defaults-a9TelDhJ.js.map +0 -1
  152. package/dist/endpoints-BVMYm9F4.js +0 -108
  153. package/dist/endpoints-BVMYm9F4.js.map +0 -1
  154. package/dist/env-api-key-BP-NFFXt.js +0 -17
  155. package/dist/env-api-key-BP-NFFXt.js.map +0 -1
  156. package/dist/env-api-key-CaWEDj_9.js +0 -2
  157. package/dist/environment-BATlQxcQ.js +0 -39
  158. package/dist/environment-BATlQxcQ.js.map +0 -1
  159. package/dist/environment-CwD8OPYj.js +0 -2
  160. package/dist/file-C5JMsyR1.js +0 -2
  161. package/dist/file-DcRKycV8.js +0 -60
  162. package/dist/file-DcRKycV8.js.map +0 -1
  163. package/dist/file-watcher-Brq2nnHV.js +0 -123
  164. package/dist/file-watcher-Brq2nnHV.js.map +0 -1
  165. package/dist/gateway-C9-GlLO9.js.map +0 -1
  166. package/dist/headless-ui-CqI2gXlD.js +0 -44
  167. package/dist/headless-ui-CqI2gXlD.js.map +0 -1
  168. package/dist/interactive-B_Ti_CsS.js +0 -11
  169. package/dist/interactive-B_Ti_CsS.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-Dza4D0MK.js +0 -226
  173. package/dist/logging-ui-Dza4D0MK.js.map +0 -1
  174. package/dist/main-CgKxbwMP.js.map +0 -1
  175. package/dist/mcp-prompt-streaming-DDWQ-FCA.js.map +0 -1
  176. package/dist/mint-failure-u8xQKNOn.js +0 -6392
  177. package/dist/mint-failure-u8xQKNOn.js.map +0 -1
  178. package/dist/non-interactive-DyVC1AGc.js +0 -18
  179. package/dist/non-interactive-DyVC1AGc.js.map +0 -1
  180. package/dist/package-json-D8Ga03tK.js +0 -2
  181. package/dist/pi-8KsYsPmM.js.map +0 -1
  182. package/dist/playground-BlYRBMj7.js.map +0 -1
  183. package/dist/posthog-Bt0Aplb8.js +0 -124
  184. package/dist/posthog-Bt0Aplb8.js.map +0 -1
  185. package/dist/posthog-CUgCEhH0.js +0 -2
  186. package/dist/provisioning-Bo2NRxFz.js.map +0 -1
  187. package/dist/provisioning-OGFGlzf7.js +0 -2
  188. package/dist/queue-tools-C8mXOh7e.js.map +0 -1
  189. package/dist/registry-C06e_x-p.js +0 -2
  190. package/dist/registry-CD5RQt38.js +0 -3464
  191. package/dist/registry-CD5RQt38.js.map +0 -1
  192. package/dist/run-agent-legacy-ChacZImU.js +0 -2
  193. package/dist/run-agent-legacy-DOlM6DQu.js +0 -3540
  194. package/dist/run-agent-legacy-DOlM6DQu.js.map +0 -1
  195. package/dist/runners-ov3EXF1n.js +0 -834
  196. package/dist/runners-ov3EXF1n.js.map +0 -1
  197. package/dist/security-C71pkwqH.js.map +0 -1
  198. package/dist/setup-utils-B26Lf2yF.js +0 -1512
  199. package/dist/setup-utils-B26Lf2yF.js.map +0 -1
  200. package/dist/setup-utils-CVS86NYR.js +0 -2
  201. package/dist/start-tui-Bo2L0bar.js +0 -6962
  202. package/dist/start-tui-Bo2L0bar.js.map +0 -1
  203. package/dist/steps-BPcg3_3Q.js.map +0 -1
  204. package/dist/store-BTzcvRGT.js +0 -992
  205. package/dist/store-BTzcvRGT.js.map +0 -1
  206. package/dist/store-BpqySPXm.js +0 -5
  207. package/dist/task-DqRlQBfs.js.map +0 -1
  208. package/dist/task-stream-Bw6JaLCX.js +0 -363
  209. package/dist/task-stream-Bw6JaLCX.js.map +0 -1
  210. package/dist/tasks-ChWufsdO.js.map +0 -1
  211. package/dist/telemetry-B7zJdRmA.js.map +0 -1
  212. package/dist/terminal-zgkEfoCL.js +0 -7196
  213. package/dist/terminal-zgkEfoCL.js.map +0 -1
  214. package/dist/tools-CkJ2y9Wt.js.map +0 -1
  215. package/dist/ui-Q6-RvERF.js +0 -15
  216. package/dist/ui-Q6-RvERF.js.map +0 -1
  217. package/dist/version-CHhJjz_H.js +0 -6
  218. package/dist/version-CHhJjz_H.js.map +0 -1
  219. package/dist/wizard-abort-BPdv07np.js.map +0 -1
  220. package/dist/wizard-abort-Br1qMDNa.js +0 -3
  221. package/dist/wizard-session-2w4Ru-Wz.js +0 -131
  222. package/dist/wizard-session-2w4Ru-Wz.js.map +0 -1
  223. package/dist/wizard-session-DGaUHOF3.js +0 -2
  224. package/dist/wizard-ui-DVqrYaOM.js +0 -16
  225. package/dist/wizard-ui-DVqrYaOM.js.map +0 -1
  226. package/dist/yara-hooks-BnxejtXK.js.map +0 -1
  227. package/dist/yara-hooks-DSuExwb4.js +0 -2
@@ -1,29 +1,19 @@
1
- import { I as WIZARD_TOOL_NAMES, et as fetchSkillMenu, u as recoverOrphanedSettingsBackups } from "./agent-interface-FkbaBJwz.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-kAHwWGg7.js";
4
- import { t as VERSION } from "./version-CHhJjz_H.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-DHCBSfnx.js";
7
- import { n as analytics } from "./analytics-DXK1gc12.js";
8
- import { r as setEntryCommand } from "./telemetry-B7zJdRmA.js";
9
- import "./errors-C2domSkK.js";
10
- import { t as LoggingUI } from "./logging-ui-Dza4D0MK.js";
11
- import { n as setUI, t as getUI } from "./ui-Q6-RvERF.js";
12
- import { t as isNonInteractiveEnvironment } from "./environment-BATlQxcQ.js";
13
- import "./agent-BWFhuLgo.js";
14
- import { h as AUDIT_CHECKS_FILE } from "./yara-hooks-BnxejtXK.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-u8xQKNOn.js";
16
- import { i as runWizard, n as runWizardCI, t as runWizardHeadless } from "./runners-ov3EXF1n.js";
17
- import { t as PickerMenu } from "./PickerMenu-dG5DQCZA.js";
18
- import { t as readApiKeyFromEnv } from "./env-api-key-BP-NFFXt.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
- //#region src/commands/command.ts
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) {
29
19
  return (typeof name === "string" ? [name] : name).map((n) => n.trim().split(/\s+/)[0]);
@@ -50,7 +40,7 @@ function toCommandModule(cmd, parentPath) {
50
40
  };
51
41
  }
52
42
  //#endregion
53
- //#region src/wizard.ts
43
+ //#region src/cli/wizard.ts
54
44
  /**
55
45
  * Global yargs options applied to every command. These are read from the
56
46
  * `POSTHOG_WIZARD` env prefix as well as flags.
@@ -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,
@@ -194,7 +192,7 @@ const LOCAL_TARGET_ENV_VARS = [
194
192
  "POSTHOG_WIZARD_LOCAL_POSTHOG"
195
193
  ];
196
194
  //#endregion
197
- //#region src/commands/provision.ts
195
+ //#region src/cli/commands/provision.ts
198
196
  const provisionCommand = {
199
197
  name: "provision",
200
198
  description: "Create a new PostHog account (headless, no TUI)",
@@ -220,58 +218,20 @@ 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-OGFGlzf7.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
- //#region src/commands/basic-integration/index.ts
234
+ //#region src/cli/commands/basic-integration/index.ts
275
235
  const basicIntegrationCommand = {
276
236
  name: ["$0"],
277
237
  description: "Run the PostHog setup wizard",
@@ -302,41 +262,41 @@ const basicIntegrationCommand = {
302
262
  setEntryCommand("integrate");
303
263
  (async () => {
304
264
  if (isHeadless(argv)) {
305
- const { runHeadlessInstall } = await import("./ci-install-COcV8SY2.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-COcV8SY2.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-DyVC1AGc.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-BlYRBMj7.js");
277
+ const { runPlayground } = await import("./playground-DTKy0XHT.js");
318
278
  return runPlayground();
319
279
  }
320
- const { runInteractive } = await import("./interactive-B_Ti_CsS.js");
280
+ const { runInteractive } = await import("./interactive-tdxZKWax.js");
321
281
  runInteractive(argv);
322
282
  })();
323
283
  }
324
284
  };
325
285
  //#endregion
326
- //#region src/commands/mcp/tui-availability.ts
286
+ //#region src/cli/commands/mcp/tui-availability.ts
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;
336
296
  return error.code === ErrorCodes.CliInteractiveRequired || /raw mode is not supported/i.test(error.message);
337
297
  }
338
298
  //#endregion
339
- //#region src/commands/mcp/add.ts
299
+ //#region src/cli/commands/mcp/add.ts
340
300
  const mcpAddCommand = {
341
301
  name: "add",
342
302
  description: "Install PostHog MCP server to supported clients",
@@ -360,49 +320,42 @@ 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-CaWEDj_9.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-Bo2L0bar.js");
379
- const { buildSession } = await import("./wizard-session-DGaUHOF3.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("./add-mcp-server-to-clients-artmN7mz.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;
402
355
  return raw.split(",").map((s) => s.trim()).filter(Boolean);
403
356
  }
404
357
  //#endregion
405
- //#region src/commands/mcp/remove.ts
358
+ //#region src/cli/commands/mcp/remove.ts
406
359
  const mcpRemoveCommand = {
407
360
  name: "remove",
408
361
  description: "Remove PostHog MCP server from supported clients",
@@ -417,36 +370,31 @@ 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-Bo2L0bar.js");
429
- const { buildSession } = await import("./wizard-session-DGaUHOF3.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("./add-mcp-server-to-clients-artmN7mz.js");
446
- await removeMCPServerFromClientsStep({ local });
394
+ });
447
395
  }
448
396
  //#endregion
449
- //#region src/commands/mcp/tutorial.ts
397
+ //#region src/cli/commands/mcp/tutorial.ts
450
398
  const mcpTutorialCommand = {
451
399
  name: "tutorial",
452
400
  description: "Try the PostHog MCP with your agent (no install needed)",
@@ -458,31 +406,29 @@ 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-Bo2L0bar.js");
466
- const { buildSession } = await import("./wizard-session-DGaUHOF3.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
- //#region src/commands/mcp/index.ts
431
+ //#region src/cli/commands/mcp/index.ts
486
432
  const mcpCommand = {
487
433
  name: "mcp",
488
434
  description: "MCP server management commands",
@@ -493,7 +439,7 @@ const mcpCommand = {
493
439
  ]
494
440
  };
495
441
  //#endregion
496
- //#region src/commands/skill-program-options.ts
442
+ //#region src/cli/commands/skill-program-options.ts
497
443
  /**
498
444
  * Per-command options shared by every skill-based program command
499
445
  * (`audit events`, `migrate statsig`, `revenue`, `source-maps`, …).
@@ -507,7 +453,7 @@ const skillProgramOptions = { "install-dir": {
507
453
  type: "string"
508
454
  } };
509
455
  //#endregion
510
- //#region src/commands/factories/shared.ts
456
+ //#region src/cli/commands/factories/shared.ts
511
457
  /**
512
458
  * Dispatch a parsed yargs invocation to the wizard runner. Applies the
513
459
  * program's `mapCliOptions` transform, then routes to `runWizardHeadless`,
@@ -562,7 +508,7 @@ function mergeCommandOptions(config) {
562
508
  };
563
509
  }
564
510
  //#endregion
565
- //#region src/commands/factories/native-command-factory.ts
511
+ //#region src/cli/commands/factories/native-command-factory.ts
566
512
  /**
567
513
  * Build a yargs `Command` from a wizard-native `ProgramConfig`.
568
514
  *
@@ -581,7 +527,7 @@ function nativeCommandFactory(config, opts = {}) {
581
527
  };
582
528
  }
583
529
  //#endregion
584
- //#region src/commands/mcp-analytics.ts
530
+ //#region src/cli/commands/mcp-analytics.ts
585
531
  /**
586
532
  * `wizard mcp-analytics` — flat skill command, instrument-an-MCP-server today.
587
533
  *
@@ -589,9 +535,9 @@ 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
- //#region src/commands/replay-vision.ts
540
+ //#region src/cli/commands/replay-vision.ts
595
541
  /**
596
542
  * `wizard replay-vision` — flat skill command, set up Replay vision today.
597
543
  *
@@ -600,9 +546,9 @@ 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
- //#region src/commands/ai-observability.ts
551
+ //#region src/cli/commands/ai-observability.ts
606
552
  /**
607
553
  * `wizard ai-observability` — flat skill command, wire AI Observability into a
608
554
  * project today.
@@ -614,9 +560,9 @@ 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
- //#region src/commands/metrics.ts
565
+ //#region src/cli/commands/metrics.ts
620
566
  /**
621
567
  * `wizard metrics` — flat skill command, wire PostHog application metrics
622
568
  * (counters, gauges, histograms via \`posthog.metrics\`) into a project.
@@ -627,9 +573,52 @@ 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
- //#region src/programs/dispatch-family.ts
621
+ //#region src/cli/commands/dispatch-family.ts
633
622
  /**
634
623
  * Capture a CLI dispatch error, flush analytics, and exit. The wizard never
635
624
  * starts a run from these paths — use flush() (not shutdown()) so we don't
@@ -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
@@ -766,25 +755,7 @@ function pickerChildrenToShow(children) {
766
755
  return defaults.length > 0 ? [...defaults] : [...children];
767
756
  }
768
757
  //#endregion
769
- //#region src/commands/factories/family-picker.tsx
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
- }
758
+ //#region src/cli/commands/factories/family-picker.ts
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
@@ -852,7 +812,7 @@ function createFamilyPickerDefault(parentLabel, children, chooser = chooseFamily
852
812
  };
853
813
  }
854
814
  //#endregion
855
- //#region src/commands/factories/family-command-factory.ts
815
+ //#region src/cli/commands/factories/family-command-factory.ts
856
816
  /**
857
817
  * Build a yargs `Command` for a family parent (`wizard audit`, etc.).
858
818
  *
@@ -894,7 +854,7 @@ function familyCommandFactory({ family, description, optionsFrom }) {
894
854
  };
895
855
  }
896
856
  //#endregion
897
- //#region src/commands/audit.ts
857
+ //#region src/cli/commands/audit.ts
898
858
  /**
899
859
  * The `wizard audit` family.
900
860
  *
@@ -907,80 +867,39 @@ 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/commands/doctor.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("./setup-utils-CVS86NYR.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-Cm9UtKZh.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
- //#region src/commands/migrate.ts
902
+ //#region src/cli/commands/migrate.ts
984
903
  /**
985
904
  * `wizard migrate` — flat skill command, Statsig today.
986
905
  *
@@ -991,30 +910,30 @@ 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
- //#region src/commands/revenue.ts
915
+ //#region src/cli/commands/revenue.ts
997
916
  /**
998
917
  * `wizard revenue-analytics` — flat skill command, Stripe today.
999
918
  *
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
- //#region src/commands/warehouse.ts
924
+ //#region src/cli/commands/warehouse.ts
1006
925
  /**
1007
926
  * `wizard warehouse` — detect and connect a data warehouse source.
1008
927
  *
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
- //#region src/commands/self-driving.ts
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,17 +949,17 @@ 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
1043
- //#region src/commands/slack.ts
962
+ //#region src/cli/commands/slack.ts
1044
963
  const slackCommand = {
1045
964
  name: "slack",
1046
965
  description: "Connect PostHog to your Slack",
@@ -1052,48 +971,47 @@ 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-Bo2L0bar.js");
1059
- const { buildSession } = await import("./wizard-session-DGaUHOF3.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
- //#region src/commands/upload-sourcemaps.ts
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
1096
- //#region src/commands/error-tracking.ts
1014
+ //#region src/cli/commands/error-tracking.ts
1097
1015
  /**
1098
1016
  * `wizard error-tracking` — flat skill command, set up error tracking today.
1099
1017
  *
@@ -1102,9 +1020,9 @@ 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);
1023
+ const errorTrackingCommand = nativeCommandFactory(config$11);
1106
1024
  //#endregion
1107
- //#region src/commands/basic-integration/skill.ts
1025
+ //#region src/cli/commands/basic-integration/skill.ts
1108
1026
  /** Run an arbitrary context-mill skill by id (`wizard skill <id>`, headless with `--ci`). */
1109
1027
  function runSkillMode(argv) {
1110
1028
  const skillId = argv.skill;
@@ -1128,12 +1046,11 @@ function runSkillMode(argv) {
1128
1046
  else runWizard(config, options);
1129
1047
  }
1130
1048
  //#endregion
1131
- //#region src/commands/skill.ts
1049
+ //#region src/cli/commands/skill.ts
1132
1050
  /** Read the `<skill-name>` positional (yargs camelCases the hyphenated key). */
1133
1051
  function readSkillName(argv) {
1134
1052
  return String(argv.skillName ?? argv["skill-name"] ?? "").trim();
1135
1053
  }
1136
- const BROWSABLE_ROLES = new Set(["command", "skill"]);
1137
1054
  /**
1138
1055
  * Reject an unknown skill id before the wizard authenticates.
1139
1056
  *
@@ -1164,10 +1081,6 @@ async function assertSkillExists(skillName) {
1164
1081
  } catch {}
1165
1082
  throw new Error(`Unknown skill "${skillName}". Run \`wizard skill list\` to see available skills.`);
1166
1083
  }
1167
- function formatEntry(entry) {
1168
- const path = entry.parentCommand ? `wizard ${entry.parentCommand} ${entry.command}` : entry.command ? `wizard ${entry.command}` : `wizard skill ${entry.skillId}`;
1169
- return ` ${entry.skillId.padEnd(38)} ${path.padEnd(36)} ${entry.description}`;
1170
- }
1171
1084
  /**
1172
1085
  * `wizard skill <skill-name>` — run a single context-mill skill by id.
1173
1086
  * `wizard skill list` — list every browsable skill in the catalog.
@@ -1179,52 +1092,17 @@ function formatEntry(entry) {
1179
1092
  const skillCommand = {
1180
1093
  name: "skill <skill-name>",
1181
1094
  description: "Run a specific context-mill skill by name (or `list` them)",
1182
- children: [{
1183
- name: "list",
1184
- description: "List every browsable skill in the catalog",
1185
- handler: () => {
1186
- runCommandHandler(async () => {
1187
- const skillsBaseUrl = getSkillsBaseUrl();
1188
- const menu = await fetchSkillMenu(skillsBaseUrl);
1189
- if (!menu) {
1190
- analytics.wizardCapture("cli dispatch error", {
1191
- reason: "registry unreachable",
1192
- family: "skill",
1193
- sub: "list",
1194
- skillsBaseUrl
1195
- });
1196
- try {
1197
- await analytics.flush();
1198
- } catch {}
1199
- 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");
1200
- emitWizardError({
1201
- code: ErrorCodes.SkillMenuFetchFailed,
1202
- message: "Couldn't reach the skill registry."
1203
- });
1204
- process.exit(1);
1205
- }
1206
- const entries = (menu.cliEntries ?? []).filter((e) => BROWSABLE_ROLES.has(e.role));
1207
- if (entries.length === 0) {
1208
- process.stdout.write("No skills found.\n");
1209
- return;
1210
- }
1211
- process.stdout.write(`${entries.length} skill${entries.length === 1 ? "" : "s"}:\n`);
1212
- process.stdout.write(` ${"SKILL ID".padEnd(38)} ${"COMMAND".padEnd(36)} DESCRIPTION\n`);
1213
- for (const entry of entries) process.stdout.write(`${formatEntry(entry)}\n`);
1214
- });
1215
- }
1216
- }],
1217
1095
  options: { ...skillProgramOptions },
1218
1096
  positionals: { "skill-name": {
1219
1097
  type: "string",
1220
1098
  describe: "Skill id to run (e.g. audit-events), or `list`"
1221
1099
  } },
1222
1100
  check: (argv) => {
1223
- if (argv.skillName == null && argv["skill-name"] == null) return true;
1224
1101
  if (!readSkillName(argv)) throw new Error("skill needs a skill name, e.g. `wizard skill audit-events`");
1225
1102
  return true;
1226
1103
  },
1227
1104
  handler: (argv) => {
1105
+ if (readSkillName(argv) === "list") return exitWith(listSkills);
1228
1106
  runCommandHandler(async () => {
1229
1107
  const skillName = readSkillName(argv);
1230
1108
  await assertSkillExists(skillName);
@@ -1236,148 +1114,13 @@ const skillCommand = {
1236
1114
  }
1237
1115
  };
1238
1116
  //#endregion
1239
- //#region src/commands/cli/add.ts
1240
- const cliAddCommand = {
1241
- name: "add",
1242
- description: "Install or update PostHog CLI and add steering instructions to your coding agent's global instructions file",
1243
- options: {
1244
- agent: {
1245
- describe: "Agent to install the instructions for",
1246
- choices: CLI_STEERING_TARGETS.map((target) => target.id),
1247
- type: "string"
1248
- },
1249
- path: {
1250
- describe: "Write to an explicit instructions file instead of a detected agent",
1251
- type: "string"
1252
- },
1253
- all: {
1254
- default: false,
1255
- describe: "Install for every detected agent without prompting",
1256
- type: "boolean"
1257
- }
1258
- },
1259
- examples: [
1260
- ["wizard cli add", "Detect your coding agents and pick one"],
1261
- ["wizard cli add --agent claude-code", "Install for Claude Code (~/.claude/CLAUDE.md)"],
1262
- ["wizard cli add --all", "Install for every detected agent"],
1263
- ["wizard cli add --path ./AGENTS.md", "Install into a specific instructions file"]
1264
- ],
1265
- check: (argv) => {
1266
- if (argv.all && (argv.agent || argv.path)) throw new Error("--all cannot be combined with --agent or --path");
1267
- return true;
1268
- },
1269
- handler: (argv) => {
1270
- runCliAdd(argv);
1271
- }
1272
- };
1273
- async function runCliAdd(argv) {
1274
- setUI(new LoggingUI());
1275
- const ui = getUI();
1276
- ui.intro("PostHog CLI setup");
1277
- const files = await resolveTargetFiles(argv);
1278
- if (files.length === 0) {
1279
- process.exit(1);
1280
- return;
1281
- }
1282
- ui.log.info("Installing or updating PostHog CLI...");
1283
- const cliInstallResult = installOrUpdatePostHogCli();
1284
- if (!cliInstallResult.success) {
1285
- ui.log.error(`Failed to install or update PostHog CLI: ${cliInstallResult.error ?? ""}`);
1286
- analytics.wizardCapture("cli steering installed", {
1287
- files: files.length,
1288
- failures: files.length,
1289
- cli_install_failed: true,
1290
- agent: typeof argv.agent === "string" ? argv.agent : void 0
1291
- });
1292
- process.exit(1);
1293
- return;
1294
- }
1295
- ui.log.success("Installed or updated PostHog CLI.");
1296
- let failures = 0;
1297
- for (const file of files) {
1298
- const result = installSteeringSnippet(file);
1299
- if (result.success) ui.log.success(`Installed PostHog steering instructions in ${file}`);
1300
- else {
1301
- failures += 1;
1302
- ui.log.error(`Failed to update ${file}: ${result.error ?? ""}`);
1303
- }
1304
- }
1305
- analytics.wizardCapture("cli steering installed", {
1306
- files: files.length,
1307
- failures,
1308
- agent: typeof argv.agent === "string" ? argv.agent : void 0
1309
- });
1310
- if (failures > 0) {
1311
- process.exit(1);
1312
- return;
1313
- }
1314
- ui.outro("Done. PostHog CLI is installed and your agent will now use `posthog-cli api` for PostHog tasks.");
1315
- process.exit(0);
1316
- }
1317
- /** Resolve which instruction files to write, from flags, detection, or a prompt. */
1318
- async function resolveTargetFiles(argv) {
1319
- const ui = getUI();
1320
- if (typeof argv.path === "string" && argv.path.trim()) return [path$1.resolve(argv.path.trim())];
1321
- if (typeof argv.agent === "string") {
1322
- const target = findTarget(argv.agent);
1323
- if (!target) {
1324
- ui.log.error(`Unsupported agent: ${argv.agent}`);
1325
- return [];
1326
- }
1327
- return [target.instructionsPath()];
1328
- }
1329
- const detected = detectTargets();
1330
- if (detected.length === 0) {
1331
- ui.log.error("No supported coding agents detected. Pass --agent <id> or --path <file> to choose a target.");
1332
- ui.log.info(`Supported agents: ${CLI_STEERING_TARGETS.map((t) => t.id).join(", ")}`);
1333
- return [];
1334
- }
1335
- if (argv.all === true) {
1336
- ui.log.info(`Installing for all detected agents: ${detected.map((t) => t.name).join(", ")}`);
1337
- return detected.map((target) => target.instructionsPath());
1338
- }
1339
- if (detected.length === 1) {
1340
- ui.log.info(`Detected ${detected[0].name} (${detected[0].instructionsPath()})`);
1341
- return [detected[0].instructionsPath()];
1342
- }
1343
- if (!process.stdin.isTTY || !process.stdout.isTTY) {
1344
- ui.log.info(`Installing for all detected agents: ${detected.map((t) => t.name).join(", ")}`);
1345
- return detected.map((target) => target.instructionsPath());
1346
- }
1347
- return (await promptForTargets(detected)).map((target) => target.instructionsPath());
1348
- }
1349
- /** Minimal numbered selection — this command is intentionally not a TUI flow. */
1350
- async function promptForTargets(detected) {
1351
- const ui = getUI();
1352
- ui.log.info("Which coding agent are you using?");
1353
- detected.forEach((target, index) => {
1354
- ui.log.info(` ${index + 1}) ${target.name} (${target.instructionsPath()})`);
1355
- });
1356
- ui.log.info(` ${detected.length + 1}) All of the above`);
1357
- const rl = readline.createInterface({
1358
- input: process.stdin,
1359
- output: process.stdout
1360
- });
1361
- try {
1362
- for (;;) {
1363
- const answer = (await rl.question(`Select 1-${detected.length + 1}: `)).trim();
1364
- const choice = Number(answer);
1365
- if (Number.isInteger(choice) && choice >= 1 && choice <= detected.length) return [detected[choice - 1]];
1366
- if (choice === detected.length + 1) return detected;
1367
- ui.log.warn(`Enter a number between 1 and ${detected.length + 1}.`);
1368
- }
1369
- } finally {
1370
- rl.close();
1371
- }
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();
1372
1122
  }
1373
1123
  //#endregion
1374
- //#region src/commands/cli/index.ts
1375
- const cliCommand = {
1376
- name: "cli",
1377
- description: "PostHog CLI agent integration commands",
1378
- children: [cliAddCommand]
1379
- };
1380
- //#endregion
1381
1124
  //#region main.ts
1382
1125
  setGlobalDispatcher(new Agent({ allowH2: false }));
1383
1126
  recoverOrphanedSettingsBackups(resolveInstallDir());
@@ -1389,8 +1132,8 @@ function resolveInstallDir() {
1389
1132
  if (inline) return inline.slice(14);
1390
1133
  return process.env.POSTHOG_WIZARD_INSTALL_DIR ?? process.cwd();
1391
1134
  }
1392
- 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();
1393
1136
  //#endregion
1394
1137
  export {};
1395
1138
 
1396
- //# sourceMappingURL=main-CgKxbwMP.js.map
1139
+ //# sourceMappingURL=main-0p-YxUNa.js.map