@paths.design/caws-cli 10.2.0 → 11.1.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 (493) hide show
  1. package/README.md +125 -374
  2. package/dist/index.js +45 -787
  3. package/dist/init/harness-detect.d.ts +18 -0
  4. package/dist/init/harness-detect.d.ts.map +1 -0
  5. package/dist/init/harness-detect.js +90 -0
  6. package/dist/init/harness-detect.js.map +1 -0
  7. package/dist/init/hook-install.d.ts +53 -0
  8. package/dist/init/hook-install.d.ts.map +1 -0
  9. package/dist/init/hook-install.js +421 -0
  10. package/dist/init/hook-install.js.map +1 -0
  11. package/dist/init/hook-packs/manifest-claude-code.d.ts +4 -0
  12. package/dist/init/hook-packs/manifest-claude-code.d.ts.map +1 -0
  13. package/dist/init/hook-packs/manifest-claude-code.js +190 -0
  14. package/dist/init/hook-packs/manifest-claude-code.js.map +1 -0
  15. package/dist/init/hook-packs/register.d.ts +19 -0
  16. package/dist/init/hook-packs/register.d.ts.map +1 -0
  17. package/dist/init/hook-packs/register.js +37 -0
  18. package/dist/init/hook-packs/register.js.map +1 -0
  19. package/dist/init/hook-packs/types.d.ts +123 -0
  20. package/dist/init/hook-packs/types.d.ts.map +1 -0
  21. package/dist/init/hook-packs/types.js +29 -0
  22. package/dist/init/hook-packs/types.js.map +1 -0
  23. package/dist/shell/binding/resolve-binding.d.ts +4 -0
  24. package/dist/shell/binding/resolve-binding.d.ts.map +1 -0
  25. package/dist/shell/binding/resolve-binding.js +228 -0
  26. package/dist/shell/binding/resolve-binding.js.map +1 -0
  27. package/dist/shell/binding/types.d.ts +42 -0
  28. package/dist/shell/binding/types.d.ts.map +1 -0
  29. package/dist/shell/binding/types.js +21 -0
  30. package/dist/shell/binding/types.js.map +1 -0
  31. package/dist/shell/commands/claim.d.ts +14 -0
  32. package/dist/shell/commands/claim.d.ts.map +1 -0
  33. package/dist/shell/commands/claim.js +197 -0
  34. package/dist/shell/commands/claim.js.map +1 -0
  35. package/dist/shell/commands/doctor.d.ts +13 -0
  36. package/dist/shell/commands/doctor.d.ts.map +1 -0
  37. package/dist/shell/commands/doctor.js +97 -0
  38. package/dist/shell/commands/doctor.js.map +1 -0
  39. package/dist/shell/commands/evidence.d.ts +28 -0
  40. package/dist/shell/commands/evidence.d.ts.map +1 -0
  41. package/dist/shell/commands/evidence.js +166 -0
  42. package/dist/shell/commands/evidence.js.map +1 -0
  43. package/dist/shell/commands/gates.d.ts +19 -0
  44. package/dist/shell/commands/gates.d.ts.map +1 -0
  45. package/dist/shell/commands/gates.js +208 -0
  46. package/dist/shell/commands/gates.js.map +1 -0
  47. package/dist/shell/commands/init.d.ts +17 -0
  48. package/dist/shell/commands/init.d.ts.map +1 -0
  49. package/dist/shell/commands/init.js +168 -0
  50. package/dist/shell/commands/init.js.map +1 -0
  51. package/dist/shell/commands/scope.d.ts +11 -0
  52. package/dist/shell/commands/scope.d.ts.map +1 -0
  53. package/dist/shell/commands/scope.js +92 -0
  54. package/dist/shell/commands/scope.js.map +1 -0
  55. package/dist/shell/commands/specs.d.ts +41 -0
  56. package/dist/shell/commands/specs.d.ts.map +1 -0
  57. package/dist/shell/commands/specs.js +264 -0
  58. package/dist/shell/commands/specs.js.map +1 -0
  59. package/dist/shell/commands/status.d.ts +15 -0
  60. package/dist/shell/commands/status.d.ts.map +1 -0
  61. package/dist/shell/commands/status.js +106 -0
  62. package/dist/shell/commands/status.js.map +1 -0
  63. package/dist/shell/commands/waiver.d.ts +38 -0
  64. package/dist/shell/commands/waiver.d.ts.map +1 -0
  65. package/dist/shell/commands/waiver.js +240 -0
  66. package/dist/shell/commands/waiver.js.map +1 -0
  67. package/dist/shell/commands/worktree.d.ts +38 -0
  68. package/dist/shell/commands/worktree.d.ts.map +1 -0
  69. package/dist/shell/commands/worktree.js +286 -0
  70. package/dist/shell/commands/worktree.js.map +1 -0
  71. package/dist/shell/gates/disposition.d.ts +23 -0
  72. package/dist/shell/gates/disposition.d.ts.map +1 -0
  73. package/dist/shell/gates/disposition.js +117 -0
  74. package/dist/shell/gates/disposition.js.map +1 -0
  75. package/dist/shell/gates/gate-result-contract.d.ts +39 -0
  76. package/dist/shell/gates/gate-result-contract.d.ts.map +1 -0
  77. package/dist/shell/gates/gate-result-contract.js +150 -0
  78. package/dist/shell/gates/gate-result-contract.js.map +1 -0
  79. package/dist/shell/gates/local-evaluators/budget-limit.d.ts +24 -0
  80. package/dist/shell/gates/local-evaluators/budget-limit.d.ts.map +1 -0
  81. package/dist/shell/gates/local-evaluators/budget-limit.js +67 -0
  82. package/dist/shell/gates/local-evaluators/budget-limit.js.map +1 -0
  83. package/dist/shell/gates/local-evaluators/diff-helpers.d.ts +25 -0
  84. package/dist/shell/gates/local-evaluators/diff-helpers.d.ts.map +1 -0
  85. package/dist/shell/gates/local-evaluators/diff-helpers.js +74 -0
  86. package/dist/shell/gates/local-evaluators/diff-helpers.js.map +1 -0
  87. package/dist/shell/gates/local-evaluators/index.d.ts +28 -0
  88. package/dist/shell/gates/local-evaluators/index.d.ts.map +1 -0
  89. package/dist/shell/gates/local-evaluators/index.js +67 -0
  90. package/dist/shell/gates/local-evaluators/index.js.map +1 -0
  91. package/dist/shell/gates/local-evaluators/scope-boundary.d.ts +23 -0
  92. package/dist/shell/gates/local-evaluators/scope-boundary.d.ts.map +1 -0
  93. package/dist/shell/gates/local-evaluators/scope-boundary.js +67 -0
  94. package/dist/shell/gates/local-evaluators/scope-boundary.js.map +1 -0
  95. package/dist/shell/gates/local-evaluators/spec-completeness.d.ts +12 -0
  96. package/dist/shell/gates/local-evaluators/spec-completeness.d.ts.map +1 -0
  97. package/dist/shell/gates/local-evaluators/spec-completeness.js +73 -0
  98. package/dist/shell/gates/local-evaluators/spec-completeness.js.map +1 -0
  99. package/dist/shell/gates/quality-gates-adapter.d.ts +55 -0
  100. package/dist/shell/gates/quality-gates-adapter.d.ts.map +1 -0
  101. package/dist/shell/gates/quality-gates-adapter.js +161 -0
  102. package/dist/shell/gates/quality-gates-adapter.js.map +1 -0
  103. package/dist/shell/gates/waiver-filter.d.ts +58 -0
  104. package/dist/shell/gates/waiver-filter.d.ts.map +1 -0
  105. package/dist/shell/gates/waiver-filter.js +119 -0
  106. package/dist/shell/gates/waiver-filter.js.map +1 -0
  107. package/dist/shell/index.d.ts +54 -0
  108. package/dist/shell/index.d.ts.map +1 -0
  109. package/dist/shell/index.js +85 -0
  110. package/dist/shell/index.js.map +1 -0
  111. package/dist/shell/register.d.ts +11 -0
  112. package/dist/shell/register.d.ts.map +1 -0
  113. package/dist/shell/register.js +464 -0
  114. package/dist/shell/register.js.map +1 -0
  115. package/dist/shell/render/claim.d.ts +22 -0
  116. package/dist/shell/render/claim.d.ts.map +1 -0
  117. package/dist/shell/render/claim.js +75 -0
  118. package/dist/shell/render/claim.js.map +1 -0
  119. package/dist/shell/render/decision.d.ts +15 -0
  120. package/dist/shell/render/decision.d.ts.map +1 -0
  121. package/dist/shell/render/decision.js +66 -0
  122. package/dist/shell/render/decision.js.map +1 -0
  123. package/dist/shell/render/diagnostic.d.ts +19 -0
  124. package/dist/shell/render/diagnostic.d.ts.map +1 -0
  125. package/dist/shell/render/diagnostic.js +76 -0
  126. package/dist/shell/render/diagnostic.js.map +1 -0
  127. package/dist/shell/render/finding.d.ts +15 -0
  128. package/dist/shell/render/finding.d.ts.map +1 -0
  129. package/dist/shell/render/finding.js +57 -0
  130. package/dist/shell/render/finding.js.map +1 -0
  131. package/dist/shell/render/gates.d.ts +3 -0
  132. package/dist/shell/render/gates.d.ts.map +1 -0
  133. package/dist/shell/render/gates.js +56 -0
  134. package/dist/shell/render/gates.js.map +1 -0
  135. package/dist/shell/render/init-hook-pack.d.ts +16 -0
  136. package/dist/shell/render/init-hook-pack.d.ts.map +1 -0
  137. package/dist/shell/render/init-hook-pack.js +206 -0
  138. package/dist/shell/render/init-hook-pack.js.map +1 -0
  139. package/dist/shell/render/init.d.ts +11 -0
  140. package/dist/shell/render/init.d.ts.map +1 -0
  141. package/dist/shell/render/init.js +32 -0
  142. package/dist/shell/render/init.js.map +1 -0
  143. package/dist/shell/render/status.d.ts +26 -0
  144. package/dist/shell/render/status.d.ts.map +1 -0
  145. package/dist/shell/render/status.js +143 -0
  146. package/dist/shell/render/status.js.map +1 -0
  147. package/dist/shell/render/waiver.d.ts +21 -0
  148. package/dist/shell/render/waiver.d.ts.map +1 -0
  149. package/dist/shell/render/waiver.js +94 -0
  150. package/dist/shell/render/waiver.js.map +1 -0
  151. package/dist/shell/rules.d.ts +37 -0
  152. package/dist/shell/rules.d.ts.map +1 -0
  153. package/dist/shell/rules.js +51 -0
  154. package/dist/shell/rules.js.map +1 -0
  155. package/dist/shell/session/actor.d.ts +14 -0
  156. package/dist/shell/session/actor.d.ts.map +1 -0
  157. package/dist/shell/session/actor.js +34 -0
  158. package/dist/shell/session/actor.js.map +1 -0
  159. package/dist/shell/session/resolve-session.d.ts +5 -0
  160. package/dist/shell/session/resolve-session.d.ts.map +1 -0
  161. package/dist/shell/session/resolve-session.js +239 -0
  162. package/dist/shell/session/resolve-session.js.map +1 -0
  163. package/dist/shell/session/types.d.ts +56 -0
  164. package/dist/shell/session/types.d.ts.map +1 -0
  165. package/dist/shell/session/types.js +15 -0
  166. package/dist/shell/session/types.js.map +1 -0
  167. package/dist/store/agents-store.d.ts +3 -0
  168. package/dist/store/agents-store.d.ts.map +1 -0
  169. package/dist/store/agents-store.js +63 -0
  170. package/dist/store/agents-store.js.map +1 -0
  171. package/dist/store/apply-patch.d.ts +16 -0
  172. package/dist/store/apply-patch.d.ts.map +1 -0
  173. package/dist/store/apply-patch.js +191 -0
  174. package/dist/store/apply-patch.js.map +1 -0
  175. package/dist/store/atomic-write.d.ts +34 -0
  176. package/dist/store/atomic-write.d.ts.map +1 -0
  177. package/dist/store/atomic-write.js +174 -0
  178. package/dist/store/atomic-write.js.map +1 -0
  179. package/dist/store/doctor-snapshot.d.ts +20 -0
  180. package/dist/store/doctor-snapshot.d.ts.map +1 -0
  181. package/dist/store/doctor-snapshot.js +176 -0
  182. package/dist/store/doctor-snapshot.js.map +1 -0
  183. package/dist/store/events-store.d.ts +33 -0
  184. package/dist/store/events-store.d.ts.map +1 -0
  185. package/dist/store/events-store.js +297 -0
  186. package/dist/store/events-store.js.map +1 -0
  187. package/dist/store/index.d.ts +21 -0
  188. package/dist/store/index.d.ts.map +1 -0
  189. package/dist/store/index.js +47 -0
  190. package/dist/store/index.js.map +1 -0
  191. package/dist/store/init-store.d.ts +21 -0
  192. package/dist/store/init-store.d.ts.map +1 -0
  193. package/dist/store/init-store.js +295 -0
  194. package/dist/store/init-store.js.map +1 -0
  195. package/dist/store/json-store.d.ts +3 -0
  196. package/dist/store/json-store.d.ts.map +1 -0
  197. package/dist/store/json-store.js +65 -0
  198. package/dist/store/json-store.js.map +1 -0
  199. package/dist/store/lifecycle-lock.d.ts +34 -0
  200. package/dist/store/lifecycle-lock.d.ts.map +1 -0
  201. package/dist/store/lifecycle-lock.js +168 -0
  202. package/dist/store/lifecycle-lock.js.map +1 -0
  203. package/dist/store/lifecycle-transaction.d.ts +79 -0
  204. package/dist/store/lifecycle-transaction.d.ts.map +1 -0
  205. package/dist/store/lifecycle-transaction.js +319 -0
  206. package/dist/store/lifecycle-transaction.js.map +1 -0
  207. package/dist/store/policy-store.d.ts +3 -0
  208. package/dist/store/policy-store.d.ts.map +1 -0
  209. package/dist/store/policy-store.js +65 -0
  210. package/dist/store/policy-store.js.map +1 -0
  211. package/dist/store/repo-root.d.ts +46 -0
  212. package/dist/store/repo-root.d.ts.map +1 -0
  213. package/dist/store/repo-root.js +145 -0
  214. package/dist/store/repo-root.js.map +1 -0
  215. package/dist/store/rules.d.ts +69 -0
  216. package/dist/store/rules.d.ts.map +1 -0
  217. package/dist/store/rules.js +95 -0
  218. package/dist/store/rules.js.map +1 -0
  219. package/dist/store/specs-store.d.ts +3 -0
  220. package/dist/store/specs-store.d.ts.map +1 -0
  221. package/dist/store/specs-store.js +131 -0
  222. package/dist/store/specs-store.js.map +1 -0
  223. package/dist/store/specs-writer.d.ts +61 -0
  224. package/dist/store/specs-writer.d.ts.map +1 -0
  225. package/dist/store/specs-writer.js +506 -0
  226. package/dist/store/specs-writer.js.map +1 -0
  227. package/dist/store/types.d.ts +84 -0
  228. package/dist/store/types.d.ts.map +1 -0
  229. package/dist/store/types.js +14 -0
  230. package/dist/store/types.js.map +1 -0
  231. package/dist/store/waivers-store.d.ts +25 -0
  232. package/dist/store/waivers-store.d.ts.map +1 -0
  233. package/dist/store/waivers-store.js +232 -0
  234. package/dist/store/waivers-store.js.map +1 -0
  235. package/dist/store/worktrees-store.d.ts +3 -0
  236. package/dist/store/worktrees-store.d.ts.map +1 -0
  237. package/dist/store/worktrees-store.js +62 -0
  238. package/dist/store/worktrees-store.js.map +1 -0
  239. package/dist/store/worktrees-writer.d.ts +77 -0
  240. package/dist/store/worktrees-writer.d.ts.map +1 -0
  241. package/dist/store/worktrees-writer.js +674 -0
  242. package/dist/store/worktrees-writer.js.map +1 -0
  243. package/dist/store/yaml-patch.d.ts +7 -0
  244. package/dist/store/yaml-patch.d.ts.map +1 -0
  245. package/dist/store/yaml-patch.js +250 -0
  246. package/dist/store/yaml-patch.js.map +1 -0
  247. package/dist/store/yaml-store.d.ts +9 -0
  248. package/dist/store/yaml-store.d.ts.map +1 -0
  249. package/dist/store/yaml-store.js +121 -0
  250. package/dist/store/yaml-store.js.map +1 -0
  251. package/package.json +15 -13
  252. package/dist/budget-derivation.js +0 -751
  253. package/dist/cicd-optimizer.js +0 -504
  254. package/dist/commands/agents.js +0 -124
  255. package/dist/commands/archive.js +0 -500
  256. package/dist/commands/burnup.js +0 -198
  257. package/dist/commands/diagnose.js +0 -525
  258. package/dist/commands/evaluate.js +0 -314
  259. package/dist/commands/gates.js +0 -149
  260. package/dist/commands/init.js +0 -857
  261. package/dist/commands/iterate.js +0 -417
  262. package/dist/commands/mode.js +0 -269
  263. package/dist/commands/parallel.js +0 -242
  264. package/dist/commands/plan.js +0 -438
  265. package/dist/commands/provenance.js +0 -1143
  266. package/dist/commands/quality-monitor.js +0 -284
  267. package/dist/commands/scope.js +0 -264
  268. package/dist/commands/session.js +0 -312
  269. package/dist/commands/sidecar.js +0 -74
  270. package/dist/commands/specs.js +0 -1656
  271. package/dist/commands/status.js +0 -1172
  272. package/dist/commands/templates.js +0 -237
  273. package/dist/commands/tool.js +0 -136
  274. package/dist/commands/tutorial.js +0 -480
  275. package/dist/commands/validate.js +0 -357
  276. package/dist/commands/verify-acs.js +0 -443
  277. package/dist/commands/waivers.js +0 -599
  278. package/dist/commands/workflow.js +0 -243
  279. package/dist/commands/worktree.js +0 -502
  280. package/dist/config/lite-scope.js +0 -158
  281. package/dist/config/modes.js +0 -347
  282. package/dist/constants/spec-types.js +0 -65
  283. package/dist/gates/budget-limit.js +0 -121
  284. package/dist/gates/feedback.js +0 -260
  285. package/dist/gates/format.js +0 -179
  286. package/dist/gates/god-object.js +0 -117
  287. package/dist/gates/pipeline.js +0 -167
  288. package/dist/gates/scope-boundary.js +0 -112
  289. package/dist/gates/spec-completeness.js +0 -109
  290. package/dist/gates/todo-detection.js +0 -205
  291. package/dist/generators/jest-config-generator.js +0 -242
  292. package/dist/generators/working-spec.js +0 -237
  293. package/dist/minimal-cli.js +0 -88
  294. package/dist/parallel/parallel-manager.js +0 -433
  295. package/dist/policy/PolicyManager.js +0 -470
  296. package/dist/scaffold/claude-hooks.js +0 -443
  297. package/dist/scaffold/cursor-hooks.js +0 -177
  298. package/dist/scaffold/git-hooks.js +0 -928
  299. package/dist/scaffold/index.js +0 -794
  300. package/dist/session/session-manager.js +0 -653
  301. package/dist/sidecars/index.js +0 -33
  302. package/dist/sidecars/listeners.js +0 -40
  303. package/dist/sidecars/provenance-summary.js +0 -238
  304. package/dist/sidecars/quality-gaps.js +0 -258
  305. package/dist/sidecars/schema.js +0 -149
  306. package/dist/sidecars/spec-drift.js +0 -151
  307. package/dist/sidecars/waiver-draft.js +0 -176
  308. package/dist/spec/SpecFileManager.js +0 -419
  309. package/dist/templates/.caws/schemas/policy.schema.json +0 -117
  310. package/dist/templates/.caws/schemas/scope.schema.json +0 -52
  311. package/dist/templates/.caws/schemas/waivers.schema.json +0 -106
  312. package/dist/templates/.caws/schemas/working-spec.schema.json +0 -340
  313. package/dist/templates/.caws/schemas/worktrees.schema.json +0 -38
  314. package/dist/templates/.caws/templates/working-spec.template.yml +0 -80
  315. package/dist/templates/.caws/tools/README.md +0 -18
  316. package/dist/templates/.caws/tools/scope-guard.js +0 -203
  317. package/dist/templates/.caws/tools-allow.json +0 -331
  318. package/dist/templates/.caws/waivers.yml +0 -19
  319. package/dist/templates/.claude/README.md +0 -190
  320. package/dist/templates/.claude/hooks/audit.sh +0 -121
  321. package/dist/templates/.claude/hooks/block-dangerous.sh +0 -203
  322. package/dist/templates/.claude/hooks/classify_command.py +0 -592
  323. package/dist/templates/.claude/hooks/doc-frontmatter-check.sh +0 -173
  324. package/dist/templates/.claude/hooks/lite-sprawl-check.sh +0 -145
  325. package/dist/templates/.claude/hooks/naming-check.sh +0 -100
  326. package/dist/templates/.claude/hooks/protected-paths.sh +0 -39
  327. package/dist/templates/.claude/hooks/quality-check.sh +0 -81
  328. package/dist/templates/.claude/hooks/scan-secrets.sh +0 -85
  329. package/dist/templates/.claude/hooks/scope-guard.sh +0 -381
  330. package/dist/templates/.claude/hooks/session-caws-status.sh +0 -117
  331. package/dist/templates/.claude/hooks/session-log.sh +0 -634
  332. package/dist/templates/.claude/hooks/simplification-guard.sh +0 -92
  333. package/dist/templates/.claude/hooks/stop-worktree-check.sh +0 -46
  334. package/dist/templates/.claude/hooks/test_classify_command.py +0 -370
  335. package/dist/templates/.claude/hooks/test_wrapper_smoke.sh +0 -96
  336. package/dist/templates/.claude/hooks/validate-spec.sh +0 -76
  337. package/dist/templates/.claude/hooks/worktree-guard.sh +0 -220
  338. package/dist/templates/.claude/hooks/worktree-write-guard.sh +0 -190
  339. package/dist/templates/.claude/rules/git-safety.md +0 -26
  340. package/dist/templates/.claude/rules/worktree-isolation.md +0 -101
  341. package/dist/templates/.claude/settings.json +0 -141
  342. package/dist/templates/.cursor/README.md +0 -299
  343. package/dist/templates/.cursor/hooks/audit.sh +0 -55
  344. package/dist/templates/.cursor/hooks/block-dangerous.sh +0 -84
  345. package/dist/templates/.cursor/hooks/caws-quality-check.sh +0 -52
  346. package/dist/templates/.cursor/hooks/caws-scope-guard.sh +0 -130
  347. package/dist/templates/.cursor/hooks/format.sh +0 -38
  348. package/dist/templates/.cursor/hooks/naming-check.sh +0 -64
  349. package/dist/templates/.cursor/hooks/scan-secrets.sh +0 -51
  350. package/dist/templates/.cursor/hooks/scope-guard.sh +0 -52
  351. package/dist/templates/.cursor/hooks/session-log.sh +0 -924
  352. package/dist/templates/.cursor/hooks/validate-spec.sh +0 -83
  353. package/dist/templates/.cursor/hooks.json +0 -76
  354. package/dist/templates/.cursor/rules/00-claims-verification.mdc +0 -144
  355. package/dist/templates/.cursor/rules/01-working-style.mdc +0 -50
  356. package/dist/templates/.cursor/rules/02-quality-gates.mdc +0 -368
  357. package/dist/templates/.cursor/rules/03-naming-and-refactor.mdc +0 -33
  358. package/dist/templates/.cursor/rules/04-logging-language-style.mdc +0 -23
  359. package/dist/templates/.cursor/rules/05-safe-defaults-guards.mdc +0 -23
  360. package/dist/templates/.cursor/rules/06-typescript-conventions.mdc +0 -36
  361. package/dist/templates/.cursor/rules/07-process-ops.mdc +0 -20
  362. package/dist/templates/.cursor/rules/08-solid-and-architecture.mdc +0 -16
  363. package/dist/templates/.cursor/rules/09-docstrings.mdc +0 -89
  364. package/dist/templates/.cursor/rules/10-documentation-quality-standards.mdc +0 -385
  365. package/dist/templates/.cursor/rules/11-scope-management-waivers.mdc +0 -381
  366. package/dist/templates/.cursor/rules/12-implementation-completeness.mdc +0 -516
  367. package/dist/templates/.cursor/rules/13-language-agnostic-standards.mdc +0 -578
  368. package/dist/templates/.cursor/rules/README.md +0 -148
  369. package/dist/templates/.github/copilot-instructions.md +0 -82
  370. package/dist/templates/.idea/runConfigurations/CAWS_Evaluate.xml +0 -5
  371. package/dist/templates/.idea/runConfigurations/CAWS_Validate.xml +0 -5
  372. package/dist/templates/.junie/guidelines.md +0 -73
  373. package/dist/templates/.vscode/launch.json +0 -17
  374. package/dist/templates/.vscode/settings.json +0 -95
  375. package/dist/templates/.windsurf/rules/caws-quality-standards.md +0 -54
  376. package/dist/templates/.windsurf/workflows/caws-guided-development.md +0 -92
  377. package/dist/templates/CLAUDE.md +0 -196
  378. package/dist/templates/COMMIT_CONVENTIONS.md +0 -86
  379. package/dist/templates/OIDC_SETUP.md +0 -300
  380. package/dist/templates/agents.md +0 -171
  381. package/dist/templates/codemod/README.md +0 -1
  382. package/dist/templates/codemod/test.js +0 -93
  383. package/dist/templates/docs/README.md +0 -151
  384. package/dist/templates/scripts/new_feature.sh +0 -80
  385. package/dist/templates/scripts/quality-gates/check-god-objects.js +0 -146
  386. package/dist/templates/scripts/quality-gates/run-quality-gates.js +0 -50
  387. package/dist/templates/scripts/v3/analysis/todo_analyzer.py +0 -1997
  388. package/dist/test-analysis.js +0 -786
  389. package/dist/tool-interface.js +0 -314
  390. package/dist/tool-loader.js +0 -303
  391. package/dist/tool-validator.js +0 -393
  392. package/dist/utils/agent-display.js +0 -210
  393. package/dist/utils/agent-session.js +0 -344
  394. package/dist/utils/async-utils.js +0 -188
  395. package/dist/utils/command-wrapper.js +0 -200
  396. package/dist/utils/event-log.js +0 -584
  397. package/dist/utils/event-renderer.js +0 -521
  398. package/dist/utils/finalization.js +0 -230
  399. package/dist/utils/git-lock.js +0 -119
  400. package/dist/utils/gitignore-updater.js +0 -158
  401. package/dist/utils/ide-detection.js +0 -133
  402. package/dist/utils/lifecycle-events.js +0 -94
  403. package/dist/utils/project-analysis.js +0 -367
  404. package/dist/utils/promise-utils.js +0 -72
  405. package/dist/utils/quality-gates-errors.js +0 -520
  406. package/dist/utils/quality-gates-utils.js +0 -387
  407. package/dist/utils/schema-validator.js +0 -50
  408. package/dist/utils/spec-resolver.js +0 -711
  409. package/dist/utils/typescript-detector.js +0 -369
  410. package/dist/utils/working-state.js +0 -530
  411. package/dist/utils/yaml-validation.js +0 -156
  412. package/dist/validation/spec-validation.js +0 -924
  413. package/dist/waivers-manager.js +0 -732
  414. package/dist/worktree/worktree-manager.js +0 -1735
  415. package/templates/.caws/schemas/policy.schema.json +0 -117
  416. package/templates/.caws/schemas/scope.schema.json +0 -52
  417. package/templates/.caws/schemas/waivers.schema.json +0 -106
  418. package/templates/.caws/schemas/working-spec.schema.json +0 -340
  419. package/templates/.caws/schemas/worktrees.schema.json +0 -38
  420. package/templates/.caws/templates/working-spec.template.yml +0 -80
  421. package/templates/.caws/tools/README.md +0 -18
  422. package/templates/.caws/tools/scope-guard.js +0 -203
  423. package/templates/.caws/tools-allow.json +0 -331
  424. package/templates/.caws/waivers.yml +0 -19
  425. package/templates/.claude/README.md +0 -190
  426. package/templates/.claude/hooks/audit.sh +0 -121
  427. package/templates/.claude/hooks/block-dangerous.sh +0 -203
  428. package/templates/.claude/hooks/classify_command.py +0 -592
  429. package/templates/.claude/hooks/doc-frontmatter-check.sh +0 -173
  430. package/templates/.claude/hooks/lite-sprawl-check.sh +0 -145
  431. package/templates/.claude/hooks/naming-check.sh +0 -100
  432. package/templates/.claude/hooks/protected-paths.sh +0 -39
  433. package/templates/.claude/hooks/quality-check.sh +0 -81
  434. package/templates/.claude/hooks/scan-secrets.sh +0 -85
  435. package/templates/.claude/hooks/scope-guard.sh +0 -381
  436. package/templates/.claude/hooks/session-caws-status.sh +0 -117
  437. package/templates/.claude/hooks/session-log.sh +0 -634
  438. package/templates/.claude/hooks/simplification-guard.sh +0 -92
  439. package/templates/.claude/hooks/stop-worktree-check.sh +0 -46
  440. package/templates/.claude/hooks/test_classify_command.py +0 -370
  441. package/templates/.claude/hooks/test_wrapper_smoke.sh +0 -96
  442. package/templates/.claude/hooks/validate-spec.sh +0 -76
  443. package/templates/.claude/hooks/worktree-guard.sh +0 -220
  444. package/templates/.claude/hooks/worktree-write-guard.sh +0 -190
  445. package/templates/.claude/rules/git-safety.md +0 -26
  446. package/templates/.claude/rules/worktree-isolation.md +0 -101
  447. package/templates/.claude/settings.json +0 -141
  448. package/templates/.cursor/README.md +0 -299
  449. package/templates/.cursor/hooks/audit.sh +0 -55
  450. package/templates/.cursor/hooks/block-dangerous.sh +0 -84
  451. package/templates/.cursor/hooks/caws-quality-check.sh +0 -52
  452. package/templates/.cursor/hooks/caws-scope-guard.sh +0 -130
  453. package/templates/.cursor/hooks/format.sh +0 -38
  454. package/templates/.cursor/hooks/naming-check.sh +0 -64
  455. package/templates/.cursor/hooks/scan-secrets.sh +0 -51
  456. package/templates/.cursor/hooks/scope-guard.sh +0 -52
  457. package/templates/.cursor/hooks/session-log.sh +0 -924
  458. package/templates/.cursor/hooks/validate-spec.sh +0 -83
  459. package/templates/.cursor/hooks.json +0 -76
  460. package/templates/.cursor/rules/00-claims-verification.mdc +0 -144
  461. package/templates/.cursor/rules/01-working-style.mdc +0 -50
  462. package/templates/.cursor/rules/02-quality-gates.mdc +0 -368
  463. package/templates/.cursor/rules/03-naming-and-refactor.mdc +0 -33
  464. package/templates/.cursor/rules/04-logging-language-style.mdc +0 -23
  465. package/templates/.cursor/rules/05-safe-defaults-guards.mdc +0 -23
  466. package/templates/.cursor/rules/06-typescript-conventions.mdc +0 -36
  467. package/templates/.cursor/rules/07-process-ops.mdc +0 -20
  468. package/templates/.cursor/rules/08-solid-and-architecture.mdc +0 -16
  469. package/templates/.cursor/rules/09-docstrings.mdc +0 -89
  470. package/templates/.cursor/rules/10-documentation-quality-standards.mdc +0 -385
  471. package/templates/.cursor/rules/11-scope-management-waivers.mdc +0 -381
  472. package/templates/.cursor/rules/12-implementation-completeness.mdc +0 -516
  473. package/templates/.cursor/rules/13-language-agnostic-standards.mdc +0 -578
  474. package/templates/.cursor/rules/README.md +0 -148
  475. package/templates/.github/copilot-instructions.md +0 -82
  476. package/templates/.idea/runConfigurations/CAWS_Evaluate.xml +0 -5
  477. package/templates/.idea/runConfigurations/CAWS_Validate.xml +0 -5
  478. package/templates/.junie/guidelines.md +0 -73
  479. package/templates/.vscode/launch.json +0 -17
  480. package/templates/.vscode/settings.json +0 -95
  481. package/templates/.windsurf/rules/caws-quality-standards.md +0 -54
  482. package/templates/.windsurf/workflows/caws-guided-development.md +0 -92
  483. package/templates/CLAUDE.md +0 -196
  484. package/templates/COMMIT_CONVENTIONS.md +0 -86
  485. package/templates/OIDC_SETUP.md +0 -300
  486. package/templates/agents.md +0 -171
  487. package/templates/codemod/README.md +0 -1
  488. package/templates/codemod/test.js +0 -93
  489. package/templates/docs/README.md +0 -151
  490. package/templates/scripts/new_feature.sh +0 -80
  491. package/templates/scripts/quality-gates/check-god-objects.js +0 -146
  492. package/templates/scripts/quality-gates/run-quality-gates.js +0 -50
  493. package/templates/scripts/v3/analysis/todo_analyzer.py +0 -1997
@@ -1,857 +0,0 @@
1
- /**
2
- * @fileoverview CAWS Init Command Handler
3
- * Handles project initialization with CAWS setup
4
- * @author @darianrosebrook
5
- */
6
-
7
- const fs = require('fs-extra');
8
- const path = require('path');
9
- const inquirer = require('inquirer');
10
- const chalk = require('chalk');
11
- const yaml = require('js-yaml');
12
-
13
- // Import shared utilities
14
- const { detectCAWSSetup } = require('../utils/detection');
15
- const { detectProjectType } = require('../utils/project-analysis');
16
- const { shouldInitInCurrentDirectory } = require('../utils/project-analysis');
17
- const { generateWorkingSpec } = require('../generators/working-spec');
18
- const { finalizeProject } = require('../utils/finalization');
19
- const { scaffoldCursorHooks } = require('../scaffold/cursor-hooks');
20
- const { scaffoldIDEIntegrations } = require('../scaffold/index');
21
- const { updateGitignore } = require('../utils/gitignore-updater');
22
- const { getLiteScopeDefaults } = require('../config/lite-scope');
23
- const { scaffoldClaudeHooks } = require('../scaffold/claude-hooks');
24
- const { setCurrentMode } = require('../config/modes');
25
- const {
26
- IDE_REGISTRY,
27
- detectActiveIDEs,
28
- getRecommendedIDEs,
29
- parseIDESelection,
30
- } = require('../utils/ide-detection');
31
- // CAWSFIX-10: share the canonical spec-ID regex with the validator
32
- const { SPEC_ID_PATTERN } = require('../validation/spec-validation');
33
-
34
- function buildInitialFeatureSpec(specContent, fallbackId) {
35
- const parsed = yaml.load(specContent);
36
- const riskTier =
37
- typeof parsed.risk_tier === 'string'
38
- ? parseInt(parsed.risk_tier.replace(/^T/i, ''), 10) || 3
39
- : parsed.risk_tier || 3;
40
- const aiConfidenceRaw = parsed.ai_assessment?.confidence_level;
41
- const aiConfidence =
42
- typeof aiConfidenceRaw === 'number' && aiConfidenceRaw <= 1
43
- ? Math.max(1, Math.min(10, Math.round(aiConfidenceRaw * 10)))
44
- : typeof aiConfidenceRaw === 'number'
45
- ? Math.max(1, Math.min(10, Math.round(aiConfidenceRaw)))
46
- : 8;
47
- const normalizedContracts =
48
- Array.isArray(parsed.contracts) && parsed.contracts.length > 0
49
- ? parsed.contracts.map((contract, index) => ({
50
- type: ['openapi', 'graphql', 'proto', 'pact'].includes(contract?.type)
51
- ? contract.type
52
- : 'openapi',
53
- path:
54
- contract?.path ||
55
- (index === 0 ? 'docs/api/initial-feature.yaml' : `docs/api/contract-${index + 1}.yaml`),
56
- }))
57
- : riskTier <= 2
58
- ? [{ type: 'openapi', path: 'docs/api/initial-feature.yaml' }]
59
- : [];
60
-
61
- return {
62
- id: parsed.id || fallbackId,
63
- title: parsed.title || 'New CAWS Project',
64
- risk_tier: riskTier,
65
- mode: parsed.mode || 'feature',
66
- blast_radius: parsed.blast_radius || { modules: ['src', 'tests'], data_migration: false },
67
- operational_rollback_slo: parsed.operational_rollback_slo || '5m',
68
- scope: parsed.scope || {
69
- in: ['src/', 'tests/'],
70
- out: ['node_modules/', 'dist/', 'build/'],
71
- },
72
- invariants: Array.isArray(parsed.invariants) && parsed.invariants.length > 0
73
- ? parsed.invariants
74
- : ['System maintains data consistency'],
75
- acceptance: Array.isArray(parsed.acceptance) && parsed.acceptance.length > 0
76
- ? parsed.acceptance
77
- : [
78
- {
79
- id: 'A1',
80
- given: 'Current system state',
81
- when: 'the initial project is bootstrapped',
82
- then: 'the CAWS project should validate successfully',
83
- },
84
- ],
85
- non_functional: parsed.non_functional || {
86
- a11y: ['keyboard'],
87
- perf: { api_p95_ms: 250 },
88
- security: [],
89
- },
90
- contracts: normalizedContracts,
91
- observability: parsed.observability || { logs: [], metrics: [], traces: [] },
92
- migrations: Array.isArray(parsed.migrations) ? parsed.migrations : [],
93
- rollback: Array.isArray(parsed.rollback) ? parsed.rollback : [],
94
- ai_assessment: {
95
- confidence_level: aiConfidence,
96
- uncertainty_areas: Array.isArray(parsed.ai_assessment?.uncertainty_areas)
97
- ? parsed.ai_assessment.uncertainty_areas
98
- : [],
99
- recommended_pairing:
100
- parsed.ai_assessment?.recommended_pairing !== undefined
101
- ? Boolean(parsed.ai_assessment.recommended_pairing)
102
- : aiConfidence <= 6,
103
- },
104
- };
105
- }
106
-
107
- async function writeInitialSpecArtifacts(specContent, fallbackId) {
108
- const canonicalSpec = buildInitialFeatureSpec(specContent, fallbackId);
109
- const now = new Date().toISOString();
110
- const canonicalContent = yaml.dump(canonicalSpec, { indent: 2 });
111
- const specsDir = path.join('.caws', 'specs');
112
- const featureSpecPath = path.join(specsDir, `${canonicalSpec.id}.yaml`);
113
- const workingSpecPath = path.join('.caws', 'working-spec.yaml');
114
- const registryPath = path.join(specsDir, 'registry.json');
115
-
116
- await fs.ensureDir(specsDir);
117
- await fs.writeFile(featureSpecPath, canonicalContent);
118
- await fs.writeFile(workingSpecPath, canonicalContent);
119
- await fs.writeJson(
120
- registryPath,
121
- {
122
- version: '1.0.0',
123
- specs: {
124
- [canonicalSpec.id]: {
125
- path: `${canonicalSpec.id}.yaml`,
126
- type: 'feature',
127
- status: 'active',
128
- created_at: now,
129
- updated_at: now,
130
- owner: null,
131
- },
132
- },
133
- lastUpdated: now,
134
- },
135
- { spaces: 2 }
136
- );
137
-
138
- return {
139
- canonicalSpec,
140
- featureSpecPath,
141
- workingSpecPath,
142
- };
143
- }
144
-
145
- /**
146
- * Initialize a new project with CAWS
147
- */
148
- async function initProject(projectName, options) {
149
- const currentDir = process.cwd();
150
- const isCurrentDirInit = shouldInitInCurrentDirectory(projectName, currentDir);
151
-
152
- if (!isCurrentDirInit && projectName !== '.') {
153
- console.log(chalk.cyan(`Initializing new CAWS project: ${projectName}`));
154
- console.log(chalk.gray(` (Creating subdirectory: ${projectName}/)`));
155
- } else {
156
- console.log(
157
- chalk.cyan(`Initializing CAWS in current project: ${path.basename(currentDir)}`)
158
- );
159
- console.log(chalk.gray(` (Adding CAWS files to existing project)`));
160
- }
161
-
162
- let answers; // Will be set either interactively or with defaults
163
-
164
- try {
165
- // Validate project name
166
- if (!projectName || projectName.trim() === '') {
167
- console.error(chalk.red('Project name is required'));
168
- console.error(chalk.blue('Usage: caws init <project-name>'));
169
- process.exit(1);
170
- }
171
-
172
- // Special case: '.' means current directory, don't sanitize
173
- if (projectName !== '.') {
174
- // Sanitize project name
175
- const sanitizedName = projectName.replace(/[^a-zA-Z0-9-_]/g, '-').toLowerCase();
176
- if (sanitizedName !== projectName) {
177
- console.warn(chalk.yellow(`Project name sanitized to: ${sanitizedName}`));
178
- projectName = sanitizedName;
179
- }
180
- }
181
-
182
- // Validate project name length
183
- if (projectName.length > 50) {
184
- console.error(chalk.red('Project name is too long (max 50 characters)'));
185
- console.error(chalk.blue('Usage: caws init <project-name>'));
186
- process.exit(1);
187
- }
188
-
189
- // Validate project name format
190
- if (projectName.length === 0) {
191
- console.error(chalk.red('Project name cannot be empty'));
192
- console.error(chalk.blue('Usage: caws init <project-name>'));
193
- process.exit(1);
194
- }
195
-
196
- // Check for invalid characters that should cause immediate failure
197
- if (projectName.includes('/') || projectName.includes('\\') || projectName.includes('..')) {
198
- console.error(chalk.red('Project name contains invalid characters'));
199
- console.error(chalk.blue('Usage: caws init <project-name>'));
200
- console.error(chalk.blue('Project name should not contain: / \\ ..'));
201
- process.exit(1);
202
- }
203
-
204
- // Determine if initializing in current directory
205
- const initInCurrentDir = projectName === '.';
206
- const targetDir = initInCurrentDir ? process.cwd() : path.resolve(process.cwd(), projectName);
207
-
208
- // Check if target directory already exists and has content (skip check for current directory)
209
- if (!initInCurrentDir && fs.existsSync(projectName)) {
210
- const existingFiles = fs.readdirSync(projectName);
211
- if (existingFiles.length > 0) {
212
- console.error(chalk.red(`Directory '${projectName}' already exists and contains files`));
213
- console.error(chalk.blue('To initialize CAWS in current directory instead:'));
214
- console.error(` ${chalk.cyan('caws init .')}`);
215
- console.error(chalk.blue('Or choose a different name/remove existing directory'));
216
- process.exit(1);
217
- }
218
- }
219
-
220
- // Check if current directory has project files when trying to init in subdirectory
221
- if (!initInCurrentDir) {
222
- const currentDirFiles = fs.readdirSync(process.cwd());
223
- const hasProjectFiles = currentDirFiles.some(
224
- (file) => !file.startsWith('.') && file !== 'node_modules' && file !== '.git'
225
- );
226
-
227
- if (hasProjectFiles && !options.nonInteractive) {
228
- console.warn(chalk.yellow('Current directory contains project files'));
229
- console.warn(
230
- chalk.blue('You might want to initialize CAWS in current directory instead:')
231
- );
232
- console.warn(` ${chalk.cyan('caws init .')}`);
233
- console.warn(chalk.blue(' Or continue to create subdirectory (Ctrl+C to cancel)'));
234
- }
235
- }
236
-
237
- // Save the original template directory before changing directories
238
- const cawsSetup = detectCAWSSetup(targetDir);
239
- const originalTemplateDir = cawsSetup?.hasTemplateDir ? cawsSetup.templateDir : null;
240
-
241
- // Check for existing AGENTS.md/agents.md/caws.md in target directory
242
- const existingAgentsMd = fs.existsSync(path.join(targetDir, 'AGENTS.md')) ||
243
- fs.existsSync(path.join(targetDir, 'agents.md'));
244
- const existingCawsMd = fs.existsSync(path.join(targetDir, 'caws.md'));
245
-
246
- // Create project directory and change to it (unless already in current directory)
247
- if (!initInCurrentDir) {
248
- await fs.ensureDir(projectName);
249
- process.chdir(projectName);
250
- console.log(chalk.green(`Created project directory: ${projectName}`));
251
- } else {
252
- console.log(chalk.green(`Initializing in current directory`));
253
- }
254
-
255
- // Detect and adapt to existing setup
256
- const currentSetup = detectCAWSSetup(process.cwd());
257
-
258
- if (currentSetup.type === 'new') {
259
- // Create minimal CAWS structure
260
- await fs.ensureDir('.caws');
261
- await fs.ensureDir('.agent');
262
- console.log(chalk.blue('Created basic CAWS structure'));
263
-
264
- // Copy AGENTS.md guide if templates are available
265
- if (originalTemplateDir) {
266
- try {
267
- const agentsMdSource = path.join(originalTemplateDir, 'AGENTS.md');
268
- let targetFile = 'AGENTS.md';
269
-
270
- if (fs.existsSync(agentsMdSource)) {
271
- if (existingAgentsMd) {
272
- if (options.interactive && !options.nonInteractive) {
273
- const overwriteAnswer = await inquirer.prompt([
274
- {
275
- type: 'confirm',
276
- name: 'overwrite',
277
- message: 'AGENTS.md already exists. Overwrite with CAWS guide?',
278
- default: false,
279
- },
280
- ]);
281
-
282
- if (!overwriteAnswer.overwrite) {
283
- targetFile = 'caws.md';
284
- }
285
- } else {
286
- targetFile = 'caws.md';
287
- console.log(chalk.blue('AGENTS.md exists, using caws.md for CAWS guide'));
288
- }
289
- }
290
-
291
- if (targetFile === 'caws.md' && existingCawsMd) {
292
- console.log(
293
- chalk.yellow('Both AGENTS.md and caws.md exist, skipping guide copy')
294
- );
295
- } else {
296
- const agentsMdDest = path.join(process.cwd(), targetFile);
297
- await fs.copyFile(agentsMdSource, agentsMdDest);
298
- console.log(chalk.green(`Added ${targetFile} guide`));
299
- }
300
- }
301
- } catch (templateError) {
302
- console.warn(chalk.yellow('Could not copy agents guide:'), templateError.message);
303
- }
304
- }
305
- } else {
306
- // Already has CAWS setup
307
- console.log(chalk.green('CAWS project detected - skipping template copy'));
308
- }
309
-
310
- // Handle lite mode init path
311
- if (options.mode === 'lite') {
312
- console.log(chalk.magenta('CAWS Lite Mode — guardrails without YAML specs'));
313
-
314
- // Detect allowed directories
315
- const detectedDirs = [];
316
- const commonDirs = ['src/', 'lib/', 'app/', 'tests/', 'test/', 'docs/'];
317
- for (const dir of commonDirs) {
318
- if (fs.existsSync(path.join(process.cwd(), dir.replace(/\/$/, '')))) {
319
- detectedDirs.push(dir);
320
- }
321
- }
322
-
323
- let allowedDirs = detectedDirs.length > 0 ? detectedDirs : ['src/', 'tests/', 'docs/'];
324
-
325
- if (options.interactive && !options.nonInteractive) {
326
- const liteAnswers = await inquirer.prompt([
327
- {
328
- type: 'input',
329
- name: 'projectName',
330
- message: 'Project name:',
331
- default: path.basename(process.cwd()),
332
- },
333
- {
334
- type: 'input',
335
- name: 'allowedDirs',
336
- message: 'Allowed directories (comma-separated):',
337
- default: allowedDirs.join(', '),
338
- },
339
- ]);
340
- allowedDirs = liteAnswers.allowedDirs.split(',').map((d) => d.trim()).filter(Boolean);
341
- }
342
-
343
- // Generate .caws/scope.json
344
- await fs.ensureDir('.caws');
345
- const scopeConfig = getLiteScopeDefaults();
346
- scopeConfig.allowedDirectories = allowedDirs;
347
- await fs.writeFile(
348
- path.join('.caws', 'scope.json'),
349
- JSON.stringify(scopeConfig, null, 2)
350
- );
351
- console.log(chalk.green('Created .caws/scope.json'));
352
-
353
- // Set mode to lite
354
- await setCurrentMode('lite');
355
- console.log(chalk.green('Set mode to lite in .caws/mode.json'));
356
-
357
- // Scaffold hooks: block-dangerous + scope-guard + lite-sprawl-check + simplification-guard
358
- const liteIDEs = options.ide ? parseIDESelection(options.ide) : ['claude'];
359
- if (liteIDEs.includes('claude')) {
360
- console.log(chalk.blue('Setting up lite-mode hooks...'));
361
- await scaffoldClaudeHooks(process.cwd(), ['safety', 'scope', 'lite']);
362
- }
363
-
364
- // Update .gitignore
365
- console.log(chalk.blue('Updating .gitignore...'));
366
- await updateGitignore(process.cwd());
367
-
368
- // Success
369
- console.log(chalk.green('\nCAWS Lite mode initialized!'));
370
- console.log(chalk.blue('\nGuardrails active:'));
371
- console.log(' - Destructive command blocking (git push --force, rm -rf, etc.)');
372
- console.log(' - Scope fencing (edits outside allowed directories require confirmation)');
373
- console.log(' - File sprawl detection (banned patterns like *-enhanced.*, *-final.*)');
374
- console.log(' - Simplification guard (prevents stubbing out implementations)');
375
- console.log(chalk.blue('\nNext steps:'));
376
- console.log(' 1. Review .caws/scope.json and customize for your project');
377
- console.log(' 2. Start coding — hooks will protect against common AI mistakes');
378
- console.log(' 3. Use `caws worktree create <name>` for isolated agent workspaces');
379
- return;
380
- }
381
-
382
- // Handle interactive wizard or template-based setup
383
- if (options.interactive && !options.nonInteractive) {
384
- console.log(chalk.cyan('CAWS Interactive Setup Wizard'));
385
- console.log(chalk.blue('========================================'));
386
- console.log(chalk.gray('This wizard will guide you through creating a CAWS working spec\n'));
387
-
388
- // Detect active IDEs for pre-selecting the IDE prompt
389
- const detectedIDEs = detectActiveIDEs();
390
- const recommendedIDEs = getRecommendedIDEs();
391
- if (detectedIDEs.length > 0) {
392
- console.log(chalk.blue(`Detected IDE: ${detectedIDEs.map((id) => IDE_REGISTRY[id].name).join(', ')}`));
393
- console.log(chalk.gray(' (Pre-selected based on your environment)\n'));
394
- }
395
-
396
- // Detect project type
397
- const detectedType = detectProjectType(process.cwd());
398
- console.log(chalk.blue(`Detected project type: ${chalk.cyan(detectedType)}`));
399
-
400
- // Get package.json info if available
401
- let packageJson = {};
402
- try {
403
- packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf8'));
404
- } catch (e) {
405
- // No package.json, that's fine
406
- }
407
-
408
- const wizardQuestions = [
409
- {
410
- type: 'list',
411
- name: 'projectType',
412
- message: 'What type of project is this?',
413
- choices: [
414
- {
415
- name: 'VS Code Extension (webview, commands, integrations)',
416
- value: 'extension',
417
- short: 'VS Code Extension',
418
- },
419
- {
420
- name: 'Library/Package (reusable components, utilities)',
421
- value: 'library',
422
- short: 'Library',
423
- },
424
- {
425
- name: 'Web Application (frontend/backend, full-stack)',
426
- value: 'application',
427
- short: 'Web Application',
428
- },
429
- {
430
- name: 'CLI Tool (command-line interface, scripts)',
431
- value: 'cli',
432
- short: 'CLI Tool',
433
- },
434
- {
435
- name: 'Mobile App (iOS/Android, React Native, etc.)',
436
- value: 'mobile',
437
- short: 'Mobile App',
438
- },
439
- {
440
- name: 'Infrastructure (DevOps, deployment, cloud)',
441
- value: 'infrastructure',
442
- short: 'Infrastructure',
443
- },
444
- {
445
- name: 'Data/Analytics (ETL, ML, dashboards)',
446
- value: 'data',
447
- short: 'Data/Analytics',
448
- },
449
- {
450
- name: 'Game Development (Unity, Godot, custom engine)',
451
- value: 'game',
452
- short: 'Game',
453
- },
454
- {
455
- name: 'Other/Custom (please specify)',
456
- value: 'other',
457
- short: 'Other',
458
- },
459
- ],
460
- default: detectedType,
461
- },
462
- {
463
- type: 'input',
464
- name: 'projectTitle',
465
- message: 'What is the project title?',
466
- default: packageJson.name || path.basename(process.cwd()),
467
- validate: (input) => {
468
- if (input.trim().length < 3) {
469
- return 'Project title must be at least 3 characters';
470
- }
471
- if (input.length > 100) {
472
- return 'Project title must be less than 100 characters';
473
- }
474
- return true;
475
- },
476
- },
477
- {
478
- type: 'input',
479
- name: 'projectDescription',
480
- message: 'Provide a brief project description (1-2 sentences):',
481
- default: packageJson.description || '',
482
- validate: (input) => {
483
- if (input.trim().length < 10) {
484
- return 'Description must be at least 10 characters';
485
- }
486
- if (input.length > 500) {
487
- return 'Description must be less than 500 characters';
488
- }
489
- return true;
490
- },
491
- },
492
- {
493
- type: 'list',
494
- name: 'riskTier',
495
- message: 'What risk tier does this project fall into?',
496
- choices: [
497
- {
498
- name: 'Tier 1 - High Risk (auth, billing, migrations, critical infrastructure)',
499
- value: 1,
500
- short: 'High Risk (T1)',
501
- },
502
- {
503
- name: 'Tier 2 - Medium Risk (features, APIs, data writes)',
504
- value: 2,
505
- short: 'Medium Risk (T2)',
506
- },
507
- {
508
- name: 'Tier 3 - Low Risk (UI, internal tools, docs)',
509
- value: 3,
510
- short: 'Low Risk (T3)',
511
- },
512
- ],
513
- default: 2,
514
- },
515
- {
516
- type: 'input',
517
- name: 'projectId',
518
- message: 'Project ID (e.g., PROJ-001, FEAT-123):',
519
- default: () => {
520
- const randomNum = Math.floor(Math.random() * 1000) + 1;
521
- return `PROJ-${randomNum.toString().padStart(3, '0')}`;
522
- },
523
- validate: (input) => {
524
- // CAWSFIX-10: accept multi-segment IDs like P03-IMPL-01
525
- if (!SPEC_ID_PATTERN.test(input)) {
526
- return 'Project ID must be in format PREFIX-NUMBER or PREFIX-SEGMENT-NUMBER (e.g., PROJ-001, P03-IMPL-01)';
527
- }
528
- if (input.length > 40) {
529
- return 'Project ID must be less than 40 characters';
530
- }
531
- return true;
532
- },
533
- },
534
- {
535
- type: 'checkbox',
536
- name: 'selectedIDEs',
537
- message: 'Which IDE integrations do you want to install?',
538
- choices: [
539
- {
540
- name: `Cursor (hooks, rules, audit) - AI-first IDE`,
541
- value: 'cursor',
542
- checked: options.ide
543
- ? parseIDESelection(options.ide).includes('cursor')
544
- : recommendedIDEs.includes('cursor'),
545
- },
546
- {
547
- name: `Claude Code (safety hooks, settings)`,
548
- value: 'claude',
549
- checked: options.ide
550
- ? parseIDESelection(options.ide).includes('claude')
551
- : recommendedIDEs.includes('claude'),
552
- },
553
- {
554
- name: `VS Code (settings, debug configs)`,
555
- value: 'vscode',
556
- checked: options.ide
557
- ? parseIDESelection(options.ide).includes('vscode')
558
- : recommendedIDEs.includes('vscode'),
559
- },
560
- {
561
- name: `IntelliJ IDEA (run configurations)`,
562
- value: 'intellij',
563
- checked: options.ide
564
- ? parseIDESelection(options.ide).includes('intellij')
565
- : recommendedIDEs.includes('intellij'),
566
- },
567
- {
568
- name: `Windsurf (CAWS workflow)`,
569
- value: 'windsurf',
570
- checked: options.ide
571
- ? parseIDESelection(options.ide).includes('windsurf')
572
- : recommendedIDEs.includes('windsurf'),
573
- },
574
- {
575
- name: `GitHub Copilot (instructions)`,
576
- value: 'copilot',
577
- checked: options.ide
578
- ? parseIDESelection(options.ide).includes('copilot')
579
- : recommendedIDEs.includes('copilot'),
580
- },
581
- {
582
- name: `JetBrains Junie (AI agent guidelines)`,
583
- value: 'junie',
584
- checked: options.ide
585
- ? parseIDESelection(options.ide).includes('junie')
586
- : recommendedIDEs.includes('junie'),
587
- },
588
- new inquirer.Separator(),
589
- {
590
- name: 'All IDEs (install everything)',
591
- value: 'all',
592
- },
593
- ],
594
- },
595
- {
596
- type: 'confirm',
597
- name: 'generateExamples',
598
- message: 'Generate example code and documentation?',
599
- default: true,
600
- },
601
- ];
602
-
603
- // Ask questions and get answers
604
- answers = await inquirer.prompt(wizardQuestions);
605
-
606
- // Generate working spec
607
- console.log(chalk.blue('\nGenerating CAWS working spec...'));
608
- const specContent = generateWorkingSpec(answers);
609
-
610
- // Write canonical feature spec plus legacy compatibility mirror
611
- await fs.ensureDir('.caws');
612
- const initialSpec = await writeInitialSpecArtifacts(specContent, answers.projectId);
613
- console.log(chalk.green(`Created ${initialSpec.featureSpecPath}`));
614
- console.log(chalk.green('Created .caws/working-spec.yaml'));
615
- console.log(chalk.green('Created .caws/specs/registry.json'));
616
-
617
- // Optionally create policy.yaml (optional - defaults work fine)
618
- const policyPath = path.join('.caws', 'policy.yaml');
619
- if (!fs.existsSync(policyPath)) {
620
- const { PolicyManager } = require('../policy/PolicyManager');
621
- const policyManager = new PolicyManager();
622
- const defaultPolicy = policyManager.getDefaultPolicy();
623
- const policyContent = yaml.dump(defaultPolicy, { indent: 2 });
624
- await fs.writeFile(policyPath, policyContent);
625
- console.log(chalk.green('Created .caws/policy.yaml (optional - defaults work fine)'));
626
- }
627
-
628
- // Generate additional files if requested
629
- if (answers.generateExamples) {
630
- console.log(chalk.blue('Generating example files...'));
631
-
632
- // Generate .caws/getting-started.md
633
- const gettingStartedGuide = `# ${answers.projectTitle} - Getting Started
634
-
635
- ## Project Overview
636
- ${answers.projectDescription}
637
-
638
- ## Risk Tier: ${answers.riskTier === 1 ? 'High (T1)' : answers.riskTier === 2 ? 'Medium (T2)' : 'Low (T3)'}
639
-
640
- ## Next Steps
641
- 1. Review and customize \`.caws/specs/${answers.projectId}.yaml\`
642
- 2. Set up your development environment
643
- 3. Implement features according to the spec
644
- 4. Run \`caws validate --spec-id ${answers.projectId}\` to check your progress
645
-
646
- ## Multi-Agent Recommendation
647
- The initial project spec is also available in \`.caws/specs/${answers.projectId}.yaml\`.
648
- For multi-agent work, treat feature specs in \`.caws/specs/\` as canonical and use
649
- \`.caws/working-spec.yaml\` only as a compatibility mirror:
650
-
651
- \`\`\`bash
652
- caws specs create my-feature --type feature --title "My Feature"
653
- caws validate --spec-id my-feature
654
- \`\`\`
655
-
656
- ## Quality Gates
657
- - **Coverage**: ${answers.riskTier === 1 ? '90%+' : answers.riskTier === 2 ? '80%+' : '70%+'}
658
- - **Mutation Score**: ${answers.riskTier === 1 ? '70%+' : answers.riskTier === 2 ? '50%+' : '30%+'}
659
- - **Review**: ${answers.riskTier === 1 ? 'Manual' : 'Optional'}
660
-
661
- Happy coding! `;
662
-
663
- await fs.writeFile(path.join('.caws', 'getting-started.md'), gettingStartedGuide);
664
- console.log(chalk.green('Created .caws/getting-started.md'));
665
-
666
- // Generate basic directory structure
667
- await fs.ensureDir('tests');
668
- await fs.ensureDir('tests/unit');
669
- await fs.ensureDir('tests/integration');
670
- await fs.ensureDir('tests/e2e');
671
- await fs.ensureDir('docs');
672
- console.log(chalk.green('Created test and docs directories'));
673
- }
674
-
675
- // Setup selected IDE integrations
676
- const selectedIDEs = parseIDESelection(answers.selectedIDEs || []);
677
-
678
- if (selectedIDEs.includes('cursor')) {
679
- console.log(chalk.blue('Setting up Cursor hooks...'));
680
- await scaffoldCursorHooks(process.cwd());
681
- }
682
-
683
- if (selectedIDEs.length > 0) {
684
- console.log(chalk.blue('Setting up IDE integrations...'));
685
- await scaffoldIDEIntegrations(process.cwd(), { force: false, ides: selectedIDEs });
686
- } else {
687
- console.log(chalk.gray('Skipping IDE setup (none selected, run `caws scaffold --ide <ides>` later)'));
688
- }
689
-
690
- // Update .gitignore to exclude CAWS local runtime files
691
- console.log(chalk.blue('Updating .gitignore...'));
692
- const gitignoreUpdated = await updateGitignore(process.cwd());
693
- if (gitignoreUpdated) {
694
- console.log(chalk.green('Updated .gitignore to exclude CAWS local runtime files'));
695
- console.log(
696
- chalk.gray(' Tracked: Specs, policy, waivers, provenance, plans (shared with team)')
697
- );
698
- console.log(chalk.gray(' Ignored: Agent runtime, temp files, logs (local-only)'));
699
- }
700
-
701
- // Finalize project
702
- await finalizeProject(projectName, options, answers);
703
- } else {
704
- // Non-interactive mode - generate basic spec with defaults
705
- console.log(chalk.blue('Generating basic CAWS working spec...'));
706
-
707
- const detectedType = detectProjectType(process.cwd());
708
- const defaultAnswers = {
709
- projectType: detectedType,
710
- projectTitle: path.basename(process.cwd()),
711
- projectDescription: `A ${detectedType} project managed with CAWS`,
712
- riskTier: 2,
713
- projectId: `PROJ-${String(Math.floor(Math.random() * 1000) + 1).padStart(3, '0')}`,
714
- useCursorHooks: true,
715
- generateExamples: false,
716
- projectMode: 'feature',
717
- maxFiles: 25,
718
- maxLoc: 1000,
719
- blastModules: 'src, tests',
720
- dataMigration: false,
721
- rollbackSlo: '5m',
722
- projectThreats: '',
723
- scopeIn: 'src/, tests/',
724
- scopeOut: 'node_modules/, dist/, build/',
725
- projectInvariants: 'System maintains data consistency',
726
- acceptanceCriteria: 'Given current state, when action occurs, then expected result',
727
- a11yRequirements: 'keyboard',
728
- perfBudget: 250,
729
- securityRequirements: 'validation',
730
- contractType: '',
731
- contractPath: '',
732
- observabilityLogs: '',
733
- observabilityMetrics: '',
734
- observabilityTraces: '',
735
- migrationPlan: '',
736
- rollbackPlan: '',
737
- needsOverride: false,
738
- overrideApprover: '',
739
- overrideRationale: '',
740
- waivedGates: [],
741
- overrideExpiresDays: 7,
742
- isExperimental: false,
743
- experimentalRationale: '',
744
- experimentalExpiresDays: 30,
745
- experimentalSandbox: '',
746
- aiConfidence: 0.8,
747
- uncertaintyAreas: '',
748
- complexityFactors: '',
749
- };
750
-
751
- const specContent = generateWorkingSpec(defaultAnswers);
752
- await fs.ensureDir('.caws');
753
- const initialSpec = await writeInitialSpecArtifacts(specContent, defaultAnswers.projectId);
754
- console.log(chalk.green(`Created ${initialSpec.featureSpecPath}`));
755
- console.log(chalk.green('Created .caws/working-spec.yaml'));
756
- console.log(chalk.green('Created .caws/specs/registry.json'));
757
-
758
- // Optionally create policy.yaml (optional - defaults work fine)
759
- const policyPath = path.join('.caws', 'policy.yaml');
760
- if (!fs.existsSync(policyPath)) {
761
- const { PolicyManager } = require('../policy/PolicyManager');
762
- const policyManager = new PolicyManager();
763
- const defaultPolicy = policyManager.getDefaultPolicy();
764
- const policyContent = yaml.dump(defaultPolicy, { indent: 2 });
765
- await fs.writeFile(policyPath, policyContent);
766
- console.log(chalk.green('Created .caws/policy.yaml (optional - defaults work fine)'));
767
- }
768
-
769
- // Setup IDE integrations based on --ide flag or auto-detection
770
- const selectedIDEs = options.ide ? parseIDESelection(options.ide) : getRecommendedIDEs();
771
-
772
- if (selectedIDEs.includes('cursor')) {
773
- console.log(chalk.blue('Setting up Cursor hooks...'));
774
- await scaffoldCursorHooks(process.cwd());
775
- }
776
-
777
- if (selectedIDEs.length > 0) {
778
- console.log(chalk.blue(`Setting up IDE integrations: ${selectedIDEs.map((id) => IDE_REGISTRY[id].name).join(', ')}...`));
779
- await scaffoldIDEIntegrations(process.cwd(), { force: false, ides: selectedIDEs });
780
- }
781
-
782
- // Update .gitignore to exclude CAWS local runtime files
783
- console.log(chalk.blue('Updating .gitignore...'));
784
- const gitignoreUpdated = await updateGitignore(process.cwd());
785
- if (gitignoreUpdated) {
786
- console.log(chalk.green('Updated .gitignore to exclude CAWS local runtime files'));
787
- console.log(
788
- chalk.gray(' Tracked: Specs, policy, waivers, provenance, plans (shared with team)')
789
- );
790
- console.log(chalk.gray(' Ignored: Agent runtime, temp files, logs (local-only)'));
791
- }
792
-
793
- // Finalize project
794
- await finalizeProject(projectName, options, defaultAnswers);
795
- }
796
-
797
- // Success message
798
- console.log(chalk.green('\nCAWS project initialized successfully!'));
799
- console.log(chalk.blue('\nNext steps:'));
800
- console.log('1. Review .caws/specs/<spec-id>.yaml');
801
- console.log('2. Treat .caws/working-spec.yaml as the compatibility mirror, not the long-term source of truth');
802
- console.log('3. If multiple agents will collaborate, create more feature specs with `caws specs create <id>`');
803
- console.log('4. Use `--spec-id` on validation/status/diagnose commands for feature work');
804
-
805
- // Show contract requirements if Tier 1 or 2
806
- // Use answers if available (interactive mode), otherwise default to 2
807
- const riskTier = answers?.riskTier || 2;
808
- if (riskTier === 1 || riskTier === 2) {
809
- console.log(chalk.yellow('\nImportant: Contract Requirements'));
810
- console.log(` Tier ${riskTier} changes require at least one contract.`);
811
- console.log(' For infrastructure/setup work, add a minimal contract:');
812
- console.log(chalk.gray(' contracts:'));
813
- console.log(chalk.gray(' - type: "project_setup"'));
814
- console.log(chalk.gray(' path: ".caws/working-spec.yaml"'));
815
- console.log(chalk.gray(' description: "Project-level CAWS configuration"'));
816
- console.log(' Or use "chore" mode for maintenance work (mode: chore)');
817
- }
818
-
819
- console.log('\nRecommended Setup Workflow:');
820
- console.log(' 1. Review .caws/specs/<spec-id>.yaml');
821
- console.log(' 2. Run: caws scaffold (adds tools and templates)');
822
- console.log(' 3. For multi-agent work, run: caws specs create <feature-id>');
823
- console.log(' 4. Run: caws validate --spec-id <spec-id> (verify setup)');
824
- console.log(' 5. Run: caws diagnose --spec-id <spec-id> (check health)');
825
- console.log(' 6. Optional: Create .caws/policy.yaml for custom budgets');
826
- const finalIDEs = answers?.selectedIDEs || [];
827
- if (finalIDEs.includes('cursor') || finalIDEs.includes('claude') || options.interactive === false) {
828
- console.log(' 7. Restart your IDE to activate quality gates');
829
- }
830
- console.log('\nQuick start: caws scaffold && caws validate && caws diagnose');
831
- console.log('Multi-agent quick start: caws specs create my-feature && caws validate --spec-id my-feature');
832
- } catch (error) {
833
- console.error(chalk.red('Error during initialization:'), error.message);
834
- if (error.stack) {
835
- console.error(chalk.gray(error.stack));
836
- }
837
-
838
- // Cleanup on error (only for new directory creation)
839
- if (projectName && projectName !== '.' && fs.existsSync(projectName)) {
840
- try {
841
- await fs.remove(projectName);
842
- console.log(chalk.green('Cleanup completed'));
843
- } catch (cleanupError) {
844
- console.warn(
845
- chalk.yellow('Could not clean up:'),
846
- cleanupError?.message || cleanupError
847
- );
848
- }
849
- }
850
-
851
- process.exit(1);
852
- }
853
- }
854
-
855
- module.exports = {
856
- initProject,
857
- };