@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
@@ -105,6 +105,9 @@ export const TRACKER_ITEM_BODY_MAX = 16384;
105
105
  export const TRACKER_TASK_BODY_MAX = 65536;
106
106
  export const TRACKER_TASK_ACTION_BODY_MAX = 1024;
107
107
  export const TRACKER_QUEUE_BODY_MAX = 1024;
108
+ export const REPOSITORY_BODY_MAX = 16384;
109
+ export const REPOSITORY_WRITE_CHILD_TIMEOUT_MS = 10000;
110
+ export const REPOSITORY_DELETE_CHILD_TIMEOUT_MS = 30000;
108
111
  export const TRACKER_WRITE_CHILD_TIMEOUT_MS = 10000;
109
112
  export const TRACKER_DELETE_CHILD_TIMEOUT_MS = 30000;
110
113
  export const TRACKER_DEFAULT_LIMIT = 50;
@@ -152,6 +155,7 @@ const CODE_STATUS_ROWS = [
152
155
  ['E_DOC_CONTENT_OMITTED', 409],
153
156
  ['E_ACTIVE_TASK', 409],
154
157
  ['E_CONFLICT', 409],
158
+ ['E_REPOSITORY_IN_USE', 409],
155
159
  ['E_SCHEDULER_OFFLINE', 409],
156
160
  ['E_RANGE', 416],
157
161
  ['E_DISABLED', 503],
@@ -191,14 +195,25 @@ const TASK_FILTER = `
191
195
  AND (?7 = '' OR t.updated_at <= ?7)
192
196
  AND (?8 = 0 OR t.slug IN (SELECT value FROM json_each(?9)))`;
193
197
 
198
+ /**
199
+ * The repository filter of the task list. A separate fragment on purpose: the
200
+ * twelve statements that share `TASK_FILTER` bind exactly its nine slots.
201
+ */
202
+ const TASK_REPOSITORY_FILTER = `
203
+ AND (
204
+ ?10 = '' OR EXISTS (
205
+ SELECT 1 FROM task_repositories tr WHERE tr.task_slug = t.slug AND tr.repository_id = ?10
206
+ )
207
+ )`;
208
+
194
209
  const TASK_ORDER = `
195
210
  ORDER BY
196
- CASE ?10 WHEN 'slug' THEN t.slug END ASC NULLS LAST,
197
- CASE ?10 WHEN '-slug' THEN t.slug END DESC NULLS LAST,
198
- CASE ?10 WHEN 'updatedAt' THEN t.updated_at END ASC NULLS LAST,
199
- CASE ?10 WHEN '-updatedAt' THEN t.updated_at END DESC NULLS LAST,
200
- CASE ?10 WHEN 'startAt' THEN t.start_at END ASC NULLS LAST,
201
- CASE ?10 WHEN '-startAt' THEN t.start_at END DESC NULLS LAST,
211
+ CASE ?11 WHEN 'slug' THEN t.slug END ASC NULLS LAST,
212
+ CASE ?11 WHEN '-slug' THEN t.slug END DESC NULLS LAST,
213
+ CASE ?11 WHEN 'updatedAt' THEN t.updated_at END ASC NULLS LAST,
214
+ CASE ?11 WHEN '-updatedAt' THEN t.updated_at END DESC NULLS LAST,
215
+ CASE ?11 WHEN 'startAt' THEN t.start_at END ASC NULLS LAST,
216
+ CASE ?11 WHEN '-startAt' THEN t.start_at END DESC NULLS LAST,
202
217
  t.slug ASC`;
203
218
 
204
219
  const ATTEMPT_ORDER = `
@@ -257,9 +272,9 @@ const SQL = {
257
272
  (SELECT CASE WHEN json_valid(d.content) THEN json_extract(d.content, '$.task.platform') END
258
273
  FROM documents d WHERE d.task_slug = t.slug AND d.path = 'metrics.json') AS platform
259
274
  FROM tasks t
260
- WHERE ${TASK_FILTER}${TASK_ORDER}
261
- LIMIT ?11 OFFSET ?12`,
262
- countTasks: `SELECT count(*) AS total FROM tasks t WHERE ${TASK_FILTER}`,
275
+ WHERE ${TASK_FILTER}${TASK_REPOSITORY_FILTER}${TASK_ORDER}
276
+ LIMIT ?12 OFFSET ?13`,
277
+ countTasks: `SELECT count(*) AS total FROM tasks t WHERE ${TASK_FILTER}${TASK_REPOSITORY_FILTER}`,
263
278
  getTask: `SELECT
264
279
  t.slug, t.title, t.intent, t.profile, t.spec_mode, t.state, t.phase,
265
280
  t.pipeline_index, t.current_agent, t.awaiting_human_gate, t.updated_at,
@@ -327,6 +342,21 @@ const SQL = {
327
342
  SELECT * FROM items ORDER BY at ASC NULLS LAST LIMIT ?2 OFFSET ?3`,
328
343
  listPrompts: `SELECT seq, source, command, captured_at, language, content, sha256, bytes
329
344
  FROM prompts WHERE task_slug = ?1 ORDER BY seq ASC`,
345
+ listTaskRepositories: `SELECT r.id, r.name, r.status
346
+ FROM task_repositories tr JOIN repositories r ON r.id = tr.repository_id
347
+ WHERE tr.task_slug = ?1 AND r.absent_at IS NULL
348
+ ORDER BY r.name COLLATE NOCASE, r.id`,
349
+ listRepositoryInferences: 'SELECT inference FROM task_repositories WHERE task_slug = ?1',
350
+ getTaskAttribution: 'SELECT verdict FROM task_repository_attributions WHERE task_slug = ?1',
351
+ listRepositories: `SELECT r.*,
352
+ (SELECT count(*) FROM task_repositories tr WHERE tr.repository_id = r.id) AS linked_task_count
353
+ FROM repositories r WHERE r.absent_at IS NULL
354
+ ORDER BY r.status, r.name COLLATE NOCASE, r.id
355
+ LIMIT ?1 OFFSET ?2`,
356
+ countRepositories: 'SELECT count(*) AS total FROM repositories r WHERE r.absent_at IS NULL',
357
+ getRepository: `SELECT r.*,
358
+ (SELECT count(*) FROM task_repositories tr WHERE tr.repository_id = r.id) AS linked_task_count
359
+ FROM repositories r WHERE r.id = ?1 AND r.absent_at IS NULL`,
330
360
  eventCounts: `SELECT type, count(*) AS count FROM events WHERE task_slug = ?1 GROUP BY type ORDER BY type`,
331
361
  attemptsByAgent: `SELECT agent, count(*) AS attempts, COALESCE(SUM(duration_ms), 0) AS duration
332
362
  FROM attempts WHERE task_slug = ?1 GROUP BY agent ORDER BY duration DESC, agent ASC`,
@@ -693,11 +723,13 @@ const taskFilters = (db, query, includeAbsentDefault = false) => {
693
723
  const to = parseInstant(query.get('to'), 'to');
694
724
  if (from && to && from > to) fail('E_VALIDATION', 422, 'from must not be later than to', { parameter: 'from' });
695
725
  const q = parseQuery(query.get('q'), 'q');
726
+ const repository = parsePattern(query.get('repository'), 'repository', slugPattern, 48);
696
727
  // An active search with no matches is an empty result set, not "no filter".
697
728
  const searchActive = q === '' ? 0 : 1;
698
729
  const slugs = searchActive === 1 ? searchSlugs(db, q) : [];
699
730
  return {
700
731
  includeAbsent,
732
+ repository,
701
733
  params: [includeAbsent ? 1 : 0, JSON.stringify(states), agent, intent, profile, from, to, searchActive, JSON.stringify(slugs)],
702
734
  };
703
735
  };
@@ -759,12 +791,28 @@ const listTasks = (db, query) => {
759
791
  const limit = parseInteger(query.get('limit'), 'limit', { min: 1, max: MAX_LIMIT, fallback: DEFAULT_LIMIT });
760
792
  const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_OFFSET, fallback: 0 });
761
793
  const sort = parseEnum(query.get('sort'), 'sort', SORT_VALUE_SET, '-updatedAt');
762
- const { params } = taskFilters(db, query);
763
- const rows = db.prepare(SQL.listTasks).all(...params, sort, limit, offset);
764
- const total = Number(db.prepare(SQL.countTasks).get(...params).total);
794
+ const { params, repository } = taskFilters(db, query);
795
+ // Contiguous slots: `?1..?9` filters, `?10` repository, `?11` sort,
796
+ // `?12`/`?13` the page. A gap makes `node:sqlite` refuse the statement.
797
+ const rows = db.prepare(SQL.listTasks).all(...params, repository, sort, limit, offset);
798
+ const total = Number(db.prepare(SQL.countTasks).get(...params, repository).total);
765
799
  return page(rows.map(taskRow), total, limit, offset);
766
800
  };
767
801
 
802
+ /**
803
+ * The task-level repository verdict.
804
+ *
805
+ * Links outrank the attribution, so a contradictory file can never report
806
+ * "not recorded" beside a non-empty array; `unknown` is the total fallback.
807
+ */
808
+ const taskRepositoriesInference = (db, slug) => {
809
+ const links = db.prepare(SQL.listRepositoryInferences).all(slug);
810
+ if (links.some((row) => row.inference === 'evidence-paths')) return 'evidence-paths';
811
+ if (links.length > 0) return 'repo-scope-only';
812
+ const verdict = db.prepare(SQL.getTaskAttribution).get(slug)?.verdict;
813
+ return verdict === 'unknown' || verdict === 'ambiguous' ? verdict : 'unknown';
814
+ };
815
+
768
816
  const getTaskDetail = (db, slug) => {
769
817
  const row = getTaskRow(db, slug);
770
818
  let decision = {};
@@ -786,6 +834,11 @@ const getTaskDetail = (db, slug) => {
786
834
  documents: row.document_count ?? 0,
787
835
  },
788
836
  hasPrompt: (row.prompt_count ?? 0) > 0,
837
+ repositories: db
838
+ .prepare(SQL.listTaskRepositories)
839
+ .all(slug)
840
+ .map((link) => ({ id: link.id, name: link.name, status: link.status })),
841
+ repositoriesInference: taskRepositoriesInference(db, slug),
789
842
  };
790
843
  };
791
844
 
@@ -2164,6 +2217,133 @@ const deleteJob = async (context) => {
2164
2217
  return { json: { ok: true, id: String(result.id ?? id), runsRemoved: Number(result.runsRemoved ?? 0) } };
2165
2218
  };
2166
2219
 
2220
+ /* ------------------------------- repositories ----------------------------- */
2221
+
2222
+ const parseRepositoryId = (value) => {
2223
+ if (typeof value !== 'string' || value.length > 48 || !slugPattern.test(value)) {
2224
+ fail('E_VALIDATION', 422, 'the repository id has an invalid shape', { parameter: 'id' });
2225
+ }
2226
+ return value;
2227
+ };
2228
+
2229
+ const repositoryLabels = (json) => {
2230
+ if (json === null || json === undefined) return null;
2231
+ try {
2232
+ const parsed = JSON.parse(json);
2233
+ return Array.isArray(parsed) ? parsed.map((label) => String(label)) : null;
2234
+ } catch {
2235
+ return null;
2236
+ }
2237
+ };
2238
+
2239
+ const repositoryRow = (row) => ({
2240
+ id: row.id,
2241
+ name: row.name,
2242
+ locator: row.locator,
2243
+ description: row.description ?? null,
2244
+ labels: repositoryLabels(row.labels_json),
2245
+ status: row.status,
2246
+ revision: row.revision,
2247
+ createdAt: row.created_at,
2248
+ updatedAt: row.updated_at,
2249
+ });
2250
+
2251
+ const repositorySummaryRow = (row) => ({
2252
+ ...repositoryRow(row),
2253
+ linkedTaskCount: Number(row.linked_task_count ?? 0),
2254
+ });
2255
+
2256
+ const listRepositories = (db, query) => {
2257
+ const limit = parseInteger(query.get('limit'), 'limit', { min: 1, max: MAX_LIMIT, fallback: DEFAULT_LIMIT });
2258
+ const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_OFFSET, fallback: 0 });
2259
+ const rows = db.prepare(SQL.listRepositories).all(limit, offset);
2260
+ const total = Number(db.prepare(SQL.countRepositories).get().total);
2261
+ return page(rows.map(repositorySummaryRow), total, limit, offset);
2262
+ };
2263
+
2264
+ const requireRepositoryRow = (db, id) => {
2265
+ const row = db.prepare(SQL.getRepository).get(id);
2266
+ if (!row) fail('E_NOT_FOUND', 404, `no repository "${id}" in the projection`);
2267
+ return row;
2268
+ };
2269
+
2270
+ const getRepositoryDetail = (db, id) => repositorySummaryRow(requireRepositoryRow(db, id));
2271
+
2272
+ const repositoryBody = (context) => {
2273
+ const text = context.body.toString('utf8').trim();
2274
+ if (text === '') fail('E_VALIDATION', 422, 'a repository body is required', { parameter: 'body' });
2275
+ let parsed;
2276
+ try {
2277
+ parsed = JSON.parse(text);
2278
+ } catch {
2279
+ fail('E_VALIDATION', 422, 'the repository body is not valid JSON', { parameter: 'body' });
2280
+ }
2281
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
2282
+ fail('E_VALIDATION', 422, 'the repository body must be an object', { parameter: 'body' });
2283
+ }
2284
+ return parsed;
2285
+ };
2286
+
2287
+ /**
2288
+ * `POST` creates the body's `id`; `PUT` refuses a body id that differs from
2289
+ * the path id. Both write one record through the lock-guarded child.
2290
+ */
2291
+ const createOrUpdateRepository = async (context, mode) => {
2292
+ const parsed = repositoryBody(context);
2293
+ const pathId = mode === 'update' ? parseRepositoryId(context.params.id) : null;
2294
+ if (mode === 'update' && parsed.id !== undefined && parsed.id !== pathId) {
2295
+ fail('E_CONFLICT', 409, 'the body id differs from the path id; the id is immutable');
2296
+ }
2297
+ if (mode === 'create') {
2298
+ const existing = parsed.id === undefined ? null : context.db().prepare(SQL.getRepository).get(parsed.id);
2299
+ if (existing) fail('E_CONFLICT', 409, `a repository with the id "${parsed.id}" already exists`);
2300
+ }
2301
+ const body = JSON.stringify(mode === 'update' ? { ...parsed, id: pathId } : parsed);
2302
+ const result = await runTeamDbChild(['repositories', 'put', '--file', '-'], {
2303
+ settings: context.settings,
2304
+ timeoutMs: REPOSITORY_WRITE_CHILD_TIMEOUT_MS,
2305
+ input: body,
2306
+ label: 'repository write',
2307
+ });
2308
+ if (result.ok !== true) {
2309
+ const code = typeof result.code === 'string' ? result.code : 'E_INTERNAL';
2310
+ const details = typeof result.parameter === 'string' ? { parameter: result.parameter } : undefined;
2311
+ fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(result.message ?? 'the repository write was refused'), details);
2312
+ }
2313
+ return { json: result.repository, status: mode === 'create' ? 201 : 200 };
2314
+ };
2315
+
2316
+ /**
2317
+ * The delete guard: `N > 0` without `force` answers 409 with the count, and
2318
+ * `force` removes the record and every link in the same write.
2319
+ */
2320
+ const deleteRepository = async (context) => {
2321
+ const id = parseRepositoryId(context.params.id);
2322
+ requireRepositoryRow(context.db(), id);
2323
+ const force = parseBoolean(context.query.get('force'), 'force', false);
2324
+ const revision = context.query.get('revision') === null
2325
+ ? undefined
2326
+ : parseInteger(context.query.get('revision'), 'revision', { min: 1, max: 2_147_483_647, fallback: undefined });
2327
+ const args = ['repositories', 'delete', id];
2328
+ if (force) args.push('--force');
2329
+ if (revision !== undefined) args.push('--revision', String(revision));
2330
+ const result = await runTeamDbChild(args, {
2331
+ settings: context.settings,
2332
+ timeoutMs: REPOSITORY_DELETE_CHILD_TIMEOUT_MS,
2333
+ label: 'repository delete',
2334
+ });
2335
+ if (result.ok !== true) {
2336
+ const code = typeof result.code === 'string' ? result.code : 'E_INTERNAL';
2337
+ if (code === 'E_REPOSITORY_IN_USE') {
2338
+ fail('E_REPOSITORY_IN_USE', 409, String(result.message ?? `removing ${id} was refused`), {
2339
+ linkedTasks: Number(result.linkedTasks ?? 0),
2340
+ });
2341
+ }
2342
+ fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(result.message ?? `removing ${id} was refused`));
2343
+ }
2344
+ return { json: { ok: true, id: String(result.id ?? id), linksRemoved: Number(result.linksRemoved ?? 0) } };
2345
+ };
2346
+
2167
2347
  /**
2168
2348
  * Run-now is refused **before any enqueue** when no scheduler holds a fresh
2169
2349
  * lease: the request could never be claimed, and "requested" with no run is
@@ -3135,6 +3315,25 @@ export const ROUTES = [
3135
3315
  route('POST', '/api/v1/jobs/{id}/run', 'runJobNow', (context) => runJobNow(context), {
3136
3316
  bodyLimit: MAX_REQUEST_BODY_BYTES,
3137
3317
  }),
3318
+ // The repository entries: two paths, five operations. `{id}` is the
3319
+ // contract's slug pattern, so no `pathPatterns` entry is needed.
3320
+ route('GET', '/api/v1/repositories', 'listRepositories', (context) => ({
3321
+ json: listRepositories(context.db(), context.query),
3322
+ })),
3323
+ route('POST', '/api/v1/repositories', 'createRepository', (context) => createOrUpdateRepository(context, 'create'), {
3324
+ bodyLimit: REPOSITORY_BODY_MAX,
3325
+ requireJson: true,
3326
+ }),
3327
+ route('GET', '/api/v1/repositories/{id}', 'getRepository', (context) => ({
3328
+ json: getRepositoryDetail(context.db(), parseRepositoryId(context.params.id)),
3329
+ })),
3330
+ route('PUT', '/api/v1/repositories/{id}', 'updateRepository', (context) => createOrUpdateRepository(context, 'update'), {
3331
+ bodyLimit: REPOSITORY_BODY_MAX,
3332
+ requireJson: true,
3333
+ }),
3334
+ route('DELETE', '/api/v1/repositories/{id}', 'deleteRepository', (context) => deleteRepository(context), {
3335
+ bodyLimit: MAX_REQUEST_BODY_BYTES,
3336
+ }),
3138
3337
  // The tracker entries: `/api/v1/tracker/queue` sits before
3139
3338
  // `/api/v1/tracker/{id}` so the `{id}` pattern can never shadow the literal
3140
3339
  // `queue` segment — the same discipline that keeps `/api/v1/jobs/{id}` from
@@ -116,6 +116,7 @@ export const ERROR_CODES = [
116
116
  'E_SCHEMA_NEWER',
117
117
  'E_BUSY',
118
118
  'E_CONFLICT',
119
+ 'E_REPOSITORY_IN_USE',
119
120
  'E_SCHEDULER_OFFLINE',
120
121
  'E_INTERNAL',
121
122
  ];
@@ -292,8 +293,22 @@ const schemas = {
292
293
  ['events', 'attempts', 'gates', 'prompts', 'documents'],
293
294
  ),
294
295
  hasPrompt: { type: 'boolean' },
296
+ // The task's own verdict never contradicts the array: links outrank the
297
+ // attribution, and `unknown` is the total fallback for a slug with
298
+ // neither.
299
+ repositories: {
300
+ type: 'array',
301
+ description: 'The repositories this task touched, ordered by `name COLLATE NOCASE, id`.',
302
+ items: ref('TaskRepositoryRef'),
303
+ },
304
+ repositoriesInference: {
305
+ type: 'string',
306
+ description:
307
+ 'How the repository list was resolved. Precedence: `evidence-paths` → any link (`repo-scope-only`) → the attribution verdict (`ambiguous`) → `unknown`. `evidence-paths` and `repo-scope-only` are link verdicts; `unknown` and `ambiguous` are attribution verdicts and always come with an empty array.',
308
+ enum: ['evidence-paths', 'repo-scope-only', 'unknown', 'ambiguous'],
309
+ },
295
310
  },
296
- ['task', 'routing', 'counts', 'hasPrompt'],
311
+ ['task', 'routing', 'counts', 'hasPrompt', 'repositories', 'repositoriesInference'],
297
312
  ),
298
313
  PipelineStep: object(
299
314
  {
@@ -1579,6 +1594,87 @@ const schemas = {
1579
1594
  },
1580
1595
  ['requested', 'requestedAt', 'schedulerOnline'],
1581
1596
  ),
1597
+ Repository: object(
1598
+ {
1599
+ id: { type: 'string', pattern: SLUG_PATTERN, minLength: 1, maxLength: 48 },
1600
+ name: { type: 'string', minLength: 1, maxLength: 120 },
1601
+ locator: {
1602
+ type: 'string',
1603
+ minLength: 1,
1604
+ maxLength: 512,
1605
+ description: 'One free-text locator: a remote URL or a filesystem path. No type discriminator in v1.',
1606
+ },
1607
+ description: nullable('string'),
1608
+ labels: { type: ['array', 'null'], items: { type: 'string', minLength: 1, maxLength: 48 }, maxItems: 24 },
1609
+ // Validated on write (`active | archived`), never by a SQL constraint:
1610
+ // the projection serves whatever a hand-edited file says.
1611
+ status: { type: 'string', description: 'The closed write-time vocabulary `active | archived`; `archived` is a status, never a delete.' },
1612
+ revision: { type: 'integer', minimum: 1 },
1613
+ createdAt: { type: 'string' },
1614
+ updatedAt: { type: 'string' },
1615
+ },
1616
+ ['id', 'name', 'locator', 'description', 'labels', 'status', 'revision', 'createdAt', 'updatedAt'],
1617
+ ),
1618
+ RepositorySummary: object(
1619
+ {
1620
+ id: { type: 'string', pattern: SLUG_PATTERN, minLength: 1, maxLength: 48 },
1621
+ name: { type: 'string', minLength: 1, maxLength: 120 },
1622
+ locator: { type: 'string', minLength: 1, maxLength: 512 },
1623
+ description: nullable('string'),
1624
+ labels: { type: ['array', 'null'], items: { type: 'string', minLength: 1, maxLength: 48 }, maxItems: 24 },
1625
+ status: { type: 'string' },
1626
+ revision: { type: 'integer', minimum: 1 },
1627
+ createdAt: { type: 'string' },
1628
+ updatedAt: { type: 'string' },
1629
+ linkedTaskCount: {
1630
+ type: 'integer',
1631
+ minimum: 0,
1632
+ description: 'Computed by the projection from `task_repositories`; the app never counts.',
1633
+ },
1634
+ },
1635
+ ['id', 'name', 'locator', 'description', 'labels', 'status', 'revision', 'createdAt', 'updatedAt', 'linkedTaskCount'],
1636
+ ),
1637
+ RepositoryList: object(
1638
+ {
1639
+ items: { type: 'array', items: ref('RepositorySummary') },
1640
+ total: { type: 'integer', minimum: 0 },
1641
+ limit: { type: 'integer', minimum: 1, maximum: 200 },
1642
+ offset: { type: 'integer', minimum: 0 },
1643
+ nextOffset: nullable('integer'),
1644
+ },
1645
+ ['items', 'total', 'limit', 'offset', 'nextOffset'],
1646
+ ),
1647
+ RepositoryWrite: object(
1648
+ {
1649
+ id: { type: 'string', pattern: SLUG_PATTERN, minLength: 1, maxLength: 48 },
1650
+ name: { type: 'string', minLength: 1, maxLength: 120 },
1651
+ locator: { type: 'string', minLength: 1, maxLength: 512 },
1652
+ description: nullable('string'),
1653
+ labels: { type: ['array', 'null'], items: { type: 'string', minLength: 1, maxLength: 48 }, maxItems: 24 },
1654
+ status: { type: 'string', enum: ['active', 'archived'] },
1655
+ // Optional on create (defaults to 1); required on update, where a
1656
+ // missing or stale value is 409 `E_CONFLICT`.
1657
+ revision: { type: 'integer', minimum: 1 },
1658
+ },
1659
+ ['id', 'name', 'locator', 'status'],
1660
+ ),
1661
+ RepositoryDeleteResult: object(
1662
+ {
1663
+ ok: { type: 'boolean' },
1664
+ id: { type: 'string', pattern: SLUG_PATTERN, minLength: 1, maxLength: 48 },
1665
+ linksRemoved: { type: 'integer', minimum: 0 },
1666
+ },
1667
+ ['ok', 'id', 'linksRemoved'],
1668
+ ),
1669
+ TaskRepositoryRef: object(
1670
+ {
1671
+ id: { type: 'string', pattern: SLUG_PATTERN, minLength: 1, maxLength: 48 },
1672
+ name: { type: 'string' },
1673
+ // A plain string, not an enum: the projection serves the raw value.
1674
+ status: { type: 'string' },
1675
+ },
1676
+ ['id', 'name', 'status'],
1677
+ ),
1582
1678
  TrackerDependency: object(
1583
1679
  {
1584
1680
  id: { type: 'integer', minimum: 1 },
@@ -1943,6 +2039,8 @@ const detailExample = {
1943
2039
  routing: { summary: 'Add a SQLite projection and a read-only dashboard.', decision: { complexity: 'high', estimatedWorkPackages: 7 } },
1944
2040
  counts: { events: 15, attempts: 3, gates: 1, prompts: 4, documents: 16 },
1945
2041
  hasPrompt: true,
2042
+ repositories: [{ id: 'ai-rules', name: 'ai-rules', status: 'active' }],
2043
+ repositoriesInference: 'evidence-paths',
1946
2044
  };
1947
2045
 
1948
2046
  const attemptExample = {
@@ -2820,6 +2918,68 @@ const EXAMPLES = {
2820
2918
  ],
2821
2919
  JobDeleteResult: [{ ok: true, id: 'nightly-retro', runsRemoved: 12 }],
2822
2920
  JobRunRequest: [{ requested: true, requestedAt: '2026-11-10T12:00:00.000Z', schedulerOnline: true }],
2921
+ Repository: [
2922
+ {
2923
+ id: 'ai-rules',
2924
+ name: 'ai-rules',
2925
+ locator: '/Users/operator/WebstormProjects/ai-rules',
2926
+ description: 'The preset repository and its agent team.',
2927
+ labels: ['preset', 'next'],
2928
+ status: 'active',
2929
+ revision: 3,
2930
+ createdAt: '2026-11-22T09:00:00.000Z',
2931
+ updatedAt: '2026-11-22T10:30:00.000Z',
2932
+ },
2933
+ ],
2934
+ RepositorySummary: [
2935
+ {
2936
+ id: 'ai-rules',
2937
+ name: 'ai-rules',
2938
+ locator: '/Users/operator/WebstormProjects/ai-rules',
2939
+ description: 'The preset repository and its agent team.',
2940
+ labels: ['preset', 'next'],
2941
+ status: 'active',
2942
+ revision: 3,
2943
+ createdAt: '2026-11-22T09:00:00.000Z',
2944
+ updatedAt: '2026-11-22T10:30:00.000Z',
2945
+ linkedTaskCount: 12,
2946
+ },
2947
+ ],
2948
+ RepositoryList: [
2949
+ {
2950
+ items: [
2951
+ {
2952
+ id: 'ai-rules',
2953
+ name: 'ai-rules',
2954
+ locator: '/Users/operator/WebstormProjects/ai-rules',
2955
+ description: 'The preset repository and its agent team.',
2956
+ labels: ['preset', 'next'],
2957
+ status: 'active',
2958
+ revision: 3,
2959
+ createdAt: '2026-11-22T09:00:00.000Z',
2960
+ updatedAt: '2026-11-22T10:30:00.000Z',
2961
+ linkedTaskCount: 12,
2962
+ },
2963
+ ],
2964
+ total: 1,
2965
+ limit: 50,
2966
+ offset: 0,
2967
+ nextOffset: null,
2968
+ },
2969
+ ],
2970
+ RepositoryWrite: [
2971
+ {
2972
+ id: 'docs-site',
2973
+ name: 'Documentation site',
2974
+ locator: 'https://github.com/example/docs-site',
2975
+ description: null,
2976
+ labels: [],
2977
+ status: 'active',
2978
+ revision: 1,
2979
+ },
2980
+ ],
2981
+ RepositoryDeleteResult: [{ ok: true, id: 'docs-site', linksRemoved: 3 }],
2982
+ TaskRepositoryRef: [{ id: 'ai-rules', name: 'ai-rules', status: 'active' }],
2823
2983
  TrackerDependency: [trackerDependencyExample],
2824
2984
  TrackerHistoryEntry: [trackerHistoryExample],
2825
2985
  TrackerItem: [trackerItemExample],
@@ -2944,6 +3104,30 @@ const runIdParameter = {
2944
3104
  schema: { type: 'string', pattern: RUN_ID_PATTERN },
2945
3105
  };
2946
3106
 
3107
+ const repositoryIdParameter = {
3108
+ name: 'id',
3109
+ in: 'path',
3110
+ required: true,
3111
+ description: 'Repository id: the immutable slug-like key of one record in `repositories.json`.',
3112
+ schema: { type: 'string', pattern: SLUG_PATTERN, minLength: 1, maxLength: 48 },
3113
+ };
3114
+
3115
+ const repositoryForceParameter = {
3116
+ name: 'force',
3117
+ in: 'query',
3118
+ required: false,
3119
+ description: 'Remove the record and every link naming it in one write. The linked tasks stay.',
3120
+ schema: { type: 'boolean', default: false },
3121
+ };
3122
+
3123
+ const repositoryRevisionParameter = {
3124
+ name: 'revision',
3125
+ in: 'query',
3126
+ required: false,
3127
+ description: 'Optional optimistic lock: when supplied it must equal the stored revision.',
3128
+ schema: { type: 'integer', minimum: 1 },
3129
+ };
3130
+
2947
3131
  const JOB_LIST_PARAMETERS = [
2948
3132
  ...paginationParameters,
2949
3133
  {
@@ -3155,6 +3339,13 @@ const LIST_TASK_PARAMETERS = [
3155
3339
  { name: 'from', in: 'query', required: false, schema: { type: 'string', format: 'date-time' } },
3156
3340
  { name: 'to', in: 'query', required: false, schema: { type: 'string', format: 'date-time' } },
3157
3341
  { name: 'q', in: 'query', required: false, schema: { type: 'string', maxLength: 200 } },
3342
+ {
3343
+ name: 'repository',
3344
+ in: 'query',
3345
+ required: false,
3346
+ description: 'Narrow to the tasks linked to one repository. A registry id matches `^[a-z0-9]+(?:-[a-z0-9]+)*$` and is at most 48 characters.',
3347
+ schema: { type: 'string', pattern: SLUG_PATTERN, maxLength: 48 },
3348
+ },
3158
3349
  { name: 'sort', in: 'query', required: false, schema: { type: 'string', enum: SORT_VALUES, default: '-updatedAt' } },
3159
3350
  { name: 'includeAbsent', in: 'query', required: false, schema: { type: 'boolean', default: false } },
3160
3351
  ];
@@ -3313,9 +3504,9 @@ export const OPENAPI_DOCUMENT = {
3313
3504
  info: {
3314
3505
  title: 'Agent team SQLite projection API',
3315
3506
  summary:
3316
- 'Projection of `.ai.local/team`. Task files, job definitions, run manifests and the tracker store are authoritative; the database is a rebuildable copy. Fourteen mutations exist — the idempotent rescan, the confirmed task delete, the four job writes, and the eight tracker writes — and every one runs as a bounded child process.',
3507
+ 'Projection of `.ai.local/team`. Task files, job definitions, run manifests, the tracker store and the repository registry are authoritative; the database is a rebuildable copy. Seventeen mutations exist — the idempotent rescan, the confirmed task delete, the four job writes, the eight tracker writes, and the three repository writes — and every one runs as a bounded child process.',
3317
3508
  description:
3318
- 'Loopback-only operator API. No authentication by design, no CORS, no outbound request. Errors use one `{error:{code,message,details?}}` envelope. Every non-GET/HEAD request to a read-only path returns 405 `E_METHOD_NOT_ALLOWED` with `Allow: GET, HEAD`; `GET` and `HEAD` on `/api/v1/sync` return 405 with `Allow: POST`; any other method on `/api/v1/tasks/{slug}` returns 405 with `Allow: GET, HEAD, DELETE`. The tracker paths advertise `GET, HEAD, POST` (`/api/v1/tracker`, `/api/v1/tracker/queue`), `GET, HEAD, PUT, DELETE` (`/api/v1/tracker/{id}`), `POST` (`/api/v1/tracker/queue/{entryId}/cancel`, `/api/v1/tracker/{id}/tasks`, `/api/v1/tracker/{id}/tasks/{taskSlug}/stop|continue`).',
3509
+ 'Loopback-only operator API. No authentication by design, no CORS, no outbound request. Errors use one `{error:{code,message,details?}}` envelope. Every non-GET/HEAD request to a read-only path returns 405 `E_METHOD_NOT_ALLOWED` with `Allow: GET, HEAD`; `GET` and `HEAD` on `/api/v1/sync` return 405 with `Allow: POST`; any other method on `/api/v1/tasks/{slug}` returns 405 with `Allow: GET, HEAD, DELETE`. The tracker paths advertise `GET, HEAD, POST` (`/api/v1/tracker`, `/api/v1/tracker/queue`), `GET, HEAD, PUT, DELETE` (`/api/v1/tracker/{id}`), `POST` (`/api/v1/tracker/queue/{entryId}/cancel`, `/api/v1/tracker/{id}/tasks`, `/api/v1/tracker/{id}/tasks/{taskSlug}/stop|continue`). The repository paths advertise `GET, HEAD, POST` (`/api/v1/repositories`) and `GET, HEAD, PUT, DELETE` (`/api/v1/repositories/{id}`).',
3319
3510
  version: API_VERSION,
3320
3511
  'x-api-major': API_MAJOR,
3321
3512
  },
@@ -3336,6 +3527,7 @@ export const OPENAPI_DOCUMENT = {
3336
3527
  { name: 'efficiency', description: 'Measured calls, turns and attempts, A/B runs and the always-on context cost' },
3337
3528
  { name: 'sync', description: 'Projection runs and the one idempotent rescan' },
3338
3529
  { name: 'jobs', description: 'Scheduled jobs, their runs and their logs' },
3530
+ { name: 'repositories', description: 'The repository registry: records, their linked-task counts and the confirmed delete' },
3339
3531
  { name: 'tracker', description: 'The file-authoritative task tracker: items, ordering and the launch queue' },
3340
3532
  ],
3341
3533
  paths: {
@@ -3602,6 +3794,100 @@ export const OPENAPI_DOCUMENT = {
3602
3794
  },
3603
3795
  }),
3604
3796
  },
3797
+ '/api/v1/repositories': {
3798
+ get: listOperation(
3799
+ ['repositories'],
3800
+ 'List repository records with their linked-task counts',
3801
+ 'listRepositories',
3802
+ 'RepositoryList',
3803
+ paginationParameters,
3804
+ {},
3805
+ 'Ordered by `status, name COLLATE NOCASE, id`. `linkedTaskCount` is computed by the projection, so the list row and the delete dialog read one field.',
3806
+ ),
3807
+ post: operation({
3808
+ tags: ['repositories'],
3809
+ summary: 'Create one repository record',
3810
+ description:
3811
+ 'The body is the file-authoritative definition (`.ai.local/team/repositories.json`); the server never writes the file directly — a bounded child takes the registry lock, writes the file by temp file plus rename and then projects the row. The body carries the record\'s own `id`; a duplicate answers 409 `E_CONFLICT` naming it, and no route derives an id from `name`. A stale `revision` on an update and a status outside `active | archived` are refused; `POST` creates at revision 1. A projection failure never fails the write: the file is durable and `projection.failed` reports the lag.',
3812
+ operationId: 'createRepository',
3813
+ parameters: [],
3814
+ requestBody: {
3815
+ required: true,
3816
+ description: 'One repository definition as `application/json`, at most 16 KiB.',
3817
+ content: { 'application/json': { schema: ref('RepositoryWrite') } },
3818
+ },
3819
+ responses: {
3820
+ 201: jsonResponse('Repository', 'The stored record at revision 1'),
3821
+ 400: errorResponse('Malformed request'),
3822
+ 403: errorResponse('A non-loopback Host or Origin was rejected before routing'),
3823
+ 405: methodNotAllowedResponse,
3824
+ 409: errorResponse('`body.id` is already in the registry, or the body carries a revision other than 1'),
3825
+ 413: errorResponse('The body exceeds the 16 KiB JSON bound'),
3826
+ 422: errorResponse('A field is outside its documented bound or the media type is not JSON; `details.parameter` names it'),
3827
+ 503: errorResponse('The projection is disabled, the database is missing, unusable, busy, or the child exceeded its time bound'),
3828
+ },
3829
+ }),
3830
+ },
3831
+ '/api/v1/repositories/{id}': {
3832
+ get: operation({
3833
+ tags: ['repositories'],
3834
+ summary: 'One repository record with its linked-task count',
3835
+ operationId: 'getRepository',
3836
+ parameters: [repositoryIdParameter],
3837
+ responses: {
3838
+ 200: jsonResponse('RepositorySummary', 'The stored record and its derived count'),
3839
+ 400: errorResponse('Malformed request: an invalid repository id'),
3840
+ 403: errorResponse('A non-loopback Host or Origin was rejected before routing'),
3841
+ 404: errorResponse('The repository is not in the projection'),
3842
+ 405: methodNotAllowedResponse,
3843
+ 422: errorResponse('The repository id is outside its documented shape'),
3844
+ 503: errorResponse('The database is missing, unusable or busy'),
3845
+ },
3846
+ }),
3847
+ put: operation({
3848
+ tags: ['repositories'],
3849
+ summary: 'Update one repository record',
3850
+ description:
3851
+ 'Optimistic concurrency: the body `revision` must equal the stored revision, a missing or stale one is 409 `E_CONFLICT`, and the stored revision advances by one. The body `id` must equal the path id — a difference is 409 `E_CONFLICT`, never an implied rename. Executed as a bounded child (10 s, `SIGKILL`) behind the `E_DISABLED` guard.',
3852
+ operationId: 'updateRepository',
3853
+ parameters: [repositoryIdParameter],
3854
+ requestBody: {
3855
+ required: true,
3856
+ description: 'The whole definition as `application/json`, at most 16 KiB.',
3857
+ content: { 'application/json': { schema: ref('RepositoryWrite') } },
3858
+ },
3859
+ responses: {
3860
+ 200: jsonResponse('Repository', 'The stored record at its incremented revision'),
3861
+ 400: errorResponse('Malformed request: an invalid repository id'),
3862
+ 403: errorResponse('A non-loopback Host or Origin was rejected before routing'),
3863
+ 404: errorResponse('The repository is not in the projection'),
3864
+ 405: methodNotAllowedResponse,
3865
+ 409: errorResponse('A missing or stale `revision`, or a body id that differs from the path id'),
3866
+ 413: errorResponse('The body exceeds the 16 KiB JSON bound'),
3867
+ 422: errorResponse('A field is outside its documented bound or the media type is not JSON; `details.parameter` names it'),
3868
+ 503: errorResponse('The projection is disabled, the database is missing, unusable, busy, or the child exceeded its time bound'),
3869
+ },
3870
+ }),
3871
+ delete: operation({
3872
+ tags: ['repositories'],
3873
+ summary: 'Delete one repository, and its links when forced',
3874
+ description:
3875
+ 'A repository linked to N tasks refuses with 409 `E_REPOSITORY_IN_USE` and `details.linkedTasks = N`; `force=true` removes the record and every link naming it in the same file write and reports `linksRemoved`. The tasks stay. `revision` is an optional query parameter: when supplied it must equal the stored revision (409 `E_CONFLICT`). `force=true` on an unlinked record is legal and reports 0. Executed as a bounded child (30 s, `SIGKILL`); the request body is ignored.',
3876
+ operationId: 'deleteRepository',
3877
+ parameters: [repositoryIdParameter, repositoryForceParameter, repositoryRevisionParameter],
3878
+ responses: {
3879
+ 200: jsonResponse('RepositoryDeleteResult', 'The deleted id and the number of removed links'),
3880
+ 400: errorResponse('Malformed request: an invalid repository id'),
3881
+ 403: errorResponse('A non-loopback Host or Origin was rejected before routing'),
3882
+ 404: errorResponse('The repository is not in the projection'),
3883
+ 405: methodNotAllowedResponse,
3884
+ 409: errorResponse('The record is linked and `force` is absent (`E_REPOSITORY_IN_USE`, with `details.linkedTasks`), or the supplied `revision` is stale'),
3885
+ 413: errorResponse('The body exceeds the declared bound'),
3886
+ 422: errorResponse('A parameter is outside its documented bound'),
3887
+ 503: errorResponse('The projection is disabled, the database is missing, unusable, busy, or the child exceeded its time bound'),
3888
+ },
3889
+ }),
3890
+ },
3605
3891
  '/api/v1/tracker': {
3606
3892
  get: listOperation(
3607
3893
  ['tracker'],