@bonesofspring/ai-rules 0.2.86 → 0.2.90

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 (742) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +9 -1
  3. package/bin/lib/engine-scripts.js +11 -0
  4. package/bin/lib/seed-ai-local-team.js +79 -2
  5. package/bin/opencode-install.js +14 -12
  6. package/docs/OPENCODE-COMPATIBILITY.md +6 -4
  7. package/docs/OPENCODE.md +15 -8
  8. package/docs/PRESET-CONTRIBUTION.md +6 -6
  9. package/docs/TOKEN-ECONOMY.md +20 -0
  10. package/docs/openapi/team-db.v1.json +2 -2
  11. package/package.json +1 -1
  12. package/presets/_shared/ai-local/env.example +54 -0
  13. package/presets/_shared/ai-local/scripts/aggregate-agent-task-metrics.mjs +34 -5
  14. package/presets/_shared/ai-local/scripts/check-task-repositories.mjs +25 -22
  15. package/presets/_shared/ai-local/scripts/process-lease.mjs +3 -2
  16. package/presets/_shared/ai-local/scripts/processes.mjs +52 -20
  17. package/presets/_shared/ai-local/scripts/report-step-cost.mjs +544 -0
  18. package/presets/_shared/ai-local/scripts/run.mjs +38 -6
  19. package/presets/_shared/ai-local/scripts/settings.mjs +246 -0
  20. package/presets/_shared/ai-local/scripts/task-worktree.mjs +364 -0
  21. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +2 -2
  22. package/presets/_shared/ai-local/scripts/team-db-project.mjs +87 -14
  23. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +102 -12
  24. package/presets/_shared/ai-local/scripts/team-db-tracker.mjs +35 -0
  25. package/presets/_shared/ai-local/scripts/tracker-planned-drain.mjs +10 -1
  26. package/presets/_shared/ai-local/scripts/verification.mjs +106 -11
  27. package/presets/_shared/assets/model-tiers.json +6 -0
  28. package/presets/_shared/core/agent-team/agent-task-metrics.md +10 -2
  29. package/presets/_shared/core/agent-team/agent-team-intake.md +2 -0
  30. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +5 -5
  31. package/presets/_shared/core/meta/preset-writing-style.md +8 -0
  32. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +541 -61
  33. package/presets/_shared/hooks/guard-shell-command.mjs.tmpl +841 -97
  34. package/presets/_shared/hooks/prompt-autoroute.mjs.tmpl +153 -0
  35. package/presets/claude/android-kotlin/CLAUDE.md +2 -4
  36. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +541 -61
  37. package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +841 -97
  38. package/presets/claude/android-kotlin/hooks/prompt-autoroute.mjs +153 -0
  39. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-intake.md +2 -0
  40. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  41. package/presets/claude/android-kotlin/rules/tooling-and-review/preset-writing-style.md +8 -0
  42. package/presets/claude/android-kotlin/settings.json +15 -5
  43. package/presets/claude/go/CLAUDE.md +2 -4
  44. package/presets/claude/go/hooks/chain-team-phases.sh +541 -61
  45. package/presets/claude/go/hooks/guard-shell-command.mjs +841 -97
  46. package/presets/claude/go/hooks/prompt-autoroute.mjs +153 -0
  47. package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +2 -0
  48. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  49. package/presets/claude/go/rules/tooling-and-review/preset-writing-style.md +8 -0
  50. package/presets/claude/go/settings.json +15 -5
  51. package/presets/claude/ios-swift/CLAUDE.md +2 -4
  52. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +541 -61
  53. package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +841 -97
  54. package/presets/claude/ios-swift/hooks/prompt-autoroute.mjs +153 -0
  55. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +2 -0
  56. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  57. package/presets/claude/ios-swift/rules/tooling-and-review/preset-writing-style.md +8 -0
  58. package/presets/claude/ios-swift/settings.json +15 -5
  59. package/presets/claude/java/CLAUDE.md +2 -4
  60. package/presets/claude/java/hooks/chain-team-phases.sh +541 -61
  61. package/presets/claude/java/hooks/guard-shell-command.mjs +841 -97
  62. package/presets/claude/java/hooks/prompt-autoroute.mjs +153 -0
  63. package/presets/claude/java/rules/tooling-and-review/agent-team-intake.md +2 -0
  64. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  65. package/presets/claude/java/rules/tooling-and-review/preset-writing-style.md +8 -0
  66. package/presets/claude/java/settings.json +15 -5
  67. package/presets/claude/mcp-ts/CLAUDE.md +2 -4
  68. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +541 -61
  69. package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +841 -97
  70. package/presets/claude/mcp-ts/hooks/prompt-autoroute.mjs +153 -0
  71. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +2 -0
  72. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  73. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-writing-style.md +8 -0
  74. package/presets/claude/mcp-ts/settings.json +15 -5
  75. package/presets/claude/mol/CLAUDE.md +2 -4
  76. package/presets/claude/mol/agents/feature-developer.md +1 -1
  77. package/presets/claude/mol/ai-local/rules-library/commit-hygiene.md +1 -1
  78. package/presets/claude/mol/commands/task-evil.md +8 -0
  79. package/presets/claude/mol/hooks/chain-team-phases.sh +541 -61
  80. package/presets/claude/mol/hooks/guard-shell-command.mjs +841 -97
  81. package/presets/claude/mol/hooks/prompt-autoroute.mjs +153 -0
  82. package/presets/claude/mol/rules/tooling-and-review/agent-team-intake.md +2 -0
  83. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  84. package/presets/claude/mol/rules/tooling-and-review/preset-writing-style.md +8 -0
  85. package/presets/claude/mol/settings.json +15 -4
  86. package/presets/claude/next/CLAUDE.md +2 -4
  87. package/presets/claude/next/REPO_AGENTS.md +2 -0
  88. package/presets/claude/next/agents/feature-developer.md +1 -1
  89. package/presets/claude/next/agents/task-analyst.md +1 -7
  90. package/presets/claude/next/agents/task-router.md +1 -1
  91. package/presets/claude/next/ai-local/rules-library/commit-hygiene.md +1 -1
  92. package/presets/claude/next/commands/spec-start.md +3 -4
  93. package/presets/claude/next/commands/task-continue.md +9 -8
  94. package/presets/claude/next/commands/task-evil.md +8 -0
  95. package/presets/claude/next/commands/task.md +1 -1
  96. package/presets/claude/next/hooks/chain-team-phases.sh +541 -61
  97. package/presets/claude/next/hooks/guard-shell-command.mjs +841 -97
  98. package/presets/claude/next/hooks/prompt-autoroute.mjs +153 -0
  99. package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +2 -0
  100. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  101. package/presets/claude/next/rules/tooling-and-review/preset-writing-style.md +8 -0
  102. package/presets/claude/next/settings.json +15 -4
  103. package/presets/claude/next/team/README.md +1 -1
  104. package/presets/claude/nuxt/CLAUDE.md +2 -4
  105. package/presets/claude/nuxt/hooks/chain-team-phases.sh +541 -61
  106. package/presets/claude/nuxt/hooks/guard-shell-command.mjs +841 -97
  107. package/presets/claude/nuxt/hooks/prompt-autoroute.mjs +153 -0
  108. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-intake.md +2 -0
  109. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  110. package/presets/claude/nuxt/rules/tooling-and-review/preset-writing-style.md +8 -0
  111. package/presets/claude/nuxt/settings.json +15 -4
  112. package/presets/claude/php-hexagonal/CLAUDE.md +2 -4
  113. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +541 -61
  114. package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +841 -97
  115. package/presets/claude/php-hexagonal/hooks/prompt-autoroute.mjs +153 -0
  116. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-intake.md +2 -0
  117. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  118. package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-writing-style.md +8 -0
  119. package/presets/claude/php-hexagonal/settings.json +15 -5
  120. package/presets/claude/php-laravel/CLAUDE.md +2 -4
  121. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +541 -61
  122. package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +841 -97
  123. package/presets/claude/php-laravel/hooks/prompt-autoroute.mjs +153 -0
  124. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-intake.md +2 -0
  125. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  126. package/presets/claude/php-laravel/rules/tooling-and-review/preset-writing-style.md +8 -0
  127. package/presets/claude/php-laravel/settings.json +15 -5
  128. package/presets/claude/svelte/CLAUDE.md +2 -4
  129. package/presets/claude/svelte/hooks/chain-team-phases.sh +541 -61
  130. package/presets/claude/svelte/hooks/guard-shell-command.mjs +841 -97
  131. package/presets/claude/svelte/hooks/prompt-autoroute.mjs +153 -0
  132. package/presets/claude/svelte/rules/tooling-and-review/agent-team-intake.md +2 -0
  133. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  134. package/presets/claude/svelte/rules/tooling-and-review/preset-writing-style.md +8 -0
  135. package/presets/claude/svelte/settings.json +15 -4
  136. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +541 -61
  137. package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +841 -97
  138. package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +2 -0
  139. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +4 -4
  140. package/presets/cursor/android-kotlin/rules/preset-writing-style.mdc +8 -0
  141. package/presets/cursor/go/hooks/chain-team-phases.sh +541 -61
  142. package/presets/cursor/go/hooks/guard-shell-command.mjs +841 -97
  143. package/presets/cursor/go/rules/agent-team-intake.mdc +2 -0
  144. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +4 -4
  145. package/presets/cursor/go/rules/preset-writing-style.mdc +8 -0
  146. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +541 -61
  147. package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +841 -97
  148. package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +2 -0
  149. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +4 -4
  150. package/presets/cursor/ios-swift/rules/preset-writing-style.mdc +8 -0
  151. package/presets/cursor/java/hooks/chain-team-phases.sh +541 -61
  152. package/presets/cursor/java/hooks/guard-shell-command.mjs +841 -97
  153. package/presets/cursor/java/rules/agent-team-intake.mdc +2 -0
  154. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +4 -4
  155. package/presets/cursor/java/rules/preset-writing-style.mdc +8 -0
  156. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +541 -61
  157. package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +841 -97
  158. package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +2 -0
  159. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +4 -4
  160. package/presets/cursor/mcp-ts/rules/preset-writing-style.mdc +8 -0
  161. package/presets/cursor/mol/agents/feature-developer.md +1 -1
  162. package/presets/cursor/mol/ai-local/rules-library/commit-hygiene.md +1 -1
  163. package/presets/cursor/mol/commands/task-evil.md +8 -0
  164. package/presets/cursor/mol/hooks/chain-team-phases.sh +541 -61
  165. package/presets/cursor/mol/hooks/guard-shell-command.mjs +841 -97
  166. package/presets/cursor/mol/rules/agent-team-intake.mdc +2 -0
  167. package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +4 -4
  168. package/presets/cursor/mol/rules/preset-writing-style.mdc +8 -0
  169. package/presets/cursor/next/REPO_AGENTS.md +2 -0
  170. package/presets/cursor/next/agents/feature-developer.md +1 -1
  171. package/presets/cursor/next/agents/task-analyst.md +1 -7
  172. package/presets/cursor/next/agents/task-router.md +1 -1
  173. package/presets/cursor/next/ai-local/rules-library/commit-hygiene.md +1 -1
  174. package/presets/cursor/next/commands/spec-start.md +3 -4
  175. package/presets/cursor/next/commands/task-continue.md +9 -8
  176. package/presets/cursor/next/commands/task-evil.md +8 -0
  177. package/presets/cursor/next/commands/task.md +1 -1
  178. package/presets/cursor/next/hooks/chain-team-phases.sh +541 -61
  179. package/presets/cursor/next/hooks/guard-shell-command.mjs +841 -97
  180. package/presets/cursor/next/rules/agent-team-intake.mdc +2 -0
  181. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +5 -5
  182. package/presets/cursor/next/rules/preset-writing-style.mdc +8 -0
  183. package/presets/cursor/next/team/README.md +1 -1
  184. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +541 -61
  185. package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +841 -97
  186. package/presets/cursor/nuxt/rules/agent-team-intake.mdc +2 -0
  187. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +4 -4
  188. package/presets/cursor/nuxt/rules/preset-writing-style.mdc +8 -0
  189. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +541 -61
  190. package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +841 -97
  191. package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +2 -0
  192. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +4 -4
  193. package/presets/cursor/php-hexagonal/rules/preset-writing-style.mdc +8 -0
  194. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +541 -61
  195. package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +841 -97
  196. package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +2 -0
  197. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +4 -4
  198. package/presets/cursor/php-laravel/rules/preset-writing-style.mdc +8 -0
  199. package/presets/cursor/svelte/hooks/chain-team-phases.sh +541 -61
  200. package/presets/cursor/svelte/hooks/guard-shell-command.mjs +841 -97
  201. package/presets/cursor/svelte/rules/agent-team-intake.mdc +2 -0
  202. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +4 -4
  203. package/presets/cursor/svelte/rules/preset-writing-style.mdc +8 -0
  204. package/presets/mavis/android-kotlin/MAVIS.md +1 -1
  205. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  206. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +541 -61
  207. package/presets/mavis/android-kotlin/rules/agent-team-intake.md +2 -0
  208. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +5 -5
  209. package/presets/mavis/android-kotlin/rules/preset-writing-style.md +8 -0
  210. package/presets/mavis/go/MAVIS.md +1 -1
  211. package/presets/mavis/go/adapter-map.json +1 -1
  212. package/presets/mavis/go/hooks/chain-team-phases.sh +541 -61
  213. package/presets/mavis/go/rules/agent-team-intake.md +2 -0
  214. package/presets/mavis/go/rules/agent-team-orchestrator.md +5 -5
  215. package/presets/mavis/go/rules/preset-writing-style.md +8 -0
  216. package/presets/mavis/ios-swift/MAVIS.md +1 -1
  217. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  218. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +541 -61
  219. package/presets/mavis/ios-swift/rules/agent-team-intake.md +2 -0
  220. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +5 -5
  221. package/presets/mavis/ios-swift/rules/preset-writing-style.md +8 -0
  222. package/presets/mavis/java/MAVIS.md +1 -1
  223. package/presets/mavis/java/adapter-map.json +1 -1
  224. package/presets/mavis/java/hooks/chain-team-phases.sh +541 -61
  225. package/presets/mavis/java/rules/agent-team-intake.md +2 -0
  226. package/presets/mavis/java/rules/agent-team-orchestrator.md +5 -5
  227. package/presets/mavis/java/rules/preset-writing-style.md +8 -0
  228. package/presets/mavis/mcp-ts/MAVIS.md +1 -1
  229. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  230. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +541 -61
  231. package/presets/mavis/mcp-ts/rules/agent-team-intake.md +2 -0
  232. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +5 -5
  233. package/presets/mavis/mcp-ts/rules/preset-writing-style.md +8 -0
  234. package/presets/mavis/mol/MAVIS.md +1 -1
  235. package/presets/mavis/mol/adapter-map.json +1 -1
  236. package/presets/mavis/mol/agents/feature-developer.md +1 -1
  237. package/presets/mavis/mol/ai-local/rules-library/commit-hygiene.md +1 -1
  238. package/presets/mavis/mol/commands/task-evil.md +8 -0
  239. package/presets/mavis/mol/hooks/chain-team-phases.sh +541 -61
  240. package/presets/mavis/mol/native-skills/task-evil/SKILL.md +8 -0
  241. package/presets/mavis/mol/rules/agent-team-intake.md +2 -0
  242. package/presets/mavis/mol/rules/agent-team-orchestrator.md +5 -5
  243. package/presets/mavis/mol/rules/preset-writing-style.md +8 -0
  244. package/presets/mavis/next/MAVIS.md +1 -1
  245. package/presets/mavis/next/REPO_AGENTS.md +2 -0
  246. package/presets/mavis/next/adapter-map.json +1 -1
  247. package/presets/mavis/next/agents/feature-developer.md +1 -1
  248. package/presets/mavis/next/agents/task-analyst.md +1 -7
  249. package/presets/mavis/next/agents/task-router.md +1 -1
  250. package/presets/mavis/next/ai-local/rules-library/commit-hygiene.md +1 -1
  251. package/presets/mavis/next/commands/spec-start.md +3 -4
  252. package/presets/mavis/next/commands/task-continue.md +9 -8
  253. package/presets/mavis/next/commands/task-evil.md +8 -0
  254. package/presets/mavis/next/commands/task.md +1 -1
  255. package/presets/mavis/next/hooks/chain-team-phases.sh +541 -61
  256. package/presets/mavis/next/native-skills/spec-start/SKILL.md +3 -4
  257. package/presets/mavis/next/native-skills/task/SKILL.md +1 -1
  258. package/presets/mavis/next/native-skills/task-continue/SKILL.md +9 -8
  259. package/presets/mavis/next/native-skills/task-evil/SKILL.md +8 -0
  260. package/presets/mavis/next/rules/agent-team-intake.md +2 -0
  261. package/presets/mavis/next/rules/agent-team-orchestrator.md +5 -5
  262. package/presets/mavis/next/rules/preset-writing-style.md +8 -0
  263. package/presets/mavis/next/team/README.md +1 -1
  264. package/presets/mavis/nuxt/MAVIS.md +1 -1
  265. package/presets/mavis/nuxt/adapter-map.json +1 -1
  266. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +541 -61
  267. package/presets/mavis/nuxt/rules/agent-team-intake.md +2 -0
  268. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +5 -5
  269. package/presets/mavis/nuxt/rules/preset-writing-style.md +8 -0
  270. package/presets/mavis/php-hexagonal/MAVIS.md +1 -1
  271. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  272. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +541 -61
  273. package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +2 -0
  274. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
  275. package/presets/mavis/php-hexagonal/rules/preset-writing-style.md +8 -0
  276. package/presets/mavis/php-laravel/MAVIS.md +1 -1
  277. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  278. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +541 -61
  279. package/presets/mavis/php-laravel/rules/agent-team-intake.md +2 -0
  280. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +5 -5
  281. package/presets/mavis/php-laravel/rules/preset-writing-style.md +8 -0
  282. package/presets/mavis/svelte/MAVIS.md +1 -1
  283. package/presets/mavis/svelte/adapter-map.json +1 -1
  284. package/presets/mavis/svelte/hooks/chain-team-phases.sh +541 -61
  285. package/presets/mavis/svelte/rules/agent-team-intake.md +2 -0
  286. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +5 -5
  287. package/presets/mavis/svelte/rules/preset-writing-style.md +8 -0
  288. package/presets/opencode/android-kotlin/OPENCODE.md +5 -66
  289. package/presets/opencode/android-kotlin/adapter-map.json +42 -42
  290. package/presets/opencode/android-kotlin/agents/accessibility-reviewer.md +1 -1
  291. package/presets/opencode/android-kotlin/agents/api-contract-reviewer.md +1 -1
  292. package/presets/opencode/android-kotlin/agents/build-verifier.md +1 -1
  293. package/presets/opencode/android-kotlin/agents/ci-investigator.md +1 -1
  294. package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -1
  295. package/presets/opencode/android-kotlin/agents/codebase-analyzer.md +1 -1
  296. package/presets/opencode/android-kotlin/agents/debugger.md +1 -1
  297. package/presets/opencode/android-kotlin/agents/feature-developer.md +1 -1
  298. package/presets/opencode/android-kotlin/agents/instrumentation-test-generator.md +1 -1
  299. package/presets/opencode/android-kotlin/agents/instrumentation-test-healer.md +1 -1
  300. package/presets/opencode/android-kotlin/agents/instrumentation-test-planner.md +1 -1
  301. package/presets/opencode/android-kotlin/agents/migration-specialist.md +1 -1
  302. package/presets/opencode/android-kotlin/agents/mockup-reviewer.md +1 -1
  303. package/presets/opencode/android-kotlin/agents/openspec-author.md +1 -1
  304. package/presets/opencode/android-kotlin/agents/performance-auditor.md +1 -1
  305. package/presets/opencode/android-kotlin/agents/qa-tester.md +1 -1
  306. package/presets/opencode/android-kotlin/agents/security-reviewer.md +1 -1
  307. package/presets/opencode/android-kotlin/agents/solution-architect.md +1 -1
  308. package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
  309. package/presets/opencode/android-kotlin/agents/task-router.md +1 -1
  310. package/presets/opencode/android-kotlin/agents/tech-writer.md +1 -1
  311. package/presets/opencode/android-kotlin/agents/unit-test-generator.md +1 -1
  312. package/presets/opencode/android-kotlin/agents/unit-test-healer.md +1 -1
  313. package/presets/opencode/android-kotlin/agents/unit-test-planner.md +1 -1
  314. package/presets/opencode/android-kotlin/commands/task-continue.md +1 -1
  315. package/presets/opencode/android-kotlin/hooks/README.md +12 -1
  316. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +541 -61
  317. package/presets/opencode/android-kotlin/hooks/guard-shell-command.mjs +879 -0
  318. package/presets/opencode/android-kotlin/opencode.json +4 -4
  319. package/presets/opencode/android-kotlin/plugins/rule-attach/globs.json +167 -0
  320. package/presets/opencode/android-kotlin/rules/agent-team-intake.md +2 -0
  321. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +7 -7
  322. package/presets/opencode/android-kotlin/rules/preset-writing-style.md +8 -0
  323. package/presets/opencode/go/OPENCODE.md +5 -51
  324. package/presets/opencode/go/adapter-map.json +45 -45
  325. package/presets/opencode/go/agents/api-contract-reviewer.md +1 -1
  326. package/presets/opencode/go/agents/build-verifier.md +1 -1
  327. package/presets/opencode/go/agents/ci-investigator.md +1 -1
  328. package/presets/opencode/go/agents/code-reviewer.md +1 -1
  329. package/presets/opencode/go/agents/codebase-analyzer.md +1 -1
  330. package/presets/opencode/go/agents/debugger.md +1 -1
  331. package/presets/opencode/go/agents/feature-developer.md +1 -1
  332. package/presets/opencode/go/agents/integration-test-generator.md +1 -1
  333. package/presets/opencode/go/agents/integration-test-healer.md +1 -1
  334. package/presets/opencode/go/agents/integration-test-planner.md +1 -1
  335. package/presets/opencode/go/agents/migration-specialist.md +1 -1
  336. package/presets/opencode/go/agents/openspec-author.md +1 -1
  337. package/presets/opencode/go/agents/performance-auditor.md +1 -1
  338. package/presets/opencode/go/agents/qa-tester.md +1 -1
  339. package/presets/opencode/go/agents/security-reviewer.md +1 -1
  340. package/presets/opencode/go/agents/solution-architect.md +1 -1
  341. package/presets/opencode/go/agents/task-analyst.md +1 -1
  342. package/presets/opencode/go/agents/task-router.md +1 -1
  343. package/presets/opencode/go/agents/tech-writer.md +1 -1
  344. package/presets/opencode/go/agents/unit-test-generator.md +1 -1
  345. package/presets/opencode/go/agents/unit-test-healer.md +1 -1
  346. package/presets/opencode/go/agents/unit-test-planner.md +1 -1
  347. package/presets/opencode/go/commands/task-continue.md +1 -1
  348. package/presets/opencode/go/hooks/README.md +12 -1
  349. package/presets/opencode/go/hooks/chain-team-phases.sh +541 -61
  350. package/presets/opencode/go/hooks/guard-shell-command.mjs +878 -0
  351. package/presets/opencode/go/opencode.json +4 -4
  352. package/presets/opencode/go/plugins/rule-attach/globs.json +198 -0
  353. package/presets/opencode/go/rules/agent-team-intake.md +2 -0
  354. package/presets/opencode/go/rules/agent-team-orchestrator.md +7 -7
  355. package/presets/opencode/go/rules/preset-writing-style.md +8 -0
  356. package/presets/opencode/ios-swift/OPENCODE.md +5 -66
  357. package/presets/opencode/ios-swift/adapter-map.json +41 -41
  358. package/presets/opencode/ios-swift/agents/accessibility-reviewer.md +1 -1
  359. package/presets/opencode/ios-swift/agents/api-contract-reviewer.md +1 -1
  360. package/presets/opencode/ios-swift/agents/build-verifier.md +1 -1
  361. package/presets/opencode/ios-swift/agents/ci-investigator.md +1 -1
  362. package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -1
  363. package/presets/opencode/ios-swift/agents/codebase-analyzer.md +1 -1
  364. package/presets/opencode/ios-swift/agents/debugger.md +1 -1
  365. package/presets/opencode/ios-swift/agents/feature-developer.md +1 -1
  366. package/presets/opencode/ios-swift/agents/migration-specialist.md +1 -1
  367. package/presets/opencode/ios-swift/agents/mockup-reviewer.md +1 -1
  368. package/presets/opencode/ios-swift/agents/openspec-author.md +1 -1
  369. package/presets/opencode/ios-swift/agents/performance-auditor.md +1 -1
  370. package/presets/opencode/ios-swift/agents/qa-tester.md +1 -1
  371. package/presets/opencode/ios-swift/agents/security-reviewer.md +1 -1
  372. package/presets/opencode/ios-swift/agents/solution-architect.md +1 -1
  373. package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
  374. package/presets/opencode/ios-swift/agents/task-router.md +1 -1
  375. package/presets/opencode/ios-swift/agents/tech-writer.md +1 -1
  376. package/presets/opencode/ios-swift/agents/unit-test-generator.md +1 -1
  377. package/presets/opencode/ios-swift/agents/unit-test-healer.md +1 -1
  378. package/presets/opencode/ios-swift/agents/unit-test-planner.md +1 -1
  379. package/presets/opencode/ios-swift/agents/xcuitest-test-generator.md +1 -1
  380. package/presets/opencode/ios-swift/agents/xcuitest-test-healer.md +1 -1
  381. package/presets/opencode/ios-swift/agents/xcuitest-test-planner.md +1 -1
  382. package/presets/opencode/ios-swift/commands/task-continue.md +1 -1
  383. package/presets/opencode/ios-swift/hooks/README.md +12 -1
  384. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +541 -61
  385. package/presets/opencode/ios-swift/hooks/guard-shell-command.mjs +878 -0
  386. package/presets/opencode/ios-swift/opencode.json +4 -4
  387. package/presets/opencode/ios-swift/plugins/rule-attach/globs.json +160 -0
  388. package/presets/opencode/ios-swift/rules/agent-team-intake.md +2 -0
  389. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +7 -7
  390. package/presets/opencode/ios-swift/rules/preset-writing-style.md +8 -0
  391. package/presets/opencode/java/OPENCODE.md +5 -58
  392. package/presets/opencode/java/adapter-map.json +45 -45
  393. package/presets/opencode/java/agents/api-contract-reviewer.md +1 -1
  394. package/presets/opencode/java/agents/build-verifier.md +1 -1
  395. package/presets/opencode/java/agents/ci-investigator.md +1 -1
  396. package/presets/opencode/java/agents/code-reviewer.md +1 -1
  397. package/presets/opencode/java/agents/codebase-analyzer.md +1 -1
  398. package/presets/opencode/java/agents/debugger.md +1 -1
  399. package/presets/opencode/java/agents/feature-developer.md +1 -1
  400. package/presets/opencode/java/agents/integration-test-generator.md +1 -1
  401. package/presets/opencode/java/agents/integration-test-healer.md +1 -1
  402. package/presets/opencode/java/agents/integration-test-planner.md +1 -1
  403. package/presets/opencode/java/agents/migration-specialist.md +1 -1
  404. package/presets/opencode/java/agents/openspec-author.md +1 -1
  405. package/presets/opencode/java/agents/performance-auditor.md +1 -1
  406. package/presets/opencode/java/agents/qa-tester.md +1 -1
  407. package/presets/opencode/java/agents/security-reviewer.md +1 -1
  408. package/presets/opencode/java/agents/solution-architect.md +1 -1
  409. package/presets/opencode/java/agents/task-analyst.md +1 -1
  410. package/presets/opencode/java/agents/task-router.md +1 -1
  411. package/presets/opencode/java/agents/tech-writer.md +1 -1
  412. package/presets/opencode/java/agents/unit-test-generator.md +1 -1
  413. package/presets/opencode/java/agents/unit-test-healer.md +1 -1
  414. package/presets/opencode/java/agents/unit-test-planner.md +1 -1
  415. package/presets/opencode/java/commands/task-continue.md +1 -1
  416. package/presets/opencode/java/hooks/README.md +12 -1
  417. package/presets/opencode/java/hooks/chain-team-phases.sh +541 -61
  418. package/presets/opencode/java/hooks/guard-shell-command.mjs +879 -0
  419. package/presets/opencode/java/opencode.json +4 -4
  420. package/presets/opencode/java/plugins/rule-attach/globs.json +230 -0
  421. package/presets/opencode/java/rules/agent-team-intake.md +2 -0
  422. package/presets/opencode/java/rules/agent-team-orchestrator.md +7 -7
  423. package/presets/opencode/java/rules/preset-writing-style.md +8 -0
  424. package/presets/opencode/mcp-ts/OPENCODE.md +5 -48
  425. package/presets/opencode/mcp-ts/adapter-map.json +36 -36
  426. package/presets/opencode/mcp-ts/agents/build-verifier.md +1 -1
  427. package/presets/opencode/mcp-ts/agents/feature-developer.md +1 -1
  428. package/presets/opencode/mcp-ts/agents/security-reviewer.md +1 -1
  429. package/presets/opencode/mcp-ts/agents/solution-architect.md +1 -1
  430. package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
  431. package/presets/opencode/mcp-ts/agents/task-router.md +1 -1
  432. package/presets/opencode/mcp-ts/commands/task-continue.md +1 -1
  433. package/presets/opencode/mcp-ts/hooks/README.md +12 -1
  434. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +541 -61
  435. package/presets/opencode/mcp-ts/hooks/guard-shell-command.mjs +878 -0
  436. package/presets/opencode/mcp-ts/opencode.json +4 -4
  437. package/presets/opencode/mcp-ts/plugins/rule-attach/globs.json +151 -0
  438. package/presets/opencode/mcp-ts/rules/agent-team-intake.md +2 -0
  439. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +7 -7
  440. package/presets/opencode/mcp-ts/rules/preset-writing-style.md +8 -0
  441. package/presets/opencode/mol/OPENCODE.md +5 -56
  442. package/presets/opencode/mol/adapter-map.json +31 -31
  443. package/presets/opencode/mol/agents/accessibility-reviewer.md +1 -1
  444. package/presets/opencode/mol/agents/api-contract-reviewer.md +1 -1
  445. package/presets/opencode/mol/agents/build-verifier.md +1 -1
  446. package/presets/opencode/mol/agents/ci-investigator.md +1 -1
  447. package/presets/opencode/mol/agents/code-reviewer.md +1 -1
  448. package/presets/opencode/mol/agents/codebase-analyzer.md +1 -1
  449. package/presets/opencode/mol/agents/debugger.md +1 -1
  450. package/presets/opencode/mol/agents/feature-developer.md +2 -2
  451. package/presets/opencode/mol/agents/migration-specialist.md +1 -1
  452. package/presets/opencode/mol/agents/mockup-reviewer.md +1 -1
  453. package/presets/opencode/mol/agents/openspec-author.md +1 -1
  454. package/presets/opencode/mol/agents/performance-auditor.md +1 -1
  455. package/presets/opencode/mol/agents/playwright-test-generator.md +1 -1
  456. package/presets/opencode/mol/agents/playwright-test-healer.md +1 -1
  457. package/presets/opencode/mol/agents/playwright-test-planner.md +1 -1
  458. package/presets/opencode/mol/agents/qa-tester.md +1 -1
  459. package/presets/opencode/mol/agents/security-reviewer.md +1 -1
  460. package/presets/opencode/mol/agents/solution-architect.md +1 -1
  461. package/presets/opencode/mol/agents/task-analyst.md +1 -1
  462. package/presets/opencode/mol/agents/task-router.md +1 -1
  463. package/presets/opencode/mol/agents/tech-writer.md +1 -1
  464. package/presets/opencode/mol/agents/unit-test-generator.md +1 -1
  465. package/presets/opencode/mol/agents/unit-test-healer.md +1 -1
  466. package/presets/opencode/mol/agents/unit-test-planner.md +1 -1
  467. package/presets/opencode/mol/ai-local/rules-library/commit-hygiene.md +1 -1
  468. package/presets/opencode/mol/commands/task-continue.md +1 -1
  469. package/presets/opencode/mol/commands/task-evil.md +8 -0
  470. package/presets/opencode/mol/hooks/README.md +12 -1
  471. package/presets/opencode/mol/hooks/chain-team-phases.sh +541 -61
  472. package/presets/opencode/mol/hooks/guard-shell-command.mjs +877 -0
  473. package/presets/opencode/mol/opencode.json +4 -4
  474. package/presets/opencode/mol/plugins/rule-attach/globs.json +112 -0
  475. package/presets/opencode/mol/rules/agent-team-intake.md +2 -0
  476. package/presets/opencode/mol/rules/agent-team-orchestrator.md +7 -7
  477. package/presets/opencode/mol/rules/preset-writing-style.md +8 -0
  478. package/presets/opencode/next/OPENCODE.md +5 -55
  479. package/presets/opencode/next/REPO_AGENTS.md +2 -0
  480. package/presets/opencode/next/adapter-map.json +56 -56
  481. package/presets/opencode/next/agents/accessibility-reviewer.md +1 -1
  482. package/presets/opencode/next/agents/api-contract-reviewer.md +1 -1
  483. package/presets/opencode/next/agents/build-verifier.md +1 -1
  484. package/presets/opencode/next/agents/ci-investigator.md +1 -1
  485. package/presets/opencode/next/agents/code-reviewer.md +1 -1
  486. package/presets/opencode/next/agents/codebase-analyzer.md +1 -1
  487. package/presets/opencode/next/agents/debugger.md +1 -1
  488. package/presets/opencode/next/agents/feature-developer.md +2 -2
  489. package/presets/opencode/next/agents/migration-specialist.md +1 -1
  490. package/presets/opencode/next/agents/mockup-reviewer.md +1 -1
  491. package/presets/opencode/next/agents/openspec-author.md +1 -1
  492. package/presets/opencode/next/agents/performance-auditor.md +1 -1
  493. package/presets/opencode/next/agents/playwright-test-generator.md +1 -1
  494. package/presets/opencode/next/agents/playwright-test-healer.md +1 -1
  495. package/presets/opencode/next/agents/playwright-test-planner.md +1 -1
  496. package/presets/opencode/next/agents/qa-tester.md +1 -1
  497. package/presets/opencode/next/agents/security-reviewer.md +1 -1
  498. package/presets/opencode/next/agents/solution-architect.md +1 -1
  499. package/presets/opencode/next/agents/task-analyst.md +2 -8
  500. package/presets/opencode/next/agents/task-router.md +2 -2
  501. package/presets/opencode/next/agents/tech-writer.md +1 -1
  502. package/presets/opencode/next/agents/unit-test-generator.md +1 -1
  503. package/presets/opencode/next/agents/unit-test-healer.md +1 -1
  504. package/presets/opencode/next/agents/unit-test-planner.md +1 -1
  505. package/presets/opencode/next/ai-local/rules-library/commit-hygiene.md +1 -1
  506. package/presets/opencode/next/commands/spec-start.md +3 -4
  507. package/presets/opencode/next/commands/task-continue.md +10 -9
  508. package/presets/opencode/next/commands/task-evil.md +8 -0
  509. package/presets/opencode/next/commands/task.md +1 -1
  510. package/presets/opencode/next/hooks/README.md +12 -1
  511. package/presets/opencode/next/hooks/chain-team-phases.sh +541 -61
  512. package/presets/opencode/next/hooks/guard-shell-command.mjs +877 -0
  513. package/presets/opencode/next/opencode.json +4 -4
  514. package/presets/opencode/next/plugins/rule-attach/globs.json +276 -0
  515. package/presets/opencode/next/rules/agent-team-intake.md +2 -0
  516. package/presets/opencode/next/rules/agent-team-orchestrator.md +7 -7
  517. package/presets/opencode/next/rules/preset-writing-style.md +8 -0
  518. package/presets/opencode/next/team/README.md +1 -1
  519. package/presets/opencode/nuxt/OPENCODE.md +5 -54
  520. package/presets/opencode/nuxt/adapter-map.json +51 -51
  521. package/presets/opencode/nuxt/agents/accessibility-reviewer.md +1 -1
  522. package/presets/opencode/nuxt/agents/api-contract-reviewer.md +1 -1
  523. package/presets/opencode/nuxt/agents/build-verifier.md +1 -1
  524. package/presets/opencode/nuxt/agents/ci-investigator.md +1 -1
  525. package/presets/opencode/nuxt/agents/code-reviewer.md +1 -1
  526. package/presets/opencode/nuxt/agents/codebase-analyzer.md +1 -1
  527. package/presets/opencode/nuxt/agents/debugger.md +1 -1
  528. package/presets/opencode/nuxt/agents/feature-developer.md +1 -1
  529. package/presets/opencode/nuxt/agents/migration-specialist.md +1 -1
  530. package/presets/opencode/nuxt/agents/mockup-reviewer.md +1 -1
  531. package/presets/opencode/nuxt/agents/openspec-author.md +1 -1
  532. package/presets/opencode/nuxt/agents/performance-auditor.md +1 -1
  533. package/presets/opencode/nuxt/agents/playwright-test-generator.md +1 -1
  534. package/presets/opencode/nuxt/agents/playwright-test-healer.md +1 -1
  535. package/presets/opencode/nuxt/agents/playwright-test-planner.md +1 -1
  536. package/presets/opencode/nuxt/agents/qa-tester.md +1 -1
  537. package/presets/opencode/nuxt/agents/security-reviewer.md +1 -1
  538. package/presets/opencode/nuxt/agents/solution-architect.md +1 -1
  539. package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
  540. package/presets/opencode/nuxt/agents/task-router.md +1 -1
  541. package/presets/opencode/nuxt/agents/tech-writer.md +1 -1
  542. package/presets/opencode/nuxt/agents/unit-test-generator.md +1 -1
  543. package/presets/opencode/nuxt/agents/unit-test-healer.md +1 -1
  544. package/presets/opencode/nuxt/agents/unit-test-planner.md +1 -1
  545. package/presets/opencode/nuxt/commands/task-continue.md +1 -1
  546. package/presets/opencode/nuxt/hooks/README.md +12 -1
  547. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +541 -61
  548. package/presets/opencode/nuxt/hooks/guard-shell-command.mjs +877 -0
  549. package/presets/opencode/nuxt/opencode.json +4 -4
  550. package/presets/opencode/nuxt/plugins/rule-attach/globs.json +266 -0
  551. package/presets/opencode/nuxt/rules/agent-team-intake.md +2 -0
  552. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +7 -7
  553. package/presets/opencode/nuxt/rules/preset-writing-style.md +8 -0
  554. package/presets/opencode/php-hexagonal/OPENCODE.md +5 -60
  555. package/presets/opencode/php-hexagonal/adapter-map.json +45 -45
  556. package/presets/opencode/php-hexagonal/agents/api-contract-reviewer.md +1 -1
  557. package/presets/opencode/php-hexagonal/agents/build-verifier.md +1 -1
  558. package/presets/opencode/php-hexagonal/agents/ci-investigator.md +1 -1
  559. package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -1
  560. package/presets/opencode/php-hexagonal/agents/codebase-analyzer.md +1 -1
  561. package/presets/opencode/php-hexagonal/agents/debugger.md +1 -1
  562. package/presets/opencode/php-hexagonal/agents/feature-developer.md +1 -1
  563. package/presets/opencode/php-hexagonal/agents/integration-test-generator.md +1 -1
  564. package/presets/opencode/php-hexagonal/agents/integration-test-healer.md +1 -1
  565. package/presets/opencode/php-hexagonal/agents/integration-test-planner.md +1 -1
  566. package/presets/opencode/php-hexagonal/agents/migration-specialist.md +1 -1
  567. package/presets/opencode/php-hexagonal/agents/openspec-author.md +1 -1
  568. package/presets/opencode/php-hexagonal/agents/performance-auditor.md +1 -1
  569. package/presets/opencode/php-hexagonal/agents/qa-tester.md +1 -1
  570. package/presets/opencode/php-hexagonal/agents/security-reviewer.md +1 -1
  571. package/presets/opencode/php-hexagonal/agents/solution-architect.md +1 -1
  572. package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
  573. package/presets/opencode/php-hexagonal/agents/task-router.md +1 -1
  574. package/presets/opencode/php-hexagonal/agents/tech-writer.md +1 -1
  575. package/presets/opencode/php-hexagonal/agents/unit-test-generator.md +1 -1
  576. package/presets/opencode/php-hexagonal/agents/unit-test-healer.md +1 -1
  577. package/presets/opencode/php-hexagonal/agents/unit-test-planner.md +1 -1
  578. package/presets/opencode/php-hexagonal/commands/task-continue.md +1 -1
  579. package/presets/opencode/php-hexagonal/hooks/README.md +12 -1
  580. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +541 -61
  581. package/presets/opencode/php-hexagonal/hooks/guard-shell-command.mjs +879 -0
  582. package/presets/opencode/php-hexagonal/opencode.json +4 -4
  583. package/presets/opencode/php-hexagonal/plugins/rule-attach/globs.json +242 -0
  584. package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +2 -0
  585. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +7 -7
  586. package/presets/opencode/php-hexagonal/rules/preset-writing-style.md +8 -0
  587. package/presets/opencode/php-laravel/OPENCODE.md +5 -60
  588. package/presets/opencode/php-laravel/adapter-map.json +45 -45
  589. package/presets/opencode/php-laravel/agents/api-contract-reviewer.md +1 -1
  590. package/presets/opencode/php-laravel/agents/build-verifier.md +1 -1
  591. package/presets/opencode/php-laravel/agents/ci-investigator.md +1 -1
  592. package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -1
  593. package/presets/opencode/php-laravel/agents/codebase-analyzer.md +1 -1
  594. package/presets/opencode/php-laravel/agents/debugger.md +1 -1
  595. package/presets/opencode/php-laravel/agents/feature-developer.md +1 -1
  596. package/presets/opencode/php-laravel/agents/integration-test-generator.md +1 -1
  597. package/presets/opencode/php-laravel/agents/integration-test-healer.md +1 -1
  598. package/presets/opencode/php-laravel/agents/integration-test-planner.md +1 -1
  599. package/presets/opencode/php-laravel/agents/migration-specialist.md +1 -1
  600. package/presets/opencode/php-laravel/agents/openspec-author.md +1 -1
  601. package/presets/opencode/php-laravel/agents/performance-auditor.md +1 -1
  602. package/presets/opencode/php-laravel/agents/qa-tester.md +1 -1
  603. package/presets/opencode/php-laravel/agents/security-reviewer.md +1 -1
  604. package/presets/opencode/php-laravel/agents/solution-architect.md +1 -1
  605. package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
  606. package/presets/opencode/php-laravel/agents/task-router.md +1 -1
  607. package/presets/opencode/php-laravel/agents/tech-writer.md +1 -1
  608. package/presets/opencode/php-laravel/agents/unit-test-generator.md +1 -1
  609. package/presets/opencode/php-laravel/agents/unit-test-healer.md +1 -1
  610. package/presets/opencode/php-laravel/agents/unit-test-planner.md +1 -1
  611. package/presets/opencode/php-laravel/commands/task-continue.md +1 -1
  612. package/presets/opencode/php-laravel/hooks/README.md +12 -1
  613. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +541 -61
  614. package/presets/opencode/php-laravel/hooks/guard-shell-command.mjs +879 -0
  615. package/presets/opencode/php-laravel/opencode.json +4 -4
  616. package/presets/opencode/php-laravel/plugins/rule-attach/globs.json +232 -0
  617. package/presets/opencode/php-laravel/rules/agent-team-intake.md +2 -0
  618. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +7 -7
  619. package/presets/opencode/php-laravel/rules/preset-writing-style.md +8 -0
  620. package/presets/opencode/platform-contract.json +4 -0
  621. package/presets/opencode/plugins/output-guard/README.md +1 -1
  622. package/presets/opencode/plugins/output-guard/index.ts +8 -2
  623. package/presets/opencode/plugins/output-guard/rewrite.ts +37 -0
  624. package/presets/opencode/plugins/rule-attach/README.md +34 -0
  625. package/presets/opencode/plugins/rule-attach/attach.ts +224 -0
  626. package/presets/opencode/plugins/rule-attach/index.ts +169 -0
  627. package/presets/opencode/plugins/rule-attach/package.json +9 -0
  628. package/presets/opencode/plugins/settings-guard/README.md +25 -0
  629. package/presets/opencode/plugins/settings-guard/index.ts +114 -0
  630. package/presets/opencode/plugins/settings-guard/package.json +9 -0
  631. package/presets/opencode/plugins/settings-guard/policy.mjs +85 -0
  632. package/presets/opencode/plugins/settings-guard/prompt-face.mjs +153 -0
  633. package/presets/opencode/plugins/task-status/README.md +9 -4
  634. package/presets/opencode/plugins/task-status/eta.ts +20 -7
  635. package/presets/opencode/plugins/task-status/index.ts +14 -1
  636. package/presets/opencode/plugins/task-status/task-view.ts +160 -5
  637. package/presets/opencode/plugins/task-status/timing.ts +244 -0
  638. package/presets/opencode/plugins/task-status/types.ts +6 -0
  639. package/presets/opencode/svelte/OPENCODE.md +5 -54
  640. package/presets/opencode/svelte/adapter-map.json +51 -51
  641. package/presets/opencode/svelte/agents/accessibility-reviewer.md +1 -1
  642. package/presets/opencode/svelte/agents/api-contract-reviewer.md +1 -1
  643. package/presets/opencode/svelte/agents/build-verifier.md +1 -1
  644. package/presets/opencode/svelte/agents/ci-investigator.md +1 -1
  645. package/presets/opencode/svelte/agents/code-reviewer.md +1 -1
  646. package/presets/opencode/svelte/agents/codebase-analyzer.md +1 -1
  647. package/presets/opencode/svelte/agents/debugger.md +1 -1
  648. package/presets/opencode/svelte/agents/feature-developer.md +1 -1
  649. package/presets/opencode/svelte/agents/migration-specialist.md +1 -1
  650. package/presets/opencode/svelte/agents/mockup-reviewer.md +1 -1
  651. package/presets/opencode/svelte/agents/openspec-author.md +1 -1
  652. package/presets/opencode/svelte/agents/performance-auditor.md +1 -1
  653. package/presets/opencode/svelte/agents/playwright-test-generator.md +1 -1
  654. package/presets/opencode/svelte/agents/playwright-test-healer.md +1 -1
  655. package/presets/opencode/svelte/agents/playwright-test-planner.md +1 -1
  656. package/presets/opencode/svelte/agents/qa-tester.md +1 -1
  657. package/presets/opencode/svelte/agents/security-reviewer.md +1 -1
  658. package/presets/opencode/svelte/agents/solution-architect.md +1 -1
  659. package/presets/opencode/svelte/agents/task-analyst.md +1 -1
  660. package/presets/opencode/svelte/agents/task-router.md +1 -1
  661. package/presets/opencode/svelte/agents/tech-writer.md +1 -1
  662. package/presets/opencode/svelte/agents/unit-test-generator.md +1 -1
  663. package/presets/opencode/svelte/agents/unit-test-healer.md +1 -1
  664. package/presets/opencode/svelte/agents/unit-test-planner.md +1 -1
  665. package/presets/opencode/svelte/commands/task-continue.md +1 -1
  666. package/presets/opencode/svelte/hooks/README.md +12 -1
  667. package/presets/opencode/svelte/hooks/chain-team-phases.sh +541 -61
  668. package/presets/opencode/svelte/hooks/guard-shell-command.mjs +877 -0
  669. package/presets/opencode/svelte/opencode.json +4 -4
  670. package/presets/opencode/svelte/plugins/rule-attach/globs.json +245 -0
  671. package/presets/opencode/svelte/rules/agent-team-intake.md +2 -0
  672. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +7 -7
  673. package/presets/opencode/svelte/rules/preset-writing-style.md +8 -0
  674. package/presets/zcode/android-kotlin/adapter-map.json +1 -1
  675. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +541 -61
  676. package/presets/zcode/android-kotlin/rules/agent-team-intake.md +2 -0
  677. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +5 -5
  678. package/presets/zcode/android-kotlin/rules/preset-writing-style.md +8 -0
  679. package/presets/zcode/go/adapter-map.json +1 -1
  680. package/presets/zcode/go/hooks/chain-team-phases.sh +541 -61
  681. package/presets/zcode/go/rules/agent-team-intake.md +2 -0
  682. package/presets/zcode/go/rules/agent-team-orchestrator.md +5 -5
  683. package/presets/zcode/go/rules/preset-writing-style.md +8 -0
  684. package/presets/zcode/ios-swift/adapter-map.json +1 -1
  685. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +541 -61
  686. package/presets/zcode/ios-swift/rules/agent-team-intake.md +2 -0
  687. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +5 -5
  688. package/presets/zcode/ios-swift/rules/preset-writing-style.md +8 -0
  689. package/presets/zcode/java/adapter-map.json +1 -1
  690. package/presets/zcode/java/hooks/chain-team-phases.sh +541 -61
  691. package/presets/zcode/java/rules/agent-team-intake.md +2 -0
  692. package/presets/zcode/java/rules/agent-team-orchestrator.md +5 -5
  693. package/presets/zcode/java/rules/preset-writing-style.md +8 -0
  694. package/presets/zcode/mcp-ts/adapter-map.json +1 -1
  695. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +541 -61
  696. package/presets/zcode/mcp-ts/rules/agent-team-intake.md +2 -0
  697. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +5 -5
  698. package/presets/zcode/mcp-ts/rules/preset-writing-style.md +8 -0
  699. package/presets/zcode/mol/adapter-map.json +1 -1
  700. package/presets/zcode/mol/agents/feature-developer.md +1 -1
  701. package/presets/zcode/mol/ai-local/rules-library/commit-hygiene.md +1 -1
  702. package/presets/zcode/mol/commands/task-evil.md +8 -0
  703. package/presets/zcode/mol/hooks/chain-team-phases.sh +541 -61
  704. package/presets/zcode/mol/rules/agent-team-intake.md +2 -0
  705. package/presets/zcode/mol/rules/agent-team-orchestrator.md +5 -5
  706. package/presets/zcode/mol/rules/preset-writing-style.md +8 -0
  707. package/presets/zcode/next/REPO_AGENTS.md +2 -0
  708. package/presets/zcode/next/adapter-map.json +1 -1
  709. package/presets/zcode/next/agents/feature-developer.md +1 -1
  710. package/presets/zcode/next/agents/task-analyst.md +1 -7
  711. package/presets/zcode/next/agents/task-router.md +1 -1
  712. package/presets/zcode/next/ai-local/rules-library/commit-hygiene.md +1 -1
  713. package/presets/zcode/next/commands/spec-start.md +3 -4
  714. package/presets/zcode/next/commands/task-continue.md +9 -8
  715. package/presets/zcode/next/commands/task-evil.md +8 -0
  716. package/presets/zcode/next/commands/task.md +1 -1
  717. package/presets/zcode/next/hooks/chain-team-phases.sh +541 -61
  718. package/presets/zcode/next/rules/agent-team-intake.md +2 -0
  719. package/presets/zcode/next/rules/agent-team-orchestrator.md +5 -5
  720. package/presets/zcode/next/rules/preset-writing-style.md +8 -0
  721. package/presets/zcode/next/team/README.md +1 -1
  722. package/presets/zcode/nuxt/adapter-map.json +1 -1
  723. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +541 -61
  724. package/presets/zcode/nuxt/rules/agent-team-intake.md +2 -0
  725. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +5 -5
  726. package/presets/zcode/nuxt/rules/preset-writing-style.md +8 -0
  727. package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
  728. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +541 -61
  729. package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +2 -0
  730. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
  731. package/presets/zcode/php-hexagonal/rules/preset-writing-style.md +8 -0
  732. package/presets/zcode/php-laravel/adapter-map.json +1 -1
  733. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +541 -61
  734. package/presets/zcode/php-laravel/rules/agent-team-intake.md +2 -0
  735. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +5 -5
  736. package/presets/zcode/php-laravel/rules/preset-writing-style.md +8 -0
  737. package/presets/zcode/svelte/adapter-map.json +1 -1
  738. package/presets/zcode/svelte/hooks/chain-team-phases.sh +541 -61
  739. package/presets/zcode/svelte/rules/agent-team-intake.md +2 -0
  740. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +5 -5
  741. package/presets/zcode/svelte/rules/preset-writing-style.md +8 -0
  742. package/scripts/report-context-cost.mjs +1 -20
@@ -0,0 +1,877 @@
1
+ #!/usr/bin/env node
2
+ // Shell guard for Cursor `beforeShellExecution` and Claude `PreToolUse`.
3
+ // Rendered from `presets/_shared/hooks/guard-shell-command.mjs.tmpl`; edit the
4
+ // template, never a rendered copy.
5
+ // Svelte: npm, yarn, and pnpm scripts are allowed; package-manager mismatch checks apply when a JS lockfile/package.json exists.
6
+ const SERVER_COMMAND = new RegExp("(^|[;&|]\\s*)(?:(?:yarn|pnpm|npm(?:\\s+run)?|npx)\\s+)?(?:storybook|vite)(?:\\s|$)|svelte-kit\\s+dev|(^|[;&|]\\s*)(?:yarn|pnpm|npm)\\s+(?:run\\s+)?dev(?:\\s|$)");
7
+ const SERVER_PORTS = [5173,6006];
8
+ import fs from 'node:fs';
9
+ import net from 'node:net';
10
+ import path from 'node:path';
11
+ import { fileURLToPath, pathToFileURL } from 'node:url';
12
+
13
+ const allowed = () => ({ permission: 'allow' });
14
+
15
+ const ask = (userMessage, agentMessage) => ({
16
+ permission: 'ask',
17
+ user_message: userMessage,
18
+ agent_message: agentMessage || userMessage,
19
+ });
20
+
21
+ const portIsOpen = (port) =>
22
+ new Promise((resolve) => {
23
+ const socket = net.createConnection({ host: '127.0.0.1', port });
24
+ const done = (open) => {
25
+ socket.destroy();
26
+ resolve(open);
27
+ };
28
+ socket.once('connect', () => done(true));
29
+ socket.once('error', () => done(false));
30
+ socket.setTimeout(400, () => done(false));
31
+ });
32
+
33
+ /**
34
+ * Default settings resolver: a dynamic import of the seeded parser under the
35
+ * project root. A missing, unreadable or unimportable module yields `null`, so
36
+ * the guard answers without a parser instead of carrying a copy of one.
37
+ *
38
+ * @returns {Promise<((key: string) => boolean) | null>} `get(key)`, or `null`
39
+ */
40
+ const importSettings = async ({ root, exists, readText }) => {
41
+ const file = path.join(root, '.ai.local', 'scripts', 'settings.mjs');
42
+ if (!exists(file)) return null;
43
+ try {
44
+ const module = await import(pathToFileURL(file).href);
45
+ if (typeof module.readSetting !== 'function') return null;
46
+ return (key) => module.readSetting(key, { root, exists, readText }).value === true;
47
+ } catch {
48
+ return null;
49
+ }
50
+ };
51
+
52
+ /**
53
+ * `git` global options that take the next token as their value. Every other
54
+ * option is skipped as a flag, so an undocumented flag cannot hide the
55
+ * subcommand; an undocumented value-taking option surfaces as an unresolved
56
+ * subcommand and is asked, never allowed.
57
+ */
58
+ const GIT_VALUE_GLOBALS = new Set([
59
+ '-c',
60
+ '-C',
61
+ '--git-dir',
62
+ '--work-tree',
63
+ '--namespace',
64
+ '--config-env',
65
+ '--super-prefix',
66
+ '--exec-path',
67
+ ]);
68
+
69
+ /**
70
+ * Join backslash line continuations, then split on shell separators outside
71
+ * quotes. Command substitution is split too, so `$(git push --force)` is a
72
+ * segment the classifier sees rather than an opaque token.
73
+ */
74
+ const splitShellSegments = (command) => {
75
+ const text = String(command).replace(/\\\r?\n/g, '');
76
+ const segments = [];
77
+ let current = '';
78
+ let quote = null;
79
+ for (let index = 0; index < text.length; index += 1) {
80
+ const char = text[index];
81
+ if (quote !== null) {
82
+ current += char;
83
+ if (char === '\\' && quote === '"' && index + 1 < text.length) {
84
+ index += 1;
85
+ current += text[index];
86
+ continue;
87
+ }
88
+ if (char === quote) quote = null;
89
+ continue;
90
+ }
91
+ if (char === "'" || char === '"') {
92
+ quote = char;
93
+ current += char;
94
+ continue;
95
+ }
96
+ if (
97
+ char === ';' ||
98
+ char === '\n' ||
99
+ char === '\r' ||
100
+ char === '|' ||
101
+ char === '&' ||
102
+ char === '(' ||
103
+ char === ')' ||
104
+ char === '`'
105
+ ) {
106
+ if ((char === '|' || char === '&') && text[index + 1] === char) index += 1;
107
+ segments.push(current);
108
+ current = '';
109
+ continue;
110
+ }
111
+ current += char;
112
+ }
113
+ segments.push(current);
114
+ return segments.filter((segment) => segment.trim() !== '');
115
+ };
116
+
117
+ /** Decode the escapes of a `$'…'` ANSI-C quoted span. */
118
+ const decodeAnsiC = (text) => {
119
+ let output = '';
120
+ for (let index = 0; index < text.length; index += 1) {
121
+ const char = text[index];
122
+ if (char !== '\\') {
123
+ output += char;
124
+ continue;
125
+ }
126
+ const next = text[index + 1];
127
+ if (next === undefined) {
128
+ output += '\\';
129
+ break;
130
+ }
131
+ index += 1;
132
+ if (next === 'n') output += '\n';
133
+ else if (next === 'r') output += '\r';
134
+ else if (next === 't') output += '\t';
135
+ else if (next === '\\' || next === "'" || next === '"' || next === '?') output += next;
136
+ else if (next === 'x') {
137
+ const hex = text.slice(index + 1, index + 3);
138
+ if (/^[0-9a-fA-F]{2}$/.test(hex)) {
139
+ output += String.fromCharCode(parseInt(hex, 16));
140
+ index += 2;
141
+ } else output += '\\x';
142
+ } else if (next === 'u') {
143
+ const hex = text.slice(index + 1, index + 5);
144
+ if (/^[0-9a-fA-F]{4}$/.test(hex)) {
145
+ output += String.fromCharCode(parseInt(hex, 16));
146
+ index += 4;
147
+ } else output += '\\u';
148
+ } else if (/[0-7]/.test(next)) {
149
+ const octal = text.slice(index, index + 3).match(/^[0-7]{1,3}/)?.[0] ?? next;
150
+ output += String.fromCharCode(parseInt(octal, 8));
151
+ index += octal.length - 1;
152
+ } else output += next;
153
+ }
154
+ return output;
155
+ };
156
+
157
+ /**
158
+ * Shell-word tokenizer: quotes and escapes concatenate into the token value,
159
+ * and `quoted` records that the token carried quoting. A quoted `git`/`push`/
160
+ * `--force` is therefore as visible as an unquoted one; an unterminated quote
161
+ * is reported so the caller asks.
162
+ */
163
+ const tokenizeSegment = (segment) => {
164
+ const tokens = [];
165
+ let value = '';
166
+ let quoted = false;
167
+ let started = false;
168
+ let quote = null;
169
+ let unterminated = false;
170
+ let index = 0;
171
+ const push = () => {
172
+ if (started) tokens.push({ value, quoted });
173
+ value = '';
174
+ quoted = false;
175
+ started = false;
176
+ };
177
+ while (index < segment.length) {
178
+ const char = segment[index];
179
+ if (quote === null && /\s/.test(char)) {
180
+ push();
181
+ index += 1;
182
+ continue;
183
+ }
184
+ if (quote === "'") {
185
+ if (char === "'") {
186
+ quote = null;
187
+ index += 1;
188
+ continue;
189
+ }
190
+ value += char;
191
+ started = true;
192
+ index += 1;
193
+ continue;
194
+ }
195
+ if (quote === '"') {
196
+ if (char === '"') {
197
+ quote = null;
198
+ index += 1;
199
+ continue;
200
+ }
201
+ if (char === '\\' && index + 1 < segment.length) {
202
+ const next = segment[index + 1];
203
+ if ('"\\$`\n'.includes(next)) {
204
+ if (next !== '\n') value += next;
205
+ index += 2;
206
+ started = true;
207
+ continue;
208
+ }
209
+ }
210
+ value += char;
211
+ started = true;
212
+ index += 1;
213
+ continue;
214
+ }
215
+ if (quote === 'ansi') {
216
+ let raw = '';
217
+ let cursor = index;
218
+ while (cursor < segment.length) {
219
+ if (segment[cursor] === '\\' && cursor + 1 < segment.length) {
220
+ raw += segment[cursor] + segment[cursor + 1];
221
+ cursor += 2;
222
+ continue;
223
+ }
224
+ if (segment[cursor] === "'") break;
225
+ raw += segment[cursor];
226
+ cursor += 1;
227
+ }
228
+ value += decodeAnsiC(raw);
229
+ started = true;
230
+ if (cursor < segment.length && segment[cursor] === "'") {
231
+ quote = null;
232
+ cursor += 1;
233
+ } else {
234
+ unterminated = true;
235
+ quote = null;
236
+ }
237
+ index = cursor;
238
+ continue;
239
+ }
240
+ if (char === "'") {
241
+ quote = "'";
242
+ quoted = true;
243
+ started = true;
244
+ index += 1;
245
+ continue;
246
+ }
247
+ if (char === '"') {
248
+ quote = '"';
249
+ quoted = true;
250
+ started = true;
251
+ index += 1;
252
+ continue;
253
+ }
254
+ if (char === '$' && segment[index + 1] === "'") {
255
+ quote = 'ansi';
256
+ quoted = true;
257
+ started = true;
258
+ index += 2;
259
+ continue;
260
+ }
261
+ if (char === '\\' && index + 1 < segment.length) {
262
+ value += segment[index + 1];
263
+ quoted = true;
264
+ started = true;
265
+ index += 2;
266
+ continue;
267
+ }
268
+ value += char;
269
+ started = true;
270
+ index += 1;
271
+ }
272
+ push();
273
+ return { tokens, unterminated: unterminated || quote !== null };
274
+ };
275
+
276
+ /**
277
+ * Benign option allowlist per git verb. Anything not on the list — including
278
+ * every abbreviation git would resolve — asks. `--amend` is deliberately absent
279
+ * (it rewrites a commit), so `commit --amend` asks.
280
+ */
281
+ const OPTION_SPECS = {
282
+ push: {
283
+ long: new Set([
284
+ '--set-upstream',
285
+ '--follow-tags',
286
+ '--dry-run',
287
+ '--no-verify',
288
+ '--porcelain',
289
+ '--progress',
290
+ '--no-progress',
291
+ '--quiet',
292
+ '--verbose',
293
+ '--atomic',
294
+ '--no-atomic',
295
+ '--thin',
296
+ '--no-thin',
297
+ '--ipv4',
298
+ '--ipv6',
299
+ '--signed',
300
+ '--no-signed',
301
+ '--recurse-submodules',
302
+ '--no-recurse-submodules',
303
+ ]),
304
+ longValue: new Set([
305
+ '--repo',
306
+ '--push-option',
307
+ '--recurse-submodules',
308
+ ]),
309
+ short: new Set(['u', 'v', 'q', 'n', '4', '6']),
310
+ shortValue: new Set(['o']),
311
+ },
312
+ commit: {
313
+ long: new Set([
314
+ '--message',
315
+ '--file',
316
+ '--author',
317
+ '--date',
318
+ '--signoff',
319
+ '--quiet',
320
+ '--verbose',
321
+ '--dry-run',
322
+ '--no-verify',
323
+ '--allow-empty',
324
+ '--allow-empty-message',
325
+ '--fixup',
326
+ '--squash',
327
+ '--reset-author',
328
+ '--include',
329
+ '--only',
330
+ '--pathspec-file-nul',
331
+ '--cleanup',
332
+ '--template',
333
+ '--edit',
334
+ '--no-edit',
335
+ '--reuse-message',
336
+ '--reedit-message',
337
+ '--gpg-sign',
338
+ '--no-gpg-sign',
339
+ '--all',
340
+ '--patch',
341
+ '--short',
342
+ '--branch',
343
+ '--long',
344
+ '--status',
345
+ '--no-status',
346
+ '--trailer',
347
+ ]),
348
+ longValue: new Set([
349
+ '--message',
350
+ '--file',
351
+ '--author',
352
+ '--date',
353
+ '--fixup',
354
+ '--squash',
355
+ '--pathspec-from-file',
356
+ '--cleanup',
357
+ '--template',
358
+ '--reuse-message',
359
+ '--reedit-message',
360
+ '--trailer',
361
+ ]),
362
+ short: new Set(['a', 'm', 's', 'q', 'v', 'n', 'e', 'i', 'p', 'o', 'F', 'C', 'c', 't', 'S']),
363
+ shortValue: new Set(['m', 'F', 'C', 'c', 't']),
364
+ shortOptionalValue: new Set(['S']),
365
+ },
366
+ clean: {
367
+ long: new Set([
368
+ '--dry-run',
369
+ '--quiet',
370
+ '--interactive',
371
+ '--ignored',
372
+ '--no-ignored',
373
+ '--pathspec-file-nul',
374
+ '--verbose',
375
+ ]),
376
+ longValue: new Set(['--exclude']),
377
+ short: new Set(['d', 'x', 'n', 'q', 'i', 'e', 'X', 'v']),
378
+ shortValue: new Set(['e']),
379
+ },
380
+ reset: {
381
+ long: new Set([
382
+ '--quiet',
383
+ '--no-refresh',
384
+ '--refresh',
385
+ '--mixed',
386
+ '--soft',
387
+ '--merge',
388
+ '--keep',
389
+ '--pathspec-file-nul',
390
+ '--patch',
391
+ ]),
392
+ longValue: new Set(['--pathspec-from-file']),
393
+ short: new Set(['q', 'p', 'h']),
394
+ shortValue: new Set(),
395
+ },
396
+ };
397
+
398
+ /** `null` when every option token is allowlisted, otherwise the unknown reason. */
399
+ const optionVerdict = (subcommand, tokens, startIndex) => {
400
+ const spec = OPTION_SPECS[subcommand];
401
+ if (!spec) return { unknown: false };
402
+ let unknown = false;
403
+ for (let index = startIndex; index < tokens.length; index += 1) {
404
+ const value = tokens[index].value;
405
+ if (value === '--') break;
406
+ if (!value.startsWith('-')) continue;
407
+ if (value.startsWith('--')) {
408
+ const name = value.split('=')[0];
409
+ if (spec.long.has(name) || spec.longValue.has(name)) {
410
+ if (!value.includes('=') && spec.longValue.has(name)) index += 1;
411
+ continue;
412
+ }
413
+ unknown = true;
414
+ continue;
415
+ }
416
+ const letters = value.slice(1);
417
+ for (let letterIndex = 0; letterIndex < letters.length; letterIndex += 1) {
418
+ const letter = letters[letterIndex];
419
+ if (!spec.short.has(letter)) {
420
+ unknown = true;
421
+ break;
422
+ }
423
+ if (spec.shortValue.has(letter)) {
424
+ if (letterIndex === letters.length - 1) index += 1;
425
+ break;
426
+ }
427
+ if (spec.shortOptionalValue?.has(letter)) {
428
+ if (letterIndex < letters.length - 1) break;
429
+ continue;
430
+ }
431
+ }
432
+ }
433
+ return { unknown };
434
+ };
435
+
436
+ /**
437
+ * `clean` needs its own decoded parse: `e` takes a value, so `-en` is the
438
+ * exclude pattern `n` (no dry-run), while `-ne foo` is `-n -e foo`. Only an
439
+ * explicit dry-run flag may allow; everything else asks.
440
+ */
441
+ const parseCleanOptions = (tokens, startIndex) => {
442
+ const spec = OPTION_SPECS.clean;
443
+ let unknown = false;
444
+ let dryRun = false;
445
+ for (let index = startIndex; index < tokens.length; index += 1) {
446
+ const value = tokens[index].value;
447
+ if (value === '--') break;
448
+ if (!value.startsWith('-')) continue;
449
+ if (value.startsWith('--')) {
450
+ if (value === '--dry-run') {
451
+ dryRun = true;
452
+ continue;
453
+ }
454
+ if (value === '--exclude') {
455
+ index += 1;
456
+ continue;
457
+ }
458
+ if (value.startsWith('--exclude=')) continue;
459
+ const name = value.split('=')[0];
460
+ if (spec.long.has(name)) continue;
461
+ unknown = true;
462
+ continue;
463
+ }
464
+ const letters = value.slice(1);
465
+ for (let letterIndex = 0; letterIndex < letters.length; letterIndex += 1) {
466
+ const letter = letters[letterIndex];
467
+ if (!spec.short.has(letter)) {
468
+ unknown = true;
469
+ break;
470
+ }
471
+ if (letter === 'e') {
472
+ if (letterIndex === letters.length - 1) index += 1;
473
+ break;
474
+ }
475
+ if (letter === 'n') dryRun = true;
476
+ }
477
+ }
478
+ return { unknown, dryRun };
479
+ };
480
+
481
+ const isDestructiveRefspec = (value) =>
482
+ /^\+/.test(value) || /^:/.test(value) || /^[^\s:]+:$/.test(value);
483
+
484
+ /**
485
+ * Classify one shell segment from its tokens. `write` is true when the segment
486
+ * may commit or push; `destructive`, `unresolved`, `alias`, `destructiveState`
487
+ * and `unknownOption` are the fail-closed reasons. The `-m` / `--message` value
488
+ * is not scanned as a command, so a quoted commit message stays inert.
489
+ */
490
+ const classifyGitSegment = (segment) => {
491
+ const { tokens, unterminated } = tokenizeSegment(segment.trim());
492
+ const gitIndex = tokens.findIndex(
493
+ (token) => token.value === 'git' || token.value.endsWith('/git'),
494
+ );
495
+ if (gitIndex < 0) {
496
+ return {
497
+ write: false,
498
+ destructive: false,
499
+ unresolved: false,
500
+ alias: false,
501
+ destructiveState: false,
502
+ unknownOption: false,
503
+ };
504
+ }
505
+
506
+ let subcommand = null;
507
+ let subcommandIndex = -1;
508
+ for (let index = gitIndex + 1; index < tokens.length; index += 1) {
509
+ const value = tokens[index].value;
510
+ if (GIT_VALUE_GLOBALS.has(value)) {
511
+ index += 1;
512
+ continue;
513
+ }
514
+ if (value.startsWith('-')) continue;
515
+ subcommand = value;
516
+ subcommandIndex = index;
517
+ break;
518
+ }
519
+
520
+ const known = subcommand === 'commit' || subcommand === 'push';
521
+ const valueIndexes = new Set();
522
+ if (subcommand === 'commit') {
523
+ for (let index = 0; index < tokens.length; index += 1) {
524
+ const value = tokens[index].value;
525
+ if (
526
+ value === '-m' ||
527
+ value === '--message' ||
528
+ (/^-[^-]+$/.test(value) && value.endsWith('m'))
529
+ ) {
530
+ valueIndexes.add(index + 1);
531
+ }
532
+ }
533
+ }
534
+ const alias = tokens.some(
535
+ (token, index) => !valueIndexes.has(index) && /^alias\.[A-Za-z0-9_-]+=/.test(token.value),
536
+ );
537
+ const writeToken = tokens.some(
538
+ (token, index) =>
539
+ index !== subcommandIndex &&
540
+ !valueIndexes.has(index) &&
541
+ (token.value === 'push' || token.value === 'commit'),
542
+ );
543
+ const write = known || alias || writeToken || unterminated;
544
+ const destructiveRefspec =
545
+ subcommand === 'push' &&
546
+ tokens.some((token, index) => {
547
+ if (index <= subcommandIndex) return false;
548
+ if (token.value.startsWith('-')) return false;
549
+ return isDestructiveRefspec(token.value);
550
+ });
551
+ const destructiveState =
552
+ subcommand === 'checkout' && tokens.some((token) => token.value === '--');
553
+ const cleanCheck =
554
+ subcommand === 'clean' ? parseCleanOptions(tokens, subcommandIndex + 1) : null;
555
+ const optionCheck = cleanCheck ?? optionVerdict(subcommand, tokens, subcommandIndex + 1);
556
+ return {
557
+ write,
558
+ destructive: write && destructiveRefspec,
559
+ unresolved: write && (!known || unterminated),
560
+ alias,
561
+ destructiveState,
562
+ unknownOption: optionCheck.unknown,
563
+ cleanAsk: subcommand === 'clean' && !cleanCheck.dryRun,
564
+ };
565
+ };
566
+
567
+ const MAX_SCAN_DEPTH = 3;
568
+
569
+ const mergeResults = (left, right) => ({
570
+ verdict: Math.max(left.verdict, right.verdict),
571
+ destructive: left.destructive || right.destructive,
572
+ });
573
+
574
+ const directSegmentResult = (segment) => {
575
+ const classified = classifyGitSegment(segment);
576
+ if (classified.destructiveState) return { verdict: 2, destructive: true };
577
+ if (classified.unknownOption || classified.cleanAsk) {
578
+ return { verdict: 2, destructive: false };
579
+ }
580
+ if (!classified.write) return { verdict: 0, destructive: false };
581
+ if (classified.destructive) return { verdict: 2, destructive: true };
582
+ if (classified.unresolved || classified.alias) return { verdict: 2, destructive: false };
583
+ return { verdict: 1, destructive: false };
584
+ };
585
+
586
+ /** Every quoted span with its content and the index of its opening quote. */
587
+ const extractQuotedSpans = (segment) => {
588
+ const spans = [];
589
+ let quote = null;
590
+ let start = -1;
591
+ let content = '';
592
+ for (let index = 0; index < segment.length; index += 1) {
593
+ const char = segment[index];
594
+ if (quote !== null) {
595
+ if (char === '\\' && quote === '"' && index + 1 < segment.length) {
596
+ index += 1;
597
+ content += segment[index];
598
+ continue;
599
+ }
600
+ if (char === quote) {
601
+ spans.push({ content, index: start });
602
+ quote = null;
603
+ content = '';
604
+ start = -1;
605
+ continue;
606
+ }
607
+ content += char;
608
+ continue;
609
+ }
610
+ if (char === "'" || char === '"') {
611
+ quote = char;
612
+ start = index;
613
+ }
614
+ }
615
+ return { spans, unterminated: quote !== null };
616
+ };
617
+
618
+ const isEvalPayload = (segment, quoteIndex) => {
619
+ const before = segment.slice(0, quoteIndex).trim();
620
+ return /\beval(?:\s+--)?\s*$/.test(before);
621
+ };
622
+
623
+ const SHELL_TOKEN = /(?:^|\/)(?:sh|bash|zsh|dash|ksh)$/;
624
+
625
+ const isShellCPayload = (segment, quoteIndex) => {
626
+ const before = segment.slice(0, quoteIndex).trim();
627
+ const tokens = before.split(/\s+/).filter(Boolean);
628
+ let shellIndex = -1;
629
+ for (let index = tokens.length - 1; index >= 0; index -= 1) {
630
+ if (SHELL_TOKEN.test(tokens[index])) {
631
+ shellIndex = index;
632
+ break;
633
+ }
634
+ }
635
+ if (shellIndex < 0) return false;
636
+ return tokens
637
+ .slice(shellIndex + 1)
638
+ .some((token) => token === '-c' || /^-[^-]*c/.test(token));
639
+ };
640
+
641
+ const nestedShellResult = (content, depth) => {
642
+ if (depth >= MAX_SCAN_DEPTH) return { verdict: 2, destructive: false };
643
+ const nested = scanGitCommand(content, depth + 1);
644
+ if (nested.verdict === 0) return { verdict: 0, destructive: false };
645
+ return { verdict: 2, destructive: nested.destructive };
646
+ };
647
+
648
+ const quotedSegmentResult = (segment, depth) => {
649
+ const { spans, unterminated } = extractQuotedSpans(segment);
650
+ if (unterminated) return { verdict: 2, destructive: false };
651
+ let result = { verdict: 0, destructive: false };
652
+ for (const span of spans) {
653
+ const trigger =
654
+ /\bgit\b/.test(span.content) ||
655
+ isEvalPayload(segment, span.index) ||
656
+ isShellCPayload(segment, span.index);
657
+ if (!trigger) continue;
658
+ result = mergeResults(result, nestedShellResult(span.content, depth));
659
+ }
660
+ return result;
661
+ };
662
+
663
+ /**
664
+ * `-c` / `--config-env` values are executed by git (pager, sshCommand,
665
+ * diff.external, hooks). Scan the value after the first `=`: a git write or a
666
+ * destructive token there asks. `-C`, `--git-dir`, `--work-tree`, `--namespace`,
667
+ * `--super-prefix` and `--exec-path` are paths/namespaces and stay inert.
668
+ */
669
+ const configSegmentResult = (segment, depth) => {
670
+ const { tokens } = tokenizeSegment(segment);
671
+ let result = { verdict: 0, destructive: false };
672
+ for (let index = 0; index < tokens.length; index += 1) {
673
+ const value = tokens[index].value;
674
+ let configValue = null;
675
+ if (value === '-c' || value === '--config-env') {
676
+ configValue = tokens[index + 1]?.value ?? null;
677
+ index += 1;
678
+ } else if (value.startsWith('--config-env=')) {
679
+ configValue = value.slice('--config-env='.length);
680
+ } else if (value.startsWith('-c') && value.length > 2) {
681
+ configValue = value.slice(2);
682
+ }
683
+ if (configValue === null) continue;
684
+ const separator = configValue.indexOf('=');
685
+ if (separator < 0) continue;
686
+ let payload = configValue.slice(separator + 1);
687
+ // Git strips a leading `!` (and whitespace around it) from an executed
688
+ // config value and shell-runs the rest; classify that remainder as a
689
+ // command. `!gh …` has no git write and stays inert.
690
+ payload = payload.replace(/^[\s!]+/, '');
691
+ if (!payload.trim()) continue;
692
+ result = mergeResults(result, nestedShellResult(payload, depth));
693
+ }
694
+ return result;
695
+ };
696
+
697
+ /** A quoted payload on the left of `| sh` / `| bash` is executed too. */
698
+ const pipeQuotedResult = (command, depth) => {
699
+ const text = String(command).replace(/\\\r?\n/g, '');
700
+ const pattern = /("(?:[^"\\]|\\.)*"|'[^']*')\s*\|\s*(?:sh|bash|zsh|dash|ksh)\b/g;
701
+ let result = { verdict: 0, destructive: false };
702
+ for (const match of text.matchAll(pattern)) {
703
+ const content = match[1].slice(1, -1);
704
+ if (!content.trim()) continue;
705
+ result = mergeResults(result, nestedShellResult(content, depth));
706
+ }
707
+ return result;
708
+ };
709
+
710
+ /**
711
+ * Recursive unwrap: every quoted span that can execute a git write is rescanned
712
+ * (depth ≤ 3) and any nested write is asked. The strictest verdict wins.
713
+ */
714
+ const scanGitCommand = (command, depth = 0) => {
715
+ if (depth > MAX_SCAN_DEPTH) return { verdict: 2, destructive: false };
716
+ let result = { verdict: 0, destructive: false };
717
+ for (const segment of splitShellSegments(command)) {
718
+ result = mergeResults(result, directSegmentResult(segment));
719
+ result = mergeResults(result, quotedSegmentResult(segment, depth));
720
+ result = mergeResults(result, configSegmentResult(segment, depth));
721
+ }
722
+ return mergeResults(result, pipeQuotedResult(command, depth));
723
+ };
724
+
725
+ /**
726
+ * The decision for one shell event: `{ permission, user_message, agent_message }`.
727
+ *
728
+ * Shared by the CLI below and any host that can import the rendered file, so
729
+ * the verdict cannot drift between them. Three effects are injected — a project
730
+ * file read, a TCP probe and the settings resolver — because a plugin has no
731
+ * stdin to read and no guaranteed working directory. Never throws: an
732
+ * unreadable event is an allow, the same fail-open the hook always had.
733
+ */
734
+ export const evaluate = async (event, options = {}) => {
735
+ const {
736
+ root = process.cwd(),
737
+ exists = (file) => fs.existsSync(file),
738
+ readText = (file) => fs.readFileSync(file, 'utf8'),
739
+ canConnect = portIsOpen,
740
+ settings = importSettings,
741
+ } = options;
742
+ const at = (file) => path.join(root, file);
743
+ if (!event || typeof event !== 'object') return allowed();
744
+
745
+ const command = String(event.command || event.input?.command || event.tool_input?.command || '');
746
+ if (!command.trim()) return allowed();
747
+
748
+ // Recursively unwrap quoted inner shells before deciding: a quoted span that
749
+ // contains `git` (or is an `eval` / shell `-c` / pipe-to-shell payload) is
750
+ // rescanned at depth + 1, and any nested write asks. The strictest verdict
751
+ // across all segments and levels wins; the flag may only lift a positively
752
+ // recognised plain `commit`/`push`.
753
+ const gitScan = scanGitCommand(command, 0);
754
+ if (gitScan.verdict > 0) {
755
+ // An autonomous `/task-evil` run writes this marker before its first action;
756
+ // no human is attached, so the flag's `allow` must not reach it.
757
+ if (exists(at('.ai.local/team/.task-evil'))) {
758
+ return ask(
759
+ 'An autonomous /task-evil run cannot commit or push. Remove .ai.local/team/.task-evil only after the run ends.',
760
+ 'Do not commit or push in an autonomous run. Return a Human commits block; a human removes the marker and commits.',
761
+ );
762
+ }
763
+ if (gitScan.verdict === 2) {
764
+ return ask(
765
+ gitScan.destructive
766
+ ? 'This command looks destructive for git state. Review it before continuing.'
767
+ : 'This command wraps a git write in a quoted or indirect shell; confirm before running it.',
768
+ gitScan.destructive
769
+ ? 'A project hook flagged a destructive git command. Ask the user before running it.'
770
+ : 'A quoted or indirect shell command contains a git write. Ask the user before running it.',
771
+ );
772
+ }
773
+ let gitWritesAllowed = false;
774
+ try {
775
+ const getSetting = await settings({ root, exists, readText });
776
+ gitWritesAllowed = typeof getSetting === 'function' && getSetting('AI_RULES_ALLOW_GIT_WRITES') === true;
777
+ } catch {
778
+ gitWritesAllowed = false;
779
+ }
780
+ if (gitWritesAllowed) return allowed();
781
+ return ask(
782
+ 'Commits and pushes are gated. Set AI_RULES_ALLOW_GIT_WRITES=true in .ai.local/.env to allow them.',
783
+ 'Do not commit or push while AI_RULES_ALLOW_GIT_WRITES is not true. Return a Human commits block instead.',
784
+ );
785
+ }
786
+
787
+ if (/\b(?:pkill|killall)\b|\bxargs\s+kill\b/.test(command)) {
788
+ return ask(
789
+ 'This command can stop processes the task does not own. Name the process you started, or use `node .ai.local/scripts/processes.mjs stop`.',
790
+ 'Never mass-kill processes. Stop the recorded pid through processes.mjs; ask before pkill, killall, or xargs kill.',
791
+ );
792
+ }
793
+
794
+ const managerByFile = [
795
+ ['yarn.lock', 'yarn'],
796
+ ['pnpm-lock.yaml', 'pnpm'],
797
+ ['package-lock.json', 'npm'],
798
+ ].find(([file]) => exists(at(file)));
799
+
800
+ let expected = managerByFile?.[1];
801
+ if (!expected && exists(at('package.json'))) {
802
+ try {
803
+ const pkg = JSON.parse(readText(at('package.json')));
804
+ const pm = typeof pkg.packageManager === 'string' ? pkg.packageManager : '';
805
+ expected = pm.split('@')[0] || undefined;
806
+ } catch {
807
+ // Ignore invalid package.json in the hook; the agent can diagnose it later.
808
+ }
809
+ }
810
+
811
+ const used = expected ? command.match(/(^|[;&|]\s*)(npm|yarn|pnpm)\s+/)?.[2] : undefined;
812
+ if (used && used !== expected) {
813
+ return ask(
814
+ `This repository appears to use ${expected}, but the command uses ${used}. Confirm before continuing.`,
815
+ `Use ${expected} for package scripts and installs unless the user explicitly approves ${used}.`,
816
+ );
817
+ }
818
+
819
+ // Only a server-start shaped command is worth probing: the hook must not slow
820
+ // down or interrogate every shell call.
821
+ const explicitPortMatch = command.match(/--port[=\s]+(\d{2,5})|\bPORT=(\d{2,5})/);
822
+ const explicitPort = Number(explicitPortMatch?.[1] || explicitPortMatch?.[2] || 0) || null;
823
+ const startsServer = SERVER_COMMAND ? SERVER_COMMAND.test(command) : false;
824
+ const portsToProbe = startsServer ? (explicitPort ? [explicitPort] : SERVER_PORTS) : [];
825
+
826
+ for (const port of portsToProbe) {
827
+ if (!(await canConnect(port))) continue;
828
+ return ask(
829
+ `Port ${port} is already listening. Reuse the running server, or stop the recorded process before starting another.`,
830
+ `A server may already serve port ${port}. Probe it first, reuse it, or stop it with \`node .ai.local/scripts/processes.mjs stop\`; never start a duplicate.`,
831
+ );
832
+ }
833
+
834
+ return allowed();
835
+ };
836
+
837
+ /** The host answers: Claude's `PreToolUse` envelope, or the neutral decision. */
838
+ const answer = (event, decision) => {
839
+ const claudePreTool = event !== null && event.hook_event_name === 'PreToolUse';
840
+ if (!claudePreTool) {
841
+ process.stdout.write(JSON.stringify(decision));
842
+ } else {
843
+ const verdict = decision.permission === 'ask' || decision.permission === 'deny' ? decision.permission : 'allow';
844
+ const hookSpecificOutput = { hookEventName: 'PreToolUse', permissionDecision: verdict };
845
+ if (decision.user_message && verdict !== 'allow') {
846
+ hookSpecificOutput.permissionDecisionReason = decision.user_message;
847
+ }
848
+ process.stdout.write(JSON.stringify({ hookSpecificOutput }));
849
+ }
850
+ process.exit(0);
851
+ };
852
+
853
+ const main = async () => {
854
+ let event = null;
855
+ try {
856
+ const parsed = JSON.parse(fs.readFileSync(0, 'utf8'));
857
+ event = parsed && typeof parsed === 'object' ? parsed : null;
858
+ } catch {
859
+ event = null;
860
+ }
861
+ answer(event, await evaluate(event));
862
+ };
863
+
864
+ const invokedDirectly = (() => {
865
+ if (process.argv[1] === undefined) return false;
866
+ // Realpath on both sides: `os.tmpdir()` and `/tmp` are symlinks on macOS, so a
867
+ // plain resolve marks a script it cannot start.
868
+ try {
869
+ return fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
870
+ } catch {
871
+ return path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url));
872
+ }
873
+ })();
874
+
875
+ if (invokedDirectly) {
876
+ await main();
877
+ }