@claudetools/cli 0.13.13 → 0.13.15

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 (368) hide show
  1. package/dist/__tests__/factories.d.ts +173 -0
  2. package/dist/__tests__/factories.d.ts.map +1 -0
  3. package/dist/__tests__/factories.js +150 -0
  4. package/dist/__tests__/factories.js.map +1 -0
  5. package/dist/__tests__/helpers.d.ts +36 -0
  6. package/dist/__tests__/helpers.d.ts.map +1 -0
  7. package/dist/__tests__/helpers.js +52 -0
  8. package/dist/__tests__/helpers.js.map +1 -0
  9. package/dist/analytics/index.d.ts +14 -0
  10. package/dist/analytics/index.d.ts.map +1 -0
  11. package/dist/analytics/index.js +259 -0
  12. package/dist/analytics/index.js.map +1 -0
  13. package/dist/analytics/session.d.ts +17 -0
  14. package/dist/analytics/session.d.ts.map +1 -0
  15. package/dist/analytics/session.js +130 -0
  16. package/dist/analytics/session.js.map +1 -0
  17. package/dist/analytics/token-tracker.d.ts +48 -0
  18. package/dist/analytics/token-tracker.d.ts.map +1 -0
  19. package/dist/analytics/token-tracker.js +269 -0
  20. package/dist/analytics/token-tracker.js.map +1 -0
  21. package/dist/analytics/tracker.d.ts +33 -0
  22. package/dist/analytics/tracker.d.ts.map +1 -0
  23. package/dist/analytics/tracker.js +210 -0
  24. package/dist/analytics/tracker.js.map +1 -0
  25. package/dist/api-keys/index.d.ts +15 -0
  26. package/dist/api-keys/index.d.ts.map +1 -0
  27. package/dist/api-keys/index.js +228 -0
  28. package/dist/api-keys/index.js.map +1 -0
  29. package/dist/auth/config.d.ts +15 -0
  30. package/dist/auth/config.d.ts.map +1 -0
  31. package/dist/auth/config.js +67 -0
  32. package/dist/auth/config.js.map +1 -0
  33. package/dist/auth/index.d.ts +8 -0
  34. package/dist/auth/index.d.ts.map +1 -0
  35. package/dist/auth/index.js +299 -0
  36. package/dist/auth/index.js.map +1 -0
  37. package/dist/auth/keychain.d.ts +21 -0
  38. package/dist/auth/keychain.d.ts.map +1 -0
  39. package/dist/auth/keychain.js +256 -0
  40. package/dist/auth/keychain.js.map +1 -0
  41. package/dist/billing/index.d.ts +7 -0
  42. package/dist/billing/index.d.ts.map +1 -0
  43. package/dist/billing/index.js +233 -0
  44. package/dist/billing/index.js.map +1 -0
  45. package/dist/cli.js +291 -43
  46. package/dist/cli.js.map +1 -1
  47. package/dist/commands/hook.d.ts +12 -0
  48. package/dist/commands/hook.d.ts.map +1 -0
  49. package/dist/commands/hook.js +190 -0
  50. package/dist/commands/hook.js.map +1 -0
  51. package/dist/commands/keys.d.ts +4 -0
  52. package/dist/commands/keys.d.ts.map +1 -0
  53. package/dist/commands/keys.js +43 -0
  54. package/dist/commands/keys.js.map +1 -0
  55. package/dist/commands/mcp.d.ts +4 -0
  56. package/dist/commands/mcp.d.ts.map +1 -0
  57. package/dist/commands/mcp.js +43 -0
  58. package/dist/commands/mcp.js.map +1 -0
  59. package/dist/commands/project.d.ts +4 -0
  60. package/dist/commands/project.d.ts.map +1 -0
  61. package/dist/commands/project.js +68 -0
  62. package/dist/commands/project.js.map +1 -0
  63. package/dist/commands/skill.d.ts +4 -0
  64. package/dist/commands/skill.d.ts.map +1 -0
  65. package/dist/commands/skill.js +37 -0
  66. package/dist/commands/skill.js.map +1 -0
  67. package/dist/commands/stacks.d.ts +4 -0
  68. package/dist/commands/stacks.d.ts.map +1 -0
  69. package/dist/commands/stacks.js +103 -0
  70. package/dist/commands/stacks.js.map +1 -0
  71. package/dist/commands/stats.d.ts +4 -0
  72. package/dist/commands/stats.d.ts.map +1 -0
  73. package/dist/commands/stats.js +6 -0
  74. package/dist/commands/stats.js.map +1 -0
  75. package/dist/commands/sync.d.ts +4 -0
  76. package/dist/commands/sync.d.ts.map +1 -0
  77. package/dist/commands/sync.js +60 -0
  78. package/dist/commands/sync.js.map +1 -0
  79. package/dist/commands/update.d.ts +4 -0
  80. package/dist/commands/update.d.ts.map +1 -0
  81. package/dist/commands/update.js +63 -0
  82. package/dist/commands/update.js.map +1 -0
  83. package/dist/daemon/client.d.ts +107 -0
  84. package/dist/daemon/client.d.ts.map +1 -0
  85. package/dist/daemon/client.js +250 -0
  86. package/dist/daemon/client.js.map +1 -0
  87. package/dist/daemon/health.d.ts +38 -0
  88. package/dist/daemon/health.d.ts.map +1 -0
  89. package/dist/daemon/health.js +212 -0
  90. package/dist/daemon/health.js.map +1 -0
  91. package/dist/daemon/index.d.ts +34 -0
  92. package/dist/daemon/index.d.ts.map +1 -0
  93. package/dist/daemon/index.js +197 -0
  94. package/dist/daemon/index.js.map +1 -0
  95. package/dist/daemon/protocol.d.ts +144 -0
  96. package/dist/daemon/protocol.d.ts.map +1 -0
  97. package/dist/daemon/protocol.js +5 -0
  98. package/dist/daemon/protocol.js.map +1 -0
  99. package/dist/gamification/index.d.ts +13 -0
  100. package/dist/gamification/index.d.ts.map +1 -0
  101. package/dist/gamification/index.js +120 -0
  102. package/dist/gamification/index.js.map +1 -0
  103. package/dist/gamification/types.d.ts +34 -0
  104. package/dist/gamification/types.d.ts.map +1 -0
  105. package/dist/gamification/types.js +5 -0
  106. package/dist/gamification/types.js.map +1 -0
  107. package/dist/hooks/index.d.ts +65 -0
  108. package/dist/hooks/index.d.ts.map +1 -0
  109. package/dist/hooks/index.js +403 -0
  110. package/dist/hooks/index.js.map +1 -0
  111. package/dist/lib/api.d.ts +29 -0
  112. package/dist/lib/api.d.ts.map +1 -0
  113. package/dist/lib/api.js +213 -0
  114. package/dist/lib/api.js.map +1 -0
  115. package/dist/lib/browser.d.ts +6 -0
  116. package/dist/lib/browser.d.ts.map +1 -0
  117. package/dist/lib/browser.js +14 -0
  118. package/dist/lib/browser.js.map +1 -0
  119. package/dist/lib/channel-config.d.ts +10 -0
  120. package/dist/lib/channel-config.d.ts.map +1 -0
  121. package/dist/lib/channel-config.js +48 -0
  122. package/dist/lib/channel-config.js.map +1 -0
  123. package/dist/lib/command-runner.d.ts +16 -0
  124. package/dist/lib/command-runner.d.ts.map +1 -0
  125. package/dist/lib/command-runner.js +59 -0
  126. package/dist/lib/command-runner.js.map +1 -0
  127. package/dist/lib/command-utils.d.ts +22 -0
  128. package/dist/lib/command-utils.d.ts.map +1 -0
  129. package/dist/lib/command-utils.js +88 -0
  130. package/dist/lib/command-utils.js.map +1 -0
  131. package/dist/lib/error-handler.d.ts +13 -0
  132. package/dist/lib/error-handler.d.ts.map +1 -0
  133. package/dist/lib/error-handler.js +70 -0
  134. package/dist/lib/error-handler.js.map +1 -0
  135. package/dist/lib/errors.d.ts +35 -0
  136. package/dist/lib/errors.d.ts.map +1 -0
  137. package/dist/lib/errors.js +70 -0
  138. package/dist/lib/errors.js.map +1 -0
  139. package/dist/lib/exit.d.ts +10 -0
  140. package/dist/lib/exit.d.ts.map +1 -0
  141. package/dist/lib/exit.js +21 -0
  142. package/dist/lib/exit.js.map +1 -0
  143. package/dist/lib/formatters.d.ts +65 -0
  144. package/dist/lib/formatters.d.ts.map +1 -0
  145. package/dist/lib/formatters.js +180 -0
  146. package/dist/lib/formatters.js.map +1 -0
  147. package/dist/lib/hybrid-data.d.ts +47 -0
  148. package/dist/lib/hybrid-data.d.ts.map +1 -0
  149. package/dist/lib/hybrid-data.js +326 -0
  150. package/dist/lib/hybrid-data.js.map +1 -0
  151. package/dist/lib/local-store.d.ts +113 -0
  152. package/dist/lib/local-store.d.ts.map +1 -0
  153. package/dist/lib/local-store.js +220 -0
  154. package/dist/lib/local-store.js.map +1 -0
  155. package/dist/lib/machine-id.d.ts +8 -0
  156. package/dist/lib/machine-id.d.ts.map +1 -0
  157. package/dist/lib/machine-id.js +39 -0
  158. package/dist/lib/machine-id.js.map +1 -0
  159. package/dist/lib/network.d.ts +15 -0
  160. package/dist/lib/network.d.ts.map +1 -0
  161. package/dist/lib/network.js +46 -0
  162. package/dist/lib/network.js.map +1 -0
  163. package/dist/lib/theme.d.ts +77 -0
  164. package/dist/lib/theme.d.ts.map +1 -0
  165. package/dist/lib/theme.js +137 -0
  166. package/dist/lib/theme.js.map +1 -0
  167. package/dist/lib/tool-availability.d.ts +13 -0
  168. package/dist/lib/tool-availability.d.ts.map +1 -0
  169. package/dist/lib/tool-availability.js +48 -0
  170. package/dist/lib/tool-availability.js.map +1 -0
  171. package/dist/lib/update-checker.d.ts +21 -0
  172. package/dist/lib/update-checker.d.ts.map +1 -0
  173. package/dist/lib/update-checker.js +110 -0
  174. package/dist/lib/update-checker.js.map +1 -0
  175. package/dist/lib/validation.d.ts +30 -0
  176. package/dist/lib/validation.d.ts.map +1 -0
  177. package/dist/lib/validation.js +82 -0
  178. package/dist/lib/validation.js.map +1 -0
  179. package/dist/lib/validators.d.ts +18 -0
  180. package/dist/lib/validators.d.ts.map +1 -0
  181. package/dist/lib/validators.js +30 -0
  182. package/dist/lib/validators.js.map +1 -0
  183. package/dist/marketplace/api.d.ts +24 -0
  184. package/dist/marketplace/api.d.ts.map +1 -0
  185. package/dist/marketplace/api.js +92 -0
  186. package/dist/marketplace/api.js.map +1 -0
  187. package/dist/marketplace/index.d.ts +13 -0
  188. package/dist/marketplace/index.d.ts.map +1 -0
  189. package/dist/marketplace/index.js +155 -0
  190. package/dist/marketplace/index.js.map +1 -0
  191. package/dist/marketplace/installer.d.ts +18 -0
  192. package/dist/marketplace/installer.d.ts.map +1 -0
  193. package/dist/marketplace/installer.js +184 -0
  194. package/dist/marketplace/installer.js.map +1 -0
  195. package/dist/mcp/api.d.ts +93 -0
  196. package/dist/mcp/api.d.ts.map +1 -0
  197. package/dist/mcp/api.js +106 -0
  198. package/dist/mcp/api.js.map +1 -0
  199. package/dist/mcp/config.d.ts +72 -0
  200. package/dist/mcp/config.d.ts.map +1 -0
  201. package/dist/mcp/config.js +156 -0
  202. package/dist/mcp/config.js.map +1 -0
  203. package/dist/mcp/index.d.ts +54 -0
  204. package/dist/mcp/index.d.ts.map +1 -0
  205. package/dist/mcp/index.js +381 -0
  206. package/dist/mcp/index.js.map +1 -0
  207. package/dist/mcp/prompt.clean.d.ts +25 -0
  208. package/dist/mcp/prompt.clean.d.ts.map +1 -0
  209. package/dist/mcp/prompt.clean.js +206 -0
  210. package/dist/mcp/prompt.clean.js.map +1 -0
  211. package/dist/mcp/prompt.d.ts +52 -0
  212. package/dist/mcp/prompt.d.ts.map +1 -0
  213. package/dist/mcp/prompt.js +210 -0
  214. package/dist/mcp/prompt.js.map +1 -0
  215. package/dist/mcp/secrets.clean.d.ts +18 -0
  216. package/dist/mcp/secrets.clean.d.ts.map +1 -0
  217. package/dist/mcp/secrets.clean.js +357 -0
  218. package/dist/mcp/secrets.clean.js.map +1 -0
  219. package/dist/mcp/secrets.d.ts +46 -0
  220. package/dist/mcp/secrets.d.ts.map +1 -0
  221. package/dist/mcp/secrets.js +339 -0
  222. package/dist/mcp/secrets.js.map +1 -0
  223. package/dist/memory/index.d.ts +14 -0
  224. package/dist/memory/index.d.ts.map +1 -0
  225. package/dist/memory/index.js +98 -0
  226. package/dist/memory/index.js.map +1 -0
  227. package/dist/onboard/agents-md-builder.d.ts.map +1 -1
  228. package/dist/onboard/agents-md-builder.js +45 -0
  229. package/dist/onboard/agents-md-builder.js.map +1 -1
  230. package/dist/onboard/claude-inference.d.ts.map +1 -1
  231. package/dist/onboard/claude-inference.js +15 -4
  232. package/dist/onboard/claude-inference.js.map +1 -1
  233. package/dist/onboard/context7-fetcher.d.ts +1 -1
  234. package/dist/onboard/context7-fetcher.d.ts.map +1 -1
  235. package/dist/onboard/context7-fetcher.js +50 -16
  236. package/dist/onboard/context7-fetcher.js.map +1 -1
  237. package/dist/onboard/docs-builder.d.ts.map +1 -1
  238. package/dist/onboard/docs-builder.js +523 -50
  239. package/dist/onboard/docs-builder.js.map +1 -1
  240. package/dist/onboard/index.d.ts.map +1 -1
  241. package/dist/onboard/index.js +74 -25
  242. package/dist/onboard/index.js.map +1 -1
  243. package/dist/onboard/stack-detector.d.ts.map +1 -1
  244. package/dist/onboard/stack-detector.js +5 -55
  245. package/dist/onboard/stack-detector.js.map +1 -1
  246. package/dist/project/constants.d.ts +21 -0
  247. package/dist/project/constants.d.ts.map +1 -0
  248. package/dist/project/constants.js +21 -0
  249. package/dist/project/constants.js.map +1 -0
  250. package/dist/project/format.d.ts +16 -0
  251. package/dist/project/format.d.ts.map +1 -0
  252. package/dist/project/format.js +40 -0
  253. package/dist/project/format.js.map +1 -0
  254. package/dist/project/git.d.ts +28 -0
  255. package/dist/project/git.d.ts.map +1 -0
  256. package/dist/project/git.js +93 -0
  257. package/dist/project/git.js.map +1 -0
  258. package/dist/project/index.d.ts +36 -0
  259. package/dist/project/index.d.ts.map +1 -0
  260. package/dist/project/index.js +272 -0
  261. package/dist/project/index.js.map +1 -0
  262. package/dist/project/mapper.d.ts +27 -0
  263. package/dist/project/mapper.d.ts.map +1 -0
  264. package/dist/project/mapper.js +64 -0
  265. package/dist/project/mapper.js.map +1 -0
  266. package/dist/project/storage.d.ts +71 -0
  267. package/dist/project/storage.d.ts.map +1 -0
  268. package/dist/project/storage.js +274 -0
  269. package/dist/project/storage.js.map +1 -0
  270. package/dist/project/sync-bridge.d.ts +33 -0
  271. package/dist/project/sync-bridge.d.ts.map +1 -0
  272. package/dist/project/sync-bridge.js +155 -0
  273. package/dist/project/sync-bridge.js.map +1 -0
  274. package/dist/project/types.d.ts +107 -0
  275. package/dist/project/types.d.ts.map +1 -0
  276. package/dist/project/types.js +77 -0
  277. package/dist/project/types.js.map +1 -0
  278. package/dist/publish/index.d.ts +4 -0
  279. package/dist/publish/index.d.ts.map +1 -0
  280. package/dist/publish/index.js +92 -0
  281. package/dist/publish/index.js.map +1 -0
  282. package/dist/setup.d.ts.map +1 -1
  283. package/dist/setup.js +29 -10
  284. package/dist/setup.js.map +1 -1
  285. package/dist/skills/index.d.ts +51 -0
  286. package/dist/skills/index.d.ts.map +1 -0
  287. package/dist/skills/index.js +509 -0
  288. package/dist/skills/index.js.map +1 -0
  289. package/dist/stacks/check.d.ts +2 -0
  290. package/dist/stacks/check.d.ts.map +1 -0
  291. package/dist/stacks/check.js +144 -0
  292. package/dist/stacks/check.js.map +1 -0
  293. package/dist/stacks/diff.d.ts +11 -0
  294. package/dist/stacks/diff.d.ts.map +1 -0
  295. package/dist/stacks/diff.js +123 -0
  296. package/dist/stacks/diff.js.map +1 -0
  297. package/dist/stacks/index.d.ts +17 -0
  298. package/dist/stacks/index.d.ts.map +1 -0
  299. package/dist/stacks/index.js +525 -0
  300. package/dist/stacks/index.js.map +1 -0
  301. package/dist/stacks/index.refactored.d.ts.map +1 -0
  302. package/dist/stacks/index.refactored.js.map +1 -0
  303. package/dist/stacks/io.d.ts +11 -0
  304. package/dist/stacks/io.d.ts.map +1 -0
  305. package/dist/stacks/io.js +179 -0
  306. package/dist/stacks/io.js.map +1 -0
  307. package/dist/stacks/rollback.d.ts +5 -0
  308. package/dist/stacks/rollback.d.ts.map +1 -0
  309. package/dist/stacks/rollback.js +162 -0
  310. package/dist/stacks/rollback.js.map +1 -0
  311. package/dist/stacks/types.d.ts +70 -0
  312. package/dist/stacks/types.d.ts.map +1 -0
  313. package/dist/stacks/types.js +6 -0
  314. package/dist/stacks/types.js.map +1 -0
  315. package/dist/stacks/utils.d.ts +9 -0
  316. package/dist/stacks/utils.d.ts.map +1 -0
  317. package/dist/stacks/utils.js +11 -0
  318. package/dist/stacks/utils.js.map +1 -0
  319. package/dist/start/index.d.ts +23 -0
  320. package/dist/start/index.d.ts.map +1 -0
  321. package/dist/start/index.js +386 -0
  322. package/dist/start/index.js.map +1 -0
  323. package/dist/sync/index.d.ts +49 -0
  324. package/dist/sync/index.d.ts.map +1 -0
  325. package/dist/sync/index.js +207 -0
  326. package/dist/sync/index.js.map +1 -0
  327. package/dist/sync-engine/__tests__/test-helpers.d.ts +14 -0
  328. package/dist/sync-engine/__tests__/test-helpers.d.ts.map +1 -0
  329. package/dist/sync-engine/__tests__/test-helpers.js +73 -0
  330. package/dist/sync-engine/__tests__/test-helpers.js.map +1 -0
  331. package/dist/sync-engine/client.d.ts +128 -0
  332. package/dist/sync-engine/client.d.ts.map +1 -0
  333. package/dist/sync-engine/client.js +289 -0
  334. package/dist/sync-engine/client.js.map +1 -0
  335. package/dist/sync-engine/health.d.ts +38 -0
  336. package/dist/sync-engine/health.d.ts.map +1 -0
  337. package/dist/sync-engine/health.js +259 -0
  338. package/dist/sync-engine/health.js.map +1 -0
  339. package/dist/sync-engine/index.d.ts +34 -0
  340. package/dist/sync-engine/index.d.ts.map +1 -0
  341. package/dist/sync-engine/index.js +197 -0
  342. package/dist/sync-engine/index.js.map +1 -0
  343. package/dist/sync-engine/protocol.d.ts +153 -0
  344. package/dist/sync-engine/protocol.d.ts.map +1 -0
  345. package/dist/sync-engine/protocol.js +5 -0
  346. package/dist/sync-engine/protocol.js.map +1 -0
  347. package/dist/tasks/index.d.ts +14 -0
  348. package/dist/tasks/index.d.ts.map +1 -0
  349. package/dist/tasks/index.js +109 -0
  350. package/dist/tasks/index.js.map +1 -0
  351. package/dist/team/index.d.ts +12 -0
  352. package/dist/team/index.d.ts.map +1 -0
  353. package/dist/team/index.js +151 -0
  354. package/dist/team/index.js.map +1 -0
  355. package/dist/updater.d.ts +5 -5
  356. package/dist/updater.d.ts.map +1 -1
  357. package/dist/updater.js +24 -88
  358. package/dist/updater.js.map +1 -1
  359. package/dist/usage/index.d.ts +10 -0
  360. package/dist/usage/index.d.ts.map +1 -0
  361. package/dist/usage/index.js +104 -0
  362. package/dist/usage/index.js.map +1 -0
  363. package/dist/webhooks/index.d.ts +7 -0
  364. package/dist/webhooks/index.d.ts.map +1 -0
  365. package/dist/webhooks/index.js +81 -0
  366. package/dist/webhooks/index.js.map +1 -0
  367. package/package.json +26 -15
  368. package/scripts/postinstall.js +282 -0
@@ -82,8 +82,8 @@ async function fetchAllLibraryDocs(stack, onProgress) {
82
82
  }
83
83
  const total = toFetch.length;
84
84
  onProgress?.(`Fetching documentation for ${total} libraries...`, 0, total);
85
- // Fetch in parallel batches of 2 (to avoid rate limiting)
86
- const batchSize = 2;
85
+ // Fetch in parallel batches of 5 (increased for better performance)
86
+ const batchSize = 5;
87
87
  for (let i = 0; i < toFetch.length; i += batchSize) {
88
88
  const batch = toFetch.slice(i, i + batchSize);
89
89
  const batchResults = await Promise.all(batch.map(async (item, batchIndex) => {
@@ -170,29 +170,60 @@ function generateLibrariesIndex(stack, libraryDocs) {
170
170
  // =============================================================================
171
171
  // Claude Inference for Doc Generation
172
172
  // =============================================================================
173
- async function runClaudeForDocs(prompt, projectPath, timeout = 90000) {
173
+ async function runClaudeForDocs(prompt, projectPath, timeout = 60000 // Reduced from 90s
174
+ ) {
174
175
  return new Promise((resolve) => {
175
- const proc = spawn('claude', ['--print', '--dangerously-skip-permissions', prompt], {
176
+ const proc = spawn('claude', [
177
+ '--print',
178
+ '--dangerously-skip-permissions',
179
+ '--model', 'opus',
180
+ '--allowedTools', 'Read,Glob,Grep,WebFetch,WebSearch',
181
+ '-' // Read prompt from stdin
182
+ ], {
176
183
  cwd: projectPath,
177
184
  stdio: ['pipe', 'pipe', 'pipe'],
178
- timeout,
179
185
  });
180
186
  let stdout = '';
187
+ let stderr = '';
188
+ let timedOut = false;
181
189
  const timer = setTimeout(() => {
190
+ timedOut = true;
182
191
  proc.kill();
192
+ if (process.env.CLAUDETOOLS_DEBUG) {
193
+ console.error(`Claude doc gen timed out after ${timeout}ms`);
194
+ }
183
195
  resolve(null);
184
196
  }, timeout);
185
197
  proc.stdout?.on('data', (data) => {
186
198
  stdout += data.toString();
187
199
  });
200
+ proc.stderr?.on('data', (data) => {
201
+ stderr += data.toString();
202
+ });
188
203
  proc.on('close', (code) => {
189
204
  clearTimeout(timer);
190
- resolve(code === 0 ? stdout.trim() : null);
205
+ if (timedOut)
206
+ return; // Already resolved
207
+ if (code === 0 && stdout.trim()) {
208
+ resolve(stdout.trim());
209
+ }
210
+ else {
211
+ // Always log failures to help diagnose issues
212
+ if (process.env.CLAUDETOOLS_DEBUG) {
213
+ console.error(`Claude doc gen failed (code ${code}):`, stderr.slice(0, 500));
214
+ }
215
+ resolve(null);
216
+ }
191
217
  });
192
- proc.on('error', () => {
218
+ proc.on('error', (err) => {
193
219
  clearTimeout(timer);
220
+ // Always log spawn errors - these indicate a real problem
221
+ console.error('Claude spawn error:', err.message);
194
222
  resolve(null);
195
223
  });
224
+ // Write prompt to stdin and close
225
+ proc.stdin?.write(prompt);
226
+ proc.stdin?.end();
196
227
  });
197
228
  }
198
229
  // =============================================================================
@@ -653,24 +684,36 @@ function generateCodingStandards(answers, stack) {
653
684
 
654
685
  ## Overview
655
686
 
656
- This document defines the coding standards for this project.
687
+ This document defines the coding standards for this project. These are non-negotiable.
657
688
 
658
689
  ${answers.projectDescription ? `**Project:** ${answers.projectDescription}\n` : ''}
659
690
 
660
- ## Language
661
-
662
- **Primary Language:** ${stack.primaryLanguage}
691
+ ## Core Principles
663
692
 
664
- ## General Principles
693
+ 1. **Minimal Code** - Write the least code necessary. Every line must earn its place.
694
+ 2. **No Duplication** - DRY principle. If you write something twice, extract it.
695
+ 3. **Composable** - Build small, focused pieces that combine well.
696
+ 4. **Maintainable** - Code should be obvious to future readers.
697
+ 5. **No AI Slop** - No verbose comments explaining obvious code. No boilerplate.
665
698
 
666
- 1. **Readability** - Code should be self-documenting
667
- 2. **Simplicity** - Prefer simple solutions
668
- 3. **Consistency** - Follow established patterns
669
- 4. **Testability** - Write testable code
699
+ ## Language
670
700
 
671
- ## Conventions
701
+ **Primary Language:** ${stack.primaryLanguage}
672
702
 
673
- - Follow standard conventions for ${stack.primaryLanguage}
703
+ ## Anti-Patterns to AVOID
704
+
705
+ | Anti-Pattern | Why It's Bad | Do This Instead |
706
+ |--------------|--------------|------------------|
707
+ | God components | Unmaintainable, untestable | Split into focused components |
708
+ | Prop drilling | Brittle, verbose | Use context or composition |
709
+ | Copy-paste code | Bugs multiply, hard to update | Extract shared utilities |
710
+ | Premature abstraction | Adds complexity before needed | Abstract on the third use |
711
+ | Magic numbers/strings | Unclear intent | Use named constants |
712
+ | Deep nesting | Hard to follow | Early returns, extract functions |
713
+ | Barrel files (index.ts exports) | Breaks tree-shaking, slow builds | Import directly from source |
714
+ | Over-engineering | Wastes time, adds bugs | Build for current needs |
715
+ | Comments explaining "what" | Redundant, goes stale | Code should be self-documenting |
716
+ | Unused code | Confuses readers, bloats bundle | Delete it |
674
717
 
675
718
  ## TypeScript Guidelines
676
719
 
@@ -680,18 +723,51 @@ ${stack.primaryLanguage === 'typescript' ? `
680
723
  - Prefer interfaces for object shapes
681
724
  - Use type guards for narrowing
682
725
  - Export types alongside implementations
726
+ - No type assertions unless absolutely necessary
683
727
  ` : 'See language-specific guidelines.'}
684
728
 
685
729
  ## Component Guidelines
686
730
 
687
731
  ${stack.frameworks.some(f => f.name.toLowerCase().includes('react')) ? `
688
- - Use functional components
689
- - Keep components small and focused
732
+ ### Structure
733
+ - Single responsibility - one component, one job
734
+ - Max 150-200 lines; split if larger
735
+ - Collocate related code (styles, tests, types with component)
736
+
737
+ ### Props
738
+ - Minimal and obvious props interface
739
+ - Use destructuring in function signature
740
+ - Default values in destructuring, not defaultProps
741
+
742
+ ### Logic
690
743
  - Extract reusable logic to custom hooks
744
+ - Keep render logic simple
691
745
  - Use composition over inheritance
692
- - Prop types should be explicit
746
+ - Prefer controlled components
747
+
748
+ ### State
749
+ - Derive what you can, don't duplicate state
750
+ - Keep state as local as possible
751
+ - Single source of truth for each piece of data
693
752
  ` : ''}
694
753
 
754
+ ## Function Guidelines
755
+
756
+ - Pure functions where possible (same input = same output)
757
+ - Max 20-30 lines; extract if longer
758
+ - Descriptive names that describe what it returns/does
759
+ - Early returns over nested conditionals
760
+ - One level of abstraction per function
761
+ - No side effects in functions unless that's their explicit purpose
762
+
763
+ ## Performance
764
+
765
+ - Measure before optimizing
766
+ - Avoid premature optimization
767
+ - Use lazy loading for routes and heavy components
768
+ - Memoize expensive computations, not everything
769
+ - Don't memoize unless you've measured a problem
770
+
695
771
  ## File Organization
696
772
 
697
773
  \`\`\`
@@ -703,6 +779,18 @@ src/
703
779
  ├── types/ # Type definitions
704
780
  └── utils/ # Helper functions
705
781
  \`\`\`
782
+
783
+ ## Code Review Checklist
784
+
785
+ Before submitting code, verify:
786
+
787
+ - [ ] No duplication - is this logic already elsewhere?
788
+ - [ ] No dead code - is everything used?
789
+ - [ ] No magic values - are constants named?
790
+ - [ ] Clear naming - can someone understand without context?
791
+ - [ ] Minimal - can any code be removed?
792
+ - [ ] Tested - are edge cases covered?
793
+ - [ ] No AI slop - no unnecessary comments or boilerplate?
706
794
  `;
707
795
  }
708
796
  function generateTestingStrategy(_answers, stack) {
@@ -901,6 +989,22 @@ export async function buildDocs(projectPath, projectName, stack, answers, option
901
989
  mkdirSync(dir, { recursive: true });
902
990
  }
903
991
  }
992
+ // ==========================================================================
993
+ // STEP 1: Fetch Context7 docs FIRST - use to inform all doc generation
994
+ // ==========================================================================
995
+ let libraryDocs = [];
996
+ let context7Summary = '';
997
+ if (stack.frameworks.length > 0 || stack.libraries.length > 0) {
998
+ progress('Fetching library documentation from Context7...');
999
+ libraryDocs = await fetchAllLibraryDocs(stack, progress);
1000
+ // Build a summary of what we learned from Context7 for use in prompts
1001
+ const successfulDocs = libraryDocs.filter(d => d.success);
1002
+ if (successfulDocs.length > 0) {
1003
+ context7Summary = successfulDocs
1004
+ .map(d => `### ${d.name}\n${d.content.slice(0, 500)}...`)
1005
+ .join('\n\n');
1006
+ }
1007
+ }
904
1008
  // Generate base documents with templates
905
1009
  const docs = {
906
1010
  'index.md': generateDocsIndex(projectName, stack, answers),
@@ -916,8 +1020,15 @@ export async function buildDocs(projectPath, projectName, stack, answers, option
916
1020
  'decisions/index.md': generateAdrIndex(),
917
1021
  'decisions/template.md': generateAdrTemplate(),
918
1022
  };
919
- // Claude-generated documents - analyze codebase and generate actual content
920
- if (useClaude) {
1023
+ // ==========================================================================
1024
+ // STEP 2: Claude-generated documents - analyze codebase with Context7 context
1025
+ // ==========================================================================
1026
+ // Skip AI analysis for empty/new projects - no code to analyse
1027
+ if (useClaude && !stack.isEmpty) {
1028
+ // Build context preamble from Context7 docs
1029
+ const contextPreamble = context7Summary
1030
+ ? `\n\n<library-context>\nThe following library documentation was fetched from Context7. Use this to inform your analysis:\n\n${context7Summary}\n</library-context>\n\n`
1031
+ : '';
921
1032
  const claudePrompts = {
922
1033
  'architecture/system-design.md': `Analyze this codebase and write a System Design document. Include:
923
1034
  - Overall architecture overview
@@ -1051,7 +1162,7 @@ Document actual setup or common patterns for the stack.`,
1051
1162
  };
1052
1163
  // Generate Claude-powered docs in parallel batches
1053
1164
  const claudeDocPaths = Object.keys(claudePrompts);
1054
- const batchSize = 3; // Run 3 at a time to avoid overwhelming
1165
+ const batchSize = 7; // Run 7 at a time for better performance
1055
1166
  const totalClaudeDocs = claudeDocPaths.length;
1056
1167
  let completedDocs = 0;
1057
1168
  const progress = options.onProgress || (() => { });
@@ -1062,7 +1173,9 @@ Document actual setup or common patterns for the stack.`,
1062
1173
  const docNames = batch.map(p => p.split('/').pop()?.replace('.md', '')).join(', ');
1063
1174
  progress(`Analyzing: ${docNames}`, completedDocs, totalClaudeDocs);
1064
1175
  const results = await Promise.all(batch.map(async (docPath) => {
1065
- const prompt = claudePrompts[docPath];
1176
+ // Add Context7 context to each prompt for better docs
1177
+ const basePrompt = claudePrompts[docPath];
1178
+ const prompt = contextPreamble + basePrompt;
1066
1179
  const content = await runClaudeForDocs(prompt, projectPath);
1067
1180
  return { docPath, content };
1068
1181
  }));
@@ -1075,7 +1188,7 @@ Document actual setup or common patterns for the stack.`,
1075
1188
  }
1076
1189
  else {
1077
1190
  // Fallback to template if Claude fails
1078
- docs[docPath] = docs[docPath] || getFallbackTemplate(docPath);
1191
+ docs[docPath] = docs[docPath] || getFallbackTemplate(docPath, stack, answers);
1079
1192
  progress(`Fallback: ${docName}`, completedDocs, totalClaudeDocs);
1080
1193
  }
1081
1194
  }
@@ -1083,48 +1196,47 @@ Document actual setup or common patterns for the stack.`,
1083
1196
  progress(`Completed ${totalClaudeDocs} documents`, totalClaudeDocs, totalClaudeDocs);
1084
1197
  }
1085
1198
  else {
1086
- // No Claude - use template fallbacks
1199
+ // No Claude or empty project - use template fallbacks with stack context
1200
+ if (stack.isEmpty) {
1201
+ progress('New project detected - using template docs (no code to analyse)');
1202
+ }
1203
+ else if (!useClaude) {
1204
+ progress('Claude CLI not available - using template docs');
1205
+ }
1087
1206
  docs['architecture/system-design.md'] = generateSystemDesign(answers, stack);
1088
1207
  docs['architecture/data-flow.md'] = generateDataFlow(answers);
1089
1208
  docs['architecture/components.md'] = generateComponentArchitecture(stack);
1090
1209
  docs['api/index.md'] = generateApiIndex(stack);
1091
1210
  docs['api/endpoints.md'] = generateEndpoints();
1092
1211
  docs['api/schemas.md'] = generateSchemas(stack);
1093
- docs['api/authentication.md'] = '# Authentication\n\nAuthentication documentation to be added.\n';
1094
- docs['guides/contributing.md'] = '# Contributing\n\nContributing guide to be added.\n';
1095
- docs['reference/configuration.md'] = '# Configuration\n\nConfiguration documentation to be added.\n';
1096
- docs['reference/environment.md'] = '# Environment Variables\n\nEnvironment variable documentation to be added.\n';
1097
- docs['reference/dependencies.md'] = '# Dependencies\n\nDependency documentation to be added.\n';
1212
+ docs['api/authentication.md'] = getFallbackTemplate('api/authentication.md', stack, answers);
1213
+ docs['guides/contributing.md'] = getFallbackTemplate('guides/contributing.md', stack, answers);
1214
+ docs['reference/configuration.md'] = getFallbackTemplate('reference/configuration.md', stack, answers);
1215
+ docs['reference/environment.md'] = getFallbackTemplate('reference/environment.md', stack, answers);
1216
+ docs['reference/dependencies.md'] = getFallbackTemplate('reference/dependencies.md', stack, answers);
1098
1217
  docs['patterns/coding-standards.md'] = generateCodingStandards(answers, stack);
1099
- docs['patterns/naming-conventions.md'] = '# Naming Conventions\n\nNaming convention documentation to be added.\n';
1100
- docs['patterns/file-structure.md'] = '# File Structure\n\nFile structure documentation to be added.\n';
1218
+ docs['patterns/naming-conventions.md'] = getFallbackTemplate('patterns/naming-conventions.md', stack, answers);
1219
+ docs['patterns/file-structure.md'] = getFallbackTemplate('patterns/file-structure.md', stack, answers);
1101
1220
  docs['testing/strategy.md'] = generateTestingStrategy(answers, stack);
1102
- docs['testing/unit-tests.md'] = '# Unit Testing\n\nUnit testing documentation to be added.\n';
1103
- docs['testing/integration-tests.md'] = '# Integration Testing\n\nIntegration testing documentation to be added.\n';
1104
- docs['testing/e2e-tests.md'] = '# E2E Testing\n\nE2E testing documentation to be added.\n';
1105
- docs['deployment/ci-cd.md'] = '# CI/CD Pipeline\n\nCI/CD documentation to be added.\n';
1106
- docs['deployment/infrastructure.md'] = '# Infrastructure\n\nInfrastructure documentation to be added.\n';
1221
+ docs['testing/unit-tests.md'] = getFallbackTemplate('testing/unit-tests.md', stack, answers);
1222
+ docs['testing/integration-tests.md'] = getFallbackTemplate('testing/integration-tests.md', stack, answers);
1223
+ docs['testing/e2e-tests.md'] = getFallbackTemplate('testing/e2e-tests.md', stack, answers);
1224
+ docs['deployment/ci-cd.md'] = getFallbackTemplate('deployment/ci-cd.md', stack, answers);
1225
+ docs['deployment/infrastructure.md'] = getFallbackTemplate('deployment/infrastructure.md', stack, answers);
1107
1226
  }
1108
1227
  // ==========================================================================
1109
- // Context7: Fetch real library documentation
1228
+ // STEP 3: Write library docs from Context7 (already fetched in step 1)
1110
1229
  // ==========================================================================
1111
- // Fetch library documentation from Context7 (if available and project has libraries)
1112
- let libraryDocs = [];
1113
- if (!stack.isEmpty && (stack.frameworks.length > 0 || stack.libraries.length > 0)) {
1114
- progress('Fetching library documentation from Context7...');
1115
- libraryDocs = await fetchAllLibraryDocs(stack, progress);
1116
- // Write library docs
1230
+ if (libraryDocs.length > 0) {
1117
1231
  for (const libDoc of libraryDocs) {
1118
1232
  if (libDoc.success && libDoc.content) {
1119
1233
  const libPath = `libraries/${libDoc.filename}`;
1120
1234
  docs[libPath] = libDoc.content;
1121
1235
  }
1122
1236
  }
1123
- // Generate libraries index
1124
1237
  docs['libraries/index.md'] = generateLibrariesIndex(stack, libraryDocs);
1125
1238
  }
1126
1239
  else {
1127
- // Empty project - placeholder library index
1128
1240
  docs['libraries/index.md'] = `# Library Documentation
1129
1241
 
1130
1242
  No libraries detected yet.
@@ -1152,10 +1264,371 @@ Once you add dependencies to your project, run \`claudetools onboard --refresh\`
1152
1264
  addToGitignore(projectPath, '.claudetools/');
1153
1265
  return generatedDocs;
1154
1266
  }
1155
- function getFallbackTemplate(docPath) {
1267
+ function getFallbackTemplate(docPath, stack, answers) {
1156
1268
  const title = docPath.split('/').pop()?.replace('.md', '').replace(/-/g, ' ') || 'Documentation';
1157
1269
  const capitalizedTitle = title.charAt(0).toUpperCase() + title.slice(1);
1158
- return `# ${capitalizedTitle}\n\nDocumentation to be added.\n`;
1270
+ // Generate meaningful templates based on doc type
1271
+ if (docPath.includes('system-design') && stack && answers) {
1272
+ return `# System Design
1273
+
1274
+ ## Overview
1275
+
1276
+ ${answers.projectDescription || 'Project system architecture documentation.'}
1277
+
1278
+ ## Technology Stack
1279
+
1280
+ **Language:** ${stack.primaryLanguage}
1281
+ **Package Manager:** ${stack.packageManager}
1282
+
1283
+ ${stack.frameworks.length > 0 ? `### Frameworks\n${stack.frameworks.map(f => `- **${f.name}** ${f.version} (${f.category})`).join('\n')}` : ''}
1284
+
1285
+ ${stack.libraries.length > 0 ? `### Key Libraries\n${stack.libraries.slice(0, 5).map(l => `- **${l.name}** ${l.version} (${l.category})`).join('\n')}` : ''}
1286
+
1287
+ ## Architecture Overview
1288
+
1289
+ *Analyse the codebase to document the architecture patterns used.*
1290
+
1291
+ ## Key Components
1292
+
1293
+ *Document the main modules and their responsibilities.*
1294
+ `;
1295
+ }
1296
+ if (docPath.includes('data-flow')) {
1297
+ return `# Data Flow
1298
+
1299
+ ## Overview
1300
+
1301
+ This document describes how data flows through the application.
1302
+
1303
+ ## Request/Response Flow
1304
+
1305
+ \`\`\`
1306
+ Client Request → Router → Handler → Service → Data Store
1307
+
1308
+ Client Response ← Handler ← Service ← Data Store
1309
+ \`\`\`
1310
+
1311
+ ## State Management
1312
+
1313
+ *Document the state management approach used in this project.*
1314
+
1315
+ ## Data Transformations
1316
+
1317
+ *Document key data transformation points.*
1318
+ `;
1319
+ }
1320
+ if (docPath.includes('components') && stack) {
1321
+ const hasReact = stack.frameworks.some(f => ['react', 'next', 'remix'].includes(f.name.toLowerCase()));
1322
+ return `# Component Architecture
1323
+
1324
+ ## Overview
1325
+
1326
+ ${hasReact ? 'React-based component architecture.' : 'Component-based architecture.'}
1327
+
1328
+ ## Component Structure
1329
+
1330
+ \`\`\`
1331
+ src/
1332
+ ├── components/
1333
+ │ ├── ui/ # Reusable UI components
1334
+ │ ├── layout/ # Layout components
1335
+ │ └── features/ # Feature-specific components
1336
+ └── pages/ # Page components
1337
+ \`\`\`
1338
+
1339
+ ## Component Guidelines
1340
+
1341
+ 1. **Single Responsibility** - One component, one job
1342
+ 2. **Composition** - Build complex UIs from simple parts
1343
+ 3. **Props** - Clear, typed interfaces
1344
+ 4. **State** - Keep state local where possible
1345
+ `;
1346
+ }
1347
+ if (docPath.includes('endpoints')) {
1348
+ return `# API Endpoints
1349
+
1350
+ ## Overview
1351
+
1352
+ API endpoint documentation.
1353
+
1354
+ ## Endpoint Reference
1355
+
1356
+ | Method | Path | Description |
1357
+ |--------|------|-------------|
1358
+ | GET | /api/health | Health check |
1359
+ | GET | /api/* | List resources |
1360
+ | POST | /api/* | Create resource |
1361
+ | GET | /api/*/:id | Get resource |
1362
+ | PUT | /api/*/:id | Update resource |
1363
+ | DELETE | /api/*/:id | Delete resource |
1364
+
1365
+ *Analyse route files to document actual endpoints.*
1366
+ `;
1367
+ }
1368
+ if (docPath.includes('schemas')) {
1369
+ return `# Data Schemas
1370
+
1371
+ ## Overview
1372
+
1373
+ Data schema and type definitions.
1374
+
1375
+ ## Core Types
1376
+
1377
+ *Extract from type definitions in the codebase.*
1378
+
1379
+ ## Validation
1380
+
1381
+ *Document validation approach (Zod, Yup, etc).*
1382
+ `;
1383
+ }
1384
+ if (docPath.includes('authentication')) {
1385
+ return `# Authentication
1386
+
1387
+ ## Overview
1388
+
1389
+ Authentication and authorisation implementation.
1390
+
1391
+ ## Auth Flow
1392
+
1393
+ *Document the authentication method used (JWT, sessions, OAuth, etc).*
1394
+
1395
+ ## Protected Resources
1396
+
1397
+ *List routes/resources requiring authentication.*
1398
+ `;
1399
+ }
1400
+ if (docPath.includes('configuration') && stack) {
1401
+ return `# Configuration
1402
+
1403
+ ## Overview
1404
+
1405
+ Project configuration documentation.
1406
+
1407
+ ## Config Files
1408
+
1409
+ - \`package.json\` - Dependencies and scripts
1410
+ - \`tsconfig.json\` - TypeScript configuration
1411
+ ${stack.frameworks.some(f => f.name === 'next') ? '- `next.config.js` - Next.js configuration\n' : ''}${stack.frameworks.some(f => f.name === 'astro') ? '- `astro.config.mjs` - Astro configuration\n' : ''}- \`.env\` - Environment variables
1412
+
1413
+ ## Build Configuration
1414
+
1415
+ *Document build and bundler configuration.*
1416
+ `;
1417
+ }
1418
+ if (docPath.includes('environment')) {
1419
+ return `# Environment Variables
1420
+
1421
+ ## Overview
1422
+
1423
+ Environment variable documentation.
1424
+
1425
+ ## Required Variables
1426
+
1427
+ | Variable | Description | Default |
1428
+ |----------|-------------|---------|
1429
+ | NODE_ENV | Environment mode | development |
1430
+
1431
+ ## Optional Variables
1432
+
1433
+ *Document optional configuration variables.*
1434
+
1435
+ ## Secrets
1436
+
1437
+ *Never commit secrets. Use .env.local for local development.*
1438
+ `;
1439
+ }
1440
+ if (docPath.includes('dependencies') && stack) {
1441
+ return `# Dependencies
1442
+
1443
+ ## Overview
1444
+
1445
+ Project dependency documentation.
1446
+
1447
+ ## Core Dependencies
1448
+
1449
+ ${stack.frameworks.map(f => `- **${f.name}** ${f.version} - ${f.category}`).join('\n') || '*No frameworks detected*'}
1450
+
1451
+ ## Libraries
1452
+
1453
+ ${stack.libraries.map(l => `- **${l.name}** ${l.version} - ${l.category}`).join('\n') || '*No libraries detected*'}
1454
+
1455
+ ## Dev Dependencies
1456
+
1457
+ ${stack.devTools.map(t => `- **${t.name}** - ${t.category}`).join('\n') || '*No dev tools detected*'}
1458
+ `;
1459
+ }
1460
+ if (docPath.includes('naming-conventions')) {
1461
+ return `# Naming Conventions
1462
+
1463
+ ## Files
1464
+
1465
+ - **Components:** PascalCase (e.g., \`UserProfile.tsx\`)
1466
+ - **Utilities:** kebab-case (e.g., \`date-utils.ts\`)
1467
+ - **Types:** PascalCase (e.g., \`UserTypes.ts\`)
1468
+
1469
+ ## Code
1470
+
1471
+ - **Variables:** camelCase
1472
+ - **Constants:** SCREAMING_SNAKE_CASE
1473
+ - **Functions:** camelCase (verbs: \`getUserById\`)
1474
+ - **Components:** PascalCase
1475
+ - **Types/Interfaces:** PascalCase
1476
+
1477
+ ## CSS
1478
+
1479
+ - **Classes:** kebab-case or BEM
1480
+ `;
1481
+ }
1482
+ if (docPath.includes('file-structure')) {
1483
+ return `# File Structure
1484
+
1485
+ ## Project Layout
1486
+
1487
+ \`\`\`
1488
+ ├── src/
1489
+ │ ├── components/ # UI components
1490
+ │ ├── lib/ # Utilities
1491
+ │ ├── pages/ # Pages/routes
1492
+ │ ├── services/ # API services
1493
+ │ └── types/ # Type definitions
1494
+ ├── public/ # Static assets
1495
+ ├── tests/ # Test files
1496
+ └── docs/ # Documentation
1497
+ \`\`\`
1498
+
1499
+ ## Conventions
1500
+
1501
+ - Collocate related code
1502
+ - One component per file
1503
+ - Index files only for public API
1504
+ `;
1505
+ }
1506
+ if (docPath.includes('unit-tests')) {
1507
+ return `# Unit Testing
1508
+
1509
+ ## Overview
1510
+
1511
+ Unit testing documentation.
1512
+
1513
+ ## Running Tests
1514
+
1515
+ \`\`\`bash
1516
+ npm test # Run all tests
1517
+ npm test -- -u # Update snapshots
1518
+ npm test -- file # Run specific file
1519
+ \`\`\`
1520
+
1521
+ ## Writing Tests
1522
+
1523
+ - Test one thing per test
1524
+ - Use descriptive test names
1525
+ - Arrange, Act, Assert pattern
1526
+ `;
1527
+ }
1528
+ if (docPath.includes('integration-tests')) {
1529
+ return `# Integration Testing
1530
+
1531
+ ## Overview
1532
+
1533
+ Integration testing documentation.
1534
+
1535
+ ## Approach
1536
+
1537
+ - Test component interactions
1538
+ - Mock external services
1539
+ - Use test databases
1540
+ `;
1541
+ }
1542
+ if (docPath.includes('e2e-tests')) {
1543
+ return `# E2E Testing
1544
+
1545
+ ## Overview
1546
+
1547
+ End-to-end testing documentation.
1548
+
1549
+ ## Running E2E Tests
1550
+
1551
+ \`\`\`bash
1552
+ npm run e2e # Run E2E tests
1553
+ npm run e2e:ui # With UI
1554
+ \`\`\`
1555
+
1556
+ ## Test Coverage
1557
+
1558
+ *Document critical user flows tested.*
1559
+ `;
1560
+ }
1561
+ if (docPath.includes('ci-cd')) {
1562
+ return `# CI/CD Pipeline
1563
+
1564
+ ## Overview
1565
+
1566
+ Continuous integration and deployment configuration.
1567
+
1568
+ ## Pipeline Stages
1569
+
1570
+ 1. **Install** - Install dependencies
1571
+ 2. **Lint** - Code quality checks
1572
+ 3. **Test** - Run test suite
1573
+ 4. **Build** - Build for production
1574
+ 5. **Deploy** - Deploy to environment
1575
+
1576
+ ## Triggers
1577
+
1578
+ - Push to main → Deploy to production
1579
+ - Pull request → Run checks
1580
+ `;
1581
+ }
1582
+ if (docPath.includes('infrastructure')) {
1583
+ return `# Infrastructure
1584
+
1585
+ ## Overview
1586
+
1587
+ Infrastructure and hosting documentation.
1588
+
1589
+ ## Hosting
1590
+
1591
+ *Document hosting platform (Vercel, Cloudflare, AWS, etc).*
1592
+
1593
+ ## Services
1594
+
1595
+ *Document external services and integrations.*
1596
+ `;
1597
+ }
1598
+ if (docPath.includes('contributing')) {
1599
+ return `# Contributing
1600
+
1601
+ ## Getting Started
1602
+
1603
+ 1. Fork the repository
1604
+ 2. Create a feature branch
1605
+ 3. Make your changes
1606
+ 4. Submit a pull request
1607
+
1608
+ ## Code Standards
1609
+
1610
+ - Follow existing patterns
1611
+ - Write tests for new features
1612
+ - Update documentation
1613
+
1614
+ ## Commit Messages
1615
+
1616
+ Use conventional commits: \`type(scope): description\`
1617
+ `;
1618
+ }
1619
+ // Default template
1620
+ return `# ${capitalizedTitle}
1621
+
1622
+ *This document will be populated based on project analysis.*
1623
+
1624
+ ## Overview
1625
+
1626
+ *Add overview content.*
1627
+
1628
+ ## Details
1629
+
1630
+ *Add detailed documentation.*
1631
+ `;
1159
1632
  }
1160
1633
  function addToGitignore(projectPath, entry) {
1161
1634
  const gitignorePath = join(projectPath, '.gitignore');