@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,23 @@
1
+ import type { Spec, Policy } from '@paths.design/caws-kernel';
2
+ import type { GatesViolation } from '../gate-result-contract';
3
+ import { type StagedFileChange } from './diff-helpers';
4
+ export interface ScopeBoundaryInput {
5
+ readonly spec: Spec;
6
+ readonly policy: Policy;
7
+ readonly repoRoot: string;
8
+ /** Worktree name; defaults to "scope-boundary" if not known. The kernel
9
+ * uses this only for diagnostic data, not for authority. */
10
+ readonly worktreeName?: string;
11
+ /** Override staged-diff source (tests). */
12
+ readonly stagedChanges?: readonly StagedFileChange[];
13
+ }
14
+ export interface ScopeBoundaryResult {
15
+ readonly violations: readonly GatesViolation[];
16
+ readonly observed: {
17
+ readonly files_evaluated: number;
18
+ readonly rejected: number;
19
+ readonly invalid: number;
20
+ };
21
+ }
22
+ export declare function evaluateScopeBoundary(input: ScopeBoundaryInput): ScopeBoundaryResult;
23
+ //# sourceMappingURL=scope-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-boundary.d.ts","sourceRoot":"","sources":["../../../../src/shell/gates/local-evaluators/scope-boundary.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE1E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;iEAC6D;IAC7D,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,2CAA2C;IAC3C,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACtD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,UAAU,EAAE,SAAS,cAAc,EAAE,CAAC;IAC/C,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;QACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,CA+CpF"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ // scope_boundary evaluator.
3
+ //
4
+ // Iterates the staged file list and asks the kernel scope evaluator
5
+ // (`evaluatePath`) for each path. Any `reject` decision becomes a
6
+ // `scope_boundary` violation; `invalid_path` decisions also become
7
+ // violations (the staged path is malformed and not policy-admissible).
8
+ //
9
+ // `admit` and `no_authority` decisions do NOT produce violations here.
10
+ // `no_authority` (unbound or one_sided) is a binding problem — the
11
+ // gates command itself should refuse to run in that state long before
12
+ // this evaluator is called, OR a doctor-style separate diagnostic
13
+ // should be raised. For v11.1 we treat `no_authority` as a non-blocking
14
+ // "cannot decide" outcome consistent with the kernel's contract; the
15
+ // caller's binding precondition is the authoritative gate.
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.evaluateScopeBoundary = evaluateScopeBoundary;
18
+ const caws_kernel_1 = require("@paths.design/caws-kernel");
19
+ const diff_helpers_1 = require("./diff-helpers");
20
+ function evaluateScopeBoundary(input) {
21
+ const changes = input.stagedChanges ?? (0, diff_helpers_1.listStagedChanges)(input.repoRoot);
22
+ // Local evaluator assumes the gates command would not have proceeded
23
+ // unbound; we synthesize a `bound` BindingState from the spec under
24
+ // evaluation. The caws-cli `caws gates run --spec <id>` contract is
25
+ // that the caller has named the spec; we treat that as authority for
26
+ // the purpose of scope evaluation here.
27
+ const binding = {
28
+ kind: 'bound',
29
+ spec: input.spec,
30
+ worktreeName: input.worktreeName ?? 'gates-run',
31
+ };
32
+ const violations = [];
33
+ let rejected = 0;
34
+ let invalid = 0;
35
+ for (const c of changes) {
36
+ const d = (0, caws_kernel_1.evaluatePath)(c.path, binding, input.policy);
37
+ if (d.kind === 'reject') {
38
+ rejected++;
39
+ violations.push({
40
+ gate: 'scope_boundary',
41
+ type: d.rule,
42
+ message: d.message,
43
+ file: c.path,
44
+ severity: 'fail',
45
+ });
46
+ }
47
+ else if (d.kind === 'invalid_path') {
48
+ invalid++;
49
+ violations.push({
50
+ gate: 'scope_boundary',
51
+ type: d.rule,
52
+ message: d.message,
53
+ file: c.path,
54
+ severity: 'fail',
55
+ });
56
+ }
57
+ }
58
+ return {
59
+ violations,
60
+ observed: {
61
+ files_evaluated: changes.length,
62
+ rejected,
63
+ invalid,
64
+ },
65
+ };
66
+ }
67
+ //# sourceMappingURL=scope-boundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-boundary.js","sourceRoot":"","sources":["../../../../src/shell/gates/local-evaluators/scope-boundary.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,oEAAoE;AACpE,kEAAkE;AAClE,mEAAmE;AACnE,uEAAuE;AACvE,EAAE;AACF,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AC,IAAI;gBACZ,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,QAAQ,EAAE,MAAM;aACjB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO;QACL,UAAU;QACV,QAAQ,EAAE;YACR,eAAe,EAAE,OAAO,CAAC,MAAM;YAC/B,QAAQ;YACR,OAAO;SACR;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Spec } from '@paths.design/caws-kernel';
2
+ import type { GatesViolation } from '../gate-result-contract';
3
+ export interface SpecCompletenessInput {
4
+ readonly spec: Spec;
5
+ /** Current ISO timestamp for evaluating experimental_mode.expires_at. */
6
+ readonly nowIso: string;
7
+ }
8
+ export interface SpecCompletenessResult {
9
+ readonly violations: readonly GatesViolation[];
10
+ }
11
+ export declare function evaluateSpecCompleteness(input: SpecCompletenessInput): SpecCompletenessResult;
12
+ //# sourceMappingURL=spec-completeness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-completeness.d.ts","sourceRoot":"","sources":["../../../../src/shell/gates/local-evaluators/spec-completeness.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,SAAS,cAAc,EAAE,CAAC;CAChD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,qBAAqB,GAAG,sBAAsB,CAoD7F"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ // spec_completeness evaluator.
3
+ //
4
+ // Bridges spec health into gate disposition. The kernel/schema layer
5
+ // already enforces structural completeness (required fields, minItems
6
+ // on invariants/acceptance, lifecycle_state shape, etc.); a spec that
7
+ // fails schema validation never reaches this evaluator — composeStoreSnapshot
8
+ // excludes it, and gates.ts already refuses the run.
9
+ //
10
+ // So this evaluator covers the *semantic* completeness checks that the
11
+ // schema cannot enforce alone:
12
+ //
13
+ // 1. The active spec must be in lifecycle_state === 'active'. Running
14
+ // gates against a closed/archived/draft spec is a category error.
15
+ // Schema admits all four states; only 'active' is a valid gating
16
+ // target.
17
+ //
18
+ // 2. blast_radius.modules must be non-empty. The schema requires
19
+ // `modules` to exist but does not require minItems > 0.
20
+ //
21
+ // 3. If the spec has experimental_mode.enabled and expires_at is in
22
+ // the past, the experimental status is stale — a completeness
23
+ // issue surfaced for the operator to either renew or remove.
24
+ //
25
+ // Each failure produces one violation with gate: 'spec_completeness'.
26
+ // `caws-cli` shell decides whether to block based on policy.
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.evaluateSpecCompleteness = evaluateSpecCompleteness;
29
+ function evaluateSpecCompleteness(input) {
30
+ const violations = [];
31
+ // Rule 1: lifecycle_state must be active for gating.
32
+ if (input.spec.lifecycle_state !== 'active') {
33
+ violations.push({
34
+ gate: 'spec_completeness',
35
+ type: 'spec_not_active',
36
+ message: `Spec ${input.spec.id} is in lifecycle_state '${input.spec.lifecycle_state}'; ` +
37
+ `gates only enforce against active specs. ` +
38
+ `Either reopen the spec or run gates against an active spec.`,
39
+ severity: 'fail',
40
+ });
41
+ }
42
+ // Rule 2: blast_radius.modules must be non-empty.
43
+ if (input.spec.blast_radius === undefined ||
44
+ !Array.isArray(input.spec.blast_radius.modules) ||
45
+ input.spec.blast_radius.modules.length === 0) {
46
+ violations.push({
47
+ gate: 'spec_completeness',
48
+ type: 'blast_radius_empty',
49
+ message: `Spec ${input.spec.id} has no blast_radius.modules; risk evaluation ` +
50
+ `cannot proceed without a declared blast radius.`,
51
+ severity: 'fail',
52
+ });
53
+ }
54
+ // Rule 3: experimental_mode expiry.
55
+ const exp = input.spec.experimental_mode;
56
+ if (exp !== undefined && exp.enabled === true) {
57
+ if (typeof exp.expires_at === 'string') {
58
+ const expDate = Date.parse(exp.expires_at);
59
+ const now = Date.parse(input.nowIso);
60
+ if (Number.isFinite(expDate) && Number.isFinite(now) && expDate < now) {
61
+ violations.push({
62
+ gate: 'spec_completeness',
63
+ type: 'experimental_mode_expired',
64
+ message: `Spec ${input.spec.id} has experimental_mode.enabled=true but expires_at ` +
65
+ `(${exp.expires_at}) is in the past. Renew or remove the experimental status.`,
66
+ severity: 'fail',
67
+ });
68
+ }
69
+ }
70
+ }
71
+ return { violations };
72
+ }
73
+ //# sourceMappingURL=spec-completeness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-completeness.js","sourceRoot":"","sources":["../../../../src/shell/gates/local-evaluators/spec-completeness.ts"],"names":[],"mappings":";AAAA,+BAA+B;AAC/B,EAAE;AACF,qEAAqE;AACrE,sEAAsE;AACtE,sEAAsE;AACtE,8EAA8E;AAC9E,qDAAqD;AACrD,EAAE;AACF,uEAAuE;AACvE,+BAA+B;AAC/B,EAAE;AACF,wEAAwE;AACxE,uEAAuE;AACvE,sEAAsE;AACtE,eAAe;AACf,EAAE;AACF,mEAAmE;AACnE,6DAA6D;AAC7D,EAAE;AACF,sEAAsE;AACtE,mEAAmE;AACnE,kEAAkE;AAClE,EAAE;AACF,sEAAsE;AACtE,6DAA6D;;AAgB7D,4DAoDC;AApDD,SAAgB,wBAAwB,CAAC,KAA4B;IACnE,MAAM,UAAU,GAAqB,EAAE,CAAC;IAExC,qDAAqD;IACrD,IAAI,KAAK,CAAC,IAAI,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;QAC5C,UAAU,CAAC,IAAI,CAAC;YACd,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,iBAAiB;YACvB,OAAO,EACL,QAAQ,KAAK,CAAC,IAAI,CAAC,EAAE,2BAA2B,KAAK,CAAC,IAAI,CAAC,eAA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,4DAA4D;oBAChF,QAAQ,EAAE,MAAM;iBACjB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { type Result } from '@paths.design/caws-kernel';
2
+ import { type GatesReport } from './gate-result-contract';
3
+ /**
4
+ * Pure resolver: given the CLI install directory and the consumer project
5
+ * cwd, decide which on-disk path to spawn. Walks up from each starting
6
+ * point looking for `node_modules/.bin/<BIN_NAME>`.
7
+ *
8
+ * Resolution order (documented per CLI-GATES-003 A4):
9
+ * 1. CLI-install-local — walk up from cliDir. This wins when caws-cli is
10
+ * installed globally or in a separate sandbox: caws-quality-gates
11
+ * ships as a runtime dep of caws-cli, so it lives beside the caws
12
+ * binary, not beside the consumer project.
13
+ * 2. Project-local — walk up from projectCwd. Preserves the prior
14
+ * behavior for the project-local install pattern (CLI-GATES-002 A1).
15
+ *
16
+ * The CLI-install-local check wins when both exist. That ordering is by
17
+ * design: a global caws install was a deliberate choice to use one CLI
18
+ * version everywhere, and we want that single subprocess version too —
19
+ * not whatever happens to be in the consumer's node_modules from an older
20
+ * project-local install.
21
+ *
22
+ * Returns the resolved path on success, or { tried: string[] } so the
23
+ * adapter can surface both attempted paths in the GATES_SUBPROCESS_NOT_FOUND
24
+ * diagnostic.
25
+ */
26
+ export declare function resolveQualityGatesBin(cliDir: string, projectCwd: string, fsCheck?: (p: string) => boolean): {
27
+ resolved: string;
28
+ source: 'cli-local' | 'project-local';
29
+ } | {
30
+ tried: string[];
31
+ };
32
+ export interface SubprocessResult {
33
+ /** Exit code of the subprocess. */
34
+ readonly status: number | null;
35
+ /** stdout captured as UTF-8. */
36
+ readonly stdout: string;
37
+ /** stderr captured as UTF-8. */
38
+ readonly stderr: string;
39
+ /** Any error thrown by the spawn itself (ENOENT, etc.). */
40
+ readonly error?: Error;
41
+ }
42
+ export interface QualityGatesRunnerInput {
43
+ readonly cwd: string;
44
+ /** Extra CLI args after `--json` (e.g. ['--context=cli', '--quiet']). */
45
+ readonly args: readonly string[];
46
+ }
47
+ export type QualityGatesRunner = (input: QualityGatesRunnerInput) => SubprocessResult;
48
+ export interface RunQualityGatesOptions {
49
+ readonly cwd: string;
50
+ readonly args?: readonly string[];
51
+ /** Inject a custom runner. Tests use this; production omits. */
52
+ readonly runner?: QualityGatesRunner;
53
+ }
54
+ export declare function runQualityGates(opts: RunQualityGatesOptions): Result<GatesReport>;
55
+ //# sourceMappingURL=quality-gates-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quality-gates-adapter.d.ts","sourceRoot":"","sources":["../../../src/shell/gates/quality-gates-adapter.ts"],"names":[],"mappings":"AAmBA,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAGlF,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAI/E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAuB,GAC9C;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAmBnF;AAED,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,uBAAuB,KAAK,gBAAgB,CAAC;AAgDtF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC;CACtC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,MAAM,CAAC,WAAW,CAAC,CAqCjF"}
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ // Adapter for the `caws-quality-gates` subprocess.
3
+ //
4
+ // Single responsibility: invoke the subprocess in `--json` mode, capture
5
+ // stdout, validate the JSON shape against `gate-result-contract`, and
6
+ // return Ok(GatesReport) or Err(diagnostic).
7
+ //
8
+ // What this adapter does NOT do:
9
+ // - it does not interpret violations
10
+ // - it does not decide pass/fail/skip
11
+ // - it does not append events
12
+ // - it does not write to any file
13
+ //
14
+ // The runner is pluggable so tests can inject canned JSON without spawning
15
+ // real subprocesses. Production uses a default child_process runner.
16
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ var desc = Object.getOwnPropertyDescriptor(m, k);
19
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
+ desc = { enumerable: true, get: function() { return m[k]; } };
21
+ }
22
+ Object.defineProperty(o, k2, desc);
23
+ }) : (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ }));
27
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
29
+ }) : function(o, v) {
30
+ o["default"] = v;
31
+ });
32
+ var __importStar = (this && this.__importStar) || (function () {
33
+ var ownKeys = function(o) {
34
+ ownKeys = Object.getOwnPropertyNames || function (o) {
35
+ var ar = [];
36
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
37
+ return ar;
38
+ };
39
+ return ownKeys(o);
40
+ };
41
+ return function (mod) {
42
+ if (mod && mod.__esModule) return mod;
43
+ var result = {};
44
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
45
+ __setModuleDefault(result, mod);
46
+ return result;
47
+ };
48
+ })();
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.resolveQualityGatesBin = resolveQualityGatesBin;
51
+ exports.runQualityGates = runQualityGates;
52
+ const fs = __importStar(require("node:fs"));
53
+ const path = __importStar(require("node:path"));
54
+ const node_child_process_1 = require("node:child_process");
55
+ const caws_kernel_1 = require("@paths.design/caws-kernel");
56
+ const rules_1 = require("../rules");
57
+ const gate_result_contract_1 = require("./gate-result-contract");
58
+ const BIN_NAME = 'caws-quality-gates';
59
+ /**
60
+ * Pure resolver: given the CLI install directory and the consumer project
61
+ * cwd, decide which on-disk path to spawn. Walks up from each starting
62
+ * point looking for `node_modules/.bin/<BIN_NAME>`.
63
+ *
64
+ * Resolution order (documented per CLI-GATES-003 A4):
65
+ * 1. CLI-install-local — walk up from cliDir. This wins when caws-cli is
66
+ * installed globally or in a separate sandbox: caws-quality-gates
67
+ * ships as a runtime dep of caws-cli, so it lives beside the caws
68
+ * binary, not beside the consumer project.
69
+ * 2. Project-local — walk up from projectCwd. Preserves the prior
70
+ * behavior for the project-local install pattern (CLI-GATES-002 A1).
71
+ *
72
+ * The CLI-install-local check wins when both exist. That ordering is by
73
+ * design: a global caws install was a deliberate choice to use one CLI
74
+ * version everywhere, and we want that single subprocess version too —
75
+ * not whatever happens to be in the consumer's node_modules from an older
76
+ * project-local install.
77
+ *
78
+ * Returns the resolved path on success, or { tried: string[] } so the
79
+ * adapter can surface both attempted paths in the GATES_SUBPROCESS_NOT_FOUND
80
+ * diagnostic.
81
+ */
82
+ function resolveQualityGatesBin(cliDir, projectCwd, fsCheck = fs.existsSync) {
83
+ const tried = [];
84
+ for (const [source, start] of [
85
+ ['cli-local', cliDir],
86
+ ['project-local', projectCwd],
87
+ ]) {
88
+ let dir = path.resolve(start);
89
+ while (true) {
90
+ const candidate = path.join(dir, 'node_modules', '.bin', BIN_NAME);
91
+ tried.push(candidate);
92
+ if (fsCheck(candidate)) {
93
+ return { resolved: candidate, source };
94
+ }
95
+ const parent = path.dirname(dir);
96
+ if (parent === dir)
97
+ break;
98
+ dir = parent;
99
+ }
100
+ }
101
+ return { tried };
102
+ }
103
+ function diag(rule, message, data) {
104
+ const base = {
105
+ rule,
106
+ authority: 'kernel/diagnostics',
107
+ severity: 'error',
108
+ message,
109
+ };
110
+ return data !== undefined ? { ...base, data } : base;
111
+ }
112
+ function defaultRunner(input) {
113
+ // CLI-GATES-003: resolve the subprocess from the installed CLI package
114
+ // location first (covers global / sandboxed install), then fall back to
115
+ // the consumer project (covers project-local install — CLI-GATES-002 A1).
116
+ // No PATH fallback — explicit failure beats a hijacked binary.
117
+ //
118
+ // Spawn cwd stays as input.cwd (CLI-GATES-003 A3): the analyzed files
119
+ // come from the consumer project, never from the CLI's install dir.
120
+ const resolution = resolveQualityGatesBin(__dirname, input.cwd);
121
+ if ('tried' in resolution) {
122
+ return {
123
+ status: null,
124
+ stdout: '',
125
+ stderr: '',
126
+ error: Object.assign(new Error(`caws-quality-gates not found. Tried ${resolution.tried.length} location(s): ${resolution.tried.join(', ')}`), { code: 'ENOENT' }),
127
+ };
128
+ }
129
+ const r = (0, node_child_process_1.spawnSync)(resolution.resolved, ['--json', ...input.args], { cwd: input.cwd, encoding: 'utf8' });
130
+ const out = {
131
+ status: r.status,
132
+ stdout: typeof r.stdout === 'string' ? r.stdout : '',
133
+ stderr: typeof r.stderr === 'string' ? r.stderr : '',
134
+ ...(r.error !== undefined ? { error: r.error } : {}),
135
+ };
136
+ return out;
137
+ }
138
+ function runQualityGates(opts) {
139
+ const runner = opts.runner ?? defaultRunner;
140
+ const result = runner({ cwd: opts.cwd, args: opts.args ?? [] });
141
+ // Subprocess could not be spawned (ENOENT, permission, etc.).
142
+ if (result.error !== undefined) {
143
+ return (0, caws_kernel_1.err)(diag(rules_1.SHELL_RULES.GATES_SUBPROCESS_NOT_FOUND, `Failed to spawn caws-quality-gates: ${result.error.message}`, { errno: result.error.code }));
144
+ }
145
+ // Nonzero exit is acceptable IF we still got valid JSON: violations
146
+ // routinely produce nonzero exit. We do NOT treat exit code as the
147
+ // disposition source — policy does. But if the subprocess didn't
148
+ // produce JSON at all, that's an integration failure.
149
+ if (result.stdout.trim().length === 0) {
150
+ return (0, caws_kernel_1.err)(diag(rules_1.SHELL_RULES.GATES_SUBPROCESS_FAILED, `caws-quality-gates produced no stdout (exit=${result.status}).`, {
151
+ exit: result.status,
152
+ stderr: result.stderr.slice(0, 4000),
153
+ }));
154
+ }
155
+ // Validate the JSON shape before trusting it. This is the contract gate.
156
+ const reportResult = (0, gate_result_contract_1.validateGatesReport)(result.stdout);
157
+ if (!reportResult.ok)
158
+ return reportResult;
159
+ return (0, caws_kernel_1.ok)(reportResult.value);
160
+ }
161
+ //# sourceMappingURL=quality-gates-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quality-gates-adapter.js","sourceRoot":"","sources":["../../../src/shell/gates/quality-gates-adapter.ts"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,EAAE;AACF,yEAAyE;AACzE,sEAAsE;AACtE,6CAA6C;AAC7C,EAAE;AACF,iCAAiC;AACjC,uCAAuC;AACvC,wCAAwC;AACxC,gCAAgC;AAChC,oCAAoC;AACpC,EAAE;AACF,2EAA2E;AAC3E,qEAAqE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCrE,wDAuBC;AA0ED,0CAqCC;AAxKD,4CAA8B;AAC9B,gDAA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ws-kernel';
2
+ import type { GatesReport } from './gate-result-contract';
3
+ export interface WaiverFilterInput {
4
+ readonly report: GatesReport;
5
+ readonly waivers: readonly Waiver[];
6
+ readonly specId: string;
7
+ readonly now: Date;
8
+ /**
9
+ * Gate ids the policy declares. Violations targeting any other gate
10
+ * pass through the filter unmodified — waivers MUST NOT promote an
11
+ * unmatched (subprocess-only) violation to a policy-suppressed state,
12
+ * because policy doesn't own that gate. Treating waivers as scoped to
13
+ * policy-declared gates keeps the unmatched bucket purely
14
+ * observational, which is the contract `deriveDispositions` relies on.
15
+ *
16
+ * If omitted, every gate is considered policy-declared (legacy / test
17
+ * convenience). Production callers should always pass this.
18
+ */
19
+ readonly policyGateIds?: readonly string[];
20
+ }
21
+ export interface WaiverEvidence {
22
+ /** Number of violations on this gate that an effective waiver suppressed. */
23
+ readonly waived_count: number;
24
+ /** Stable ids of the waivers credited with the suppression, deduped + sorted. */
25
+ readonly waiver_ids: readonly string[];
26
+ }
27
+ export interface WaiverFilterResult {
28
+ /**
29
+ * The same report shape, but with `violations` reduced to those NOT
30
+ * suppressed by an effective waiver. `warnings`, `timestamp`,
31
+ * `context`, `files_scoped`, and the optional `waivers` / `performance`
32
+ * blocks are passed through unchanged.
33
+ */
34
+ readonly reportForDisposition: GatesReport;
35
+ /**
36
+ * Per-gate evidence keyed by the violation's `gate` field. Only gates
37
+ * that actually had at least one suppression appear here. Gates with
38
+ * zero suppressions are intentionally omitted: callers should default
39
+ * them to `{ waived_count: 0, waiver_ids: [] }` if they need a uniform
40
+ * shape, but the canonical form is "absent means zero".
41
+ */
42
+ readonly waivedByGate: Readonly<Record<string, WaiverEvidence>>;
43
+ }
44
+ /**
45
+ * Filter `report.violations` against the supplied effective waivers.
46
+ *
47
+ * For each violation:
48
+ * - look up the effective waivers for that violation's gate (kernel call)
49
+ * - if any are effective, the violation is suppressed and the waivers'
50
+ * ids are recorded as evidence on that gate's bucket
51
+ * - if none are effective, the violation passes through unchanged
52
+ *
53
+ * The kernel's effectiveness rule (active && not expired && gate matches
54
+ * && (no spec_id OR matches input.specId)) is the only applicability
55
+ * decision. Path scoping is not consulted (see file header).
56
+ */
57
+ export declare function filterWaivedViolations(input: WaiverFilterInput): WaiverFilterResult;
58
+ //# sourceMappingURL=waiver-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waiver-filter.d.ts","sourceRoot":"","sources":["../../../src/shell/gates/waiver-filter.ts"],"names":[],"mappings":"AAiCA,OAAO,EAEL,KAAK,MAAM,EACZ,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,wBAAwB,CAAC;AAE1E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;IACnB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,iFAAiF;IACjF,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC;IAC3C;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;CACjE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,iBAAiB,GACvB,kBAAkB,CAuEpB"}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ // Waiver filter — shell-level helper that removes effective-waiver-suppressed
3
+ // violations from a GatesReport before disposition.
4
+ //
5
+ // Discipline:
6
+ //
7
+ // 1. This helper does NOT mutate `policy.gates[gate].mode`. A waived
8
+ // violation is removed from the blocking calculation, but the gate's
9
+ // block/warn/skip meaning still comes only from policy. After filtering,
10
+ // `deriveDispositions(filteredReport, policy)` is run unchanged.
11
+ //
12
+ // 2. Applicability is delegated to the kernel
13
+ // (`effectiveWaiversForGate`) so kernel rules stay the single source
14
+ // of truth. The shell only knows: "given the per-gate effective
15
+ // waivers, drop the violations that match this gate."
16
+ //
17
+ // 3. Path scoping (`scope.paths`) is intentionally absent. The kernel
18
+ // type does not include it. Doing it half-way here would be worse
19
+ // than deferring it to a later slice.
20
+ //
21
+ // 4. The "violation matched this gate" rule is the same as
22
+ // `deriveDispositions`'s grouping rule: violations whose `gate`
23
+ // field equals a gate in the waiver's `gates` list. We do NOT use
24
+ // the violation's `severity` field for matching — policy and waivers
25
+ // are both gate-level constructs in this slice; per-violation
26
+ // identity (e.g. by rule + subject) is not yet a thing waivers
27
+ // address.
28
+ //
29
+ // 5. Subprocess "unmatched" gates (gates the subprocess reports but
30
+ // policy doesn't declare) are never waiver-suppressed: waivers
31
+ // filter violations that policy can act on, and unmatched gates
32
+ // are observational by construction. Leaving them untouched here
33
+ // preserves the existing `unmatchedViolations` surface.
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.filterWaivedViolations = filterWaivedViolations;
36
+ const caws_kernel_1 = require("@paths.design/caws-kernel");
37
+ /**
38
+ * Filter `report.violations` against the supplied effective waivers.
39
+ *
40
+ * For each violation:
41
+ * - look up the effective waivers for that violation's gate (kernel call)
42
+ * - if any are effective, the violation is suppressed and the waivers'
43
+ * ids are recorded as evidence on that gate's bucket
44
+ * - if none are effective, the violation passes through unchanged
45
+ *
46
+ * The kernel's effectiveness rule (active && not expired && gate matches
47
+ * && (no spec_id OR matches input.specId)) is the only applicability
48
+ * decision. Path scoping is not consulted (see file header).
49
+ */
50
+ function filterWaivedViolations(input) {
51
+ // Per-gate effective waivers, computed lazily so we don't pay the cost
52
+ // for gates that have no violations in this report.
53
+ const effectiveByGate = new Map();
54
+ const policyGateSet = input.policyGateIds === undefined
55
+ ? undefined
56
+ : new Set(input.policyGateIds);
57
+ function effectiveFor(gate) {
58
+ // Waivers only touch policy-declared gates. An unmatched (subprocess-
59
+ // only) violation is observational by construction; letting waivers
60
+ // suppress it would break that contract and confuse the unmatched
61
+ // surface in `deriveDispositions`.
62
+ if (policyGateSet !== undefined && !policyGateSet.has(gate)) {
63
+ return [];
64
+ }
65
+ const cached = effectiveByGate.get(gate);
66
+ if (cached !== undefined)
67
+ return cached;
68
+ const computed = (0, caws_kernel_1.effectiveWaiversForGate)({
69
+ waivers: input.waivers,
70
+ gate,
71
+ specId: input.specId,
72
+ now: input.now,
73
+ });
74
+ effectiveByGate.set(gate, computed);
75
+ return computed;
76
+ }
77
+ const survivors = [];
78
+ const evidenceByGate = new Map();
79
+ for (const v of input.report.violations) {
80
+ const effective = effectiveFor(v.gate);
81
+ if (effective.length === 0) {
82
+ survivors.push(v);
83
+ continue;
84
+ }
85
+ // Suppressed. Credit every effective waiver — overlapping coverage is
86
+ // fine; the audit record names every authorized exception.
87
+ let bucket = evidenceByGate.get(v.gate);
88
+ if (bucket === undefined) {
89
+ bucket = new Set();
90
+ evidenceByGate.set(v.gate, bucket);
91
+ }
92
+ for (const w of effective)
93
+ bucket.add(w.id);
94
+ }
95
+ const waivedByGate = {};
96
+ for (const [gate, ids] of evidenceByGate) {
97
+ const sorted = Array.from(ids).sort();
98
+ // waived_count counts violations on this gate that were suppressed,
99
+ // not waivers credited. Recompute by re-walking; cheaper than carrying
100
+ // a parallel counter and keeps the meaning explicit.
101
+ let count = 0;
102
+ for (const v of input.report.violations) {
103
+ if (v.gate !== gate)
104
+ continue;
105
+ if (effectiveFor(v.gate).length > 0)
106
+ count++;
107
+ }
108
+ waivedByGate[gate] = {
109
+ waived_count: count,
110
+ waiver_ids: sorted,
111
+ };
112
+ }
113
+ const reportForDisposition = {
114
+ ...input.report,
115
+ violations: survivors,
116
+ };
117
+ return { reportForDisposition, waivedByGate };
118
+ }
119
+ //# sourceMappingURL=waiver-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waiver-filter.js","sourceRoot":"","sources":["../../../src/shell/gates/waiver-filter.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,oDAAoD;AACpD,EAAE;AACF,cAAc;AACd,EAAE;AACF,uEAAuE;AACvE,0EAA0E;AAC1E,8EAA8E;AAC9E,sEAAsE;AACtE,EAAE;AACF,gDAAgD;AAChD,0EAA0E;AAC1E,qEAAqE;AACrE,2DAA2D;AAC3D,EAAE;AACF,wEAAwE;AACxE,uEAAuE;AACvE,2CAA2C;AAC3C,EAAE;AACF,6DAA6D;AAC7D,qEAAqE;AACrE,uEAAuE;AACvE,0EAA0E;AAC1E,mEAAmE;AACnE,oEAAoE;AACpE,gBAAgB;AAChB,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,qEAAqE;AACrE,sEAAsE;AACtE,6DAA6D;;AAkE7D,wDAyEC;AAzID,2DAGmC;AAgDnC;;;;;;;;;;;;GAYG;AACH,SAAgB,sBAAsB,CACpC,KAAwB;IAExB,uEAAuE;IACvE,oDAAoD;IACpD,MAAM,eAAe,GAAG,IAAI,GAAG,EAA6B,CAAC;IAC7D,MAAM,aAAa,GACjB,KAAK,CAAC,aAAa,KAAK,SAAS;QAC/B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,IAAI,GAAG,CAAS,KAAK,CAAC,aAAa,CAAC,CAAC;IAE3C,SAAS,YAAY,CAAC,IAAY;QAChC,sEAAsE;QACtE,oEAAoE;QACpE,kEAAkE;QAClE,mCAAmC;QACnC,IAAI,aAAa,KAAK,SAAS,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5D,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,MAAM,GAAG,eAAe,CAAC,G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