@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
package/docs/TEAM-DB.md CHANGED
@@ -4,12 +4,14 @@
4
4
  The task files remain the source of truth; the database exists so an operator or a tool can
5
5
  query history without walking JSON on every request.
6
6
 
7
- The projection is installed by `init` as seven modules under `.ai.local/scripts/`:
7
+ The projection is installed by `init` as ten `team-db*.mjs` modules under `.ai.local/scripts/`:
8
8
 
9
9
  | Module | Role |
10
10
  |---|---|
11
- | `team-db.mjs` | CLI: `init`, `sync`, `delete`, `migrate-tasks`, `check`, `serve`, `jobs`, `schedule`, `backlog` |
12
- | `team-db-backlog.mjs` | the file-authoritative backlog: items, the launch queue, eligibility order, import |
11
+ | `team-db.mjs` | CLI: `init`, `sync`, `delete`, `migrate-tasks`, `check`, `search`, `serve`, `jobs`, `schedule`, `tracker`, `task-run`, `ui` |
12
+ | `team-db-ui.mjs` | the `ui` supervisor: probe-first `start`, `stop`, `status`, `restart`, the ownership marker, leader-only termination |
13
+ | `team-db-tracker.mjs` | the file-authoritative tracker: items, links, the launch queue, eligibility order, import |
14
+ | `team-db-task-runner.mjs` | the opt-in `team/runner.json` supervisor behind tracker Continue |
13
15
  | `team-db-schema.mjs` | capability probe, embedded migrations, pragmas, fingerprint, integrity |
14
16
  | `team-db-project.mjs` | parsers, idempotent projector, confirmed task deletion, retention, search |
15
17
  | `team-db-api.mjs` | `node:http` server (reads plus the bounded mutations), query layer, security boundary |
@@ -17,6 +19,15 @@ The projection is installed by `init` as seven modules under `.ai.local/scripts/
17
19
  | `team-db-dashboard.mjs` | the no-build dashboard (HTML, CSS, JS strings) |
18
20
  | `team-db-scheduler.mjs` | job model, cron/interval math, the file store, the projection, and the timer |
19
21
 
22
+ The same seeded set is `ENGINE_SCRIPTS` in `bin/lib/engine-scripts.js`: the ten `team-db*.mjs`
23
+ modules plus the self-learning engine, `manifest.mjs`, `dump-output.mjs`,
24
+ `check-write-scope.mjs`, `aggregate-agent-task-metrics.mjs`, and the `processes.mjs` +
25
+ `process-lease.mjs` process manager (twenty-two published entries;
26
+ `node -e "require('./bin/lib/engine-scripts.js').SHIPPED_ENGINE_SCRIPTS.length"` prints the
27
+ shipped count). One further module, `upstream-research.mjs`, is declared in
28
+ `REPO_ONLY_ENGINE_SCRIPTS`: it exists in this repository's preset source and dogfood mirror but
29
+ is excluded from the published tarball, and a consumer install skips it without a warning.
30
+
20
31
  ## Behavior contract
21
32
 
22
33
  - **Files are authoritative.** `status.json`, `pipeline.json`, `metrics.json`,
@@ -106,8 +117,12 @@ node .ai.local/scripts/team-db.mjs delete --slug <slug> [--root <team-dir>] [--j
106
117
  node .ai.local/scripts/team-db.mjs migrate-tasks [--root <team-dir>] [--quiet] [--json]
107
118
  [--rebuild | --no-rebuild]
108
119
  node .ai.local/scripts/team-db.mjs check [--root <team-dir>]
120
+ node .ai.local/scripts/team-db.mjs search <query> [--limit <n>] [--json] [--root <team-dir>]
109
121
  node .ai.local/scripts/team-db.mjs serve [--root <team-dir>] [--host <addr>] [--port <n>]
110
122
  [--allow-remote] [--open]
123
+ node .ai.local/scripts/team-db.mjs ui start|restart [--root <team-dir>] [--json] [--quiet]
124
+ [--host <loopback>] [--port <n>] [--open]
125
+ node .ai.local/scripts/team-db.mjs ui stop|status [--root <team-dir>] [--json] [--quiet]
111
126
  node .ai.local/scripts/team-db.mjs jobs list [--enabled] [--sort <key>] [--json] [--quiet]
112
127
  node .ai.local/scripts/team-db.mjs jobs get <id> [--json]
113
128
  node .ai.local/scripts/team-db.mjs jobs put --file <path|-> [--dry-run] [--json]
@@ -117,12 +132,13 @@ node .ai.local/scripts/team-db.mjs jobs reconcile [--json]
117
132
  node .ai.local/scripts/team-db.mjs jobs run --id <id> [--json]
118
133
  node .ai.local/scripts/team-db.mjs schedule [--once] [--interval-ms <n>] [--grace-ms <n>]
119
134
  [--drain-ms <n>] [--json] [--quiet]
120
- node .ai.local/scripts/team-db.mjs backlog add --file <path|-> [--json] [--quiet]
121
- node .ai.local/scripts/team-db.mjs backlog set <id> --file <path|-> [--json]
122
- node .ai.local/scripts/team-db.mjs backlog show <id> | list [--status <csv>] [--ready] | ready | validate
135
+ node .ai.local/scripts/team-db.mjs tracker add --file <path|-> [--json] [--quiet]
136
+ node .ai.local/scripts/team-db.mjs tracker set <id> --file <path|-> [--json]
137
+ node .ai.local/scripts/team-db.mjs tracker show <id> | list [--status <csv>] [--ready] | ready | validate
123
138
  [--json]
124
- node .ai.local/scripts/team-db.mjs backlog import --file <path|-> [--dry-run] [--json]
125
- node .ai.local/scripts/team-db.mjs backlog enqueue --file <path|-> | cancel <entryId> | drain [--claim]
139
+ node .ai.local/scripts/team-db.mjs tracker import --file <path|-> [--dry-run] [--json]
140
+ node .ai.local/scripts/team-db.mjs tracker migrate-ids [--json] [--quiet]
141
+ node .ai.local/scripts/team-db.mjs tracker enqueue --file <path|-> | cancel <entryId> | drain [--claim]
126
142
  | recover | prune [--older-than <days>] [--json] [--quiet]
127
143
  ```
128
144
 
@@ -130,11 +146,24 @@ Exit codes: `0` ok, `1` at least one task failed, a delete refusal (unknown slug
130
146
  task, kill switch, folder-delete failure) or a migration checksum drifted, `2`
131
147
  database-level failure — a `delete` without `node:sqlite` refuses here rather than deleting
132
148
  the folder only, `3` usage, `4` deadline or busy database (the hook-shaped `sync --slug`
133
- deadline, or a delete that meets a locked database). The `backlog` verbs reuse the same
134
- vocabulary: `0` ok, `1` a validation refusal carrying its named code (`E_BACKLOG_CYCLE`,
135
- `E_BACKLOG_SELF_DEP`, `E_BACKLOG_UNKNOWN_DEP`, `E_BACKLOG_DUPLICATE_ID`, `E_ID_COLLISION`,
136
- `E_BACKLOG_TRANSITION`, `E_BACKLOG_REVISION`, `E_SCHEMA`), `3` usage, `4` the tree lock was
137
- contended (`E_BACKLOG_BUSY`).
149
+ deadline, or a delete that meets a locked database). The `tracker` verbs reuse the same
150
+ vocabulary: `0` ok, `1` a validation refusal carrying its named code (`E_TRACKER_CYCLE`,
151
+ `E_TRACKER_SELF_DEP`, `E_TRACKER_UNKNOWN_DEP`, `E_TRACKER_DUPLICATE_ID`, `E_ID_COLLISION`,
152
+ `E_TRACKER_TRANSITION`, `E_TRACKER_REVISION`, `E_SCHEMA`), `3` usage, `4` the tree lock was
153
+ contended (`E_TRACKER_BUSY`).
154
+
155
+ `search <query>` answers from the FTS5 projection: it calls `searchProjection` (`MATCH` when the
156
+ `search_fts` table exists, the escaped `LIKE` fallback otherwise) and never builds SQL from the
157
+ input. It opens the database read-only, defaults to 5 hits, clamps `--limit` to 1…20 (a larger
158
+ number is clamped, not refused) and prints one line per hit — task slug, document path, kind,
159
+ snippet. A snippet collapses whitespace and is cut at 800 B on a UTF-8 boundary with `…`;
160
+ `--json` prints exactly one array of `{taskSlug, doc_path, kind, snippet, snippetBytes,
161
+ snippetTruncated}`. No match prints `team-db: no matches for "<query>"` (`[]` under `--json`)
162
+ with exit 0, a missing database is `E_DB_MISSING` with exit 2, and the kill switch or an
163
+ unavailable `node:sqlite` answer as they do for `check` (exit 1). The writer behind it is the
164
+ shipped `dump-output.mjs`: it stores a command output under
165
+ `.ai.local/team/tasks/<slug>/outputs/<id>.txt` with a hard cap of 2 097 152 B (2 MiB) per file
166
+ and prints a bounded head, so the next projection indexes the file and this verb finds it.
138
167
 
139
168
  `sync` is idempotent: a second run reports `inserted=0 updated=0 unchanged=<n>`. One changed
140
169
  byte changes exactly one document hash and one task content hash. A removed task directory is
@@ -170,57 +199,96 @@ targets must be on the same host.
170
199
 
171
200
  | Name | Effect |
172
201
  |---|---|
173
- | `AI_RULES_TEAM_DB_DISABLE` | truthy value turns the **projection** off — the database write points and `serve` stop; the task files and the `backlog` file verbs stay usable (the backlog is not disabled by this switch, R3-7) |
202
+ | `AI_RULES_TEAM_DB_DISABLE` | truthy value turns the **projection** off — the database write points, the `task-run ensure` seed and `serve` stop; `ui start`/`ui restart` refuse with `E_DISABLED` before any probe, write or signal; the task files and the `tracker` file verbs stay usable (the tracker is not disabled by this switch, R3-7) |
174
203
  | `AI_RULES_TEAM_DB_FORCE_FALLBACK` | truthy value forces the file-only path even on a supported runtime |
175
204
  | `AI_RULES_TEAM_DB_ROOT` | team directory when `--root` is absent |
176
205
  | `AI_RULES_TEAM_DB_PATH` | database file path (default `<teamRoot>/team.db`) |
177
206
  | `AI_RULES_TEAM_DB_LOG` | error-log path (default `<cwd>/.ai.local/team/team-db-errors.log`) |
178
207
  | `AI_RULES_TEAM_DB_SEAM` | phase label in the error log: `hook`, `receipt`, `cli`, `serve` |
179
- | `AI_RULES_TEAM_DB_BACKLOG_DRAIN_DISABLE` | truthy value stops the hook stop-seam auto-drain only; the `backlog` file verbs stay usable |
208
+ | `AI_RULES_TEAM_DB_TRACKER_DRAIN_DISABLE` | truthy value stops the hook stop-seam auto-drain only; the `tracker` file verbs stay usable |
180
209
 
181
210
  No other environment value is read or persisted. The error log stores a timestamp, a code,
182
211
  a phase, and a message; it never stores prompt content or an environment value, and it is
183
212
  trimmed to the newest 200 lines / 64 KiB.
184
213
 
185
- ## Backlog
186
-
187
- `team/backlog/` is a file-authoritative store with one writer: `team-db-backlog.mjs`.
188
- `backlog/items/<id>.json` is committed (the plan the team executes); `backlog/queue/` is
189
- runtime state and git-ignored. The stored status lattice is `planned|completed|cancelled|
190
- superseded`; every operational status (`effectiveStatus`, `ready`, `waitingOn`) is derived
191
- from the item files, the queue entries and the hook-owned `tasks/*/status.json` state, and
192
- is never written to a file. The total order is `priority` ascending — **lower runs
193
- first**, with the default priority 5 — then `createdAt`, then `id`; there is no `sort`
194
- parameter, so the list, the drain and the ready set can never disagree.
195
-
196
- An item's `id` matches the slug grammar, is immutable, and becomes the `/task` slug at
197
- launch; creating an item whose id already names a `tasks/<id>/` folder is refused with
198
- `E_ID_COLLISION`. Writes validate schema → identity → graph (first failure wins) and bump
199
- the `revision` CAS token; `backlog set` refuses a stale `revision` with `E_BACKLOG_REVISION`.
200
-
201
- The launch queue serializes task starts: `backlog enqueue` records a request (idempotent
202
- per item — a duplicate appends its reason to the entry history), `backlog drain --claim`
203
- grants at most one claim in drain order and never starts a run, and the hook stop seam
204
- consumes the claim and bootstraps `tasks/<slug>/pipeline.json` (the recorded `command` is
205
- never executed). `backlog/config.json` carries `maxActive` (1…8, default 1): a task in a
206
- holding state (`in_progress`, `awaiting_artifact_receipt`, `blocked`) occupies a slot, a
207
- task at a human gate does not. A claim older than 90 s with no task row is released on the
208
- next drain or by `backlog recover`; `backlog prune --older-than <days>` deletes aged
209
- terminal entry files only. The backlog module never writes `status.json`, `metrics.json`,
214
+ ## Tracker
215
+
216
+ `team/tracker/` is a file-authoritative store with one writer: `team-db-tracker.mjs`.
217
+ `tracker/items/<id>.json` is committed (the plan the team executes); `tracker/links/` is
218
+ committed (one relation record and prompt per item ↔ task pair); `tracker/queue/` and
219
+ `team/task-runs/` are runtime state and git-ignored. The stored status lattice is
220
+ `backlog|planned|completed|cancelled|superseded`; **backlog is the captured state** and is
221
+ not launchable until promoted to `planned`. Every operational status (`effectiveStatus`,
222
+ `ready`, `waitingOn`) is derived from the item files, the links, the queue entries and the
223
+ hook-owned `tasks/*/status.json` state, and is never written to a file. The total order is
224
+ `priority` ascending — **lower runs first**, with the default priority 5 — then
225
+ `createdAt`, then `id`; there is no `sort` parameter, so the list, the drain and the ready
226
+ set can never disagree.
227
+
228
+ An item's `id` is a positive integer assigned by the store and immutable. The store keeps
229
+ `tracker/sequence.json` (`{schemaVersion, nextId}`) and falls back to the highest existing
230
+ item file, so ids are monotonic and never reused. The id is **not** the team-task slug:
231
+ `tracker/link add` writes `tracker/links/<itemId>--<taskSlug>.json` plus its prompt, and one
232
+ item may carry several linked tasks. A task started from an item without an explicit slug
233
+ defaults to `tracker-<itemId>`. The link stores only the operator decision
234
+ (`requested|stopped|unlinked`); its effective state (`requested|claimed|active|paused|
235
+ stopped|completed|failed|unlinked`) is derived from the queue entry and the task row. A
236
+ legacy `tasks/<itemId>/` without a link file is shown as an implicit primary link;
237
+ `tracker link adopt` materializes it. `tracker delete <id>` removes the item, its links and
238
+ prompts, but never the team tasks; it refuses while a linked task is active or a queue
239
+ entry is non-terminal. Writes validate schema → identity → graph (first failure wins) and
240
+ bump the `revision` CAS token; `tracker set` refuses a stale `revision` with
241
+ `E_TRACKER_REVISION`.
242
+
243
+ The launch queue serializes task starts: `tracker enqueue` records a request with its own
244
+ `taskSlug` and `linkId` (a duplicate for the same task appends its reason to the entry
245
+ history), `tracker drain --claim` grants at most one claim in drain order and never starts
246
+ a run, and the hook stop seam consumes the claim and bootstraps `tasks/<taskSlug>/` with a
247
+ `pipeline.json` naming `trackerItemId`/`trackerLinkId` and the link prompt (the recorded
248
+ `command` is never executed). `tracker/config.json` carries `maxActive` (1…8, default 1): a
249
+ task in a holding state (`in_progress`, `awaiting_artifact_receipt`, `blocked`) occupies a
250
+ slot, a task at a human gate does not. A claim older than 90 s with no task row is released
251
+ on the next drain or by `tracker recover`; `tracker prune --older-than <days>` deletes aged
252
+ terminal entry files only. The tracker module never writes `status.json`, `metrics.json`,
210
253
  or `scheduler/jobs.json`.
211
254
 
212
- **Import envelope (D-8).** `backlog import --file <path|->` reads a versioned envelope
255
+ **Task control.** The tracker item detail can start a new linked task (link + queue
256
+ request), stop a link (cancel the queued request, write the per-task `tasks/<slug>/STOP`
257
+ sentinel, and terminate the active runner process group), and continue a paused/stopped
258
+ link. Continue uses the committed `team/runner.json`; `team-db.mjs task-run ensure` seeds it
259
+ with the OpenCode default when absent (the `ui` verbs never write it, and the kill switch
260
+ skips the seed), so an operator never edits the file by hand. The runner is supervised by
261
+ `team-db-task-runner.mjs` with an argv array, no shell, a repository-confined cwd, an env
262
+ allow-list, a timeout, capped logs and a process-group kill. A missing file still answers
263
+ `409 E_RUNNER_OFFLINE` and the UI disables Continue. The runner never writes `status.json`
264
+ or `metrics.json`. The seeded config is:
265
+
266
+ ```json
267
+ {
268
+ "schemaVersion": 1,
269
+ "runner": ["opencode", "run", "--format", "json", "/task-continue", "{taskSlug}"],
270
+ "cwd": "../..",
271
+ "timeoutMs": 1800000,
272
+ "envPassthrough": []
273
+ }
274
+ ```
275
+
276
+ Replace `runner` only when the host CLI differs; the argv array may use `{promptFile}`,
277
+ `{taskSlug}` or `{teamRoot}`, never a shell string.
278
+
279
+ **Import envelope (D-8).** `tracker import --file <path|->` reads a versioned envelope
213
280
  `{ schemaVersion: 1, source: { task, generatedAt }, items: [...] }`, validates every item
214
281
  as one transaction (a failure writes nothing), upserts by id, writes nothing on `--dry-run`,
215
282
  and an idle re-import (content-hash equality over the envelope fields) writes nothing.
216
283
  `revision` and `history` are store-owned and never part of that comparison.
217
284
 
218
- **Kill switch.** `AI_RULES_TEAM_DB_DISABLE=1` disables the **projection**, not the backlog:
219
- `backlog add|set|show|list|ready|validate|import|enqueue|cancel|drain|recover|prune` stay
220
- usable because they are file writes to the authoritative tree; the projection child each
221
- write verb spawns is skipped silently, and a runtime without `node:sqlite` keeps the store
222
- file-only end to end. `AI_RULES_TEAM_DB_BACKLOG_DRAIN_DISABLE=1` stops only the hook's
223
- automatic drain.
285
+ **Kill switch.** `AI_RULES_TEAM_DB_DISABLE=1` disables the **projection**, not the tracker:
286
+ `tracker add|set|show|list|ready|validate|import|enqueue|cancel|drain|recover|prune|link|delete|adopt`
287
+ stay usable because they are file writes to the authoritative tree; the projection child
288
+ each write verb spawns is skipped silently, and a runtime without `node:sqlite` keeps the
289
+ store file-only end to end. `AI_RULES_TEAM_DB_TRACKER_DRAIN_DISABLE=1` stops only the hook's
290
+ automatic drain. The API's `E_DISABLED` guard refuses every tracker mutation, including
291
+ `task-run`, before a child is spawned.
224
292
 
225
293
  ## Scheduled jobs
226
294
 
@@ -284,7 +352,13 @@ not supported in v1.
284
352
 
285
353
  ## Upstream research job
286
354
 
287
- The `next` preset ships one `pipeline` job, `upstream-research`, and one engine module,
355
+ **Repository-only.** This job, the `/upstream-research` command, the
356
+ `.ai.local/scripts/upstream-research.mjs` runner, and every `team/upstream/` template are used
357
+ only in the `@bonesofspring/ai-rules` repository. The published tarball excludes all of them:
358
+ a consumer install seeds no job and no runner. The rest of this section documents the workflow
359
+ for repository maintainers.
360
+
361
+ The `next` preset carries one `pipeline` job, `upstream-research`, and one engine module,
288
362
  `.ai.local/scripts/upstream-research.mjs`. The job renders `upstream/prompt.md` and runs the
289
363
  module with `--prompt {promptFile} --team-root . --repo-root ../..`; it is a normal
290
364
  definition in `scheduler/jobs.json`, so `jobs list|get|put|enable|disable|run`, the dashboard
@@ -305,19 +379,35 @@ one `schedule --once` tick.
305
379
  `.ai.local/team/upstream/cursor.json`. A lost cursor is rebuilt from the newest
306
380
  `scheduler/runs/upstream-research/<runId>/report.json`, then degrades to a bounded baseline
307
381
  when the run tree has been pruned. `upstream/projects.json`, `config.json`, `signatures.json`,
308
- the prompt, the digest template, and the agent config are committed; `docs/upstream/digest-
309
- <runId>.md` is committed and never pruned.
382
+ the prompt, the plan prompt, the digest template, the agent config, and `tracker.json` are
383
+ committed; `docs/upstream/digest-<runId>.md` is committed and never pruned.
310
384
 
311
385
  **Write allow-list.** A run writes only `scheduler/runs/upstream-research/<runId>/**`, the
312
- cursor, and the committed digest. It never writes `status.json` or `metrics.json`, and the
313
- scheduler keeps owning `run.json`, `stdout.log`, `stderr.log`, and `<runDir>/prompt.md`.
386
+ cursor, `upstream/tracker.json`, the `team/tracker/items/**` it creates, and the committed
387
+ digest. It never writes `status.json` or `metrics.json`, and the scheduler keeps owning
388
+ `run.json`, `stdout.log`, `stderr.log`, and `<runDir>/prompt.md`.
389
+
390
+ **Planning and backlog.** After the digest proposals are ranked, the runner makes one
391
+ read-only `upstream-planner` call over that ranked set. The planner returns ordered steps;
392
+ each step names the proposal signatures it covers and the steps that block it. The runner
393
+ validates the plan (coverage, known keys, acyclic `dependsOn`), writes `plan-prompt.md` and
394
+ `plan.json` under the run tree, and creates one tracker item per step in the captured
395
+ `backlog` state — blockers first, so the store can accept the dependency edge. The
396
+ idempotency map is `upstream/tracker.json` (`plan key → item id`, `signature → per-run ids`):
397
+ a retry reuses an id instead of duplicating a step, and an idea imported by an earlier run is
398
+ not re-created. A missing prompt, a failed planner call, or an invalid plan is a digest gap,
399
+ never a failed research run; no tracker item is written without a validated plan. Set
400
+ `tracker.enabled` to `false` to skip planning, and `tracker.maxItems` (1…30, default 12) to
401
+ cap one plan. `backlog` is not launchable: a human promotes an item to `planned` in the
402
+ tracker UI or with `tracker set`.
314
403
 
315
404
  **Failure surface.** The scheduler's reason codes are a closed set, so a runner code such as
316
405
  `E_OPENCODE_MISSING` lives in `report.json`, `stderr.log`, and the digest header; the job row
317
406
  reports `E_EXIT_10` / `E_EXIT_11` / `E_EXIT_12` / `E_EXIT_13` / `E_EXIT_15` / `E_EXIT_16`.
318
- `E_AGENT_CONFIG_INVALID` (12) means the resolved `upstream-researcher` no longer denies
319
- every tool (the global `*` or a named action); reinstall `team/upstream/opencode.json` with
320
- `init`/`update`.
407
+ `E_AGENT_CONFIG_INVALID` (12) means the resolved `upstream-researcher` or `upstream-planner`
408
+ no longer denies every tool (the global `*` or a named action); reinstall
409
+ `team/upstream/opencode.json` with `init`/`update`. Plan and tracker failures are `Gaps:` and
410
+ `report.plan`, not run exit codes.
321
411
 
322
412
  **Commands.** Validate the registry with
323
413
  `node .ai.local/scripts/upstream-research.mjs registry --check --team-root .`; refresh the
@@ -355,15 +445,22 @@ schema, so the next open moves the file aside as `team.db.mismatch-<stamp>`, reb
355
445
  reprojects from the task files — database-only rows are discarded by design, which is why the
356
446
  files are the source of truth. Run `sync` after an upgrade and the counters reconverge.
357
447
 
358
- Migration `0003-backlog` adds the backlog projection — `backlog_items`, `backlog_item_deps`,
359
- `backlog_queue`, `backlog_queue_events` — and five indexes, and moves `SCHEMA_VERSION` to 3.
448
+ Migration `0003-backlog` stays immutable; migration `0004-tracker` creates the tracker
449
+ tables (`tracker_items`, `tracker_item_deps`, `tracker_queue`, `tracker_queue_events`,
450
+ `tracker_item_tasks`) with **INTEGER** item ids, adds the queue task/link columns, drops the
451
+ backlog tables and moves `SCHEMA_VERSION` to 4. The projection is derived, so v4 does not
452
+ copy backlog rows: the next `sync` rebuilds the tracker rows from the files. On a tree that
453
+ still has the shipped slug store, run `tracker migrate-ids` once before that sync — it moves
454
+ `backlog/items` and `backlog/queue` into `tracker/`, converts every slug id to the integer
455
+ sequence, rewrites dependencies, links and queue entries, and records the reserved mapping
456
+ in `tracker/id-migration.json` until the conversion completes.
360
457
  It is additive and sha256-pinned like the first two: no `ALTER` of the `tasks` or scheduler
361
458
  tables, so a wrong v3 costs a v4, never an edit. `active`/`done` are derived from the joined
362
- task row, never stored; `backlog_item_deps` has no foreign key on `dep_id`, so a broken file
363
- set projects as a recorded `parse_error` instead of aborting the run. The backlog walker runs
459
+ task row, never stored; `tracker_item_deps` has no foreign key on `dep_id`, so a broken file
460
+ set projects as a recorded `parse_error` instead of aborting the run. The tracker walker runs
364
461
  two bounded directory listings inside the existing sync deadline — 200 items measure well
365
462
  under 250 ms — and is idempotent by `content_hash` with `absent_at` marking like the task
366
- walker; `sync --prune` removes tombstoned backlog rows.
463
+ walker; `sync --prune` removes tombstoned tracker rows.
367
464
 
368
465
  Each connection sets `journal_mode=WAL`, `busy_timeout=5000`, `foreign_keys=ON`, and
369
466
  `synchronous=NORMAL`. One task is projected in one transaction; a `SIGKILL` mid-sync
@@ -434,6 +531,89 @@ the confirmed task delete and the rescan to the named interface without authenti
434
531
  A job definition carries arbitrary `argv` and run-now enqueues it, so that surface
435
532
  executes operator-supplied commands as the API user; see `## Scheduled jobs`.
436
533
 
534
+ ## Dashboard lifecycle
535
+
536
+ `ui` runs the same server `serve` does, detached, with a marker the next call can prove:
537
+
538
+ ```bash
539
+ node .ai.local/scripts/team-db.mjs ui start [--host <loopback>] [--port <n>] [--open] [--json] [--quiet]
540
+ node .ai.local/scripts/team-db.mjs ui status [--json]
541
+ node .ai.local/scripts/team-db.mjs ui stop [--json]
542
+ node .ai.local/scripts/team-db.mjs ui restart [--host <loopback>] [--port <n>] [--open] [--json] [--quiet]
543
+ ```
544
+
545
+ Exit codes: `0` started, already running, stopped, or nothing running; `1` a refusal
546
+ (`E_UI_OTHER_ROOT`, `E_UI_PORT_FOREIGN`, `E_UI_DISABLED`, `E_UI_UNAVAILABLE`, `E_UI_DB_MISSING`),
547
+ or a leader that outlived `SIGKILL` (the marker is kept); `2` a start failure
548
+ (`E_UI_START_TIMEOUT`, `E_UI_CHILD_EXIT`, `E_UI_MARKER_UNWRITABLE`, `E_UI_PORT_IN_USE`); `3` usage.
549
+
550
+ The bind address is loopback (`127.0.0.1` by default): `--allow-remote` and any non-loopback
551
+ `--host` are usage errors, so the verb never exposes the dashboard.
552
+
553
+ **`start` is probe-first.** A server that already answers `200` on the requested target with this
554
+ repository's `rootId` is the no-op: the command prints the same pid, leaves `startedAt` untouched
555
+ and writes nothing. A live marker for this root on another port is reused the same way instead of
556
+ starting a second server. Only a free port leads to a detached `serve` and the marker; `restart` is
557
+ the verb that stops and replaces an owned server. The `ui` path writes the marker plus at most one
558
+ bounded `sync` — the missing-projection repair (`503 E_DB_MISSING` → one `team-db.mjs sync`, 30 s
559
+ cap) — and nothing under `team/`: no `migrate-tasks`, no `runner.json`. The `E_DISABLED` and
560
+ `E_UI_UNAVAILABLE` preflights run before any probe, write or signal, so a disabled runtime never
561
+ stops a live server.
562
+
563
+ The marker is `.ai.local/.ui/api.json` —
564
+ `{schemaVersion,pid,host,port,root,rootId,startedAt,command}` — written `0600` through
565
+ `api.json.tmp` + rename, with `rootId = sha256(realpath(resolved team root)).slice(0, 12)`: a hash,
566
+ never a path, and never transmitted. A marker whose `host` is outside `LOOPBACK_HOSTS`, or whose
567
+ port is not an integer in `0..65535`, is treated as unreadable: no probe ever targets it, and `stop`
568
+ removes it as stale.
569
+
570
+ **Ownership is the authorization.** A signal needs the marker pid alive **and**
571
+ `ps -p <pid> -o command=` matching `/team-db\.mjs\s+serve\b/`; the marker alone never authorizes one.
572
+ `stop` re-proves ownership immediately before each signal, signals that leader pid only — never the
573
+ process group, because `serve` spawns bounded delete children — sends `SIGTERM`, polls every 100 ms
574
+ for at most 5 000 ms, then `SIGKILL`s and verifies the pid is gone. A process that survives keeps its
575
+ marker and the command exits `1`. A live pid whose command does not match is left running with its
576
+ marker intact. A server answering with a different `rootId` is `E_UI_OTHER_ROOT`; a port answered by
577
+ something that is not a team-db health document is `E_UI_PORT_FOREIGN`; neither writes a marker.
578
+
579
+ **Platform.** `ui` is POSIX only: the ownership proof reads `ps`, and no equivalent command-line
580
+ reader exists on Windows, so no signal is ever sent there and `stop` reports the pid as unowned.
581
+ Use the foreground `serve` on Windows.
582
+
583
+ **The root override.** `--root <team-dir>` wins; otherwise `AI_RULES_TEAM_DB_ROOT`; otherwise
584
+ `<cwd>/.ai.local/team` — the same precedence as the projection layers, so `ui status` and `ui stop`
585
+ find a server started through the environment variable.
586
+
587
+ **The timer stays separate.** `ui start` never starts `team-db.mjs schedule`: the timer is one
588
+ foreground process holding a lease, and it is started explicitly. `ui start` and `ui status --json`
589
+ report the read-only `/health.scheduler` block instead.
590
+
591
+ A consumer tree installed from an older release needs `ai-rules update --fix`. A plain `update`
592
+ refreshes the command files but leaves an existing engine module alone, so a stale `team-db.mjs`
593
+ answers `ui` with exit `3`. A fork whose engine predates the verb uses the foreground
594
+ `node .ai.local/scripts/team-db.mjs serve`.
595
+
596
+ ### Dashboard parity
597
+
598
+ | Surface | Dashboard | Excluded, with the reason |
599
+ |---|---|---|
600
+ | Tasks | list, detail, rescan, confirmed delete | — |
601
+ | Task delete | `DELETE /api/v1/tasks/{slug}` behind `confirm()`; the `200` success is announced in the page-level live region and focus returns to the list heading; `409 E_ACTIVE_TASK` names `activeSlug` in the detail live region | — |
602
+ | Tracker | read-only list, item panel (dependencies, dependents, linked tasks), queue section | create, update, enqueue and cancel stay in `team-db.mjs tracker` and the API: the dashboard is a read-plus-two-mutations operator surface, and the four writes carry graph and lease rules a browser page must not own |
603
+ | Jobs | definitions, next fire, run-now, runs, logs | unchanged |
604
+ | Mutating calls | exactly two on the task surface: `POST /api/v1/sync`, `DELETE /api/v1/tasks/{slug}` | pinned by `test-team-db-dashboard.mjs`, which also enumerates the four pre-existing jobs writes (`POST`/`PUT`/`DELETE /api/v1/jobs*`, run-now) and fails on a seventh `method:` site; together with no inline style or handler, no absolute URL, and the unchanged CSP |
605
+
606
+ ### Delivery surface
607
+
608
+ | Platform | `next` commands | Other stacks |
609
+ |---|---|---|
610
+ | cursor | `ui-start.md`, `ui-stop.md` (authored) | — |
611
+ | claude, mavis, opencode, zcode | the same two files (generated twins) | — |
612
+ | every released stack | — | the verb: `node .ai.local/scripts/team-db.mjs ui start\|status\|stop\|restart` |
613
+
614
+ Ten twins across five platforms: `find presets -path '*/next/commands/ui-start.md' | wc -l` prints 5,
615
+ and the same for `ui-stop.md`. The verb is the contract on every stack; the command is discoverability.
616
+
437
617
  ## Prompt capture
438
618
 
439
619
  `prompt.md` and `prompt-log.md` are read by the existing projection. An inline work request calls `sync --slug <slug>` once after writing `prompt.md`; a post-terminal entry calls the same once after appending to `prompt-log.md`. Both are bounded, off the critical path, and never fail the file write. A missed projection is staleness, not data loss — the next full sync rebuilds the row.
@@ -0,0 +1,79 @@
1
+ # Token economy
2
+
3
+ Scope: the fixed context cost `ai-rules` charges before a session does any work. `report-context-cost.mjs` prints, per host, the always-on files, their bytes, and a labelled `bytes / 4` estimate; then the Cursor fixture lines; then the bytes every task directory holds; then `usage_recorded` totals.
4
+
5
+ It counts **inputs**, not session tokens: prompt bytes and artifact bytes. Nothing tokenizes, nothing starts a session, and no number here is a measured token count or a claimed saving.
6
+
7
+ ## Run it
8
+
9
+ From a repository checkout, at the package directory:
10
+
11
+ ```bash
12
+ cd packages/ai-rules
13
+ node scripts/report-context-cost.mjs # human tables
14
+ node scripts/report-context-cost.mjs --json # same data, machine-readable
15
+ ```
16
+
17
+ The script resolves the repository root from its own path, so it runs from any cwd. Node built-ins only; it writes nothing.
18
+
19
+ Exit code is 0 on success and 1 only when a required file exists but cannot be read. A host whose files are absent is still reported: empty `alwaysOnFiles`, a note in `rule`, bytes 0.
20
+
21
+ ## Host rules
22
+
23
+ | Host | What is counted |
24
+ |---|---|
25
+ | OpenCode | every path in `.opencode/opencode.json` `instructions`, resolved against the repository root |
26
+ | Cursor | `.cursor/rules/**/*.mdc` with `alwaysApply: true` in frontmatter |
27
+ | Claude | `.claude/CLAUDE.md` plus `.claude/rules/**/*.md` with no `paths:` frontmatter key; `README.md` excluded |
28
+ | Mavis | entries with `loadMode: "root-entry"` in `packages/ai-rules/presets/mavis/next/adapter-map.json`, mapped to `.mavis/MAVIS.md`, `.mavis/rules/*.md`, and the root `AGENTS.md` |
29
+ | ZCode | the root `AGENTS.md`; ZCode loads it natively and has no per-tool map |
30
+
31
+ Each host entry repeats the rule it used, so every byte is attributable. `alwaysOnFiles` is repo-relative and sorted.
32
+
33
+ ## JSON shape
34
+
35
+ Example run, 2026-11-13; file lists elided; task bytes move as a task grows.
36
+
37
+ ```json
38
+ {
39
+ "generatedAt": "2026-11-13T14:11:07.317Z",
40
+ "root": "/abs/path/to/repo",
41
+ "hosts": {
42
+ "cursor": { "rule": "alwaysApply: true under .cursor/rules", "alwaysOnFiles": ["…"], "alwaysOnBytes": 12470, "estimatedTokens": 3118 },
43
+ "claude": { "rule": "CLAUDE.md + rules without paths: (README excluded)", "alwaysOnFiles": ["…"], "alwaysOnBytes": 16452, "estimatedTokens": 4113 },
44
+ "mavis": { "rule": "adapter-map root-entry: …", "alwaysOnFiles": ["…"], "alwaysOnBytes": 26298, "estimatedTokens": 6575 },
45
+ "opencode": { "rule": "opencode.json instructions", "alwaysOnFiles": ["…"], "alwaysOnBytes": 17285, "estimatedTokens": 4321 },
46
+ "zcode": { "rule": "root AGENTS.md (native entry; no per-tool map)", "alwaysOnFiles": ["AGENTS.md"], "alwaysOnBytes": 9648, "estimatedTokens": 2412 }
47
+ },
48
+ "fixtures": [
49
+ { "key": "UI", "file": "app/src/ui/pages/Example/Example.tsx", "cap": 420, "attachedLines": 415, "headroom": 5 }
50
+ ],
51
+ "tasks": [{ "slug": "context-cost-report", "files": 8, "bytes": 18257 }],
52
+ "usage": { "events": 0, "input": 0, "output": 0, "cached": 0 }
53
+ }
54
+ ```
55
+
56
+ `fixtures` carries the seven fixtures from `check-next-attached-budget.mjs` and attaches them against `.cursor/rules`; that gate and its caps stay untouched.
57
+
58
+ `tasks` sums every file under `.ai.local/team/tasks/<slug>`, `archive/` included. A missing team directory returns `tasks: []`.
59
+
60
+ `usage` sums `input`, `output`, and `cached` over `metrics.json` events with `type: "usage_recorded"`. Zero events is a valid result and prints as zero. A usage record that was never written stays missing; the report does not infer one.
61
+
62
+ ## Baseline
63
+
64
+ Measured 2026-11-13 on the same file sets:
65
+
66
+ | Surface | Bytes |
67
+ |---|---|
68
+ | OpenCode always-on set (5 files) | 17,285 |
69
+ | Root `AGENTS.md` (ZCode entry; Mavis `REPO_AGENTS.md` target) | 9,648 |
70
+
71
+ Re-run the command for the current tree; these numbers move with any rule edit.
72
+
73
+ ## Bytes are not tokens
74
+
75
+ `estimatedTokens` is `Math.round(bytes / 4)` for every host. The JSON key, the human output, and this page call it an estimate. No tokenizer runs, no model is called, no session is observed.
76
+
77
+ ## Next steps
78
+
79
+ WP2…WP5 — externalize and search, prompt byte cap, PreToolUse size deny, `focus.md` pointer budget — are planned in `.ai.local/team/tasks/context-mode-token-economy/archive/2026-11-13/architecture.md` §4.