@amplitude/wizard 1.0.0-beta.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 (333) hide show
  1. package/LICENSE +47 -0
  2. package/README.md +119 -0
  3. package/dist/bin.d.ts +2 -0
  4. package/dist/bin.js +763 -0
  5. package/dist/package.json +144 -0
  6. package/dist/src/frameworks/android/android-wizard-agent.d.ts +6 -0
  7. package/dist/src/frameworks/android/android-wizard-agent.js +72 -0
  8. package/dist/src/frameworks/android/utils.d.ts +11 -0
  9. package/dist/src/frameworks/android/utils.js +32 -0
  10. package/dist/src/frameworks/django/django-wizard-agent.d.ts +8 -0
  11. package/dist/src/frameworks/django/django-wizard-agent.js +171 -0
  12. package/dist/src/frameworks/django/utils.d.ts +31 -0
  13. package/dist/src/frameworks/django/utils.js +305 -0
  14. package/dist/src/frameworks/fastapi/fastapi-wizard-agent.d.ts +11 -0
  15. package/dist/src/frameworks/fastapi/fastapi-wizard-agent.js +189 -0
  16. package/dist/src/frameworks/fastapi/utils.d.ts +26 -0
  17. package/dist/src/frameworks/fastapi/utils.js +257 -0
  18. package/dist/src/frameworks/flask/flask-wizard-agent.d.ts +8 -0
  19. package/dist/src/frameworks/flask/flask-wizard-agent.js +177 -0
  20. package/dist/src/frameworks/flask/utils.d.ts +28 -0
  21. package/dist/src/frameworks/flask/utils.js +343 -0
  22. package/dist/src/frameworks/flutter/flutter-wizard-agent.d.ts +4 -0
  23. package/dist/src/frameworks/flutter/flutter-wizard-agent.js +57 -0
  24. package/dist/src/frameworks/flutter/utils.d.ts +7 -0
  25. package/dist/src/frameworks/flutter/utils.js +64 -0
  26. package/dist/src/frameworks/generic/generic-wizard-agent.d.ts +2 -0
  27. package/dist/src/frameworks/generic/generic-wizard-agent.js +176 -0
  28. package/dist/src/frameworks/go/go-wizard-agent.d.ts +4 -0
  29. package/dist/src/frameworks/go/go-wizard-agent.js +57 -0
  30. package/dist/src/frameworks/go/utils.d.ts +5 -0
  31. package/dist/src/frameworks/go/utils.js +44 -0
  32. package/dist/src/frameworks/java/java-wizard-agent.d.ts +7 -0
  33. package/dist/src/frameworks/java/java-wizard-agent.js +73 -0
  34. package/dist/src/frameworks/java/utils.d.ts +15 -0
  35. package/dist/src/frameworks/java/utils.js +64 -0
  36. package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.d.ts +4 -0
  37. package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.js +57 -0
  38. package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.d.ts +3 -0
  39. package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.js +151 -0
  40. package/dist/src/frameworks/javascript-web/utils.d.ts +28 -0
  41. package/dist/src/frameworks/javascript-web/utils.js +153 -0
  42. package/dist/src/frameworks/nextjs/nextjs-wizard-agent.d.ts +7 -0
  43. package/dist/src/frameworks/nextjs/nextjs-wizard-agent.js +98 -0
  44. package/dist/src/frameworks/nextjs/utils.d.ts +12 -0
  45. package/dist/src/frameworks/nextjs/utils.js +51 -0
  46. package/dist/src/frameworks/python/python-wizard-agent.d.ts +7 -0
  47. package/dist/src/frameworks/python/python-wizard-agent.js +193 -0
  48. package/dist/src/frameworks/python/utils.d.ts +28 -0
  49. package/dist/src/frameworks/python/utils.js +146 -0
  50. package/dist/src/frameworks/react-native/react-native-wizard-agent.d.ts +6 -0
  51. package/dist/src/frameworks/react-native/react-native-wizard-agent.js +84 -0
  52. package/dist/src/frameworks/react-native/utils.d.ts +21 -0
  53. package/dist/src/frameworks/react-native/utils.js +82 -0
  54. package/dist/src/frameworks/react-router/react-router-wizard-agent.d.ts +7 -0
  55. package/dist/src/frameworks/react-router/react-router-wizard-agent.js +98 -0
  56. package/dist/src/frameworks/react-router/utils.d.ts +13 -0
  57. package/dist/src/frameworks/react-router/utils.js +160 -0
  58. package/dist/src/frameworks/swift/swift-wizard-agent.d.ts +7 -0
  59. package/dist/src/frameworks/swift/swift-wizard-agent.js +72 -0
  60. package/dist/src/frameworks/swift/utils.d.ts +12 -0
  61. package/dist/src/frameworks/swift/utils.js +82 -0
  62. package/dist/src/frameworks/unity/unity-wizard-agent.d.ts +6 -0
  63. package/dist/src/frameworks/unity/unity-wizard-agent.js +79 -0
  64. package/dist/src/frameworks/unity/utils.d.ts +12 -0
  65. package/dist/src/frameworks/unity/utils.js +66 -0
  66. package/dist/src/frameworks/unreal/unreal-wizard-agent.d.ts +6 -0
  67. package/dist/src/frameworks/unreal/unreal-wizard-agent.js +77 -0
  68. package/dist/src/frameworks/unreal/utils.d.ts +10 -0
  69. package/dist/src/frameworks/unreal/utils.js +29 -0
  70. package/dist/src/frameworks/vue/vue-wizard-agent.d.ts +4 -0
  71. package/dist/src/frameworks/vue/vue-wizard-agent.js +64 -0
  72. package/dist/src/lib/agent-hooks.d.ts +26 -0
  73. package/dist/src/lib/agent-hooks.js +118 -0
  74. package/dist/src/lib/agent-interface.d.ts +175 -0
  75. package/dist/src/lib/agent-interface.js +1217 -0
  76. package/dist/src/lib/agent-runner.d.ts +9 -0
  77. package/dist/src/lib/agent-runner.js +415 -0
  78. package/dist/src/lib/ampli-config.d.ts +105 -0
  79. package/dist/src/lib/ampli-config.js +178 -0
  80. package/dist/src/lib/api.d.ts +107 -0
  81. package/dist/src/lib/api.js +442 -0
  82. package/dist/src/lib/commandments.d.ts +1 -0
  83. package/dist/src/lib/commandments.js +24 -0
  84. package/dist/src/lib/console-query.d.ts +27 -0
  85. package/dist/src/lib/console-query.js +121 -0
  86. package/dist/src/lib/constants.d.ts +124 -0
  87. package/dist/src/lib/constants.js +170 -0
  88. package/dist/src/lib/detect-amplitude.d.ts +31 -0
  89. package/dist/src/lib/detect-amplitude.js +407 -0
  90. package/dist/src/lib/framework-config.d.ts +188 -0
  91. package/dist/src/lib/framework-config.js +21 -0
  92. package/dist/src/lib/health-checks/endpoints.d.ts +3 -0
  93. package/dist/src/lib/health-checks/endpoints.js +45 -0
  94. package/dist/src/lib/health-checks/index.d.ts +4 -0
  95. package/dist/src/lib/health-checks/index.js +22 -0
  96. package/dist/src/lib/health-checks/readiness.d.ts +24 -0
  97. package/dist/src/lib/health-checks/readiness.js +118 -0
  98. package/dist/src/lib/health-checks/statuspage.d.ts +9 -0
  99. package/dist/src/lib/health-checks/statuspage.js +104 -0
  100. package/dist/src/lib/health-checks/types.d.ts +31 -0
  101. package/dist/src/lib/health-checks/types.js +9 -0
  102. package/dist/src/lib/helper-functions.d.ts +1 -0
  103. package/dist/src/lib/helper-functions.js +5 -0
  104. package/dist/src/lib/middleware/benchmark.d.ts +54 -0
  105. package/dist/src/lib/middleware/benchmark.js +48 -0
  106. package/dist/src/lib/middleware/benchmarks/cache-tracker.d.ts +44 -0
  107. package/dist/src/lib/middleware/benchmarks/cache-tracker.js +80 -0
  108. package/dist/src/lib/middleware/benchmarks/compaction-tracker.d.ts +29 -0
  109. package/dist/src/lib/middleware/benchmarks/compaction-tracker.js +59 -0
  110. package/dist/src/lib/middleware/benchmarks/context-size-tracker.d.ts +26 -0
  111. package/dist/src/lib/middleware/benchmarks/context-size-tracker.js +55 -0
  112. package/dist/src/lib/middleware/benchmarks/cost-tracker.d.ts +16 -0
  113. package/dist/src/lib/middleware/benchmarks/cost-tracker.js +75 -0
  114. package/dist/src/lib/middleware/benchmarks/duration-tracker.d.ts +20 -0
  115. package/dist/src/lib/middleware/benchmarks/duration-tracker.js +39 -0
  116. package/dist/src/lib/middleware/benchmarks/index.d.ts +9 -0
  117. package/dist/src/lib/middleware/benchmarks/index.js +67 -0
  118. package/dist/src/lib/middleware/benchmarks/json-writer.d.ts +15 -0
  119. package/dist/src/lib/middleware/benchmarks/json-writer.js +144 -0
  120. package/dist/src/lib/middleware/benchmarks/summary.d.ts +9 -0
  121. package/dist/src/lib/middleware/benchmarks/summary.js +105 -0
  122. package/dist/src/lib/middleware/benchmarks/token-tracker.d.ts +40 -0
  123. package/dist/src/lib/middleware/benchmarks/token-tracker.js +76 -0
  124. package/dist/src/lib/middleware/benchmarks/turn-counter.d.ts +34 -0
  125. package/dist/src/lib/middleware/benchmarks/turn-counter.js +58 -0
  126. package/dist/src/lib/middleware/config.d.ts +24 -0
  127. package/dist/src/lib/middleware/config.js +96 -0
  128. package/dist/src/lib/middleware/index.d.ts +11 -0
  129. package/dist/src/lib/middleware/index.js +17 -0
  130. package/dist/src/lib/middleware/phase-detector.d.ts +8 -0
  131. package/dist/src/lib/middleware/phase-detector.js +63 -0
  132. package/dist/src/lib/middleware/pipeline.d.ts +29 -0
  133. package/dist/src/lib/middleware/pipeline.js +81 -0
  134. package/dist/src/lib/middleware/schemas.d.ts +27 -0
  135. package/dist/src/lib/middleware/schemas.js +84 -0
  136. package/dist/src/lib/middleware/types.d.ts +94 -0
  137. package/dist/src/lib/middleware/types.js +8 -0
  138. package/dist/src/lib/package-manager-detection.d.ts +42 -0
  139. package/dist/src/lib/package-manager-detection.js +292 -0
  140. package/dist/src/lib/registry.d.ts +3 -0
  141. package/dist/src/lib/registry.js +42 -0
  142. package/dist/src/lib/safe-tools.d.ts +2 -0
  143. package/dist/src/lib/safe-tools.js +214 -0
  144. package/dist/src/lib/wizard-session.d.ts +220 -0
  145. package/dist/src/lib/wizard-session.js +127 -0
  146. package/dist/src/lib/wizard-tools.d.ts +82 -0
  147. package/dist/src/lib/wizard-tools.js +499 -0
  148. package/dist/src/run.d.ts +19 -0
  149. package/dist/src/run.js +151 -0
  150. package/dist/src/steps/add-mcp-server-to-clients/MCPClient.d.ts +30 -0
  151. package/dist/src/steps/add-mcp-server-to-clients/MCPClient.js +141 -0
  152. package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.d.ts +29 -0
  153. package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.js +180 -0
  154. package/dist/src/steps/add-mcp-server-to-clients/clients/claude.d.ts +20 -0
  155. package/dist/src/steps/add-mcp-server-to-clients/clients/claude.js +63 -0
  156. package/dist/src/steps/add-mcp-server-to-clients/clients/codex.d.ts +28 -0
  157. package/dist/src/steps/add-mcp-server-to-clients/clients/codex.js +77 -0
  158. package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.d.ts +24 -0
  159. package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.js +60 -0
  160. package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.d.ts +27 -0
  161. package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.js +101 -0
  162. package/dist/src/steps/add-mcp-server-to-clients/clients/zed.d.ts +26 -0
  163. package/dist/src/steps/add-mcp-server-to-clients/clients/zed.js +102 -0
  164. package/dist/src/steps/add-mcp-server-to-clients/defaults.d.ts +44 -0
  165. package/dist/src/steps/add-mcp-server-to-clients/defaults.js +123 -0
  166. package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +19 -0
  167. package/dist/src/steps/add-mcp-server-to-clients/index.js +110 -0
  168. package/dist/src/steps/add-or-update-environment-variables.d.ts +10 -0
  169. package/dist/src/steps/add-or-update-environment-variables.js +188 -0
  170. package/dist/src/steps/index.d.ts +4 -0
  171. package/dist/src/steps/index.js +20 -0
  172. package/dist/src/steps/run-prettier.d.ts +5 -0
  173. package/dist/src/steps/run-prettier.js +90 -0
  174. package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +11 -0
  175. package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js +11 -0
  176. package/dist/src/steps/upload-environment-variables/index.d.ts +6 -0
  177. package/dist/src/steps/upload-environment-variables/index.js +37 -0
  178. package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +15 -0
  179. package/dist/src/steps/upload-environment-variables/providers/vercel.js +145 -0
  180. package/dist/src/telemetry.d.ts +2 -0
  181. package/dist/src/telemetry.js +12 -0
  182. package/dist/src/ui/index.d.ts +8 -0
  183. package/dist/src/ui/index.js +16 -0
  184. package/dist/src/ui/logging-ui.d.ts +56 -0
  185. package/dist/src/ui/logging-ui.js +157 -0
  186. package/dist/src/ui/tui/App.d.ts +6 -0
  187. package/dist/src/ui/tui/App.js +34 -0
  188. package/dist/src/ui/tui/components/AmplitudeLogo.d.ts +5 -0
  189. package/dist/src/ui/tui/components/AmplitudeLogo.js +81 -0
  190. package/dist/src/ui/tui/components/AmplitudeTextLogo.d.ts +3 -0
  191. package/dist/src/ui/tui/components/AmplitudeTextLogo.js +31 -0
  192. package/dist/src/ui/tui/components/ConsoleView.d.ts +23 -0
  193. package/dist/src/ui/tui/components/ConsoleView.js +220 -0
  194. package/dist/src/ui/tui/components/TitleBar.d.ts +6 -0
  195. package/dist/src/ui/tui/components/TitleBar.js +16 -0
  196. package/dist/src/ui/tui/console-commands.d.ts +16 -0
  197. package/dist/src/ui/tui/console-commands.js +31 -0
  198. package/dist/src/ui/tui/context/CommandModeContext.d.ts +2 -0
  199. package/dist/src/ui/tui/context/CommandModeContext.js +3 -0
  200. package/dist/src/ui/tui/flows.d.ts +48 -0
  201. package/dist/src/ui/tui/flows.js +154 -0
  202. package/dist/src/ui/tui/hooks/useScreenInput.d.ts +13 -0
  203. package/dist/src/ui/tui/hooks/useScreenInput.js +18 -0
  204. package/dist/src/ui/tui/hooks/useStdoutDimensions.d.ts +9 -0
  205. package/dist/src/ui/tui/hooks/useStdoutDimensions.js +29 -0
  206. package/dist/src/ui/tui/ink-ui.d.ts +62 -0
  207. package/dist/src/ui/tui/ink-ui.js +142 -0
  208. package/dist/src/ui/tui/primitives/CardLayout.d.ts +12 -0
  209. package/dist/src/ui/tui/primitives/CardLayout.js +9 -0
  210. package/dist/src/ui/tui/primitives/ConfirmationInput.d.ts +13 -0
  211. package/dist/src/ui/tui/primitives/ConfirmationInput.js +35 -0
  212. package/dist/src/ui/tui/primitives/DissolveTransition.d.ts +21 -0
  213. package/dist/src/ui/tui/primitives/DissolveTransition.js +143 -0
  214. package/dist/src/ui/tui/primitives/EventPlanViewer.d.ts +9 -0
  215. package/dist/src/ui/tui/primitives/EventPlanViewer.js +9 -0
  216. package/dist/src/ui/tui/primitives/KagiSmallWebViewer.d.ts +7 -0
  217. package/dist/src/ui/tui/primitives/KagiSmallWebViewer.js +101 -0
  218. package/dist/src/ui/tui/primitives/LoadingBox.d.ts +8 -0
  219. package/dist/src/ui/tui/primitives/LoadingBox.js +9 -0
  220. package/dist/src/ui/tui/primitives/LogViewer.d.ts +11 -0
  221. package/dist/src/ui/tui/primitives/LogViewer.js +55 -0
  222. package/dist/src/ui/tui/primitives/PickerMenu.d.ts +20 -0
  223. package/dist/src/ui/tui/primitives/PickerMenu.js +212 -0
  224. package/dist/src/ui/tui/primitives/ProgressList.d.ts +15 -0
  225. package/dist/src/ui/tui/primitives/ProgressList.js +29 -0
  226. package/dist/src/ui/tui/primitives/PromptLabel.d.ts +11 -0
  227. package/dist/src/ui/tui/primitives/PromptLabel.js +12 -0
  228. package/dist/src/ui/tui/primitives/ReportViewer.d.ts +12 -0
  229. package/dist/src/ui/tui/primitives/ReportViewer.js +99 -0
  230. package/dist/src/ui/tui/primitives/ScreenErrorBoundary.d.ts +26 -0
  231. package/dist/src/ui/tui/primitives/ScreenErrorBoundary.js +29 -0
  232. package/dist/src/ui/tui/primitives/SlashCommandInput.d.ts +21 -0
  233. package/dist/src/ui/tui/primitives/SlashCommandInput.js +85 -0
  234. package/dist/src/ui/tui/primitives/SnakeGame.d.ts +1 -0
  235. package/dist/src/ui/tui/primitives/SnakeGame.js +1 -0
  236. package/dist/src/ui/tui/primitives/SplitView.d.ts +11 -0
  237. package/dist/src/ui/tui/primitives/SplitView.js +8 -0
  238. package/dist/src/ui/tui/primitives/TabContainer.d.ts +18 -0
  239. package/dist/src/ui/tui/primitives/TabContainer.js +30 -0
  240. package/dist/src/ui/tui/primitives/index.d.ts +23 -0
  241. package/dist/src/ui/tui/primitives/index.js +19 -0
  242. package/dist/src/ui/tui/router.d.ts +61 -0
  243. package/dist/src/ui/tui/router.js +104 -0
  244. package/dist/src/ui/tui/screen-registry.d.ts +19 -0
  245. package/dist/src/ui/tui/screen-registry.js +56 -0
  246. package/dist/src/ui/tui/screens/ActivationOptionsScreen.d.ts +12 -0
  247. package/dist/src/ui/tui/screens/ActivationOptionsScreen.js +57 -0
  248. package/dist/src/ui/tui/screens/AuthScreen.d.ts +18 -0
  249. package/dist/src/ui/tui/screens/AuthScreen.js +107 -0
  250. package/dist/src/ui/tui/screens/ChecklistScreen.d.ts +22 -0
  251. package/dist/src/ui/tui/screens/ChecklistScreen.js +122 -0
  252. package/dist/src/ui/tui/screens/DataIngestionCheckScreen.d.ts +24 -0
  253. package/dist/src/ui/tui/screens/DataIngestionCheckScreen.js +113 -0
  254. package/dist/src/ui/tui/screens/DataSetupScreen.d.ts +17 -0
  255. package/dist/src/ui/tui/screens/DataSetupScreen.js +73 -0
  256. package/dist/src/ui/tui/screens/IntroScreen.d.ts +16 -0
  257. package/dist/src/ui/tui/screens/IntroScreen.js +86 -0
  258. package/dist/src/ui/tui/screens/LoginScreen.d.ts +15 -0
  259. package/dist/src/ui/tui/screens/LoginScreen.js +65 -0
  260. package/dist/src/ui/tui/screens/LogoutScreen.d.ts +12 -0
  261. package/dist/src/ui/tui/screens/LogoutScreen.js +28 -0
  262. package/dist/src/ui/tui/screens/McpScreen.d.ts +26 -0
  263. package/dist/src/ui/tui/screens/McpScreen.js +148 -0
  264. package/dist/src/ui/tui/screens/OutageScreen.d.ts +10 -0
  265. package/dist/src/ui/tui/screens/OutageScreen.js +17 -0
  266. package/dist/src/ui/tui/screens/OutroScreen.d.ts +11 -0
  267. package/dist/src/ui/tui/screens/OutroScreen.js +69 -0
  268. package/dist/src/ui/tui/screens/RegionSelectScreen.d.ts +17 -0
  269. package/dist/src/ui/tui/screens/RegionSelectScreen.js +40 -0
  270. package/dist/src/ui/tui/screens/RunScreen.d.ts +16 -0
  271. package/dist/src/ui/tui/screens/RunScreen.js +212 -0
  272. package/dist/src/ui/tui/screens/SettingsOverrideScreen.d.ts +10 -0
  273. package/dist/src/ui/tui/screens/SettingsOverrideScreen.js +23 -0
  274. package/dist/src/ui/tui/screens/SetupScreen.d.ts +13 -0
  275. package/dist/src/ui/tui/screens/SetupScreen.js +73 -0
  276. package/dist/src/ui/tui/screens/SlackScreen.d.ts +25 -0
  277. package/dist/src/ui/tui/screens/SlackScreen.js +97 -0
  278. package/dist/src/ui/tui/services/mcp-installer.d.ts +25 -0
  279. package/dist/src/ui/tui/services/mcp-installer.js +82 -0
  280. package/dist/src/ui/tui/start-tui.d.ts +10 -0
  281. package/dist/src/ui/tui/start-tui.js +50 -0
  282. package/dist/src/ui/tui/store.d.ts +231 -0
  283. package/dist/src/ui/tui/store.js +568 -0
  284. package/dist/src/ui/tui/styles.d.ts +31 -0
  285. package/dist/src/ui/tui/styles.js +33 -0
  286. package/dist/src/ui/wizard-ui.d.ts +110 -0
  287. package/dist/src/ui/wizard-ui.js +18 -0
  288. package/dist/src/utils/ampli-settings.d.ts +37 -0
  289. package/dist/src/utils/ampli-settings.js +182 -0
  290. package/dist/src/utils/analytics.d.ts +35 -0
  291. package/dist/src/utils/analytics.js +133 -0
  292. package/dist/src/utils/anthropic-status.d.ts +17 -0
  293. package/dist/src/utils/anthropic-status.js +51 -0
  294. package/dist/src/utils/api-key-store.d.ts +35 -0
  295. package/dist/src/utils/api-key-store.js +176 -0
  296. package/dist/src/utils/bash.d.ts +2 -0
  297. package/dist/src/utils/bash.js +53 -0
  298. package/dist/src/utils/custom-headers.d.ts +9 -0
  299. package/dist/src/utils/custom-headers.js +23 -0
  300. package/dist/src/utils/debug.d.ts +23 -0
  301. package/dist/src/utils/debug.js +86 -0
  302. package/dist/src/utils/environment.d.ts +4 -0
  303. package/dist/src/utils/environment.js +76 -0
  304. package/dist/src/utils/file-utils.d.ts +2 -0
  305. package/dist/src/utils/file-utils.js +16 -0
  306. package/dist/src/utils/get-api-key.d.ts +17 -0
  307. package/dist/src/utils/get-api-key.js +50 -0
  308. package/dist/src/utils/logging.d.ts +9 -0
  309. package/dist/src/utils/logging.js +48 -0
  310. package/dist/src/utils/oauth.d.ts +53 -0
  311. package/dist/src/utils/oauth.js +354 -0
  312. package/dist/src/utils/package-json.d.ts +25 -0
  313. package/dist/src/utils/package-json.js +26 -0
  314. package/dist/src/utils/package-manager.d.ts +21 -0
  315. package/dist/src/utils/package-manager.js +208 -0
  316. package/dist/src/utils/semver.d.ts +21 -0
  317. package/dist/src/utils/semver.js +61 -0
  318. package/dist/src/utils/setup-utils.d.ts +82 -0
  319. package/dist/src/utils/setup-utils.js +467 -0
  320. package/dist/src/utils/shell-completions.d.ts +10 -0
  321. package/dist/src/utils/shell-completions.js +199 -0
  322. package/dist/src/utils/string.d.ts +1 -0
  323. package/dist/src/utils/string.js +8 -0
  324. package/dist/src/utils/types.d.ts +72 -0
  325. package/dist/src/utils/types.js +2 -0
  326. package/dist/src/utils/urls.d.ts +14 -0
  327. package/dist/src/utils/urls.js +69 -0
  328. package/dist/src/utils/vendor/is-unicorn-supported.d.ts +1 -0
  329. package/dist/src/utils/vendor/is-unicorn-supported.js +23 -0
  330. package/dist/src/utils/wizard-abort.d.ts +13 -0
  331. package/dist/src/utils/wizard-abort.js +56 -0
  332. package/man/amplitude-wizard.1 +170 -0
  333. package/package.json +144 -0
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.detectReactNativeProject = detectReactNativeProject;
37
+ exports.detectExpo = detectExpo;
38
+ const fs = __importStar(require("node:fs"));
39
+ const path = __importStar(require("node:path"));
40
+ const package_json_1 = require("../../utils/package-json");
41
+ const setup_utils_1 = require("../../utils/setup-utils");
42
+ /**
43
+ * Returns true when the directory contains a React Native project.
44
+ *
45
+ * Primary signal: package.json with `react-native` in dependencies or
46
+ * devDependencies. This is the definitive indicator that distinguishes
47
+ * React Native from:
48
+ * - Plain web apps (Next.js, Vite, CRA) — no `react-native` dep
49
+ * - Pure Android native projects — no package.json at all
50
+ * - Flutter — uses pubspec.yaml, detected earlier in the pipeline
51
+ *
52
+ * Note: The `javascript-web` detector already excludes `react-native`
53
+ * via FRAMEWORK_PACKAGES, and this detector runs before `android` in
54
+ * the registry so AndroidManifest.xml overlap is not a concern.
55
+ */
56
+ async function detectReactNativeProject(options) {
57
+ const packageJson = await (0, setup_utils_1.tryGetPackageJson)(options);
58
+ if (!packageJson)
59
+ return false;
60
+ return (0, package_json_1.hasPackageInstalled)('react-native', packageJson);
61
+ }
62
+ /**
63
+ * Returns true if the React Native project uses Expo.
64
+ * Checks for `expo` package or an app.json with a top-level "expo" key.
65
+ */
66
+ async function detectExpo(options) {
67
+ const packageJson = await (0, setup_utils_1.tryGetPackageJson)(options);
68
+ if (packageJson && (0, package_json_1.hasPackageInstalled)('expo', packageJson)) {
69
+ return true;
70
+ }
71
+ // Expo managed workflow: app.json has { "expo": { ... } }
72
+ const appJsonPath = path.join(options.installDir, 'app.json');
73
+ try {
74
+ const appJson = JSON.parse(fs.readFileSync(appJsonPath, 'utf-8'));
75
+ if ('expo' in appJson)
76
+ return true;
77
+ }
78
+ catch {
79
+ // absent or unparseable — not Expo
80
+ }
81
+ return false;
82
+ }
@@ -0,0 +1,7 @@
1
+ import type { FrameworkConfig } from '../../lib/framework-config';
2
+ import { ReactRouterMode } from './utils';
3
+ type ReactRouterContext = {
4
+ routerMode?: ReactRouterMode;
5
+ };
6
+ export declare const REACT_ROUTER_AGENT_CONFIG: FrameworkConfig<ReactRouterContext>;
7
+ export {};
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REACT_ROUTER_AGENT_CONFIG = void 0;
4
+ const package_manager_detection_1 = require("../../lib/package-manager-detection");
5
+ const constants_1 = require("../../lib/constants");
6
+ const package_json_1 = require("../../utils/package-json");
7
+ const setup_utils_1 = require("../../utils/setup-utils");
8
+ const ui_1 = require("../../ui");
9
+ const utils_1 = require("./utils");
10
+ exports.REACT_ROUTER_AGENT_CONFIG = {
11
+ metadata: {
12
+ name: 'React Router',
13
+ integration: constants_1.Integration.reactRouter,
14
+ docsUrl: 'https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2',
15
+ unsupportedVersionDocsUrl: 'https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2',
16
+ gatherContext: async (options) => {
17
+ const routerMode = await (0, utils_1.getReactRouterMode)(options);
18
+ if (routerMode) {
19
+ (0, ui_1.getUI)().setDetectedFramework(`React Router ${(0, utils_1.getReactRouterModeName)(routerMode)}`);
20
+ return { routerMode };
21
+ }
22
+ return {};
23
+ },
24
+ },
25
+ detection: {
26
+ packageName: 'react-router',
27
+ packageDisplayName: 'React Router',
28
+ getVersion: (packageJson) => (0, package_json_1.getPackageVersion)('react-router', packageJson),
29
+ getVersionBucket: utils_1.getReactRouterVersionBucket,
30
+ minimumVersion: '6.0.0',
31
+ getInstalledVersion: async (options) => {
32
+ const packageJson = await (0, setup_utils_1.tryGetPackageJson)(options);
33
+ return packageJson
34
+ ? (0, package_json_1.getPackageVersion)('react-router', packageJson)
35
+ : undefined;
36
+ },
37
+ detect: async (options) => {
38
+ const packageJson = await (0, setup_utils_1.tryGetPackageJson)(options);
39
+ return packageJson
40
+ ? (0, package_json_1.hasPackageInstalled)('react-router', packageJson)
41
+ : false;
42
+ },
43
+ detectPackageManager: package_manager_detection_1.detectNodePackageManagers,
44
+ },
45
+ environment: {
46
+ uploadToHosting: false,
47
+ getEnvVars: (apiKey, _host) => ({
48
+ REACT_APP_AMPLITUDE_API_KEY: apiKey,
49
+ }),
50
+ },
51
+ analytics: {
52
+ getTags: (context) => ({
53
+ routerMode: context.routerMode || 'unknown',
54
+ }),
55
+ },
56
+ prompts: {
57
+ projectTypeDetection: 'This is a JavaScript/TypeScript project. Look for package.json and lockfiles (package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb) to confirm.',
58
+ getAdditionalContextLines: (context) => {
59
+ const routerMode = context.routerMode;
60
+ const modeName = routerMode
61
+ ? (0, utils_1.getReactRouterModeName)(routerMode)
62
+ : 'unknown';
63
+ // Map router mode to framework ID for MCP docs resource
64
+ const frameworkIdMap = {
65
+ [utils_1.ReactRouterMode.V6]: 'react-react-router-6',
66
+ [utils_1.ReactRouterMode.V7_FRAMEWORK]: 'react-react-router-7-framework',
67
+ [utils_1.ReactRouterMode.V7_DATA]: 'react-react-router-7-data',
68
+ [utils_1.ReactRouterMode.V7_DECLARATIVE]: 'react-react-router-7-declarative',
69
+ };
70
+ const frameworkId = routerMode
71
+ ? frameworkIdMap[routerMode]
72
+ : utils_1.ReactRouterMode.V7_FRAMEWORK;
73
+ return [
74
+ `Router mode: ${modeName}`,
75
+ `Framework docs ID: ${frameworkId} (use amplitude://docs/frameworks/${frameworkId} for documentation)`,
76
+ `Preferred Amplitude SDK: @amplitude/unified (prefer over @amplitude/analytics-browser for new browser integrations)`,
77
+ ];
78
+ },
79
+ },
80
+ ui: {
81
+ successMessage: 'Amplitude integration complete',
82
+ estimatedDurationMinutes: 8,
83
+ getOutroChanges: (context) => {
84
+ const modeName = context.routerMode
85
+ ? (0, utils_1.getReactRouterModeName)(context.routerMode)
86
+ : 'React Router';
87
+ return [
88
+ `Analyzed your React Router project structure (${modeName})`,
89
+ `Created and configured Amplitude initializers`,
90
+ `Integrated Amplitude into your application`,
91
+ ];
92
+ },
93
+ getOutroNextSteps: () => [
94
+ 'Start your development server to see Amplitude in action',
95
+ 'Visit your Amplitude dashboard to see incoming events',
96
+ ],
97
+ },
98
+ };
@@ -0,0 +1,13 @@
1
+ import type { WizardOptions } from '../../utils/types';
2
+ export declare enum ReactRouterMode {
3
+ V6 = "v6",
4
+ V7_FRAMEWORK = "v7-framework",
5
+ V7_DATA = "v7-data",
6
+ V7_DECLARATIVE = "v7-declarative"
7
+ }
8
+ export declare const getReactRouterVersionBucket: (version: string | undefined) => string;
9
+ /**
10
+ * Detect React Router mode. Pure — returns null if ambiguous.
11
+ */
12
+ export declare function getReactRouterMode(options: WizardOptions): Promise<ReactRouterMode | null>;
13
+ export declare function getReactRouterModeName(mode: ReactRouterMode): string;
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getReactRouterVersionBucket = exports.ReactRouterMode = void 0;
40
+ exports.getReactRouterMode = getReactRouterMode;
41
+ exports.getReactRouterModeName = getReactRouterModeName;
42
+ const semver_1 = require("semver");
43
+ const fast_glob_1 = __importDefault(require("fast-glob"));
44
+ const setup_utils_1 = require("../../utils/setup-utils");
45
+ const package_json_1 = require("../../utils/package-json");
46
+ const semver_2 = require("../../utils/semver");
47
+ const fs = __importStar(require("node:fs"));
48
+ const path = __importStar(require("node:path"));
49
+ const semver = __importStar(require("semver"));
50
+ var ReactRouterMode;
51
+ (function (ReactRouterMode) {
52
+ ReactRouterMode["V6"] = "v6";
53
+ ReactRouterMode["V7_FRAMEWORK"] = "v7-framework";
54
+ ReactRouterMode["V7_DATA"] = "v7-data";
55
+ ReactRouterMode["V7_DECLARATIVE"] = "v7-declarative";
56
+ })(ReactRouterMode || (exports.ReactRouterMode = ReactRouterMode = {}));
57
+ const IGNORE_PATTERNS = [
58
+ '**/node_modules/**',
59
+ '**/dist/**',
60
+ '**/build/**',
61
+ '**/public/**',
62
+ '**/.next/**',
63
+ ];
64
+ exports.getReactRouterVersionBucket = (0, semver_2.createVersionBucket)();
65
+ async function hasReactRouterConfig({ installDir, }) {
66
+ const configMatches = await (0, fast_glob_1.default)('**/react-router.config.@(ts|js|tsx|jsx)', {
67
+ dot: true,
68
+ cwd: installDir,
69
+ ignore: IGNORE_PATTERNS,
70
+ });
71
+ return configMatches.length > 0;
72
+ }
73
+ async function hasCreateBrowserRouter({ installDir, }) {
74
+ const sourceFiles = await (0, fast_glob_1.default)('**/*.@(ts|tsx|js|jsx)', {
75
+ dot: true,
76
+ cwd: installDir,
77
+ ignore: IGNORE_PATTERNS,
78
+ });
79
+ for (const file of sourceFiles) {
80
+ try {
81
+ const filePath = path.join(installDir, file);
82
+ const content = fs.readFileSync(filePath, 'utf-8');
83
+ if (content.includes('createBrowserRouter')) {
84
+ return true;
85
+ }
86
+ }
87
+ catch {
88
+ continue;
89
+ }
90
+ }
91
+ return false;
92
+ }
93
+ async function hasDeclarativeRouter({ installDir, }) {
94
+ const sourceFiles = await (0, fast_glob_1.default)('**/*.@(ts|tsx|js|jsx)', {
95
+ dot: true,
96
+ cwd: installDir,
97
+ ignore: IGNORE_PATTERNS,
98
+ });
99
+ for (const file of sourceFiles) {
100
+ try {
101
+ const filePath = path.join(installDir, file);
102
+ const content = fs.readFileSync(filePath, 'utf-8');
103
+ if (content.includes('<BrowserRouter') ||
104
+ (content.includes('BrowserRouter') &&
105
+ (content.includes('from "react-router-dom"') ||
106
+ content.includes("from 'react-router-dom'")))) {
107
+ return true;
108
+ }
109
+ }
110
+ catch {
111
+ continue;
112
+ }
113
+ }
114
+ return false;
115
+ }
116
+ /**
117
+ * Detect React Router mode. Pure — returns null if ambiguous.
118
+ */
119
+ async function getReactRouterMode(options) {
120
+ const { installDir } = options;
121
+ const packageJson = await (0, setup_utils_1.tryGetPackageJson)(options);
122
+ if (!packageJson)
123
+ return null;
124
+ const reactRouterVersion = (0, package_json_1.getPackageVersion)('react-router-dom', packageJson) ||
125
+ (0, package_json_1.getPackageVersion)('react-router', packageJson);
126
+ if (!reactRouterVersion) {
127
+ return null;
128
+ }
129
+ const coercedVersion = semver.coerce(reactRouterVersion);
130
+ const majorVersion = coercedVersion ? (0, semver_1.major)(coercedVersion) : null;
131
+ if (majorVersion === 6) {
132
+ return ReactRouterMode.V6;
133
+ }
134
+ if (majorVersion === 7) {
135
+ const hasConfig = await hasReactRouterConfig({ installDir });
136
+ if (hasConfig)
137
+ return ReactRouterMode.V7_FRAMEWORK;
138
+ const hasDataMode = await hasCreateBrowserRouter({ installDir });
139
+ if (hasDataMode)
140
+ return ReactRouterMode.V7_DATA;
141
+ const hasDeclarative = await hasDeclarativeRouter({ installDir });
142
+ if (hasDeclarative)
143
+ return ReactRouterMode.V7_DECLARATIVE;
144
+ // v7 but can't detect mode
145
+ return null;
146
+ }
147
+ return null;
148
+ }
149
+ function getReactRouterModeName(mode) {
150
+ switch (mode) {
151
+ case ReactRouterMode.V6:
152
+ return 'v6';
153
+ case ReactRouterMode.V7_FRAMEWORK:
154
+ return 'v7 Framework mode';
155
+ case ReactRouterMode.V7_DATA:
156
+ return 'v7 Data mode';
157
+ case ReactRouterMode.V7_DECLARATIVE:
158
+ return 'v7 Declarative mode';
159
+ }
160
+ }
@@ -0,0 +1,7 @@
1
+ import type { FrameworkConfig } from '../../lib/framework-config';
2
+ import type { SwiftPackageManager } from './utils';
3
+ type SwiftContext = {
4
+ packageManager?: SwiftPackageManager;
5
+ };
6
+ export declare const SWIFT_AGENT_CONFIG: FrameworkConfig<SwiftContext>;
7
+ export {};
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SWIFT_AGENT_CONFIG = void 0;
4
+ const package_manager_detection_1 = require("../../lib/package-manager-detection");
5
+ const constants_1 = require("../../lib/constants");
6
+ const utils_1 = require("./utils");
7
+ const SWIFT_PACKAGE_INSTALLATION = "Use the detect_package_manager tool to determine the package manager. For Swift Package Manager: add the dependency via Xcode (File > Add Package Dependencies) using the URL https://github.com/amplitude/AmplitudeUnified-Swift, or by editing Package.swift. For CocoaPods: add `pod 'AmplitudeUnified'` to the Podfile and run pod install.";
8
+ exports.SWIFT_AGENT_CONFIG = {
9
+ metadata: {
10
+ name: 'Swift',
11
+ integration: constants_1.Integration.swift,
12
+ beta: true,
13
+ docsUrl: 'https://amplitude.com/docs/sdks/analytics/ios/unified-sdk',
14
+ preRunNotice: 'Close Xcode before running the wizard to avoid file conflicts.',
15
+ gatherContext: (options) => {
16
+ const packageManager = (0, utils_1.detectSwiftPackageManager)(options);
17
+ return Promise.resolve({ packageManager });
18
+ },
19
+ },
20
+ detection: {
21
+ packageName: 'AmplitudeUnified',
22
+ packageDisplayName: 'Swift',
23
+ usesPackageJson: false,
24
+ getVersion: () => undefined,
25
+ detect: utils_1.detectSwiftProject,
26
+ detectPackageManager: package_manager_detection_1.swiftPackageManager,
27
+ },
28
+ environment: {
29
+ // iOS/macOS apps don't use .env files — the agent stores the key in the project
30
+ uploadToHosting: false,
31
+ getEnvVars: () => ({}),
32
+ },
33
+ analytics: {
34
+ getTags: (context) => ({
35
+ packageManager: context.packageManager ?? 'unknown',
36
+ }),
37
+ },
38
+ prompts: {
39
+ projectTypeDetection: 'This is a Swift/iOS/macOS project. Look for *.xcodeproj directories, Podfile, Package.swift, or .swift source files to confirm.',
40
+ packageInstallation: SWIFT_PACKAGE_INSTALLATION,
41
+ getAdditionalContextLines: (context) => {
42
+ const pm = context.packageManager ?? 'spm';
43
+ return [
44
+ `Package manager: ${pm === 'cocoapods' ? 'CocoaPods' : 'Swift Package Manager'}`,
45
+ `Framework docs ID: swift (use amplitude://docs/frameworks/swift for documentation)`,
46
+ `SDK: AmplitudeUnified — Swift package URL: https://github.com/amplitude/AmplitudeUnified-Swift`,
47
+ `Initialization: let amplitude = Amplitude(apiKey: "YOUR_API_KEY", analyticsConfig: AnalyticsConfig(autocapture: [.sessions, .appLifecycles, .screenViews]))`,
48
+ `Never hardcode the API key in source files — store it in a .xcconfig file or Info.plist and read it at runtime`,
49
+ ];
50
+ },
51
+ },
52
+ ui: {
53
+ successMessage: 'Amplitude integration complete',
54
+ estimatedDurationMinutes: 8,
55
+ getOutroChanges: (context) => {
56
+ const pmLabel = context.packageManager === 'cocoapods'
57
+ ? 'CocoaPods'
58
+ : 'Swift Package Manager';
59
+ return [
60
+ `Analyzed your Swift project structure`,
61
+ `Added the AmplitudeUnified package via ${pmLabel}`,
62
+ `Configured Amplitude with autocapture for sessions, app lifecycles, and screen views`,
63
+ ];
64
+ },
65
+ getOutroNextSteps: () => [
66
+ 'Build and run your app in the simulator to verify the integration',
67
+ 'Visit your Amplitude dashboard to see incoming events',
68
+ 'Use amplitude.track(eventType:eventProperties:) for custom events',
69
+ 'Use amplitude.setUserId(userId:) to associate events with users',
70
+ ],
71
+ },
72
+ };
@@ -0,0 +1,12 @@
1
+ import type { WizardOptions } from '../../utils/types';
2
+ export type SwiftPackageManager = 'spm' | 'cocoapods';
3
+ /**
4
+ * Returns the package manager used by the Swift project.
5
+ * CocoaPods takes priority when a Podfile is present.
6
+ */
7
+ export declare function detectSwiftPackageManager(options: Pick<WizardOptions, 'installDir'>): SwiftPackageManager;
8
+ /**
9
+ * Returns true when the directory contains an iOS/macOS Swift project.
10
+ * Signals: *.xcodeproj directory, Podfile, or Package.swift + .swift sources.
11
+ */
12
+ export declare function detectSwiftProject(options: Pick<WizardOptions, 'installDir'>): Promise<boolean>;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.detectSwiftPackageManager = detectSwiftPackageManager;
40
+ exports.detectSwiftProject = detectSwiftProject;
41
+ const fs = __importStar(require("node:fs"));
42
+ const path = __importStar(require("node:path"));
43
+ const fast_glob_1 = __importDefault(require("fast-glob"));
44
+ /**
45
+ * Returns the package manager used by the Swift project.
46
+ * CocoaPods takes priority when a Podfile is present.
47
+ */
48
+ function detectSwiftPackageManager(options) {
49
+ if (fs.existsSync(path.join(options.installDir, 'Podfile'))) {
50
+ return 'cocoapods';
51
+ }
52
+ return 'spm';
53
+ }
54
+ /**
55
+ * Returns true when the directory contains an iOS/macOS Swift project.
56
+ * Signals: *.xcodeproj directory, Podfile, or Package.swift + .swift sources.
57
+ */
58
+ async function detectSwiftProject(options) {
59
+ const { installDir } = options;
60
+ // Xcode project or workspace
61
+ const xcodeProjects = await (0, fast_glob_1.default)(['*.xcodeproj', '*.xcworkspace'], {
62
+ cwd: installDir,
63
+ onlyDirectories: true,
64
+ deep: 1,
65
+ });
66
+ if (xcodeProjects.length > 0) {
67
+ return true;
68
+ }
69
+ // CocoaPods Podfile
70
+ if (fs.existsSync(path.join(installDir, 'Podfile'))) {
71
+ return true;
72
+ }
73
+ // Package.swift with at least one .swift source file
74
+ if (fs.existsSync(path.join(installDir, 'Package.swift'))) {
75
+ const swiftFiles = await (0, fast_glob_1.default)('Sources/**/*.swift', {
76
+ cwd: installDir,
77
+ ignore: ['**/.build/**'],
78
+ });
79
+ return swiftFiles.length > 0;
80
+ }
81
+ return false;
82
+ }
@@ -0,0 +1,6 @@
1
+ import type { FrameworkConfig } from '../../lib/framework-config';
2
+ type UnityContext = {
3
+ pluginAlreadyPresent?: boolean;
4
+ };
5
+ export declare const UNITY_AGENT_CONFIG: FrameworkConfig<UnityContext>;
6
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UNITY_AGENT_CONFIG = void 0;
4
+ const package_manager_detection_1 = require("../../lib/package-manager-detection");
5
+ const constants_1 = require("../../lib/constants");
6
+ const utils_1 = require("./utils");
7
+ exports.UNITY_AGENT_CONFIG = {
8
+ metadata: {
9
+ name: 'Unity',
10
+ integration: constants_1.Integration.unity,
11
+ beta: true,
12
+ docsUrl: 'https://amplitude.com/docs/sdks/analytics/unity/unity-sdk',
13
+ preRunNotice: 'Close the Unity Editor before running the wizard to avoid file conflicts.',
14
+ gatherContext: (options) => {
15
+ const pluginAlreadyPresent = (0, utils_1.isAmplitudePluginPresent)(options);
16
+ return Promise.resolve({ pluginAlreadyPresent });
17
+ },
18
+ },
19
+ detection: {
20
+ packageName: 'com.amplitude.unity-plugin',
21
+ packageDisplayName: 'Unity',
22
+ usesPackageJson: false,
23
+ getVersion: () => undefined,
24
+ detect: utils_1.detectUnityProject,
25
+ detectPackageManager: package_manager_detection_1.unityPackageManager,
26
+ },
27
+ environment: {
28
+ // Unity C# doesn't read from .env files — API key is stored in a
29
+ // ScriptableObject, Resources asset, or directly in initialization code
30
+ uploadToHosting: false,
31
+ getEnvVars: () => ({}),
32
+ },
33
+ analytics: {
34
+ getTags: (context) => ({
35
+ pluginAlreadyPresent: context.pluginAlreadyPresent ? 'true' : 'false',
36
+ }),
37
+ },
38
+ prompts: {
39
+ projectTypeDetection: 'This is a Unity project. Look for ProjectSettings/ProjectVersion.txt to confirm.',
40
+ packageInstallation: 'Install via Unity Package Manager by editing Packages/manifest.json: add "com.amplitude.unity-plugin": "https://github.com/amplitude/unity-plugin.git?path=/Assets" to the dependencies object. Do not use npm or any other package manager.',
41
+ getAdditionalContextLines: (context) => {
42
+ const lines = [
43
+ `Framework docs ID: unity (use amplitude://docs/frameworks/unity for documentation)`,
44
+ `SDK: amplitude/unity-plugin — install via UPM git URL in Packages/manifest.json`,
45
+ `Initialization (C#):`,
46
+ ` Amplitude amplitude = Amplitude.getInstance();`,
47
+ ` amplitude.setServerUrl("https://api2.amplitude.com");`,
48
+ ` amplitude.trackSessionEvents(true);`,
49
+ ` amplitude.init("YOUR_API_KEY");`,
50
+ `Event tracking: amplitude.logEvent("Button Clicked", new Dictionary<string, object> {{ "key", "value" }});`,
51
+ `EU data residency (SDK 2.4.0+): amplitude.setServerZone(AmplitudeServerZone.EU);`,
52
+ `Store the API key in a Unity ScriptableObject or Resources asset — never hardcode it in a file committed to source control`,
53
+ `NOT supported: WebGL, Unity Editor-only builds`,
54
+ ];
55
+ if (context.pluginAlreadyPresent) {
56
+ lines.unshift('Amplitude plugin is already present — skip installation, proceed to initialization.');
57
+ }
58
+ return lines;
59
+ },
60
+ },
61
+ ui: {
62
+ successMessage: 'Amplitude integration complete',
63
+ estimatedDurationMinutes: 8,
64
+ getOutroChanges: (context) => [
65
+ context.pluginAlreadyPresent
66
+ ? 'Amplitude plugin was already present — skipped installation'
67
+ : 'Added amplitude/unity-plugin to Packages/manifest.json via UPM',
68
+ 'Configured Amplitude initialization in a C# script',
69
+ 'Added event tracking calls',
70
+ ],
71
+ getOutroNextSteps: () => [
72
+ 'Open the Unity Editor — it will automatically resolve and download the package',
73
+ 'Attach the Amplitude initialization script to a persistent GameObject (e.g. GameManager)',
74
+ 'Visit your Amplitude dashboard to see incoming events',
75
+ 'Use amplitude.logEvent("Event Name") for custom events',
76
+ 'Note: WebGL builds are not supported',
77
+ ],
78
+ },
79
+ };
@@ -0,0 +1,12 @@
1
+ import type { WizardOptions } from '../../utils/types';
2
+ /**
3
+ * Returns true when the directory contains a Unity project.
4
+ * Primary signal: ProjectSettings/ProjectVersion.txt — Unity-specific,
5
+ * present in every Unity project since 2017+.
6
+ */
7
+ export declare function detectUnityProject(options: Pick<WizardOptions, 'installDir'>): Promise<boolean>;
8
+ /**
9
+ * Returns true if the Amplitude Unity plugin is already present,
10
+ * either via UPM (Packages/manifest.json) or manual import (Assets/).
11
+ */
12
+ export declare function isAmplitudePluginPresent(options: Pick<WizardOptions, 'installDir'>): boolean;