@bonesofspring/ai-rules 0.2.64 → 0.2.66

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 (464) hide show
  1. package/CHANGELOG.md +80 -11
  2. package/README.md +24 -16
  3. package/bin/lib/engine-scripts.js +52 -12
  4. package/bin/lib/engine-upgrade.js +5 -2
  5. package/bin/lib/seed-ai-local-team.js +13 -3
  6. package/docs/OPENCODE.md +17 -9
  7. package/docs/PRESET-CONTRIBUTION.md +41 -0
  8. package/docs/TEAM-DB.md +240 -60
  9. package/docs/TOKEN-ECONOMY.md +79 -0
  10. package/docs/openapi/team-db.v1.json +1238 -377
  11. package/mcp/defectdojo-mcp.mjs +7 -5
  12. package/mcp/lib/defectdojo.mjs +26 -14
  13. package/package.json +31 -20
  14. package/presets/_shared/ai-local/scripts/dump-output.mjs +371 -0
  15. package/presets/_shared/ai-local/scripts/process-lease.mjs +576 -0
  16. package/presets/_shared/ai-local/scripts/processes.mjs +1618 -0
  17. package/presets/_shared/ai-local/scripts/run.mjs +5 -5
  18. package/presets/_shared/ai-local/scripts/team-db-api.mjs +465 -152
  19. package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +235 -10
  20. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +416 -176
  21. package/presets/_shared/ai-local/scripts/team-db-project.mjs +171 -62
  22. package/presets/_shared/ai-local/scripts/team-db-scheduler.mjs +4 -0
  23. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +143 -5
  24. package/presets/_shared/ai-local/scripts/team-db-task-runner.mjs +567 -0
  25. package/presets/_shared/ai-local/scripts/{team-db-backlog.mjs → team-db-tracker.mjs} +900 -197
  26. package/presets/_shared/ai-local/scripts/team-db-ui.mjs +750 -0
  27. package/presets/_shared/ai-local/scripts/team-db.mjs +184 -23
  28. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +4 -2
  29. package/presets/_shared/core/architecture/feature-delivery-workflow.md +4 -0
  30. package/presets/_shared/core/quality/context-and-iteration.md +1 -0
  31. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +105 -17
  32. package/presets/_shared/hooks/guard-shell-command.mjs.tmpl +40 -2
  33. package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
  34. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +105 -17
  35. package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +41 -2
  36. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  37. package/presets/claude/android-kotlin/settings.json +6 -1
  38. package/presets/claude/go/agents/task-analyst.md +1 -1
  39. package/presets/claude/go/hooks/chain-team-phases.sh +105 -17
  40. package/presets/claude/go/hooks/guard-shell-command.mjs +41 -2
  41. package/presets/claude/go/rules/architecture/feature-delivery.md +4 -0
  42. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  43. package/presets/claude/go/settings.json +6 -1
  44. package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
  45. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +105 -17
  46. package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +41 -2
  47. package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +4 -0
  48. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  49. package/presets/claude/ios-swift/settings.json +6 -1
  50. package/presets/claude/java/agents/task-analyst.md +1 -1
  51. package/presets/claude/java/hooks/chain-team-phases.sh +105 -17
  52. package/presets/claude/java/hooks/guard-shell-command.mjs +41 -2
  53. package/presets/claude/java/rules/architecture/feature-delivery.md +4 -0
  54. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  55. package/presets/claude/java/settings.json +6 -1
  56. package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
  57. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +105 -17
  58. package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +41 -2
  59. package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +4 -0
  60. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  61. package/presets/claude/mcp-ts/settings.json +6 -1
  62. package/presets/claude/mol/agents/task-analyst.md +1 -1
  63. package/presets/claude/mol/hooks/chain-team-phases.sh +105 -17
  64. package/presets/claude/mol/hooks/guard-shell-command.mjs +41 -2
  65. package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +4 -0
  66. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  67. package/presets/claude/mol/settings.json +6 -1
  68. package/presets/claude/next/MCP.md +2 -0
  69. package/presets/claude/next/REPO_AGENTS.md +2 -0
  70. package/presets/claude/next/agents/build-verifier.md +1 -1
  71. package/presets/claude/next/agents/ci-investigator.md +3 -0
  72. package/presets/claude/next/agents/debugger.md +3 -0
  73. package/presets/claude/next/agents/feature-developer.md +3 -0
  74. package/presets/claude/next/agents/mockup-reviewer.md +2 -0
  75. package/presets/claude/next/agents/performance-auditor.md +2 -0
  76. package/presets/claude/next/agents/playwright-test-generator.md +3 -0
  77. package/presets/claude/next/agents/playwright-test-healer.md +3 -0
  78. package/presets/claude/next/agents/playwright-test-planner.md +3 -0
  79. package/presets/claude/next/agents/qa-tester.md +3 -0
  80. package/presets/claude/next/agents/task-analyst.md +1 -1
  81. package/presets/claude/next/commands/README.md +7 -1
  82. package/presets/claude/next/commands/task.md +1 -1
  83. package/presets/claude/next/commands/ui-start.md +78 -0
  84. package/presets/claude/next/commands/ui-stop.md +71 -0
  85. package/presets/claude/next/hooks/chain-team-phases.sh +105 -17
  86. package/presets/claude/next/hooks/guard-shell-command.mjs +41 -2
  87. package/presets/claude/next/rules/README.md +2 -1
  88. package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +4 -0
  89. package/presets/claude/next/rules/stack/next-app-core.md +1 -0
  90. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  91. package/presets/claude/next/rules/tooling-and-review/dev-process-lifecycle.md +43 -0
  92. package/presets/claude/next/settings.json +6 -1
  93. package/presets/claude/next/team/README.md +7 -3
  94. package/presets/claude/nuxt/agents/task-analyst.md +1 -1
  95. package/presets/claude/nuxt/hooks/chain-team-phases.sh +105 -17
  96. package/presets/claude/nuxt/hooks/guard-shell-command.mjs +41 -2
  97. package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +4 -0
  98. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  99. package/presets/claude/nuxt/settings.json +6 -1
  100. package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
  101. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +105 -17
  102. package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +41 -2
  103. package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +4 -0
  104. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  105. package/presets/claude/php-hexagonal/settings.json +6 -1
  106. package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
  107. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +106 -18
  108. package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +41 -2
  109. package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +4 -0
  110. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  111. package/presets/claude/php-laravel/settings.json +6 -1
  112. package/presets/claude/svelte/agents/task-analyst.md +1 -1
  113. package/presets/claude/svelte/hooks/chain-team-phases.sh +105 -17
  114. package/presets/claude/svelte/hooks/guard-shell-command.mjs +41 -2
  115. package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +4 -0
  116. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
  117. package/presets/claude/svelte/settings.json +6 -1
  118. package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
  119. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +105 -17
  120. package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +41 -2
  121. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
  122. package/presets/cursor/go/agents/task-analyst.md +1 -1
  123. package/presets/cursor/go/hooks/chain-team-phases.sh +105 -17
  124. package/presets/cursor/go/hooks/guard-shell-command.mjs +41 -2
  125. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
  126. package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
  127. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +105 -17
  128. package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +41 -2
  129. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
  130. package/presets/cursor/java/agents/task-analyst.md +1 -1
  131. package/presets/cursor/java/hooks/chain-team-phases.sh +105 -17
  132. package/presets/cursor/java/hooks/guard-shell-command.mjs +41 -2
  133. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
  134. package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
  135. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +105 -17
  136. package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +41 -2
  137. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
  138. package/presets/cursor/mol/agents/task-analyst.md +1 -1
  139. package/presets/cursor/mol/hooks/chain-team-phases.sh +105 -17
  140. package/presets/cursor/mol/hooks/guard-shell-command.mjs +41 -2
  141. package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
  142. package/presets/cursor/next/MCP.md +2 -0
  143. package/presets/cursor/next/REPO_AGENTS.md +2 -0
  144. package/presets/cursor/next/agents/build-verifier.md +1 -1
  145. package/presets/cursor/next/agents/ci-investigator.md +2 -0
  146. package/presets/cursor/next/agents/debugger.md +2 -0
  147. package/presets/cursor/next/agents/feature-developer.md +2 -0
  148. package/presets/cursor/next/agents/mockup-reviewer.md +2 -0
  149. package/presets/cursor/next/agents/performance-auditor.md +2 -0
  150. package/presets/cursor/next/agents/playwright-test-generator.md +2 -0
  151. package/presets/cursor/next/agents/playwright-test-healer.md +2 -0
  152. package/presets/cursor/next/agents/playwright-test-planner.md +2 -0
  153. package/presets/cursor/next/agents/qa-tester.md +2 -0
  154. package/presets/cursor/next/agents/task-analyst.md +1 -1
  155. package/presets/cursor/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
  156. package/presets/cursor/next/commands/README.md +7 -1
  157. package/presets/cursor/next/commands/task.md +1 -1
  158. package/presets/cursor/next/commands/ui-start.md +78 -0
  159. package/presets/cursor/next/commands/ui-stop.md +71 -0
  160. package/presets/cursor/next/hooks/chain-team-phases.sh +105 -17
  161. package/presets/cursor/next/hooks/guard-shell-command.mjs +41 -2
  162. package/presets/cursor/next/rules/README.md +2 -1
  163. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +3 -1
  164. package/presets/cursor/next/rules/dev-process-lifecycle.mdc +43 -0
  165. package/presets/cursor/next/rules/next-app-core.mdc +1 -0
  166. package/presets/cursor/next/team/README.md +7 -3
  167. package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
  168. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +105 -17
  169. package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +41 -2
  170. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
  171. package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
  172. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +105 -17
  173. package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +41 -2
  174. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
  175. package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
  176. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +106 -18
  177. package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +41 -2
  178. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
  179. package/presets/cursor/svelte/agents/task-analyst.md +1 -1
  180. package/presets/cursor/svelte/hooks/chain-team-phases.sh +105 -17
  181. package/presets/cursor/svelte/hooks/guard-shell-command.mjs +41 -2
  182. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
  183. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  184. package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
  185. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +105 -17
  186. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +4 -2
  187. package/presets/mavis/go/adapter-map.json +1 -1
  188. package/presets/mavis/go/agents/task-analyst.md +1 -1
  189. package/presets/mavis/go/hooks/chain-team-phases.sh +105 -17
  190. package/presets/mavis/go/rules/agent-team-orchestrator.md +4 -2
  191. package/presets/mavis/go/rules/feature-delivery-workflow.md +4 -0
  192. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  193. package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
  194. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +105 -17
  195. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +4 -2
  196. package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +4 -0
  197. package/presets/mavis/java/adapter-map.json +1 -1
  198. package/presets/mavis/java/agents/task-analyst.md +1 -1
  199. package/presets/mavis/java/hooks/chain-team-phases.sh +105 -17
  200. package/presets/mavis/java/rules/agent-team-orchestrator.md +4 -2
  201. package/presets/mavis/java/rules/feature-delivery-workflow.md +4 -0
  202. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  203. package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
  204. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +105 -17
  205. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +4 -2
  206. package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +4 -0
  207. package/presets/mavis/mol/adapter-map.json +1 -1
  208. package/presets/mavis/mol/agents/task-analyst.md +1 -1
  209. package/presets/mavis/mol/hooks/chain-team-phases.sh +105 -17
  210. package/presets/mavis/mol/rules/agent-team-orchestrator.md +4 -2
  211. package/presets/mavis/mol/rules/feature-delivery-workflow.md +4 -0
  212. package/presets/mavis/next/MCP.md +2 -0
  213. package/presets/mavis/next/REPO_AGENTS.md +2 -0
  214. package/presets/mavis/next/adapter-map.json +33 -1
  215. package/presets/mavis/next/agents/build-verifier.md +1 -1
  216. package/presets/mavis/next/agents/ci-investigator.md +3 -0
  217. package/presets/mavis/next/agents/debugger.md +3 -0
  218. package/presets/mavis/next/agents/feature-developer.md +3 -0
  219. package/presets/mavis/next/agents/mockup-reviewer.md +2 -0
  220. package/presets/mavis/next/agents/performance-auditor.md +2 -0
  221. package/presets/mavis/next/agents/playwright-test-generator.md +3 -0
  222. package/presets/mavis/next/agents/playwright-test-healer.md +3 -0
  223. package/presets/mavis/next/agents/playwright-test-planner.md +3 -0
  224. package/presets/mavis/next/agents/qa-tester.md +3 -0
  225. package/presets/mavis/next/agents/task-analyst.md +1 -1
  226. package/presets/mavis/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
  227. package/presets/mavis/next/commands/README.md +7 -1
  228. package/presets/mavis/next/commands/task.md +1 -1
  229. package/presets/mavis/next/commands/ui-start.md +73 -0
  230. package/presets/mavis/next/commands/ui-stop.md +66 -0
  231. package/presets/mavis/next/hooks/chain-team-phases.sh +105 -17
  232. package/presets/mavis/next/rules/agent-team-orchestrator.md +4 -2
  233. package/presets/mavis/next/rules/dev-process-lifecycle.md +38 -0
  234. package/presets/mavis/next/rules/feature-delivery-workflow.md +4 -0
  235. package/presets/mavis/next/rules/next-app-core.md +1 -0
  236. package/presets/mavis/next/team/README.md +7 -3
  237. package/presets/mavis/nuxt/adapter-map.json +1 -1
  238. package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
  239. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +105 -17
  240. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +4 -2
  241. package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +4 -0
  242. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  243. package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
  244. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +105 -17
  245. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +4 -2
  246. package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
  247. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  248. package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
  249. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +106 -18
  250. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +4 -2
  251. package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +4 -0
  252. package/presets/mavis/svelte/adapter-map.json +1 -1
  253. package/presets/mavis/svelte/agents/task-analyst.md +1 -1
  254. package/presets/mavis/svelte/hooks/chain-team-phases.sh +105 -17
  255. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +4 -2
  256. package/presets/mavis/svelte/rules/feature-delivery-workflow.md +4 -0
  257. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  258. package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
  259. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +105 -17
  260. package/presets/opencode/android-kotlin/opencode.json +5 -1
  261. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +4 -2
  262. package/presets/opencode/go/adapter-map.json +1 -1
  263. package/presets/opencode/go/agents/task-analyst.md +1 -1
  264. package/presets/opencode/go/hooks/chain-team-phases.sh +105 -17
  265. package/presets/opencode/go/opencode.json +5 -1
  266. package/presets/opencode/go/rules/agent-team-orchestrator.md +4 -2
  267. package/presets/opencode/go/rules/feature-delivery-workflow.md +4 -0
  268. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  269. package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
  270. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +105 -17
  271. package/presets/opencode/ios-swift/opencode.json +5 -1
  272. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +4 -2
  273. package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +4 -0
  274. package/presets/opencode/java/adapter-map.json +1 -1
  275. package/presets/opencode/java/agents/task-analyst.md +1 -1
  276. package/presets/opencode/java/hooks/chain-team-phases.sh +105 -17
  277. package/presets/opencode/java/opencode.json +5 -1
  278. package/presets/opencode/java/rules/agent-team-orchestrator.md +4 -2
  279. package/presets/opencode/java/rules/feature-delivery-workflow.md +4 -0
  280. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  281. package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
  282. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +105 -17
  283. package/presets/opencode/mcp-ts/opencode.json +5 -1
  284. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +4 -2
  285. package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
  286. package/presets/opencode/mol/adapter-map.json +1 -1
  287. package/presets/opencode/mol/agents/task-analyst.md +1 -1
  288. package/presets/opencode/mol/hooks/chain-team-phases.sh +105 -17
  289. package/presets/opencode/mol/opencode.json +4 -0
  290. package/presets/opencode/mol/rules/agent-team-orchestrator.md +4 -2
  291. package/presets/opencode/mol/rules/feature-delivery-workflow.md +4 -0
  292. package/presets/opencode/next/MCP.md +2 -0
  293. package/presets/opencode/next/REPO_AGENTS.md +2 -0
  294. package/presets/opencode/next/adapter-map.json +33 -1
  295. package/presets/opencode/next/agents/build-verifier.md +1 -1
  296. package/presets/opencode/next/agents/ci-investigator.md +3 -0
  297. package/presets/opencode/next/agents/debugger.md +3 -0
  298. package/presets/opencode/next/agents/feature-developer.md +3 -0
  299. package/presets/opencode/next/agents/mockup-reviewer.md +2 -0
  300. package/presets/opencode/next/agents/performance-auditor.md +2 -0
  301. package/presets/opencode/next/agents/playwright-test-generator.md +3 -0
  302. package/presets/opencode/next/agents/playwright-test-healer.md +3 -0
  303. package/presets/opencode/next/agents/playwright-test-planner.md +3 -0
  304. package/presets/opencode/next/agents/qa-tester.md +3 -0
  305. package/presets/opencode/next/agents/task-analyst.md +1 -1
  306. package/presets/opencode/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
  307. package/presets/opencode/next/commands/README.md +7 -1
  308. package/presets/opencode/next/commands/task.md +1 -1
  309. package/presets/opencode/next/commands/ui-start.md +81 -0
  310. package/presets/opencode/next/commands/ui-stop.md +74 -0
  311. package/presets/opencode/next/hooks/chain-team-phases.sh +105 -17
  312. package/presets/opencode/next/opencode.json +4 -0
  313. package/presets/opencode/next/rules/agent-team-orchestrator.md +4 -2
  314. package/presets/opencode/next/rules/dev-process-lifecycle.md +38 -0
  315. package/presets/opencode/next/rules/feature-delivery-workflow.md +4 -0
  316. package/presets/opencode/next/rules/next-app-core.md +1 -0
  317. package/presets/opencode/next/team/README.md +7 -3
  318. package/presets/opencode/nuxt/adapter-map.json +1 -1
  319. package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
  320. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +105 -17
  321. package/presets/opencode/nuxt/opencode.json +4 -0
  322. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +4 -2
  323. package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +4 -0
  324. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  325. package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
  326. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +105 -17
  327. package/presets/opencode/php-hexagonal/opencode.json +5 -1
  328. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +4 -2
  329. package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
  330. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  331. package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
  332. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +106 -18
  333. package/presets/opencode/php-laravel/opencode.json +5 -1
  334. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +4 -2
  335. package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +4 -0
  336. package/presets/opencode/plugins/task-status/README.md +23 -11
  337. package/presets/opencode/plugins/task-status/details-data.ts +64 -46
  338. package/presets/opencode/plugins/task-status/details.tsx +12 -2
  339. package/presets/opencode/plugins/task-status/format.ts +16 -0
  340. package/presets/opencode/plugins/task-status/prompt-text.ts +37 -0
  341. package/presets/opencode/plugins/task-status/task-view.ts +241 -177
  342. package/presets/opencode/plugins/task-status/tui.tsx +57 -15
  343. package/presets/opencode/plugins/task-status/types.ts +74 -0
  344. package/presets/opencode/svelte/adapter-map.json +1 -1
  345. package/presets/opencode/svelte/agents/task-analyst.md +1 -1
  346. package/presets/opencode/svelte/hooks/chain-team-phases.sh +105 -17
  347. package/presets/opencode/svelte/opencode.json +4 -0
  348. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +4 -2
  349. package/presets/opencode/svelte/rules/feature-delivery-workflow.md +4 -0
  350. package/presets/zcode/android-kotlin/adapter-map.json +1 -1
  351. package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
  352. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +105 -17
  353. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +4 -2
  354. package/presets/zcode/go/adapter-map.json +1 -1
  355. package/presets/zcode/go/agents/task-analyst.md +1 -1
  356. package/presets/zcode/go/hooks/chain-team-phases.sh +105 -17
  357. package/presets/zcode/go/rules/agent-team-orchestrator.md +4 -2
  358. package/presets/zcode/go/rules/feature-delivery-workflow.md +4 -0
  359. package/presets/zcode/ios-swift/adapter-map.json +1 -1
  360. package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
  361. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +105 -17
  362. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +4 -2
  363. package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +4 -0
  364. package/presets/zcode/java/adapter-map.json +1 -1
  365. package/presets/zcode/java/agents/task-analyst.md +1 -1
  366. package/presets/zcode/java/hooks/chain-team-phases.sh +105 -17
  367. package/presets/zcode/java/rules/agent-team-orchestrator.md +4 -2
  368. package/presets/zcode/java/rules/feature-delivery-workflow.md +4 -0
  369. package/presets/zcode/mcp-ts/adapter-map.json +1 -1
  370. package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
  371. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +105 -17
  372. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +4 -2
  373. package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
  374. package/presets/zcode/mol/adapter-map.json +1 -1
  375. package/presets/zcode/mol/agents/task-analyst.md +1 -1
  376. package/presets/zcode/mol/hooks/chain-team-phases.sh +105 -17
  377. package/presets/zcode/mol/rules/agent-team-orchestrator.md +4 -2
  378. package/presets/zcode/mol/rules/feature-delivery-workflow.md +4 -0
  379. package/presets/zcode/next/MCP.md +2 -0
  380. package/presets/zcode/next/REPO_AGENTS.md +2 -0
  381. package/presets/zcode/next/adapter-map.json +33 -1
  382. package/presets/zcode/next/agents/build-verifier.md +1 -1
  383. package/presets/zcode/next/agents/ci-investigator.md +3 -0
  384. package/presets/zcode/next/agents/debugger.md +3 -0
  385. package/presets/zcode/next/agents/feature-developer.md +3 -0
  386. package/presets/zcode/next/agents/mockup-reviewer.md +2 -0
  387. package/presets/zcode/next/agents/performance-auditor.md +2 -0
  388. package/presets/zcode/next/agents/playwright-test-generator.md +3 -0
  389. package/presets/zcode/next/agents/playwright-test-healer.md +3 -0
  390. package/presets/zcode/next/agents/playwright-test-planner.md +3 -0
  391. package/presets/zcode/next/agents/qa-tester.md +3 -0
  392. package/presets/zcode/next/agents/task-analyst.md +1 -1
  393. package/presets/zcode/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
  394. package/presets/zcode/next/commands/README.md +7 -1
  395. package/presets/zcode/next/commands/task.md +1 -1
  396. package/presets/zcode/next/commands/ui-start.md +81 -0
  397. package/presets/zcode/next/commands/ui-stop.md +74 -0
  398. package/presets/zcode/next/hooks/chain-team-phases.sh +105 -17
  399. package/presets/zcode/next/rules/agent-team-orchestrator.md +4 -2
  400. package/presets/zcode/next/rules/dev-process-lifecycle.md +38 -0
  401. package/presets/zcode/next/rules/feature-delivery-workflow.md +4 -0
  402. package/presets/zcode/next/rules/next-app-core.md +1 -0
  403. package/presets/zcode/next/team/README.md +7 -3
  404. package/presets/zcode/nuxt/adapter-map.json +1 -1
  405. package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
  406. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +105 -17
  407. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +4 -2
  408. package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +4 -0
  409. package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
  410. package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
  411. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +105 -17
  412. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +4 -2
  413. package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
  414. package/presets/zcode/php-laravel/adapter-map.json +1 -1
  415. package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
  416. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +106 -18
  417. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +4 -2
  418. package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +4 -0
  419. package/presets/zcode/svelte/adapter-map.json +1 -1
  420. package/presets/zcode/svelte/agents/task-analyst.md +1 -1
  421. package/presets/zcode/svelte/hooks/chain-team-phases.sh +105 -17
  422. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +4 -2
  423. package/presets/zcode/svelte/rules/feature-delivery-workflow.md +4 -0
  424. package/presets/_shared/ai-local/scripts/upstream-research.mjs +0 -2964
  425. package/presets/claude/next/commands/upstream-research.md +0 -23
  426. package/presets/claude/next/team/upstream/config.json +0 -31
  427. package/presets/claude/next/team/upstream/digest-template.md +0 -55
  428. package/presets/claude/next/team/upstream/jobs.json +0 -34
  429. package/presets/claude/next/team/upstream/opencode.json +0 -34
  430. package/presets/claude/next/team/upstream/projects.json +0 -4
  431. package/presets/claude/next/team/upstream/prompt.md +0 -77
  432. package/presets/claude/next/team/upstream/signatures.json +0 -9
  433. package/presets/cursor/next/commands/upstream-research.md +0 -23
  434. package/presets/cursor/next/team/upstream/config.json +0 -31
  435. package/presets/cursor/next/team/upstream/digest-template.md +0 -55
  436. package/presets/cursor/next/team/upstream/jobs.json +0 -34
  437. package/presets/cursor/next/team/upstream/opencode.json +0 -34
  438. package/presets/cursor/next/team/upstream/projects.json +0 -4
  439. package/presets/cursor/next/team/upstream/prompt.md +0 -77
  440. package/presets/cursor/next/team/upstream/signatures.json +0 -9
  441. package/presets/mavis/next/commands/upstream-research.md +0 -18
  442. package/presets/mavis/next/team/upstream/config.json +0 -31
  443. package/presets/mavis/next/team/upstream/digest-template.md +0 -55
  444. package/presets/mavis/next/team/upstream/jobs.json +0 -34
  445. package/presets/mavis/next/team/upstream/opencode.json +0 -34
  446. package/presets/mavis/next/team/upstream/projects.json +0 -4
  447. package/presets/mavis/next/team/upstream/prompt.md +0 -77
  448. package/presets/mavis/next/team/upstream/signatures.json +0 -9
  449. package/presets/opencode/next/commands/upstream-research.md +0 -26
  450. package/presets/opencode/next/team/upstream/config.json +0 -31
  451. package/presets/opencode/next/team/upstream/digest-template.md +0 -55
  452. package/presets/opencode/next/team/upstream/jobs.json +0 -34
  453. package/presets/opencode/next/team/upstream/opencode.json +0 -34
  454. package/presets/opencode/next/team/upstream/projects.json +0 -4
  455. package/presets/opencode/next/team/upstream/prompt.md +0 -77
  456. package/presets/opencode/next/team/upstream/signatures.json +0 -9
  457. package/presets/zcode/next/commands/upstream-research.md +0 -26
  458. package/presets/zcode/next/team/upstream/config.json +0 -31
  459. package/presets/zcode/next/team/upstream/digest-template.md +0 -55
  460. package/presets/zcode/next/team/upstream/jobs.json +0 -34
  461. package/presets/zcode/next/team/upstream/opencode.json +0 -34
  462. package/presets/zcode/next/team/upstream/projects.json +0 -4
  463. package/presets/zcode/next/team/upstream/prompt.md +0 -77
  464. package/presets/zcode/next/team/upstream/signatures.json +0 -9
@@ -32,7 +32,7 @@ import {
32
32
  teamDbFail,
33
33
  } from './team-db-schema.mjs';
34
34
  import { projectScheduler, retainRuns } from './team-db-scheduler.mjs';
35
- import { validateEntrySchema, validateItemSchema } from './team-db-backlog.mjs';
35
+ import { validateEntrySchema, validateItemSchema, validateLinkIdentity, validateLinkSchema } from './team-db-tracker.mjs';
36
36
 
37
37
  export const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
38
38
  export const MAX_RAW_BYTES = 32 * 1024 * 1024;
@@ -1338,12 +1338,13 @@ const projectTask = ({ db, teamRoot, slug, now, searchMode, deadlineAt }) => {
1338
1338
  return { status: existing ? 'updated' : 'inserted', errors };
1339
1339
  };
1340
1340
 
1341
- /* ------------------------------ backlog walker ----------------------------- */
1341
+ /* ------------------------------ tracker walker ----------------------------- */
1342
1342
 
1343
- const BACKLOG_ITEM_DIR = 'backlog/items';
1344
- const BACKLOG_QUEUE_DIR = 'backlog/queue';
1343
+ const TRACKER_ITEM_DIR = 'tracker/items';
1344
+ const TRACKER_QUEUE_DIR = 'tracker/queue';
1345
+ const TRACKER_LINK_DIR = 'tracker/links';
1345
1346
 
1346
- const listBacklogJsonFiles = (teamRoot, dirName) => {
1347
+ const listTrackerJsonFiles = (teamRoot, dirName) => {
1347
1348
  const dir = path.join(teamRoot, dirName);
1348
1349
  if (!fs.existsSync(dir)) return [];
1349
1350
  return fs
@@ -1353,7 +1354,7 @@ const listBacklogJsonFiles = (teamRoot, dirName) => {
1353
1354
  .sort();
1354
1355
  };
1355
1356
 
1356
- const readBacklogJson = (file) => {
1357
+ const readTrackerJson = (file) => {
1357
1358
  try {
1358
1359
  return { text: fs.readFileSync(file, 'utf8'), error: null };
1359
1360
  } catch (error) {
@@ -1361,8 +1362,8 @@ const readBacklogJson = (file) => {
1361
1362
  }
1362
1363
  };
1363
1364
 
1364
- const UPSERT_BACKLOG_ITEM_SQL = `
1365
- INSERT INTO backlog_items (
1365
+ const UPSERT_TRACKER_ITEM_SQL = `
1366
+ INSERT INTO tracker_items (
1366
1367
  id, title, status, priority, type, description, labels_json, source_task,
1367
1368
  source_refs_json, revision, created_at, updated_at, completed_at, cancelled_at,
1368
1369
  cancel_reason, superseded_by, history_json, content_hash, parse_error,
@@ -1392,14 +1393,16 @@ ON CONFLICT(id) DO UPDATE SET
1392
1393
  absent_at = NULL
1393
1394
  `;
1394
1395
 
1395
- const UPSERT_BACKLOG_ENTRY_SQL = `
1396
- INSERT INTO backlog_queue (
1397
- entry_id, item_id, status, reason, requested_by, command, revision,
1396
+ const UPSERT_TRACKER_ENTRY_SQL = `
1397
+ INSERT INTO tracker_queue (
1398
+ entry_id, item_id, task_slug, link_id, status, reason, requested_by, command, revision,
1398
1399
  requested_at, claimed_at, finished_at, history_json, content_hash, parse_error,
1399
1400
  projected_at, first_seen_at, last_seen_at, absent_at
1400
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)
1401
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)
1401
1402
  ON CONFLICT(entry_id) DO UPDATE SET
1402
1403
  item_id = excluded.item_id,
1404
+ task_slug = excluded.task_slug,
1405
+ link_id = excluded.link_id,
1403
1406
  status = excluded.status,
1404
1407
  reason = excluded.reason,
1405
1408
  requested_by = excluded.requested_by,
@@ -1416,19 +1419,44 @@ ON CONFLICT(entry_id) DO UPDATE SET
1416
1419
  absent_at = NULL
1417
1420
  `;
1418
1421
 
1422
+ const UPSERT_TRACKER_LINK_SQL = `
1423
+ INSERT INTO tracker_item_tasks (
1424
+ link_id, item_id, task_slug, entry_id, role, decision, prompt_path, language,
1425
+ revision, created_at, updated_at, history_json, content_hash, parse_error,
1426
+ projected_at, first_seen_at, last_seen_at, absent_at
1427
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)
1428
+ ON CONFLICT(link_id) DO UPDATE SET
1429
+ item_id = excluded.item_id,
1430
+ task_slug = excluded.task_slug,
1431
+ entry_id = excluded.entry_id,
1432
+ role = excluded.role,
1433
+ decision = excluded.decision,
1434
+ prompt_path = excluded.prompt_path,
1435
+ language = excluded.language,
1436
+ revision = excluded.revision,
1437
+ created_at = excluded.created_at,
1438
+ updated_at = excluded.updated_at,
1439
+ history_json = excluded.history_json,
1440
+ content_hash = excluded.content_hash,
1441
+ parse_error = excluded.parse_error,
1442
+ projected_at = excluded.projected_at,
1443
+ last_seen_at = excluded.last_seen_at,
1444
+ absent_at = NULL
1445
+ `;
1446
+
1419
1447
  /**
1420
- * One backlog item: parse, validate, upsert by natural key, replace its deps.
1448
+ * One tracker item: parse, validate, upsert by natural key, replace its deps.
1421
1449
  * An unchanged `content_hash` only touches `last_seen_at`; a broken file
1422
1450
  * projects as a recorded `parse_error`, never aborts the run.
1423
1451
  */
1424
- const projectBacklogItem = ({ db, teamRoot, stem, now, deadlineAt }) => {
1425
- if (Date.now() > deadlineAt) teamDbFail('E_DEADLINE', 'projection deadline expired in the backlog walk', 4);
1426
- const file = path.join(teamRoot, BACKLOG_ITEM_DIR, `${stem}.json`);
1427
- const read = readBacklogJson(file);
1452
+ const projectTrackerItem = ({ db, teamRoot, stem, now, deadlineAt }) => {
1453
+ if (Date.now() > deadlineAt) teamDbFail('E_DEADLINE', 'projection deadline expired in the tracker walk', 4);
1454
+ const file = path.join(teamRoot, TRACKER_ITEM_DIR, `${stem}.json`);
1455
+ const read = readTrackerJson(file);
1428
1456
  const contentHash = sha256(read.text ?? '');
1429
- const existing = db.prepare('SELECT content_hash, absent_at FROM backlog_items WHERE id = ?').get(stem);
1457
+ const existing = db.prepare('SELECT content_hash, absent_at FROM tracker_items WHERE id = ?').get(stem);
1430
1458
  if (read.text !== null && existing && existing.content_hash === contentHash && existing.absent_at === null) {
1431
- db.prepare('UPDATE backlog_items SET last_seen_at = ? WHERE id = ?').run(now, stem);
1459
+ db.prepare('UPDATE tracker_items SET last_seen_at = ? WHERE id = ?').run(now, stem);
1432
1460
  return { status: 'unchanged', parseError: null };
1433
1461
  }
1434
1462
  let item = null;
@@ -1447,7 +1475,7 @@ const projectBacklogItem = ({ db, teamRoot, stem, now, deadlineAt }) => {
1447
1475
  }
1448
1476
  }
1449
1477
  }
1450
- db.prepare(UPSERT_BACKLOG_ITEM_SQL).run(
1478
+ db.prepare(UPSERT_TRACKER_ITEM_SQL).run(
1451
1479
  stem,
1452
1480
  item?.title ?? null,
1453
1481
  item?.status ?? null,
@@ -1471,23 +1499,23 @@ const projectBacklogItem = ({ db, teamRoot, stem, now, deadlineAt }) => {
1471
1499
  now,
1472
1500
  now,
1473
1501
  );
1474
- db.prepare('DELETE FROM backlog_item_deps WHERE item_id = ?').run(stem);
1502
+ db.prepare('DELETE FROM tracker_item_deps WHERE item_id = ?').run(stem);
1475
1503
  if (Array.isArray(item?.dependsOn)) {
1476
- const insert = db.prepare('INSERT INTO backlog_item_deps(item_id, dep_id, ordinal) VALUES (?, ?, ?)');
1504
+ const insert = db.prepare('INSERT INTO tracker_item_deps(item_id, dep_id, ordinal) VALUES (?, ?, ?)');
1477
1505
  item.dependsOn.forEach((dep, ordinal) => insert.run(stem, dep, ordinal));
1478
1506
  }
1479
1507
  return { status: existing ? 'updated' : 'inserted', parseError };
1480
1508
  };
1481
1509
 
1482
1510
  /** One queue entry: upsert by entry id and replace its derived event rows. */
1483
- const projectBacklogEntry = ({ db, teamRoot, stem, now, deadlineAt }) => {
1484
- if (Date.now() > deadlineAt) teamDbFail('E_DEADLINE', 'projection deadline expired in the backlog walk', 4);
1485
- const file = path.join(teamRoot, BACKLOG_QUEUE_DIR, `${stem}.json`);
1486
- const read = readBacklogJson(file);
1511
+ const projectTrackerEntry = ({ db, teamRoot, stem, now, deadlineAt }) => {
1512
+ if (Date.now() > deadlineAt) teamDbFail('E_DEADLINE', 'projection deadline expired in the tracker walk', 4);
1513
+ const file = path.join(teamRoot, TRACKER_QUEUE_DIR, `${stem}.json`);
1514
+ const read = readTrackerJson(file);
1487
1515
  const contentHash = sha256(read.text ?? '');
1488
- const existing = db.prepare('SELECT content_hash, absent_at FROM backlog_queue WHERE entry_id = ?').get(stem);
1516
+ const existing = db.prepare('SELECT content_hash, absent_at FROM tracker_queue WHERE entry_id = ?').get(stem);
1489
1517
  if (read.text !== null && existing && existing.content_hash === contentHash && existing.absent_at === null) {
1490
- db.prepare('UPDATE backlog_queue SET last_seen_at = ? WHERE entry_id = ?').run(now, stem);
1518
+ db.prepare('UPDATE tracker_queue SET last_seen_at = ? WHERE entry_id = ?').run(now, stem);
1491
1519
  return { status: 'unchanged', parseError: null };
1492
1520
  }
1493
1521
  let entry = null;
@@ -1506,9 +1534,11 @@ const projectBacklogEntry = ({ db, teamRoot, stem, now, deadlineAt }) => {
1506
1534
  }
1507
1535
  }
1508
1536
  }
1509
- db.prepare(UPSERT_BACKLOG_ENTRY_SQL).run(
1537
+ db.prepare(UPSERT_TRACKER_ENTRY_SQL).run(
1510
1538
  stem,
1511
1539
  entry?.itemId ?? null,
1540
+ entry?.taskSlug ?? null,
1541
+ entry?.linkId ?? null,
1512
1542
  entry?.status ?? null,
1513
1543
  entry?.reason ?? null,
1514
1544
  entry?.requestedBy ?? null,
@@ -1524,10 +1554,10 @@ const projectBacklogEntry = ({ db, teamRoot, stem, now, deadlineAt }) => {
1524
1554
  now,
1525
1555
  now,
1526
1556
  );
1527
- db.prepare('DELETE FROM backlog_queue_events WHERE entry_id = ?').run(stem);
1557
+ db.prepare('DELETE FROM tracker_queue_events WHERE entry_id = ?').run(stem);
1528
1558
  if (Array.isArray(entry?.history)) {
1529
1559
  const insert = db.prepare(
1530
- 'INSERT INTO backlog_queue_events(entry_id, seq, at, type, actor, detail) VALUES (?, ?, ?, ?, ?, ?)',
1560
+ 'INSERT INTO tracker_queue_events(entry_id, seq, at, type, actor, detail) VALUES (?, ?, ?, ?, ?, ?)',
1531
1561
  );
1532
1562
  entry.history.forEach((event, index) => {
1533
1563
  insert.run(stem, index + 1, isoTimestamp(event?.at), event?.type ?? null, event?.actor ?? null, event?.detail ?? null);
@@ -1536,59 +1566,118 @@ const projectBacklogEntry = ({ db, teamRoot, stem, now, deadlineAt }) => {
1536
1566
  return { status: existing ? 'updated' : 'inserted', parseError };
1537
1567
  };
1538
1568
 
1539
- /**
1540
- * Walk `backlog/items/*.json` and `backlog/queue/*.json`: two bounded
1541
- * listings, idempotent by `content_hash`, absent marking for files the walk
1542
- * did not see. `parse_error` rows are recorded failures, never an abort. The
1543
- * whole walk runs in one transaction — 200 rows must stay far under the
1544
- * 250 ms WP3 bound, and a deadline failure rolls the walk back as a unit.
1545
- */
1546
- export function projectBacklog({ db, teamRoot, now, deadlineAt = Infinity }) {
1569
+ /** One tracker link: upsert by link id; the prompt file is read through the document plane. */
1570
+ const projectTrackerLink = ({ db, teamRoot, stem, now, deadlineAt }) => {
1571
+ if (Date.now() > deadlineAt) teamDbFail('E_DEADLINE', 'projection deadline expired in the tracker walk', 4);
1572
+ const file = path.join(teamRoot, TRACKER_LINK_DIR, `${stem}.json`);
1573
+ const read = readTrackerJson(file);
1574
+ const contentHash = sha256(read.text ?? '');
1575
+ const existing = db.prepare('SELECT content_hash, absent_at FROM tracker_item_tasks WHERE link_id = ?').get(stem);
1576
+ if (read.text !== null && existing && existing.content_hash === contentHash && existing.absent_at === null) {
1577
+ db.prepare('UPDATE tracker_item_tasks SET last_seen_at = ? WHERE link_id = ?').run(now, stem);
1578
+ return { status: 'unchanged', parseError: null };
1579
+ }
1580
+ let link = null;
1581
+ let parseError = read.error;
1582
+ if (read.text !== null) {
1583
+ try {
1584
+ link = JSON.parse(read.text);
1585
+ } catch (error) {
1586
+ parseError = error.message;
1587
+ }
1588
+ if (link !== null) {
1589
+ try {
1590
+ validateLinkSchema(link);
1591
+ validateLinkIdentity(link, stem);
1592
+ } catch (error) {
1593
+ parseError = error instanceof TeamDbError ? `${error.code}: ${error.message}` : error.message;
1594
+ }
1595
+ }
1596
+ }
1597
+ db.prepare(UPSERT_TRACKER_LINK_SQL).run(
1598
+ stem,
1599
+ link?.itemId ?? null,
1600
+ link?.taskSlug ?? null,
1601
+ link?.entryId ?? null,
1602
+ link?.role ?? null,
1603
+ link?.decision ?? null,
1604
+ link?.promptPath ?? null,
1605
+ link?.language ?? null,
1606
+ Number.isInteger(link?.revision) ? link.revision : null,
1607
+ isoTimestamp(link?.createdAt),
1608
+ isoTimestamp(link?.updatedAt),
1609
+ Array.isArray(link?.history) ? canonicalJson(link.history) : null,
1610
+ contentHash,
1611
+ parseError,
1612
+ now,
1613
+ now,
1614
+ now,
1615
+ );
1616
+ return { status: existing ? 'updated' : 'inserted', parseError };
1617
+ };
1618
+ export function projectTracker({ db, teamRoot, now, deadlineAt = Infinity }) {
1547
1619
  const seenItems = new Set();
1548
1620
  const seenEntries = new Set();
1621
+ const seenLinks = new Set();
1549
1622
  const counters = { inserted: 0, updated: 0, unchanged: 0, failed: 0, absent: 0 };
1550
1623
  const errors = [];
1551
1624
  db.exec('BEGIN IMMEDIATE');
1552
1625
  try {
1553
- for (const stem of listBacklogJsonFiles(teamRoot, BACKLOG_ITEM_DIR)) {
1626
+ for (const stem of listTrackerJsonFiles(teamRoot, TRACKER_ITEM_DIR)) {
1554
1627
  seenItems.add(stem);
1555
1628
  try {
1556
- const { status, parseError } = projectBacklogItem({ db, teamRoot, stem, now, deadlineAt });
1629
+ const { status, parseError } = projectTrackerItem({ db, teamRoot, stem, now, deadlineAt });
1557
1630
  counters[status] += 1;
1558
1631
  if (parseError !== null) {
1559
1632
  counters.failed += 1;
1560
- errors.push({ path: `${BACKLOG_ITEM_DIR}/${stem}.json`, reason: parseError });
1633
+ errors.push({ path: `${TRACKER_ITEM_DIR}/${stem}.json`, reason: parseError });
1561
1634
  }
1562
1635
  } catch (error) {
1563
1636
  if (error instanceof TeamDbError) throw error;
1564
1637
  counters.failed += 1;
1565
- errors.push({ path: `${BACKLOG_ITEM_DIR}/${stem}.json`, reason: error.message });
1638
+ errors.push({ path: `${TRACKER_ITEM_DIR}/${stem}.json`, reason: error.message });
1566
1639
  }
1567
1640
  }
1568
- for (const stem of listBacklogJsonFiles(teamRoot, BACKLOG_QUEUE_DIR)) {
1641
+ for (const stem of listTrackerJsonFiles(teamRoot, TRACKER_QUEUE_DIR)) {
1569
1642
  seenEntries.add(stem);
1570
1643
  try {
1571
- const { status, parseError } = projectBacklogEntry({ db, teamRoot, stem, now, deadlineAt });
1644
+ const { status, parseError } = projectTrackerEntry({ db, teamRoot, stem, now, deadlineAt });
1572
1645
  counters[status] += 1;
1573
1646
  if (parseError !== null) {
1574
1647
  counters.failed += 1;
1575
- errors.push({ path: `${BACKLOG_QUEUE_DIR}/${stem}.json`, reason: parseError });
1648
+ errors.push({ path: `${TRACKER_QUEUE_DIR}/${stem}.json`, reason: parseError });
1576
1649
  }
1577
1650
  } catch (error) {
1578
1651
  if (error instanceof TeamDbError) throw error;
1579
1652
  counters.failed += 1;
1580
- errors.push({ path: `${BACKLOG_QUEUE_DIR}/${stem}.json`, reason: error.message });
1653
+ errors.push({ path: `${TRACKER_QUEUE_DIR}/${stem}.json`, reason: error.message });
1654
+ }
1655
+ }
1656
+ for (const stem of listTrackerJsonFiles(teamRoot, TRACKER_LINK_DIR)) {
1657
+ seenLinks.add(stem);
1658
+ try {
1659
+ const { status, parseError } = projectTrackerLink({ db, teamRoot, stem, now, deadlineAt });
1660
+ counters[status] += 1;
1661
+ if (parseError !== null) {
1662
+ counters.failed += 1;
1663
+ errors.push({ path: `${TRACKER_LINK_DIR}/${stem}.json`, reason: parseError });
1664
+ }
1665
+ } catch (error) {
1666
+ if (error instanceof TeamDbError) throw error;
1667
+ counters.failed += 1;
1668
+ errors.push({ path: `${TRACKER_LINK_DIR}/${stem}.json`, reason: error.message });
1581
1669
  }
1582
1670
  }
1583
1671
  const markAbsent = (table, keyColumn, seen) => {
1584
1672
  for (const row of db.prepare(`SELECT ${keyColumn} AS key FROM ${table} WHERE absent_at IS NULL`).all()) {
1585
- if (seen.has(row.key)) continue;
1673
+ if (seen.has(String(row.key))) continue;
1586
1674
  db.prepare(`UPDATE ${table} SET absent_at = ? WHERE ${keyColumn} = ? AND absent_at IS NULL`).run(now, row.key);
1587
1675
  counters.absent += 1;
1588
1676
  }
1589
1677
  };
1590
- markAbsent('backlog_items', 'id', seenItems);
1591
- markAbsent('backlog_queue', 'entry_id', seenEntries);
1678
+ markAbsent('tracker_items', 'id', seenItems);
1679
+ markAbsent('tracker_queue', 'entry_id', seenEntries);
1680
+ markAbsent('tracker_item_tasks', 'link_id', seenLinks);
1592
1681
  db.exec('COMMIT');
1593
1682
  } catch (error) {
1594
1683
  try {
@@ -1728,6 +1817,26 @@ const defaultDeadline = (slug) => (slug ? DEFAULT_SLUG_DEADLINE_MS : Infinity);
1728
1817
  * Returns the `SyncResult` shape; throws `TeamDbError` for database-level
1729
1818
  * failures, usage errors, and deadline expiry.
1730
1819
  */
1820
+ /**
1821
+ * Project only the tracker store. The write verbs call this after a tracker
1822
+ * write so the read-only API sees the new rows without paying for a full task
1823
+ * walk; the next full sync reconciles every other surface.
1824
+ */
1825
+ export function syncTrackerProjection(options = {}) {
1826
+ const handle = openTeamDb({
1827
+ teamRoot: options.teamRoot,
1828
+ dbPath: options.dbPath,
1829
+ env: options.env,
1830
+ });
1831
+ try {
1832
+ const now = (options.now ?? new Date()).toISOString();
1833
+ const deadlineAt = Date.now() + (options.deadlineMs ?? 4_000);
1834
+ return projectTracker({ db: handle.db, teamRoot: handle.teamRoot, now, deadlineAt });
1835
+ } finally {
1836
+ handle.db.close();
1837
+ }
1838
+ }
1839
+
1731
1840
  export function syncProjection(options = {}) {
1732
1841
  const slug = options.slug ?? null;
1733
1842
  const maintain = Boolean(options.maintain || options.vacuum);
@@ -1816,27 +1925,27 @@ export function syncProjection(options = {}) {
1816
1925
  }
1817
1926
  if (prune) {
1818
1927
  result.pruned += db.prepare('DELETE FROM tasks WHERE absent_at IS NOT NULL').run().changes;
1819
- // Backlog rows follow their files: pruning deletes rows marked absent.
1820
- result.pruned += db.prepare('DELETE FROM backlog_queue WHERE absent_at IS NOT NULL').run().changes;
1821
- result.pruned += db.prepare('DELETE FROM backlog_items WHERE absent_at IS NOT NULL').run().changes;
1928
+ // Tracker rows follow their files: pruning deletes rows marked absent.
1929
+ result.pruned += db.prepare('DELETE FROM tracker_queue WHERE absent_at IS NOT NULL').run().changes;
1930
+ result.pruned += db.prepare('DELETE FROM tracker_items WHERE absent_at IS NOT NULL').run().changes;
1822
1931
  }
1823
- // Projection order is tasks -> backlog -> jobs.json -> runs/** (FK-safe)
1824
- // -> retention. The backlog walk is two bounded listings, runs in slug
1932
+ // Projection order is tasks -> tracker -> jobs.json -> runs/** (FK-safe)
1933
+ // -> retention. The tracker walk is two bounded listings, runs in slug
1825
1934
  // mode too, and stays inside the deadline budget (WP3 VERIFY: 200 items
1826
1935
  // must cost well under 250 ms).
1827
1936
  {
1828
- const backlogProjection = projectBacklog({
1937
+ const trackerProjection = projectTracker({
1829
1938
  db,
1830
1939
  teamRoot: handle.teamRoot,
1831
1940
  now: new Date().toISOString(),
1832
1941
  deadlineAt,
1833
1942
  });
1834
- result.inserted += backlogProjection.inserted;
1835
- result.updated += backlogProjection.updated;
1836
- result.unchanged += backlogProjection.unchanged;
1837
- result.absent += backlogProjection.absent;
1838
- result.failed += backlogProjection.failed;
1839
- for (const error of backlogProjection.errors) result.errors.push(error);
1943
+ result.inserted += trackerProjection.inserted;
1944
+ result.updated += trackerProjection.updated;
1945
+ result.unchanged += trackerProjection.unchanged;
1946
+ result.absent += trackerProjection.absent;
1947
+ result.failed += trackerProjection.failed;
1948
+ for (const error of trackerProjection.errors) result.errors.push(error);
1840
1949
  }
1841
1950
  if (!slug) {
1842
1951
  const schedulerProjection = projectScheduler(db, { teamRoot: handle.teamRoot });
@@ -887,6 +887,10 @@ const writeLease = (teamRoot, lease) => {
887
887
  */
888
888
  const claimLease = (teamRoot, lease) => {
889
889
  const paths = schedulerPaths(teamRoot);
890
+ // The replaced writeLease created the directory through writeAtomic; the
891
+ // exclusive create must do the same, or a bare team root fails with ENOENT.
892
+ // Two contenders both mkdir recursively, then exactly one `wx` wins.
893
+ fs.mkdirSync(path.dirname(paths.lock), { recursive: true, mode: 0o700 });
890
894
  let fd;
891
895
  try {
892
896
  fd = fs.openSync(paths.lock, 'wx', 0o600);
@@ -397,11 +397,10 @@ CREATE INDEX idx_job_run_events_at ON job_run_events(at);
397
397
  `;
398
398
 
399
399
  /**
400
- * Migration 3: the backlog projection. Four tables, five indexes, additive
401
- * only — no `ALTER` of `tasks` or `scheduler` tables, so a wrong v3 costs a
402
- * v4, never an edit (D-1, brief R-2). `active`/`done` are derived from the
403
- * joined task row, never stored; `backlog_item_deps` has no FK on `dep_id` so
404
- * a broken file set projects as a recorded error instead of aborting the run.
400
+ * Migration 3: the shipped backlog projection. Kept byte-for-byte because
401
+ * migration history is immutable; migration 4 replaces it with the integer-id
402
+ * tracker surface. Its rows are not carried across: the projection is rebuilt
403
+ * from the files after `tracker migrate-ids`.
405
404
  */
406
405
  export const BACKLOG_SQL = SQL`CREATE TABLE backlog_items (
407
406
  id TEXT PRIMARY KEY,
@@ -473,6 +472,116 @@ CREATE INDEX idx_backlog_queue_status ON backlog_queue(status, requested_at);
473
472
  CREATE INDEX idx_backlog_queue_item ON backlog_queue(item_id);
474
473
  `;
475
474
 
475
+ /**
476
+ * Migration 4: the integer-id tracker surface. Tracker tables carry the
477
+ * `backlog` status and a numeric item key, the queue gains task/link columns,
478
+ * and `tracker_item_tasks` holds the item↔task relation. The old backlog tables
479
+ * are dropped without a row copy: the projection is derived from the files and
480
+ * the next sync rebuilds it. Migration 3 stays byte-identical.
481
+ */
482
+ export const TRACKER_SQL = SQL`CREATE TABLE tracker_items (
483
+ id INTEGER PRIMARY KEY,
484
+ title TEXT,
485
+ status TEXT CHECK (status IS NULL OR status IN ('backlog','planned','completed','cancelled','superseded')),
486
+ priority INTEGER CHECK (priority IS NULL OR priority BETWEEN 0 AND 9),
487
+ type TEXT,
488
+ description TEXT,
489
+ labels_json TEXT,
490
+ source_task TEXT,
491
+ source_refs_json TEXT,
492
+ revision INTEGER,
493
+ created_at TEXT,
494
+ updated_at TEXT,
495
+ completed_at TEXT,
496
+ cancelled_at TEXT,
497
+ cancel_reason TEXT,
498
+ superseded_by INTEGER,
499
+ history_json TEXT,
500
+ content_hash TEXT,
501
+ parse_error TEXT,
502
+ projected_at TEXT NOT NULL,
503
+ first_seen_at TEXT NOT NULL,
504
+ last_seen_at TEXT NOT NULL,
505
+ absent_at TEXT
506
+ ) STRICT;
507
+
508
+ CREATE TABLE tracker_item_deps (
509
+ item_id INTEGER NOT NULL,
510
+ dep_id INTEGER NOT NULL,
511
+ ordinal INTEGER NOT NULL,
512
+ PRIMARY KEY (item_id, dep_id)
513
+ ) STRICT;
514
+
515
+ CREATE TABLE tracker_queue (
516
+ entry_id TEXT PRIMARY KEY,
517
+ item_id INTEGER NOT NULL,
518
+ task_slug TEXT,
519
+ link_id TEXT,
520
+ status TEXT CHECK (status IS NULL OR status IN ('queued','claimed','cancelled','expired')),
521
+ reason TEXT,
522
+ requested_by TEXT,
523
+ command TEXT,
524
+ revision INTEGER,
525
+ requested_at TEXT,
526
+ claimed_at TEXT,
527
+ finished_at TEXT,
528
+ history_json TEXT,
529
+ content_hash TEXT,
530
+ parse_error TEXT,
531
+ projected_at TEXT NOT NULL,
532
+ first_seen_at TEXT NOT NULL,
533
+ last_seen_at TEXT NOT NULL,
534
+ absent_at TEXT
535
+ ) STRICT;
536
+
537
+ CREATE TABLE tracker_queue_events (
538
+ entry_id TEXT NOT NULL,
539
+ seq INTEGER NOT NULL CHECK (seq >= 1),
540
+ at TEXT,
541
+ type TEXT,
542
+ actor TEXT,
543
+ detail TEXT,
544
+ PRIMARY KEY (entry_id, seq)
545
+ ) STRICT;
546
+
547
+ CREATE TABLE tracker_item_tasks (
548
+ link_id TEXT PRIMARY KEY,
549
+ item_id INTEGER NOT NULL,
550
+ task_slug TEXT NOT NULL,
551
+ entry_id TEXT,
552
+ role TEXT,
553
+ decision TEXT CHECK (decision IS NULL OR decision IN ('requested','stopped','unlinked')),
554
+ prompt_path TEXT,
555
+ language TEXT,
556
+ revision INTEGER,
557
+ created_at TEXT,
558
+ updated_at TEXT,
559
+ history_json TEXT,
560
+ content_hash TEXT,
561
+ parse_error TEXT,
562
+ projected_at TEXT NOT NULL,
563
+ first_seen_at TEXT NOT NULL,
564
+ last_seen_at TEXT NOT NULL,
565
+ absent_at TEXT
566
+ ) STRICT;
567
+
568
+ -- The projection is derived: the first sync rebuilds it from the files.
569
+ DROP TABLE backlog_item_deps;
570
+ DROP TABLE backlog_queue_events;
571
+ DROP TABLE backlog_queue;
572
+ DROP TABLE backlog_items;
573
+
574
+ CREATE INDEX idx_tracker_items_order ON tracker_items(status, priority, created_at, id);
575
+ CREATE INDEX idx_tracker_items_source ON tracker_items(source_task);
576
+ CREATE INDEX idx_tracker_item_deps_dep ON tracker_item_deps(dep_id);
577
+ CREATE INDEX idx_tracker_queue_status ON tracker_queue(status, requested_at);
578
+ CREATE INDEX idx_tracker_queue_item ON tracker_queue(item_id);
579
+ CREATE INDEX idx_tracker_queue_task ON tracker_queue(task_slug);
580
+ CREATE INDEX idx_tracker_item_tasks_item ON tracker_item_tasks(item_id);
581
+ CREATE INDEX idx_tracker_item_tasks_task ON tracker_item_tasks(task_slug);
582
+ CREATE INDEX idx_tracker_item_tasks_decision ON tracker_item_tasks(decision);
583
+ `;
584
+
476
585
  const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
477
586
 
478
587
  /**
@@ -498,6 +607,12 @@ export const MIGRATIONS = [
498
607
  sql: BACKLOG_SQL,
499
608
  checksum: '430c079a4ec42bc93094f364df228c2f55772e1f9e8f1e0e509b1d16c2de7f90',
500
609
  },
610
+ {
611
+ version: 4,
612
+ name: '0004-tracker',
613
+ sql: TRACKER_SQL,
614
+ checksum: '641f18c269a1595d1fb1e4878f9919e9d41a257d030cf1f65ee07fb99ac55552',
615
+ },
501
616
  ];
502
617
 
503
618
  /** Highest migration version shipped by this module. */
@@ -530,6 +645,29 @@ const isTruthy = (value) => {
530
645
 
531
646
  export const isKillSwitchSet = (env = process.env) => isTruthy(env.AI_RULES_TEAM_DB_DISABLE);
532
647
 
648
+ /**
649
+ * Repository identity of one team root: the first 12 hex characters of
650
+ * `sha256(<resolved team root>)`.
651
+ *
652
+ * The path is canonicalised through `realpath` when it exists, so a symlinked
653
+ * spelling of the same repository hashes like the real one; a path that does not
654
+ * exist yet falls back to `path.resolve`. The API publishes the value as
655
+ * `/health.rootId` and the `ui` supervisor compares it with its own hash, so two
656
+ * repositories that find each other on one port are a named refusal instead of a
657
+ * silent cross-wired dashboard. It is a hash, never a path: the value discloses
658
+ * nothing about the filesystem.
659
+ */
660
+ export const teamRootId = (teamRoot) => {
661
+ const resolved = path.resolve(teamRoot);
662
+ let identity = resolved;
663
+ try {
664
+ identity = fs.realpathSync(resolved);
665
+ } catch {
666
+ identity = resolved;
667
+ }
668
+ return crypto.createHash('sha256').update(identity).digest('hex').slice(0, 12);
669
+ };
670
+
533
671
  const parseNodeVersion = (version) => {
534
672
  const match = /^(\d+)\.(\d+)\.(\d+)/.exec(String(version || ''));
535
673
  if (!match) return null;