@bonesofspring/ai-rules 0.2.50 → 0.2.52

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 (400) hide show
  1. package/CHANGELOG.md +122 -1
  2. package/README.md +3 -1
  3. package/bin/cli.js +65 -13
  4. package/bin/lib/ai-local-drift.js +706 -0
  5. package/bin/lib/seed-ai-local-team.js +169 -40
  6. package/bin/mavis-install.js +8 -0
  7. package/bin/opencode-install.js +15 -2
  8. package/docs/LOCAL-OVERLAY.md +77 -1
  9. package/docs/PRESET-CONTRIBUTION.md +11 -9
  10. package/package.json +5 -1
  11. package/presets/_shared/ai-local/scripts/efficacy-oracle.mjs +1 -1
  12. package/presets/_shared/ai-local/scripts/manifest.mjs +13 -3
  13. package/presets/_shared/ai-local/scripts/rule-improver.mjs +872 -99
  14. package/presets/_shared/ai-local/scripts/run.mjs +76 -3
  15. package/presets/_shared/ai-local/scripts/signals.mjs +123 -7
  16. package/presets/_shared/core/meta/preset-pr-checklist.md +1 -1
  17. package/presets/_shared/core/quality/anti-hallucination-contract.md +2 -0
  18. package/presets/_shared/core/quality/interactive-questions.md +8 -8
  19. package/presets/_shared/core/review/code-review-mr.md +20 -1
  20. package/presets/_shared/core/review/receiving-code-review.md +7 -0
  21. package/presets/claude/android-kotlin/agents/code-reviewer.md +15 -0
  22. package/presets/claude/android-kotlin/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  23. package/presets/claude/android-kotlin/rules/tooling-and-review/code-review.md +20 -1
  24. package/presets/claude/android-kotlin/rules/tooling-and-review/interactive-questions.md +8 -8
  25. package/presets/claude/android-kotlin/rules/tooling-and-review/language-policy.md +1 -1
  26. package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  27. package/presets/claude/android-kotlin/skills/code-review/SKILL.md +11 -1
  28. package/presets/claude/go/agents/code-reviewer.md +37 -2
  29. package/presets/claude/go/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  30. package/presets/claude/go/rules/tooling-and-review/code-review.md +20 -1
  31. package/presets/claude/go/rules/tooling-and-review/interactive-questions.md +8 -8
  32. package/presets/claude/go/rules/tooling-and-review/language-policy.md +1 -1
  33. package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  34. package/presets/claude/go/skills/code-review/SKILL.md +10 -1
  35. package/presets/claude/ios-swift/agents/code-reviewer.md +15 -0
  36. package/presets/claude/ios-swift/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  37. package/presets/claude/ios-swift/rules/tooling-and-review/code-review.md +20 -1
  38. package/presets/claude/ios-swift/rules/tooling-and-review/interactive-questions.md +8 -8
  39. package/presets/claude/ios-swift/rules/tooling-and-review/language-policy.md +1 -1
  40. package/presets/claude/ios-swift/rules/tooling-and-review/post-change-build.md +1 -1
  41. package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  42. package/presets/claude/ios-swift/skills/code-review/SKILL.md +11 -1
  43. package/presets/claude/java/agents/code-reviewer.md +37 -2
  44. package/presets/claude/java/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  45. package/presets/claude/java/rules/tooling-and-review/code-review.md +20 -1
  46. package/presets/claude/java/rules/tooling-and-review/interactive-questions.md +8 -8
  47. package/presets/claude/java/rules/tooling-and-review/language-policy.md +1 -1
  48. package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  49. package/presets/claude/java/skills/code-review/SKILL.md +10 -1
  50. package/presets/claude/mcp-ts/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  51. package/presets/claude/mcp-ts/rules/tooling-and-review/code-review.md +20 -1
  52. package/presets/claude/mcp-ts/rules/tooling-and-review/interactive-questions.md +8 -8
  53. package/presets/claude/mcp-ts/rules/tooling-and-review/language-policy.md +1 -1
  54. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  55. package/presets/claude/mcp-ts/skills/code-review/SKILL.md +8 -0
  56. package/presets/claude/next/MCP.md +7 -0
  57. package/presets/claude/next/README.md +1 -1
  58. package/presets/claude/next/REPO_AGENTS.md +1 -1
  59. package/presets/claude/next/agents/README.md +3 -3
  60. package/presets/claude/next/agents/build-verifier.md +9 -3
  61. package/presets/claude/next/agents/code-reviewer.md +16 -1
  62. package/presets/claude/next/agents/codebase-analyzer.md +1 -1
  63. package/presets/claude/next/agents/feature-developer.md +18 -8
  64. package/presets/claude/next/agents/openspec-author.md +1 -1
  65. package/presets/claude/next/agents/playwright-test-generator.md +22 -68
  66. package/presets/claude/next/agents/playwright-test-healer.md +27 -54
  67. package/presets/claude/next/agents/playwright-test-planner.md +18 -51
  68. package/presets/claude/next/agents/task-analyst.md +25 -9
  69. package/presets/claude/next/agents/task-router.md +1 -1
  70. package/presets/claude/next/agents/tech-writer.md +1 -1
  71. package/presets/claude/next/mcp.json +3 -3
  72. package/presets/claude/next/rules/anti-hallucination/react-next-anti-hallucination.md +1 -1
  73. package/presets/claude/next/rules/architecture/layer-barrel-exports.md +1 -1
  74. package/presets/claude/next/rules/architecture/reference-features.md +1 -1
  75. package/presets/claude/next/rules/stack/navigation-router-ui.md +1 -1
  76. package/presets/claude/next/rules/stack/navigation-router.md +14 -0
  77. package/presets/claude/next/rules/stack/next-app-core.md +19 -17
  78. package/presets/claude/next/rules/stack/next-app-router.md +5 -17
  79. package/presets/claude/next/rules/stack/next-static-export.md +1 -1
  80. package/presets/claude/next/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  81. package/presets/claude/next/rules/tooling-and-review/code-review-mr.md +20 -1
  82. package/presets/claude/next/rules/tooling-and-review/interactive-questions.md +8 -8
  83. package/presets/claude/next/rules/tooling-and-review/language-policy.md +1 -1
  84. package/presets/claude/next/rules/tooling-and-review/post-change-lint.md +1 -1
  85. package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  86. package/presets/claude/next/rules/tooling-and-review/preset-token-budget.md +1 -1
  87. package/presets/claude/next/rules/tooling-and-review/security-next.md +28 -3
  88. package/presets/claude/next/rules/ui-and-accessibility/css-property-order.md +1 -1
  89. package/presets/claude/next/rules/ui-and-accessibility/design-tokens-binding.md +4 -4
  90. package/presets/claude/next/rules/ui-and-accessibility/forms-validation.md +2 -2
  91. package/presets/claude/next/skills/code-review/SKILL.md +12 -2
  92. package/presets/claude/next/team/README.md +11 -0
  93. package/presets/claude/next/team/fixtures/feature-with-figma-url.json +10 -0
  94. package/presets/claude/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
  95. package/presets/claude/next/team/fixtures/mockup-review-standalone.json +9 -0
  96. package/presets/claude/next/team/fixtures/ux-design-standalone.json +9 -0
  97. package/presets/claude/nuxt/agents/code-reviewer.md +15 -0
  98. package/presets/claude/nuxt/rules/architecture/layer-barrel-exports.md +1 -1
  99. package/presets/claude/nuxt/rules/stack/navigation-router-ui.md +1 -1
  100. package/presets/claude/nuxt/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  101. package/presets/claude/nuxt/rules/tooling-and-review/code-review-mr.md +20 -1
  102. package/presets/claude/nuxt/rules/tooling-and-review/interactive-questions.md +8 -8
  103. package/presets/claude/nuxt/rules/tooling-and-review/language-policy.md +1 -1
  104. package/presets/claude/nuxt/rules/tooling-and-review/post-change-lint.md +1 -1
  105. package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  106. package/presets/claude/nuxt/skills/code-review/SKILL.md +11 -1
  107. package/presets/claude/php-hexagonal/agents/code-reviewer.md +37 -2
  108. package/presets/claude/php-hexagonal/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  109. package/presets/claude/php-hexagonal/rules/tooling-and-review/code-review.md +20 -1
  110. package/presets/claude/php-hexagonal/rules/tooling-and-review/interactive-questions.md +8 -8
  111. package/presets/claude/php-hexagonal/rules/tooling-and-review/language-policy.md +1 -1
  112. package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  113. package/presets/claude/php-hexagonal/skills/code-review/SKILL.md +10 -1
  114. package/presets/claude/php-laravel/agents/code-reviewer.md +37 -2
  115. package/presets/claude/php-laravel/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  116. package/presets/claude/php-laravel/rules/tooling-and-review/code-review.md +20 -1
  117. package/presets/claude/php-laravel/rules/tooling-and-review/interactive-questions.md +8 -8
  118. package/presets/claude/php-laravel/rules/tooling-and-review/language-policy.md +1 -1
  119. package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  120. package/presets/claude/php-laravel/skills/code-review/SKILL.md +10 -1
  121. package/presets/claude/svelte/agents/code-reviewer.md +15 -0
  122. package/presets/claude/svelte/rules/architecture/layer-barrel-exports.md +1 -1
  123. package/presets/claude/svelte/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  124. package/presets/claude/svelte/rules/tooling-and-review/code-review-mr.md +20 -1
  125. package/presets/claude/svelte/rules/tooling-and-review/interactive-questions.md +8 -8
  126. package/presets/claude/svelte/rules/tooling-and-review/language-policy.md +1 -1
  127. package/presets/claude/svelte/rules/tooling-and-review/post-change-lint.md +1 -1
  128. package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  129. package/presets/claude/svelte/skills/code-review/SKILL.md +11 -1
  130. package/presets/cursor/android-kotlin/agents/code-reviewer.md +15 -0
  131. package/presets/cursor/android-kotlin/rules/README.md +1 -0
  132. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +3 -3
  133. package/presets/cursor/android-kotlin/rules/anti-hallucination-contract.mdc +2 -0
  134. package/presets/cursor/android-kotlin/rules/code-review-mr.mdc +20 -1
  135. package/presets/cursor/android-kotlin/rules/interactive-questions.mdc +8 -8
  136. package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +1 -1
  137. package/presets/cursor/android-kotlin/skills/code-review/SKILL.md +11 -1
  138. package/presets/cursor/go/agents/code-reviewer.md +37 -2
  139. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +2 -2
  140. package/presets/cursor/go/rules/anti-hallucination-contract.mdc +2 -0
  141. package/presets/cursor/go/rules/code-review-mr.mdc +20 -1
  142. package/presets/cursor/go/rules/interactive-questions.mdc +8 -8
  143. package/presets/cursor/go/rules/preset-pr-checklist.mdc +1 -1
  144. package/presets/cursor/go/skills/code-review/SKILL.md +10 -1
  145. package/presets/cursor/ios-swift/agents/code-reviewer.md +15 -0
  146. package/presets/cursor/ios-swift/rules/README.md +1 -0
  147. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +3 -3
  148. package/presets/cursor/ios-swift/rules/anti-hallucination-contract.mdc +2 -0
  149. package/presets/cursor/ios-swift/rules/code-review-mr.mdc +20 -1
  150. package/presets/cursor/ios-swift/rules/interactive-questions.mdc +8 -8
  151. package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +1 -1
  152. package/presets/cursor/ios-swift/skills/code-review/SKILL.md +11 -1
  153. package/presets/cursor/java/agents/code-reviewer.md +37 -2
  154. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +2 -2
  155. package/presets/cursor/java/rules/anti-hallucination-contract.mdc +2 -0
  156. package/presets/cursor/java/rules/code-review-mr.mdc +20 -1
  157. package/presets/cursor/java/rules/interactive-questions.mdc +8 -8
  158. package/presets/cursor/java/rules/preset-pr-checklist.mdc +1 -1
  159. package/presets/cursor/java/skills/code-review/SKILL.md +10 -1
  160. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +2 -2
  161. package/presets/cursor/mcp-ts/rules/anti-hallucination-contract.mdc +2 -0
  162. package/presets/cursor/mcp-ts/rules/code-review-mr.mdc +20 -1
  163. package/presets/cursor/mcp-ts/rules/interactive-questions.mdc +8 -8
  164. package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +1 -1
  165. package/presets/cursor/mcp-ts/skills/code-review/SKILL.md +8 -0
  166. package/presets/cursor/next/MCP.md +7 -0
  167. package/presets/cursor/next/REPO_AGENTS.md +1 -1
  168. package/presets/cursor/next/agents/code-reviewer.md +15 -0
  169. package/presets/cursor/next/agents/playwright-test-healer.md +1 -0
  170. package/presets/cursor/next/ai-local/rules-library/router-pages.md +5 -5
  171. package/presets/cursor/next/mcp.json +3 -3
  172. package/presets/cursor/next/rules/README.md +1 -1
  173. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +1 -1
  174. package/presets/cursor/next/rules/anti-hallucination-contract.mdc +2 -0
  175. package/presets/cursor/next/rules/code-review-mr.mdc +20 -1
  176. package/presets/cursor/next/rules/css-property-order-stylelint.mdc +1 -1
  177. package/presets/cursor/next/rules/design-tokens-binding.mdc +4 -4
  178. package/presets/cursor/next/rules/forms-validation.mdc +2 -2
  179. package/presets/cursor/next/rules/interactive-questions.mdc +8 -8
  180. package/presets/cursor/next/rules/navigation-router-stack.mdc +14 -1
  181. package/presets/cursor/next/rules/next-app-core.mdc +19 -17
  182. package/presets/cursor/next/rules/next-app-router.mdc +5 -17
  183. package/presets/cursor/next/rules/next-static-export.mdc +1 -1
  184. package/presets/cursor/next/rules/preset-pr-checklist.mdc +1 -1
  185. package/presets/cursor/next/rules/preset-token-budget.mdc +1 -1
  186. package/presets/cursor/next/rules/react-next-anti-hallucination.mdc +1 -1
  187. package/presets/cursor/next/rules/reference-features.mdc +1 -1
  188. package/presets/cursor/next/rules/security-next.mdc +28 -3
  189. package/presets/cursor/next/skills/code-review/SKILL.md +12 -2
  190. package/presets/cursor/next/team/README.md +11 -0
  191. package/presets/cursor/next/team/fixtures/feature-with-figma-url.json +10 -0
  192. package/presets/cursor/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
  193. package/presets/cursor/next/team/fixtures/mockup-review-standalone.json +9 -0
  194. package/presets/cursor/next/team/fixtures/ux-design-standalone.json +9 -0
  195. package/presets/cursor/nuxt/agents/code-reviewer.md +15 -0
  196. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
  197. package/presets/cursor/nuxt/rules/anti-hallucination-contract.mdc +2 -0
  198. package/presets/cursor/nuxt/rules/code-review-mr.mdc +20 -1
  199. package/presets/cursor/nuxt/rules/interactive-questions.mdc +8 -8
  200. package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +1 -1
  201. package/presets/cursor/nuxt/skills/code-review/SKILL.md +11 -1
  202. package/presets/cursor/php-hexagonal/agents/code-reviewer.md +37 -2
  203. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +2 -2
  204. package/presets/cursor/php-hexagonal/rules/anti-hallucination-contract.mdc +2 -0
  205. package/presets/cursor/php-hexagonal/rules/code-review-mr.mdc +20 -1
  206. package/presets/cursor/php-hexagonal/rules/interactive-questions.mdc +8 -8
  207. package/presets/cursor/php-hexagonal/rules/preset-pr-checklist.mdc +1 -1
  208. package/presets/cursor/php-hexagonal/skills/code-review/SKILL.md +10 -1
  209. package/presets/cursor/php-laravel/agents/code-reviewer.md +37 -2
  210. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +2 -2
  211. package/presets/cursor/php-laravel/rules/anti-hallucination-contract.mdc +2 -0
  212. package/presets/cursor/php-laravel/rules/code-review-mr.mdc +20 -1
  213. package/presets/cursor/php-laravel/rules/interactive-questions.mdc +8 -8
  214. package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +1 -1
  215. package/presets/cursor/php-laravel/skills/code-review/SKILL.md +10 -1
  216. package/presets/cursor/svelte/agents/code-reviewer.md +15 -0
  217. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
  218. package/presets/cursor/svelte/rules/anti-hallucination-contract.mdc +2 -0
  219. package/presets/cursor/svelte/rules/code-review-mr.mdc +20 -1
  220. package/presets/cursor/svelte/rules/interactive-questions.mdc +8 -8
  221. package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +1 -1
  222. package/presets/cursor/svelte/skills/code-review/SKILL.md +11 -1
  223. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  224. package/presets/mavis/android-kotlin/agents/code-reviewer.md +15 -0
  225. package/presets/mavis/android-kotlin/rules/anti-hallucination-contract.md +2 -0
  226. package/presets/mavis/android-kotlin/rules/code-review-mr.md +20 -1
  227. package/presets/mavis/android-kotlin/rules/interactive-questions.md +8 -8
  228. package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +1 -1
  229. package/presets/mavis/android-kotlin/skills/code-review/SKILL.md +11 -1
  230. package/presets/mavis/go/adapter-map.json +1 -1
  231. package/presets/mavis/go/agents/code-reviewer.md +37 -2
  232. package/presets/mavis/go/rules/anti-hallucination-contract.md +2 -0
  233. package/presets/mavis/go/rules/code-review-mr.md +20 -1
  234. package/presets/mavis/go/rules/interactive-questions.md +8 -8
  235. package/presets/mavis/go/rules/preset-pr-checklist.md +1 -1
  236. package/presets/mavis/go/skills/code-review/SKILL.md +10 -1
  237. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  238. package/presets/mavis/ios-swift/agents/code-reviewer.md +15 -0
  239. package/presets/mavis/ios-swift/rules/anti-hallucination-contract.md +2 -0
  240. package/presets/mavis/ios-swift/rules/code-review-mr.md +20 -1
  241. package/presets/mavis/ios-swift/rules/interactive-questions.md +8 -8
  242. package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +1 -1
  243. package/presets/mavis/ios-swift/skills/code-review/SKILL.md +11 -1
  244. package/presets/mavis/java/adapter-map.json +1 -1
  245. package/presets/mavis/java/agents/code-reviewer.md +37 -2
  246. package/presets/mavis/java/rules/anti-hallucination-contract.md +2 -0
  247. package/presets/mavis/java/rules/code-review-mr.md +20 -1
  248. package/presets/mavis/java/rules/interactive-questions.md +8 -8
  249. package/presets/mavis/java/rules/preset-pr-checklist.md +1 -1
  250. package/presets/mavis/java/skills/code-review/SKILL.md +10 -1
  251. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  252. package/presets/mavis/mcp-ts/rules/anti-hallucination-contract.md +2 -0
  253. package/presets/mavis/mcp-ts/rules/code-review-mr.md +20 -1
  254. package/presets/mavis/mcp-ts/rules/interactive-questions.md +8 -8
  255. package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +1 -1
  256. package/presets/mavis/mcp-ts/skills/code-review/SKILL.md +8 -0
  257. package/presets/mavis/next/MCP.md +7 -0
  258. package/presets/mavis/next/REPO_AGENTS.md +1 -1
  259. package/presets/mavis/next/adapter-map.json +1 -1
  260. package/presets/mavis/next/agents/code-reviewer.md +15 -0
  261. package/presets/mavis/next/agents/playwright-test-healer.md +1 -0
  262. package/presets/mavis/next/ai-local/rules-library/router-pages.md +5 -5
  263. package/presets/mavis/next/mcp.json +3 -3
  264. package/presets/mavis/next/rules/anti-hallucination-contract.md +2 -0
  265. package/presets/mavis/next/rules/code-review-mr.md +20 -1
  266. package/presets/mavis/next/rules/css-property-order-stylelint.md +1 -1
  267. package/presets/mavis/next/rules/design-tokens-binding.md +4 -4
  268. package/presets/mavis/next/rules/forms-validation.md +2 -2
  269. package/presets/mavis/next/rules/interactive-questions.md +8 -8
  270. package/presets/mavis/next/rules/navigation-router-stack.md +12 -0
  271. package/presets/mavis/next/rules/next-app-core.md +18 -17
  272. package/presets/mavis/next/rules/next-app-router.md +4 -17
  273. package/presets/mavis/next/rules/next-static-export.md +1 -1
  274. package/presets/mavis/next/rules/preset-pr-checklist.md +1 -1
  275. package/presets/mavis/next/rules/react-next-anti-hallucination.md +1 -1
  276. package/presets/mavis/next/rules/reference-features.md +1 -1
  277. package/presets/mavis/next/rules/security-next.md +24 -3
  278. package/presets/mavis/next/skills/code-review/SKILL.md +12 -2
  279. package/presets/mavis/next/team/README.md +11 -0
  280. package/presets/mavis/next/team/fixtures/feature-with-figma-url.json +10 -0
  281. package/presets/mavis/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
  282. package/presets/mavis/next/team/fixtures/mockup-review-standalone.json +9 -0
  283. package/presets/mavis/next/team/fixtures/ux-design-standalone.json +9 -0
  284. package/presets/mavis/nuxt/adapter-map.json +1 -1
  285. package/presets/mavis/nuxt/agents/code-reviewer.md +15 -0
  286. package/presets/mavis/nuxt/rules/anti-hallucination-contract.md +2 -0
  287. package/presets/mavis/nuxt/rules/code-review-mr.md +20 -1
  288. package/presets/mavis/nuxt/rules/interactive-questions.md +8 -8
  289. package/presets/mavis/nuxt/rules/preset-pr-checklist.md +1 -1
  290. package/presets/mavis/nuxt/skills/code-review/SKILL.md +11 -1
  291. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  292. package/presets/mavis/php-hexagonal/agents/code-reviewer.md +37 -2
  293. package/presets/mavis/php-hexagonal/rules/anti-hallucination-contract.md +2 -0
  294. package/presets/mavis/php-hexagonal/rules/code-review-mr.md +20 -1
  295. package/presets/mavis/php-hexagonal/rules/interactive-questions.md +8 -8
  296. package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +1 -1
  297. package/presets/mavis/php-hexagonal/skills/code-review/SKILL.md +10 -1
  298. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  299. package/presets/mavis/php-laravel/agents/code-reviewer.md +37 -2
  300. package/presets/mavis/php-laravel/rules/anti-hallucination-contract.md +2 -0
  301. package/presets/mavis/php-laravel/rules/code-review-mr.md +20 -1
  302. package/presets/mavis/php-laravel/rules/interactive-questions.md +8 -8
  303. package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +1 -1
  304. package/presets/mavis/php-laravel/skills/code-review/SKILL.md +10 -1
  305. package/presets/mavis/svelte/adapter-map.json +1 -1
  306. package/presets/mavis/svelte/agents/code-reviewer.md +15 -0
  307. package/presets/mavis/svelte/rules/anti-hallucination-contract.md +2 -0
  308. package/presets/mavis/svelte/rules/code-review-mr.md +20 -1
  309. package/presets/mavis/svelte/rules/interactive-questions.md +8 -8
  310. package/presets/mavis/svelte/rules/preset-pr-checklist.md +1 -1
  311. package/presets/mavis/svelte/skills/code-review/SKILL.md +11 -1
  312. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  313. package/presets/opencode/android-kotlin/agents/code-reviewer.md +15 -0
  314. package/presets/opencode/android-kotlin/rules/anti-hallucination-contract.md +2 -0
  315. package/presets/opencode/android-kotlin/rules/code-review-mr.md +20 -1
  316. package/presets/opencode/android-kotlin/rules/interactive-questions.md +8 -8
  317. package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +1 -1
  318. package/presets/opencode/android-kotlin/skills/code-review/SKILL.md +11 -1
  319. package/presets/opencode/go/adapter-map.json +1 -1
  320. package/presets/opencode/go/agents/code-reviewer.md +37 -2
  321. package/presets/opencode/go/rules/anti-hallucination-contract.md +2 -0
  322. package/presets/opencode/go/rules/code-review-mr.md +20 -1
  323. package/presets/opencode/go/rules/interactive-questions.md +8 -8
  324. package/presets/opencode/go/rules/preset-pr-checklist.md +1 -1
  325. package/presets/opencode/go/skills/code-review/SKILL.md +10 -1
  326. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  327. package/presets/opencode/ios-swift/agents/code-reviewer.md +15 -0
  328. package/presets/opencode/ios-swift/rules/anti-hallucination-contract.md +2 -0
  329. package/presets/opencode/ios-swift/rules/code-review-mr.md +20 -1
  330. package/presets/opencode/ios-swift/rules/interactive-questions.md +8 -8
  331. package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +1 -1
  332. package/presets/opencode/ios-swift/skills/code-review/SKILL.md +11 -1
  333. package/presets/opencode/java/adapter-map.json +1 -1
  334. package/presets/opencode/java/agents/code-reviewer.md +37 -2
  335. package/presets/opencode/java/rules/anti-hallucination-contract.md +2 -0
  336. package/presets/opencode/java/rules/code-review-mr.md +20 -1
  337. package/presets/opencode/java/rules/interactive-questions.md +8 -8
  338. package/presets/opencode/java/rules/preset-pr-checklist.md +1 -1
  339. package/presets/opencode/java/skills/code-review/SKILL.md +10 -1
  340. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  341. package/presets/opencode/mcp-ts/rules/anti-hallucination-contract.md +2 -0
  342. package/presets/opencode/mcp-ts/rules/code-review-mr.md +20 -1
  343. package/presets/opencode/mcp-ts/rules/interactive-questions.md +8 -8
  344. package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +1 -1
  345. package/presets/opencode/mcp-ts/skills/code-review/SKILL.md +8 -0
  346. package/presets/opencode/next/MCP.md +7 -0
  347. package/presets/opencode/next/REPO_AGENTS.md +1 -1
  348. package/presets/opencode/next/adapter-map.json +1 -1
  349. package/presets/opencode/next/agents/code-reviewer.md +15 -0
  350. package/presets/opencode/next/agents/playwright-test-healer.md +1 -0
  351. package/presets/opencode/next/ai-local/rules-library/router-pages.md +5 -5
  352. package/presets/opencode/next/opencode.json +3 -3
  353. package/presets/opencode/next/rules/anti-hallucination-contract.md +2 -0
  354. package/presets/opencode/next/rules/code-review-mr.md +20 -1
  355. package/presets/opencode/next/rules/css-property-order-stylelint.md +1 -1
  356. package/presets/opencode/next/rules/design-tokens-binding.md +4 -4
  357. package/presets/opencode/next/rules/forms-validation.md +2 -2
  358. package/presets/opencode/next/rules/interactive-questions.md +8 -8
  359. package/presets/opencode/next/rules/navigation-router-stack.md +12 -0
  360. package/presets/opencode/next/rules/next-app-core.md +18 -17
  361. package/presets/opencode/next/rules/next-app-router.md +4 -17
  362. package/presets/opencode/next/rules/next-static-export.md +1 -1
  363. package/presets/opencode/next/rules/preset-pr-checklist.md +1 -1
  364. package/presets/opencode/next/rules/react-next-anti-hallucination.md +1 -1
  365. package/presets/opencode/next/rules/reference-features.md +1 -1
  366. package/presets/opencode/next/rules/security-next.md +24 -3
  367. package/presets/opencode/next/skills/code-review/SKILL.md +12 -2
  368. package/presets/opencode/next/team/README.md +11 -0
  369. package/presets/opencode/next/team/fixtures/feature-with-figma-url.json +10 -0
  370. package/presets/opencode/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
  371. package/presets/opencode/next/team/fixtures/mockup-review-standalone.json +9 -0
  372. package/presets/opencode/next/team/fixtures/ux-design-standalone.json +9 -0
  373. package/presets/opencode/nuxt/adapter-map.json +1 -1
  374. package/presets/opencode/nuxt/agents/code-reviewer.md +15 -0
  375. package/presets/opencode/nuxt/rules/anti-hallucination-contract.md +2 -0
  376. package/presets/opencode/nuxt/rules/code-review-mr.md +20 -1
  377. package/presets/opencode/nuxt/rules/interactive-questions.md +8 -8
  378. package/presets/opencode/nuxt/rules/preset-pr-checklist.md +1 -1
  379. package/presets/opencode/nuxt/skills/code-review/SKILL.md +11 -1
  380. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  381. package/presets/opencode/php-hexagonal/agents/code-reviewer.md +37 -2
  382. package/presets/opencode/php-hexagonal/rules/anti-hallucination-contract.md +2 -0
  383. package/presets/opencode/php-hexagonal/rules/code-review-mr.md +20 -1
  384. package/presets/opencode/php-hexagonal/rules/interactive-questions.md +8 -8
  385. package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +1 -1
  386. package/presets/opencode/php-hexagonal/skills/code-review/SKILL.md +10 -1
  387. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  388. package/presets/opencode/php-laravel/agents/code-reviewer.md +37 -2
  389. package/presets/opencode/php-laravel/rules/anti-hallucination-contract.md +2 -0
  390. package/presets/opencode/php-laravel/rules/code-review-mr.md +20 -1
  391. package/presets/opencode/php-laravel/rules/interactive-questions.md +8 -8
  392. package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +1 -1
  393. package/presets/opencode/php-laravel/skills/code-review/SKILL.md +10 -1
  394. package/presets/opencode/svelte/adapter-map.json +1 -1
  395. package/presets/opencode/svelte/agents/code-reviewer.md +15 -0
  396. package/presets/opencode/svelte/rules/anti-hallucination-contract.md +2 -0
  397. package/presets/opencode/svelte/rules/code-review-mr.md +20 -1
  398. package/presets/opencode/svelte/rules/interactive-questions.md +8 -8
  399. package/presets/opencode/svelte/rules/preset-pr-checklist.md +1 -1
  400. package/presets/opencode/svelte/skills/code-review/SKILL.md +11 -1
@@ -11,8 +11,20 @@ const fs = require('fs');
11
11
  const path = require('path');
12
12
  const { assertSafeDest } = require('./safe-path');
13
13
  const { ENGINE_SCRIPTS, ENGINE_SOURCE_RELATIVE } = require('./engine-scripts');
14
+ const { runTemplateDrift } = require('./ai-local-drift');
14
15
 
15
16
  const LEGACY_TOOLS = ['cursor', 'claude', 'mavis', 'opencode'];
17
+ /** Content of `.ai.local/.gitignore`; also the template digest the record tracks. */
18
+ const AI_LOCAL_GITIGNORE = [
19
+ '# Files written by the in-task self-learning engine and by legacy-team',
20
+ '# migration backups. Local safety net — never commit.',
21
+ '*.lock',
22
+ '*.tmp',
23
+ '.rollback/',
24
+ '.template-base.json',
25
+ '*.intent',
26
+ '',
27
+ ].join('\n');
16
28
  const POINTER_README = `# Agent team artifacts moved
17
29
 
18
30
  Runtime artifacts now live at \`.ai.local/team/\` (shared across Cursor, Claude, Mavis, and OpenCode).
@@ -222,40 +234,49 @@ function ensureRollbackIgnored(rollbackRoot) {
222
234
  * scripts (`*.lock`, `*.tmp`) and the migration backups (`.rollback/`). A
223
235
  * `.gitignore` inside `.ai.local/` is used instead of appending to the
224
236
  * consumer's root `.gitignore`: the CLI never edits that file, and this works
225
- * even in a repo that has no `.gitignore` at all. Created only when absent.
237
+ * even in a repo that has no `.gitignore` at all. An existing file keeps its
238
+ * own lines; missing required lines are appended.
226
239
  */
227
240
  function ensureAiLocalIgnored(aiLocalRoot) {
228
241
  const ignoreFile = path.join(aiLocalRoot, '.gitignore');
229
- if (fs.existsSync(ignoreFile)) {
230
- return false;
231
- }
232
242
  fs.mkdirSync(aiLocalRoot, { recursive: true });
233
- fs.writeFileSync(
234
- ignoreFile,
235
- [
236
- '# Files written by the in-task self-learning engine and by legacy-team',
237
- '# migration backups. Local safety net — never commit.',
238
- '*.lock',
239
- '*.tmp',
240
- '.rollback/',
241
- '',
242
- ].join('\n'),
243
- );
243
+ const required = AI_LOCAL_GITIGNORE.split('\n').filter((line) => line !== '' && !line.startsWith('#'));
244
+ if (!fs.existsSync(ignoreFile)) {
245
+ fs.writeFileSync(ignoreFile, AI_LOCAL_GITIGNORE);
246
+ return true;
247
+ }
248
+ const current = fs.readFileSync(ignoreFile, 'utf8');
249
+ const present = new Set(current.split('\n').map((line) => line.trim()).filter(Boolean));
250
+ const missing = required.filter((line) => !present.has(line));
251
+ if (missing.length === 0) return false;
252
+ const suffix = current.endsWith('\n') || current.length === 0 ? '' : '\n';
253
+ fs.writeFileSync(ignoreFile, `${current}${suffix}${missing.join('\n')}\n`);
244
254
  return true;
245
255
  }
246
256
 
257
+ /**
258
+ * Preset-root-relative directory holding the shipped engine scripts.
259
+ * `presetTeamSrc` is `<presetBase>/team`, so three levels up is the preset root.
260
+ */
261
+ function engineSourceDir(presetTeamSrc) {
262
+ if (!presetTeamSrc) {
263
+ return null;
264
+ }
265
+ return path.resolve(presetTeamSrc, '..', '..', '..', ...ENGINE_SOURCE_RELATIVE.split('/'));
266
+ }
267
+
247
268
  /**
248
269
  * Seed the shipped self-learning engine (`presets/_shared/ai-local/scripts/`)
249
270
  * into `<cwd>/.ai.local/scripts/`. Skip-if-exists: a consumer edit is never
250
271
  * overwritten and there is no `--force`. Returns the absolute paths this call
251
- * created so an init rollback removes exactly those.
272
+ * created so an init rollback removes exactly those, plus the rels it wrote.
252
273
  */
253
274
  function seedEngineScripts({ cwd, presetTeamSrc }) {
254
- const result = { seeded: 0, skipped: 0, created: [] };
275
+ const result = { seeded: 0, skipped: 0, created: [], written: [] };
255
276
  if (!presetTeamSrc) {
256
277
  return result;
257
278
  }
258
- const sourceDir = path.resolve(presetTeamSrc, '..', '..', '..', ...ENGINE_SOURCE_RELATIVE.split('/'));
279
+ const sourceDir = engineSourceDir(presetTeamSrc);
259
280
  if (!fs.existsSync(sourceDir) || !fs.statSync(sourceDir).isDirectory()) {
260
281
  return result;
261
282
  }
@@ -276,6 +297,7 @@ function seedEngineScripts({ cwd, presetTeamSrc }) {
276
297
  copyFile(source, dest);
277
298
  result.seeded += 1;
278
299
  result.created.push(dest);
300
+ result.written.push(`.ai.local/scripts/${name}`);
279
301
  }
280
302
  if (!destExisted && result.created.length > 0) {
281
303
  result.created.unshift(destDir);
@@ -291,43 +313,53 @@ function seedEngineScripts({ cwd, presetTeamSrc }) {
291
313
  return result;
292
314
  }
293
315
 
316
+ /** Rewrite `team/README.md` and `team/fixtures/`; returns the rels it wrote. */
294
317
  function copyTemplates(presetTeamSrc, dest) {
318
+ const written = [];
295
319
  if (!presetTeamSrc || !fs.existsSync(presetTeamSrc)) {
296
- return;
320
+ return written;
297
321
  }
298
322
  const readme = path.join(presetTeamSrc, 'README.md');
299
323
  if (fs.existsSync(readme)) {
300
324
  copyFile(readme, path.join(dest, 'README.md'));
325
+ written.push('.ai.local/team/README.md');
301
326
  }
302
327
  const fixturesSrc = path.join(presetTeamSrc, 'fixtures');
303
328
  if (fs.existsSync(fixturesSrc)) {
304
- copyTree(fixturesSrc, path.join(dest, 'fixtures'));
329
+ const copied = copyTree(fixturesSrc, path.join(dest, 'fixtures')).copied;
330
+ for (const rel of copied) {
331
+ written.push(`.ai.local/team/fixtures/${rel}`);
332
+ }
305
333
  }
306
334
  const gitkeepSrc = path.join(presetTeamSrc, 'tasks', '.gitkeep');
307
335
  if (fs.existsSync(gitkeepSrc) && !hasConsumerTaskSlugs(path.join(dest, 'tasks'))) {
308
336
  copyFile(gitkeepSrc, path.join(dest, 'tasks', '.gitkeep'));
337
+ written.push('.ai.local/team/tasks/.gitkeep');
309
338
  }
339
+ return written;
310
340
  }
311
341
 
312
342
  /**
313
343
  * Seed `.ai.local/conventions.md` (the living-conventions file the overlay probes)
314
344
  * from the preset template. Never overwrites an existing consumer file.
345
+ *
346
+ * @returns {string | null} the rel this call wrote
315
347
  */
316
348
  function seedConventions(presetTeamSrc, cwd) {
317
349
  if (!presetTeamSrc) {
318
- return false;
350
+ return null;
319
351
  }
320
352
  const template = path.join(path.dirname(presetTeamSrc), 'ai-local', 'conventions.md');
321
353
  if (!fs.existsSync(template)) {
322
- return false;
354
+ return null;
323
355
  }
324
356
  const dest = path.join(cwd, '.ai.local', 'conventions.md');
325
357
  if (fs.existsSync(dest)) {
326
- return false;
358
+ return null;
327
359
  }
328
360
  copyFile(template, dest);
329
361
  console.log('Seeded .ai.local/conventions.md');
330
- return true;
362
+ return '.ai.local/conventions.md';
331
363
  }
332
364
 
333
365
  /**
@@ -340,7 +372,7 @@ function seedConventions(presetTeamSrc, cwd) {
340
372
  */
341
373
  function seedAiLocalRules(presetTeamSrc, cwd) {
342
374
  if (!presetTeamSrc) {
343
- return { seeded: false, created: [] };
375
+ return { seeded: false, created: [], written: [] };
344
376
  }
345
377
  const libraryDir = path.join(path.dirname(presetTeamSrc), 'ai-local', 'rules-library');
346
378
  if (!fs.existsSync(libraryDir) || !fs.statSync(libraryDir).isDirectory()) {
@@ -348,6 +380,7 @@ function seedAiLocalRules(presetTeamSrc, cwd) {
348
380
  }
349
381
  const destDir = path.join(cwd, '.ai.local', 'rules-library');
350
382
  assertSafeDest(cwd, destDir, '.ai.local/rules-library');
383
+ const written = [];
351
384
  let copied = 0;
352
385
  let skipped = 0;
353
386
  for (const entry of fs.readdirSync(libraryDir)) {
@@ -360,13 +393,21 @@ function seedAiLocalRules(presetTeamSrc, cwd) {
360
393
  }
361
394
  copyFile(src, dest);
362
395
  copied += 1;
396
+ written.push(`.ai.local/rules-library/${entry}`);
363
397
  }
364
398
  if (copied > 0) {
365
399
  console.log(`Seeded .ai.local/rules-library/ (${copied} rules; ${skipped} already present)`);
366
400
  }
367
- activateRouterPagesSeed(cwd, libraryDir);
401
+ const activated = activateRouterPagesSeed(cwd, libraryDir);
402
+ if (activated) {
403
+ written.push(activated);
404
+ }
368
405
  const active = seedActiveOverlayRules(presetTeamSrc, cwd);
369
- return { seeded: copied > 0 || active.seeded, created: active.created };
406
+ return {
407
+ seeded: copied > 0 || active.seeded,
408
+ created: active.created,
409
+ written: [...written, ...active.written],
410
+ };
370
411
  }
371
412
 
372
413
  /**
@@ -375,15 +416,16 @@ function seedAiLocalRules(presetTeamSrc, cwd) {
375
416
  */
376
417
  function seedActiveOverlayRules(presetTeamSrc, cwd) {
377
418
  if (!presetTeamSrc) {
378
- return { seeded: false, created: [] };
419
+ return { seeded: false, created: [], written: [] };
379
420
  }
380
421
  const rulesDir = path.join(path.dirname(presetTeamSrc), 'ai-local', 'rules');
381
422
  if (!fs.existsSync(rulesDir) || !fs.statSync(rulesDir).isDirectory()) {
382
- return { seeded: false, created: [] };
423
+ return { seeded: false, created: [], written: [] };
383
424
  }
384
425
  const destDir = path.join(cwd, '.ai.local', 'rules');
385
426
  assertSafeDest(cwd, destDir, '.ai.local/rules');
386
427
  const created = [];
428
+ const written = [];
387
429
  for (const entry of fs.readdirSync(rulesDir)) {
388
430
  if (!entry.endsWith('.md')) continue;
389
431
  const src = path.join(rulesDir, entry);
@@ -392,11 +434,12 @@ function seedActiveOverlayRules(presetTeamSrc, cwd) {
392
434
  if (fs.existsSync(dest)) continue;
393
435
  copyFile(src, dest);
394
436
  created.push(dest);
437
+ written.push(`.ai.local/rules/${entry}`);
395
438
  }
396
439
  if (created.length > 0) {
397
440
  console.log(`Activated .ai.local/rules/ (${created.length} rule${created.length === 1 ? '' : 's'})`);
398
441
  }
399
- return { seeded: created.length > 0, created };
442
+ return { seeded: created.length > 0, created, written };
400
443
  }
401
444
 
402
445
  function hasStaticExport(cwd) {
@@ -418,14 +461,16 @@ function hasPagesApp(cwd) {
418
461
  ].some((rel) => fs.existsSync(path.join(cwd, rel)));
419
462
  }
420
463
 
464
+ /** @returns {string | null} the rel written when the Pages Router seed activates */
421
465
  function activateRouterPagesSeed(cwd, libraryDir) {
422
466
  const seed = path.join(libraryDir, 'router-pages.md');
423
- if (!fs.existsSync(seed) || !hasStaticExport(cwd) || !hasPagesApp(cwd)) return;
467
+ if (!fs.existsSync(seed) || !hasStaticExport(cwd) || !hasPagesApp(cwd)) return null;
424
468
  const dest = path.join(cwd, '.ai.local', 'rules', 'router-pages.md');
425
469
  assertSafeDest(cwd, dest, '.ai.local/rules/router-pages.md');
426
- if (fs.existsSync(dest)) return;
470
+ if (fs.existsSync(dest)) return null;
427
471
  copyFile(seed, dest);
428
472
  console.log('Activated .ai.local/rules/router-pages.md (static export + Pages Router)');
473
+ return '.ai.local/rules/router-pages.md';
429
474
  }
430
475
 
431
476
  /**
@@ -564,13 +609,78 @@ function migrateLegacyTeams(cwd, dest) {
564
609
  }
565
610
 
566
611
  /**
567
- * @param {{ cwd: string, presetTeamSrc?: string }} options
612
+ * Every rel the preset can seed into `.ai.local/`, mapped to the template bytes.
613
+ * This is the allowlist the record and the merge use: it is built from the
614
+ * preset tree, never by walking the consumer's `.ai.local/`, so `team/tasks/**`,
615
+ * `requirements/**`, `adr/**`, and engine runtime state are unreachable.
616
+ *
617
+ * `.ai.local/team/**` is absent on purpose: `copyTemplates` rewrites
618
+ * `team/README.md` and `team/fixtures/**` unconditionally before anything can be
619
+ * classified, and `team/tasks/**` is consumer-owned, so recording any of them
620
+ * would promise a protection the seed does not give.
621
+ *
622
+ * @returns {Map<string, Buffer>} rel → template bytes
623
+ */
624
+ function templateEntries(presetTeamSrc) {
625
+ const out = new Map();
626
+ const addFile = (rel, abs) => {
627
+ let stat;
628
+ try {
629
+ stat = fs.lstatSync(abs);
630
+ } catch {
631
+ return;
632
+ }
633
+ if (!stat.isFile()) {
634
+ return;
635
+ }
636
+ out.set(rel, fs.readFileSync(abs));
637
+ };
638
+ const addDir = (relPrefix, dir, accept) => {
639
+ let stat;
640
+ try {
641
+ stat = fs.lstatSync(dir);
642
+ } catch {
643
+ return;
644
+ }
645
+ if (!stat.isDirectory()) {
646
+ return;
647
+ }
648
+ for (const name of fs.readdirSync(dir).sort()) {
649
+ if (!accept(name)) continue;
650
+ addFile(`${relPrefix}${name}`, path.join(dir, name));
651
+ }
652
+ };
653
+
654
+ if (!presetTeamSrc) {
655
+ return out;
656
+ }
657
+ const presetBase = path.dirname(presetTeamSrc);
658
+ const libraryDir = path.join(presetBase, 'ai-local', 'rules-library');
659
+ addFile('.ai.local/conventions.md', path.join(presetBase, 'ai-local', 'conventions.md'));
660
+ addDir('.ai.local/rules-library/', libraryDir, (name) => name.endsWith('.md'));
661
+ // The activation seed is a template byte too: `activateRouterPagesSeed` copies it
662
+ // into `rules/` when the repo shape matches, and an active copy shipped by the
663
+ // preset keeps precedence because it is added after this line.
664
+ addFile('.ai.local/rules/router-pages.md', path.join(libraryDir, 'router-pages.md'));
665
+ addDir('.ai.local/rules/', path.join(presetBase, 'ai-local', 'rules'), (name) => name.endsWith('.md'));
666
+ const engineDir = engineSourceDir(presetTeamSrc);
667
+ if (engineDir) {
668
+ for (const name of ENGINE_SCRIPTS) {
669
+ addFile(`.ai.local/scripts/${name}`, path.join(engineDir, name));
670
+ }
671
+ }
672
+ out.set('.ai.local/.gitignore', Buffer.from(AI_LOCAL_GITIGNORE));
673
+ return out;
674
+ }
675
+
676
+ /**
677
+ * @param {{ cwd: string, presetTeamSrc?: string, source?: string, packageVersion?: string, mergeAiLocal?: boolean, writeFile?: (dest: string, content: string | Buffer, label: string) => void, trackFile?: (dest: string, label: string) => void }} options
568
678
  * `createdPaths` lists what an init rollback may remove: the fresh-seed tree
569
679
  * plus every engine module / ignore file this call created (never a path that
570
680
  * already existed, never a consumer-modified file).
571
681
  * @returns {{ created: boolean, createdPaths: string[], migrated: boolean, refreshed: boolean, conventionsSeeded: boolean, rulesLibrarySeeded: boolean, engineSeeded: boolean }}
572
682
  */
573
- function seedAiLocalTeam({ cwd, presetTeamSrc }) {
683
+ function seedAiLocalTeam({ cwd, presetTeamSrc, source, packageVersion, mergeAiLocal, checkAiLocal, writeFile, trackFile }) {
574
684
  const dest = destTeamRoot(cwd);
575
685
  const aiLocalRoot = path.join(cwd, '.ai.local');
576
686
  const empty = {
@@ -623,14 +733,33 @@ function seedAiLocalTeam({ cwd, presetTeamSrc }) {
623
733
  ...engine.created,
624
734
  ];
625
735
  const migrated = migrateLegacyTeams(cwd, dest);
626
- copyTemplates(presetTeamSrc, dest);
627
- const conventionsSeeded = seedConventions(presetTeamSrc, cwd);
736
+ const templateWritten = copyTemplates(presetTeamSrc, dest);
737
+ const conventionsRel = seedConventions(presetTeamSrc, cwd);
628
738
  const rulesSeed = seedAiLocalRules(presetTeamSrc, cwd);
629
739
  const rulesLibrarySeeded = rulesSeed.seeded;
630
740
  if (!freshPaths.includes(path.join(aiLocalRoot, 'rules'))) {
631
741
  for (const created of rulesSeed.created) createdPaths.push(created);
632
742
  }
633
743
 
744
+ const written = [
745
+ ...templateWritten,
746
+ ...(conventionsRel ? [conventionsRel] : []),
747
+ ...rulesSeed.written,
748
+ ...engine.written,
749
+ ...(ignoreCreated ? ['.ai.local/.gitignore'] : []),
750
+ ];
751
+ runTemplateDrift({
752
+ cwd,
753
+ written,
754
+ templates: templateEntries(presetTeamSrc),
755
+ source,
756
+ packageVersion,
757
+ mergeAiLocal,
758
+ checkAiLocal,
759
+ writeFile,
760
+ trackFile,
761
+ });
762
+
634
763
  if (migrated) {
635
764
  console.log('Migrated legacy .{tool}/team → .ai.local/team');
636
765
  }
@@ -642,7 +771,7 @@ function seedAiLocalTeam({ cwd, presetTeamSrc }) {
642
771
  createdPaths,
643
772
  migrated: false,
644
773
  refreshed: false,
645
- conventionsSeeded,
774
+ conventionsSeeded: Boolean(conventionsRel),
646
775
  rulesLibrarySeeded,
647
776
  engineSeeded: engine.seeded > 0,
648
777
  };
@@ -659,7 +788,7 @@ function seedAiLocalTeam({ cwd, presetTeamSrc }) {
659
788
  createdPaths,
660
789
  migrated,
661
790
  refreshed: true,
662
- conventionsSeeded,
791
+ conventionsSeeded: Boolean(conventionsRel),
663
792
  rulesLibrarySeeded,
664
793
  engineSeeded: engine.seeded > 0,
665
794
  };
@@ -670,10 +799,10 @@ function seedAiLocalTeam({ cwd, presetTeamSrc }) {
670
799
  createdPaths,
671
800
  migrated,
672
801
  refreshed: false,
673
- conventionsSeeded,
802
+ conventionsSeeded: Boolean(conventionsRel),
674
803
  rulesLibrarySeeded,
675
804
  engineSeeded: engine.seeded > 0,
676
805
  };
677
806
  }
678
807
 
679
- module.exports = { seedAiLocalTeam, destTeamRoot };
808
+ module.exports = { seedAiLocalTeam, destTeamRoot, ensureAiLocalIgnored };
@@ -160,6 +160,8 @@ function cmdInitMavis({ preset, cwdOption, helpers }) {
160
160
  seedAiLocalTeam,
161
161
  installMcpJson,
162
162
  getPackageRoot,
163
+ mergeAiLocal,
164
+ checkAiLocal,
163
165
  } = helpers;
164
166
  const packageRoot = getPackageRoot();
165
167
  const cwd = resolveTargetCwd(cwdOption);
@@ -250,6 +252,12 @@ function cmdInitMavis({ preset, cwdOption, helpers }) {
250
252
  const teamResult = seedAiLocalTeam({
251
253
  cwd,
252
254
  presetTeamSrc: path.join(sourceBase, 'team'),
255
+ source: `mavis/${stack}`,
256
+ packageVersion: packageVersion(packageRoot),
257
+ mergeAiLocal: Boolean(mergeAiLocal),
258
+ checkAiLocal: Boolean(checkAiLocal),
259
+ writeFile: (dest, content, label) => tx.writeFile(dest, content, label),
260
+ trackFile: (dest, label) => tx.track(dest, label),
253
261
  });
254
262
  for (const created of teamResult.createdPaths || []) {
255
263
  tx.addCreated(created);
@@ -337,8 +337,15 @@ function installOpencodeJson(mcpFrom, mcpDestAbs, destLabel, tx, priorRecord) {
337
337
  }
338
338
 
339
339
  function cmdInitOpencode({ preset, cwdOption, helpers }) {
340
- const { resolveTargetCwd, validatePresetName, seedDocsSpecsIfAbsent, seedAiLocalTeam, getPackageRoot } =
341
- helpers;
340
+ const {
341
+ resolveTargetCwd,
342
+ validatePresetName,
343
+ seedDocsSpecsIfAbsent,
344
+ seedAiLocalTeam,
345
+ getPackageRoot,
346
+ mergeAiLocal,
347
+ checkAiLocal,
348
+ } = helpers;
342
349
  const packageRoot = getPackageRoot();
343
350
  const cwd = resolveTargetCwd(cwdOption);
344
351
  const contract = loadContract(packageRoot);
@@ -424,6 +431,12 @@ function cmdInitOpencode({ preset, cwdOption, helpers }) {
424
431
  const teamResult = seedAiLocalTeam({
425
432
  cwd,
426
433
  presetTeamSrc: path.join(sourceBase, 'team'),
434
+ source: `opencode/${stack}`,
435
+ packageVersion: packageVersion(packageRoot),
436
+ mergeAiLocal: Boolean(mergeAiLocal),
437
+ checkAiLocal: Boolean(checkAiLocal),
438
+ writeFile: (dest, content, label) => tx.writeFile(dest, content, label),
439
+ trackFile: (dest, label) => tx.track(dest, label),
427
440
  });
428
441
  for (const created of teamResult.createdPaths || []) {
429
442
  tx.addCreated(created);
@@ -19,6 +19,8 @@ Put a `.ai.local/` directory in your repo. Write rules as plain markdown. The `a
19
19
  └── tasks/<slug>/
20
20
  ```
21
21
 
22
+ `init` and `update` write `.ai.local/.template-base.json` — the digest of every `.ai.local/` file that holds a shipped template byte — so `update` can tell a file you edited from a file the preset moved. Your own bytes never become a base. See [Template drift](#template-drift).
23
+
22
24
  No IDE config, no `@include`, no codegen. Same files work in Cursor, Claude Code, Mavis, and OpenCode.
23
25
 
24
26
  ## How it works
@@ -31,7 +33,7 @@ No IDE config, no `@include`, no codegen. Same files work in Cursor, Claude Code
31
33
 
32
34
  ## Seed library (`.ai.local/rules-library/`)
33
35
 
34
- `init` copies `presets/<tool>/<stack>/ai-local/rules/*.md` into `.ai.local/rules/` and does not overwrite an existing file. The next stack ships `task-levels` there, so L0–L3 selection applies on install.
36
+ `init` copies `presets/<tool>/<stack>/ai-local/rules/*.md` into `.ai.local/rules/`; an existing consumer file is never overwritten by seeding. The one exception is opt-in and hash-gated: `update --merge-ai-local` may replace a file whose recorded base still matches — see [Template drift](#template-drift). The next stack ships `task-levels` there, so L0–L3 selection applies on install.
35
37
 
36
38
  `init` also seeds **staged-inactive** rule templates into `.ai.local/rules-library/`. They ship with every install but **do not apply** until you move a matching file into `.ai.local/rules/`.
37
39
 
@@ -44,6 +46,80 @@ The `ai-local-overlay` rule instructs the model to treat a matching seed as the
44
46
  git mv .ai.local/rules-library/router-pages.md .ai.local/rules/router-pages.md
45
47
  ```
46
48
 
49
+ ## Template drift
50
+
51
+ Your `.ai.local/` is yours. The preset still ships those files, so their text moves between releases — and until now nothing told you which of your files had moved and which you had edited.
52
+
53
+ `init` and `update` write **`.ai.local/.template-base.json`**:
54
+
55
+ ```json
56
+ {
57
+ "schemaVersion": 1,
58
+ "packageVersion": "0.2.50",
59
+ "files": {
60
+ ".ai.local/rules/task-levels.md": {
61
+ "sha256": "<digest of the seeded bytes>",
62
+ "normSha256": "<digest with line endings and trailing newlines normalised>",
63
+ "source": "cursor/next"
64
+ }
65
+ }
66
+ }
67
+ ```
68
+
69
+ - One entry per `.ai.local/` rel whose current bytes are a shipped template byte — the rels the seed wrote plus a file that already holds the current template. No tree walk, so `.ai.local/team/**`, `.ai.local/requirements/**`, `.ai.local/adr/**`, and the engine's runtime files are never recorded, never compared, and never written by the merge. `team/README.md` and `team/fixtures/**` are absent too: the seed refreshes them on every run, so a record of them would promise a protection it cannot give. **A file you edited is never recorded**: your bytes never become a base, so no later run can mistake them for an untouched template copy.
70
+ - Sorted keys, no timestamp, `source` = `<tool>/<preset>` (the tool that wrote the file keeps the attribution).
71
+ - The record is **not** in `<tool>/.ai-rules-install.json`, so `clean <tool>` still removes nothing under `.ai.local/`. Commit it: it is small and the next `update` rewrites it deterministically.
72
+
73
+ ### The default summary line
74
+
75
+ Plain `update` prints one line per tree when anything drifted — one, not one per installed tool:
76
+
77
+ ```text
78
+ .ai.local drift: 3 behind template, 1 edited locally (run with --merge-ai-local to fast-forward the untouched ones)
79
+ ```
80
+
81
+ *Behind* means the preset text moved and your file still holds the recorded base — only those files are ever fast-forwarded. *Edited locally* means your bytes differ from both the base and the current template: you changed the file, or the file predates the record and cannot be attributed. The line writes nothing to a consumer file; it is a report.
82
+
83
+ Every installed tool's pass classifies its own template map. Each rel is counted once per tree: the first pass reports it, and a later pass does not add it again or replace its proposal. A later pass whose template already matches the file adopts it and drops that proposal. Files two tools own separately still both appear, so `init claude` followed by `init cursor` reports the same rels as a `cursor`-first tree. The line itself is printed once per tree, after the last pass of the command.
84
+
85
+ ### `update --merge-ai-local`
86
+
87
+ The flag is opt-in, and it never touches a file you edited:
88
+
89
+ | Your file | Outcome | What the run does |
90
+ |---|---|---|
91
+ | Still holds the recorded base, preset moved | fast-forward | writes the preset bytes, re-records both digests, prints `merge-ai-local: fast-forward <rel>` |
92
+ | Already equals the current template, but has no base or a stale one (installed before this feature, the seed skipped it, or you applied a proposal yourself) | adopt | records the **template** digests as the base, **writes nothing**, prints `merge-ai-local: adopt <rel>` |
93
+ | Differs from both the base and the current template — you edited it | drift | keeps your file byte-identical, writes a unified diff and the preset copy to `.ai.local/.rollback/template-drift/`, prints `merge-ai-local: drift <rel> → <diff>` |
94
+ | Recorded by another tool or preset | noop | this pass leaves it alone; a `source` of `claude/next` is never fast-forwarded by a `cursor/next` run — the writing tool's own pass decides it, so a tool you `clean`ed stops reporting its files until you install it again (see limits below) |
95
+
96
+ The sink is `<rel with / → __>.diff` plus `<…>.template-new`. No sink entry ends in `.md` and nothing is created under `rules/` or beside `conventions.md`: the overlay probe loads every `*.md` under `rules/`, so a sidecar there would be read as instruction text. **No conflict marker is ever written under `.ai.local/**`** — a divergence is a diff you apply, never a `<<<<<<<` you clean up.
97
+
98
+ Two consecutive flagged runs leave the tree byte-identical; the second reports zero fast-forwards. A file that is still drifted keeps its `kept edited locally` count and its proposal, so a still-drifted tree repeats the line rather than going silent. A four-tool `update` merges once per tree, because `.ai.local/` is one tree with one record. Apply the proposal yourself and the next `update` (flagged or not) adopts the file instead of reporting it again.
99
+
100
+ ### First run on a pre-feature tree
101
+
102
+ The record only exists from the release that introduced it. On a tree installed earlier, the first `update` (the flag is not required for this step) records every file that already holds the shipped template; nothing is overwritten, and a file that differs is reported as *edited locally* instead of being recorded. `init` records the base immediately, so a fresh install needs no adoption step. The next release then has something to compare against.
103
+
104
+ Recording is deliberately conservative: a file whose bytes differ from the current template is never adopted, because a base equal to your bytes would make the *next* preset release fast-forward over your edit.
105
+
106
+ ### Limits — what stays manual
107
+
108
+ - **`conventions.md` body edits.** Your prose is the part the preset cannot know. Only line-ending and trailing-newline churn is normalised away; a wording change stays a reported diff.
109
+ - **A rule you rewrote.** Local rules win by contract; replacing one changes precedence, not just bytes. It is reported as *edited locally*, never fast-forwarded, and never becomes a base — apply the proposal if you want the preset text, and the next run records the result.
110
+ - **A file whose owning tool you `clean`ed.** The record keeps the `source` of the tool that wrote a file, and only that tool's pass classifies it. `clean claude` leaves the record and that `source` in place, so a file attributed to `claude` is neither reported nor merged — even when another installed tool ships a newer copy — until you run `init claude` again. Deleting the entry from `.ai.local/.template-base.json` re-attributes the file to the next pass that ships it: if it already matches that preset's template, the next `update` records it; if not, the flagged run offers a diff instead, and applying it completes the re-attribution.
111
+ - **Both sides changed.** The sink shows the diff; resolution is yours.
112
+ - **`override: kill` and `i18n-keep` disagreements.** A fast-forward copies the preset file whole, so it can neither move nor duplicate a marker — and a disagreement is reported rather than resolved.
113
+ - **`.ai.local/team/**`, `.ai.local/requirements/**`, `.ai.local/adr/**`, engine runtime state.** Out of scope by allowlist. `team/README.md` and `team/fixtures/**` are refreshed by the seed on every run before any comparison, so edit them and your edit is gone — they are seed-owned, not drift-tracked, and never reported.
114
+ - **A file you deleted.** The next `init` or `update` copies it again when the destination is absent: `conventions.md`, a file under `rules/`, and a file under `rules-library/`. `team/tasks/**` is not re-seeded. A rel the owning preset no longer ships loses its record entry and its proposal on the next flagged run, so the record does not accumulate dead keys.
115
+ - **A record written by a newer CLI.** A `schemaVersion` above this CLI's own makes it skip the record and the merge with a warning rather than rewrite the file as v1.
116
+ - **An activated seed** (`rules-library/X.md` → `rules/X.md`). Activation stays a judgement call; the pair is not auto-merged.
117
+ - **Three-way merge.** Not implemented: without a stored copy of the old preset bytes a line merge would invent conflicts inside files that load on every turn.
118
+
119
+ ### Git noise
120
+
121
+ On a tree installed before `.ai.local/.gitignore` carried `.rollback/`, the sink shows up as untracked files. That is noise, not data loss: the directory is a tool-owned proposal area, safe to delete, and a fresh install ignores it from the start. The root `.gitignore` is never edited.
122
+
47
123
  ## How to write `.ai.local/rules/*.md`
48
124
 
49
125
  One file = one rule. Plain markdown. **No YAML frontmatter** — the format is shared across IDEs, so each file uses a tiny markdown header for scoping.
@@ -19,7 +19,7 @@ Every preset artifact belongs to one of these layers. Do not mix semantics acros
19
19
  | Layer | Path | What belongs here |
20
20
  |-------|------|-------------------|
21
21
  | **Core** | `presets/_shared/core/**` | Stack-agnostic prose and checklists. No Cursor/Claude frontmatter. No stack paths (`app/src/**`, `Features/**`, Playwright, `xcodebuild`). |
22
- | **Stack** | `presets/{cursor\|claude}/<stack>/` | Domain rules, stack always-on trio, stack tooling, stack examples in a delimited `## Stack notes` section. |
22
+ | **Stack** | `presets/{cursor\|claude}/<stack>/` | Domain rules, stack always-on set, stack tooling, stack examples in a delimited `## Stack notes` section. |
23
23
  | **Platform** | Same stack tree | Adapter packaging: Cursor `.mdc` (`alwaysApply` / `globs`) vs Claude `.md` (`paths:`). Platform-only files (`BUGBOT.md`, `AGENTS.md`, `CLAUDE.md`, `hooks.json`). |
24
24
 
25
25
  ```text
@@ -169,7 +169,7 @@ Summary:
169
169
  - [ ] Embed drift: `scripts/check-shared-core-drift.sh` after core/embed edits
170
170
  - [ ] Anti-hallucination: `check-anti-hallucination-coverage.mjs` passes. New skill families are registered in `SKILL_CONTRACT_CLASS` (`writer` loads the stack floor; `reader` loads the contract only). `code-review` is `writer`.
171
171
  - [ ] Structure gates: `yarn check:preset-structure` (or `bash scripts/check-preset-structure.sh`) passes
172
- - [ ] Twin drift: after editing a Claude `commands/**` or `skills/**` file, `node scripts/check-preset-twin-drift.mjs` passes — mirror the change in the Cursor twin (delta unchanged) or record a deliberate divergence with `--update`
172
+ - [ ] Twin drift: after editing a Claude `commands/**` or `skills/**` file, `node scripts/check-preset-twin-drift.mjs` passes — mirror the change in the Cursor twin (delta and divergence unchanged) or record a deliberate divergence with `--update`. A deliberate divergence that **raises** an allowance needs `--update --widen`; dropping a baseline row needs `--update --prune`. A plain `--update` refuses both.
173
173
  - [ ] Generated trees regenerated (`generate-mavis.mjs` + `generate-opencode.mjs`) and CLI goldens recaptured (`capture-cli-golden.mjs`) after any preset-installed file changes
174
174
 
175
175
  Validation: `yarn check:preset-structure` + the `preset-pr-checklist` rule; CI workflow `preset-structure.yml` (`check`, `hooks`, `ai-local-engine-tests`).
@@ -271,7 +271,7 @@ Distinct CLI ids; neither renames nor replaces the other. Comparison prose in st
271
271
  Recent additions: **`android-kotlin`** (scaffolded from `ios-swift` agent-team + `java` CA/Gradle patterns; instrumentation-test trio; vendor-neutral placeholders); **`php-hexagonal`** (scaffolded from `java`, Composer/PHPUnit gates; dogfood `dogfood/php-hexagonal`); **`php-laravel`** (scaffolded from `php-hexagonal`, Laravel-first rules; dogfood `dogfood/php-laravel` — full `laravel/framework`).
272
272
 
273
273
  1. **Copy structure** from the closest existing stack (flat Cursor `rules/*.mdc`, Claude topic folders). For PHP/Go backends, start from `java` or `go` skeleton and rewrite Stack notes / tooling.
274
- 2. **Define always-on set** (Cursor/Claude 3–10 — extra slots reserved for `ai-local-overlay`) — stack-specific cores plus `ai-local-overlay` on Cursor. Embed shared quality from `_shared/core` where applicable. `go` uses `go-app-core`, `architecture-boundaries`, `code-quality-and-refactoring`, `ai-local-overlay`.
274
+ 2. **Define always-on set** (Cursor/Claude 3–10 — extra slots reserved for `ai-local-overlay`) — stack-specific cores plus `ai-local-overlay` on both Cursor and Claude. Embed shared quality from `_shared/core` where applicable. `go` uses `go-app-core`, `architecture-boundaries`, `code-quality-and-refactoring`, `ai-local-overlay`.
275
275
  3. **Stack-specific rules** — domain, tooling, post-change gate, agents/skills with stack-appropriate names (no Playwright stems on iOS/go, no XCUITest stems on Next/go, no xcodebuild/ESLint as required handoffs on go, etc.).
276
276
  4. **Embed core** — add `<!-- shared-core: … -->` adapters for shared stems; fill `## Stack notes` with stack examples only in adapters (Go: hexagonal layers; Android: Activity/Compose paths).
277
277
  5. **Claude twin** — create topic `.md` files + **Cursor→Claude mapping table** in `claude/<stack>/rules/README.md`. `go` ships `ui-and-accessibility/README.md` as N/A stub only.
@@ -309,7 +309,7 @@ impact: HIGH # CRITICAL | HIGH | MEDIUM | LOW
309
309
  - Claude twins: **mirror the same `impact:` key/value** in YAML frontmatter (with `paths:`).
310
310
  - **Do not** use a body `## Impact` block — frontmatter only.
311
311
  - **Forbidden** in `_shared/core/**` (core has no frontmatter).
312
- - Structure scripts ignore unknown YAML keys; `check:preset-structure` does **not** require `impact`. Opt-in `yarn check:rule-eval` may require it for golden stems.
312
+ - Structure scripts ignore unknown YAML keys; `check:preset-structure` does **not** require `impact`. `yarn check:rule-eval` requires it for registered golden stems.
313
313
 
314
314
  ---
315
315
 
@@ -396,20 +396,22 @@ Load these when editing files under `packages/ai-rules/presets/**`, `.cursor/**`
396
396
  |--------------|---------|
397
397
  | `yarn fix:generated` | Regenerate every released generated platform and recapture all required CLI goldens. Run after changing Cursor SoT, before fail-only checks. Dogfood sync remains separate. |
398
398
  | `scripts/sync-dogfood-cursor.sh` | Copy `presets/cursor/<preset>/` → root `.cursor/` (`AI_RULES_DOGFOOD_PRESET`, default `next`). Also copies `REPO_AGENTS.md` → repo-root `AGENTS.md`. Seeds `.ai.local/team` templates; preserves `.ai.local/team/tasks/`. |
399
- | `scripts/check-shared-core-drift.sh` / `yarn check:shared-core-drift` | Check embed-mode adapters vs core; lists lineage consumers. **Always hard:** every `_shared/core/**` file must be classified `embed | lineage | internal` in `_lib/embed-stems.json` (unclassified → exit 1). Drift is soft by default; set `AI_RULES_DRIFT_FAIL=1` (or use `check:preset-structure`) to exit non-zero. |
399
+ | `scripts/check-shared-core-drift.sh` / `yarn check:shared-core-drift` | Check embed-mode adapters vs core; lists lineage consumers. **Always hard:** every `_shared/core/**` file must be classified `embed | lineage | internal` in `_lib/embed-stems.json` (unclassified → exit 1). Drift is soft by default; set `AI_RULES_DRIFT_FAIL=1` (or use `check:preset-structure`) to exit non-zero. A stem listed in `requiredSentences` is checked in the core **and in every adapter of that stem, whatever the lineage class** — the body comparison cannot cover a platform whose adapter is not a byte-embed of the core (the Cursor family reorders, omits and adds sections), so the normative fragments of that stem are pinned separately. |
400
400
  | `scripts/check-preset-twin-map.sh` / `yarn check:preset-twin-map` | **FAIL** if Cursor `.mdc` missing from Claude mapping table, twin file missing, or orphan topic `.md` (excl. `**/README.md`). Stacks: `next`, `nuxt`, `svelte`, `ios-swift`, `android-kotlin`, `go`, `java`, `mcp-ts`, `php-hexagonal`, `php-laravel`. **Rules only** — commands and skills are guarded by `check-preset-twin-drift.mjs`. |
401
- | `scripts/check-preset-twin-drift.mjs` / `yarn check:preset-twin-drift` | **FAIL** when a hand-maintained Claude twin (`presets/claude/<stack>/{commands,skills}/**/*.md`) drifts further from its Cursor source than `scripts/_lib/claude-twin-drift-baseline.json` records, when a command/skill has no twin on the other side, or when a new pair has no baseline row. Full parity is not required: mirror a change in both twins (delta unchanged) or record a deliberate divergence with `--update`. Fixture `test-preset-twin-drift.mjs`. |
401
+ | `scripts/check-preset-twin-drift.mjs` / `yarn check:preset-twin-drift` | **FAIL** when a hand-maintained Claude twin (`presets/claude/<stack>/{commands,skills}/**/*.md`) drifts further from its Cursor source than `scripts/_lib/claude-twin-drift-baseline.json` records, when the recorded divergence between the twins changes while the line delta does not, when a command/skill has no twin on the other side, when a new pair has no baseline row, when a baseline row has no live pair, or when the baseline itself is missing its hash rows. Full parity is not required: mirror a change in both twins (delta and divergence unchanged) or record a deliberate divergence with `--update`. Raising an allowance needs `--update --widen`; dropping a row needs `--update --prune`. Fixture `test-preset-twin-drift.mjs`. |
402
+ | `scripts/check-claude-agent-parity.mjs` / `yarn check:claude-agent-parity` | **FAIL** when a hand-maintained Claude `agents/*.md` twin drifts from its Cursor source beyond `scripts/_lib/claude-agent-parity-baseline.json`: a grown or shrunk normalized line delta, a one-sided rewrite at an unchanged delta, a changed divergence hash, a missing twin, an unrecorded pair, an orphan row, or a pair in the static `parity` allowlist that is not at delta 0. Normalization masks packaging only — YAML frontmatter, the `## Rules to load (subagent context)` block, `<!-- shared-core -->` markers, the two anti-hallucination load lines, the `.cursor/` / `.claude/` root, and `.mdc` → `.md` — and reuses the twin-drift diff helpers. `--update` re-records deltas and hashes; `--widen` / `--prune` gate a raised allowance or a dropped row; `parity` is never edited by `--update`. Fixture `test-claude-agent-parity.mjs` proves one-sided Claude FAIL, one-sided Cursor FAIL and mirrored PASS. Wired into `check-preset-structure.sh` next to `claude-agent-blocks`. |
403
+ | `scripts/check-consumer-links.mjs` / `yarn check:consumer-links` | **FAIL** when a generated Claude rule or agent carries a source-only `.cursor/` path or a `.mdc` reference whose stem resolves through `claude/<stack>/rules/README.md`; `README.md` and `preset-*.md` are exempt by class. `scripts/_lib/claude-consumer-link-allowlist.json` records the legitimate lines one hash at a time; a stale row fails, and a planted line in an allowlisted file still fails unless it matches the recorded hash. `--update` re-hashes recorded rows only and refuses to add one. Scans `next` by default; `--stack` opts another stack in. Fixture `test-consumer-links.mjs`. Wired into `check-preset-structure.sh` next to `generated-drift`. |
402
404
  | `scripts/check-preset-token-budget.sh` / `yarn check:preset-token-budget` | **FAIL** if Cursor `alwaysApply: true` or Claude no-`paths:` (excl. README) count is outside **3–10**, `preset-*` always-on, or intended body sum > **4000**. Stacks include `nuxt`, `svelte`. |
403
405
  | `scripts/check-preset-leakage.sh` / `yarn check:preset-leakage` | **FAIL** on forbidden stems in `hooks/**/*.sh` (recursive), wrong-stack agent filenames, or **positive** (non-negation) agent body mentions; **FAIL** if chain scripts are byte-identical across stacks. Explicit **negation** of forbidden stems in agent bodies is **suppressed** (INFO summary count only — not a merge blocker). Non-negation mentions in `build-verifier` → **WARN only**. |
404
406
  | `scripts/check-preset-prompt-persistence.sh` / `yarn check:preset-structure` | **FAIL** if the prompt-persistence contract (`prompt.md` + the append-only `prompt-log.md` ledger, both on the `routing` entry) is missing from any platform × stack command (`task.md` + `task-continue.md`), orchestrator, or intake body, from the **always-on** root `REPO_AGENTS.md` entry (check **E** — reachability without `/task`), or a core `agent-artifact-contracts` anchor (`## Prompt artifact` / `## Prompt log`) is gone; **refuses vacuous PASS** when the iteration set is empty. Wired into `check-preset-structure.sh` next to `goal-contract`; fixture `test-preset-prompt-persistence-fixtures.mjs`. |
405
407
  | `scripts/check-preset-reachability.sh` / `yarn check:preset-reachability` | **FAIL** if a non-`preset-*` OpenCode/Mavis rule is reachable by neither a direct reference (entry / agent / command / skill) nor the transitive closure of rule→rule references from the `root-entry` rules. `preset-*` meta rules are exempt as preset-authoring-only. **Refuses vacuous PASS** on an empty iteration set. Wired into `check-preset-structure.sh` next to `prompt-persistence`. |
406
408
  | `scripts/check-preset-language-policy.sh` / `yarn check:preset-structure` | **FAIL** if the native-language policy is absent: the core `_shared/core/agent-team/language-policy.md` tokens, the `language-policy` consumer + `<!-- shared-core -->` marker, the Cursor `globs:`/`alwaysApply: false` + Claude `paths:` shape, the `## Language` setting home (with a BCP-47 marker) in `ai-local/conventions.md`, the always-on anchors (`ai-local-overlay` + `<app-core>` + `REPO_AGENTS.md` must contain `native language` and `every user message`), or the `language:` persistence token in `commands/task.md`; **refuses vacuous PASS** when the iteration set is empty. Wired into `check-preset-structure.sh` next to `goal-contract` / `prompt-persistence`; fixture `test-preset-language-policy-fixtures.mjs`. |
407
- | `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 — a spliced tail fails), 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`. |
409
+ | `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`. |
408
410
  | `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`. |
409
- | `scripts/check-preset-structure.sh` / `yarn check:preset-structure` | Orchestrator: twin-map + token-budget + leakage + shared-core drift + anti-hallucination coverage (**all hard**; drift via `AI_RULES_DRIFT_FAIL=1`). Does **not** run rule-eval. |
411
+ | `scripts/check-preset-structure.sh` / `yarn check:preset-structure` | Orchestrator: twin-map + token-budget + leakage + shared-core drift + anti-hallucination coverage + rule-eval (**all hard**; drift via `AI_RULES_DRIFT_FAIL=1`). |
410
412
  | `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. |
411
413
  | `yarn check:product-specs:dogfood` | Same script against monorepo `dogfood/mcp-ts-sample`. Soft WARN inside `check:preset-structure` + CI step (`continue-on-error`); not a hard consumer CI gate. |
412
- | `scripts/check-rule-eval.mjs` / `yarn check:rule-eval` | Opt-in: 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>/`. Not part of `check:preset-structure`. |
414
+ | `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>/`. |
413
415
  | `scripts/check-release-consistency.mjs` / `yarn check:release-consistency` | **FAIL** when `packages/ai-rules/package.json` version and the newest `## <version>` heading in `CHANGELOG.md` disagree — a tag must not ship the previous release's notes. Wired into `check-preset-structure.sh`; fixture `test-release-consistency.mjs`. |
414
416
 
415
417
  Run from `packages/ai-rules/`: