@posthog/wizard 1.36.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (464) hide show
  1. package/README.md +79 -0
  2. package/dist/bin.js +199 -12
  3. package/dist/bin.js.map +1 -1
  4. package/dist/src/__tests__/cli.test.js +7 -18
  5. package/dist/src/__tests__/cli.test.js.map +1 -1
  6. package/dist/src/__tests__/run.test.js +50 -5
  7. package/dist/src/__tests__/run.test.js.map +1 -1
  8. package/dist/src/__tests__/wizard-abort.test.js +127 -0
  9. package/dist/src/__tests__/wizard-abort.test.js.map +1 -0
  10. package/dist/src/{android → frameworks/android}/android-wizard-agent.d.ts +1 -1
  11. package/dist/src/{android → frameworks/android}/android-wizard-agent.js +2 -2
  12. package/dist/src/frameworks/android/android-wizard-agent.js.map +1 -0
  13. package/dist/src/{android → frameworks/android}/utils.d.ts +1 -1
  14. package/dist/src/{android → frameworks/android}/utils.js +1 -1
  15. package/dist/src/frameworks/android/utils.js.map +1 -0
  16. package/dist/src/{angular → frameworks/angular}/angular-wizard-agent.d.ts +1 -1
  17. package/dist/src/{angular → frameworks/angular}/angular-wizard-agent.js +9 -7
  18. package/dist/src/frameworks/angular/angular-wizard-agent.js.map +1 -0
  19. package/dist/src/{angular → frameworks/angular}/utils.js +1 -1
  20. package/dist/src/frameworks/angular/utils.js.map +1 -0
  21. package/dist/src/{astro → frameworks/astro}/astro-wizard-agent.d.ts +1 -1
  22. package/dist/src/{astro → frameworks/astro}/astro-wizard-agent.js +9 -7
  23. package/dist/src/frameworks/astro/astro-wizard-agent.js.map +1 -0
  24. package/dist/src/{astro → frameworks/astro}/utils.d.ts +2 -5
  25. package/dist/src/{astro → frameworks/astro}/utils.js +3 -52
  26. package/dist/src/frameworks/astro/utils.js.map +1 -0
  27. package/dist/src/{django → frameworks/django}/django-wizard-agent.d.ts +1 -1
  28. package/dist/src/{django → frameworks/django}/django-wizard-agent.js +3 -3
  29. package/dist/src/frameworks/django/django-wizard-agent.js.map +1 -0
  30. package/dist/src/{django → frameworks/django}/utils.d.ts +1 -1
  31. package/dist/src/{django → frameworks/django}/utils.js +6 -6
  32. package/dist/src/frameworks/django/utils.js.map +1 -0
  33. package/dist/src/frameworks/fastapi/fastapi-wizard-agent.d.ts +5 -0
  34. package/dist/src/{fastapi → frameworks/fastapi}/fastapi-wizard-agent.js +3 -32
  35. package/dist/src/frameworks/fastapi/fastapi-wizard-agent.js.map +1 -0
  36. package/dist/src/{fastapi → frameworks/fastapi}/utils.d.ts +1 -1
  37. package/dist/src/{fastapi → frameworks/fastapi}/utils.js +4 -4
  38. package/dist/src/frameworks/fastapi/utils.js.map +1 -0
  39. package/dist/src/{flask → frameworks/flask}/flask-wizard-agent.d.ts +1 -1
  40. package/dist/src/{flask → frameworks/flask}/flask-wizard-agent.js +3 -3
  41. package/dist/src/frameworks/flask/flask-wizard-agent.js.map +1 -0
  42. package/dist/src/{flask → frameworks/flask}/utils.d.ts +1 -1
  43. package/dist/src/{flask → frameworks/flask}/utils.js +7 -7
  44. package/dist/src/frameworks/flask/utils.js.map +1 -0
  45. package/dist/src/{javascript-node → frameworks/javascript-node}/javascript-node-wizard-agent.d.ts +1 -1
  46. package/dist/src/{javascript-node → frameworks/javascript-node}/javascript-node-wizard-agent.js +4 -4
  47. package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.js.map +1 -0
  48. package/dist/src/{javascript-web → frameworks/javascript-web}/javascript-web-wizard-agent.d.ts +1 -1
  49. package/dist/src/{javascript-web → frameworks/javascript-web}/javascript-web-wizard-agent.js +16 -14
  50. package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.js.map +1 -0
  51. package/dist/src/{javascript-web → frameworks/javascript-web}/utils.d.ts +6 -1
  52. package/dist/src/{javascript-web → frameworks/javascript-web}/utils.js +49 -1
  53. package/dist/src/frameworks/javascript-web/utils.js.map +1 -0
  54. package/dist/src/{laravel → frameworks/laravel}/laravel-wizard-agent.d.ts +1 -1
  55. package/dist/src/{laravel → frameworks/laravel}/laravel-wizard-agent.js +2 -2
  56. package/dist/src/frameworks/laravel/laravel-wizard-agent.js.map +1 -0
  57. package/dist/src/{laravel → frameworks/laravel}/utils.d.ts +1 -1
  58. package/dist/src/{laravel → frameworks/laravel}/utils.js +5 -5
  59. package/dist/src/frameworks/laravel/utils.js.map +1 -0
  60. package/dist/src/{nextjs → frameworks/nextjs}/nextjs-wizard-agent.d.ts +1 -1
  61. package/dist/src/{nextjs → frameworks/nextjs}/nextjs-wizard-agent.js +30 -8
  62. package/dist/src/frameworks/nextjs/nextjs-wizard-agent.js.map +1 -0
  63. package/dist/src/{nextjs → frameworks/nextjs}/utils.d.ts +5 -2
  64. package/dist/src/{nextjs → frameworks/nextjs}/utils.js +6 -20
  65. package/dist/src/frameworks/nextjs/utils.js.map +1 -0
  66. package/dist/src/{nuxt → frameworks/nuxt}/nuxt-wizard-agent.d.ts +1 -1
  67. package/dist/src/{nuxt → frameworks/nuxt}/nuxt-wizard-agent.js +11 -9
  68. package/dist/src/frameworks/nuxt/nuxt-wizard-agent.js.map +1 -0
  69. package/dist/src/{python → frameworks/python}/python-wizard-agent.d.ts +1 -1
  70. package/dist/src/{python → frameworks/python}/python-wizard-agent.js +3 -3
  71. package/dist/src/frameworks/python/python-wizard-agent.js.map +1 -0
  72. package/dist/src/{python → frameworks/python}/utils.d.ts +1 -1
  73. package/dist/src/frameworks/python/utils.js.map +1 -0
  74. package/dist/src/{rails → frameworks/rails}/rails-wizard-agent.d.ts +1 -1
  75. package/dist/src/{rails → frameworks/rails}/rails-wizard-agent.js +2 -2
  76. package/dist/src/frameworks/rails/rails-wizard-agent.js.map +1 -0
  77. package/dist/src/{rails → frameworks/rails}/utils.d.ts +1 -1
  78. package/dist/src/{rails → frameworks/rails}/utils.js +4 -4
  79. package/dist/src/frameworks/rails/utils.js.map +1 -0
  80. package/dist/src/{react-native → frameworks/react-native}/react-native-wizard-agent.d.ts +1 -1
  81. package/dist/src/{react-native → frameworks/react-native}/react-native-wizard-agent.js +9 -7
  82. package/dist/src/frameworks/react-native/react-native-wizard-agent.js.map +1 -0
  83. package/dist/src/{react-native → frameworks/react-native}/utils.d.ts +1 -1
  84. package/dist/src/{react-native → frameworks/react-native}/utils.js +7 -10
  85. package/dist/src/frameworks/react-native/utils.js.map +1 -0
  86. package/dist/src/{react-router → frameworks/react-router}/react-router-wizard-agent.d.ts +1 -1
  87. package/dist/src/{react-router → frameworks/react-router}/react-router-wizard-agent.js +15 -8
  88. package/dist/src/frameworks/react-router/react-router-wizard-agent.js.map +1 -0
  89. package/dist/src/frameworks/react-router/utils.d.ts +13 -0
  90. package/dist/src/{react-router → frameworks/react-router}/utils.js +14 -111
  91. package/dist/src/frameworks/react-router/utils.js.map +1 -0
  92. package/dist/src/{ruby → frameworks/ruby}/ruby-wizard-agent.d.ts +1 -1
  93. package/dist/src/{ruby → frameworks/ruby}/ruby-wizard-agent.js +2 -2
  94. package/dist/src/frameworks/ruby/ruby-wizard-agent.js.map +1 -0
  95. package/dist/src/{ruby → frameworks/ruby}/utils.d.ts +1 -1
  96. package/dist/src/{ruby → frameworks/ruby}/utils.js +1 -1
  97. package/dist/src/frameworks/ruby/utils.js.map +1 -0
  98. package/dist/src/{svelte → frameworks/svelte}/svelte-wizard-agent.d.ts +1 -1
  99. package/dist/src/{svelte → frameworks/svelte}/svelte-wizard-agent.js +5 -5
  100. package/dist/src/frameworks/svelte/svelte-wizard-agent.js.map +1 -0
  101. package/dist/src/{swift → frameworks/swift}/swift-wizard-agent.d.ts +1 -1
  102. package/dist/src/{swift → frameworks/swift}/swift-wizard-agent.js +2 -2
  103. package/dist/src/frameworks/swift/swift-wizard-agent.js.map +1 -0
  104. package/dist/src/{swift → frameworks/swift}/utils.d.ts +1 -1
  105. package/dist/src/frameworks/swift/utils.js.map +1 -0
  106. package/dist/src/{tanstack-router → frameworks/tanstack-router}/tanstack-router-wizard-agent.d.ts +1 -1
  107. package/dist/src/{tanstack-router → frameworks/tanstack-router}/tanstack-router-wizard-agent.js +15 -8
  108. package/dist/src/frameworks/tanstack-router/tanstack-router-wizard-agent.js.map +1 -0
  109. package/dist/src/frameworks/tanstack-router/utils.d.ts +11 -0
  110. package/dist/src/{tanstack-router → frameworks/tanstack-router}/utils.js +4 -47
  111. package/dist/src/frameworks/tanstack-router/utils.js.map +1 -0
  112. package/dist/src/{tanstack-start → frameworks/tanstack-start}/tanstack-start-wizard-agent.d.ts +1 -1
  113. package/dist/src/{tanstack-start → frameworks/tanstack-start}/tanstack-start-wizard-agent.js +9 -7
  114. package/dist/src/frameworks/tanstack-start/tanstack-start-wizard-agent.js.map +1 -0
  115. package/dist/src/{tanstack-start → frameworks/tanstack-start}/utils.js +1 -1
  116. package/dist/src/frameworks/tanstack-start/utils.js.map +1 -0
  117. package/dist/src/{vue → frameworks/vue}/vue-wizard-agent.d.ts +1 -1
  118. package/dist/src/{vue → frameworks/vue}/vue-wizard-agent.js +8 -8
  119. package/dist/src/frameworks/vue/vue-wizard-agent.js.map +1 -0
  120. package/dist/src/lib/__tests__/agent-interface.test.js +91 -19
  121. package/dist/src/lib/__tests__/agent-interface.test.js.map +1 -1
  122. package/dist/src/lib/agent-interface.d.ts +49 -2
  123. package/dist/src/lib/agent-interface.js +254 -40
  124. package/dist/src/lib/agent-interface.js.map +1 -1
  125. package/dist/src/lib/agent-runner.d.ts +4 -2
  126. package/dist/src/lib/agent-runner.js +132 -126
  127. package/dist/src/lib/agent-runner.js.map +1 -1
  128. package/dist/src/lib/api.d.ts +4 -4
  129. package/dist/src/lib/commandments.js +1 -0
  130. package/dist/src/lib/commandments.js.map +1 -1
  131. package/dist/src/lib/constants.d.ts +22 -9
  132. package/dist/src/lib/constants.js +35 -11
  133. package/dist/src/lib/constants.js.map +1 -1
  134. package/dist/src/lib/framework-config.d.ts +26 -0
  135. package/dist/src/lib/framework-config.js.map +1 -1
  136. package/dist/src/lib/health-checks/__tests__/health-checks.test.d.ts +18 -0
  137. package/dist/src/lib/health-checks/__tests__/health-checks.test.js +752 -0
  138. package/dist/src/lib/health-checks/__tests__/health-checks.test.js.map +1 -0
  139. package/dist/src/lib/health-checks/endpoints.d.ts +3 -0
  140. package/dist/src/lib/health-checks/endpoints.js +46 -0
  141. package/dist/src/lib/health-checks/endpoints.js.map +1 -0
  142. package/dist/src/lib/health-checks/index.d.ts +4 -0
  143. package/dist/src/lib/health-checks/index.js +23 -0
  144. package/dist/src/lib/health-checks/index.js.map +1 -0
  145. package/dist/src/lib/health-checks/readiness.d.ts +24 -0
  146. package/dist/src/lib/health-checks/readiness.js +119 -0
  147. package/dist/src/lib/health-checks/readiness.js.map +1 -0
  148. package/dist/src/lib/health-checks/statuspage.d.ts +9 -0
  149. package/dist/src/lib/health-checks/statuspage.js +105 -0
  150. package/dist/src/lib/health-checks/statuspage.js.map +1 -0
  151. package/dist/src/lib/health-checks/types.d.ts +31 -0
  152. package/dist/src/lib/health-checks/types.js +10 -0
  153. package/dist/src/lib/health-checks/types.js.map +1 -0
  154. package/dist/src/lib/middleware/benchmark.d.ts +2 -2
  155. package/dist/src/lib/middleware/benchmark.js +3 -3
  156. package/dist/src/lib/middleware/benchmark.js.map +1 -1
  157. package/dist/src/lib/middleware/benchmarks/json-writer.js +2 -2
  158. package/dist/src/lib/middleware/benchmarks/json-writer.js.map +1 -1
  159. package/dist/src/lib/middleware/benchmarks/summary.d.ts +2 -2
  160. package/dist/src/lib/middleware/benchmarks/summary.js +9 -9
  161. package/dist/src/lib/middleware/benchmarks/summary.js.map +1 -1
  162. package/dist/src/lib/middleware/types.d.ts +2 -2
  163. package/dist/src/lib/middleware/types.js.map +1 -1
  164. package/dist/src/lib/package-manager-detection.js +1 -1
  165. package/dist/src/lib/package-manager-detection.js.map +1 -1
  166. package/dist/src/lib/registry.js +21 -21
  167. package/dist/src/lib/registry.js.map +1 -1
  168. package/dist/src/lib/version.d.ts +1 -1
  169. package/dist/src/lib/version.js +1 -1
  170. package/dist/src/lib/version.js.map +1 -1
  171. package/dist/src/lib/wizard-session.d.ts +115 -0
  172. package/dist/src/lib/wizard-session.js +104 -0
  173. package/dist/src/lib/wizard-session.js.map +1 -0
  174. package/dist/src/lib/wizard-tools.js +13 -0
  175. package/dist/src/lib/wizard-tools.js.map +1 -1
  176. package/dist/src/run.d.ts +3 -1
  177. package/dist/src/run.js +73 -55
  178. package/dist/src/run.js.map +1 -1
  179. package/dist/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.js +18 -22
  180. package/dist/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.js.map +1 -1
  181. package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.d.ts +6 -6
  182. package/dist/src/steps/add-mcp-server-to-clients/clients/claude.d.ts +6 -6
  183. package/dist/src/steps/add-mcp-server-to-clients/clients/codex.d.ts +7 -7
  184. package/dist/src/steps/add-mcp-server-to-clients/clients/codex.js +8 -9
  185. package/dist/src/steps/add-mcp-server-to-clients/clients/codex.js.map +1 -1
  186. package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.d.ts +6 -6
  187. package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.d.ts +6 -6
  188. package/dist/src/steps/add-mcp-server-to-clients/clients/zed.d.ts +6 -6
  189. package/dist/src/steps/add-mcp-server-to-clients/defaults.d.ts +6 -6
  190. package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +5 -2
  191. package/dist/src/steps/add-mcp-server-to-clients/index.js +24 -107
  192. package/dist/src/steps/add-mcp-server-to-clients/index.js.map +1 -1
  193. package/dist/src/steps/add-or-update-environment-variables.js +15 -20
  194. package/dist/src/steps/add-or-update-environment-variables.js.map +1 -1
  195. package/dist/src/steps/index.d.ts +0 -1
  196. package/dist/src/steps/index.js +0 -1
  197. package/dist/src/steps/index.js.map +1 -1
  198. package/dist/src/steps/run-prettier.js +9 -11
  199. package/dist/src/steps/run-prettier.js.map +1 -1
  200. package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +6 -3
  201. package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js.map +1 -1
  202. package/dist/src/steps/upload-environment-variables/index.d.ts +3 -3
  203. package/dist/src/steps/upload-environment-variables/index.js +7 -35
  204. package/dist/src/steps/upload-environment-variables/index.js.map +1 -1
  205. package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +3 -2
  206. package/dist/src/steps/upload-environment-variables/providers/vercel.js +2 -2
  207. package/dist/src/steps/upload-environment-variables/providers/vercel.js.map +1 -1
  208. package/dist/src/ui/index.d.ts +8 -0
  209. package/dist/src/ui/index.js +17 -0
  210. package/dist/src/ui/index.js.map +1 -0
  211. package/dist/src/ui/logging-ui.d.ts +44 -0
  212. package/dist/src/ui/logging-ui.js +103 -0
  213. package/dist/src/ui/logging-ui.js.map +1 -0
  214. package/dist/src/ui/tui/App.d.ts +6 -0
  215. package/dist/src/ui/tui/App.js +10 -0
  216. package/dist/src/ui/tui/App.js.map +1 -0
  217. package/dist/src/ui/tui/__tests__/layout-helpers.test.js +68 -0
  218. package/dist/src/ui/tui/__tests__/layout-helpers.test.js.map +1 -0
  219. package/dist/src/ui/tui/__tests__/store.test.d.ts +1 -0
  220. package/dist/src/ui/tui/__tests__/store.test.js +723 -0
  221. package/dist/src/ui/tui/__tests__/store.test.js.map +1 -0
  222. package/dist/src/ui/tui/components/LearnCard.d.ts +10 -0
  223. package/dist/src/ui/tui/components/LearnCard.js +217 -0
  224. package/dist/src/ui/tui/components/LearnCard.js.map +1 -0
  225. package/dist/src/ui/tui/components/TipsCard.d.ts +9 -0
  226. package/dist/src/ui/tui/components/TipsCard.js +55 -0
  227. package/dist/src/ui/tui/components/TipsCard.js.map +1 -0
  228. package/dist/src/ui/tui/components/TitleBar.d.ts +6 -0
  229. package/dist/src/ui/tui/components/TitleBar.js +17 -0
  230. package/dist/src/ui/tui/components/TitleBar.js.map +1 -0
  231. package/dist/src/ui/tui/flows.d.ts +38 -0
  232. package/dist/src/ui/tui/flows.js +82 -0
  233. package/dist/src/ui/tui/flows.js.map +1 -0
  234. package/dist/src/ui/tui/hooks/useStdoutDimensions.d.ts +9 -0
  235. package/dist/src/ui/tui/hooks/useStdoutDimensions.js +37 -0
  236. package/dist/src/ui/tui/hooks/useStdoutDimensions.js.map +1 -0
  237. package/dist/src/ui/tui/ink-ui.d.ts +50 -0
  238. package/dist/src/ui/tui/ink-ui.js +108 -0
  239. package/dist/src/ui/tui/ink-ui.js.map +1 -0
  240. package/dist/src/ui/tui/package.json +1 -0
  241. package/dist/src/ui/tui/playground/PlaygroundApp.d.ts +12 -0
  242. package/dist/src/ui/tui/playground/PlaygroundApp.js +32 -0
  243. package/dist/src/ui/tui/playground/PlaygroundApp.js.map +1 -0
  244. package/dist/src/ui/tui/playground/demos/InputDemo.d.ts +4 -0
  245. package/dist/src/ui/tui/playground/demos/InputDemo.js +53 -0
  246. package/dist/src/ui/tui/playground/demos/InputDemo.js.map +1 -0
  247. package/dist/src/ui/tui/playground/demos/LayoutDemo.d.ts +5 -0
  248. package/dist/src/ui/tui/playground/demos/LayoutDemo.js +25 -0
  249. package/dist/src/ui/tui/playground/demos/LayoutDemo.js.map +1 -0
  250. package/dist/src/ui/tui/playground/demos/LogDemo.d.ts +5 -0
  251. package/dist/src/ui/tui/playground/demos/LogDemo.js +53 -0
  252. package/dist/src/ui/tui/playground/demos/LogDemo.js.map +1 -0
  253. package/dist/src/ui/tui/playground/demos/ProgressDemo.d.ts +5 -0
  254. package/dist/src/ui/tui/playground/demos/ProgressDemo.js +58 -0
  255. package/dist/src/ui/tui/playground/demos/ProgressDemo.js.map +1 -0
  256. package/dist/src/ui/tui/playground/demos/RunScreenDemo.d.ts +11 -0
  257. package/dist/src/ui/tui/playground/demos/RunScreenDemo.js +159 -0
  258. package/dist/src/ui/tui/playground/demos/RunScreenDemo.js.map +1 -0
  259. package/dist/src/ui/tui/playground/demos/WelcomeDemo.d.ts +9 -0
  260. package/dist/src/ui/tui/playground/demos/WelcomeDemo.js +15 -0
  261. package/dist/src/ui/tui/playground/demos/WelcomeDemo.js.map +1 -0
  262. package/dist/src/ui/tui/playground/start-playground.d.ts +4 -0
  263. package/dist/src/ui/tui/playground/start-playground.js +24 -0
  264. package/dist/src/ui/tui/playground/start-playground.js.map +1 -0
  265. package/dist/src/ui/tui/primitives/CardLayout.d.ts +12 -0
  266. package/dist/src/ui/tui/primitives/CardLayout.js +10 -0
  267. package/dist/src/ui/tui/primitives/CardLayout.js.map +1 -0
  268. package/dist/src/ui/tui/primitives/ConfirmationInput.d.ts +13 -0
  269. package/dist/src/ui/tui/primitives/ConfirmationInput.js +35 -0
  270. package/dist/src/ui/tui/primitives/ConfirmationInput.js.map +1 -0
  271. package/dist/src/ui/tui/primitives/ContentSequencer.d.ts +42 -0
  272. package/dist/src/ui/tui/primitives/ContentSequencer.js +137 -0
  273. package/dist/src/ui/tui/primitives/ContentSequencer.js.map +1 -0
  274. package/dist/src/ui/tui/primitives/DissolveTransition.d.ts +21 -0
  275. package/dist/src/ui/tui/primitives/DissolveTransition.js +149 -0
  276. package/dist/src/ui/tui/primitives/DissolveTransition.js.map +1 -0
  277. package/dist/src/ui/tui/primitives/EventPlanViewer.d.ts +9 -0
  278. package/dist/src/ui/tui/primitives/EventPlanViewer.js +9 -0
  279. package/dist/src/ui/tui/primitives/EventPlanViewer.js.map +1 -0
  280. package/dist/src/ui/tui/primitives/HNViewer.d.ts +7 -0
  281. package/dist/src/ui/tui/primitives/HNViewer.js +63 -0
  282. package/dist/src/ui/tui/primitives/HNViewer.js.map +1 -0
  283. package/dist/src/ui/tui/primitives/LinesBlock.d.ts +16 -0
  284. package/dist/src/ui/tui/primitives/LinesBlock.js +37 -0
  285. package/dist/src/ui/tui/primitives/LinesBlock.js.map +1 -0
  286. package/dist/src/ui/tui/primitives/LoadingBox.d.ts +8 -0
  287. package/dist/src/ui/tui/primitives/LoadingBox.js +10 -0
  288. package/dist/src/ui/tui/primitives/LoadingBox.js.map +1 -0
  289. package/dist/src/ui/tui/primitives/LogViewer.d.ts +11 -0
  290. package/dist/src/ui/tui/primitives/LogViewer.js +55 -0
  291. package/dist/src/ui/tui/primitives/LogViewer.js.map +1 -0
  292. package/dist/src/ui/tui/primitives/NodeBlock.d.ts +13 -0
  293. package/dist/src/ui/tui/primitives/NodeBlock.js +17 -0
  294. package/dist/src/ui/tui/primitives/NodeBlock.js.map +1 -0
  295. package/dist/src/ui/tui/primitives/PickerMenu.d.ts +20 -0
  296. package/dist/src/ui/tui/primitives/PickerMenu.js +134 -0
  297. package/dist/src/ui/tui/primitives/PickerMenu.js.map +1 -0
  298. package/dist/src/ui/tui/primitives/ProgressList.d.ts +15 -0
  299. package/dist/src/ui/tui/primitives/ProgressList.js +30 -0
  300. package/dist/src/ui/tui/primitives/ProgressList.js.map +1 -0
  301. package/dist/src/ui/tui/primitives/PromptLabel.d.ts +11 -0
  302. package/dist/src/ui/tui/primitives/PromptLabel.js +13 -0
  303. package/dist/src/ui/tui/primitives/PromptLabel.js.map +1 -0
  304. package/dist/src/ui/tui/primitives/ScreenContainer.d.ts +16 -0
  305. package/dist/src/ui/tui/primitives/ScreenContainer.js +36 -0
  306. package/dist/src/ui/tui/primitives/ScreenContainer.js.map +1 -0
  307. package/dist/src/ui/tui/primitives/ScreenErrorBoundary.d.ts +22 -0
  308. package/dist/src/ui/tui/primitives/ScreenErrorBoundary.js +35 -0
  309. package/dist/src/ui/tui/primitives/ScreenErrorBoundary.js.map +1 -0
  310. package/dist/src/ui/tui/primitives/SplitView.d.ts +11 -0
  311. package/dist/src/ui/tui/primitives/SplitView.js +9 -0
  312. package/dist/src/ui/tui/primitives/SplitView.js.map +1 -0
  313. package/dist/src/ui/tui/primitives/TabContainer.d.ts +23 -0
  314. package/dist/src/ui/tui/primitives/TabContainer.js +45 -0
  315. package/dist/src/ui/tui/primitives/TabContainer.js.map +1 -0
  316. package/dist/src/ui/tui/primitives/TextBlock.d.ts +41 -0
  317. package/dist/src/ui/tui/primitives/TextBlock.js +144 -0
  318. package/dist/src/ui/tui/primitives/TextBlock.js.map +1 -0
  319. package/dist/src/ui/tui/primitives/content-types.d.ts +37 -0
  320. package/dist/src/ui/tui/primitives/content-types.js +19 -0
  321. package/dist/src/ui/tui/primitives/content-types.js.map +1 -0
  322. package/dist/src/ui/tui/primitives/index.d.ts +24 -0
  323. package/dist/src/ui/tui/primitives/index.js +21 -0
  324. package/dist/src/ui/tui/primitives/index.js.map +1 -0
  325. package/dist/src/ui/tui/primitives/layout-helpers.d.ts +36 -0
  326. package/dist/src/ui/tui/primitives/layout-helpers.js +95 -0
  327. package/dist/src/ui/tui/primitives/layout-helpers.js.map +1 -0
  328. package/dist/src/ui/tui/primitives/text-helpers.d.ts +10 -0
  329. package/dist/src/ui/tui/primitives/text-helpers.js +43 -0
  330. package/dist/src/ui/tui/primitives/text-helpers.js.map +1 -0
  331. package/dist/src/ui/tui/router.d.ts +56 -0
  332. package/dist/src/ui/tui/router.js +94 -0
  333. package/dist/src/ui/tui/router.js.map +1 -0
  334. package/dist/src/ui/tui/screen-registry.d.ts +19 -0
  335. package/dist/src/ui/tui/screen-registry.js +34 -0
  336. package/dist/src/ui/tui/screen-registry.js.map +1 -0
  337. package/dist/src/ui/tui/screens/AuthScreen.d.ts +13 -0
  338. package/dist/src/ui/tui/screens/AuthScreen.js +20 -0
  339. package/dist/src/ui/tui/screens/AuthScreen.js.map +1 -0
  340. package/dist/src/ui/tui/screens/IntroScreen.d.ts +16 -0
  341. package/dist/src/ui/tui/screens/IntroScreen.js +63 -0
  342. package/dist/src/ui/tui/screens/IntroScreen.js.map +1 -0
  343. package/dist/src/ui/tui/screens/McpScreen.d.ts +24 -0
  344. package/dist/src/ui/tui/screens/McpScreen.js +112 -0
  345. package/dist/src/ui/tui/screens/McpScreen.js.map +1 -0
  346. package/dist/src/ui/tui/screens/OutageScreen.d.ts +10 -0
  347. package/dist/src/ui/tui/screens/OutageScreen.js +17 -0
  348. package/dist/src/ui/tui/screens/OutageScreen.js.map +1 -0
  349. package/dist/src/ui/tui/screens/OutroScreen.d.ts +11 -0
  350. package/dist/src/ui/tui/screens/OutroScreen.js +22 -0
  351. package/dist/src/ui/tui/screens/OutroScreen.js.map +1 -0
  352. package/dist/src/ui/tui/screens/RunScreen.d.ts +16 -0
  353. package/dist/src/ui/tui/screens/RunScreen.js +73 -0
  354. package/dist/src/ui/tui/screens/RunScreen.js.map +1 -0
  355. package/dist/src/ui/tui/screens/SettingsOverrideScreen.d.ts +10 -0
  356. package/dist/src/ui/tui/screens/SettingsOverrideScreen.js +24 -0
  357. package/dist/src/ui/tui/screens/SettingsOverrideScreen.js.map +1 -0
  358. package/dist/src/ui/tui/screens/SetupScreen.d.ts +13 -0
  359. package/dist/src/ui/tui/screens/SetupScreen.js +74 -0
  360. package/dist/src/ui/tui/screens/SetupScreen.js.map +1 -0
  361. package/dist/src/ui/tui/services/mcp-installer.d.ts +21 -0
  362. package/dist/src/ui/tui/services/mcp-installer.js +58 -0
  363. package/dist/src/ui/tui/services/mcp-installer.js.map +1 -0
  364. package/dist/src/ui/tui/start-tui.d.ts +9 -0
  365. package/dist/src/ui/tui/start-tui.js +41 -0
  366. package/dist/src/ui/tui/start-tui.js.map +1 -0
  367. package/dist/src/ui/tui/store.d.ts +132 -0
  368. package/dist/src/ui/tui/store.js +320 -0
  369. package/dist/src/ui/tui/store.js.map +1 -0
  370. package/dist/src/ui/tui/styles.d.ts +31 -0
  371. package/dist/src/ui/tui/styles.js +34 -0
  372. package/dist/src/ui/tui/styles.js.map +1 -0
  373. package/dist/src/ui/wizard-ui.d.ts +64 -0
  374. package/dist/src/ui/wizard-ui.js +19 -0
  375. package/dist/src/ui/wizard-ui.js.map +1 -0
  376. package/dist/src/utils/__tests__/setup-utils.test.d.ts +1 -0
  377. package/dist/src/utils/__tests__/{clack-utils.test.js → setup-utils.test.js} +31 -22
  378. package/dist/src/utils/__tests__/setup-utils.test.js.map +1 -0
  379. package/dist/src/utils/analytics.d.ts +18 -0
  380. package/dist/src/utils/analytics.js +53 -0
  381. package/dist/src/utils/analytics.js.map +1 -1
  382. package/dist/src/utils/anthropic-status.d.ts +1 -12
  383. package/dist/src/utils/anthropic-status.js +4 -56
  384. package/dist/src/utils/anthropic-status.js.map +1 -1
  385. package/dist/src/utils/custom-headers.d.ts +9 -0
  386. package/dist/src/utils/custom-headers.js +24 -0
  387. package/dist/src/utils/custom-headers.js.map +1 -0
  388. package/dist/src/utils/debug.js +2 -2
  389. package/dist/src/utils/debug.js.map +1 -1
  390. package/dist/src/utils/environment.js +4 -2
  391. package/dist/src/utils/environment.js.map +1 -1
  392. package/dist/src/utils/oauth.js +9 -10
  393. package/dist/src/utils/oauth.js.map +1 -1
  394. package/dist/src/utils/package-manager.js +13 -13
  395. package/dist/src/utils/package-manager.js.map +1 -1
  396. package/dist/src/utils/setup-utils.d.ts +76 -0
  397. package/dist/src/utils/setup-utils.js +364 -0
  398. package/dist/src/utils/setup-utils.js.map +1 -0
  399. package/dist/src/utils/wizard-abort.d.ts +13 -0
  400. package/dist/src/utils/wizard-abort.js +57 -0
  401. package/dist/src/utils/wizard-abort.js.map +1 -0
  402. package/package.json +19 -7
  403. package/dist/src/android/android-wizard-agent.js.map +0 -1
  404. package/dist/src/android/utils.js.map +0 -1
  405. package/dist/src/angular/angular-wizard-agent.js.map +0 -1
  406. package/dist/src/angular/utils.js.map +0 -1
  407. package/dist/src/astro/astro-wizard-agent.js.map +0 -1
  408. package/dist/src/astro/utils.js.map +0 -1
  409. package/dist/src/django/django-wizard-agent.js.map +0 -1
  410. package/dist/src/django/utils.js.map +0 -1
  411. package/dist/src/fastapi/fastapi-wizard-agent.d.ts +0 -7
  412. package/dist/src/fastapi/fastapi-wizard-agent.js.map +0 -1
  413. package/dist/src/fastapi/utils.js.map +0 -1
  414. package/dist/src/flask/flask-wizard-agent.js.map +0 -1
  415. package/dist/src/flask/utils.js.map +0 -1
  416. package/dist/src/javascript-node/javascript-node-wizard-agent.js.map +0 -1
  417. package/dist/src/javascript-web/javascript-web-wizard-agent.js.map +0 -1
  418. package/dist/src/javascript-web/utils.js.map +0 -1
  419. package/dist/src/laravel/laravel-wizard-agent.js.map +0 -1
  420. package/dist/src/laravel/utils.js.map +0 -1
  421. package/dist/src/mcp.d.ts +0 -8
  422. package/dist/src/mcp.js +0 -44
  423. package/dist/src/mcp.js.map +0 -1
  424. package/dist/src/nextjs/nextjs-wizard-agent.js.map +0 -1
  425. package/dist/src/nextjs/utils.js.map +0 -1
  426. package/dist/src/nuxt/nuxt-wizard-agent.js.map +0 -1
  427. package/dist/src/python/python-wizard-agent.js.map +0 -1
  428. package/dist/src/python/utils.js.map +0 -1
  429. package/dist/src/rails/rails-wizard-agent.js.map +0 -1
  430. package/dist/src/rails/utils.js.map +0 -1
  431. package/dist/src/react-native/react-native-wizard-agent.js.map +0 -1
  432. package/dist/src/react-native/utils.js.map +0 -1
  433. package/dist/src/react-router/react-router-wizard-agent.js.map +0 -1
  434. package/dist/src/react-router/utils.d.ts +0 -19
  435. package/dist/src/react-router/utils.js.map +0 -1
  436. package/dist/src/ruby/ruby-wizard-agent.js.map +0 -1
  437. package/dist/src/ruby/utils.js.map +0 -1
  438. package/dist/src/steps/__tests__/add-editor-rules.test.js +0 -208
  439. package/dist/src/steps/__tests__/add-editor-rules.test.js.map +0 -1
  440. package/dist/src/steps/add-editor-rules.d.ts +0 -8
  441. package/dist/src/steps/add-editor-rules.js +0 -71
  442. package/dist/src/steps/add-editor-rules.js.map +0 -1
  443. package/dist/src/svelte/svelte-wizard-agent.js.map +0 -1
  444. package/dist/src/swift/swift-wizard-agent.js.map +0 -1
  445. package/dist/src/swift/utils.js.map +0 -1
  446. package/dist/src/tanstack-router/tanstack-router-wizard-agent.js.map +0 -1
  447. package/dist/src/tanstack-router/utils.d.ts +0 -17
  448. package/dist/src/tanstack-router/utils.js.map +0 -1
  449. package/dist/src/tanstack-start/tanstack-start-wizard-agent.js.map +0 -1
  450. package/dist/src/tanstack-start/utils.js.map +0 -1
  451. package/dist/src/utils/__tests__/clack-utils.test.js.map +0 -1
  452. package/dist/src/utils/clack-utils.d.ts +0 -188
  453. package/dist/src/utils/clack-utils.js +0 -705
  454. package/dist/src/utils/clack-utils.js.map +0 -1
  455. package/dist/src/utils/clack.d.ts +0 -2
  456. package/dist/src/utils/clack.js +0 -9
  457. package/dist/src/utils/clack.js.map +0 -1
  458. package/dist/src/vue/vue-wizard-agent.js.map +0 -1
  459. /package/dist/src/{steps/__tests__/add-editor-rules.test.d.ts → __tests__/wizard-abort.test.d.ts} +0 -0
  460. /package/dist/src/{angular → frameworks/angular}/utils.d.ts +0 -0
  461. /package/dist/src/{python → frameworks/python}/utils.js +0 -0
  462. /package/dist/src/{swift → frameworks/swift}/utils.js +0 -0
  463. /package/dist/src/{tanstack-start → frameworks/tanstack-start}/utils.d.ts +0 -0
  464. /package/dist/src/{utils/__tests__/clack-utils.test.d.ts → ui/tui/__tests__/layout-helpers.test.d.ts} +0 -0
@@ -38,72 +38,101 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.runAgentWizard = runAgentWizard;
40
40
  const framework_config_1 = require("./framework-config");
41
- const clack_utils_1 = require("../utils/clack-utils");
41
+ const wizard_session_1 = require("./wizard-session");
42
+ const setup_utils_1 = require("../utils/setup-utils");
42
43
  const analytics_1 = require("../utils/analytics");
43
- const constants_1 = require("./constants");
44
- const clack_1 = __importDefault(require("../utils/clack"));
44
+ const ui_1 = require("../ui");
45
45
  const agent_interface_1 = require("./agent-interface");
46
46
  const urls_1 = require("../utils/urls");
47
47
  const chalk_1 = __importDefault(require("chalk"));
48
48
  const semver = __importStar(require("semver"));
49
- const steps_1 = require("../steps");
50
49
  const anthropic_status_1 = require("../utils/anthropic-status");
51
50
  const debug_1 = require("../utils/debug");
52
51
  const benchmark_1 = require("./middleware/benchmark");
52
+ const wizard_abort_1 = require("../utils/wizard-abort");
53
+ /**
54
+ * Build a WizardOptions bag from a WizardSession (for code that still expects WizardOptions).
55
+ */
56
+ function sessionToOptions(session) {
57
+ return {
58
+ installDir: session.installDir,
59
+ debug: session.debug,
60
+ forceInstall: session.forceInstall,
61
+ default: false,
62
+ signup: session.signup,
63
+ localMcp: session.localMcp,
64
+ ci: session.ci,
65
+ menu: session.menu,
66
+ benchmark: session.benchmark,
67
+ projectId: session.projectId,
68
+ apiKey: session.apiKey,
69
+ };
70
+ }
53
71
  /**
54
72
  * Universal agent-powered wizard runner.
55
73
  * Handles the complete flow for any framework using PostHog MCP integration.
74
+ *
75
+ * All user decisions come from the session — no UI prompts.
56
76
  */
57
- async function runAgentWizard(config, options) {
58
- if (options.debug) {
77
+ async function runAgentWizard(config, session) {
78
+ if (session.debug) {
59
79
  (0, debug_1.enableDebugLogs)();
60
80
  }
61
81
  // Version check
62
82
  if (config.detection.minimumVersion && config.detection.getInstalledVersion) {
63
- const version = await config.detection.getInstalledVersion(options);
83
+ const version = await config.detection.getInstalledVersion(sessionToOptions(session));
64
84
  if (version) {
65
85
  const coerced = semver.coerce(version);
66
86
  if (coerced && semver.lt(coerced, config.detection.minimumVersion)) {
67
87
  const docsUrl = config.metadata.unsupportedVersionDocsUrl ?? config.metadata.docsUrl;
68
- clack_1.default.log.warn(`Sorry: the wizard can't help you with ${config.metadata.name} ${version}. Upgrade to ${config.metadata.name} ${config.detection.minimumVersion} or later, or check out the manual setup guide.`);
69
- clack_1.default.log.info(`Setup ${config.metadata.name} manually: ${chalk_1.default.cyan(docsUrl)}`);
70
- clack_1.default.outro('PostHog wizard will see you next time!');
88
+ (0, ui_1.getUI)().log.warn(`Sorry: the wizard can't help you with ${config.metadata.name} ${version}. Upgrade to ${config.metadata.name} ${config.detection.minimumVersion} or later, or check out the manual setup guide.`);
89
+ (0, ui_1.getUI)().log.info(`Setup ${config.metadata.name} manually: ${chalk_1.default.cyan(docsUrl)}`);
90
+ (0, ui_1.getUI)().outro('PostHog wizard will see you next time!');
71
91
  return;
72
92
  }
73
93
  }
74
94
  }
75
- // Setup phase
76
- (0, clack_utils_1.printWelcome)({ wizardName: (0, framework_config_1.getWelcomeMessage)(config.metadata.name) });
77
- if (config.metadata.beta) {
78
- clack_1.default.log.info(`${chalk_1.default.yellow('[BETA]')} The ${config.metadata.name} wizard is in beta. Questions or feedback? Email ${chalk_1.default.cyan('wizard@posthog.com')}`);
79
- }
80
- if (config.metadata.preRunNotice) {
81
- clack_1.default.log.warn(config.metadata.preRunNotice);
82
- }
83
- clack_1.default.log.info(`We're about to read your project using our LLM gateway.\n\n.env* file contents will not leave your machine.\n\nOther files will be read and edited to provide a fully-custom PostHog integration.`);
84
- const aiConsent = await (0, clack_utils_1.askForAIConsent)(options);
85
- if (!aiConsent) {
86
- await (0, clack_utils_1.abort)(`This wizard uses an LLM agent to intelligently modify your project. Please view the docs to set up ${config.metadata.name} manually instead: ${config.metadata.docsUrl}`, 0);
95
+ // Setup phase — informational only, no prompts
96
+ // Beta notice, pre-run notice, and welcome label are all derivable
97
+ // from session.frameworkConfig — IntroScreen reads them directly.
98
+ // Check Anthropic/Claude service status (pure no prompt)
99
+ const statusResult = await (0, anthropic_status_1.checkAnthropicStatus)();
100
+ if (statusResult.status === 'down' || statusResult.status === 'degraded') {
101
+ (0, ui_1.getUI)().showServiceStatus({
102
+ description: statusResult.description,
103
+ statusPageUrl: 'https://status.claude.com',
104
+ });
87
105
  }
88
- // Check Anthropic/Claude service status before proceeding
89
- const statusOk = await (0, anthropic_status_1.checkAnthropicStatusWithPrompt)({ ci: options.ci });
90
- if (!statusOk) {
91
- await (0, clack_utils_1.abort)(`Please try again later, or set up ${config.metadata.name} manually: ${config.metadata.docsUrl}`, 0);
106
+ // Check for blocking env overrides in .claude/settings.json before login.
107
+ // These keys block the Wizard from accessing the PostHog LLM Gateway.
108
+ const blockingOverrideKeys = (0, agent_interface_1.checkClaudeSettingsOverrides)(session.installDir);
109
+ if (blockingOverrideKeys.length > 0) {
110
+ await (0, ui_1.getUI)().showSettingsOverride(blockingOverrideKeys, () => (0, agent_interface_1.backupAndFixClaudeSettings)(session.installDir));
92
111
  }
93
- const typeScriptDetected = (0, clack_utils_1.isUsingTypeScript)(options);
94
- await (0, clack_utils_1.confirmContinueIfNoOrDirtyGitRepo)(options);
112
+ // Disclosure text is static — IntroScreen renders it directly.
113
+ const typeScriptDetected = (0, setup_utils_1.isUsingTypeScript)({
114
+ installDir: session.installDir,
115
+ });
116
+ session.typescript = typeScriptDetected;
95
117
  // Framework detection and version
96
- // Only check package.json for Node.js/JavaScript frameworks
97
118
  const usesPackageJson = config.detection.usesPackageJson !== false;
98
119
  let packageJson = null;
99
120
  let frameworkVersion;
100
121
  if (usesPackageJson) {
101
- packageJson = await (0, clack_utils_1.getPackageDotJson)(options);
102
- await (0, clack_utils_1.ensurePackageIsInstalled)(packageJson, config.detection.packageName, config.detection.packageDisplayName);
103
- frameworkVersion = config.detection.getVersion(packageJson);
122
+ packageJson = await (0, setup_utils_1.tryGetPackageJson)({ installDir: session.installDir });
123
+ if (packageJson) {
124
+ // Log warning if package not installed, but continue (agent handles it)
125
+ const { hasPackageInstalled } = await import('../utils/package-json.js');
126
+ if (!hasPackageInstalled(config.detection.packageName, packageJson)) {
127
+ (0, ui_1.getUI)().log.warn(`${config.detection.packageDisplayName} does not seem to be installed. Continuing anyway — the agent will handle it.`);
128
+ }
129
+ frameworkVersion = config.detection.getVersion(packageJson);
130
+ }
131
+ else {
132
+ (0, ui_1.getUI)().log.warn('Could not find package.json. Continuing anyway — the agent will handle it.');
133
+ }
104
134
  }
105
135
  else {
106
- // For non-Node frameworks (e.g., Django), version is handled differently
107
136
  frameworkVersion = config.detection.getVersion(null);
108
137
  }
109
138
  // Set analytics tags for framework version
@@ -111,16 +140,21 @@ async function runAgentWizard(config, options) {
111
140
  const versionBucket = config.detection.getVersionBucket(frameworkVersion);
112
141
  analytics_1.analytics.setTag(`${config.metadata.integration}-version`, versionBucket);
113
142
  }
114
- analytics_1.analytics.capture(constants_1.WIZARD_INTERACTION_EVENT_NAME, {
115
- action: 'started agent integration',
143
+ analytics_1.analytics.wizardCapture('agent started', {
116
144
  integration: config.metadata.integration,
117
145
  });
118
- // Get PostHog credentials
119
- const { projectApiKey, host, accessToken, projectId, cloudRegion } = await (0, clack_utils_1.getOrAskForProjectData)(options);
120
- // Gather framework-specific context (e.g., Next.js router, React Native platform)
121
- const frameworkContext = config.metadata.gatherContext
122
- ? await config.metadata.gatherContext(options)
123
- : {};
146
+ // Get PostHog credentials (region auto-detected from token)
147
+ const { projectApiKey, host, accessToken, projectId, cloudRegion } = await (0, setup_utils_1.getOrAskForProjectData)({
148
+ signup: session.signup,
149
+ ci: session.ci,
150
+ apiKey: session.apiKey,
151
+ projectId: session.projectId,
152
+ });
153
+ session.credentials = { accessToken, projectApiKey, host, projectId };
154
+ // Notify TUI that credentials are available (resolves past AuthScreen)
155
+ (0, ui_1.getUI)().setCredentials(session.credentials);
156
+ // Framework context was already gathered by SetupScreen + detection
157
+ const frameworkContext = session.frameworkContext;
124
158
  // Set analytics tags from framework context
125
159
  const contextTags = config.analytics.getTags(frameworkContext);
126
160
  Object.entries(contextTags).forEach(([key, value]) => {
@@ -134,102 +168,87 @@ async function runAgentWizard(config, options) {
134
168
  projectId,
135
169
  }, frameworkContext);
136
170
  // Initialize and run agent
137
- const spinner = clack_1.default.spinner();
138
- const mcpUrl = options.localMcp
171
+ const spinner = (0, ui_1.getUI)().spinner();
172
+ // Evaluate all feature flags at the start of the run so they can be sent to the LLM gateway
173
+ const wizardFlags = await analytics_1.analytics.getAllFlagsForWizard();
174
+ const wizardMetadata = (0, agent_interface_1.buildWizardMetadata)(wizardFlags);
175
+ // Determine MCP URL: CLI flag > env var > production default
176
+ const mcpUrl = session.localMcp
139
177
  ? 'http://localhost:8787/mcp'
140
178
  : process.env.MCP_URL || 'https://mcp.posthog.com/mcp';
179
+ const restoreSettings = () => (0, agent_interface_1.restoreClaudeSettings)(session.installDir);
180
+ (0, ui_1.getUI)().onEnterScreen('outro', restoreSettings);
181
+ (0, ui_1.getUI)().startRun();
141
182
  const agent = await (0, agent_interface_1.initializeAgent)({
142
- workingDirectory: options.installDir,
183
+ workingDirectory: session.installDir,
143
184
  posthogMcpUrl: mcpUrl,
144
185
  posthogApiKey: accessToken,
145
186
  posthogApiHost: host,
146
187
  additionalMcpServers: config.metadata.additionalMcpServers,
147
188
  detectPackageManager: config.detection.detectPackageManager,
148
- }, options);
149
- const middleware = options.benchmark
150
- ? (0, benchmark_1.createBenchmarkPipeline)(spinner, options)
189
+ wizardFlags,
190
+ wizardMetadata,
191
+ }, sessionToOptions(session));
192
+ const middleware = session.benchmark
193
+ ? (0, benchmark_1.createBenchmarkPipeline)(spinner, sessionToOptions(session))
151
194
  : undefined;
152
- const agentResult = await (0, agent_interface_1.runAgent)(agent, integrationPrompt, options, spinner, {
195
+ const agentResult = await (0, agent_interface_1.runAgent)(agent, integrationPrompt, sessionToOptions(session), spinner, {
153
196
  estimatedDurationMinutes: config.ui.estimatedDurationMinutes,
154
197
  spinnerMessage: framework_config_1.SPINNER_MESSAGE,
155
198
  successMessage: config.ui.successMessage,
156
199
  errorMessage: 'Integration failed',
200
+ additionalFeatureQueue: session.additionalFeatureQueue,
157
201
  }, middleware);
158
202
  // Handle error cases detected in agent output
159
203
  if (agentResult.error === agent_interface_1.AgentErrorType.MCP_MISSING) {
160
- analytics_1.analytics.captureException(new Error('Agent could not access PostHog MCP server'), {
161
- integration: config.metadata.integration,
162
- error_type: agent_interface_1.AgentErrorType.MCP_MISSING,
163
- signal: agent_interface_1.AgentSignals.ERROR_MCP_MISSING,
204
+ await (0, wizard_abort_1.wizardAbort)({
205
+ message: `Could not access the PostHog MCP server\n\nThe wizard was unable to connect to the PostHog MCP server.\nThis could be due to a network issue or a configuration problem.\n\nPlease try again, or set up ${config.metadata.name} manually by following our documentation:\n${config.metadata.docsUrl}`,
206
+ error: new wizard_abort_1.WizardError('Agent could not access PostHog MCP server', {
207
+ integration: config.metadata.integration,
208
+ error_type: agent_interface_1.AgentErrorType.MCP_MISSING,
209
+ signal: agent_interface_1.AgentSignals.ERROR_MCP_MISSING,
210
+ }),
164
211
  });
165
- const errorMessage = `
166
- ${chalk_1.default.red('❌ Could not access the PostHog MCP server')}
167
-
168
- The wizard was unable to connect to the PostHog MCP server.
169
- This could be due to a network issue or a configuration problem.
170
-
171
- Please try again, or set up ${config.metadata.name} manually by following our documentation:
172
- ${chalk_1.default.cyan(config.metadata.docsUrl)}`;
173
- clack_1.default.outro(errorMessage);
174
- await analytics_1.analytics.shutdown('error');
175
- process.exit(1);
176
212
  }
177
213
  if (agentResult.error === agent_interface_1.AgentErrorType.RESOURCE_MISSING) {
178
- analytics_1.analytics.captureException(new Error('Agent could not access setup resource'), {
179
- integration: config.metadata.integration,
180
- error_type: agent_interface_1.AgentErrorType.RESOURCE_MISSING,
181
- signal: agent_interface_1.AgentSignals.ERROR_RESOURCE_MISSING,
214
+ await (0, wizard_abort_1.wizardAbort)({
215
+ message: `Could not access the setup resource\n\nThe wizard could not access the setup resource. This may indicate a version mismatch or a temporary service issue.\n\nPlease try again, or set up ${config.metadata.name} manually by following our documentation:\n${config.metadata.docsUrl}`,
216
+ error: new wizard_abort_1.WizardError('Agent could not access setup resource', {
217
+ integration: config.metadata.integration,
218
+ error_type: agent_interface_1.AgentErrorType.RESOURCE_MISSING,
219
+ signal: agent_interface_1.AgentSignals.ERROR_RESOURCE_MISSING,
220
+ }),
182
221
  });
183
- const errorMessage = `
184
- ${chalk_1.default.red('❌ Could not access the setup resource')}
185
-
186
- The wizard could not access the setup resource. This may indicate a version mismatch or a temporary service issue.
187
-
188
- Please try again, or set up ${config.metadata.name} manually by following our documentation:
189
- ${chalk_1.default.cyan(config.metadata.docsUrl)}`;
190
- clack_1.default.outro(errorMessage);
191
- await analytics_1.analytics.shutdown('error');
192
- process.exit(1);
193
222
  }
194
223
  if (agentResult.error === agent_interface_1.AgentErrorType.RATE_LIMIT ||
195
224
  agentResult.error === agent_interface_1.AgentErrorType.API_ERROR) {
196
- analytics_1.analytics.capture(constants_1.WIZARD_INTERACTION_EVENT_NAME, {
197
- action: 'api error',
225
+ analytics_1.analytics.wizardCapture('agent api error', {
198
226
  integration: config.metadata.integration,
199
227
  error_type: agentResult.error,
200
228
  error_message: agentResult.message,
201
229
  });
202
- analytics_1.analytics.captureException(new Error(`API error: ${agentResult.message}`), {
203
- integration: config.metadata.integration,
204
- error_type: agentResult.error,
230
+ await (0, wizard_abort_1.wizardAbort)({
231
+ message: `API Error\n\n${agentResult.message || 'Unknown error'}\n\nPlease report this error to: wizard@posthog.com`,
232
+ error: new wizard_abort_1.WizardError(`API error: ${agentResult.message}`, {
233
+ integration: config.metadata.integration,
234
+ error_type: agentResult.error,
235
+ }),
205
236
  });
206
- const errorMessage = `
207
- ${chalk_1.default.red('❌ API Error')}
208
-
209
- ${chalk_1.default.yellow(agentResult.message || 'Unknown error')}
210
-
211
- Please report this error to: ${chalk_1.default.cyan('wizard@posthog.com')}`;
212
- clack_1.default.outro(errorMessage);
213
- await analytics_1.analytics.shutdown('error');
214
- process.exit(1);
215
237
  }
216
238
  // Build environment variables from OAuth credentials
217
239
  const envVars = config.environment.getEnvVars(projectApiKey, host);
218
- // Upload environment variables to hosting providers (if configured)
240
+ // Upload environment variables to hosting providers (auto-accept)
219
241
  let uploadedEnvVars = [];
220
242
  if (config.environment.uploadToHosting) {
221
- uploadedEnvVars = await (0, steps_1.uploadEnvironmentVariablesStep)(envVars, {
243
+ const { uploadEnvironmentVariablesStep } = await import('../steps/index.js');
244
+ uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {
222
245
  integration: config.metadata.integration,
223
- options,
246
+ session,
224
247
  });
225
248
  }
226
- // Add MCP server to clients
227
- await (0, steps_1.addMCPServerToClientsStep)({
228
- integration: config.metadata.integration,
229
- ci: options.ci,
230
- });
231
- // Build outro message
232
- const continueUrl = options.signup
249
+ // MCP installation is handled by McpScreen — no prompt here
250
+ // Build outro data and store it for OutroScreen
251
+ const continueUrl = session.signup
233
252
  ? `${(0, urls_1.getCloudUrlFromRegion)(cloudRegion)}/products?source=wizard`
234
253
  : undefined;
235
254
  const changes = [
@@ -241,27 +260,13 @@ Please report this error to: ${chalk_1.default.cyan('wizard@posthog.com')}`;
241
260
  ? `Uploaded environment variables to your hosting provider`
242
261
  : '',
243
262
  ].filter(Boolean);
244
- const nextSteps = [
245
- ...config.ui.getOutroNextSteps(frameworkContext),
246
- uploadedEnvVars.length === 0 && config.environment.uploadToHosting
247
- ? `Upload your Project API key to your hosting provider`
248
- : '',
249
- ].filter(Boolean);
250
- const outroMessage = `
251
- ${chalk_1.default.green('Successfully installed PostHog!')}
252
-
253
- ${chalk_1.default.cyan('What the agent did:')}
254
- ${changes.map((change) => `• ${change}`).join('\n')}
255
-
256
- ${chalk_1.default.yellow('Next steps:')}
257
- ${nextSteps.map((step) => `• ${step}`).join('\n')}
258
-
259
- Learn more: ${chalk_1.default.cyan(config.metadata.docsUrl)}
260
- ${continueUrl ? `\nContinue onboarding: ${chalk_1.default.cyan(continueUrl)}\n` : ``}
261
- ${chalk_1.default.dim('Note: This wizard uses an LLM agent to analyze and modify your project. Please review the changes made.')}
262
-
263
- ${chalk_1.default.dim(`How did this work for you? Drop us a line: wizard@posthog.com`)}`;
264
- clack_1.default.outro(outroMessage);
263
+ session.outroData = {
264
+ kind: wizard_session_1.OutroKind.Success,
265
+ changes,
266
+ docsUrl: config.metadata.docsUrl,
267
+ continueUrl,
268
+ };
269
+ (0, ui_1.getUI)().outro(`Successfully installed PostHog!`);
265
270
  await analytics_1.analytics.shutdown('success');
266
271
  }
267
272
  /**
@@ -280,7 +285,7 @@ Project context:
280
285
  - PostHog Project ID: ${context.projectId}
281
286
  - Framework: ${config.metadata.name} ${context.frameworkVersion}
282
287
  - TypeScript: ${context.typescript ? 'Yes' : 'No'}
283
- - PostHog API Key: ${context.projectApiKey}
288
+ - PostHog public token: ${context.projectApiKey}
284
289
  - PostHog Host: ${context.host}
285
290
  - Project type: ${config.prompts.projectTypeDetection}
286
291
  - Package installation: ${config.prompts.packageInstallation ?? framework_config_1.DEFAULT_PACKAGE_INSTALLATION}${additionalContext}
@@ -301,15 +306,16 @@ STEP 3: Run the installation command using Bash:
301
306
 
302
307
  STEP 4: Load the installed skill's SKILL.md file to understand what references are available.
303
308
 
304
- STEP 5: Follow the skill's workflow files in sequence. Look for numbered workflow files in the references (e.g., files with patterns like "1.0-", "1.1-", "1.2-"). Start with the first one and proceed through each step until completion. Each workflow file will tell you what to do and which file comes next. Never directly write PostHog keys directly to code files; always use environment variables.
309
+ STEP 5: Follow the skill's workflow files in sequence. Look for numbered workflow files in the references (e.g., files with patterns like "1.0-", "1.1-", "1.2-"). Start with the first one and proceed through each step until completion. Each workflow file will tell you what to do and which file comes next. Never directly write PostHog tokens directly to code files; always use environment variables.
305
310
 
306
311
  STEP 6: Set up environment variables for PostHog using the wizard-tools MCP server (this runs locally — secret values never leave the machine):
307
312
  - Use check_env_keys to see which keys already exist in the project's .env file (e.g. .env.local or .env).
308
- - Use set_env_values to create or update the PostHog API key and host, using the appropriate naming convention for ${config.metadata.name}. The tool will also ensure .gitignore coverage. Don't assume the presence of keys means the value is up to date. Write the correct value each time.
309
- - Reference these environment variables in the code files you create instead of hardcoding the API key and host.
313
+ - Use set_env_values to create or update the PostHog public token and host, using the appropriate environment variable naming convention for ${config.metadata.name}, which you'll find in example code. The tool will also ensure .gitignore coverage. Don't assume the presence of keys means the value is up to date. Write the correct value each time.
314
+ - Reference these environment variables in the code files you create instead of hardcoding the public token and host.
310
315
 
311
316
  Important: Use the detect_package_manager tool (from the wizard-tools MCP server) to determine which package manager the project uses. Do not manually search for lockfiles or config files. Always install packages as a background task. Don't await completion; proceed with other work immediately after starting the installation. You must read a file immediately before attempting to write it, even if you have previously read it; failure to do so will cause a tool failure.
312
317
 
318
+
313
319
  `;
314
320
  }
315
321
  //# sourceMappingURL=agent-runner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/lib/agent-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0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AAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC9D,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,kGACL,MAAM,CAAC,QAAQ,CAAC,IAClB;;;wBAGsB,OAAO,CAAC,SAAS;eAC1B,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,gBAAgB;gBAC/C,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;qBAC5B,OAAO,CAAC,aAAa;kBACxB,OAAO,CAAC,IAAI;kBACZ,MAAM,CAAC,OAAO,CAAC,oBAAoB;0BAEjD,MAAM,CAAC,OAAO,CAAC,mBAAmB,IAAI,+CACxC,GAAG,iBAAiB;;;;0KAKlB,8BAAY,CAAC,iBACf;;;mFAIG,8BAAY,CAAC,sBACf;;;;;;;;;;;;;;;wHAgBE,MAAM,CAAC,QAAQ,CAAC,IAClB;;;;;CAKF,CAAC;AACF,CAAC","sourcesContent":["import {\n DEFAULT_PACKAGE_INSTALLATION,\n getWelcomeMessage,\n SPINNER_MESSAGE,\n type FrameworkConfig,\n} from './framework-config';\nimport type { WizardOptions } from '../utils/types';\nimport {\n abort,\n askForAIConsent,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n isUsingTypeScript,\n printWelcome,\n} from '../utils/clack-utils';\nimport type { PackageDotJson } from '../utils/package-json';\nimport { analytics } from '../utils/analytics';\nimport { WIZARD_INTERACTION_EVENT_NAME } from './constants';\nimport clack from '../utils/clack';\nimport {\n initializeAgent,\n runAgent,\n AgentSignals,\n AgentErrorType,\n} from './agent-interface';\nimport { getCloudUrlFromRegion } from '../utils/urls';\nimport chalk from 'chalk';\nimport * as semver from 'semver';\nimport {\n addMCPServerToClientsStep,\n uploadEnvironmentVariablesStep,\n} from '../steps';\nimport { checkAnthropicStatusWithPrompt } from '../utils/anthropic-status';\nimport { enableDebugLogs } from '../utils/debug';\nimport { createBenchmarkPipeline } from './middleware/benchmark';\n\n/**\n * Universal agent-powered wizard runner.\n * Handles the complete flow for any framework using PostHog MCP integration.\n */\nexport async function runAgentWizard(\n config: FrameworkConfig,\n options: WizardOptions,\n): Promise<void> {\n if (options.debug) {\n enableDebugLogs();\n }\n\n // Version check\n if (config.detection.minimumVersion && config.detection.getInstalledVersion) {\n const version = await config.detection.getInstalledVersion(options);\n if (version) {\n const coerced = semver.coerce(version);\n if (coerced && semver.lt(coerced, config.detection.minimumVersion)) {\n const docsUrl =\n config.metadata.unsupportedVersionDocsUrl ?? config.metadata.docsUrl;\n clack.log.warn(\n `Sorry: the wizard can't help you with ${config.metadata.name} ${version}. Upgrade to ${config.metadata.name} ${config.detection.minimumVersion} or later, or check out the manual setup guide.`,\n );\n clack.log.info(\n `Setup ${config.metadata.name} manually: ${chalk.cyan(docsUrl)}`,\n );\n clack.outro('PostHog wizard will see you next time!');\n return;\n }\n }\n }\n\n // Setup phase\n printWelcome({ wizardName: getWelcomeMessage(config.metadata.name) });\n\n if (config.metadata.beta) {\n clack.log.info(\n `${chalk.yellow('[BETA]')} The ${\n config.metadata.name\n } wizard is in beta. Questions or feedback? Email ${chalk.cyan(\n 'wizard@posthog.com',\n )}`,\n );\n }\n\n if (config.metadata.preRunNotice) {\n clack.log.warn(config.metadata.preRunNotice);\n }\n\n clack.log.info(\n `We're about to read your project using our LLM gateway.\\n\\n.env* file contents will not leave your machine.\\n\\nOther files will be read and edited to provide a fully-custom PostHog integration.`,\n );\n\n const aiConsent = await askForAIConsent(options);\n if (!aiConsent) {\n await abort(\n `This wizard uses an LLM agent to intelligently modify your project. Please view the docs to set up ${config.metadata.name} manually instead: ${config.metadata.docsUrl}`,\n 0,\n );\n }\n\n // Check Anthropic/Claude service status before proceeding\n const statusOk = await checkAnthropicStatusWithPrompt({ ci: options.ci });\n if (!statusOk) {\n await abort(\n `Please try again later, or set up ${config.metadata.name} manually: ${config.metadata.docsUrl}`,\n 0,\n );\n }\n\n const typeScriptDetected = isUsingTypeScript(options);\n\n await confirmContinueIfNoOrDirtyGitRepo(options);\n\n // Framework detection and version\n // Only check package.json for Node.js/JavaScript frameworks\n const usesPackageJson = config.detection.usesPackageJson !== false;\n let packageJson: PackageDotJson | null = null;\n let frameworkVersion: string | undefined;\n\n if (usesPackageJson) {\n packageJson = await getPackageDotJson(options);\n await ensurePackageIsInstalled(\n packageJson,\n config.detection.packageName,\n config.detection.packageDisplayName,\n );\n frameworkVersion = config.detection.getVersion(packageJson);\n } else {\n // For non-Node frameworks (e.g., Django), version is handled differently\n frameworkVersion = config.detection.getVersion(null);\n }\n\n // Set analytics tags for framework version\n if (frameworkVersion && config.detection.getVersionBucket) {\n const versionBucket = config.detection.getVersionBucket(frameworkVersion);\n analytics.setTag(`${config.metadata.integration}-version`, versionBucket);\n }\n\n analytics.capture(WIZARD_INTERACTION_EVENT_NAME, {\n action: 'started agent integration',\n integration: config.metadata.integration,\n });\n\n // Get PostHog credentials\n const { projectApiKey, host, accessToken, projectId, cloudRegion } =\n await getOrAskForProjectData(options);\n\n // Gather framework-specific context (e.g., Next.js router, React Native platform)\n const frameworkContext = config.metadata.gatherContext\n ? await config.metadata.gatherContext(options)\n : {};\n\n // Set analytics tags from framework context\n const contextTags = config.analytics.getTags(frameworkContext);\n Object.entries(contextTags).forEach(([key, value]) => {\n analytics.setTag(key, value);\n });\n\n const integrationPrompt = buildIntegrationPrompt(\n config,\n {\n frameworkVersion: frameworkVersion || 'latest',\n typescript: typeScriptDetected,\n projectApiKey,\n host,\n projectId,\n },\n frameworkContext,\n );\n\n // Initialize and run agent\n const spinner = clack.spinner();\n\n const mcpUrl = options.localMcp\n ? 'http://localhost:8787/mcp'\n : process.env.MCP_URL || 'https://mcp.posthog.com/mcp';\n\n const agent = await initializeAgent(\n {\n workingDirectory: options.installDir,\n posthogMcpUrl: mcpUrl,\n posthogApiKey: accessToken,\n posthogApiHost: host,\n additionalMcpServers: config.metadata.additionalMcpServers,\n detectPackageManager: config.detection.detectPackageManager,\n },\n options,\n );\n\n const middleware = options.benchmark\n ? createBenchmarkPipeline(spinner, options)\n : undefined;\n\n const agentResult = await runAgent(\n agent,\n integrationPrompt,\n options,\n spinner,\n {\n estimatedDurationMinutes: config.ui.estimatedDurationMinutes,\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: config.ui.successMessage,\n errorMessage: 'Integration failed',\n },\n middleware,\n );\n\n // Handle error cases detected in agent output\n if (agentResult.error === AgentErrorType.MCP_MISSING) {\n analytics.captureException(\n new Error('Agent could not access PostHog MCP server'),\n {\n integration: config.metadata.integration,\n error_type: AgentErrorType.MCP_MISSING,\n signal: AgentSignals.ERROR_MCP_MISSING,\n },\n );\n\n const errorMessage = `\n${chalk.red('❌ Could not access the PostHog MCP server')}\n\nThe wizard was unable to connect to the PostHog MCP server.\nThis could be due to a network issue or a configuration problem.\n\nPlease try again, or set up ${\n config.metadata.name\n } manually by following our documentation:\n${chalk.cyan(config.metadata.docsUrl)}`;\n\n clack.outro(errorMessage);\n await analytics.shutdown('error');\n process.exit(1);\n }\n\n if (agentResult.error === AgentErrorType.RESOURCE_MISSING) {\n analytics.captureException(\n new Error('Agent could not access setup resource'),\n {\n integration: config.metadata.integration,\n error_type: AgentErrorType.RESOURCE_MISSING,\n signal: AgentSignals.ERROR_RESOURCE_MISSING,\n },\n );\n\n const errorMessage = `\n${chalk.red('❌ Could not access the setup resource')}\n\nThe wizard could not access the setup resource. This may indicate a version mismatch or a temporary service issue.\n\nPlease try again, or set up ${\n config.metadata.name\n } manually by following our documentation:\n${chalk.cyan(config.metadata.docsUrl)}`;\n\n clack.outro(errorMessage);\n await analytics.shutdown('error');\n process.exit(1);\n }\n\n if (\n agentResult.error === AgentErrorType.RATE_LIMIT ||\n agentResult.error === AgentErrorType.API_ERROR\n ) {\n analytics.capture(WIZARD_INTERACTION_EVENT_NAME, {\n action: 'api error',\n integration: config.metadata.integration,\n error_type: agentResult.error,\n error_message: agentResult.message,\n });\n\n analytics.captureException(new Error(`API error: ${agentResult.message}`), {\n integration: config.metadata.integration,\n error_type: agentResult.error,\n });\n\n const errorMessage = `\n${chalk.red('❌ API Error')}\n\n${chalk.yellow(agentResult.message || 'Unknown error')}\n\nPlease report this error to: ${chalk.cyan('wizard@posthog.com')}`;\n\n clack.outro(errorMessage);\n await analytics.shutdown('error');\n process.exit(1);\n }\n\n // Build environment variables from OAuth credentials\n const envVars = config.environment.getEnvVars(projectApiKey, host);\n\n // Upload environment variables to hosting providers (if configured)\n let uploadedEnvVars: string[] = [];\n if (config.environment.uploadToHosting) {\n uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {\n integration: config.metadata.integration,\n options,\n });\n }\n\n // Add MCP server to clients\n await addMCPServerToClientsStep({\n integration: config.metadata.integration,\n ci: options.ci,\n });\n\n // Build outro message\n const continueUrl = options.signup\n ? `${getCloudUrlFromRegion(cloudRegion)}/products?source=wizard`\n : undefined;\n\n const changes = [\n ...config.ui.getOutroChanges(frameworkContext),\n Object.keys(envVars).length > 0\n ? `Added environment variables to .env file`\n : '',\n uploadedEnvVars.length > 0\n ? `Uploaded environment variables to your hosting provider`\n : '',\n ].filter(Boolean);\n\n const nextSteps = [\n ...config.ui.getOutroNextSteps(frameworkContext),\n uploadedEnvVars.length === 0 && config.environment.uploadToHosting\n ? `Upload your Project API key to your hosting provider`\n : '',\n ].filter(Boolean);\n\n const outroMessage = `\n${chalk.green('Successfully installed PostHog!')}\n\n${chalk.cyan('What the agent did:')}\n${changes.map((change) => `• ${change}`).join('\\n')}\n\n${chalk.yellow('Next steps:')}\n${nextSteps.map((step) => `• ${step}`).join('\\n')}\n\nLearn more: ${chalk.cyan(config.metadata.docsUrl)}\n${continueUrl ? `\\nContinue onboarding: ${chalk.cyan(continueUrl)}\\n` : ``}\n${chalk.dim(\n 'Note: This wizard uses an LLM agent to analyze and modify your project. Please review the changes made.',\n)}\n\n${chalk.dim(`How did this work for you? Drop us a line: wizard@posthog.com`)}`;\n\n clack.outro(outroMessage);\n\n await analytics.shutdown('success');\n}\n\n/**\n * Build the integration prompt for the agent.\n */\nfunction buildIntegrationPrompt(\n config: FrameworkConfig,\n context: {\n frameworkVersion: string;\n typescript: boolean;\n projectApiKey: string;\n host: string;\n projectId: number;\n },\n frameworkContext: Record<string, unknown>,\n): string {\n const additionalLines = config.prompts.getAdditionalContextLines\n ? config.prompts.getAdditionalContextLines(frameworkContext)\n : [];\n\n const additionalContext =\n additionalLines.length > 0\n ? '\\n' + additionalLines.map((line) => `- ${line}`).join('\\n')\n : '';\n\n return `You have access to the PostHog MCP server which provides skills to integrate PostHog into this ${\n config.metadata.name\n } project.\n\nProject context:\n- PostHog Project ID: ${context.projectId}\n- Framework: ${config.metadata.name} ${context.frameworkVersion}\n- TypeScript: ${context.typescript ? 'Yes' : 'No'}\n- PostHog API Key: ${context.projectApiKey}\n- PostHog Host: ${context.host}\n- Project type: ${config.prompts.projectTypeDetection}\n- Package installation: ${\n config.prompts.packageInstallation ?? DEFAULT_PACKAGE_INSTALLATION\n }${additionalContext}\n\nInstructions (follow these steps IN ORDER - do not skip or reorder):\n\nSTEP 1: List available skills from the PostHog MCP server using ListMcpResourcesTool. If this tool is not available or you cannot access the MCP server, you must emit: ${\n AgentSignals.ERROR_MCP_MISSING\n } Could not access the PostHog MCP server and halt.\n\n Review the skill descriptions and choose the one that best matches this project's framework and configuration.\n If no suitable skill is found, or you cannot access the MCP server, you emit: ${\n AgentSignals.ERROR_RESOURCE_MISSING\n } Could not find a suitable skill for this project.\n\nSTEP 2: Fetch the chosen skill resource (e.g., posthog://skills/{skill-id}).\n The resource returns a shell command to install the skill.\n\nSTEP 3: Run the installation command using Bash:\n - Execute the EXACT command returned by the resource (do not modify it)\n - This will download and extract the skill to .claude/skills/{skill-id}/\n\nSTEP 4: Load the installed skill's SKILL.md file to understand what references are available.\n\nSTEP 5: Follow the skill's workflow files in sequence. Look for numbered workflow files in the references (e.g., files with patterns like \"1.0-\", \"1.1-\", \"1.2-\"). Start with the first one and proceed through each step until completion. Each workflow file will tell you what to do and which file comes next. Never directly write PostHog keys directly to code files; always use environment variables.\n\nSTEP 6: Set up environment variables for PostHog using the wizard-tools MCP server (this runs locally — secret values never leave the machine):\n - Use check_env_keys to see which keys already exist in the project's .env file (e.g. .env.local or .env).\n - Use set_env_values to create or update the PostHog API key and host, using the appropriate naming convention for ${\n config.metadata.name\n }. The tool will also ensure .gitignore coverage. Don't assume the presence of keys means the value is up to date. Write the correct value each time.\n - Reference these environment variables in the code files you create instead of hardcoding the API key and host.\n\nImportant: Use the detect_package_manager tool (from the wizard-tools MCP server) to determine which package manager the project uses. Do not manually search for lockfiles or config files. Always install packages as a background task. Don't await completion; proceed with other work immediately after starting the installation. You must read a file immediately before attempting to write it, even if you have previously read it; failure to do so will cause a tool failure.\n\n`;\n}\n"]}
1
+ {"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/lib/agent-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,wCAwQC;AAlUD,yDAI4B;AAC5B,qDAAiE;AACjE,sDAI8B;AAG9B,kDAA+C;AAC/C,8BAA8B;AAC9B,uDAS2B;AAC3B,wCAAsD;AACtD,kDAA0B;AAC1B,+CAAiC;AACjC,gEAAiE;AACjE,0CAAiD;AACjD,sDAAiE;AACjE,wDAAiE;AAEjE;;GAEG;AACH,SAAS,gBAAgB,CAAC,OAAsB;IAC9C,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,SAAS,EAAE,OAAO,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C,yBAAyB;QAC9D,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC,gBAAgB,CAAC;QAC5D,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,iBAAiB,GACrB,eAAe,CAAC,MAAM,GAAG,CAAC;QACxB,CAAC,CAAC,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC9D,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,kGACL,MAAM,CAAC,QAAQ,CAAC,IAClB;;;wBAGsB,OAAO,CAAC,SAAS;eAC1B,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,gBAAgB;gBAC/C,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;0BACvB,OAAO,CAAC,aAAa;kBAC7B,OAAO,CAAC,IAAI;kBACZ,MAAM,CAAC,OAAO,CAAC,oBAAoB;0BAEjD,MAAM,CAAC,OAAO,CAAC,mBAAmB,IAAI,+CACxC,GAAG,iBAAiB;;;;0KAKlB,8BAAY,CAAC,iBACf;;;mFAIG,8BAAY,CAAC,sBACf;;;;;;;;;;;;;;;kJAgBE,MAAM,CAAC,QAAQ,CAAC,IAClB;;;;;;CAMF,CAAC;AACF,CAAC","sourcesContent":["import {\n DEFAULT_PACKAGE_INSTALLATION,\n SPINNER_MESSAGE,\n type FrameworkConfig,\n} from './framework-config';\nimport { type WizardSession, OutroKind } from './wizard-session';\nimport {\n tryGetPackageJson,\n isUsingTypeScript,\n getOrAskForProjectData,\n} from '../utils/setup-utils';\nimport type { PackageDotJson } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { analytics } from '../utils/analytics';\nimport { getUI } from '../ui';\nimport {\n initializeAgent,\n runAgent,\n AgentSignals,\n AgentErrorType,\n buildWizardMetadata,\n checkClaudeSettingsOverrides,\n backupAndFixClaudeSettings,\n restoreClaudeSettings,\n} from './agent-interface';\nimport { getCloudUrlFromRegion } from '../utils/urls';\nimport chalk from 'chalk';\nimport * as semver from 'semver';\nimport { checkAnthropicStatus } from '../utils/anthropic-status';\nimport { enableDebugLogs } from '../utils/debug';\nimport { createBenchmarkPipeline } from './middleware/benchmark';\nimport { wizardAbort, WizardError } from '../utils/wizard-abort';\n\n/**\n * Build a WizardOptions bag from a WizardSession (for code that still expects WizardOptions).\n */\nfunction sessionToOptions(session: WizardSession): WizardOptions {\n return {\n installDir: session.installDir,\n debug: session.debug,\n forceInstall: session.forceInstall,\n default: false,\n signup: session.signup,\n localMcp: session.localMcp,\n ci: session.ci,\n menu: session.menu,\n benchmark: session.benchmark,\n projectId: session.projectId,\n apiKey: session.apiKey,\n };\n}\n\n/**\n * Universal agent-powered wizard runner.\n * Handles the complete flow for any framework using PostHog MCP integration.\n *\n * All user decisions come from the session — no UI prompts.\n */\nexport async function runAgentWizard(\n config: FrameworkConfig,\n session: WizardSession,\n): Promise<void> {\n if (session.debug) {\n enableDebugLogs();\n }\n\n // Version check\n if (config.detection.minimumVersion && config.detection.getInstalledVersion) {\n const version = await config.detection.getInstalledVersion(\n sessionToOptions(session),\n );\n if (version) {\n const coerced = semver.coerce(version);\n if (coerced && semver.lt(coerced, config.detection.minimumVersion)) {\n const docsUrl =\n config.metadata.unsupportedVersionDocsUrl ?? config.metadata.docsUrl;\n getUI().log.warn(\n `Sorry: the wizard can't help you with ${config.metadata.name} ${version}. Upgrade to ${config.metadata.name} ${config.detection.minimumVersion} or later, or check out the manual setup guide.`,\n );\n getUI().log.info(\n `Setup ${config.metadata.name} manually: ${chalk.cyan(docsUrl)}`,\n );\n getUI().outro('PostHog wizard will see you next time!');\n return;\n }\n }\n }\n\n // Setup phase — informational only, no prompts\n // Beta notice, pre-run notice, and welcome label are all derivable\n // from session.frameworkConfig — IntroScreen reads them directly.\n\n // Check Anthropic/Claude service status (pure — no prompt)\n const statusResult = await checkAnthropicStatus();\n if (statusResult.status === 'down' || statusResult.status === 'degraded') {\n getUI().showServiceStatus({\n description: statusResult.description,\n statusPageUrl: 'https://status.claude.com',\n });\n }\n\n // Check for blocking env overrides in .claude/settings.json before login.\n // These keys block the Wizard from accessing the PostHog LLM Gateway.\n const blockingOverrideKeys = checkClaudeSettingsOverrides(session.installDir);\n if (blockingOverrideKeys.length > 0) {\n await getUI().showSettingsOverride(blockingOverrideKeys, () =>\n backupAndFixClaudeSettings(session.installDir),\n );\n }\n\n // Disclosure text is static — IntroScreen renders it directly.\n\n const typeScriptDetected = isUsingTypeScript({\n installDir: session.installDir,\n });\n session.typescript = typeScriptDetected;\n\n // Framework detection and version\n const usesPackageJson = config.detection.usesPackageJson !== false;\n let packageJson: PackageDotJson | null = null;\n let frameworkVersion: string | undefined;\n\n if (usesPackageJson) {\n packageJson = await tryGetPackageJson({ installDir: session.installDir });\n if (packageJson) {\n // Log warning if package not installed, but continue (agent handles it)\n const { hasPackageInstalled } = await import('../utils/package-json.js');\n if (!hasPackageInstalled(config.detection.packageName, packageJson)) {\n getUI().log.warn(\n `${config.detection.packageDisplayName} does not seem to be installed. Continuing anyway — the agent will handle it.`,\n );\n }\n frameworkVersion = config.detection.getVersion(packageJson);\n } else {\n getUI().log.warn(\n 'Could not find package.json. Continuing anyway — the agent will handle it.',\n );\n }\n } else {\n frameworkVersion = config.detection.getVersion(null);\n }\n\n // Set analytics tags for framework version\n if (frameworkVersion && config.detection.getVersionBucket) {\n const versionBucket = config.detection.getVersionBucket(frameworkVersion);\n analytics.setTag(`${config.metadata.integration}-version`, versionBucket);\n }\n\n analytics.wizardCapture('agent started', {\n integration: config.metadata.integration,\n });\n\n // Get PostHog credentials (region auto-detected from token)\n const { projectApiKey, host, accessToken, projectId, cloudRegion } =\n await getOrAskForProjectData({\n signup: session.signup,\n ci: session.ci,\n apiKey: session.apiKey,\n projectId: session.projectId,\n });\n\n session.credentials = { accessToken, projectApiKey, host, projectId };\n\n // Notify TUI that credentials are available (resolves past AuthScreen)\n getUI().setCredentials(session.credentials);\n\n // Framework context was already gathered by SetupScreen + detection\n const frameworkContext = session.frameworkContext;\n\n // Set analytics tags from framework context\n const contextTags = config.analytics.getTags(frameworkContext);\n Object.entries(contextTags).forEach(([key, value]) => {\n analytics.setTag(key, value);\n });\n\n const integrationPrompt = buildIntegrationPrompt(\n config,\n {\n frameworkVersion: frameworkVersion || 'latest',\n typescript: typeScriptDetected,\n projectApiKey,\n host,\n projectId,\n },\n frameworkContext,\n );\n\n // Initialize and run agent\n const spinner = getUI().spinner();\n\n // Evaluate all feature flags at the start of the run so they can be sent to the LLM gateway\n const wizardFlags = await analytics.getAllFlagsForWizard();\n const wizardMetadata = buildWizardMetadata(wizardFlags);\n\n // Determine MCP URL: CLI flag > env var > production default\n const mcpUrl = session.localMcp\n ? 'http://localhost:8787/mcp'\n : process.env.MCP_URL || 'https://mcp.posthog.com/mcp';\n\n const restoreSettings = () => restoreClaudeSettings(session.installDir);\n getUI().onEnterScreen('outro', restoreSettings);\n getUI().startRun();\n\n const agent = await initializeAgent(\n {\n workingDirectory: session.installDir,\n posthogMcpUrl: mcpUrl,\n posthogApiKey: accessToken,\n posthogApiHost: host,\n additionalMcpServers: config.metadata.additionalMcpServers,\n detectPackageManager: config.detection.detectPackageManager,\n wizardFlags,\n wizardMetadata,\n },\n sessionToOptions(session),\n );\n\n const middleware = session.benchmark\n ? createBenchmarkPipeline(spinner, sessionToOptions(session))\n : undefined;\n\n const agentResult = await runAgent(\n agent,\n integrationPrompt,\n sessionToOptions(session),\n spinner,\n {\n estimatedDurationMinutes: config.ui.estimatedDurationMinutes,\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: config.ui.successMessage,\n errorMessage: 'Integration failed',\n additionalFeatureQueue: session.additionalFeatureQueue,\n },\n middleware,\n );\n\n // Handle error cases detected in agent output\n if (agentResult.error === AgentErrorType.MCP_MISSING) {\n await wizardAbort({\n message: `Could not access the PostHog MCP server\\n\\nThe wizard was unable to connect to the PostHog MCP server.\\nThis could be due to a network issue or a configuration problem.\\n\\nPlease try again, or set up ${config.metadata.name} manually by following our documentation:\\n${config.metadata.docsUrl}`,\n error: new WizardError('Agent could not access PostHog MCP server', {\n integration: config.metadata.integration,\n error_type: AgentErrorType.MCP_MISSING,\n signal: AgentSignals.ERROR_MCP_MISSING,\n }),\n });\n }\n\n if (agentResult.error === AgentErrorType.RESOURCE_MISSING) {\n await wizardAbort({\n message: `Could not access the setup resource\\n\\nThe wizard could not access the setup resource. This may indicate a version mismatch or a temporary service issue.\\n\\nPlease try again, or set up ${config.metadata.name} manually by following our documentation:\\n${config.metadata.docsUrl}`,\n error: new WizardError('Agent could not access setup resource', {\n integration: config.metadata.integration,\n error_type: AgentErrorType.RESOURCE_MISSING,\n signal: AgentSignals.ERROR_RESOURCE_MISSING,\n }),\n });\n }\n\n if (\n agentResult.error === AgentErrorType.RATE_LIMIT ||\n agentResult.error === AgentErrorType.API_ERROR\n ) {\n analytics.wizardCapture('agent api error', {\n integration: config.metadata.integration,\n error_type: agentResult.error,\n error_message: agentResult.message,\n });\n\n await wizardAbort({\n message: `API Error\\n\\n${\n agentResult.message || 'Unknown error'\n }\\n\\nPlease report this error to: wizard@posthog.com`,\n error: new WizardError(`API error: ${agentResult.message}`, {\n integration: config.metadata.integration,\n error_type: agentResult.error,\n }),\n });\n }\n\n // Build environment variables from OAuth credentials\n const envVars = config.environment.getEnvVars(projectApiKey, host);\n\n // Upload environment variables to hosting providers (auto-accept)\n let uploadedEnvVars: string[] = [];\n if (config.environment.uploadToHosting) {\n const { uploadEnvironmentVariablesStep } = await import(\n '../steps/index.js'\n );\n uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {\n integration: config.metadata.integration,\n session,\n });\n }\n\n // MCP installation is handled by McpScreen — no prompt here\n\n // Build outro data and store it for OutroScreen\n const continueUrl = session.signup\n ? `${getCloudUrlFromRegion(cloudRegion)}/products?source=wizard`\n : undefined;\n\n const changes = [\n ...config.ui.getOutroChanges(frameworkContext),\n Object.keys(envVars).length > 0\n ? `Added environment variables to .env file`\n : '',\n uploadedEnvVars.length > 0\n ? `Uploaded environment variables to your hosting provider`\n : '',\n ].filter(Boolean);\n\n session.outroData = {\n kind: OutroKind.Success,\n changes,\n docsUrl: config.metadata.docsUrl,\n continueUrl,\n };\n\n getUI().outro(`Successfully installed PostHog!`);\n\n await analytics.shutdown('success');\n}\n\n/**\n * Build the integration prompt for the agent.\n */\nfunction buildIntegrationPrompt(\n config: FrameworkConfig,\n context: {\n frameworkVersion: string;\n typescript: boolean;\n projectApiKey: string;\n host: string;\n projectId: number;\n },\n frameworkContext: Record<string, unknown>,\n): string {\n const additionalLines = config.prompts.getAdditionalContextLines\n ? config.prompts.getAdditionalContextLines(frameworkContext)\n : [];\n\n const additionalContext =\n additionalLines.length > 0\n ? '\\n' + additionalLines.map((line) => `- ${line}`).join('\\n')\n : '';\n\n return `You have access to the PostHog MCP server which provides skills to integrate PostHog into this ${\n config.metadata.name\n } project.\n\nProject context:\n- PostHog Project ID: ${context.projectId}\n- Framework: ${config.metadata.name} ${context.frameworkVersion}\n- TypeScript: ${context.typescript ? 'Yes' : 'No'}\n- PostHog public token: ${context.projectApiKey}\n- PostHog Host: ${context.host}\n- Project type: ${config.prompts.projectTypeDetection}\n- Package installation: ${\n config.prompts.packageInstallation ?? DEFAULT_PACKAGE_INSTALLATION\n }${additionalContext}\n\nInstructions (follow these steps IN ORDER - do not skip or reorder):\n\nSTEP 1: List available skills from the PostHog MCP server using ListMcpResourcesTool. If this tool is not available or you cannot access the MCP server, you must emit: ${\n AgentSignals.ERROR_MCP_MISSING\n } Could not access the PostHog MCP server and halt.\n\n Review the skill descriptions and choose the one that best matches this project's framework and configuration.\n If no suitable skill is found, or you cannot access the MCP server, you emit: ${\n AgentSignals.ERROR_RESOURCE_MISSING\n } Could not find a suitable skill for this project.\n\nSTEP 2: Fetch the chosen skill resource (e.g., posthog://skills/{skill-id}).\n The resource returns a shell command to install the skill.\n\nSTEP 3: Run the installation command using Bash:\n - Execute the EXACT command returned by the resource (do not modify it)\n - This will download and extract the skill to .claude/skills/{skill-id}/\n\nSTEP 4: Load the installed skill's SKILL.md file to understand what references are available.\n\nSTEP 5: Follow the skill's workflow files in sequence. Look for numbered workflow files in the references (e.g., files with patterns like \"1.0-\", \"1.1-\", \"1.2-\"). Start with the first one and proceed through each step until completion. Each workflow file will tell you what to do and which file comes next. Never directly write PostHog tokens directly to code files; always use environment variables.\n\nSTEP 6: Set up environment variables for PostHog using the wizard-tools MCP server (this runs locally — secret values never leave the machine):\n - Use check_env_keys to see which keys already exist in the project's .env file (e.g. .env.local or .env).\n - Use set_env_values to create or update the PostHog public token and host, using the appropriate environment variable naming convention for ${\n config.metadata.name\n }, which you'll find in example code. The tool will also ensure .gitignore coverage. Don't assume the presence of keys means the value is up to date. Write the correct value each time.\n - Reference these environment variables in the code files you create instead of hardcoding the public token and host.\n\nImportant: Use the detect_package_manager tool (from the wizard-tools MCP server) to determine which package manager the project uses. Do not manually search for lockfiles or config files. Always install packages as a background task. Don't await completion; proceed with other work immediately after starting the installation. You must read a file immediately before attempting to write it, even if you have previously read it; failure to do so will cause a tool failure.\n\n\n`;\n}\n"]}
@@ -57,17 +57,17 @@ export declare const ApiProjectSchema: z.ZodObject<{
57
57
  api_token: z.ZodString;
58
58
  name: z.ZodString;
59
59
  }, "strip", z.ZodTypeAny, {
60
- uuid: string;
61
- name: string;
62
60
  id: number;
63
61
  organization: string;
64
- api_token: string;
65
- }, {
66
62
  uuid: string;
63
+ api_token: string;
67
64
  name: string;
65
+ }, {
68
66
  id: number;
69
67
  organization: string;
68
+ uuid: string;
70
69
  api_token: string;
70
+ name: string;
71
71
  }>;
72
72
  export type ApiUser = z.infer<typeof ApiUserSchema>;
73
73
  export type ApiProject = z.infer<typeof ApiProjectSchema>;
@@ -16,6 +16,7 @@ const WIZARD_COMMANDMENTS = [
16
16
  'Treat feature flags, custom properties, and event names as part of an analytics contract. Prefer reusing existing names and patterns in the project. When you must introduce new ones, make them clear, descriptive, and consistent with existing conventions, and avoid scattering the same flag or property across many unrelated callsites.',
17
17
  'Prefer minimal, targeted edits that achieve the requested behavior while preserving existing structure and style. Avoid large refactors, broad reformatting, or unrelated changes unless explicitly requested.',
18
18
  'Do not spawn subagents unless explicitly instructed to do so.',
19
+ 'Use the TodoWrite tool to track your progress. Create a todo list at the start describing the high-level areas of work, mark each as in_progress when you begin it, and completed when done.',
19
20
  ].join('\n');
20
21
  function getWizardCommandments() {
21
22
  return WIZARD_COMMANDMENTS;
@@ -1 +1 @@
1
- {"version":3,"file":"commandments.js","sourceRoot":"","sources":["../../../src/lib/commandments.ts"],"names":[],"mappings":";;AAwBA,sDAEC;AA1BD;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG;IAC1B,gLAAgL;IAEhL,4OAA4O;IAE5O,4LAA4L;IAE5L,oLAAoL;IAEpL,uMAAuM;IAEvM,gVAAgV;IAEhV,gNAAgN;IAEhN,+DAA+D;CAChE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,SAAgB,qBAAqB;IACnC,OAAO,mBAAmB,CAAC;AAC7B,CAAC","sourcesContent":["/**\n * Wizard-wide commandments that are always appended as a system prompt.\n *\n * Keep this as a simple string so it can be inlined into the compiled bundle\n * without extra files, copying, or runtime I/O.\n */\nconst WIZARD_COMMANDMENTS = [\n 'Never hallucinate a PostHog API key, host, or any other secret. Always use the real values that have been configured for this project (for example via environment variables).',\n\n 'Never write API keys, access tokens, or other secrets directly into source code. Always reference environment variables instead, and rely on the wizard-tools MCP server (check_env_keys / set_env_values) to create or update .env files.',\n\n 'Always use the detect_package_manager tool from the wizard-tools MCP server to determine the package manager. Do not guess based on lockfiles or hard-code npm, yarn, pnpm, bun, pip, etc.',\n\n 'When installing packages, start the installation as a background task and then continue with other work. Do not block waiting for installs to finish unless explicitly instructed.',\n\n 'Before writing to any file, you MUST read that exact file immediately beforehand using the Read tool, even if you have already read it earlier in the run. This avoids tool failures and stale edits.',\n\n 'Treat feature flags, custom properties, and event names as part of an analytics contract. Prefer reusing existing names and patterns in the project. When you must introduce new ones, make them clear, descriptive, and consistent with existing conventions, and avoid scattering the same flag or property across many unrelated callsites.',\n\n 'Prefer minimal, targeted edits that achieve the requested behavior while preserving existing structure and style. Avoid large refactors, broad reformatting, or unrelated changes unless explicitly requested.',\n\n 'Do not spawn subagents unless explicitly instructed to do so.',\n].join('\\n');\n\nexport function getWizardCommandments(): string {\n return WIZARD_COMMANDMENTS;\n}\n"]}
1
+ {"version":3,"file":"commandments.js","sourceRoot":"","sources":["../../../src/lib/commandments.ts"],"names":[],"mappings":";;AA0BA,sDAEC;AA5BD;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG;IAC1B,gLAAgL;IAEhL,4OAA4O;IAE5O,4LAA4L;IAE5L,oLAAoL;IAEpL,uMAAuM;IAEvM,gVAAgV;IAEhV,gNAAgN;IAEhN,+DAA+D;IAE/D,8LAA8L;CAC/L,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,SAAgB,qBAAqB;IACnC,OAAO,mBAAmB,CAAC;AAC7B,CAAC","sourcesContent":["/**\n * Wizard-wide commandments that are always appended as a system prompt.\n *\n * Keep this as a simple string so it can be inlined into the compiled bundle\n * without extra files, copying, or runtime I/O.\n */\nconst WIZARD_COMMANDMENTS = [\n 'Never hallucinate a PostHog API key, host, or any other secret. Always use the real values that have been configured for this project (for example via environment variables).',\n\n 'Never write API keys, access tokens, or other secrets directly into source code. Always reference environment variables instead, and rely on the wizard-tools MCP server (check_env_keys / set_env_values) to create or update .env files.',\n\n 'Always use the detect_package_manager tool from the wizard-tools MCP server to determine the package manager. Do not guess based on lockfiles or hard-code npm, yarn, pnpm, bun, pip, etc.',\n\n 'When installing packages, start the installation as a background task and then continue with other work. Do not block waiting for installs to finish unless explicitly instructed.',\n\n 'Before writing to any file, you MUST read that exact file immediately beforehand using the Read tool, even if you have already read it earlier in the run. This avoids tool failures and stale edits.',\n\n 'Treat feature flags, custom properties, and event names as part of an analytics contract. Prefer reusing existing names and patterns in the project. When you must introduce new ones, make them clear, descriptive, and consistent with existing conventions, and avoid scattering the same flag or property across many unrelated callsites.',\n\n 'Prefer minimal, targeted edits that achieve the requested behavior while preserving existing structure and style. Avoid large refactors, broad reformatting, or unrelated changes unless explicitly requested.',\n\n 'Do not spawn subagents unless explicitly instructed to do so.',\n\n 'Use the TodoWrite tool to track your progress. Create a todo list at the start describing the high-level areas of work, mark each as in_progress when you begin it, and completed when done.',\n].join('\\n');\n\nexport function getWizardCommandments(): string {\n return WIZARD_COMMANDMENTS;\n}\n"]}
@@ -1,5 +1,8 @@
1
1
  /**
2
- * Detection order matters: put framework-specific integrations BEFORE basic language fallbacks
2
+ * Shared constants for the PostHog wizard.
3
+ */
4
+ /**
5
+ * Detection order matters: put framework-specific integrations BEFORE basic language fallbacks.
3
6
  */
4
7
  export declare enum Integration {
5
8
  nextjs = "nextjs",
@@ -19,10 +22,10 @@ export declare enum Integration {
19
22
  swift = "swift",
20
23
  android = "android",
21
24
  rails = "rails",
25
+ javascript_web = "javascript_web",
22
26
  python = "python",
23
27
  ruby = "ruby",
24
- javascriptNode = "javascript_node",
25
- javascript_web = "javascript_web"
28
+ javascriptNode = "javascript_node"
26
29
  }
27
30
  export interface Args {
28
31
  debug: boolean;
@@ -31,18 +34,28 @@ export interface Args {
31
34
  export declare const IS_DEV: boolean;
32
35
  export declare const DEBUG = false;
33
36
  export declare const DEFAULT_URL: string;
34
- export declare const ISSUES_URL = "https://github.com/posthog/wizard/issues";
35
37
  export declare const DEFAULT_HOST_URL: string;
38
+ export declare const ISSUES_URL = "https://github.com/posthog/wizard/issues";
36
39
  export declare const ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY = "sTMFPsFhdP1Ssg";
37
40
  export declare const ANALYTICS_HOST_URL = "https://internal-j.posthog.com";
38
41
  export declare const ANALYTICS_TEAM_TAG = "docs-and-wizard";
39
- export declare const DUMMY_PROJECT_API_KEY = "_YOUR_POSTHOG_PROJECT_API_KEY_";
42
+ export declare const POSTHOG_OAUTH_URL: string;
43
+ export declare const OAUTH_PORT = 8239;
40
44
  export declare const POSTHOG_US_CLIENT_ID = "c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM";
41
45
  export declare const POSTHOG_EU_CLIENT_ID = "bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRLkcKEy";
42
46
  export declare const POSTHOG_DEV_CLIENT_ID = "DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ";
43
47
  export declare const POSTHOG_PROXY_CLIENT_ID = "c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM";
44
- export declare const POSTHOG_OAUTH_URL: string;
45
- export declare const OAUTH_PORT = 8239;
46
- export declare const WIZARD_INTERACTION_EVENT_NAME = "wizard interaction";
48
+ export declare const DUMMY_PROJECT_API_KEY = "_YOUR_POSTHOG_PROJECT_API_KEY_";
47
49
  export declare const WIZARD_REMARK_EVENT_NAME = "wizard remark";
48
- export declare const WIZARD_USER_AGENT = "posthog/wizard; version: 1.36.1";
50
+ /** Feature flag key whose value selects a variant from WIZARD_VARIANTS. */
51
+ export declare const WIZARD_VARIANT_FLAG_KEY = "wizard-variant";
52
+ /** Variant key -> metadata for wizard run (VARIANT flag selects which entry to use). */
53
+ export declare const WIZARD_VARIANTS: Record<string, Record<string, string>>;
54
+ /** User-Agent for wizard HTTP requests and MCP server identification. */
55
+ export declare const WIZARD_USER_AGENT = "posthog/wizard; version: 2.0.0";
56
+ /** Header prefix for PostHog properties (e.g. X-POSTHOG-PROPERTY-VARIANT). */
57
+ export declare const POSTHOG_PROPERTY_HEADER_PREFIX = "X-POSTHOG-PROPERTY-";
58
+ /** Header prefix for PostHog feature flags. */
59
+ export declare const POSTHOG_FLAG_HEADER_PREFIX = "X-POSTHOG-FLAG-";
60
+ /** Timeout for framework / project detection probes (ms). */
61
+ export declare const DETECTION_TIMEOUT_MS = 10000;