@bonesofspring/ai-rules 0.2.51 → 0.2.53

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 (376) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/README.md +27 -3
  3. package/bin/cli.js +565 -61
  4. package/bin/lib/ai-local-drift.js +55 -14
  5. package/bin/lib/engine-scripts.js +10 -0
  6. package/bin/lib/mcp/clients.js +168 -0
  7. package/bin/lib/mcp/credentials.js +298 -0
  8. package/bin/lib/mcp/doctor.js +394 -0
  9. package/bin/lib/mcp/prompt.js +115 -0
  10. package/bin/lib/mcp/registry.js +170 -0
  11. package/bin/lib/mcp/run.js +123 -0
  12. package/bin/lib/merged-config.js +45 -0
  13. package/bin/lib/seed-ai-local-team.js +23 -7
  14. package/bin/lib/tool-installs.js +27 -0
  15. package/bin/mavis-install.js +2 -0
  16. package/bin/opencode-install.js +2 -0
  17. package/docs/LOCAL-OVERLAY.md +1 -1
  18. package/docs/MCP-SETUP.md +62 -0
  19. package/docs/PRESET-CONTRIBUTION.md +14 -10
  20. package/docs/TEAM-DB.md +173 -0
  21. package/docs/openapi/team-db.v1.json +5085 -0
  22. package/mcp/gitlab.mjs +123 -0
  23. package/mcp/lib/envfile.mjs +126 -0
  24. package/mcp/lib/yandex.mjs +384 -0
  25. package/mcp/yandex-mcp-proxy.mjs +155 -0
  26. package/mcp/yandex-token-refresh.mjs +65 -0
  27. package/package.json +18 -1
  28. package/presets/_shared/ai-local/scripts/manifest.mjs +112 -3
  29. package/presets/_shared/ai-local/scripts/rule-improver.mjs +428 -91
  30. package/presets/_shared/ai-local/scripts/run.mjs +22 -4
  31. package/presets/_shared/ai-local/scripts/signals.mjs +4 -1
  32. package/presets/_shared/ai-local/scripts/team-db-api.mjs +1275 -0
  33. package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +1067 -0
  34. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +1301 -0
  35. package/presets/_shared/ai-local/scripts/team-db-project.mjs +1506 -0
  36. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +831 -0
  37. package/presets/_shared/ai-local/scripts/team-db.mjs +251 -0
  38. package/presets/_shared/core/meta/preset-pr-checklist.md +1 -1
  39. package/presets/_shared/core/quality/interactive-questions.md +8 -8
  40. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +109 -0
  41. package/presets/claude/android-kotlin/agents/code-reviewer.md +1 -0
  42. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +109 -0
  43. package/presets/claude/android-kotlin/rules/tooling-and-review/interactive-questions.md +8 -8
  44. package/presets/claude/android-kotlin/rules/tooling-and-review/language-policy.md +1 -1
  45. package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  46. package/presets/claude/android-kotlin/team/README.md +10 -0
  47. package/presets/claude/go/agents/code-reviewer.md +1 -0
  48. package/presets/claude/go/hooks/chain-team-phases.sh +109 -0
  49. package/presets/claude/go/rules/tooling-and-review/interactive-questions.md +8 -8
  50. package/presets/claude/go/rules/tooling-and-review/language-policy.md +1 -1
  51. package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  52. package/presets/claude/go/team/README.md +10 -0
  53. package/presets/claude/ios-swift/agents/code-reviewer.md +1 -0
  54. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +109 -0
  55. package/presets/claude/ios-swift/rules/tooling-and-review/interactive-questions.md +8 -8
  56. package/presets/claude/ios-swift/rules/tooling-and-review/language-policy.md +1 -1
  57. package/presets/claude/ios-swift/rules/tooling-and-review/post-change-build.md +1 -1
  58. package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  59. package/presets/claude/ios-swift/team/README.md +10 -0
  60. package/presets/claude/java/agents/code-reviewer.md +1 -0
  61. package/presets/claude/java/hooks/chain-team-phases.sh +109 -0
  62. package/presets/claude/java/rules/tooling-and-review/interactive-questions.md +8 -8
  63. package/presets/claude/java/rules/tooling-and-review/language-policy.md +1 -1
  64. package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  65. package/presets/claude/java/team/README.md +10 -0
  66. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +109 -0
  67. package/presets/claude/mcp-ts/rules/tooling-and-review/interactive-questions.md +8 -8
  68. package/presets/claude/mcp-ts/rules/tooling-and-review/language-policy.md +1 -1
  69. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  70. package/presets/claude/mcp-ts/team/README.md +10 -0
  71. package/presets/claude/next/MCP.md +7 -0
  72. package/presets/claude/next/README.md +1 -1
  73. package/presets/claude/next/REPO_AGENTS.md +1 -1
  74. package/presets/claude/next/agents/README.md +3 -3
  75. package/presets/claude/next/agents/build-verifier.md +9 -3
  76. package/presets/claude/next/agents/code-reviewer.md +2 -1
  77. package/presets/claude/next/agents/codebase-analyzer.md +1 -1
  78. package/presets/claude/next/agents/feature-developer.md +18 -8
  79. package/presets/claude/next/agents/openspec-author.md +1 -1
  80. package/presets/claude/next/agents/playwright-test-generator.md +22 -68
  81. package/presets/claude/next/agents/playwright-test-healer.md +27 -54
  82. package/presets/claude/next/agents/playwright-test-planner.md +18 -51
  83. package/presets/claude/next/agents/task-analyst.md +25 -9
  84. package/presets/claude/next/agents/task-router.md +1 -1
  85. package/presets/claude/next/agents/tech-writer.md +1 -1
  86. package/presets/claude/next/hooks/chain-team-phases.sh +109 -0
  87. package/presets/claude/next/mcp.json +3 -3
  88. package/presets/claude/next/rules/anti-hallucination/react-next-anti-hallucination.md +1 -1
  89. package/presets/claude/next/rules/architecture/layer-barrel-exports.md +1 -1
  90. package/presets/claude/next/rules/architecture/reference-features.md +1 -1
  91. package/presets/claude/next/rules/stack/navigation-router-ui.md +1 -1
  92. package/presets/claude/next/rules/stack/navigation-router.md +14 -0
  93. package/presets/claude/next/rules/stack/next-app-core.md +19 -17
  94. package/presets/claude/next/rules/stack/next-app-router.md +5 -17
  95. package/presets/claude/next/rules/stack/next-static-export.md +1 -1
  96. package/presets/claude/next/rules/tooling-and-review/interactive-questions.md +8 -8
  97. package/presets/claude/next/rules/tooling-and-review/language-policy.md +1 -1
  98. package/presets/claude/next/rules/tooling-and-review/post-change-lint.md +1 -1
  99. package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  100. package/presets/claude/next/rules/tooling-and-review/preset-token-budget.md +1 -1
  101. package/presets/claude/next/rules/tooling-and-review/security-next.md +28 -3
  102. package/presets/claude/next/rules/ui-and-accessibility/css-property-order.md +1 -1
  103. package/presets/claude/next/rules/ui-and-accessibility/design-tokens-binding.md +4 -4
  104. package/presets/claude/next/rules/ui-and-accessibility/forms-validation.md +2 -2
  105. package/presets/claude/next/team/README.md +21 -0
  106. package/presets/claude/next/team/fixtures/feature-with-figma-url.json +10 -0
  107. package/presets/claude/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
  108. package/presets/claude/next/team/fixtures/mockup-review-standalone.json +9 -0
  109. package/presets/claude/next/team/fixtures/ux-design-standalone.json +9 -0
  110. package/presets/claude/nuxt/agents/code-reviewer.md +1 -0
  111. package/presets/claude/nuxt/hooks/chain-team-phases.sh +109 -0
  112. package/presets/claude/nuxt/rules/architecture/layer-barrel-exports.md +1 -1
  113. package/presets/claude/nuxt/rules/stack/navigation-router-ui.md +1 -1
  114. package/presets/claude/nuxt/rules/tooling-and-review/interactive-questions.md +8 -8
  115. package/presets/claude/nuxt/rules/tooling-and-review/language-policy.md +1 -1
  116. package/presets/claude/nuxt/rules/tooling-and-review/post-change-lint.md +1 -1
  117. package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  118. package/presets/claude/nuxt/team/README.md +10 -0
  119. package/presets/claude/php-hexagonal/agents/code-reviewer.md +1 -0
  120. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +109 -0
  121. package/presets/claude/php-hexagonal/rules/tooling-and-review/interactive-questions.md +8 -8
  122. package/presets/claude/php-hexagonal/rules/tooling-and-review/language-policy.md +1 -1
  123. package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  124. package/presets/claude/php-hexagonal/team/README.md +10 -0
  125. package/presets/claude/php-laravel/agents/code-reviewer.md +1 -0
  126. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +109 -0
  127. package/presets/claude/php-laravel/rules/tooling-and-review/interactive-questions.md +8 -8
  128. package/presets/claude/php-laravel/rules/tooling-and-review/language-policy.md +1 -1
  129. package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  130. package/presets/claude/php-laravel/team/README.md +10 -0
  131. package/presets/claude/svelte/agents/code-reviewer.md +1 -0
  132. package/presets/claude/svelte/hooks/chain-team-phases.sh +109 -0
  133. package/presets/claude/svelte/rules/architecture/layer-barrel-exports.md +1 -1
  134. package/presets/claude/svelte/rules/tooling-and-review/interactive-questions.md +8 -8
  135. package/presets/claude/svelte/rules/tooling-and-review/language-policy.md +1 -1
  136. package/presets/claude/svelte/rules/tooling-and-review/post-change-lint.md +1 -1
  137. package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +1 -1
  138. package/presets/claude/svelte/team/README.md +10 -0
  139. package/presets/cursor/android-kotlin/agents/code-reviewer.md +1 -0
  140. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +109 -0
  141. package/presets/cursor/android-kotlin/rules/README.md +1 -0
  142. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +3 -3
  143. package/presets/cursor/android-kotlin/rules/interactive-questions.mdc +8 -8
  144. package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +1 -1
  145. package/presets/cursor/android-kotlin/team/README.md +10 -0
  146. package/presets/cursor/go/agents/code-reviewer.md +1 -0
  147. package/presets/cursor/go/hooks/chain-team-phases.sh +109 -0
  148. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +2 -2
  149. package/presets/cursor/go/rules/interactive-questions.mdc +8 -8
  150. package/presets/cursor/go/rules/preset-pr-checklist.mdc +1 -1
  151. package/presets/cursor/go/team/README.md +10 -0
  152. package/presets/cursor/ios-swift/agents/code-reviewer.md +1 -0
  153. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +109 -0
  154. package/presets/cursor/ios-swift/rules/README.md +1 -0
  155. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +3 -3
  156. package/presets/cursor/ios-swift/rules/interactive-questions.mdc +8 -8
  157. package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +1 -1
  158. package/presets/cursor/ios-swift/team/README.md +10 -0
  159. package/presets/cursor/java/agents/code-reviewer.md +1 -0
  160. package/presets/cursor/java/hooks/chain-team-phases.sh +109 -0
  161. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +2 -2
  162. package/presets/cursor/java/rules/interactive-questions.mdc +8 -8
  163. package/presets/cursor/java/rules/preset-pr-checklist.mdc +1 -1
  164. package/presets/cursor/java/team/README.md +10 -0
  165. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +109 -0
  166. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +2 -2
  167. package/presets/cursor/mcp-ts/rules/interactive-questions.mdc +8 -8
  168. package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +1 -1
  169. package/presets/cursor/mcp-ts/team/README.md +10 -0
  170. package/presets/cursor/next/MCP.md +14 -0
  171. package/presets/cursor/next/REPO_AGENTS.md +1 -1
  172. package/presets/cursor/next/agents/code-reviewer.md +1 -0
  173. package/presets/cursor/next/agents/playwright-test-healer.md +1 -0
  174. package/presets/cursor/next/ai-local/rules-library/router-pages.md +5 -5
  175. package/presets/cursor/next/hooks/chain-team-phases.sh +109 -0
  176. package/presets/cursor/next/mcp.json +3 -3
  177. package/presets/cursor/next/rules/README.md +1 -1
  178. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +1 -1
  179. package/presets/cursor/next/rules/css-property-order-stylelint.mdc +1 -1
  180. package/presets/cursor/next/rules/design-tokens-binding.mdc +4 -4
  181. package/presets/cursor/next/rules/forms-validation.mdc +2 -2
  182. package/presets/cursor/next/rules/interactive-questions.mdc +8 -8
  183. package/presets/cursor/next/rules/navigation-router-stack.mdc +14 -1
  184. package/presets/cursor/next/rules/next-app-core.mdc +19 -17
  185. package/presets/cursor/next/rules/next-app-router.mdc +5 -17
  186. package/presets/cursor/next/rules/next-static-export.mdc +1 -1
  187. package/presets/cursor/next/rules/preset-pr-checklist.mdc +1 -1
  188. package/presets/cursor/next/rules/preset-token-budget.mdc +1 -1
  189. package/presets/cursor/next/rules/react-next-anti-hallucination.mdc +1 -1
  190. package/presets/cursor/next/rules/reference-features.mdc +1 -1
  191. package/presets/cursor/next/rules/security-next.mdc +28 -3
  192. package/presets/cursor/next/team/README.md +21 -0
  193. package/presets/cursor/next/team/fixtures/feature-with-figma-url.json +10 -0
  194. package/presets/cursor/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
  195. package/presets/cursor/next/team/fixtures/mockup-review-standalone.json +9 -0
  196. package/presets/cursor/next/team/fixtures/ux-design-standalone.json +9 -0
  197. package/presets/cursor/nuxt/agents/code-reviewer.md +1 -0
  198. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +109 -0
  199. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
  200. package/presets/cursor/nuxt/rules/interactive-questions.mdc +8 -8
  201. package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +1 -1
  202. package/presets/cursor/nuxt/team/README.md +10 -0
  203. package/presets/cursor/php-hexagonal/agents/code-reviewer.md +1 -0
  204. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +109 -0
  205. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +2 -2
  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/team/README.md +10 -0
  209. package/presets/cursor/php-laravel/agents/code-reviewer.md +1 -0
  210. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +109 -0
  211. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +2 -2
  212. package/presets/cursor/php-laravel/rules/interactive-questions.mdc +8 -8
  213. package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +1 -1
  214. package/presets/cursor/php-laravel/team/README.md +10 -0
  215. package/presets/cursor/svelte/agents/code-reviewer.md +1 -0
  216. package/presets/cursor/svelte/hooks/chain-team-phases.sh +109 -0
  217. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
  218. package/presets/cursor/svelte/rules/interactive-questions.mdc +8 -8
  219. package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +1 -1
  220. package/presets/cursor/svelte/team/README.md +10 -0
  221. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  222. package/presets/mavis/android-kotlin/agents/code-reviewer.md +1 -0
  223. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +109 -0
  224. package/presets/mavis/android-kotlin/rules/interactive-questions.md +8 -8
  225. package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +1 -1
  226. package/presets/mavis/android-kotlin/team/README.md +10 -0
  227. package/presets/mavis/go/adapter-map.json +1 -1
  228. package/presets/mavis/go/agents/code-reviewer.md +1 -0
  229. package/presets/mavis/go/hooks/chain-team-phases.sh +109 -0
  230. package/presets/mavis/go/rules/interactive-questions.md +8 -8
  231. package/presets/mavis/go/rules/preset-pr-checklist.md +1 -1
  232. package/presets/mavis/go/team/README.md +10 -0
  233. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  234. package/presets/mavis/ios-swift/agents/code-reviewer.md +1 -0
  235. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +109 -0
  236. package/presets/mavis/ios-swift/rules/interactive-questions.md +8 -8
  237. package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +1 -1
  238. package/presets/mavis/ios-swift/team/README.md +10 -0
  239. package/presets/mavis/java/adapter-map.json +1 -1
  240. package/presets/mavis/java/agents/code-reviewer.md +1 -0
  241. package/presets/mavis/java/hooks/chain-team-phases.sh +109 -0
  242. package/presets/mavis/java/rules/interactive-questions.md +8 -8
  243. package/presets/mavis/java/rules/preset-pr-checklist.md +1 -1
  244. package/presets/mavis/java/team/README.md +10 -0
  245. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  246. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +109 -0
  247. package/presets/mavis/mcp-ts/rules/interactive-questions.md +8 -8
  248. package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +1 -1
  249. package/presets/mavis/mcp-ts/team/README.md +10 -0
  250. package/presets/mavis/next/MCP.md +14 -0
  251. package/presets/mavis/next/REPO_AGENTS.md +1 -1
  252. package/presets/mavis/next/adapter-map.json +1 -1
  253. package/presets/mavis/next/agents/code-reviewer.md +1 -0
  254. package/presets/mavis/next/agents/playwright-test-healer.md +1 -0
  255. package/presets/mavis/next/ai-local/rules-library/router-pages.md +5 -5
  256. package/presets/mavis/next/hooks/chain-team-phases.sh +109 -0
  257. package/presets/mavis/next/mcp.json +3 -3
  258. package/presets/mavis/next/rules/css-property-order-stylelint.md +1 -1
  259. package/presets/mavis/next/rules/design-tokens-binding.md +4 -4
  260. package/presets/mavis/next/rules/forms-validation.md +2 -2
  261. package/presets/mavis/next/rules/interactive-questions.md +8 -8
  262. package/presets/mavis/next/rules/navigation-router-stack.md +12 -0
  263. package/presets/mavis/next/rules/next-app-core.md +18 -17
  264. package/presets/mavis/next/rules/next-app-router.md +4 -17
  265. package/presets/mavis/next/rules/next-static-export.md +1 -1
  266. package/presets/mavis/next/rules/preset-pr-checklist.md +1 -1
  267. package/presets/mavis/next/rules/react-next-anti-hallucination.md +1 -1
  268. package/presets/mavis/next/rules/reference-features.md +1 -1
  269. package/presets/mavis/next/rules/security-next.md +24 -3
  270. package/presets/mavis/next/team/README.md +21 -0
  271. package/presets/mavis/next/team/fixtures/feature-with-figma-url.json +10 -0
  272. package/presets/mavis/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
  273. package/presets/mavis/next/team/fixtures/mockup-review-standalone.json +9 -0
  274. package/presets/mavis/next/team/fixtures/ux-design-standalone.json +9 -0
  275. package/presets/mavis/nuxt/adapter-map.json +1 -1
  276. package/presets/mavis/nuxt/agents/code-reviewer.md +1 -0
  277. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +109 -0
  278. package/presets/mavis/nuxt/rules/interactive-questions.md +8 -8
  279. package/presets/mavis/nuxt/rules/preset-pr-checklist.md +1 -1
  280. package/presets/mavis/nuxt/team/README.md +10 -0
  281. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  282. package/presets/mavis/php-hexagonal/agents/code-reviewer.md +1 -0
  283. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +109 -0
  284. package/presets/mavis/php-hexagonal/rules/interactive-questions.md +8 -8
  285. package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +1 -1
  286. package/presets/mavis/php-hexagonal/team/README.md +10 -0
  287. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  288. package/presets/mavis/php-laravel/agents/code-reviewer.md +1 -0
  289. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +109 -0
  290. package/presets/mavis/php-laravel/rules/interactive-questions.md +8 -8
  291. package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +1 -1
  292. package/presets/mavis/php-laravel/team/README.md +10 -0
  293. package/presets/mavis/svelte/adapter-map.json +1 -1
  294. package/presets/mavis/svelte/agents/code-reviewer.md +1 -0
  295. package/presets/mavis/svelte/hooks/chain-team-phases.sh +109 -0
  296. package/presets/mavis/svelte/rules/interactive-questions.md +8 -8
  297. package/presets/mavis/svelte/rules/preset-pr-checklist.md +1 -1
  298. package/presets/mavis/svelte/team/README.md +10 -0
  299. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  300. package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -0
  301. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +109 -0
  302. package/presets/opencode/android-kotlin/rules/interactive-questions.md +8 -8
  303. package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +1 -1
  304. package/presets/opencode/android-kotlin/team/README.md +10 -0
  305. package/presets/opencode/go/adapter-map.json +1 -1
  306. package/presets/opencode/go/agents/code-reviewer.md +1 -0
  307. package/presets/opencode/go/hooks/chain-team-phases.sh +109 -0
  308. package/presets/opencode/go/rules/interactive-questions.md +8 -8
  309. package/presets/opencode/go/rules/preset-pr-checklist.md +1 -1
  310. package/presets/opencode/go/team/README.md +10 -0
  311. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  312. package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -0
  313. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +109 -0
  314. package/presets/opencode/ios-swift/rules/interactive-questions.md +8 -8
  315. package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +1 -1
  316. package/presets/opencode/ios-swift/team/README.md +10 -0
  317. package/presets/opencode/java/adapter-map.json +1 -1
  318. package/presets/opencode/java/agents/code-reviewer.md +1 -0
  319. package/presets/opencode/java/hooks/chain-team-phases.sh +109 -0
  320. package/presets/opencode/java/rules/interactive-questions.md +8 -8
  321. package/presets/opencode/java/rules/preset-pr-checklist.md +1 -1
  322. package/presets/opencode/java/team/README.md +10 -0
  323. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  324. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +109 -0
  325. package/presets/opencode/mcp-ts/rules/interactive-questions.md +8 -8
  326. package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +1 -1
  327. package/presets/opencode/mcp-ts/team/README.md +10 -0
  328. package/presets/opencode/next/MCP.md +14 -0
  329. package/presets/opencode/next/REPO_AGENTS.md +1 -1
  330. package/presets/opencode/next/adapter-map.json +1 -1
  331. package/presets/opencode/next/agents/code-reviewer.md +1 -0
  332. package/presets/opencode/next/agents/playwright-test-healer.md +1 -0
  333. package/presets/opencode/next/ai-local/rules-library/router-pages.md +5 -5
  334. package/presets/opencode/next/hooks/chain-team-phases.sh +109 -0
  335. package/presets/opencode/next/opencode.json +3 -3
  336. package/presets/opencode/next/rules/css-property-order-stylelint.md +1 -1
  337. package/presets/opencode/next/rules/design-tokens-binding.md +4 -4
  338. package/presets/opencode/next/rules/forms-validation.md +2 -2
  339. package/presets/opencode/next/rules/interactive-questions.md +8 -8
  340. package/presets/opencode/next/rules/navigation-router-stack.md +12 -0
  341. package/presets/opencode/next/rules/next-app-core.md +18 -17
  342. package/presets/opencode/next/rules/next-app-router.md +4 -17
  343. package/presets/opencode/next/rules/next-static-export.md +1 -1
  344. package/presets/opencode/next/rules/preset-pr-checklist.md +1 -1
  345. package/presets/opencode/next/rules/react-next-anti-hallucination.md +1 -1
  346. package/presets/opencode/next/rules/reference-features.md +1 -1
  347. package/presets/opencode/next/rules/security-next.md +24 -3
  348. package/presets/opencode/next/team/README.md +21 -0
  349. package/presets/opencode/next/team/fixtures/feature-with-figma-url.json +10 -0
  350. package/presets/opencode/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
  351. package/presets/opencode/next/team/fixtures/mockup-review-standalone.json +9 -0
  352. package/presets/opencode/next/team/fixtures/ux-design-standalone.json +9 -0
  353. package/presets/opencode/nuxt/adapter-map.json +1 -1
  354. package/presets/opencode/nuxt/agents/code-reviewer.md +1 -0
  355. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +109 -0
  356. package/presets/opencode/nuxt/rules/interactive-questions.md +8 -8
  357. package/presets/opencode/nuxt/rules/preset-pr-checklist.md +1 -1
  358. package/presets/opencode/nuxt/team/README.md +10 -0
  359. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  360. package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -0
  361. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +109 -0
  362. package/presets/opencode/php-hexagonal/rules/interactive-questions.md +8 -8
  363. package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +1 -1
  364. package/presets/opencode/php-hexagonal/team/README.md +10 -0
  365. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  366. package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -0
  367. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +109 -0
  368. package/presets/opencode/php-laravel/rules/interactive-questions.md +8 -8
  369. package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +1 -1
  370. package/presets/opencode/php-laravel/team/README.md +10 -0
  371. package/presets/opencode/svelte/adapter-map.json +1 -1
  372. package/presets/opencode/svelte/agents/code-reviewer.md +1 -0
  373. package/presets/opencode/svelte/hooks/chain-team-phases.sh +109 -0
  374. package/presets/opencode/svelte/rules/interactive-questions.md +8 -8
  375. package/presets/opencode/svelte/rules/preset-pr-checklist.md +1 -1
  376. package/presets/opencode/svelte/team/README.md +10 -0
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Runtime support for `ai-rules mcp …`: project-root resolution, the Node floor,
3
+ * and the `mcp run` spawn. The moved `mcp/*.mjs` modules import this file so a
4
+ * published package never derives its project root from `import.meta.url`
5
+ * (which would resolve inside the npm cache / `node_modules`).
6
+ */
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+
10
+ const NODE_FLOOR_MAJOR = 20;
11
+ const PROJECT_ROOT_NEXT = 'start the client from the repository root or set AI_RULES_PROJECT_ROOT';
12
+
13
+ /** A directory containing any of these is a consumer project root; `.git` is the walk boundary. */
14
+ const PROJECT_MARKERS = [
15
+ '.git',
16
+ '.ai.local',
17
+ '.cursor/.ai-rules-install.json',
18
+ '.claude/.ai-rules-install.json',
19
+ '.mavis/.ai-rules-install.json',
20
+ '.opencode/.ai-rules-install.json',
21
+ '.cursor/mcp.json',
22
+ '.mcp.json',
23
+ '.mavis/mcp.json',
24
+ 'opencode.json',
25
+ ];
26
+
27
+ /** A `ConfigError`-shaped failure the runtime and the doctor can print as one next step. */
28
+ class ProjectRootError extends Error {
29
+ constructor(message, next = PROJECT_ROOT_NEXT) {
30
+ super(message);
31
+ this.name = 'ConfigError';
32
+ this.next = next;
33
+ }
34
+ }
35
+
36
+ function nodeMajor(version) {
37
+ const major = Number.parseInt(String(version).split('.')[0], 10);
38
+ return Number.isNaN(major) ? 0 : major;
39
+ }
40
+
41
+ /** Pure floor check: `assertNodeFloor('18.20.0', 20) === false`. */
42
+ function assertNodeFloor(version, floor = NODE_FLOOR_MAJOR) {
43
+ return nodeMajor(version) >= floor;
44
+ }
45
+
46
+ function isDirectory(target) {
47
+ try {
48
+ return fs.statSync(target).isDirectory();
49
+ } catch {
50
+ return false;
51
+ }
52
+ }
53
+
54
+ function isInsideNodeModules(dir) {
55
+ return dir.split(path.sep).includes('node_modules');
56
+ }
57
+
58
+ /**
59
+ * @returns {{ root: string, source: 'env' | 'marker' | 'cwd' }}
60
+ * `source` lets the doctor explain a fallback to the current directory.
61
+ */
62
+ function resolveProjectRootDetailed({ cwd = process.cwd(), env = process.env } = {}) {
63
+ const fromEnv = env.AI_RULES_PROJECT_ROOT;
64
+ if (typeof fromEnv === 'string' && fromEnv !== '' && isDirectory(fromEnv)) {
65
+ const resolved = path.resolve(fromEnv);
66
+ if (isInsideNodeModules(resolved)) {
67
+ throw new ProjectRootError(
68
+ `AI_RULES_PROJECT_ROOT points inside node_modules; ${PROJECT_ROOT_NEXT}`,
69
+ );
70
+ }
71
+ return { root: resolved, source: 'env' };
72
+ }
73
+
74
+ const resolvedCwd = path.resolve(cwd);
75
+ let current = resolvedCwd;
76
+ while (true) {
77
+ if (!isInsideNodeModules(current) && PROJECT_MARKERS.some((rel) => fs.existsSync(path.join(current, rel)))) {
78
+ return { root: current, source: 'marker' };
79
+ }
80
+ const parent = path.dirname(current);
81
+ if (parent === current) {
82
+ break;
83
+ }
84
+ current = parent;
85
+ }
86
+
87
+ if (isInsideNodeModules(resolvedCwd)) {
88
+ throw new ProjectRootError(
89
+ `project root not found: the working directory is inside node_modules; ${PROJECT_ROOT_NEXT}`,
90
+ );
91
+ }
92
+
93
+ return { root: resolvedCwd, source: 'cwd' };
94
+ }
95
+
96
+ function resolveProjectRoot(options) {
97
+ return resolveProjectRootDetailed(options).root;
98
+ }
99
+
100
+ function packageVersion(packageRoot) {
101
+ try {
102
+ return JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8')).version;
103
+ } catch {
104
+ return '0.0.0';
105
+ }
106
+ }
107
+
108
+ function runtimeEntryPath(packageRoot, entry) {
109
+ return path.join(packageRoot, entry);
110
+ }
111
+
112
+ module.exports = {
113
+ NODE_FLOOR_MAJOR,
114
+ PROJECT_MARKERS,
115
+ PROJECT_ROOT_NEXT,
116
+ ProjectRootError,
117
+ nodeMajor,
118
+ assertNodeFloor,
119
+ resolveProjectRootDetailed,
120
+ resolveProjectRoot,
121
+ packageVersion,
122
+ runtimeEntryPath,
123
+ };
@@ -208,6 +208,49 @@ function stripMergedConfigs(cwd, records) {
208
208
  }
209
209
  }
210
210
 
211
+ /**
212
+ * Merge one shipped server object. Preset scalar fields win; nested `env` / `headers`
213
+ * keep consumer keys unless the preset defines the same nested key.
214
+ */
215
+ function mergeServerEntry(existingEntry, presetEntry) {
216
+ if (!isPlainObject(existingEntry) || !isPlainObject(presetEntry)) {
217
+ return presetEntry;
218
+ }
219
+ const merged = { ...existingEntry, ...presetEntry };
220
+ for (const nested of ['env', 'headers']) {
221
+ const existingNested = existingEntry[nested];
222
+ const presetNested = presetEntry[nested];
223
+ if (isPlainObject(existingNested) && isPlainObject(presetNested)) {
224
+ merged[nested] = { ...existingNested, ...presetNested };
225
+ } else if (isPlainObject(existingNested) && presetNested === undefined) {
226
+ merged[nested] = existingNested;
227
+ }
228
+ }
229
+ return merged;
230
+ }
231
+
232
+ /**
233
+ * Extra local `mcpServers` keys are kept. Shipped keys update; nested `env` / `headers`
234
+ * on overlapping keys are preserved unless the preset defines them.
235
+ * Other unknown top-level keys on the existing file are preserved.
236
+ * @returns {{ merged: object, extrasKept: string[] }}
237
+ */
238
+ function mergeMcpConfig(presetObj, existingObj) {
239
+ const preset = isPlainObject(presetObj) ? presetObj : {};
240
+ const existing = isPlainObject(existingObj) ? existingObj : {};
241
+ const presetServers = isPlainObject(preset.mcpServers) ? preset.mcpServers : {};
242
+ const existingServers = isPlainObject(existing.mcpServers) ? existing.mcpServers : {};
243
+ const extrasKept = ownKeys(existingServers).filter((key) => !Object.hasOwn(presetServers, key));
244
+ const mergedServers = { ...existingServers };
245
+ for (const key of ownKeys(presetServers)) {
246
+ mergedServers[key] = mergeServerEntry(existingServers[key], presetServers[key]);
247
+ }
248
+ return {
249
+ merged: { ...existing, ...preset, mcpServers: mergedServers },
250
+ extrasKept,
251
+ };
252
+ }
253
+
211
254
  /**
212
255
  * Union `permissions.*` arrays and add preset hooks by event (deduped by `command`).
213
256
  * Every other consumer key wins. Bare `Bash(git commit)` and `Bash(git push)` are
@@ -316,4 +359,6 @@ module.exports = {
316
359
  mergedConfigRecords,
317
360
  stripMergedConfigs,
318
361
  mergeClaudeSettings,
362
+ mergeServerEntry,
363
+ mergeMcpConfig,
319
364
  };
@@ -21,6 +21,13 @@ const AI_LOCAL_GITIGNORE = [
21
21
  '*.lock',
22
22
  '*.tmp',
23
23
  '.rollback/',
24
+ '.template-base.json',
25
+ '*.intent',
26
+ '# Rebuildable SQLite projection of .ai.local/team; never commit a database.',
27
+ 'team.db',
28
+ 'team.db-wal',
29
+ 'team.db-shm',
30
+ 'team-db-errors.log',
24
31
  '',
25
32
  ].join('\n');
26
33
  const POINTER_README = `# Agent team artifacts moved
@@ -232,15 +239,23 @@ function ensureRollbackIgnored(rollbackRoot) {
232
239
  * scripts (`*.lock`, `*.tmp`) and the migration backups (`.rollback/`). A
233
240
  * `.gitignore` inside `.ai.local/` is used instead of appending to the
234
241
  * consumer's root `.gitignore`: the CLI never edits that file, and this works
235
- * even in a repo that has no `.gitignore` at all. Created only when absent.
242
+ * even in a repo that has no `.gitignore` at all. An existing file keeps its
243
+ * own lines; missing required lines are appended.
236
244
  */
237
245
  function ensureAiLocalIgnored(aiLocalRoot) {
238
246
  const ignoreFile = path.join(aiLocalRoot, '.gitignore');
239
- if (fs.existsSync(ignoreFile)) {
240
- return false;
241
- }
242
247
  fs.mkdirSync(aiLocalRoot, { recursive: true });
243
- fs.writeFileSync(ignoreFile, AI_LOCAL_GITIGNORE);
248
+ const required = AI_LOCAL_GITIGNORE.split('\n').filter((line) => line !== '' && !line.startsWith('#'));
249
+ if (!fs.existsSync(ignoreFile)) {
250
+ fs.writeFileSync(ignoreFile, AI_LOCAL_GITIGNORE);
251
+ return true;
252
+ }
253
+ const current = fs.readFileSync(ignoreFile, 'utf8');
254
+ const present = new Set(current.split('\n').map((line) => line.trim()).filter(Boolean));
255
+ const missing = required.filter((line) => !present.has(line));
256
+ if (missing.length === 0) return false;
257
+ const suffix = current.endsWith('\n') || current.length === 0 ? '' : '\n';
258
+ fs.writeFileSync(ignoreFile, `${current}${suffix}${missing.join('\n')}\n`);
244
259
  return true;
245
260
  }
246
261
 
@@ -670,7 +685,7 @@ function templateEntries(presetTeamSrc) {
670
685
  * already existed, never a consumer-modified file).
671
686
  * @returns {{ created: boolean, createdPaths: string[], migrated: boolean, refreshed: boolean, conventionsSeeded: boolean, rulesLibrarySeeded: boolean, engineSeeded: boolean }}
672
687
  */
673
- function seedAiLocalTeam({ cwd, presetTeamSrc, source, packageVersion, mergeAiLocal, writeFile, trackFile }) {
688
+ function seedAiLocalTeam({ cwd, presetTeamSrc, source, packageVersion, mergeAiLocal, checkAiLocal, writeFile, trackFile }) {
674
689
  const dest = destTeamRoot(cwd);
675
690
  const aiLocalRoot = path.join(cwd, '.ai.local');
676
691
  const empty = {
@@ -745,6 +760,7 @@ function seedAiLocalTeam({ cwd, presetTeamSrc, source, packageVersion, mergeAiLo
745
760
  source,
746
761
  packageVersion,
747
762
  mergeAiLocal,
763
+ checkAiLocal,
748
764
  writeFile,
749
765
  trackFile,
750
766
  });
@@ -794,4 +810,4 @@ function seedAiLocalTeam({ cwd, presetTeamSrc, source, packageVersion, mergeAiLo
794
810
  };
795
811
  }
796
812
 
797
- module.exports = { seedAiLocalTeam, destTeamRoot };
813
+ module.exports = { seedAiLocalTeam, destTeamRoot, ensureAiLocalIgnored };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Install-presence markers shared by `clean` and the MCP registration command.
3
+ *
4
+ * A leftover directory does not mean a tool install is still present; these
5
+ * markers do (see `clean`'s AGENTS.md ownership rule).
6
+ */
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+
10
+ /** Markers that mean a tool install is still present (directory leftovers do not count). */
11
+ const TOOL_INSTALL_MARKERS = {
12
+ '.cursor': ['.cursor/AGENTS.md', '.cursor/hooks.json', '.cursor/rules'],
13
+ '.claude': ['.claude/CLAUDE.md', '.claude/rules', '.claude/settings.json'],
14
+ '.mavis': ['.mavis/.ai-rules-install.json', '.mavis/AGENTS.md'],
15
+ '.opencode': ['.opencode/.ai-rules-install.json', '.opencode/AGENTS.md'],
16
+ };
17
+
18
+ function otherToolInstallPresent(cwd, exceptRoot) {
19
+ return Object.entries(TOOL_INSTALL_MARKERS).some(([root, markers]) => {
20
+ if (root === exceptRoot) {
21
+ return false;
22
+ }
23
+ return markers.some((rel) => fs.existsSync(path.join(cwd, rel)));
24
+ });
25
+ }
26
+
27
+ module.exports = { TOOL_INSTALL_MARKERS, otherToolInstallPresent };
@@ -161,6 +161,7 @@ function cmdInitMavis({ preset, cwdOption, helpers }) {
161
161
  installMcpJson,
162
162
  getPackageRoot,
163
163
  mergeAiLocal,
164
+ checkAiLocal,
164
165
  } = helpers;
165
166
  const packageRoot = getPackageRoot();
166
167
  const cwd = resolveTargetCwd(cwdOption);
@@ -254,6 +255,7 @@ function cmdInitMavis({ preset, cwdOption, helpers }) {
254
255
  source: `mavis/${stack}`,
255
256
  packageVersion: packageVersion(packageRoot),
256
257
  mergeAiLocal: Boolean(mergeAiLocal),
258
+ checkAiLocal: Boolean(checkAiLocal),
257
259
  writeFile: (dest, content, label) => tx.writeFile(dest, content, label),
258
260
  trackFile: (dest, label) => tx.track(dest, label),
259
261
  });
@@ -344,6 +344,7 @@ function cmdInitOpencode({ preset, cwdOption, helpers }) {
344
344
  seedAiLocalTeam,
345
345
  getPackageRoot,
346
346
  mergeAiLocal,
347
+ checkAiLocal,
347
348
  } = helpers;
348
349
  const packageRoot = getPackageRoot();
349
350
  const cwd = resolveTargetCwd(cwdOption);
@@ -433,6 +434,7 @@ function cmdInitOpencode({ preset, cwdOption, helpers }) {
433
434
  source: `opencode/${stack}`,
434
435
  packageVersion: packageVersion(packageRoot),
435
436
  mergeAiLocal: Boolean(mergeAiLocal),
437
+ checkAiLocal: Boolean(checkAiLocal),
436
438
  writeFile: (dest, content, label) => tx.writeFile(dest, content, label),
437
439
  trackFile: (dest, label) => tx.track(dest, label),
438
440
  });
@@ -111,7 +111,7 @@ Recording is deliberately conservative: a file whose bytes differ from the curre
111
111
  - **Both sides changed.** The sink shows the diff; resolution is yours.
112
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
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, or a preset that dropped a file.** Absence is intent; nothing is re-seeded or removed. 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.
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
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
116
  - **An activated seed** (`rules-library/X.md` → `rules/X.md`). Activation stays a judgement call; the pair is not auto-merged.
117
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.
@@ -0,0 +1,62 @@
1
+ # MCP setup: GitLab, Yandex Tracker, Yandex Wiki
2
+
3
+ Two sequences. Nothing here stores a token in a client config.
4
+ `mcp setup` writes the exact installed version pin into the client config; the runtime is pinned even though setup runs `@latest`.
5
+ It registers only the clients already installed in the repository.
6
+ GitLab credentials live in `.ai-rules/mcp/credentials.env`; Yandex keeps only non-secret settings in `.ai-rules/mcp/config.env`.
7
+ Both sequences are idempotent: rerun a step instead of editing a client config by hand.
8
+ Prerequisites: Node 20+, an MCP client, network to your GitLab instance and to Yandex.
9
+
10
+ ## 1. GitLab
11
+
12
+ 1. **Create a personal access token.**
13
+ Open Preferences → Access Tokens on your GitLab instance and add scope `read_api`; add `api` only if the agent must write.
14
+ [GitLab: personal access tokens](https://docs.gitlab.com/user/profile/personal_access_tokens/)
15
+ → expected: the token is shown once; keep it for the next step.
16
+
17
+ 2. **Save the credentials.** Paste the instance URL, then the token at the hidden prompt.
18
+ The token is validated against the API before the file is written.
19
+ `npx @bonesofspring/ai-rules@latest mcp setup gitlab`
20
+ → expected: `ok credentials … (0600, ignored)`, then `ok registration` per client.
21
+
22
+ 3. **Reconnect the client.**
23
+
24
+ - OpenCode: `opencode reload`
25
+ - Cursor: restart the server in Settings → MCP
26
+ - Claude Code: `/mcp`, then approve the server
27
+ - Mavis: reconnect the server
28
+
29
+ → expected: `gitlab` is connected and lists tools.
30
+
31
+ 4. **Verify the setup.** Any failure exits 1 and names the next command.
32
+ `npx @bonesofspring/ai-rules@latest mcp doctor gitlab`
33
+ → expected: four `ok` lines — runtime, registration, credentials, upstream — and exit 0.
34
+
35
+ 5. **Rotate the token.** Create a new token with the same scopes.
36
+ Rerun the setup; the file is rewritten only after the new token validates.
37
+ `npx @bonesofspring/ai-rules@latest mcp setup gitlab`
38
+ → expected: the new token is validated and saved; the server reconnects with it.
39
+
40
+ ## 2. Yandex (Tracker + Wiki)
41
+
42
+ 1. **Install the Yandex Cloud CLI.**
43
+ [Yandex Cloud CLI: installation](https://yandex.cloud/en/docs/cli/operations/install-cli)
44
+ → expected: `yc --version` prints a version.
45
+
46
+ 2. **Log in through your federation.** Use the federation id from your cloud admin; it is not a secret.
47
+ The wizard opens the browser and asks for a profile, cloud, and folder.
48
+ `yc init --federation-id <id>`
49
+ → expected: `yc iam create-token` prints an IAM token.
50
+
51
+ 3. **Save the settings.** Enter the organization id at the prompt; it is not a secret.
52
+ The setup registers the clients present and finishes with a doctor over both servers.
53
+ `npx @bonesofspring/ai-rules@latest mcp setup yandex`
54
+ → expected: `ok credentials` with the organization id saved, then `ok` lines for `yandex tracker` and `yandex wiki`.
55
+
56
+ 4. **Reconnect both servers** with the client action from GitLab step 3 (`opencode reload` in OpenCode).
57
+ → expected: `yandex tracker` and `yandex wiki` are connected and list tools.
58
+
59
+ 5. **Refresh the SSO session** when `mcp doctor yandex` exits 2; finish the browser login, then reconnect.
60
+ The IAM token stays in the `yc` profile; `.ai-rules/mcp/` holds no token.
61
+ `npx @bonesofspring/ai-rules@latest mcp refresh yandex`
62
+ → expected: `Yandex IAM token refreshed` and exit 0; no token is stored.
@@ -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
 
@@ -394,23 +394,27 @@ Load these when editing files under `packages/ai-rules/presets/**`, `.cursor/**`
394
394
 
395
395
  | Script / npm | Purpose |
396
396
  |--------------|---------|
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. |
397
+ | `yarn fix:generated` | Regenerate every released generated platform and recapture the CLI goldens it owns (`cursor/next`, `claude/next`, and every Mavis/OpenCode stack). Run after changing Cursor SoT, before fail-only checks. Capture a non-`next` Cursor/Claude golden explicitly with `node scripts/capture-cli-golden.mjs <cursor|claude> <stack>`; never hand-edit one. 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`. |
416
+ | `scripts/check-team-db-contract.mjs` / `yarn check:team-db-contract` | **FAIL** when the checked-in OpenAPI 3.1 document (`docs/openapi/team-db.v1.json`) drifts from `team-db-openapi.mjs`, fails the vendored 3.1 meta-schema (sha256-pinned), loses an `operationId`, diverges from `ROUTE_TABLE` in either direction, carries an invalid example, or leaves a `$ref` unresolved. `--write` is the only writer; no network at gate time. Wired into `check-preset-structure.sh`. |
417
+ | `scripts/test-team-db-*.mjs` | The team-db suite family: schema (13), project (17), dual-write (13), API (12), security (10), dashboard (9), concurrency (6), and FAIL-direction fixtures (14). The fixtures prove each gate fails on its planted defect; `test-team-db-concurrency.mjs` covers first-creation races, a mixed writer/reader load, `SIGKILL` recovery, a held lock, and the 5 s hook budget. Wired into `check-preset-structure.sh`; `yarn test:team-db` runs the family. |
414
418
 
415
419
  Run from `packages/ai-rules/`:
416
420
 
@@ -0,0 +1,173 @@
1
+ # Team database projection
2
+
3
+ `@bonesofspring/ai-rules` ships a rebuildable SQLite projection of `.ai.local/team/`.
4
+ The task files remain the source of truth; the database exists so an operator or a tool can
5
+ query history without walking JSON on every request.
6
+
7
+ The projection is installed by `init` as six modules under `.ai.local/scripts/`:
8
+
9
+ | Module | Role |
10
+ |---|---|
11
+ | `team-db.mjs` | CLI: `init`, `sync`, `check`, `serve` |
12
+ | `team-db-schema.mjs` | capability probe, embedded migrations, pragmas, fingerprint, integrity |
13
+ | `team-db-project.mjs` | parsers, idempotent projector, retention, search |
14
+ | `team-db-api.mjs` | read-only `node:http` server, query layer, security boundary |
15
+ | `team-db-openapi.mjs` | the OpenAPI 3.1 document source |
16
+ | `team-db-dashboard.mjs` | the no-build dashboard (HTML, CSS, JS strings) |
17
+
18
+ ## Behavior contract
19
+
20
+ - **Files are authoritative.** `status.json`, `pipeline.json`, `metrics.json`,
21
+ `artifact-manifest.json`, prompts, memlogs, and review ledgers are read, never written.
22
+ No agent writes a lifecycle field through the projection.
23
+ - **The database is rebuildable.** Delete `team.db*` and run `sync`; the next run recreates
24
+ the schema and reconverges. A schema fingerprint mismatch rebuilds automatically.
25
+ - **Writes are isolated.** A projection failure never fails a file write or a receipt. The
26
+ hook and `manifest.mjs` run a bounded child (5 s, `SIGKILL`) and append one line to
27
+ `team-db-errors.log` on failure.
28
+ - **One read-only surface.** `POST /api/v1/sync` is the only mutation; every other route is
29
+ `GET`/`HEAD`. There is no write-back, no telemetry, and no outbound request.
30
+ - **Local only.** The server binds loopback by default, checks `Host` and `Origin`, sends no
31
+ CORS header, and serves raw documents from SQLite by exact `(slug, path)` lookup.
32
+
33
+ ## Location and ignore rules
34
+
35
+ The database lives at `.ai.local/team/team.db` with its `-wal` and `-shm` companions.
36
+ `init` writes (or completes) `.ai.local/.gitignore` so these paths are ignored:
37
+
38
+ ```text
39
+ team.db
40
+ team.db-wal
41
+ team.db-shm
42
+ team-db-errors.log
43
+ ```
44
+
45
+ The consumer root `.gitignore` is never created or edited. Never commit the database even
46
+ for a demo: it contains copies of prompts and task documents.
47
+
48
+ ## Node floor
49
+
50
+ The floor is Node 22.13.0. `node:sqlite` was unflagged in that release
51
+ ([Node.js 22.13.0 release notes](https://nodejs.org/en/blog/release/v22.13.0), commit
52
+ `55239a48b6`, PR [#55890](https://github.com/nodejs/node/pull/55890)); the module is still
53
+ marked experimental. `MIN_NODE = '22.13.0'` in `team-db-schema.mjs` is the code constant
54
+ behind this sentence; `engines` stays `>=18`.
55
+
56
+ Measured surface: Node 24.21.0 with SQLite 3.54.1 (`DatabaseSync`, prepared statements,
57
+ `PRAGMA`, WAL, FTS5); re-verified on Node 26.13.0 / SQLite 3.54.1 for this release. A runtime
58
+ below the floor, or a build without `node:sqlite`, is detected at runtime:
59
+
60
+ | Entry point | No `node:sqlite` | `AI_RULES_TEAM_DB_DISABLE=1` |
61
+ |---|---|---|
62
+ | hook postflight | one line, no child, exit 0 | silent, exit 0 |
63
+ | `manifest.mjs` upsert | one line, return 0 after the receipt | silent, return 0 |
64
+ | `team-db.mjs init` / `sync` | one line, exit 0, no file | one line, exit 0, no file |
65
+ | `team-db.mjs check` | one line, exit 1 | one line, exit 1 |
66
+ | `team-db.mjs serve` | one line, exit 0 | one line, exit 0 |
67
+
68
+ The file-only pipeline is unchanged: `status.json` / `metrics.json` writes, manifest upserts,
69
+ and the pipeline run with exit 0.
70
+
71
+ ## Commands
72
+
73
+ ```bash
74
+ node .ai.local/scripts/team-db.mjs init [--root <team-dir>] [--rebuild]
75
+ node .ai.local/scripts/team-db.mjs sync [--root <team-dir>] [--slug <slug>] [--quiet] [--json]
76
+ [--maintain] [--prune] [--vacuum]
77
+ [--rebuild | --no-rebuild] [--deadline-ms <n>]
78
+ node .ai.local/scripts/team-db.mjs check [--root <team-dir>]
79
+ node .ai.local/scripts/team-db.mjs serve [--root <team-dir>] [--host <addr>] [--port <n>]
80
+ [--allow-remote] [--open]
81
+ ```
82
+
83
+ Exit codes: `0` ok, `1` at least one task failed or a migration checksum drifted, `2`
84
+ database-level failure, `3` usage, `4` deadline or busy database on the hook-shaped `--slug`
85
+ path.
86
+
87
+ `sync` is idempotent: a second run reports `inserted=0 updated=0 unchanged=<n>`. One changed
88
+ byte changes exactly one document hash and one task content hash. A removed task directory is
89
+ tombstoned with `absent_at` (soft delete) and `--prune` removes tombstones.
90
+
91
+ ## Environment names
92
+
93
+ | Name | Effect |
94
+ |---|---|
95
+ | `AI_RULES_TEAM_DB_DISABLE` | truthy value disables every write point and `serve`; files are untouched |
96
+ | `AI_RULES_TEAM_DB_FORCE_FALLBACK` | truthy value forces the file-only path even on a supported runtime |
97
+ | `AI_RULES_TEAM_DB_ROOT` | team directory when `--root` is absent |
98
+ | `AI_RULES_TEAM_DB_PATH` | database file path (default `<teamRoot>/team.db`) |
99
+ | `AI_RULES_TEAM_DB_LOG` | error-log path (default `<cwd>/.ai.local/team/team-db-errors.log`) |
100
+ | `AI_RULES_TEAM_DB_SEAM` | phase label in the error log: `hook`, `receipt`, `cli`, `serve` |
101
+
102
+ No other environment value is read or persisted. The error log stores a timestamp, a code,
103
+ a phase, and a message; it never stores prompt content or an environment value, and it is
104
+ trimmed to the newest 200 lines / 64 KiB.
105
+
106
+ ## Schema
107
+
108
+ One embedded migration (`0001-init`, sha256-pinned) creates 15 row tables: `schema_migrations`,
109
+ `schema_meta`, `tasks`, `pipeline_steps`, `pipeline_step_agents`, `attempts`, `events`,
110
+ `gates`, `artifacts`, `artifact_paths`, `prompts`, `review_ledger`, `outcomes`, `documents`,
111
+ `sync_runs`; 19 indexes; and the `attempt_timeline` view. FTS5 (`search_fts`) is a runtime
112
+ capability created after migration, with an escaped `LIKE` fallback.
113
+
114
+ Each connection sets `journal_mode=WAL`, `busy_timeout=5000`, `foreign_keys=ON`, and
115
+ `synchronous=NORMAL`. One task is projected in one transaction; a `SIGKILL` mid-sync
116
+ rolls back the in-flight task and leaves `integrity_check` `ok`.
117
+
118
+ Raw document content is capped at 32 MiB; above that the row keeps path, sha256, and length
119
+ and sets `content_omitted=size` (binary content sets `binary`). Raw content older than 90
120
+ days on an absent task is nulled only by `sync --maintain`; `sync --vacuum` checkpoints WAL and
121
+ runs `VACUUM`. The `sync_runs` table keeps the newest 200 runs.
122
+
123
+ ## Dashboard and API
124
+
125
+ `team-db.mjs serve` prints one line with the bound URL (default
126
+ `http://127.0.0.1:4178`). The dashboard is a single no-build HTML document at `/`, its CSS and
127
+ JS are served from `/assets/`, and the OpenAPI 3.1 document is at `/openapi.json`. The frozen
128
+ document is checked in at `packages/ai-rules/docs/openapi/team-db.v1.json`; the gate is
129
+ `node scripts/check-team-db-contract.mjs`.
130
+
131
+ Security boundary: loopback bind by default (`--host` outside loopback needs
132
+ `--allow-remote`, and a wildcard address is refused), exact `Host`/`Origin` allow-list,
133
+ no `Access-Control-*` header, hardened response headers, request bodies bounded at 1 KiB,
134
+ document chunks at 1 MiB, exports at 5 MiB, parameterized SQL only, and no outbound call.
135
+
136
+ ## Privacy and retention
137
+
138
+ Prompts are copied verbatim into `prompts` and `documents`. The database is local, git-ignored,
139
+ and readable by the same OS user who can read the task folder; that is the trust boundary.
140
+ There is no upload, telemetry, or remote asset. `sync --maintain` nulls raw document content
141
+ for tasks absent longer than 90 days while keeping normalized rows and hashes.
142
+
143
+ ## Rollback
144
+
145
+ 1. Set `AI_RULES_TEAM_DB_DISABLE=1`. Every write point and `serve` becomes a no-op with exit 0.
146
+ 2. Delete the projection: `rm -f .ai.local/team/team.db .ai.local/team/team.db-wal
147
+ .ai.local/team/team.db-shm .ai.local/team/team-db-errors.log`. No task file is touched.
148
+ 3. Revert the code: remove the hook region and the `projectAfterReceipt` call, delete the six
149
+ modules from `ENGINE_SCRIPTS`, then run `yarn fix:generated` and recapture the goldens.
150
+ 4. The ADR stays as history: mark it superseded instead of deleting it.
151
+
152
+ ## Gates
153
+
154
+ From `packages/ai-rules`:
155
+
156
+ ```bash
157
+ node scripts/check-team-db-contract.mjs
158
+ node scripts/test-team-db-schema.mjs
159
+ node scripts/test-team-db-project.mjs
160
+ node scripts/test-team-db-dualwrite.mjs
161
+ node scripts/test-team-db-api.mjs
162
+ node scripts/test-team-db-security.mjs
163
+ node scripts/test-team-db-dashboard.mjs
164
+ node scripts/test-team-db-concurrency.mjs
165
+ node scripts/test-team-db-fixtures.mjs
166
+ ```
167
+
168
+ `test-team-db-fixtures.mjs` is the FAIL-direction suite: every gate above is exercised on a
169
+ planted defect, not only on the happy path.
170
+
171
+ Links: [`../README.md`](../README.md), [`PRESET-CONTRIBUTION.md`](PRESET-CONTRIBUTION.md),
172
+ the OpenSpec change `openspec/changes/2026-11-06-agent-team-sqlite-dashboard/`, and ADR
173
+ `.ai.local/adr/0004-team-db-projection.md` in this repository.