@paths.design/caws-cli 10.2.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/README.md +125 -374
  2. package/dist/index.js +43 -785
  3. package/dist/shell/binding/resolve-binding.d.ts +4 -0
  4. package/dist/shell/binding/resolve-binding.d.ts.map +1 -0
  5. package/dist/shell/binding/resolve-binding.js +228 -0
  6. package/dist/shell/binding/resolve-binding.js.map +1 -0
  7. package/dist/shell/binding/types.d.ts +42 -0
  8. package/dist/shell/binding/types.d.ts.map +1 -0
  9. package/dist/shell/binding/types.js +21 -0
  10. package/dist/shell/binding/types.js.map +1 -0
  11. package/dist/shell/commands/claim.d.ts +14 -0
  12. package/dist/shell/commands/claim.d.ts.map +1 -0
  13. package/dist/shell/commands/claim.js +197 -0
  14. package/dist/shell/commands/claim.js.map +1 -0
  15. package/dist/shell/commands/doctor.d.ts +13 -0
  16. package/dist/shell/commands/doctor.d.ts.map +1 -0
  17. package/dist/shell/commands/doctor.js +97 -0
  18. package/dist/shell/commands/doctor.js.map +1 -0
  19. package/dist/shell/commands/evidence.d.ts +28 -0
  20. package/dist/shell/commands/evidence.d.ts.map +1 -0
  21. package/dist/shell/commands/evidence.js +166 -0
  22. package/dist/shell/commands/evidence.js.map +1 -0
  23. package/dist/shell/commands/gates.d.ts +19 -0
  24. package/dist/shell/commands/gates.d.ts.map +1 -0
  25. package/dist/shell/commands/gates.js +181 -0
  26. package/dist/shell/commands/gates.js.map +1 -0
  27. package/dist/shell/commands/init.d.ts +8 -0
  28. package/dist/shell/commands/init.d.ts.map +1 -0
  29. package/dist/shell/commands/init.js +64 -0
  30. package/dist/shell/commands/init.js.map +1 -0
  31. package/dist/shell/commands/scope.d.ts +11 -0
  32. package/dist/shell/commands/scope.d.ts.map +1 -0
  33. package/dist/shell/commands/scope.js +92 -0
  34. package/dist/shell/commands/scope.js.map +1 -0
  35. package/dist/shell/commands/status.d.ts +15 -0
  36. package/dist/shell/commands/status.d.ts.map +1 -0
  37. package/dist/shell/commands/status.js +106 -0
  38. package/dist/shell/commands/status.js.map +1 -0
  39. package/dist/shell/commands/waiver.d.ts +38 -0
  40. package/dist/shell/commands/waiver.d.ts.map +1 -0
  41. package/dist/shell/commands/waiver.js +240 -0
  42. package/dist/shell/commands/waiver.js.map +1 -0
  43. package/dist/shell/gates/disposition.d.ts +23 -0
  44. package/dist/shell/gates/disposition.d.ts.map +1 -0
  45. package/dist/shell/gates/disposition.js +87 -0
  46. package/dist/shell/gates/disposition.js.map +1 -0
  47. package/dist/shell/gates/gate-result-contract.d.ts +39 -0
  48. package/dist/shell/gates/gate-result-contract.d.ts.map +1 -0
  49. package/dist/shell/gates/gate-result-contract.js +150 -0
  50. package/dist/shell/gates/gate-result-contract.js.map +1 -0
  51. package/dist/shell/gates/quality-gates-adapter.d.ts +55 -0
  52. package/dist/shell/gates/quality-gates-adapter.d.ts.map +1 -0
  53. package/dist/shell/gates/quality-gates-adapter.js +161 -0
  54. package/dist/shell/gates/quality-gates-adapter.js.map +1 -0
  55. package/dist/shell/gates/waiver-filter.d.ts +58 -0
  56. package/dist/shell/gates/waiver-filter.d.ts.map +1 -0
  57. package/dist/shell/gates/waiver-filter.js +119 -0
  58. package/dist/shell/gates/waiver-filter.js.map +1 -0
  59. package/dist/shell/index.d.ts +50 -0
  60. package/dist/shell/index.d.ts.map +1 -0
  61. package/dist/shell/index.js +73 -0
  62. package/dist/shell/index.js.map +1 -0
  63. package/dist/shell/register.d.ts +11 -0
  64. package/dist/shell/register.d.ts.map +1 -0
  65. package/dist/shell/register.js +274 -0
  66. package/dist/shell/register.js.map +1 -0
  67. package/dist/shell/render/claim.d.ts +22 -0
  68. package/dist/shell/render/claim.d.ts.map +1 -0
  69. package/dist/shell/render/claim.js +75 -0
  70. package/dist/shell/render/claim.js.map +1 -0
  71. package/dist/shell/render/decision.d.ts +15 -0
  72. package/dist/shell/render/decision.d.ts.map +1 -0
  73. package/dist/shell/render/decision.js +66 -0
  74. package/dist/shell/render/decision.js.map +1 -0
  75. package/dist/shell/render/diagnostic.d.ts +19 -0
  76. package/dist/shell/render/diagnostic.d.ts.map +1 -0
  77. package/dist/shell/render/diagnostic.js +76 -0
  78. package/dist/shell/render/diagnostic.js.map +1 -0
  79. package/dist/shell/render/finding.d.ts +15 -0
  80. package/dist/shell/render/finding.d.ts.map +1 -0
  81. package/dist/shell/render/finding.js +57 -0
  82. package/dist/shell/render/finding.js.map +1 -0
  83. package/dist/shell/render/gates.d.ts +3 -0
  84. package/dist/shell/render/gates.d.ts.map +1 -0
  85. package/dist/shell/render/gates.js +56 -0
  86. package/dist/shell/render/gates.js.map +1 -0
  87. package/dist/shell/render/init.d.ts +11 -0
  88. package/dist/shell/render/init.d.ts.map +1 -0
  89. package/dist/shell/render/init.js +32 -0
  90. package/dist/shell/render/init.js.map +1 -0
  91. package/dist/shell/render/status.d.ts +26 -0
  92. package/dist/shell/render/status.d.ts.map +1 -0
  93. package/dist/shell/render/status.js +143 -0
  94. package/dist/shell/render/status.js.map +1 -0
  95. package/dist/shell/render/waiver.d.ts +21 -0
  96. package/dist/shell/render/waiver.d.ts.map +1 -0
  97. package/dist/shell/render/waiver.js +94 -0
  98. package/dist/shell/render/waiver.js.map +1 -0
  99. package/dist/shell/rules.d.ts +37 -0
  100. package/dist/shell/rules.d.ts.map +1 -0
  101. package/dist/shell/rules.js +51 -0
  102. package/dist/shell/rules.js.map +1 -0
  103. package/dist/shell/session/actor.d.ts +14 -0
  104. package/dist/shell/session/actor.d.ts.map +1 -0
  105. package/dist/shell/session/actor.js +34 -0
  106. package/dist/shell/session/actor.js.map +1 -0
  107. package/dist/shell/session/resolve-session.d.ts +5 -0
  108. package/dist/shell/session/resolve-session.d.ts.map +1 -0
  109. package/dist/shell/session/resolve-session.js +239 -0
  110. package/dist/shell/session/resolve-session.js.map +1 -0
  111. package/dist/shell/session/types.d.ts +56 -0
  112. package/dist/shell/session/types.d.ts.map +1 -0
  113. package/dist/shell/session/types.js +15 -0
  114. package/dist/shell/session/types.js.map +1 -0
  115. package/dist/store/agents-store.d.ts +3 -0
  116. package/dist/store/agents-store.d.ts.map +1 -0
  117. package/dist/store/agents-store.js +63 -0
  118. package/dist/store/agents-store.js.map +1 -0
  119. package/dist/store/apply-patch.d.ts +16 -0
  120. package/dist/store/apply-patch.d.ts.map +1 -0
  121. package/dist/store/apply-patch.js +191 -0
  122. package/dist/store/apply-patch.js.map +1 -0
  123. package/dist/store/atomic-write.d.ts +16 -0
  124. package/dist/store/atomic-write.d.ts.map +1 -0
  125. package/dist/store/atomic-write.js +132 -0
  126. package/dist/store/atomic-write.js.map +1 -0
  127. package/dist/store/doctor-snapshot.d.ts +20 -0
  128. package/dist/store/doctor-snapshot.d.ts.map +1 -0
  129. package/dist/store/doctor-snapshot.js +176 -0
  130. package/dist/store/doctor-snapshot.js.map +1 -0
  131. package/dist/store/events-store.d.ts +33 -0
  132. package/dist/store/events-store.d.ts.map +1 -0
  133. package/dist/store/events-store.js +297 -0
  134. package/dist/store/events-store.js.map +1 -0
  135. package/dist/store/index.d.ts +21 -0
  136. package/dist/store/index.d.ts.map +1 -0
  137. package/dist/store/index.js +47 -0
  138. package/dist/store/index.js.map +1 -0
  139. package/dist/store/init-store.d.ts +21 -0
  140. package/dist/store/init-store.d.ts.map +1 -0
  141. package/dist/store/init-store.js +295 -0
  142. package/dist/store/init-store.js.map +1 -0
  143. package/dist/store/json-store.d.ts +3 -0
  144. package/dist/store/json-store.d.ts.map +1 -0
  145. package/dist/store/json-store.js +65 -0
  146. package/dist/store/json-store.js.map +1 -0
  147. package/dist/store/policy-store.d.ts +3 -0
  148. package/dist/store/policy-store.d.ts.map +1 -0
  149. package/dist/store/policy-store.js +65 -0
  150. package/dist/store/policy-store.js.map +1 -0
  151. package/dist/store/repo-root.d.ts +46 -0
  152. package/dist/store/repo-root.d.ts.map +1 -0
  153. package/dist/store/repo-root.js +145 -0
  154. package/dist/store/repo-root.js.map +1 -0
  155. package/dist/store/rules.d.ts +53 -0
  156. package/dist/store/rules.d.ts.map +1 -0
  157. package/dist/store/rules.js +78 -0
  158. package/dist/store/rules.js.map +1 -0
  159. package/dist/store/specs-store.d.ts +3 -0
  160. package/dist/store/specs-store.d.ts.map +1 -0
  161. package/dist/store/specs-store.js +131 -0
  162. package/dist/store/specs-store.js.map +1 -0
  163. package/dist/store/types.d.ts +84 -0
  164. package/dist/store/types.d.ts.map +1 -0
  165. package/dist/store/types.js +14 -0
  166. package/dist/store/types.js.map +1 -0
  167. package/dist/store/waivers-store.d.ts +25 -0
  168. package/dist/store/waivers-store.d.ts.map +1 -0
  169. package/dist/store/waivers-store.js +232 -0
  170. package/dist/store/waivers-store.js.map +1 -0
  171. package/dist/store/worktrees-store.d.ts +3 -0
  172. package/dist/store/worktrees-store.d.ts.map +1 -0
  173. package/dist/store/worktrees-store.js +62 -0
  174. package/dist/store/worktrees-store.js.map +1 -0
  175. package/dist/store/yaml-store.d.ts +9 -0
  176. package/dist/store/yaml-store.d.ts.map +1 -0
  177. package/dist/store/yaml-store.js +121 -0
  178. package/dist/store/yaml-store.js.map +1 -0
  179. package/package.json +15 -13
  180. package/dist/budget-derivation.js +0 -751
  181. package/dist/cicd-optimizer.js +0 -504
  182. package/dist/commands/agents.js +0 -124
  183. package/dist/commands/archive.js +0 -500
  184. package/dist/commands/burnup.js +0 -198
  185. package/dist/commands/diagnose.js +0 -525
  186. package/dist/commands/evaluate.js +0 -314
  187. package/dist/commands/gates.js +0 -149
  188. package/dist/commands/init.js +0 -857
  189. package/dist/commands/iterate.js +0 -417
  190. package/dist/commands/mode.js +0 -269
  191. package/dist/commands/parallel.js +0 -242
  192. package/dist/commands/plan.js +0 -438
  193. package/dist/commands/provenance.js +0 -1143
  194. package/dist/commands/quality-monitor.js +0 -284
  195. package/dist/commands/scope.js +0 -264
  196. package/dist/commands/session.js +0 -312
  197. package/dist/commands/sidecar.js +0 -74
  198. package/dist/commands/specs.js +0 -1656
  199. package/dist/commands/status.js +0 -1172
  200. package/dist/commands/templates.js +0 -237
  201. package/dist/commands/tool.js +0 -136
  202. package/dist/commands/tutorial.js +0 -480
  203. package/dist/commands/validate.js +0 -357
  204. package/dist/commands/verify-acs.js +0 -443
  205. package/dist/commands/waivers.js +0 -599
  206. package/dist/commands/workflow.js +0 -243
  207. package/dist/commands/worktree.js +0 -502
  208. package/dist/config/lite-scope.js +0 -158
  209. package/dist/config/modes.js +0 -347
  210. package/dist/constants/spec-types.js +0 -65
  211. package/dist/gates/budget-limit.js +0 -121
  212. package/dist/gates/feedback.js +0 -260
  213. package/dist/gates/format.js +0 -179
  214. package/dist/gates/god-object.js +0 -117
  215. package/dist/gates/pipeline.js +0 -167
  216. package/dist/gates/scope-boundary.js +0 -112
  217. package/dist/gates/spec-completeness.js +0 -109
  218. package/dist/gates/todo-detection.js +0 -205
  219. package/dist/generators/jest-config-generator.js +0 -242
  220. package/dist/generators/working-spec.js +0 -237
  221. package/dist/minimal-cli.js +0 -88
  222. package/dist/parallel/parallel-manager.js +0 -433
  223. package/dist/policy/PolicyManager.js +0 -470
  224. package/dist/scaffold/claude-hooks.js +0 -443
  225. package/dist/scaffold/cursor-hooks.js +0 -177
  226. package/dist/scaffold/git-hooks.js +0 -928
  227. package/dist/scaffold/index.js +0 -794
  228. package/dist/session/session-manager.js +0 -653
  229. package/dist/sidecars/index.js +0 -33
  230. package/dist/sidecars/listeners.js +0 -40
  231. package/dist/sidecars/provenance-summary.js +0 -238
  232. package/dist/sidecars/quality-gaps.js +0 -258
  233. package/dist/sidecars/schema.js +0 -149
  234. package/dist/sidecars/spec-drift.js +0 -151
  235. package/dist/sidecars/waiver-draft.js +0 -176
  236. package/dist/spec/SpecFileManager.js +0 -419
  237. package/dist/templates/.caws/schemas/policy.schema.json +0 -117
  238. package/dist/templates/.caws/schemas/scope.schema.json +0 -52
  239. package/dist/templates/.caws/schemas/waivers.schema.json +0 -106
  240. package/dist/templates/.caws/schemas/working-spec.schema.json +0 -340
  241. package/dist/templates/.caws/schemas/worktrees.schema.json +0 -38
  242. package/dist/templates/.caws/templates/working-spec.template.yml +0 -80
  243. package/dist/templates/.caws/tools/README.md +0 -18
  244. package/dist/templates/.caws/tools/scope-guard.js +0 -203
  245. package/dist/templates/.caws/tools-allow.json +0 -331
  246. package/dist/templates/.caws/waivers.yml +0 -19
  247. package/dist/templates/.claude/README.md +0 -190
  248. package/dist/templates/.claude/hooks/audit.sh +0 -121
  249. package/dist/templates/.claude/hooks/block-dangerous.sh +0 -203
  250. package/dist/templates/.claude/hooks/classify_command.py +0 -592
  251. package/dist/templates/.claude/hooks/doc-frontmatter-check.sh +0 -173
  252. package/dist/templates/.claude/hooks/lite-sprawl-check.sh +0 -145
  253. package/dist/templates/.claude/hooks/naming-check.sh +0 -100
  254. package/dist/templates/.claude/hooks/protected-paths.sh +0 -39
  255. package/dist/templates/.claude/hooks/quality-check.sh +0 -81
  256. package/dist/templates/.claude/hooks/scan-secrets.sh +0 -85
  257. package/dist/templates/.claude/hooks/scope-guard.sh +0 -381
  258. package/dist/templates/.claude/hooks/session-caws-status.sh +0 -117
  259. package/dist/templates/.claude/hooks/session-log.sh +0 -634
  260. package/dist/templates/.claude/hooks/simplification-guard.sh +0 -92
  261. package/dist/templates/.claude/hooks/stop-worktree-check.sh +0 -46
  262. package/dist/templates/.claude/hooks/test_classify_command.py +0 -370
  263. package/dist/templates/.claude/hooks/test_wrapper_smoke.sh +0 -96
  264. package/dist/templates/.claude/hooks/validate-spec.sh +0 -76
  265. package/dist/templates/.claude/hooks/worktree-guard.sh +0 -220
  266. package/dist/templates/.claude/hooks/worktree-write-guard.sh +0 -190
  267. package/dist/templates/.claude/rules/git-safety.md +0 -26
  268. package/dist/templates/.claude/rules/worktree-isolation.md +0 -101
  269. package/dist/templates/.claude/settings.json +0 -141
  270. package/dist/templates/.cursor/README.md +0 -299
  271. package/dist/templates/.cursor/hooks/audit.sh +0 -55
  272. package/dist/templates/.cursor/hooks/block-dangerous.sh +0 -84
  273. package/dist/templates/.cursor/hooks/caws-quality-check.sh +0 -52
  274. package/dist/templates/.cursor/hooks/caws-scope-guard.sh +0 -130
  275. package/dist/templates/.cursor/hooks/format.sh +0 -38
  276. package/dist/templates/.cursor/hooks/naming-check.sh +0 -64
  277. package/dist/templates/.cursor/hooks/scan-secrets.sh +0 -51
  278. package/dist/templates/.cursor/hooks/scope-guard.sh +0 -52
  279. package/dist/templates/.cursor/hooks/session-log.sh +0 -924
  280. package/dist/templates/.cursor/hooks/validate-spec.sh +0 -83
  281. package/dist/templates/.cursor/hooks.json +0 -76
  282. package/dist/templates/.cursor/rules/00-claims-verification.mdc +0 -144
  283. package/dist/templates/.cursor/rules/01-working-style.mdc +0 -50
  284. package/dist/templates/.cursor/rules/02-quality-gates.mdc +0 -368
  285. package/dist/templates/.cursor/rules/03-naming-and-refactor.mdc +0 -33
  286. package/dist/templates/.cursor/rules/04-logging-language-style.mdc +0 -23
  287. package/dist/templates/.cursor/rules/05-safe-defaults-guards.mdc +0 -23
  288. package/dist/templates/.cursor/rules/06-typescript-conventions.mdc +0 -36
  289. package/dist/templates/.cursor/rules/07-process-ops.mdc +0 -20
  290. package/dist/templates/.cursor/rules/08-solid-and-architecture.mdc +0 -16
  291. package/dist/templates/.cursor/rules/09-docstrings.mdc +0 -89
  292. package/dist/templates/.cursor/rules/10-documentation-quality-standards.mdc +0 -385
  293. package/dist/templates/.cursor/rules/11-scope-management-waivers.mdc +0 -381
  294. package/dist/templates/.cursor/rules/12-implementation-completeness.mdc +0 -516
  295. package/dist/templates/.cursor/rules/13-language-agnostic-standards.mdc +0 -578
  296. package/dist/templates/.cursor/rules/README.md +0 -148
  297. package/dist/templates/.github/copilot-instructions.md +0 -82
  298. package/dist/templates/.idea/runConfigurations/CAWS_Evaluate.xml +0 -5
  299. package/dist/templates/.idea/runConfigurations/CAWS_Validate.xml +0 -5
  300. package/dist/templates/.junie/guidelines.md +0 -73
  301. package/dist/templates/.vscode/launch.json +0 -17
  302. package/dist/templates/.vscode/settings.json +0 -95
  303. package/dist/templates/.windsurf/rules/caws-quality-standards.md +0 -54
  304. package/dist/templates/.windsurf/workflows/caws-guided-development.md +0 -92
  305. package/dist/templates/CLAUDE.md +0 -196
  306. package/dist/templates/COMMIT_CONVENTIONS.md +0 -86
  307. package/dist/templates/OIDC_SETUP.md +0 -300
  308. package/dist/templates/agents.md +0 -171
  309. package/dist/templates/codemod/README.md +0 -1
  310. package/dist/templates/codemod/test.js +0 -93
  311. package/dist/templates/docs/README.md +0 -151
  312. package/dist/templates/scripts/new_feature.sh +0 -80
  313. package/dist/templates/scripts/quality-gates/check-god-objects.js +0 -146
  314. package/dist/templates/scripts/quality-gates/run-quality-gates.js +0 -50
  315. package/dist/templates/scripts/v3/analysis/todo_analyzer.py +0 -1997
  316. package/dist/test-analysis.js +0 -786
  317. package/dist/tool-interface.js +0 -314
  318. package/dist/tool-loader.js +0 -303
  319. package/dist/tool-validator.js +0 -393
  320. package/dist/utils/agent-display.js +0 -210
  321. package/dist/utils/agent-session.js +0 -344
  322. package/dist/utils/async-utils.js +0 -188
  323. package/dist/utils/command-wrapper.js +0 -200
  324. package/dist/utils/event-log.js +0 -584
  325. package/dist/utils/event-renderer.js +0 -521
  326. package/dist/utils/finalization.js +0 -230
  327. package/dist/utils/git-lock.js +0 -119
  328. package/dist/utils/gitignore-updater.js +0 -158
  329. package/dist/utils/ide-detection.js +0 -133
  330. package/dist/utils/lifecycle-events.js +0 -94
  331. package/dist/utils/project-analysis.js +0 -367
  332. package/dist/utils/promise-utils.js +0 -72
  333. package/dist/utils/quality-gates-errors.js +0 -520
  334. package/dist/utils/quality-gates-utils.js +0 -387
  335. package/dist/utils/schema-validator.js +0 -50
  336. package/dist/utils/spec-resolver.js +0 -711
  337. package/dist/utils/typescript-detector.js +0 -369
  338. package/dist/utils/working-state.js +0 -530
  339. package/dist/utils/yaml-validation.js +0 -156
  340. package/dist/validation/spec-validation.js +0 -924
  341. package/dist/waivers-manager.js +0 -732
  342. package/dist/worktree/worktree-manager.js +0 -1735
  343. package/templates/.caws/schemas/policy.schema.json +0 -117
  344. package/templates/.caws/schemas/scope.schema.json +0 -52
  345. package/templates/.caws/schemas/waivers.schema.json +0 -106
  346. package/templates/.caws/schemas/working-spec.schema.json +0 -340
  347. package/templates/.caws/schemas/worktrees.schema.json +0 -38
  348. package/templates/.caws/templates/working-spec.template.yml +0 -80
  349. package/templates/.caws/tools/README.md +0 -18
  350. package/templates/.caws/tools/scope-guard.js +0 -203
  351. package/templates/.caws/tools-allow.json +0 -331
  352. package/templates/.caws/waivers.yml +0 -19
  353. package/templates/.claude/README.md +0 -190
  354. package/templates/.claude/hooks/audit.sh +0 -121
  355. package/templates/.claude/hooks/block-dangerous.sh +0 -203
  356. package/templates/.claude/hooks/classify_command.py +0 -592
  357. package/templates/.claude/hooks/doc-frontmatter-check.sh +0 -173
  358. package/templates/.claude/hooks/lite-sprawl-check.sh +0 -145
  359. package/templates/.claude/hooks/naming-check.sh +0 -100
  360. package/templates/.claude/hooks/protected-paths.sh +0 -39
  361. package/templates/.claude/hooks/quality-check.sh +0 -81
  362. package/templates/.claude/hooks/scan-secrets.sh +0 -85
  363. package/templates/.claude/hooks/scope-guard.sh +0 -381
  364. package/templates/.claude/hooks/session-caws-status.sh +0 -117
  365. package/templates/.claude/hooks/session-log.sh +0 -634
  366. package/templates/.claude/hooks/simplification-guard.sh +0 -92
  367. package/templates/.claude/hooks/stop-worktree-check.sh +0 -46
  368. package/templates/.claude/hooks/test_classify_command.py +0 -370
  369. package/templates/.claude/hooks/test_wrapper_smoke.sh +0 -96
  370. package/templates/.claude/hooks/validate-spec.sh +0 -76
  371. package/templates/.claude/hooks/worktree-guard.sh +0 -220
  372. package/templates/.claude/hooks/worktree-write-guard.sh +0 -190
  373. package/templates/.claude/rules/git-safety.md +0 -26
  374. package/templates/.claude/rules/worktree-isolation.md +0 -101
  375. package/templates/.claude/settings.json +0 -141
  376. package/templates/.cursor/README.md +0 -299
  377. package/templates/.cursor/hooks/audit.sh +0 -55
  378. package/templates/.cursor/hooks/block-dangerous.sh +0 -84
  379. package/templates/.cursor/hooks/caws-quality-check.sh +0 -52
  380. package/templates/.cursor/hooks/caws-scope-guard.sh +0 -130
  381. package/templates/.cursor/hooks/format.sh +0 -38
  382. package/templates/.cursor/hooks/naming-check.sh +0 -64
  383. package/templates/.cursor/hooks/scan-secrets.sh +0 -51
  384. package/templates/.cursor/hooks/scope-guard.sh +0 -52
  385. package/templates/.cursor/hooks/session-log.sh +0 -924
  386. package/templates/.cursor/hooks/validate-spec.sh +0 -83
  387. package/templates/.cursor/hooks.json +0 -76
  388. package/templates/.cursor/rules/00-claims-verification.mdc +0 -144
  389. package/templates/.cursor/rules/01-working-style.mdc +0 -50
  390. package/templates/.cursor/rules/02-quality-gates.mdc +0 -368
  391. package/templates/.cursor/rules/03-naming-and-refactor.mdc +0 -33
  392. package/templates/.cursor/rules/04-logging-language-style.mdc +0 -23
  393. package/templates/.cursor/rules/05-safe-defaults-guards.mdc +0 -23
  394. package/templates/.cursor/rules/06-typescript-conventions.mdc +0 -36
  395. package/templates/.cursor/rules/07-process-ops.mdc +0 -20
  396. package/templates/.cursor/rules/08-solid-and-architecture.mdc +0 -16
  397. package/templates/.cursor/rules/09-docstrings.mdc +0 -89
  398. package/templates/.cursor/rules/10-documentation-quality-standards.mdc +0 -385
  399. package/templates/.cursor/rules/11-scope-management-waivers.mdc +0 -381
  400. package/templates/.cursor/rules/12-implementation-completeness.mdc +0 -516
  401. package/templates/.cursor/rules/13-language-agnostic-standards.mdc +0 -578
  402. package/templates/.cursor/rules/README.md +0 -148
  403. package/templates/.github/copilot-instructions.md +0 -82
  404. package/templates/.idea/runConfigurations/CAWS_Evaluate.xml +0 -5
  405. package/templates/.idea/runConfigurations/CAWS_Validate.xml +0 -5
  406. package/templates/.junie/guidelines.md +0 -73
  407. package/templates/.vscode/launch.json +0 -17
  408. package/templates/.vscode/settings.json +0 -95
  409. package/templates/.windsurf/rules/caws-quality-standards.md +0 -54
  410. package/templates/.windsurf/workflows/caws-guided-development.md +0 -92
  411. package/templates/CLAUDE.md +0 -196
  412. package/templates/COMMIT_CONVENTIONS.md +0 -86
  413. package/templates/OIDC_SETUP.md +0 -300
  414. package/templates/agents.md +0 -171
  415. package/templates/codemod/README.md +0 -1
  416. package/templates/codemod/test.js +0 -93
  417. package/templates/docs/README.md +0 -151
  418. package/templates/scripts/new_feature.sh +0 -80
  419. package/templates/scripts/quality-gates/check-god-objects.js +0 -146
  420. package/templates/scripts/quality-gates/run-quality-gates.js +0 -50
  421. 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
- };