@bonesofspring/ai-rules 0.2.60 → 0.2.61

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 (433) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +59 -26
  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 +29 -14
  15. package/docs/MCP-CATALOG.md +30 -2
  16. package/docs/MCP-SETUP.md +30 -6
  17. package/docs/OPENCODE.md +22 -2
  18. package/docs/PLATFORMS.md +38 -0
  19. package/docs/PRESET-CONTRIBUTION.md +11 -1
  20. package/docs/TEAM-DB.md +187 -20
  21. package/docs/openapi/team-db.v1.json +4443 -2083
  22. package/mcp/defectdojo-mcp.mjs +353 -0
  23. package/mcp/gitlab.mjs +5 -1
  24. package/mcp/lib/defectdojo.mjs +249 -0
  25. package/mcp/lib/yandex.mjs +39 -15
  26. package/package.json +9 -3
  27. package/presets/_shared/ai-local/scripts/lock.mjs +139 -19
  28. package/presets/_shared/ai-local/scripts/signals.mjs +17 -1
  29. package/presets/_shared/ai-local/scripts/team-db-api.mjs +496 -67
  30. package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +816 -5
  31. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +761 -6
  32. package/presets/_shared/ai-local/scripts/team-db-project.mjs +10 -0
  33. package/presets/_shared/ai-local/scripts/team-db-scheduler.mjs +2360 -0
  34. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +87 -0
  35. package/presets/_shared/ai-local/scripts/team-db.mjs +151 -9
  36. package/presets/_shared/ai-local/scripts/upstream-research.mjs +2961 -0
  37. package/presets/_shared/core/agent-team/agent-artifact-contracts.md +13 -0
  38. package/presets/_shared/hooks/README.md +23 -3
  39. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +57 -3
  40. package/presets/{claude/nuxt/hooks/guard-shell-command.sh → _shared/hooks/guard-shell-command.mjs.tmpl} +29 -35
  41. package/presets/_shared/hooks/run-hook.mjs +102 -0
  42. package/presets/claude/android-kotlin/hooks/README.md +4 -3
  43. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +57 -3
  44. package/presets/claude/android-kotlin/hooks/examples/README.md +2 -2
  45. package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +96 -0
  46. package/presets/claude/android-kotlin/hooks/run-hook.mjs +102 -0
  47. package/presets/claude/android-kotlin/settings.json +2 -2
  48. package/presets/claude/android-kotlin/team/README.md +5 -0
  49. package/presets/claude/go/hooks/README.md +4 -3
  50. package/presets/claude/go/hooks/chain-team-phases.sh +57 -3
  51. package/presets/claude/go/hooks/examples/README.md +2 -2
  52. package/presets/claude/go/hooks/guard-shell-command.mjs +95 -0
  53. package/presets/claude/go/hooks/run-hook.mjs +102 -0
  54. package/presets/claude/go/settings.json +2 -2
  55. package/presets/claude/go/team/README.md +5 -0
  56. package/presets/claude/ios-swift/hooks/README.md +4 -3
  57. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +57 -3
  58. package/presets/claude/ios-swift/hooks/examples/README.md +2 -2
  59. package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +95 -0
  60. package/presets/claude/ios-swift/hooks/run-hook.mjs +102 -0
  61. package/presets/claude/ios-swift/settings.json +2 -2
  62. package/presets/claude/ios-swift/team/README.md +5 -0
  63. package/presets/claude/java/hooks/README.md +4 -3
  64. package/presets/claude/java/hooks/chain-team-phases.sh +57 -3
  65. package/presets/claude/java/hooks/examples/README.md +2 -2
  66. package/presets/claude/java/hooks/{guard-shell-command.sh → guard-shell-command.mjs} +31 -38
  67. package/presets/claude/java/hooks/run-hook.mjs +102 -0
  68. package/presets/claude/java/settings.json +2 -2
  69. package/presets/claude/java/team/README.md +5 -0
  70. package/presets/claude/mcp-ts/hooks/README.md +4 -3
  71. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +57 -3
  72. package/presets/claude/mcp-ts/hooks/examples/README.md +1 -1
  73. package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +95 -0
  74. package/presets/claude/mcp-ts/hooks/run-hook.mjs +102 -0
  75. package/presets/claude/mcp-ts/settings.json +2 -2
  76. package/presets/claude/mcp-ts/team/README.md +5 -0
  77. package/presets/claude/mol/hooks/README.md +20 -0
  78. package/presets/claude/mol/hooks/chain-team-phases.sh +57 -3
  79. package/presets/claude/{svelte/hooks/guard-shell-command.sh → mol/hooks/guard-shell-command.mjs} +29 -35
  80. package/presets/claude/mol/hooks/run-hook.mjs +102 -0
  81. package/presets/claude/mol/settings.json +2 -2
  82. package/presets/claude/mol/team/README.md +5 -0
  83. package/presets/claude/next/agents/build-verifier.md +2 -0
  84. package/presets/claude/next/agents/code-reviewer.md +2 -0
  85. package/presets/claude/next/agents/feature-developer.md +1 -0
  86. package/presets/claude/next/agents/task-analyst.md +4 -0
  87. package/presets/claude/next/agents/task-router.md +5 -3
  88. package/presets/claude/next/commands/README.md +1 -0
  89. package/presets/claude/next/commands/task-continue.md +1 -1
  90. package/presets/claude/next/commands/upstream-research.md +23 -0
  91. package/presets/claude/next/hooks/README.md +4 -3
  92. package/presets/claude/next/hooks/chain-team-phases.sh +57 -3
  93. package/presets/claude/next/hooks/examples/README.md +2 -2
  94. package/presets/claude/next/hooks/guard-shell-command.mjs +94 -0
  95. package/presets/claude/next/hooks/run-hook.mjs +102 -0
  96. package/presets/claude/next/settings.json +2 -2
  97. package/presets/claude/next/team/README.md +23 -0
  98. package/presets/claude/next/team/upstream/config.json +31 -0
  99. package/presets/claude/next/team/upstream/digest-template.md +55 -0
  100. package/presets/claude/next/team/upstream/opencode.json +34 -0
  101. package/presets/claude/next/team/upstream/projects.json +4 -0
  102. package/presets/claude/next/team/upstream/prompt.md +77 -0
  103. package/presets/claude/next/team/upstream/signatures.json +9 -0
  104. package/presets/claude/nuxt/hooks/README.md +4 -3
  105. package/presets/claude/nuxt/hooks/chain-team-phases.sh +57 -3
  106. package/presets/claude/nuxt/hooks/examples/README.md +2 -2
  107. package/presets/claude/{ios-swift/hooks/guard-shell-command.sh → nuxt/hooks/guard-shell-command.mjs} +29 -37
  108. package/presets/claude/nuxt/hooks/run-hook.mjs +102 -0
  109. package/presets/claude/nuxt/settings.json +2 -2
  110. package/presets/claude/nuxt/team/README.md +5 -0
  111. package/presets/claude/php-hexagonal/hooks/README.md +4 -3
  112. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +57 -3
  113. package/presets/claude/php-hexagonal/hooks/examples/README.md +2 -2
  114. package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +96 -0
  115. package/presets/claude/php-hexagonal/hooks/run-hook.mjs +102 -0
  116. package/presets/claude/php-hexagonal/settings.json +2 -2
  117. package/presets/claude/php-hexagonal/team/README.md +5 -0
  118. package/presets/claude/php-laravel/hooks/README.md +4 -3
  119. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +57 -3
  120. package/presets/claude/php-laravel/hooks/examples/README.md +2 -2
  121. package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +96 -0
  122. package/presets/claude/php-laravel/hooks/run-hook.mjs +102 -0
  123. package/presets/claude/php-laravel/settings.json +2 -2
  124. package/presets/claude/php-laravel/team/README.md +5 -0
  125. package/presets/claude/svelte/hooks/README.md +4 -3
  126. package/presets/claude/svelte/hooks/chain-team-phases.sh +57 -3
  127. package/presets/claude/svelte/hooks/examples/README.md +2 -2
  128. package/presets/claude/svelte/hooks/guard-shell-command.mjs +94 -0
  129. package/presets/claude/svelte/hooks/run-hook.mjs +102 -0
  130. package/presets/claude/svelte/settings.json +2 -2
  131. package/presets/claude/svelte/team/README.md +5 -0
  132. package/presets/cursor/android-kotlin/hooks/README.md +2 -1
  133. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +57 -3
  134. package/presets/cursor/android-kotlin/hooks/examples/README.md +1 -1
  135. package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +96 -0
  136. package/presets/cursor/android-kotlin/hooks/run-hook.mjs +102 -0
  137. package/presets/cursor/android-kotlin/hooks.json +2 -2
  138. package/presets/cursor/android-kotlin/team/README.md +5 -0
  139. package/presets/cursor/go/hooks/README.md +2 -1
  140. package/presets/cursor/go/hooks/chain-team-phases.sh +57 -3
  141. package/presets/cursor/go/hooks/examples/README.md +1 -1
  142. package/presets/cursor/go/hooks/guard-shell-command.mjs +95 -0
  143. package/presets/cursor/go/hooks/run-hook.mjs +102 -0
  144. package/presets/cursor/go/hooks.json +2 -2
  145. package/presets/cursor/go/team/README.md +5 -0
  146. package/presets/cursor/ios-swift/hooks/README.md +2 -1
  147. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +57 -3
  148. package/presets/cursor/ios-swift/hooks/examples/README.md +1 -1
  149. package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +95 -0
  150. package/presets/cursor/ios-swift/hooks/run-hook.mjs +102 -0
  151. package/presets/cursor/ios-swift/hooks.json +2 -2
  152. package/presets/cursor/ios-swift/team/README.md +5 -0
  153. package/presets/cursor/java/hooks/README.md +2 -1
  154. package/presets/cursor/java/hooks/chain-team-phases.sh +57 -3
  155. package/presets/cursor/java/hooks/examples/README.md +1 -1
  156. package/presets/cursor/java/hooks/guard-shell-command.mjs +96 -0
  157. package/presets/cursor/java/hooks/run-hook.mjs +102 -0
  158. package/presets/cursor/java/hooks.json +2 -2
  159. package/presets/cursor/java/team/README.md +5 -0
  160. package/presets/cursor/mcp-ts/hooks/README.md +2 -1
  161. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +57 -3
  162. package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +95 -0
  163. package/presets/cursor/mcp-ts/hooks/run-hook.mjs +102 -0
  164. package/presets/cursor/mcp-ts/hooks.json +2 -2
  165. package/presets/cursor/mcp-ts/team/README.md +5 -0
  166. package/presets/cursor/mol/hooks/README.md +2 -1
  167. package/presets/cursor/mol/hooks/chain-team-phases.sh +57 -3
  168. package/presets/cursor/mol/hooks/examples/README.md +1 -1
  169. package/presets/{claude/next/hooks/guard-shell-command.sh → cursor/mol/hooks/guard-shell-command.mjs} +29 -35
  170. package/presets/cursor/mol/hooks/run-hook.mjs +102 -0
  171. package/presets/cursor/mol/hooks.json +2 -2
  172. package/presets/cursor/mol/team/README.md +5 -0
  173. package/presets/cursor/next/agents/build-verifier.md +2 -0
  174. package/presets/cursor/next/agents/code-reviewer.md +2 -0
  175. package/presets/cursor/next/agents/feature-developer.md +1 -0
  176. package/presets/cursor/next/agents/task-analyst.md +4 -0
  177. package/presets/cursor/next/agents/task-router.md +5 -3
  178. package/presets/cursor/next/commands/README.md +1 -0
  179. package/presets/cursor/next/commands/task-continue.md +1 -1
  180. package/presets/cursor/next/commands/upstream-research.md +23 -0
  181. package/presets/cursor/next/hooks/README.md +2 -1
  182. package/presets/cursor/next/hooks/chain-team-phases.sh +57 -3
  183. package/presets/cursor/next/hooks/examples/README.md +1 -1
  184. package/presets/cursor/next/hooks/guard-shell-command.mjs +94 -0
  185. package/presets/cursor/next/hooks/run-hook.mjs +102 -0
  186. package/presets/cursor/next/hooks.json +2 -2
  187. package/presets/cursor/next/team/README.md +23 -0
  188. package/presets/cursor/next/team/upstream/config.json +31 -0
  189. package/presets/cursor/next/team/upstream/digest-template.md +55 -0
  190. package/presets/cursor/next/team/upstream/opencode.json +34 -0
  191. package/presets/cursor/next/team/upstream/projects.json +4 -0
  192. package/presets/cursor/next/team/upstream/prompt.md +77 -0
  193. package/presets/cursor/next/team/upstream/signatures.json +9 -0
  194. package/presets/cursor/nuxt/hooks/README.md +2 -1
  195. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +57 -3
  196. package/presets/cursor/nuxt/hooks/examples/README.md +1 -1
  197. package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +94 -0
  198. package/presets/cursor/nuxt/hooks/run-hook.mjs +102 -0
  199. package/presets/cursor/nuxt/hooks.json +2 -2
  200. package/presets/cursor/nuxt/team/README.md +5 -0
  201. package/presets/cursor/php-hexagonal/hooks/README.md +2 -1
  202. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +57 -3
  203. package/presets/cursor/php-hexagonal/hooks/examples/README.md +1 -1
  204. package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +96 -0
  205. package/presets/cursor/php-hexagonal/hooks/run-hook.mjs +102 -0
  206. package/presets/cursor/php-hexagonal/hooks.json +2 -2
  207. package/presets/cursor/php-hexagonal/team/README.md +5 -0
  208. package/presets/cursor/php-laravel/hooks/README.md +2 -1
  209. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +57 -3
  210. package/presets/cursor/php-laravel/hooks/examples/README.md +1 -1
  211. package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +96 -0
  212. package/presets/cursor/php-laravel/hooks/run-hook.mjs +102 -0
  213. package/presets/cursor/php-laravel/hooks.json +2 -2
  214. package/presets/cursor/php-laravel/team/README.md +5 -0
  215. package/presets/cursor/svelte/hooks/README.md +2 -1
  216. package/presets/cursor/svelte/hooks/chain-team-phases.sh +57 -3
  217. package/presets/cursor/svelte/hooks/examples/README.md +1 -1
  218. package/presets/cursor/svelte/hooks/guard-shell-command.mjs +94 -0
  219. package/presets/cursor/svelte/hooks/run-hook.mjs +102 -0
  220. package/presets/cursor/svelte/hooks.json +2 -2
  221. package/presets/cursor/svelte/team/README.md +5 -0
  222. package/presets/mavis/android-kotlin/adapter-map.json +11 -3
  223. package/presets/mavis/android-kotlin/hooks/README.md +2 -1
  224. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +57 -3
  225. package/presets/mavis/android-kotlin/team/README.md +5 -0
  226. package/presets/mavis/go/adapter-map.json +11 -3
  227. package/presets/mavis/go/hooks/README.md +2 -1
  228. package/presets/mavis/go/hooks/chain-team-phases.sh +57 -3
  229. package/presets/mavis/go/team/README.md +5 -0
  230. package/presets/mavis/ios-swift/adapter-map.json +11 -3
  231. package/presets/mavis/ios-swift/hooks/README.md +2 -1
  232. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +57 -3
  233. package/presets/mavis/ios-swift/team/README.md +5 -0
  234. package/presets/mavis/java/adapter-map.json +11 -3
  235. package/presets/mavis/java/hooks/README.md +2 -1
  236. package/presets/mavis/java/hooks/chain-team-phases.sh +57 -3
  237. package/presets/mavis/java/team/README.md +5 -0
  238. package/presets/mavis/mcp-ts/adapter-map.json +11 -3
  239. package/presets/mavis/mcp-ts/hooks/README.md +2 -1
  240. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +57 -3
  241. package/presets/mavis/mcp-ts/team/README.md +5 -0
  242. package/presets/mavis/mol/adapter-map.json +11 -3
  243. package/presets/mavis/mol/hooks/README.md +2 -1
  244. package/presets/mavis/mol/hooks/chain-team-phases.sh +57 -3
  245. package/presets/mavis/mol/team/README.md +5 -0
  246. package/presets/mavis/next/adapter-map.json +67 -3
  247. package/presets/mavis/next/agents/build-verifier.md +2 -0
  248. package/presets/mavis/next/agents/code-reviewer.md +2 -0
  249. package/presets/mavis/next/agents/feature-developer.md +1 -0
  250. package/presets/mavis/next/agents/task-analyst.md +4 -0
  251. package/presets/mavis/next/agents/task-router.md +5 -3
  252. package/presets/mavis/next/commands/README.md +1 -0
  253. package/presets/mavis/next/commands/task-continue.md +1 -1
  254. package/presets/mavis/next/commands/upstream-research.md +18 -0
  255. package/presets/mavis/next/hooks/README.md +2 -1
  256. package/presets/mavis/next/hooks/chain-team-phases.sh +57 -3
  257. package/presets/mavis/next/team/README.md +23 -0
  258. package/presets/mavis/next/team/upstream/config.json +31 -0
  259. package/presets/mavis/next/team/upstream/digest-template.md +55 -0
  260. package/presets/mavis/next/team/upstream/opencode.json +34 -0
  261. package/presets/mavis/next/team/upstream/projects.json +4 -0
  262. package/presets/mavis/next/team/upstream/prompt.md +77 -0
  263. package/presets/mavis/next/team/upstream/signatures.json +9 -0
  264. package/presets/mavis/nuxt/adapter-map.json +11 -3
  265. package/presets/mavis/nuxt/hooks/README.md +2 -1
  266. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +57 -3
  267. package/presets/mavis/nuxt/team/README.md +5 -0
  268. package/presets/mavis/php-hexagonal/adapter-map.json +11 -3
  269. package/presets/mavis/php-hexagonal/hooks/README.md +2 -1
  270. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +57 -3
  271. package/presets/mavis/php-hexagonal/team/README.md +5 -0
  272. package/presets/mavis/php-laravel/adapter-map.json +11 -3
  273. package/presets/mavis/php-laravel/hooks/README.md +2 -1
  274. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +57 -3
  275. package/presets/mavis/php-laravel/team/README.md +5 -0
  276. package/presets/mavis/svelte/adapter-map.json +11 -3
  277. package/presets/mavis/svelte/hooks/README.md +2 -1
  278. package/presets/mavis/svelte/hooks/chain-team-phases.sh +57 -3
  279. package/presets/mavis/svelte/team/README.md +5 -0
  280. package/presets/opencode/android-kotlin/OPENCODE.md +1 -1
  281. package/presets/opencode/android-kotlin/README.md +1 -1
  282. package/presets/opencode/android-kotlin/adapter-map.json +11 -3
  283. package/presets/opencode/android-kotlin/hooks/README.md +3 -2
  284. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +57 -3
  285. package/presets/opencode/android-kotlin/team/README.md +5 -0
  286. package/presets/opencode/go/OPENCODE.md +1 -1
  287. package/presets/opencode/go/README.md +1 -1
  288. package/presets/opencode/go/adapter-map.json +11 -3
  289. package/presets/opencode/go/hooks/README.md +3 -2
  290. package/presets/opencode/go/hooks/chain-team-phases.sh +57 -3
  291. package/presets/opencode/go/team/README.md +5 -0
  292. package/presets/opencode/ios-swift/OPENCODE.md +1 -1
  293. package/presets/opencode/ios-swift/README.md +1 -1
  294. package/presets/opencode/ios-swift/adapter-map.json +11 -3
  295. package/presets/opencode/ios-swift/hooks/README.md +3 -2
  296. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +57 -3
  297. package/presets/opencode/ios-swift/team/README.md +5 -0
  298. package/presets/opencode/java/OPENCODE.md +1 -1
  299. package/presets/opencode/java/README.md +1 -1
  300. package/presets/opencode/java/adapter-map.json +11 -3
  301. package/presets/opencode/java/hooks/README.md +3 -2
  302. package/presets/opencode/java/hooks/chain-team-phases.sh +57 -3
  303. package/presets/opencode/java/team/README.md +5 -0
  304. package/presets/opencode/mcp-ts/OPENCODE.md +1 -1
  305. package/presets/opencode/mcp-ts/README.md +1 -1
  306. package/presets/opencode/mcp-ts/adapter-map.json +11 -3
  307. package/presets/opencode/mcp-ts/hooks/README.md +3 -2
  308. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +57 -3
  309. package/presets/opencode/mcp-ts/team/README.md +5 -0
  310. package/presets/opencode/mol/OPENCODE.md +1 -1
  311. package/presets/opencode/mol/README.md +1 -1
  312. package/presets/opencode/mol/adapter-map.json +11 -3
  313. package/presets/opencode/mol/hooks/README.md +3 -2
  314. package/presets/opencode/mol/hooks/chain-team-phases.sh +57 -3
  315. package/presets/opencode/mol/team/README.md +5 -0
  316. package/presets/opencode/next/OPENCODE.md +1 -1
  317. package/presets/opencode/next/README.md +1 -1
  318. package/presets/opencode/next/adapter-map.json +67 -3
  319. package/presets/opencode/next/agents/build-verifier.md +2 -0
  320. package/presets/opencode/next/agents/code-reviewer.md +2 -0
  321. package/presets/opencode/next/agents/feature-developer.md +1 -0
  322. package/presets/opencode/next/agents/task-analyst.md +4 -0
  323. package/presets/opencode/next/agents/task-router.md +5 -3
  324. package/presets/opencode/next/commands/README.md +1 -0
  325. package/presets/opencode/next/commands/task-continue.md +1 -1
  326. package/presets/opencode/next/commands/upstream-research.md +26 -0
  327. package/presets/opencode/next/hooks/README.md +3 -2
  328. package/presets/opencode/next/hooks/chain-team-phases.sh +57 -3
  329. package/presets/opencode/next/team/README.md +23 -0
  330. package/presets/opencode/next/team/upstream/config.json +31 -0
  331. package/presets/opencode/next/team/upstream/digest-template.md +55 -0
  332. package/presets/opencode/next/team/upstream/opencode.json +34 -0
  333. package/presets/opencode/next/team/upstream/projects.json +4 -0
  334. package/presets/opencode/next/team/upstream/prompt.md +77 -0
  335. package/presets/opencode/next/team/upstream/signatures.json +9 -0
  336. package/presets/opencode/nuxt/OPENCODE.md +1 -1
  337. package/presets/opencode/nuxt/README.md +1 -1
  338. package/presets/opencode/nuxt/adapter-map.json +11 -3
  339. package/presets/opencode/nuxt/hooks/README.md +3 -2
  340. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +57 -3
  341. package/presets/opencode/nuxt/team/README.md +5 -0
  342. package/presets/opencode/php-hexagonal/OPENCODE.md +1 -1
  343. package/presets/opencode/php-hexagonal/README.md +1 -1
  344. package/presets/opencode/php-hexagonal/adapter-map.json +11 -3
  345. package/presets/opencode/php-hexagonal/hooks/README.md +3 -2
  346. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +57 -3
  347. package/presets/opencode/php-hexagonal/team/README.md +5 -0
  348. package/presets/opencode/php-laravel/OPENCODE.md +1 -1
  349. package/presets/opencode/php-laravel/README.md +1 -1
  350. package/presets/opencode/php-laravel/adapter-map.json +11 -3
  351. package/presets/opencode/php-laravel/hooks/README.md +3 -2
  352. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +57 -3
  353. package/presets/opencode/php-laravel/team/README.md +5 -0
  354. package/presets/opencode/svelte/OPENCODE.md +1 -1
  355. package/presets/opencode/svelte/README.md +1 -1
  356. package/presets/opencode/svelte/adapter-map.json +11 -3
  357. package/presets/opencode/svelte/hooks/README.md +3 -2
  358. package/presets/opencode/svelte/hooks/chain-team-phases.sh +57 -3
  359. package/presets/opencode/svelte/team/README.md +5 -0
  360. package/presets/zcode/android-kotlin/adapter-map.json +11 -3
  361. package/presets/zcode/android-kotlin/hooks/README.md +2 -1
  362. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +57 -3
  363. package/presets/zcode/android-kotlin/team/README.md +5 -0
  364. package/presets/zcode/go/adapter-map.json +11 -3
  365. package/presets/zcode/go/hooks/README.md +2 -1
  366. package/presets/zcode/go/hooks/chain-team-phases.sh +57 -3
  367. package/presets/zcode/go/team/README.md +5 -0
  368. package/presets/zcode/ios-swift/adapter-map.json +11 -3
  369. package/presets/zcode/ios-swift/hooks/README.md +2 -1
  370. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +57 -3
  371. package/presets/zcode/ios-swift/team/README.md +5 -0
  372. package/presets/zcode/java/adapter-map.json +11 -3
  373. package/presets/zcode/java/hooks/README.md +2 -1
  374. package/presets/zcode/java/hooks/chain-team-phases.sh +57 -3
  375. package/presets/zcode/java/team/README.md +5 -0
  376. package/presets/zcode/mcp-ts/adapter-map.json +11 -3
  377. package/presets/zcode/mcp-ts/hooks/README.md +2 -1
  378. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +57 -3
  379. package/presets/zcode/mcp-ts/team/README.md +5 -0
  380. package/presets/zcode/mol/adapter-map.json +11 -3
  381. package/presets/zcode/mol/hooks/README.md +2 -1
  382. package/presets/zcode/mol/hooks/chain-team-phases.sh +57 -3
  383. package/presets/zcode/mol/team/README.md +5 -0
  384. package/presets/zcode/next/adapter-map.json +67 -3
  385. package/presets/zcode/next/agents/build-verifier.md +2 -0
  386. package/presets/zcode/next/agents/code-reviewer.md +2 -0
  387. package/presets/zcode/next/agents/feature-developer.md +1 -0
  388. package/presets/zcode/next/agents/task-analyst.md +4 -0
  389. package/presets/zcode/next/agents/task-router.md +5 -3
  390. package/presets/zcode/next/commands/README.md +1 -0
  391. package/presets/zcode/next/commands/task-continue.md +1 -1
  392. package/presets/zcode/next/commands/upstream-research.md +26 -0
  393. package/presets/zcode/next/hooks/README.md +2 -1
  394. package/presets/zcode/next/hooks/chain-team-phases.sh +57 -3
  395. package/presets/zcode/next/team/README.md +23 -0
  396. package/presets/zcode/next/team/upstream/config.json +31 -0
  397. package/presets/zcode/next/team/upstream/digest-template.md +55 -0
  398. package/presets/zcode/next/team/upstream/opencode.json +34 -0
  399. package/presets/zcode/next/team/upstream/projects.json +4 -0
  400. package/presets/zcode/next/team/upstream/prompt.md +77 -0
  401. package/presets/zcode/next/team/upstream/signatures.json +9 -0
  402. package/presets/zcode/nuxt/adapter-map.json +11 -3
  403. package/presets/zcode/nuxt/hooks/README.md +2 -1
  404. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +57 -3
  405. package/presets/zcode/nuxt/team/README.md +5 -0
  406. package/presets/zcode/php-hexagonal/adapter-map.json +11 -3
  407. package/presets/zcode/php-hexagonal/hooks/README.md +2 -1
  408. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +57 -3
  409. package/presets/zcode/php-hexagonal/team/README.md +5 -0
  410. package/presets/zcode/php-laravel/adapter-map.json +11 -3
  411. package/presets/zcode/php-laravel/hooks/README.md +2 -1
  412. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +57 -3
  413. package/presets/zcode/php-laravel/team/README.md +5 -0
  414. package/presets/zcode/svelte/adapter-map.json +11 -3
  415. package/presets/zcode/svelte/hooks/README.md +2 -1
  416. package/presets/zcode/svelte/hooks/chain-team-phases.sh +57 -3
  417. package/presets/zcode/svelte/team/README.md +5 -0
  418. package/presets/claude/android-kotlin/hooks/guard-shell-command.sh +0 -103
  419. package/presets/claude/go/hooks/guard-shell-command.sh +0 -102
  420. package/presets/claude/mcp-ts/hooks/guard-shell-command.sh +0 -102
  421. package/presets/claude/php-hexagonal/hooks/guard-shell-command.sh +0 -103
  422. package/presets/claude/php-laravel/hooks/guard-shell-command.sh +0 -103
  423. package/presets/cursor/android-kotlin/hooks/guard-shell-command.sh +0 -80
  424. package/presets/cursor/go/hooks/guard-shell-command.sh +0 -79
  425. package/presets/cursor/ios-swift/hooks/guard-shell-command.sh +0 -79
  426. package/presets/cursor/java/hooks/guard-shell-command.sh +0 -80
  427. package/presets/cursor/mcp-ts/hooks/guard-shell-command.sh +0 -79
  428. package/presets/cursor/mol/hooks/guard-shell-command.sh +0 -77
  429. package/presets/cursor/next/hooks/guard-shell-command.sh +0 -77
  430. package/presets/cursor/nuxt/hooks/guard-shell-command.sh +0 -77
  431. package/presets/cursor/php-hexagonal/hooks/guard-shell-command.sh +0 -80
  432. package/presets/cursor/php-laravel/hooks/guard-shell-command.sh +0 -80
  433. package/presets/cursor/svelte/hooks/guard-shell-command.sh +0 -77
package/docs/TEAM-DB.md CHANGED
@@ -4,16 +4,17 @@
4
4
  The task files remain the source of truth; the database exists so an operator or a tool can
5
5
  query history without walking JSON on every request.
6
6
 
7
- The projection is installed by `init` as six modules under `.ai.local/scripts/`:
7
+ The projection is installed by `init` as seven modules under `.ai.local/scripts/`:
8
8
 
9
9
  | Module | Role |
10
10
  |---|---|
11
- | `team-db.mjs` | CLI: `init`, `sync`, `delete`, `migrate-tasks`, `check`, `serve` |
11
+ | `team-db.mjs` | CLI: `init`, `sync`, `delete`, `migrate-tasks`, `check`, `serve`, `jobs`, `schedule` |
12
12
  | `team-db-schema.mjs` | capability probe, embedded migrations, pragmas, fingerprint, integrity |
13
13
  | `team-db-project.mjs` | parsers, idempotent projector, confirmed task deletion, retention, search |
14
- | `team-db-api.mjs` | `node:http` server (reads plus two bounded mutations), query layer, security boundary |
14
+ | `team-db-api.mjs` | `node:http` server (reads plus the bounded mutations), query layer, security boundary |
15
15
  | `team-db-openapi.mjs` | the OpenAPI 3.1 document source |
16
16
  | `team-db-dashboard.mjs` | the no-build dashboard (HTML, CSS, JS strings) |
17
+ | `team-db-scheduler.mjs` | job model, cron/interval math, the file store, the projection, and the timer |
17
18
 
18
19
  ## Behavior contract
19
20
 
@@ -27,11 +28,17 @@ The projection is installed by `init` as six modules under `.ai.local/scripts/`:
27
28
  one line to `team-db-errors.log` on failure; the confirmed task delete runs its own
28
29
  bounded child (30 s, `SIGKILL`), and its failure reaches the caller through the one error
29
30
  envelope, or one stderr line on the CLI.
30
- - **Two bounded mutations.** `POST /api/v1/sync` re-runs the projector; `DELETE
31
- /api/v1/tasks/{slug}` deletes one confirmed task (the folder first, then the rows). Every
32
- other route is `GET`/`HEAD`, and both mutations run as bounded child processes — the
33
- server process never opens a writable connection, and the kill switch stops both before a
34
- child is spawned. There is no write-back, no telemetry, and no outbound request.
31
+ - **Bounded mutations.** `POST /api/v1/sync` re-runs the projector and `DELETE
32
+ /api/v1/tasks/{slug}` deletes one confirmed task (the folder first, then the rows); every
33
+ other route is `GET`/`HEAD` apart from the four job writes. Each mutation runs as an
34
+ asynchronous child process — the server never opens a writable connection, and the kill
35
+ switch answers before a child is spawned. Job writes carry `application/json` and at most
36
+ 64 KiB, run-now an absent body or `{}`. The rescan and delete children are bounded at 30 s,
37
+ a job write or run-now at 10 s. There is no write-back, no telemetry, and no outbound call.
38
+ - **The scheduler writes files before rows.** `scheduler/jobs.json` is the definition of
39
+ record, `scheduler/runs/**` and `scheduler/state.json` are its runtime state, and the three
40
+ `scheduled_jobs` / `job_runs` / `job_run_events` tables are projections of those files. The
41
+ scheduler never writes `status.json`, `metrics.json`, or a receipt.
35
42
  - **Local only.** The server binds loopback by default, checks `Host` and `Origin`, sends no
36
43
  CORS header, and serves raw documents from SQLite by exact `(slug, path)` lookup.
37
44
 
@@ -45,9 +52,12 @@ team.db
45
52
  team.db-wal
46
53
  team.db-shm
47
54
  team-db-errors.log
55
+ team/scheduler/runs/
56
+ team/scheduler/state.json
48
57
  ```
49
58
 
50
- The consumer root `.gitignore` is never created or edited. Never commit the database even
59
+ `team/scheduler/jobs.json` stays tracked: definitions are code, run output is not. The
60
+ consumer root `.gitignore` is never created or edited. Never commit the database even
51
61
  for a demo: it contains copies of prompts and task documents.
52
62
 
53
63
  ## Node floor
@@ -56,7 +66,8 @@ The floor is Node 22.13.0. `node:sqlite` was unflagged in that release
56
66
  ([Node.js 22.13.0 release notes](https://nodejs.org/en/blog/release/v22.13.0), commit
57
67
  `55239a48b6`, PR [#55890](https://github.com/nodejs/node/pull/55890)); the module is still
58
68
  marked experimental. `MIN_NODE = '22.13.0'` in `team-db-schema.mjs` is the code constant
59
- behind this sentence; `engines` stays `>=18`.
69
+ behind this sentence. `engines` in `package.json` is the package runtime contract and is not
70
+ the SQLite floor; a runtime below `MIN_NODE`, or one without `node:sqlite`, stays file-only.
60
71
 
61
72
  Measured surface: Node 24.21.0 with SQLite 3.54.1 (`DatabaseSync`, prepared statements,
62
73
  `PRAGMA`, WAL, FTS5); re-verified on Node 26.13.0 / SQLite 3.54.1 for this release. A runtime
@@ -70,6 +81,15 @@ below the floor, or a build without `node:sqlite`, is detected at runtime:
70
81
  | `team-db.mjs check` | one line, exit 1 | one line, exit 1 |
71
82
  | `team-db.mjs delete` | one line, exit 2 | one line, exit 1 |
72
83
  | `team-db.mjs serve` | one line, exit 0 | one line, exit 0 |
84
+ | `team-db.mjs jobs list\|get` | exit 0, file-only | exit 0, file-only |
85
+ | `team-db.mjs jobs put\|delete\|run\|enable\|disable` | exit 0, file-only, no row | exit 1, no write |
86
+ | `team-db.mjs jobs reconcile` | exit 0 | exit 0, no row written |
87
+ | `team-db.mjs schedule` | exit 0, no file | exit 0, no claim |
88
+
89
+ The scheduler reads a job's IANA zone through `Intl.DateTimeFormat`. On a build with small ICU
90
+ (`--with-intl=small-icu`) every zone name resolves, so a zone that needs full ICU data is
91
+ treated as UTC instead of being refused. The runtime stays supported and the projection still
92
+ works; check a job's next fire on such a build before trusting it.
73
93
 
74
94
  The file-only pipeline is unchanged: `status.json` / `metrics.json` writes, manifest upserts,
75
95
  and the pipeline run with exit 0.
@@ -87,6 +107,15 @@ node .ai.local/scripts/team-db.mjs migrate-tasks [--root <team-dir>] [--quiet] [
87
107
  node .ai.local/scripts/team-db.mjs check [--root <team-dir>]
88
108
  node .ai.local/scripts/team-db.mjs serve [--root <team-dir>] [--host <addr>] [--port <n>]
89
109
  [--allow-remote] [--open]
110
+ node .ai.local/scripts/team-db.mjs jobs list [--enabled] [--sort <key>] [--json] [--quiet]
111
+ node .ai.local/scripts/team-db.mjs jobs get <id> [--json]
112
+ node .ai.local/scripts/team-db.mjs jobs put --file <path|-> [--dry-run] [--json]
113
+ node .ai.local/scripts/team-db.mjs jobs delete <id> [--keep-runs] [--json]
114
+ node .ai.local/scripts/team-db.mjs jobs enable|disable <id> [--json]
115
+ node .ai.local/scripts/team-db.mjs jobs reconcile [--json]
116
+ node .ai.local/scripts/team-db.mjs jobs run --id <id> [--json]
117
+ node .ai.local/scripts/team-db.mjs schedule [--once] [--interval-ms <n>] [--grace-ms <n>]
118
+ [--drain-ms <n>] [--json] [--quiet]
90
119
  ```
91
120
 
92
121
  Exit codes: `0` ok, `1` at least one task failed, a delete refusal (unknown slug, active
@@ -140,6 +169,119 @@ No other environment value is read or persisted. The error log stores a timestam
140
169
  a phase, and a message; it never stores prompt content or an environment value, and it is
141
170
  trimmed to the newest 200 lines / 64 KiB.
142
171
 
172
+ ## Scheduled jobs
173
+
174
+ `scheduler/jobs.json` holds the definitions, sorted by `id` and rewritten atomically; it is
175
+ meant to be **committed** ("jobs as code"), while run output and runtime state are ignored
176
+ (§ Location and ignore rules). A job carries `id`, `title`, `enabled`, a `schedule` (`cron`
177
+ five-field expression or `interval` with `everySeconds`), the IANA `timezone`, a `payload`,
178
+ `cwd`, `envPassthrough` (names only), `timeoutMs` (1 s – 12 h, default 15 min), `concurrency`
179
+ (`skip` / `queue` / `allow`), and `misfire` (`skip` / `run-once` / `catch-up`). The id is
180
+ immutable; a stale `revision` is `409 E_CONFLICT`.
181
+
182
+ **Payload kinds.** `command` runs `payload.argv` directly — `spawn(argv[0], argv.slice(1),
183
+ { shell: false })`, never a shell string. `pipeline` lowers the same call after rendering
184
+ `payload.promptTemplate` into `<runDir>/prompt.md` (placeholders `{{job.id}}`, `{{run.id}}`,
185
+ `{{run.dir}}`, `{{team.root}}`, `{{now}}`) and substituting `{promptFile}` in
186
+ `payload.runner`. A `pipeline` job without `runner` is refused at validation; there is no
187
+ bundled agent runtime. The child environment is `PATH`, `HOME`, `TMPDIR`, `LANG`, `TZ` plus
188
+ the `envPassthrough` names; no `AI_RULES_TEAM_DB_*` value is forwarded, and `TZ` is the job's
189
+ timezone.
190
+
191
+ **Runs.** One tick claims each due occurrence inside `BEGIN IMMEDIATE` against `job_runs`, so
192
+ two racing firings produce one child and one `skipped` row. Children are spawned detached in
193
+ their own process group and bounded by `timeoutMs`: `SIGTERM`, a 5 s grace, then `SIGKILL` to
194
+ the group. `stdout` and `stderr` land in separate files capped at 1 MiB, the run manifest
195
+ carries the byte count, sha256, and truncation flag, and a run's state is one of `claimed`,
196
+ `running`, `succeeded`, `failed`, `timeout`, `skipped`, `interrupted`. The recorded sha256
197
+ covers exactly the capped bytes; the truncation marker is appended outside that scope, so a
198
+ capped stream projects clean instead of reporting `E_LOG_HASH`. A run-now request is durable:
199
+ `jobs run` appends it to `state.json`, the live timer re-reads and merges the queue at every
200
+ tick, and a request leaves the queue only when its run is claimed.
201
+
202
+ **Retention.** 1 MiB per stream per run, 200 runs per job, 30 days, and 2 GiB per team root,
203
+ enforced before the next write; an active run is never pruned, and a pruned run directory
204
+ takes its `job_runs` row with it. `state.json` keeps the last fire instant per job, which is
205
+ what makes `run-once` and `catch-up` survive downtime. `catch-up` replays at most five
206
+ occurrences per gap; when more were due, the replay is marked truncated (`catchUp.truncated`
207
+ on the manifest and an `E_CATCH_UP_TRUNCATED` event) and the remainder is dropped instead of
208
+ replaying five more on the next tick. A candidate fire must be later than the recorded one, so
209
+ a clock jump backwards never re-fires.
210
+
211
+ **There is no redaction.** A child's output is persisted verbatim in
212
+ `.ai.local/team/scheduler/runs/<jobId>/<runId>/`. Treat a job's output as secret-bearing: it
213
+ inherits the operator's environment through `envPassthrough`, the run directory is git-ignored
214
+ by the rule above, and retention bounds how long it is kept. `envPassthrough` carries names,
215
+ so `jobs.json` never holds a value.
216
+
217
+ **Recovery.** One scheduler per team root: the lease file `scheduler/scheduler.lock` refuses a
218
+ second `schedule` with exit 4, and a lease older than 90 s is stale, never deleted. A
219
+ `claimed`/`running` run whose process is gone is orphaned by definition: the next `schedule`
220
+ reconciles it before the first fire, and `jobs reconcile` does the same on demand — the
221
+ manifest and the row become `interrupted` with reason `E_ORPHANED`. `sync --rebuild` and
222
+ `sync --vacuum` refuse with `E_SCHEDULER_RUNNING` (exit 4) while a fresh lease exists. That
223
+ guard covers the explicit destructive flags only: a plain `init` or `sync` opens writable, and
224
+ a database whose recorded schema fingerprint no longer matches is moved aside as
225
+ `team.db.mismatch-<stamp>` and rebuilt (see § Schema) even while a scheduler holds the lease.
226
+ Stop the scheduler before any schema upgrade; the explicit flags are a backstop, not a
227
+ complete guard. The kill switch drains: no new claim, the in-flight child finishes inside its
228
+ own timeout, the result is recorded, exit 0. Supervision (launchd, systemd, Task Scheduler) is
229
+ documented practice, never shipped as a second timer, and Windows process-group termination is
230
+ not supported in v1.
231
+
232
+ ## Upstream research job
233
+
234
+ The `next` preset ships one `pipeline` job, `upstream-research`, and one engine module,
235
+ `.ai.local/scripts/upstream-research.mjs`. The job renders `upstream/prompt.md` and runs the
236
+ module with `--prompt {promptFile} --team-root . --repo-root ../..`; it is a normal
237
+ definition in `scheduler/jobs.json`, so `jobs list|get|put|enable|disable|run`, the dashboard
238
+ Jobs tab, and every job route work unchanged.
239
+
240
+ **Supervision.** `misfire: run-once` fires one missed Monday at the next tick, and
241
+ `concurrency: skip` consumes and drops a manual request while a weekly run is live (the drop
242
+ is a `skipped` row with `E_CONCURRENCY_SKIP`). `jobs run` is durable: a request executes only
243
+ when a `schedule` tick claims it. Keep one supervisor (`launchd`, `systemd`, Task Scheduler)
244
+ running `node .ai.local/scripts/team-db.mjs schedule`; without one, `/upstream-research` adds
245
+ one `schedule --once` tick.
246
+
247
+ **Cursor.** Per-project scan state lives in the git-ignored
248
+ `.ai.local/team/upstream/cursor.json`. A lost cursor is rebuilt from the newest
249
+ `scheduler/runs/upstream-research/<runId>/report.json`, then degrades to a bounded baseline
250
+ when the run tree has been pruned. `upstream/projects.json`, `config.json`, `signatures.json`,
251
+ the prompt, the digest template, and the agent config are committed; `docs/upstream/digest-
252
+ <runId>.md` is committed and never pruned.
253
+
254
+ **Write allow-list.** A run writes only `scheduler/runs/upstream-research/<runId>/**`, the
255
+ cursor, and the committed digest. It never writes `status.json` or `metrics.json`, and the
256
+ scheduler keeps owning `run.json`, `stdout.log`, `stderr.log`, and `<runDir>/prompt.md`.
257
+
258
+ **Failure surface.** The scheduler's reason codes are a closed set, so a runner code such as
259
+ `E_OPENCODE_MISSING` lives in `report.json`, `stderr.log`, and the digest header; the job row
260
+ reports `E_EXIT_10` / `E_EXIT_11` / `E_EXIT_12` / `E_EXIT_13` / `E_EXIT_15` / `E_EXIT_16`.
261
+ `E_AGENT_CONFIG_INVALID` (12) means the resolved `upstream-researcher` no longer denies
262
+ every tool (the global `*` or a named action); reinstall `team/upstream/opencode.json` with
263
+ `init`/`update`.
264
+
265
+ **Commands.** Validate the registry with
266
+ `node .ai.local/scripts/upstream-research.mjs registry --check --team-root .`; refresh the
267
+ durable prior-art index with `signatures --write` (`--check` reports drift and writes
268
+ nothing). Adding a comparison project is one registry object plus a commit — no scheduler,
269
+ prompt, or code change.
270
+
271
+ **Model route.** `upstream/config.json` `agent.model` is `null` by default, so the agent runs
272
+ on whatever model the installed `opencode` resolves; set it to a `provider/model` id to pin
273
+ the route, which adds `--model` to the call with no code change.
274
+
275
+ ## Upgrading an installed engine set
276
+
277
+ `update --fix` rewrites a seeded module only when its bytes still equal the digest recorded in
278
+ `.ai.local/.template-base.json`; the previous bytes go to `.ai.local/.rollback/engine-<stamp>/`
279
+ (the newest five runs are kept). `update --check` is the dry run: it names each eligible rel
280
+ and writes nothing. A module whose bytes differ from the recorded base is reported
281
+ `kept modified` and stays byte-identical — review the diff and delete the module to let the
282
+ next `update` seed it again. A module with no recorded base is `unattributable` and is never
283
+ written; delete it and re-run `init`. `doctor --fix` runs the same plan and writer.
284
+
143
285
  ## Schema
144
286
 
145
287
  One embedded migration (`0001-init`, sha256-pinned) creates 15 row tables: `schema_migrations`,
@@ -148,6 +290,14 @@ One embedded migration (`0001-init`, sha256-pinned) creates 15 row tables: `sche
148
290
  `sync_runs`; 19 indexes; and the `attempt_timeline` view. FTS5 (`search_fts`) is a runtime
149
291
  capability created after migration, with an escaped `LIKE` fallback.
150
292
 
293
+ Migration `0002-scheduler` adds the scheduler's three tables — `scheduled_jobs`, `job_runs`,
294
+ `job_run_events` — and five indexes, and moves `SCHEMA_VERSION` to 2. It is additive and
295
+ sha256-pinned like the first one: a tampered literal aborts with `E_MIGRATION_CHECKSUM` before
296
+ any DDL. A v1 database is not read forward: its recorded fingerprint no longer describes the
297
+ schema, so the next open moves the file aside as `team.db.mismatch-<stamp>`, rebuilds, and
298
+ reprojects from the task files — database-only rows are discarded by design, which is why the
299
+ files are the source of truth. Run `sync` after an upgrade and the counters reconverge.
300
+
151
301
  Each connection sets `journal_mode=WAL`, `busy_timeout=5000`, `foreign_keys=ON`, and
152
302
  `synchronous=NORMAL`. One task is projected in one transaction; a `SIGKILL` mid-sync
153
303
  rolls back the in-flight task and leaves `integrity_check` `ok`.
@@ -211,8 +361,11 @@ Security boundary: loopback bind by default (`--host` outside loopback needs
211
361
  `--allow-remote`, and a wildcard address is refused), exact `Host`/`Origin` allow-list,
212
362
  no `Access-Control-*` header, hardened response headers, request bodies bounded at 1 KiB,
213
363
  document chunks at 1 MiB, exports at 5 MiB, parameterized SQL only, and no outbound call.
214
- `--allow-remote` also exposes the confirmed delete and the rescan to the named interface
215
- without authentication.
364
+ `--allow-remote` also exposes the four job mutations — `POST /api/v1/jobs`,
365
+ `PUT /api/v1/jobs/{id}`, `DELETE /api/v1/jobs/{id}`, and `POST /api/v1/jobs/{id}/run` —
366
+ the confirmed task delete and the rescan to the named interface without authentication.
367
+ A job definition carries arbitrary `argv` and run-now enqueues it, so that surface
368
+ executes operator-supplied commands as the API user; see `## Scheduled jobs`.
216
369
 
217
370
  ## Privacy and retention
218
371
 
@@ -221,16 +374,27 @@ and readable by the same OS user who can read the task folder; that is the trust
221
374
  There is no upload, telemetry, or remote asset. `sync --maintain` nulls raw document content
222
375
  for tasks absent longer than 90 days while keeping normalized rows and hashes.
223
376
 
377
+ Run output crosses the same boundary and is **not** redacted: `scheduler/runs/**` holds a
378
+ child's `stdout` and `stderr` verbatim, a job inherits the listed `envPassthrough` names, and
379
+ only the retention caps bound how long the bytes stay on disk.
380
+
224
381
  ## Rollback
225
382
 
226
383
  1. Set `AI_RULES_TEAM_DB_DISABLE=1`. Every write point becomes a no-op: the hook,
227
- `manifest.mjs`, `init`/`sync`/`migrate-tasks` and `serve` exit 0; `delete` refuses with
228
- exit 1 and touches nothing.
229
- 2. Delete the projection: `rm -f .ai.local/team/team.db .ai.local/team/team.db-wal
230
- .ai.local/team/team.db-shm .ai.local/team/team-db-errors.log`. No task file is touched.
231
- 3. Revert the code: remove the hook region and the `projectAfterReceipt` call, delete the six
384
+ `manifest.mjs`, `init`/`sync`/`migrate-tasks` and `serve` exit 0; `jobs` writes and
385
+ `delete` refuse with exit 1; `schedule` starts no claim and exits 0.
386
+ 2. Stop the scheduler: send `SIGTERM` to the `schedule` process and let its in-flight run
387
+ finish, or let `--once` return. The lease is released on a clean exit; a lease left by a
388
+ killed process goes stale after 90 s, and `jobs reconcile` marks its runs `interrupted`.
389
+ 3. Delete the projection: `rm -rf .ai.local/team/team.db .ai.local/team/team.db-wal
390
+ .ai.local/team/team.db-shm .ai.local/team/team-db-errors.log
391
+ .ai.local/team/scheduler/runs .ai.local/team/scheduler/state.json`. `scheduler/jobs.json`
392
+ is a definition file — keep it unless you are removing the feature. No task file is touched.
393
+ 4. Revert the code: remove the hook region and the `projectAfterReceipt` call, delete the seven
232
394
  modules from `ENGINE_SCRIPTS`, then run `yarn fix:generated` and recapture the goldens.
233
- 4. The ADR stays as history: mark it superseded instead of deleting it.
395
+ `update --fix` restores a module whose bytes still match the recorded base; `cp -R
396
+ .ai.local/.rollback/engine-<stamp>/.ai.local .` restores a whole previous set.
397
+ 5. The ADR stays as history: mark it superseded instead of deleting it.
234
398
 
235
399
  ## Gates
236
400
 
@@ -246,6 +410,7 @@ node scripts/test-team-db-api.mjs
246
410
  node scripts/test-team-db-security.mjs
247
411
  node scripts/test-team-db-dashboard.mjs
248
412
  node scripts/test-team-db-concurrency.mjs
413
+ node scripts/test-team-db-scheduler.mjs
249
414
  node scripts/test-team-db-fixtures.mjs
250
415
  ```
251
416
 
@@ -253,5 +418,7 @@ node scripts/test-team-db-fixtures.mjs
253
418
  planted defect, not only on the happy path.
254
419
 
255
420
  Links: [`../README.md`](../README.md), [`PRESET-CONTRIBUTION.md`](PRESET-CONTRIBUTION.md),
256
- the OpenSpec change `openspec/changes/2026-11-06-agent-team-sqlite-dashboard/`, and ADR
257
- `.ai.local/adr/0004-team-db-projection.md` in this repository.
421
+ the OpenSpec changes `openspec/changes/2026-11-06-agent-team-sqlite-dashboard/` and
422
+ `openspec/changes/2026-11-10-preset-task-scheduler-impl/`, and ADRs
423
+ `.ai.local/adr/0004-team-db-projection.md` and `.ai.local/adr/0005-team-db-scheduler.md` in
424
+ this repository.