@bonesofspring/ai-rules 0.2.78 → 0.2.80

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 (340) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +4 -2
  3. package/bin/lib/engine-scripts.js +6 -0
  4. package/bin/lib/seed-ai-local-team.js +2 -0
  5. package/docs/TEAM-DB.md +118 -15
  6. package/docs/openapi/team-db.v1.json +2879 -1858
  7. package/package.json +5 -1
  8. package/presets/_shared/ai-local/scripts/check-task-repositories.mjs +264 -0
  9. package/presets/_shared/ai-local/scripts/rr-migrate-repositories.mjs +481 -0
  10. package/presets/_shared/ai-local/scripts/team-db-api.mjs +211 -12
  11. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +289 -3
  12. package/presets/_shared/ai-local/scripts/team-db-project.mjs +857 -1
  13. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +68 -0
  14. package/presets/_shared/ai-local/scripts/team-db-tracker.mjs +29 -10
  15. package/presets/_shared/ai-local/scripts/team-db.mjs +46 -1
  16. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +69 -1
  17. package/presets/claude/android-kotlin/agents/task-router.md +2 -0
  18. package/presets/claude/android-kotlin/commands/README.md +1 -0
  19. package/presets/claude/android-kotlin/commands/rr-migrate-repositories.md +59 -0
  20. package/presets/claude/android-kotlin/commands/task.md +4 -0
  21. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +69 -1
  22. package/presets/claude/go/agents/task-router.md +2 -0
  23. package/presets/claude/go/commands/README.md +1 -0
  24. package/presets/claude/go/commands/rr-migrate-repositories.md +59 -0
  25. package/presets/claude/go/commands/task.md +4 -0
  26. package/presets/claude/go/hooks/chain-team-phases.sh +69 -1
  27. package/presets/claude/ios-swift/agents/task-router.md +2 -0
  28. package/presets/claude/ios-swift/commands/README.md +1 -0
  29. package/presets/claude/ios-swift/commands/rr-migrate-repositories.md +59 -0
  30. package/presets/claude/ios-swift/commands/task.md +4 -0
  31. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +69 -1
  32. package/presets/claude/java/agents/task-router.md +2 -0
  33. package/presets/claude/java/commands/README.md +1 -0
  34. package/presets/claude/java/commands/rr-migrate-repositories.md +59 -0
  35. package/presets/claude/java/commands/task.md +4 -0
  36. package/presets/claude/java/hooks/chain-team-phases.sh +69 -1
  37. package/presets/claude/mcp-ts/agents/task-router.md +2 -0
  38. package/presets/claude/mcp-ts/commands/README.md +1 -0
  39. package/presets/claude/mcp-ts/commands/rr-migrate-repositories.md +59 -0
  40. package/presets/claude/mcp-ts/commands/task.md +4 -0
  41. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +69 -1
  42. package/presets/claude/mol/agents/task-router.md +2 -0
  43. package/presets/claude/mol/commands/README.md +1 -0
  44. package/presets/claude/mol/commands/rr-migrate-repositories.md +59 -0
  45. package/presets/claude/mol/commands/task.md +4 -0
  46. package/presets/claude/mol/hooks/chain-team-phases.sh +69 -1
  47. package/presets/claude/next/agents/task-router.md +2 -0
  48. package/presets/claude/next/commands/README.md +1 -0
  49. package/presets/claude/next/commands/rr-migrate-repositories.md +59 -0
  50. package/presets/claude/next/commands/task.md +4 -0
  51. package/presets/claude/next/commands/ui-start.md +12 -4
  52. package/presets/claude/next/commands/ui-stop.md +5 -2
  53. package/presets/claude/next/hooks/chain-team-phases.sh +69 -1
  54. package/presets/claude/nuxt/agents/task-router.md +2 -0
  55. package/presets/claude/nuxt/commands/README.md +1 -0
  56. package/presets/claude/nuxt/commands/rr-migrate-repositories.md +59 -0
  57. package/presets/claude/nuxt/commands/task.md +4 -0
  58. package/presets/claude/nuxt/hooks/chain-team-phases.sh +69 -1
  59. package/presets/claude/php-hexagonal/agents/task-router.md +2 -0
  60. package/presets/claude/php-hexagonal/commands/README.md +1 -0
  61. package/presets/claude/php-hexagonal/commands/rr-migrate-repositories.md +59 -0
  62. package/presets/claude/php-hexagonal/commands/task.md +4 -0
  63. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +69 -1
  64. package/presets/claude/php-laravel/agents/task-router.md +2 -0
  65. package/presets/claude/php-laravel/commands/README.md +1 -0
  66. package/presets/claude/php-laravel/commands/rr-migrate-repositories.md +59 -0
  67. package/presets/claude/php-laravel/commands/task.md +4 -0
  68. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +69 -1
  69. package/presets/claude/svelte/agents/task-router.md +2 -0
  70. package/presets/claude/svelte/commands/README.md +1 -0
  71. package/presets/claude/svelte/commands/rr-migrate-repositories.md +59 -0
  72. package/presets/claude/svelte/commands/task.md +4 -0
  73. package/presets/claude/svelte/hooks/chain-team-phases.sh +69 -1
  74. package/presets/cursor/android-kotlin/agents/task-router.md +2 -0
  75. package/presets/cursor/android-kotlin/commands/README.md +1 -0
  76. package/presets/cursor/android-kotlin/commands/rr-migrate-repositories.md +59 -0
  77. package/presets/cursor/android-kotlin/commands/task.md +4 -0
  78. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +69 -1
  79. package/presets/cursor/go/agents/task-router.md +2 -0
  80. package/presets/cursor/go/commands/README.md +1 -0
  81. package/presets/cursor/go/commands/rr-migrate-repositories.md +59 -0
  82. package/presets/cursor/go/commands/task.md +4 -0
  83. package/presets/cursor/go/hooks/chain-team-phases.sh +69 -1
  84. package/presets/cursor/ios-swift/agents/task-router.md +2 -0
  85. package/presets/cursor/ios-swift/commands/README.md +1 -0
  86. package/presets/cursor/ios-swift/commands/rr-migrate-repositories.md +59 -0
  87. package/presets/cursor/ios-swift/commands/task.md +4 -0
  88. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +69 -1
  89. package/presets/cursor/java/agents/task-router.md +2 -0
  90. package/presets/cursor/java/commands/README.md +1 -0
  91. package/presets/cursor/java/commands/rr-migrate-repositories.md +59 -0
  92. package/presets/cursor/java/commands/task.md +4 -0
  93. package/presets/cursor/java/hooks/chain-team-phases.sh +69 -1
  94. package/presets/cursor/mcp-ts/agents/task-router.md +2 -0
  95. package/presets/cursor/mcp-ts/commands/README.md +1 -0
  96. package/presets/cursor/mcp-ts/commands/rr-migrate-repositories.md +59 -0
  97. package/presets/cursor/mcp-ts/commands/task.md +4 -0
  98. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +69 -1
  99. package/presets/cursor/mol/agents/task-router.md +2 -0
  100. package/presets/cursor/mol/commands/README.md +1 -0
  101. package/presets/cursor/mol/commands/rr-migrate-repositories.md +59 -0
  102. package/presets/cursor/mol/commands/task.md +4 -0
  103. package/presets/cursor/mol/hooks/chain-team-phases.sh +69 -1
  104. package/presets/cursor/next/agents/task-router.md +2 -0
  105. package/presets/cursor/next/commands/README.md +1 -0
  106. package/presets/cursor/next/commands/rr-migrate-repositories.md +59 -0
  107. package/presets/cursor/next/commands/task.md +4 -0
  108. package/presets/cursor/next/commands/ui-start.md +12 -4
  109. package/presets/cursor/next/commands/ui-stop.md +5 -2
  110. package/presets/cursor/next/hooks/chain-team-phases.sh +69 -1
  111. package/presets/cursor/nuxt/agents/task-router.md +2 -0
  112. package/presets/cursor/nuxt/commands/README.md +1 -0
  113. package/presets/cursor/nuxt/commands/rr-migrate-repositories.md +59 -0
  114. package/presets/cursor/nuxt/commands/task.md +4 -0
  115. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +69 -1
  116. package/presets/cursor/php-hexagonal/agents/task-router.md +2 -0
  117. package/presets/cursor/php-hexagonal/commands/README.md +1 -0
  118. package/presets/cursor/php-hexagonal/commands/rr-migrate-repositories.md +59 -0
  119. package/presets/cursor/php-hexagonal/commands/task.md +4 -0
  120. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +69 -1
  121. package/presets/cursor/php-laravel/agents/task-router.md +2 -0
  122. package/presets/cursor/php-laravel/commands/README.md +1 -0
  123. package/presets/cursor/php-laravel/commands/rr-migrate-repositories.md +59 -0
  124. package/presets/cursor/php-laravel/commands/task.md +4 -0
  125. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +69 -1
  126. package/presets/cursor/svelte/agents/task-router.md +2 -0
  127. package/presets/cursor/svelte/commands/README.md +1 -0
  128. package/presets/cursor/svelte/commands/rr-migrate-repositories.md +59 -0
  129. package/presets/cursor/svelte/commands/task.md +4 -0
  130. package/presets/cursor/svelte/hooks/chain-team-phases.sh +69 -1
  131. package/presets/mavis/android-kotlin/adapter-map.json +9 -1
  132. package/presets/mavis/android-kotlin/agents/task-router.md +2 -0
  133. package/presets/mavis/android-kotlin/commands/README.md +1 -0
  134. package/presets/mavis/android-kotlin/commands/rr-migrate-repositories.md +54 -0
  135. package/presets/mavis/android-kotlin/commands/task.md +4 -0
  136. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +69 -1
  137. package/presets/mavis/go/adapter-map.json +9 -1
  138. package/presets/mavis/go/agents/task-router.md +2 -0
  139. package/presets/mavis/go/commands/README.md +1 -0
  140. package/presets/mavis/go/commands/rr-migrate-repositories.md +54 -0
  141. package/presets/mavis/go/commands/task.md +4 -0
  142. package/presets/mavis/go/hooks/chain-team-phases.sh +69 -1
  143. package/presets/mavis/ios-swift/adapter-map.json +9 -1
  144. package/presets/mavis/ios-swift/agents/task-router.md +2 -0
  145. package/presets/mavis/ios-swift/commands/README.md +1 -0
  146. package/presets/mavis/ios-swift/commands/rr-migrate-repositories.md +54 -0
  147. package/presets/mavis/ios-swift/commands/task.md +4 -0
  148. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +69 -1
  149. package/presets/mavis/java/adapter-map.json +9 -1
  150. package/presets/mavis/java/agents/task-router.md +2 -0
  151. package/presets/mavis/java/commands/README.md +1 -0
  152. package/presets/mavis/java/commands/rr-migrate-repositories.md +54 -0
  153. package/presets/mavis/java/commands/task.md +4 -0
  154. package/presets/mavis/java/hooks/chain-team-phases.sh +69 -1
  155. package/presets/mavis/mcp-ts/adapter-map.json +9 -1
  156. package/presets/mavis/mcp-ts/agents/task-router.md +2 -0
  157. package/presets/mavis/mcp-ts/commands/README.md +1 -0
  158. package/presets/mavis/mcp-ts/commands/rr-migrate-repositories.md +54 -0
  159. package/presets/mavis/mcp-ts/commands/task.md +4 -0
  160. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +69 -1
  161. package/presets/mavis/mol/adapter-map.json +9 -1
  162. package/presets/mavis/mol/agents/task-router.md +2 -0
  163. package/presets/mavis/mol/commands/README.md +1 -0
  164. package/presets/mavis/mol/commands/rr-migrate-repositories.md +54 -0
  165. package/presets/mavis/mol/commands/task.md +4 -0
  166. package/presets/mavis/mol/hooks/chain-team-phases.sh +69 -1
  167. package/presets/mavis/next/adapter-map.json +9 -1
  168. package/presets/mavis/next/agents/task-router.md +2 -0
  169. package/presets/mavis/next/commands/README.md +1 -0
  170. package/presets/mavis/next/commands/rr-migrate-repositories.md +54 -0
  171. package/presets/mavis/next/commands/task.md +4 -0
  172. package/presets/mavis/next/commands/ui-start.md +12 -4
  173. package/presets/mavis/next/commands/ui-stop.md +5 -2
  174. package/presets/mavis/next/hooks/chain-team-phases.sh +69 -1
  175. package/presets/mavis/nuxt/adapter-map.json +9 -1
  176. package/presets/mavis/nuxt/agents/task-router.md +2 -0
  177. package/presets/mavis/nuxt/commands/README.md +1 -0
  178. package/presets/mavis/nuxt/commands/rr-migrate-repositories.md +54 -0
  179. package/presets/mavis/nuxt/commands/task.md +4 -0
  180. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +69 -1
  181. package/presets/mavis/php-hexagonal/adapter-map.json +9 -1
  182. package/presets/mavis/php-hexagonal/agents/task-router.md +2 -0
  183. package/presets/mavis/php-hexagonal/commands/README.md +1 -0
  184. package/presets/mavis/php-hexagonal/commands/rr-migrate-repositories.md +54 -0
  185. package/presets/mavis/php-hexagonal/commands/task.md +4 -0
  186. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +69 -1
  187. package/presets/mavis/php-laravel/adapter-map.json +9 -1
  188. package/presets/mavis/php-laravel/agents/task-router.md +2 -0
  189. package/presets/mavis/php-laravel/commands/README.md +1 -0
  190. package/presets/mavis/php-laravel/commands/rr-migrate-repositories.md +54 -0
  191. package/presets/mavis/php-laravel/commands/task.md +4 -0
  192. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +69 -1
  193. package/presets/mavis/svelte/adapter-map.json +9 -1
  194. package/presets/mavis/svelte/agents/task-router.md +2 -0
  195. package/presets/mavis/svelte/commands/README.md +1 -0
  196. package/presets/mavis/svelte/commands/rr-migrate-repositories.md +54 -0
  197. package/presets/mavis/svelte/commands/task.md +4 -0
  198. package/presets/mavis/svelte/hooks/chain-team-phases.sh +69 -1
  199. package/presets/opencode/android-kotlin/adapter-map.json +9 -1
  200. package/presets/opencode/android-kotlin/agents/task-router.md +2 -0
  201. package/presets/opencode/android-kotlin/commands/README.md +1 -0
  202. package/presets/opencode/android-kotlin/commands/rr-migrate-repositories.md +62 -0
  203. package/presets/opencode/android-kotlin/commands/task.md +4 -0
  204. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +69 -1
  205. package/presets/opencode/go/adapter-map.json +9 -1
  206. package/presets/opencode/go/agents/task-router.md +2 -0
  207. package/presets/opencode/go/commands/README.md +1 -0
  208. package/presets/opencode/go/commands/rr-migrate-repositories.md +62 -0
  209. package/presets/opencode/go/commands/task.md +4 -0
  210. package/presets/opencode/go/hooks/chain-team-phases.sh +69 -1
  211. package/presets/opencode/ios-swift/adapter-map.json +9 -1
  212. package/presets/opencode/ios-swift/agents/task-router.md +2 -0
  213. package/presets/opencode/ios-swift/commands/README.md +1 -0
  214. package/presets/opencode/ios-swift/commands/rr-migrate-repositories.md +62 -0
  215. package/presets/opencode/ios-swift/commands/task.md +4 -0
  216. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +69 -1
  217. package/presets/opencode/java/adapter-map.json +9 -1
  218. package/presets/opencode/java/agents/task-router.md +2 -0
  219. package/presets/opencode/java/commands/README.md +1 -0
  220. package/presets/opencode/java/commands/rr-migrate-repositories.md +62 -0
  221. package/presets/opencode/java/commands/task.md +4 -0
  222. package/presets/opencode/java/hooks/chain-team-phases.sh +69 -1
  223. package/presets/opencode/mcp-ts/adapter-map.json +9 -1
  224. package/presets/opencode/mcp-ts/agents/task-router.md +2 -0
  225. package/presets/opencode/mcp-ts/commands/README.md +1 -0
  226. package/presets/opencode/mcp-ts/commands/rr-migrate-repositories.md +62 -0
  227. package/presets/opencode/mcp-ts/commands/task.md +4 -0
  228. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +69 -1
  229. package/presets/opencode/mol/adapter-map.json +9 -1
  230. package/presets/opencode/mol/agents/task-router.md +2 -0
  231. package/presets/opencode/mol/commands/README.md +1 -0
  232. package/presets/opencode/mol/commands/rr-migrate-repositories.md +62 -0
  233. package/presets/opencode/mol/commands/task.md +4 -0
  234. package/presets/opencode/mol/hooks/chain-team-phases.sh +69 -1
  235. package/presets/opencode/next/adapter-map.json +9 -1
  236. package/presets/opencode/next/agents/task-router.md +2 -0
  237. package/presets/opencode/next/commands/README.md +1 -0
  238. package/presets/opencode/next/commands/rr-migrate-repositories.md +62 -0
  239. package/presets/opencode/next/commands/task.md +4 -0
  240. package/presets/opencode/next/commands/ui-start.md +12 -4
  241. package/presets/opencode/next/commands/ui-stop.md +5 -2
  242. package/presets/opencode/next/hooks/chain-team-phases.sh +69 -1
  243. package/presets/opencode/nuxt/adapter-map.json +9 -1
  244. package/presets/opencode/nuxt/agents/task-router.md +2 -0
  245. package/presets/opencode/nuxt/commands/README.md +1 -0
  246. package/presets/opencode/nuxt/commands/rr-migrate-repositories.md +62 -0
  247. package/presets/opencode/nuxt/commands/task.md +4 -0
  248. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +69 -1
  249. package/presets/opencode/php-hexagonal/adapter-map.json +9 -1
  250. package/presets/opencode/php-hexagonal/agents/task-router.md +2 -0
  251. package/presets/opencode/php-hexagonal/commands/README.md +1 -0
  252. package/presets/opencode/php-hexagonal/commands/rr-migrate-repositories.md +62 -0
  253. package/presets/opencode/php-hexagonal/commands/task.md +4 -0
  254. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +69 -1
  255. package/presets/opencode/php-laravel/adapter-map.json +9 -1
  256. package/presets/opencode/php-laravel/agents/task-router.md +2 -0
  257. package/presets/opencode/php-laravel/commands/README.md +1 -0
  258. package/presets/opencode/php-laravel/commands/rr-migrate-repositories.md +62 -0
  259. package/presets/opencode/php-laravel/commands/task.md +4 -0
  260. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +69 -1
  261. package/presets/opencode/plugins/task-status/README.md +15 -7
  262. package/presets/opencode/plugins/task-status/deepseek.ts +193 -0
  263. package/presets/opencode/plugins/task-status/details-data.ts +39 -2
  264. package/presets/opencode/plugins/task-status/prompt-text.ts +18 -8
  265. package/presets/opencode/plugins/task-status/task-view.ts +253 -63
  266. package/presets/opencode/plugins/task-status/tui.tsx +48 -11
  267. package/presets/opencode/svelte/adapter-map.json +9 -1
  268. package/presets/opencode/svelte/agents/task-router.md +2 -0
  269. package/presets/opencode/svelte/commands/README.md +1 -0
  270. package/presets/opencode/svelte/commands/rr-migrate-repositories.md +62 -0
  271. package/presets/opencode/svelte/commands/task.md +4 -0
  272. package/presets/opencode/svelte/hooks/chain-team-phases.sh +69 -1
  273. package/presets/zcode/android-kotlin/adapter-map.json +9 -1
  274. package/presets/zcode/android-kotlin/agents/task-router.md +2 -0
  275. package/presets/zcode/android-kotlin/commands/README.md +1 -0
  276. package/presets/zcode/android-kotlin/commands/rr-migrate-repositories.md +62 -0
  277. package/presets/zcode/android-kotlin/commands/task.md +4 -0
  278. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +69 -1
  279. package/presets/zcode/go/adapter-map.json +9 -1
  280. package/presets/zcode/go/agents/task-router.md +2 -0
  281. package/presets/zcode/go/commands/README.md +1 -0
  282. package/presets/zcode/go/commands/rr-migrate-repositories.md +62 -0
  283. package/presets/zcode/go/commands/task.md +4 -0
  284. package/presets/zcode/go/hooks/chain-team-phases.sh +69 -1
  285. package/presets/zcode/ios-swift/adapter-map.json +9 -1
  286. package/presets/zcode/ios-swift/agents/task-router.md +2 -0
  287. package/presets/zcode/ios-swift/commands/README.md +1 -0
  288. package/presets/zcode/ios-swift/commands/rr-migrate-repositories.md +62 -0
  289. package/presets/zcode/ios-swift/commands/task.md +4 -0
  290. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +69 -1
  291. package/presets/zcode/java/adapter-map.json +9 -1
  292. package/presets/zcode/java/agents/task-router.md +2 -0
  293. package/presets/zcode/java/commands/README.md +1 -0
  294. package/presets/zcode/java/commands/rr-migrate-repositories.md +62 -0
  295. package/presets/zcode/java/commands/task.md +4 -0
  296. package/presets/zcode/java/hooks/chain-team-phases.sh +69 -1
  297. package/presets/zcode/mcp-ts/adapter-map.json +9 -1
  298. package/presets/zcode/mcp-ts/agents/task-router.md +2 -0
  299. package/presets/zcode/mcp-ts/commands/README.md +1 -0
  300. package/presets/zcode/mcp-ts/commands/rr-migrate-repositories.md +62 -0
  301. package/presets/zcode/mcp-ts/commands/task.md +4 -0
  302. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +69 -1
  303. package/presets/zcode/mol/adapter-map.json +9 -1
  304. package/presets/zcode/mol/agents/task-router.md +2 -0
  305. package/presets/zcode/mol/commands/README.md +1 -0
  306. package/presets/zcode/mol/commands/rr-migrate-repositories.md +62 -0
  307. package/presets/zcode/mol/commands/task.md +4 -0
  308. package/presets/zcode/mol/hooks/chain-team-phases.sh +69 -1
  309. package/presets/zcode/next/adapter-map.json +9 -1
  310. package/presets/zcode/next/agents/task-router.md +2 -0
  311. package/presets/zcode/next/commands/README.md +1 -0
  312. package/presets/zcode/next/commands/rr-migrate-repositories.md +62 -0
  313. package/presets/zcode/next/commands/task.md +4 -0
  314. package/presets/zcode/next/commands/ui-start.md +12 -4
  315. package/presets/zcode/next/commands/ui-stop.md +5 -2
  316. package/presets/zcode/next/hooks/chain-team-phases.sh +69 -1
  317. package/presets/zcode/nuxt/adapter-map.json +9 -1
  318. package/presets/zcode/nuxt/agents/task-router.md +2 -0
  319. package/presets/zcode/nuxt/commands/README.md +1 -0
  320. package/presets/zcode/nuxt/commands/rr-migrate-repositories.md +62 -0
  321. package/presets/zcode/nuxt/commands/task.md +4 -0
  322. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +69 -1
  323. package/presets/zcode/php-hexagonal/adapter-map.json +9 -1
  324. package/presets/zcode/php-hexagonal/agents/task-router.md +2 -0
  325. package/presets/zcode/php-hexagonal/commands/README.md +1 -0
  326. package/presets/zcode/php-hexagonal/commands/rr-migrate-repositories.md +62 -0
  327. package/presets/zcode/php-hexagonal/commands/task.md +4 -0
  328. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +69 -1
  329. package/presets/zcode/php-laravel/adapter-map.json +9 -1
  330. package/presets/zcode/php-laravel/agents/task-router.md +2 -0
  331. package/presets/zcode/php-laravel/commands/README.md +1 -0
  332. package/presets/zcode/php-laravel/commands/rr-migrate-repositories.md +62 -0
  333. package/presets/zcode/php-laravel/commands/task.md +4 -0
  334. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +69 -1
  335. package/presets/zcode/svelte/adapter-map.json +9 -1
  336. package/presets/zcode/svelte/agents/task-router.md +2 -0
  337. package/presets/zcode/svelte/commands/README.md +1 -0
  338. package/presets/zcode/svelte/commands/rr-migrate-repositories.md +62 -0
  339. package/presets/zcode/svelte/commands/task.md +4 -0
  340. package/presets/zcode/svelte/hooks/chain-team-phases.sh +69 -1
@@ -857,6 +857,62 @@ ALTER TABLE review_ledger ADD COLUMN due TEXT;
857
857
  ALTER TABLE review_ledger ADD COLUMN follow_up TEXT;
858
858
  `;
859
859
 
860
+ /**
861
+ * Migration 9: the repository registry projection. Two tables; `status` is
862
+ * validated on write rather than by a `CHECK`, so a hand-edited file still
863
+ * projects its row. `task_slug` carries no foreign key on purpose: a link may
864
+ * name a folder that is not projected yet, and `tasks` rows are pruned while
865
+ * the file keeps naming them.
866
+ */
867
+ export const REPOSITORIES_SQL = SQL`CREATE TABLE repositories (
868
+ id TEXT PRIMARY KEY,
869
+ name TEXT NOT NULL,
870
+ locator TEXT NOT NULL,
871
+ description TEXT,
872
+ labels_json TEXT,
873
+ status TEXT NOT NULL,
874
+ revision INTEGER NOT NULL CHECK (revision >= 1),
875
+ created_at TEXT NOT NULL,
876
+ updated_at TEXT NOT NULL,
877
+ content_hash TEXT NOT NULL,
878
+ parse_error TEXT,
879
+ projected_at TEXT NOT NULL,
880
+ first_seen_at TEXT NOT NULL,
881
+ last_seen_at TEXT NOT NULL,
882
+ absent_at TEXT
883
+ ) STRICT;
884
+
885
+ CREATE TABLE task_repositories (
886
+ task_slug TEXT NOT NULL,
887
+ repository_id TEXT NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
888
+ added_at TEXT NOT NULL,
889
+ source TEXT NOT NULL,
890
+ inference TEXT NOT NULL,
891
+ evidence TEXT NOT NULL,
892
+ content_hash TEXT NOT NULL,
893
+ projected_at TEXT NOT NULL,
894
+ PRIMARY KEY (task_slug, repository_id)
895
+ ) STRICT;
896
+
897
+ CREATE INDEX idx_repositories_absent ON repositories(absent_at);
898
+ CREATE INDEX idx_repositories_status_name ON repositories(status, name COLLATE NOCASE);
899
+ CREATE INDEX idx_task_repositories_repository ON task_repositories(repository_id);
900
+ `;
901
+
902
+ /**
903
+ * Migration 10: one verdict per task that resolved to no repository, so the
904
+ * task detail can tell "not recorded" from "attribution ambiguous" without a
905
+ * file read in a route. `evidence`, `recordedAt` and `source` stay in the file
906
+ * because no operation serves them.
907
+ */
908
+ export const REPOSITORY_ATTRIBUTIONS_SQL = SQL`CREATE TABLE task_repository_attributions (
909
+ task_slug TEXT PRIMARY KEY,
910
+ verdict TEXT NOT NULL,
911
+ content_hash TEXT NOT NULL,
912
+ projected_at TEXT NOT NULL
913
+ ) STRICT;
914
+ `;
915
+
860
916
  const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
861
917
  /**
862
918
  * Ordered, immutable migrations. The literal checksum is verified before any
@@ -911,6 +967,18 @@ export const MIGRATIONS = [
911
967
  sql: LEDGER_OWNER_SQL,
912
968
  checksum: '31279ac1f6ba980e10d79fef8aa97226d4afcb4cee0bdf8fbc3f1d0d286f2349',
913
969
  },
970
+ {
971
+ version: 9,
972
+ name: '0009-repositories',
973
+ sql: REPOSITORIES_SQL,
974
+ checksum: 'bffba731a590f8d59bb8f59c99316742570aba6b2ea524b0346cd92c1f90d25d',
975
+ },
976
+ {
977
+ version: 10,
978
+ name: '0010-repository-attributions',
979
+ sql: REPOSITORY_ATTRIBUTIONS_SQL,
980
+ checksum: '4677b2b62b5b9c8cb571f5706abac97487175c8251facdab6b42bf2371f2720e',
981
+ },
914
982
  ];
915
983
 
916
984
  /** Highest migration version shipped by this module. */
@@ -173,8 +173,12 @@ export const linkIdOf = (itemId, taskSlug) => `${itemId}--${taskSlug}`;
173
173
  export const sequenceFilePath = (teamRoot) => path.join(trackerPaths(teamRoot).root, 'sequence.json');
174
174
  const idMigrationFilePath = (teamRoot) => path.join(trackerPaths(teamRoot).root, 'id-migration.json');
175
175
 
176
- /** The monotonic item-id sequence; max(existing) covers a lost sequence file. */
177
- const nextItemId = (teamRoot) => {
176
+ /**
177
+ * The monotonic item-id sequence; max(existing) covers a lost sequence file.
178
+ * Peek reserves without consuming: the caller commits only after the item passes
179
+ * validation, so a rejected payload never burns an id.
180
+ */
181
+ const peekItemId = (teamRoot) => {
178
182
  const current = listItemIds(teamRoot).reduce((max, id) => Math.max(max, id), 0);
179
183
  let reserved = 0;
180
184
  try {
@@ -183,9 +187,11 @@ const nextItemId = (teamRoot) => {
183
187
  } catch {
184
188
  /* a missing or unreadable sequence falls back to the file maximum */
185
189
  }
186
- const nextId = Math.max(current + 1, reserved, 1);
187
- writeAtomic(sequenceFilePath(teamRoot), `${JSON.stringify({ schemaVersion: 1, nextId: nextId + 1 }, null, 2)}\n`);
188
- return nextId;
190
+ return Math.max(current + 1, reserved, 1);
191
+ };
192
+
193
+ const commitItemId = (teamRoot, id) => {
194
+ writeAtomic(sequenceFilePath(teamRoot), `${JSON.stringify({ schemaVersion: 1, nextId: id + 1 }, null, 2)}\n`);
189
195
  };
190
196
 
191
197
  /** Both directories are created on first write (`mkdir -p` inside the CLI). */
@@ -963,7 +969,7 @@ export function addTrackerItem(teamRoot, payload, options = {}) {
963
969
  if (!isRecord(payload)) reject('E_SCHEMA', 'tracker add payload must be an object');
964
970
  return withTrackerLock(teamRoot, () => {
965
971
  const items = readAllItems(teamRoot);
966
- const id = nextItemId(teamRoot);
972
+ const id = peekItemId(teamRoot);
967
973
  const now = nowIso();
968
974
  const createdAt = payload.createdAt ?? now;
969
975
  const item = {
@@ -991,6 +997,7 @@ export function addTrackerItem(teamRoot, payload, options = {}) {
991
997
  validateItemIdentity(item, id);
992
998
  validateItemGraph(item, items);
993
999
  validateTransition(null, item);
1000
+ commitItemId(teamRoot, id);
994
1001
  writeItemFile(teamRoot, item);
995
1002
  return item;
996
1003
  });
@@ -1031,8 +1038,12 @@ export function setTrackerItem(teamRoot, id, payload, options = {}) {
1031
1038
  type = 'deps-changed';
1032
1039
  }
1033
1040
  next.history = capHistory([...(existing.history ?? []), { at: now, type, actor, detail: null }], MAX_ITEM_HISTORY);
1034
- if (next.status === 'cancelled' || next.status === 'superseded') {
1035
- expireEntriesForItem(teamRoot, id, next.status === 'cancelled' ? 'item-cancelled' : 'item-superseded', actor);
1041
+ // A terminal item closes its open requests in the same transaction: `done`
1042
+ // is derived from the task row and never stored, so a completed item would
1043
+ // otherwise leave a `claimed` entry that `prune` can never retire.
1044
+ const terminalDetail = { cancelled: 'item-cancelled', superseded: 'item-superseded', completed: 'item-completed' }[next.status];
1045
+ if (terminalDetail !== undefined && next.status !== existing.status) {
1046
+ expireEntriesForItem(teamRoot, id, terminalDetail, actor);
1036
1047
  }
1037
1048
  writeItemFile(teamRoot, next);
1038
1049
  return next;
@@ -1626,10 +1637,18 @@ export function drainTracker(teamRoot, { claim = false, actor = 'operator' } = {
1626
1637
  export function pruneTrackerEntries(teamRoot, { olderThanDays = DEFAULT_PRUNE_DAYS } = {}) {
1627
1638
  return withTrackerLock(teamRoot, () => {
1628
1639
  const cutoff = Date.now() - olderThanDays * 24 * 60 * 60 * 1000;
1640
+ const taskStates = readTaskStates(teamRoot);
1629
1641
  let pruned = 0;
1630
1642
  for (const [entryId, entry] of readAllEntries(teamRoot)) {
1631
- if (entry.status !== 'cancelled' && entry.status !== 'expired') continue;
1632
- if (!entry.finishedAt || Date.parse(entry.finishedAt) >= cutoff) continue;
1643
+ // `done` is derived from the task row and never stored: a completed item's
1644
+ // entry stays `claimed`, so the stored vocabulary alone cannot retire it.
1645
+ const taskSlug = entry.taskSlug ?? `tracker-${entry.itemId}`;
1646
+ const effective = effectiveEntryStatus(entry, taskStates.get(taskSlug) ?? null);
1647
+ if (!['cancelled', 'expired', 'done'].includes(effective)) continue;
1648
+ // A derived-done entry has no finish time of its own; its last known
1649
+ // activity is the oldest evidence of when the request left the queue.
1650
+ const endedAt = entry.finishedAt ?? entry.claimedAt ?? entry.requestedAt;
1651
+ if (!endedAt || Date.parse(endedAt) >= cutoff) continue;
1633
1652
  fs.rmSync(entryFilePath(teamRoot, entryId), { force: true });
1634
1653
  pruned += 1;
1635
1654
  }
@@ -25,6 +25,11 @@
25
25
  * jobs enable|disable <id> [--root <team-dir>] [--json]
26
26
  * jobs reconcile [--root <team-dir>] [--json]
27
27
  * jobs run --id <id> [--root <team-dir>] [--json]
28
+ * repositories list|project [--root <team-dir>] [--json] [--quiet]
29
+ * repositories apply --file <path|-> [--dry-run] [--root <team-dir>] [--json]
30
+ * repositories put --file <path|-> [--dry-run] [--root <team-dir>] [--json]
31
+ * repositories delete <id> [--force] [--revision <n>] [--root <team-dir>]
32
+ * [--json] the repository registry and its projection
28
33
  * schedule [--root <team-dir>] [--once] [--interval-ms <n>] [--grace-ms <n>]
29
34
  * [--drain-ms <n>] [--json] [--quiet] the scheduler timer
30
35
  * tracker add|set|show|list|ready|validate|import|enqueue|cancel|drain|recover|prune
@@ -72,6 +77,7 @@ import {
72
77
  LEDGER_HEADER_ROW,
73
78
  listTaskDirectories,
74
79
  parseReviewLedgerMarkdown,
80
+ runRepositoriesCommand,
75
81
  searchProjection,
76
82
  syncProjection,
77
83
  syncTrackerProjection,
@@ -106,6 +112,10 @@ const USAGE = `usage:
106
112
  team-db.mjs jobs enable|disable <id> [--root <team-dir>] [--json]
107
113
  team-db.mjs jobs reconcile [--root <team-dir>] [--json]
108
114
  team-db.mjs jobs run --id <id> [--root <team-dir>] [--json]
115
+ team-db.mjs repositories list|project [--root <team-dir>] [--json] [--quiet]
116
+ team-db.mjs repositories apply --file <path|-> [--dry-run] [--root <team-dir>] [--json]
117
+ team-db.mjs repositories put --file <path|-> [--dry-run] [--root <team-dir>] [--json]
118
+ team-db.mjs repositories delete <id> [--force] [--revision <n>] [--root <team-dir>] [--json]
109
119
  team-db.mjs schedule [--root <team-dir>] [--once] [--interval-ms <n>]
110
120
  [--grace-ms <n>] [--drain-ms <n>] [--json] [--quiet]
111
121
  team-db.mjs tracker add --file <path|-> [--root <team-dir>] [--json] [--quiet]
@@ -140,6 +150,7 @@ const VALUE_FLAGS = new Set([
140
150
  'link',
141
151
  'run',
142
152
  'limit',
153
+ 'revision',
143
154
  ]);
144
155
  const BOOLEAN_FLAGS = new Set([
145
156
  'quiet',
@@ -158,8 +169,9 @@ const BOOLEAN_FLAGS = new Set([
158
169
  'once',
159
170
  'ready',
160
171
  'claim',
172
+ 'force',
161
173
  ]);
162
- const COMMANDS = new Set(['init', 'check', 'search', 'sync', 'delete', 'migrate-tasks', 'ledger-check', 'serve', 'jobs', 'schedule', 'tracker', 'task-run']);
174
+ const COMMANDS = new Set(['init', 'check', 'search', 'sync', 'delete', 'migrate-tasks', 'ledger-check', 'serve', 'jobs', 'schedule', 'tracker', 'task-run', 'repositories']);
163
175
  const ALLOWED_FLAGS = {
164
176
  init: new Set(['root', 'rebuild']),
165
177
  check: new Set(['root']),
@@ -173,6 +185,7 @@ const ALLOWED_FLAGS = {
173
185
  schedule: new Set(['root', 'json', 'quiet', 'once', 'interval-ms', 'grace-ms', 'drain-ms']),
174
186
  tracker: new Set(['root', 'json', 'quiet', 'file', 'dry-run', 'older-than', 'status', 'ready', 'claim']),
175
187
  'task-run': new Set(['root', 'json', 'task', 'item', 'link', 'run']),
188
+ repositories: new Set(['root', 'json', 'quiet', 'file', 'dry-run', 'force', 'revision']),
176
189
  };
177
190
 
178
191
  const JOBS_POSITIONALS = new Set([
@@ -207,10 +220,13 @@ const TRACKER_POSITIONALS = new Set([
207
220
 
208
221
  const TASK_RUN_POSITIONALS = new Set(['start', 'stop', 'supervise', 'list', 'show', 'status', 'ensure']);
209
222
 
223
+ const REPOSITORIES_POSITIONALS = new Set(['list', 'project', 'apply', 'put', 'delete']);
224
+
210
225
  const POSITIONAL_VERBS = {
211
226
  jobs: JOBS_POSITIONALS,
212
227
  tracker: TRACKER_POSITIONALS,
213
228
  'task-run': TASK_RUN_POSITIONALS,
229
+ repositories: REPOSITORIES_POSITIONALS,
214
230
  };
215
231
 
216
232
  const parseArgs = (argv) => {
@@ -574,6 +590,34 @@ const runJobs = (flags, positionals) => {
574
590
  }
575
591
  };
576
592
 
593
+ const runRepositories = (flags, positionals) => {
594
+ const [subcommand = 'list', positionalId] = positionals;
595
+ try {
596
+ const result = runRepositoriesCommand(subcommand, positionalId ? [positionalId] : [], {
597
+ root: flags.root,
598
+ json: Boolean(flags.json),
599
+ quiet: Boolean(flags.quiet),
600
+ file: flags.file,
601
+ dryRun: Boolean(flags['dry-run']),
602
+ force: Boolean(flags.force),
603
+ revision: flags.revision === undefined ? undefined : Number(flags.revision),
604
+ });
605
+ if (result.output) process.stdout.write(result.output);
606
+ return result.exitCode;
607
+ } catch (error) {
608
+ const code = error instanceof TeamDbError ? error.code : 'E_INTERNAL';
609
+ const exitCode = error instanceof TeamDbError ? error.exitCode : 2;
610
+ const failure = { ok: false, code, message: error.message };
611
+ if (error instanceof TeamDbError && typeof error.parameter === 'string') failure.parameter = error.parameter;
612
+ // The delete guard names the linked-task count; the API lifts it into
613
+ // `details.linkedTasks` without parsing prose.
614
+ if (error && Number.isInteger(error.linkedTasks)) failure.linkedTasks = error.linkedTasks;
615
+ if (flags.json) process.stdout.write(`${JSON.stringify(failure)}\n`);
616
+ process.stderr.write(`${error.message}\n`);
617
+ return exitCode;
618
+ }
619
+ };
620
+
577
621
  const runTaskRunner = async (flags, positionals) => {
578
622
  const [subcommand = 'status'] = positionals;
579
623
  try {
@@ -739,6 +783,7 @@ export async function runCli(argv) {
739
783
  if (command === 'ledger-check') return runLedgerCheck(flags);
740
784
  if (command === 'serve') return runServe(flags);
741
785
  if (command === 'jobs') return runJobs(flags, positionals);
786
+ if (command === 'repositories') return runRepositories(flags, positionals);
742
787
  if (command === 'tracker') return runTracker(flags, positionals);
743
788
  if (command === 'task-run') return runTaskRunner(flags, positionals);
744
789
  if (command === 'schedule') return runSchedule(flags);
@@ -2796,6 +2796,10 @@ if (status.state === 'awaiting_artifact_receipt') {
2796
2796
  emitArtifactStall(artifactStallMessage, !wasWaitingForReceipt);
2797
2797
  process.exit(0);
2798
2798
  }
2799
+ // Snapshot before `finishActiveAttempt` writes `lastCompletedAttempt`: the
2800
+ // repositories intake gate judges a task at its first receipt, so a folder whose
2801
+ // first step already completed is never re-judged.
2802
+ const hadPriorCompletion = Boolean(status.lastCompletedAttempt);
2799
2803
  let finishedAttempt = finishActiveAttempt();
2800
2804
  // The just-finished attempt's metric is already written; a pause now blocks
2801
2805
  // every handoff, including the unattributable-stop repair path below.
@@ -2823,7 +2827,7 @@ if (!finishedAttempt && activeAttemptCountBeforeFinish > 0) {
2823
2827
  }
2824
2828
  }
2825
2829
  endHumanGateIfResumed();
2826
- if (steps.length === 0 || pipeline.autoChain === false) {
2830
+ if (steps.length === 0) {
2827
2831
  writeStatus({});
2828
2832
  process.stdout.write('{}');
2829
2833
  process.exit(0);
@@ -2870,6 +2874,70 @@ const waveIndexes = activeWave
2870
2874
  ? [idx]
2871
2875
  : (isGraphMode() && finishedAttempt ? [completedStepIndex] : null));
2872
2876
 
2877
+ /**
2878
+ * Intake invariant: a task records which repositories it touches — or says that
2879
+ * it does not know. Judged on the first receipt of a task: the router's, or the
2880
+ * first step's when a pipeline runs without one. A task that already completed a
2881
+ * step predates the invariant and is never re-judged.
2882
+ * `intakeExemption: { approvedBy, reason, at }` is the recorded escape hatch; a
2883
+ * bare boolean does not count, so an exemption always names who approved it. The
2884
+ * shape mirrors `check-task-repositories.mjs`, which audits the same field after
2885
+ * the fact.
2886
+ */
2887
+ const REPOSITORY_INFERENCES = new Set(['evidence-paths', 'repo-scope-only', 'unknown', 'ambiguous']);
2888
+ const EXEMPTION_DATE = /^\d{4}-\d{2}-\d{2}$/;
2889
+ function repositoriesIntakeViolation(record) {
2890
+ if (!record) return 'has no `repositories` array';
2891
+ const ids = record.repositories;
2892
+ const inference = record.repositoriesInference;
2893
+ if (!Array.isArray(ids)) return 'carries no `repositories` array';
2894
+ if (ids.some((id) => typeof id !== 'string' || id.trim() === '')) return 'carries a `repositories` entry that is not a non-empty registry id';
2895
+ if (ids.length === 0) {
2896
+ return inference === 'unknown' ? null : 'carries `repositories: []` without `"repositoriesInference": "unknown"`';
2897
+ }
2898
+ if (inference !== undefined && !REPOSITORY_INFERENCES.has(inference)) return `carries an unknown \`repositoriesInference\` value "${inference}"`;
2899
+ if (inference === 'unknown') return 'lists repositories beside `"repositoriesInference": "unknown"`';
2900
+ let known = null;
2901
+ try {
2902
+ const registry = JSON.parse(fs.readFileSync(path.join(TEAM_ROOT, 'repositories.json'), 'utf8'));
2903
+ known = new Set((Array.isArray(registry.repositories) ? registry.repositories : []).map((row) => row && row.id).filter((id) => typeof id === 'string'));
2904
+ } catch { known = null; }
2905
+ if (known && known.size > 0) {
2906
+ const unknownIds = ids.filter((id) => !known.has(id));
2907
+ if (unknownIds.length > 0) return `names ${unknownIds.join(', ')} — not in .ai.local/team/repositories.json`;
2908
+ }
2909
+ return null;
2910
+ }
2911
+ function repositoriesIntakeExemption(record) {
2912
+ const entry = record && record.intakeExemption;
2913
+ if (!entry || typeof entry !== 'object') return null;
2914
+ const approvedBy = typeof entry.approvedBy === 'string' ? entry.approvedBy.trim() : '';
2915
+ const reason = typeof entry.reason === 'string' ? entry.reason.trim() : '';
2916
+ const at = typeof entry.at === 'string' ? entry.at.trim() : '';
2917
+ if (approvedBy === '' || reason.length < 10 || !EXEMPTION_DATE.test(at)) return null;
2918
+ return { approvedBy, reason, at };
2919
+ }
2920
+ const repositoriesGateApplies = Boolean(finishedAttempt)
2921
+ && (completedAgent === 'task-router' || (!hadPriorCompletion && completedStepIndex === 0));
2922
+ if (repositoriesGateApplies) {
2923
+ const violation = repositoriesIntakeViolation(pipeline);
2924
+ if (violation) {
2925
+ const exemption = repositoriesIntakeExemption(pipeline);
2926
+ if (!exemption) {
2927
+ appendMetric({ type: 'intake_repositories_blocked', at: now, stepIndex: completedStepIndex, agent: completedAgent, violation, source: 'hook', attributionConfidence: 'high' });
2928
+ writeStatus({ state: 'blocked', phase: 'blocked', currentAgent: 'task-router' });
2929
+ out(`pipeline.json for "${slug}" ${violation}. Intake stays open until the repositories are recorded: set "repositories" to the ids in .ai.local/team/repositories.json with "repositoriesInference": "evidence-paths" (or "repo-scope-only"), or "repositories": [] with "repositoriesInference": "unknown" when the request names none. Rewrite pipeline.json through the task-router, then resume via /task-continue ${slug}. A task that predates the invariant carries "intakeExemption": { "approvedBy": "<human>", "reason": "<why, 10+ characters>", "at": "YYYY-MM-DD" } — a bare boolean is not accepted.`);
2930
+ process.exit(0);
2931
+ }
2932
+ appendMetric({ type: 'intake_repositories_exempted', at: now, stepIndex: completedStepIndex, agent: completedAgent, violation, approvedBy: exemption.approvedBy, reason: exemption.reason, exemptedAt: exemption.at, source: 'hook', attributionConfidence: 'high' });
2933
+ }
2934
+ }
2935
+ if (pipeline.autoChain === false) {
2936
+ writeStatus({});
2937
+ process.stdout.write('{}');
2938
+ process.exit(0);
2939
+ }
2940
+
2873
2941
 
2874
2942
  if (waveIndexes) {
2875
2943
  const waveAgents = waveIndexes.flatMap((i) => getStepAgents(steps[i]));
@@ -171,6 +171,8 @@ Do **not** add a dedicated `spec-author` agent for `docs/specs/**`. Do not requi
171
171
 
172
172
  **specMode (optional `pipeline.json` field):** `none` for spike/research; `generate` for `spec-gen` / `/spec-start`; `consume` default when INDEX exists. Echo top-level `specMode`. Brief `## Spec mode` wins on conflict.
173
173
 
174
+ **repositories (mandatory `pipeline.json` field):** echo `"repositories": [<ids>]` and `"repositoriesInference": "evidence-paths" | "repo-scope-only" | "unknown" | "ambiguous"` immediately after `specMode`, before `summary`; the ids come from `.ai.local/team/repositories.json` and are never defaulted to the workspace repository. Then record the same list as link rows through `node .ai.local/scripts/team-db.mjs repositories apply --file -` — one `{"links": [{taskSlug, repositoryId, source: "intake", inference: "evidence-paths"}]}` envelope per touched repository (the verb takes the envelope, never a bare row). When the request names no repository, write `"repositories": []` with `"unknown"` and one `{"attributions": [{taskSlug, verdict: "unknown", evidence: ""}]}` envelope; `yarn check:task-repositories` fails a folder without the field.
175
+
174
176
  Do **not** add a pipeline step for `spec-discovery`. Instruct analyst to load that skill only when the user/AC asks research-before-spec.
175
177
 
176
178
  ## Runtime initialization
@@ -11,6 +11,7 @@ Slash commands are copied to `.claude/commands/` on `ai-rules init claude --pres
11
11
  | `/technical-retro [slug]` | Retro; with slug — “Agent work” block |
12
12
  | `update.md` | Reinstall each installed tool with the preset recorded at init |
13
13
  | `migrate-tasks.md` | Create or reconcile `.ai.local/team/team.db`; writes only the delta |
14
+ | `rr-migrate-repositories.md` | Scan repositories on disk, add the missing ones to the local registry, and project the file into `team.db` |
14
15
 
15
16
  ## `/task` examples
16
17
 
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: rr-migrate-repositories
3
+ description: Scan repositories on disk, add the missing ones to the local registry, and project the file into team.db.
4
+ ---
5
+
6
+ # Migrate repositories
7
+
8
+ Turn the repositories already cloned on this machine into registry records, then
9
+ sync the registry file into the team database.
10
+
11
+ ## What to do
12
+
13
+ 1. From the repository root, run:
14
+
15
+ ```bash
16
+ node .ai.local/scripts/rr-migrate-repositories.mjs
17
+ ```
18
+
19
+ 2. Report the summary in the user's native language, keeping the counters
20
+ verbatim: `scanned`, `repositories`, `duplicates`, `create`, `update`,
21
+ `unchanged`, `not-on-disk`, and the `project` line.
22
+ 3. A `disabled by AI_RULES_TEAM_DB_DISABLE` line means the plan was computed and
23
+ nothing was written; exit 0 is the documented fallback. Relay it and stop.
24
+ 4. Any non-zero exit: quote stderr and stop.
25
+
26
+ ## Arguments
27
+
28
+ - `--scan <dir>` — directory to scan; repeatable. Default: the parent of the
29
+ repository root (the repository root itself when its parent is `$HOME`), so
30
+ sibling clones are picked up.
31
+ - `--depth <n>` — directory levels below a scan root (default `4`).
32
+ - `--dry-run` — print the plan and write nothing.
33
+ - `--no-update` — create missing records only; never touch an existing one.
34
+ - `--team-root <dir>` — team store root (default `<repo-root>/.ai.local/team`).
35
+ - `--json` — machine-readable summary.
36
+
37
+ ## What the script does
38
+
39
+ - Walks the scan roots; a directory with `.git` is a repository and is not
40
+ descended into. Submodule checkouts and linked worktrees are skipped.
41
+ - Collapses clones that share one remote to the shallowest path.
42
+ - Keeps the id of a record whose locator already exists, so a re-run is
43
+ idempotent; a new id is the slug of the directory name, with a parent prefix
44
+ when that slug is taken.
45
+ - Creates missing records through `team-db.mjs repositories apply`, updates a
46
+ changed `name`, `locator`, or `status` through `repositories put`, then runs
47
+ `repositories project`. The lock-guarded verb is the only writer.
48
+ - Never deletes a record: a repository missing from this scan may simply live
49
+ outside the scanned roots.
50
+
51
+ `.ai.local/team/repositories.json` is local-only and git-ignored. The database is
52
+ derived: deleting `team.db` costs a rebuild, not the records.
53
+
54
+ ## Do not
55
+
56
+ - Hand-edit `.ai.local/team/repositories.json`; the verb owns the write lock.
57
+ - Commit the registry file or `team.db*`.
58
+ - Delete registry records to make a scan look clean.
59
+ - Pass `--scan` a filesystem root without a matching `--depth`.
@@ -44,6 +44,10 @@ Examples:
44
44
  6. **After each agent** — wait for hook handoff / reconciliation of the terminal receipt → `status.state`; do not start the next step until `status.json` reflects the handoff (or until there is a hook `followup_message`).
45
45
  7. **Human gate** — if after the current step there is a gate in `humanGates` (`after:<agent>`), after the agent finishes **stop** and ask for `/task-continue <slug>`.
46
46
 
47
+ ## Repositories (mandatory)
48
+
49
+ The repositories a task touches are part of its intake: `pipeline.json` must carry `"repositories": [<registry ids>]`, or `"repositories": []` together with `"repositoriesInference": "unknown"` when the request names none. The router reads `.ai.local/team/repositories.json` and records the same list as link rows; the field is never defaulted; `node .ai.local/scripts/check-task-repositories.mjs` audits the store and the chain hook blocks a task-router receipt that omits it. See `agents/task-router.md`.
50
+
47
51
  ## Plan contract
48
52
 
49
53
  Intake runs the planning workflow before any implementation: **goal frame** (goal, user value, success + result-evaluation criteria) → **requirements + AC-IDs** → **information-sufficiency** verdict (`sufficient` | `insufficient`) → decompose with a **dependency graph** (`dependsOn[]`, DAG, critical path) and, for large flows, **epics / stages** with exit criteria. The plan is revisable: a **plan revision** is a named, recorded operation (`planRevision`), and progress is checkpointed to `.memlog.md` (with the optional `contextBudget` note) so a run can resume.
@@ -2955,6 +2955,10 @@ if (status.state === 'awaiting_artifact_receipt') {
2955
2955
  emitArtifactStall(artifactStallMessage, !wasWaitingForReceipt);
2956
2956
  process.exit(0);
2957
2957
  }
2958
+ // Snapshot before `finishActiveAttempt` writes `lastCompletedAttempt`: the
2959
+ // repositories intake gate judges a task at its first receipt, so a folder whose
2960
+ // first step already completed is never re-judged.
2961
+ const hadPriorCompletion = Boolean(status.lastCompletedAttempt);
2958
2962
  let finishedAttempt = finishActiveAttempt();
2959
2963
  // The just-finished attempt's metric is already written; a pause now blocks
2960
2964
  // every handoff, including the unattributable-stop repair path below.
@@ -2982,7 +2986,7 @@ if (!finishedAttempt && activeAttemptCountBeforeFinish > 0) {
2982
2986
  }
2983
2987
  }
2984
2988
  endHumanGateIfResumed();
2985
- if (steps.length === 0 || pipeline.autoChain === false) {
2989
+ if (steps.length === 0) {
2986
2990
  writeStatus({});
2987
2991
  process.stdout.write('{}');
2988
2992
  process.exit(0);
@@ -3029,6 +3033,70 @@ const waveIndexes = activeWave
3029
3033
  ? [idx]
3030
3034
  : (isGraphMode() && finishedAttempt ? [completedStepIndex] : null));
3031
3035
 
3036
+ /**
3037
+ * Intake invariant: a task records which repositories it touches — or says that
3038
+ * it does not know. Judged on the first receipt of a task: the router's, or the
3039
+ * first step's when a pipeline runs without one. A task that already completed a
3040
+ * step predates the invariant and is never re-judged.
3041
+ * `intakeExemption: { approvedBy, reason, at }` is the recorded escape hatch; a
3042
+ * bare boolean does not count, so an exemption always names who approved it. The
3043
+ * shape mirrors `check-task-repositories.mjs`, which audits the same field after
3044
+ * the fact.
3045
+ */
3046
+ const REPOSITORY_INFERENCES = new Set(['evidence-paths', 'repo-scope-only', 'unknown', 'ambiguous']);
3047
+ const EXEMPTION_DATE = /^\d{4}-\d{2}-\d{2}$/;
3048
+ function repositoriesIntakeViolation(record) {
3049
+ if (!record) return 'has no `repositories` array';
3050
+ const ids = record.repositories;
3051
+ const inference = record.repositoriesInference;
3052
+ if (!Array.isArray(ids)) return 'carries no `repositories` array';
3053
+ if (ids.some((id) => typeof id !== 'string' || id.trim() === '')) return 'carries a `repositories` entry that is not a non-empty registry id';
3054
+ if (ids.length === 0) {
3055
+ return inference === 'unknown' ? null : 'carries `repositories: []` without `"repositoriesInference": "unknown"`';
3056
+ }
3057
+ if (inference !== undefined && !REPOSITORY_INFERENCES.has(inference)) return `carries an unknown \`repositoriesInference\` value "${inference}"`;
3058
+ if (inference === 'unknown') return 'lists repositories beside `"repositoriesInference": "unknown"`';
3059
+ let known = null;
3060
+ try {
3061
+ const registry = JSON.parse(fs.readFileSync(path.join(TEAM_ROOT, 'repositories.json'), 'utf8'));
3062
+ known = new Set((Array.isArray(registry.repositories) ? registry.repositories : []).map((row) => row && row.id).filter((id) => typeof id === 'string'));
3063
+ } catch { known = null; }
3064
+ if (known && known.size > 0) {
3065
+ const unknownIds = ids.filter((id) => !known.has(id));
3066
+ if (unknownIds.length > 0) return `names ${unknownIds.join(', ')} — not in .ai.local/team/repositories.json`;
3067
+ }
3068
+ return null;
3069
+ }
3070
+ function repositoriesIntakeExemption(record) {
3071
+ const entry = record && record.intakeExemption;
3072
+ if (!entry || typeof entry !== 'object') return null;
3073
+ const approvedBy = typeof entry.approvedBy === 'string' ? entry.approvedBy.trim() : '';
3074
+ const reason = typeof entry.reason === 'string' ? entry.reason.trim() : '';
3075
+ const at = typeof entry.at === 'string' ? entry.at.trim() : '';
3076
+ if (approvedBy === '' || reason.length < 10 || !EXEMPTION_DATE.test(at)) return null;
3077
+ return { approvedBy, reason, at };
3078
+ }
3079
+ const repositoriesGateApplies = Boolean(finishedAttempt)
3080
+ && (completedAgent === 'task-router' || (!hadPriorCompletion && completedStepIndex === 0));
3081
+ if (repositoriesGateApplies) {
3082
+ const violation = repositoriesIntakeViolation(pipeline);
3083
+ if (violation) {
3084
+ const exemption = repositoriesIntakeExemption(pipeline);
3085
+ if (!exemption) {
3086
+ appendMetric({ type: 'intake_repositories_blocked', at: now, stepIndex: completedStepIndex, agent: completedAgent, violation, source: 'hook', attributionConfidence: 'high' });
3087
+ writeStatus({ state: 'blocked', phase: 'blocked', currentAgent: 'task-router' });
3088
+ out(`pipeline.json for "${slug}" ${violation}. Intake stays open until the repositories are recorded: set "repositories" to the ids in .ai.local/team/repositories.json with "repositoriesInference": "evidence-paths" (or "repo-scope-only"), or "repositories": [] with "repositoriesInference": "unknown" when the request names none. Rewrite pipeline.json through the task-router, then resume via /task-continue ${slug}. A task that predates the invariant carries "intakeExemption": { "approvedBy": "<human>", "reason": "<why, 10+ characters>", "at": "YYYY-MM-DD" } — a bare boolean is not accepted.`);
3089
+ process.exit(0);
3090
+ }
3091
+ appendMetric({ type: 'intake_repositories_exempted', at: now, stepIndex: completedStepIndex, agent: completedAgent, violation, approvedBy: exemption.approvedBy, reason: exemption.reason, exemptedAt: exemption.at, source: 'hook', attributionConfidence: 'high' });
3092
+ }
3093
+ }
3094
+ if (pipeline.autoChain === false) {
3095
+ writeStatus({});
3096
+ process.stdout.write('{}');
3097
+ process.exit(0);
3098
+ }
3099
+
3032
3100
 
3033
3101
  if (waveIndexes) {
3034
3102
  const waveAgents = waveIndexes.flatMap((i) => getStepAgents(steps[i]));
@@ -160,6 +160,8 @@ Do **not** add a dedicated `spec-author` agent for `docs/specs/**`. Do not requi
160
160
 
161
161
  **specMode (optional `pipeline.json` field):** `none` for spike/research; `generate` for `spec-gen` / `/spec-start`; `consume` default when INDEX exists. Echo top-level `specMode`. Brief `## Spec mode` wins on conflict.
162
162
 
163
+ **repositories (mandatory `pipeline.json` field):** echo `"repositories": [<ids>]` and `"repositoriesInference": "evidence-paths" | "repo-scope-only" | "unknown" | "ambiguous"` immediately after `specMode`, before `summary`; the ids come from `.ai.local/team/repositories.json` and are never defaulted to the workspace repository. Then record the same list as link rows through `node .ai.local/scripts/team-db.mjs repositories apply --file -` — one `{"links": [{taskSlug, repositoryId, source: "intake", inference: "evidence-paths"}]}` envelope per touched repository (the verb takes the envelope, never a bare row). When the request names no repository, write `"repositories": []` with `"unknown"` and one `{"attributions": [{taskSlug, verdict: "unknown", evidence: ""}]}` envelope; `yarn check:task-repositories` fails a folder without the field.
164
+
163
165
  Do **not** add a pipeline step for `spec-discovery`. Instruct analyst to load that skill only when the user/AC asks research-before-spec.
164
166
 
165
167
  ## Runtime initialization
@@ -9,6 +9,7 @@ Slash-command and on-demand scenario definitions. Copied to `.claude/commands/`
9
9
  | `technical-retro.md` | Facilitate a technical retro, including the “Agent work” block |
10
10
  | `update.md` | Reinstall each installed tool with the preset recorded at init |
11
11
  | `migrate-tasks.md` | Create or reconcile `.ai.local/team/team.db`; writes only the delta |
12
+ | `rr-migrate-repositories.md` | Scan repositories on disk, add the missing ones to the local registry, and project the file into `team.db` |
12
13
 
13
14
  See also the preset root `README.md`. Artifacts: `.ai.local/team/README.md`.
14
15
 
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: rr-migrate-repositories
3
+ description: Scan repositories on disk, add the missing ones to the local registry, and project the file into team.db.
4
+ ---
5
+
6
+ # Migrate repositories
7
+
8
+ Turn the repositories already cloned on this machine into registry records, then
9
+ sync the registry file into the team database.
10
+
11
+ ## What to do
12
+
13
+ 1. From the repository root, run:
14
+
15
+ ```bash
16
+ node .ai.local/scripts/rr-migrate-repositories.mjs
17
+ ```
18
+
19
+ 2. Report the summary in the user's native language, keeping the counters
20
+ verbatim: `scanned`, `repositories`, `duplicates`, `create`, `update`,
21
+ `unchanged`, `not-on-disk`, and the `project` line.
22
+ 3. A `disabled by AI_RULES_TEAM_DB_DISABLE` line means the plan was computed and
23
+ nothing was written; exit 0 is the documented fallback. Relay it and stop.
24
+ 4. Any non-zero exit: quote stderr and stop.
25
+
26
+ ## Arguments
27
+
28
+ - `--scan <dir>` — directory to scan; repeatable. Default: the parent of the
29
+ repository root (the repository root itself when its parent is `$HOME`), so
30
+ sibling clones are picked up.
31
+ - `--depth <n>` — directory levels below a scan root (default `4`).
32
+ - `--dry-run` — print the plan and write nothing.
33
+ - `--no-update` — create missing records only; never touch an existing one.
34
+ - `--team-root <dir>` — team store root (default `<repo-root>/.ai.local/team`).
35
+ - `--json` — machine-readable summary.
36
+
37
+ ## What the script does
38
+
39
+ - Walks the scan roots; a directory with `.git` is a repository and is not
40
+ descended into. Submodule checkouts and linked worktrees are skipped.
41
+ - Collapses clones that share one remote to the shallowest path.
42
+ - Keeps the id of a record whose locator already exists, so a re-run is
43
+ idempotent; a new id is the slug of the directory name, with a parent prefix
44
+ when that slug is taken.
45
+ - Creates missing records through `team-db.mjs repositories apply`, updates a
46
+ changed `name`, `locator`, or `status` through `repositories put`, then runs
47
+ `repositories project`. The lock-guarded verb is the only writer.
48
+ - Never deletes a record: a repository missing from this scan may simply live
49
+ outside the scanned roots.
50
+
51
+ `.ai.local/team/repositories.json` is local-only and git-ignored. The database is
52
+ derived: deleting `team.db` costs a rebuild, not the records.
53
+
54
+ ## Do not
55
+
56
+ - Hand-edit `.ai.local/team/repositories.json`; the verb owns the write lock.
57
+ - Commit the registry file or `team.db*`.
58
+ - Delete registry records to make a scan look clean.
59
+ - Pass `--scan` a filesystem root without a matching `--depth`.
@@ -41,6 +41,10 @@ Examples:
41
41
  6. **After each agent** — wait for hook handoff / reconciliation terminal receipt → `status.state`; do not start the next step until `status.json` reflects handoff (or until hook returns `followup_message`).
42
42
  7. **Human gate** — if there is a gate in `humanGates` after the current step (`after:<agent>`), **stop** after the agent finishes and ask for `/task-continue <slug>`.
43
43
 
44
+ ## Repositories (mandatory)
45
+
46
+ The repositories a task touches are part of its intake: `pipeline.json` must carry `"repositories": [<registry ids>]`, or `"repositories": []` together with `"repositoriesInference": "unknown"` when the request names none. The router reads `.ai.local/team/repositories.json` and records the same list as link rows; the field is never defaulted; `node .ai.local/scripts/check-task-repositories.mjs` audits the store and the chain hook blocks a task-router receipt that omits it. See `agents/task-router.md`.
47
+
44
48
  ## Plan contract
45
49
 
46
50
  Intake runs the planning workflow before any implementation: **goal frame** (goal, user value, success + result-evaluation criteria) → **requirements + AC-IDs** → **information-sufficiency** verdict (`sufficient` | `insufficient`) → decompose with a **dependency graph** (`dependsOn[]`, DAG, critical path) and, for large flows, **epics / stages** with exit criteria. The plan is revisable: a **plan revision** is a named, recorded operation (`planRevision`), and progress is checkpointed to `.memlog.md` (with the optional `contextBudget` note) so a run can resume.