@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-binding.js","sourceRoot":"","sources":["../../../src/shell/binding/resolve-binding.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,6DAA6D;AAC7D,EAAE;AACF,aAAa;AACb,EAAE;AACF,yEAAyE;AACzE,sEAAsE;AACtE,qEAAqE;AACrE,0EAA0E;AAC1E,4EAA4E;AAC5E,uEAAuE;AACvE,iCAAiC;AACjC,qEAAqE;AACrE,2EAA2E;AAC3E,gEAAgE;AAChE,yEAAyE;AACzE,mEAAmE;AACnE,0EAA0E;AAC1E,sEAAsE;AACtE,uDAAuD;AACvD,EAAE;AACF,kEAAkE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsClE,wDAqCC;AA6BD,wCA2FC;AAjMD,4CAA8B;AAC9B,gDAAkC;AAClC,2DAA+C;AAE/C,2DAA+D;AAQ/D,SAAS,YAAY,CAAC,CAAS;IAC7B,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;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EAAE,MAAM,CAAC;IACtC,IAAI,OAAO,cAAc,KAAK,QAAQ,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtE,kEAAkE;QAClE,8DAA8D;QAC9D,oEAAoE;QACpE,4DAA4D;QAC5D,kEAAkE;QAClE,yCAAyC;QACzC,OAAO;YACL,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;YAC5B,YAAY,EAAE,SAAS,CAAC,IAAI;YAC5B,MAAM;SACP,CAAC;IACJ,CAAC;IAED,wEAAwE;IACxE,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,CAAC;IACnE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,mEAAmE;QACnE,qEAAqE;QACrE,OAAO;YACL,OAAO,EAAE;gBACP,IAAI,EAAE,WAAW;gBACjB,MAAM,EAAE;oBACN,eAAe,EAAE,KAAK;oBACtB,iBAAiB,EAAE,IAAI;oBACvB,cAAc;oBACd,YAAY,EAAE,SAAS,CAAC,IAAI;iBAC7B;aACF;YACD,YAAY,EAAE,SAAS,CAAC,IAAI;YAC5B,MAAM;SACP,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAA,gCAAkB,EAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC;QACtE,YAAY,EAAE,SAAS,CAAC,IAAI;QAC5B,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { BindingState, Spec, WorktreeRegistry } from '@paths.design/caws-kernel';
2
+ export interface ResolveBindingInput {
3
+ /** Repo root (from store/repo-root.ts, --git-common-dir based). */
4
+ readonly repoRoot: string;
5
+ /** Current working directory the command was invoked from. */
6
+ readonly cwd: string;
7
+ /** Loaded `.caws/worktrees.json`. */
8
+ readonly registry: WorktreeRegistry;
9
+ /**
10
+ * Loaded valid specs. The resolver looks up the spec referenced by the
11
+ * registry entry's `specId`. If the spec is missing, the binding is
12
+ * reported as `one_sided`.
13
+ */
14
+ readonly specs: readonly Spec[];
15
+ /**
16
+ * Optional pluggable git-worktree lookup, for tests. Receives `repoRoot`
17
+ * and returns a list of `{ name?, path }` entries OR `null` when git
18
+ * cannot be invoked. Production injects a real git runner.
19
+ */
20
+ readonly gitWorktreeList?: (repoRoot: string) => readonly GitWorktreeEntry[];
21
+ }
22
+ export interface GitWorktreeEntry {
23
+ /** Absolute path of the worktree on disk. */
24
+ readonly path: string;
25
+ /** Branch name (may be `(detached)` or `refs/heads/<x>`). */
26
+ readonly branch?: string;
27
+ }
28
+ export interface ResolvedBinding {
29
+ /** The kernel's `BindingState`. */
30
+ readonly binding: BindingState;
31
+ /**
32
+ * The resolved worktree name, if any. `undefined` when cwd is in the main
33
+ * checkout (no worktree).
34
+ */
35
+ readonly worktreeName?: string;
36
+ /**
37
+ * Where the worktree-name resolution came from. Helps explain `bound`
38
+ * vs `one_sided` decisions to the user.
39
+ */
40
+ readonly source: 'registry_path_match' | 'git_porcelain_match' | 'none';
41
+ }
42
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shell/binding/types.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,YAAY,EACZ,IAAI,EACJ,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,SAAS,gBAAgB,EAAE,CAAC;CAC9E;AAED,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,qBAAqB,GAAG,qBAAqB,GAAG,MAAM,CAAC;CACzE"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // Types for cwd → worktree binding resolution.
3
+ //
4
+ // The shell turns a `(repoRoot, cwd, worktreesRegistry, specs)` tuple into
5
+ // one of three terminal states:
6
+ //
7
+ // - `bound`: cwd is inside a worktree that is bidirectionally bound
8
+ // to a spec (registry.specId === spec.worktree === name).
9
+ // - `one_sided`: cwd is inside a worktree whose binding is partial. The
10
+ // shell reports this verbatim from the kernel; it is NOT
11
+ // authority.
12
+ // - `unbound`: cwd is not inside a CAWS-tracked worktree (or is inside
13
+ // the main checkout). Hooks treat this as no-authority
14
+ // for write-class operations.
15
+ //
16
+ // The shell never derives worktree name from `basename(cwd)`. Authority
17
+ // flows from the registry's recorded `path` field (or a git-worktree
18
+ // porcelain lookup as a deterministic fallback), never from the
19
+ // filesystem layout alone.
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shell/binding/types.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,gCAAgC;AAChC,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,2EAA2E;AAC3E,+BAA+B;AAC/B,4EAA4E;AAC5E,yEAAyE;AACzE,gDAAgD;AAChD,EAAE;AACF,wEAAwE;AACxE,qEAAqE;AACrE,gEAAgE;AAChE,2BAA2B"}
@@ -0,0 +1,14 @@
1
+ export interface ClaimCommandOptions {
2
+ readonly takeover?: boolean;
3
+ readonly cwd?: string;
4
+ readonly now?: () => Date;
5
+ readonly env?: NodeJS.ProcessEnv;
6
+ readonly out?: (line: string) => void;
7
+ readonly err?: (line: string) => void;
8
+ /** Heartbeat-stale TTL in ms; display only. Default 24h. */
9
+ readonly staleTtlMs?: number;
10
+ /** Show optional `data` block on rendered diagnostics. */
11
+ readonly showData?: boolean;
12
+ }
13
+ export declare function runClaimCommand(opts?: ClaimCommandOptions): number;
14
+ //# sourceMappingURL=claim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../../src/shell/commands/claim.ts"],"names":[],"mappings":"AAwDA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,eAAe,CAAC,IAAI,GAAE,mBAAwB,GAAG,MAAM,CA0KtE"}
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ // `caws claim [--takeover]` — surface and (optionally) acquire ownership
3
+ // of the current worktree.
4
+ //
5
+ // Pipeline:
6
+ // 1. resolveRepoRoot(cwd)
7
+ // 2. composeStoreSnapshot (worktrees + agents + specs)
8
+ // 3. resolveSession({ allowMint: true }) — write op, mints if needed
9
+ // 4. resolveBinding(cwd, registry, specs) — identify the worktree
10
+ // 5. kernel.assertOwnership(registry, name, session, { takeover }, now)
11
+ // → Ok(null) — same-session, no patch
12
+ // → Ok(takeover_claim) — foreign + --takeover; prior_owners audit
13
+ // → Err — foreign without --takeover, OR unowned
14
+ // (unowned is a soft block; caller must use
15
+ // `caws worktree create`/`bind` to mint)
16
+ // 6. If a patch was returned, applyRegistryPatch (atomic write to
17
+ // worktrees.json). prior_owners is append-only.
18
+ // 7. ALWAYS refresh agents.json freshness for the current session
19
+ // via kernel.refreshAgentClaim → applyRegistryPatch.
20
+ // 8. Render the Claim panel.
21
+ //
22
+ // Exit codes:
23
+ // 0 = ownership is established for the current session (same-session
24
+ // Ok or successful takeover)
25
+ // 1 = foreign owner without --takeover, or unowned worktree, or kernel
26
+ // refused for any reason
27
+ // 2 = repo-root / session / store composition failure, or cwd is not
28
+ // inside a tracked worktree
29
+ //
30
+ // Authority discipline (load-bearing):
31
+ // - worktrees.json[name].owner is the SOLE ownership authority.
32
+ // - agents.json last-active is freshness/display only.
33
+ // - Stale heartbeat is NOT abandonment.
34
+ // - prior_owners is unbounded, append-only on takeover.
35
+ //
36
+ // Event emission is OUT OF SCOPE for 6a. The `claim_taken_over` event
37
+ // type exists in the kernel schema, but emitting it requires deciding
38
+ // the exact payload shape, and that decision belongs with the broader
39
+ // claim/worktree event work in a later slice. Same-session refresh
40
+ // emits nothing.
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.runClaimCommand = runClaimCommand;
43
+ const caws_kernel_1 = require("@paths.design/caws-kernel");
44
+ const store_1 = require("../../store");
45
+ const resolve_binding_1 = require("../binding/resolve-binding");
46
+ const claim_1 = require("../render/claim");
47
+ const diagnostic_1 = require("../render/diagnostic");
48
+ const resolve_session_1 = require("../session/resolve-session");
49
+ function runClaimCommand(opts = {}) {
50
+ const cwd = opts.cwd ?? process.cwd();
51
+ const nowFn = opts.now ?? (() => new Date());
52
+ const env = opts.env ?? process.env;
53
+ const out = opts.out ?? ((s) => process.stdout.write(s + '\n'));
54
+ const err = opts.err ?? ((s) => process.stderr.write(s + '\n'));
55
+ const showData = opts.showData === true;
56
+ const wantsTakeover = opts.takeover === true;
57
+ // 1. Repo root.
58
+ const repoRootResult = (0, store_1.resolveRepoRoot)(cwd);
59
+ if (!repoRootResult.ok) {
60
+ err('caws claim: failed to resolve repo root.');
61
+ err((0, diagnostic_1.renderDiagnostics)(repoRootResult.errors, { showData }));
62
+ return 2;
63
+ }
64
+ const { repoRoot, cawsDir } = repoRootResult.value;
65
+ // 2. Snapshot (we want both worktrees AND agents).
66
+ let snapshot;
67
+ try {
68
+ snapshot = (0, store_1.composeStoreSnapshot)({ repoRoot, cawsDir });
69
+ }
70
+ catch (e) {
71
+ err(`caws claim: store composition failed: ${e.message}`);
72
+ return 2;
73
+ }
74
+ // 3. Session (write op → mint if missing).
75
+ const sessionResult = (0, resolve_session_1.resolveSession)({
76
+ cawsDir,
77
+ worktreeRoot: cwd,
78
+ env,
79
+ now: nowFn,
80
+ allowMint: true,
81
+ });
82
+ if (!sessionResult.ok) {
83
+ err('caws claim: failed to resolve session identity.');
84
+ err((0, diagnostic_1.renderDiagnostics)(sessionResult.errors, { showData }));
85
+ return 2;
86
+ }
87
+ const session = sessionResult.value.identity;
88
+ // 4. Binding from cwd.
89
+ const bound = (0, resolve_binding_1.resolveBinding)({
90
+ repoRoot,
91
+ cwd,
92
+ registry: snapshot.worktrees,
93
+ specs: snapshot.specs,
94
+ });
95
+ if (bound.worktreeName === undefined) {
96
+ err('caws claim: cwd is not inside a CAWS-tracked worktree. ' +
97
+ 'v11.0.0 does not ship worktree lifecycle commands; create the ' +
98
+ 'worktree externally (git worktree add) and register it via ' +
99
+ 'a future `caws worktree` command (planned for v11.1). To use ' +
100
+ 'lifecycle commands today, pin to caws-cli@^10.2.x.');
101
+ return 2;
102
+ }
103
+ const worktreeName = bound.worktreeName;
104
+ const record = snapshot.worktrees[worktreeName];
105
+ if (record === undefined) {
106
+ // This should not happen if resolveBinding said we are in a tracked
107
+ // worktree — but be defensive: if the registry lost the entry
108
+ // between the bound resolution and now, treat as a composition error.
109
+ err(`caws claim: worktree '${worktreeName}' not in worktrees.json (registry race).`);
110
+ return 2;
111
+ }
112
+ // 5. Kernel ownership decision.
113
+ const now = nowFn();
114
+ const ownershipResult = (0, caws_kernel_1.assertOwnership)(snapshot.worktrees, worktreeName, session, { takeover: wantsTakeover }, now);
115
+ // 6. Apply takeover patch if the kernel emitted one. assertOwnership
116
+ // never silently mints unowned-→-owned; if the kernel refused, we
117
+ // surface that as exit 1.
118
+ if (!ownershipResult.ok) {
119
+ err('caws claim: ownership refused.');
120
+ err((0, diagnostic_1.renderDiagnostics)(ownershipResult.errors, { showData }));
121
+ // Show the current claim panel so the caller can see who holds it.
122
+ const ownerLine = (0, claim_1.renderClaimPanel)({
123
+ worktreeName,
124
+ worktreeRecord: record,
125
+ ...(record.owner !== undefined && snapshot.agents[record.owner.session_id] !== undefined
126
+ ? { agentRecord: snapshot.agents[record.owner.session_id] }
127
+ : {}),
128
+ currentSession: session,
129
+ now,
130
+ ...(opts.staleTtlMs !== undefined ? { staleTtlMs: opts.staleTtlMs } : {}),
131
+ });
132
+ err('');
133
+ err(ownerLine);
134
+ return 1;
135
+ }
136
+ const patch = ownershipResult.value;
137
+ if (patch !== null) {
138
+ // Patch must be a takeover_claim (the kernel only emits null or a
139
+ // takeover_claim from assertOwnership). Apply it.
140
+ const applyResult = (0, store_1.applyRegistryPatch)(cawsDir, patch);
141
+ if (!applyResult.ok) {
142
+ err('caws claim: failed to apply takeover patch.');
143
+ err((0, diagnostic_1.renderDiagnostics)(applyResult.errors, { showData }));
144
+ return 2;
145
+ }
146
+ }
147
+ // 7. Refresh agents.json — even when ownership was already ours.
148
+ // Visible references to lifecycle verbs refresh agents.json so
149
+ // freshness display stays current independent of IDE hooks.
150
+ // refreshAgentClaim only fails on a malformed session shape; we
151
+ // just validated this session via resolveSession, so Err here
152
+ // would be a real bug. Treat it as exit 2.
153
+ const refreshResult = (0, caws_kernel_1.refreshAgentClaim)(snapshot.agents, session, now, {
154
+ bound_worktree: worktreeName,
155
+ ...(record.specId !== undefined ? { bound_spec_id: record.specId } : {}),
156
+ });
157
+ if (!refreshResult.ok) {
158
+ err('caws claim: internal — refreshAgentClaim returned Err with a validated session.');
159
+ err((0, diagnostic_1.renderDiagnostics)(refreshResult.errors, { showData }));
160
+ return 2;
161
+ }
162
+ const refreshApply = (0, store_1.applyRegistryPatch)(cawsDir, refreshResult.value);
163
+ if (!refreshApply.ok) {
164
+ // Apply failure is a hygiene problem (disk I/O on agents.json),
165
+ // not an authority problem. Ownership is already secured; surface
166
+ // a warning but continue.
167
+ err('caws claim: warning — agents.json refresh failed (display only).');
168
+ err((0, diagnostic_1.renderDiagnostics)(refreshApply.errors, { showData }));
169
+ }
170
+ // 8. Render the Claim panel — re-read the worktree record so it shows
171
+ // the new owner / prior_owners count after the patch.
172
+ // We don't re-compose the snapshot because the apply functions already
173
+ // wrote to disk; reading the in-memory `record` (pre-patch) would lie.
174
+ // For determinism: reconstruct what the post-patch record looks like
175
+ // from the patch we just applied.
176
+ const renderedRecord = patch !== null && patch.kind === 'takeover_claim'
177
+ ? {
178
+ ...record,
179
+ owner: patch.owner,
180
+ last_heartbeat: patch.when,
181
+ prior_owners: [...(record.prior_owners ?? []), patch.prior_owner],
182
+ }
183
+ : record;
184
+ const newRel = (0, claim_1.classifyOwnership)(renderedRecord, session);
185
+ out((0, claim_1.renderClaimPanel)({
186
+ worktreeName,
187
+ worktreeRecord: renderedRecord,
188
+ currentSession: session,
189
+ now,
190
+ ...(opts.staleTtlMs !== undefined ? { staleTtlMs: opts.staleTtlMs } : {}),
191
+ }));
192
+ // Same-session OR successful takeover both count as "claim established".
193
+ // The only Ok-but-not-yours case is impossible here: assertOwnership
194
+ // never returns Ok with a foreign owner intact.
195
+ return newRel === 'you' ? 0 : 1;
196
+ }
197
+ //# sourceMappingURL=claim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claim.js","sourceRoot":"","sources":["../../../src/shell/commands/claim.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,2BAA2B;AAC3B,EAAE;AACF,YAAY;AACZ,4BAA4B;AAC5B,yDAAyD;AACzD,8EAA8E;AAC9E,2EAA2E;AAC3E,0EAA0E;AAC1E,uDAAuD;AACvD,yEAAyE;AACzE,uEAAuE;AACvE,yEAAyE;AACzE,sEAAsE;AACtE,oEAAoE;AACpE,qDAAqD;AACrD,oEAAoE;AACpE,0DAA0D;AAC1D,+BAA+B;AAC/B,EAAE;AACF,cAAc;AACd,uEAAuE;AACvE,mCAAmC;AACnC,yEAAyE;AACzE,+BAA+B;AAC/B,uEAAuE;AACvE,kCAAkC;AAClC,EAAE;AACF,uCAAuC;AACvC,kEAAkE;AAClE,yDAAyD;AACzD,0CAA0C;AAC1C,0DAA0D;AAC1D,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,sEAAsE;AACtE,mEAAmE;AACnE,iBAAiB;;AA+BjB,0CA0KC;AAvMD,2DAImC;AAEnC,uCAIqB;AACrB,gEAA4D;AAC5D,2CAAsE;AACtE,qDAAyD;AACzD,gEAA4D;AAe5D,SAAgB,eAAe,CAAC,OAA4B,EAAE;IAC5D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,O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EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;SAClE;QACH,CAAC,CAAC,MAAM,CAAC;IAEb,MAAM,MAAM,GAAG,IAAA,yBAAiB,EAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC1D,GAAG,CACD,IAAA,wBAAgB,EAAC;QACf,YAAY;QACZ,cAAc,EAAE,cAAc;QAC9B,cAAc,EAAE,OAAO;QACvB,GAAG;QACH,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1E,CAAC,CACH,CAAC;IAEF,yEAAyE;IACzE,qEAAqE;IACrE,gDAAgD;IAChD,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface DoctorCommandOptions {
2
+ readonly cwd?: string;
3
+ readonly now?: Date;
4
+ readonly out?: (line: string) => void;
5
+ readonly err?: (line: string) => void;
6
+ /**
7
+ * Show the optional `data` block for each diagnostic/finding. Default
8
+ * false to keep output tight.
9
+ */
10
+ readonly showData?: boolean;
11
+ }
12
+ export declare function runDoctorCommand(opts?: DoctorCommandOptions): number;
13
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../src/shell/commands/doctor.ts"],"names":[],"mappings":"AAyCA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,oBAAyB,GAAG,MAAM,CAsExE"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ // `caws doctor` — composition command.
3
+ //
4
+ // Pipeline (no business logic in this file):
5
+ //
6
+ // 1. resolveRepoRoot(cwd) (store)
7
+ // 2. composeDoctorSnapshot(...) (store)
8
+ // 3. inspectProjectState(input) (kernel)
9
+ // 4. render store-load diagnostics (renderer)
10
+ // 5. render doctor findings (renderer)
11
+ // 6. choose exit code (this file)
12
+ //
13
+ // The command does NOT read .caws/ files directly, does NOT walk specs,
14
+ // does NOT invent repair rules, and does NOT re-validate state.
15
+ //
16
+ // Exit codes:
17
+ // 0 = no error-severity findings AND no error-severity store-load
18
+ // diagnostics
19
+ // 1 = any error-severity finding OR any error-severity store-load
20
+ // diagnostic. (Store-load errors count even when they were filtered
21
+ // out before reaching the kernel, because an invalid spec file is a
22
+ // project-health problem regardless.)
23
+ // 2 = repo-root resolution failed, or other hard composition failure.
24
+ //
25
+ // Testable without Commander: caller passes cwd / out / err / now and
26
+ // receives a number. `registerShellCommands(program)` (Slice 5c.9) is the
27
+ // only place that wires this to Commander.
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.runDoctorCommand = runDoctorCommand;
30
+ const caws_kernel_1 = require("@paths.design/caws-kernel");
31
+ const store_1 = require("../../store");
32
+ const index_1 = require("../index");
33
+ function runDoctorCommand(opts = {}) {
34
+ const cwd = opts.cwd ?? process.cwd();
35
+ const now = opts.now ?? new Date();
36
+ const out = opts.out ?? ((s) => process.stdout.write(s + '\n'));
37
+ const err = opts.err ?? ((s) => process.stderr.write(s + '\n'));
38
+ const showData = opts.showData === true;
39
+ // 1. Repo root
40
+ const repoRootResult = (0, store_1.resolveRepoRoot)(cwd);
41
+ if (!repoRootResult.ok) {
42
+ err('caws doctor: failed to resolve repo root.');
43
+ err((0, index_1.renderDiagnostics)(repoRootResult.errors, { showData }));
44
+ return 2;
45
+ }
46
+ const { repoRoot, cawsDir } = repoRootResult.value;
47
+ // 2 + 3. Compose snapshot, run kernel diagnoser
48
+ let composition;
49
+ try {
50
+ composition = (0, store_1.composeDoctorSnapshot)({ repoRoot, cawsDir, now });
51
+ }
52
+ catch (e) {
53
+ err(`caws doctor: store composition failed: ${e.message}`);
54
+ return 2;
55
+ }
56
+ const { snapshot, doctorInput } = composition;
57
+ let report;
58
+ try {
59
+ report = (0, caws_kernel_1.inspectProjectState)(doctorInput);
60
+ }
61
+ catch (e) {
62
+ err(`caws doctor: kernel inspect failed: ${e.message}`);
63
+ return 2;
64
+ }
65
+ // 4. Render store-load diagnostics — kept SEPARATE from doctor findings.
66
+ const loadDiagnostics = [
67
+ ...snapshot.specDiagnostics,
68
+ ...snapshot.policyErrors,
69
+ ...snapshot.policyWarnings,
70
+ ...snapshot.eventWarnings,
71
+ ];
72
+ out('Store load diagnostics:');
73
+ if (loadDiagnostics.length === 0) {
74
+ out(' (none)');
75
+ }
76
+ else {
77
+ out((0, index_1.renderDiagnostics)(loadDiagnostics, { showData }));
78
+ }
79
+ // 5. Render doctor findings — separate section.
80
+ out('');
81
+ out('Doctor findings:');
82
+ if (report.findings.length === 0) {
83
+ out(' (none)');
84
+ }
85
+ else {
86
+ out((0, index_1.renderFindings)(report.findings, { showData }));
87
+ }
88
+ // 6. Exit code
89
+ const loadCounts = (0, index_1.countSeverities)(loadDiagnostics);
90
+ const findingCounts = (0, index_1.countFindingSeverities)(report.findings);
91
+ const hasErrors = findingCounts.errors > 0 || loadCounts.errors > 0;
92
+ out('');
93
+ out(`Summary: findings ${findingCounts.errors}E/${findingCounts.warnings}W/${findingCounts.infos}I; ` +
94
+ `load ${loadCounts.errors}E/${loadCounts.warnings}W/${loadCounts.infos}I`);
95
+ return hasErrors ? 1 : 0;
96
+ }
97
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../../src/shell/commands/doctor.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,4CAA4C;AAC5C,4CAA4C;AAC5C,6CAA6C;AAC7C,iDAAiD;AACjD,iDAAiD;AACjD,kDAAkD;AAClD,EAAE;AACF,wEAAwE;AACxE,gEAAgE;AAChE,EAAE;AACF,cAAc;AACd,oEAAoE;AACpE,oBAAoB;AACpB,oEAAoE;AACpE,0EAA0E;AAC1E,0EAA0E;AAC1E,4CAA4C;AAC5C,wEAAwE;AACxE,EAAE;AACF,sEAAsE;AACtE,0EAA0E;AAC1E,2CAA2C;;AA4B3C,4CAsEC;AA/FD,2DAAgE;AAEhE,uCAGqB;AACrB,oCAKkB;AAclB,SAAgB,gBAAgB,CAAC,OAA6B,EAAE;IAC9D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACtC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACxE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC;IAExC,eAAe;IACf,MAAM,cAAc,GAAG,IAAA,uBAAe,EAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE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,QAAQ,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,gDAAgD;IAChD,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACxB,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,GAAG,CAAC,UAAU,CAAC,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,IAAA,sBAAc,EAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,eAAe;IACf,MAAM,UAAU,GAAG,IAAA,uBAAe,EAAC,eAAe,CAAC,CAAC;IACpD,MAAM,aAAa,GAAG,IAAA,8BAAsB,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC9D,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IAEpE,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,GAAG,CACD,qBAAqB,aAAa,CAAC,MAAM,KAAK,aAAa,CAAC,QAAQ,KAAK,aAAa,CAAC,KAAK,KAAK;QAC/F,QAAQ,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC,QAAQ,KAAK,UAAU,CAAC,KAAK,GAAG,CAC5E,CAAC;IAEF,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { type ActorKind } from '@paths.design/caws-kernel';
2
+ export type EvidenceKind = 'test' | 'gate' | 'ac';
3
+ export interface EvidenceRecordOptions {
4
+ /** Which evidence event to record. */
5
+ readonly kind: EvidenceKind;
6
+ /** Required: the spec id this evidence is about. */
7
+ readonly specId: string;
8
+ /** Required: the event payload — must match the kernel's event-type schema. */
9
+ readonly data: Record<string, unknown>;
10
+ /** Actor kind. Defaults to 'agent'. */
11
+ readonly actorKind?: ActorKind;
12
+ /** Optional actor id override. Defaults to session.identity.session_id. */
13
+ readonly actorId?: string;
14
+ /** Optional ISO-8601 ts. Defaults to now. */
15
+ readonly ts?: string;
16
+ /** Working directory. Defaults to process.cwd(). */
17
+ readonly cwd?: string;
18
+ /** Injected clock for tests. */
19
+ readonly now?: () => Date;
20
+ /** Injected env for tests. */
21
+ readonly env?: NodeJS.ProcessEnv;
22
+ readonly out?: (line: string) => void;
23
+ readonly err?: (line: string) => void;
24
+ /** Show optional `data` blocks on rendered errors. */
25
+ readonly showData?: boolean;
26
+ }
27
+ export declare function runEvidenceRecordCommand(opts: EvidenceRecordOptions): number;
28
+ //# sourceMappingURL=evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../../../src/shell/commands/evidence.ts"],"names":[],"mappings":"AAyBA,OAAO,EAEL,KAAK,SAAS,EAGf,MAAM,2BAA2B,CAAC;AAQnC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAQlD,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,uCAAuC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,gCAAgC;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,8BAA8B;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAeD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,CAqG5E"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ // `caws evidence record` — append one typed evidence event.
3
+ //
4
+ // Pipeline:
5
+ // 1. resolveRepoRoot(cwd)
6
+ // 2. resolveSession({ allowMint: true }) — this is a write op
7
+ // 3. buildActor({ session, kind })
8
+ // 4. construct EventBody from caller inputs — body-only; no seq/prev/hash
9
+ // 5. appendEvent(cawsDir, body) — store enforces lock,
10
+ // chain via kernel
11
+ // prepareAppend
12
+ // 6. print seq + event_hash AFTER success
13
+ //
14
+ // Exit codes:
15
+ // 0 = append succeeded
16
+ // 1 = validation rejected the body OR appendEvent returned Err
17
+ // 2 = repo-root / session resolution / composition failure
18
+ //
19
+ // CRITICAL: the API surface accepts EventBody-shaped inputs only. It does
20
+ // not accept `seq`, `prev_hash`, or `event_hash`. The CLI layer parsing
21
+ // (commander) MUST NOT add those fields. If a caller does pass them via
22
+ // the data object, kernel `validateEventBody` rejects them (additionalProperties:
23
+ // false on the per-event-type payload schemas).
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
36
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
37
+ }) : function(o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar = (this && this.__importStar) || (function () {
41
+ var ownKeys = function(o) {
42
+ ownKeys = Object.getOwnPropertyNames || function (o) {
43
+ var ar = [];
44
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
45
+ return ar;
46
+ };
47
+ return ownKeys(o);
48
+ };
49
+ return function (mod) {
50
+ if (mod && mod.__esModule) return mod;
51
+ var result = {};
52
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
53
+ __setModuleDefault(result, mod);
54
+ return result;
55
+ };
56
+ })();
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.runEvidenceRecordCommand = runEvidenceRecordCommand;
59
+ const path = __importStar(require("node:path"));
60
+ const store_1 = require("../../store");
61
+ const actor_1 = require("../session/actor");
62
+ const resolve_session_1 = require("../session/resolve-session");
63
+ const diagnostic_1 = require("../render/diagnostic");
64
+ const rules_1 = require("../rules");
65
+ const KIND_TO_EVENT_TYPE = {
66
+ test: 'test_recorded',
67
+ gate: 'gate_evaluated',
68
+ ac: 'ac_recorded',
69
+ };
70
+ function rejectPreChainedFields(data) {
71
+ for (const banned of ['seq', 'prev_hash', 'event_hash']) {
72
+ if (Object.prototype.hasOwnProperty.call(data, banned)) {
73
+ return banned;
74
+ }
75
+ }
76
+ return null;
77
+ }
78
+ function isEvidenceKind(value) {
79
+ return value === 'test' || value === 'gate' || value === 'ac';
80
+ }
81
+ function runEvidenceRecordCommand(opts) {
82
+ const cwd = opts.cwd ?? process.cwd();
83
+ const now = opts.now ?? (() => new Date());
84
+ const env = opts.env ?? process.env;
85
+ const out = opts.out ?? ((s) => process.stdout.write(s + '\n'));
86
+ const err = opts.err ?? ((s) => process.stderr.write(s + '\n'));
87
+ const showData = opts.showData === true;
88
+ // Validate the evidence kind up front (defensive — Commander should
89
+ // reject unknown values at the parser, but tests / programmatic callers
90
+ // may bypass that).
91
+ if (!isEvidenceKind(opts.kind)) {
92
+ err(`caws evidence record: invalid --type. Got ${JSON.stringify(opts.kind)}; expected test|gate|ac.`);
93
+ err(`(rule: ${rules_1.SHELL_RULES.COMMAND_INVALID_EVIDENCE_TYPE})`);
94
+ return 1;
95
+ }
96
+ // Reject pre-chained fields in the payload BEFORE doing any I/O.
97
+ const banned = rejectPreChainedFields(opts.data);
98
+ if (banned !== null) {
99
+ err(`caws evidence record: payload must NOT include \`${banned}\`. Pre-chained events are not accepted by this command.`);
100
+ err(`(rule: ${rules_1.SHELL_RULES.COMMAND_PRE_CHAINED_EVENT_REFUSED})`);
101
+ return 1;
102
+ }
103
+ // Require non-empty spec_id (also enforced by kernel REQUIRES_SPEC_ID
104
+ // fence, but we surface the shell-level error early).
105
+ if (typeof opts.specId !== 'string' || opts.specId.length === 0) {
106
+ err('caws evidence record: --spec is required.');
107
+ err(`(rule: ${rules_1.SHELL_RULES.COMMAND_MISSING_SPEC_ID})`);
108
+ return 1;
109
+ }
110
+ // 1. Repo root.
111
+ const repoRootResult = (0, store_1.resolveRepoRoot)(cwd);
112
+ if (!repoRootResult.ok) {
113
+ err('caws evidence record: failed to resolve repo root.');
114
+ err((0, diagnostic_1.renderDiagnostics)(repoRootResult.errors, { showData }));
115
+ return 2;
116
+ }
117
+ const { repoRoot, cawsDir } = repoRootResult.value;
118
+ // 2. Session (write op → allowMint).
119
+ const sessionResult = (0, resolve_session_1.resolveSession)({
120
+ cawsDir,
121
+ worktreeRoot: cwd,
122
+ env,
123
+ now,
124
+ allowMint: true,
125
+ });
126
+ if (!sessionResult.ok) {
127
+ err('caws evidence record: failed to resolve session identity.');
128
+ err((0, diagnostic_1.renderDiagnostics)(sessionResult.errors, { showData }));
129
+ return 2;
130
+ }
131
+ // 3. Actor envelope.
132
+ const actor = (0, actor_1.buildActor)({
133
+ session: sessionResult.value,
134
+ kind: opts.actorKind ?? 'agent',
135
+ ...(opts.actorId !== undefined ? { id: opts.actorId } : {}),
136
+ });
137
+ // 4. Body.
138
+ const eventType = KIND_TO_EVENT_TYPE[opts.kind];
139
+ const ts = opts.ts ?? now().toISOString();
140
+ // `EventBody.data` is typed as `EventPayload` (a union of per-event
141
+ // payload shapes). The kernel will validate against the right schema
142
+ // at append time; we hand off the caller's already-parsed object.
143
+ const body = {
144
+ event: eventType,
145
+ ts,
146
+ actor,
147
+ spec_id: opts.specId,
148
+ data: opts.data,
149
+ };
150
+ // 5. Append. `appendEvent` calls `prepareAppend` which calls
151
+ // `validateEventBody` against the per-type schema.
152
+ const appendResult = (0, store_1.appendEvent)(cawsDir, body);
153
+ if (!appendResult.ok) {
154
+ err('caws evidence record: append rejected.');
155
+ err((0, diagnostic_1.renderDiagnostics)(appendResult.errors, { showData }));
156
+ return 1;
157
+ }
158
+ // 6. Print outcome AFTER success. Includes seq + event_hash so the
159
+ // caller (agent or human) gets a stable handle for the new event.
160
+ const ev = appendResult.value;
161
+ out(`recorded ${ev.event} seq=${ev.seq} hash=${ev.event_hash} spec=${ev.spec_id ?? '(none)'}`);
162
+ // Print the relative events file path for ergonomics.
163
+ out(` written to ${path.relative(repoRoot, path.join(cawsDir, 'events.jsonl'))}`);
164
+ return 0;
165
+ }
166
+ //# sourceMappingURL=evidence.js.map