@bonesofspring/ai-rules 0.2.63 → 0.2.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/CHANGELOG.md +96 -1
  2. package/README.md +11 -4
  3. package/bin/cli.js +7 -5
  4. package/bin/lib/ai-local-drift.js +7 -6
  5. package/bin/lib/engine-scripts.js +17 -4
  6. package/bin/lib/engine-upgrade.js +10 -2
  7. package/bin/lib/manifest-schema.js +12 -0
  8. package/bin/lib/seed-ai-local-team.js +20 -0
  9. package/bin/mavis-install.js +4 -3
  10. package/bin/opencode-install.js +22 -6
  11. package/bin/zcode-install.js +4 -3
  12. package/docs/MCP-CATALOG.md +1 -1
  13. package/docs/OPENCODE-COMPATIBILITY.md +3 -2
  14. package/docs/OPENCODE.md +22 -2
  15. package/docs/PRESET-CONTRIBUTION.md +43 -2
  16. package/docs/TEAM-DB.md +213 -5
  17. package/docs/openapi/team-db.v1.json +5928 -3045
  18. package/mcp/defectdojo-mcp.mjs +44 -12
  19. package/mcp/lib/defectdojo.mjs +57 -2
  20. package/package.json +27 -15
  21. package/presets/_shared/ai-local/scripts/aggregate-agent-task-metrics.mjs +279 -0
  22. package/presets/_shared/ai-local/scripts/process-lease.mjs +576 -0
  23. package/presets/_shared/ai-local/scripts/processes.mjs +1618 -0
  24. package/presets/_shared/ai-local/scripts/run.mjs +5 -5
  25. package/presets/_shared/ai-local/scripts/team-db-api.mjs +784 -7
  26. package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +235 -10
  27. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +813 -7
  28. package/presets/_shared/ai-local/scripts/team-db-project.mjs +397 -4
  29. package/presets/_shared/ai-local/scripts/team-db-scheduler.mjs +86 -10
  30. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +221 -0
  31. package/presets/_shared/ai-local/scripts/team-db-task-runner.mjs +567 -0
  32. package/presets/_shared/ai-local/scripts/team-db-tracker.mjs +2069 -0
  33. package/presets/_shared/ai-local/scripts/team-db-ui.mjs +750 -0
  34. package/presets/_shared/ai-local/scripts/team-db.mjs +151 -7
  35. package/presets/_shared/ai-local/scripts/upstream-research.mjs +3 -0
  36. package/presets/_shared/core/agent-team/agent-task-metrics.md +7 -2
  37. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +2 -1
  38. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +314 -1
  39. package/presets/_shared/hooks/guard-shell-command.mjs.tmpl +40 -2
  40. package/presets/_shared/hooks/run-hook.mjs +2 -1
  41. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +314 -1
  42. package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +41 -2
  43. package/presets/claude/android-kotlin/hooks/run-hook.mjs +2 -1
  44. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  45. package/presets/claude/android-kotlin/settings.json +6 -1
  46. package/presets/claude/go/hooks/chain-team-phases.sh +314 -1
  47. package/presets/claude/go/hooks/guard-shell-command.mjs +41 -2
  48. package/presets/claude/go/hooks/run-hook.mjs +2 -1
  49. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  50. package/presets/claude/go/settings.json +6 -1
  51. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +314 -1
  52. package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +41 -2
  53. package/presets/claude/ios-swift/hooks/run-hook.mjs +2 -1
  54. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  55. package/presets/claude/ios-swift/settings.json +6 -1
  56. package/presets/claude/java/hooks/chain-team-phases.sh +314 -1
  57. package/presets/claude/java/hooks/guard-shell-command.mjs +41 -2
  58. package/presets/claude/java/hooks/run-hook.mjs +2 -1
  59. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  60. package/presets/claude/java/settings.json +6 -1
  61. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +314 -1
  62. package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +41 -2
  63. package/presets/claude/mcp-ts/hooks/run-hook.mjs +2 -1
  64. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  65. package/presets/claude/mcp-ts/settings.json +6 -1
  66. package/presets/claude/mol/hooks/chain-team-phases.sh +314 -1
  67. package/presets/claude/mol/hooks/guard-shell-command.mjs +41 -2
  68. package/presets/claude/mol/hooks/run-hook.mjs +2 -1
  69. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  70. package/presets/claude/mol/settings.json +6 -1
  71. package/presets/claude/next/MCP.md +2 -0
  72. package/presets/claude/next/REPO_AGENTS.md +2 -0
  73. package/presets/claude/next/agents/build-verifier.md +1 -1
  74. package/presets/claude/next/agents/ci-investigator.md +3 -0
  75. package/presets/claude/next/agents/code-reviewer.md +1 -0
  76. package/presets/claude/next/agents/debugger.md +3 -0
  77. package/presets/claude/next/agents/feature-developer.md +3 -0
  78. package/presets/claude/next/agents/mockup-reviewer.md +4 -1
  79. package/presets/claude/next/agents/performance-auditor.md +2 -0
  80. package/presets/claude/next/agents/playwright-test-generator.md +3 -0
  81. package/presets/claude/next/agents/playwright-test-healer.md +3 -0
  82. package/presets/claude/next/agents/playwright-test-planner.md +3 -0
  83. package/presets/claude/next/agents/qa-tester.md +3 -0
  84. package/presets/claude/next/agents/task-analyst.md +2 -0
  85. package/presets/claude/next/commands/README.md +6 -0
  86. package/presets/claude/next/commands/task.md +7 -1
  87. package/presets/claude/next/commands/technical-retro.md +7 -1
  88. package/presets/claude/next/commands/ui-start.md +78 -0
  89. package/presets/claude/next/commands/ui-stop.md +71 -0
  90. package/presets/claude/next/commands/upstream-research.md +1 -1
  91. package/presets/claude/next/hooks/chain-team-phases.sh +314 -1
  92. package/presets/claude/next/hooks/guard-shell-command.mjs +41 -2
  93. package/presets/claude/next/hooks/run-hook.mjs +2 -1
  94. package/presets/claude/next/rules/README.md +2 -1
  95. package/presets/claude/next/rules/stack/next-app-core.md +1 -0
  96. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  97. package/presets/claude/next/rules/tooling-and-review/dev-process-lifecycle.md +43 -0
  98. package/presets/claude/next/settings.json +6 -1
  99. package/presets/claude/next/skills/figma-fidelity/SKILL.md +4 -1
  100. package/presets/claude/next/skills/mockup-review/SKILL.md +4 -0
  101. package/presets/claude/next/team/README.md +5 -1
  102. package/presets/claude/next/team/upstream/jobs.json +34 -0
  103. package/presets/claude/nuxt/hooks/chain-team-phases.sh +314 -1
  104. package/presets/claude/nuxt/hooks/guard-shell-command.mjs +41 -2
  105. package/presets/claude/nuxt/hooks/run-hook.mjs +2 -1
  106. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  107. package/presets/claude/nuxt/settings.json +6 -1
  108. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +314 -1
  109. package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +41 -2
  110. package/presets/claude/php-hexagonal/hooks/run-hook.mjs +2 -1
  111. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  112. package/presets/claude/php-hexagonal/settings.json +6 -1
  113. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +315 -2
  114. package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +41 -2
  115. package/presets/claude/php-laravel/hooks/run-hook.mjs +2 -1
  116. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  117. package/presets/claude/php-laravel/settings.json +6 -1
  118. package/presets/claude/svelte/hooks/chain-team-phases.sh +314 -1
  119. package/presets/claude/svelte/hooks/guard-shell-command.mjs +41 -2
  120. package/presets/claude/svelte/hooks/run-hook.mjs +2 -1
  121. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +2 -1
  122. package/presets/claude/svelte/settings.json +6 -1
  123. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +314 -1
  124. package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +41 -2
  125. package/presets/cursor/android-kotlin/hooks/run-hook.mjs +2 -1
  126. package/presets/cursor/go/hooks/chain-team-phases.sh +314 -1
  127. package/presets/cursor/go/hooks/guard-shell-command.mjs +41 -2
  128. package/presets/cursor/go/hooks/run-hook.mjs +2 -1
  129. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +314 -1
  130. package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +41 -2
  131. package/presets/cursor/ios-swift/hooks/run-hook.mjs +2 -1
  132. package/presets/cursor/java/hooks/chain-team-phases.sh +314 -1
  133. package/presets/cursor/java/hooks/guard-shell-command.mjs +41 -2
  134. package/presets/cursor/java/hooks/run-hook.mjs +2 -1
  135. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +314 -1
  136. package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +41 -2
  137. package/presets/cursor/mcp-ts/hooks/run-hook.mjs +2 -1
  138. package/presets/cursor/mol/hooks/chain-team-phases.sh +314 -1
  139. package/presets/cursor/mol/hooks/guard-shell-command.mjs +41 -2
  140. package/presets/cursor/mol/hooks/run-hook.mjs +2 -1
  141. package/presets/cursor/next/MCP.md +2 -0
  142. package/presets/cursor/next/REPO_AGENTS.md +2 -0
  143. package/presets/cursor/next/agents/build-verifier.md +1 -1
  144. package/presets/cursor/next/agents/ci-investigator.md +2 -0
  145. package/presets/cursor/next/agents/code-reviewer.md +1 -0
  146. package/presets/cursor/next/agents/debugger.md +2 -0
  147. package/presets/cursor/next/agents/feature-developer.md +2 -0
  148. package/presets/cursor/next/agents/mockup-reviewer.md +4 -1
  149. package/presets/cursor/next/agents/performance-auditor.md +2 -0
  150. package/presets/cursor/next/agents/playwright-test-generator.md +2 -0
  151. package/presets/cursor/next/agents/playwright-test-healer.md +2 -0
  152. package/presets/cursor/next/agents/playwright-test-planner.md +2 -0
  153. package/presets/cursor/next/agents/qa-tester.md +2 -0
  154. package/presets/cursor/next/agents/task-analyst.md +2 -0
  155. package/presets/cursor/next/ai-local/rules-library/storybook-dev-compare-figma.md +2 -1
  156. package/presets/cursor/next/ai-local/rules-library/ui-change-review-gate.md +1 -0
  157. package/presets/cursor/next/commands/README.md +6 -0
  158. package/presets/cursor/next/commands/task.md +7 -1
  159. package/presets/cursor/next/commands/technical-retro.md +7 -1
  160. package/presets/cursor/next/commands/ui-start.md +78 -0
  161. package/presets/cursor/next/commands/ui-stop.md +71 -0
  162. package/presets/cursor/next/commands/upstream-research.md +1 -1
  163. package/presets/cursor/next/hooks/chain-team-phases.sh +314 -1
  164. package/presets/cursor/next/hooks/guard-shell-command.mjs +41 -2
  165. package/presets/cursor/next/hooks/run-hook.mjs +2 -1
  166. package/presets/cursor/next/rules/README.md +2 -1
  167. package/presets/cursor/next/rules/dev-process-lifecycle.mdc +43 -0
  168. package/presets/cursor/next/rules/next-app-core.mdc +1 -0
  169. package/presets/cursor/next/skills/figma-fidelity/SKILL.md +4 -1
  170. package/presets/cursor/next/skills/mockup-review/SKILL.md +4 -0
  171. package/presets/cursor/next/team/README.md +5 -1
  172. package/presets/cursor/next/team/upstream/jobs.json +34 -0
  173. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +314 -1
  174. package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +41 -2
  175. package/presets/cursor/nuxt/hooks/run-hook.mjs +2 -1
  176. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +314 -1
  177. package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +41 -2
  178. package/presets/cursor/php-hexagonal/hooks/run-hook.mjs +2 -1
  179. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +315 -2
  180. package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +41 -2
  181. package/presets/cursor/php-laravel/hooks/run-hook.mjs +2 -1
  182. package/presets/cursor/svelte/hooks/chain-team-phases.sh +314 -1
  183. package/presets/cursor/svelte/hooks/guard-shell-command.mjs +41 -2
  184. package/presets/cursor/svelte/hooks/run-hook.mjs +2 -1
  185. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  186. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +314 -1
  187. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +2 -1
  188. package/presets/mavis/go/adapter-map.json +1 -1
  189. package/presets/mavis/go/hooks/chain-team-phases.sh +314 -1
  190. package/presets/mavis/go/rules/agent-team-orchestrator.md +2 -1
  191. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  192. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +314 -1
  193. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +2 -1
  194. package/presets/mavis/java/adapter-map.json +1 -1
  195. package/presets/mavis/java/hooks/chain-team-phases.sh +314 -1
  196. package/presets/mavis/java/rules/agent-team-orchestrator.md +2 -1
  197. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  198. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +314 -1
  199. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +2 -1
  200. package/presets/mavis/mol/adapter-map.json +1 -1
  201. package/presets/mavis/mol/hooks/chain-team-phases.sh +314 -1
  202. package/presets/mavis/mol/rules/agent-team-orchestrator.md +2 -1
  203. package/presets/mavis/next/MCP.md +2 -0
  204. package/presets/mavis/next/REPO_AGENTS.md +2 -0
  205. package/presets/mavis/next/adapter-map.json +33 -1
  206. package/presets/mavis/next/agents/build-verifier.md +1 -1
  207. package/presets/mavis/next/agents/ci-investigator.md +3 -0
  208. package/presets/mavis/next/agents/code-reviewer.md +1 -0
  209. package/presets/mavis/next/agents/debugger.md +3 -0
  210. package/presets/mavis/next/agents/feature-developer.md +3 -0
  211. package/presets/mavis/next/agents/mockup-reviewer.md +4 -1
  212. package/presets/mavis/next/agents/performance-auditor.md +2 -0
  213. package/presets/mavis/next/agents/playwright-test-generator.md +3 -0
  214. package/presets/mavis/next/agents/playwright-test-healer.md +3 -0
  215. package/presets/mavis/next/agents/playwright-test-planner.md +3 -0
  216. package/presets/mavis/next/agents/qa-tester.md +3 -0
  217. package/presets/mavis/next/agents/task-analyst.md +2 -0
  218. package/presets/mavis/next/ai-local/rules-library/storybook-dev-compare-figma.md +2 -1
  219. package/presets/mavis/next/ai-local/rules-library/ui-change-review-gate.md +1 -0
  220. package/presets/mavis/next/commands/README.md +6 -0
  221. package/presets/mavis/next/commands/task.md +7 -1
  222. package/presets/mavis/next/commands/technical-retro.md +7 -1
  223. package/presets/mavis/next/commands/ui-start.md +73 -0
  224. package/presets/mavis/next/commands/ui-stop.md +66 -0
  225. package/presets/mavis/next/commands/upstream-research.md +1 -1
  226. package/presets/mavis/next/hooks/chain-team-phases.sh +314 -1
  227. package/presets/mavis/next/rules/agent-team-orchestrator.md +2 -1
  228. package/presets/mavis/next/rules/dev-process-lifecycle.md +38 -0
  229. package/presets/mavis/next/rules/next-app-core.md +1 -0
  230. package/presets/mavis/next/skills/figma-fidelity/SKILL.md +4 -1
  231. package/presets/mavis/next/skills/mockup-review/SKILL.md +4 -0
  232. package/presets/mavis/next/team/README.md +5 -1
  233. package/presets/mavis/next/team/upstream/jobs.json +34 -0
  234. package/presets/mavis/nuxt/adapter-map.json +1 -1
  235. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +314 -1
  236. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +2 -1
  237. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  238. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +314 -1
  239. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +2 -1
  240. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  241. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +315 -2
  242. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +2 -1
  243. package/presets/mavis/svelte/adapter-map.json +1 -1
  244. package/presets/mavis/svelte/hooks/chain-team-phases.sh +314 -1
  245. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +2 -1
  246. package/presets/opencode/android-kotlin/OPENCODE.md +4 -1
  247. package/presets/opencode/android-kotlin/README.md +1 -0
  248. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  249. package/presets/opencode/android-kotlin/hooks/README.md +4 -2
  250. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +314 -1
  251. package/presets/opencode/android-kotlin/opencode.json +5 -1
  252. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +2 -1
  253. package/presets/opencode/go/OPENCODE.md +4 -1
  254. package/presets/opencode/go/README.md +1 -0
  255. package/presets/opencode/go/adapter-map.json +1 -1
  256. package/presets/opencode/go/hooks/README.md +4 -2
  257. package/presets/opencode/go/hooks/chain-team-phases.sh +314 -1
  258. package/presets/opencode/go/opencode.json +5 -1
  259. package/presets/opencode/go/rules/agent-team-orchestrator.md +2 -1
  260. package/presets/opencode/ios-swift/OPENCODE.md +4 -1
  261. package/presets/opencode/ios-swift/README.md +1 -0
  262. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  263. package/presets/opencode/ios-swift/hooks/README.md +4 -2
  264. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +314 -1
  265. package/presets/opencode/ios-swift/opencode.json +5 -1
  266. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +2 -1
  267. package/presets/opencode/java/OPENCODE.md +4 -1
  268. package/presets/opencode/java/README.md +1 -0
  269. package/presets/opencode/java/adapter-map.json +1 -1
  270. package/presets/opencode/java/hooks/README.md +4 -2
  271. package/presets/opencode/java/hooks/chain-team-phases.sh +314 -1
  272. package/presets/opencode/java/opencode.json +5 -1
  273. package/presets/opencode/java/rules/agent-team-orchestrator.md +2 -1
  274. package/presets/opencode/mcp-ts/OPENCODE.md +4 -1
  275. package/presets/opencode/mcp-ts/README.md +1 -0
  276. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  277. package/presets/opencode/mcp-ts/hooks/README.md +4 -2
  278. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +314 -1
  279. package/presets/opencode/mcp-ts/opencode.json +5 -1
  280. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +2 -1
  281. package/presets/opencode/mol/OPENCODE.md +4 -1
  282. package/presets/opencode/mol/README.md +1 -0
  283. package/presets/opencode/mol/adapter-map.json +1 -1
  284. package/presets/opencode/mol/hooks/README.md +4 -2
  285. package/presets/opencode/mol/hooks/chain-team-phases.sh +314 -1
  286. package/presets/opencode/mol/opencode.json +4 -0
  287. package/presets/opencode/mol/rules/agent-team-orchestrator.md +2 -1
  288. package/presets/opencode/next/MCP.md +2 -0
  289. package/presets/opencode/next/OPENCODE.md +4 -1
  290. package/presets/opencode/next/README.md +1 -0
  291. package/presets/opencode/next/REPO_AGENTS.md +2 -0
  292. package/presets/opencode/next/adapter-map.json +33 -1
  293. package/presets/opencode/next/agents/build-verifier.md +1 -1
  294. package/presets/opencode/next/agents/ci-investigator.md +3 -0
  295. package/presets/opencode/next/agents/code-reviewer.md +1 -0
  296. package/presets/opencode/next/agents/debugger.md +3 -0
  297. package/presets/opencode/next/agents/feature-developer.md +3 -0
  298. package/presets/opencode/next/agents/mockup-reviewer.md +4 -1
  299. package/presets/opencode/next/agents/performance-auditor.md +2 -0
  300. package/presets/opencode/next/agents/playwright-test-generator.md +3 -0
  301. package/presets/opencode/next/agents/playwright-test-healer.md +3 -0
  302. package/presets/opencode/next/agents/playwright-test-planner.md +3 -0
  303. package/presets/opencode/next/agents/qa-tester.md +3 -0
  304. package/presets/opencode/next/agents/task-analyst.md +2 -0
  305. package/presets/opencode/next/ai-local/rules-library/storybook-dev-compare-figma.md +2 -1
  306. package/presets/opencode/next/ai-local/rules-library/ui-change-review-gate.md +1 -0
  307. package/presets/opencode/next/commands/README.md +6 -0
  308. package/presets/opencode/next/commands/task.md +7 -1
  309. package/presets/opencode/next/commands/technical-retro.md +7 -1
  310. package/presets/opencode/next/commands/ui-start.md +81 -0
  311. package/presets/opencode/next/commands/ui-stop.md +74 -0
  312. package/presets/opencode/next/commands/upstream-research.md +1 -1
  313. package/presets/opencode/next/hooks/README.md +4 -2
  314. package/presets/opencode/next/hooks/chain-team-phases.sh +314 -1
  315. package/presets/opencode/next/opencode.json +4 -0
  316. package/presets/opencode/next/rules/agent-team-orchestrator.md +2 -1
  317. package/presets/opencode/next/rules/dev-process-lifecycle.md +38 -0
  318. package/presets/opencode/next/rules/next-app-core.md +1 -0
  319. package/presets/opencode/next/skills/figma-fidelity/SKILL.md +4 -1
  320. package/presets/opencode/next/skills/mockup-review/SKILL.md +4 -0
  321. package/presets/opencode/next/team/README.md +5 -1
  322. package/presets/opencode/next/team/upstream/jobs.json +34 -0
  323. package/presets/opencode/nuxt/OPENCODE.md +4 -1
  324. package/presets/opencode/nuxt/README.md +1 -0
  325. package/presets/opencode/nuxt/adapter-map.json +1 -1
  326. package/presets/opencode/nuxt/hooks/README.md +4 -2
  327. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +314 -1
  328. package/presets/opencode/nuxt/opencode.json +4 -0
  329. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +2 -1
  330. package/presets/opencode/php-hexagonal/OPENCODE.md +4 -1
  331. package/presets/opencode/php-hexagonal/README.md +1 -0
  332. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  333. package/presets/opencode/php-hexagonal/hooks/README.md +4 -2
  334. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +314 -1
  335. package/presets/opencode/php-hexagonal/opencode.json +5 -1
  336. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +2 -1
  337. package/presets/opencode/php-laravel/OPENCODE.md +4 -1
  338. package/presets/opencode/php-laravel/README.md +1 -0
  339. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  340. package/presets/opencode/php-laravel/hooks/README.md +4 -2
  341. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +315 -2
  342. package/presets/opencode/php-laravel/opencode.json +5 -1
  343. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +2 -1
  344. package/presets/opencode/platform-contract.json +6 -0
  345. package/presets/opencode/plugins/task-status/README.md +92 -0
  346. package/presets/opencode/plugins/task-status/details-data.ts +130 -0
  347. package/presets/opencode/plugins/task-status/details.tsx +84 -0
  348. package/presets/opencode/plugins/task-status/eta.ts +230 -0
  349. package/presets/opencode/plugins/task-status/index.ts +6 -0
  350. package/presets/opencode/plugins/task-status/package.json +10 -0
  351. package/presets/opencode/plugins/task-status/task-view.ts +606 -0
  352. package/presets/opencode/plugins/task-status/tui.tsx +139 -0
  353. package/presets/opencode/svelte/OPENCODE.md +4 -1
  354. package/presets/opencode/svelte/README.md +1 -0
  355. package/presets/opencode/svelte/adapter-map.json +1 -1
  356. package/presets/opencode/svelte/hooks/README.md +4 -2
  357. package/presets/opencode/svelte/hooks/chain-team-phases.sh +314 -1
  358. package/presets/opencode/svelte/opencode.json +4 -0
  359. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +2 -1
  360. package/presets/zcode/android-kotlin/adapter-map.json +1 -1
  361. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +314 -1
  362. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +2 -1
  363. package/presets/zcode/go/adapter-map.json +1 -1
  364. package/presets/zcode/go/hooks/chain-team-phases.sh +314 -1
  365. package/presets/zcode/go/rules/agent-team-orchestrator.md +2 -1
  366. package/presets/zcode/ios-swift/adapter-map.json +1 -1
  367. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +314 -1
  368. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +2 -1
  369. package/presets/zcode/java/adapter-map.json +1 -1
  370. package/presets/zcode/java/hooks/chain-team-phases.sh +314 -1
  371. package/presets/zcode/java/rules/agent-team-orchestrator.md +2 -1
  372. package/presets/zcode/mcp-ts/adapter-map.json +1 -1
  373. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +314 -1
  374. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +2 -1
  375. package/presets/zcode/mol/adapter-map.json +1 -1
  376. package/presets/zcode/mol/hooks/chain-team-phases.sh +314 -1
  377. package/presets/zcode/mol/rules/agent-team-orchestrator.md +2 -1
  378. package/presets/zcode/next/MCP.md +2 -0
  379. package/presets/zcode/next/REPO_AGENTS.md +2 -0
  380. package/presets/zcode/next/adapter-map.json +33 -1
  381. package/presets/zcode/next/agents/build-verifier.md +1 -1
  382. package/presets/zcode/next/agents/ci-investigator.md +3 -0
  383. package/presets/zcode/next/agents/code-reviewer.md +1 -0
  384. package/presets/zcode/next/agents/debugger.md +3 -0
  385. package/presets/zcode/next/agents/feature-developer.md +3 -0
  386. package/presets/zcode/next/agents/mockup-reviewer.md +4 -1
  387. package/presets/zcode/next/agents/performance-auditor.md +2 -0
  388. package/presets/zcode/next/agents/playwright-test-generator.md +3 -0
  389. package/presets/zcode/next/agents/playwright-test-healer.md +3 -0
  390. package/presets/zcode/next/agents/playwright-test-planner.md +3 -0
  391. package/presets/zcode/next/agents/qa-tester.md +3 -0
  392. package/presets/zcode/next/agents/task-analyst.md +2 -0
  393. package/presets/zcode/next/ai-local/rules-library/storybook-dev-compare-figma.md +2 -1
  394. package/presets/zcode/next/ai-local/rules-library/ui-change-review-gate.md +1 -0
  395. package/presets/zcode/next/commands/README.md +6 -0
  396. package/presets/zcode/next/commands/task.md +7 -1
  397. package/presets/zcode/next/commands/technical-retro.md +7 -1
  398. package/presets/zcode/next/commands/ui-start.md +81 -0
  399. package/presets/zcode/next/commands/ui-stop.md +74 -0
  400. package/presets/zcode/next/commands/upstream-research.md +1 -1
  401. package/presets/zcode/next/hooks/chain-team-phases.sh +314 -1
  402. package/presets/zcode/next/rules/agent-team-orchestrator.md +2 -1
  403. package/presets/zcode/next/rules/dev-process-lifecycle.md +38 -0
  404. package/presets/zcode/next/rules/next-app-core.md +1 -0
  405. package/presets/zcode/next/skills/figma-fidelity/SKILL.md +4 -1
  406. package/presets/zcode/next/skills/mockup-review/SKILL.md +4 -0
  407. package/presets/zcode/next/team/README.md +5 -1
  408. package/presets/zcode/next/team/upstream/jobs.json +34 -0
  409. package/presets/zcode/nuxt/adapter-map.json +1 -1
  410. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +314 -1
  411. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +2 -1
  412. package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
  413. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +314 -1
  414. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +2 -1
  415. package/presets/zcode/php-laravel/adapter-map.json +1 -1
  416. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +315 -2
  417. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +2 -1
  418. package/presets/zcode/svelte/adapter-map.json +1 -1
  419. package/presets/zcode/svelte/hooks/chain-team-phases.sh +314 -1
  420. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +2 -1
  421. package/scripts/aggregate-agent-task-metrics.mjs +48 -4
@@ -8,7 +8,7 @@
8
8
  * `.env.defectdojo`; the token is never written by this package.
9
9
  */
10
10
  import { readFileSync } from 'node:fs';
11
- import { basename, resolve } from 'node:path';
11
+ import { basename } from 'node:path';
12
12
  import { createInterface } from 'node:readline';
13
13
  import {
14
14
  ApiError,
@@ -16,6 +16,7 @@ import {
16
16
  isAllowedPath,
17
17
  loadDefectDojoConfig,
18
18
  request,
19
+ resolveImportPath,
19
20
  } from './lib/defectdojo.mjs';
20
21
 
21
22
  const PROTOCOL_VERSION = '2025-06-18';
@@ -141,7 +142,7 @@ const TOOLS = [
141
142
  properties: {
142
143
  engagement: { type: 'integer', minimum: 1 },
143
144
  scan_type: { type: 'string' },
144
- file: { type: 'string', description: 'Repo-relative or absolute path to the report file.' },
145
+ file: { type: 'string', description: 'Repo-relative path to the report file, read inside the project root.' },
145
146
  minimum_severity: { type: 'string', enum: ['Info', 'Low', 'Medium', 'High', 'Critical'] },
146
147
  active: { type: 'boolean' },
147
148
  verified: { type: 'boolean' },
@@ -178,18 +179,44 @@ function jsonResult(payload) {
178
179
  return { content: [{ type: 'text', text: clipped }] };
179
180
  }
180
181
 
182
+ /**
183
+ * Known error classes carry crafted messages without local paths; anything
184
+ * else is sanitized: the client gets a short generic message, the stack (and
185
+ * any local paths in it) goes to stderr for the operator only.
186
+ */
181
187
  function errorResult(error) {
182
- const message = error instanceof ConfigError || error instanceof ApiError
183
- ? error.message
184
- : error instanceof Error
185
- ? error.stack ?? error.message
186
- : String(error);
188
+ if (error instanceof ConfigError || error instanceof ApiError) {
189
+ return { content: [{ type: 'text', text: error.message }], isError: true };
190
+ }
191
+
192
+ const detail = error instanceof Error
193
+ ? error.stack ?? `${error.name}: ${error.message}`
194
+ : String(error);
187
195
 
188
- return { content: [{ type: 'text', text: message }], isError: true };
196
+ process.stderr.write(`defectdojo-mcp: unexpected tool failure\n${detail}\n`);
197
+
198
+ return { content: [{ type: 'text', text: 'unexpected tool failure (details in the server log)' }], isError: true };
189
199
  }
190
200
 
191
- function readFileForImport(root, path) {
192
- const absolute = resolve(root, path);
201
+ /** Declared-integer args are validated at runtime before they reach a path or payload. */
202
+ function requireInteger(value, name) {
203
+ if (!Number.isInteger(value)) {
204
+ throw new ConfigError(`${name} must be an integer`);
205
+ }
206
+
207
+ return value;
208
+ }
209
+
210
+ function readFileForImport(root, file) {
211
+ // Read the resolved path, never re-resolve the raw argument: the validated
212
+ // object and the uploaded object must be the same filesystem entry.
213
+ const absolute = resolveImportPath(root, file);
214
+
215
+ if (absolute === null) {
216
+ throw new ConfigError(
217
+ 'file must be a repo-relative path inside the project root; absolute paths, ".." traversal and symlink escapes are refused',
218
+ );
219
+ }
193
220
 
194
221
  return { buffer: readFileSync(absolute), name: basename(absolute) };
195
222
  }
@@ -205,15 +232,19 @@ async function callTool(name, args) {
205
232
  });
206
233
 
207
234
  case 'dd_finding':
208
- return request(config, { path: `findings/${args.id}/` });
235
+ return request(config, { path: `findings/${requireInteger(args.id, 'id')}/` });
209
236
 
210
237
  case 'dd_products':
211
238
  return request(config, { path: 'products/', query: asQuery(args, ['name', 'prod_type', 'limit', 'offset']) });
212
239
 
213
240
  case 'dd_product':
214
- return request(config, { path: `products/${args.id}/` });
241
+ return request(config, { path: `products/${requireInteger(args.id, 'id')}/` });
215
242
 
216
243
  case 'dd_engagements':
244
+ if (args.product !== undefined && args.product !== null) {
245
+ requireInteger(args.product, 'product');
246
+ }
247
+
217
248
  return request(config, { path: 'engagements/', query: asQuery(args, ['product', 'status', 'limit', 'offset']) });
218
249
 
219
250
  case 'dd_test_types':
@@ -228,6 +259,7 @@ async function callTool(name, args) {
228
259
  }
229
260
 
230
261
  case 'dd_import_scan': {
262
+ requireInteger(args.engagement, 'engagement');
231
263
  const { buffer, name: filename } = readFileForImport(config.root, args.file);
232
264
  const formData = new FormData();
233
265
 
@@ -7,8 +7,8 @@
7
7
  * `.env.defectdojo` file. Unlike GitLab, the token is not validated with a
8
8
  * provider endpoint at setup time only — the same probe powers the doctor.
9
9
  */
10
- import { existsSync } from 'node:fs';
11
- import { join } from 'node:path';
10
+ import { existsSync, realpathSync } from 'node:fs';
11
+ import { isAbsolute, join, resolve, sep } from 'node:path';
12
12
  import run from '../../bin/lib/mcp/run.js';
13
13
  import { ConfigError, readEnvFile } from './envfile.mjs';
14
14
 
@@ -157,6 +157,61 @@ export function isAllowedPath(path, baseUrl) {
157
157
  }
158
158
  }
159
159
 
160
+ /**
161
+ * `dd_import_scan` may read the report file inside the project root only —
162
+ * the local-file twin of {@link isAllowedPath}: a prompt-injected upload must
163
+ * not become a read of arbitrary local files. Absolute paths (POSIX, Windows
164
+ * drive or UNC) and any `..` traversal form — raw, percent-encoded, or
165
+ * backslash — are refused outright, and the resolved file must really exist
166
+ * under the *real* project root: a symlink that leaves the root is an escape,
167
+ * not a read. Deny closed: an unreadable, unresolvable, or malformed-encoding
168
+ * path is a refusal, never a best-effort read.
169
+ *
170
+ * Returns the real path the caller must read. Resolving the name once is
171
+ * deliberate: a validator that trims and a reader that resolves the raw input
172
+ * can approve one filesystem object and read another (a whitespace-padded
173
+ * symlink alias is a distinct directory entry on POSIX). Padded names are
174
+ * refused, never trimmed, for the same reason.
175
+ */
176
+ export function resolveImportPath(root, input) {
177
+ if (typeof root !== 'string' || root === '' || typeof input !== 'string' || input === '') {
178
+ return null;
179
+ }
180
+ if (input.trim() === '' || input !== input.trim()) {
181
+ return null;
182
+ }
183
+
184
+ if (isAbsolute(input) || /^[a-zA-Z]:[/\\]/.test(input) || input.startsWith('\\\\')) {
185
+ return null;
186
+ }
187
+
188
+ const forms = [input];
189
+ try {
190
+ forms.push(decodeURIComponent(input));
191
+ } catch {
192
+ return null;
193
+ }
194
+
195
+ for (const form of forms) {
196
+ if (form.split(/[\\/]/).includes('..')) {
197
+ return null;
198
+ }
199
+ }
200
+
201
+ try {
202
+ const realRoot = realpathSync(root);
203
+ const realFile = realpathSync(resolve(root, input));
204
+ return realFile === realRoot || realFile.startsWith(realRoot + sep) ? realFile : null;
205
+ } catch {
206
+ return null;
207
+ }
208
+ }
209
+
210
+ /** Boolean form of {@link resolveImportPath} for callers that only gate. */
211
+ export function isAllowedImportPath(root, input) {
212
+ return resolveImportPath(root, input) !== null;
213
+ }
214
+
160
215
  export function buildUrl(baseUrl, path, query = {}) {
161
216
  const url = /^https?:\/\//.test(path) ? new URL(path) : new URL(`${baseUrl}/${apiPath(path)}`);
162
217
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonesofspring/ai-rules",
3
- "version": "0.2.63",
3
+ "version": "0.2.65",
4
4
  "description": "Presets of Cursor, Claude, Mavis, OpenCode, and ZCode rules/commands for Revy Ross personal use",
5
5
  "license": "MIT",
6
6
  "author": "Revy Ross",
@@ -37,7 +37,7 @@
37
37
  "scripts": {
38
38
  "check:fast": "bash scripts/check-preset-fast.sh",
39
39
  "check:changed": "node scripts/check-preset-delta.mjs --base HEAD",
40
- "test:hooks": "node scripts/test-chain-team-phases-coverage.mjs && node scripts/test-agent-task-metrics-hooks.mjs",
40
+ "test:hooks": "node scripts/test-chain-team-phases-coverage.mjs && node scripts/test-agent-task-metrics-hooks.mjs && node scripts/test-chain-team-phases-dev-cleanup.mjs",
41
41
  "check:preset-structure": "bash scripts/check-preset-structure.sh",
42
42
  "release:gate": "bash scripts/release-gate.sh",
43
43
  "check:platform-scripts": "node scripts/check-platform-scripts.mjs",
@@ -49,27 +49,27 @@
49
49
  "check:claude-agent-blocks": "node scripts/check-claude-agent-blocks.mjs",
50
50
  "check:claude-agent-parity": "node scripts/check-claude-agent-parity.mjs",
51
51
  "test:claude-agent-parity": "node scripts/test-claude-agent-parity.mjs",
52
- "check:consumer-links": "node scripts/check-consumer-links.mjs",
52
+ "check:consumer-links": "node scripts/run-locked.mjs --label check:consumer-links -- node scripts/check-consumer-links.mjs",
53
53
  "test:consumer-links": "node scripts/test-consumer-links.mjs",
54
- "check:preset-twin-map": "bash scripts/check-preset-twin-map.sh",
55
- "check:preset-twin-drift": "node scripts/check-preset-twin-drift.mjs",
54
+ "check:preset-twin-map": "node scripts/run-locked.mjs --label check:preset-twin-map -- bash scripts/check-preset-twin-map.sh",
55
+ "check:preset-twin-drift": "node scripts/run-locked.mjs --label check:preset-twin-drift -- node scripts/check-preset-twin-drift.mjs",
56
56
  "test:twin-drift-fixtures": "node scripts/test-preset-twin-drift.mjs",
57
- "check:preset-token-budget": "bash scripts/check-preset-token-budget.sh",
58
- "check:preset-leakage": "bash scripts/check-preset-leakage.sh",
57
+ "check:preset-token-budget": "node scripts/run-locked.mjs --label check:preset-token-budget -- bash scripts/check-preset-token-budget.sh",
58
+ "check:preset-leakage": "node scripts/run-locked.mjs --label check:preset-leakage -- bash scripts/check-preset-leakage.sh",
59
59
  "check:figma-contract": "bash scripts/check-figma-contract-presence.sh",
60
60
  "check:hook-only-lifecycle": "bash scripts/check-hook-only-lifecycle.sh",
61
- "check:preset-reachability": "bash scripts/check-preset-reachability.sh",
61
+ "check:preset-reachability": "node scripts/run-locked.mjs --label check:preset-reachability -- bash scripts/check-preset-reachability.sh",
62
62
  "check:local-overlay": "bash scripts/check-local-overlay.sh",
63
- "check:preset-i18n": "AI_RULES_I18N_FAIL=1 AI_RULES_I18N_SOFT=0 bash scripts/check-preset-i18n.sh",
64
- "check:frontmatter": "node scripts/check-frontmatter.mjs",
65
- "check:shared-core-drift": "bash scripts/check-shared-core-drift.sh",
63
+ "check:preset-i18n": "node scripts/run-locked.mjs --label check:preset-i18n -- env AI_RULES_I18N_FAIL=1 AI_RULES_I18N_SOFT=0 bash scripts/check-preset-i18n.sh",
64
+ "check:frontmatter": "node scripts/run-locked.mjs --label check:frontmatter -- node scripts/check-frontmatter.mjs",
65
+ "check:shared-core-drift": "node scripts/run-locked.mjs --label check:shared-core-drift -- bash scripts/check-shared-core-drift.sh",
66
66
  "check:product-specs": "bash scripts/check-product-specs.sh",
67
67
  "check:product-specs:self-test": "bash scripts/check-product-specs.sh --self-test",
68
68
  "check:product-specs:dogfood": "bash scripts/check-product-specs.sh ../../dogfood/mcp-ts-sample",
69
69
  "check:rule-eval": "node scripts/check-rule-eval.mjs",
70
70
  "check:next-attached-budget": "node scripts/check-next-attached-budget.mjs",
71
71
  "check:release-consistency": "node scripts/check-release-consistency.mjs",
72
- "check:generated-drift": "node scripts/check-generated-drift.mjs",
72
+ "check:generated-drift": "node scripts/run-locked.mjs --label check:generated-drift -- node scripts/check-generated-drift.mjs",
73
73
  "check:hook-body-parity": "node scripts/check-hook-body-parity.mjs",
74
74
  "test:hook-body-parity-fixtures": "node scripts/test-hook-body-parity-fixtures.mjs",
75
75
  "test:shared-core-drift-lineage-fixtures": "node scripts/test-shared-core-drift-lineage-fixtures.mjs",
@@ -77,8 +77,10 @@
77
77
  "test:generate-claude-fixtures": "node scripts/test-generate-claude-fixtures.mjs",
78
78
  "test:generated-drift-claude-fixtures": "node scripts/test-generated-drift-claude-fixtures.mjs",
79
79
  "test:rule-improver": "node scripts/test-rule-improver-ledger.mjs",
80
+ "test:guard-shell-command": "node scripts/test-guard-shell-command.mjs",
81
+ "check:processes": "node scripts/test-process-lease.mjs && node scripts/test-process-adapters.mjs && node scripts/test-process-scan.mjs",
80
82
  "test:cli-mcp-merge": "node scripts/test-cli-mcp-merge.mjs",
81
- "test:cli-init-clean": "node scripts/test-cli-init-clean.mjs",
83
+ "test:cli-init-clean": "node scripts/run-locked.mjs --label test:cli-init-clean -- node scripts/test-cli-init-clean.mjs",
82
84
  "test:cli-update": "node scripts/test-cli-update.mjs",
83
85
  "test:cli-install-doctor": "node scripts/test-install-doctor.mjs",
84
86
  "test:engine-upgrade": "node scripts/test-engine-upgrade.mjs",
@@ -87,6 +89,7 @@
87
89
  "test:mcp-pack-tarball": "node scripts/test-mcp-pack-tarball.mjs",
88
90
  "test:chain-coverage": "node scripts/test-chain-team-phases-coverage.mjs",
89
91
  "test:agent-task-metrics-hooks": "node scripts/test-agent-task-metrics-hooks.mjs",
92
+ "test:upstream": "node scripts/test-upstream-research.mjs",
90
93
  "test:team-db:schema": "node scripts/test-team-db-schema.mjs",
91
94
  "test:team-db:project": "node scripts/test-team-db-project.mjs",
92
95
  "test:team-db:migrate-tasks": "node scripts/test-team-db-migrate-tasks.mjs",
@@ -94,10 +97,17 @@
94
97
  "test:team-db:api": "node scripts/test-team-db-api.mjs",
95
98
  "test:team-db:security": "node scripts/test-team-db-security.mjs",
96
99
  "test:team-db:dashboard": "node scripts/test-team-db-dashboard.mjs",
100
+ "test:team-db:ui": "node scripts/test-team-db-ui.mjs",
97
101
  "test:team-db:concurrency": "node scripts/test-team-db-concurrency.mjs",
102
+ "test:team-db:tracker": "node scripts/test-team-db-tracker.mjs",
103
+ "test:team-db:tracker-order": "node scripts/test-team-db-tracker-order.mjs",
104
+ "test:team-db:tracker-project": "node scripts/test-team-db-tracker-project.mjs",
105
+ "test:team-db:tracker-queue": "node scripts/test-team-db-tracker-queue.mjs",
106
+ "test:team-db:tracker-import": "node scripts/test-team-db-tracker-import.mjs",
107
+ "test:team-db:task-runner": "node scripts/test-team-db-task-runner.mjs",
98
108
  "test:team-db:scheduler": "node scripts/test-team-db-scheduler.mjs",
99
109
  "test:team-db:fixtures": "node scripts/test-team-db-fixtures.mjs",
100
- "test:team-db": "node scripts/test-team-db-schema.mjs && node scripts/test-team-db-project.mjs && node scripts/test-team-db-migrate-tasks.mjs && node scripts/test-team-db-dualwrite.mjs && node scripts/check-team-db-contract.mjs && node scripts/test-team-db-api.mjs && node scripts/test-team-db-security.mjs && node scripts/test-team-db-dashboard.mjs && node scripts/test-team-db-concurrency.mjs && node scripts/test-team-db-scheduler.mjs && node scripts/test-team-db-fixtures.mjs",
110
+ "test:team-db": "node scripts/test-team-db-schema.mjs && node scripts/test-team-db-project.mjs && node scripts/test-team-db-migrate-tasks.mjs && node scripts/test-team-db-dualwrite.mjs && node scripts/check-team-db-contract.mjs && node scripts/test-team-db-api.mjs && node scripts/test-team-db-security.mjs && node scripts/test-team-db-dashboard.mjs && node scripts/test-team-db-ui.mjs && node scripts/test-team-db-concurrency.mjs && node scripts/test-team-db-tracker.mjs && node scripts/test-team-db-tracker-order.mjs && node scripts/test-team-db-tracker-project.mjs && node scripts/test-team-db-tracker-queue.mjs && node scripts/test-team-db-tracker-import.mjs && node scripts/test-team-db-task-runner.mjs && node scripts/test-team-db-scheduler.mjs && node scripts/test-team-db-fixtures.mjs",
101
111
  "check:team-db-contract": "node scripts/check-team-db-contract.mjs",
102
112
  "check:mavis-platform-contract": "node scripts/check-mavis-platform-contract.mjs --self-test",
103
113
  "check:mavis-adapter-map": "node scripts/check-mavis-adapter-map.mjs --self-test",
@@ -115,11 +125,13 @@
115
125
  "check:zcode-local-overlay": "node scripts/check-zcode-local-overlay.mjs",
116
126
  "test:opencode-context-budget": "node scripts/test-opencode-context-budget.mjs",
117
127
  "test:probe-mavis-capabilities": "node scripts/test-probe-mavis-capabilities.mjs",
128
+ "preset:loop": "yarn fix:generated && yarn check:changed && yarn check:fast",
118
129
  "fix:generated": "node scripts/fix-generated.mjs",
119
130
  "generate:claude": "node scripts/generate-claude.mjs",
120
131
  "generate:mavis": "node scripts/generate-mavis.mjs",
121
132
  "generate:opencode": "node scripts/generate-opencode.mjs",
122
- "generate:zcode": "node scripts/generate-zcode.mjs"
133
+ "generate:zcode": "node scripts/generate-zcode.mjs",
134
+ "test:dev-processes": "node scripts/test-dev-processes.mjs"
123
135
  },
124
136
  "engines": {
125
137
  "node": ">=20"
@@ -0,0 +1,279 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Aggregate `metrics.json` ledgers across `.ai.local/team/tasks/*` and emit a JSON report.
4
+ *
5
+ * Usage:
6
+ * node scripts/aggregate-agent-task-metrics.mjs [--team-root <dir>] [--help]
7
+ *
8
+ * Defaults to `<cwd>/.ai.local/team` when --team-root is omitted.
9
+ */
10
+
11
+ import fs from 'node:fs';
12
+ import path from 'node:path';
13
+
14
+ const args = process.argv.slice(2);
15
+
16
+ if (args.includes('-h') || args.includes('--help')) {
17
+ console.log(`Aggregate agent-task metrics ledgers.
18
+
19
+ Usage:
20
+ node scripts/aggregate-agent-task-metrics.mjs [--team-root <dir>] [--slug <slug>]
21
+
22
+ Options:
23
+ --team-root <dir> Directory containing a 'tasks/' subfolder with *.metrics.json ledgers
24
+ (default: <cwd>/.ai.local/team)
25
+ --slug <slug> Only aggregate the named task directory
26
+
27
+ Output: JSON report on stdout (machine-readable).`);
28
+ process.exit(0);
29
+ }
30
+
31
+ const teamRootIndex = args.indexOf('--team-root');
32
+ const teamRoot =
33
+ teamRootIndex >= 0
34
+ ? path.resolve(args[teamRootIndex + 1] ?? '')
35
+ : path.join(process.cwd(), '.ai.local', 'team');
36
+ const slugIndex = args.indexOf('--slug');
37
+ const slugFilter = slugIndex >= 0 ? args[slugIndex + 1] ?? null : null;
38
+ const tasksDir = path.join(teamRoot, 'tasks');
39
+ const incomplete = [];
40
+ const attempts = [];
41
+ const tasks = [];
42
+ const taskReports = [];
43
+ const gateWaits = [];
44
+ const outOfBandDurations = [];
45
+ const attributionConfidenceCounts = new Map();
46
+ let unmatchedAttemptCount = 0;
47
+ let duplicateTerminalAttemptCount = 0;
48
+ let duplicateAttemptIdCount = 0;
49
+ let missingLedgerCount = 0;
50
+ let malformedLedgerCount = 0;
51
+ let invalidLedgerCount = 0;
52
+ let unterminatedAttemptCount = 0;
53
+
54
+ function readMetrics(filePath) {
55
+ if (!fs.existsSync(filePath)) {
56
+ incomplete.push({ file: filePath, category: 'missing_ledger', reason: 'missing ledger' });
57
+ missingLedgerCount += 1;
58
+ return;
59
+ }
60
+ let parsed;
61
+ try {
62
+ parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
63
+ } catch {
64
+ incomplete.push({ file: filePath, category: 'malformed_json', reason: 'malformed JSON' });
65
+ malformedLedgerCount += 1;
66
+ return;
67
+ }
68
+ if (parsed.schemaVersion !== 1 || !parsed.task || !Array.isArray(parsed.events)) {
69
+ incomplete.push({ file: filePath, category: 'unsupported_schema', reason: 'unsupported schema' });
70
+ return;
71
+ }
72
+ try {
73
+ collect(parsed, filePath);
74
+ } catch (error) {
75
+ incomplete.push({
76
+ file: filePath,
77
+ category: 'invalid_ledger',
78
+ reason: error instanceof Error ? error.message : 'invalid ledger structure',
79
+ });
80
+ invalidLedgerCount += 1;
81
+ }
82
+ }
83
+
84
+ function collect(metrics, filePath) {
85
+ const starts = new Map();
86
+ const gateStarts = new Map();
87
+ const terminalAttempts = new Set();
88
+ const attemptDurations = [];
89
+ let taskCompleted = false;
90
+ let ledgerIncomplete = false;
91
+ let taskStartedAt = null;
92
+ let taskCompletedAt = null;
93
+ let taskGateWaitMs = 0;
94
+ let taskOutOfBandMs = 0;
95
+ let taskOutOfBandCount = 0;
96
+
97
+ for (const event of metrics.events) {
98
+ if (event.type === 'task_started') taskStartedAt = event.at;
99
+ if (event.type === 'out_of_band_finished' && Number.isFinite(event.durationMs)) {
100
+ outOfBandDurations.push(event.durationMs);
101
+ taskOutOfBandMs += event.durationMs;
102
+ taskOutOfBandCount += 1;
103
+ }
104
+ if (event.type === 'attempt_started' && event.attemptId) {
105
+ if (starts.has(event.attemptId)) {
106
+ incomplete.push({
107
+ file: filePath,
108
+ category: 'duplicate_attempt_id',
109
+ reason: `duplicate attempt ID ${event.attemptId}`,
110
+ });
111
+ duplicateAttemptIdCount += 1;
112
+ ledgerIncomplete = true;
113
+ continue;
114
+ }
115
+ starts.set(event.attemptId, event);
116
+ }
117
+ if (event.type === 'attempt_finished' && event.attemptId) {
118
+ const start = starts.get(event.attemptId);
119
+ if (!start) {
120
+ incomplete.push({
121
+ file: filePath,
122
+ category: 'unmatched_attempt',
123
+ reason: `unmatched attempt ${event.attemptId}`,
124
+ });
125
+ unmatchedAttemptCount += 1;
126
+ ledgerIncomplete = true;
127
+ continue;
128
+ }
129
+ if (terminalAttempts.has(event.attemptId)) {
130
+ incomplete.push({
131
+ file: filePath,
132
+ category: 'duplicate_terminal_attempt',
133
+ reason: `duplicate terminal attempt ${event.attemptId}`,
134
+ });
135
+ duplicateTerminalAttemptCount += 1;
136
+ ledgerIncomplete = true;
137
+ continue;
138
+ }
139
+ terminalAttempts.add(event.attemptId);
140
+ const attributionConfidence = event.attributionConfidence ?? 'unknown';
141
+ attributionConfidenceCounts.set(
142
+ attributionConfidence,
143
+ (attributionConfidenceCounts.get(attributionConfidence) ?? 0) + 1,
144
+ );
145
+ if (Number.isFinite(event.durationMs)) attemptDurations.push(event.durationMs);
146
+ attempts.push({
147
+ ...metrics.task,
148
+ agent: start.agent ?? 'unknown',
149
+ role: start.role ?? 'unknown',
150
+ durationMs: Number.isFinite(event.durationMs) ? event.durationMs : null,
151
+ outcome: event.outcome ?? 'unknown',
152
+ attributionConfidence,
153
+ });
154
+ }
155
+ if (event.type === 'human_gate_started' && event.eventId) {
156
+ gateStarts.set(event.eventId, event);
157
+ }
158
+ if (event.type === 'human_gate_ended') {
159
+ const start = event.gateStartedEventId ? gateStarts.get(event.gateStartedEventId) : undefined;
160
+ const elapsed = start ? Date.parse(event.at) - Date.parse(start.at) : NaN;
161
+ if (Number.isFinite(elapsed) && elapsed >= 0) {
162
+ gateWaits.push(elapsed);
163
+ taskGateWaitMs += elapsed;
164
+ }
165
+ }
166
+ if (event.type === 'task_completed') {
167
+ taskCompleted = true;
168
+ taskCompletedAt = event.at;
169
+ }
170
+ }
171
+
172
+ for (const attemptId of starts.keys()) {
173
+ if (terminalAttempts.has(attemptId)) continue;
174
+ incomplete.push({
175
+ file: filePath,
176
+ category: 'unterminated_attempt',
177
+ reason: `unterminated attempt ${attemptId}`,
178
+ });
179
+ unterminatedAttemptCount += 1;
180
+ ledgerIncomplete = true;
181
+ }
182
+
183
+ if (taskCompleted && !ledgerIncomplete) tasks.push(metrics.task);
184
+ if (taskStartedAt) {
185
+ taskReports.push({
186
+ ...metrics.task,
187
+ elapsedMs: taskCompletedAt ? Date.parse(taskCompletedAt) - Date.parse(taskStartedAt) : null,
188
+ activeMs: attemptDurations.reduce((sum, value) => sum + value, 0),
189
+ gateWaitMs: taskGateWaitMs,
190
+ outOfBandMs: taskOutOfBandMs,
191
+ outOfBandCount: taskOutOfBandCount,
192
+ attemptCount: terminalAttempts.size,
193
+ completed: taskCompleted,
194
+ incomplete: ledgerIncomplete,
195
+ });
196
+ }
197
+ }
198
+
199
+ function groupBy(items, keyFor) {
200
+ const groups = new Map();
201
+ for (const item of items) {
202
+ const key = keyFor(item);
203
+ groups.set(key, [...(groups.get(key) ?? []), item]);
204
+ }
205
+ return [...groups.values()];
206
+ }
207
+
208
+ if (!fs.existsSync(tasksDir)) {
209
+ console.error(`Task directory does not exist: ${tasksDir}`);
210
+ process.exit(1);
211
+ }
212
+
213
+ for (const entry of fs.readdirSync(tasksDir, { withFileTypes: true })) {
214
+ if (!entry.isDirectory()) continue;
215
+ if (slugFilter && entry.name !== slugFilter) continue;
216
+ readMetrics(path.join(tasksDir, entry.name, 'metrics.json'));
217
+ }
218
+
219
+ const byAgentRole = groupBy(
220
+ attempts,
221
+ (item) => `${item.platform}|${item.stack}|${item.preset}|${item.agent}|${item.role}`,
222
+ ).map((group) => {
223
+ const sample = group[0];
224
+ const durations = group.map((item) => item.durationMs).filter((value) => value !== null);
225
+ const sumDurationMs = durations.reduce((sum, value) => sum + value, 0);
226
+ return {
227
+ platform: sample.platform,
228
+ stack: sample.stack,
229
+ preset: sample.preset,
230
+ agent: sample.agent,
231
+ role: sample.role,
232
+ count: group.length,
233
+ completedCount: group.filter((item) => item.outcome === 'completed').length,
234
+ sumDurationMs,
235
+ avgDurationMs: durations.length ? sumDurationMs / durations.length : null,
236
+ };
237
+ });
238
+
239
+ const taskCountsByRunId = [...new Map(tasks.map((task) => [task.runId, task])).values()].map((task) => ({
240
+ runId: task.runId,
241
+ slug: task.slug,
242
+ platform: task.platform,
243
+ stack: task.stack,
244
+ preset: task.preset,
245
+ intent: task.intent,
246
+ }));
247
+
248
+ process.stdout.write(
249
+ `${JSON.stringify(
250
+ {
251
+ schemaVersion: 1,
252
+ teamRoot,
253
+ agentRole: byAgentRole,
254
+ taskCountsByRunId,
255
+ taskReports,
256
+ humanGateWait: {
257
+ count: gateWaits.length,
258
+ sumDurationMs: gateWaits.reduce((sum, value) => sum + value, 0),
259
+ },
260
+ outOfBand: {
261
+ count: outOfBandDurations.length,
262
+ sumDurationMs: outOfBandDurations.reduce((sum, value) => sum + value, 0),
263
+ },
264
+ attributionConfidence: Object.fromEntries(attributionConfidenceCounts),
265
+ completeness: {
266
+ missingLedgerCount,
267
+ malformedLedgerCount,
268
+ invalidLedgerCount,
269
+ duplicateAttemptIdCount,
270
+ unterminatedAttemptCount,
271
+ unmatchedAttemptCount,
272
+ duplicateTerminalAttemptCount,
273
+ },
274
+ incomplete,
275
+ },
276
+ null,
277
+ 2,
278
+ )}\n`,
279
+ );