@bonesofspring/ai-rules 0.2.71 → 0.2.73

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 (660) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +7 -6
  3. package/bin/lib/ai-local-drift.js +4 -4
  4. package/bin/lib/engine-scripts.js +11 -0
  5. package/bin/lib/seed-ai-local-team.js +9 -5
  6. package/docs/OPENCODE.md +4 -2
  7. package/docs/TEAM-DB.md +27 -9
  8. package/package.json +1 -1
  9. package/presets/_shared/ai-local/scripts/aggregate-agent-task-metrics.mjs +201 -0
  10. package/presets/_shared/ai-local/scripts/incidents.mjs +452 -0
  11. package/presets/_shared/ai-local/scripts/manifest.mjs +19 -1
  12. package/presets/_shared/ai-local/scripts/record-usage.mjs +163 -0
  13. package/presets/_shared/ai-local/scripts/team-db-project.mjs +75 -11
  14. package/presets/_shared/ai-local/scripts/team-db.mjs +125 -40
  15. package/presets/_shared/ai-local/scripts/tracker-planned-drain.mjs +335 -0
  16. package/presets/_shared/ai-local/scripts/verification.mjs +374 -0
  17. package/presets/_shared/core/agent-team/agent-artifact-contracts.md +9 -0
  18. package/presets/_shared/core/agent-team/agent-task-metrics.md +61 -1
  19. package/presets/_shared/core/agent-team/agent-team-intake.md +2 -2
  20. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +5 -4
  21. package/presets/_shared/core/agent-team/incident-registry.md +47 -0
  22. package/presets/_shared/core/architecture/feature-delivery-workflow.md +1 -1
  23. package/presets/_shared/core/quality/self-review-and-context-hygiene.md +1 -0
  24. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +108 -1
  25. package/presets/claude/android-kotlin/agents/build-verifier.md +1 -1
  26. package/presets/claude/android-kotlin/agents/code-reviewer.md +1 -1
  27. package/presets/claude/android-kotlin/agents/debugger.md +1 -1
  28. package/presets/claude/android-kotlin/agents/feature-developer.md +1 -1
  29. package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
  30. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +108 -1
  31. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-intake.md +2 -2
  32. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  33. package/presets/claude/go/agents/build-verifier.md +1 -1
  34. package/presets/claude/go/agents/code-reviewer.md +1 -1
  35. package/presets/claude/go/agents/debugger.md +1 -1
  36. package/presets/claude/go/agents/feature-developer.md +1 -1
  37. package/presets/claude/go/agents/task-analyst.md +1 -1
  38. package/presets/claude/go/hooks/chain-team-phases.sh +108 -1
  39. package/presets/claude/go/rules/architecture/feature-delivery.md +1 -1
  40. package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +2 -2
  41. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  42. package/presets/claude/ios-swift/agents/build-verifier.md +1 -1
  43. package/presets/claude/ios-swift/agents/code-reviewer.md +1 -1
  44. package/presets/claude/ios-swift/agents/debugger.md +1 -1
  45. package/presets/claude/ios-swift/agents/feature-developer.md +1 -1
  46. package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
  47. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +108 -1
  48. package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +1 -1
  49. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +2 -2
  50. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  51. package/presets/claude/java/agents/build-verifier.md +1 -1
  52. package/presets/claude/java/agents/code-reviewer.md +1 -1
  53. package/presets/claude/java/agents/debugger.md +1 -1
  54. package/presets/claude/java/agents/feature-developer.md +1 -1
  55. package/presets/claude/java/agents/task-analyst.md +1 -1
  56. package/presets/claude/java/hooks/chain-team-phases.sh +108 -1
  57. package/presets/claude/java/rules/architecture/feature-delivery.md +1 -1
  58. package/presets/claude/java/rules/tooling-and-review/agent-team-intake.md +2 -2
  59. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  60. package/presets/claude/mcp-ts/agents/build-verifier.md +1 -1
  61. package/presets/claude/mcp-ts/agents/feature-developer.md +1 -1
  62. package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
  63. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +108 -1
  64. package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +1 -1
  65. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +2 -2
  66. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  67. package/presets/claude/mol/agents/build-verifier.md +1 -1
  68. package/presets/claude/mol/agents/code-reviewer.md +1 -1
  69. package/presets/claude/mol/agents/debugger.md +1 -1
  70. package/presets/claude/mol/agents/feature-developer.md +1 -1
  71. package/presets/claude/mol/agents/task-analyst.md +1 -1
  72. package/presets/claude/mol/hooks/chain-team-phases.sh +108 -1
  73. package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +1 -1
  74. package/presets/claude/mol/rules/tooling-and-review/agent-team-intake.md +2 -2
  75. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  76. package/presets/claude/next/REPO_AGENTS.md +16 -0
  77. package/presets/claude/next/agents/README.md +4 -3
  78. package/presets/claude/next/agents/accessibility-reviewer.md +4 -1
  79. package/presets/claude/next/agents/api-contract-reviewer.md +6 -3
  80. package/presets/claude/next/agents/build-verifier.md +6 -3
  81. package/presets/claude/next/agents/ci-investigator.md +1 -1
  82. package/presets/claude/next/agents/code-reviewer.md +7 -4
  83. package/presets/claude/next/agents/codebase-analyzer.md +4 -1
  84. package/presets/claude/next/agents/debugger.md +2 -2
  85. package/presets/claude/next/agents/feature-developer.md +2 -2
  86. package/presets/claude/next/agents/migration-specialist.md +4 -1
  87. package/presets/claude/next/agents/mockup-reviewer.md +5 -2
  88. package/presets/claude/next/agents/openspec-author.md +4 -1
  89. package/presets/claude/next/agents/performance-auditor.md +4 -1
  90. package/presets/claude/next/agents/playwright-test-generator.md +5 -2
  91. package/presets/claude/next/agents/playwright-test-healer.md +5 -2
  92. package/presets/claude/next/agents/playwright-test-planner.md +5 -2
  93. package/presets/claude/next/agents/qa-tester.md +5 -2
  94. package/presets/claude/next/agents/security-reviewer.md +4 -1
  95. package/presets/claude/next/agents/solution-architect.md +4 -1
  96. package/presets/claude/next/agents/task-analyst.md +5 -2
  97. package/presets/claude/next/agents/task-router.md +8 -5
  98. package/presets/claude/next/agents/tech-writer.md +4 -1
  99. package/presets/claude/next/agents/unit-test-generator.md +5 -2
  100. package/presets/claude/next/agents/unit-test-healer.md +5 -2
  101. package/presets/claude/next/agents/unit-test-planner.md +5 -2
  102. package/presets/claude/next/ai-local/conventions.md +26 -1
  103. package/presets/claude/next/hooks/chain-team-phases.sh +108 -1
  104. package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +2 -2
  105. package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +2 -2
  106. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  107. package/presets/claude/nuxt/agents/build-verifier.md +1 -1
  108. package/presets/claude/nuxt/agents/code-reviewer.md +1 -1
  109. package/presets/claude/nuxt/agents/debugger.md +1 -1
  110. package/presets/claude/nuxt/agents/feature-developer.md +1 -1
  111. package/presets/claude/nuxt/agents/task-analyst.md +1 -1
  112. package/presets/claude/nuxt/hooks/chain-team-phases.sh +108 -1
  113. package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +1 -1
  114. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-intake.md +2 -2
  115. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  116. package/presets/claude/php-hexagonal/agents/build-verifier.md +1 -1
  117. package/presets/claude/php-hexagonal/agents/code-reviewer.md +1 -1
  118. package/presets/claude/php-hexagonal/agents/debugger.md +1 -1
  119. package/presets/claude/php-hexagonal/agents/feature-developer.md +1 -1
  120. package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
  121. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +108 -1
  122. package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +1 -1
  123. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-intake.md +2 -2
  124. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  125. package/presets/claude/php-laravel/agents/build-verifier.md +1 -1
  126. package/presets/claude/php-laravel/agents/code-reviewer.md +1 -1
  127. package/presets/claude/php-laravel/agents/debugger.md +1 -1
  128. package/presets/claude/php-laravel/agents/feature-developer.md +1 -1
  129. package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
  130. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +108 -1
  131. package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +1 -1
  132. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-intake.md +2 -2
  133. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  134. package/presets/claude/svelte/agents/build-verifier.md +1 -1
  135. package/presets/claude/svelte/agents/code-reviewer.md +1 -1
  136. package/presets/claude/svelte/agents/debugger.md +1 -1
  137. package/presets/claude/svelte/agents/feature-developer.md +1 -1
  138. package/presets/claude/svelte/agents/task-analyst.md +1 -1
  139. package/presets/claude/svelte/hooks/chain-team-phases.sh +108 -1
  140. package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +1 -1
  141. package/presets/claude/svelte/rules/tooling-and-review/agent-team-intake.md +2 -2
  142. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
  143. package/presets/cursor/android-kotlin/agents/build-verifier.md +1 -1
  144. package/presets/cursor/android-kotlin/agents/code-reviewer.md +1 -1
  145. package/presets/cursor/android-kotlin/agents/debugger.md +1 -1
  146. package/presets/cursor/android-kotlin/agents/feature-developer.md +1 -1
  147. package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
  148. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +108 -1
  149. package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +2 -2
  150. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
  151. package/presets/cursor/go/agents/build-verifier.md +1 -1
  152. package/presets/cursor/go/agents/code-reviewer.md +1 -1
  153. package/presets/cursor/go/agents/debugger.md +1 -1
  154. package/presets/cursor/go/agents/feature-developer.md +1 -1
  155. package/presets/cursor/go/agents/task-analyst.md +1 -1
  156. package/presets/cursor/go/hooks/chain-team-phases.sh +108 -1
  157. package/presets/cursor/go/rules/agent-team-intake.mdc +2 -2
  158. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
  159. package/presets/cursor/ios-swift/agents/build-verifier.md +1 -1
  160. package/presets/cursor/ios-swift/agents/code-reviewer.md +1 -1
  161. package/presets/cursor/ios-swift/agents/debugger.md +1 -1
  162. package/presets/cursor/ios-swift/agents/feature-developer.md +1 -1
  163. package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
  164. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +108 -1
  165. package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +2 -2
  166. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
  167. package/presets/cursor/java/agents/build-verifier.md +1 -1
  168. package/presets/cursor/java/agents/code-reviewer.md +1 -1
  169. package/presets/cursor/java/agents/debugger.md +1 -1
  170. package/presets/cursor/java/agents/feature-developer.md +1 -1
  171. package/presets/cursor/java/agents/task-analyst.md +1 -1
  172. package/presets/cursor/java/hooks/chain-team-phases.sh +108 -1
  173. package/presets/cursor/java/rules/agent-team-intake.mdc +2 -2
  174. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
  175. package/presets/cursor/mcp-ts/agents/build-verifier.md +1 -1
  176. package/presets/cursor/mcp-ts/agents/feature-developer.md +1 -1
  177. package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
  178. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +108 -1
  179. package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +2 -2
  180. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
  181. package/presets/cursor/mol/agents/build-verifier.md +1 -1
  182. package/presets/cursor/mol/agents/code-reviewer.md +1 -1
  183. package/presets/cursor/mol/agents/debugger.md +1 -1
  184. package/presets/cursor/mol/agents/feature-developer.md +1 -1
  185. package/presets/cursor/mol/agents/task-analyst.md +1 -1
  186. package/presets/cursor/mol/hooks/chain-team-phases.sh +108 -1
  187. package/presets/cursor/mol/rules/agent-team-intake.mdc +2 -2
  188. package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
  189. package/presets/cursor/next/AGENTS.md +2 -1
  190. package/presets/cursor/next/REPO_AGENTS.md +16 -0
  191. package/presets/cursor/next/agents/README.md +4 -3
  192. package/presets/cursor/next/agents/api-contract-reviewer.md +1 -1
  193. package/presets/cursor/next/agents/build-verifier.md +1 -1
  194. package/presets/cursor/next/agents/code-reviewer.md +1 -1
  195. package/presets/cursor/next/agents/debugger.md +1 -1
  196. package/presets/cursor/next/agents/feature-developer.md +1 -1
  197. package/presets/cursor/next/agents/mockup-reviewer.md +1 -1
  198. package/presets/cursor/next/agents/task-analyst.md +1 -1
  199. package/presets/cursor/next/agents/task-router.md +4 -4
  200. package/presets/cursor/next/ai-local/conventions.md +6 -1
  201. package/presets/cursor/next/hooks/chain-team-phases.sh +108 -1
  202. package/presets/cursor/next/rules/agent-team-intake.mdc +2 -2
  203. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +1 -1
  204. package/presets/cursor/next/rules/feature-delivery-workflow.mdc +1 -1
  205. package/presets/cursor/nuxt/agents/build-verifier.md +1 -1
  206. package/presets/cursor/nuxt/agents/code-reviewer.md +1 -1
  207. package/presets/cursor/nuxt/agents/debugger.md +1 -1
  208. package/presets/cursor/nuxt/agents/feature-developer.md +1 -1
  209. package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
  210. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +108 -1
  211. package/presets/cursor/nuxt/rules/agent-team-intake.mdc +2 -2
  212. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
  213. package/presets/cursor/php-hexagonal/agents/build-verifier.md +1 -1
  214. package/presets/cursor/php-hexagonal/agents/code-reviewer.md +1 -1
  215. package/presets/cursor/php-hexagonal/agents/debugger.md +1 -1
  216. package/presets/cursor/php-hexagonal/agents/feature-developer.md +1 -1
  217. package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
  218. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +108 -1
  219. package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +2 -2
  220. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
  221. package/presets/cursor/php-laravel/agents/build-verifier.md +1 -1
  222. package/presets/cursor/php-laravel/agents/code-reviewer.md +1 -1
  223. package/presets/cursor/php-laravel/agents/debugger.md +1 -1
  224. package/presets/cursor/php-laravel/agents/feature-developer.md +1 -1
  225. package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
  226. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +108 -1
  227. package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +2 -2
  228. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
  229. package/presets/cursor/svelte/agents/build-verifier.md +1 -1
  230. package/presets/cursor/svelte/agents/code-reviewer.md +1 -1
  231. package/presets/cursor/svelte/agents/debugger.md +1 -1
  232. package/presets/cursor/svelte/agents/feature-developer.md +1 -1
  233. package/presets/cursor/svelte/agents/task-analyst.md +1 -1
  234. package/presets/cursor/svelte/hooks/chain-team-phases.sh +108 -1
  235. package/presets/cursor/svelte/rules/agent-team-intake.mdc +2 -2
  236. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
  237. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  238. package/presets/mavis/android-kotlin/agents/README.md +3 -3
  239. package/presets/mavis/android-kotlin/agents/build-verifier.md +1 -1
  240. package/presets/mavis/android-kotlin/agents/code-reviewer.md +1 -1
  241. package/presets/mavis/android-kotlin/agents/debugger.md +1 -1
  242. package/presets/mavis/android-kotlin/agents/feature-developer.md +1 -1
  243. package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
  244. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +108 -1
  245. package/presets/mavis/android-kotlin/rules/agent-team-intake.md +2 -2
  246. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +5 -4
  247. package/presets/mavis/go/adapter-map.json +1 -1
  248. package/presets/mavis/go/agents/README.md +2 -2
  249. package/presets/mavis/go/agents/build-verifier.md +1 -1
  250. package/presets/mavis/go/agents/code-reviewer.md +1 -1
  251. package/presets/mavis/go/agents/debugger.md +1 -1
  252. package/presets/mavis/go/agents/feature-developer.md +1 -1
  253. package/presets/mavis/go/agents/task-analyst.md +1 -1
  254. package/presets/mavis/go/hooks/chain-team-phases.sh +108 -1
  255. package/presets/mavis/go/rules/agent-team-intake.md +2 -2
  256. package/presets/mavis/go/rules/agent-team-orchestrator.md +5 -4
  257. package/presets/mavis/go/rules/feature-delivery-workflow.md +1 -1
  258. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  259. package/presets/mavis/ios-swift/agents/README.md +3 -3
  260. package/presets/mavis/ios-swift/agents/build-verifier.md +1 -1
  261. package/presets/mavis/ios-swift/agents/code-reviewer.md +1 -1
  262. package/presets/mavis/ios-swift/agents/debugger.md +1 -1
  263. package/presets/mavis/ios-swift/agents/feature-developer.md +1 -1
  264. package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
  265. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +108 -1
  266. package/presets/mavis/ios-swift/rules/agent-team-intake.md +2 -2
  267. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +5 -4
  268. package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +1 -1
  269. package/presets/mavis/java/adapter-map.json +1 -1
  270. package/presets/mavis/java/agents/README.md +2 -2
  271. package/presets/mavis/java/agents/build-verifier.md +1 -1
  272. package/presets/mavis/java/agents/code-reviewer.md +1 -1
  273. package/presets/mavis/java/agents/debugger.md +1 -1
  274. package/presets/mavis/java/agents/feature-developer.md +1 -1
  275. package/presets/mavis/java/agents/task-analyst.md +1 -1
  276. package/presets/mavis/java/hooks/chain-team-phases.sh +108 -1
  277. package/presets/mavis/java/rules/agent-team-intake.md +2 -2
  278. package/presets/mavis/java/rules/agent-team-orchestrator.md +5 -4
  279. package/presets/mavis/java/rules/feature-delivery-workflow.md +1 -1
  280. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  281. package/presets/mavis/mcp-ts/agents/README.md +1 -1
  282. package/presets/mavis/mcp-ts/agents/build-verifier.md +1 -1
  283. package/presets/mavis/mcp-ts/agents/feature-developer.md +1 -1
  284. package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
  285. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +108 -1
  286. package/presets/mavis/mcp-ts/rules/agent-team-intake.md +2 -2
  287. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +5 -4
  288. package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +1 -1
  289. package/presets/mavis/mol/adapter-map.json +1 -1
  290. package/presets/mavis/mol/agents/README.md +3 -3
  291. package/presets/mavis/mol/agents/build-verifier.md +1 -1
  292. package/presets/mavis/mol/agents/code-reviewer.md +1 -1
  293. package/presets/mavis/mol/agents/debugger.md +1 -1
  294. package/presets/mavis/mol/agents/feature-developer.md +1 -1
  295. package/presets/mavis/mol/agents/task-analyst.md +1 -1
  296. package/presets/mavis/mol/hooks/chain-team-phases.sh +108 -1
  297. package/presets/mavis/mol/rules/agent-team-intake.md +2 -2
  298. package/presets/mavis/mol/rules/agent-team-orchestrator.md +5 -4
  299. package/presets/mavis/mol/rules/feature-delivery-workflow.md +1 -1
  300. package/presets/mavis/next/MAVIS.md +2 -1
  301. package/presets/mavis/next/REPO_AGENTS.md +16 -0
  302. package/presets/mavis/next/adapter-map.json +1 -1
  303. package/presets/mavis/next/agents/README.md +3 -3
  304. package/presets/mavis/next/agents/accessibility-reviewer.md +4 -1
  305. package/presets/mavis/next/agents/api-contract-reviewer.md +5 -2
  306. package/presets/mavis/next/agents/build-verifier.md +6 -3
  307. package/presets/mavis/next/agents/ci-investigator.md +1 -1
  308. package/presets/mavis/next/agents/code-reviewer.md +7 -4
  309. package/presets/mavis/next/agents/codebase-analyzer.md +4 -1
  310. package/presets/mavis/next/agents/debugger.md +2 -2
  311. package/presets/mavis/next/agents/feature-developer.md +2 -2
  312. package/presets/mavis/next/agents/migration-specialist.md +4 -1
  313. package/presets/mavis/next/agents/mockup-reviewer.md +4 -1
  314. package/presets/mavis/next/agents/openspec-author.md +4 -1
  315. package/presets/mavis/next/agents/performance-auditor.md +4 -1
  316. package/presets/mavis/next/agents/playwright-test-generator.md +5 -2
  317. package/presets/mavis/next/agents/playwright-test-healer.md +5 -2
  318. package/presets/mavis/next/agents/playwright-test-planner.md +5 -2
  319. package/presets/mavis/next/agents/qa-tester.md +5 -2
  320. package/presets/mavis/next/agents/security-reviewer.md +4 -1
  321. package/presets/mavis/next/agents/solution-architect.md +4 -1
  322. package/presets/mavis/next/agents/task-analyst.md +5 -2
  323. package/presets/mavis/next/agents/task-router.md +8 -5
  324. package/presets/mavis/next/agents/tech-writer.md +4 -1
  325. package/presets/mavis/next/agents/unit-test-generator.md +5 -2
  326. package/presets/mavis/next/agents/unit-test-healer.md +5 -2
  327. package/presets/mavis/next/agents/unit-test-planner.md +5 -2
  328. package/presets/mavis/next/ai-local/conventions.md +6 -1
  329. package/presets/mavis/next/hooks/chain-team-phases.sh +108 -1
  330. package/presets/mavis/next/rules/agent-team-intake.md +2 -2
  331. package/presets/mavis/next/rules/agent-team-orchestrator.md +5 -4
  332. package/presets/mavis/next/rules/feature-delivery-workflow.md +2 -2
  333. package/presets/mavis/nuxt/adapter-map.json +1 -1
  334. package/presets/mavis/nuxt/agents/README.md +3 -3
  335. package/presets/mavis/nuxt/agents/build-verifier.md +1 -1
  336. package/presets/mavis/nuxt/agents/code-reviewer.md +1 -1
  337. package/presets/mavis/nuxt/agents/debugger.md +1 -1
  338. package/presets/mavis/nuxt/agents/feature-developer.md +1 -1
  339. package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
  340. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +108 -1
  341. package/presets/mavis/nuxt/rules/agent-team-intake.md +2 -2
  342. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +5 -4
  343. package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +1 -1
  344. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  345. package/presets/mavis/php-hexagonal/agents/README.md +2 -2
  346. package/presets/mavis/php-hexagonal/agents/build-verifier.md +1 -1
  347. package/presets/mavis/php-hexagonal/agents/code-reviewer.md +1 -1
  348. package/presets/mavis/php-hexagonal/agents/debugger.md +1 -1
  349. package/presets/mavis/php-hexagonal/agents/feature-developer.md +1 -1
  350. package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
  351. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +108 -1
  352. package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +2 -2
  353. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +5 -4
  354. package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +1 -1
  355. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  356. package/presets/mavis/php-laravel/agents/README.md +2 -2
  357. package/presets/mavis/php-laravel/agents/build-verifier.md +1 -1
  358. package/presets/mavis/php-laravel/agents/code-reviewer.md +1 -1
  359. package/presets/mavis/php-laravel/agents/debugger.md +1 -1
  360. package/presets/mavis/php-laravel/agents/feature-developer.md +1 -1
  361. package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
  362. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +108 -1
  363. package/presets/mavis/php-laravel/rules/agent-team-intake.md +2 -2
  364. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +5 -4
  365. package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +1 -1
  366. package/presets/mavis/svelte/adapter-map.json +1 -1
  367. package/presets/mavis/svelte/agents/README.md +3 -3
  368. package/presets/mavis/svelte/agents/build-verifier.md +1 -1
  369. package/presets/mavis/svelte/agents/code-reviewer.md +1 -1
  370. package/presets/mavis/svelte/agents/debugger.md +1 -1
  371. package/presets/mavis/svelte/agents/feature-developer.md +1 -1
  372. package/presets/mavis/svelte/agents/task-analyst.md +1 -1
  373. package/presets/mavis/svelte/hooks/chain-team-phases.sh +108 -1
  374. package/presets/mavis/svelte/rules/agent-team-intake.md +2 -2
  375. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +5 -4
  376. package/presets/mavis/svelte/rules/feature-delivery-workflow.md +1 -1
  377. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  378. package/presets/opencode/android-kotlin/agents/README.md +4 -4
  379. package/presets/opencode/android-kotlin/agents/build-verifier.md +1 -1
  380. package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -1
  381. package/presets/opencode/android-kotlin/agents/debugger.md +1 -1
  382. package/presets/opencode/android-kotlin/agents/feature-developer.md +1 -1
  383. package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
  384. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +108 -1
  385. package/presets/opencode/android-kotlin/rules/agent-team-intake.md +2 -2
  386. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +5 -4
  387. package/presets/opencode/go/adapter-map.json +1 -1
  388. package/presets/opencode/go/agents/README.md +3 -3
  389. package/presets/opencode/go/agents/build-verifier.md +1 -1
  390. package/presets/opencode/go/agents/code-reviewer.md +1 -1
  391. package/presets/opencode/go/agents/debugger.md +1 -1
  392. package/presets/opencode/go/agents/feature-developer.md +1 -1
  393. package/presets/opencode/go/agents/task-analyst.md +1 -1
  394. package/presets/opencode/go/hooks/chain-team-phases.sh +108 -1
  395. package/presets/opencode/go/rules/agent-team-intake.md +2 -2
  396. package/presets/opencode/go/rules/agent-team-orchestrator.md +5 -4
  397. package/presets/opencode/go/rules/feature-delivery-workflow.md +1 -1
  398. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  399. package/presets/opencode/ios-swift/agents/README.md +4 -4
  400. package/presets/opencode/ios-swift/agents/build-verifier.md +1 -1
  401. package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -1
  402. package/presets/opencode/ios-swift/agents/debugger.md +1 -1
  403. package/presets/opencode/ios-swift/agents/feature-developer.md +1 -1
  404. package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
  405. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +108 -1
  406. package/presets/opencode/ios-swift/rules/agent-team-intake.md +2 -2
  407. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +5 -4
  408. package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +1 -1
  409. package/presets/opencode/java/adapter-map.json +1 -1
  410. package/presets/opencode/java/agents/README.md +3 -3
  411. package/presets/opencode/java/agents/build-verifier.md +1 -1
  412. package/presets/opencode/java/agents/code-reviewer.md +1 -1
  413. package/presets/opencode/java/agents/debugger.md +1 -1
  414. package/presets/opencode/java/agents/feature-developer.md +1 -1
  415. package/presets/opencode/java/agents/task-analyst.md +1 -1
  416. package/presets/opencode/java/hooks/chain-team-phases.sh +108 -1
  417. package/presets/opencode/java/rules/agent-team-intake.md +2 -2
  418. package/presets/opencode/java/rules/agent-team-orchestrator.md +5 -4
  419. package/presets/opencode/java/rules/feature-delivery-workflow.md +1 -1
  420. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  421. package/presets/opencode/mcp-ts/agents/README.md +2 -2
  422. package/presets/opencode/mcp-ts/agents/build-verifier.md +1 -1
  423. package/presets/opencode/mcp-ts/agents/feature-developer.md +1 -1
  424. package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
  425. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +108 -1
  426. package/presets/opencode/mcp-ts/rules/agent-team-intake.md +2 -2
  427. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +5 -4
  428. package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +1 -1
  429. package/presets/opencode/mol/adapter-map.json +1 -1
  430. package/presets/opencode/mol/agents/README.md +4 -4
  431. package/presets/opencode/mol/agents/build-verifier.md +1 -1
  432. package/presets/opencode/mol/agents/code-reviewer.md +1 -1
  433. package/presets/opencode/mol/agents/debugger.md +1 -1
  434. package/presets/opencode/mol/agents/feature-developer.md +1 -1
  435. package/presets/opencode/mol/agents/task-analyst.md +1 -1
  436. package/presets/opencode/mol/hooks/chain-team-phases.sh +108 -1
  437. package/presets/opencode/mol/rules/agent-team-intake.md +2 -2
  438. package/presets/opencode/mol/rules/agent-team-orchestrator.md +5 -4
  439. package/presets/opencode/mol/rules/feature-delivery-workflow.md +1 -1
  440. package/presets/opencode/next/OPENCODE.md +2 -1
  441. package/presets/opencode/next/REPO_AGENTS.md +16 -0
  442. package/presets/opencode/next/adapter-map.json +1 -1
  443. package/presets/opencode/next/agents/README.md +4 -4
  444. package/presets/opencode/next/agents/accessibility-reviewer.md +4 -1
  445. package/presets/opencode/next/agents/api-contract-reviewer.md +5 -2
  446. package/presets/opencode/next/agents/build-verifier.md +6 -3
  447. package/presets/opencode/next/agents/ci-investigator.md +1 -1
  448. package/presets/opencode/next/agents/code-reviewer.md +7 -4
  449. package/presets/opencode/next/agents/codebase-analyzer.md +4 -1
  450. package/presets/opencode/next/agents/debugger.md +2 -2
  451. package/presets/opencode/next/agents/feature-developer.md +2 -2
  452. package/presets/opencode/next/agents/migration-specialist.md +4 -1
  453. package/presets/opencode/next/agents/mockup-reviewer.md +4 -1
  454. package/presets/opencode/next/agents/openspec-author.md +4 -1
  455. package/presets/opencode/next/agents/performance-auditor.md +4 -1
  456. package/presets/opencode/next/agents/playwright-test-generator.md +5 -2
  457. package/presets/opencode/next/agents/playwright-test-healer.md +5 -2
  458. package/presets/opencode/next/agents/playwright-test-planner.md +5 -2
  459. package/presets/opencode/next/agents/qa-tester.md +5 -2
  460. package/presets/opencode/next/agents/security-reviewer.md +4 -1
  461. package/presets/opencode/next/agents/solution-architect.md +4 -1
  462. package/presets/opencode/next/agents/task-analyst.md +5 -2
  463. package/presets/opencode/next/agents/task-router.md +8 -5
  464. package/presets/opencode/next/agents/tech-writer.md +4 -1
  465. package/presets/opencode/next/agents/unit-test-generator.md +5 -2
  466. package/presets/opencode/next/agents/unit-test-healer.md +5 -2
  467. package/presets/opencode/next/agents/unit-test-planner.md +5 -2
  468. package/presets/opencode/next/ai-local/conventions.md +6 -1
  469. package/presets/opencode/next/hooks/chain-team-phases.sh +108 -1
  470. package/presets/opencode/next/rules/agent-team-intake.md +2 -2
  471. package/presets/opencode/next/rules/agent-team-orchestrator.md +5 -4
  472. package/presets/opencode/next/rules/feature-delivery-workflow.md +2 -2
  473. package/presets/opencode/nuxt/adapter-map.json +1 -1
  474. package/presets/opencode/nuxt/agents/README.md +4 -4
  475. package/presets/opencode/nuxt/agents/build-verifier.md +1 -1
  476. package/presets/opencode/nuxt/agents/code-reviewer.md +1 -1
  477. package/presets/opencode/nuxt/agents/debugger.md +1 -1
  478. package/presets/opencode/nuxt/agents/feature-developer.md +1 -1
  479. package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
  480. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +108 -1
  481. package/presets/opencode/nuxt/rules/agent-team-intake.md +2 -2
  482. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +5 -4
  483. package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +1 -1
  484. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  485. package/presets/opencode/php-hexagonal/agents/README.md +3 -3
  486. package/presets/opencode/php-hexagonal/agents/build-verifier.md +1 -1
  487. package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -1
  488. package/presets/opencode/php-hexagonal/agents/debugger.md +1 -1
  489. package/presets/opencode/php-hexagonal/agents/feature-developer.md +1 -1
  490. package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
  491. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +108 -1
  492. package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +2 -2
  493. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +5 -4
  494. package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +1 -1
  495. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  496. package/presets/opencode/php-laravel/agents/README.md +3 -3
  497. package/presets/opencode/php-laravel/agents/build-verifier.md +1 -1
  498. package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -1
  499. package/presets/opencode/php-laravel/agents/debugger.md +1 -1
  500. package/presets/opencode/php-laravel/agents/feature-developer.md +1 -1
  501. package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
  502. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +108 -1
  503. package/presets/opencode/php-laravel/rules/agent-team-intake.md +2 -2
  504. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +5 -4
  505. package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +1 -1
  506. package/presets/opencode/plugins/output-guard/README.md +25 -6
  507. package/presets/opencode/plugins/output-guard/index.ts +27 -9
  508. package/presets/opencode/plugins/output-guard/rewrite.ts +113 -4
  509. package/presets/opencode/svelte/adapter-map.json +1 -1
  510. package/presets/opencode/svelte/agents/README.md +4 -4
  511. package/presets/opencode/svelte/agents/build-verifier.md +1 -1
  512. package/presets/opencode/svelte/agents/code-reviewer.md +1 -1
  513. package/presets/opencode/svelte/agents/debugger.md +1 -1
  514. package/presets/opencode/svelte/agents/feature-developer.md +1 -1
  515. package/presets/opencode/svelte/agents/task-analyst.md +1 -1
  516. package/presets/opencode/svelte/hooks/chain-team-phases.sh +108 -1
  517. package/presets/opencode/svelte/rules/agent-team-intake.md +2 -2
  518. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +5 -4
  519. package/presets/opencode/svelte/rules/feature-delivery-workflow.md +1 -1
  520. package/presets/zcode/android-kotlin/adapter-map.json +1 -1
  521. package/presets/zcode/android-kotlin/agents/README.md +3 -3
  522. package/presets/zcode/android-kotlin/agents/build-verifier.md +1 -1
  523. package/presets/zcode/android-kotlin/agents/code-reviewer.md +1 -1
  524. package/presets/zcode/android-kotlin/agents/debugger.md +1 -1
  525. package/presets/zcode/android-kotlin/agents/feature-developer.md +1 -1
  526. package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
  527. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +108 -1
  528. package/presets/zcode/android-kotlin/rules/agent-team-intake.md +2 -2
  529. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +5 -4
  530. package/presets/zcode/go/adapter-map.json +1 -1
  531. package/presets/zcode/go/agents/README.md +2 -2
  532. package/presets/zcode/go/agents/build-verifier.md +1 -1
  533. package/presets/zcode/go/agents/code-reviewer.md +1 -1
  534. package/presets/zcode/go/agents/debugger.md +1 -1
  535. package/presets/zcode/go/agents/feature-developer.md +1 -1
  536. package/presets/zcode/go/agents/task-analyst.md +1 -1
  537. package/presets/zcode/go/hooks/chain-team-phases.sh +108 -1
  538. package/presets/zcode/go/rules/agent-team-intake.md +2 -2
  539. package/presets/zcode/go/rules/agent-team-orchestrator.md +5 -4
  540. package/presets/zcode/go/rules/feature-delivery-workflow.md +1 -1
  541. package/presets/zcode/ios-swift/adapter-map.json +1 -1
  542. package/presets/zcode/ios-swift/agents/README.md +3 -3
  543. package/presets/zcode/ios-swift/agents/build-verifier.md +1 -1
  544. package/presets/zcode/ios-swift/agents/code-reviewer.md +1 -1
  545. package/presets/zcode/ios-swift/agents/debugger.md +1 -1
  546. package/presets/zcode/ios-swift/agents/feature-developer.md +1 -1
  547. package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
  548. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +108 -1
  549. package/presets/zcode/ios-swift/rules/agent-team-intake.md +2 -2
  550. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +5 -4
  551. package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +1 -1
  552. package/presets/zcode/java/adapter-map.json +1 -1
  553. package/presets/zcode/java/agents/README.md +2 -2
  554. package/presets/zcode/java/agents/build-verifier.md +1 -1
  555. package/presets/zcode/java/agents/code-reviewer.md +1 -1
  556. package/presets/zcode/java/agents/debugger.md +1 -1
  557. package/presets/zcode/java/agents/feature-developer.md +1 -1
  558. package/presets/zcode/java/agents/task-analyst.md +1 -1
  559. package/presets/zcode/java/hooks/chain-team-phases.sh +108 -1
  560. package/presets/zcode/java/rules/agent-team-intake.md +2 -2
  561. package/presets/zcode/java/rules/agent-team-orchestrator.md +5 -4
  562. package/presets/zcode/java/rules/feature-delivery-workflow.md +1 -1
  563. package/presets/zcode/mcp-ts/adapter-map.json +1 -1
  564. package/presets/zcode/mcp-ts/agents/README.md +1 -1
  565. package/presets/zcode/mcp-ts/agents/build-verifier.md +1 -1
  566. package/presets/zcode/mcp-ts/agents/feature-developer.md +1 -1
  567. package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
  568. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +108 -1
  569. package/presets/zcode/mcp-ts/rules/agent-team-intake.md +2 -2
  570. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +5 -4
  571. package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +1 -1
  572. package/presets/zcode/mol/adapter-map.json +1 -1
  573. package/presets/zcode/mol/agents/README.md +3 -3
  574. package/presets/zcode/mol/agents/build-verifier.md +1 -1
  575. package/presets/zcode/mol/agents/code-reviewer.md +1 -1
  576. package/presets/zcode/mol/agents/debugger.md +1 -1
  577. package/presets/zcode/mol/agents/feature-developer.md +1 -1
  578. package/presets/zcode/mol/agents/task-analyst.md +1 -1
  579. package/presets/zcode/mol/hooks/chain-team-phases.sh +108 -1
  580. package/presets/zcode/mol/rules/agent-team-intake.md +2 -2
  581. package/presets/zcode/mol/rules/agent-team-orchestrator.md +5 -4
  582. package/presets/zcode/mol/rules/feature-delivery-workflow.md +1 -1
  583. package/presets/zcode/next/REPO_AGENTS.md +16 -0
  584. package/presets/zcode/next/adapter-map.json +1 -1
  585. package/presets/zcode/next/agents/README.md +3 -3
  586. package/presets/zcode/next/agents/accessibility-reviewer.md +4 -1
  587. package/presets/zcode/next/agents/api-contract-reviewer.md +5 -2
  588. package/presets/zcode/next/agents/build-verifier.md +6 -3
  589. package/presets/zcode/next/agents/ci-investigator.md +1 -1
  590. package/presets/zcode/next/agents/code-reviewer.md +7 -4
  591. package/presets/zcode/next/agents/codebase-analyzer.md +4 -1
  592. package/presets/zcode/next/agents/debugger.md +2 -2
  593. package/presets/zcode/next/agents/feature-developer.md +2 -2
  594. package/presets/zcode/next/agents/migration-specialist.md +4 -1
  595. package/presets/zcode/next/agents/mockup-reviewer.md +4 -1
  596. package/presets/zcode/next/agents/openspec-author.md +4 -1
  597. package/presets/zcode/next/agents/performance-auditor.md +4 -1
  598. package/presets/zcode/next/agents/playwright-test-generator.md +5 -2
  599. package/presets/zcode/next/agents/playwright-test-healer.md +5 -2
  600. package/presets/zcode/next/agents/playwright-test-planner.md +5 -2
  601. package/presets/zcode/next/agents/qa-tester.md +5 -2
  602. package/presets/zcode/next/agents/security-reviewer.md +4 -1
  603. package/presets/zcode/next/agents/solution-architect.md +4 -1
  604. package/presets/zcode/next/agents/task-analyst.md +5 -2
  605. package/presets/zcode/next/agents/task-router.md +8 -5
  606. package/presets/zcode/next/agents/tech-writer.md +4 -1
  607. package/presets/zcode/next/agents/unit-test-generator.md +5 -2
  608. package/presets/zcode/next/agents/unit-test-healer.md +5 -2
  609. package/presets/zcode/next/agents/unit-test-planner.md +5 -2
  610. package/presets/zcode/next/ai-local/conventions.md +6 -1
  611. package/presets/zcode/next/hooks/chain-team-phases.sh +108 -1
  612. package/presets/zcode/next/rules/agent-team-intake.md +2 -2
  613. package/presets/zcode/next/rules/agent-team-orchestrator.md +5 -4
  614. package/presets/zcode/next/rules/feature-delivery-workflow.md +2 -2
  615. package/presets/zcode/nuxt/adapter-map.json +1 -1
  616. package/presets/zcode/nuxt/agents/README.md +3 -3
  617. package/presets/zcode/nuxt/agents/build-verifier.md +1 -1
  618. package/presets/zcode/nuxt/agents/code-reviewer.md +1 -1
  619. package/presets/zcode/nuxt/agents/debugger.md +1 -1
  620. package/presets/zcode/nuxt/agents/feature-developer.md +1 -1
  621. package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
  622. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +108 -1
  623. package/presets/zcode/nuxt/rules/agent-team-intake.md +2 -2
  624. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +5 -4
  625. package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +1 -1
  626. package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
  627. package/presets/zcode/php-hexagonal/agents/README.md +2 -2
  628. package/presets/zcode/php-hexagonal/agents/build-verifier.md +1 -1
  629. package/presets/zcode/php-hexagonal/agents/code-reviewer.md +1 -1
  630. package/presets/zcode/php-hexagonal/agents/debugger.md +1 -1
  631. package/presets/zcode/php-hexagonal/agents/feature-developer.md +1 -1
  632. package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
  633. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +108 -1
  634. package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +2 -2
  635. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +5 -4
  636. package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +1 -1
  637. package/presets/zcode/php-laravel/adapter-map.json +1 -1
  638. package/presets/zcode/php-laravel/agents/README.md +2 -2
  639. package/presets/zcode/php-laravel/agents/build-verifier.md +1 -1
  640. package/presets/zcode/php-laravel/agents/code-reviewer.md +1 -1
  641. package/presets/zcode/php-laravel/agents/debugger.md +1 -1
  642. package/presets/zcode/php-laravel/agents/feature-developer.md +1 -1
  643. package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
  644. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +108 -1
  645. package/presets/zcode/php-laravel/rules/agent-team-intake.md +2 -2
  646. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +5 -4
  647. package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +1 -1
  648. package/presets/zcode/svelte/adapter-map.json +1 -1
  649. package/presets/zcode/svelte/agents/README.md +3 -3
  650. package/presets/zcode/svelte/agents/build-verifier.md +1 -1
  651. package/presets/zcode/svelte/agents/code-reviewer.md +1 -1
  652. package/presets/zcode/svelte/agents/debugger.md +1 -1
  653. package/presets/zcode/svelte/agents/feature-developer.md +1 -1
  654. package/presets/zcode/svelte/agents/task-analyst.md +1 -1
  655. package/presets/zcode/svelte/hooks/chain-team-phases.sh +108 -1
  656. package/presets/zcode/svelte/rules/agent-team-intake.md +2 -2
  657. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +5 -4
  658. package/presets/zcode/svelte/rules/feature-delivery-workflow.md +1 -1
  659. package/scripts/aggregate-agent-task-metrics.mjs +201 -0
  660. package/scripts/report-context-cost.mjs +126 -0
@@ -234,6 +234,15 @@ Append-only `.ai.local/team/tasks/<slug>/review-ledger.md`.
234
234
 
235
235
  The producer appends a row when a self-review defect changes the output (`source: self`, `fair: yes`, `fixed`). `code-reviewer` appends each finding (`disposition: open`). The orchestrator appends a user or other-agent objection from `prompt-log.md` or `/task-continue`. `fixed` ⇒ `fair: yes`. `rejected` ⇒ `fair: no` and the row cites the rebuttal. `open` at outcome time ⇒ `fair: yes`.
236
236
 
237
+ Write the header exactly as the table above spells it:
238
+
239
+ ```markdown
240
+ | id | at | source | summary | fair | disposition | evidence | signature |
241
+ |---|---|---|---|---|---|---|---|
242
+ ```
243
+
244
+ A table the projection cannot map is dropped from the database, so a producer that appends a row runs the gate: `node .ai.local/scripts/team-db.mjs ledger-check --slug <slug>`. Exit 0 means every task ledger parses; a non-zero exit names the file and the header it rejected. The parser also reads the legacy headers `seq`/`date`/`origin`/`finding`, `Date`/`Source`/`Finding`/`Fair`, and the sectioned `ID`/`Severity`/`Finding`/`Status` roll-up — a new table uses the canonical header.
245
+
237
246
  Register the path on the `routing` entry. The ledger is not a `status.json` or `metrics.json` field.
238
247
 
239
248
  ## Default producer → entry map
@@ -16,7 +16,7 @@ Each pipeline run owns `<team>/tasks/<slug>/metrics.json`:
16
16
 
17
17
  `events` is append-only. A task is one `runId`; a subtask is one invocation of `pipeline.steps[i]`. Every invocation has an `attemptId`, including each member of a parallel step. Events inherit the immutable task dimensions rather than duplicating them.
18
18
 
19
- Allowed event types are `task_started`, `attempt_started`, `attempt_finished`, `retry_scheduled`, `attempt_skipped`, `human_gate_started`, `human_gate_ended`, `pipeline_parse_error`, `task_completed`, `profile_changed`, `out_of_band_started`, `out_of_band_finished`, and the parallel events `parallel_wave_started`, `step_joined`, `parallel_attribution_repair`, `parallel_conflict_deferred`.
19
+ Allowed event types are `task_started`, `attempt_started`, `attempt_finished`, `retry_scheduled`, `attempt_skipped`, `human_gate_started`, `human_gate_ended`, `pipeline_parse_error`, `task_completed`, `profile_changed`, `out_of_band_started`, `out_of_band_finished`, `usage_recorded`, `verification_recorded`, `verification_stale`, and the parallel events `parallel_wave_started`, `step_joined`, `parallel_attribution_repair`, `parallel_conflict_deferred`.
20
20
 
21
21
  Outcome values, with their actual emission site:
22
22
 
@@ -57,3 +57,63 @@ A **wave** is the scheduling unit: one `parallel: true` step, or (in graph mode)
57
57
  - `parallel_attribution_repair` marks a stop the payload could not attribute that a fallback rule bound (`attemptIds[]`, `attributionConfidence: "fallback"`).
58
58
  - `parallel_conflict_deferred` marks a ready step the hook deferred because the ready set was not conflict-free or a member lacked declared scopes (`stepIndex`, `deferredStepIndexes[]`, `reason`). The hook defers and logs; it never blocks and never stalls.
59
59
  - Attribution always prefers the active attempt or an explicit receipt; `currentAgent` is only a third disambiguator and is always marked `fallback`.
60
+
61
+ ## Token usage
62
+
63
+ Tokens are optional evidence, never an estimate. A missing record stays missing
64
+ (`null`), not `0`; a token kind nobody reported stays `null` as well.
65
+
66
+ Two write paths exist, in precedence order:
67
+
68
+ 1. **Host object.** When the host exposes counts, put a `usage` object on the
69
+ `attempt_finished` receipt (the chain hook forwards `hookInput.usage`). The
70
+ hook allowlists the shape before the ledger sees it:
71
+ `{ input, output, reasoning, cacheRead, cacheWrite, costUsd, model, origin }`
72
+ — numbers are non-negative integers (or `null`), `model` is capped at 120
73
+ characters, `origin` is `measured` unless the host says `estimated`.
74
+ 2. **`usage_recorded` events.** When only some turns are observable, append one
75
+ event per turn next to the attempt (writer: `record-usage.mjs`):
76
+
77
+ ```bash
78
+ node .ai.local/scripts/record-usage.mjs --task <slug> --attempt <attemptId> \
79
+ --input <n> --output <n> [--cached <n>] [--cache-write <n>] [--reasoning <n>] \
80
+ [--turn <turnId>] [--model <id>]
81
+ ```
82
+
83
+ The projection collapses events per `turn` (latest wins) and sums the
84
+ survivors. A host object wins over `usage_recorded` rows for the same
85
+ attempt; the two are never added together.
86
+
87
+ `aggregate-agent-task-metrics.mjs` reports `usage` at the task, agent, and model
88
+ level with an explicit coverage ratio (`reportedAttempts / attempts`). Read a
89
+ partial coverage as "some turns were observable", never as a cost baseline.
90
+
91
+ ## Verification evidence
92
+
93
+ `validation-report.md` stays the human-readable narrative. The machine-checkable
94
+ half is `<team>/tasks/<slug>/verification.json` plus `evidence/*.log`, written by
95
+ the verifier with `verification.mjs`:
96
+
97
+ ```bash
98
+ node .ai.local/scripts/verification.mjs record --task <slug> \
99
+ --command "<exact command>" --exit <code> [--log <file>] [--agent <id>] [--attempt <attemptId>]
100
+ node .ai.local/scripts/verification.mjs check --task <slug> [--strict]
101
+ ```
102
+
103
+ - `record` appends one command entry (`id`, `command`, `exit`, `at`, optional
104
+ `logRef`/`logSha256`), stores a capped, secret-redacted log tail under
105
+ `evidence/`, and snapshots the git state (`head`, `branch`, `dirtyFiles`,
106
+ `worktreeHash`). `.ai.local/**` is excluded from the snapshot.
107
+ - `check` compares the stored snapshot with the current worktree:
108
+ `head-changed` / `worktree-changed` mean the evidence belongs to an older
109
+ tree. `--strict` exits `1` when stale and `2` when missing.
110
+ - When a `build-verifier` attempt finishes without an explicit `record`, the
111
+ chain hook seeds the file once (`gate.status: snapshot-only`): the git snapshot
112
+ plus a SHA-256 of `validation-report.md`, with `commands: []`. An existing file
113
+ is never refreshed, so its binding keeps pointing at the tree the commands ran
114
+ on.
115
+ - The chain hook warns at closure when a `verification.json` is stale and writes
116
+ one `verification_stale` event (`reasons[]`). It never blocks: re-running the
117
+ gate is the fix, not a new approval.
118
+ - `verification_recorded` marks each persisted command in the ledger; command
119
+ text stays out of `metrics.json`.
@@ -4,9 +4,9 @@ When the user message looks like a **work request** (implement, add, fix, refact
4
4
 
5
5
  1. Prefer **`/task <their request>`** or invoke **task-router** first.
6
6
  2. Do not jump straight to coding without router + pipeline when scope is non-trivial.
7
- 3. Pure questions (“how does X work”, “explain”) — prefer agent **`codebase-analyzer`** (explain-as-is); trivial one-liners may be answered inline. Do not open `/task`.
7
+ 3. A question that one read answers — “how does X work”, “explain this function” — is a **pure question**: answer inline, no file, no `/task`. A question that needs more than one read, or whose answer is written down, is a **research** request: route it to agent **`codebase-analyzer`** (explain-as-is) or a `spike` pipeline, and never open implementation steps for it. Where the always-on root agent file ships the research gate, it states this same boundary as a `MUST` (§ Research requests).
8
8
  4. A work request now runs the planning workflow — **goal frame → requirements → information-sufficiency → decompose** (dependency graph / epics); see **task-framing** and **plan-graph**.
9
- 5. Every **work request** — with or without `/task`, and even when the user says “no pipeline” / “just do it” — persists the **verbatim** original prompt at `.ai.local/team/tasks/<slug>/prompt.md`. Prefer `/task` (its **Slug** step writes it). If handling inline without `/task`, first create the slug dir and write `prompt.md` (write-if-absent), then proceed. Pure questions and trivial one-liners are not work requests → no file. On an inline follow-up for an existing slug (no `/task`) where the user authors new text, append it verbatim to `.ai.local/team/tasks/<slug>/prompt-log.md` (`seq` = max + 1; create on first append; exclude machine-generated and empty/argument-less invocations).
9
+ 5. Every **work request** — with or without `/task`, and even when the user says “no pipeline” / “just do it” — persists the **verbatim** original prompt at `.ai.local/team/tasks/<slug>/prompt.md`. Prefer `/task` (its **Slug** step writes it). If handling inline without `/task`, first create the slug dir and write `prompt.md` (write-if-absent), then proceed. Pure questions and trivial one-liners are not work requests → no file; a research request is one (rule 3). On an inline follow-up for an existing slug (no `/task`) where the user authors new text, append it verbatim to `.ai.local/team/tasks/<slug>/prompt-log.md` (`seq` = max + 1; create on first append; exclude machine-generated and empty/argument-less invocations).
10
10
  6. **Reuse the dialogue language already resolved on this turn** (always-on `ai-local-overlay` / **language-policy**). A question and a message without a slash command still resolve before you speak. When this request writes `prompt.md`, persist that tag once in the header (`language: <BCP-47>`) + a `.memlog.md` `event:` line. Development, reasoning, and artifacts stay English. The setting wins over a mid-task prompt switch (surface it once, never ask). See **language-policy**.
11
11
  7. **Project the intake write.** After `prompt.md` is written for an inline (non-`/task`) work request, run `node .ai.local/scripts/team-db.mjs sync --slug <slug> --deadline-ms 4500` once, so the new task row and its prompt reach the database. A projection failure is reported to the user, never blocks the request; the next full sync remains the convergence path. Do not run a full sync from intake.
12
12
 
@@ -145,7 +145,7 @@ Replanning is a **named, auditable operation** — never a silent reorder. Trigg
145
145
 
146
146
  ## Context budget & checkpoint/resume
147
147
 
148
- Work in bounded waves (one artifact class across the target surface). **Checkpoint** each completed wave to `.memlog.md` (`## <date>` + an `event:` line) and record the produced paths on the `implementation` manifest entry (`authoritativePaths`). That checkpoint is the hook `writeStatus` path: it rewrites `.ai.local/team/tasks/<slug>/focus.md`. `focus.md` is a view, not the system of record. It lists slug, pipeline step index, authoritative paths for incomplete manifest ids, the last `.memlog.md` `event:` line, the next gate, one decomposition ready-set line, and one archive index line, and it stays under 100 lines. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record. A resumed run (`/task-continue`) reads `focus.md` first, then `artifact-manifest.json` and `.memlog.md`, and continues at the first stage whose exit criteria are unmet — never re-derive state from the chat. A completed manifest entry keeps id, status, and `authoritativePaths`, and the default resume read omits that entry's markdown body; closing it appends one new `.memlog.md` event: line, moves the bulky body to `.ai.local/team/tasks/<slug>/archive/YYYY-MM-DD/`, and leaves earlier memlog lines, the human-readable slug and artifact ids, and the manifest entry in place, with no Beads hash ids and no Taskmaster tags. Mechanical waves (generation, embed sync) are delegated to repo scripts. A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. An **interrupted producer** (tool abort, killed session) is resumed, not restarted: run the stack's compile gate on the working tree first, and when it is red hand the failing output to the same producer with a `fix and finish` brief instead of starting a second parallel attempt. When the host runtime writes no `status.json` (manual-hook hosts such as OpenCode), the resume checkpoint is `artifact-manifest.json` + `.memlog.md`; never gate a resume on a file the runtime does not produce. See **context-and-iteration** for the budget, checkpoint, resume, and refinement loop.
148
+ Work in bounded waves (one artifact class across the target surface). **Checkpoint** each completed wave to `.memlog.md` (`## <date>` + an `event:` line) and record the produced paths on the `implementation` manifest entry (`authoritativePaths`). That checkpoint is the hook `writeStatus` path: it rewrites `.ai.local/team/tasks/<slug>/focus.md`. `focus.md` is a view, not the system of record. It lists slug, pipeline step index, authoritative paths for incomplete manifest ids, the last `.memlog.md` `event:` line, the next gate, one decomposition ready-set line, and one archive index line, and it stays under 100 lines. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record. A resumed run (`/task-continue`) reads `focus.md` first, then `artifact-manifest.json` and `.memlog.md`, and continues at the first stage whose exit criteria are unmet — never re-derive state from the chat. A session approaching ~50 turns does not keep growing its history: the producer finishes the current wave, checkpoints it (`focus.md` + `artifact-manifest.json` + `.memlog.md`), and hands off to a fresh session. A wave that cannot finish before the cap checkpoints its partial state the same way. A completed manifest entry keeps id, status, and `authoritativePaths`, and the default resume read omits that entry's markdown body; closing it appends one new `.memlog.md` event: line, moves the bulky body to `.ai.local/team/tasks/<slug>/archive/YYYY-MM-DD/`, and leaves earlier memlog lines, the human-readable slug and artifact ids, and the manifest entry in place, with no Beads hash ids and no Taskmaster tags. Mechanical waves (generation, embed sync) are delegated to repo scripts. A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. An **interrupted producer** (tool abort, killed session) is resumed, not restarted: run the stack's compile gate on the working tree first, and when it is red hand the failing output to the same producer with a `fix and finish` brief instead of starting a second parallel attempt. When the host runtime writes no `status.json` (manual-hook hosts such as OpenCode), the resume checkpoint is `artifact-manifest.json` + `.memlog.md`; never gate a resume on a file the runtime does not produce. See **context-and-iteration** for the budget, checkpoint, resume, and refinement loop.
149
149
 
150
150
  ## Self-review & context hygiene
151
151
 
@@ -263,9 +263,10 @@ Use Task tool or `/agent-name`. Pass: slug, artifact paths, step `scope` if set.
263
263
 
264
264
  1. Read `steps[i].model` if present; else use the agent’s frontmatter `model` (see `agents/README.md` matrix).
265
265
  2. Resolve the tier through `.ai.local/team/model-tiers.json` → `tiers.<tier>` when that file exists. The user approved that map, so passing an explicit model is allowed. Pass the resolved `providerID/modelID` (or `providerID/modelID#variant`) to the Task/subagent tool.
266
- - **`cheap`** → mechanical steps only (router, analyst, tech-writer, codebase-analyzer).
267
- - **`standard`** → implementation, verification, review, QA, contract review.
268
- - **`strong`** → architecture, security, migration, performance, mockup review. Never downgrade a `strong` step to the parent default.
266
+ - **`cheap`** → router, analyst, tech-writer, codebase-analyzer, and the review roles `code-reviewer`, `build-verifier`, `api-contract-reviewer`, `mockup-reviewer`. Resolve the provider through `.ai.local/team/model-tiers.json`. Do not write a provider id into the agent file. Pass the mapped id as written; do not append `#high`.
267
+ - **`standard`** → implementation and the other non-review specialists. `feature-developer` stays on this tier.
268
+ - **`strong`** → architecture, security, migration, performance. Never downgrade a `strong` step to the parent default, and do not put `mockup-reviewer` on `strong`.
269
+ - When `steps[i].model` is omitted and the agent file has no `model`, those four review roles stay `cheap` when `.ai.local/team/model-tiers.json` exists. Without that file, omit the model and the session model applies.
269
270
  - If a tier is declared but the file has no mapping, **STOP** and report `model-tier-unmapped`; do not silently inherit the parent model.
270
271
  3. If the tool does not accept a model (Cursor/Claude adapters), record the resolved tier in the handoff and let the platform pin apply.
271
272
  4. Parallel steps: apply the step-level `model` to **each** agent in the array (or omit → each agent’s own frontmatter).
@@ -0,0 +1,47 @@
1
+ # Incident registry
2
+
3
+ Durable memory for agent-pipeline failures. A task finding is local and dies
4
+ with the slug; the registry keeps the failure class, the rule that should have
5
+ prevented it, and the evidence, until either the class is promoted or archived.
6
+
7
+ Writer: `.ai.local/scripts/incidents.mjs`. Store:
8
+ `<team>/incidents.jsonl` — one record per line, append-only.
9
+
10
+ ## Record shape
11
+
12
+ `incident` rows carry `id`, `at`, `signature`, `state`, `title`, `scope`,
13
+ `failure`, `rule`, `advice`, `task`, `tags`, `evidence[]`. `state` rows carry
14
+ `id`, `at`, `state`, and the promotion fields (`enforcement`, `rulePath`).
15
+ Current state is the latest `state` row, defaulting to `open`.
16
+
17
+ `signature` is derived from `scope | failure | rule` (normalized, hashed), so the
18
+ same class recorded from two tasks lands in one recurrence group. Secrets are
19
+ rejected at write time; evidence is a reference (path + anchor, command id,
20
+ incident id), never a log body.
21
+
22
+ ## Stabilization threshold
23
+
24
+ An incident is **stabilized** when the same signature occurs at least **twice in
25
+ 30 days** (`check --window-days` overrides the window). One occurrence is a
26
+ finding, not a rule.
27
+
28
+ ## Promotion
29
+
30
+ Only a stabilized incident can be promoted, and promotion requires a named
31
+ enforcement — `ci`, `test`, `lint`, or `policy-check`. Enforcement is the reason
32
+ the rule will not silently rot; a rule without one is documentation, not a gate.
33
+
34
+ `promote <id> --enforcement <kind> [--stem <kebab>]` writes an **inactive draft**
35
+ to `.ai.local/rules-library/<stem>.md` and appends the state row. A human moves
36
+ the file into `.ai.local/rules/` to activate it — the registry never edits active
37
+ rules, and the overlay's envelope caps still apply.
38
+
39
+ ## Use
40
+
41
+ - After a retro or a repeated agent mistake: `incidents.mjs record`.
42
+ - Before a similar task: `incidents.mjs advise --query "<symptom>"` — targeted
43
+ lookup, never a bulk load.
44
+ - Periodic review: `incidents.mjs check` (stabilized groups), then
45
+ `incidents.mjs promote`, `archive`, or leave `open`.
46
+
47
+ Archiving keeps the line, removes it from advice, and preserves the history.
@@ -14,7 +14,7 @@ Typical feature with data and UI. Concrete directories and rule stems — in the
14
14
 
15
15
  ## Context hygiene
16
16
 
17
- A command whose output can exceed ~4 KB — a test run, a build/lint log, `git log`, a diff — is piped through `.ai.local/scripts/dump-output.mjs --task <slug>` instead of being read whole. Work from its ≤40-line head and the stored file (grep it or use `team-db.mjs search`), and when that output informed a decision, record the repo-relative `outputs/…` path in `implementation.md` or `validation-report.md`; a `code-reviewer` may ask for that path. Do not read the whole output into context.
17
+ A command whose output can exceed ~4 KB — a test run, a build/lint log, `git log`, a diff — is piped through `.ai.local/scripts/dump-output.mjs --task <slug>` instead of being read whole. Work from its ≤40-line head and the stored file (grep it or use `team-db.mjs search`), and when that output informed a decision, record the repo-relative `outputs/…` path in `implementation.md` or `validation-report.md`; a `code-reviewer` may ask for that path. Do not read the whole output into context. Artifact reads take the same slice: read the `artifact-manifest.json` entry, not the artifact body, and never re-read a completed entry's body. Read a large artifact with offset/limit ranges instead of a whole-file read.
18
18
 
19
19
  ## Iterative refinement loop
20
20
 
@@ -13,6 +13,7 @@ multi-wave work). It ratchets down for bounded/spike tasks (see § Ratchet).
13
13
  (c) **alignment / drift** — the result still serves the framed goal and does not exceed the framed scope.
14
14
  - Record a `## Self-review` block in the artifact the producer owns.
15
15
  - A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Schema: **agent-artifact-contracts** § Review ledger.
16
+ - Ledger rows go under the canonical header `| id | at | source | summary | fair | disposition | evidence | signature |`; after appending, run `node .ai.local/scripts/team-db.mjs ledger-check --slug <slug>` and fix any header it rejects. Schema: **agent-artifact-contracts** § Review ledger.
16
17
  - Do not start implementation when `goal.md` is missing.
17
18
 
18
19
  ## Boundary vs existing gates (do not re-implement)
@@ -961,11 +961,117 @@ function reconcileStatusFromManifest(agent, step, resolved) {
961
961
  return status.state;
962
962
  }
963
963
 
964
+ /**
965
+ * Keep only the numeric usage fields and the two provenance fields. A host may
966
+ * forward richer objects; the ledger is allowlisted so nothing unbounded or
967
+ * secret-shaped reaches `metrics.json`.
968
+ */
969
+ function sanitizeUsage(value) {
970
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
971
+ const num = (input) => (typeof input === 'number' && Number.isFinite(input) && input >= 0 ? input : null);
972
+ const usage = {
973
+ input: num(value.input), output: num(value.output), reasoning: num(value.reasoning),
974
+ cacheRead: num(value.cacheRead === undefined ? value.cached : value.cacheRead),
975
+ cacheWrite: num(value.cacheWrite), costUsd: num(value.costUsd),
976
+ model: typeof value.model === 'string' ? value.model.slice(0, 120) : null,
977
+ origin: value.origin === 'estimated' ? 'estimated' : 'measured',
978
+ };
979
+ const reported = usage.input !== null || usage.output !== null || usage.reasoning !== null ||
980
+ usage.cacheRead !== null || usage.cacheWrite !== null || usage.costUsd !== null;
981
+ return reported ? usage : null;
982
+ }
983
+
984
+ /**
985
+ * Freshness of a persisted verification snapshot against the current worktree.
986
+ * Read-only: closure warns, it never blocks on a stale snapshot.
987
+ */
988
+ function gitSnapshot() {
989
+ const { spawnSync } = require('child_process');
990
+ const git = (args) => {
991
+ const result = spawnSync('git', args, { cwd: process.cwd(), encoding: 'utf8', timeout: 10000, maxBuffer: 32 * 1024 * 1024 });
992
+ return result && result.status === 0 ? String(result.stdout || '') : null;
993
+ };
994
+ const head = git(['rev-parse', 'HEAD']);
995
+ if (head === null) return null;
996
+ const branch = git(['rev-parse', '--abbrev-ref', 'HEAD']);
997
+ const exclude = ['--', '.', ':(exclude).ai.local'];
998
+ const statusText = git(['status', '--porcelain=v1', ...exclude]) || '';
999
+ const diffText = git(['diff', '--binary', 'HEAD', ...exclude]) || '';
1000
+ const untracked = git(['ls-files', '--others', '--exclude-standard', ...exclude]) || '';
1001
+ return {
1002
+ head: head.trim(),
1003
+ branch: branch === null ? null : branch.trim(),
1004
+ dirtyFiles: statusText === '' ? 0 : statusText.split('\n').filter((line) => line !== '').length,
1005
+ worktreeHash: crypto.createHash('sha256').update(`${statusText}\u0000${diffText}\u0000${untracked}`).digest('hex'),
1006
+ capturedAt: now,
1007
+ };
1008
+ }
1009
+
1010
+ /**
1011
+ * Seed the evidence file when the verifier finishes without an explicit
1012
+ * `verification.mjs record`: the snapshot plus a hash of `validation-report.md`.
1013
+ * An existing file is never refreshed — its binding must keep pointing at the
1014
+ * tree the commands actually ran on.
1015
+ */
1016
+ function ensureVerificationSnapshot(dir, agent) {
1017
+ const file = path.join(dir, 'verification.json');
1018
+ if (fs.existsSync(file)) return;
1019
+ const snapshot = gitSnapshot();
1020
+ if (!snapshot) return;
1021
+ const reportPath = path.join(dir, 'validation-report.md');
1022
+ let report = null;
1023
+ try {
1024
+ const text = fs.readFileSync(reportPath);
1025
+ report = { path: 'validation-report.md', sha256: crypto.createHash('sha256').update(text).digest('hex') };
1026
+ } catch {}
1027
+ const verification = {
1028
+ schemaVersion: 1,
1029
+ task: path.basename(dir),
1030
+ snapshot,
1031
+ report,
1032
+ commands: [],
1033
+ gate: { status: 'snapshot-only', recordedBy: agent || null, checkedAt: now },
1034
+ };
1035
+ const temporary = `${file}.${process.pid}.tmp`;
1036
+ fs.writeFileSync(temporary, JSON.stringify(verification, null, 2) + '\n');
1037
+ fs.renameSync(temporary, file);
1038
+ appendMetric({ type: 'verification_recorded', at: now, kind: 'snapshot-only', agent: agent || null, head: snapshot.head, worktreeHash: snapshot.worktreeHash, source: 'hook', attributionConfidence: 'high' });
1039
+ }
1040
+
1041
+ function verificationFreshness(dir) {
1042
+ const file = path.join(dir, 'verification.json');
1043
+ if (!fs.existsSync(file)) return { present: false };
1044
+ let verification;
1045
+ try { verification = JSON.parse(fs.readFileSync(file, 'utf8')); } catch { return { present: true, fresh: false, reasons: ['unreadable'] }; }
1046
+ const snapshot = verification && verification.snapshot;
1047
+ if (!snapshot || typeof snapshot.head !== 'string') return { present: true, fresh: false, reasons: ['no-snapshot'] };
1048
+ const current = gitSnapshot();
1049
+ if (!current) return { present: true, fresh: false, reasons: ['no-git'] };
1050
+ const reasons = [];
1051
+ if (current.head !== snapshot.head) reasons.push('head-changed');
1052
+ if (current.worktreeHash !== snapshot.worktreeHash) reasons.push('worktree-changed');
1053
+ return { present: true, fresh: reasons.length === 0, reasons };
1054
+ }
1055
+
1056
+ let verificationStaleNoted = false;
1057
+
1058
+ function noteVerificationFreshness(dir, agent) {
1059
+ if (verificationStaleNoted) return;
1060
+ const freshness = verificationFreshness(dir);
1061
+ if (!freshness.present) return;
1062
+ if (freshness.fresh) return;
1063
+ verificationStaleNoted = true;
1064
+ appendMetric({ type: 'verification_stale', at: now, agent: agent || null, reasons: freshness.reasons, source: 'hook', attributionConfidence: 'high' });
1065
+ process.stderr.write(`verification evidence is stale (${freshness.reasons.join(', ')}); re-run the gate and record it before closure\n`);
1066
+ }
1067
+
964
1068
  function finishActiveAttempt(forced) {
965
1069
  const resolved = forced || resolvedAttempt(); if (!resolved) return null;
966
1070
  const durationMs = Date.parse(now) - Date.parse(resolved.entry.startedAt);
967
1071
  const outcome = ['completed', 'blocked', 'changes_requested', 'validation_failed'].includes(status.state) ? status.state : 'unknown';
968
- appendMetric({ type: 'attempt_finished', at: now, attemptId: resolved.attemptId, outcome, durationMs: Number.isFinite(durationMs) && durationMs >= 0 ? durationMs : null, retryAfterFix: status.retryAfterFix || null, source: resolved.source || 'hook', attributionConfidence: resolved.confidence, ...(hookInput.usage && typeof hookInput.usage === 'object' ? { usage: hookInput.usage } : {}) });
1072
+ const usage = sanitizeUsage(hookInput.usage);
1073
+ appendMetric({ type: 'attempt_finished', at: now, attemptId: resolved.attemptId, outcome, durationMs: Number.isFinite(durationMs) && durationMs >= 0 ? durationMs : null, retryAfterFix: status.retryAfterFix || null, source: resolved.source || 'hook', attributionConfidence: resolved.confidence, ...(usage ? { usage } : {}) });
1074
+ if (resolved.entry && resolved.entry.agent === 'build-verifier') { ensureVerificationSnapshot(taskDir, resolved.entry.agent); noteVerificationFreshness(taskDir, resolved.entry.agent); }
969
1075
  const active = { ...(status.activeAttempts || {}) }; delete active[resolved.attemptId]; status.activeAttempts = active; status.lastCompletedAttempt = { attemptId: resolved.attemptId, completedAt: now }; return { ...resolved, outcome };
970
1076
  }
971
1077
  function missingConsumerArtifacts() {
@@ -995,6 +1101,7 @@ function completePipeline(statusPatch) {
995
1101
  // task_completed is written only on this branch. A missing receipt blocks
996
1102
  // above and must not be counted as a finished task.
997
1103
  status.state = 'completed';
1104
+ noteVerificationFreshness(taskDir, null);
998
1105
  completeTaskMetrics();
999
1106
  writeStatus(statusPatch);
1000
1107
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
@@ -61,7 +61,7 @@ Before you run the project gate and write the terminal validation receipt, self-
61
61
 
62
62
  Record a `## Self-review` block in `validation-report.md` (goal/AC coverage, evidence, alignment/drift). Optional loop (see the requestable `self-review-and-context-hygiene` contract). In-task self-learning loop: run `node .ai.local/scripts/run.mjs` at the pre-receipt self-review when the engine exists; capture one wrong-turn with `node .ai.local/scripts/signals.mjs --append '<json>'` and inspect read-only with `node .ai.local/scripts/run.mjs --status`. Keep the loop deterministic: it runs no model-driven pass — rule text is template-derived from the validated signature; a model-driven pass is not part of the loop, and if one is ever added it must be default-off and may write only to the staged band. Ratchet: no self-review / context-health pass / re-anchor ceremony for `bounded`/`spike` tasks (or the `light` profile).
63
63
 
64
- A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing.
64
+ A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing. Ledger rows go under the canonical header `| id | at | source | summary | fair | disposition | evidence | signature |`; after appending, run `node .ai.local/scripts/team-db.mjs ledger-check --slug <slug>` and fix any header it rejects.
65
65
 
66
66
  ## Output
67
67
 
@@ -66,7 +66,7 @@ Before you emit the terminal review receipt, self-audit the review artifact: eve
66
66
 
67
67
  Record a `## Self-review` block in `review.md` (goal/AC coverage, evidence, alignment/drift). Optional loop (see the requestable `self-review-and-context-hygiene` contract). In-task self-learning loop: run `node .ai.local/scripts/run.mjs` at the pre-receipt self-review when the engine exists; capture one wrong-turn with `node .ai.local/scripts/signals.mjs --append '<json>'` and inspect read-only with `node .ai.local/scripts/run.mjs --status`. Keep the loop deterministic: it runs no model-driven pass — rule text is template-derived from the validated signature; a model-driven pass is not part of the loop, and if one is ever added it must be default-off and may write only to the staged band. Ratchet: no self-review / context-health pass / re-anchor ceremony for `bounded`/`spike` tasks (or the `light` profile).
68
68
 
69
- A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing. Append each finding to `review-ledger.md` (`disposition: open`) before the receipt.
69
+ A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing. Append each finding to `review-ledger.md` (`disposition: open`) before the receipt. Ledger rows go under the canonical header `| id | at | source | summary | fair | disposition | evidence | signature |`; after appending, run `node .ai.local/scripts/team-db.mjs ledger-check --slug <slug>` and fix any header it rejects.
70
70
 
71
71
  ## Review artifact
72
72
 
@@ -102,7 +102,7 @@ Before you set `fixApplied: true` and emit the terminal receipt, self-audit the
102
102
 
103
103
  Record a `## Self-review` block in `debug-report.md` (goal/AC coverage, evidence, alignment/drift). Optional loop (see the requestable `self-review-and-context-hygiene` contract). In-task self-learning loop: run `node .ai.local/scripts/run.mjs` at the pre-receipt self-review when the engine exists; capture one wrong-turn with `node .ai.local/scripts/signals.mjs --append '<json>'` and inspect read-only with `node .ai.local/scripts/run.mjs --status`. Keep the loop deterministic: it runs no model-driven pass — rule text is template-derived from the validated signature; a model-driven pass is not part of the loop, and if one is ever added it must be default-off and may write only to the staged band. Ratchet: no self-review / context-health pass / re-anchor ceremony for `bounded`/`spike` tasks (or the `light` profile).
104
104
 
105
- A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing.
105
+ A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing. Ledger rows go under the canonical header `| id | at | source | summary | fair | disposition | evidence | signature |`; after appending, run `node .ai.local/scripts/team-db.mjs ledger-check --slug <slug>` and fix any header it rejects.
106
106
 
107
107
  ## MCP usage
108
108
 
@@ -104,7 +104,7 @@ Before you emit the terminal implementation receipt (per wave for multi-wave wor
104
104
 
105
105
  Record a `## Self-review` block in `implementation.md` (goal/AC coverage, evidence, alignment/drift). Optional loop (see the requestable `self-review-and-context-hygiene` contract). In-task self-learning loop: run `node .ai.local/scripts/run.mjs` at the pre-receipt self-review when the engine exists; capture one wrong-turn with `node .ai.local/scripts/signals.mjs --append '<json>'` and inspect read-only with `node .ai.local/scripts/run.mjs --status`. Keep the loop deterministic: it runs no model-driven pass — rule text is template-derived from the validated signature; a model-driven pass is not part of the loop, and if one is ever added it must be default-off and may write only to the staged band. Ratchet: no self-review / context-health pass / re-anchor ceremony for `bounded`/`spike` tasks (or the `light` profile).
106
106
 
107
- A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing.
107
+ A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing. Ledger rows go under the canonical header `| id | at | source | summary | fair | disposition | evidence | signature |`; after appending, run `node .ai.local/scripts/team-db.mjs ledger-check --slug <slug>` and fix any header it rejects.
108
108
 
109
109
  ## UX design (behavioral)
110
110
 
@@ -63,7 +63,7 @@ Before you emit the terminal analysis receipt, self-audit the goal frame and dec
63
63
 
64
64
  Record a `## Self-review` block in `brief.md` (goal/AC coverage, evidence, alignment/drift). Optional loop (see the requestable `self-review-and-context-hygiene` contract). In-task self-learning loop: run `node .ai.local/scripts/run.mjs` at the pre-receipt self-review when the engine exists; capture one wrong-turn with `node .ai.local/scripts/signals.mjs --append '<json>'` and inspect read-only with `node .ai.local/scripts/run.mjs --status`. Keep the loop deterministic: it runs no model-driven pass — rule text is template-derived from the validated signature; a model-driven pass is not part of the loop, and if one is ever added it must be default-off and may write only to the staged band. Ratchet: no self-review / context-health pass / re-anchor ceremony for `bounded`/`spike` tasks (or the `light` profile).
65
65
 
66
- A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing.
66
+ A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing. Ledger rows go under the canonical header `| id | at | source | summary | fair | disposition | evidence | signature |`; after appending, run `node .ai.local/scripts/team-db.mjs ledger-check --slug <slug>` and fix any header it rejects.
67
67
 
68
68
  ## Clarification cycle
69
69
 
@@ -998,11 +998,117 @@ function reconcileStatusFromManifest(agent, step, resolved) {
998
998
  return status.state;
999
999
  }
1000
1000
 
1001
+ /**
1002
+ * Keep only the numeric usage fields and the two provenance fields. A host may
1003
+ * forward richer objects; the ledger is allowlisted so nothing unbounded or
1004
+ * secret-shaped reaches `metrics.json`.
1005
+ */
1006
+ function sanitizeUsage(value) {
1007
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
1008
+ const num = (input) => (typeof input === 'number' && Number.isFinite(input) && input >= 0 ? input : null);
1009
+ const usage = {
1010
+ input: num(value.input), output: num(value.output), reasoning: num(value.reasoning),
1011
+ cacheRead: num(value.cacheRead === undefined ? value.cached : value.cacheRead),
1012
+ cacheWrite: num(value.cacheWrite), costUsd: num(value.costUsd),
1013
+ model: typeof value.model === 'string' ? value.model.slice(0, 120) : null,
1014
+ origin: value.origin === 'estimated' ? 'estimated' : 'measured',
1015
+ };
1016
+ const reported = usage.input !== null || usage.output !== null || usage.reasoning !== null ||
1017
+ usage.cacheRead !== null || usage.cacheWrite !== null || usage.costUsd !== null;
1018
+ return reported ? usage : null;
1019
+ }
1020
+
1021
+ /**
1022
+ * Freshness of a persisted verification snapshot against the current worktree.
1023
+ * Read-only: closure warns, it never blocks on a stale snapshot.
1024
+ */
1025
+ function gitSnapshot() {
1026
+ const { spawnSync } = require('child_process');
1027
+ const git = (args) => {
1028
+ const result = spawnSync('git', args, { cwd: process.cwd(), encoding: 'utf8', timeout: 10000, maxBuffer: 32 * 1024 * 1024 });
1029
+ return result && result.status === 0 ? String(result.stdout || '') : null;
1030
+ };
1031
+ const head = git(['rev-parse', 'HEAD']);
1032
+ if (head === null) return null;
1033
+ const branch = git(['rev-parse', '--abbrev-ref', 'HEAD']);
1034
+ const exclude = ['--', '.', ':(exclude).ai.local'];
1035
+ const statusText = git(['status', '--porcelain=v1', ...exclude]) || '';
1036
+ const diffText = git(['diff', '--binary', 'HEAD', ...exclude]) || '';
1037
+ const untracked = git(['ls-files', '--others', '--exclude-standard', ...exclude]) || '';
1038
+ return {
1039
+ head: head.trim(),
1040
+ branch: branch === null ? null : branch.trim(),
1041
+ dirtyFiles: statusText === '' ? 0 : statusText.split('\n').filter((line) => line !== '').length,
1042
+ worktreeHash: crypto.createHash('sha256').update(`${statusText}\u0000${diffText}\u0000${untracked}`).digest('hex'),
1043
+ capturedAt: now,
1044
+ };
1045
+ }
1046
+
1047
+ /**
1048
+ * Seed the evidence file when the verifier finishes without an explicit
1049
+ * `verification.mjs record`: the snapshot plus a hash of `validation-report.md`.
1050
+ * An existing file is never refreshed — its binding must keep pointing at the
1051
+ * tree the commands actually ran on.
1052
+ */
1053
+ function ensureVerificationSnapshot(dir, agent) {
1054
+ const file = path.join(dir, 'verification.json');
1055
+ if (fs.existsSync(file)) return;
1056
+ const snapshot = gitSnapshot();
1057
+ if (!snapshot) return;
1058
+ const reportPath = path.join(dir, 'validation-report.md');
1059
+ let report = null;
1060
+ try {
1061
+ const text = fs.readFileSync(reportPath);
1062
+ report = { path: 'validation-report.md', sha256: crypto.createHash('sha256').update(text).digest('hex') };
1063
+ } catch {}
1064
+ const verification = {
1065
+ schemaVersion: 1,
1066
+ task: path.basename(dir),
1067
+ snapshot,
1068
+ report,
1069
+ commands: [],
1070
+ gate: { status: 'snapshot-only', recordedBy: agent || null, checkedAt: now },
1071
+ };
1072
+ const temporary = `${file}.${process.pid}.tmp`;
1073
+ fs.writeFileSync(temporary, JSON.stringify(verification, null, 2) + '\n');
1074
+ fs.renameSync(temporary, file);
1075
+ appendMetric({ type: 'verification_recorded', at: now, kind: 'snapshot-only', agent: agent || null, head: snapshot.head, worktreeHash: snapshot.worktreeHash, source: 'hook', attributionConfidence: 'high' });
1076
+ }
1077
+
1078
+ function verificationFreshness(dir) {
1079
+ const file = path.join(dir, 'verification.json');
1080
+ if (!fs.existsSync(file)) return { present: false };
1081
+ let verification;
1082
+ try { verification = JSON.parse(fs.readFileSync(file, 'utf8')); } catch { return { present: true, fresh: false, reasons: ['unreadable'] }; }
1083
+ const snapshot = verification && verification.snapshot;
1084
+ if (!snapshot || typeof snapshot.head !== 'string') return { present: true, fresh: false, reasons: ['no-snapshot'] };
1085
+ const current = gitSnapshot();
1086
+ if (!current) return { present: true, fresh: false, reasons: ['no-git'] };
1087
+ const reasons = [];
1088
+ if (current.head !== snapshot.head) reasons.push('head-changed');
1089
+ if (current.worktreeHash !== snapshot.worktreeHash) reasons.push('worktree-changed');
1090
+ return { present: true, fresh: reasons.length === 0, reasons };
1091
+ }
1092
+
1093
+ let verificationStaleNoted = false;
1094
+
1095
+ function noteVerificationFreshness(dir, agent) {
1096
+ if (verificationStaleNoted) return;
1097
+ const freshness = verificationFreshness(dir);
1098
+ if (!freshness.present) return;
1099
+ if (freshness.fresh) return;
1100
+ verificationStaleNoted = true;
1101
+ appendMetric({ type: 'verification_stale', at: now, agent: agent || null, reasons: freshness.reasons, source: 'hook', attributionConfidence: 'high' });
1102
+ process.stderr.write(`verification evidence is stale (${freshness.reasons.join(', ')}); re-run the gate and record it before closure\n`);
1103
+ }
1104
+
1001
1105
  function finishActiveAttempt(forced) {
1002
1106
  const resolved = forced || resolvedAttempt(); if (!resolved) return null;
1003
1107
  const durationMs = Date.parse(now) - Date.parse(resolved.entry.startedAt);
1004
1108
  const outcome = ['completed', 'blocked', 'changes_requested', 'validation_failed'].includes(status.state) ? status.state : 'unknown';
1005
- appendMetric({ type: 'attempt_finished', at: now, attemptId: resolved.attemptId, outcome, durationMs: Number.isFinite(durationMs) && durationMs >= 0 ? durationMs : null, retryAfterFix: status.retryAfterFix || null, source: resolved.source || 'hook', attributionConfidence: resolved.confidence, ...(hookInput.usage && typeof hookInput.usage === 'object' ? { usage: hookInput.usage } : {}) });
1109
+ const usage = sanitizeUsage(hookInput.usage);
1110
+ appendMetric({ type: 'attempt_finished', at: now, attemptId: resolved.attemptId, outcome, durationMs: Number.isFinite(durationMs) && durationMs >= 0 ? durationMs : null, retryAfterFix: status.retryAfterFix || null, source: resolved.source || 'hook', attributionConfidence: resolved.confidence, ...(usage ? { usage } : {}) });
1111
+ if (resolved.entry && resolved.entry.agent === 'build-verifier') { ensureVerificationSnapshot(taskDir, resolved.entry.agent); noteVerificationFreshness(taskDir, resolved.entry.agent); }
1006
1112
  const active = { ...(status.activeAttempts || {}) }; delete active[resolved.attemptId]; status.activeAttempts = active; status.lastCompletedAttempt = { attemptId: resolved.attemptId, completedAt: now }; return { ...resolved, outcome };
1007
1113
  }
1008
1114
  function missingConsumerArtifacts() {
@@ -1032,6 +1138,7 @@ function completePipeline(statusPatch) {
1032
1138
  // task_completed is written only on this branch. A missing receipt blocks
1033
1139
  // above and must not be counted as a finished task.
1034
1140
  status.state = 'completed';
1141
+ noteVerificationFreshness(taskDir, null);
1035
1142
  completeTaskMetrics();
1036
1143
  writeStatus(statusPatch);
1037
1144
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
@@ -11,9 +11,9 @@ When the user message looks like a **work request** (implement, add, fix, refact
11
11
 
12
12
  1. Prefer **`/task <their request>`** or invoke **task-router** first.
13
13
  2. Do not jump straight to coding without router + pipeline when scope is non-trivial.
14
- 3. Pure questions (“how does X work”, “explain”) — prefer agent **`codebase-analyzer`** (explain-as-is); trivial one-liners may be answered inline. Do not open `/task`.
14
+ 3. A question that one read answers — “how does X work”, “explain this function” — is a **pure question**: answer inline, no file, no `/task`. A question that needs more than one read, or whose answer is written down, is a **research** request: route it to agent **`codebase-analyzer`** (explain-as-is) or a `spike` pipeline, and never open implementation steps for it. Where the always-on root agent file ships the research gate, it states this same boundary as a `MUST` (§ Research requests).
15
15
  4. A work request now runs the planning workflow — **goal frame → requirements → information-sufficiency → decompose** (dependency graph / epics); see **task-framing** and **plan-graph**.
16
- 5. Every **work request** — with or without `/task`, and even when the user says “no pipeline” / “just do it” — persists the **verbatim** original prompt at `.ai.local/team/tasks/<slug>/prompt.md`. Prefer `/task` (its **Slug** step writes it). If handling inline without `/task`, first create the slug dir and write `prompt.md` (write-if-absent), then proceed. Pure questions and trivial one-liners are not work requests → no file. On an inline follow-up for an existing slug (no `/task`) where the user authors new text, append it verbatim to `.ai.local/team/tasks/<slug>/prompt-log.md` (`seq` = max + 1; create on first append; exclude machine-generated and empty/argument-less invocations).
16
+ 5. Every **work request** — with or without `/task`, and even when the user says “no pipeline” / “just do it” — persists the **verbatim** original prompt at `.ai.local/team/tasks/<slug>/prompt.md`. Prefer `/task` (its **Slug** step writes it). If handling inline without `/task`, first create the slug dir and write `prompt.md` (write-if-absent), then proceed. Pure questions and trivial one-liners are not work requests → no file; a research request is one (rule 3). On an inline follow-up for an existing slug (no `/task`) where the user authors new text, append it verbatim to `.ai.local/team/tasks/<slug>/prompt-log.md` (`seq` = max + 1; create on first append; exclude machine-generated and empty/argument-less invocations).
17
17
  6. **Reuse the dialogue language already resolved on this turn** (always-on `ai-local-overlay` / **language-policy**). A question and a message without a slash command still resolve before you speak. When this request writes `prompt.md`, persist that tag once in the header (`language: <BCP-47>`) + a `.memlog.md` `event:` line. Development, reasoning, and artifacts stay English. The setting wins over a mid-task prompt switch (surface it once, never ask). See **language-policy**.
18
18
  7. **Project the intake write.** After `prompt.md` is written for an inline (non-`/task`) work request, run `node .ai.local/scripts/team-db.mjs sync --slug <slug> --deadline-ms 4500` once, so the new task row and its prompt reach the database. A projection failure is reported to the user, never blocks the request; the next full sync remains the convergence path. Do not run a full sync from intake.
19
19
 
@@ -156,7 +156,7 @@ Replanning is a **named, auditable operation** — never a silent reorder. Trigg
156
156
 
157
157
  ## Context budget & checkpoint/resume
158
158
 
159
- Work in bounded waves (one artifact class across the target surface). **Checkpoint** each completed wave to `.memlog.md` (`## <date>` + an `event:` line) and record the produced paths on the `implementation` manifest entry (`authoritativePaths`). That checkpoint is the hook `writeStatus` path: it rewrites `.ai.local/team/tasks/<slug>/focus.md`. `focus.md` is a view, not the system of record. It lists slug, pipeline step index, authoritative paths for incomplete manifest ids, the last `.memlog.md` `event:` line, the next gate, one decomposition ready-set line, and one archive index line, and it stays under 100 lines. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record. A resumed run (`/task-continue`) reads `focus.md` first, then `artifact-manifest.json` and `.memlog.md`, and continues at the first stage whose exit criteria are unmet — never re-derive state from the chat. A completed manifest entry keeps id, status, and `authoritativePaths`, and the default resume read omits that entry's markdown body; closing it appends one new `.memlog.md` event: line, moves the bulky body to `.ai.local/team/tasks/<slug>/archive/YYYY-MM-DD/`, and leaves earlier memlog lines, the human-readable slug and artifact ids, and the manifest entry in place, with no Beads hash ids and no Taskmaster tags. Mechanical waves (generation, embed sync) are delegated to repo scripts. A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. An **interrupted producer** (tool abort, killed session) is resumed, not restarted: run the stack's compile gate on the working tree first, and when it is red hand the failing output to the same producer with a `fix and finish` brief instead of starting a second parallel attempt. When the host runtime writes no `status.json` (manual-hook hosts such as OpenCode), the resume checkpoint is `artifact-manifest.json` + `.memlog.md`; never gate a resume on a file the runtime does not produce. See **context-and-iteration** for the budget, checkpoint, resume, and refinement loop.
159
+ Work in bounded waves (one artifact class across the target surface). **Checkpoint** each completed wave to `.memlog.md` (`## <date>` + an `event:` line) and record the produced paths on the `implementation` manifest entry (`authoritativePaths`). That checkpoint is the hook `writeStatus` path: it rewrites `.ai.local/team/tasks/<slug>/focus.md`. `focus.md` is a view, not the system of record. It lists slug, pipeline step index, authoritative paths for incomplete manifest ids, the last `.memlog.md` `event:` line, the next gate, one decomposition ready-set line, and one archive index line, and it stays under 100 lines. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record. A resumed run (`/task-continue`) reads `focus.md` first, then `artifact-manifest.json` and `.memlog.md`, and continues at the first stage whose exit criteria are unmet — never re-derive state from the chat. A session approaching ~50 turns does not keep growing its history: the producer finishes the current wave, checkpoints it (`focus.md` + `artifact-manifest.json` + `.memlog.md`), and hands off to a fresh session. A wave that cannot finish before the cap checkpoints its partial state the same way. A completed manifest entry keeps id, status, and `authoritativePaths`, and the default resume read omits that entry's markdown body; closing it appends one new `.memlog.md` event: line, moves the bulky body to `.ai.local/team/tasks/<slug>/archive/YYYY-MM-DD/`, and leaves earlier memlog lines, the human-readable slug and artifact ids, and the manifest entry in place, with no Beads hash ids and no Taskmaster tags. Mechanical waves (generation, embed sync) are delegated to repo scripts. A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. An **interrupted producer** (tool abort, killed session) is resumed, not restarted: run the stack's compile gate on the working tree first, and when it is red hand the failing output to the same producer with a `fix and finish` brief instead of starting a second parallel attempt. When the host runtime writes no `status.json` (manual-hook hosts such as OpenCode), the resume checkpoint is `artifact-manifest.json` + `.memlog.md`; never gate a resume on a file the runtime does not produce. See **context-and-iteration** for the budget, checkpoint, resume, and refinement loop.
160
160
 
161
161
  ## Self-review & context hygiene
162
162
 
@@ -274,9 +274,10 @@ Use Task tool or `/agent-name`. Pass: slug, artifact paths, step `scope` if set.
274
274
 
275
275
  1. Read `steps[i].model` if present; else use the agent’s frontmatter `model` (see `agents/README.md` matrix).
276
276
  2. Resolve the tier through `.ai.local/team/model-tiers.json` → `tiers.<tier>` when that file exists. The user approved that map, so passing an explicit model is allowed. Pass the resolved `providerID/modelID` (or `providerID/modelID#variant`) to the Task/subagent tool.
277
- - **`cheap`** → mechanical steps only (router, analyst, tech-writer, codebase-analyzer).
278
- - **`standard`** → implementation, verification, review, QA, contract review.
279
- - **`strong`** → architecture, security, migration, performance, mockup review. Never downgrade a `strong` step to the parent default.
277
+ - **`cheap`** → router, analyst, tech-writer, codebase-analyzer, and the review roles `code-reviewer`, `build-verifier`, `api-contract-reviewer`, `mockup-reviewer`. Resolve the provider through `.ai.local/team/model-tiers.json`. Do not write a provider id into the agent file. Pass the mapped id as written; do not append `#high`.
278
+ - **`standard`** → implementation and the other non-review specialists. `feature-developer` stays on this tier.
279
+ - **`strong`** → architecture, security, migration, performance. Never downgrade a `strong` step to the parent default, and do not put `mockup-reviewer` on `strong`.
280
+ - When `steps[i].model` is omitted and the agent file has no `model`, those four review roles stay `cheap` when `.ai.local/team/model-tiers.json` exists. Without that file, omit the model and the session model applies.
280
281
  - If a tier is declared but the file has no mapping, **STOP** and report `model-tier-unmapped`; do not silently inherit the parent model.
281
282
  3. If the tool does not accept a model (Cursor/Claude adapters), record the resolved tier in the handoff and let the platform pin apply.
282
283
  4. Parallel steps: apply the step-level `model` to **each** agent in the array (or omit → each agent’s own frontmatter).
@@ -53,7 +53,7 @@ Before you run the project gate and write the terminal validation receipt, self-
53
53
 
54
54
  Record a `## Self-review` block in `validation-report.md` (goal/AC coverage, evidence, alignment/drift). Optional loop (see the requestable `self-review-and-context-hygiene` contract). In-task self-learning loop: run `node .ai.local/scripts/run.mjs` at the pre-receipt self-review when the engine exists; capture one wrong-turn with `node .ai.local/scripts/signals.mjs --append '<json>'` and inspect read-only with `node .ai.local/scripts/run.mjs --status`. Keep the loop deterministic: it runs no model-driven pass — rule text is template-derived from the validated signature; a model-driven pass is not part of the loop, and if one is ever added it must be default-off and may write only to the staged band. Ratchet: no self-review / context-health pass / re-anchor ceremony for `bounded`/`spike` tasks (or the `light` profile).
55
55
 
56
- A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing.
56
+ A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing. Ledger rows go under the canonical header `| id | at | source | summary | fair | disposition | evidence | signature |`; after appending, run `node .ai.local/scripts/team-db.mjs ledger-check --slug <slug>` and fix any header it rejects.
57
57
 
58
58
  ## Artifact contract
59
59
 
@@ -65,7 +65,7 @@ Before you emit the terminal review receipt, self-audit the review artifact: eve
65
65
 
66
66
  Record a `## Self-review` block in `review.md` (goal/AC coverage, evidence, alignment/drift). Optional loop (see the requestable `self-review-and-context-hygiene` contract). In-task self-learning loop: run `node .ai.local/scripts/run.mjs` at the pre-receipt self-review when the engine exists; capture one wrong-turn with `node .ai.local/scripts/signals.mjs --append '<json>'` and inspect read-only with `node .ai.local/scripts/run.mjs --status`. Keep the loop deterministic: it runs no model-driven pass — rule text is template-derived from the validated signature; a model-driven pass is not part of the loop, and if one is ever added it must be default-off and may write only to the staged band. Ratchet: no self-review / context-health pass / re-anchor ceremony for `bounded`/`spike` tasks (or the `light` profile).
67
67
 
68
- A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing. Append each finding to `review-ledger.md` (`disposition: open`) before the receipt.
68
+ A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing. Append each finding to `review-ledger.md` (`disposition: open`) before the receipt. Ledger rows go under the canonical header `| id | at | source | summary | fair | disposition | evidence | signature |`; after appending, run `node .ai.local/scripts/team-db.mjs ledger-check --slug <slug>` and fix any header it rejects.
69
69
 
70
70
  ## Review artifact
71
71
 
@@ -70,7 +70,7 @@ Before you set `fixApplied: true` and emit the terminal receipt, self-audit the
70
70
 
71
71
  Record a `## Self-review` block in `debug-report.md` (goal/AC coverage, evidence, alignment/drift). Optional loop (see the requestable `self-review-and-context-hygiene` contract). In-task self-learning loop: run `node .ai.local/scripts/run.mjs` at the pre-receipt self-review when the engine exists; capture one wrong-turn with `node .ai.local/scripts/signals.mjs --append '<json>'` and inspect read-only with `node .ai.local/scripts/run.mjs --status`. Keep the loop deterministic: it runs no model-driven pass — rule text is template-derived from the validated signature; a model-driven pass is not part of the loop, and if one is ever added it must be default-off and may write only to the staged band. Ratchet: no self-review / context-health pass / re-anchor ceremony for `bounded`/`spike` tasks (or the `light` profile).
72
72
 
73
- A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing.
73
+ A self-review defect that changes the output appends one `review-ledger.md` row (`source: self`, `fair: yes`, `disposition: fixed`) before the receipt. Do not start implementation when `goal.md` is missing. Ledger rows go under the canonical header `| id | at | source | summary | fair | disposition | evidence | signature |`; after appending, run `node .ai.local/scripts/team-db.mjs ledger-check --slug <slug>` and fix any header it rejects.
74
74
 
75
75
  ## MCP usage
76
76