@bonesofspring/ai-rules 0.2.65 → 0.2.67

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 (396) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +21 -11
  3. package/bin/cli.js +9 -1
  4. package/bin/lib/engine-scripts.js +34 -7
  5. package/bin/lib/engine-upgrade.js +5 -2
  6. package/bin/lib/seed-ai-local-team.js +32 -3
  7. package/docs/OPENCODE-COMPATIBILITY.md +1 -0
  8. package/docs/OPENCODE.md +31 -10
  9. package/docs/TEAM-DB.md +54 -14
  10. package/docs/TOKEN-ECONOMY.md +110 -0
  11. package/docs/openapi/team-db.v1.json +5 -5
  12. package/package.json +16 -3
  13. package/presets/_shared/ai-local/scripts/dump-output.mjs +422 -0
  14. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +3 -3
  15. package/presets/_shared/ai-local/scripts/team-db-tracker.mjs +2 -0
  16. package/presets/_shared/ai-local/scripts/team-db.mjs +82 -2
  17. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +3 -1
  18. package/presets/_shared/core/architecture/feature-delivery-workflow.md +4 -0
  19. package/presets/_shared/core/quality/context-and-iteration.md +1 -0
  20. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +9 -2
  21. package/presets/_shared/hooks/list-ai-local.mjs +17 -0
  22. package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
  23. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +9 -2
  24. package/presets/claude/android-kotlin/hooks/list-ai-local.mjs +17 -0
  25. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  26. package/presets/claude/go/agents/task-analyst.md +1 -1
  27. package/presets/claude/go/hooks/chain-team-phases.sh +9 -2
  28. package/presets/claude/go/hooks/list-ai-local.mjs +17 -0
  29. package/presets/claude/go/rules/architecture/feature-delivery.md +4 -0
  30. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  31. package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
  32. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +9 -2
  33. package/presets/claude/ios-swift/hooks/list-ai-local.mjs +17 -0
  34. package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +4 -0
  35. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  36. package/presets/claude/java/agents/task-analyst.md +1 -1
  37. package/presets/claude/java/hooks/chain-team-phases.sh +9 -2
  38. package/presets/claude/java/hooks/list-ai-local.mjs +17 -0
  39. package/presets/claude/java/rules/architecture/feature-delivery.md +4 -0
  40. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  41. package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
  42. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +9 -2
  43. package/presets/claude/mcp-ts/hooks/list-ai-local.mjs +17 -0
  44. package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +4 -0
  45. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  46. package/presets/claude/mol/agents/task-analyst.md +1 -1
  47. package/presets/claude/mol/hooks/chain-team-phases.sh +9 -2
  48. package/presets/claude/mol/hooks/list-ai-local.mjs +17 -0
  49. package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +4 -0
  50. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  51. package/presets/claude/next/agents/ci-investigator.md +5 -2
  52. package/presets/claude/next/agents/debugger.md +5 -2
  53. package/presets/claude/next/agents/feature-developer.md +5 -2
  54. package/presets/claude/next/agents/task-analyst.md +1 -1
  55. package/presets/claude/next/commands/README.md +1 -1
  56. package/presets/claude/next/commands/task.md +1 -1
  57. package/presets/claude/next/hooks/chain-team-phases.sh +9 -2
  58. package/presets/claude/next/hooks/list-ai-local.mjs +17 -0
  59. package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +8 -0
  60. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  61. package/presets/claude/next/team/README.md +7 -3
  62. package/presets/claude/nuxt/agents/task-analyst.md +1 -1
  63. package/presets/claude/nuxt/hooks/chain-team-phases.sh +9 -2
  64. package/presets/claude/nuxt/hooks/list-ai-local.mjs +17 -0
  65. package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +4 -0
  66. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  67. package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
  68. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +9 -2
  69. package/presets/claude/php-hexagonal/hooks/list-ai-local.mjs +17 -0
  70. package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +4 -0
  71. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  72. package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
  73. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +9 -2
  74. package/presets/claude/php-laravel/hooks/list-ai-local.mjs +17 -0
  75. package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +4 -0
  76. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  77. package/presets/claude/svelte/agents/task-analyst.md +1 -1
  78. package/presets/claude/svelte/hooks/chain-team-phases.sh +9 -2
  79. package/presets/claude/svelte/hooks/list-ai-local.mjs +17 -0
  80. package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +4 -0
  81. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
  82. package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
  83. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +9 -2
  84. package/presets/cursor/android-kotlin/hooks/list-ai-local.mjs +17 -0
  85. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
  86. package/presets/cursor/go/agents/task-analyst.md +1 -1
  87. package/presets/cursor/go/hooks/chain-team-phases.sh +9 -2
  88. package/presets/cursor/go/hooks/list-ai-local.mjs +17 -0
  89. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
  90. package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
  91. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +9 -2
  92. package/presets/cursor/ios-swift/hooks/list-ai-local.mjs +17 -0
  93. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
  94. package/presets/cursor/java/agents/task-analyst.md +1 -1
  95. package/presets/cursor/java/hooks/chain-team-phases.sh +9 -2
  96. package/presets/cursor/java/hooks/list-ai-local.mjs +17 -0
  97. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
  98. package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
  99. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +9 -2
  100. package/presets/cursor/mcp-ts/hooks/list-ai-local.mjs +17 -0
  101. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
  102. package/presets/cursor/mol/agents/task-analyst.md +1 -1
  103. package/presets/cursor/mol/hooks/chain-team-phases.sh +9 -2
  104. package/presets/cursor/mol/hooks/list-ai-local.mjs +17 -0
  105. package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
  106. package/presets/cursor/next/agents/task-analyst.md +1 -1
  107. package/presets/cursor/next/commands/README.md +1 -1
  108. package/presets/cursor/next/commands/task.md +1 -1
  109. package/presets/cursor/next/hooks/chain-team-phases.sh +9 -2
  110. package/presets/cursor/next/hooks/list-ai-local.mjs +17 -0
  111. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +3 -1
  112. package/presets/cursor/next/rules/feature-delivery-workflow.mdc +4 -0
  113. package/presets/cursor/next/team/README.md +7 -3
  114. package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
  115. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +9 -2
  116. package/presets/cursor/nuxt/hooks/list-ai-local.mjs +17 -0
  117. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
  118. package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
  119. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +9 -2
  120. package/presets/cursor/php-hexagonal/hooks/list-ai-local.mjs +17 -0
  121. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
  122. package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
  123. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +9 -2
  124. package/presets/cursor/php-laravel/hooks/list-ai-local.mjs +17 -0
  125. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
  126. package/presets/cursor/svelte/agents/task-analyst.md +1 -1
  127. package/presets/cursor/svelte/hooks/chain-team-phases.sh +9 -2
  128. package/presets/cursor/svelte/hooks/list-ai-local.mjs +17 -0
  129. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
  130. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  131. package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
  132. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +9 -2
  133. package/presets/mavis/android-kotlin/hooks/list-ai-local.mjs +17 -0
  134. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +3 -1
  135. package/presets/mavis/go/adapter-map.json +1 -1
  136. package/presets/mavis/go/agents/task-analyst.md +1 -1
  137. package/presets/mavis/go/hooks/chain-team-phases.sh +9 -2
  138. package/presets/mavis/go/hooks/list-ai-local.mjs +17 -0
  139. package/presets/mavis/go/rules/agent-team-orchestrator.md +3 -1
  140. package/presets/mavis/go/rules/feature-delivery-workflow.md +4 -0
  141. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  142. package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
  143. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +9 -2
  144. package/presets/mavis/ios-swift/hooks/list-ai-local.mjs +17 -0
  145. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +3 -1
  146. package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +4 -0
  147. package/presets/mavis/java/adapter-map.json +1 -1
  148. package/presets/mavis/java/agents/task-analyst.md +1 -1
  149. package/presets/mavis/java/hooks/chain-team-phases.sh +9 -2
  150. package/presets/mavis/java/hooks/list-ai-local.mjs +17 -0
  151. package/presets/mavis/java/rules/agent-team-orchestrator.md +3 -1
  152. package/presets/mavis/java/rules/feature-delivery-workflow.md +4 -0
  153. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  154. package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
  155. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +9 -2
  156. package/presets/mavis/mcp-ts/hooks/list-ai-local.mjs +17 -0
  157. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +3 -1
  158. package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +4 -0
  159. package/presets/mavis/mol/adapter-map.json +1 -1
  160. package/presets/mavis/mol/agents/task-analyst.md +1 -1
  161. package/presets/mavis/mol/hooks/chain-team-phases.sh +9 -2
  162. package/presets/mavis/mol/hooks/list-ai-local.mjs +17 -0
  163. package/presets/mavis/mol/rules/agent-team-orchestrator.md +3 -1
  164. package/presets/mavis/mol/rules/feature-delivery-workflow.md +4 -0
  165. package/presets/mavis/next/adapter-map.json +9 -1
  166. package/presets/mavis/next/agents/ci-investigator.md +5 -2
  167. package/presets/mavis/next/agents/debugger.md +5 -2
  168. package/presets/mavis/next/agents/feature-developer.md +5 -2
  169. package/presets/mavis/next/agents/task-analyst.md +1 -1
  170. package/presets/mavis/next/commands/README.md +1 -1
  171. package/presets/mavis/next/commands/task.md +1 -1
  172. package/presets/mavis/next/hooks/chain-team-phases.sh +9 -2
  173. package/presets/mavis/next/hooks/list-ai-local.mjs +17 -0
  174. package/presets/mavis/next/rules/agent-team-orchestrator.md +3 -1
  175. package/presets/mavis/next/rules/feature-delivery-workflow.md +8 -0
  176. package/presets/mavis/next/team/README.md +7 -3
  177. package/presets/mavis/nuxt/adapter-map.json +1 -1
  178. package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
  179. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +9 -2
  180. package/presets/mavis/nuxt/hooks/list-ai-local.mjs +17 -0
  181. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +3 -1
  182. package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +4 -0
  183. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  184. package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
  185. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +9 -2
  186. package/presets/mavis/php-hexagonal/hooks/list-ai-local.mjs +17 -0
  187. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
  188. package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
  189. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  190. package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
  191. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +9 -2
  192. package/presets/mavis/php-laravel/hooks/list-ai-local.mjs +17 -0
  193. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +3 -1
  194. package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +4 -0
  195. package/presets/mavis/svelte/adapter-map.json +1 -1
  196. package/presets/mavis/svelte/agents/task-analyst.md +1 -1
  197. package/presets/mavis/svelte/hooks/chain-team-phases.sh +9 -2
  198. package/presets/mavis/svelte/hooks/list-ai-local.mjs +17 -0
  199. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +3 -1
  200. package/presets/mavis/svelte/rules/feature-delivery-workflow.md +4 -0
  201. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  202. package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
  203. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +9 -2
  204. package/presets/opencode/android-kotlin/hooks/list-ai-local.mjs +17 -0
  205. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +3 -1
  206. package/presets/opencode/go/adapter-map.json +1 -1
  207. package/presets/opencode/go/agents/task-analyst.md +1 -1
  208. package/presets/opencode/go/hooks/chain-team-phases.sh +9 -2
  209. package/presets/opencode/go/hooks/list-ai-local.mjs +17 -0
  210. package/presets/opencode/go/rules/agent-team-orchestrator.md +3 -1
  211. package/presets/opencode/go/rules/feature-delivery-workflow.md +4 -0
  212. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  213. package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
  214. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +9 -2
  215. package/presets/opencode/ios-swift/hooks/list-ai-local.mjs +17 -0
  216. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +3 -1
  217. package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +4 -0
  218. package/presets/opencode/java/adapter-map.json +1 -1
  219. package/presets/opencode/java/agents/task-analyst.md +1 -1
  220. package/presets/opencode/java/hooks/chain-team-phases.sh +9 -2
  221. package/presets/opencode/java/hooks/list-ai-local.mjs +17 -0
  222. package/presets/opencode/java/rules/agent-team-orchestrator.md +3 -1
  223. package/presets/opencode/java/rules/feature-delivery-workflow.md +4 -0
  224. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  225. package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
  226. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +9 -2
  227. package/presets/opencode/mcp-ts/hooks/list-ai-local.mjs +17 -0
  228. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +3 -1
  229. package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
  230. package/presets/opencode/mol/adapter-map.json +1 -1
  231. package/presets/opencode/mol/agents/task-analyst.md +1 -1
  232. package/presets/opencode/mol/hooks/chain-team-phases.sh +9 -2
  233. package/presets/opencode/mol/hooks/list-ai-local.mjs +17 -0
  234. package/presets/opencode/mol/rules/agent-team-orchestrator.md +3 -1
  235. package/presets/opencode/mol/rules/feature-delivery-workflow.md +4 -0
  236. package/presets/opencode/next/adapter-map.json +9 -1
  237. package/presets/opencode/next/agents/ci-investigator.md +5 -2
  238. package/presets/opencode/next/agents/debugger.md +5 -2
  239. package/presets/opencode/next/agents/feature-developer.md +5 -2
  240. package/presets/opencode/next/agents/task-analyst.md +1 -1
  241. package/presets/opencode/next/commands/README.md +1 -1
  242. package/presets/opencode/next/commands/task.md +1 -1
  243. package/presets/opencode/next/hooks/chain-team-phases.sh +9 -2
  244. package/presets/opencode/next/hooks/list-ai-local.mjs +17 -0
  245. package/presets/opencode/next/rules/agent-team-orchestrator.md +3 -1
  246. package/presets/opencode/next/rules/feature-delivery-workflow.md +8 -0
  247. package/presets/opencode/next/team/README.md +7 -3
  248. package/presets/opencode/nuxt/adapter-map.json +1 -1
  249. package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
  250. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +9 -2
  251. package/presets/opencode/nuxt/hooks/list-ai-local.mjs +17 -0
  252. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +3 -1
  253. package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +4 -0
  254. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  255. package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
  256. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +9 -2
  257. package/presets/opencode/php-hexagonal/hooks/list-ai-local.mjs +17 -0
  258. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
  259. package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
  260. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  261. package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
  262. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +9 -2
  263. package/presets/opencode/php-laravel/hooks/list-ai-local.mjs +17 -0
  264. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +3 -1
  265. package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +4 -0
  266. package/presets/opencode/plugins/output-guard/README.md +43 -0
  267. package/presets/opencode/plugins/output-guard/index.ts +300 -0
  268. package/presets/opencode/plugins/output-guard/package.json +9 -0
  269. package/presets/opencode/plugins/output-guard/rewrite.ts +149 -0
  270. package/presets/opencode/plugins/task-status/README.md +23 -11
  271. package/presets/opencode/plugins/task-status/details-data.ts +64 -46
  272. package/presets/opencode/plugins/task-status/details.tsx +12 -2
  273. package/presets/opencode/plugins/task-status/format.ts +16 -0
  274. package/presets/opencode/plugins/task-status/prompt-text.ts +37 -0
  275. package/presets/opencode/plugins/task-status/task-view.ts +281 -179
  276. package/presets/opencode/plugins/task-status/tui.tsx +60 -16
  277. package/presets/opencode/plugins/task-status/types.ts +74 -0
  278. package/presets/opencode/svelte/adapter-map.json +1 -1
  279. package/presets/opencode/svelte/agents/task-analyst.md +1 -1
  280. package/presets/opencode/svelte/hooks/chain-team-phases.sh +9 -2
  281. package/presets/opencode/svelte/hooks/list-ai-local.mjs +17 -0
  282. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +3 -1
  283. package/presets/opencode/svelte/rules/feature-delivery-workflow.md +4 -0
  284. package/presets/zcode/android-kotlin/adapter-map.json +1 -1
  285. package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
  286. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +9 -2
  287. package/presets/zcode/android-kotlin/hooks/list-ai-local.mjs +17 -0
  288. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +3 -1
  289. package/presets/zcode/go/adapter-map.json +1 -1
  290. package/presets/zcode/go/agents/task-analyst.md +1 -1
  291. package/presets/zcode/go/hooks/chain-team-phases.sh +9 -2
  292. package/presets/zcode/go/hooks/list-ai-local.mjs +17 -0
  293. package/presets/zcode/go/rules/agent-team-orchestrator.md +3 -1
  294. package/presets/zcode/go/rules/feature-delivery-workflow.md +4 -0
  295. package/presets/zcode/ios-swift/adapter-map.json +1 -1
  296. package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
  297. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +9 -2
  298. package/presets/zcode/ios-swift/hooks/list-ai-local.mjs +17 -0
  299. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +3 -1
  300. package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +4 -0
  301. package/presets/zcode/java/adapter-map.json +1 -1
  302. package/presets/zcode/java/agents/task-analyst.md +1 -1
  303. package/presets/zcode/java/hooks/chain-team-phases.sh +9 -2
  304. package/presets/zcode/java/hooks/list-ai-local.mjs +17 -0
  305. package/presets/zcode/java/rules/agent-team-orchestrator.md +3 -1
  306. package/presets/zcode/java/rules/feature-delivery-workflow.md +4 -0
  307. package/presets/zcode/mcp-ts/adapter-map.json +1 -1
  308. package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
  309. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +9 -2
  310. package/presets/zcode/mcp-ts/hooks/list-ai-local.mjs +17 -0
  311. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +3 -1
  312. package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
  313. package/presets/zcode/mol/adapter-map.json +1 -1
  314. package/presets/zcode/mol/agents/task-analyst.md +1 -1
  315. package/presets/zcode/mol/hooks/chain-team-phases.sh +9 -2
  316. package/presets/zcode/mol/hooks/list-ai-local.mjs +17 -0
  317. package/presets/zcode/mol/rules/agent-team-orchestrator.md +3 -1
  318. package/presets/zcode/mol/rules/feature-delivery-workflow.md +4 -0
  319. package/presets/zcode/next/adapter-map.json +9 -1
  320. package/presets/zcode/next/agents/ci-investigator.md +5 -2
  321. package/presets/zcode/next/agents/debugger.md +5 -2
  322. package/presets/zcode/next/agents/feature-developer.md +5 -2
  323. package/presets/zcode/next/agents/task-analyst.md +1 -1
  324. package/presets/zcode/next/commands/README.md +1 -1
  325. package/presets/zcode/next/commands/task.md +1 -1
  326. package/presets/zcode/next/hooks/chain-team-phases.sh +9 -2
  327. package/presets/zcode/next/hooks/list-ai-local.mjs +17 -0
  328. package/presets/zcode/next/rules/agent-team-orchestrator.md +3 -1
  329. package/presets/zcode/next/rules/feature-delivery-workflow.md +8 -0
  330. package/presets/zcode/next/team/README.md +7 -3
  331. package/presets/zcode/nuxt/adapter-map.json +1 -1
  332. package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
  333. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +9 -2
  334. package/presets/zcode/nuxt/hooks/list-ai-local.mjs +17 -0
  335. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +3 -1
  336. package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +4 -0
  337. package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
  338. package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
  339. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +9 -2
  340. package/presets/zcode/php-hexagonal/hooks/list-ai-local.mjs +17 -0
  341. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
  342. package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
  343. package/presets/zcode/php-laravel/adapter-map.json +1 -1
  344. package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
  345. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +9 -2
  346. package/presets/zcode/php-laravel/hooks/list-ai-local.mjs +17 -0
  347. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +3 -1
  348. package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +4 -0
  349. package/presets/zcode/svelte/adapter-map.json +1 -1
  350. package/presets/zcode/svelte/agents/task-analyst.md +1 -1
  351. package/presets/zcode/svelte/hooks/chain-team-phases.sh +9 -2
  352. package/presets/zcode/svelte/hooks/list-ai-local.mjs +17 -0
  353. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +3 -1
  354. package/presets/zcode/svelte/rules/feature-delivery-workflow.md +4 -0
  355. package/scripts/report-context-cost.mjs +432 -0
  356. package/presets/_shared/ai-local/scripts/upstream-research.mjs +0 -2964
  357. package/presets/claude/next/commands/upstream-research.md +0 -23
  358. package/presets/claude/next/team/upstream/config.json +0 -31
  359. package/presets/claude/next/team/upstream/digest-template.md +0 -55
  360. package/presets/claude/next/team/upstream/jobs.json +0 -34
  361. package/presets/claude/next/team/upstream/opencode.json +0 -34
  362. package/presets/claude/next/team/upstream/projects.json +0 -4
  363. package/presets/claude/next/team/upstream/prompt.md +0 -77
  364. package/presets/claude/next/team/upstream/signatures.json +0 -9
  365. package/presets/cursor/next/commands/upstream-research.md +0 -23
  366. package/presets/cursor/next/team/upstream/config.json +0 -31
  367. package/presets/cursor/next/team/upstream/digest-template.md +0 -55
  368. package/presets/cursor/next/team/upstream/jobs.json +0 -34
  369. package/presets/cursor/next/team/upstream/opencode.json +0 -34
  370. package/presets/cursor/next/team/upstream/projects.json +0 -4
  371. package/presets/cursor/next/team/upstream/prompt.md +0 -77
  372. package/presets/cursor/next/team/upstream/signatures.json +0 -9
  373. package/presets/mavis/next/commands/upstream-research.md +0 -18
  374. package/presets/mavis/next/team/upstream/config.json +0 -31
  375. package/presets/mavis/next/team/upstream/digest-template.md +0 -55
  376. package/presets/mavis/next/team/upstream/jobs.json +0 -34
  377. package/presets/mavis/next/team/upstream/opencode.json +0 -34
  378. package/presets/mavis/next/team/upstream/projects.json +0 -4
  379. package/presets/mavis/next/team/upstream/prompt.md +0 -77
  380. package/presets/mavis/next/team/upstream/signatures.json +0 -9
  381. package/presets/opencode/next/commands/upstream-research.md +0 -26
  382. package/presets/opencode/next/team/upstream/config.json +0 -31
  383. package/presets/opencode/next/team/upstream/digest-template.md +0 -55
  384. package/presets/opencode/next/team/upstream/jobs.json +0 -34
  385. package/presets/opencode/next/team/upstream/opencode.json +0 -34
  386. package/presets/opencode/next/team/upstream/projects.json +0 -4
  387. package/presets/opencode/next/team/upstream/prompt.md +0 -77
  388. package/presets/opencode/next/team/upstream/signatures.json +0 -9
  389. package/presets/zcode/next/commands/upstream-research.md +0 -26
  390. package/presets/zcode/next/team/upstream/config.json +0 -31
  391. package/presets/zcode/next/team/upstream/digest-template.md +0 -55
  392. package/presets/zcode/next/team/upstream/jobs.json +0 -34
  393. package/presets/zcode/next/team/upstream/opencode.json +0 -34
  394. package/presets/zcode/next/team/upstream/projects.json +0 -4
  395. package/presets/zcode/next/team/upstream/prompt.md +0 -77
  396. package/presets/zcode/next/team/upstream/signatures.json +0 -9
@@ -9287,7 +9287,7 @@
9287
9287
  "dependsOn": [
9288
9288
  2
9289
9289
  ],
9290
- "sourceTask": "task-tracker-tracker-impl",
9290
+ "sourceTask": "task-tracker-impl",
9291
9291
  "sourceRefs": [
9292
9292
  "AC-5",
9293
9293
  "WP7"
@@ -9465,7 +9465,7 @@
9465
9465
  ],
9466
9466
  "waitingOn": [],
9467
9467
  "ready": true,
9468
- "sourceTask": "task-tracker-tracker-impl",
9468
+ "sourceTask": "task-tracker-impl",
9469
9469
  "sourceRefs": [
9470
9470
  "AC-5",
9471
9471
  "WP7"
@@ -9734,7 +9734,7 @@
9734
9734
  "dependsOn": [
9735
9735
  2
9736
9736
  ],
9737
- "sourceTask": "task-tracker-tracker-impl",
9737
+ "sourceTask": "task-tracker-impl",
9738
9738
  "sourceRefs": [
9739
9739
  "AC-5",
9740
9740
  "WP7"
@@ -9911,7 +9911,7 @@
9911
9911
  ],
9912
9912
  "waitingOn": [],
9913
9913
  "ready": true,
9914
- "sourceTask": "task-tracker-tracker-impl",
9914
+ "sourceTask": "task-tracker-impl",
9915
9915
  "sourceRefs": [
9916
9916
  "AC-5",
9917
9917
  "WP7"
@@ -10014,7 +10014,7 @@
10014
10014
  2
10015
10015
  ],
10016
10016
  "priority": 2,
10017
- "sourceTask": "task-tracker-tracker-impl",
10017
+ "sourceTask": "task-tracker-impl",
10018
10018
  "sourceRefs": [
10019
10019
  "AC-5",
10020
10020
  "WP7"
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.67",
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,10 +29,14 @@
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",
35
- "scripts/close-agent-task-human-gate.mjs"
38
+ "scripts/close-agent-task-human-gate.mjs",
39
+ "scripts/report-context-cost.mjs"
36
40
  ],
37
41
  "scripts": {
38
42
  "check:fast": "bash scripts/check-preset-fast.sh",
@@ -78,6 +82,13 @@
78
82
  "test:generated-drift-claude-fixtures": "node scripts/test-generated-drift-claude-fixtures.mjs",
79
83
  "test:rule-improver": "node scripts/test-rule-improver-ledger.mjs",
80
84
  "test:guard-shell-command": "node scripts/test-guard-shell-command.mjs",
85
+ "test:dump-output": "node scripts/test-dump-output.mjs",
86
+ "test:output-guard": "node scripts/test-output-guard.mjs",
87
+ "test:context-cost-report": "node scripts/test-context-cost-report.mjs",
88
+ "test:report-efficiency": "node scripts/test-report-efficiency.mjs",
89
+ "test:bench-efficiency": "node scripts/test-bench-efficiency.mjs",
90
+ "report:efficiency": "node scripts/report-efficiency.mjs",
91
+ "bench:efficiency": "node scripts/bench-efficiency.mjs",
81
92
  "check:processes": "node scripts/test-process-lease.mjs && node scripts/test-process-adapters.mjs && node scripts/test-process-scan.mjs",
82
93
  "test:cli-mcp-merge": "node scripts/test-cli-mcp-merge.mjs",
83
94
  "test:cli-init-clean": "node scripts/run-locked.mjs --label test:cli-init-clean -- node scripts/test-cli-init-clean.mjs",
@@ -87,6 +98,7 @@
87
98
  "test:cli-mcp-registration": "node scripts/test-cli-mcp-registration.mjs",
88
99
  "test:cli-mcp-catalog": "node scripts/test-cli-mcp-catalog.mjs",
89
100
  "test:mcp-pack-tarball": "node scripts/test-mcp-pack-tarball.mjs",
101
+ "test:pack-repo-only": "node scripts/test-pack-repo-only.mjs",
90
102
  "test:chain-coverage": "node scripts/test-chain-team-phases-coverage.mjs",
91
103
  "test:agent-task-metrics-hooks": "node scripts/test-agent-task-metrics-hooks.mjs",
92
104
  "test:upstream": "node scripts/test-upstream-research.mjs",
@@ -131,7 +143,8 @@
131
143
  "generate:mavis": "node scripts/generate-mavis.mjs",
132
144
  "generate:opencode": "node scripts/generate-opencode.mjs",
133
145
  "generate:zcode": "node scripts/generate-zcode.mjs",
134
- "test:dev-processes": "node scripts/test-dev-processes.mjs"
146
+ "test:dev-processes": "node scripts/test-dev-processes.mjs",
147
+ "test:task-status-view": "node scripts/test-task-status-view.mjs"
135
148
  },
136
149
  "engines": {
137
150
  "node": ">=20"
@@ -0,0 +1,422 @@
1
+ /**
2
+ * Externalize a command's output into the task directory.
3
+ *
4
+ * Reads stdin (or `--input <file>`), writes the bytes to
5
+ * `.ai.local/team/tasks/<slug>/outputs/<id>.txt` under a 2 097 152-byte cap,
6
+ * and prints a bounded head plus the path and one `grep -n` hint. The full
7
+ * output stays on disk, where the team-db projection indexes it, so an agent
8
+ * searches the stored file instead of reading it or re-running the command.
9
+ *
10
+ * The cap is applied while streaming: memory stays at one chunk plus the 8 KiB
11
+ * head, whatever the input size. The bytes are copied raw — no decode, no
12
+ * re-encode — so a binary dump is stored as-is (and skipped by the projection).
13
+ *
14
+ * Invocation: dump-output.mjs [--task <slug>] [--label <text>] [--input <file>]
15
+ * [--root <team-dir>]
16
+ *
17
+ * Exit codes: 0 ok (including empty or truncated input), 2 usage or containment
18
+ * refusal, 1 write failure. The task comes from `--task`, else TEAM_TASK_SLUG.
19
+ * Without `--root`, the team root is the nearest `.ai.local/team` above the
20
+ * current directory, so a run from a nested package does not create a second
21
+ * overlay.
22
+ */
23
+
24
+ import fs from 'node:fs';
25
+ import path from 'node:path';
26
+ import { fileURLToPath } from 'node:url';
27
+
28
+ export const MAX_BYTES = 2 * 1024 * 1024;
29
+
30
+ const HEAD_LINES = 40;
31
+ const HEAD_BYTES = 8 * 1024;
32
+ const HEAD_LINE_BYTES = 400;
33
+ const LABEL_MAX = 32;
34
+ const SLUG_MAX = 48;
35
+ const CHUNK_BYTES = 64 * 1024;
36
+ const COLLISION_SCAN_LIMIT = 1000;
37
+ const CREATE_ATTEMPTS = COLLISION_SCAN_LIMIT + 1;
38
+ const TERM_MAX = 64;
39
+ const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
40
+ /** A token a shell can carry inside single quotes: no `'`, `"`, `$`, or backtick. */
41
+ const GREP_TOKEN_RE = /^[\p{L}\p{N}][\p{L}\p{N}_-]*$/u;
42
+
43
+ const USAGE = `usage:
44
+ dump-output.mjs [--task <slug>] [--label <text>] [--input <file>] [--root <team-dir>]
45
+
46
+ Reads a command's stdout (or --input) and writes it to
47
+ .ai.local/team/tasks/<slug>/outputs/<id>.txt under a ${MAX_BYTES}-byte cap, then prints
48
+ at most ${HEAD_LINES} head lines, the byte count, the path, and one grep hint.
49
+
50
+ --task <slug> task slug; defaults to TEAM_TASK_SLUG
51
+ --label <text> suffix in the output name (lowercased, [^a-z0-9]+ -> -)
52
+ --input <file> read this file instead of stdin
53
+ --root <dir> team root; defaults to the nearest .ai.local/team above the current directory
54
+
55
+ Exit codes: 0 ok (including empty or truncated input), 2 usage or containment
56
+ refusal, 1 write failure.`;
57
+
58
+ const usageFail = (message) => {
59
+ const error = new Error(message);
60
+ error.exitCode = 2;
61
+ throw error;
62
+ };
63
+
64
+ /**
65
+ * Filename-safe label: lowercase, every non-alphanumeric run becomes `-`, no
66
+ * leading/trailing `-`, capped so the id stays a readable filename.
67
+ */
68
+ export function sanitizeLabel(value) {
69
+ if (typeof value !== 'string') return '';
70
+ return value
71
+ .toLowerCase()
72
+ .replace(/[^a-z0-9]+/g, '-')
73
+ .replace(/^-+/, '')
74
+ .slice(0, LABEL_MAX)
75
+ .replace(/-+$/, '');
76
+ }
77
+
78
+ const sanitizeSlug = (value) => {
79
+ if (typeof value !== 'string') return '';
80
+ if (/[/\\]/.test(value) || value.includes('..') || value.startsWith('.')) return '';
81
+ const slug = value
82
+ .toLowerCase()
83
+ .replace(/[^a-z0-9]+/g, '-')
84
+ .replace(/^-+|-+$/g, '');
85
+ if (slug.length === 0 || slug.length > SLUG_MAX || !SLUG_RE.test(slug)) return '';
86
+ return slug;
87
+ };
88
+
89
+ /** The first free `<id>.txt`, `<id>-2.txt`, `<id>-3.txt`, … — never an existing file. */
90
+ export function resolveOutputPath({ outputsDir, id }) {
91
+ const first = path.join(outputsDir, `${id}.txt`);
92
+ if (!fs.existsSync(first)) return first;
93
+ for (let suffix = 2; suffix <= COLLISION_SCAN_LIMIT; suffix += 1) {
94
+ const candidate = path.join(outputsDir, `${id}-${suffix}.txt`);
95
+ if (!fs.existsSync(candidate)) return candidate;
96
+ }
97
+ throw new Error(`no free name for ${id}.txt in ${outputsDir}`);
98
+ }
99
+
100
+ const utcStamp = () =>
101
+ new Date()
102
+ .toISOString()
103
+ .replace(/[-:]/g, '')
104
+ .replace(/\.\d{3}Z$/, 'Z');
105
+
106
+ const parseArgs = (argv) => {
107
+ const flags = {};
108
+ for (let index = 0; index < argv.length; index += 1) {
109
+ const token = argv[index];
110
+ if (token === '--help' || token === '-h') return { help: true, flags };
111
+ if (!token.startsWith('--')) usageFail(`unexpected argument "${token}"`);
112
+ const [name, inline] = token.slice(2).split('=');
113
+ if (!['task', 'label', 'input', 'root'].includes(name)) usageFail(`unknown flag --${name}`);
114
+ if (inline !== undefined) {
115
+ flags[name] = inline;
116
+ continue;
117
+ }
118
+ const next = argv[index + 1];
119
+ if (next === undefined || next.startsWith('--')) usageFail(`flag --${name} needs a value`);
120
+ flags[name] = next;
121
+ index += 1;
122
+ }
123
+ return { help: false, flags };
124
+ };
125
+
126
+ const assertNotSymlink = (target, label, boundary) => {
127
+ // Walk from the team root down, not from `/`: a system alias above the
128
+ // project (`/var` → `/private/var` on macOS) is not a write-through dead end
129
+ // for the projection. A symlink at any depth **inside** the team tree still
130
+ // is, including the root itself.
131
+ const absolute = path.resolve(target);
132
+ const start = path.resolve(boundary ?? path.parse(absolute).root);
133
+ try {
134
+ if (fs.lstatSync(start).isSymbolicLink()) {
135
+ usageFail(`refusing a symlinked ${label}: ${target}`);
136
+ }
137
+ } catch (error) {
138
+ if (error.code !== 'ENOENT') throw error;
139
+ return;
140
+ }
141
+ const relative = path.relative(start, absolute);
142
+ if (relative.startsWith('..') || path.isAbsolute(relative)) {
143
+ usageFail(`refusing to write ${label} outside ${start}: ${target}`);
144
+ }
145
+ let walked = start;
146
+ for (const part of relative.split(path.sep).filter((part) => part !== '')) {
147
+ walked = path.join(walked, part);
148
+ let stats;
149
+ try {
150
+ stats = fs.lstatSync(walked);
151
+ } catch (error) {
152
+ if (error.code === 'ENOENT') return;
153
+ throw error;
154
+ }
155
+ // The projection walk skips symlinks, so anything written through one is
156
+ // invisible to `team-db search` — refuse instead of dumping into a dead end.
157
+ if (stats.isSymbolicLink()) usageFail(`refusing a symlinked ${label}: ${target}`);
158
+ }
159
+ };
160
+
161
+ const assertReadableFile = (file) => {
162
+ let stats;
163
+ try {
164
+ stats = fs.statSync(file);
165
+ } catch (error) {
166
+ return usageFail(`--input ${file} is not readable (${error.code ?? error.message})`);
167
+ }
168
+ if (!stats.isFile()) return usageFail(`--input ${file} is not a regular file`);
169
+ try {
170
+ fs.accessSync(file, fs.constants.R_OK);
171
+ } catch (error) {
172
+ return usageFail(`--input ${file} is not readable (${error.code ?? error.message})`);
173
+ }
174
+ return undefined;
175
+ };
176
+
177
+ const assertContained = (outputsDir, file) => {
178
+ const resolvedDir = path.resolve(outputsDir);
179
+ const resolvedFile = path.resolve(file);
180
+ const expected = path.join(resolvedDir, path.basename(file));
181
+ if (resolvedFile !== expected || !resolvedFile.startsWith(`${resolvedDir}${path.sep}`)) {
182
+ usageFail(`refusing to write outside ${resolvedDir}: ${file}`);
183
+ }
184
+ };
185
+
186
+ const createOutput = (outputsDir, baseId) => {
187
+ for (let attempt = 0; attempt < CREATE_ATTEMPTS; attempt += 1) {
188
+ const file = resolveOutputPath({ outputsDir, id: baseId });
189
+ assertContained(outputsDir, file);
190
+ try {
191
+ // `wx` closes the race between resolveOutputPath and the create: a file
192
+ // that appeared in between is a collision, never an overwrite.
193
+ return { file, fd: fs.openSync(file, 'wx') };
194
+ } catch (error) {
195
+ if (error.code !== 'EEXIST') throw error;
196
+ }
197
+ }
198
+ throw new Error(
199
+ `could not create a unique name for ${baseId}.txt in ${outputsDir} after ${CREATE_ATTEMPTS} attempts (every candidate was taken by a concurrent writer)`,
200
+ );
201
+ };
202
+
203
+ const writeAll = (fd, buffer) => {
204
+ let offset = 0;
205
+ while (offset < buffer.length) {
206
+ offset += fs.writeSync(fd, buffer, offset, buffer.length - offset);
207
+ }
208
+ };
209
+
210
+ /**
211
+ * Stream the source into the file: the head is collected up to 8 KiB and 40
212
+ * lines, the body stops at the cap. Reading stops at the first chunk past the
213
+ * cap, so a 1 GB dump costs one chunk of extra work, not 1 GB of I/O.
214
+ */
215
+ async function copyInto(source, fd) {
216
+ let written = 0;
217
+ let truncated = false;
218
+ let headBytes = 0;
219
+ let headNewlines = 0;
220
+ let headCut = false;
221
+ const headChunks = [];
222
+ for await (const chunk of source) {
223
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk), 'utf8');
224
+ if (buffer.length === 0) continue;
225
+ if (headNewlines < HEAD_LINES) {
226
+ const room = HEAD_BYTES - headBytes;
227
+ if (room > 0) {
228
+ const slice = buffer.subarray(0, room);
229
+ headChunks.push(slice);
230
+ headBytes += slice.length;
231
+ for (let index = 0; index < slice.length; index += 1) {
232
+ if (slice[index] === 0x0a) headNewlines += 1;
233
+ }
234
+ if (slice.length < buffer.length && headNewlines < HEAD_LINES) headCut = true;
235
+ } else {
236
+ headCut = true;
237
+ }
238
+ }
239
+ if (written >= MAX_BYTES) {
240
+ truncated = true;
241
+ break;
242
+ }
243
+ const slice = buffer.subarray(0, MAX_BYTES - written);
244
+ writeAll(fd, slice);
245
+ written += slice.length;
246
+ if (slice.length < buffer.length) {
247
+ truncated = true;
248
+ break;
249
+ }
250
+ }
251
+ return { written, truncated, head: Buffer.concat(headChunks), headCut };
252
+ }
253
+
254
+ /** Drop a code point the cap split, so the head never shows a replacement char. */
255
+ const trimPartialUtf8 = (buffer) => {
256
+ let index = buffer.length;
257
+ let trailing = 0;
258
+ while (index > 0 && trailing < 3 && (buffer[index - 1] & 0xc0) === 0x80) {
259
+ index -= 1;
260
+ trailing += 1;
261
+ }
262
+ if (index === 0) return buffer;
263
+ const lead = buffer[index - 1];
264
+ const expected = lead >= 0xf0 ? 4 : lead >= 0xe0 ? 3 : lead >= 0xc0 ? 2 : 1;
265
+ return buffer.length - (index - 1) < expected ? buffer.subarray(0, index - 1) : buffer;
266
+ };
267
+
268
+ const cutLine = (text, partial) => {
269
+ const buffer = Buffer.from(text, 'utf8');
270
+ if (!partial && buffer.length <= HEAD_LINE_BYTES) return { text, bytes: buffer.length };
271
+ let end = Math.min(buffer.length, HEAD_LINE_BYTES - 3);
272
+ while (end > 0 && (buffer[end] & 0xc0) === 0x80) end -= 1;
273
+ return { text: `${buffer.subarray(0, end).toString('utf8')}…`, bytes: end + 3 };
274
+ };
275
+
276
+ const formatHead = ({ head, headCut }) => {
277
+ const text = (headCut ? trimPartialUtf8(head) : head).toString('utf8');
278
+ const partialTail = headCut && !text.endsWith('\n');
279
+ const lines = text.split('\n');
280
+ if (lines.length > 0 && lines[lines.length - 1] === '') lines.pop();
281
+ const printed = [];
282
+ let total = 0;
283
+ for (let index = 0; index < lines.length && printed.length < HEAD_LINES; index += 1) {
284
+ const line = cutLine(lines[index].replace(/\r$/, ''), partialTail && index === lines.length - 1);
285
+ if (total + line.bytes + 1 > HEAD_BYTES) break;
286
+ printed.push(line.text);
287
+ total += line.bytes + 1;
288
+ }
289
+ return printed;
290
+ };
291
+
292
+ /** A usable first search term: the first head token a shell cannot break on. */
293
+ const grepTerm = (lines, fallback) => {
294
+ for (const line of lines) {
295
+ for (const token of line.split(/\s+/)) {
296
+ if (token.length >= 2 && GREP_TOKEN_RE.test(token)) return token.slice(0, TERM_MAX);
297
+ }
298
+ }
299
+ return fallback;
300
+ };
301
+
302
+ const realpathOr = (value) => {
303
+ try {
304
+ return fs.realpathSync(value);
305
+ } catch {
306
+ return value;
307
+ }
308
+ };
309
+
310
+ const displayPath = (file) => {
311
+ // Both sides go through realpath: a `--root` under a symlinked prefix (`/var`
312
+ // on macOS) is the same directory as the physical cwd, not "outside" it.
313
+ const target = path.resolve(file);
314
+ const relative = path.relative(realpathOr(path.resolve(process.cwd())), realpathOr(target));
315
+ const inside = relative !== '' && !relative.startsWith('..') && !path.isAbsolute(relative);
316
+ return (inside ? relative : target).split(path.sep).join('/');
317
+ };
318
+
319
+ /**
320
+ * Nearest `.ai.local/team` at or above `start`. A nested package in a monorepo
321
+ * owns its overlay when it has one; otherwise the repo-root overlay wins. Null
322
+ * means the caller must pass `--root` — never create a second overlay by
323
+ * guessing the current directory.
324
+ */
325
+ export function resolveTeamRoot(start = process.cwd()) {
326
+ let dir = path.resolve(start);
327
+ for (;;) {
328
+ const candidate = path.join(dir, '.ai.local', 'team');
329
+ try {
330
+ if (fs.statSync(candidate).isDirectory()) return candidate;
331
+ } catch {
332
+ /* keep walking up */
333
+ }
334
+ const parent = path.dirname(dir);
335
+ if (parent === dir) return null;
336
+ dir = parent;
337
+ }
338
+ }
339
+
340
+ async function main(argv) {
341
+ const { help, flags } = parseArgs(argv);
342
+ if (help) {
343
+ process.stdout.write(`${USAGE}\n`);
344
+ return 0;
345
+ }
346
+
347
+ const slug = sanitizeSlug(flags.task ?? process.env.TEAM_TASK_SLUG ?? '');
348
+ if (slug === '') {
349
+ usageFail('a task slug is required: --task <slug> or TEAM_TASK_SLUG (letters, digits, "-", max 48 chars)');
350
+ }
351
+ const root = flags.root ? path.resolve(flags.root) : resolveTeamRoot(process.cwd());
352
+ if (!root) {
353
+ usageFail(
354
+ 'no .ai.local/team found above the current directory; pass --root <team-dir>',
355
+ );
356
+ }
357
+ const inputPath = typeof flags.input === 'string' && flags.input !== '' ? path.resolve(flags.input) : null;
358
+ // Validate before touching the tree, so a usage refusal writes nothing.
359
+ if (inputPath) assertReadableFile(inputPath);
360
+
361
+ const taskDir = path.join(root, 'tasks', slug);
362
+ const outputsDir = path.join(taskDir, 'outputs');
363
+ assertNotSymlink(taskDir, 'task directory', root);
364
+ assertNotSymlink(outputsDir, 'outputs directory', root);
365
+ fs.mkdirSync(outputsDir, { recursive: true });
366
+
367
+ const baseId = [utcStamp(), sanitizeLabel(flags.label)].filter(Boolean).join('-');
368
+ const { file, fd } = createOutput(outputsDir, baseId);
369
+ let result;
370
+ try {
371
+ result = await copyInto(
372
+ inputPath ? fs.createReadStream(inputPath, { highWaterMark: CHUNK_BYTES }) : process.stdin,
373
+ fd,
374
+ );
375
+ } catch (error) {
376
+ try {
377
+ fs.closeSync(fd);
378
+ } catch {
379
+ /* the write failure is the finding */
380
+ }
381
+ try {
382
+ fs.unlinkSync(file);
383
+ } catch {
384
+ /* a partial file is already the failure being reported */
385
+ }
386
+ throw error;
387
+ }
388
+ fs.closeSync(fd);
389
+
390
+ const printed = displayPath(file);
391
+ if (result.written === 0) {
392
+ process.stdout.write('empty input; nothing to externalize\n');
393
+ process.stdout.write(`path: ${printed}\n`);
394
+ return 0;
395
+ }
396
+
397
+ const head = formatHead(result);
398
+ process.stdout.write('head:\n');
399
+ for (const line of head) process.stdout.write(`${line}\n`);
400
+ process.stdout.write(`bytes: ${result.written} (cap ${MAX_BYTES}, truncated: ${result.truncated ? 'yes' : 'no'})\n`);
401
+ process.stdout.write(`path: ${printed}\n`);
402
+ process.stdout.write(`grep -n '${grepTerm(head, baseId)}' ${printed}\n`);
403
+ return 0;
404
+ }
405
+
406
+ const invokedDirectly = (() => {
407
+ if (!process.argv[1]) return false;
408
+ try {
409
+ return fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
410
+ } catch {
411
+ return false;
412
+ }
413
+ })();
414
+
415
+ if (invokedDirectly) {
416
+ try {
417
+ process.exitCode = await main(process.argv.slice(2));
418
+ } catch (error) {
419
+ process.stderr.write(`dump-output: ${error.message}\n`);
420
+ process.exitCode = typeof error.exitCode === 'number' ? error.exitCode : 1;
421
+ }
422
+ }
@@ -1526,7 +1526,7 @@ const trackerItemExample = {
1526
1526
  labels: ['tracker', 'ui'],
1527
1527
  history: [trackerHistoryExample],
1528
1528
  dependsOn: [2],
1529
- sourceTask: 'task-tracker-tracker-impl',
1529
+ sourceTask: 'task-tracker-impl',
1530
1530
  sourceRefs: ['AC-5', 'WP7'],
1531
1531
  createdAt: '2026-11-10T09:00:00.000Z',
1532
1532
  updatedAt: '2026-11-12T10:00:00.000Z',
@@ -1554,7 +1554,7 @@ const trackerItemSummaryExample = {
1554
1554
  dependsOn: [2],
1555
1555
  waitingOn: [],
1556
1556
  ready: true,
1557
- sourceTask: 'task-tracker-tracker-impl',
1557
+ sourceTask: 'task-tracker-impl',
1558
1558
  sourceRefs: ['AC-5', 'WP7'],
1559
1559
  taskState: null,
1560
1560
  createdAt: '2026-11-10T09:00:00.000Z',
@@ -1568,7 +1568,7 @@ const trackerCreateRequestExample = {
1568
1568
  title: 'Ship the tracker operator UI',
1569
1569
  dependsOn: [2],
1570
1570
  priority: 2,
1571
- sourceTask: 'task-tracker-tracker-impl',
1571
+ sourceTask: 'task-tracker-impl',
1572
1572
  sourceRefs: ['AC-5', 'WP7'],
1573
1573
  type: 'feature',
1574
1574
  description: 'The /tracker list and the /tracker/[id] detail over the existing proxy.',
@@ -1953,6 +1953,8 @@ export function runTrackerCommand(subcommand, positionalId, options = {}) {
1953
1953
  status: annotated.item.status,
1954
1954
  effectiveStatus: annotated.effectiveStatus,
1955
1955
  priority: annotated.item.priority,
1956
+ labels: annotated.item.labels,
1957
+ sourceRefs: annotated.item.sourceRefs,
1956
1958
  ready: annotated.ready,
1957
1959
  waitingOn: annotated.waitingOn,
1958
1960
  createdAt: annotated.item.createdAt,