@bonesofspring/ai-rules 0.2.65 → 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 (261) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +19 -11
  3. package/bin/lib/engine-scripts.js +38 -7
  4. package/bin/lib/engine-upgrade.js +5 -2
  5. package/bin/lib/seed-ai-local-team.js +6 -3
  6. package/docs/OPENCODE.md +17 -9
  7. package/docs/TEAM-DB.md +52 -13
  8. package/docs/TOKEN-ECONOMY.md +79 -0
  9. package/package.json +7 -2
  10. package/presets/_shared/ai-local/scripts/dump-output.mjs +371 -0
  11. package/presets/_shared/ai-local/scripts/team-db.mjs +82 -2
  12. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +3 -1
  13. package/presets/_shared/core/architecture/feature-delivery-workflow.md +4 -0
  14. package/presets/_shared/core/quality/context-and-iteration.md +1 -0
  15. package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
  16. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  17. package/presets/claude/go/agents/task-analyst.md +1 -1
  18. package/presets/claude/go/rules/architecture/feature-delivery.md +4 -0
  19. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  20. package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
  21. package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +4 -0
  22. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  23. package/presets/claude/java/agents/task-analyst.md +1 -1
  24. package/presets/claude/java/rules/architecture/feature-delivery.md +4 -0
  25. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  26. package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
  27. package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +4 -0
  28. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  29. package/presets/claude/mol/agents/task-analyst.md +1 -1
  30. package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +4 -0
  31. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  32. package/presets/claude/next/agents/task-analyst.md +1 -1
  33. package/presets/claude/next/commands/README.md +1 -1
  34. package/presets/claude/next/commands/task.md +1 -1
  35. package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +4 -0
  36. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  37. package/presets/claude/next/team/README.md +7 -3
  38. package/presets/claude/nuxt/agents/task-analyst.md +1 -1
  39. package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +4 -0
  40. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  41. package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
  42. package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +4 -0
  43. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  44. package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
  45. package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +4 -0
  46. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  47. package/presets/claude/svelte/agents/task-analyst.md +1 -1
  48. package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +4 -0
  49. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  50. package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
  51. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
  52. package/presets/cursor/go/agents/task-analyst.md +1 -1
  53. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
  54. package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
  55. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
  56. package/presets/cursor/java/agents/task-analyst.md +1 -1
  57. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
  58. package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
  59. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
  60. package/presets/cursor/mol/agents/task-analyst.md +1 -1
  61. package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
  62. package/presets/cursor/next/agents/task-analyst.md +1 -1
  63. package/presets/cursor/next/commands/README.md +1 -1
  64. package/presets/cursor/next/commands/task.md +1 -1
  65. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +3 -1
  66. package/presets/cursor/next/team/README.md +7 -3
  67. package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
  68. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
  69. package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
  70. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
  71. package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
  72. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
  73. package/presets/cursor/svelte/agents/task-analyst.md +1 -1
  74. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
  75. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  76. package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
  77. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +3 -1
  78. package/presets/mavis/go/adapter-map.json +1 -1
  79. package/presets/mavis/go/agents/task-analyst.md +1 -1
  80. package/presets/mavis/go/rules/agent-team-orchestrator.md +3 -1
  81. package/presets/mavis/go/rules/feature-delivery-workflow.md +4 -0
  82. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  83. package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
  84. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +3 -1
  85. package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +4 -0
  86. package/presets/mavis/java/adapter-map.json +1 -1
  87. package/presets/mavis/java/agents/task-analyst.md +1 -1
  88. package/presets/mavis/java/rules/agent-team-orchestrator.md +3 -1
  89. package/presets/mavis/java/rules/feature-delivery-workflow.md +4 -0
  90. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  91. package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
  92. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +3 -1
  93. package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +4 -0
  94. package/presets/mavis/mol/adapter-map.json +1 -1
  95. package/presets/mavis/mol/agents/task-analyst.md +1 -1
  96. package/presets/mavis/mol/rules/agent-team-orchestrator.md +3 -1
  97. package/presets/mavis/mol/rules/feature-delivery-workflow.md +4 -0
  98. package/presets/mavis/next/adapter-map.json +9 -1
  99. package/presets/mavis/next/agents/task-analyst.md +1 -1
  100. package/presets/mavis/next/commands/README.md +1 -1
  101. package/presets/mavis/next/commands/task.md +1 -1
  102. package/presets/mavis/next/rules/agent-team-orchestrator.md +3 -1
  103. package/presets/mavis/next/rules/feature-delivery-workflow.md +4 -0
  104. package/presets/mavis/next/team/README.md +7 -3
  105. package/presets/mavis/nuxt/adapter-map.json +1 -1
  106. package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
  107. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +3 -1
  108. package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +4 -0
  109. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  110. package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
  111. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
  112. package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
  113. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  114. package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
  115. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +3 -1
  116. package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +4 -0
  117. package/presets/mavis/svelte/adapter-map.json +1 -1
  118. package/presets/mavis/svelte/agents/task-analyst.md +1 -1
  119. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +3 -1
  120. package/presets/mavis/svelte/rules/feature-delivery-workflow.md +4 -0
  121. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  122. package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
  123. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +3 -1
  124. package/presets/opencode/go/adapter-map.json +1 -1
  125. package/presets/opencode/go/agents/task-analyst.md +1 -1
  126. package/presets/opencode/go/rules/agent-team-orchestrator.md +3 -1
  127. package/presets/opencode/go/rules/feature-delivery-workflow.md +4 -0
  128. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  129. package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
  130. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +3 -1
  131. package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +4 -0
  132. package/presets/opencode/java/adapter-map.json +1 -1
  133. package/presets/opencode/java/agents/task-analyst.md +1 -1
  134. package/presets/opencode/java/rules/agent-team-orchestrator.md +3 -1
  135. package/presets/opencode/java/rules/feature-delivery-workflow.md +4 -0
  136. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  137. package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
  138. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +3 -1
  139. package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
  140. package/presets/opencode/mol/adapter-map.json +1 -1
  141. package/presets/opencode/mol/agents/task-analyst.md +1 -1
  142. package/presets/opencode/mol/rules/agent-team-orchestrator.md +3 -1
  143. package/presets/opencode/mol/rules/feature-delivery-workflow.md +4 -0
  144. package/presets/opencode/next/adapter-map.json +9 -1
  145. package/presets/opencode/next/agents/task-analyst.md +1 -1
  146. package/presets/opencode/next/commands/README.md +1 -1
  147. package/presets/opencode/next/commands/task.md +1 -1
  148. package/presets/opencode/next/rules/agent-team-orchestrator.md +3 -1
  149. package/presets/opencode/next/rules/feature-delivery-workflow.md +4 -0
  150. package/presets/opencode/next/team/README.md +7 -3
  151. package/presets/opencode/nuxt/adapter-map.json +1 -1
  152. package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
  153. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +3 -1
  154. package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +4 -0
  155. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  156. package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
  157. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
  158. package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
  159. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  160. package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
  161. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +3 -1
  162. package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +4 -0
  163. package/presets/opencode/plugins/task-status/README.md +23 -11
  164. package/presets/opencode/plugins/task-status/details-data.ts +64 -46
  165. package/presets/opencode/plugins/task-status/details.tsx +12 -2
  166. package/presets/opencode/plugins/task-status/format.ts +16 -0
  167. package/presets/opencode/plugins/task-status/prompt-text.ts +37 -0
  168. package/presets/opencode/plugins/task-status/task-view.ts +241 -177
  169. package/presets/opencode/plugins/task-status/tui.tsx +57 -15
  170. package/presets/opencode/plugins/task-status/types.ts +74 -0
  171. package/presets/opencode/svelte/adapter-map.json +1 -1
  172. package/presets/opencode/svelte/agents/task-analyst.md +1 -1
  173. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +3 -1
  174. package/presets/opencode/svelte/rules/feature-delivery-workflow.md +4 -0
  175. package/presets/zcode/android-kotlin/adapter-map.json +1 -1
  176. package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
  177. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +3 -1
  178. package/presets/zcode/go/adapter-map.json +1 -1
  179. package/presets/zcode/go/agents/task-analyst.md +1 -1
  180. package/presets/zcode/go/rules/agent-team-orchestrator.md +3 -1
  181. package/presets/zcode/go/rules/feature-delivery-workflow.md +4 -0
  182. package/presets/zcode/ios-swift/adapter-map.json +1 -1
  183. package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
  184. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +3 -1
  185. package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +4 -0
  186. package/presets/zcode/java/adapter-map.json +1 -1
  187. package/presets/zcode/java/agents/task-analyst.md +1 -1
  188. package/presets/zcode/java/rules/agent-team-orchestrator.md +3 -1
  189. package/presets/zcode/java/rules/feature-delivery-workflow.md +4 -0
  190. package/presets/zcode/mcp-ts/adapter-map.json +1 -1
  191. package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
  192. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +3 -1
  193. package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
  194. package/presets/zcode/mol/adapter-map.json +1 -1
  195. package/presets/zcode/mol/agents/task-analyst.md +1 -1
  196. package/presets/zcode/mol/rules/agent-team-orchestrator.md +3 -1
  197. package/presets/zcode/mol/rules/feature-delivery-workflow.md +4 -0
  198. package/presets/zcode/next/adapter-map.json +9 -1
  199. package/presets/zcode/next/agents/task-analyst.md +1 -1
  200. package/presets/zcode/next/commands/README.md +1 -1
  201. package/presets/zcode/next/commands/task.md +1 -1
  202. package/presets/zcode/next/rules/agent-team-orchestrator.md +3 -1
  203. package/presets/zcode/next/rules/feature-delivery-workflow.md +4 -0
  204. package/presets/zcode/next/team/README.md +7 -3
  205. package/presets/zcode/nuxt/adapter-map.json +1 -1
  206. package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
  207. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +3 -1
  208. package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +4 -0
  209. package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
  210. package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
  211. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
  212. package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
  213. package/presets/zcode/php-laravel/adapter-map.json +1 -1
  214. package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
  215. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +3 -1
  216. package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +4 -0
  217. package/presets/zcode/svelte/adapter-map.json +1 -1
  218. package/presets/zcode/svelte/agents/task-analyst.md +1 -1
  219. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +3 -1
  220. package/presets/zcode/svelte/rules/feature-delivery-workflow.md +4 -0
  221. package/presets/_shared/ai-local/scripts/upstream-research.mjs +0 -2964
  222. package/presets/claude/next/commands/upstream-research.md +0 -23
  223. package/presets/claude/next/team/upstream/config.json +0 -31
  224. package/presets/claude/next/team/upstream/digest-template.md +0 -55
  225. package/presets/claude/next/team/upstream/jobs.json +0 -34
  226. package/presets/claude/next/team/upstream/opencode.json +0 -34
  227. package/presets/claude/next/team/upstream/projects.json +0 -4
  228. package/presets/claude/next/team/upstream/prompt.md +0 -77
  229. package/presets/claude/next/team/upstream/signatures.json +0 -9
  230. package/presets/cursor/next/commands/upstream-research.md +0 -23
  231. package/presets/cursor/next/team/upstream/config.json +0 -31
  232. package/presets/cursor/next/team/upstream/digest-template.md +0 -55
  233. package/presets/cursor/next/team/upstream/jobs.json +0 -34
  234. package/presets/cursor/next/team/upstream/opencode.json +0 -34
  235. package/presets/cursor/next/team/upstream/projects.json +0 -4
  236. package/presets/cursor/next/team/upstream/prompt.md +0 -77
  237. package/presets/cursor/next/team/upstream/signatures.json +0 -9
  238. package/presets/mavis/next/commands/upstream-research.md +0 -18
  239. package/presets/mavis/next/team/upstream/config.json +0 -31
  240. package/presets/mavis/next/team/upstream/digest-template.md +0 -55
  241. package/presets/mavis/next/team/upstream/jobs.json +0 -34
  242. package/presets/mavis/next/team/upstream/opencode.json +0 -34
  243. package/presets/mavis/next/team/upstream/projects.json +0 -4
  244. package/presets/mavis/next/team/upstream/prompt.md +0 -77
  245. package/presets/mavis/next/team/upstream/signatures.json +0 -9
  246. package/presets/opencode/next/commands/upstream-research.md +0 -26
  247. package/presets/opencode/next/team/upstream/config.json +0 -31
  248. package/presets/opencode/next/team/upstream/digest-template.md +0 -55
  249. package/presets/opencode/next/team/upstream/jobs.json +0 -34
  250. package/presets/opencode/next/team/upstream/opencode.json +0 -34
  251. package/presets/opencode/next/team/upstream/projects.json +0 -4
  252. package/presets/opencode/next/team/upstream/prompt.md +0 -77
  253. package/presets/opencode/next/team/upstream/signatures.json +0 -9
  254. package/presets/zcode/next/commands/upstream-research.md +0 -26
  255. package/presets/zcode/next/team/upstream/config.json +0 -31
  256. package/presets/zcode/next/team/upstream/digest-template.md +0 -55
  257. package/presets/zcode/next/team/upstream/jobs.json +0 -34
  258. package/presets/zcode/next/team/upstream/opencode.json +0 -34
  259. package/presets/zcode/next/team/upstream/projects.json +0 -4
  260. package/presets/zcode/next/team/upstream/prompt.md +0 -77
  261. package/presets/zcode/next/team/upstream/signatures.json +0 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.66
4
+
5
+ ### Repository-only upstream research payload
6
+
7
+ - **The npm package no longer carries the `upstream-research` workflow.** `package.json` excludes the runner, the `/upstream-research` command, and every `presets/<tool>/next/team/upstream/**` template from the published tarball. `REPO_ONLY_ENGINE_SCRIPTS` names the runner: `init`, `update`, and `doctor` skip it silently when the installed preset has no source, while the repository checkout keeps seeding and mirroring it.
8
+ - **Packaging proof.** `test-pack-repo-only.mjs` packs the tarball, installs it into a scratch consumer, and asserts no job, runner, command, or `team/upstream/` file appears, the 22 published engine modules seed, and `doctor` reports no missing-engine finding.
9
+
10
+ ### Upstream research plans into the tracker backlog
11
+
12
+ - **A second read-only call turns proposals into an ordered plan.** After ranking, the runner composes `plan-prompt.md` from the digest proposals and the target-repository sketch, calls the shipped `upstream-planner` agent once (one retry on a validation failure), and validates coverage, keys, `dependsOn` edges, and the acyclicity before any write.
13
+ - **Plan steps become `backlog` tracker items, blockers first.** Each item carries its mechanism, evidence, signature, and run; dependencies reference the generated ids. The idempotency map `upstream/tracker.json` reuses an id on a retry and never re-creates an idea imported by an earlier run.
14
+ - **A failed plan or tracker write is a digest gap.** Research evidence and the cursor stay the record; `report.plan` and the digest `Plan:` header name the state. `tracker.enabled` (default `true`) and `tracker.maxItems` (default 12) are data in `upstream/config.json`.
15
+ - **Seeding.** `init`/`update` refresh `upstream/plan-prompt.md` beside the prompt and agent config; the sealed `upstream-planner` permission map denies every tool like the researcher, and both are asserted before a project runs.
16
+
17
+ ### Task-status sidebar: session source, pause scope, and thin-status rows
18
+
19
+ - **The sidebar reads the session from the `sidebar.content` slot input.** The router is only a fallback, so a session tab keeps its own task while a background subagent runs in another tab; a subagent tab still maps through `data.session.root`.
20
+ - **Stop and resume are task-scoped.** `■ stop` writes `tasks/<slug>/STOP` (repo-wide `.ai.local/STOP` only as a fallback), a paused task shows `▶ resume`, and the resume intent clears a sentinel only when the session maps to that task — a bare `дальше` in an unrelated session no longer releases a repo-wide pause. The view recognises the task-scoped sentinel the tracker writes.
21
+ - **A bootstrap or stale `status.json` keeps its rows.** `role`/`agent` fall back to `currentAgent` and then to the planned step, an `in_progress` task without an attempt reads `2/3 · no attempt started`, and the `eta` row survives a `stale` marker. `stale` now uses the agent's p90 as a floor, so a genuinely long step is not called stale after six hours.
22
+ - **State semantics match the hook.** `blocked` hides stop and ETA, `awaiting_artifact_receipt` hides ETA, a human gate hides stop and ETA, and an unknown agent reads `—` instead of a fabricated `implementation` role.
23
+ - **Matching is deterministic and cheap.** An exact prompt match outranks a newer substring match, matching is memoized per index generation and message fingerprint, normalized texts live in the session cache, and `message.list` follows up to five cursor pages so a late `/task-continue` is seen.
24
+ - **Fewer redundant reads.** `findTeamRoot` is cached for 30s, the session cache keeps the last four tabs (no `no task` flash on tab switch), a failed fetch keeps the last view and marks it `offline` for a minute, and the error is logged under the debug flag.
25
+ - **The details dialog reads the manifest.** Artifacts come from `artifact-manifest.json` (producer + outcome + path, last eight) with the known file names as a fallback, and the header adds the last update age, the ETA with its ledger count, and the run id.
26
+ - **Shared modules.** `types.ts`, `prompt-text.ts`, and `format.ts` replace the duplicated status types and two divergent `prompt.md` parsers.
27
+ - **Diagnostics without UI noise.** `OPENCODE_TASK_STATUS_DEBUG=1` appends the slot/route session IDs, message count, matched slug, rendered summary, fetch errors, and cleared pauses to `<tmpdir>/ai-rules-task-status-debug.log`.
28
+ - **Fixtures.** `test-task-status-view.mjs` grows to 14 cases (matched, no match, bootstrap, stale, repo stop, task stop, completed, gate, blocked, receipt, exact-vs-newer, unknown agent, note, details) and runs from `check-preset-structure.sh` and as `test:task-status-view`; it needs Node's built-in type stripping and skips on older runtimes.
29
+ - **Explicit import extensions.** The plugin's relative imports carry `.ts` / `.tsx`, so a local plugin directory resolves them (the loader skips extensionless `.tsx` imports silently).
30
+ - **Orchestrator contract.** The shared rule and `/task` now say a returned session handle has only **started** the specialist: the step stays open until the agent reports back and the hook records the receipt.
31
+
32
+ ### Context output externalization
33
+
34
+ - **`dump-output.mjs` keeps a large command output out of the context window.** New shipped engine module: reads stdin or `--input`, writes `.ai.local/team/tasks/<slug>/outputs/<id>.txt` under a hard 2 097 152 B cap applied while streaming (a 0-byte file and a notice for empty input, a `-2`/`-3` suffix instead of an overwrite, a symlinked task or `outputs/` directory refused), then prints at most 40 head lines (≤8 KiB, ≤400 B per line), the byte count, the path, and one `grep -n` hint.
35
+ - **`team-db.mjs search <query>` reads the existing FTS5 projection.** Default 5 hits, `--limit` clamped to 1…20, snippets collapsed to single spaces and cut at 800 B on a UTF-8 boundary, `--json` one array with `snippetBytes`/`snippetTruncated`, and no hit is `team-db: no matches` with exit 0. Read-only: no schema, migration, route or `searchProjection` change. One requestable line in `context-and-iteration.md` names the dump → head → `grep`/`search` flow.
36
+
3
37
  ## 0.2.65
4
38
 
5
39
  ### Agent process manager
package/README.md CHANGED
@@ -25,7 +25,7 @@ Run `init` from the **app root** (`--cwd` if needed). Default `--preset` is `nex
25
25
  | Root agents | `REPO_AGENTS.md` → `AGENTS.md` (same file on all five; ZCode loads it natively) | | | | |
26
26
  | `/task` artifacts | **`.ai.local/team/`** (shared; templates refreshed; `tasks/<slug>/` never overwritten) | | | |
27
27
  | Template drift | **`.ai.local/.template-base.json`** (shared; one record per tree of files that hold a shipped template byte; `update` prints one drift line, `update --merge-ai-local` fast-forwards a file only when its recorded base still matches and reports the rest) | | | |
28
- | Self-learning engine | **`.ai.local/scripts/`** (shared; twenty-two scripts — the six self-learning engine modules, `manifest.mjs`, the ten `team-db*.mjs` projection, scheduler and lifecycle modules, the `upstream-research.mjs` review, the read-only `check-write-scope.mjs` write audit, the `aggregate-agent-task-metrics.mjs` aggregator, and the `processes.mjs` + `process-lease.mjs` process manager; existing files never overwritten) | | | |
28
+ | Self-learning engine | **`.ai.local/scripts/`** (shared; twenty-two scripts — the six self-learning engine modules, `manifest.mjs`, the `dump-output.mjs` output externalizer, the ten `team-db*.mjs` projection, scheduler and lifecycle modules, the read-only `check-write-scope.mjs` write audit, the `aggregate-agent-task-metrics.mjs` aggregator, and the `processes.mjs` + `process-lease.mjs` process manager; existing files never overwritten. The repository-only `upstream-research.mjs` is not published) | | | |
29
29
  | Specs seed | `docs/specs/` copied only if the directory is **absent** | | | |
30
30
 
31
31
  OpenCode also ships **`.opencode/plugins/task-status/`**, a TUI sidebar for the active `/task` run (slug, state, elapsed time, step, remaining-time estimate, soft-stop). OpenCode auto-loads it; it needs no `opencode.json` entry, is refreshed by `update`, and is a viewer only — the chain hook stays manual.
@@ -168,16 +168,24 @@ pre-v2 database is rebuilt from the files on the next `sync`.
168
168
 
169
169
  ### Upstream research
170
170
 
171
- The `next` preset ships a weekly `upstream-research` job and a read-only `opencode` agent for
172
- it. `init`/`update` seed the job definition into `.ai.local/team/scheduler/jobs.json` when the
173
- file is absent; an operator-edited definition is never overwritten. The runner
174
- (`.ai.local/scripts/upstream-research.mjs`) probes `opencode`, loads
175
- `upstream/projects.json` and `upstream/config.json`, fetches each due clone with
176
- `git fetch --depth 1`, labels the window (`range`, `baseline`, `unprovable`, `no-change`),
177
- validates the agent's marked JSON, re-checks every citation inside the clone, dedupes by
178
- mechanism against the committed `upstream/signatures.json`, and writes one ranked digest to
179
- `docs/upstream/digest-<runId>.md`. The cursor is git-ignored; the caps are data. `/upstream-research`
180
- queues a run and adds one `schedule --once` tick when no timer is online. Details:
171
+ **Repository-only.** The `upstream-research` job, the `/upstream-research` command, the runner
172
+ (`.ai.local/scripts/upstream-research.mjs`), and the `team/upstream/` templates are not part of
173
+ the published npm package; they are used only in the `@bonesofspring/ai-rules` repository
174
+ itself. A consumer install seeds no job and no runner.
175
+
176
+ In this repository the `next` preset carries a weekly `upstream-research` job and a read-only
177
+ `opencode` agent for it. `init`/`update` seed the job definition into
178
+ `.ai.local/team/scheduler/jobs.json` when the file is absent; an operator-edited definition is
179
+ never overwritten. The runner probes `opencode`, loads `upstream/projects.json` and
180
+ `upstream/config.json`, fetches each due clone with `git fetch --depth 1`, labels the window
181
+ (`range`, `baseline`, `unprovable`, `no-change`), validates the agent's marked JSON, re-checks
182
+ every citation inside the clone, dedupes by mechanism against the committed
183
+ `upstream/signatures.json`, and writes one ranked digest to `docs/upstream/digest-<runId>.md`.
184
+ A second read-only planner call decomposes the ranked proposals into ordered steps, and the
185
+ runner imports them into `team/tracker` as `backlog` items with `dependsOn` edges (blockers
186
+ first) and an idempotency map in `upstream/tracker.json`. The cursor is git-ignored; the caps
187
+ are data. `/upstream-research` queues a run and adds one `schedule --once` tick when no timer
188
+ is online. Details:
181
189
  [`docs/TEAM-DB.md`](docs/TEAM-DB.md#upstream-research-job) and
182
190
  [`docs/OPENCODE.md`](docs/OPENCODE.md#upstream-research-agent).
183
191
 
@@ -1,13 +1,13 @@
1
1
  const path = require('path');
2
2
 
3
3
  /**
4
- * The shipped `.ai.local/scripts/` set, declared once.
4
+ * The engine `.ai.local/scripts/` set, declared once.
5
5
  *
6
- * `init` seeds exactly these files into a consumer's `.ai.local/scripts/`, and
7
- * the monorepo dogfood copy is mirrored from the same source by
8
- * `scripts/lib/engine-mirror.mjs`. An explicit list — never a glob — keeps the
9
- * repo-local tooling (the `*.test.mjs` suites and `requirements-*.mjs`) out of
10
- * the shipped set.
6
+ * `init` seeds these files into a consumer's `.ai.local/scripts/` when their
7
+ * source exists in the installed preset, and the monorepo dogfood copy is
8
+ * mirrored from the same source by `scripts/lib/engine-mirror.mjs`. An explicit
9
+ * list — never a glob — keeps the repo-local tooling (the `*.test.mjs` suites
10
+ * and `requirements-*.mjs`) out of the shipped set.
11
11
  *
12
12
  * `manifest.mjs` is the deterministic writer for
13
13
  * `.ai.local/team/tasks/<slug>/artifact-manifest.json`; producers call it
@@ -17,7 +17,19 @@ const path = require('path');
17
17
  * read-only dashboard, the scheduler, and the `ui` lifecycle supervisor.
18
18
  * `team-db.mjs` is the CLI; the others are loaded by it on demand, so a runtime
19
19
  * without `node:sqlite` never imports them.
20
+ *
21
+ * `REPO_ONLY_ENGINE_SCRIPTS` stay in the preset source and the monorepo dogfood
22
+ * mirror, but the published tarball excludes their sources. A consumer install
23
+ * sees no source for them, so `init`, `update`, and `doctor` skip them without
24
+ * warning; a source that exists (this repository) is seeded and upgraded as
25
+ * usual.
20
26
  */
27
+ const REPO_ONLY_ENGINE_SCRIPTS = [
28
+ // The weekly upstream evolution review is a personal workflow: the job,
29
+ // prompt, agent config, and runner live only in this repository.
30
+ 'upstream-research.mjs',
31
+ ];
32
+
21
33
  const ENGINE_SCRIPTS = [
22
34
  'run.mjs',
23
35
  'signals.mjs',
@@ -26,6 +38,10 @@ const ENGINE_SCRIPTS = [
26
38
  'derive-gate-signals.mjs',
27
39
  'efficacy-oracle.mjs',
28
40
  'manifest.mjs',
41
+ // Command-output externalizer: stdin (or `--input`) becomes a capped
42
+ // `.ai.local/team/tasks/<slug>/outputs/` file plus a head, so a large dump
43
+ // never enters the context window. Reads no network and spawns nothing.
44
+ 'dump-output.mjs',
29
45
  'team-db.mjs',
30
46
  'team-db-ui.mjs',
31
47
  'team-db-tracker.mjs',
@@ -57,6 +73,9 @@ const ENGINE_SCRIPTS = [
57
73
  /** Package `presets/`-relative directory holding the engine source of truth. */
58
74
  const ENGINE_SOURCE_RELATIVE = '_shared/ai-local/scripts';
59
75
 
76
+ /** The `ENGINE_SCRIPTS` subset whose sources ship in the published tarball. */
77
+ const SHIPPED_ENGINE_SCRIPTS = ENGINE_SCRIPTS.filter((name) => !isRepoOnlyEngineScript(name));
78
+
60
79
  /**
61
80
  * Absolute shipped engine directory for a package.
62
81
  *
@@ -67,4 +86,16 @@ function engineSourceDir(presetsRoot) {
67
86
  return path.join(presetsRoot, ...ENGINE_SOURCE_RELATIVE.split('/'));
68
87
  }
69
88
 
70
- module.exports = { ENGINE_SCRIPTS, ENGINE_SOURCE_RELATIVE, engineSourceDir };
89
+ /** True when the module is source-only in this repository and never published. */
90
+ function isRepoOnlyEngineScript(name) {
91
+ return REPO_ONLY_ENGINE_SCRIPTS.includes(name);
92
+ }
93
+
94
+ module.exports = {
95
+ ENGINE_SCRIPTS,
96
+ SHIPPED_ENGINE_SCRIPTS,
97
+ REPO_ONLY_ENGINE_SCRIPTS,
98
+ ENGINE_SOURCE_RELATIVE,
99
+ engineSourceDir,
100
+ isRepoOnlyEngineScript,
101
+ };
@@ -27,7 +27,7 @@ const {
27
27
  serialiseRecord,
28
28
  } = require('./ai-local-drift');
29
29
  const { runStamp } = require('./fs-utils');
30
- const { ENGINE_SCRIPTS, ENGINE_SOURCE_RELATIVE, engineSourceDir } = require('./engine-scripts');
30
+ const { ENGINE_SCRIPTS, ENGINE_SOURCE_RELATIVE, engineSourceDir, isRepoOnlyEngineScript } = require('./engine-scripts');
31
31
 
32
32
  const ENGINE_ROOT_REL = '.ai.local/scripts';
33
33
  const BACKUP_PREFIX = 'engine-';
@@ -54,7 +54,10 @@ function shippedEngineTemplates(packageRoot) {
54
54
  const abs = path.join(sourceDir, name);
55
55
  const stat = lstatOrNull(abs);
56
56
  if (!stat || !stat.isFile()) {
57
- warn(`engine source ${name} is missing from presets/${ENGINE_SOURCE_RELATIVE}; skipped`);
57
+ // A repo-only module is intentionally absent from the published tarball.
58
+ if (!isRepoOnlyEngineScript(name)) {
59
+ warn(`engine source ${name} is missing from presets/${ENGINE_SOURCE_RELATIVE}; skipped`);
60
+ }
58
61
  continue;
59
62
  }
60
63
  const content = fs.readFileSync(abs);
@@ -10,7 +10,7 @@
10
10
  const fs = require('fs');
11
11
  const path = require('path');
12
12
  const { assertSafeDest } = require('./safe-path');
13
- const { ENGINE_SCRIPTS, engineSourceDir } = require('./engine-scripts');
13
+ const { ENGINE_SCRIPTS, engineSourceDir, isRepoOnlyEngineScript } = require('./engine-scripts');
14
14
  const { runTemplateDrift } = require('./ai-local-drift');
15
15
 
16
16
  const LEGACY_TOOLS = ['cursor', 'claude', 'mavis', 'opencode', 'zcode'];
@@ -301,7 +301,10 @@ function seedEngineScripts({ cwd, presetTeamSrc }) {
301
301
  const source = path.join(sourceDir, name);
302
302
  const dest = path.join(destDir, name);
303
303
  if (!fs.existsSync(source)) {
304
- warn(`.ai.local/scripts: engine source ${name} is missing from the preset; skipped`);
304
+ // A repo-only module is absent from the published tarball by design.
305
+ if (!isRepoOnlyEngineScript(name)) {
306
+ warn(`.ai.local/scripts: engine source ${name} is missing from the preset; skipped`);
307
+ }
305
308
  continue;
306
309
  }
307
310
  if (fs.existsSync(dest)) {
@@ -348,7 +351,7 @@ function copyTemplates(presetTeamSrc, dest) {
348
351
  // Preset-owned upstream templates refresh on every init/update: a consumer edit
349
352
  // to the permission map or the prompt must not silently defeat the contract.
350
353
  const upstreamSrc = path.join(presetTeamSrc, 'upstream');
351
- for (const name of ['prompt.md', 'digest-template.md', 'opencode.json']) {
354
+ for (const name of ['prompt.md', 'plan-prompt.md', 'digest-template.md', 'opencode.json']) {
352
355
  const source = path.join(upstreamSrc, name);
353
356
  if (!fs.existsSync(source)) continue;
354
357
  copyFile(source, path.join(dest, 'upstream', name));
package/docs/OPENCODE.md CHANGED
@@ -128,24 +128,32 @@ Do not pin OpenCode CLI or TUI versions in the contract.
128
128
 
129
129
  ## Upstream research agent
130
130
 
131
- The `next` preset ships a read-only agent for the `upstream-research` job at
131
+ **Repository-only.** The `upstream-research` job and its `team/upstream/` payload are not part
132
+ of the published npm package; this section documents the workflow used in the
133
+ `@bonesofspring/ai-rules` repository itself. A consumer install does not include the agent
134
+ config, the command, or the runner.
135
+
136
+ The `next` preset carries a read-only agent for the `upstream-research` job at
132
137
  `.ai.local/team/upstream/opencode.json` (source:
133
- `presets/cursor/next/team/upstream/opencode.json`). It is refreshed on every `init`/`update`,
134
- so a consumer cannot widen it by editing the installed copy.
138
+ `presets/cursor/next/team/upstream/opencode.json`). It is refreshed on every `init`/`update`
139
+ in this repository, so the installed copy cannot be widened by editing it.
135
140
 
136
- - `agent.upstream-researcher` has `mode: "subagent"`.
137
- - `permission` starts with `"*": "deny"`, so the agent has no tool at all: MCP servers installed by the same project (`chrome-devtools`, `playwright`, `context7`, `figma`) and custom tools resolve as `<server>_<tool>` and are denied by the same wildcard. The named rows stay as a second line of defence: `edit`/`bash`/`read`/`glob`/`grep`/`list` are `{"*": "deny"}`; `webfetch`, `websearch`, `task`, and `external_directory` are `deny`. The shell deny stops a write around the edit deny; the wildcard and the read/fetch/subagent denies keep untrusted upstream content from reaching a secret or a network destination. The agent needs no tool: the prompt arrives as an attached `--file` message and the runner verifies evidence itself.
138
- - Before phase 1 the runner resolves the installed agent with `opencode debug agents` and refuses to start a project unless the global `*` and every named action still resolve to `deny` on resource `*` under last-match-wins (`E_AGENT_CONFIG_INVALID`, exit 12). The probe also asserts a synthetic non-built-in name, so a config that enumerates only the ten built-ins fails. A discovered config that appends an allow after the preset deny is caught here, not by a file grep.
141
+ - `agent.upstream-researcher` and `agent.upstream-planner` have `mode: "subagent"`.
142
+ - `permission` starts with `"*": "deny"`, so an agent has no tool at all: MCP servers installed by the same project (`chrome-devtools`, `playwright`, `context7`, `figma`) and custom tools resolve as `<server>_<tool>` and are denied by the same wildcard. The named rows stay as a second line of defence: `edit`/`bash`/`read`/`glob`/`grep`/`list` are `{"*": "deny"}`; `webfetch`, `websearch`, `task`, and `external_directory` are `deny`. The shell deny stops a write around the edit deny; the wildcard and the read/fetch/subagent denies keep untrusted upstream content from reaching a secret or a network destination. Neither agent needs a tool: the prompt arrives as an attached `--file` message and the runner verifies evidence itself.
143
+ - Before phase 1 the runner resolves both installed agents with `opencode debug agents` and refuses to start a project unless the global `*` and every named action still resolve to `deny` on resource `*` under last-match-wins (`E_AGENT_CONFIG_INVALID`, exit 12). The probe also asserts a synthetic non-built-in name, so a config that enumerates only the ten built-ins fails. A discovered config that appends an allow after the preset deny is caught here, not by a file grep.
139
144
  - The job invokes `opencode run --agent upstream-researcher --format json --archived --auto`
140
145
  with the child `cwd` set to the team `upstream/` directory; that nested config is the only
141
- selector, because this build has no `--dir`.
146
+ selector, because this build has no `--dir`. After ranking, one
147
+ `--agent upstream-planner` call over the same `cwd` decomposes the proposals into ordered
148
+ backlog steps; it reads only the attached `plan-prompt.md`.
142
149
  - `--worktree` is never passed: the research is read-only.
143
150
  - `--auto` cannot widen an explicit `deny`; the runner also compares `git status --porcelain`
144
151
  in the repository before and after each call (`E_WORKTREE_CHANGED`) and inside the reviewed
145
152
  clone (`E_UPSTREAM_DIRTY`).
146
153
 
147
- The agent is not a first-class preset agent: it has no `agents/**` mirror and no adapter-map
148
- row; the job asserts its resolved rules with `opencode debug agents` before the first project.
154
+ The agents are not first-class preset agents: they have no `agents/**` mirror and no
155
+ adapter-map row; the job asserts their resolved rules with `opencode debug agents` before the
156
+ first project.
149
157
  ## Local overlay
150
158
 
151
159
  `.ai.local/rules/*.md` at repo root (or monorepo parents) override preset rules. See [`LOCAL-OVERLAY.md`](./LOCAL-OVERLAY.md).
package/docs/TEAM-DB.md CHANGED
@@ -8,7 +8,7 @@ The projection is installed by `init` as ten `team-db*.mjs` modules under `.ai.l
8
8
 
9
9
  | Module | Role |
10
10
  |---|---|
11
- | `team-db.mjs` | CLI: `init`, `sync`, `delete`, `migrate-tasks`, `check`, `serve`, `jobs`, `schedule`, `tracker`, `task-run`, `ui` |
11
+ | `team-db.mjs` | CLI: `init`, `sync`, `delete`, `migrate-tasks`, `check`, `search`, `serve`, `jobs`, `schedule`, `tracker`, `task-run`, `ui` |
12
12
  | `team-db-ui.mjs` | the `ui` supervisor: probe-first `start`, `stop`, `status`, `restart`, the ownership marker, leader-only termination |
13
13
  | `team-db-tracker.mjs` | the file-authoritative tracker: items, links, the launch queue, eligibility order, import |
14
14
  | `team-db-task-runner.mjs` | the opt-in `team/runner.json` supervisor behind tracker Continue |
@@ -20,10 +20,13 @@ The projection is installed by `init` as ten `team-db*.mjs` modules under `.ai.l
20
20
  | `team-db-scheduler.mjs` | job model, cron/interval math, the file store, the projection, and the timer |
21
21
 
22
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`, `upstream-research.mjs`,
24
- `check-write-scope.mjs`, `aggregate-agent-task-metrics.mjs`, and the `processes.mjs` + `process-lease.mjs` process manager
25
- (twenty-two entries; `node -e "require('./bin/lib/engine-scripts.js').ENGINE_SCRIPTS.length"`
26
- prints the shipped count).
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.
27
30
 
28
31
  ## Behavior contract
29
32
 
@@ -114,6 +117,7 @@ node .ai.local/scripts/team-db.mjs delete --slug <slug> [--root <team-dir>] [--j
114
117
  node .ai.local/scripts/team-db.mjs migrate-tasks [--root <team-dir>] [--quiet] [--json]
115
118
  [--rebuild | --no-rebuild]
116
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>]
117
121
  node .ai.local/scripts/team-db.mjs serve [--root <team-dir>] [--host <addr>] [--port <n>]
118
122
  [--allow-remote] [--open]
119
123
  node .ai.local/scripts/team-db.mjs ui start|restart [--root <team-dir>] [--json] [--quiet]
@@ -148,6 +152,19 @@ vocabulary: `0` ok, `1` a validation refusal carrying its named code (`E_TRACKER
148
152
  `E_TRACKER_TRANSITION`, `E_TRACKER_REVISION`, `E_SCHEMA`), `3` usage, `4` the tree lock was
149
153
  contended (`E_TRACKER_BUSY`).
150
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.
167
+
151
168
  `sync` is idempotent: a second run reports `inserted=0 updated=0 unchanged=<n>`. One changed
152
169
  byte changes exactly one document hash and one task content hash. A removed task directory is
153
170
  tombstoned with `absent_at` (soft delete) and `--prune` removes tombstones.
@@ -335,7 +352,13 @@ not supported in v1.
335
352
 
336
353
  ## Upstream research job
337
354
 
338
- 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,
339
362
  `.ai.local/scripts/upstream-research.mjs`. The job renders `upstream/prompt.md` and runs the
340
363
  module with `--prompt {promptFile} --team-root . --repo-root ../..`; it is a normal
341
364
  definition in `scheduler/jobs.json`, so `jobs list|get|put|enable|disable|run`, the dashboard
@@ -356,19 +379,35 @@ one `schedule --once` tick.
356
379
  `.ai.local/team/upstream/cursor.json`. A lost cursor is rebuilt from the newest
357
380
  `scheduler/runs/upstream-research/<runId>/report.json`, then degrades to a bounded baseline
358
381
  when the run tree has been pruned. `upstream/projects.json`, `config.json`, `signatures.json`,
359
- the prompt, the digest template, and the agent config are committed; `docs/upstream/digest-
360
- <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.
361
384
 
362
385
  **Write allow-list.** A run writes only `scheduler/runs/upstream-research/<runId>/**`, the
363
- cursor, and the committed digest. It never writes `status.json` or `metrics.json`, and the
364
- 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`.
365
403
 
366
404
  **Failure surface.** The scheduler's reason codes are a closed set, so a runner code such as
367
405
  `E_OPENCODE_MISSING` lives in `report.json`, `stderr.log`, and the digest header; the job row
368
406
  reports `E_EXIT_10` / `E_EXIT_11` / `E_EXIT_12` / `E_EXIT_13` / `E_EXIT_15` / `E_EXIT_16`.
369
- `E_AGENT_CONFIG_INVALID` (12) means the resolved `upstream-researcher` no longer denies
370
- every tool (the global `*` or a named action); reinstall `team/upstream/opencode.json` with
371
- `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.
372
411
 
373
412
  **Commands.** Validate the registry with
374
413
  `node .ai.local/scripts/upstream-research.mjs registry --check --team-root .`; refresh the
@@ -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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonesofspring/ai-rules",
3
- "version": "0.2.65",
3
+ "version": "0.2.66",
4
4
  "description": "Presets of Cursor, Claude, Mavis, OpenCode, and ZCode rules/commands for Revy Ross personal use",
5
5
  "license": "MIT",
6
6
  "author": "Revy Ross",
@@ -29,6 +29,9 @@
29
29
  "mcp",
30
30
  "docs",
31
31
  "presets",
32
+ "!presets/_shared/ai-local/scripts/upstream-research.mjs",
33
+ "!presets/*/next/commands/upstream-research.md",
34
+ "!presets/*/next/team/upstream/**",
32
35
  "presets/_shared/ai-local/scripts/check-write-scope.mjs",
33
36
  "scripts/check-product-specs.sh",
34
37
  "scripts/aggregate-agent-task-metrics.mjs",
@@ -87,6 +90,7 @@
87
90
  "test:cli-mcp-registration": "node scripts/test-cli-mcp-registration.mjs",
88
91
  "test:cli-mcp-catalog": "node scripts/test-cli-mcp-catalog.mjs",
89
92
  "test:mcp-pack-tarball": "node scripts/test-mcp-pack-tarball.mjs",
93
+ "test:pack-repo-only": "node scripts/test-pack-repo-only.mjs",
90
94
  "test:chain-coverage": "node scripts/test-chain-team-phases-coverage.mjs",
91
95
  "test:agent-task-metrics-hooks": "node scripts/test-agent-task-metrics-hooks.mjs",
92
96
  "test:upstream": "node scripts/test-upstream-research.mjs",
@@ -131,7 +135,8 @@
131
135
  "generate:mavis": "node scripts/generate-mavis.mjs",
132
136
  "generate:opencode": "node scripts/generate-opencode.mjs",
133
137
  "generate:zcode": "node scripts/generate-zcode.mjs",
134
- "test:dev-processes": "node scripts/test-dev-processes.mjs"
138
+ "test:dev-processes": "node scripts/test-dev-processes.mjs",
139
+ "test:task-status-view": "node scripts/test-task-status-view.mjs"
135
140
  },
136
141
  "engines": {
137
142
  "node": ">=20"