@bonesofspring/ai-rules 0.2.67 → 0.2.68

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 (770) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +4 -4
  3. package/bin/lib/engine-scripts.js +3 -6
  4. package/bin/lib/seed-ai-local-team.js +1 -1
  5. package/docs/PRESET-CONTRIBUTION.md +15 -8
  6. package/docs/TEAM-DB.md +105 -105
  7. package/docs/TOKEN-ECONOMY.md +4 -2
  8. package/docs/openapi/team-db.v1.json +3905 -1466
  9. package/package.json +4 -4
  10. package/presets/_shared/ai-local/scripts/processes.mjs +467 -55
  11. package/presets/_shared/ai-local/scripts/team-db-api.mjs +564 -10
  12. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +816 -47
  13. package/presets/_shared/ai-local/scripts/team-db-project.mjs +659 -5
  14. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +135 -0
  15. package/presets/_shared/ai-local/scripts/team-db-task-runner.mjs +11 -6
  16. package/presets/_shared/ai-local/scripts/team-db.mjs +16 -54
  17. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +5 -5
  18. package/presets/_shared/core/architecture/feature-delivery-workflow.md +3 -7
  19. package/presets/_shared/core/meta/preset-pr-checklist.md +2 -2
  20. package/presets/_shared/core/quality/code-quality-and-refactoring.md +2 -6
  21. package/presets/_shared/core/quality/verification-before-completion.md +20 -3
  22. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +12 -3
  23. package/presets/claude/android-kotlin/REPO_AGENTS.md +7 -47
  24. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +12 -3
  25. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  26. package/presets/claude/android-kotlin/rules/tooling-and-review/code-quality.md +2 -6
  27. package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  28. package/presets/claude/go/REPO_AGENTS.md +7 -47
  29. package/presets/claude/go/hooks/chain-team-phases.sh +12 -3
  30. package/presets/claude/go/rules/architecture/feature-delivery.md +3 -7
  31. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  32. package/presets/claude/go/rules/tooling-and-review/code-quality.md +2 -6
  33. package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  34. package/presets/claude/ios-swift/REPO_AGENTS.md +7 -47
  35. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +12 -3
  36. package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +3 -7
  37. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  38. package/presets/claude/ios-swift/rules/tooling-and-review/code-quality.md +2 -6
  39. package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  40. package/presets/claude/java/REPO_AGENTS.md +7 -47
  41. package/presets/claude/java/hooks/chain-team-phases.sh +12 -3
  42. package/presets/claude/java/rules/architecture/feature-delivery.md +3 -7
  43. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  44. package/presets/claude/java/rules/tooling-and-review/code-quality.md +2 -6
  45. package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  46. package/presets/claude/mcp-ts/REPO_AGENTS.md +7 -47
  47. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +12 -3
  48. package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +3 -7
  49. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  50. package/presets/claude/mcp-ts/rules/tooling-and-review/code-quality.md +2 -6
  51. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  52. package/presets/claude/mol/REPO_AGENTS.md +9 -49
  53. package/presets/claude/mol/hooks/chain-team-phases.sh +12 -3
  54. package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +3 -7
  55. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  56. package/presets/claude/mol/rules/tooling-and-review/code-quality.md +2 -6
  57. package/presets/claude/mol/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  58. package/presets/claude/next/REPO_AGENTS.md +10 -50
  59. package/presets/claude/next/agents/accessibility-reviewer.md +0 -1
  60. package/presets/claude/next/agents/api-contract-reviewer.md +0 -1
  61. package/presets/claude/next/agents/build-verifier.md +12 -8
  62. package/presets/claude/next/agents/code-reviewer.md +1 -1
  63. package/presets/claude/next/agents/codebase-analyzer.md +0 -1
  64. package/presets/claude/next/agents/feature-developer.md +6 -6
  65. package/presets/claude/next/agents/migration-specialist.md +0 -1
  66. package/presets/claude/next/agents/mockup-reviewer.md +0 -1
  67. package/presets/claude/next/agents/openspec-author.md +0 -1
  68. package/presets/claude/next/agents/performance-auditor.md +0 -1
  69. package/presets/claude/next/agents/playwright-test-generator.md +0 -1
  70. package/presets/claude/next/agents/playwright-test-healer.md +0 -1
  71. package/presets/claude/next/agents/playwright-test-planner.md +0 -1
  72. package/presets/claude/next/agents/qa-tester.md +3 -3
  73. package/presets/claude/next/agents/security-reviewer.md +0 -1
  74. package/presets/claude/next/agents/solution-architect.md +0 -1
  75. package/presets/claude/next/agents/task-analyst.md +0 -1
  76. package/presets/claude/next/agents/task-router.md +8 -7
  77. package/presets/claude/next/agents/tech-writer.md +0 -1
  78. package/presets/claude/next/agents/unit-test-generator.md +0 -1
  79. package/presets/claude/next/agents/unit-test-healer.md +0 -1
  80. package/presets/claude/next/agents/unit-test-planner.md +0 -1
  81. package/presets/claude/next/commands/README.md +0 -6
  82. package/presets/claude/next/hooks/chain-team-phases.sh +12 -3
  83. package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +5 -9
  84. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  85. package/presets/claude/next/rules/tooling-and-review/code-quality.md +2 -6
  86. package/presets/claude/next/rules/tooling-and-review/post-change-lint.md +12 -16
  87. package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  88. package/presets/claude/next/skills/feature-delivery/SKILL.md +1 -1
  89. package/presets/claude/next/skills/playwright-e2e/SKILL.md +1 -1
  90. package/presets/claude/next/skills/unit-testing/SKILL.md +1 -1
  91. package/presets/claude/nuxt/REPO_AGENTS.md +8 -48
  92. package/presets/claude/nuxt/agents/accessibility-reviewer.md +0 -1
  93. package/presets/claude/nuxt/agents/api-contract-reviewer.md +0 -1
  94. package/presets/claude/nuxt/agents/build-verifier.md +5 -3
  95. package/presets/claude/nuxt/agents/ci-investigator.md +1 -1
  96. package/presets/claude/nuxt/agents/code-reviewer.md +0 -1
  97. package/presets/claude/nuxt/agents/codebase-analyzer.md +0 -1
  98. package/presets/claude/nuxt/agents/debugger.md +1 -1
  99. package/presets/claude/nuxt/agents/feature-developer.md +6 -6
  100. package/presets/claude/nuxt/agents/migration-specialist.md +0 -1
  101. package/presets/claude/nuxt/agents/mockup-reviewer.md +0 -1
  102. package/presets/claude/nuxt/agents/openspec-author.md +0 -1
  103. package/presets/claude/nuxt/agents/performance-auditor.md +0 -1
  104. package/presets/claude/nuxt/agents/playwright-test-generator.md +0 -1
  105. package/presets/claude/nuxt/agents/playwright-test-healer.md +0 -1
  106. package/presets/claude/nuxt/agents/playwright-test-planner.md +0 -1
  107. package/presets/claude/nuxt/agents/qa-tester.md +3 -3
  108. package/presets/claude/nuxt/agents/security-reviewer.md +0 -1
  109. package/presets/claude/nuxt/agents/solution-architect.md +0 -1
  110. package/presets/claude/nuxt/agents/task-analyst.md +0 -1
  111. package/presets/claude/nuxt/agents/task-router.md +8 -7
  112. package/presets/claude/nuxt/agents/tech-writer.md +0 -1
  113. package/presets/claude/nuxt/agents/unit-test-generator.md +0 -1
  114. package/presets/claude/nuxt/agents/unit-test-healer.md +0 -1
  115. package/presets/claude/nuxt/agents/unit-test-planner.md +0 -1
  116. package/presets/claude/nuxt/hooks/chain-team-phases.sh +12 -3
  117. package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +3 -7
  118. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  119. package/presets/claude/nuxt/rules/tooling-and-review/code-quality.md +2 -6
  120. package/presets/claude/nuxt/rules/tooling-and-review/post-change-lint.md +14 -14
  121. package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  122. package/presets/claude/nuxt/skills/feature-delivery/SKILL.md +1 -1
  123. package/presets/claude/nuxt/skills/playwright-e2e/SKILL.md +1 -1
  124. package/presets/claude/nuxt/skills/unit-testing/SKILL.md +1 -1
  125. package/presets/claude/php-hexagonal/REPO_AGENTS.md +7 -47
  126. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +12 -3
  127. package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +3 -7
  128. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  129. package/presets/claude/php-hexagonal/rules/tooling-and-review/code-quality.md +2 -6
  130. package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  131. package/presets/claude/php-laravel/REPO_AGENTS.md +7 -47
  132. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +12 -3
  133. package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +3 -7
  134. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  135. package/presets/claude/php-laravel/rules/tooling-and-review/code-quality.md +2 -6
  136. package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  137. package/presets/claude/svelte/REPO_AGENTS.md +8 -48
  138. package/presets/claude/svelte/agents/accessibility-reviewer.md +0 -1
  139. package/presets/claude/svelte/agents/api-contract-reviewer.md +0 -1
  140. package/presets/claude/svelte/agents/build-verifier.md +5 -3
  141. package/presets/claude/svelte/agents/ci-investigator.md +1 -1
  142. package/presets/claude/svelte/agents/code-reviewer.md +0 -1
  143. package/presets/claude/svelte/agents/codebase-analyzer.md +0 -1
  144. package/presets/claude/svelte/agents/debugger.md +1 -1
  145. package/presets/claude/svelte/agents/feature-developer.md +6 -6
  146. package/presets/claude/svelte/agents/migration-specialist.md +0 -1
  147. package/presets/claude/svelte/agents/mockup-reviewer.md +0 -1
  148. package/presets/claude/svelte/agents/openspec-author.md +0 -1
  149. package/presets/claude/svelte/agents/performance-auditor.md +0 -1
  150. package/presets/claude/svelte/agents/playwright-test-generator.md +0 -1
  151. package/presets/claude/svelte/agents/playwright-test-healer.md +0 -1
  152. package/presets/claude/svelte/agents/playwright-test-planner.md +0 -1
  153. package/presets/claude/svelte/agents/qa-tester.md +3 -3
  154. package/presets/claude/svelte/agents/security-reviewer.md +0 -1
  155. package/presets/claude/svelte/agents/solution-architect.md +0 -1
  156. package/presets/claude/svelte/agents/task-analyst.md +0 -1
  157. package/presets/claude/svelte/agents/task-router.md +8 -7
  158. package/presets/claude/svelte/agents/tech-writer.md +0 -1
  159. package/presets/claude/svelte/agents/unit-test-generator.md +0 -1
  160. package/presets/claude/svelte/agents/unit-test-healer.md +0 -1
  161. package/presets/claude/svelte/agents/unit-test-planner.md +0 -1
  162. package/presets/claude/svelte/hooks/chain-team-phases.sh +12 -3
  163. package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +3 -7
  164. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
  165. package/presets/claude/svelte/rules/tooling-and-review/code-quality.md +2 -6
  166. package/presets/claude/svelte/rules/tooling-and-review/post-change-lint.md +14 -14
  167. package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +2 -2
  168. package/presets/claude/svelte/skills/feature-delivery/SKILL.md +1 -1
  169. package/presets/claude/svelte/skills/playwright-e2e/SKILL.md +1 -1
  170. package/presets/claude/svelte/skills/unit-testing/SKILL.md +1 -1
  171. package/presets/cursor/android-kotlin/AGENTS.md +0 -10
  172. package/presets/cursor/android-kotlin/REPO_AGENTS.md +7 -47
  173. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +12 -3
  174. package/presets/cursor/android-kotlin/rules/code-quality-and-refactoring.mdc +2 -6
  175. package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +2 -2
  176. package/presets/cursor/go/AGENTS.md +0 -8
  177. package/presets/cursor/go/REPO_AGENTS.md +7 -47
  178. package/presets/cursor/go/hooks/chain-team-phases.sh +12 -3
  179. package/presets/cursor/go/rules/code-quality-and-refactoring.mdc +2 -6
  180. package/presets/cursor/go/rules/preset-pr-checklist.mdc +2 -2
  181. package/presets/cursor/ios-swift/AGENTS.md +0 -10
  182. package/presets/cursor/ios-swift/REPO_AGENTS.md +7 -47
  183. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +12 -3
  184. package/presets/cursor/ios-swift/rules/code-quality-and-refactoring.mdc +2 -6
  185. package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +2 -2
  186. package/presets/cursor/java/AGENTS.md +0 -8
  187. package/presets/cursor/java/REPO_AGENTS.md +7 -47
  188. package/presets/cursor/java/hooks/chain-team-phases.sh +12 -3
  189. package/presets/cursor/java/rules/code-quality-and-refactoring.mdc +2 -6
  190. package/presets/cursor/java/rules/preset-pr-checklist.mdc +2 -2
  191. package/presets/cursor/mcp-ts/AGENTS.md +0 -6
  192. package/presets/cursor/mcp-ts/REPO_AGENTS.md +7 -47
  193. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +12 -3
  194. package/presets/cursor/mcp-ts/rules/code-quality-and-refactoring.mdc +2 -6
  195. package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +2 -2
  196. package/presets/cursor/mol/AGENTS.md +0 -11
  197. package/presets/cursor/mol/REPO_AGENTS.md +9 -49
  198. package/presets/cursor/mol/hooks/chain-team-phases.sh +12 -3
  199. package/presets/cursor/mol/rules/code-quality-and-refactoring.mdc +2 -6
  200. package/presets/cursor/mol/rules/preset-pr-checklist.mdc +2 -2
  201. package/presets/cursor/next/AGENTS.md +1 -12
  202. package/presets/cursor/next/REPO_AGENTS.md +10 -50
  203. package/presets/cursor/next/agents/build-verifier.md +11 -7
  204. package/presets/cursor/next/agents/code-reviewer.md +1 -0
  205. package/presets/cursor/next/agents/feature-developer.md +6 -6
  206. package/presets/cursor/next/agents/qa-tester.md +3 -2
  207. package/presets/cursor/next/agents/task-router.md +8 -6
  208. package/presets/cursor/next/commands/README.md +0 -6
  209. package/presets/cursor/next/hooks/chain-team-phases.sh +12 -3
  210. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +4 -4
  211. package/presets/cursor/next/rules/code-quality-and-refactoring.mdc +2 -6
  212. package/presets/cursor/next/rules/feature-delivery-workflow.mdc +2 -2
  213. package/presets/cursor/next/rules/post-change-lint.mdc +12 -16
  214. package/presets/cursor/next/rules/preset-pr-checklist.mdc +2 -2
  215. package/presets/cursor/next/skills/feature-delivery/SKILL.md +1 -1
  216. package/presets/cursor/next/skills/playwright-e2e/SKILL.md +1 -1
  217. package/presets/cursor/next/skills/unit-testing/SKILL.md +1 -1
  218. package/presets/cursor/nuxt/AGENTS.md +1 -12
  219. package/presets/cursor/nuxt/REPO_AGENTS.md +8 -48
  220. package/presets/cursor/nuxt/agents/build-verifier.md +1 -1
  221. package/presets/cursor/nuxt/agents/feature-developer.md +2 -2
  222. package/presets/cursor/nuxt/agents/qa-tester.md +3 -2
  223. package/presets/cursor/nuxt/agents/task-router.md +8 -6
  224. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +12 -3
  225. package/presets/cursor/nuxt/rules/code-quality-and-refactoring.mdc +2 -6
  226. package/presets/cursor/nuxt/rules/post-change-lint.mdc +14 -14
  227. package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +2 -2
  228. package/presets/cursor/nuxt/skills/feature-delivery/SKILL.md +1 -1
  229. package/presets/cursor/nuxt/skills/playwright-e2e/SKILL.md +1 -1
  230. package/presets/cursor/nuxt/skills/unit-testing/SKILL.md +1 -1
  231. package/presets/cursor/php-hexagonal/AGENTS.md +0 -8
  232. package/presets/cursor/php-hexagonal/REPO_AGENTS.md +7 -47
  233. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +12 -3
  234. package/presets/cursor/php-hexagonal/rules/code-quality-and-refactoring.mdc +2 -6
  235. package/presets/cursor/php-hexagonal/rules/preset-pr-checklist.mdc +2 -2
  236. package/presets/cursor/php-laravel/AGENTS.md +0 -8
  237. package/presets/cursor/php-laravel/REPO_AGENTS.md +7 -47
  238. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +12 -3
  239. package/presets/cursor/php-laravel/rules/code-quality-and-refactoring.mdc +2 -6
  240. package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +2 -2
  241. package/presets/cursor/svelte/AGENTS.md +1 -12
  242. package/presets/cursor/svelte/REPO_AGENTS.md +8 -48
  243. package/presets/cursor/svelte/agents/build-verifier.md +1 -1
  244. package/presets/cursor/svelte/agents/feature-developer.md +2 -2
  245. package/presets/cursor/svelte/agents/qa-tester.md +3 -2
  246. package/presets/cursor/svelte/agents/task-router.md +8 -6
  247. package/presets/cursor/svelte/hooks/chain-team-phases.sh +12 -3
  248. package/presets/cursor/svelte/rules/code-quality-and-refactoring.mdc +2 -6
  249. package/presets/cursor/svelte/rules/post-change-lint.mdc +14 -14
  250. package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +2 -2
  251. package/presets/cursor/svelte/skills/feature-delivery/SKILL.md +1 -1
  252. package/presets/cursor/svelte/skills/playwright-e2e/SKILL.md +1 -1
  253. package/presets/cursor/svelte/skills/unit-testing/SKILL.md +1 -1
  254. package/presets/mavis/android-kotlin/MAVIS.md +0 -2
  255. package/presets/mavis/android-kotlin/REPO_AGENTS.md +7 -47
  256. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  257. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +12 -3
  258. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +5 -5
  259. package/presets/mavis/android-kotlin/rules/code-quality-and-refactoring.md +2 -6
  260. package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +2 -2
  261. package/presets/mavis/go/MAVIS.md +8 -0
  262. package/presets/mavis/go/REPO_AGENTS.md +7 -47
  263. package/presets/mavis/go/adapter-map.json +1 -1
  264. package/presets/mavis/go/hooks/chain-team-phases.sh +12 -3
  265. package/presets/mavis/go/rules/agent-team-orchestrator.md +5 -5
  266. package/presets/mavis/go/rules/code-quality-and-refactoring.md +2 -6
  267. package/presets/mavis/go/rules/feature-delivery-workflow.md +3 -7
  268. package/presets/mavis/go/rules/preset-pr-checklist.md +2 -2
  269. package/presets/mavis/ios-swift/MAVIS.md +0 -2
  270. package/presets/mavis/ios-swift/REPO_AGENTS.md +7 -47
  271. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  272. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +12 -3
  273. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +5 -5
  274. package/presets/mavis/ios-swift/rules/code-quality-and-refactoring.md +2 -6
  275. package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +3 -7
  276. package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +2 -2
  277. package/presets/mavis/java/MAVIS.md +14 -0
  278. package/presets/mavis/java/REPO_AGENTS.md +7 -47
  279. package/presets/mavis/java/adapter-map.json +1 -1
  280. package/presets/mavis/java/hooks/chain-team-phases.sh +12 -3
  281. package/presets/mavis/java/rules/agent-team-orchestrator.md +5 -5
  282. package/presets/mavis/java/rules/code-quality-and-refactoring.md +2 -6
  283. package/presets/mavis/java/rules/feature-delivery-workflow.md +3 -7
  284. package/presets/mavis/java/rules/preset-pr-checklist.md +2 -2
  285. package/presets/mavis/mcp-ts/MAVIS.md +6 -0
  286. package/presets/mavis/mcp-ts/REPO_AGENTS.md +7 -47
  287. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  288. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +12 -3
  289. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +5 -5
  290. package/presets/mavis/mcp-ts/rules/code-quality-and-refactoring.md +2 -6
  291. package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +3 -7
  292. package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +2 -2
  293. package/presets/mavis/mol/MAVIS.md +1 -5
  294. package/presets/mavis/mol/REPO_AGENTS.md +9 -49
  295. package/presets/mavis/mol/adapter-map.json +1 -1
  296. package/presets/mavis/mol/hooks/chain-team-phases.sh +12 -3
  297. package/presets/mavis/mol/rules/agent-team-orchestrator.md +5 -5
  298. package/presets/mavis/mol/rules/code-quality-and-refactoring.md +2 -6
  299. package/presets/mavis/mol/rules/feature-delivery-workflow.md +3 -7
  300. package/presets/mavis/mol/rules/preset-pr-checklist.md +2 -2
  301. package/presets/mavis/next/MAVIS.md +2 -6
  302. package/presets/mavis/next/REPO_AGENTS.md +10 -50
  303. package/presets/mavis/next/adapter-map.json +1 -17
  304. package/presets/mavis/next/agents/accessibility-reviewer.md +0 -1
  305. package/presets/mavis/next/agents/api-contract-reviewer.md +0 -1
  306. package/presets/mavis/next/agents/build-verifier.md +12 -8
  307. package/presets/mavis/next/agents/code-reviewer.md +1 -1
  308. package/presets/mavis/next/agents/codebase-analyzer.md +0 -1
  309. package/presets/mavis/next/agents/feature-developer.md +6 -6
  310. package/presets/mavis/next/agents/migration-specialist.md +0 -1
  311. package/presets/mavis/next/agents/mockup-reviewer.md +0 -1
  312. package/presets/mavis/next/agents/openspec-author.md +0 -1
  313. package/presets/mavis/next/agents/performance-auditor.md +0 -1
  314. package/presets/mavis/next/agents/playwright-test-generator.md +0 -1
  315. package/presets/mavis/next/agents/playwright-test-healer.md +0 -1
  316. package/presets/mavis/next/agents/playwright-test-planner.md +0 -1
  317. package/presets/mavis/next/agents/qa-tester.md +3 -3
  318. package/presets/mavis/next/agents/security-reviewer.md +0 -1
  319. package/presets/mavis/next/agents/solution-architect.md +0 -1
  320. package/presets/mavis/next/agents/task-analyst.md +0 -1
  321. package/presets/mavis/next/agents/task-router.md +8 -7
  322. package/presets/mavis/next/agents/tech-writer.md +0 -1
  323. package/presets/mavis/next/agents/unit-test-generator.md +0 -1
  324. package/presets/mavis/next/agents/unit-test-healer.md +0 -1
  325. package/presets/mavis/next/agents/unit-test-planner.md +0 -1
  326. package/presets/mavis/next/commands/README.md +0 -6
  327. package/presets/mavis/next/hooks/chain-team-phases.sh +12 -3
  328. package/presets/mavis/next/rules/agent-team-orchestrator.md +5 -5
  329. package/presets/mavis/next/rules/code-quality-and-refactoring.md +2 -6
  330. package/presets/mavis/next/rules/feature-delivery-workflow.md +5 -9
  331. package/presets/mavis/next/rules/post-change-lint.md +11 -15
  332. package/presets/mavis/next/rules/preset-pr-checklist.md +2 -2
  333. package/presets/mavis/next/skills/feature-delivery/SKILL.md +1 -1
  334. package/presets/mavis/next/skills/playwright-e2e/SKILL.md +1 -1
  335. package/presets/mavis/next/skills/unit-testing/SKILL.md +1 -1
  336. package/presets/mavis/nuxt/MAVIS.md +2 -6
  337. package/presets/mavis/nuxt/REPO_AGENTS.md +8 -48
  338. package/presets/mavis/nuxt/adapter-map.json +1 -1
  339. package/presets/mavis/nuxt/agents/accessibility-reviewer.md +0 -1
  340. package/presets/mavis/nuxt/agents/api-contract-reviewer.md +0 -1
  341. package/presets/mavis/nuxt/agents/build-verifier.md +2 -2
  342. package/presets/mavis/nuxt/agents/ci-investigator.md +1 -1
  343. package/presets/mavis/nuxt/agents/code-reviewer.md +0 -1
  344. package/presets/mavis/nuxt/agents/codebase-analyzer.md +0 -1
  345. package/presets/mavis/nuxt/agents/debugger.md +1 -1
  346. package/presets/mavis/nuxt/agents/feature-developer.md +3 -3
  347. package/presets/mavis/nuxt/agents/migration-specialist.md +0 -1
  348. package/presets/mavis/nuxt/agents/mockup-reviewer.md +0 -1
  349. package/presets/mavis/nuxt/agents/openspec-author.md +0 -1
  350. package/presets/mavis/nuxt/agents/performance-auditor.md +0 -1
  351. package/presets/mavis/nuxt/agents/playwright-test-generator.md +0 -1
  352. package/presets/mavis/nuxt/agents/playwright-test-healer.md +0 -1
  353. package/presets/mavis/nuxt/agents/playwright-test-planner.md +0 -1
  354. package/presets/mavis/nuxt/agents/qa-tester.md +3 -3
  355. package/presets/mavis/nuxt/agents/security-reviewer.md +0 -1
  356. package/presets/mavis/nuxt/agents/solution-architect.md +0 -1
  357. package/presets/mavis/nuxt/agents/task-analyst.md +0 -1
  358. package/presets/mavis/nuxt/agents/task-router.md +8 -7
  359. package/presets/mavis/nuxt/agents/tech-writer.md +0 -1
  360. package/presets/mavis/nuxt/agents/unit-test-generator.md +0 -1
  361. package/presets/mavis/nuxt/agents/unit-test-healer.md +0 -1
  362. package/presets/mavis/nuxt/agents/unit-test-planner.md +0 -1
  363. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +12 -3
  364. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +5 -5
  365. package/presets/mavis/nuxt/rules/code-quality-and-refactoring.md +2 -6
  366. package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +3 -7
  367. package/presets/mavis/nuxt/rules/post-change-lint.md +13 -13
  368. package/presets/mavis/nuxt/rules/preset-pr-checklist.md +2 -2
  369. package/presets/mavis/nuxt/skills/feature-delivery/SKILL.md +1 -1
  370. package/presets/mavis/nuxt/skills/playwright-e2e/SKILL.md +1 -1
  371. package/presets/mavis/nuxt/skills/unit-testing/SKILL.md +1 -1
  372. package/presets/mavis/php-hexagonal/MAVIS.md +16 -0
  373. package/presets/mavis/php-hexagonal/REPO_AGENTS.md +7 -47
  374. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  375. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +12 -3
  376. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
  377. package/presets/mavis/php-hexagonal/rules/code-quality-and-refactoring.md +2 -6
  378. package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +3 -7
  379. package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +2 -2
  380. package/presets/mavis/php-laravel/MAVIS.md +16 -0
  381. package/presets/mavis/php-laravel/REPO_AGENTS.md +7 -47
  382. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  383. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +12 -3
  384. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +5 -5
  385. package/presets/mavis/php-laravel/rules/code-quality-and-refactoring.md +2 -6
  386. package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +3 -7
  387. package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +2 -2
  388. package/presets/mavis/svelte/MAVIS.md +2 -6
  389. package/presets/mavis/svelte/REPO_AGENTS.md +8 -48
  390. package/presets/mavis/svelte/adapter-map.json +1 -1
  391. package/presets/mavis/svelte/agents/accessibility-reviewer.md +0 -1
  392. package/presets/mavis/svelte/agents/api-contract-reviewer.md +0 -1
  393. package/presets/mavis/svelte/agents/build-verifier.md +2 -2
  394. package/presets/mavis/svelte/agents/ci-investigator.md +1 -1
  395. package/presets/mavis/svelte/agents/code-reviewer.md +0 -1
  396. package/presets/mavis/svelte/agents/codebase-analyzer.md +0 -1
  397. package/presets/mavis/svelte/agents/debugger.md +1 -1
  398. package/presets/mavis/svelte/agents/feature-developer.md +3 -3
  399. package/presets/mavis/svelte/agents/migration-specialist.md +0 -1
  400. package/presets/mavis/svelte/agents/mockup-reviewer.md +0 -1
  401. package/presets/mavis/svelte/agents/openspec-author.md +0 -1
  402. package/presets/mavis/svelte/agents/performance-auditor.md +0 -1
  403. package/presets/mavis/svelte/agents/playwright-test-generator.md +0 -1
  404. package/presets/mavis/svelte/agents/playwright-test-healer.md +0 -1
  405. package/presets/mavis/svelte/agents/playwright-test-planner.md +0 -1
  406. package/presets/mavis/svelte/agents/qa-tester.md +3 -3
  407. package/presets/mavis/svelte/agents/security-reviewer.md +0 -1
  408. package/presets/mavis/svelte/agents/solution-architect.md +0 -1
  409. package/presets/mavis/svelte/agents/task-analyst.md +0 -1
  410. package/presets/mavis/svelte/agents/task-router.md +8 -7
  411. package/presets/mavis/svelte/agents/tech-writer.md +0 -1
  412. package/presets/mavis/svelte/agents/unit-test-generator.md +0 -1
  413. package/presets/mavis/svelte/agents/unit-test-healer.md +0 -1
  414. package/presets/mavis/svelte/agents/unit-test-planner.md +0 -1
  415. package/presets/mavis/svelte/hooks/chain-team-phases.sh +12 -3
  416. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +5 -5
  417. package/presets/mavis/svelte/rules/code-quality-and-refactoring.md +2 -6
  418. package/presets/mavis/svelte/rules/feature-delivery-workflow.md +3 -7
  419. package/presets/mavis/svelte/rules/post-change-lint.md +13 -13
  420. package/presets/mavis/svelte/rules/preset-pr-checklist.md +2 -2
  421. package/presets/mavis/svelte/skills/feature-delivery/SKILL.md +1 -1
  422. package/presets/mavis/svelte/skills/playwright-e2e/SKILL.md +1 -1
  423. package/presets/mavis/svelte/skills/unit-testing/SKILL.md +1 -1
  424. package/presets/opencode/android-kotlin/OPENCODE.md +1 -43
  425. package/presets/opencode/android-kotlin/REPO_AGENTS.md +7 -47
  426. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  427. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +12 -3
  428. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +5 -5
  429. package/presets/opencode/android-kotlin/rules/code-quality-and-refactoring.md +2 -6
  430. package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +2 -2
  431. package/presets/opencode/go/OPENCODE.md +7 -39
  432. package/presets/opencode/go/REPO_AGENTS.md +7 -47
  433. package/presets/opencode/go/adapter-map.json +1 -1
  434. package/presets/opencode/go/hooks/chain-team-phases.sh +12 -3
  435. package/presets/opencode/go/rules/agent-team-orchestrator.md +5 -5
  436. package/presets/opencode/go/rules/code-quality-and-refactoring.md +2 -6
  437. package/presets/opencode/go/rules/feature-delivery-workflow.md +3 -7
  438. package/presets/opencode/go/rules/preset-pr-checklist.md +2 -2
  439. package/presets/opencode/ios-swift/OPENCODE.md +1 -43
  440. package/presets/opencode/ios-swift/REPO_AGENTS.md +7 -47
  441. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  442. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +12 -3
  443. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +5 -5
  444. package/presets/opencode/ios-swift/rules/code-quality-and-refactoring.md +2 -6
  445. package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +3 -7
  446. package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +2 -2
  447. package/presets/opencode/java/OPENCODE.md +12 -38
  448. package/presets/opencode/java/REPO_AGENTS.md +7 -47
  449. package/presets/opencode/java/adapter-map.json +1 -1
  450. package/presets/opencode/java/hooks/chain-team-phases.sh +12 -3
  451. package/presets/opencode/java/rules/agent-team-orchestrator.md +5 -5
  452. package/presets/opencode/java/rules/code-quality-and-refactoring.md +2 -6
  453. package/presets/opencode/java/rules/feature-delivery-workflow.md +3 -7
  454. package/presets/opencode/java/rules/preset-pr-checklist.md +2 -2
  455. package/presets/opencode/mcp-ts/OPENCODE.md +5 -39
  456. package/presets/opencode/mcp-ts/REPO_AGENTS.md +7 -47
  457. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  458. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +12 -3
  459. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +5 -5
  460. package/presets/opencode/mcp-ts/rules/code-quality-and-refactoring.md +2 -6
  461. package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +3 -7
  462. package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +2 -2
  463. package/presets/opencode/mol/OPENCODE.md +1 -44
  464. package/presets/opencode/mol/REPO_AGENTS.md +9 -49
  465. package/presets/opencode/mol/adapter-map.json +1 -1
  466. package/presets/opencode/mol/hooks/chain-team-phases.sh +12 -3
  467. package/presets/opencode/mol/rules/agent-team-orchestrator.md +5 -5
  468. package/presets/opencode/mol/rules/code-quality-and-refactoring.md +2 -6
  469. package/presets/opencode/mol/rules/feature-delivery-workflow.md +3 -7
  470. package/presets/opencode/mol/rules/preset-pr-checklist.md +2 -2
  471. package/presets/opencode/next/OPENCODE.md +2 -45
  472. package/presets/opencode/next/REPO_AGENTS.md +10 -50
  473. package/presets/opencode/next/adapter-map.json +1 -17
  474. package/presets/opencode/next/agents/accessibility-reviewer.md +0 -1
  475. package/presets/opencode/next/agents/api-contract-reviewer.md +0 -1
  476. package/presets/opencode/next/agents/build-verifier.md +12 -8
  477. package/presets/opencode/next/agents/code-reviewer.md +1 -1
  478. package/presets/opencode/next/agents/codebase-analyzer.md +0 -1
  479. package/presets/opencode/next/agents/feature-developer.md +6 -6
  480. package/presets/opencode/next/agents/migration-specialist.md +0 -1
  481. package/presets/opencode/next/agents/mockup-reviewer.md +0 -1
  482. package/presets/opencode/next/agents/openspec-author.md +0 -1
  483. package/presets/opencode/next/agents/performance-auditor.md +0 -1
  484. package/presets/opencode/next/agents/playwright-test-generator.md +0 -1
  485. package/presets/opencode/next/agents/playwright-test-healer.md +0 -1
  486. package/presets/opencode/next/agents/playwright-test-planner.md +0 -1
  487. package/presets/opencode/next/agents/qa-tester.md +3 -3
  488. package/presets/opencode/next/agents/security-reviewer.md +0 -1
  489. package/presets/opencode/next/agents/solution-architect.md +0 -1
  490. package/presets/opencode/next/agents/task-analyst.md +0 -1
  491. package/presets/opencode/next/agents/task-router.md +8 -7
  492. package/presets/opencode/next/agents/tech-writer.md +0 -1
  493. package/presets/opencode/next/agents/unit-test-generator.md +0 -1
  494. package/presets/opencode/next/agents/unit-test-healer.md +0 -1
  495. package/presets/opencode/next/agents/unit-test-planner.md +0 -1
  496. package/presets/opencode/next/commands/README.md +0 -6
  497. package/presets/opencode/next/hooks/chain-team-phases.sh +12 -3
  498. package/presets/opencode/next/rules/agent-team-orchestrator.md +5 -5
  499. package/presets/opencode/next/rules/code-quality-and-refactoring.md +2 -6
  500. package/presets/opencode/next/rules/feature-delivery-workflow.md +5 -9
  501. package/presets/opencode/next/rules/post-change-lint.md +11 -15
  502. package/presets/opencode/next/rules/preset-pr-checklist.md +2 -2
  503. package/presets/opencode/next/skills/feature-delivery/SKILL.md +1 -1
  504. package/presets/opencode/next/skills/playwright-e2e/SKILL.md +1 -1
  505. package/presets/opencode/next/skills/unit-testing/SKILL.md +1 -1
  506. package/presets/opencode/nuxt/OPENCODE.md +2 -45
  507. package/presets/opencode/nuxt/REPO_AGENTS.md +8 -48
  508. package/presets/opencode/nuxt/adapter-map.json +1 -1
  509. package/presets/opencode/nuxt/agents/accessibility-reviewer.md +0 -1
  510. package/presets/opencode/nuxt/agents/api-contract-reviewer.md +0 -1
  511. package/presets/opencode/nuxt/agents/build-verifier.md +2 -2
  512. package/presets/opencode/nuxt/agents/ci-investigator.md +1 -1
  513. package/presets/opencode/nuxt/agents/code-reviewer.md +0 -1
  514. package/presets/opencode/nuxt/agents/codebase-analyzer.md +0 -1
  515. package/presets/opencode/nuxt/agents/debugger.md +1 -1
  516. package/presets/opencode/nuxt/agents/feature-developer.md +3 -3
  517. package/presets/opencode/nuxt/agents/migration-specialist.md +0 -1
  518. package/presets/opencode/nuxt/agents/mockup-reviewer.md +0 -1
  519. package/presets/opencode/nuxt/agents/openspec-author.md +0 -1
  520. package/presets/opencode/nuxt/agents/performance-auditor.md +0 -1
  521. package/presets/opencode/nuxt/agents/playwright-test-generator.md +0 -1
  522. package/presets/opencode/nuxt/agents/playwright-test-healer.md +0 -1
  523. package/presets/opencode/nuxt/agents/playwright-test-planner.md +0 -1
  524. package/presets/opencode/nuxt/agents/qa-tester.md +3 -3
  525. package/presets/opencode/nuxt/agents/security-reviewer.md +0 -1
  526. package/presets/opencode/nuxt/agents/solution-architect.md +0 -1
  527. package/presets/opencode/nuxt/agents/task-analyst.md +0 -1
  528. package/presets/opencode/nuxt/agents/task-router.md +8 -7
  529. package/presets/opencode/nuxt/agents/tech-writer.md +0 -1
  530. package/presets/opencode/nuxt/agents/unit-test-generator.md +0 -1
  531. package/presets/opencode/nuxt/agents/unit-test-healer.md +0 -1
  532. package/presets/opencode/nuxt/agents/unit-test-planner.md +0 -1
  533. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +12 -3
  534. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +5 -5
  535. package/presets/opencode/nuxt/rules/code-quality-and-refactoring.md +2 -6
  536. package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +3 -7
  537. package/presets/opencode/nuxt/rules/post-change-lint.md +13 -13
  538. package/presets/opencode/nuxt/rules/preset-pr-checklist.md +2 -2
  539. package/presets/opencode/nuxt/skills/feature-delivery/SKILL.md +1 -1
  540. package/presets/opencode/nuxt/skills/playwright-e2e/SKILL.md +1 -1
  541. package/presets/opencode/nuxt/skills/unit-testing/SKILL.md +1 -1
  542. package/presets/opencode/php-hexagonal/OPENCODE.md +14 -38
  543. package/presets/opencode/php-hexagonal/REPO_AGENTS.md +7 -47
  544. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  545. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +12 -3
  546. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
  547. package/presets/opencode/php-hexagonal/rules/code-quality-and-refactoring.md +2 -6
  548. package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +3 -7
  549. package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +2 -2
  550. package/presets/opencode/php-laravel/OPENCODE.md +14 -38
  551. package/presets/opencode/php-laravel/REPO_AGENTS.md +7 -47
  552. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  553. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +12 -3
  554. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +5 -5
  555. package/presets/opencode/php-laravel/rules/code-quality-and-refactoring.md +2 -6
  556. package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +3 -7
  557. package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +2 -2
  558. package/presets/opencode/plugins/output-guard/index.ts +7 -1
  559. package/presets/opencode/plugins/output-guard/ledger.ts +43 -0
  560. package/presets/opencode/plugins/task-status/economy.ts +112 -0
  561. package/presets/opencode/plugins/task-status/task-view.ts +28 -0
  562. package/presets/opencode/plugins/task-status/tui.tsx +14 -2
  563. package/presets/opencode/plugins/task-status/types.ts +3 -1
  564. package/presets/opencode/svelte/OPENCODE.md +2 -45
  565. package/presets/opencode/svelte/REPO_AGENTS.md +8 -48
  566. package/presets/opencode/svelte/adapter-map.json +1 -1
  567. package/presets/opencode/svelte/agents/accessibility-reviewer.md +0 -1
  568. package/presets/opencode/svelte/agents/api-contract-reviewer.md +0 -1
  569. package/presets/opencode/svelte/agents/build-verifier.md +2 -2
  570. package/presets/opencode/svelte/agents/ci-investigator.md +1 -1
  571. package/presets/opencode/svelte/agents/code-reviewer.md +0 -1
  572. package/presets/opencode/svelte/agents/codebase-analyzer.md +0 -1
  573. package/presets/opencode/svelte/agents/debugger.md +1 -1
  574. package/presets/opencode/svelte/agents/feature-developer.md +3 -3
  575. package/presets/opencode/svelte/agents/migration-specialist.md +0 -1
  576. package/presets/opencode/svelte/agents/mockup-reviewer.md +0 -1
  577. package/presets/opencode/svelte/agents/openspec-author.md +0 -1
  578. package/presets/opencode/svelte/agents/performance-auditor.md +0 -1
  579. package/presets/opencode/svelte/agents/playwright-test-generator.md +0 -1
  580. package/presets/opencode/svelte/agents/playwright-test-healer.md +0 -1
  581. package/presets/opencode/svelte/agents/playwright-test-planner.md +0 -1
  582. package/presets/opencode/svelte/agents/qa-tester.md +3 -3
  583. package/presets/opencode/svelte/agents/security-reviewer.md +0 -1
  584. package/presets/opencode/svelte/agents/solution-architect.md +0 -1
  585. package/presets/opencode/svelte/agents/task-analyst.md +0 -1
  586. package/presets/opencode/svelte/agents/task-router.md +8 -7
  587. package/presets/opencode/svelte/agents/tech-writer.md +0 -1
  588. package/presets/opencode/svelte/agents/unit-test-generator.md +0 -1
  589. package/presets/opencode/svelte/agents/unit-test-healer.md +0 -1
  590. package/presets/opencode/svelte/agents/unit-test-planner.md +0 -1
  591. package/presets/opencode/svelte/hooks/chain-team-phases.sh +12 -3
  592. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +5 -5
  593. package/presets/opencode/svelte/rules/code-quality-and-refactoring.md +2 -6
  594. package/presets/opencode/svelte/rules/feature-delivery-workflow.md +3 -7
  595. package/presets/opencode/svelte/rules/post-change-lint.md +13 -13
  596. package/presets/opencode/svelte/rules/preset-pr-checklist.md +2 -2
  597. package/presets/opencode/svelte/skills/feature-delivery/SKILL.md +1 -1
  598. package/presets/opencode/svelte/skills/playwright-e2e/SKILL.md +1 -1
  599. package/presets/opencode/svelte/skills/unit-testing/SKILL.md +1 -1
  600. package/presets/zcode/android-kotlin/REPO_AGENTS.md +7 -47
  601. package/presets/zcode/android-kotlin/adapter-map.json +1 -1
  602. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +12 -3
  603. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +5 -5
  604. package/presets/zcode/android-kotlin/rules/code-quality-and-refactoring.md +2 -6
  605. package/presets/zcode/android-kotlin/rules/preset-pr-checklist.md +2 -2
  606. package/presets/zcode/go/REPO_AGENTS.md +7 -47
  607. package/presets/zcode/go/adapter-map.json +1 -1
  608. package/presets/zcode/go/hooks/chain-team-phases.sh +12 -3
  609. package/presets/zcode/go/rules/agent-team-orchestrator.md +5 -5
  610. package/presets/zcode/go/rules/code-quality-and-refactoring.md +2 -6
  611. package/presets/zcode/go/rules/feature-delivery-workflow.md +3 -7
  612. package/presets/zcode/go/rules/preset-pr-checklist.md +2 -2
  613. package/presets/zcode/ios-swift/REPO_AGENTS.md +7 -47
  614. package/presets/zcode/ios-swift/adapter-map.json +1 -1
  615. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +12 -3
  616. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +5 -5
  617. package/presets/zcode/ios-swift/rules/code-quality-and-refactoring.md +2 -6
  618. package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +3 -7
  619. package/presets/zcode/ios-swift/rules/preset-pr-checklist.md +2 -2
  620. package/presets/zcode/java/REPO_AGENTS.md +7 -47
  621. package/presets/zcode/java/adapter-map.json +1 -1
  622. package/presets/zcode/java/hooks/chain-team-phases.sh +12 -3
  623. package/presets/zcode/java/rules/agent-team-orchestrator.md +5 -5
  624. package/presets/zcode/java/rules/code-quality-and-refactoring.md +2 -6
  625. package/presets/zcode/java/rules/feature-delivery-workflow.md +3 -7
  626. package/presets/zcode/java/rules/preset-pr-checklist.md +2 -2
  627. package/presets/zcode/mcp-ts/REPO_AGENTS.md +7 -47
  628. package/presets/zcode/mcp-ts/adapter-map.json +1 -1
  629. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +12 -3
  630. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +5 -5
  631. package/presets/zcode/mcp-ts/rules/code-quality-and-refactoring.md +2 -6
  632. package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +3 -7
  633. package/presets/zcode/mcp-ts/rules/preset-pr-checklist.md +2 -2
  634. package/presets/zcode/mol/REPO_AGENTS.md +9 -49
  635. package/presets/zcode/mol/adapter-map.json +1 -1
  636. package/presets/zcode/mol/hooks/chain-team-phases.sh +12 -3
  637. package/presets/zcode/mol/rules/agent-team-orchestrator.md +5 -5
  638. package/presets/zcode/mol/rules/code-quality-and-refactoring.md +2 -6
  639. package/presets/zcode/mol/rules/feature-delivery-workflow.md +3 -7
  640. package/presets/zcode/mol/rules/preset-pr-checklist.md +2 -2
  641. package/presets/zcode/next/REPO_AGENTS.md +10 -50
  642. package/presets/zcode/next/adapter-map.json +1 -17
  643. package/presets/zcode/next/agents/accessibility-reviewer.md +0 -1
  644. package/presets/zcode/next/agents/api-contract-reviewer.md +0 -1
  645. package/presets/zcode/next/agents/build-verifier.md +12 -8
  646. package/presets/zcode/next/agents/code-reviewer.md +1 -1
  647. package/presets/zcode/next/agents/codebase-analyzer.md +0 -1
  648. package/presets/zcode/next/agents/feature-developer.md +6 -6
  649. package/presets/zcode/next/agents/migration-specialist.md +0 -1
  650. package/presets/zcode/next/agents/mockup-reviewer.md +0 -1
  651. package/presets/zcode/next/agents/openspec-author.md +0 -1
  652. package/presets/zcode/next/agents/performance-auditor.md +0 -1
  653. package/presets/zcode/next/agents/playwright-test-generator.md +0 -1
  654. package/presets/zcode/next/agents/playwright-test-healer.md +0 -1
  655. package/presets/zcode/next/agents/playwright-test-planner.md +0 -1
  656. package/presets/zcode/next/agents/qa-tester.md +3 -3
  657. package/presets/zcode/next/agents/security-reviewer.md +0 -1
  658. package/presets/zcode/next/agents/solution-architect.md +0 -1
  659. package/presets/zcode/next/agents/task-analyst.md +0 -1
  660. package/presets/zcode/next/agents/task-router.md +8 -7
  661. package/presets/zcode/next/agents/tech-writer.md +0 -1
  662. package/presets/zcode/next/agents/unit-test-generator.md +0 -1
  663. package/presets/zcode/next/agents/unit-test-healer.md +0 -1
  664. package/presets/zcode/next/agents/unit-test-planner.md +0 -1
  665. package/presets/zcode/next/commands/README.md +0 -6
  666. package/presets/zcode/next/hooks/chain-team-phases.sh +12 -3
  667. package/presets/zcode/next/rules/agent-team-orchestrator.md +5 -5
  668. package/presets/zcode/next/rules/code-quality-and-refactoring.md +2 -6
  669. package/presets/zcode/next/rules/feature-delivery-workflow.md +5 -9
  670. package/presets/zcode/next/rules/post-change-lint.md +11 -15
  671. package/presets/zcode/next/rules/preset-pr-checklist.md +2 -2
  672. package/presets/zcode/next/skills/feature-delivery/SKILL.md +1 -1
  673. package/presets/zcode/next/skills/playwright-e2e/SKILL.md +1 -1
  674. package/presets/zcode/next/skills/unit-testing/SKILL.md +1 -1
  675. package/presets/zcode/nuxt/REPO_AGENTS.md +8 -48
  676. package/presets/zcode/nuxt/adapter-map.json +1 -1
  677. package/presets/zcode/nuxt/agents/accessibility-reviewer.md +0 -1
  678. package/presets/zcode/nuxt/agents/api-contract-reviewer.md +0 -1
  679. package/presets/zcode/nuxt/agents/build-verifier.md +2 -2
  680. package/presets/zcode/nuxt/agents/ci-investigator.md +1 -1
  681. package/presets/zcode/nuxt/agents/code-reviewer.md +0 -1
  682. package/presets/zcode/nuxt/agents/codebase-analyzer.md +0 -1
  683. package/presets/zcode/nuxt/agents/debugger.md +1 -1
  684. package/presets/zcode/nuxt/agents/feature-developer.md +3 -3
  685. package/presets/zcode/nuxt/agents/migration-specialist.md +0 -1
  686. package/presets/zcode/nuxt/agents/mockup-reviewer.md +0 -1
  687. package/presets/zcode/nuxt/agents/openspec-author.md +0 -1
  688. package/presets/zcode/nuxt/agents/performance-auditor.md +0 -1
  689. package/presets/zcode/nuxt/agents/playwright-test-generator.md +0 -1
  690. package/presets/zcode/nuxt/agents/playwright-test-healer.md +0 -1
  691. package/presets/zcode/nuxt/agents/playwright-test-planner.md +0 -1
  692. package/presets/zcode/nuxt/agents/qa-tester.md +3 -3
  693. package/presets/zcode/nuxt/agents/security-reviewer.md +0 -1
  694. package/presets/zcode/nuxt/agents/solution-architect.md +0 -1
  695. package/presets/zcode/nuxt/agents/task-analyst.md +0 -1
  696. package/presets/zcode/nuxt/agents/task-router.md +8 -7
  697. package/presets/zcode/nuxt/agents/tech-writer.md +0 -1
  698. package/presets/zcode/nuxt/agents/unit-test-generator.md +0 -1
  699. package/presets/zcode/nuxt/agents/unit-test-healer.md +0 -1
  700. package/presets/zcode/nuxt/agents/unit-test-planner.md +0 -1
  701. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +12 -3
  702. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +5 -5
  703. package/presets/zcode/nuxt/rules/code-quality-and-refactoring.md +2 -6
  704. package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +3 -7
  705. package/presets/zcode/nuxt/rules/post-change-lint.md +13 -13
  706. package/presets/zcode/nuxt/rules/preset-pr-checklist.md +2 -2
  707. package/presets/zcode/nuxt/skills/feature-delivery/SKILL.md +1 -1
  708. package/presets/zcode/nuxt/skills/playwright-e2e/SKILL.md +1 -1
  709. package/presets/zcode/nuxt/skills/unit-testing/SKILL.md +1 -1
  710. package/presets/zcode/php-hexagonal/REPO_AGENTS.md +7 -47
  711. package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
  712. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +12 -3
  713. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
  714. package/presets/zcode/php-hexagonal/rules/code-quality-and-refactoring.md +2 -6
  715. package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +3 -7
  716. package/presets/zcode/php-hexagonal/rules/preset-pr-checklist.md +2 -2
  717. package/presets/zcode/php-laravel/REPO_AGENTS.md +7 -47
  718. package/presets/zcode/php-laravel/adapter-map.json +1 -1
  719. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +12 -3
  720. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +5 -5
  721. package/presets/zcode/php-laravel/rules/code-quality-and-refactoring.md +2 -6
  722. package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +3 -7
  723. package/presets/zcode/php-laravel/rules/preset-pr-checklist.md +2 -2
  724. package/presets/zcode/svelte/REPO_AGENTS.md +8 -48
  725. package/presets/zcode/svelte/adapter-map.json +1 -1
  726. package/presets/zcode/svelte/agents/accessibility-reviewer.md +0 -1
  727. package/presets/zcode/svelte/agents/api-contract-reviewer.md +0 -1
  728. package/presets/zcode/svelte/agents/build-verifier.md +2 -2
  729. package/presets/zcode/svelte/agents/ci-investigator.md +1 -1
  730. package/presets/zcode/svelte/agents/code-reviewer.md +0 -1
  731. package/presets/zcode/svelte/agents/codebase-analyzer.md +0 -1
  732. package/presets/zcode/svelte/agents/debugger.md +1 -1
  733. package/presets/zcode/svelte/agents/feature-developer.md +3 -3
  734. package/presets/zcode/svelte/agents/migration-specialist.md +0 -1
  735. package/presets/zcode/svelte/agents/mockup-reviewer.md +0 -1
  736. package/presets/zcode/svelte/agents/openspec-author.md +0 -1
  737. package/presets/zcode/svelte/agents/performance-auditor.md +0 -1
  738. package/presets/zcode/svelte/agents/playwright-test-generator.md +0 -1
  739. package/presets/zcode/svelte/agents/playwright-test-healer.md +0 -1
  740. package/presets/zcode/svelte/agents/playwright-test-planner.md +0 -1
  741. package/presets/zcode/svelte/agents/qa-tester.md +3 -3
  742. package/presets/zcode/svelte/agents/security-reviewer.md +0 -1
  743. package/presets/zcode/svelte/agents/solution-architect.md +0 -1
  744. package/presets/zcode/svelte/agents/task-analyst.md +0 -1
  745. package/presets/zcode/svelte/agents/task-router.md +8 -7
  746. package/presets/zcode/svelte/agents/tech-writer.md +0 -1
  747. package/presets/zcode/svelte/agents/unit-test-generator.md +0 -1
  748. package/presets/zcode/svelte/agents/unit-test-healer.md +0 -1
  749. package/presets/zcode/svelte/agents/unit-test-planner.md +0 -1
  750. package/presets/zcode/svelte/hooks/chain-team-phases.sh +12 -3
  751. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +5 -5
  752. package/presets/zcode/svelte/rules/code-quality-and-refactoring.md +2 -6
  753. package/presets/zcode/svelte/rules/feature-delivery-workflow.md +3 -7
  754. package/presets/zcode/svelte/rules/post-change-lint.md +13 -13
  755. package/presets/zcode/svelte/rules/preset-pr-checklist.md +2 -2
  756. package/presets/zcode/svelte/skills/feature-delivery/SKILL.md +1 -1
  757. package/presets/zcode/svelte/skills/playwright-e2e/SKILL.md +1 -1
  758. package/presets/zcode/svelte/skills/unit-testing/SKILL.md +1 -1
  759. package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +0 -2103
  760. package/presets/_shared/ai-local/scripts/team-db-ui.mjs +0 -750
  761. package/presets/claude/next/commands/ui-start.md +0 -78
  762. package/presets/claude/next/commands/ui-stop.md +0 -71
  763. package/presets/cursor/next/commands/ui-start.md +0 -78
  764. package/presets/cursor/next/commands/ui-stop.md +0 -71
  765. package/presets/mavis/next/commands/ui-start.md +0 -73
  766. package/presets/mavis/next/commands/ui-stop.md +0 -66
  767. package/presets/opencode/next/commands/ui-start.md +0 -81
  768. package/presets/opencode/next/commands/ui-stop.md +0 -74
  769. package/presets/zcode/next/commands/ui-start.md +0 -81
  770. package/presets/zcode/next/commands/ui-stop.md +0 -74
@@ -1,750 +0,0 @@
1
- /**
2
- * `ui` lifecycle for the shipped team-db dashboard.
3
- *
4
- * `start` is probe-first: a healthy server for this root is a no-op with the
5
- * same pid and an untouched marker, so only a free port leads to a detached
6
- * `serve` plus `<aiLocalRoot>/.ui/api.json`. `start` writes the marker and at
7
- * most one bounded `sync` (the missing-projection repair) and nothing else;
8
- * `restart` is the explicit owned-stop-then-start verb. `stop` re-proves
9
- * ownership from the live command line, signals the leader pid only and keeps
10
- * the marker when the process survives. `status` reports the marker, the health
11
- * block and a stale-engine warning.
12
- *
13
- * Ownership is a live pid AND `ps -p <pid> -o command=` matching
14
- * `/team-db\.mjs\s+serve\b/`: the marker alone never authorizes a signal. Only
15
- * the leader pid is signalled, never the process group — `serve` spawns bounded
16
- * delete children and a group kill could truncate a delete between its folder
17
- * and row legs. The timer stays separate: `ui start` reports
18
- * `/health.scheduler` and never starts `team-db.mjs schedule`.
19
- *
20
- * POSIX only: the ownership probe reads `ps`. `win32` has no equivalent
21
- * command-line reader, so no ownership can be proven there and no signal is
22
- * ever sent — use the foreground `serve` on Windows.
23
- *
24
- * Exit codes: 0 ok or no-op, 1 refusal, 2 start failure, 3 usage.
25
- */
26
-
27
- import { spawn, spawnSync } from 'node:child_process';
28
- import fs from 'node:fs';
29
- import path from 'node:path';
30
- import { fileURLToPath } from 'node:url';
31
-
32
- import { DEFAULT_HOST, DEFAULT_PORT, LOOPBACK_HOSTS } from './team-db-api.mjs';
33
- import {
34
- DEFAULT_TEAM_ROOT,
35
- INDEX_UNAVAILABLE_LINE,
36
- isKillSwitchSet,
37
- isSqliteAvailable,
38
- teamRootId,
39
- } from './team-db-schema.mjs';
40
-
41
- const MARKER_DIR_NAME = '.ui';
42
- const MARKER_FILE_NAME = 'api.json';
43
- const MARKER_SCHEMA_VERSION = 1;
44
- const MARKER_FILE_MODE = 0o600;
45
- const MARKER_COMMAND = 'node .ai.local/scripts/team-db.mjs serve';
46
- const OWNED_COMMAND = /team-db\.mjs\s+serve\b/;
47
- const PROBE_TIMEOUT_MS = 2000;
48
- const START_TIMEOUT_MS = 30000;
49
- const SYNC_TIMEOUT_MS = 30000;
50
- const HEALTH_POLL_INTERVAL_MS = 250;
51
- const TERMINATE_WAIT_MS = 5000;
52
- const TERMINATE_POLL_INTERVAL_MS = 100;
53
- const KILL_WAIT_MS = 2000;
54
- const OWNER_STARTED = 'started by this repository';
55
- const OWNER_PRE_EXISTING = 'pre-existing';
56
-
57
- const VERB_FLAGS = {
58
- start: new Set(['root', 'json', 'quiet', 'host', 'port', 'open']),
59
- stop: new Set(['root', 'json', 'quiet']),
60
- status: new Set(['root', 'json', 'quiet']),
61
- restart: new Set(['root', 'json', 'quiet', 'host', 'port', 'open']),
62
- };
63
-
64
- class UiError extends Error {
65
- constructor(code, message, exitCode) {
66
- super(message);
67
- this.name = 'UiError';
68
- this.code = code;
69
- this.exitCode = exitCode;
70
- }
71
- }
72
-
73
- const uiFail = (code, message, exitCode) => {
74
- throw new UiError(code, message, exitCode);
75
- };
76
-
77
- const sleep = (ms) =>
78
- new Promise((resolve) => {
79
- setTimeout(resolve, ms);
80
- });
81
-
82
- const cliPath = () => fileURLToPath(new URL('./team-db.mjs', import.meta.url));
83
-
84
- const urlHost = (host) => (host.includes(':') ? `[${host}]` : host);
85
-
86
- const describeTarget = (target) => `http://${urlHost(target.host)}:${target.port}`;
87
-
88
- const resolveRoots = (flags) => {
89
- // Same precedence as the projection layers (`team-db-schema.mjs`): an explicit
90
- // `--root`, else `AI_RULES_TEAM_DB_ROOT`, else `<cwd>/.ai.local/team`. The ui
91
- // verbs must find a server started through the environment override.
92
- const teamRoot = path.resolve(flags.root || process.env.AI_RULES_TEAM_DB_ROOT || DEFAULT_TEAM_ROOT);
93
- const markerDir = path.join(path.dirname(teamRoot), MARKER_DIR_NAME);
94
- return {
95
- teamRoot,
96
- markerDir,
97
- markerPath: path.join(markerDir, MARKER_FILE_NAME),
98
- rootId: teamRootId(teamRoot),
99
- };
100
- };
101
-
102
- /* --------------------------------- process -------------------------------- */
103
-
104
- const isAlive = (pid) => {
105
- try {
106
- process.kill(pid, 0);
107
- } catch (error) {
108
- return error.code === 'EPERM';
109
- }
110
- // A killed child stays a zombie until its parent reaps it; it holds a pid
111
- // slot but no longer runs, so `stop` must not wait on it forever.
112
- const state = spawnSync('ps', ['-p', String(pid), '-o', 'stat='], { encoding: 'utf8' }).stdout.trim();
113
- return state !== '' && !state.startsWith('Z');
114
- };
115
-
116
- const signalPid = (pid, signal) => {
117
- try {
118
- process.kill(pid, signal);
119
- return true;
120
- } catch {
121
- return false;
122
- }
123
- };
124
-
125
- const liveCommand = (pid) => {
126
- const result = spawnSync('ps', ['-p', String(pid), '-o', 'command='], { encoding: 'utf8' });
127
- if (result.status !== 0) return null;
128
- return result.stdout.trim();
129
- };
130
-
131
- const ownsPid = (pid) => {
132
- if (!isAlive(pid)) return false;
133
- const command = liveCommand(pid);
134
- return command !== null && OWNED_COMMAND.test(command);
135
- };
136
-
137
- const terminate = async (pid) => {
138
- // Ownership is re-proved here rather than trusted from the caller's earlier
139
- // read: a pid can be reused between the two calls.
140
- if (!ownsPid(pid)) return !isAlive(pid);
141
- if (!signalPid(pid, 'SIGTERM')) {
142
- // ESRCH means it is already gone; EPERM means no signal can ever land, so
143
- // the grace period could not change the outcome either.
144
- return !isAlive(pid);
145
- }
146
- const deadline = Date.now() + TERMINATE_WAIT_MS;
147
- while (Date.now() < deadline) {
148
- if (!isAlive(pid)) return true;
149
- await sleep(TERMINATE_POLL_INTERVAL_MS);
150
- }
151
- if (!isAlive(pid)) return true;
152
- // A reused pid must not receive the escalation either.
153
- if (ownsPid(pid)) signalPid(pid, 'SIGKILL');
154
- const killDeadline = Date.now() + KILL_WAIT_MS;
155
- while (Date.now() < killDeadline) {
156
- if (!isAlive(pid)) return true;
157
- await sleep(TERMINATE_POLL_INTERVAL_MS);
158
- }
159
- return !isAlive(pid);
160
- };
161
-
162
- /* ---------------------------------- marker -------------------------------- */
163
-
164
- const readMarker = (roots) => {
165
- if (!fs.existsSync(roots.markerPath)) return { marker: null, present: false };
166
- try {
167
- const marker = JSON.parse(fs.readFileSync(roots.markerPath, 'utf8'));
168
- const valid =
169
- Number.isInteger(marker?.pid) &&
170
- marker.pid > 0 &&
171
- typeof marker.host === 'string' &&
172
- LOOPBACK_HOSTS.includes(marker.host) &&
173
- Number.isInteger(marker.port) &&
174
- marker.port >= 0 &&
175
- marker.port <= 65535;
176
- return { marker: valid ? marker : null, present: true };
177
- } catch {
178
- return { marker: null, present: true };
179
- }
180
- };
181
-
182
- const removeMarker = (roots) => {
183
- try {
184
- fs.rmSync(roots.markerPath, { force: true });
185
- } catch {
186
- /* a marker that cannot be removed is reported by the next start probe */
187
- }
188
- };
189
-
190
- const writeMarker = (roots, marker) => {
191
- fs.mkdirSync(roots.markerDir, { recursive: true });
192
- const temporary = `${roots.markerPath}.tmp`;
193
- fs.writeFileSync(temporary, `${JSON.stringify(marker, null, 2)}\n`, { mode: MARKER_FILE_MODE });
194
- // `mode` only applies on creation: a `.tmp` left by an earlier crash must not
195
- // donate its permissions to the rename.
196
- fs.chmodSync(temporary, MARKER_FILE_MODE);
197
- fs.renameSync(temporary, roots.markerPath);
198
- };
199
-
200
- /* ---------------------------------- health -------------------------------- */
201
-
202
- const isHealthDocument = (body) =>
203
- body !== null &&
204
- typeof body === 'object' &&
205
- typeof body.status === 'string' &&
206
- typeof body.db === 'object' &&
207
- body.db !== null &&
208
- typeof body.tasks === 'object' &&
209
- body.tasks !== null;
210
-
211
- const probeHealth = async (host, port) => {
212
- if (port === 0) return { kind: 'free' };
213
- try {
214
- const response = await fetch(`${describeTarget({ host, port })}/health`, {
215
- signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
216
- });
217
- let body = null;
218
- try {
219
- body = await response.json();
220
- } catch {
221
- body = null;
222
- }
223
- return { kind: 'response', status: response.status, body };
224
- } catch (error) {
225
- if (error?.name === 'TimeoutError') return { kind: 'timeout' };
226
- if (error?.cause?.code === 'ECONNREFUSED' || error?.cause?.code === 'ECONNRESET') return { kind: 'refused' };
227
- return { kind: 'error', reason: error?.cause?.message ?? error?.message };
228
- }
229
- };
230
-
231
- /**
232
- * `free` covers a refusal, a timeout and any other transport error: the only
233
- * safe reading of "no health document came back" is "no known server", and the
234
- * spawn decides the port race with its own bind (`EADDRINUSE`).
235
- */
236
- const classifyProbe = (probe) => {
237
- if (probe.kind !== 'response') return { kind: 'free' };
238
- if (probe.status === 200 && isHealthDocument(probe.body)) return { kind: 'health', body: probe.body };
239
- if (probe.status === 503 && probe.body?.error?.code === 'E_DB_MISSING') return { kind: 'missing-db' };
240
- return { kind: 'foreign', status: probe.status };
241
- };
242
-
243
- const repairProjection = (roots) => {
244
- const result = spawnSync(process.execPath, [cliPath(), 'sync', '--root', roots.teamRoot, '--quiet'], {
245
- encoding: 'utf8',
246
- env: process.env,
247
- timeout: SYNC_TIMEOUT_MS,
248
- });
249
- if (!result.error && result.status === 0) return;
250
- const lastLine = result.stderr.trim().split('\n').filter(Boolean).slice(-1)[0];
251
- const detail = result.error?.message ?? lastLine ?? `sync exited ${result.status}`;
252
- uiFail('E_UI_DB_MISSING', `the projection is still missing and team-db.mjs sync failed: ${detail}`, 1);
253
- };
254
-
255
- /* ---------------------------------- spawn --------------------------------- */
256
-
257
- const spawnServe = (roots, target) =>
258
- spawn(
259
- process.execPath,
260
- [cliPath(), 'serve', '--root', roots.teamRoot, '--host', target.host, '--port', String(target.port)],
261
- { cwd: process.cwd(), detached: true, stdio: ['ignore', 'pipe', 'pipe'] },
262
- );
263
-
264
- const readServingLine = (child) =>
265
- new Promise((resolve, reject) => {
266
- let stdout = '';
267
- let stderr = '';
268
- let settled = false;
269
- const settle = (fn, value) => {
270
- if (settled) return;
271
- settled = true;
272
- clearTimeout(timer);
273
- fn(value);
274
- };
275
- const timer = setTimeout(
276
- () =>
277
- settle(
278
- reject,
279
- new UiError('E_UI_START_TIMEOUT', `serve did not report its URL within ${START_TIMEOUT_MS} ms`, 2),
280
- ),
281
- START_TIMEOUT_MS,
282
- );
283
- child.stdout.setEncoding('utf8');
284
- child.stderr.setEncoding('utf8');
285
- child.stdout.on('data', (chunk) => {
286
- stdout += chunk;
287
- const match = /^team-db: serving (\S+)/m.exec(stdout);
288
- if (match) settle(resolve, { url: match[1] });
289
- });
290
- child.stderr.on('data', (chunk) => {
291
- stderr += chunk;
292
- });
293
- child.once('error', (error) => settle(reject, new UiError('E_UI_CHILD_EXIT', error.message, 2)));
294
- child.once('exit', (code, signal) => {
295
- const lastLine = stderr.trim().split('\n').filter(Boolean).slice(-1)[0];
296
- const failureCode = /EADDRINUSE/.test(`${stdout}\n${stderr}`) ? 'E_UI_PORT_IN_USE' : 'E_UI_CHILD_EXIT';
297
- const reason = signal === null ? `code ${code}` : signal;
298
- settle(
299
- reject,
300
- new UiError(failureCode, `serve exited (${reason})${lastLine ? `: ${lastLine}` : ''}`, 2),
301
- );
302
- });
303
- });
304
-
305
- /**
306
- * The parent must exit while the server keeps running, so both pipes are
307
- * destroyed rather than drained — draining would hold the event loop open. The
308
- * child therefore gets EPIPE on its next diagnostic write after the serving
309
- * line; `team-db.mjs serve` installs a no-op `error` handler for exactly that.
310
- */
311
- const detachChild = (child) => {
312
- child.unref();
313
- for (const stream of [child.stdout, child.stderr]) {
314
- if (stream) stream.destroy();
315
- }
316
- };
317
-
318
- const terminateSpawned = async (pid) => {
319
- if (pid !== undefined && isAlive(pid)) await terminate(pid);
320
- };
321
-
322
- /* --------------------------------- results -------------------------------- */
323
-
324
- const engineChangedSince = (startedAt) => {
325
- const since = Date.parse(startedAt);
326
- if (Number.isNaN(since)) return false;
327
- try {
328
- return fs.statSync(cliPath()).mtimeMs > since;
329
- } catch {
330
- return false;
331
- }
332
- };
333
-
334
- const staleWarning = 'stale: the engine changed after the server started; run ui restart';
335
-
336
- const runningResult = ({ verb, owner, pid, target, startedAt, rootId, marker, health, stale, spawned }) => ({
337
- ok: true,
338
- verb,
339
- running: true,
340
- spawned: Boolean(spawned),
341
- owner,
342
- pid: pid ?? null,
343
- host: target.host,
344
- port: target.port,
345
- url: describeTarget(target),
346
- startedAt: startedAt ?? null,
347
- rootId,
348
- marker,
349
- health,
350
- stale,
351
- staleWarning: stale ? staleWarning : null,
352
- });
353
-
354
- const schedulerLine = (health) => {
355
- const scheduler = health?.scheduler;
356
- if (!scheduler || typeof scheduler.state !== 'string') return null;
357
- return `scheduler: ${scheduler.state}${Number.isInteger(scheduler.pid) ? ` (pid ${scheduler.pid})` : ''}`;
358
- };
359
-
360
- const pidLabel = (pid) => (Number.isInteger(pid) ? `pid ${pid}, ` : '');
361
-
362
- /* ---------------------------------- start --------------------------------- */
363
-
364
- const settleRunning = (roots, marker, health, target) => {
365
- const healthRootId = typeof health.rootId === 'string' ? health.rootId : null;
366
- if (healthRootId !== null && healthRootId !== roots.rootId) {
367
- uiFail(
368
- 'E_UI_OTHER_ROOT',
369
- `${describeTarget(target)} serves team root ${healthRootId}; this repository is ${roots.rootId}`,
370
- 1,
371
- );
372
- }
373
- const markerOwned = marker !== null && ownsPid(marker.pid);
374
- const owned = markerOwned && marker.rootId === roots.rootId;
375
- const startedAt = owned ? marker.startedAt : null;
376
- return runningResult({
377
- verb: 'start',
378
- owner: owned ? OWNER_STARTED : OWNER_PRE_EXISTING,
379
- pid: markerOwned ? marker.pid : null,
380
- target,
381
- startedAt,
382
- rootId: roots.rootId,
383
- marker,
384
- health,
385
- stale: owned && engineChangedSince(startedAt),
386
- });
387
- };
388
-
389
- /**
390
- * Probe with the one repair the lifecycle owns: a `503 E_DB_MISSING` answer buys
391
- * exactly one bounded `sync` and one re-probe.
392
- */
393
- const probeView = async (roots, target) => {
394
- const view = classifyProbe(await probeHealth(target.host, target.port));
395
- if (view.kind === 'foreign') {
396
- uiFail(
397
- 'E_UI_PORT_FOREIGN',
398
- `${describeTarget(target)} answered (HTTP ${view.status}) but not with a team-db health document`,
399
- 1,
400
- );
401
- }
402
- if (view.kind !== 'missing-db') return view;
403
- repairProjection(roots);
404
- const again = classifyProbe(await probeHealth(target.host, target.port));
405
- if (again.kind !== 'health') {
406
- uiFail('E_UI_DB_MISSING', `${describeTarget(target)} still reports a missing projection after one sync`, 1);
407
- }
408
- return again;
409
- };
410
-
411
- const awaitHealth = async (roots, target, deadline) => {
412
- while (Date.now() < deadline) {
413
- const view = classifyProbe(await probeHealth(target.host, target.port));
414
- if (view.kind === 'health') return view.body;
415
- if (view.kind === 'missing-db') {
416
- repairProjection(roots);
417
- const again = classifyProbe(await probeHealth(target.host, target.port));
418
- if (again.kind === 'health') return again.body;
419
- uiFail('E_UI_DB_MISSING', 'the projection is still missing after one sync; run team-db.mjs sync and retry', 1);
420
- }
421
- await sleep(HEALTH_POLL_INTERVAL_MS);
422
- }
423
- uiFail('E_UI_START_TIMEOUT', `no healthy answer on ${describeTarget(target)} within ${START_TIMEOUT_MS} ms`, 2);
424
- };
425
-
426
- const startUi = async (roots, target) => {
427
- const marker = readMarker(roots).marker;
428
- const ownedMarker = marker !== null && marker.rootId === roots.rootId && ownsPid(marker.pid) ? marker : null;
429
-
430
- // A marker that names a live owned server on another target is the same
431
- // "already running" no-op: one repository never runs two dashboards. A probe
432
- // that answers anything else falls through to the requested target.
433
- if (ownedMarker !== null && (ownedMarker.host !== target.host || ownedMarker.port !== target.port)) {
434
- const own = classifyProbe(await probeHealth(ownedMarker.host, ownedMarker.port));
435
- if (own.kind === 'health' && own.body.rootId === roots.rootId) {
436
- return settleRunning(roots, ownedMarker, own.body, { host: ownedMarker.host, port: ownedMarker.port });
437
- }
438
- }
439
-
440
- // Probe first: a server that already answers 200 for this root is the no-op
441
- // the contract pins (same pid, unchanged `startedAt`). `restart` is the verb
442
- // that stops and replaces it, so this path never stops or spawns.
443
- const view = await probeView(roots, target);
444
- if (view.kind === 'health') return settleRunning(roots, marker, view.body, target);
445
-
446
- // The port is free: a marker whose pid is gone or not ours is stale.
447
- if (readMarker(roots).present && ownedMarker === null) removeMarker(roots);
448
-
449
- const startedAt = new Date().toISOString();
450
- const deadline = Date.now() + START_TIMEOUT_MS;
451
- let child;
452
- try {
453
- child = spawnServe(roots, target);
454
- } catch (error) {
455
- uiFail('E_UI_CHILD_EXIT', `serve could not start: ${error.message}`, 2);
456
- }
457
- let serving;
458
- try {
459
- serving = await readServingLine(child);
460
- } catch (error) {
461
- await terminateSpawned(child.pid);
462
- if (error.code === 'E_UI_PORT_IN_USE') {
463
- const raced = classifyProbe(await probeHealth(target.host, target.port));
464
- if (raced.kind === 'health') return settleRunning(roots, marker, raced.body, target);
465
- uiFail('E_UI_PORT_IN_USE', `port ${target.port} was taken between the probe and the spawn`, 2);
466
- }
467
- throw error;
468
- }
469
- detachChild(child);
470
- const url = new URL(serving.url);
471
- const boundPort = Number(url.port);
472
- const nextMarker = {
473
- schemaVersion: MARKER_SCHEMA_VERSION,
474
- pid: child.pid,
475
- host: target.host,
476
- port: boundPort,
477
- root: roots.teamRoot,
478
- rootId: roots.rootId,
479
- startedAt,
480
- command: MARKER_COMMAND,
481
- };
482
- // Every throw after the spawn leaves neither the marker nor the child behind.
483
- const cleanup = async () => {
484
- try {
485
- fs.rmSync(`${roots.markerPath}.tmp`, { force: true });
486
- } catch {
487
- /* the directory itself may be unwritable */
488
- }
489
- removeMarker(roots);
490
- await terminateSpawned(child.pid);
491
- };
492
- try {
493
- writeMarker(roots, nextMarker);
494
- } catch (error) {
495
- await cleanup();
496
- uiFail('E_UI_MARKER_UNWRITABLE', `${roots.markerPath} could not be written: ${error.message}`, 2);
497
- }
498
- let health;
499
- try {
500
- health = await awaitHealth(roots, { host: target.host, port: boundPort }, deadline);
501
- } catch (error) {
502
- await cleanup();
503
- if (error instanceof UiError) throw error;
504
- uiFail('E_UI_CHILD_EXIT', `serve failed after it reported its URL: ${error.message}`, 2);
505
- }
506
- return runningResult({
507
- verb: 'start',
508
- spawned: true,
509
- owner: OWNER_STARTED,
510
- pid: child.pid,
511
- target: { host: target.host, port: boundPort },
512
- startedAt,
513
- rootId: roots.rootId,
514
- marker: nextMarker,
515
- health,
516
- stale: false,
517
- });
518
- };
519
-
520
- /* ---------------------------------- stop ---------------------------------- */
521
-
522
- const stopUi = async (roots) => {
523
- const { marker, present } = readMarker(roots);
524
- if (marker === null) {
525
- if (!present) return { state: 'nothing', pid: null };
526
- removeMarker(roots);
527
- return { state: 'stale', pid: null };
528
- }
529
- if (!isAlive(marker.pid)) {
530
- removeMarker(roots);
531
- return { state: 'stale', pid: marker.pid };
532
- }
533
- const command = liveCommand(marker.pid);
534
- if (command === null || !OWNED_COMMAND.test(command)) {
535
- return { state: 'unowned', pid: marker.pid };
536
- }
537
- const gone = await terminate(marker.pid);
538
- // A process that outlived SIGKILL keeps its marker: the next call must still
539
- // find it instead of reporting a clean stop that never happened.
540
- if (!gone) return { state: 'survived', pid: marker.pid };
541
- removeMarker(roots);
542
- return { state: 'stopped', pid: marker.pid };
543
- };
544
-
545
- /* --------------------------------- status --------------------------------- */
546
-
547
- const statusUi = async (roots) => {
548
- const { marker } = readMarker(roots);
549
- const owned = marker !== null && ownsPid(marker.pid);
550
- const target = {
551
- host: marker?.host ?? DEFAULT_HOST,
552
- port: marker?.port ?? DEFAULT_PORT,
553
- };
554
- const view = classifyProbe(await probeHealth(target.host, target.port));
555
- if (view.kind !== 'health') {
556
- return {
557
- ok: true,
558
- verb: 'status',
559
- running: false,
560
- owner: null,
561
- pid: null,
562
- host: target.host,
563
- port: target.port,
564
- url: describeTarget(target),
565
- startedAt: null,
566
- rootId: roots.rootId,
567
- marker,
568
- health: null,
569
- stale: false,
570
- staleWarning: null,
571
- };
572
- }
573
- const startedAt = owned ? marker.startedAt : null;
574
- return runningResult({
575
- verb: 'status',
576
- owner: owned ? OWNER_STARTED : OWNER_PRE_EXISTING,
577
- pid: owned ? marker.pid : null,
578
- target,
579
- startedAt,
580
- rootId: roots.rootId,
581
- marker,
582
- health: view.body,
583
- stale: owned && engineChangedSince(startedAt),
584
- });
585
- };
586
-
587
- /* -------------------------------- reporting ------------------------------- */
588
-
589
- const createReporter = (flags) => {
590
- const json = Boolean(flags.json);
591
- const quiet = Boolean(flags.quiet);
592
- return {
593
- info: (line) => {
594
- if (!json && !quiet) process.stdout.write(`${line}\n`);
595
- },
596
- warn: (line) => process.stderr.write(`${line}\n`),
597
- result: (value) => {
598
- if (json) process.stdout.write(`${JSON.stringify(value)}\n`);
599
- },
600
- };
601
- };
602
-
603
- const announceStart = (out, result) => {
604
- out.info(`ui: already running (${pidLabel(result.pid)}owner: ${result.owner})`);
605
- const scheduler = schedulerLine(result.health);
606
- if (scheduler) out.info(scheduler);
607
- if (result.stale) out.warn(`ui: ${result.staleWarning}`);
608
- };
609
-
610
- const announceFreshStart = (out, result) => {
611
- out.info(`ui: ${result.url} (pid ${result.pid})`);
612
- const scheduler = schedulerLine(result.health);
613
- if (scheduler) out.info(scheduler);
614
- };
615
-
616
- const announceStatus = (out, result) => {
617
- if (!result.running) {
618
- out.info('ui: nothing running');
619
- return;
620
- }
621
- out.info(`ui: running ${result.url} (${pidLabel(result.pid)}owner: ${result.owner})`);
622
- const scheduler = schedulerLine(result.health);
623
- if (scheduler) out.info(scheduler);
624
- if (result.stale) out.warn(`ui: ${result.staleWarning}`);
625
- };
626
-
627
- const announceStop = (out, result) => {
628
- if (result.state === 'stopped') out.info(`ui: stopped (pid ${result.pid})`);
629
- else if (result.state === 'stale') out.info('ui: nothing running (stale marker removed)');
630
- else if (result.state === 'unowned') out.info(`ui: marker pid ${result.pid} is not team-db.mjs serve; left running`);
631
- else if (result.state === 'survived') {
632
- out.warn(`ui: pid ${result.pid} is still running after the 5 s grace and SIGKILL; the marker is kept`);
633
- } else out.info('ui: nothing running');
634
- };
635
-
636
- /* ---------------------------------- verbs --------------------------------- */
637
-
638
- const parseTarget = (flags) => {
639
- const host = typeof flags.host === 'string' ? flags.host.trim() : DEFAULT_HOST;
640
- if (!LOOPBACK_HOSTS.includes(host)) {
641
- uiFail('E_USAGE', `--host ${host || '(empty)'} is not loopback; a ui verb never binds a remote host`, 3);
642
- }
643
- const port = flags.port === undefined ? DEFAULT_PORT : Number(flags.port);
644
- if (!Number.isInteger(port) || port < 0 || port > 65535) {
645
- uiFail('E_USAGE', '--port must be an integer between 0 and 65535', 3);
646
- }
647
- return { host, port };
648
- };
649
-
650
- /**
651
- * The two environment refusals every start-shaped verb shares. Both must land
652
- * before the first write or probe: a disabled runtime must not stop a live
653
- * server, write a marker or run the repair sync.
654
- */
655
- const assertStartAllowed = () => {
656
- if (isKillSwitchSet(process.env)) uiFail('E_DISABLED', 'disabled by AI_RULES_TEAM_DB_DISABLE', 1);
657
- if (!isSqliteAvailable(process.env)) uiFail('E_UI_UNAVAILABLE', INDEX_UNAVAILABLE_LINE, 1);
658
- };
659
-
660
- const openDashboard = (url) => {
661
- try {
662
- const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'explorer' : 'xdg-open';
663
- const child = spawn(command, [url], { detached: true, stdio: 'ignore' });
664
- child.on('error', (error) => {
665
- process.stderr.write(`ui: could not open ${url} (${error.code ?? error.message}); open it manually\n`);
666
- });
667
- child.unref();
668
- } catch {
669
- /* opening a browser is a convenience, never a failure */
670
- }
671
- };
672
-
673
- const runStart = async (flags, out) => {
674
- const roots = resolveRoots(flags);
675
- const target = parseTarget(flags);
676
- assertStartAllowed();
677
- // Probe-first no-op; the only writes are the marker and at most one sync.
678
- const result = await startUi(roots, target);
679
- if (result.spawned) announceFreshStart(out, result);
680
- else announceStart(out, result);
681
- if (flags.open) openDashboard(result.url);
682
- out.result(result);
683
- return 0;
684
- };
685
-
686
- const runRestart = async (flags, out) => {
687
- // `restart` is the explicit stop+start verb; `start` never stops anything.
688
- const roots = resolveRoots(flags);
689
- const target = parseTarget(flags);
690
- assertStartAllowed();
691
- const stopped = await stopUi(roots);
692
- if (stopped.state === 'survived') {
693
- announceStop(out, stopped);
694
- out.result({ ok: false, verb: 'restart', state: stopped.state, pid: stopped.pid });
695
- return 1;
696
- }
697
- if (stopped.state !== 'nothing') announceStop(out, stopped);
698
- const result = await startUi(roots, target);
699
- if (result.spawned) announceFreshStart(out, result);
700
- else announceStart(out, result);
701
- if (flags.open) openDashboard(result.url);
702
- out.result(result);
703
- return 0;
704
- };
705
-
706
- const runStop = async (flags, out) => {
707
- const result = await stopUi(resolveRoots(flags));
708
- announceStop(out, result);
709
- out.result({ ok: result.state !== 'survived', verb: 'stop', state: result.state, pid: result.pid });
710
- return result.state === 'survived' ? 1 : 0;
711
- };
712
-
713
- const runStatus = async (flags, out) => {
714
- const result = await statusUi(resolveRoots(flags));
715
- announceStatus(out, result);
716
- out.result(result);
717
- return 0;
718
- };
719
-
720
- const runVerb = async (verb, flags, out) => {
721
- if (verb === 'stop') return runStop(flags, out);
722
- if (verb === 'status') return runStatus(flags, out);
723
- if (verb === 'restart') return runRestart(flags, out);
724
- return runStart(flags, out);
725
- };
726
-
727
- /* ---------------------------------- entry --------------------------------- */
728
-
729
- /**
730
- * One `ui` dispatch: `positionals[0]` is the verb, and the flags already passed
731
- * the CLI's union allow-list, so this layer owns the per-verb reach table.
732
- */
733
- export async function runUiCommand({ flags, positionals }) {
734
- const out = createReporter(flags);
735
- try {
736
- const [verb, ...rest] = positionals;
737
- if (verb === undefined) uiFail('E_USAGE', 'ui needs a verb: start, stop, status or restart', 3);
738
- if (rest.length > 0) uiFail('E_USAGE', `ui ${verb} takes no further arguments`, 3);
739
- if (!VERB_FLAGS[verb]) uiFail('E_USAGE', `unknown ui verb "${verb}"; expected start, stop, status or restart`, 3);
740
- for (const name of Object.keys(flags)) {
741
- if (!VERB_FLAGS[verb].has(name)) uiFail('E_USAGE', `flag --${name} does not apply to ui ${verb}`, 3);
742
- }
743
- return await runVerb(verb, flags, out);
744
- } catch (error) {
745
- if (!(error instanceof UiError)) throw error;
746
- out.result({ ok: false, code: error.code, message: error.message });
747
- out.warn(`ui: ${error.code}: ${error.message}`);
748
- return error.exitCode;
749
- }
750
- }