@bonesofspring/ai-rules 0.2.74 → 0.2.77

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 (856) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/README.md +2 -2
  3. package/bin/lib/engine-scripts.js +4 -0
  4. package/docs/PRESET-CONTRIBUTION.md +6 -3
  5. package/docs/TEAM-DB.md +10 -0
  6. package/docs/TOKEN-ECONOMY.md +18 -5
  7. package/docs/ZCODE.md +1 -1
  8. package/package.json +6 -2
  9. package/presets/_shared/ai-local/scripts/check-write-scope.mjs +126 -34
  10. package/presets/_shared/ai-local/scripts/lock.mjs +103 -30
  11. package/presets/_shared/ai-local/scripts/rule-improver.mjs +4 -0
  12. package/presets/_shared/ai-local/scripts/run-compact.mjs +132 -0
  13. package/presets/_shared/ai-local/scripts/signals.mjs +3 -1
  14. package/presets/_shared/ai-local/scripts/team-db-api.mjs +7 -2
  15. package/presets/_shared/ai-local/scripts/team-db-project.mjs +276 -1
  16. package/presets/_shared/ai-local/scripts/team-db-scheduler.mjs +32 -2
  17. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +99 -0
  18. package/presets/_shared/ai-local/scripts/team-db-task-runner.mjs +3 -1
  19. package/presets/_shared/core/agent-team/agent-task-metrics.md +29 -0
  20. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +1 -1
  21. package/presets/_shared/core/architecture/feature-delivery-workflow.md +1 -1
  22. package/presets/_shared/core/meta/preset-pr-checklist.md +2 -2
  23. package/presets/_shared/core/quality/context-and-iteration.md +1 -1
  24. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +4 -1
  25. package/presets/_shared/hooks/compact-shell-output.mjs +68 -0
  26. package/presets/claude/android-kotlin/CLAUDE.md +1 -1
  27. package/presets/claude/android-kotlin/REPO_AGENTS.md +8 -0
  28. package/presets/claude/android-kotlin/agents/README.md +4 -0
  29. package/presets/claude/android-kotlin/agents/accessibility-reviewer.md +1 -1
  30. package/presets/claude/android-kotlin/agents/api-contract-reviewer.md +1 -1
  31. package/presets/claude/android-kotlin/agents/build-verifier.md +1 -1
  32. package/presets/claude/android-kotlin/agents/ci-investigator.md +0 -1
  33. package/presets/claude/android-kotlin/agents/code-reviewer.md +1 -1
  34. package/presets/claude/android-kotlin/agents/codebase-analyzer.md +1 -1
  35. package/presets/claude/android-kotlin/agents/debugger.md +0 -1
  36. package/presets/claude/android-kotlin/agents/feature-developer.md +0 -1
  37. package/presets/claude/android-kotlin/agents/migration-specialist.md +1 -1
  38. package/presets/claude/android-kotlin/agents/mockup-reviewer.md +1 -0
  39. package/presets/claude/android-kotlin/agents/openspec-author.md +2 -1
  40. package/presets/claude/android-kotlin/agents/performance-auditor.md +1 -1
  41. package/presets/claude/android-kotlin/agents/qa-tester.md +0 -1
  42. package/presets/claude/android-kotlin/agents/security-reviewer.md +1 -1
  43. package/presets/claude/android-kotlin/agents/solution-architect.md +1 -1
  44. package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
  45. package/presets/claude/android-kotlin/agents/task-router.md +1 -1
  46. package/presets/claude/android-kotlin/agents/tech-writer.md +1 -1
  47. package/presets/claude/android-kotlin/agents/unit-test-generator.md +0 -1
  48. package/presets/claude/android-kotlin/agents/unit-test-healer.md +0 -1
  49. package/presets/claude/android-kotlin/agents/unit-test-planner.md +1 -1
  50. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +4 -1
  51. package/presets/claude/android-kotlin/rules/architecture/feature-delivery.md +66 -8
  52. package/presets/claude/android-kotlin/rules/architecture/reference-features.md +48 -2
  53. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  54. package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  55. package/presets/claude/android-kotlin/skills/unit-testing/SKILL.md +1 -1
  56. package/presets/claude/android-kotlin/team/README.md +1 -1
  57. package/presets/claude/android-kotlin/team/fixtures/feature-parallel.json +84 -0
  58. package/presets/claude/go/CLAUDE.md +1 -1
  59. package/presets/claude/go/REPO_AGENTS.md +8 -0
  60. package/presets/claude/go/agents/README.md +4 -0
  61. package/presets/claude/go/agents/api-contract-reviewer.md +1 -1
  62. package/presets/claude/go/agents/build-verifier.md +1 -1
  63. package/presets/claude/go/agents/ci-investigator.md +0 -1
  64. package/presets/claude/go/agents/code-reviewer.md +3 -3
  65. package/presets/claude/go/agents/codebase-analyzer.md +1 -1
  66. package/presets/claude/go/agents/debugger.md +0 -1
  67. package/presets/claude/go/agents/feature-developer.md +2 -3
  68. package/presets/claude/go/agents/integration-test-generator.md +1 -2
  69. package/presets/claude/go/agents/integration-test-healer.md +1 -2
  70. package/presets/claude/go/agents/integration-test-planner.md +1 -2
  71. package/presets/claude/go/agents/migration-specialist.md +1 -1
  72. package/presets/claude/go/agents/openspec-author.md +2 -1
  73. package/presets/claude/go/agents/performance-auditor.md +1 -1
  74. package/presets/claude/go/agents/qa-tester.md +0 -1
  75. package/presets/claude/go/agents/security-reviewer.md +2 -2
  76. package/presets/claude/go/agents/solution-architect.md +1 -1
  77. package/presets/claude/go/agents/task-analyst.md +1 -1
  78. package/presets/claude/go/agents/task-router.md +1 -1
  79. package/presets/claude/go/agents/tech-writer.md +1 -1
  80. package/presets/claude/go/agents/unit-test-generator.md +1 -2
  81. package/presets/claude/go/agents/unit-test-healer.md +1 -2
  82. package/presets/claude/go/agents/unit-test-planner.md +1 -1
  83. package/presets/claude/go/hooks/chain-team-phases.sh +4 -1
  84. package/presets/claude/go/rules/architecture/feature-delivery.md +50 -1
  85. package/presets/claude/go/rules/architecture/reference-features.md +22 -0
  86. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  87. package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  88. package/presets/claude/go/skills/feature-delivery/SKILL.md +2 -2
  89. package/presets/claude/go/skills/unit-testing/SKILL.md +1 -1
  90. package/presets/claude/go/team/README.md +1 -1
  91. package/presets/claude/go/team/fixtures/feature-parallel.json +84 -0
  92. package/presets/claude/ios-swift/CLAUDE.md +1 -1
  93. package/presets/claude/ios-swift/REPO_AGENTS.md +8 -0
  94. package/presets/claude/ios-swift/agents/README.md +4 -0
  95. package/presets/claude/ios-swift/agents/accessibility-reviewer.md +1 -1
  96. package/presets/claude/ios-swift/agents/api-contract-reviewer.md +1 -1
  97. package/presets/claude/ios-swift/agents/build-verifier.md +1 -1
  98. package/presets/claude/ios-swift/agents/ci-investigator.md +0 -1
  99. package/presets/claude/ios-swift/agents/code-reviewer.md +1 -1
  100. package/presets/claude/ios-swift/agents/codebase-analyzer.md +1 -1
  101. package/presets/claude/ios-swift/agents/debugger.md +0 -1
  102. package/presets/claude/ios-swift/agents/feature-developer.md +0 -1
  103. package/presets/claude/ios-swift/agents/migration-specialist.md +1 -1
  104. package/presets/claude/ios-swift/agents/mockup-reviewer.md +1 -0
  105. package/presets/claude/ios-swift/agents/openspec-author.md +2 -1
  106. package/presets/claude/ios-swift/agents/performance-auditor.md +1 -1
  107. package/presets/claude/ios-swift/agents/qa-tester.md +0 -1
  108. package/presets/claude/ios-swift/agents/security-reviewer.md +1 -1
  109. package/presets/claude/ios-swift/agents/solution-architect.md +1 -1
  110. package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
  111. package/presets/claude/ios-swift/agents/task-router.md +1 -1
  112. package/presets/claude/ios-swift/agents/tech-writer.md +1 -1
  113. package/presets/claude/ios-swift/agents/unit-test-generator.md +0 -1
  114. package/presets/claude/ios-swift/agents/unit-test-healer.md +0 -1
  115. package/presets/claude/ios-swift/agents/unit-test-planner.md +1 -1
  116. package/presets/claude/ios-swift/agents/xcuitest-test-generator.md +0 -1
  117. package/presets/claude/ios-swift/agents/xcuitest-test-healer.md +0 -1
  118. package/presets/claude/ios-swift/agents/xcuitest-test-planner.md +0 -1
  119. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +4 -1
  120. package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +8 -8
  121. package/presets/claude/ios-swift/rules/architecture/reference-features.md +2 -21
  122. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  123. package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  124. package/presets/claude/ios-swift/skills/unit-testing/SKILL.md +1 -1
  125. package/presets/claude/ios-swift/team/README.md +1 -1
  126. package/presets/claude/ios-swift/team/fixtures/feature-parallel.json +84 -0
  127. package/presets/claude/java/CLAUDE.md +2 -2
  128. package/presets/claude/java/REPO_AGENTS.md +8 -0
  129. package/presets/claude/java/agents/README.md +4 -0
  130. package/presets/claude/java/agents/api-contract-reviewer.md +1 -1
  131. package/presets/claude/java/agents/build-verifier.md +1 -1
  132. package/presets/claude/java/agents/ci-investigator.md +0 -1
  133. package/presets/claude/java/agents/code-reviewer.md +3 -3
  134. package/presets/claude/java/agents/codebase-analyzer.md +1 -1
  135. package/presets/claude/java/agents/debugger.md +0 -1
  136. package/presets/claude/java/agents/feature-developer.md +2 -3
  137. package/presets/claude/java/agents/integration-test-generator.md +1 -2
  138. package/presets/claude/java/agents/integration-test-healer.md +1 -2
  139. package/presets/claude/java/agents/integration-test-planner.md +1 -2
  140. package/presets/claude/java/agents/migration-specialist.md +1 -1
  141. package/presets/claude/java/agents/openspec-author.md +2 -1
  142. package/presets/claude/java/agents/performance-auditor.md +1 -1
  143. package/presets/claude/java/agents/qa-tester.md +0 -1
  144. package/presets/claude/java/agents/security-reviewer.md +2 -2
  145. package/presets/claude/java/agents/solution-architect.md +1 -1
  146. package/presets/claude/java/agents/task-analyst.md +1 -1
  147. package/presets/claude/java/agents/task-router.md +1 -1
  148. package/presets/claude/java/agents/tech-writer.md +1 -1
  149. package/presets/claude/java/agents/unit-test-generator.md +1 -2
  150. package/presets/claude/java/agents/unit-test-healer.md +1 -2
  151. package/presets/claude/java/agents/unit-test-planner.md +1 -1
  152. package/presets/claude/java/hooks/chain-team-phases.sh +4 -1
  153. package/presets/claude/java/rules/architecture/feature-delivery.md +51 -1
  154. package/presets/claude/java/rules/architecture/reference-features.md +22 -0
  155. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  156. package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  157. package/presets/claude/java/skills/feature-delivery/SKILL.md +2 -2
  158. package/presets/claude/java/team/README.md +1 -1
  159. package/presets/claude/java/team/fixtures/feature-parallel.json +84 -0
  160. package/presets/claude/mcp-ts/CLAUDE.md +1 -1
  161. package/presets/claude/mcp-ts/REPO_AGENTS.md +8 -0
  162. package/presets/claude/mcp-ts/agents/README.md +4 -0
  163. package/presets/claude/mcp-ts/agents/build-verifier.md +1 -1
  164. package/presets/claude/mcp-ts/agents/feature-developer.md +2 -3
  165. package/presets/claude/mcp-ts/agents/security-reviewer.md +2 -2
  166. package/presets/claude/mcp-ts/agents/solution-architect.md +1 -1
  167. package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
  168. package/presets/claude/mcp-ts/agents/task-router.md +1 -1
  169. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +4 -1
  170. package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +47 -1
  171. package/presets/claude/mcp-ts/rules/architecture/reference-features.md +22 -0
  172. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  173. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  174. package/presets/claude/mcp-ts/skills/code-review/SKILL.md +1 -1
  175. package/presets/claude/mcp-ts/skills/feature-delivery/SKILL.md +2 -2
  176. package/presets/claude/mcp-ts/skills/unit-testing/SKILL.md +1 -1
  177. package/presets/claude/mcp-ts/team/README.md +1 -1
  178. package/presets/claude/mcp-ts/team/fixtures/feature-parallel.json +84 -0
  179. package/presets/claude/mol/CLAUDE.md +1 -1
  180. package/presets/claude/mol/REPO_AGENTS.md +8 -0
  181. package/presets/claude/mol/agents/README.md +2 -4
  182. package/presets/claude/mol/agents/accessibility-reviewer.md +1 -0
  183. package/presets/claude/mol/agents/api-contract-reviewer.md +1 -0
  184. package/presets/claude/mol/agents/build-verifier.md +1 -0
  185. package/presets/claude/mol/agents/code-reviewer.md +1 -0
  186. package/presets/claude/mol/agents/codebase-analyzer.md +1 -0
  187. package/presets/claude/mol/agents/migration-specialist.md +1 -0
  188. package/presets/claude/mol/agents/mockup-reviewer.md +1 -0
  189. package/presets/claude/mol/agents/openspec-author.md +1 -0
  190. package/presets/claude/mol/agents/performance-auditor.md +1 -0
  191. package/presets/claude/mol/agents/security-reviewer.md +1 -0
  192. package/presets/claude/mol/agents/solution-architect.md +1 -0
  193. package/presets/claude/mol/agents/task-analyst.md +1 -0
  194. package/presets/claude/mol/agents/task-router.md +1 -0
  195. package/presets/claude/mol/agents/tech-writer.md +1 -0
  196. package/presets/claude/mol/agents/unit-test-planner.md +1 -0
  197. package/presets/claude/mol/hooks/chain-team-phases.sh +4 -1
  198. package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +10 -10
  199. package/presets/claude/mol/rules/architecture/reference-features.md +0 -19
  200. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  201. package/presets/claude/mol/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  202. package/presets/claude/mol/team/README.md +1 -1
  203. package/presets/claude/next/CLAUDE.md +3 -3
  204. package/presets/claude/next/REPO_AGENTS.md +8 -0
  205. package/presets/claude/next/agents/README.md +4 -0
  206. package/presets/claude/next/agents/accessibility-reviewer.md +1 -0
  207. package/presets/claude/next/agents/api-contract-reviewer.md +1 -0
  208. package/presets/claude/next/agents/build-verifier.md +2 -1
  209. package/presets/claude/next/agents/code-reviewer.md +3 -0
  210. package/presets/claude/next/agents/codebase-analyzer.md +1 -1
  211. package/presets/claude/next/agents/migration-specialist.md +1 -0
  212. package/presets/claude/next/agents/mockup-reviewer.md +1 -0
  213. package/presets/claude/next/agents/openspec-author.md +1 -0
  214. package/presets/claude/next/agents/performance-auditor.md +1 -0
  215. package/presets/claude/next/agents/security-reviewer.md +1 -0
  216. package/presets/claude/next/agents/solution-architect.md +1 -0
  217. package/presets/claude/next/agents/task-analyst.md +1 -0
  218. package/presets/claude/next/agents/task-router.md +12 -0
  219. package/presets/claude/next/agents/tech-writer.md +1 -0
  220. package/presets/claude/next/agents/unit-test-planner.md +1 -0
  221. package/presets/claude/next/ai-local/rules-library/agent-artifacts-no-local-paths.md +71 -0
  222. package/presets/claude/next/ai-local/rules-library/agent-pipeline-gates.md +19 -0
  223. package/presets/claude/next/ai-local/rules-library/analytics-events.md +18 -0
  224. package/presets/claude/next/ai-local/rules-library/api-contract-source.md +14 -0
  225. package/presets/claude/next/ai-local/rules-library/artifact-lifecycle.md +17 -0
  226. package/presets/claude/next/ai-local/rules-library/code-style.md +68 -0
  227. package/presets/claude/next/ai-local/rules-library/commit-hygiene.md +17 -0
  228. package/presets/claude/next/ai-local/rules-library/component-child-decomposition.md +81 -0
  229. package/presets/claude/next/ai-local/rules-library/feature-flags-experiments.md +15 -0
  230. package/presets/claude/next/ai-local/rules-library/mcp-required-for-ui-layout.md +45 -0
  231. package/presets/claude/next/ai-local/rules-library/no-react-fc.md +46 -0
  232. package/presets/claude/next/ai-local/rules-library/no-test-driven-behavior-change.md +14 -0
  233. package/presets/claude/next/ai-local/rules-library/pre-pr-checklist.md +16 -0
  234. package/presets/claude/next/ai-local/rules-library/pwa-service-worker.md +15 -0
  235. package/presets/claude/next/ai-local/rules-library/qa-test-cases.md +14 -0
  236. package/presets/claude/next/ai-local/rules-library/router-pages.md +25 -0
  237. package/presets/claude/next/ai-local/rules-library/single-source-copy-constants.md +18 -0
  238. package/presets/claude/next/ai-local/rules-library/storybook-catalog-structure.md +62 -0
  239. package/presets/claude/next/ai-local/rules-library/storybook-cleanup-temp-screenshots.md +40 -0
  240. package/presets/claude/next/ai-local/rules-library/storybook-csf-authoring.md +100 -0
  241. package/presets/claude/next/ai-local/rules-library/storybook-dev-compare-figma.md +72 -0
  242. package/presets/claude/next/ai-local/rules-library/storybook-keep-tests-current.md +75 -0
  243. package/presets/claude/next/ai-local/rules-library/storybook-modals.md +64 -0
  244. package/presets/claude/next/ai-local/rules-library/storybook-no-app-node-modules.md +40 -0
  245. package/presets/claude/next/ai-local/rules-library/storybook-ui-quality-gate.md +38 -0
  246. package/presets/claude/next/ai-local/rules-library/ui-change-review-gate.md +16 -0
  247. package/presets/claude/next/hooks/chain-team-phases.sh +4 -1
  248. package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +13 -13
  249. package/presets/claude/next/rules/architecture/reference-features.md +0 -19
  250. package/presets/claude/next/rules/stack/next-app-core.md +1 -1
  251. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  252. package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  253. package/presets/claude/next/team/README.md +1 -1
  254. package/presets/claude/next/team/fixtures/feature-l2-lite.json +27 -0
  255. package/presets/claude/nuxt/CLAUDE.md +3 -3
  256. package/presets/claude/nuxt/REPO_AGENTS.md +8 -0
  257. package/presets/claude/nuxt/agents/README.md +2 -4
  258. package/presets/claude/nuxt/agents/accessibility-reviewer.md +1 -0
  259. package/presets/claude/nuxt/agents/api-contract-reviewer.md +1 -0
  260. package/presets/claude/nuxt/agents/build-verifier.md +1 -0
  261. package/presets/claude/nuxt/agents/code-reviewer.md +1 -0
  262. package/presets/claude/nuxt/agents/codebase-analyzer.md +1 -1
  263. package/presets/claude/nuxt/agents/migration-specialist.md +1 -0
  264. package/presets/claude/nuxt/agents/mockup-reviewer.md +1 -0
  265. package/presets/claude/nuxt/agents/openspec-author.md +2 -1
  266. package/presets/claude/nuxt/agents/performance-auditor.md +1 -0
  267. package/presets/claude/nuxt/agents/playwright-test-generator.md +24 -68
  268. package/presets/claude/nuxt/agents/playwright-test-healer.md +28 -54
  269. package/presets/claude/nuxt/agents/playwright-test-planner.md +18 -51
  270. package/presets/claude/nuxt/agents/security-reviewer.md +1 -0
  271. package/presets/claude/nuxt/agents/solution-architect.md +1 -0
  272. package/presets/claude/nuxt/agents/task-analyst.md +12 -0
  273. package/presets/claude/nuxt/agents/task-router.md +1 -0
  274. package/presets/claude/nuxt/agents/tech-writer.md +1 -0
  275. package/presets/claude/nuxt/agents/unit-test-planner.md +1 -0
  276. package/presets/claude/nuxt/hooks/chain-team-phases.sh +4 -1
  277. package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +9 -9
  278. package/presets/claude/nuxt/rules/architecture/reference-features.md +1 -20
  279. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  280. package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  281. package/presets/claude/nuxt/team/README.md +1 -1
  282. package/presets/claude/nuxt/team/fixtures/feature-parallel.json +84 -0
  283. package/presets/claude/php-hexagonal/CLAUDE.md +2 -2
  284. package/presets/claude/php-hexagonal/REPO_AGENTS.md +8 -0
  285. package/presets/claude/php-hexagonal/agents/README.md +4 -0
  286. package/presets/claude/php-hexagonal/agents/api-contract-reviewer.md +1 -1
  287. package/presets/claude/php-hexagonal/agents/build-verifier.md +1 -1
  288. package/presets/claude/php-hexagonal/agents/ci-investigator.md +0 -1
  289. package/presets/claude/php-hexagonal/agents/code-reviewer.md +3 -3
  290. package/presets/claude/php-hexagonal/agents/codebase-analyzer.md +1 -1
  291. package/presets/claude/php-hexagonal/agents/debugger.md +0 -1
  292. package/presets/claude/php-hexagonal/agents/feature-developer.md +2 -3
  293. package/presets/claude/php-hexagonal/agents/integration-test-generator.md +1 -2
  294. package/presets/claude/php-hexagonal/agents/integration-test-healer.md +1 -2
  295. package/presets/claude/php-hexagonal/agents/integration-test-planner.md +1 -2
  296. package/presets/claude/php-hexagonal/agents/migration-specialist.md +1 -1
  297. package/presets/claude/php-hexagonal/agents/openspec-author.md +2 -1
  298. package/presets/claude/php-hexagonal/agents/performance-auditor.md +1 -1
  299. package/presets/claude/php-hexagonal/agents/qa-tester.md +0 -1
  300. package/presets/claude/php-hexagonal/agents/security-reviewer.md +2 -2
  301. package/presets/claude/php-hexagonal/agents/solution-architect.md +1 -1
  302. package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
  303. package/presets/claude/php-hexagonal/agents/task-router.md +1 -1
  304. package/presets/claude/php-hexagonal/agents/tech-writer.md +1 -1
  305. package/presets/claude/php-hexagonal/agents/unit-test-generator.md +1 -2
  306. package/presets/claude/php-hexagonal/agents/unit-test-healer.md +1 -2
  307. package/presets/claude/php-hexagonal/agents/unit-test-planner.md +1 -1
  308. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +4 -1
  309. package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +51 -1
  310. package/presets/claude/php-hexagonal/rules/architecture/reference-features.md +25 -0
  311. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  312. package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  313. package/presets/claude/php-hexagonal/skills/feature-delivery/SKILL.md +2 -2
  314. package/presets/claude/php-hexagonal/team/README.md +1 -1
  315. package/presets/claude/php-hexagonal/team/fixtures/feature-parallel.json +84 -0
  316. package/presets/claude/php-laravel/CLAUDE.md +1 -1
  317. package/presets/claude/php-laravel/REPO_AGENTS.md +8 -0
  318. package/presets/claude/php-laravel/agents/README.md +4 -0
  319. package/presets/claude/php-laravel/agents/api-contract-reviewer.md +1 -1
  320. package/presets/claude/php-laravel/agents/build-verifier.md +1 -1
  321. package/presets/claude/php-laravel/agents/ci-investigator.md +0 -1
  322. package/presets/claude/php-laravel/agents/code-reviewer.md +1 -1
  323. package/presets/claude/php-laravel/agents/codebase-analyzer.md +1 -1
  324. package/presets/claude/php-laravel/agents/debugger.md +0 -1
  325. package/presets/claude/php-laravel/agents/feature-developer.md +2 -3
  326. package/presets/claude/php-laravel/agents/integration-test-generator.md +1 -2
  327. package/presets/claude/php-laravel/agents/integration-test-healer.md +1 -2
  328. package/presets/claude/php-laravel/agents/integration-test-planner.md +1 -2
  329. package/presets/claude/php-laravel/agents/migration-specialist.md +1 -1
  330. package/presets/claude/php-laravel/agents/openspec-author.md +2 -1
  331. package/presets/claude/php-laravel/agents/performance-auditor.md +1 -1
  332. package/presets/claude/php-laravel/agents/qa-tester.md +0 -1
  333. package/presets/claude/php-laravel/agents/security-reviewer.md +1 -1
  334. package/presets/claude/php-laravel/agents/solution-architect.md +1 -1
  335. package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
  336. package/presets/claude/php-laravel/agents/task-router.md +1 -1
  337. package/presets/claude/php-laravel/agents/tech-writer.md +1 -1
  338. package/presets/claude/php-laravel/agents/unit-test-generator.md +1 -2
  339. package/presets/claude/php-laravel/agents/unit-test-healer.md +1 -2
  340. package/presets/claude/php-laravel/agents/unit-test-planner.md +1 -1
  341. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +4 -1
  342. package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +54 -1
  343. package/presets/claude/php-laravel/rules/architecture/reference-features.md +27 -0
  344. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  345. package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  346. package/presets/claude/php-laravel/skills/feature-delivery/SKILL.md +2 -2
  347. package/presets/claude/php-laravel/team/README.md +1 -1
  348. package/presets/claude/php-laravel/team/fixtures/feature-parallel.json +84 -0
  349. package/presets/claude/svelte/CLAUDE.md +3 -3
  350. package/presets/claude/svelte/REPO_AGENTS.md +8 -0
  351. package/presets/claude/svelte/agents/README.md +2 -4
  352. package/presets/claude/svelte/agents/accessibility-reviewer.md +1 -0
  353. package/presets/claude/svelte/agents/api-contract-reviewer.md +1 -0
  354. package/presets/claude/svelte/agents/build-verifier.md +1 -0
  355. package/presets/claude/svelte/agents/code-reviewer.md +1 -0
  356. package/presets/claude/svelte/agents/codebase-analyzer.md +1 -1
  357. package/presets/claude/svelte/agents/migration-specialist.md +1 -0
  358. package/presets/claude/svelte/agents/mockup-reviewer.md +1 -0
  359. package/presets/claude/svelte/agents/openspec-author.md +2 -1
  360. package/presets/claude/svelte/agents/performance-auditor.md +1 -0
  361. package/presets/claude/svelte/agents/playwright-test-generator.md +24 -68
  362. package/presets/claude/svelte/agents/playwright-test-healer.md +28 -54
  363. package/presets/claude/svelte/agents/playwright-test-planner.md +18 -51
  364. package/presets/claude/svelte/agents/security-reviewer.md +1 -0
  365. package/presets/claude/svelte/agents/solution-architect.md +1 -0
  366. package/presets/claude/svelte/agents/task-analyst.md +12 -0
  367. package/presets/claude/svelte/agents/task-router.md +1 -1
  368. package/presets/claude/svelte/agents/tech-writer.md +1 -0
  369. package/presets/claude/svelte/agents/unit-test-planner.md +1 -0
  370. package/presets/claude/svelte/hooks/chain-team-phases.sh +4 -1
  371. package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +7 -7
  372. package/presets/claude/svelte/rules/architecture/reference-features.md +1 -20
  373. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  374. package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  375. package/presets/claude/svelte/team/README.md +1 -1
  376. package/presets/claude/svelte/team/fixtures/feature-parallel.json +84 -0
  377. package/presets/cursor/android-kotlin/REPO_AGENTS.md +8 -0
  378. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +4 -1
  379. package/presets/cursor/android-kotlin/hooks/compact-shell-output.mjs +68 -0
  380. package/presets/cursor/android-kotlin/hooks.json +7 -0
  381. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +17 -5
  382. package/presets/cursor/android-kotlin/rules/feature-delivery-workflow.mdc +66 -8
  383. package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +2 -2
  384. package/presets/cursor/android-kotlin/rules/reference-features.mdc +48 -2
  385. package/presets/cursor/android-kotlin/skills/unit-testing/SKILL.md +1 -1
  386. package/presets/cursor/android-kotlin/team/README.md +1 -1
  387. package/presets/cursor/android-kotlin/team/fixtures/feature-parallel.json +84 -0
  388. package/presets/cursor/go/REPO_AGENTS.md +8 -0
  389. package/presets/cursor/go/hooks/chain-team-phases.sh +4 -1
  390. package/presets/cursor/go/hooks/compact-shell-output.mjs +68 -0
  391. package/presets/cursor/go/hooks.json +7 -0
  392. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +16 -5
  393. package/presets/cursor/go/rules/feature-delivery-workflow.mdc +63 -5
  394. package/presets/cursor/go/rules/preset-pr-checklist.mdc +2 -2
  395. package/presets/cursor/go/rules/reference-features.mdc +46 -6
  396. package/presets/cursor/go/skills/feature-delivery/SKILL.md +2 -2
  397. package/presets/cursor/go/skills/unit-testing/SKILL.md +1 -1
  398. package/presets/cursor/go/team/README.md +1 -1
  399. package/presets/cursor/go/team/fixtures/feature-parallel.json +84 -0
  400. package/presets/cursor/ios-swift/REPO_AGENTS.md +8 -0
  401. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +4 -1
  402. package/presets/cursor/ios-swift/hooks/compact-shell-output.mjs +68 -0
  403. package/presets/cursor/ios-swift/hooks.json +7 -0
  404. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +17 -5
  405. package/presets/cursor/ios-swift/rules/feature-delivery-workflow.mdc +64 -8
  406. package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +2 -2
  407. package/presets/cursor/ios-swift/rules/reference-features.mdc +44 -21
  408. package/presets/cursor/ios-swift/skills/unit-testing/SKILL.md +1 -1
  409. package/presets/cursor/ios-swift/team/README.md +1 -1
  410. package/presets/cursor/ios-swift/team/fixtures/feature-parallel.json +84 -0
  411. package/presets/cursor/java/AGENTS.md +1 -1
  412. package/presets/cursor/java/REPO_AGENTS.md +8 -0
  413. package/presets/cursor/java/hooks/chain-team-phases.sh +4 -1
  414. package/presets/cursor/java/hooks/compact-shell-output.mjs +68 -0
  415. package/presets/cursor/java/hooks.json +7 -0
  416. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +16 -5
  417. package/presets/cursor/java/rules/feature-delivery-workflow.mdc +63 -5
  418. package/presets/cursor/java/rules/preset-pr-checklist.mdc +2 -2
  419. package/presets/cursor/java/rules/reference-features.mdc +46 -6
  420. package/presets/cursor/java/skills/feature-delivery/SKILL.md +2 -2
  421. package/presets/cursor/java/team/README.md +1 -1
  422. package/presets/cursor/java/team/fixtures/feature-parallel.json +84 -0
  423. package/presets/cursor/mcp-ts/REPO_AGENTS.md +8 -0
  424. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +4 -1
  425. package/presets/cursor/mcp-ts/hooks/compact-shell-output.mjs +68 -0
  426. package/presets/cursor/mcp-ts/hooks.json +7 -0
  427. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +17 -6
  428. package/presets/cursor/mcp-ts/rules/feature-delivery-workflow.mdc +63 -5
  429. package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +2 -2
  430. package/presets/cursor/mcp-ts/rules/reference-features.mdc +46 -6
  431. package/presets/cursor/mcp-ts/skills/code-review/SKILL.md +1 -1
  432. package/presets/cursor/mcp-ts/skills/feature-delivery/SKILL.md +2 -2
  433. package/presets/cursor/mcp-ts/skills/unit-testing/SKILL.md +1 -1
  434. package/presets/cursor/mcp-ts/team/README.md +1 -1
  435. package/presets/cursor/mcp-ts/team/fixtures/feature-parallel.json +84 -0
  436. package/presets/cursor/mol/REPO_AGENTS.md +8 -0
  437. package/presets/cursor/mol/hooks/chain-team-phases.sh +4 -1
  438. package/presets/cursor/mol/hooks/compact-shell-output.mjs +68 -0
  439. package/presets/cursor/mol/hooks.json +7 -0
  440. package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +16 -5
  441. package/presets/cursor/mol/rules/feature-delivery-workflow.mdc +65 -9
  442. package/presets/cursor/mol/rules/preset-pr-checklist.mdc +2 -2
  443. package/presets/cursor/mol/rules/reference-features.mdc +43 -20
  444. package/presets/cursor/mol/team/README.md +1 -1
  445. package/presets/cursor/next/README.md +2 -2
  446. package/presets/cursor/next/REPO_AGENTS.md +8 -0
  447. package/presets/cursor/next/agents/build-verifier.md +1 -1
  448. package/presets/cursor/next/agents/code-reviewer.md +2 -0
  449. package/presets/cursor/next/hooks/chain-team-phases.sh +4 -1
  450. package/presets/cursor/next/hooks/compact-shell-output.mjs +68 -0
  451. package/presets/cursor/next/hooks.json +7 -0
  452. package/presets/cursor/next/rules/README.md +2 -2
  453. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +16 -5
  454. package/presets/cursor/next/rules/feature-delivery-workflow.mdc +68 -12
  455. package/presets/cursor/next/rules/next-app-core.mdc +1 -1
  456. package/presets/cursor/next/rules/preset-pr-checklist.mdc +2 -2
  457. package/presets/cursor/next/rules/reference-features.mdc +42 -19
  458. package/presets/cursor/next/team/README.md +1 -1
  459. package/presets/cursor/nuxt/REPO_AGENTS.md +8 -0
  460. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +4 -1
  461. package/presets/cursor/nuxt/hooks/compact-shell-output.mjs +68 -0
  462. package/presets/cursor/nuxt/hooks.json +7 -0
  463. package/presets/cursor/nuxt/rules/README.md +2 -2
  464. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +16 -5
  465. package/presets/cursor/nuxt/rules/feature-delivery-workflow.mdc +64 -8
  466. package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +2 -2
  467. package/presets/cursor/nuxt/rules/reference-features.mdc +37 -14
  468. package/presets/cursor/nuxt/team/README.md +1 -1
  469. package/presets/cursor/nuxt/team/fixtures/feature-parallel.json +84 -0
  470. package/presets/cursor/php-hexagonal/AGENTS.md +1 -1
  471. package/presets/cursor/php-hexagonal/REPO_AGENTS.md +8 -0
  472. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +4 -1
  473. package/presets/cursor/php-hexagonal/hooks/compact-shell-output.mjs +68 -0
  474. package/presets/cursor/php-hexagonal/hooks.json +7 -0
  475. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +16 -5
  476. package/presets/cursor/php-hexagonal/rules/feature-delivery-workflow.mdc +63 -5
  477. package/presets/cursor/php-hexagonal/rules/preset-pr-checklist.mdc +2 -2
  478. package/presets/cursor/php-hexagonal/rules/reference-features.mdc +46 -6
  479. package/presets/cursor/php-hexagonal/skills/feature-delivery/SKILL.md +2 -2
  480. package/presets/cursor/php-hexagonal/team/README.md +1 -1
  481. package/presets/cursor/php-hexagonal/team/fixtures/feature-parallel.json +84 -0
  482. package/presets/cursor/php-laravel/AGENTS.md +1 -1
  483. package/presets/cursor/php-laravel/REPO_AGENTS.md +8 -0
  484. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +4 -1
  485. package/presets/cursor/php-laravel/hooks/compact-shell-output.mjs +68 -0
  486. package/presets/cursor/php-laravel/hooks.json +7 -0
  487. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +16 -5
  488. package/presets/cursor/php-laravel/rules/feature-delivery-workflow.mdc +63 -5
  489. package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +2 -2
  490. package/presets/cursor/php-laravel/rules/reference-features.mdc +46 -6
  491. package/presets/cursor/php-laravel/skills/feature-delivery/SKILL.md +2 -2
  492. package/presets/cursor/php-laravel/team/README.md +1 -1
  493. package/presets/cursor/php-laravel/team/fixtures/feature-parallel.json +84 -0
  494. package/presets/cursor/svelte/REPO_AGENTS.md +8 -0
  495. package/presets/cursor/svelte/hooks/chain-team-phases.sh +4 -1
  496. package/presets/cursor/svelte/hooks/compact-shell-output.mjs +68 -0
  497. package/presets/cursor/svelte/hooks.json +7 -0
  498. package/presets/cursor/svelte/rules/README.md +1 -1
  499. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +16 -5
  500. package/presets/cursor/svelte/rules/feature-delivery-workflow.mdc +62 -6
  501. package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +2 -2
  502. package/presets/cursor/svelte/rules/reference-features.mdc +40 -17
  503. package/presets/cursor/svelte/team/README.md +1 -1
  504. package/presets/cursor/svelte/team/fixtures/feature-parallel.json +84 -0
  505. package/presets/mavis/android-kotlin/REPO_AGENTS.md +8 -0
  506. package/presets/mavis/android-kotlin/adapter-map.json +19 -2
  507. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +4 -1
  508. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +1 -1
  509. package/presets/mavis/android-kotlin/rules/feature-delivery-workflow.md +66 -8
  510. package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +2 -2
  511. package/presets/mavis/android-kotlin/rules/reference-features.md +48 -2
  512. package/presets/mavis/android-kotlin/skills/unit-testing/SKILL.md +1 -1
  513. package/presets/mavis/android-kotlin/team/README.md +1 -1
  514. package/presets/mavis/android-kotlin/team/fixtures/feature-parallel.json +84 -0
  515. package/presets/mavis/go/REPO_AGENTS.md +8 -0
  516. package/presets/mavis/go/adapter-map.json +17 -1
  517. package/presets/mavis/go/hooks/chain-team-phases.sh +4 -1
  518. package/presets/mavis/go/rules/agent-team-orchestrator.md +1 -1
  519. package/presets/mavis/go/rules/feature-delivery-workflow.md +50 -1
  520. package/presets/mavis/go/rules/preset-pr-checklist.md +2 -2
  521. package/presets/mavis/go/rules/reference-features.md +22 -0
  522. package/presets/mavis/go/skills/feature-delivery/SKILL.md +2 -2
  523. package/presets/mavis/go/skills/unit-testing/SKILL.md +1 -1
  524. package/presets/mavis/go/team/README.md +1 -1
  525. package/presets/mavis/go/team/fixtures/feature-parallel.json +84 -0
  526. package/presets/mavis/ios-swift/REPO_AGENTS.md +8 -0
  527. package/presets/mavis/ios-swift/adapter-map.json +17 -1
  528. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +4 -1
  529. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +1 -1
  530. package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +8 -8
  531. package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +2 -2
  532. package/presets/mavis/ios-swift/rules/reference-features.md +2 -21
  533. package/presets/mavis/ios-swift/skills/unit-testing/SKILL.md +1 -1
  534. package/presets/mavis/ios-swift/team/README.md +1 -1
  535. package/presets/mavis/ios-swift/team/fixtures/feature-parallel.json +84 -0
  536. package/presets/mavis/java/MAVIS.md +1 -1
  537. package/presets/mavis/java/REPO_AGENTS.md +8 -0
  538. package/presets/mavis/java/adapter-map.json +17 -1
  539. package/presets/mavis/java/hooks/chain-team-phases.sh +4 -1
  540. package/presets/mavis/java/rules/agent-team-orchestrator.md +1 -1
  541. package/presets/mavis/java/rules/feature-delivery-workflow.md +51 -1
  542. package/presets/mavis/java/rules/preset-pr-checklist.md +2 -2
  543. package/presets/mavis/java/rules/reference-features.md +22 -0
  544. package/presets/mavis/java/skills/feature-delivery/SKILL.md +2 -2
  545. package/presets/mavis/java/team/README.md +1 -1
  546. package/presets/mavis/java/team/fixtures/feature-parallel.json +84 -0
  547. package/presets/mavis/mcp-ts/REPO_AGENTS.md +8 -0
  548. package/presets/mavis/mcp-ts/adapter-map.json +17 -1
  549. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +4 -1
  550. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +1 -1
  551. package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +47 -1
  552. package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +2 -2
  553. package/presets/mavis/mcp-ts/rules/reference-features.md +22 -0
  554. package/presets/mavis/mcp-ts/skills/code-review/SKILL.md +1 -1
  555. package/presets/mavis/mcp-ts/skills/feature-delivery/SKILL.md +2 -2
  556. package/presets/mavis/mcp-ts/skills/unit-testing/SKILL.md +1 -1
  557. package/presets/mavis/mcp-ts/team/README.md +1 -1
  558. package/presets/mavis/mcp-ts/team/fixtures/feature-parallel.json +84 -0
  559. package/presets/mavis/mol/REPO_AGENTS.md +8 -0
  560. package/presets/mavis/mol/adapter-map.json +9 -1
  561. package/presets/mavis/mol/hooks/chain-team-phases.sh +4 -1
  562. package/presets/mavis/mol/rules/agent-team-orchestrator.md +1 -1
  563. package/presets/mavis/mol/rules/feature-delivery-workflow.md +10 -10
  564. package/presets/mavis/mol/rules/preset-pr-checklist.md +2 -2
  565. package/presets/mavis/mol/rules/reference-features.md +0 -19
  566. package/presets/mavis/mol/team/README.md +1 -1
  567. package/presets/mavis/next/REPO_AGENTS.md +8 -0
  568. package/presets/mavis/next/adapter-map.json +9 -1
  569. package/presets/mavis/next/agents/build-verifier.md +1 -1
  570. package/presets/mavis/next/agents/code-reviewer.md +2 -0
  571. package/presets/mavis/next/hooks/chain-team-phases.sh +4 -1
  572. package/presets/mavis/next/rules/agent-team-orchestrator.md +1 -1
  573. package/presets/mavis/next/rules/feature-delivery-workflow.md +13 -13
  574. package/presets/mavis/next/rules/next-app-core.md +1 -1
  575. package/presets/mavis/next/rules/preset-pr-checklist.md +2 -2
  576. package/presets/mavis/next/rules/reference-features.md +0 -19
  577. package/presets/mavis/next/team/README.md +1 -1
  578. package/presets/mavis/nuxt/REPO_AGENTS.md +8 -0
  579. package/presets/mavis/nuxt/adapter-map.json +17 -1
  580. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +4 -1
  581. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +1 -1
  582. package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +9 -9
  583. package/presets/mavis/nuxt/rules/preset-pr-checklist.md +2 -2
  584. package/presets/mavis/nuxt/rules/reference-features.md +1 -20
  585. package/presets/mavis/nuxt/team/README.md +1 -1
  586. package/presets/mavis/nuxt/team/fixtures/feature-parallel.json +84 -0
  587. package/presets/mavis/php-hexagonal/MAVIS.md +1 -1
  588. package/presets/mavis/php-hexagonal/REPO_AGENTS.md +8 -0
  589. package/presets/mavis/php-hexagonal/adapter-map.json +17 -1
  590. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +4 -1
  591. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +1 -1
  592. package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +51 -1
  593. package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +2 -2
  594. package/presets/mavis/php-hexagonal/rules/reference-features.md +25 -0
  595. package/presets/mavis/php-hexagonal/skills/feature-delivery/SKILL.md +2 -2
  596. package/presets/mavis/php-hexagonal/team/README.md +1 -1
  597. package/presets/mavis/php-hexagonal/team/fixtures/feature-parallel.json +84 -0
  598. package/presets/mavis/php-laravel/MAVIS.md +1 -1
  599. package/presets/mavis/php-laravel/REPO_AGENTS.md +8 -0
  600. package/presets/mavis/php-laravel/adapter-map.json +17 -1
  601. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +4 -1
  602. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +1 -1
  603. package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +54 -1
  604. package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +2 -2
  605. package/presets/mavis/php-laravel/rules/reference-features.md +27 -0
  606. package/presets/mavis/php-laravel/skills/feature-delivery/SKILL.md +2 -2
  607. package/presets/mavis/php-laravel/team/README.md +1 -1
  608. package/presets/mavis/php-laravel/team/fixtures/feature-parallel.json +84 -0
  609. package/presets/mavis/svelte/REPO_AGENTS.md +8 -0
  610. package/presets/mavis/svelte/adapter-map.json +17 -1
  611. package/presets/mavis/svelte/hooks/chain-team-phases.sh +4 -1
  612. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +1 -1
  613. package/presets/mavis/svelte/rules/feature-delivery-workflow.md +7 -7
  614. package/presets/mavis/svelte/rules/preset-pr-checklist.md +2 -2
  615. package/presets/mavis/svelte/rules/reference-features.md +1 -20
  616. package/presets/mavis/svelte/team/README.md +1 -1
  617. package/presets/mavis/svelte/team/fixtures/feature-parallel.json +84 -0
  618. package/presets/opencode/android-kotlin/REPO_AGENTS.md +8 -0
  619. package/presets/opencode/android-kotlin/adapter-map.json +19 -2
  620. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +4 -1
  621. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +1 -1
  622. package/presets/opencode/android-kotlin/rules/feature-delivery-workflow.md +66 -8
  623. package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +2 -2
  624. package/presets/opencode/android-kotlin/rules/reference-features.md +48 -2
  625. package/presets/opencode/android-kotlin/skills/unit-testing/SKILL.md +1 -1
  626. package/presets/opencode/android-kotlin/team/README.md +1 -1
  627. package/presets/opencode/android-kotlin/team/fixtures/feature-parallel.json +84 -0
  628. package/presets/opencode/go/REPO_AGENTS.md +8 -0
  629. package/presets/opencode/go/adapter-map.json +17 -1
  630. package/presets/opencode/go/hooks/chain-team-phases.sh +4 -1
  631. package/presets/opencode/go/rules/agent-team-orchestrator.md +1 -1
  632. package/presets/opencode/go/rules/feature-delivery-workflow.md +50 -1
  633. package/presets/opencode/go/rules/preset-pr-checklist.md +2 -2
  634. package/presets/opencode/go/rules/reference-features.md +22 -0
  635. package/presets/opencode/go/skills/feature-delivery/SKILL.md +2 -2
  636. package/presets/opencode/go/skills/unit-testing/SKILL.md +1 -1
  637. package/presets/opencode/go/team/README.md +1 -1
  638. package/presets/opencode/go/team/fixtures/feature-parallel.json +84 -0
  639. package/presets/opencode/ios-swift/REPO_AGENTS.md +8 -0
  640. package/presets/opencode/ios-swift/adapter-map.json +17 -1
  641. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +4 -1
  642. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +1 -1
  643. package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +8 -8
  644. package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +2 -2
  645. package/presets/opencode/ios-swift/rules/reference-features.md +2 -21
  646. package/presets/opencode/ios-swift/skills/unit-testing/SKILL.md +1 -1
  647. package/presets/opencode/ios-swift/team/README.md +1 -1
  648. package/presets/opencode/ios-swift/team/fixtures/feature-parallel.json +84 -0
  649. package/presets/opencode/java/OPENCODE.md +1 -1
  650. package/presets/opencode/java/REPO_AGENTS.md +8 -0
  651. package/presets/opencode/java/adapter-map.json +17 -1
  652. package/presets/opencode/java/hooks/chain-team-phases.sh +4 -1
  653. package/presets/opencode/java/rules/agent-team-orchestrator.md +1 -1
  654. package/presets/opencode/java/rules/feature-delivery-workflow.md +51 -1
  655. package/presets/opencode/java/rules/preset-pr-checklist.md +2 -2
  656. package/presets/opencode/java/rules/reference-features.md +22 -0
  657. package/presets/opencode/java/skills/feature-delivery/SKILL.md +2 -2
  658. package/presets/opencode/java/team/README.md +1 -1
  659. package/presets/opencode/java/team/fixtures/feature-parallel.json +84 -0
  660. package/presets/opencode/mcp-ts/REPO_AGENTS.md +8 -0
  661. package/presets/opencode/mcp-ts/adapter-map.json +17 -1
  662. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +4 -1
  663. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +1 -1
  664. package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +47 -1
  665. package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +2 -2
  666. package/presets/opencode/mcp-ts/rules/reference-features.md +22 -0
  667. package/presets/opencode/mcp-ts/skills/code-review/SKILL.md +1 -1
  668. package/presets/opencode/mcp-ts/skills/feature-delivery/SKILL.md +2 -2
  669. package/presets/opencode/mcp-ts/skills/unit-testing/SKILL.md +1 -1
  670. package/presets/opencode/mcp-ts/team/README.md +1 -1
  671. package/presets/opencode/mcp-ts/team/fixtures/feature-parallel.json +84 -0
  672. package/presets/opencode/mol/REPO_AGENTS.md +8 -0
  673. package/presets/opencode/mol/adapter-map.json +9 -1
  674. package/presets/opencode/mol/hooks/chain-team-phases.sh +4 -1
  675. package/presets/opencode/mol/rules/agent-team-orchestrator.md +1 -1
  676. package/presets/opencode/mol/rules/feature-delivery-workflow.md +10 -10
  677. package/presets/opencode/mol/rules/preset-pr-checklist.md +2 -2
  678. package/presets/opencode/mol/rules/reference-features.md +0 -19
  679. package/presets/opencode/mol/team/README.md +1 -1
  680. package/presets/opencode/next/REPO_AGENTS.md +8 -0
  681. package/presets/opencode/next/adapter-map.json +9 -1
  682. package/presets/opencode/next/agents/build-verifier.md +1 -1
  683. package/presets/opencode/next/agents/code-reviewer.md +2 -0
  684. package/presets/opencode/next/hooks/chain-team-phases.sh +4 -1
  685. package/presets/opencode/next/rules/agent-team-orchestrator.md +1 -1
  686. package/presets/opencode/next/rules/feature-delivery-workflow.md +13 -13
  687. package/presets/opencode/next/rules/next-app-core.md +1 -1
  688. package/presets/opencode/next/rules/preset-pr-checklist.md +2 -2
  689. package/presets/opencode/next/rules/reference-features.md +0 -19
  690. package/presets/opencode/next/team/README.md +1 -1
  691. package/presets/opencode/nuxt/REPO_AGENTS.md +8 -0
  692. package/presets/opencode/nuxt/adapter-map.json +17 -1
  693. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +4 -1
  694. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +1 -1
  695. package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +9 -9
  696. package/presets/opencode/nuxt/rules/preset-pr-checklist.md +2 -2
  697. package/presets/opencode/nuxt/rules/reference-features.md +1 -20
  698. package/presets/opencode/nuxt/team/README.md +1 -1
  699. package/presets/opencode/nuxt/team/fixtures/feature-parallel.json +84 -0
  700. package/presets/opencode/php-hexagonal/OPENCODE.md +1 -1
  701. package/presets/opencode/php-hexagonal/REPO_AGENTS.md +8 -0
  702. package/presets/opencode/php-hexagonal/adapter-map.json +17 -1
  703. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +4 -1
  704. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +1 -1
  705. package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +51 -1
  706. package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +2 -2
  707. package/presets/opencode/php-hexagonal/rules/reference-features.md +25 -0
  708. package/presets/opencode/php-hexagonal/skills/feature-delivery/SKILL.md +2 -2
  709. package/presets/opencode/php-hexagonal/team/README.md +1 -1
  710. package/presets/opencode/php-hexagonal/team/fixtures/feature-parallel.json +84 -0
  711. package/presets/opencode/php-laravel/OPENCODE.md +1 -1
  712. package/presets/opencode/php-laravel/REPO_AGENTS.md +8 -0
  713. package/presets/opencode/php-laravel/adapter-map.json +17 -1
  714. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +4 -1
  715. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +1 -1
  716. package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +54 -1
  717. package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +2 -2
  718. package/presets/opencode/php-laravel/rules/reference-features.md +27 -0
  719. package/presets/opencode/php-laravel/skills/feature-delivery/SKILL.md +2 -2
  720. package/presets/opencode/php-laravel/team/README.md +1 -1
  721. package/presets/opencode/php-laravel/team/fixtures/feature-parallel.json +84 -0
  722. package/presets/opencode/plugins/output-guard/README.md +3 -2
  723. package/presets/opencode/plugins/output-guard/rewrite.ts +10 -1
  724. package/presets/opencode/svelte/REPO_AGENTS.md +8 -0
  725. package/presets/opencode/svelte/adapter-map.json +17 -1
  726. package/presets/opencode/svelte/hooks/chain-team-phases.sh +4 -1
  727. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +1 -1
  728. package/presets/opencode/svelte/rules/feature-delivery-workflow.md +7 -7
  729. package/presets/opencode/svelte/rules/preset-pr-checklist.md +2 -2
  730. package/presets/opencode/svelte/rules/reference-features.md +1 -20
  731. package/presets/opencode/svelte/team/README.md +1 -1
  732. package/presets/opencode/svelte/team/fixtures/feature-parallel.json +84 -0
  733. package/presets/zcode/android-kotlin/REPO_AGENTS.md +8 -0
  734. package/presets/zcode/android-kotlin/adapter-map.json +19 -2
  735. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +4 -1
  736. package/presets/zcode/android-kotlin/rules/README.md +3 -3
  737. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +1 -1
  738. package/presets/zcode/android-kotlin/rules/feature-delivery-workflow.md +66 -8
  739. package/presets/zcode/android-kotlin/rules/preset-pr-checklist.md +2 -2
  740. package/presets/zcode/android-kotlin/rules/reference-features.md +48 -2
  741. package/presets/zcode/android-kotlin/skills/unit-testing/SKILL.md +1 -1
  742. package/presets/zcode/android-kotlin/team/README.md +1 -1
  743. package/presets/zcode/android-kotlin/team/fixtures/feature-parallel.json +84 -0
  744. package/presets/zcode/go/REPO_AGENTS.md +8 -0
  745. package/presets/zcode/go/adapter-map.json +17 -1
  746. package/presets/zcode/go/hooks/chain-team-phases.sh +4 -1
  747. package/presets/zcode/go/rules/README.md +3 -3
  748. package/presets/zcode/go/rules/agent-team-orchestrator.md +1 -1
  749. package/presets/zcode/go/rules/feature-delivery-workflow.md +50 -1
  750. package/presets/zcode/go/rules/preset-pr-checklist.md +2 -2
  751. package/presets/zcode/go/rules/reference-features.md +22 -0
  752. package/presets/zcode/go/skills/feature-delivery/SKILL.md +2 -2
  753. package/presets/zcode/go/skills/unit-testing/SKILL.md +1 -1
  754. package/presets/zcode/go/team/README.md +1 -1
  755. package/presets/zcode/go/team/fixtures/feature-parallel.json +84 -0
  756. package/presets/zcode/ios-swift/REPO_AGENTS.md +8 -0
  757. package/presets/zcode/ios-swift/adapter-map.json +17 -1
  758. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +4 -1
  759. package/presets/zcode/ios-swift/rules/README.md +3 -3
  760. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +1 -1
  761. package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +8 -8
  762. package/presets/zcode/ios-swift/rules/preset-pr-checklist.md +2 -2
  763. package/presets/zcode/ios-swift/rules/reference-features.md +2 -21
  764. package/presets/zcode/ios-swift/skills/unit-testing/SKILL.md +1 -1
  765. package/presets/zcode/ios-swift/team/README.md +1 -1
  766. package/presets/zcode/ios-swift/team/fixtures/feature-parallel.json +84 -0
  767. package/presets/zcode/java/REPO_AGENTS.md +8 -0
  768. package/presets/zcode/java/adapter-map.json +17 -1
  769. package/presets/zcode/java/hooks/chain-team-phases.sh +4 -1
  770. package/presets/zcode/java/rules/README.md +3 -3
  771. package/presets/zcode/java/rules/agent-team-orchestrator.md +1 -1
  772. package/presets/zcode/java/rules/feature-delivery-workflow.md +51 -1
  773. package/presets/zcode/java/rules/preset-pr-checklist.md +2 -2
  774. package/presets/zcode/java/rules/reference-features.md +22 -0
  775. package/presets/zcode/java/skills/feature-delivery/SKILL.md +2 -2
  776. package/presets/zcode/java/team/README.md +1 -1
  777. package/presets/zcode/java/team/fixtures/feature-parallel.json +84 -0
  778. package/presets/zcode/mcp-ts/REPO_AGENTS.md +8 -0
  779. package/presets/zcode/mcp-ts/adapter-map.json +17 -1
  780. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +4 -1
  781. package/presets/zcode/mcp-ts/rules/README.md +3 -3
  782. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +1 -1
  783. package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +47 -1
  784. package/presets/zcode/mcp-ts/rules/preset-pr-checklist.md +2 -2
  785. package/presets/zcode/mcp-ts/rules/reference-features.md +22 -0
  786. package/presets/zcode/mcp-ts/skills/code-review/SKILL.md +1 -1
  787. package/presets/zcode/mcp-ts/skills/feature-delivery/SKILL.md +2 -2
  788. package/presets/zcode/mcp-ts/skills/unit-testing/SKILL.md +1 -1
  789. package/presets/zcode/mcp-ts/team/README.md +1 -1
  790. package/presets/zcode/mcp-ts/team/fixtures/feature-parallel.json +84 -0
  791. package/presets/zcode/mol/REPO_AGENTS.md +8 -0
  792. package/presets/zcode/mol/adapter-map.json +9 -1
  793. package/presets/zcode/mol/hooks/chain-team-phases.sh +4 -1
  794. package/presets/zcode/mol/rules/README.md +3 -3
  795. package/presets/zcode/mol/rules/agent-team-orchestrator.md +1 -1
  796. package/presets/zcode/mol/rules/feature-delivery-workflow.md +10 -10
  797. package/presets/zcode/mol/rules/preset-pr-checklist.md +2 -2
  798. package/presets/zcode/mol/rules/reference-features.md +0 -19
  799. package/presets/zcode/mol/team/README.md +1 -1
  800. package/presets/zcode/next/REPO_AGENTS.md +8 -0
  801. package/presets/zcode/next/adapter-map.json +9 -1
  802. package/presets/zcode/next/agents/build-verifier.md +1 -1
  803. package/presets/zcode/next/agents/code-reviewer.md +2 -0
  804. package/presets/zcode/next/hooks/chain-team-phases.sh +4 -1
  805. package/presets/zcode/next/rules/README.md +3 -3
  806. package/presets/zcode/next/rules/agent-team-orchestrator.md +1 -1
  807. package/presets/zcode/next/rules/feature-delivery-workflow.md +13 -13
  808. package/presets/zcode/next/rules/next-app-core.md +1 -1
  809. package/presets/zcode/next/rules/preset-pr-checklist.md +2 -2
  810. package/presets/zcode/next/rules/reference-features.md +0 -19
  811. package/presets/zcode/next/team/README.md +1 -1
  812. package/presets/zcode/nuxt/REPO_AGENTS.md +8 -0
  813. package/presets/zcode/nuxt/adapter-map.json +17 -1
  814. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +4 -1
  815. package/presets/zcode/nuxt/rules/README.md +3 -3
  816. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +1 -1
  817. package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +9 -9
  818. package/presets/zcode/nuxt/rules/preset-pr-checklist.md +2 -2
  819. package/presets/zcode/nuxt/rules/reference-features.md +1 -20
  820. package/presets/zcode/nuxt/team/README.md +1 -1
  821. package/presets/zcode/nuxt/team/fixtures/feature-parallel.json +84 -0
  822. package/presets/zcode/php-hexagonal/REPO_AGENTS.md +8 -0
  823. package/presets/zcode/php-hexagonal/adapter-map.json +17 -1
  824. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +4 -1
  825. package/presets/zcode/php-hexagonal/rules/README.md +3 -3
  826. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +1 -1
  827. package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +51 -1
  828. package/presets/zcode/php-hexagonal/rules/preset-pr-checklist.md +2 -2
  829. package/presets/zcode/php-hexagonal/rules/reference-features.md +25 -0
  830. package/presets/zcode/php-hexagonal/skills/feature-delivery/SKILL.md +2 -2
  831. package/presets/zcode/php-hexagonal/team/README.md +1 -1
  832. package/presets/zcode/php-hexagonal/team/fixtures/feature-parallel.json +84 -0
  833. package/presets/zcode/php-laravel/REPO_AGENTS.md +8 -0
  834. package/presets/zcode/php-laravel/adapter-map.json +17 -1
  835. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +4 -1
  836. package/presets/zcode/php-laravel/rules/README.md +3 -3
  837. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +1 -1
  838. package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +54 -1
  839. package/presets/zcode/php-laravel/rules/preset-pr-checklist.md +2 -2
  840. package/presets/zcode/php-laravel/rules/reference-features.md +27 -0
  841. package/presets/zcode/php-laravel/skills/feature-delivery/SKILL.md +2 -2
  842. package/presets/zcode/php-laravel/team/README.md +1 -1
  843. package/presets/zcode/php-laravel/team/fixtures/feature-parallel.json +84 -0
  844. package/presets/zcode/svelte/REPO_AGENTS.md +8 -0
  845. package/presets/zcode/svelte/adapter-map.json +17 -1
  846. package/presets/zcode/svelte/hooks/chain-team-phases.sh +4 -1
  847. package/presets/zcode/svelte/rules/README.md +3 -3
  848. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +1 -1
  849. package/presets/zcode/svelte/rules/feature-delivery-workflow.md +7 -7
  850. package/presets/zcode/svelte/rules/preset-pr-checklist.md +2 -2
  851. package/presets/zcode/svelte/rules/reference-features.md +1 -20
  852. package/presets/zcode/svelte/team/README.md +1 -1
  853. package/presets/zcode/svelte/team/fixtures/feature-parallel.json +84 -0
  854. package/scripts/close-agent-task-human-gate.mjs +3 -3
  855. package/scripts/report-context-cost.mjs +10 -3
  856. package/scripts/aggregate-agent-task-metrics.mjs +0 -480
@@ -750,7 +750,12 @@ const normalizeEvent = (event, index, slug) => {
750
750
  attemptId: typeof event.attemptId === 'string' ? event.attemptId : null,
751
751
  stepIndex: integerOrNull(event.stepIndex),
752
752
  stepLabel: typeof event.stepLabel === 'string' ? event.stepLabel : null,
753
- agent: typeof event.agent === 'string' ? event.agent : null,
753
+ agent:
754
+ typeof event.agent === 'string' && event.agent !== ''
755
+ ? event.agent
756
+ : typeof event.nextAgent === 'string' && event.nextAgent !== ''
757
+ ? event.nextAgent
758
+ : null,
754
759
  role: typeof event.role === 'string' ? event.role : null,
755
760
  attemptNo: integerOrNull(event.attempt),
756
761
  outcome: typeof event.outcome === 'string' ? event.outcome : null,
@@ -2370,6 +2375,47 @@ const projectSessionLeases = (db, teamRoot) => {
2370
2375
  return projected;
2371
2376
  };
2372
2377
 
2378
+ const INSTANT_LEASE_MS = 1000;
2379
+ const LEASE_ATTEMPT_SPAN_MS = 7 * 24 * 60 * 60 * 1000;
2380
+
2381
+ /**
2382
+ * An instant lease (the file still has no grown `firstSeenAt`) covers the
2383
+ * attempt span of its slug, at most a week either side of that instant. A
2384
+ * lease that already has a window is left alone. The next-lease clip runs
2385
+ * after this, so a later slug of the same session still owns the overlap.
2386
+ */
2387
+ const expandInstantLeases = (db, bySession) => {
2388
+ let attempts;
2389
+ try {
2390
+ attempts = db
2391
+ .prepare('SELECT task_slug, started_at, finished_at FROM attempts WHERE started_at IS NOT NULL')
2392
+ .all();
2393
+ } catch {
2394
+ return;
2395
+ }
2396
+ const bySlug = new Map();
2397
+ for (const row of attempts) {
2398
+ const list = bySlug.get(row.task_slug) ?? [];
2399
+ list.push(row);
2400
+ bySlug.set(row.task_slug, list);
2401
+ }
2402
+ for (const sessions of bySession.values()) {
2403
+ for (const window of sessions) {
2404
+ if (window.last - window.first > INSTANT_LEASE_MS) continue;
2405
+ for (const row of bySlug.get(window.slug) ?? []) {
2406
+ const start = Date.parse(row.started_at);
2407
+ const end = row.finished_at ? Date.parse(row.finished_at) : start;
2408
+ if (!Number.isFinite(start) || !Number.isFinite(end)) continue;
2409
+ if (start > window.last + LEASE_ATTEMPT_SPAN_MS) continue;
2410
+ if (end < window.first - LEASE_ATTEMPT_SPAN_MS) continue;
2411
+ if (start < window.first) window.first = start;
2412
+ if (end > window.last) window.last = end;
2413
+ }
2414
+ window.end = window.last + LEASE_TTL_MS;
2415
+ }
2416
+ }
2417
+ };
2418
+
2373
2419
  /**
2374
2420
  * The attribution context: the lease windows of every session, the same
2375
2421
  * windows indexed by task, and the mtime of every task directory.
@@ -2393,6 +2439,7 @@ const leaseWindows = (db) => {
2393
2439
  tasks.push(window);
2394
2440
  byTask.set(row.task_slug, tasks);
2395
2441
  }
2442
+ expandInstantLeases(db, bySession);
2396
2443
  for (const sessions of bySession.values()) {
2397
2444
  sessions.sort((left, right) => left.first - right.first || (left.slug < right.slug ? -1 : left.slug > right.slug ? 1 : 0));
2398
2445
  for (let index = 0; index < sessions.length - 1; index += 1) {
@@ -2604,6 +2651,227 @@ const ingestLedgerFile = ({ db, file, kind, keyOf, ingestedAt, deadlineAt, conte
2604
2651
  return { rows, invalid, refused, ingested: true };
2605
2652
  };
2606
2653
 
2654
+ const RUNG_RANK = { unmapped: 0, 'dir-mtime': 1, window: 2, lease: 3 };
2655
+ const BOUND_RUNGS = new Set(['lease', 'window']);
2656
+ const EPISODE_CAP = 40;
2657
+
2658
+ /**
2659
+ * The attempt whose window contains the call. A matching agent outranks a
2660
+ * shorter window; otherwise the narrowest window wins, then the later start.
2661
+ * Returns null when the call has no task or no attempt covers it.
2662
+ */
2663
+ export function matchAttemptId(call, attempts) {
2664
+ const at = Date.parse(call.observedAt ?? '');
2665
+ if (!Number.isFinite(at) || !call.taskSlug) return null;
2666
+ let best = null;
2667
+ for (const attempt of attempts) {
2668
+ if (attempt.taskSlug !== call.taskSlug || !attempt.attemptId) continue;
2669
+ const start = Date.parse(attempt.startedAt ?? '');
2670
+ if (!Number.isFinite(start) || start > at) continue;
2671
+ const finished = attempt.finishedAt ? Date.parse(attempt.finishedAt) : Number.POSITIVE_INFINITY;
2672
+ if (!Number.isFinite(finished) || at > finished) continue;
2673
+ const agentMatch = Boolean(call.agent && attempt.agent && call.agent === attempt.agent);
2674
+ const span = finished === Number.POSITIVE_INFINITY ? Number.POSITIVE_INFINITY : finished - start;
2675
+ const rank = { agentMatch, span, start, attemptId: attempt.attemptId, agent: attempt.agent ?? null };
2676
+ if (
2677
+ best === null
2678
+ || rank.agentMatch > best.agentMatch
2679
+ || (rank.agentMatch === best.agentMatch && rank.span < best.span)
2680
+ || (rank.agentMatch === best.agentMatch && rank.span === best.span && rank.start > best.start)
2681
+ ) {
2682
+ best = rank;
2683
+ }
2684
+ }
2685
+ return best;
2686
+ }
2687
+
2688
+ const reattributeRows = (db, teamRoot) => {
2689
+ const context = { ...leaseWindows(db), dirs: taskDirectoryWindows(teamRoot) };
2690
+ const updateCall = db.prepare('UPDATE tool_calls SET task_slug = ?, attribution = ? WHERE call_key = ?');
2691
+ const updateTurn = db.prepare('UPDATE usage_turns SET task_slug = ?, attribution = ? WHERE turn_key = ?');
2692
+ let upgraded = 0;
2693
+ for (const row of db.prepare('SELECT call_key, session_id, observed_at, attribution FROM tool_calls').all()) {
2694
+ const next = resolveAttribution(context, row.session_id, row.observed_at);
2695
+ if ((RUNG_RANK[next.attribution] ?? 0) <= (RUNG_RANK[row.attribution] ?? 0)) continue;
2696
+ updateCall.run(next.taskSlug, next.attribution, row.call_key);
2697
+ upgraded += 1;
2698
+ }
2699
+ for (const row of db.prepare('SELECT turn_key, session_id, observed_at, attribution FROM usage_turns').all()) {
2700
+ const next = resolveAttribution(context, row.session_id, row.observed_at);
2701
+ if ((RUNG_RANK[next.attribution] ?? 0) <= (RUNG_RANK[row.attribution] ?? 0)) continue;
2702
+ updateTurn.run(next.taskSlug, next.attribution, row.turn_key);
2703
+ upgraded += 1;
2704
+ }
2705
+ return upgraded;
2706
+ };
2707
+
2708
+ const bindAttemptIds = (db) => {
2709
+ const attempts = db
2710
+ .prepare(
2711
+ `SELECT attempt_id AS attemptId, task_slug AS taskSlug, agent, started_at AS startedAt, finished_at AS finishedAt
2712
+ FROM attempts WHERE started_at IS NOT NULL`,
2713
+ )
2714
+ .all();
2715
+ const update = db.prepare('UPDATE tool_calls SET attempt_id = ?, agent = COALESCE(agent, ?) WHERE call_key = ?');
2716
+ const clear = db.prepare('UPDATE tool_calls SET attempt_id = NULL WHERE call_key = ?');
2717
+ let bound = 0;
2718
+ for (const call of db.prepare('SELECT call_key, task_slug, observed_at, agent, attribution FROM tool_calls').all()) {
2719
+ if (!BOUND_RUNGS.has(call.attribution)) {
2720
+ clear.run(call.call_key);
2721
+ continue;
2722
+ }
2723
+ const match = matchAttemptId(
2724
+ { taskSlug: call.task_slug, observedAt: call.observed_at, agent: call.agent },
2725
+ attempts,
2726
+ );
2727
+ if (!match) {
2728
+ clear.run(call.call_key);
2729
+ continue;
2730
+ }
2731
+ update.run(match.attemptId, match.agent, call.call_key);
2732
+ bound += 1;
2733
+ }
2734
+ return bound;
2735
+ };
2736
+
2737
+ const rebuildEpisodes = (db) => {
2738
+ db.exec('DELETE FROM attempt_episodes');
2739
+ const insert = db.prepare(
2740
+ `INSERT INTO attempt_episodes (attempt_id, ordinal, intent, target_key, error_class, observed_at)
2741
+ VALUES (?, ?, ?, ?, ?, ?)`,
2742
+ );
2743
+ const counts = new Map();
2744
+ let episodes = 0;
2745
+ for (const call of db
2746
+ .prepare(
2747
+ `SELECT attempt_id, intent, target_key, error_class, observed_at
2748
+ FROM tool_calls WHERE attempt_id IS NOT NULL
2749
+ ORDER BY attempt_id, observed_at, call_key`,
2750
+ )
2751
+ .all()) {
2752
+ const ordinal = counts.get(call.attempt_id) ?? 0;
2753
+ if (ordinal >= EPISODE_CAP) continue;
2754
+ counts.set(call.attempt_id, ordinal + 1);
2755
+ insert.run(call.attempt_id, ordinal, call.intent, call.target_key, call.error_class, call.observed_at);
2756
+ episodes += 1;
2757
+ }
2758
+ return episodes;
2759
+ };
2760
+
2761
+ const fillGaps = (db) => {
2762
+ const update = db.prepare('UPDATE tool_calls SET gap_ms = ? WHERE call_key = ? AND gap_ms IS NULL');
2763
+ let filled = 0;
2764
+ let previous = null;
2765
+ for (const row of db
2766
+ .prepare('SELECT call_key, session_id, observed_at, gap_ms FROM tool_calls ORDER BY session_id, observed_at, call_key')
2767
+ .all()) {
2768
+ if (previous && previous.session_id === row.session_id && row.gap_ms === null) {
2769
+ const gap = Date.parse(row.observed_at) - Date.parse(previous.observed_at);
2770
+ if (Number.isFinite(gap) && gap >= 0 && gap <= LEASE_TTL_MS) {
2771
+ update.run(gap, row.call_key);
2772
+ filled += 1;
2773
+ }
2774
+ }
2775
+ previous = row;
2776
+ }
2777
+ return filled;
2778
+ };
2779
+
2780
+ const foldSessionUsage = (db) => {
2781
+ const attempts = db
2782
+ .prepare(
2783
+ `SELECT attempt_id, task_slug, started_at, finished_at, usage_source FROM attempts
2784
+ WHERE (usage_source IS NULL OR usage_source = 'session') AND started_at IS NOT NULL`,
2785
+ )
2786
+ .all();
2787
+ const byTask = new Map();
2788
+ for (const turn of db
2789
+ .prepare(
2790
+ `SELECT task_slug, observed_at, input_tokens, output_tokens, reasoning_tokens,
2791
+ cache_read_tokens, cache_write_tokens, cost_usd, provider_id, model_id
2792
+ FROM usage_turns WHERE attribution IN ('lease', 'window') AND task_slug IS NOT NULL`,
2793
+ )
2794
+ .all()) {
2795
+ const list = byTask.get(turn.task_slug) ?? [];
2796
+ list.push(turn);
2797
+ byTask.set(turn.task_slug, list);
2798
+ }
2799
+ const update = db.prepare(
2800
+ `UPDATE attempts SET
2801
+ input_tokens = ?, output_tokens = ?, reasoning_tokens = ?,
2802
+ cache_read_tokens = ?, cache_write_tokens = ?, cost_usd = ?,
2803
+ usage_origin = 'measured', usage_source = 'session', usage_turn_count = ?,
2804
+ model_provider = ?, model_id = ?
2805
+ WHERE attempt_id = ? AND (usage_source IS NULL OR usage_source = 'session')`,
2806
+ );
2807
+ const clear = db.prepare(
2808
+ `UPDATE attempts SET
2809
+ input_tokens = NULL, output_tokens = NULL, reasoning_tokens = NULL,
2810
+ cache_read_tokens = NULL, cache_write_tokens = NULL, cost_usd = NULL,
2811
+ usage_origin = NULL, usage_source = NULL, usage_turn_count = NULL,
2812
+ model_provider = NULL, model_id = NULL
2813
+ WHERE attempt_id = ? AND usage_source = 'session'`,
2814
+ );
2815
+ let usage = 0;
2816
+ for (const attempt of attempts) {
2817
+ const start = Date.parse(attempt.started_at);
2818
+ const end = attempt.finished_at ? Date.parse(attempt.finished_at) : Number.POSITIVE_INFINITY;
2819
+ const matched = (byTask.get(attempt.task_slug) ?? []).filter((turn) => {
2820
+ const at = Date.parse(turn.observed_at);
2821
+ return Number.isFinite(at) && at >= start && at <= end;
2822
+ });
2823
+ if (matched.length === 0) {
2824
+ if (attempt.usage_source === 'session') clear.run(attempt.attempt_id);
2825
+ continue;
2826
+ }
2827
+ const sum = (key) => matched.reduce((total, turn) => total + Number(turn[key] ?? 0), 0);
2828
+ let model = matched[0];
2829
+ for (const turn of matched) {
2830
+ if (Number(turn.input_tokens) > Number(model.input_tokens)) model = turn;
2831
+ }
2832
+ update.run(
2833
+ sum('input_tokens'),
2834
+ sum('output_tokens'),
2835
+ sum('reasoning_tokens'),
2836
+ sum('cache_read_tokens'),
2837
+ sum('cache_write_tokens'),
2838
+ sum('cost_usd'),
2839
+ matched.length,
2840
+ model.provider_id,
2841
+ model.model_id,
2842
+ attempt.attempt_id,
2843
+ );
2844
+ usage += 1;
2845
+ }
2846
+ return usage;
2847
+ };
2848
+
2849
+ /**
2850
+ * Join already-projected calls to attempts. Stronger attribution replaces a
2851
+ * weaker one; host and CLI usage are never overwritten. Safe to re-run.
2852
+ */
2853
+ export function bindBehaviorResearch(db, teamRoot) {
2854
+ const columns = db.prepare('PRAGMA table_info(tool_calls)').all().map((row) => row.name);
2855
+ if (!columns.includes('attempt_id')) return { upgraded: 0, bound: 0, episodes: 0, gaps: 0, usage: 0 };
2856
+ db.exec('BEGIN IMMEDIATE');
2857
+ try {
2858
+ const upgraded = teamRoot ? reattributeRows(db, teamRoot) : 0;
2859
+ const bound = bindAttemptIds(db);
2860
+ const episodes = rebuildEpisodes(db);
2861
+ const gaps = fillGaps(db);
2862
+ const usage = foldSessionUsage(db);
2863
+ db.exec('COMMIT');
2864
+ return { upgraded, bound, episodes, gaps, usage };
2865
+ } catch (error) {
2866
+ try {
2867
+ db.exec('ROLLBACK');
2868
+ } catch {
2869
+ /* the original error is the finding */
2870
+ }
2871
+ throw error;
2872
+ }
2873
+ }
2874
+
2607
2875
  /**
2608
2876
  * Ingest the OpenCode ledgers into `tool_calls` / `usage_turns` and the
2609
2877
  * session leases into `session_tasks`. Full sync only; a per-file watermark
@@ -2884,6 +3152,13 @@ export function syncProjection(options = {}) {
2884
3152
  logProjectionFailure('E_TELEMETRY_FAILED', error.message, options.env);
2885
3153
  }
2886
3154
  }
3155
+ if (!slug) {
3156
+ try {
3157
+ bindBehaviorResearch(db, handle.teamRoot);
3158
+ } catch (error) {
3159
+ logProjectionFailure('E_TELEMETRY_FAILED', error.message, options.env);
3160
+ }
3161
+ }
2887
3162
  if (maintain) {
2888
3163
  result.retained += maintainDatabase(db, startedAt).retained;
2889
3164
  retainRuns(db);
@@ -32,6 +32,7 @@ import {
32
32
  isKillSwitchSet,
33
33
  isSqliteAvailable,
34
34
  openTeamDb,
35
+ readNewerSchemaModule,
35
36
  teamDbFail,
36
37
  } from './team-db-schema.mjs';
37
38
 
@@ -2223,8 +2224,9 @@ export async function runScheduler(options = {}) {
2223
2224
  }
2224
2225
  fs.mkdirSync(schedulerPaths(teamRoot).runs, { recursive: true, mode: 0o700 });
2225
2226
 
2226
- const handle = openTeamDb({ teamRoot });
2227
- const { db } = handle;
2227
+ let handle = openTeamDb({ teamRoot });
2228
+ let db = handle.db;
2229
+ let loadedSchemaMtime = 0;
2228
2230
  let draining = false;
2229
2231
  const inFlight = new Set();
2230
2232
 
@@ -2258,7 +2260,35 @@ export async function runScheduler(options = {}) {
2258
2260
  process.once('SIGINT', shutdown);
2259
2261
  process.once('SIGTERM', shutdown);
2260
2262
 
2263
+ const reloadSchema = async () => {
2264
+ if (inFlight.size > 0) return;
2265
+ let fresh = null;
2266
+ try {
2267
+ fresh = await readNewerSchemaModule();
2268
+ } catch (error) {
2269
+ err(`schedule: schema reload failed: ${error.message}\n`);
2270
+ return;
2271
+ }
2272
+ if (!fresh || fresh.mtimeMs === loadedSchemaMtime) return;
2273
+ try {
2274
+ const next = fresh.openTeamDb({ teamRoot });
2275
+ try {
2276
+ handle.db.close();
2277
+ } catch {
2278
+ /* the replacement connection is the one the next tick uses */
2279
+ }
2280
+ handle = next;
2281
+ db = next.db;
2282
+ loadedSchemaMtime = fresh.mtimeMs;
2283
+ if (!options.quiet) out(`schedule: reloaded schema v${fresh.SCHEMA_VERSION}\n`);
2284
+ } catch (error) {
2285
+ loadedSchemaMtime = fresh.mtimeMs;
2286
+ err(`schedule: schema reload failed: ${error.message}\n`);
2287
+ }
2288
+ };
2289
+
2261
2290
  const tick = async () => {
2291
+ await reloadSchema();
2262
2292
  const now = Date.now();
2263
2293
  const nowIso = new Date(now).toISOString();
2264
2294
  let file;
@@ -18,6 +18,7 @@ import crypto from 'node:crypto';
18
18
  import fs from 'node:fs';
19
19
  import { createRequire } from 'node:module';
20
20
  import path from 'node:path';
21
+ import { fileURLToPath, pathToFileURL } from 'node:url';
21
22
 
22
23
  /** Node floor for the unflagged `node:sqlite` module. */
23
24
  export const MIN_NODE = '22.13.0';
@@ -791,6 +792,59 @@ SELECT task_slug, signal, value FROM (
791
792
  ) WHERE value > 0;
792
793
  `;
793
794
 
795
+ /**
796
+ * Migration 7: the research join. `attempt_id` on a call, one capped episode
797
+ * per attempt, and a closed task-quality label. Every new column is nullable
798
+ * and the episode table starts empty, so a version-6 file migrates in place.
799
+ */
800
+ export const BEHAVIOR_RESEARCH_SQL = SQL`-- The call belongs to the attempt whose window contains it. Nullable:
801
+ -- a dir-mtime or unmapped row stays unbound.
802
+ ALTER TABLE tool_calls ADD COLUMN attempt_id TEXT;
803
+
804
+ CREATE INDEX idx_tool_calls_attempt ON tool_calls(attempt_id, observed_at);
805
+
806
+ -- Ordered (intent, target hash, error class) for one attempt. No command
807
+ -- text and no path. Rebuilt by the projector; ordinal is the only order.
808
+ CREATE TABLE attempt_episodes (
809
+ attempt_id TEXT NOT NULL,
810
+ ordinal INTEGER NOT NULL,
811
+ intent TEXT,
812
+ target_key TEXT,
813
+ error_class TEXT,
814
+ observed_at TEXT NOT NULL,
815
+ PRIMARY KEY (attempt_id, ordinal)
816
+ ) STRICT;
817
+
818
+ -- One closed label per task. Step outcome stays on attempts; this is the
819
+ -- research cohort key. A task still in progress stays NULL.
820
+ CREATE VIEW task_quality AS
821
+ SELECT
822
+ t.slug AS task_slug,
823
+ CASE
824
+ WHEN NOT EXISTS (
825
+ SELECT 1 FROM events e WHERE e.task_slug = t.slug AND e.type = 'task_completed'
826
+ ) AND EXISTS (
827
+ SELECT 1 FROM attempts a
828
+ WHERE a.task_slug = t.slug AND a.outcome IN ('blocked', 'validation_failed')
829
+ ) THEN 'failed'
830
+ WHEN EXISTS (
831
+ SELECT 1 FROM attempts a WHERE a.task_slug = t.slug AND a.outcome = 'changes_requested'
832
+ ) THEN 'rework'
833
+ WHEN EXISTS (
834
+ SELECT 1 FROM events e WHERE e.task_slug = t.slug AND e.type = 'task_completed'
835
+ ) AND EXISTS (
836
+ SELECT 1 FROM events e WHERE e.task_slug = t.slug AND e.type = 'verification_recorded'
837
+ ) AND NOT EXISTS (
838
+ SELECT 1 FROM events e WHERE e.task_slug = t.slug AND e.type = 'verification_stale'
839
+ ) THEN 'met'
840
+ WHEN EXISTS (
841
+ SELECT 1 FROM events e WHERE e.task_slug = t.slug AND e.type = 'task_completed'
842
+ ) THEN 'unverified'
843
+ ELSE NULL
844
+ END AS quality
845
+ FROM tasks t;
846
+ `;
847
+
794
848
  const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
795
849
  /**
796
850
  * Ordered, immutable migrations. The literal checksum is verified before any
@@ -833,6 +887,12 @@ export const MIGRATIONS = [
833
887
  sql: ACTION_TELEMETRY_SQL,
834
888
  checksum: 'f250814d462f1d6085ff56a1cc233179002dd5b5d97c200ed28104e4e42fbbfe',
835
889
  },
890
+ {
891
+ version: 7,
892
+ name: '0007-behavior-research',
893
+ sql: BEHAVIOR_RESEARCH_SQL,
894
+ checksum: '5a64fd028118ef7b3831006a13e5ca9ac6bd17ee5ce3dfa5441d7946cf4694e0',
895
+ },
836
896
  ];
837
897
 
838
898
  /** Highest migration version shipped by this module. */
@@ -1247,6 +1307,45 @@ export function moveDatabaseAside(dbPath, reason) {
1247
1307
  return suffix;
1248
1308
  }
1249
1309
 
1310
+ const schemaModuleUrl = new URL(import.meta.url);
1311
+ schemaModuleUrl.search = '';
1312
+ schemaModuleUrl.hash = '';
1313
+ const schemaModulePath = fileURLToPath(schemaModuleUrl);
1314
+ const schemaModuleMtimeMs = fs.statSync(schemaModulePath).mtimeMs;
1315
+ let newerSchemaLoad = null;
1316
+
1317
+ /**
1318
+ * The schema module a long-lived process loaded at startup.
1319
+ *
1320
+ * `serve` and `schedule` keep this module in memory. A later edit that raises
1321
+ * `SCHEMA_VERSION`, applied by another process, makes every cached open fail
1322
+ * with `E_SCHEMA_NEWER`. Re-importing the file picks up that version. A
1323
+ * database newer than the file on disk still fails closed: the result is
1324
+ * `null` when the file is unchanged or its version is not higher.
1325
+ *
1326
+ * @returns {Promise<{ mtimeMs: number, SCHEMA_VERSION: number, openTeamDb: typeof openTeamDb } | null>}
1327
+ */
1328
+ export async function readNewerSchemaModule() {
1329
+ let mtimeMs;
1330
+ try {
1331
+ mtimeMs = fs.statSync(schemaModulePath).mtimeMs;
1332
+ } catch {
1333
+ return null;
1334
+ }
1335
+ if (!(mtimeMs > schemaModuleMtimeMs)) return null;
1336
+ if (!newerSchemaLoad || newerSchemaLoad.mtimeMs !== mtimeMs) {
1337
+ const stamp = mtimeMs;
1338
+ newerSchemaLoad = {
1339
+ mtimeMs: stamp,
1340
+ promise: import(`${pathToFileURL(schemaModulePath).href}?mtime=${stamp}`).then((fresh) => {
1341
+ if (!(fresh.SCHEMA_VERSION > SCHEMA_VERSION)) return null;
1342
+ return { mtimeMs: stamp, SCHEMA_VERSION: fresh.SCHEMA_VERSION, openTeamDb: fresh.openTeamDb };
1343
+ }),
1344
+ };
1345
+ }
1346
+ return newerSchemaLoad.promise;
1347
+ }
1348
+
1250
1349
  /**
1251
1350
  * Open, migrate, verify and return a connection handle.
1252
1351
  *
@@ -158,7 +158,9 @@ const repoRootOf = (teamRoot) => path.resolve(teamRoot, '..', '..');
158
158
 
159
159
  const resolveConfigCwd = (teamRoot, config) => {
160
160
  const root = repoRootOf(teamRoot);
161
- const resolved = path.isAbsolute(config.cwd) ? config.cwd : path.resolve(root, config.cwd);
161
+ // A relative cwd belongs to the file that declares it, so it resolves
162
+ // against the team root and the seeded "../.." is the repository root.
163
+ const resolved = path.isAbsolute(config.cwd) ? config.cwd : path.resolve(teamRoot, config.cwd);
162
164
  const relative = path.relative(root, resolved);
163
165
  if (relative.startsWith('..') || path.isAbsolute(relative)) {
164
166
  reject('E_VALIDATION', 'runner.json: cwd must stay inside the repository root');
@@ -88,6 +88,35 @@ Two write paths exist, in precedence order:
88
88
  level with an explicit coverage ratio (`reportedAttempts / attempts`). Read a
89
89
  partial coverage as "some turns were observable", never as a cost baseline.
90
90
 
91
+ A third source, `usage_source: session`, is filled by the projector when neither
92
+ path above wrote a count: it sums `usage_turns` that the lease or window rung
93
+ already mapped onto that attempt. It never adds to a host or CLI rollup. A
94
+ missing session match stays `null`.
95
+
96
+ ## Research projection
97
+
98
+ The projector, not the agent, writes the research join. None of it goes into
99
+ `metrics.json`.
100
+
101
+ - `tool_calls.attempt_id` is set only for `lease` and `window` rows whose time
102
+ falls inside an attempt of that task. `dir-mtime` and `unmapped` stay unbound.
103
+ - `attempt_episodes` keeps at most 40 ordered `(intent, target_key, error_class)`
104
+ steps for that attempt. The target is the existing hash, never a path.
105
+ - `task_quality` is `failed`, `rework`, `met`, or `unverified`. `met` requires
106
+ `task_completed` plus `verification_recorded` and no `verification_stale`.
107
+ `rework` is any `changes_requested`. A task with no terminal event stays null.
108
+ - An instant session lease (no `firstSeenAt` yet) is stretched to the attempt
109
+ span of its slug, at most seven days either side, then clipped by the next
110
+ lease of that session. A stored row is re-attributed only when the new rung
111
+ is stronger.
112
+ - `gap_ms`, when the capture left it empty, is the gap to the previous call in
113
+ the same session, and only when that gap is under 30 minutes. `duration_ms`
114
+ stays null unless the host measured it.
115
+ - `retry_scheduled` with `nextAgent` and no `agent` projects `nextAgent` as the
116
+ agent. The hook does not grow a second id.
117
+ - A learning-ledger kind `exemplar` names a clean path. The rule improver does
118
+ not turn it into a rule.
119
+
91
120
  ## Verification evidence
92
121
 
93
122
  `validation-report.md` stays the human-readable narrative. The machine-checkable
@@ -227,7 +227,7 @@ On each `subagentStop`, the hook reconciles `status.state` from the completing p
227
227
  | `scope` | e.g. `unit-in-dev`, `e2e-only` — passed to developer/qa |
228
228
  | `model` | `cheap` \| `standard` \| `strong` — optional tier override |
229
229
 
230
- `writeScopes` are reconciled after the step, never in the hook: `node .ai.local/scripts/check-write-scope.mjs --slug <slug> --step <step-id> --json` labels every changed path `declared`, `derived`, or `out-of-scope`. The orchestrator writes the step baseline (`--step <step-id> --save-baseline`) before the step writes, so the audit sees this step's paths and not the earlier ones. Exit `3` is a skip, not a failure: a pipeline that predates step ids or `writeScopes` is not auditable, and the reason goes under `## Soft notes`. `build-verifier` hard-fails an out-of-scope implementation write; `code-reviewer` reports a reviewer-step path as advisory.
230
+ `writeScopes` are reconciled after the step, never in the hook: `node .ai.local/scripts/check-write-scope.mjs --slug <slug> --step <step-id> --json` labels every changed path `declared`, `derived`, or `out-of-scope`. The orchestrator writes the step baseline (`--step <step-id> --save-baseline`) before the step writes, so the audit sees this step's paths and not the earlier ones. Automatic selection only considers steps with an `id`, because the baseline file is keyed by it. Exit `3` is a skip, not a failure: a pipeline that predates step ids or `writeScopes` is not auditable, and the reason goes under `## Soft notes`. Exit `2` is a usage error (unknown `--step`, unreadable `pipeline.json`, failed git ref): the audit did not run and the result is neither a pass nor a finding — fix the invocation and re-run. A `no-baseline` skip is an orchestration defect: the step wrote without its baseline, so no path can be attributed to it — save the baseline and re-run the audit instead of reading the skip as a pass. `build-verifier` hard-fails an out-of-scope implementation write; `code-reviewer` reports a reviewer-step path as advisory.
231
231
 
232
232
  ## Rules (strict)
233
233
 
@@ -54,4 +54,4 @@ flowchart LR
54
54
 
55
55
  ## Zone → rules matrix
56
56
 
57
- Filled in the stack adapter: concrete globs/paths and `.mdc` / topic `.md` names.
57
+ Filled in the stack adapter: concrete globs/paths and each rule name in the format that platform ships.
@@ -21,7 +21,7 @@ Checklist for PRs that touch `packages/ai-rules/presets/**` (and dogfood `.curso
21
21
  - [ ] **README:** stack `rules/README.md` core→stack mapping / catalog updated if stems added
22
22
  - [ ] **CHANGELOG / package README:** note when public preset paths or install surface change
23
23
  - [ ] **i18n anchors:** kept-marked Cyrillic fragments in `tests-unit.md(c)` stay consistent with their English counterparts. Run `packages/ai-rules/scripts/check-preset-i18n.sh`.
24
- - [ ] **Dogfood:** run `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, and `sync-dogfood-opencode.sh` when those platforms changed, or document an intentional skip, when maintaining this monorepo
24
+ - [ ] **Dogfood:** run `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, `sync-dogfood-opencode.sh`, and `sync-dogfood-zcode.sh` when those platforms changed, or document an intentional skip, when maintaining this monorepo
25
25
  - [ ] **shared-core drift:** for embed-mode stems, run `packages/ai-rules/scripts/check-shared-core-drift.sh` (or document intentional fork)
26
26
  - [ ] **Packaging:** every installable preset ships `REPO_AGENTS.md`; default `hooks.json` does not reference `hooks/examples/`; `_shared/assets/docs-specs/` ships `INDEX.md` + `_templates/{page,feature}.md`; `product-specs` / `product-specs-authoring` stay requestable
27
27
  - [ ] **UI-only surfaces:** `mockup-reviewer`, `accessibility-reviewer`, `ux-design`, and the stack performance skill ship only on UI stacks (`check-preset-leakage.sh`)
@@ -38,6 +38,6 @@ Checklist for PRs that touch `packages/ai-rules/presets/**` (and dogfood `.curso
38
38
  - Budget: `preset-token-budget`
39
39
  - Leakage: `preset-no-cross-stack-leakage`
40
40
  - Validation: same `check:task` / `check:changed` loop; `yarn release:gate` before a release (`packages/ai-rules/scripts/release-gate.sh`)
41
- - Dogfood scripts: `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, `sync-dogfood-opencode.sh`
41
+ - Dogfood scripts: `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, `sync-dogfood-opencode.sh`, `sync-dogfood-zcode.sh`
42
42
  - Drift script: `packages/ai-rules/scripts/check-shared-core-drift.sh`
43
43
  - Orchestrator: when editing presets, load this checklist + twin-sync
@@ -6,7 +6,7 @@ Stack-agnostic. Keep each run inside a bounded context, checkpoint progress to d
6
6
 
7
7
  - Work in **bounded waves** (one artifact class across the target surface) rather than one target across all classes; a wave must fit comfortably in context.
8
8
  - **Mechanical waves** (generation, embed sync, drift re-checks) are delegated to **repo scripts** — spend tokens reading the gate output, not re-deriving the transformation.
9
- - 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>"`.
9
+ - 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>"`. On Cursor, an eligible simple `test`, `lint`, `git log`, or `git diff` is rewritten into `run-compact.mjs` when `TEAM_TASK_SLUG` is set: the full output is that `outputs/` file, and the model reads the printed failure lines.
10
10
  - Split work before the context overflows; do not carry state in the chat that belongs on disk.
11
11
 
12
12
  ## Checkpoint & resume
@@ -67,7 +67,10 @@ function firstSeenAtOf(file, value, now) {
67
67
  try {
68
68
  if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
69
69
  const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
70
- if (previous && previous.slug === value && typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
70
+ if (previous && previous.slug === value) {
71
+ if (typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
72
+ if (typeof previous.updatedAt === 'string') return previous.updatedAt;
73
+ }
71
74
  } catch {}
72
75
  return now;
73
76
  }
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ // Cursor preToolUse: rewrite an eligible simple command so its output is stored
3
+ // and only the short view reaches the model. Fail open. Edit this shared source;
4
+ // the generator copies it into each Cursor stack.
5
+
6
+ import fs from 'node:fs';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const SLUG_MAX = 48;
10
+ const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
11
+ const ELIGIBLE =
12
+ /^(?:(?:yarn|pnpm|npm|npx|bun)\s+(?:run\s+)?(?:test|lint)(?::\S+)?|git\s+(?:log|diff)|go\s+test|cargo\s+test|pytest|phpunit)\b/;
13
+ const META = /[|&;<>()\n`]|\$\(/;
14
+
15
+ const slugOf = (env) => {
16
+ const value = typeof env?.TEAM_TASK_SLUG === 'string' ? env.TEAM_TASK_SLUG : '';
17
+ if (value.length === 0 || value.length > SLUG_MAX || !SLUG_RE.test(value)) return '';
18
+ return value;
19
+ };
20
+
21
+ /** Return the rewritten shell string, or null to leave the command unchanged. */
22
+ export const rewriteCommand = (command, env) => {
23
+ const slug = slugOf(env);
24
+ if (slug === '') return null;
25
+ const text = typeof command === 'string' ? command.trim() : '';
26
+ if (text === '' || META.test(text)) return null;
27
+ if (text.split(/\s+/).some((token) => token.includes("'") || token.includes('"'))) return null;
28
+ if (text.includes('dump-output.mjs') || text.includes('run-compact.mjs')) return null;
29
+ if (!ELIGIBLE.test(text)) return null;
30
+ return `node .ai.local/scripts/run-compact.mjs --task ${slug} -- ${text}`;
31
+ };
32
+
33
+ const allow = () => {
34
+ process.stdout.write('{"permission":"allow"}');
35
+ };
36
+
37
+ const commandOf = (event) => {
38
+ if (typeof event.command === 'string') return event.command;
39
+ if (typeof event.input?.command === 'string') return event.input.command;
40
+ if (typeof event.tool_input?.command === 'string') return event.tool_input.command;
41
+ return '';
42
+ };
43
+
44
+ const invokedDirectly = (() => {
45
+ if (!process.argv[1]) return false;
46
+ try {
47
+ return fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
48
+ } catch {
49
+ return false;
50
+ }
51
+ })();
52
+
53
+ if (invokedDirectly) {
54
+ try {
55
+ const parsed = JSON.parse(fs.readFileSync(0, 'utf8'));
56
+ const event = parsed && typeof parsed === 'object' ? parsed : null;
57
+ const rewritten = event ? rewriteCommand(commandOf(event), process.env) : null;
58
+ if (rewritten === null) {
59
+ allow();
60
+ } else {
61
+ process.stdout.write(
62
+ JSON.stringify({ permission: 'allow', updated_input: { command: rewritten } }),
63
+ );
64
+ }
65
+ } catch {
66
+ allow();
67
+ }
68
+ }