@bonesofspring/ai-rules 0.2.86 → 0.2.87

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 (425) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/bin/lib/engine-scripts.js +4 -0
  3. package/bin/lib/seed-ai-local-team.js +39 -2
  4. package/bin/opencode-install.js +3 -2
  5. package/docs/OPENCODE-COMPATIBILITY.md +6 -4
  6. package/docs/OPENCODE.md +8 -5
  7. package/docs/PRESET-CONTRIBUTION.md +6 -6
  8. package/docs/TOKEN-ECONOMY.md +20 -0
  9. package/package.json +1 -1
  10. package/presets/_shared/ai-local/scripts/report-step-cost.mjs +544 -0
  11. package/presets/_shared/assets/model-tiers.json +6 -0
  12. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +3 -3
  13. package/presets/_shared/hooks/guard-shell-command.mjs.tmpl +125 -105
  14. package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +125 -105
  15. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  16. package/presets/claude/go/hooks/guard-shell-command.mjs +125 -105
  17. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  18. package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +125 -105
  19. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  20. package/presets/claude/java/hooks/guard-shell-command.mjs +125 -105
  21. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  22. package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +125 -105
  23. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  24. package/presets/claude/mol/hooks/guard-shell-command.mjs +125 -105
  25. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  26. package/presets/claude/next/hooks/guard-shell-command.mjs +125 -105
  27. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  28. package/presets/claude/nuxt/hooks/guard-shell-command.mjs +125 -105
  29. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  30. package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +125 -105
  31. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  32. package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +125 -105
  33. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  34. package/presets/claude/svelte/hooks/guard-shell-command.mjs +125 -105
  35. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +3 -3
  36. package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +125 -105
  37. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +3 -3
  38. package/presets/cursor/go/hooks/guard-shell-command.mjs +125 -105
  39. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +3 -3
  40. package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +125 -105
  41. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +3 -3
  42. package/presets/cursor/java/hooks/guard-shell-command.mjs +125 -105
  43. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +3 -3
  44. package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +125 -105
  45. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +3 -3
  46. package/presets/cursor/mol/hooks/guard-shell-command.mjs +125 -105
  47. package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +3 -3
  48. package/presets/cursor/next/hooks/guard-shell-command.mjs +125 -105
  49. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +3 -3
  50. package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +125 -105
  51. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +3 -3
  52. package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +125 -105
  53. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +3 -3
  54. package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +125 -105
  55. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +3 -3
  56. package/presets/cursor/svelte/hooks/guard-shell-command.mjs +125 -105
  57. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +3 -3
  58. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  59. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +3 -3
  60. package/presets/mavis/go/adapter-map.json +1 -1
  61. package/presets/mavis/go/rules/agent-team-orchestrator.md +3 -3
  62. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  63. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +3 -3
  64. package/presets/mavis/java/adapter-map.json +1 -1
  65. package/presets/mavis/java/rules/agent-team-orchestrator.md +3 -3
  66. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  67. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +3 -3
  68. package/presets/mavis/mol/adapter-map.json +1 -1
  69. package/presets/mavis/mol/rules/agent-team-orchestrator.md +3 -3
  70. package/presets/mavis/next/adapter-map.json +1 -1
  71. package/presets/mavis/next/rules/agent-team-orchestrator.md +3 -3
  72. package/presets/mavis/nuxt/adapter-map.json +1 -1
  73. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +3 -3
  74. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  75. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +3 -3
  76. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  77. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +3 -3
  78. package/presets/mavis/svelte/adapter-map.json +1 -1
  79. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +3 -3
  80. package/presets/opencode/android-kotlin/OPENCODE.md +5 -66
  81. package/presets/opencode/android-kotlin/adapter-map.json +42 -42
  82. package/presets/opencode/android-kotlin/agents/accessibility-reviewer.md +1 -1
  83. package/presets/opencode/android-kotlin/agents/api-contract-reviewer.md +1 -1
  84. package/presets/opencode/android-kotlin/agents/build-verifier.md +1 -1
  85. package/presets/opencode/android-kotlin/agents/ci-investigator.md +1 -1
  86. package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -1
  87. package/presets/opencode/android-kotlin/agents/codebase-analyzer.md +1 -1
  88. package/presets/opencode/android-kotlin/agents/debugger.md +1 -1
  89. package/presets/opencode/android-kotlin/agents/feature-developer.md +1 -1
  90. package/presets/opencode/android-kotlin/agents/instrumentation-test-generator.md +1 -1
  91. package/presets/opencode/android-kotlin/agents/instrumentation-test-healer.md +1 -1
  92. package/presets/opencode/android-kotlin/agents/instrumentation-test-planner.md +1 -1
  93. package/presets/opencode/android-kotlin/agents/migration-specialist.md +1 -1
  94. package/presets/opencode/android-kotlin/agents/mockup-reviewer.md +1 -1
  95. package/presets/opencode/android-kotlin/agents/openspec-author.md +1 -1
  96. package/presets/opencode/android-kotlin/agents/performance-auditor.md +1 -1
  97. package/presets/opencode/android-kotlin/agents/qa-tester.md +1 -1
  98. package/presets/opencode/android-kotlin/agents/security-reviewer.md +1 -1
  99. package/presets/opencode/android-kotlin/agents/solution-architect.md +1 -1
  100. package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
  101. package/presets/opencode/android-kotlin/agents/task-router.md +1 -1
  102. package/presets/opencode/android-kotlin/agents/tech-writer.md +1 -1
  103. package/presets/opencode/android-kotlin/agents/unit-test-generator.md +1 -1
  104. package/presets/opencode/android-kotlin/agents/unit-test-healer.md +1 -1
  105. package/presets/opencode/android-kotlin/agents/unit-test-planner.md +1 -1
  106. package/presets/opencode/android-kotlin/commands/task-continue.md +1 -1
  107. package/presets/opencode/android-kotlin/hooks/README.md +11 -1
  108. package/presets/opencode/android-kotlin/hooks/guard-shell-command.mjs +155 -0
  109. package/presets/opencode/android-kotlin/plugins/rule-attach/globs.json +167 -0
  110. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +5 -5
  111. package/presets/opencode/go/OPENCODE.md +5 -51
  112. package/presets/opencode/go/adapter-map.json +45 -45
  113. package/presets/opencode/go/agents/api-contract-reviewer.md +1 -1
  114. package/presets/opencode/go/agents/build-verifier.md +1 -1
  115. package/presets/opencode/go/agents/ci-investigator.md +1 -1
  116. package/presets/opencode/go/agents/code-reviewer.md +1 -1
  117. package/presets/opencode/go/agents/codebase-analyzer.md +1 -1
  118. package/presets/opencode/go/agents/debugger.md +1 -1
  119. package/presets/opencode/go/agents/feature-developer.md +1 -1
  120. package/presets/opencode/go/agents/integration-test-generator.md +1 -1
  121. package/presets/opencode/go/agents/integration-test-healer.md +1 -1
  122. package/presets/opencode/go/agents/integration-test-planner.md +1 -1
  123. package/presets/opencode/go/agents/migration-specialist.md +1 -1
  124. package/presets/opencode/go/agents/openspec-author.md +1 -1
  125. package/presets/opencode/go/agents/performance-auditor.md +1 -1
  126. package/presets/opencode/go/agents/qa-tester.md +1 -1
  127. package/presets/opencode/go/agents/security-reviewer.md +1 -1
  128. package/presets/opencode/go/agents/solution-architect.md +1 -1
  129. package/presets/opencode/go/agents/task-analyst.md +1 -1
  130. package/presets/opencode/go/agents/task-router.md +1 -1
  131. package/presets/opencode/go/agents/tech-writer.md +1 -1
  132. package/presets/opencode/go/agents/unit-test-generator.md +1 -1
  133. package/presets/opencode/go/agents/unit-test-healer.md +1 -1
  134. package/presets/opencode/go/agents/unit-test-planner.md +1 -1
  135. package/presets/opencode/go/commands/task-continue.md +1 -1
  136. package/presets/opencode/go/hooks/README.md +11 -1
  137. package/presets/opencode/go/hooks/guard-shell-command.mjs +154 -0
  138. package/presets/opencode/go/plugins/rule-attach/globs.json +198 -0
  139. package/presets/opencode/go/rules/agent-team-orchestrator.md +5 -5
  140. package/presets/opencode/ios-swift/OPENCODE.md +5 -66
  141. package/presets/opencode/ios-swift/adapter-map.json +41 -41
  142. package/presets/opencode/ios-swift/agents/accessibility-reviewer.md +1 -1
  143. package/presets/opencode/ios-swift/agents/api-contract-reviewer.md +1 -1
  144. package/presets/opencode/ios-swift/agents/build-verifier.md +1 -1
  145. package/presets/opencode/ios-swift/agents/ci-investigator.md +1 -1
  146. package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -1
  147. package/presets/opencode/ios-swift/agents/codebase-analyzer.md +1 -1
  148. package/presets/opencode/ios-swift/agents/debugger.md +1 -1
  149. package/presets/opencode/ios-swift/agents/feature-developer.md +1 -1
  150. package/presets/opencode/ios-swift/agents/migration-specialist.md +1 -1
  151. package/presets/opencode/ios-swift/agents/mockup-reviewer.md +1 -1
  152. package/presets/opencode/ios-swift/agents/openspec-author.md +1 -1
  153. package/presets/opencode/ios-swift/agents/performance-auditor.md +1 -1
  154. package/presets/opencode/ios-swift/agents/qa-tester.md +1 -1
  155. package/presets/opencode/ios-swift/agents/security-reviewer.md +1 -1
  156. package/presets/opencode/ios-swift/agents/solution-architect.md +1 -1
  157. package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
  158. package/presets/opencode/ios-swift/agents/task-router.md +1 -1
  159. package/presets/opencode/ios-swift/agents/tech-writer.md +1 -1
  160. package/presets/opencode/ios-swift/agents/unit-test-generator.md +1 -1
  161. package/presets/opencode/ios-swift/agents/unit-test-healer.md +1 -1
  162. package/presets/opencode/ios-swift/agents/unit-test-planner.md +1 -1
  163. package/presets/opencode/ios-swift/agents/xcuitest-test-generator.md +1 -1
  164. package/presets/opencode/ios-swift/agents/xcuitest-test-healer.md +1 -1
  165. package/presets/opencode/ios-swift/agents/xcuitest-test-planner.md +1 -1
  166. package/presets/opencode/ios-swift/commands/task-continue.md +1 -1
  167. package/presets/opencode/ios-swift/hooks/README.md +11 -1
  168. package/presets/opencode/ios-swift/hooks/guard-shell-command.mjs +154 -0
  169. package/presets/opencode/ios-swift/plugins/rule-attach/globs.json +160 -0
  170. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +5 -5
  171. package/presets/opencode/java/OPENCODE.md +5 -58
  172. package/presets/opencode/java/adapter-map.json +45 -45
  173. package/presets/opencode/java/agents/api-contract-reviewer.md +1 -1
  174. package/presets/opencode/java/agents/build-verifier.md +1 -1
  175. package/presets/opencode/java/agents/ci-investigator.md +1 -1
  176. package/presets/opencode/java/agents/code-reviewer.md +1 -1
  177. package/presets/opencode/java/agents/codebase-analyzer.md +1 -1
  178. package/presets/opencode/java/agents/debugger.md +1 -1
  179. package/presets/opencode/java/agents/feature-developer.md +1 -1
  180. package/presets/opencode/java/agents/integration-test-generator.md +1 -1
  181. package/presets/opencode/java/agents/integration-test-healer.md +1 -1
  182. package/presets/opencode/java/agents/integration-test-planner.md +1 -1
  183. package/presets/opencode/java/agents/migration-specialist.md +1 -1
  184. package/presets/opencode/java/agents/openspec-author.md +1 -1
  185. package/presets/opencode/java/agents/performance-auditor.md +1 -1
  186. package/presets/opencode/java/agents/qa-tester.md +1 -1
  187. package/presets/opencode/java/agents/security-reviewer.md +1 -1
  188. package/presets/opencode/java/agents/solution-architect.md +1 -1
  189. package/presets/opencode/java/agents/task-analyst.md +1 -1
  190. package/presets/opencode/java/agents/task-router.md +1 -1
  191. package/presets/opencode/java/agents/tech-writer.md +1 -1
  192. package/presets/opencode/java/agents/unit-test-generator.md +1 -1
  193. package/presets/opencode/java/agents/unit-test-healer.md +1 -1
  194. package/presets/opencode/java/agents/unit-test-planner.md +1 -1
  195. package/presets/opencode/java/commands/task-continue.md +1 -1
  196. package/presets/opencode/java/hooks/README.md +11 -1
  197. package/presets/opencode/java/hooks/guard-shell-command.mjs +155 -0
  198. package/presets/opencode/java/plugins/rule-attach/globs.json +230 -0
  199. package/presets/opencode/java/rules/agent-team-orchestrator.md +5 -5
  200. package/presets/opencode/mcp-ts/OPENCODE.md +5 -48
  201. package/presets/opencode/mcp-ts/adapter-map.json +36 -36
  202. package/presets/opencode/mcp-ts/agents/build-verifier.md +1 -1
  203. package/presets/opencode/mcp-ts/agents/feature-developer.md +1 -1
  204. package/presets/opencode/mcp-ts/agents/security-reviewer.md +1 -1
  205. package/presets/opencode/mcp-ts/agents/solution-architect.md +1 -1
  206. package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
  207. package/presets/opencode/mcp-ts/agents/task-router.md +1 -1
  208. package/presets/opencode/mcp-ts/commands/task-continue.md +1 -1
  209. package/presets/opencode/mcp-ts/hooks/README.md +11 -1
  210. package/presets/opencode/mcp-ts/hooks/guard-shell-command.mjs +154 -0
  211. package/presets/opencode/mcp-ts/plugins/rule-attach/globs.json +151 -0
  212. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +5 -5
  213. package/presets/opencode/mol/OPENCODE.md +5 -56
  214. package/presets/opencode/mol/adapter-map.json +31 -31
  215. package/presets/opencode/mol/agents/accessibility-reviewer.md +1 -1
  216. package/presets/opencode/mol/agents/api-contract-reviewer.md +1 -1
  217. package/presets/opencode/mol/agents/build-verifier.md +1 -1
  218. package/presets/opencode/mol/agents/ci-investigator.md +1 -1
  219. package/presets/opencode/mol/agents/code-reviewer.md +1 -1
  220. package/presets/opencode/mol/agents/codebase-analyzer.md +1 -1
  221. package/presets/opencode/mol/agents/debugger.md +1 -1
  222. package/presets/opencode/mol/agents/feature-developer.md +1 -1
  223. package/presets/opencode/mol/agents/migration-specialist.md +1 -1
  224. package/presets/opencode/mol/agents/mockup-reviewer.md +1 -1
  225. package/presets/opencode/mol/agents/openspec-author.md +1 -1
  226. package/presets/opencode/mol/agents/performance-auditor.md +1 -1
  227. package/presets/opencode/mol/agents/playwright-test-generator.md +1 -1
  228. package/presets/opencode/mol/agents/playwright-test-healer.md +1 -1
  229. package/presets/opencode/mol/agents/playwright-test-planner.md +1 -1
  230. package/presets/opencode/mol/agents/qa-tester.md +1 -1
  231. package/presets/opencode/mol/agents/security-reviewer.md +1 -1
  232. package/presets/opencode/mol/agents/solution-architect.md +1 -1
  233. package/presets/opencode/mol/agents/task-analyst.md +1 -1
  234. package/presets/opencode/mol/agents/task-router.md +1 -1
  235. package/presets/opencode/mol/agents/tech-writer.md +1 -1
  236. package/presets/opencode/mol/agents/unit-test-generator.md +1 -1
  237. package/presets/opencode/mol/agents/unit-test-healer.md +1 -1
  238. package/presets/opencode/mol/agents/unit-test-planner.md +1 -1
  239. package/presets/opencode/mol/commands/task-continue.md +1 -1
  240. package/presets/opencode/mol/hooks/README.md +11 -1
  241. package/presets/opencode/mol/hooks/guard-shell-command.mjs +153 -0
  242. package/presets/opencode/mol/plugins/rule-attach/globs.json +112 -0
  243. package/presets/opencode/mol/rules/agent-team-orchestrator.md +5 -5
  244. package/presets/opencode/next/OPENCODE.md +5 -55
  245. package/presets/opencode/next/adapter-map.json +56 -56
  246. package/presets/opencode/next/agents/accessibility-reviewer.md +1 -1
  247. package/presets/opencode/next/agents/api-contract-reviewer.md +1 -1
  248. package/presets/opencode/next/agents/build-verifier.md +1 -1
  249. package/presets/opencode/next/agents/ci-investigator.md +1 -1
  250. package/presets/opencode/next/agents/code-reviewer.md +1 -1
  251. package/presets/opencode/next/agents/codebase-analyzer.md +1 -1
  252. package/presets/opencode/next/agents/debugger.md +1 -1
  253. package/presets/opencode/next/agents/feature-developer.md +1 -1
  254. package/presets/opencode/next/agents/migration-specialist.md +1 -1
  255. package/presets/opencode/next/agents/mockup-reviewer.md +1 -1
  256. package/presets/opencode/next/agents/openspec-author.md +1 -1
  257. package/presets/opencode/next/agents/performance-auditor.md +1 -1
  258. package/presets/opencode/next/agents/playwright-test-generator.md +1 -1
  259. package/presets/opencode/next/agents/playwright-test-healer.md +1 -1
  260. package/presets/opencode/next/agents/playwright-test-planner.md +1 -1
  261. package/presets/opencode/next/agents/qa-tester.md +1 -1
  262. package/presets/opencode/next/agents/security-reviewer.md +1 -1
  263. package/presets/opencode/next/agents/solution-architect.md +1 -1
  264. package/presets/opencode/next/agents/task-analyst.md +1 -1
  265. package/presets/opencode/next/agents/task-router.md +1 -1
  266. package/presets/opencode/next/agents/tech-writer.md +1 -1
  267. package/presets/opencode/next/agents/unit-test-generator.md +1 -1
  268. package/presets/opencode/next/agents/unit-test-healer.md +1 -1
  269. package/presets/opencode/next/agents/unit-test-planner.md +1 -1
  270. package/presets/opencode/next/commands/task-continue.md +1 -1
  271. package/presets/opencode/next/hooks/README.md +11 -1
  272. package/presets/opencode/next/hooks/guard-shell-command.mjs +153 -0
  273. package/presets/opencode/next/plugins/rule-attach/globs.json +276 -0
  274. package/presets/opencode/next/rules/agent-team-orchestrator.md +5 -5
  275. package/presets/opencode/nuxt/OPENCODE.md +5 -54
  276. package/presets/opencode/nuxt/adapter-map.json +51 -51
  277. package/presets/opencode/nuxt/agents/accessibility-reviewer.md +1 -1
  278. package/presets/opencode/nuxt/agents/api-contract-reviewer.md +1 -1
  279. package/presets/opencode/nuxt/agents/build-verifier.md +1 -1
  280. package/presets/opencode/nuxt/agents/ci-investigator.md +1 -1
  281. package/presets/opencode/nuxt/agents/code-reviewer.md +1 -1
  282. package/presets/opencode/nuxt/agents/codebase-analyzer.md +1 -1
  283. package/presets/opencode/nuxt/agents/debugger.md +1 -1
  284. package/presets/opencode/nuxt/agents/feature-developer.md +1 -1
  285. package/presets/opencode/nuxt/agents/migration-specialist.md +1 -1
  286. package/presets/opencode/nuxt/agents/mockup-reviewer.md +1 -1
  287. package/presets/opencode/nuxt/agents/openspec-author.md +1 -1
  288. package/presets/opencode/nuxt/agents/performance-auditor.md +1 -1
  289. package/presets/opencode/nuxt/agents/playwright-test-generator.md +1 -1
  290. package/presets/opencode/nuxt/agents/playwright-test-healer.md +1 -1
  291. package/presets/opencode/nuxt/agents/playwright-test-planner.md +1 -1
  292. package/presets/opencode/nuxt/agents/qa-tester.md +1 -1
  293. package/presets/opencode/nuxt/agents/security-reviewer.md +1 -1
  294. package/presets/opencode/nuxt/agents/solution-architect.md +1 -1
  295. package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
  296. package/presets/opencode/nuxt/agents/task-router.md +1 -1
  297. package/presets/opencode/nuxt/agents/tech-writer.md +1 -1
  298. package/presets/opencode/nuxt/agents/unit-test-generator.md +1 -1
  299. package/presets/opencode/nuxt/agents/unit-test-healer.md +1 -1
  300. package/presets/opencode/nuxt/agents/unit-test-planner.md +1 -1
  301. package/presets/opencode/nuxt/commands/task-continue.md +1 -1
  302. package/presets/opencode/nuxt/hooks/README.md +11 -1
  303. package/presets/opencode/nuxt/hooks/guard-shell-command.mjs +153 -0
  304. package/presets/opencode/nuxt/plugins/rule-attach/globs.json +266 -0
  305. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +5 -5
  306. package/presets/opencode/php-hexagonal/OPENCODE.md +5 -60
  307. package/presets/opencode/php-hexagonal/adapter-map.json +45 -45
  308. package/presets/opencode/php-hexagonal/agents/api-contract-reviewer.md +1 -1
  309. package/presets/opencode/php-hexagonal/agents/build-verifier.md +1 -1
  310. package/presets/opencode/php-hexagonal/agents/ci-investigator.md +1 -1
  311. package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -1
  312. package/presets/opencode/php-hexagonal/agents/codebase-analyzer.md +1 -1
  313. package/presets/opencode/php-hexagonal/agents/debugger.md +1 -1
  314. package/presets/opencode/php-hexagonal/agents/feature-developer.md +1 -1
  315. package/presets/opencode/php-hexagonal/agents/integration-test-generator.md +1 -1
  316. package/presets/opencode/php-hexagonal/agents/integration-test-healer.md +1 -1
  317. package/presets/opencode/php-hexagonal/agents/integration-test-planner.md +1 -1
  318. package/presets/opencode/php-hexagonal/agents/migration-specialist.md +1 -1
  319. package/presets/opencode/php-hexagonal/agents/openspec-author.md +1 -1
  320. package/presets/opencode/php-hexagonal/agents/performance-auditor.md +1 -1
  321. package/presets/opencode/php-hexagonal/agents/qa-tester.md +1 -1
  322. package/presets/opencode/php-hexagonal/agents/security-reviewer.md +1 -1
  323. package/presets/opencode/php-hexagonal/agents/solution-architect.md +1 -1
  324. package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
  325. package/presets/opencode/php-hexagonal/agents/task-router.md +1 -1
  326. package/presets/opencode/php-hexagonal/agents/tech-writer.md +1 -1
  327. package/presets/opencode/php-hexagonal/agents/unit-test-generator.md +1 -1
  328. package/presets/opencode/php-hexagonal/agents/unit-test-healer.md +1 -1
  329. package/presets/opencode/php-hexagonal/agents/unit-test-planner.md +1 -1
  330. package/presets/opencode/php-hexagonal/commands/task-continue.md +1 -1
  331. package/presets/opencode/php-hexagonal/hooks/README.md +11 -1
  332. package/presets/opencode/php-hexagonal/hooks/guard-shell-command.mjs +155 -0
  333. package/presets/opencode/php-hexagonal/plugins/rule-attach/globs.json +242 -0
  334. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
  335. package/presets/opencode/php-laravel/OPENCODE.md +5 -60
  336. package/presets/opencode/php-laravel/adapter-map.json +45 -45
  337. package/presets/opencode/php-laravel/agents/api-contract-reviewer.md +1 -1
  338. package/presets/opencode/php-laravel/agents/build-verifier.md +1 -1
  339. package/presets/opencode/php-laravel/agents/ci-investigator.md +1 -1
  340. package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -1
  341. package/presets/opencode/php-laravel/agents/codebase-analyzer.md +1 -1
  342. package/presets/opencode/php-laravel/agents/debugger.md +1 -1
  343. package/presets/opencode/php-laravel/agents/feature-developer.md +1 -1
  344. package/presets/opencode/php-laravel/agents/integration-test-generator.md +1 -1
  345. package/presets/opencode/php-laravel/agents/integration-test-healer.md +1 -1
  346. package/presets/opencode/php-laravel/agents/integration-test-planner.md +1 -1
  347. package/presets/opencode/php-laravel/agents/migration-specialist.md +1 -1
  348. package/presets/opencode/php-laravel/agents/openspec-author.md +1 -1
  349. package/presets/opencode/php-laravel/agents/performance-auditor.md +1 -1
  350. package/presets/opencode/php-laravel/agents/qa-tester.md +1 -1
  351. package/presets/opencode/php-laravel/agents/security-reviewer.md +1 -1
  352. package/presets/opencode/php-laravel/agents/solution-architect.md +1 -1
  353. package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
  354. package/presets/opencode/php-laravel/agents/task-router.md +1 -1
  355. package/presets/opencode/php-laravel/agents/tech-writer.md +1 -1
  356. package/presets/opencode/php-laravel/agents/unit-test-generator.md +1 -1
  357. package/presets/opencode/php-laravel/agents/unit-test-healer.md +1 -1
  358. package/presets/opencode/php-laravel/agents/unit-test-planner.md +1 -1
  359. package/presets/opencode/php-laravel/commands/task-continue.md +1 -1
  360. package/presets/opencode/php-laravel/hooks/README.md +11 -1
  361. package/presets/opencode/php-laravel/hooks/guard-shell-command.mjs +155 -0
  362. package/presets/opencode/php-laravel/plugins/rule-attach/globs.json +232 -0
  363. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +5 -5
  364. package/presets/opencode/platform-contract.json +4 -0
  365. package/presets/opencode/plugins/output-guard/README.md +1 -1
  366. package/presets/opencode/plugins/output-guard/index.ts +8 -2
  367. package/presets/opencode/plugins/output-guard/rewrite.ts +37 -0
  368. package/presets/opencode/plugins/rule-attach/README.md +34 -0
  369. package/presets/opencode/plugins/rule-attach/attach.ts +224 -0
  370. package/presets/opencode/plugins/rule-attach/index.ts +169 -0
  371. package/presets/opencode/plugins/rule-attach/package.json +9 -0
  372. package/presets/opencode/svelte/OPENCODE.md +5 -54
  373. package/presets/opencode/svelte/adapter-map.json +51 -51
  374. package/presets/opencode/svelte/agents/accessibility-reviewer.md +1 -1
  375. package/presets/opencode/svelte/agents/api-contract-reviewer.md +1 -1
  376. package/presets/opencode/svelte/agents/build-verifier.md +1 -1
  377. package/presets/opencode/svelte/agents/ci-investigator.md +1 -1
  378. package/presets/opencode/svelte/agents/code-reviewer.md +1 -1
  379. package/presets/opencode/svelte/agents/codebase-analyzer.md +1 -1
  380. package/presets/opencode/svelte/agents/debugger.md +1 -1
  381. package/presets/opencode/svelte/agents/feature-developer.md +1 -1
  382. package/presets/opencode/svelte/agents/migration-specialist.md +1 -1
  383. package/presets/opencode/svelte/agents/mockup-reviewer.md +1 -1
  384. package/presets/opencode/svelte/agents/openspec-author.md +1 -1
  385. package/presets/opencode/svelte/agents/performance-auditor.md +1 -1
  386. package/presets/opencode/svelte/agents/playwright-test-generator.md +1 -1
  387. package/presets/opencode/svelte/agents/playwright-test-healer.md +1 -1
  388. package/presets/opencode/svelte/agents/playwright-test-planner.md +1 -1
  389. package/presets/opencode/svelte/agents/qa-tester.md +1 -1
  390. package/presets/opencode/svelte/agents/security-reviewer.md +1 -1
  391. package/presets/opencode/svelte/agents/solution-architect.md +1 -1
  392. package/presets/opencode/svelte/agents/task-analyst.md +1 -1
  393. package/presets/opencode/svelte/agents/task-router.md +1 -1
  394. package/presets/opencode/svelte/agents/tech-writer.md +1 -1
  395. package/presets/opencode/svelte/agents/unit-test-generator.md +1 -1
  396. package/presets/opencode/svelte/agents/unit-test-healer.md +1 -1
  397. package/presets/opencode/svelte/agents/unit-test-planner.md +1 -1
  398. package/presets/opencode/svelte/commands/task-continue.md +1 -1
  399. package/presets/opencode/svelte/hooks/README.md +11 -1
  400. package/presets/opencode/svelte/hooks/guard-shell-command.mjs +153 -0
  401. package/presets/opencode/svelte/plugins/rule-attach/globs.json +245 -0
  402. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +5 -5
  403. package/presets/zcode/android-kotlin/adapter-map.json +1 -1
  404. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +3 -3
  405. package/presets/zcode/go/adapter-map.json +1 -1
  406. package/presets/zcode/go/rules/agent-team-orchestrator.md +3 -3
  407. package/presets/zcode/ios-swift/adapter-map.json +1 -1
  408. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +3 -3
  409. package/presets/zcode/java/adapter-map.json +1 -1
  410. package/presets/zcode/java/rules/agent-team-orchestrator.md +3 -3
  411. package/presets/zcode/mcp-ts/adapter-map.json +1 -1
  412. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +3 -3
  413. package/presets/zcode/mol/adapter-map.json +1 -1
  414. package/presets/zcode/mol/rules/agent-team-orchestrator.md +3 -3
  415. package/presets/zcode/next/adapter-map.json +1 -1
  416. package/presets/zcode/next/rules/agent-team-orchestrator.md +3 -3
  417. package/presets/zcode/nuxt/adapter-map.json +1 -1
  418. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +3 -3
  419. package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
  420. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +3 -3
  421. package/presets/zcode/php-laravel/adapter-map.json +1 -1
  422. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +3 -3
  423. package/presets/zcode/svelte/adapter-map.json +1 -1
  424. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +3 -3
  425. package/scripts/report-context-cost.mjs +1 -20
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.87
4
+
5
+ ### OpenCode attaches each stack's globs, and step cost stops double-counting
6
+
7
+ - **Per-stack rule catalog.** `rule-attach` `globs.json` is generated from that stack's Cursor frontmatter and installed ahead of the shared plugin tree. A Go test file matches `**/*_test.go`, not the Next unit-test glob.
8
+ - **Shell path tokens.** A `bash` / `shell` / `sh` command contributes path tokens. The command is not executed. A quoted sentence with spaces is not a path, and neither is `NAME=$var`.
9
+ - **Step cost.** Attempt windows are clipped at the next later start. Attempts that share a start (a parallel step or a ready wave) are one phase, so the row is counted once. Rows with no dedupe id stay in `unattributed` and in the totals for the host window; a session lease moves them to `excluded`. A chain invocation is a shell token that runs `chain-team-phases.sh`. When a session lease names the task, other sessions are excluded; otherwise the report says the window is the host ledger. The text table shows the attempt id.
10
+ - **Unfilled tier template.** An OpenCode install still seeds an empty `model-tiers.json`. While `tiers` and `approvedBy` are empty, the session model applies. After the map is approved, a declared tier with no mapping still stops with `model-tier-unmapped`.
11
+ - **Tooling tier.** `yarn test:tooling` lists 85 suites. The four added rows are rule-attach, the OpenCode text contract, the model-tiers seed, and the step-cost report. `release-gate` phase 2 names that count.
12
+
3
13
  ## 0.2.86
4
14
 
5
15
  ### Project entity: registry, migration 0011, seven routes, derived task attribution
@@ -97,6 +97,10 @@ const ENGINE_SCRIPTS = [
97
97
  'check-verification.mjs',
98
98
  // Append-only incident registry: recurrence threshold, promotion gate, advice.
99
99
  'incidents.mjs',
100
+ // Per-phase step cost for one task: turns, calls by tool and chain
101
+ // invocations, grouped by the attempt windows `metrics.json` records. Reads
102
+ // the output-guard ledgers and writes nothing, so it ships with the engine.
103
+ 'report-step-cost.mjs',
100
104
  ];
101
105
 
102
106
  /** Package `presets/`-relative directory holding the engine source of truth. */
@@ -422,6 +422,36 @@ function copyTemplates(presetTeamSrc, dest) {
422
422
  return written;
423
423
  }
424
424
 
425
+ /** The shared-asset tier map an OpenCode install seeds; other platforms pin in frontmatter. */
426
+ function modelTiersTemplate(presetTeamSrc) {
427
+ return path.resolve(path.dirname(presetTeamSrc), '..', '..', '_shared', 'assets', 'model-tiers.json');
428
+ }
429
+
430
+ /**
431
+ * Seed `.ai.local/team/model-tiers.json` for an OpenCode install, absent-only.
432
+ *
433
+ * The map names provider model ids only the consumer can approve, so this is
434
+ * the same contract as the research data beside it: a re-init never rewrites a
435
+ * file the consumer has filled in.
436
+ *
437
+ * @returns {string | null} the rel this call wrote
438
+ */
439
+ function seedModelTiers(presetTeamSrc, dest, source) {
440
+ if (!presetTeamSrc || typeof source !== 'string' || !source.startsWith('opencode/')) {
441
+ return null;
442
+ }
443
+ const template = modelTiersTemplate(presetTeamSrc);
444
+ if (!fs.existsSync(template)) {
445
+ return null;
446
+ }
447
+ const target = path.join(dest, 'model-tiers.json');
448
+ if (fs.existsSync(target)) {
449
+ return null;
450
+ }
451
+ copyFile(template, target);
452
+ return '.ai.local/team/model-tiers.json';
453
+ }
454
+
425
455
  /**
426
456
  * Seed `.ai.local/conventions.md` (the living-conventions file the overlay probes)
427
457
  * from the preset template. Never overwrites an existing consumer file.
@@ -704,7 +734,7 @@ function migrateLegacyTeams(cwd, dest) {
704
734
  *
705
735
  * @returns {Map<string, Buffer>} rel → template bytes
706
736
  */
707
- function templateEntries(presetTeamSrc) {
737
+ function templateEntries(presetTeamSrc, source) {
708
738
  const out = new Map();
709
739
  const addFile = (rel, abs) => {
710
740
  let stat;
@@ -752,6 +782,11 @@ function templateEntries(presetTeamSrc) {
752
782
  addFile(`.ai.local/scripts/${name}`, path.join(engineDir, name));
753
783
  }
754
784
  }
785
+ // OpenCode resolves a tier through the map; the file is a template byte there
786
+ // so a consumer edit reports drift instead of being rewritten by a re-init.
787
+ if (typeof source === 'string' && source.startsWith('opencode/')) {
788
+ addFile('.ai.local/team/model-tiers.json', modelTiersTemplate(presetTeamSrc));
789
+ }
755
790
  out.set('.ai.local/.gitignore', Buffer.from(AI_LOCAL_GITIGNORE));
756
791
  return out;
757
792
  }
@@ -817,6 +852,7 @@ function seedAiLocalTeam({ cwd, presetTeamSrc, source, packageVersion, mergeAiLo
817
852
  ];
818
853
  const migrated = migrateLegacyTeams(cwd, dest);
819
854
  const templateWritten = copyTemplates(presetTeamSrc, dest);
855
+ const modelTiersRel = seedModelTiers(presetTeamSrc, dest, source);
820
856
  const conventionsRel = seedConventions(presetTeamSrc, cwd);
821
857
  const rulesSeed = seedAiLocalRules(presetTeamSrc, cwd);
822
858
  const rulesLibrarySeeded = rulesSeed.seeded;
@@ -826,6 +862,7 @@ function seedAiLocalTeam({ cwd, presetTeamSrc, source, packageVersion, mergeAiLo
826
862
 
827
863
  const written = [
828
864
  ...templateWritten,
865
+ ...(modelTiersRel ? [modelTiersRel] : []),
829
866
  ...(conventionsRel ? [conventionsRel] : []),
830
867
  ...rulesSeed.written,
831
868
  ...engine.written,
@@ -834,7 +871,7 @@ function seedAiLocalTeam({ cwd, presetTeamSrc, source, packageVersion, mergeAiLo
834
871
  runTemplateDrift({
835
872
  cwd,
836
873
  written,
837
- templates: templateEntries(presetTeamSrc),
874
+ templates: templateEntries(presetTeamSrc, source),
838
875
  source,
839
876
  packageVersion,
840
877
  mergeAiLocal,
@@ -98,8 +98,9 @@ function buildPlan({ contract, sourceBase, sharedSourceBase, cwd }) {
98
98
  }
99
99
  }
100
100
 
101
- // Shared platform assets (for example the TUI plugins) live beside the stack
102
- // directories, so every released preset installs the same copy.
101
+ // Stack directory mappings run first. A stack `plugins/rule-attach/globs.json`
102
+ // therefore wins over the shared plugin tree; every other plugin file still
103
+ // comes from the shared copy.
103
104
  for (const mapping of contract.sharedDirectoryMappings || []) {
104
105
  const sourceDir = path.join(sharedSourceBase, mapping.source);
105
106
  if (!fs.existsSync(sourceDir)) {
@@ -30,14 +30,14 @@ Allowed status values are `confirmed`, `partial`, `unknown`, `manual`, and `no-e
30
30
  | Explicit role file | `confirmed` | opencode.ai/docs/agents | `.opencode/agents/<name>.md` | Native `@name` / Task |
31
31
  | Deterministic structured output | `unknown` | no probe | — | Do not require a JSON schema from agents |
32
32
  | `opencode` `/init` | `unknown` | docs describe `/init`; not used by this package | TTY / interactive | Use `ai-rules init opencode` |
33
- | Project rule discovery (no reference) | `no-equivalent` | no `.opencode/rules` alwaysApply/globs engine | `.mdc` globs do not exist | Lazy `Read` from `AGENTS.md` catalog |
33
+ | Project rule discovery (no reference) | `no-equivalent` | no `.opencode/rules` alwaysApply/globs engine | `.mdc` globs do not exist | `rule-attach` plugin injects a matched stem; the four essential rules stay in `opencode.json` `instructions` |
34
34
  | Project rule discovery (explicit root reference) | `confirmed` | docs “Referencing External Files” | Agent can `Read` listed paths | Essential four rules in `AGENTS.md` |
35
35
  | Workspace agent discovery | `confirmed` | opencode.ai/docs/agents | `.opencode/agents/` | Native |
36
36
  | Workspace Skill discovery | `confirmed` | opencode.ai/docs/skills | `.opencode/skills/<name>/SKILL.md` | Native `skill` tool |
37
37
  | Project MCP | `confirmed` | opencode.ai/docs/mcp-servers | `opencode.json` `mcp` | Merge on init |
38
- | TUI plugin discovery | `confirmed` | opencode.ai/docs/plugins | `.opencode/plugins/<name>/` loads automatically | Ships `task-status` TUI sidebar |
38
+ | TUI plugin discovery | `confirmed` | opencode.ai/docs/plugins | `.opencode/plugins/<name>/` loads automatically | Ships `task-status` TUI sidebar, `output-guard`, `rule-attach` |
39
39
  | Tool-output guard (server plugin) | `confirmed` | opencode.ai/docs/build/plugins/server + live probe 2026-11-13 | `ctx.session.hook("context")` mutates assembled messages before dispatch | Ships `output-guard`; a host without the hook no-ops |
40
- | Project hooks (`hooks.json`) | `manual` | plugins exist; this preset ships a TUI viewer, not a hook plugin | No confirmed `subagentStop` analog was opened | Manual `chain-team-phases.sh` |
40
+ | Project hooks (`hooks.json`) | `manual` | probe 2026-11-25 on OpenCode v2.4.1: `ctx.session.hook` dispatches `context` / `compaction` / `generate` / `prompt` and passes other names through unvalidated to a bus nothing triggers; no `subagentStop`, and `tool.execute.after` produced 0 timing rows in 32,841 ledger rows (575 `subagent` calls) | The event that would end a step carries no attemptId | Manual `chain-team-phases.sh` |
41
41
  | Slash commands | `confirmed` | opencode.ai/docs/commands | `.opencode/commands/<name>.md` | Native `/task` |
42
42
  | Plugin / skill / MCP combo | `confirmed` | skills + mcp docs | MCP inflates context | Gate unused servers in operator config |
43
43
  | Native Team lifecycle | `partial` | file pipeline is ai-rules SoT | No native team runtime | Hook owns `status.json` / `metrics.json` |
@@ -45,9 +45,11 @@ Allowed status values are `confirmed`, `partial`, `unknown`, `manual`, and `no-e
45
45
 
46
46
  ## What we do not claim
47
47
 
48
- - Cursor `alwaysApply` / `globs` on OpenCode
48
+ - Cursor `alwaysApply` / `globs` on OpenCode (the `rule-attach` plugin reproduces the outcome, not the mechanism)
49
49
  - Claude topic-folder twins as the OpenCode source
50
50
  - Auto-registration of `hooks.json` or a hook plugin in v1
51
+ - A plugin-side `subagentStop` / `tool.execute.*` event: the name is not on the
52
+ host's plugin bus, so the chain stays manual
51
53
  - `init opencode --dry-run` / manifest preview (v1 is apply + rollback only)
52
54
  - Writes to `~/.config/opencode/**` or `~/.opencode/**`
53
55
 
package/docs/OPENCODE.md CHANGED
@@ -45,14 +45,14 @@ OpenCode has **no** `.mdc` `alwaysApply` / `globs` engine. The preset uses three
45
45
  |-----------|------|----------|
46
46
  | Root `AGENTS.md` + `.opencode/AGENTS.md` | Always-on core (essential rules + entry maps) for the **parent** | yes |
47
47
  | `opencode.json` `instructions` | Compact hedge (`alwaysOn` paths + `.opencode/AGENTS.md`) for the **parent**; re-init unions preset paths into the consumer list | V1 yes, V2 uncertain (kept narrow) |
48
- | `## Rules to load (subagent context)` block in every `.opencode/agents/*.md` | Authoritative for **subagents** (`Task`/`@name`); alwaysOn + stack zone rules filtered to existing stems | yes |
48
+ | `## Rules to load (subagent context)` block in every `.opencode/agents/*.md` | Authoritative for **subagents** (`Task`/`@name`); alwaysOn + stack zone rules filtered to existing stems. A stem `rule-attach` already attached need not be Read again | yes |
49
49
 
50
50
  `bin/opencode-install.js` `mergeOpencodeConfig` on re-init **unions** preset `instructions` paths into the existing list, **fills missing** `permission.bash` keys, and re-applies the universal `git commit` / `git push` deny rows even when the consumer file already set that key. Other bash keys stay consumer-wins. An empty `instructions: []` receives the preset paths. A non-array `instructions` value is left as-is. A top-level `policies` array is not a tool deny; re-init leaves it untouched. The v1 tool key is `bash` ([permissions](https://opencode.ai/docs/permissions/)). v2 is a different document: a `permissions` array whose action is `shell`. This preset emits the v1 object, not `permission.shell`.
51
51
 
52
52
  | Kind | How it loads |
53
53
  |------|----------------|
54
54
  | Essential rules | Root `AGENTS.md` + `.opencode/AGENTS.md` list four paths — **Read immediately** |
55
- | Other rules | Lazy `Read` of `.opencode/rules/<stem>.md` when the task matches |
55
+ | Other rules | `rule-attach` injects stems whose stack `globs.json` matches a touched path, including a path token in a `bash` or `shell` command. The catalog is that stack's Cursor `globs:`. A stem with no glob stays a lazy `Read` |
56
56
  | Agents | Native `.opencode/agents/*.md` (`@name` / Task). `mode: subagent`. Each ships the **rules-to-load block** so subagents see the always-on + zone set |
57
57
  | MCP | `opencode.json` `mcp` — preset ships context7 / playwright / chrome-devtools / figma; merge keeps extras |
58
58
  | Harness enforcement | `opencode.json` `permission.bash` — universal `git commit/push deny` + JS-stack `npm/npx/pnpm/bun ask` + `npx jest* deny`. An agent-level `permission` block can override the global map |
@@ -62,7 +62,7 @@ OpenCode has **no** `.mdc` `alwaysApply` / `globs` engine. The preset uses three
62
62
 
63
63
  **Every turn:** read root `AGENTS.md`, then `.opencode/AGENTS.md`, then the four essential rules. Probe `.ai.local` (see [`LOCAL-OVERLAY.md`](./LOCAL-OVERLAY.md)).
64
64
 
65
- Do not pin a provider model in agent frontmatter. A tier resolves through `.ai.local/team/model-tiers.json` when that file exists; otherwise the session model applies.
65
+ Do not pin a provider model in agent frontmatter. `init` seeds `.ai.local/team/model-tiers.json` absent-only with an empty `tiers` map and an empty `approvedBy`. That template is not a map yet: the session model applies. After `approvedBy` or any tier is set, a declared tier with no mapping stops the step with `model-tier-unmapped`. A re-init leaves a filled file byte-identical.
66
66
 
67
67
  ## Task pipeline (semi-auto)
68
68
 
@@ -78,7 +78,7 @@ printf '%s\n' '{"status":"completed","attemptId":"<from-status.json>"}' \
78
78
  | TEAM_TASK_SLUG=<slug> bash .opencode/hooks/chain-team-phases.sh
79
79
  ```
80
80
 
81
- Human gates pause with `awaitingHumanGate: true`. Resume with `/task-continue`. There is **no** shipped `hooks.json`; the shipped OpenCode plugins are the TUI viewer and the output guard.
81
+ Human gates pause with `awaitingHumanGate: true`. Resume with `/task-continue`. There is **no** shipped `hooks.json`: on OpenCode v2.4.1 `ctx.session.hook` dispatches `context` / `compaction` / `generate` / `prompt` only, so no plugin observes a subagent return and the chain stays a manual run. The shipped plugins are `task-status` (TUI), `output-guard` (compaction) and `rule-attach` (path-glob rule delivery).
82
82
 
83
83
  Full team layout: `.ai.local/team/README.md`.
84
84
 
@@ -90,6 +90,9 @@ dispatch. A `tool-result` over 8 KB is written to
90
90
  `.ai.local/team/output-guard/<sessionID>/outputs/` and replaced with a bounded
91
91
  head + tail. The 8–20 KB band uses the structured shape: a whole-line gap is a `sed -n` range, a mid-line cut is a `tail -c` byte window, and JSON keys are listed only when they sit in that gap. Above 20 KB stays the flat renderer.
92
92
  `AI_RULES_OUTPUT_GUARD_SHAPE=flat` forces the flat renderer inside the band.
93
+ A `read` of `.opencode/rules/**` or `.ai.local/rules/**` is never replaced: a rule
94
+ is the instruction the agent follows, and a compacted rule is a contract read at
95
+ a fraction of its bytes. Every other `read` stays guarded.
93
96
  It works for every prompt,
94
97
  including one without `/task`.
95
98
 
@@ -135,7 +138,7 @@ Labels from official OpenCode docs (live CLI probe not yet run). Full matrix: [`
135
138
  | Root `AGENTS.md` | **confirmed** (docs) | Native always-on; reference rules explicitly |
136
139
  | `.opencode/agents` / `skills` / `commands` | **confirmed** (docs) | Native discovery |
137
140
  | `opencode.json` MCP | **confirmed** (docs) | Merge `mcp` |
138
- | Glob / alwaysApply rules | **no-equivalent** | Lazy Read catalog under `.opencode/rules/` |
141
+ | Glob / alwaysApply rules | **no-equivalent** | No host glob engine; `rule-attach` injects the stems whose stack `globs.json` matches a touched path (file tools and a `bash`/`shell` path token), and a stem with no glob stays a lazy Read |
139
142
  | `hooks.json` / subagentStop | **manual** | `TEAM_TASK_SLUG=<slug> bash .opencode/hooks/chain-team-phases.sh` after receipts; the `task-status` TUI plugin is a viewer, not a hook |
140
143
  | Native Team lifecycle | **partial** | File pipeline is SoT; hook is single lifecycle writer |
141
144
 
@@ -433,8 +433,8 @@ uses the carrier instead of printing.
433
433
  | `scripts/check-preset-self-review-contract.sh` / `yarn check:preset-structure` | **FAIL** if the producer-side self-review / context-hygiene contract is absent: the core `_shared/core/quality/self-review-and-context-hygiene.md` tokens (G0 non-vacuous guard), the `<!-- shared-core: quality/self-review-and-context-hygiene.md -->` marker on `task-analyst` / `feature-developer` / `build-verifier` (×10) and on `debugger` / `code-reviewer` where present (skip-if-absent → `mcp-ts`), the `Self-review` + `re-anchor` tokens on every orchestrator rule, `Self-review` in `team/README.md` + `commands/task.md`, and leakage-free core + docs; **refuses vacuous PASS** when the iteration set is empty. Also holds two prose contracts: the canonical self-learning-loop sentence must not be followed by unsanctioned prose (an allowlist of sanctioned clauses; the tail is bounded by the carrier's **section**, not by a blank line, so prose moved one paragraph down still fails — a tail in a later `## ` section is out of scope), and every retro carrier (command, skill, rule) must state `finding_category`. Wired into `check-preset-structure.sh` next to `goal-contract`; fixture `test-preset-self-review-contract-fixtures.mjs`. |
434
434
  | `scripts/check-anti-hallucination-coverage.mjs` | **FAIL** when the shared contract, a Cursor load-line embed, a writer stack floor, or a generated Rules-to-load stem is missing. Writer roles are `implementer`, `unit-test`, `e2e`, `qa`, and `reviewer` (`code-reviewer` loads `STACK_FLOOR_STEMS` plus the contract). `/task` and the orchestrator must not name a floor stem. Does not scan consumer `app/**` and does not call Context7. Fixture `test-anti-hallucination-coverage.mjs` deletes `anti-hallucination-contract` from `next.reviewer` in memory and expects FAIL mentioning `next` and `reviewer`. Wired into `check-preset-structure.sh` immediately after `check-claude-agent-blocks.mjs`. |
435
435
  | `presets/_shared/ai-local/scripts/check-write-scope.mjs` | Read-only post-step audit: compares the actual changed paths with the current `pipeline.json` step's `writeScopes` and labels each path `declared`, `derived` (task folder, engine mirror, generated platform tree/golden/hook, dogfood tree, adapter map), or `out-of-scope`, with the source named. Shipped to consumers as `.ai.local/scripts/check-write-scope.mjs` (`ENGINE_SCRIPTS`). `--slug <slug> [--step <id>] [--base <ref>] [--root <project>] [--paths a,b] [--save-baseline] [--json]`. Baseline resolution: `--paths`, then `--base <ref>`, then the step baseline written by `--step <id> --save-baseline` (every dirty path with its content hash, plus the files its declared `writeScopes` cover — passed as `--paths` — so a step armed on a clean tree still owns its surface), then `HEAD` (whole uncommitted change-set, reported with a notice). Exit `1` for an out-of-scope path on an implementation step, `0` for a reviewer/verifier step (advisory), `2` on a usage/config error, `3` (SKIP) when the pipeline predates step ids or `writeScopes` and is therefore not auditable. Fixture `test-write-scope.mjs`; wired into the build-verifier and code-reviewer prompts, never a hook. |
436
- | `scripts/check-preset-structure.sh` / `yarn check:preset-structure` | Low-level orchestrator: twin-map + token-budget + leakage + shared-core drift + anti-hallucination coverage + rule-eval (**all hard**; drift via `AI_RULES_DRIFT_FAIL=1`). Runs the 54 preset checks only (~2 min); `--list` prints their labels. Invoked by `yarn release:gate` and CI; not a feature-task gate. |
437
- | `scripts/run-tooling-tests.sh` / `yarn test:tooling` | The tooling self-test tier: the 81 `test-*` suites that guard the preset tooling itself (preset fixtures, CLI install, team-db, hook lifecycle, contract guards, tooling core). One command, one exit code, ~21 min; `--list` prints the 81 labels. Reached through `run-locked.mjs --label test:tooling`, so it holds the same `preset-tree-lock` as the composite; a direct `bash` run warns that it holds none. Its failures are downgraded only by `scripts/_lib/structure-known-failures.json`, and it is the second phase of `yarn release:gate`. CI runs it from the `tooling-suites` job when the change-set touches the tooling domains (`ci-tooling-tier-gate.sh`). |
436
+ | `scripts/check-preset-structure.sh` / `yarn check:preset-structure` | Low-level orchestrator: twin-map + token-budget + leakage + shared-core drift + anti-hallucination coverage + rule-eval (**all hard**; drift via `AI_RULES_DRIFT_FAIL=1`). Runs the 52 preset checks only (~2 min); `--list` prints their labels. Invoked by `yarn release:gate` and CI; not a feature-task gate. |
437
+ | `scripts/run-tooling-tests.sh` / `yarn test:tooling` | The tooling self-test tier: the 85 `test-*` suites that guard the preset tooling itself (preset fixtures, CLI install, team-db, hook lifecycle, contract guards, tooling core). One command, one exit code, ~21 min; `--list` prints the 85 labels. Reached through `run-locked.mjs --label test:tooling`, so it holds the same `preset-tree-lock` as the composite; a direct `bash` run warns that it holds none. Its failures are downgraded only by `scripts/_lib/structure-known-failures.json`, and it is the second phase of `yarn release:gate`. CI runs it from the `tooling-suites` job when the change-set touches the tooling domains (`ci-tooling-tier-gate.sh`). |
438
438
  | `scripts/check-product-specs.sh` / `yarn check:product-specs` | Opt-in consumer tree check: frontmatter v1 keys + required body headings on `docs/specs/**` (bash; does **not** run JSON Schema). Ships in the npm package `files` (`scripts/`). **WARN** by default; **`--strict`** exits non-zero. |
439
439
  | `yarn check:product-specs:dogfood` | Same script against monorepo `dogfood/mcp-ts-sample`. Soft WARN inside the composite + CI step (`continue-on-error`); the release gate runs `--strict`; not a hard consumer CI gate. |
440
440
  | `scripts/check-rule-eval.mjs` / `yarn check:rule-eval` | **Hard gate** inside `check-preset-structure.sh`: validates Incorrect/Correct pairs + `impact:` on **next-only** golden stems (`eval/next/manifest.json`). Backend / ios / php-hexagonal / php-laravel stems are out of scope until a stack adds `eval/<stack>/`. |
@@ -449,9 +449,9 @@ The ladder, one composite run per change-set:
449
449
  1. **Targeted (seconds):** `node scripts/check-preset-twin-drift.mjs`, `check-claude-agent-parity.mjs`, `test-cli-init-clean.mjs`, `test-generated-cache.mjs` — a source edit that is not mirrored in the Claude twin fails here, not after the ~2-minute composite, and not 21 minutes into `yarn test:tooling`.
450
450
  2. **Regenerate:** `yarn fix:generated` after a source or generator edit; it rewrites every platform stack and the CLI goldens.
451
451
  3. **Classified:** `yarn check:changed` — the classifier names the gates the change-set affects.
452
- 4. **Composite, once:** `bash scripts/check-preset-structure.sh` after the last edit. `--fail-fast` stops at the first failure the allowlist does not declare (a known one is printed and the sweep continues), `--list` prints the 54 preset checks, and a single gate is its own script under `scripts/` — run that directly rather than filtering the composite. The 81 tooling self-test suites (`test-*`) run from `yarn test:tooling` (~23 min, one command, one exit code); `--list` on `scripts/run-tooling-tests.sh` prints those 81 labels. The union of the two label sets is the 135 the two entry points now carry (134 before `structure-output-contract fixtures` was added), pinned by `test-structure-tier-partition.mjs`.
452
+ 4. **Composite, once:** `bash scripts/check-preset-structure.sh` after the last edit. `--fail-fast` stops at the first failure the allowlist does not declare (a known one is printed and the sweep continues), `--list` prints the 52 preset checks, and a single gate is its own script under `scripts/` — run that directly rather than filtering the composite. The 85 tooling self-test suites (`test-*`) run from `yarn test:tooling` (~23 min, one command, one exit code); `--list` on `scripts/run-tooling-tests.sh` prints those 85 labels. The union of the two label sets is the 137 the two entry points now carry, pinned by `test-structure-tier-partition.mjs`.
453
453
 
454
- The composite exits 0 when every failure is already listed in `scripts/_lib/structure-known-failures.json` (each entry carries owner, reason, and date). A known failure that starts passing prints a stale-entry warning and the aggregate exits 1, so the row cannot hide the next regression. Both entry points read that file, but each tier reports only its own labels: the composite prints one `NOTE:` line for an allowlisted suite that belongs to the tooling tier, and `yarn test:tooling` owns the stale-entry warning for its 81. A malformed allowlist exits 2. Two runs may fill the same cache key at once — `generated-cache.mjs` publishes with one rename — while the preset-tree lock still keeps a gate away from a running `fix:generated`.
454
+ The composite exits 0 when every failure is already listed in `scripts/_lib/structure-known-failures.json` (each entry carries owner, reason, and date). A known failure that starts passing prints a stale-entry warning and the aggregate exits 1, so the row cannot hide the next regression. Both entry points read that file, but each tier reports only its own labels: the composite prints one `NOTE:` line for an allowlisted suite that belongs to the tooling tier, and `yarn test:tooling` owns the stale-entry warning for its 85. A malformed allowlist exits 2. Two runs may fill the same cache key at once — `generated-cache.mjs` publishes with one rename — while the preset-tree lock still keeps a gate away from a running `fix:generated`.
455
455
 
456
456
  Run from `packages/ai-rules/`:
457
457
 
@@ -473,12 +473,12 @@ Iteration versus release:
473
473
  - **`yarn check:task <slug>`** — the task-scoped classifier (`check-preset-delta.mjs --since-task <slug>`). It reads `.ai.local/team/.write-scope/<slug>/*.json`, unions the step baselines, and returns only this task's change-set; `--save-baseline` snapshots an inline task before its first write. A missing baseline falls back to `--base HEAD` with a warning.
474
474
  - **`yarn check:changed`** — the repo-wide classifier (`check-preset-delta.mjs --base HEAD`, or `--paths a,b`). Use it on a clean tree or pass the task paths explicitly; otherwise earlier uncommitted batches are attributed to this task. It prints `affected loop gates` and a separate `release-only gates` line.
475
475
  - **`yarn check:fast`** — the fallback gate (`check-preset-fast.sh`: the content floor — twin map, twin drift, generated drift, semantic parity, token budget, leakage, frontmatter — plus frontmatter dogfood, consumer links, next attached budget, and the OpenCode platform-contract self-test). Run it only when the classifier names no gate. A `preset-content` diff names that floor plus the path slice for the file that changed: hooks also name chain-hook coverage and hook-token lock, a router edit names parallel-plan, and preset prose names hard i18n. `test-cli-init-clean` stays on `preset-install` / `preset-generator` and in `yarn test:tooling`, not on a rule edit.
476
- - **`yarn release:gate`** — the full release gate, four phases: `preset-structure` (the 54 preset checks), `tooling-tests` (`yarn test:tooling`, the 81 tooling suites — `AI_RULES_SKIP_HOOK_TESTS` / `AI_RULES_SKIP_PACK_TESTS` are refused), `test:ai-local`, and the strict product-specs dogfood. Each phase writes its own `exit`, so a red tooling suite fails the release without hiding a green preset tier. Run it alone on the release commit before a tag.
476
+ - **`yarn release:gate`** — the full release gate, four phases: `preset-structure` (the 52 preset checks), `tooling-tests` (`yarn test:tooling`, the 85 tooling suites — `AI_RULES_SKIP_HOOK_TESTS` / `AI_RULES_SKIP_PACK_TESTS` are refused), `test:ai-local`, and the strict product-specs dogfood. Each phase writes its own `exit`, so a red tooling suite fails the release without hiding a green preset tier. Run it alone on the release commit before a tag.
477
477
  - **`yarn check:preset-structure`** — the low-level composite; CI and `release:gate` call it. It runs the preset tier only. Do not run it in a feature task.
478
478
 
479
479
  `check-generated-drift` caches generated trees in the OS temp directory, keyed by a digest of the Cursor/`_shared` sources and the generator libraries. A source or generator edit misses the cache and regenerates; the cache is disposable and never hides drift.
480
480
 
481
- CI: [`.github/workflows/preset-structure.yml`](../../../.github/workflows/preset-structure.yml) runs the 54 preset checks on PRs touching `packages/ai-rules/**`; its `classify` job reads the change-set domains from `check-preset-delta.mjs` and the `tooling-suites` job runs `yarn test:tooling` only when they touch `preset-tooling`, `preset-generator`, `preset-install`, `preset-engine`, or `team-db` (a prose-only `preset-content` change stays on the 54-check job; a skip is announced in the job summary). The other workflows in `.github/workflows/`: `platform-smoke.yml` (3-OS smoke: `init multi`, `update`, `doctor`, platform suites, script gate), `rule-eval.yml` (opt-in next rule-eval via `scripts/check-rule-eval.mjs`), `team-tasks-ui.yml` (lint, type-check, and unit tests for `apps/team-tasks-ui`; no e2e), and `release-gate.yml` (`yarn release:gate` on a `v*` tag or a chosen ref; uploads the `.release-gate/` report as an artifact).
481
+ CI: [`.github/workflows/preset-structure.yml`](../../../.github/workflows/preset-structure.yml) runs the 52 preset checks on PRs touching `packages/ai-rules/**`; its `classify` job reads the change-set domains from `check-preset-delta.mjs` and the `tooling-suites` job runs `yarn test:tooling` only when they touch `preset-tooling`, `preset-generator`, `preset-install`, `preset-engine`, or `team-db` (a prose-only `preset-content` change stays on the 52-check job; a skip is announced in the job summary). The other workflows in `.github/workflows/`: `platform-smoke.yml` (3-OS smoke: `init multi`, `update`, `doctor`, platform suites, script gate), `rule-eval.yml` (opt-in next rule-eval via `scripts/check-rule-eval.mjs`), `team-tasks-ui.yml` (lint, type-check, and unit tests for `apps/team-tasks-ui`; no e2e), and `release-gate.yml` (`yarn release:gate` on a `v*` tag or a chosen ref; uploads the `.release-gate/` report as an artifact).
482
482
 
483
483
  ---
484
484
 
@@ -105,6 +105,26 @@ The OpenCode row counts `instructions` only; the root `AGENTS.md` is loaded nati
105
105
 
106
106
  Re-run the command for the current tree; these numbers move with any rule edit.
107
107
 
108
+ ## Step cost
109
+
110
+ Bytes are the fixed part; `report-step-cost.mjs` counts the per-run part — how
111
+ many turns and tool calls each pipeline phase spent, and how many of those calls
112
+ were the manual `chain-team-phases.sh` step:
113
+
114
+ ```bash
115
+ node .ai.local/scripts/report-step-cost.mjs --task <slug> --json
116
+ ```
117
+
118
+ The phases are the task's own `attempt_started` / `attempt_finished` windows from
119
+ `metrics.json`, clipped so they do not overlap. Attempts that share a start are
120
+ one phase. The counts are the deduped `usage.jsonl` turns and `results.jsonl`
121
+ tool calls inside each window. A row with no id stays in `unattributed` for the
122
+ host window; a session lease moves it to `excluded` with the other sessions.
123
+ With no lease the text says the window is the whole host ledger. A chain
124
+ invocation is a shell command that runs the script. A task with no ledger rows
125
+ prints zeros. Read-only, writes nothing. This is the before/after measure for
126
+ the step-count work; it is not a latency claim.
127
+
108
128
  ## Bytes are not tokens
109
129
 
110
130
  `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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonesofspring/ai-rules",
3
- "version": "0.2.86",
3
+ "version": "0.2.87",
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",