@bonesofspring/ai-rules 0.2.60 → 0.2.63

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 (718) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/README.md +62 -29
  3. package/bin/cli.js +368 -59
  4. package/bin/lib/ai-local-drift.js +18 -0
  5. package/bin/lib/engine-scripts.js +22 -5
  6. package/bin/lib/engine-upgrade.js +279 -0
  7. package/bin/lib/mcp/catalog.js +66 -5
  8. package/bin/lib/mcp/clients.js +4 -4
  9. package/bin/lib/mcp/credentials.js +88 -0
  10. package/bin/lib/mcp/doctor.js +100 -8
  11. package/bin/lib/mcp/npx.js +17 -0
  12. package/bin/lib/mcp/registry.js +2 -0
  13. package/bin/lib/merged-config.js +38 -0
  14. package/bin/lib/seed-ai-local-team.js +32 -14
  15. package/bin/mavis-install.js +3 -1
  16. package/bin/opencode-install.js +3 -1
  17. package/bin/zcode-install.js +3 -1
  18. package/docs/MAVIS.md +5 -2
  19. package/docs/MCP-CATALOG.md +30 -2
  20. package/docs/MCP-SETUP.md +30 -6
  21. package/docs/OPENCODE.md +27 -4
  22. package/docs/PLATFORMS.md +38 -0
  23. package/docs/PRESET-CONTRIBUTION.md +27 -14
  24. package/docs/TEAM-DB.md +194 -21
  25. package/docs/openapi/team-db.v1.json +4443 -2083
  26. package/mcp/defectdojo-mcp.mjs +353 -0
  27. package/mcp/gitlab.mjs +5 -1
  28. package/mcp/lib/defectdojo.mjs +249 -0
  29. package/mcp/lib/yandex.mjs +39 -15
  30. package/package.json +11 -5
  31. package/presets/_shared/ai-local/scripts/check-write-scope.mjs +176 -28
  32. package/presets/_shared/ai-local/scripts/lock.mjs +128 -69
  33. package/presets/_shared/ai-local/scripts/signals.mjs +17 -1
  34. package/presets/_shared/ai-local/scripts/team-db-api.mjs +496 -67
  35. package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +816 -5
  36. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +761 -6
  37. package/presets/_shared/ai-local/scripts/team-db-project.mjs +10 -0
  38. package/presets/_shared/ai-local/scripts/team-db-scheduler.mjs +2360 -0
  39. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +87 -0
  40. package/presets/_shared/ai-local/scripts/team-db.mjs +151 -9
  41. package/presets/_shared/ai-local/scripts/upstream-research.mjs +2961 -0
  42. package/presets/_shared/core/agent-team/agent-artifact-contracts.md +17 -0
  43. package/presets/_shared/core/agent-team/agent-team-intake.md +1 -0
  44. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +5 -2
  45. package/presets/_shared/core/meta/preset-pr-checklist.md +4 -4
  46. package/presets/_shared/core/meta/preset-twin-sync.md +1 -1
  47. package/presets/_shared/hooks/README.md +23 -3
  48. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +57 -3
  49. package/presets/_shared/hooks/check-preset-update.mjs +4 -3
  50. package/presets/{claude/nuxt/hooks/guard-shell-command.sh → _shared/hooks/guard-shell-command.mjs.tmpl} +29 -35
  51. package/presets/_shared/hooks/run-hook.mjs +102 -0
  52. package/presets/claude/android-kotlin/hooks/README.md +4 -3
  53. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +57 -3
  54. package/presets/claude/android-kotlin/hooks/check-preset-update.mjs +4 -3
  55. package/presets/claude/android-kotlin/hooks/examples/README.md +2 -2
  56. package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +96 -0
  57. package/presets/claude/android-kotlin/hooks/run-hook.mjs +102 -0
  58. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-intake.md +1 -0
  59. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  60. package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  61. package/presets/claude/android-kotlin/rules/tooling-and-review/preset-twin-sync.md +1 -1
  62. package/presets/claude/android-kotlin/settings.json +2 -2
  63. package/presets/claude/android-kotlin/team/README.md +5 -0
  64. package/presets/claude/go/hooks/README.md +4 -3
  65. package/presets/claude/go/hooks/chain-team-phases.sh +57 -3
  66. package/presets/claude/go/hooks/check-preset-update.mjs +4 -3
  67. package/presets/claude/go/hooks/examples/README.md +2 -2
  68. package/presets/claude/go/hooks/guard-shell-command.mjs +95 -0
  69. package/presets/claude/go/hooks/run-hook.mjs +102 -0
  70. package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +1 -0
  71. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  72. package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  73. package/presets/claude/go/rules/tooling-and-review/preset-twin-sync.md +1 -1
  74. package/presets/claude/go/settings.json +2 -2
  75. package/presets/claude/go/team/README.md +5 -0
  76. package/presets/claude/ios-swift/hooks/README.md +4 -3
  77. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +57 -3
  78. package/presets/claude/ios-swift/hooks/check-preset-update.mjs +4 -3
  79. package/presets/claude/ios-swift/hooks/examples/README.md +2 -2
  80. package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +95 -0
  81. package/presets/claude/ios-swift/hooks/run-hook.mjs +102 -0
  82. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +1 -0
  83. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  84. package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  85. package/presets/claude/ios-swift/rules/tooling-and-review/preset-twin-sync.md +1 -1
  86. package/presets/claude/ios-swift/settings.json +2 -2
  87. package/presets/claude/ios-swift/team/README.md +5 -0
  88. package/presets/claude/java/hooks/README.md +4 -3
  89. package/presets/claude/java/hooks/chain-team-phases.sh +57 -3
  90. package/presets/claude/java/hooks/check-preset-update.mjs +4 -3
  91. package/presets/claude/java/hooks/examples/README.md +2 -2
  92. package/presets/claude/java/hooks/{guard-shell-command.sh → guard-shell-command.mjs} +31 -38
  93. package/presets/claude/java/hooks/run-hook.mjs +102 -0
  94. package/presets/claude/java/rules/tooling-and-review/agent-team-intake.md +1 -0
  95. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  96. package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  97. package/presets/claude/java/rules/tooling-and-review/preset-twin-sync.md +1 -1
  98. package/presets/claude/java/settings.json +2 -2
  99. package/presets/claude/java/team/README.md +5 -0
  100. package/presets/claude/mcp-ts/hooks/README.md +4 -3
  101. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +57 -3
  102. package/presets/claude/mcp-ts/hooks/check-preset-update.mjs +4 -3
  103. package/presets/claude/mcp-ts/hooks/examples/README.md +1 -1
  104. package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +95 -0
  105. package/presets/claude/mcp-ts/hooks/run-hook.mjs +102 -0
  106. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +1 -0
  107. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  108. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  109. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-twin-sync.md +1 -1
  110. package/presets/claude/mcp-ts/settings.json +2 -2
  111. package/presets/claude/mcp-ts/team/README.md +5 -0
  112. package/presets/claude/mol/hooks/README.md +20 -0
  113. package/presets/claude/mol/hooks/chain-team-phases.sh +57 -3
  114. package/presets/claude/mol/hooks/check-preset-update.mjs +4 -3
  115. package/presets/claude/{svelte/hooks/guard-shell-command.sh → mol/hooks/guard-shell-command.mjs} +29 -35
  116. package/presets/claude/mol/hooks/run-hook.mjs +102 -0
  117. package/presets/claude/mol/rules/tooling-and-review/agent-team-intake.md +1 -0
  118. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  119. package/presets/claude/mol/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  120. package/presets/claude/mol/rules/tooling-and-review/preset-twin-sync.md +1 -1
  121. package/presets/claude/mol/settings.json +2 -2
  122. package/presets/claude/mol/team/README.md +5 -0
  123. package/presets/claude/next/agents/build-verifier.md +18 -3
  124. package/presets/claude/next/agents/code-reviewer.md +2 -0
  125. package/presets/claude/next/agents/feature-developer.md +3 -1
  126. package/presets/claude/next/agents/task-analyst.md +6 -0
  127. package/presets/claude/next/agents/task-router.md +5 -3
  128. package/presets/claude/next/commands/README.md +1 -0
  129. package/presets/claude/next/commands/task-continue.md +1 -1
  130. package/presets/claude/next/commands/upstream-research.md +23 -0
  131. package/presets/claude/next/hooks/README.md +4 -3
  132. package/presets/claude/next/hooks/chain-team-phases.sh +57 -3
  133. package/presets/claude/next/hooks/check-preset-update.mjs +4 -3
  134. package/presets/claude/next/hooks/examples/README.md +2 -2
  135. package/presets/claude/next/hooks/guard-shell-command.mjs +94 -0
  136. package/presets/claude/next/hooks/run-hook.mjs +102 -0
  137. package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +1 -0
  138. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  139. package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  140. package/presets/claude/next/rules/tooling-and-review/preset-twin-sync.md +1 -1
  141. package/presets/claude/next/settings.json +2 -2
  142. package/presets/claude/next/team/README.md +23 -0
  143. package/presets/claude/next/team/upstream/config.json +31 -0
  144. package/presets/claude/next/team/upstream/digest-template.md +55 -0
  145. package/presets/claude/next/team/upstream/opencode.json +34 -0
  146. package/presets/claude/next/team/upstream/projects.json +4 -0
  147. package/presets/claude/next/team/upstream/prompt.md +77 -0
  148. package/presets/claude/next/team/upstream/signatures.json +9 -0
  149. package/presets/claude/nuxt/hooks/README.md +4 -3
  150. package/presets/claude/nuxt/hooks/chain-team-phases.sh +57 -3
  151. package/presets/claude/nuxt/hooks/check-preset-update.mjs +4 -3
  152. package/presets/claude/nuxt/hooks/examples/README.md +2 -2
  153. package/presets/claude/{ios-swift/hooks/guard-shell-command.sh → nuxt/hooks/guard-shell-command.mjs} +29 -37
  154. package/presets/claude/nuxt/hooks/run-hook.mjs +102 -0
  155. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-intake.md +1 -0
  156. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  157. package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  158. package/presets/claude/nuxt/rules/tooling-and-review/preset-twin-sync.md +1 -1
  159. package/presets/claude/nuxt/settings.json +2 -2
  160. package/presets/claude/nuxt/team/README.md +5 -0
  161. package/presets/claude/php-hexagonal/hooks/README.md +4 -3
  162. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +57 -3
  163. package/presets/claude/php-hexagonal/hooks/check-preset-update.mjs +4 -3
  164. package/presets/claude/php-hexagonal/hooks/examples/README.md +2 -2
  165. package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +96 -0
  166. package/presets/claude/php-hexagonal/hooks/run-hook.mjs +102 -0
  167. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-intake.md +1 -0
  168. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  169. package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  170. package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-twin-sync.md +1 -1
  171. package/presets/claude/php-hexagonal/settings.json +2 -2
  172. package/presets/claude/php-hexagonal/team/README.md +5 -0
  173. package/presets/claude/php-laravel/hooks/README.md +4 -3
  174. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +57 -3
  175. package/presets/claude/php-laravel/hooks/check-preset-update.mjs +4 -3
  176. package/presets/claude/php-laravel/hooks/examples/README.md +2 -2
  177. package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +96 -0
  178. package/presets/claude/php-laravel/hooks/run-hook.mjs +102 -0
  179. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-intake.md +1 -0
  180. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  181. package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  182. package/presets/claude/php-laravel/rules/tooling-and-review/preset-twin-sync.md +1 -1
  183. package/presets/claude/php-laravel/settings.json +2 -2
  184. package/presets/claude/php-laravel/team/README.md +5 -0
  185. package/presets/claude/svelte/hooks/README.md +4 -3
  186. package/presets/claude/svelte/hooks/chain-team-phases.sh +57 -3
  187. package/presets/claude/svelte/hooks/check-preset-update.mjs +4 -3
  188. package/presets/claude/svelte/hooks/examples/README.md +2 -2
  189. package/presets/claude/svelte/hooks/guard-shell-command.mjs +94 -0
  190. package/presets/claude/svelte/hooks/run-hook.mjs +102 -0
  191. package/presets/claude/svelte/rules/tooling-and-review/agent-team-intake.md +1 -0
  192. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
  193. package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +4 -4
  194. package/presets/claude/svelte/rules/tooling-and-review/preset-twin-sync.md +1 -1
  195. package/presets/claude/svelte/settings.json +2 -2
  196. package/presets/claude/svelte/team/README.md +5 -0
  197. package/presets/cursor/android-kotlin/hooks/README.md +2 -1
  198. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +57 -3
  199. package/presets/cursor/android-kotlin/hooks/check-preset-update.mjs +4 -3
  200. package/presets/cursor/android-kotlin/hooks/examples/README.md +1 -1
  201. package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +96 -0
  202. package/presets/cursor/android-kotlin/hooks/run-hook.mjs +102 -0
  203. package/presets/cursor/android-kotlin/hooks.json +2 -2
  204. package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +1 -0
  205. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +2 -1
  206. package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +4 -4
  207. package/presets/cursor/android-kotlin/rules/preset-twin-sync.mdc +1 -1
  208. package/presets/cursor/android-kotlin/team/README.md +5 -0
  209. package/presets/cursor/go/hooks/README.md +2 -1
  210. package/presets/cursor/go/hooks/chain-team-phases.sh +57 -3
  211. package/presets/cursor/go/hooks/check-preset-update.mjs +4 -3
  212. package/presets/cursor/go/hooks/examples/README.md +1 -1
  213. package/presets/cursor/go/hooks/guard-shell-command.mjs +95 -0
  214. package/presets/cursor/go/hooks/run-hook.mjs +102 -0
  215. package/presets/cursor/go/hooks.json +2 -2
  216. package/presets/cursor/go/rules/agent-team-intake.mdc +1 -0
  217. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +2 -1
  218. package/presets/cursor/go/rules/preset-pr-checklist.mdc +4 -4
  219. package/presets/cursor/go/rules/preset-twin-sync.mdc +1 -1
  220. package/presets/cursor/go/team/README.md +5 -0
  221. package/presets/cursor/ios-swift/hooks/README.md +2 -1
  222. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +57 -3
  223. package/presets/cursor/ios-swift/hooks/check-preset-update.mjs +4 -3
  224. package/presets/cursor/ios-swift/hooks/examples/README.md +1 -1
  225. package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +95 -0
  226. package/presets/cursor/ios-swift/hooks/run-hook.mjs +102 -0
  227. package/presets/cursor/ios-swift/hooks.json +2 -2
  228. package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +1 -0
  229. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +2 -1
  230. package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +4 -4
  231. package/presets/cursor/ios-swift/rules/preset-twin-sync.mdc +1 -1
  232. package/presets/cursor/ios-swift/team/README.md +5 -0
  233. package/presets/cursor/java/hooks/README.md +2 -1
  234. package/presets/cursor/java/hooks/chain-team-phases.sh +57 -3
  235. package/presets/cursor/java/hooks/check-preset-update.mjs +4 -3
  236. package/presets/cursor/java/hooks/examples/README.md +1 -1
  237. package/presets/cursor/java/hooks/guard-shell-command.mjs +96 -0
  238. package/presets/cursor/java/hooks/run-hook.mjs +102 -0
  239. package/presets/cursor/java/hooks.json +2 -2
  240. package/presets/cursor/java/rules/agent-team-intake.mdc +1 -0
  241. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +2 -1
  242. package/presets/cursor/java/rules/preset-pr-checklist.mdc +4 -4
  243. package/presets/cursor/java/rules/preset-twin-sync.mdc +1 -1
  244. package/presets/cursor/java/team/README.md +5 -0
  245. package/presets/cursor/mcp-ts/hooks/README.md +2 -1
  246. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +57 -3
  247. package/presets/cursor/mcp-ts/hooks/check-preset-update.mjs +4 -3
  248. package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +95 -0
  249. package/presets/cursor/mcp-ts/hooks/run-hook.mjs +102 -0
  250. package/presets/cursor/mcp-ts/hooks.json +2 -2
  251. package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +1 -0
  252. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +2 -1
  253. package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +4 -4
  254. package/presets/cursor/mcp-ts/rules/preset-twin-sync.mdc +1 -1
  255. package/presets/cursor/mcp-ts/team/README.md +5 -0
  256. package/presets/cursor/mol/hooks/README.md +2 -1
  257. package/presets/cursor/mol/hooks/chain-team-phases.sh +57 -3
  258. package/presets/cursor/mol/hooks/check-preset-update.mjs +4 -3
  259. package/presets/cursor/mol/hooks/examples/README.md +1 -1
  260. package/presets/{claude/next/hooks/guard-shell-command.sh → cursor/mol/hooks/guard-shell-command.mjs} +29 -35
  261. package/presets/cursor/mol/hooks/run-hook.mjs +102 -0
  262. package/presets/cursor/mol/hooks.json +2 -2
  263. package/presets/cursor/mol/rules/agent-team-intake.mdc +1 -0
  264. package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +2 -1
  265. package/presets/cursor/mol/rules/preset-pr-checklist.mdc +4 -4
  266. package/presets/cursor/mol/rules/preset-twin-sync.mdc +1 -1
  267. package/presets/cursor/mol/team/README.md +5 -0
  268. package/presets/cursor/next/agents/build-verifier.md +18 -3
  269. package/presets/cursor/next/agents/code-reviewer.md +2 -0
  270. package/presets/cursor/next/agents/feature-developer.md +3 -1
  271. package/presets/cursor/next/agents/task-analyst.md +6 -0
  272. package/presets/cursor/next/agents/task-router.md +5 -3
  273. package/presets/cursor/next/commands/README.md +1 -0
  274. package/presets/cursor/next/commands/task-continue.md +1 -1
  275. package/presets/cursor/next/commands/upstream-research.md +23 -0
  276. package/presets/cursor/next/hooks/README.md +2 -1
  277. package/presets/cursor/next/hooks/chain-team-phases.sh +57 -3
  278. package/presets/cursor/next/hooks/check-preset-update.mjs +4 -3
  279. package/presets/cursor/next/hooks/examples/README.md +1 -1
  280. package/presets/cursor/next/hooks/guard-shell-command.mjs +94 -0
  281. package/presets/cursor/next/hooks/run-hook.mjs +102 -0
  282. package/presets/cursor/next/hooks.json +2 -2
  283. package/presets/cursor/next/rules/agent-team-intake.mdc +1 -0
  284. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +2 -1
  285. package/presets/cursor/next/rules/preset-pr-checklist.mdc +4 -4
  286. package/presets/cursor/next/rules/preset-twin-sync.mdc +1 -1
  287. package/presets/cursor/next/team/README.md +23 -0
  288. package/presets/cursor/next/team/upstream/config.json +31 -0
  289. package/presets/cursor/next/team/upstream/digest-template.md +55 -0
  290. package/presets/cursor/next/team/upstream/opencode.json +34 -0
  291. package/presets/cursor/next/team/upstream/projects.json +4 -0
  292. package/presets/cursor/next/team/upstream/prompt.md +77 -0
  293. package/presets/cursor/next/team/upstream/signatures.json +9 -0
  294. package/presets/cursor/nuxt/hooks/README.md +2 -1
  295. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +57 -3
  296. package/presets/cursor/nuxt/hooks/check-preset-update.mjs +4 -3
  297. package/presets/cursor/nuxt/hooks/examples/README.md +1 -1
  298. package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +94 -0
  299. package/presets/cursor/nuxt/hooks/run-hook.mjs +102 -0
  300. package/presets/cursor/nuxt/hooks.json +2 -2
  301. package/presets/cursor/nuxt/rules/agent-team-intake.mdc +1 -0
  302. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +2 -1
  303. package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +4 -4
  304. package/presets/cursor/nuxt/rules/preset-twin-sync.mdc +1 -1
  305. package/presets/cursor/nuxt/team/README.md +5 -0
  306. package/presets/cursor/php-hexagonal/hooks/README.md +2 -1
  307. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +57 -3
  308. package/presets/cursor/php-hexagonal/hooks/check-preset-update.mjs +4 -3
  309. package/presets/cursor/php-hexagonal/hooks/examples/README.md +1 -1
  310. package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +96 -0
  311. package/presets/cursor/php-hexagonal/hooks/run-hook.mjs +102 -0
  312. package/presets/cursor/php-hexagonal/hooks.json +2 -2
  313. package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +1 -0
  314. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +2 -1
  315. package/presets/cursor/php-hexagonal/rules/preset-pr-checklist.mdc +4 -4
  316. package/presets/cursor/php-hexagonal/rules/preset-twin-sync.mdc +1 -1
  317. package/presets/cursor/php-hexagonal/team/README.md +5 -0
  318. package/presets/cursor/php-laravel/hooks/README.md +2 -1
  319. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +57 -3
  320. package/presets/cursor/php-laravel/hooks/check-preset-update.mjs +4 -3
  321. package/presets/cursor/php-laravel/hooks/examples/README.md +1 -1
  322. package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +96 -0
  323. package/presets/cursor/php-laravel/hooks/run-hook.mjs +102 -0
  324. package/presets/cursor/php-laravel/hooks.json +2 -2
  325. package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +1 -0
  326. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +2 -1
  327. package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +4 -4
  328. package/presets/cursor/php-laravel/rules/preset-twin-sync.mdc +1 -1
  329. package/presets/cursor/php-laravel/team/README.md +5 -0
  330. package/presets/cursor/svelte/hooks/README.md +2 -1
  331. package/presets/cursor/svelte/hooks/chain-team-phases.sh +57 -3
  332. package/presets/cursor/svelte/hooks/check-preset-update.mjs +4 -3
  333. package/presets/cursor/svelte/hooks/examples/README.md +1 -1
  334. package/presets/cursor/svelte/hooks/guard-shell-command.mjs +94 -0
  335. package/presets/cursor/svelte/hooks/run-hook.mjs +102 -0
  336. package/presets/cursor/svelte/hooks.json +2 -2
  337. package/presets/cursor/svelte/rules/agent-team-intake.mdc +1 -0
  338. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +2 -1
  339. package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +4 -4
  340. package/presets/cursor/svelte/rules/preset-twin-sync.mdc +1 -1
  341. package/presets/cursor/svelte/team/README.md +5 -0
  342. package/presets/mavis/android-kotlin/adapter-map.json +11 -3
  343. package/presets/mavis/android-kotlin/hooks/README.md +2 -1
  344. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +57 -3
  345. package/presets/mavis/android-kotlin/hooks/check-preset-update.mjs +4 -3
  346. package/presets/mavis/android-kotlin/rules/agent-team-intake.md +1 -0
  347. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +5 -2
  348. package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +4 -4
  349. package/presets/mavis/android-kotlin/rules/preset-twin-sync.md +1 -1
  350. package/presets/mavis/android-kotlin/team/README.md +5 -0
  351. package/presets/mavis/go/adapter-map.json +11 -3
  352. package/presets/mavis/go/hooks/README.md +2 -1
  353. package/presets/mavis/go/hooks/chain-team-phases.sh +57 -3
  354. package/presets/mavis/go/hooks/check-preset-update.mjs +4 -3
  355. package/presets/mavis/go/rules/agent-team-intake.md +1 -0
  356. package/presets/mavis/go/rules/agent-team-orchestrator.md +5 -2
  357. package/presets/mavis/go/rules/preset-pr-checklist.md +4 -4
  358. package/presets/mavis/go/rules/preset-twin-sync.md +1 -1
  359. package/presets/mavis/go/team/README.md +5 -0
  360. package/presets/mavis/ios-swift/adapter-map.json +11 -3
  361. package/presets/mavis/ios-swift/hooks/README.md +2 -1
  362. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +57 -3
  363. package/presets/mavis/ios-swift/hooks/check-preset-update.mjs +4 -3
  364. package/presets/mavis/ios-swift/rules/agent-team-intake.md +1 -0
  365. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +5 -2
  366. package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +4 -4
  367. package/presets/mavis/ios-swift/rules/preset-twin-sync.md +1 -1
  368. package/presets/mavis/ios-swift/team/README.md +5 -0
  369. package/presets/mavis/java/adapter-map.json +11 -3
  370. package/presets/mavis/java/hooks/README.md +2 -1
  371. package/presets/mavis/java/hooks/chain-team-phases.sh +57 -3
  372. package/presets/mavis/java/hooks/check-preset-update.mjs +4 -3
  373. package/presets/mavis/java/rules/agent-team-intake.md +1 -0
  374. package/presets/mavis/java/rules/agent-team-orchestrator.md +5 -2
  375. package/presets/mavis/java/rules/preset-pr-checklist.md +4 -4
  376. package/presets/mavis/java/rules/preset-twin-sync.md +1 -1
  377. package/presets/mavis/java/team/README.md +5 -0
  378. package/presets/mavis/mcp-ts/adapter-map.json +11 -3
  379. package/presets/mavis/mcp-ts/hooks/README.md +2 -1
  380. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +57 -3
  381. package/presets/mavis/mcp-ts/hooks/check-preset-update.mjs +4 -3
  382. package/presets/mavis/mcp-ts/rules/agent-team-intake.md +1 -0
  383. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +5 -2
  384. package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +4 -4
  385. package/presets/mavis/mcp-ts/rules/preset-twin-sync.md +1 -1
  386. package/presets/mavis/mcp-ts/team/README.md +5 -0
  387. package/presets/mavis/mol/adapter-map.json +11 -3
  388. package/presets/mavis/mol/hooks/README.md +2 -1
  389. package/presets/mavis/mol/hooks/chain-team-phases.sh +57 -3
  390. package/presets/mavis/mol/hooks/check-preset-update.mjs +4 -3
  391. package/presets/mavis/mol/rules/agent-team-intake.md +1 -0
  392. package/presets/mavis/mol/rules/agent-team-orchestrator.md +5 -2
  393. package/presets/mavis/mol/rules/preset-pr-checklist.md +4 -4
  394. package/presets/mavis/mol/rules/preset-twin-sync.md +1 -1
  395. package/presets/mavis/mol/team/README.md +5 -0
  396. package/presets/mavis/next/adapter-map.json +67 -3
  397. package/presets/mavis/next/agents/build-verifier.md +18 -3
  398. package/presets/mavis/next/agents/code-reviewer.md +2 -0
  399. package/presets/mavis/next/agents/feature-developer.md +3 -1
  400. package/presets/mavis/next/agents/task-analyst.md +6 -0
  401. package/presets/mavis/next/agents/task-router.md +5 -3
  402. package/presets/mavis/next/commands/README.md +1 -0
  403. package/presets/mavis/next/commands/task-continue.md +1 -1
  404. package/presets/mavis/next/commands/upstream-research.md +18 -0
  405. package/presets/mavis/next/hooks/README.md +2 -1
  406. package/presets/mavis/next/hooks/chain-team-phases.sh +57 -3
  407. package/presets/mavis/next/hooks/check-preset-update.mjs +4 -3
  408. package/presets/mavis/next/rules/agent-team-intake.md +1 -0
  409. package/presets/mavis/next/rules/agent-team-orchestrator.md +5 -2
  410. package/presets/mavis/next/rules/preset-pr-checklist.md +4 -4
  411. package/presets/mavis/next/rules/preset-twin-sync.md +1 -1
  412. package/presets/mavis/next/team/README.md +23 -0
  413. package/presets/mavis/next/team/upstream/config.json +31 -0
  414. package/presets/mavis/next/team/upstream/digest-template.md +55 -0
  415. package/presets/mavis/next/team/upstream/opencode.json +34 -0
  416. package/presets/mavis/next/team/upstream/projects.json +4 -0
  417. package/presets/mavis/next/team/upstream/prompt.md +77 -0
  418. package/presets/mavis/next/team/upstream/signatures.json +9 -0
  419. package/presets/mavis/nuxt/adapter-map.json +11 -3
  420. package/presets/mavis/nuxt/hooks/README.md +2 -1
  421. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +57 -3
  422. package/presets/mavis/nuxt/hooks/check-preset-update.mjs +4 -3
  423. package/presets/mavis/nuxt/rules/agent-team-intake.md +1 -0
  424. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +5 -2
  425. package/presets/mavis/nuxt/rules/preset-pr-checklist.md +4 -4
  426. package/presets/mavis/nuxt/rules/preset-twin-sync.md +1 -1
  427. package/presets/mavis/nuxt/team/README.md +5 -0
  428. package/presets/mavis/php-hexagonal/adapter-map.json +11 -3
  429. package/presets/mavis/php-hexagonal/hooks/README.md +2 -1
  430. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +57 -3
  431. package/presets/mavis/php-hexagonal/hooks/check-preset-update.mjs +4 -3
  432. package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +1 -0
  433. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +5 -2
  434. package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +4 -4
  435. package/presets/mavis/php-hexagonal/rules/preset-twin-sync.md +1 -1
  436. package/presets/mavis/php-hexagonal/team/README.md +5 -0
  437. package/presets/mavis/php-laravel/adapter-map.json +11 -3
  438. package/presets/mavis/php-laravel/hooks/README.md +2 -1
  439. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +57 -3
  440. package/presets/mavis/php-laravel/hooks/check-preset-update.mjs +4 -3
  441. package/presets/mavis/php-laravel/rules/agent-team-intake.md +1 -0
  442. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +5 -2
  443. package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +4 -4
  444. package/presets/mavis/php-laravel/rules/preset-twin-sync.md +1 -1
  445. package/presets/mavis/php-laravel/team/README.md +5 -0
  446. package/presets/mavis/svelte/adapter-map.json +11 -3
  447. package/presets/mavis/svelte/hooks/README.md +2 -1
  448. package/presets/mavis/svelte/hooks/chain-team-phases.sh +57 -3
  449. package/presets/mavis/svelte/hooks/check-preset-update.mjs +4 -3
  450. package/presets/mavis/svelte/rules/agent-team-intake.md +1 -0
  451. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +5 -2
  452. package/presets/mavis/svelte/rules/preset-pr-checklist.md +4 -4
  453. package/presets/mavis/svelte/rules/preset-twin-sync.md +1 -1
  454. package/presets/mavis/svelte/team/README.md +5 -0
  455. package/presets/opencode/android-kotlin/OPENCODE.md +1 -1
  456. package/presets/opencode/android-kotlin/README.md +1 -1
  457. package/presets/opencode/android-kotlin/adapter-map.json +11 -3
  458. package/presets/opencode/android-kotlin/hooks/README.md +3 -2
  459. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +57 -3
  460. package/presets/opencode/android-kotlin/hooks/check-preset-update.mjs +4 -3
  461. package/presets/opencode/android-kotlin/rules/agent-team-intake.md +1 -0
  462. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +5 -2
  463. package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +4 -4
  464. package/presets/opencode/android-kotlin/rules/preset-twin-sync.md +1 -1
  465. package/presets/opencode/android-kotlin/team/README.md +5 -0
  466. package/presets/opencode/go/OPENCODE.md +1 -1
  467. package/presets/opencode/go/README.md +1 -1
  468. package/presets/opencode/go/adapter-map.json +11 -3
  469. package/presets/opencode/go/hooks/README.md +3 -2
  470. package/presets/opencode/go/hooks/chain-team-phases.sh +57 -3
  471. package/presets/opencode/go/hooks/check-preset-update.mjs +4 -3
  472. package/presets/opencode/go/rules/agent-team-intake.md +1 -0
  473. package/presets/opencode/go/rules/agent-team-orchestrator.md +5 -2
  474. package/presets/opencode/go/rules/preset-pr-checklist.md +4 -4
  475. package/presets/opencode/go/rules/preset-twin-sync.md +1 -1
  476. package/presets/opencode/go/team/README.md +5 -0
  477. package/presets/opencode/ios-swift/OPENCODE.md +1 -1
  478. package/presets/opencode/ios-swift/README.md +1 -1
  479. package/presets/opencode/ios-swift/adapter-map.json +11 -3
  480. package/presets/opencode/ios-swift/hooks/README.md +3 -2
  481. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +57 -3
  482. package/presets/opencode/ios-swift/hooks/check-preset-update.mjs +4 -3
  483. package/presets/opencode/ios-swift/rules/agent-team-intake.md +1 -0
  484. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +5 -2
  485. package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +4 -4
  486. package/presets/opencode/ios-swift/rules/preset-twin-sync.md +1 -1
  487. package/presets/opencode/ios-swift/team/README.md +5 -0
  488. package/presets/opencode/java/OPENCODE.md +1 -1
  489. package/presets/opencode/java/README.md +1 -1
  490. package/presets/opencode/java/adapter-map.json +11 -3
  491. package/presets/opencode/java/hooks/README.md +3 -2
  492. package/presets/opencode/java/hooks/chain-team-phases.sh +57 -3
  493. package/presets/opencode/java/hooks/check-preset-update.mjs +4 -3
  494. package/presets/opencode/java/rules/agent-team-intake.md +1 -0
  495. package/presets/opencode/java/rules/agent-team-orchestrator.md +5 -2
  496. package/presets/opencode/java/rules/preset-pr-checklist.md +4 -4
  497. package/presets/opencode/java/rules/preset-twin-sync.md +1 -1
  498. package/presets/opencode/java/team/README.md +5 -0
  499. package/presets/opencode/mcp-ts/OPENCODE.md +1 -1
  500. package/presets/opencode/mcp-ts/README.md +1 -1
  501. package/presets/opencode/mcp-ts/adapter-map.json +11 -3
  502. package/presets/opencode/mcp-ts/hooks/README.md +3 -2
  503. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +57 -3
  504. package/presets/opencode/mcp-ts/hooks/check-preset-update.mjs +4 -3
  505. package/presets/opencode/mcp-ts/rules/agent-team-intake.md +1 -0
  506. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +5 -2
  507. package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +4 -4
  508. package/presets/opencode/mcp-ts/rules/preset-twin-sync.md +1 -1
  509. package/presets/opencode/mcp-ts/team/README.md +5 -0
  510. package/presets/opencode/mol/OPENCODE.md +1 -1
  511. package/presets/opencode/mol/README.md +1 -1
  512. package/presets/opencode/mol/adapter-map.json +11 -3
  513. package/presets/opencode/mol/hooks/README.md +3 -2
  514. package/presets/opencode/mol/hooks/chain-team-phases.sh +57 -3
  515. package/presets/opencode/mol/hooks/check-preset-update.mjs +4 -3
  516. package/presets/opencode/mol/rules/agent-team-intake.md +1 -0
  517. package/presets/opencode/mol/rules/agent-team-orchestrator.md +5 -2
  518. package/presets/opencode/mol/rules/preset-pr-checklist.md +4 -4
  519. package/presets/opencode/mol/rules/preset-twin-sync.md +1 -1
  520. package/presets/opencode/mol/team/README.md +5 -0
  521. package/presets/opencode/next/OPENCODE.md +1 -1
  522. package/presets/opencode/next/README.md +1 -1
  523. package/presets/opencode/next/adapter-map.json +67 -3
  524. package/presets/opencode/next/agents/build-verifier.md +18 -3
  525. package/presets/opencode/next/agents/code-reviewer.md +2 -0
  526. package/presets/opencode/next/agents/feature-developer.md +3 -1
  527. package/presets/opencode/next/agents/task-analyst.md +6 -0
  528. package/presets/opencode/next/agents/task-router.md +5 -3
  529. package/presets/opencode/next/commands/README.md +1 -0
  530. package/presets/opencode/next/commands/task-continue.md +1 -1
  531. package/presets/opencode/next/commands/upstream-research.md +26 -0
  532. package/presets/opencode/next/hooks/README.md +3 -2
  533. package/presets/opencode/next/hooks/chain-team-phases.sh +57 -3
  534. package/presets/opencode/next/hooks/check-preset-update.mjs +4 -3
  535. package/presets/opencode/next/rules/agent-team-intake.md +1 -0
  536. package/presets/opencode/next/rules/agent-team-orchestrator.md +5 -2
  537. package/presets/opencode/next/rules/preset-pr-checklist.md +4 -4
  538. package/presets/opencode/next/rules/preset-twin-sync.md +1 -1
  539. package/presets/opencode/next/team/README.md +23 -0
  540. package/presets/opencode/next/team/upstream/config.json +31 -0
  541. package/presets/opencode/next/team/upstream/digest-template.md +55 -0
  542. package/presets/opencode/next/team/upstream/opencode.json +34 -0
  543. package/presets/opencode/next/team/upstream/projects.json +4 -0
  544. package/presets/opencode/next/team/upstream/prompt.md +77 -0
  545. package/presets/opencode/next/team/upstream/signatures.json +9 -0
  546. package/presets/opencode/nuxt/OPENCODE.md +1 -1
  547. package/presets/opencode/nuxt/README.md +1 -1
  548. package/presets/opencode/nuxt/adapter-map.json +11 -3
  549. package/presets/opencode/nuxt/hooks/README.md +3 -2
  550. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +57 -3
  551. package/presets/opencode/nuxt/hooks/check-preset-update.mjs +4 -3
  552. package/presets/opencode/nuxt/rules/agent-team-intake.md +1 -0
  553. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +5 -2
  554. package/presets/opencode/nuxt/rules/preset-pr-checklist.md +4 -4
  555. package/presets/opencode/nuxt/rules/preset-twin-sync.md +1 -1
  556. package/presets/opencode/nuxt/team/README.md +5 -0
  557. package/presets/opencode/php-hexagonal/OPENCODE.md +1 -1
  558. package/presets/opencode/php-hexagonal/README.md +1 -1
  559. package/presets/opencode/php-hexagonal/adapter-map.json +11 -3
  560. package/presets/opencode/php-hexagonal/hooks/README.md +3 -2
  561. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +57 -3
  562. package/presets/opencode/php-hexagonal/hooks/check-preset-update.mjs +4 -3
  563. package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +1 -0
  564. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +5 -2
  565. package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +4 -4
  566. package/presets/opencode/php-hexagonal/rules/preset-twin-sync.md +1 -1
  567. package/presets/opencode/php-hexagonal/team/README.md +5 -0
  568. package/presets/opencode/php-laravel/OPENCODE.md +1 -1
  569. package/presets/opencode/php-laravel/README.md +1 -1
  570. package/presets/opencode/php-laravel/adapter-map.json +11 -3
  571. package/presets/opencode/php-laravel/hooks/README.md +3 -2
  572. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +57 -3
  573. package/presets/opencode/php-laravel/hooks/check-preset-update.mjs +4 -3
  574. package/presets/opencode/php-laravel/rules/agent-team-intake.md +1 -0
  575. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +5 -2
  576. package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +4 -4
  577. package/presets/opencode/php-laravel/rules/preset-twin-sync.md +1 -1
  578. package/presets/opencode/php-laravel/team/README.md +5 -0
  579. package/presets/opencode/svelte/OPENCODE.md +1 -1
  580. package/presets/opencode/svelte/README.md +1 -1
  581. package/presets/opencode/svelte/adapter-map.json +11 -3
  582. package/presets/opencode/svelte/hooks/README.md +3 -2
  583. package/presets/opencode/svelte/hooks/chain-team-phases.sh +57 -3
  584. package/presets/opencode/svelte/hooks/check-preset-update.mjs +4 -3
  585. package/presets/opencode/svelte/rules/agent-team-intake.md +1 -0
  586. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +5 -2
  587. package/presets/opencode/svelte/rules/preset-pr-checklist.md +4 -4
  588. package/presets/opencode/svelte/rules/preset-twin-sync.md +1 -1
  589. package/presets/opencode/svelte/team/README.md +5 -0
  590. package/presets/zcode/android-kotlin/adapter-map.json +11 -3
  591. package/presets/zcode/android-kotlin/hooks/README.md +2 -1
  592. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +57 -3
  593. package/presets/zcode/android-kotlin/hooks/check-preset-update.mjs +4 -3
  594. package/presets/zcode/android-kotlin/rules/agent-team-intake.md +1 -0
  595. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +5 -2
  596. package/presets/zcode/android-kotlin/rules/preset-pr-checklist.md +4 -4
  597. package/presets/zcode/android-kotlin/rules/preset-twin-sync.md +1 -1
  598. package/presets/zcode/android-kotlin/team/README.md +5 -0
  599. package/presets/zcode/go/adapter-map.json +11 -3
  600. package/presets/zcode/go/hooks/README.md +2 -1
  601. package/presets/zcode/go/hooks/chain-team-phases.sh +57 -3
  602. package/presets/zcode/go/hooks/check-preset-update.mjs +4 -3
  603. package/presets/zcode/go/rules/agent-team-intake.md +1 -0
  604. package/presets/zcode/go/rules/agent-team-orchestrator.md +5 -2
  605. package/presets/zcode/go/rules/preset-pr-checklist.md +4 -4
  606. package/presets/zcode/go/rules/preset-twin-sync.md +1 -1
  607. package/presets/zcode/go/team/README.md +5 -0
  608. package/presets/zcode/ios-swift/adapter-map.json +11 -3
  609. package/presets/zcode/ios-swift/hooks/README.md +2 -1
  610. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +57 -3
  611. package/presets/zcode/ios-swift/hooks/check-preset-update.mjs +4 -3
  612. package/presets/zcode/ios-swift/rules/agent-team-intake.md +1 -0
  613. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +5 -2
  614. package/presets/zcode/ios-swift/rules/preset-pr-checklist.md +4 -4
  615. package/presets/zcode/ios-swift/rules/preset-twin-sync.md +1 -1
  616. package/presets/zcode/ios-swift/team/README.md +5 -0
  617. package/presets/zcode/java/adapter-map.json +11 -3
  618. package/presets/zcode/java/hooks/README.md +2 -1
  619. package/presets/zcode/java/hooks/chain-team-phases.sh +57 -3
  620. package/presets/zcode/java/hooks/check-preset-update.mjs +4 -3
  621. package/presets/zcode/java/rules/agent-team-intake.md +1 -0
  622. package/presets/zcode/java/rules/agent-team-orchestrator.md +5 -2
  623. package/presets/zcode/java/rules/preset-pr-checklist.md +4 -4
  624. package/presets/zcode/java/rules/preset-twin-sync.md +1 -1
  625. package/presets/zcode/java/team/README.md +5 -0
  626. package/presets/zcode/mcp-ts/adapter-map.json +11 -3
  627. package/presets/zcode/mcp-ts/hooks/README.md +2 -1
  628. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +57 -3
  629. package/presets/zcode/mcp-ts/hooks/check-preset-update.mjs +4 -3
  630. package/presets/zcode/mcp-ts/rules/agent-team-intake.md +1 -0
  631. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +5 -2
  632. package/presets/zcode/mcp-ts/rules/preset-pr-checklist.md +4 -4
  633. package/presets/zcode/mcp-ts/rules/preset-twin-sync.md +1 -1
  634. package/presets/zcode/mcp-ts/team/README.md +5 -0
  635. package/presets/zcode/mol/adapter-map.json +11 -3
  636. package/presets/zcode/mol/hooks/README.md +2 -1
  637. package/presets/zcode/mol/hooks/chain-team-phases.sh +57 -3
  638. package/presets/zcode/mol/hooks/check-preset-update.mjs +4 -3
  639. package/presets/zcode/mol/rules/agent-team-intake.md +1 -0
  640. package/presets/zcode/mol/rules/agent-team-orchestrator.md +5 -2
  641. package/presets/zcode/mol/rules/preset-pr-checklist.md +4 -4
  642. package/presets/zcode/mol/rules/preset-twin-sync.md +1 -1
  643. package/presets/zcode/mol/team/README.md +5 -0
  644. package/presets/zcode/next/adapter-map.json +67 -3
  645. package/presets/zcode/next/agents/build-verifier.md +18 -3
  646. package/presets/zcode/next/agents/code-reviewer.md +2 -0
  647. package/presets/zcode/next/agents/feature-developer.md +3 -1
  648. package/presets/zcode/next/agents/task-analyst.md +6 -0
  649. package/presets/zcode/next/agents/task-router.md +5 -3
  650. package/presets/zcode/next/commands/README.md +1 -0
  651. package/presets/zcode/next/commands/task-continue.md +1 -1
  652. package/presets/zcode/next/commands/upstream-research.md +26 -0
  653. package/presets/zcode/next/hooks/README.md +2 -1
  654. package/presets/zcode/next/hooks/chain-team-phases.sh +57 -3
  655. package/presets/zcode/next/hooks/check-preset-update.mjs +4 -3
  656. package/presets/zcode/next/rules/agent-team-intake.md +1 -0
  657. package/presets/zcode/next/rules/agent-team-orchestrator.md +5 -2
  658. package/presets/zcode/next/rules/preset-pr-checklist.md +4 -4
  659. package/presets/zcode/next/rules/preset-twin-sync.md +1 -1
  660. package/presets/zcode/next/team/README.md +23 -0
  661. package/presets/zcode/next/team/upstream/config.json +31 -0
  662. package/presets/zcode/next/team/upstream/digest-template.md +55 -0
  663. package/presets/zcode/next/team/upstream/opencode.json +34 -0
  664. package/presets/zcode/next/team/upstream/projects.json +4 -0
  665. package/presets/zcode/next/team/upstream/prompt.md +77 -0
  666. package/presets/zcode/next/team/upstream/signatures.json +9 -0
  667. package/presets/zcode/nuxt/adapter-map.json +11 -3
  668. package/presets/zcode/nuxt/hooks/README.md +2 -1
  669. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +57 -3
  670. package/presets/zcode/nuxt/hooks/check-preset-update.mjs +4 -3
  671. package/presets/zcode/nuxt/rules/agent-team-intake.md +1 -0
  672. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +5 -2
  673. package/presets/zcode/nuxt/rules/preset-pr-checklist.md +4 -4
  674. package/presets/zcode/nuxt/rules/preset-twin-sync.md +1 -1
  675. package/presets/zcode/nuxt/team/README.md +5 -0
  676. package/presets/zcode/php-hexagonal/adapter-map.json +11 -3
  677. package/presets/zcode/php-hexagonal/hooks/README.md +2 -1
  678. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +57 -3
  679. package/presets/zcode/php-hexagonal/hooks/check-preset-update.mjs +4 -3
  680. package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +1 -0
  681. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +5 -2
  682. package/presets/zcode/php-hexagonal/rules/preset-pr-checklist.md +4 -4
  683. package/presets/zcode/php-hexagonal/rules/preset-twin-sync.md +1 -1
  684. package/presets/zcode/php-hexagonal/team/README.md +5 -0
  685. package/presets/zcode/php-laravel/adapter-map.json +11 -3
  686. package/presets/zcode/php-laravel/hooks/README.md +2 -1
  687. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +57 -3
  688. package/presets/zcode/php-laravel/hooks/check-preset-update.mjs +4 -3
  689. package/presets/zcode/php-laravel/rules/agent-team-intake.md +1 -0
  690. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +5 -2
  691. package/presets/zcode/php-laravel/rules/preset-pr-checklist.md +4 -4
  692. package/presets/zcode/php-laravel/rules/preset-twin-sync.md +1 -1
  693. package/presets/zcode/php-laravel/team/README.md +5 -0
  694. package/presets/zcode/svelte/adapter-map.json +11 -3
  695. package/presets/zcode/svelte/hooks/README.md +2 -1
  696. package/presets/zcode/svelte/hooks/chain-team-phases.sh +57 -3
  697. package/presets/zcode/svelte/hooks/check-preset-update.mjs +4 -3
  698. package/presets/zcode/svelte/rules/agent-team-intake.md +1 -0
  699. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +5 -2
  700. package/presets/zcode/svelte/rules/preset-pr-checklist.md +4 -4
  701. package/presets/zcode/svelte/rules/preset-twin-sync.md +1 -1
  702. package/presets/zcode/svelte/team/README.md +5 -0
  703. package/presets/claude/android-kotlin/hooks/guard-shell-command.sh +0 -103
  704. package/presets/claude/go/hooks/guard-shell-command.sh +0 -102
  705. package/presets/claude/mcp-ts/hooks/guard-shell-command.sh +0 -102
  706. package/presets/claude/php-hexagonal/hooks/guard-shell-command.sh +0 -103
  707. package/presets/claude/php-laravel/hooks/guard-shell-command.sh +0 -103
  708. package/presets/cursor/android-kotlin/hooks/guard-shell-command.sh +0 -80
  709. package/presets/cursor/go/hooks/guard-shell-command.sh +0 -79
  710. package/presets/cursor/ios-swift/hooks/guard-shell-command.sh +0 -79
  711. package/presets/cursor/java/hooks/guard-shell-command.sh +0 -80
  712. package/presets/cursor/mcp-ts/hooks/guard-shell-command.sh +0 -79
  713. package/presets/cursor/mol/hooks/guard-shell-command.sh +0 -77
  714. package/presets/cursor/next/hooks/guard-shell-command.sh +0 -77
  715. package/presets/cursor/nuxt/hooks/guard-shell-command.sh +0 -77
  716. package/presets/cursor/php-hexagonal/hooks/guard-shell-command.sh +0 -80
  717. package/presets/cursor/php-laravel/hooks/guard-shell-command.sh +0 -80
  718. package/presets/cursor/svelte/hooks/guard-shell-command.sh +0 -77
@@ -3,10 +3,11 @@
3
3
  *
4
4
  * `node:http` only. The surface is loopback-only by default, sends no CORS
5
5
  * header, and reads files through SQLite rows (never through a request path).
6
- * The two mutating operations — the idempotent rescan and the confirmed task
7
- * delete — each run one bounded child process; the server itself never opens a
8
- * writable connection and the kill switch stops both mutations before a child
9
- * is spawned.
6
+ * The six mutating operations — the idempotent rescan, the confirmed task
7
+ * delete, and the four job writes (create, update, delete, run-now) — each run
8
+ * one bounded child process; the server itself never opens a writable
9
+ * connection and the kill switch stops every mutation before a child is
10
+ * spawned.
10
11
  *
11
12
  * Every SQL statement in this module is a static string with bound parameters.
12
13
  * The only interpolated fragments are the module-level constants `TASK_FILTER`,
@@ -17,7 +18,7 @@
17
18
  import fs from 'node:fs';
18
19
  import http from 'node:http';
19
20
  import path from 'node:path';
20
- import { spawnSync } from 'node:child_process';
21
+ import { spawn } from 'node:child_process';
21
22
  import { fileURLToPath } from 'node:url';
22
23
 
23
24
  import {
@@ -44,6 +45,21 @@ import {
44
45
  serializeOpenApiDocument,
45
46
  } from './team-db-openapi.mjs';
46
47
  import { DASHBOARD_CSS, DASHBOARD_HTML, DASHBOARD_JS } from './team-db-dashboard.mjs';
48
+ import {
49
+ DEFAULT_LOG_LIMIT,
50
+ JOB_ID_RE,
51
+ MAX_JOBS,
52
+ MAX_LOG_LIMIT,
53
+ MIN_LOG_LIMIT,
54
+ RUN_ID_RE,
55
+ RUN_STATES,
56
+ TERMINAL_RUN_STATES,
57
+ jobDueInstants,
58
+ nextFireAt,
59
+ readLease,
60
+ readLogChunk,
61
+ readStateFile,
62
+ } from './team-db-scheduler.mjs';
47
63
 
48
64
  export const DEFAULT_HOST = '127.0.0.1';
49
65
  export const DEFAULT_PORT = 4178;
@@ -56,6 +72,11 @@ export const MAX_REQUEST_BODY_BYTES = 1024;
56
72
  export const MAX_EXPORT_BYTES = 5 * 1024 * 1024;
57
73
  export const SYNC_CHILD_TIMEOUT_MS = 30000;
58
74
  export const SYNC_CHILD_DEADLINE_MS = 25000;
75
+ export const JOB_BODY_MAX = 65536;
76
+ export const JOB_WRITE_CHILD_TIMEOUT_MS = 10000;
77
+ export const JOB_DELETE_CHILD_TIMEOUT_MS = 30000;
78
+ export const JOB_RUN_CHILD_TIMEOUT_MS = 10000;
79
+ export const SCHEDULER_HINT = 'start team-db.mjs schedule';
59
80
  export const LOOPBACK_HOSTS = ['127.0.0.1', 'localhost', '::1'];
60
81
  const CLIENT_HEADERS = {
61
82
  'X-Content-Type-Options': 'nosniff',
@@ -87,6 +108,8 @@ const CODE_STATUS_ROWS = [
87
108
  ['E_DOC_BINARY', 410],
88
109
  ['E_DOC_CONTENT_OMITTED', 409],
89
110
  ['E_ACTIVE_TASK', 409],
111
+ ['E_CONFLICT', 409],
112
+ ['E_SCHEDULER_OFFLINE', 409],
90
113
  ['E_RANGE', 416],
91
114
  ['E_DISABLED', 503],
92
115
  ['E_DB_MISSING', 503],
@@ -271,6 +294,17 @@ const SQL = {
271
294
  listSyncRuns: `SELECT run_id, mode, started_at, finished_at, inserted, updated, unchanged, failed, absent, pruned, rebuilt, exit_code, error
272
295
  FROM sync_runs ORDER BY started_at DESC, run_id DESC LIMIT ?1 OFFSET ?2`,
273
296
  maxSyncRun: 'SELECT max(run_id) AS run_id FROM sync_runs',
297
+ listJobs: `SELECT * FROM scheduled_jobs WHERE absent_at IS NULL ORDER BY id ASC LIMIT ?1`,
298
+ getJob: 'SELECT * FROM scheduled_jobs WHERE id = ?1 AND absent_at IS NULL',
299
+ countJobRuns: `SELECT count(*) AS total FROM job_runs
300
+ WHERE job_id = ?1 AND (json_array_length(?2) = 0 OR state IN (SELECT value FROM json_each(?2)))`,
301
+ listJobRuns: `SELECT * FROM job_runs
302
+ WHERE job_id = ?1 AND (json_array_length(?2) = 0 OR state IN (SELECT value FROM json_each(?2)))
303
+ ORDER BY started_at DESC, run_id DESC LIMIT ?3 OFFSET ?4`,
304
+ getJobRun: 'SELECT * FROM job_runs WHERE job_id = ?1 AND run_id = ?2',
305
+ listJobRunEvents: 'SELECT seq, at, state, code, message FROM job_run_events WHERE run_id = ?1 ORDER BY seq ASC',
306
+ lastJobRun: `SELECT run_id, state, finished_at, duration_ms FROM job_runs
307
+ WHERE job_id = ?1 ORDER BY started_at DESC, run_id DESC LIMIT 1`,
274
308
  healthTotals: 'SELECT count(*) AS total, COALESCE(SUM(CASE WHEN absent_at IS NOT NULL THEN 1 ELSE 0 END), 0) AS absent, max(projected_at) AS projected_at FROM tasks',
275
309
  searchFts: `SELECT DISTINCT task_slug AS slug FROM search_fts WHERE search_fts MATCH ?1 LIMIT ?2`,
276
310
  searchLike: `SELECT DISTINCT task_slug AS slug FROM documents
@@ -892,6 +926,22 @@ const getHealth = (handle, settings) => {
892
926
  const connection = handle.db;
893
927
  const totals = connection.prepare(SQL.healthTotals).get();
894
928
  const stored = readSchemaMeta(connection, 'fingerprint');
929
+ // The scheduler signal comes from the lease file, never from SQL: a runtime
930
+ // that cannot schedule still answers, and its absence is discoverable.
931
+ const lease = readLease(settings.teamRoot);
932
+ const state = readStateFile(settings.teamRoot);
933
+ const now = Date.now();
934
+ const jobsDue = connection
935
+ .prepare(SQL.listJobs)
936
+ .all(MAX_JOBS)
937
+ .map(jobRowToDefinition)
938
+ .filter((job) => job.enabled)
939
+ .filter((job) => {
940
+ const recorded = state.lastFireAt?.[job.id];
941
+ const lastFireAt =
942
+ typeof recorded === 'string' && !Number.isNaN(Date.parse(recorded)) ? Date.parse(recorded) : null;
943
+ return jobDueInstants(job, lastFireAt, now, 1000).length > 0;
944
+ }).length;
895
945
  return {
896
946
  status: 'ok',
897
947
  db: {
@@ -903,7 +953,18 @@ const getHealth = (handle, settings) => {
903
953
  },
904
954
  tasks: { total: Number(totals.total), absent: Number(totals.absent) },
905
955
  projectedAt: totals.projected_at ?? null,
906
- capabilities: ['sync', 'delete'],
956
+ capabilities: ['sync', 'delete', 'jobs', 'schedule'],
957
+ scheduler: {
958
+ state: lease.state,
959
+ pid: lease.lease?.pid === undefined ? null : Number(lease.lease.pid),
960
+ startedAt: lease.lease?.startedAt ?? null,
961
+ heartbeatAt: lease.lease?.heartbeatAt ?? null,
962
+ nextTickAt:
963
+ lease.state === 'running' && lease.lease?.heartbeatAt
964
+ ? new Date(Date.parse(lease.lease.heartbeatAt) + 1000).toISOString()
965
+ : null,
966
+ jobsDue,
967
+ },
907
968
  };
908
969
  };
909
970
 
@@ -928,6 +989,353 @@ const getMeta = (handle) => {
928
989
  };
929
990
  };
930
991
 
992
+ /* ---------------------------------- jobs ---------------------------------- */
993
+
994
+ const JOBS_SORT = new Set(['id', '-id', 'updatedAt', '-updatedAt', 'nextFireAt', '-nextFireAt']);
995
+
996
+ /** One `scheduled_jobs` row back into the definition the file holds. */
997
+ const jobRowToDefinition = (row) => ({
998
+ id: String(row.id),
999
+ title: String(row.title),
1000
+ enabled: row.enabled === 1,
1001
+ // The response omits the key that belongs to the other `kind`, exactly like
1002
+ // `payload_json`: the write validator refuses a null sibling, so a
1003
+ // `JobDetail.job` can be sent straight back as a `PUT` body.
1004
+ schedule:
1005
+ row.schedule_kind === 'cron'
1006
+ ? { kind: 'cron', expression: row.cron, timezone: String(row.timezone) }
1007
+ : { kind: 'interval', everySeconds: Number(row.every_seconds), timezone: String(row.timezone) },
1008
+ payload: JSON.parse(row.payload_json),
1009
+ cwd: String(row.cwd),
1010
+ envPassthrough: JSON.parse(row.env_json),
1011
+ timeoutMs: Number(row.timeout_ms),
1012
+ concurrency: String(row.concurrency),
1013
+ misfire: String(row.misfire),
1014
+ createdAt: String(row.created_at),
1015
+ updatedAt: String(row.updated_at),
1016
+ revision: Number(row.revision),
1017
+ });
1018
+
1019
+ const runRowToJson = (row) => ({
1020
+ runId: String(row.run_id),
1021
+ jobId: String(row.job_id),
1022
+ trigger: String(row.trigger),
1023
+ state: String(row.state),
1024
+ reasonCode: row.reason_code ?? null,
1025
+ exitCode: row.exit_code === null ? null : Number(row.exit_code),
1026
+ signal: row.signal ?? null,
1027
+ pid: row.pid === null ? null : Number(row.pid),
1028
+ startedAt: String(row.started_at),
1029
+ finishedAt: row.finished_at ?? null,
1030
+ durationMs: row.duration_ms === null ? null : Number(row.duration_ms),
1031
+ stdoutBytes: Number(row.stdout_bytes ?? 0),
1032
+ stderrBytes: Number(row.stderr_bytes ?? 0),
1033
+ stdoutTruncated: row.stdout_truncated === 1,
1034
+ stderrTruncated: row.stderr_truncated === 1,
1035
+ parseError: row.parse_error ?? null,
1036
+ });
1037
+
1038
+ const jobDetail = (db, settings, row, now) => {
1039
+ const definition = jobRowToDefinition(row);
1040
+ const state = readStateFile(settings.teamRoot);
1041
+ const recorded = state.lastFireAt?.[definition.id];
1042
+ const lastFireAt = typeof recorded === 'string' && !Number.isNaN(Date.parse(recorded)) ? Date.parse(recorded) : null;
1043
+ const last = db.prepare(SQL.lastJobRun).get(definition.id);
1044
+ return {
1045
+ job: definition,
1046
+ nextFireAt: nextFireAt(definition, { now, lastFireAt }),
1047
+ lastRun: last
1048
+ ? {
1049
+ runId: String(last.run_id),
1050
+ state: String(last.state),
1051
+ finishedAt: last.finished_at ?? null,
1052
+ durationMs: last.duration_ms === null ? null : Number(last.duration_ms),
1053
+ }
1054
+ : null,
1055
+ };
1056
+ };
1057
+
1058
+ const requireJobRow = (db, id) => {
1059
+ const row = db.prepare(SQL.getJob).get(id);
1060
+ if (!row) fail('E_NOT_FOUND', 404, `no job "${id}"`);
1061
+ return row;
1062
+ };
1063
+
1064
+ const parseJobId = (value) => {
1065
+ if (typeof value !== 'string' || value.length > 64 || !JOB_ID_RE.test(value)) {
1066
+ fail('E_VALIDATION', 422, 'the job id has an invalid shape', { parameter: 'id' });
1067
+ }
1068
+ return value;
1069
+ };
1070
+
1071
+ const parseRunId = (value) => {
1072
+ if (typeof value !== 'string' || !RUN_ID_RE.test(value)) {
1073
+ fail('E_VALIDATION', 422, 'the run id has an invalid shape', { parameter: 'runId' });
1074
+ }
1075
+ return value;
1076
+ };
1077
+
1078
+ const listJobs = (db, settings, query) => {
1079
+ const limit = parseInteger(query.get('limit'), 'limit', { min: 1, max: MAX_LIMIT, fallback: DEFAULT_LIMIT });
1080
+ const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_OFFSET, fallback: 0 });
1081
+ const enabled = parseBoolean(query.get('enabled'), 'enabled', null);
1082
+ const sort = parseEnum(query.get('sort'), 'sort', JOBS_SORT, 'id');
1083
+ const now = Date.now();
1084
+ // At most MAX_JOBS definitions are read, so `sort=nextFireAt` is exact while
1085
+ // the SQL stays a plain ordered read by id.
1086
+ const rows = db.prepare(SQL.listJobs).all(MAX_JOBS);
1087
+ const items = rows
1088
+ .map((row) => jobDetail(db, settings, row, now))
1089
+ .filter((entry) => enabled === null || entry.job.enabled === enabled);
1090
+ const compare = {
1091
+ id: (left, right) => left.job.id.localeCompare(right.job.id),
1092
+ updatedAt: (left, right) => String(left.job.updatedAt).localeCompare(String(right.job.updatedAt)),
1093
+ nextFireAt: (left, right) => String(left.nextFireAt ?? '9999').localeCompare(String(right.nextFireAt ?? '9999')),
1094
+ }[sort.replace(/^-/, '')];
1095
+ const direction = sort.startsWith('-') ? -1 : 1;
1096
+ items.sort((left, right) => direction * compare(left, right));
1097
+ const total = items.length;
1098
+ return {
1099
+ items: items.slice(offset, offset + limit),
1100
+ total,
1101
+ limit,
1102
+ offset,
1103
+ nextOffset: offset + limit < total ? offset + limit : null,
1104
+ };
1105
+ };
1106
+
1107
+ const listJobRuns = (db, id, query) => {
1108
+ requireJobRow(db, id);
1109
+ const limit = parseInteger(query.get('limit'), 'limit', { min: 1, max: MAX_LIMIT, fallback: DEFAULT_LIMIT });
1110
+ const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_OFFSET, fallback: 0 });
1111
+ const states = parseCsv(query.get('state'), 'state', new Set(RUN_STATES));
1112
+ const total = Number(db.prepare(SQL.countJobRuns).get(id, JSON.stringify(states)).total);
1113
+ const rows = db.prepare(SQL.listJobRuns).all(id, JSON.stringify(states), limit, offset);
1114
+ return {
1115
+ items: rows.map(runRowToJson),
1116
+ total,
1117
+ limit,
1118
+ offset,
1119
+ nextOffset: offset + limit < total ? offset + limit : null,
1120
+ };
1121
+ };
1122
+
1123
+ const getJobRun = (db, id, runId) => {
1124
+ requireJobRow(db, id);
1125
+ const row = db.prepare(SQL.getJobRun).get(id, runId);
1126
+ if (!row) fail('E_NOT_FOUND', 404, `no run "${runId}" for job "${id}"`);
1127
+ const events = db
1128
+ .prepare(SQL.listJobRunEvents)
1129
+ .all(runId)
1130
+ .map((event) => ({
1131
+ seq: Number(event.seq),
1132
+ at: String(event.at),
1133
+ state: String(event.state),
1134
+ code: event.code ?? null,
1135
+ message: event.message ?? null,
1136
+ }));
1137
+ return {
1138
+ run: runRowToJson(row),
1139
+ events,
1140
+ child: {
1141
+ pid: row.pid === null ? null : Number(row.pid),
1142
+ exitCode: row.exit_code === null ? null : Number(row.exit_code),
1143
+ signal: row.signal ?? null,
1144
+ timedOut: String(row.state) === 'timeout',
1145
+ },
1146
+ logs: {
1147
+ stdout: {
1148
+ bytes: Number(row.stdout_bytes ?? 0),
1149
+ sha256: row.stdout_sha256 ?? null,
1150
+ truncated: row.stdout_truncated === 1,
1151
+ },
1152
+ stderr: {
1153
+ bytes: Number(row.stderr_bytes ?? 0),
1154
+ sha256: row.stderr_sha256 ?? null,
1155
+ truncated: row.stderr_truncated === 1,
1156
+ },
1157
+ },
1158
+ };
1159
+ };
1160
+
1161
+ const getJobRunLog = (db, settings, id, runId, query) => {
1162
+ requireJobRow(db, id);
1163
+ const row = db.prepare(SQL.getJobRun).get(id, runId);
1164
+ if (!row) fail('E_NOT_FOUND', 404, `no run "${runId}" for job "${id}"`);
1165
+ const stream = query.get('stream');
1166
+ if (stream !== null && stream !== 'stdout' && stream !== 'stderr') {
1167
+ fail('E_VALIDATION', 422, 'stream must be stdout or stderr', { parameter: 'stream' });
1168
+ }
1169
+ const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_DOC_LIMIT, fallback: 0 });
1170
+ const limit = parseInteger(query.get('limit'), 'limit', {
1171
+ min: MIN_LOG_LIMIT,
1172
+ max: MAX_LOG_LIMIT,
1173
+ fallback: DEFAULT_LOG_LIMIT,
1174
+ });
1175
+ return readLogChunk(settings.teamRoot, row, { stream: stream ?? 'stdout', offset, limit });
1176
+ };
1177
+
1178
+ /* ----------------------------- write children ----------------------------- */
1179
+
1180
+ const runTeamDbChild = (args, options) =>
1181
+ new Promise((resolve, reject) => {
1182
+ if (isKillSwitchSet()) fail('E_DISABLED', 503, 'the projection is disabled by AI_RULES_TEAM_DB_DISABLE');
1183
+ const script = path.join(moduleDirectory, 'team-db.mjs');
1184
+ if (!fs.existsSync(script)) fail('E_DB_MISSING', 503, 'team-db.mjs is not installed next to the server');
1185
+ const { settings, timeoutMs, input, label } = options;
1186
+ let child;
1187
+ try {
1188
+ child = spawn(
1189
+ process.execPath,
1190
+ [script, ...args, '--json', '--root', settings.teamRoot],
1191
+ {
1192
+ cwd: settings.cwd,
1193
+ env: { ...process.env, AI_RULES_TEAM_DB_PATH: settings.dbPath },
1194
+ stdio: ['pipe', 'pipe', 'pipe'],
1195
+ },
1196
+ );
1197
+ } catch {
1198
+ fail('E_INTERNAL', 500, `the ${label} child could not start`);
1199
+ }
1200
+ let stdout = '';
1201
+ let stderr = '';
1202
+ let timedOut = false;
1203
+ let settled = false;
1204
+ const timer = setTimeout(() => {
1205
+ timedOut = true;
1206
+ try {
1207
+ child.kill('SIGKILL');
1208
+ } catch {
1209
+ /* the child may have exited between the timer and the signal */
1210
+ }
1211
+ }, timeoutMs);
1212
+ const settle = (fn, value) => {
1213
+ if (settled) return;
1214
+ settled = true;
1215
+ clearTimeout(timer);
1216
+ fn(value);
1217
+ };
1218
+ child.stdout.on('data', (chunk) => {
1219
+ stdout += chunk;
1220
+ });
1221
+ child.stderr.on('data', (chunk) => {
1222
+ stderr += chunk;
1223
+ });
1224
+ child.on('error', () => {
1225
+ settle(reject, new ApiError('E_INTERNAL', 500, `the ${label} child could not start`));
1226
+ });
1227
+ child.on('close', (code) => {
1228
+ if (timedOut) {
1229
+ settle(reject, new ApiError('E_BUSY', 503, `the ${label} exceeded ${Math.round(timeoutMs / 1000)} s and was killed`));
1230
+ return;
1231
+ }
1232
+ let parsed = null;
1233
+ try {
1234
+ parsed = JSON.parse(String(stdout || '').trim());
1235
+ } catch {
1236
+ parsed = null;
1237
+ }
1238
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
1239
+ // One `path: reason` line, never prompt content, so an operator can act.
1240
+ const detail = String(stderr || '')
1241
+ .split('\n')
1242
+ .map((line) => line.trim())
1243
+ .find((line) => line.length > 0);
1244
+ settle(
1245
+ reject,
1246
+ new ApiError(
1247
+ 'E_INTERNAL',
1248
+ 500,
1249
+ `the ${label} exited ${code} without a parseable result${detail ? ` (${detail.slice(0, 300)})` : ''}`,
1250
+ ),
1251
+ );
1252
+ return;
1253
+ }
1254
+ settle(resolve, parsed);
1255
+ });
1256
+ if (input !== undefined) child.stdin.write(input);
1257
+ child.stdin.end();
1258
+ });
1259
+
1260
+ const requireJsonBody = (context) => {
1261
+ const text = context.body.toString('utf8').trim();
1262
+ if (text === '') fail('E_VALIDATION', 422, 'a job body is required', { parameter: 'body' });
1263
+ try {
1264
+ return JSON.parse(text);
1265
+ } catch {
1266
+ fail('E_VALIDATION', 422, 'the job body is not valid JSON', { parameter: 'body' });
1267
+ }
1268
+ return null;
1269
+ };
1270
+
1271
+ const createOrUpdateJob = async (context, mode) => {
1272
+ const parsed = requireJsonBody(context);
1273
+ const id = mode === 'update' ? parseJobId(context.params.id) : undefined;
1274
+ if (mode === 'update' && parsed && parsed.id !== undefined && parsed.id !== id) {
1275
+ fail('E_CONFLICT', 409, 'the body id differs from the path id; the id is immutable');
1276
+ }
1277
+ const body = JSON.stringify(mode === 'update' ? { ...parsed, id } : parsed);
1278
+ const result = await runTeamDbChild(['jobs', 'put', '--file', '-'], {
1279
+ settings: context.settings,
1280
+ timeoutMs: JOB_WRITE_CHILD_TIMEOUT_MS,
1281
+ input: body,
1282
+ label: 'job write',
1283
+ });
1284
+ if (result.ok !== true) {
1285
+ const code = typeof result.code === 'string' ? result.code : 'E_INTERNAL';
1286
+ const details = typeof result.parameter === 'string' ? { parameter: result.parameter } : undefined;
1287
+ fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(result.message ?? 'the job write was refused'), details);
1288
+ }
1289
+ const db = context.db();
1290
+ const row = requireJobRow(db, result.job.id);
1291
+ return { json: jobDetail(db, context.settings, row, Date.now()) };
1292
+ };
1293
+
1294
+ const deleteJob = async (context) => {
1295
+ const id = parseJobId(context.params.id);
1296
+ requireJobRow(context.db(), id);
1297
+ const result = await runTeamDbChild(['jobs', 'delete', id], {
1298
+ settings: context.settings,
1299
+ timeoutMs: JOB_DELETE_CHILD_TIMEOUT_MS,
1300
+ label: 'job delete',
1301
+ });
1302
+ if (result.ok !== true) {
1303
+ const code = typeof result.code === 'string' ? result.code : 'E_INTERNAL';
1304
+ fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(result.message ?? `the delete of ${id} was refused`));
1305
+ }
1306
+ return { json: { ok: true, id: String(result.id ?? id), runsRemoved: Number(result.runsRemoved ?? 0) } };
1307
+ };
1308
+
1309
+ /**
1310
+ * Run-now is refused **before any enqueue** when no scheduler holds a fresh
1311
+ * lease: the request could never be claimed, and "requested" with no run is
1312
+ * the failure N-3 exists to prevent.
1313
+ */
1314
+ const runJobNow = async (context) => {
1315
+ const id = parseJobId(context.params.id);
1316
+ requireJobRow(context.db(), id);
1317
+ if (readLease(context.settings.teamRoot).state !== 'running') {
1318
+ fail('E_SCHEDULER_OFFLINE', 409, 'no scheduler holds the lease, so the request could not be claimed', {
1319
+ hint: SCHEDULER_HINT,
1320
+ });
1321
+ }
1322
+ const result = await runTeamDbChild(['jobs', 'run', '--id', id], {
1323
+ settings: context.settings,
1324
+ timeoutMs: JOB_RUN_CHILD_TIMEOUT_MS,
1325
+ label: 'job run request',
1326
+ });
1327
+ if (result.requested !== true) {
1328
+ fail('E_INTERNAL', 500, 'the run request reported neither an acceptance nor a documented refusal');
1329
+ }
1330
+ return {
1331
+ json: {
1332
+ requested: true,
1333
+ requestedAt: String(result.requestedAt ?? new Date().toISOString()),
1334
+ schedulerOnline: result.schedulerOnline !== false,
1335
+ },
1336
+ };
1337
+ };
1338
+
931
1339
  /* --------------------------------- rescan ---------------------------------- */
932
1340
 
933
1341
  const syncSettings = (settings) => ({
@@ -935,33 +1343,18 @@ const syncSettings = (settings) => ({
935
1343
  dbPath: settings.dbPath,
936
1344
  });
937
1345
 
938
- const runSyncChild = (db, settings) => {
939
- if (isKillSwitchSet()) fail('E_DISABLED', 503, 'the projection is disabled by AI_RULES_TEAM_DB_DISABLE');
940
- const script = path.join(moduleDirectory, 'team-db.mjs');
941
- if (!fs.existsSync(script)) fail('E_DB_MISSING', 503, 'team-db.mjs is not installed next to the server');
942
- const child = spawnSync(
943
- process.execPath,
944
- [script, 'sync', '--json', '--quiet', '--deadline-ms', String(SYNC_CHILD_DEADLINE_MS), '--root', settings.teamRoot],
945
- { cwd: settings.cwd, env: { ...process.env, AI_RULES_TEAM_DB_PATH: settings.dbPath }, encoding: 'utf8', timeout: SYNC_CHILD_TIMEOUT_MS, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
1346
+ /**
1347
+ * Rescan through the canonical CLI in a bounded, asynchronous child: no
1348
+ * request path ever blocks the event loop (AC-4.3).
1349
+ */
1350
+ const runSyncChild = async (context) => {
1351
+ const { settings } = context;
1352
+ const parsed = await runTeamDbChild(
1353
+ ['sync', '--quiet', '--deadline-ms', String(SYNC_CHILD_DEADLINE_MS)],
1354
+ { settings, timeoutMs: SYNC_CHILD_TIMEOUT_MS, label: 'rescan' },
946
1355
  );
947
- if (child.error && child.error.code === 'ETIMEDOUT') fail('E_BUSY', 503, 'the rescan exceeded 30 s and was killed');
948
- if (child.error) fail('E_INTERNAL', 500, 'the rescan child could not start');
949
- let parsed = null;
950
- try {
951
- parsed = JSON.parse(String(child.stdout || '').trim());
952
- } catch {
953
- parsed = null;
954
- }
955
- if (!parsed) {
956
- // One `path: reason` line, never prompt content, so an operator can act.
957
- const detail = String(child.stderr || '')
958
- .split('\n')
959
- .map((line) => line.trim())
960
- .find((line) => line.length > 0);
961
- fail('E_INTERNAL', 500, `the rescan exited ${child.status} without a parseable result${detail ? ` (${detail.slice(0, 300)})` : ''}`);
962
- }
963
- const connection = db();
964
- const row = connection.prepare(SQL.maxSyncRun).get();
1356
+ const db = context.db();
1357
+ const row = db.prepare(SQL.maxSyncRun).get();
965
1358
  const runId = row && row.run_id !== null ? Number(row.run_id) : null;
966
1359
  return {
967
1360
  runId,
@@ -991,31 +1384,12 @@ const runSyncChild = (db, settings) => {
991
1384
  * unspecified code ever leaks. The 30 s `SIGKILL` bound and the sanitized
992
1385
  * one-line stderr detail are the rescan child's own.
993
1386
  */
994
- const runDeleteChild = (slug, settings) => {
995
- if (isKillSwitchSet()) fail('E_DISABLED', 503, 'the projection is disabled by AI_RULES_TEAM_DB_DISABLE');
996
- const script = path.join(moduleDirectory, 'team-db.mjs');
997
- if (!fs.existsSync(script)) fail('E_DB_MISSING', 503, 'team-db.mjs is not installed next to the server');
998
- const child = spawnSync(
999
- process.execPath,
1000
- [script, 'delete', '--slug', slug, '--json', '--root', settings.teamRoot],
1001
- { cwd: settings.cwd, env: { ...process.env, AI_RULES_TEAM_DB_PATH: settings.dbPath }, encoding: 'utf8', timeout: SYNC_CHILD_TIMEOUT_MS, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
1002
- );
1003
- if (child.error && child.error.code === 'ETIMEDOUT') fail('E_BUSY', 503, `the delete of ${slug} exceeded 30 s and was killed`);
1004
- if (child.error) fail('E_INTERNAL', 500, 'the delete child could not start');
1005
- let parsed = null;
1006
- try {
1007
- parsed = JSON.parse(String(child.stdout || '').trim());
1008
- } catch {
1009
- parsed = null;
1010
- }
1011
- if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
1012
- // One `path: reason` line, never prompt content, so an operator can act.
1013
- const detail = String(child.stderr || '')
1014
- .split('\n')
1015
- .map((line) => line.trim())
1016
- .find((line) => line.length > 0);
1017
- fail('E_INTERNAL', 500, `the delete exited ${child.status} without a parseable result${detail ? ` (${detail.slice(0, 300)})` : ''}`);
1018
- }
1387
+ const runDeleteChild = async (slug, context) => {
1388
+ const parsed = await runTeamDbChild(['delete', '--slug', slug], {
1389
+ settings: context.settings,
1390
+ timeoutMs: SYNC_CHILD_TIMEOUT_MS,
1391
+ label: `delete of ${slug}`,
1392
+ });
1019
1393
  if (parsed.ok === false) {
1020
1394
  const code = typeof parsed.code === 'string' ? parsed.code : 'E_INTERNAL';
1021
1395
  // The guard fires only when the target is the active slug, so the detail
@@ -1031,11 +1405,13 @@ const runDeleteChild = (slug, settings) => {
1031
1405
 
1032
1406
  /* --------------------------------- routing -------------------------------- */
1033
1407
 
1034
- const route = (method, routePath, operationId, handler) => ({
1408
+ const route = (method, routePath, operationId, handler, options = {}) => ({
1035
1409
  method,
1036
1410
  path: routePath,
1037
1411
  operationId,
1038
1412
  handler,
1413
+ bodyLimit: options.bodyLimit ?? MAX_REQUEST_BODY_BYTES,
1414
+ requireJson: Boolean(options.requireJson),
1039
1415
  pattern: new RegExp(
1040
1416
  `^${routePath
1041
1417
  .split('/')
@@ -1071,12 +1447,12 @@ export const ROUTES = [
1071
1447
  route('GET', '/api/v1/tasks/{slug}', 'getTask', (context) => ({
1072
1448
  json: getTaskDetail(context.db(), context.params.slug),
1073
1449
  })),
1074
- route('DELETE', '/api/v1/tasks/{slug}', 'deleteTask', (context) => {
1450
+ route('DELETE', '/api/v1/tasks/{slug}', 'deleteTask', async (context) => {
1075
1451
  // The kill switch answers before any read or child spawn; the existence
1076
1452
  // pre-read fast-fails an unknown slug through the read-only handle.
1077
1453
  if (isKillSwitchSet()) fail('E_DISABLED', 503, 'the projection is disabled by AI_RULES_TEAM_DB_DISABLE');
1078
1454
  requireTask(context.db(), context.params.slug);
1079
- return { json: runDeleteChild(context.params.slug, context.settings) };
1455
+ return { json: await runDeleteChild(context.params.slug, context) };
1080
1456
  }),
1081
1457
  taskRoute('getTaskPipeline', { path: 'pipeline', handler: getPipeline }),
1082
1458
  taskRoute('listTaskAttempts', { path: 'attempts', handler: listAttempts }),
@@ -1091,7 +1467,47 @@ export const ROUTES = [
1091
1467
  taskRoute('exportTask', { path: 'export', handler: exportTask }),
1092
1468
  route('GET', '/api/v1/stats', 'getStats', (context) => ({ json: getStats(context.db(), context.query) })),
1093
1469
  route('GET', '/api/v1/sync-runs', 'listSyncRuns', (context) => ({ json: listSyncRuns(context.db(), context.query) })),
1094
- route('POST', '/api/v1/sync', 'triggerSync', (context) => ({ json: runSyncChild(context.db, context.settings) })),
1470
+ route('POST', '/api/v1/sync', 'triggerSync', async (context) => {
1471
+ const text = context.body.toString('utf8').trim();
1472
+ if (text !== '' && text !== '{}') {
1473
+ fail('E_VALIDATION', 422, 'the rescan accepts no request body', { parameter: 'body' });
1474
+ }
1475
+ return { json: await runSyncChild(context) };
1476
+ }),
1477
+ // The job entries sit after every task entry and before the stats route, so
1478
+ // `/api/v1/jobs/{id}` can never shadow `/api/v1/jobs/{id}/runs`.
1479
+ route('GET', '/api/v1/jobs', 'listJobs', (context) => ({ json: listJobs(context.db(), context.settings, context.query) })),
1480
+ route('POST', '/api/v1/jobs', 'createJob', (context) => createOrUpdateJob(context, 'create'), {
1481
+ bodyLimit: JOB_BODY_MAX,
1482
+ requireJson: true,
1483
+ }),
1484
+ route('GET', '/api/v1/jobs/{id}', 'getJob', (context) => {
1485
+ const row = requireJobRow(context.db(), parseJobId(context.params.id));
1486
+ return { json: jobDetail(context.db(), context.settings, row, Date.now()) };
1487
+ }),
1488
+ route('PUT', '/api/v1/jobs/{id}', 'updateJob', (context) => createOrUpdateJob(context, 'update'), {
1489
+ bodyLimit: JOB_BODY_MAX,
1490
+ requireJson: true,
1491
+ }),
1492
+ route('DELETE', '/api/v1/jobs/{id}', 'deleteJob', (context) => deleteJob(context), { bodyLimit: MAX_REQUEST_BODY_BYTES }),
1493
+ route('GET', '/api/v1/jobs/{id}/runs', 'listJobRuns', (context) => ({
1494
+ json: listJobRuns(context.db(), parseJobId(context.params.id), context.query),
1495
+ })),
1496
+ route('GET', '/api/v1/jobs/{id}/runs/{runId}', 'getJobRun', (context) => ({
1497
+ json: getJobRun(context.db(), parseJobId(context.params.id), parseRunId(context.params.runId)),
1498
+ })),
1499
+ route('GET', '/api/v1/jobs/{id}/runs/{runId}/log', 'getJobRunLog', (context) => ({
1500
+ json: getJobRunLog(
1501
+ context.db(),
1502
+ context.settings,
1503
+ parseJobId(context.params.id),
1504
+ parseRunId(context.params.runId),
1505
+ context.query,
1506
+ ),
1507
+ })),
1508
+ route('POST', '/api/v1/jobs/{id}/run', 'runJobNow', (context) => runJobNow(context), {
1509
+ bodyLimit: MAX_REQUEST_BODY_BYTES,
1510
+ }),
1095
1511
  ];
1096
1512
 
1097
1513
  /** The documented `METHOD path` pairs, for the contract gate's route parity. */
@@ -1230,12 +1646,18 @@ const handle = async (req, res, settings) => {
1230
1646
  return;
1231
1647
  }
1232
1648
 
1233
- if (entry.method === 'POST') {
1234
- const body = await readBody(req, MAX_REQUEST_BODY_BYTES);
1235
- const text = body.toString('utf8').trim();
1236
- if (text !== '' && text !== '{}') {
1649
+ // Every method that may carry a body drains it against the route's own
1650
+ // bound; the rescan keeps its "no body" semantics in its handler.
1651
+ const body = ['POST', 'PUT', 'DELETE'].includes(entry.method)
1652
+ ? await readBody(req, entry.bodyLimit)
1653
+ : Buffer.alloc(0);
1654
+ if (entry.requireJson && body.length > 0) {
1655
+ const contentType = String(req.headers['content-type'] ?? '').toLowerCase();
1656
+ if (!contentType.startsWith('application/json')) {
1657
+ // The closed code table maps `E_VALIDATION` to 422 only: a media-type
1658
+ // refusal is a validation answer, never an undocumented 415.
1237
1659
  sendJson(req, res, 422, {
1238
- error: { code: 'E_VALIDATION', message: 'the rescan accepts no request body', details: { parameter: 'body' } },
1660
+ error: { code: 'E_VALIDATION', message: 'job bodies require application/json', details: { parameter: 'content-type' } },
1239
1661
  });
1240
1662
  return;
1241
1663
  }
@@ -1264,7 +1686,14 @@ const handle = async (req, res, settings) => {
1264
1686
  };
1265
1687
  const dbOnce = () => handleOnce().db;
1266
1688
  try {
1267
- const result = entry.handler({ settings, params, query: url.searchParams, db: dbOnce, handle: handleOnce });
1689
+ const result = await entry.handler({
1690
+ settings,
1691
+ params,
1692
+ query: url.searchParams,
1693
+ body,
1694
+ db: dbOnce,
1695
+ handle: handleOnce,
1696
+ });
1268
1697
  if (result.json !== undefined) {
1269
1698
  sendJson(req, res, 200, result.json);
1270
1699
  return;