@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.
- package/CHANGELOG.md +92 -0
- package/README.md +27 -3
- package/bin/cli.js +565 -61
- package/bin/lib/ai-local-drift.js +55 -14
- package/bin/lib/engine-scripts.js +10 -0
- package/bin/lib/mcp/clients.js +168 -0
- package/bin/lib/mcp/credentials.js +298 -0
- package/bin/lib/mcp/doctor.js +394 -0
- package/bin/lib/mcp/prompt.js +115 -0
- package/bin/lib/mcp/registry.js +170 -0
- package/bin/lib/mcp/run.js +123 -0
- package/bin/lib/merged-config.js +45 -0
- package/bin/lib/seed-ai-local-team.js +23 -7
- package/bin/lib/tool-installs.js +27 -0
- package/bin/mavis-install.js +2 -0
- package/bin/opencode-install.js +2 -0
- package/docs/LOCAL-OVERLAY.md +1 -1
- package/docs/MCP-SETUP.md +62 -0
- package/docs/PRESET-CONTRIBUTION.md +14 -10
- package/docs/TEAM-DB.md +173 -0
- package/docs/openapi/team-db.v1.json +5085 -0
- package/mcp/gitlab.mjs +123 -0
- package/mcp/lib/envfile.mjs +126 -0
- package/mcp/lib/yandex.mjs +384 -0
- package/mcp/yandex-mcp-proxy.mjs +155 -0
- package/mcp/yandex-token-refresh.mjs +65 -0
- package/package.json +18 -1
- package/presets/_shared/ai-local/scripts/manifest.mjs +112 -3
- package/presets/_shared/ai-local/scripts/rule-improver.mjs +428 -91
- package/presets/_shared/ai-local/scripts/run.mjs +22 -4
- package/presets/_shared/ai-local/scripts/signals.mjs +4 -1
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +1275 -0
- package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +1067 -0
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +1301 -0
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +1506 -0
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +831 -0
- package/presets/_shared/ai-local/scripts/team-db.mjs +251 -0
- package/presets/_shared/core/meta/preset-pr-checklist.md +1 -1
- package/presets/_shared/core/quality/interactive-questions.md +8 -8
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +109 -0
- package/presets/claude/android-kotlin/agents/code-reviewer.md +1 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/interactive-questions.md +8 -8
- package/presets/claude/android-kotlin/rules/tooling-and-review/language-policy.md +1 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/android-kotlin/team/README.md +10 -0
- package/presets/claude/go/agents/code-reviewer.md +1 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/go/rules/tooling-and-review/interactive-questions.md +8 -8
- package/presets/claude/go/rules/tooling-and-review/language-policy.md +1 -1
- package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/go/team/README.md +10 -0
- package/presets/claude/ios-swift/agents/code-reviewer.md +1 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/interactive-questions.md +8 -8
- package/presets/claude/ios-swift/rules/tooling-and-review/language-policy.md +1 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/post-change-build.md +1 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/ios-swift/team/README.md +10 -0
- package/presets/claude/java/agents/code-reviewer.md +1 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/java/rules/tooling-and-review/interactive-questions.md +8 -8
- package/presets/claude/java/rules/tooling-and-review/language-policy.md +1 -1
- package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/java/team/README.md +10 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/interactive-questions.md +8 -8
- package/presets/claude/mcp-ts/rules/tooling-and-review/language-policy.md +1 -1
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/mcp-ts/team/README.md +10 -0
- package/presets/claude/next/MCP.md +7 -0
- package/presets/claude/next/README.md +1 -1
- package/presets/claude/next/REPO_AGENTS.md +1 -1
- package/presets/claude/next/agents/README.md +3 -3
- package/presets/claude/next/agents/build-verifier.md +9 -3
- package/presets/claude/next/agents/code-reviewer.md +2 -1
- package/presets/claude/next/agents/codebase-analyzer.md +1 -1
- package/presets/claude/next/agents/feature-developer.md +18 -8
- package/presets/claude/next/agents/openspec-author.md +1 -1
- package/presets/claude/next/agents/playwright-test-generator.md +22 -68
- package/presets/claude/next/agents/playwright-test-healer.md +27 -54
- package/presets/claude/next/agents/playwright-test-planner.md +18 -51
- package/presets/claude/next/agents/task-analyst.md +25 -9
- package/presets/claude/next/agents/task-router.md +1 -1
- package/presets/claude/next/agents/tech-writer.md +1 -1
- package/presets/claude/next/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/next/mcp.json +3 -3
- package/presets/claude/next/rules/anti-hallucination/react-next-anti-hallucination.md +1 -1
- package/presets/claude/next/rules/architecture/layer-barrel-exports.md +1 -1
- package/presets/claude/next/rules/architecture/reference-features.md +1 -1
- package/presets/claude/next/rules/stack/navigation-router-ui.md +1 -1
- package/presets/claude/next/rules/stack/navigation-router.md +14 -0
- package/presets/claude/next/rules/stack/next-app-core.md +19 -17
- package/presets/claude/next/rules/stack/next-app-router.md +5 -17
- package/presets/claude/next/rules/stack/next-static-export.md +1 -1
- package/presets/claude/next/rules/tooling-and-review/interactive-questions.md +8 -8
- package/presets/claude/next/rules/tooling-and-review/language-policy.md +1 -1
- package/presets/claude/next/rules/tooling-and-review/post-change-lint.md +1 -1
- package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/next/rules/tooling-and-review/preset-token-budget.md +1 -1
- package/presets/claude/next/rules/tooling-and-review/security-next.md +28 -3
- package/presets/claude/next/rules/ui-and-accessibility/css-property-order.md +1 -1
- package/presets/claude/next/rules/ui-and-accessibility/design-tokens-binding.md +4 -4
- package/presets/claude/next/rules/ui-and-accessibility/forms-validation.md +2 -2
- package/presets/claude/next/team/README.md +21 -0
- package/presets/claude/next/team/fixtures/feature-with-figma-url.json +10 -0
- package/presets/claude/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
- package/presets/claude/next/team/fixtures/mockup-review-standalone.json +9 -0
- package/presets/claude/next/team/fixtures/ux-design-standalone.json +9 -0
- package/presets/claude/nuxt/agents/code-reviewer.md +1 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/nuxt/rules/architecture/layer-barrel-exports.md +1 -1
- package/presets/claude/nuxt/rules/stack/navigation-router-ui.md +1 -1
- package/presets/claude/nuxt/rules/tooling-and-review/interactive-questions.md +8 -8
- package/presets/claude/nuxt/rules/tooling-and-review/language-policy.md +1 -1
- package/presets/claude/nuxt/rules/tooling-and-review/post-change-lint.md +1 -1
- package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/nuxt/team/README.md +10 -0
- package/presets/claude/php-hexagonal/agents/code-reviewer.md +1 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/interactive-questions.md +8 -8
- package/presets/claude/php-hexagonal/rules/tooling-and-review/language-policy.md +1 -1
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/php-hexagonal/team/README.md +10 -0
- package/presets/claude/php-laravel/agents/code-reviewer.md +1 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/interactive-questions.md +8 -8
- package/presets/claude/php-laravel/rules/tooling-and-review/language-policy.md +1 -1
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/php-laravel/team/README.md +10 -0
- package/presets/claude/svelte/agents/code-reviewer.md +1 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/svelte/rules/architecture/layer-barrel-exports.md +1 -1
- package/presets/claude/svelte/rules/tooling-and-review/interactive-questions.md +8 -8
- package/presets/claude/svelte/rules/tooling-and-review/language-policy.md +1 -1
- package/presets/claude/svelte/rules/tooling-and-review/post-change-lint.md +1 -1
- package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/svelte/team/README.md +10 -0
- package/presets/cursor/android-kotlin/agents/code-reviewer.md +1 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/android-kotlin/rules/README.md +1 -0
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +3 -3
- package/presets/cursor/android-kotlin/rules/interactive-questions.mdc +8 -8
- package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/android-kotlin/team/README.md +10 -0
- package/presets/cursor/go/agents/code-reviewer.md +1 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +2 -2
- package/presets/cursor/go/rules/interactive-questions.mdc +8 -8
- package/presets/cursor/go/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/go/team/README.md +10 -0
- package/presets/cursor/ios-swift/agents/code-reviewer.md +1 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/ios-swift/rules/README.md +1 -0
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +3 -3
- package/presets/cursor/ios-swift/rules/interactive-questions.mdc +8 -8
- package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/ios-swift/team/README.md +10 -0
- package/presets/cursor/java/agents/code-reviewer.md +1 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +2 -2
- package/presets/cursor/java/rules/interactive-questions.mdc +8 -8
- package/presets/cursor/java/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/java/team/README.md +10 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +2 -2
- package/presets/cursor/mcp-ts/rules/interactive-questions.mdc +8 -8
- package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/mcp-ts/team/README.md +10 -0
- package/presets/cursor/next/MCP.md +14 -0
- package/presets/cursor/next/REPO_AGENTS.md +1 -1
- package/presets/cursor/next/agents/code-reviewer.md +1 -0
- package/presets/cursor/next/agents/playwright-test-healer.md +1 -0
- package/presets/cursor/next/ai-local/rules-library/router-pages.md +5 -5
- package/presets/cursor/next/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/next/mcp.json +3 -3
- package/presets/cursor/next/rules/README.md +1 -1
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/rules/css-property-order-stylelint.mdc +1 -1
- package/presets/cursor/next/rules/design-tokens-binding.mdc +4 -4
- package/presets/cursor/next/rules/forms-validation.mdc +2 -2
- package/presets/cursor/next/rules/interactive-questions.mdc +8 -8
- package/presets/cursor/next/rules/navigation-router-stack.mdc +14 -1
- package/presets/cursor/next/rules/next-app-core.mdc +19 -17
- package/presets/cursor/next/rules/next-app-router.mdc +5 -17
- package/presets/cursor/next/rules/next-static-export.mdc +1 -1
- package/presets/cursor/next/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/next/rules/preset-token-budget.mdc +1 -1
- package/presets/cursor/next/rules/react-next-anti-hallucination.mdc +1 -1
- package/presets/cursor/next/rules/reference-features.mdc +1 -1
- package/presets/cursor/next/rules/security-next.mdc +28 -3
- package/presets/cursor/next/team/README.md +21 -0
- package/presets/cursor/next/team/fixtures/feature-with-figma-url.json +10 -0
- package/presets/cursor/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
- package/presets/cursor/next/team/fixtures/mockup-review-standalone.json +9 -0
- package/presets/cursor/next/team/fixtures/ux-design-standalone.json +9 -0
- package/presets/cursor/nuxt/agents/code-reviewer.md +1 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/nuxt/rules/interactive-questions.mdc +8 -8
- package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/nuxt/team/README.md +10 -0
- package/presets/cursor/php-hexagonal/agents/code-reviewer.md +1 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +2 -2
- package/presets/cursor/php-hexagonal/rules/interactive-questions.mdc +8 -8
- package/presets/cursor/php-hexagonal/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/php-hexagonal/team/README.md +10 -0
- package/presets/cursor/php-laravel/agents/code-reviewer.md +1 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +2 -2
- package/presets/cursor/php-laravel/rules/interactive-questions.mdc +8 -8
- package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/php-laravel/team/README.md +10 -0
- package/presets/cursor/svelte/agents/code-reviewer.md +1 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/svelte/rules/interactive-questions.mdc +8 -8
- package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/svelte/team/README.md +10 -0
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/agents/code-reviewer.md +1 -0
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/android-kotlin/rules/interactive-questions.md +8 -8
- package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/android-kotlin/team/README.md +10 -0
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/agents/code-reviewer.md +1 -0
- package/presets/mavis/go/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/go/rules/interactive-questions.md +8 -8
- package/presets/mavis/go/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/go/team/README.md +10 -0
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/agents/code-reviewer.md +1 -0
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/ios-swift/rules/interactive-questions.md +8 -8
- package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/ios-swift/team/README.md +10 -0
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/agents/code-reviewer.md +1 -0
- package/presets/mavis/java/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/java/rules/interactive-questions.md +8 -8
- package/presets/mavis/java/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/java/team/README.md +10 -0
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/mcp-ts/rules/interactive-questions.md +8 -8
- package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/mcp-ts/team/README.md +10 -0
- package/presets/mavis/next/MCP.md +14 -0
- package/presets/mavis/next/REPO_AGENTS.md +1 -1
- package/presets/mavis/next/adapter-map.json +1 -1
- package/presets/mavis/next/agents/code-reviewer.md +1 -0
- package/presets/mavis/next/agents/playwright-test-healer.md +1 -0
- package/presets/mavis/next/ai-local/rules-library/router-pages.md +5 -5
- package/presets/mavis/next/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/next/mcp.json +3 -3
- package/presets/mavis/next/rules/css-property-order-stylelint.md +1 -1
- package/presets/mavis/next/rules/design-tokens-binding.md +4 -4
- package/presets/mavis/next/rules/forms-validation.md +2 -2
- package/presets/mavis/next/rules/interactive-questions.md +8 -8
- package/presets/mavis/next/rules/navigation-router-stack.md +12 -0
- package/presets/mavis/next/rules/next-app-core.md +18 -17
- package/presets/mavis/next/rules/next-app-router.md +4 -17
- package/presets/mavis/next/rules/next-static-export.md +1 -1
- package/presets/mavis/next/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/next/rules/react-next-anti-hallucination.md +1 -1
- package/presets/mavis/next/rules/reference-features.md +1 -1
- package/presets/mavis/next/rules/security-next.md +24 -3
- package/presets/mavis/next/team/README.md +21 -0
- package/presets/mavis/next/team/fixtures/feature-with-figma-url.json +10 -0
- package/presets/mavis/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
- package/presets/mavis/next/team/fixtures/mockup-review-standalone.json +9 -0
- package/presets/mavis/next/team/fixtures/ux-design-standalone.json +9 -0
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/agents/code-reviewer.md +1 -0
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/nuxt/rules/interactive-questions.md +8 -8
- package/presets/mavis/nuxt/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/nuxt/team/README.md +10 -0
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/agents/code-reviewer.md +1 -0
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/php-hexagonal/rules/interactive-questions.md +8 -8
- package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/php-hexagonal/team/README.md +10 -0
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/agents/code-reviewer.md +1 -0
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/php-laravel/rules/interactive-questions.md +8 -8
- package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/php-laravel/team/README.md +10 -0
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/agents/code-reviewer.md +1 -0
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/svelte/rules/interactive-questions.md +8 -8
- package/presets/mavis/svelte/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/svelte/team/README.md +10 -0
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -0
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/android-kotlin/rules/interactive-questions.md +8 -8
- package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/android-kotlin/team/README.md +10 -0
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/agents/code-reviewer.md +1 -0
- package/presets/opencode/go/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/go/rules/interactive-questions.md +8 -8
- package/presets/opencode/go/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/go/team/README.md +10 -0
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -0
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/ios-swift/rules/interactive-questions.md +8 -8
- package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/ios-swift/team/README.md +10 -0
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/agents/code-reviewer.md +1 -0
- package/presets/opencode/java/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/java/rules/interactive-questions.md +8 -8
- package/presets/opencode/java/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/java/team/README.md +10 -0
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/mcp-ts/rules/interactive-questions.md +8 -8
- package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/mcp-ts/team/README.md +10 -0
- package/presets/opencode/next/MCP.md +14 -0
- package/presets/opencode/next/REPO_AGENTS.md +1 -1
- package/presets/opencode/next/adapter-map.json +1 -1
- package/presets/opencode/next/agents/code-reviewer.md +1 -0
- package/presets/opencode/next/agents/playwright-test-healer.md +1 -0
- package/presets/opencode/next/ai-local/rules-library/router-pages.md +5 -5
- package/presets/opencode/next/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/next/opencode.json +3 -3
- package/presets/opencode/next/rules/css-property-order-stylelint.md +1 -1
- package/presets/opencode/next/rules/design-tokens-binding.md +4 -4
- package/presets/opencode/next/rules/forms-validation.md +2 -2
- package/presets/opencode/next/rules/interactive-questions.md +8 -8
- package/presets/opencode/next/rules/navigation-router-stack.md +12 -0
- package/presets/opencode/next/rules/next-app-core.md +18 -17
- package/presets/opencode/next/rules/next-app-router.md +4 -17
- package/presets/opencode/next/rules/next-static-export.md +1 -1
- package/presets/opencode/next/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/next/rules/react-next-anti-hallucination.md +1 -1
- package/presets/opencode/next/rules/reference-features.md +1 -1
- package/presets/opencode/next/rules/security-next.md +24 -3
- package/presets/opencode/next/team/README.md +21 -0
- package/presets/opencode/next/team/fixtures/feature-with-figma-url.json +10 -0
- package/presets/opencode/next/team/fixtures/feature-with-ux-no-figma.json +10 -0
- package/presets/opencode/next/team/fixtures/mockup-review-standalone.json +9 -0
- package/presets/opencode/next/team/fixtures/ux-design-standalone.json +9 -0
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/agents/code-reviewer.md +1 -0
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/nuxt/rules/interactive-questions.md +8 -8
- package/presets/opencode/nuxt/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/nuxt/team/README.md +10 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -0
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/php-hexagonal/rules/interactive-questions.md +8 -8
- package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/php-hexagonal/team/README.md +10 -0
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -0
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/php-laravel/rules/interactive-questions.md +8 -8
- package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/php-laravel/team/README.md +10 -0
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/agents/code-reviewer.md +1 -0
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/svelte/rules/interactive-questions.md +8 -8
- package/presets/opencode/svelte/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/svelte/team/README.md +10 -0
package/bin/cli.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
|
+
const { spawn, spawnSync } = require('child_process');
|
|
8
|
+
const { pathToFileURL } = require('url');
|
|
7
9
|
const { cmdInitMavis, cmdCleanMavis } = require('./mavis-install');
|
|
8
10
|
const { cmdInitOpencode, cmdCleanOpencode } = require('./opencode-install');
|
|
9
11
|
const { seedAiLocalTeam } = require('./lib/seed-ai-local-team');
|
|
@@ -21,11 +23,28 @@ const {
|
|
|
21
23
|
} = require('./lib/fs-utils');
|
|
22
24
|
const {
|
|
23
25
|
mergeClaudeSettings,
|
|
26
|
+
mergeMcpConfig,
|
|
27
|
+
mergeServerEntry,
|
|
24
28
|
mergedConfigRecords,
|
|
25
29
|
nextMergedRecord,
|
|
26
30
|
priorMergedRecord,
|
|
27
31
|
stripMergedConfigs,
|
|
28
32
|
} = require('./lib/merged-config');
|
|
33
|
+
const { otherToolInstallPresent, TOOL_INSTALL_MARKERS } = require('./lib/tool-installs');
|
|
34
|
+
const {
|
|
35
|
+
CLIENT_IDS,
|
|
36
|
+
serverBySlug,
|
|
37
|
+
serversFor,
|
|
38
|
+
} = require('./lib/mcp/registry');
|
|
39
|
+
const { selectClients, registerServers, removeServers } = require('./lib/mcp/clients');
|
|
40
|
+
const credentials = require('./lib/mcp/credentials');
|
|
41
|
+
const { runDoctor, AREAS } = require('./lib/mcp/doctor');
|
|
42
|
+
const {
|
|
43
|
+
assertNodeFloor,
|
|
44
|
+
packageVersion,
|
|
45
|
+
resolveProjectRoot,
|
|
46
|
+
runtimeEntryPath,
|
|
47
|
+
} = require('./lib/mcp/run');
|
|
29
48
|
|
|
30
49
|
// A pass that fails before the command boundary (`cmdInit` exits the process)
|
|
31
50
|
// must still print the drift line its completed passes accumulated.
|
|
@@ -86,13 +105,20 @@ function printHelp() {
|
|
|
86
105
|
Usage:
|
|
87
106
|
ai-rules init <cursor|claude|mavis|opencode|multi> [--preset <name>]
|
|
88
107
|
ai-rules init <cursor|claude|mavis|opencode|multi> <preset-name>
|
|
89
|
-
ai-rules update [--merge-ai-local] [--cwd <dir>]
|
|
108
|
+
ai-rules update [--merge-ai-local | --check] [--cwd <dir>]
|
|
90
109
|
ai-rules clean <cursor|claude|mavis|opencode> [--cwd <dir>]
|
|
110
|
+
ai-rules mcp setup <gitlab|yandex|all> [--tools <list>] [--yes] [--replace] [--url <url>] [--org-id <id>] [--json] [--cwd <dir>]
|
|
111
|
+
ai-rules mcp add <gitlab|yandex|all> [--tools <list>] [--replace] [--json] [--cwd <dir>]
|
|
112
|
+
ai-rules mcp remove <gitlab|yandex|all> [--tools <list>] [--purge] [--json] [--cwd <dir>]
|
|
113
|
+
ai-rules mcp doctor [gitlab|yandex|all] [--json] [--cwd <dir>]
|
|
114
|
+
ai-rules mcp refresh yandex [--print] [--json] [--yc-bin <path>] [--cwd <dir>]
|
|
115
|
+
ai-rules mcp run <gitlab|yandex-tracker|yandex-wiki> [--print-env] (internal — used by the client config)
|
|
91
116
|
|
|
92
117
|
Options:
|
|
93
118
|
--preset <name> Preset name (default: ${DEFAULT_PRESET})
|
|
94
119
|
--cwd <dir> Target project directory (default: current working directory)
|
|
95
120
|
--merge-ai-local Fast-forward .ai.local/ files whose recorded base still matches
|
|
121
|
+
--check Print each .ai.local/ drift rel and write nothing
|
|
96
122
|
the preset template; a file you edited is kept and its diff is
|
|
97
123
|
written to .ai.local/.rollback/template-drift/
|
|
98
124
|
|
|
@@ -131,6 +157,10 @@ Notes:
|
|
|
131
157
|
settings.json permissions/hooks, opencode.json instructions/bash keys) and removes the file only when nothing
|
|
132
158
|
else is left in a file init created. Shared <cwd>/AGENTS.md is removed only when no other tool install remains.
|
|
133
159
|
Command forms: "init cursor --preset next", "init cursor next", "--preset next init cursor", "cursor init --preset next".
|
|
160
|
+
mcp setup obtains and validates credentials, writes the client entries and runs the doctor. GitLab credentials live in
|
|
161
|
+
.ai-rules/mcp/credentials.env (0600); Yandex settings live in .ai-rules/mcp/config.env (no token). Both sit in a
|
|
162
|
+
self-ignoring .ai-rules/ (the root .gitignore is never modified). Only clients already installed are registered; --tools
|
|
163
|
+
narrows or names a client explicitly. mcp commands require Node 20+ (the GitLab child declares engines >=20).
|
|
134
164
|
|
|
135
165
|
Examples:
|
|
136
166
|
npx @bonesofspring/ai-rules init cursor --preset next
|
|
@@ -164,6 +194,10 @@ Examples:
|
|
|
164
194
|
npx @bonesofspring/ai-rules clean mavis
|
|
165
195
|
npx @bonesofspring/ai-rules clean opencode
|
|
166
196
|
npx @bonesofspring/ai-rules clean cursor
|
|
197
|
+
npx @bonesofspring/ai-rules mcp setup gitlab
|
|
198
|
+
npx @bonesofspring/ai-rules mcp setup yandex
|
|
199
|
+
npx @bonesofspring/ai-rules mcp doctor
|
|
200
|
+
npx @bonesofspring/ai-rules mcp refresh yandex
|
|
167
201
|
`);
|
|
168
202
|
}
|
|
169
203
|
|
|
@@ -218,6 +252,10 @@ function parseArgs(argv) {
|
|
|
218
252
|
args.mergeAiLocal = true;
|
|
219
253
|
continue;
|
|
220
254
|
}
|
|
255
|
+
if (a === '--check') {
|
|
256
|
+
args.checkAiLocal = true;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
221
259
|
if (a.startsWith('-') && a !== '-') {
|
|
222
260
|
args.unknownOption = a;
|
|
223
261
|
continue;
|
|
@@ -288,49 +326,6 @@ function assertPresetDirInsideRoot(presetsRoot, presetBase) {
|
|
|
288
326
|
}
|
|
289
327
|
}
|
|
290
328
|
|
|
291
|
-
/**
|
|
292
|
-
* Merge one shipped server object. Preset scalar fields win; nested `env` / `headers`
|
|
293
|
-
* keep consumer keys unless the preset defines the same nested key.
|
|
294
|
-
*/
|
|
295
|
-
function mergeServerEntry(existingEntry, presetEntry) {
|
|
296
|
-
if (!isPlainObject(existingEntry) || !isPlainObject(presetEntry)) {
|
|
297
|
-
return presetEntry;
|
|
298
|
-
}
|
|
299
|
-
const merged = { ...existingEntry, ...presetEntry };
|
|
300
|
-
for (const nested of ['env', 'headers']) {
|
|
301
|
-
const existingNested = existingEntry[nested];
|
|
302
|
-
const presetNested = presetEntry[nested];
|
|
303
|
-
if (isPlainObject(existingNested) && isPlainObject(presetNested)) {
|
|
304
|
-
merged[nested] = { ...existingNested, ...presetNested };
|
|
305
|
-
} else if (isPlainObject(existingNested) && presetNested === undefined) {
|
|
306
|
-
merged[nested] = existingNested;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
return merged;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Extra local `mcpServers` keys are kept. Shipped keys update; nested `env` / `headers`
|
|
314
|
-
* on overlapping keys are preserved unless the preset defines them.
|
|
315
|
-
* Other unknown top-level keys on the existing file are preserved.
|
|
316
|
-
* @returns {{ merged: object, extrasKept: string[] }}
|
|
317
|
-
*/
|
|
318
|
-
function mergeMcpConfig(presetObj, existingObj) {
|
|
319
|
-
const preset = isPlainObject(presetObj) ? presetObj : {};
|
|
320
|
-
const existing = isPlainObject(existingObj) ? existingObj : {};
|
|
321
|
-
const presetServers = isPlainObject(preset.mcpServers) ? preset.mcpServers : {};
|
|
322
|
-
const existingServers = isPlainObject(existing.mcpServers) ? existing.mcpServers : {};
|
|
323
|
-
const extrasKept = ownKeys(existingServers).filter((key) => !Object.hasOwn(presetServers, key));
|
|
324
|
-
const mergedServers = { ...existingServers };
|
|
325
|
-
for (const key of ownKeys(presetServers)) {
|
|
326
|
-
mergedServers[key] = mergeServerEntry(existingServers[key], presetServers[key]);
|
|
327
|
-
}
|
|
328
|
-
return {
|
|
329
|
-
merged: { ...existing, ...preset, mcpServers: mergedServers },
|
|
330
|
-
extrasKept,
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
|
|
334
329
|
/**
|
|
335
330
|
* Merge the preset MCP file into `mcpDestAbs` through `tx`.
|
|
336
331
|
* @returns {object} The `mergedConfigs` record for this destination.
|
|
@@ -546,23 +541,6 @@ function readInstallManifest(cwd, toolRoot) {
|
|
|
546
541
|
}
|
|
547
542
|
}
|
|
548
543
|
|
|
549
|
-
/** Markers that mean a tool install is still present (directory leftovers do not count). */
|
|
550
|
-
const TOOL_INSTALL_MARKERS = {
|
|
551
|
-
'.cursor': ['.cursor/AGENTS.md', '.cursor/hooks.json', '.cursor/rules'],
|
|
552
|
-
'.claude': ['.claude/CLAUDE.md', '.claude/rules', '.claude/settings.json'],
|
|
553
|
-
'.mavis': ['.mavis/.ai-rules-install.json', '.mavis/AGENTS.md'],
|
|
554
|
-
'.opencode': ['.opencode/.ai-rules-install.json', '.opencode/AGENTS.md'],
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
function otherToolInstallPresent(cwd, exceptRoot) {
|
|
558
|
-
return Object.entries(TOOL_INSTALL_MARKERS).some(([root, markers]) => {
|
|
559
|
-
if (root === exceptRoot) {
|
|
560
|
-
return false;
|
|
561
|
-
}
|
|
562
|
-
return markers.some((rel) => fs.existsSync(path.join(cwd, rel)));
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
|
|
566
544
|
function listPresetNames(presetsRoot) {
|
|
567
545
|
if (!fs.existsSync(presetsRoot)) {
|
|
568
546
|
return [];
|
|
@@ -807,6 +785,7 @@ function cmdUpdate(cwdOption, opts) {
|
|
|
807
785
|
|
|
808
786
|
function cmdInit(tool, preset, cwdOption, opts) {
|
|
809
787
|
const mergeAiLocal = Boolean(opts && opts.mergeAiLocal);
|
|
788
|
+
const checkAiLocal = Boolean(opts && opts.checkAiLocal);
|
|
810
789
|
const deferSummary = Boolean(opts && opts.deferAiLocalSummary);
|
|
811
790
|
if (tool === 'mavis') {
|
|
812
791
|
cmdInitMavis({
|
|
@@ -820,6 +799,7 @@ function cmdInit(tool, preset, cwdOption, opts) {
|
|
|
820
799
|
installMcpJson,
|
|
821
800
|
getPackageRoot,
|
|
822
801
|
mergeAiLocal,
|
|
802
|
+
checkAiLocal,
|
|
823
803
|
},
|
|
824
804
|
});
|
|
825
805
|
if (!deferSummary) flushAiLocalDriftSummary(resolveTargetCwd(cwdOption));
|
|
@@ -836,6 +816,7 @@ function cmdInit(tool, preset, cwdOption, opts) {
|
|
|
836
816
|
seedAiLocalTeam,
|
|
837
817
|
getPackageRoot,
|
|
838
818
|
mergeAiLocal,
|
|
819
|
+
checkAiLocal,
|
|
839
820
|
},
|
|
840
821
|
});
|
|
841
822
|
if (!deferSummary) flushAiLocalDriftSummary(resolveTargetCwd(cwdOption));
|
|
@@ -936,6 +917,7 @@ function cmdInit(tool, preset, cwdOption, opts) {
|
|
|
936
917
|
source: `${tool}/${presetName}`,
|
|
937
918
|
packageVersion: getPackageVersion(packageRoot),
|
|
938
919
|
mergeAiLocal,
|
|
920
|
+
checkAiLocal,
|
|
939
921
|
writeFile: (dest, content, label) => tx.writeFile(dest, content, label),
|
|
940
922
|
trackFile: (dest, label) => tx.track(dest, label),
|
|
941
923
|
});
|
|
@@ -1121,6 +1103,516 @@ function cmdClean(tool, cwdOption) {
|
|
|
1121
1103
|
);
|
|
1122
1104
|
}
|
|
1123
1105
|
|
|
1106
|
+
function printMcpHelp() {
|
|
1107
|
+
console.log(`ai-rules mcp
|
|
1108
|
+
|
|
1109
|
+
Usage:
|
|
1110
|
+
ai-rules mcp setup <gitlab|yandex|all> [--tools <list>] [--yes] [--replace] [--url <url>] [--org-id <id>] [--json] [--cwd <dir>]
|
|
1111
|
+
ai-rules mcp add <gitlab|yandex|all> [--tools <list>] [--replace] [--json] [--cwd <dir>]
|
|
1112
|
+
ai-rules mcp remove <gitlab|yandex|all> [--tools <list>] [--purge] [--json] [--cwd <dir>]
|
|
1113
|
+
ai-rules mcp doctor [gitlab|yandex|all] [--json] [--cwd <dir>]
|
|
1114
|
+
ai-rules mcp refresh yandex [--print] [--json] [--yc-bin <path>] [--cwd <dir>]
|
|
1115
|
+
ai-rules mcp run <gitlab|yandex-tracker|yandex-wiki> [--print-env]
|
|
1116
|
+
|
|
1117
|
+
Options:
|
|
1118
|
+
--tools <list> Comma-separated clients (cursor, claude, mavis, opencode); default: detected
|
|
1119
|
+
--yes Never prompt; required values must arrive by flag or stdin
|
|
1120
|
+
--replace Replace a foreign entry that occupies one of our ids
|
|
1121
|
+
--url <url> GitLab instance URL (https)
|
|
1122
|
+
--org-id <id> Yandex organization id (non-secret)
|
|
1123
|
+
--yc-bin <path> Override the yc lookup
|
|
1124
|
+
--purge remove: also delete .ai-rules/mcp/{credentials,config}.env
|
|
1125
|
+
--print refresh: print the fresh IAM token to stdout (opt-in)
|
|
1126
|
+
--json One JSON document on stdout; human text moves to stderr
|
|
1127
|
+
--cwd <dir> Target project directory (default: current working directory)
|
|
1128
|
+
--print-env run (gitlab): print the masked child env mapping and exit
|
|
1129
|
+
|
|
1130
|
+
Commands:
|
|
1131
|
+
setup Credentials + registration + doctor for one provider (the normal entry point)
|
|
1132
|
+
add Registration only (after installing a client or bumping ai-rules)
|
|
1133
|
+
remove Delete only the entries this command owns
|
|
1134
|
+
doctor Per-server runtime / registration / credentials / upstream report
|
|
1135
|
+
refresh The Yandex re-login (exit 0 fresh, 1 yc error, 2 re-login required)
|
|
1136
|
+
run Internal — the client config starts it; speaks MCP over stdio
|
|
1137
|
+
|
|
1138
|
+
Node 20+ is required for every mcp command. Nothing here writes a token into a client config.
|
|
1139
|
+
`);
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
const MCP_COMMANDS = new Set(['setup', 'add', 'remove', 'doctor', 'refresh', 'run']);
|
|
1143
|
+
const MCP_VALUE_OPTIONS = new Set(['--tools', '--url', '--org-id', '--yc-bin', '--cwd']);
|
|
1144
|
+
const MCP_BOOL_OPTIONS = new Set(['--yes', '--json', '--replace', '--purge', '--print', '--print-env', '--help', '-h']);
|
|
1145
|
+
|
|
1146
|
+
function camelOption(name) {
|
|
1147
|
+
return name.slice(2).replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
function parseMcpArgs(argv) {
|
|
1151
|
+
const options = { _: [] };
|
|
1152
|
+
for (let i = 0; i < argv.length; i++) {
|
|
1153
|
+
const token = argv[i];
|
|
1154
|
+
if (token === '--') {
|
|
1155
|
+
options._.push(...argv.slice(i + 1));
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1158
|
+
if (MCP_VALUE_OPTIONS.has(token)) {
|
|
1159
|
+
const value = argv[i + 1];
|
|
1160
|
+
if (value === undefined || value === '' || value.startsWith('-')) {
|
|
1161
|
+
throw new Error(`Missing value for ${token}`);
|
|
1162
|
+
}
|
|
1163
|
+
options[camelOption(token)] = value;
|
|
1164
|
+
i++;
|
|
1165
|
+
continue;
|
|
1166
|
+
}
|
|
1167
|
+
const equals = token.indexOf('=');
|
|
1168
|
+
if (token.startsWith('--') && equals > 0) {
|
|
1169
|
+
const name = token.slice(0, equals);
|
|
1170
|
+
if (MCP_VALUE_OPTIONS.has(name)) {
|
|
1171
|
+
options[camelOption(name)] = token.slice(equals + 1);
|
|
1172
|
+
continue;
|
|
1173
|
+
}
|
|
1174
|
+
if (MCP_BOOL_OPTIONS.has(name)) {
|
|
1175
|
+
throw new Error(`Option ${name} does not take a value`);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
if (MCP_BOOL_OPTIONS.has(token)) {
|
|
1179
|
+
options[camelOption(token)] = true;
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
if (token.startsWith('-') && token !== '-') {
|
|
1183
|
+
throw new Error(`Unknown option: ${token}`);
|
|
1184
|
+
}
|
|
1185
|
+
options._.push(token);
|
|
1186
|
+
}
|
|
1187
|
+
return options;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
function createMcpPrinter(jsonMode) {
|
|
1191
|
+
const write = (line) => {
|
|
1192
|
+
if (jsonMode) {
|
|
1193
|
+
process.stderr.write(`${line}\n`);
|
|
1194
|
+
} else {
|
|
1195
|
+
process.stdout.write(`${line}\n`);
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
return {
|
|
1199
|
+
jsonMode,
|
|
1200
|
+
ok: (area, detail) => write(`ok ${area.padEnd(14)} ${detail}`),
|
|
1201
|
+
warn: (area, detail) => write(`warn ${area.padEnd(14)} ${detail}`),
|
|
1202
|
+
fail: (area, detail) => write(`fail ${area.padEnd(14)} ${detail}`),
|
|
1203
|
+
next: (command) => write(`next: ${command}`),
|
|
1204
|
+
result: (document) => {
|
|
1205
|
+
if (jsonMode) {
|
|
1206
|
+
process.stdout.write(`${JSON.stringify(document, null, 2)}\n`);
|
|
1207
|
+
}
|
|
1208
|
+
},
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
function renderDoctor(doctor, printer) {
|
|
1213
|
+
for (const server of doctor.servers) {
|
|
1214
|
+
for (const area of AREAS) {
|
|
1215
|
+
const check = server.checks[area];
|
|
1216
|
+
const detail = `${server.id}: ${check.detail}`;
|
|
1217
|
+
if (check.status === 'ok') {
|
|
1218
|
+
printer.ok(area, detail);
|
|
1219
|
+
} else if (check.status === 'fail') {
|
|
1220
|
+
printer.fail(area, detail);
|
|
1221
|
+
} else {
|
|
1222
|
+
printer.warn(area, detail);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
for (const next of server.nexts) {
|
|
1226
|
+
printer.next(next);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
function publicServers(servers) {
|
|
1232
|
+
return servers.map((server) => ({
|
|
1233
|
+
id: server.id,
|
|
1234
|
+
ready: server.ready,
|
|
1235
|
+
checks: server.checks,
|
|
1236
|
+
next: server.next,
|
|
1237
|
+
}));
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
async function loadPackModules(packageRoot) {
|
|
1241
|
+
const envfile = await import(pathToFileURL(path.join(packageRoot, 'mcp', 'lib', 'envfile.mjs')).href);
|
|
1242
|
+
const yandex = await import(pathToFileURL(path.join(packageRoot, 'mcp', 'lib', 'yandex.mjs')).href);
|
|
1243
|
+
return { envfile, yandex };
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
function parseMcpTools(value) {
|
|
1247
|
+
const tools = String(value)
|
|
1248
|
+
.split(',')
|
|
1249
|
+
.map((item) => item.trim())
|
|
1250
|
+
.filter(Boolean);
|
|
1251
|
+
if (tools.length === 0) {
|
|
1252
|
+
throw new Error('Missing value for --tools');
|
|
1253
|
+
}
|
|
1254
|
+
const unknown = tools.find((tool) => !CLIENT_IDS.includes(tool));
|
|
1255
|
+
if (unknown) {
|
|
1256
|
+
throw new Error(`Unknown client: ${unknown}. Use ${CLIENT_IDS.join(', ')}.`);
|
|
1257
|
+
}
|
|
1258
|
+
return tools;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
function registerProvider({ cwd, provider, options, version, printer }) {
|
|
1262
|
+
const selection = selectClients({ cwd, tools: options.tools, markers: TOOL_INSTALL_MARKERS });
|
|
1263
|
+
for (const warning of selection.warnings) {
|
|
1264
|
+
printer.warn('clients', warning);
|
|
1265
|
+
}
|
|
1266
|
+
if (selection.clients.length === 0) {
|
|
1267
|
+
printer.fail('clients', 'no MCP client detected');
|
|
1268
|
+
printer.next(`ai-rules mcp add ${provider} --tools <cursor|claude|mavis|opencode>`);
|
|
1269
|
+
return null;
|
|
1270
|
+
}
|
|
1271
|
+
const registration = registerServers({
|
|
1272
|
+
cwd,
|
|
1273
|
+
clients: selection.clients,
|
|
1274
|
+
servers: serversFor(provider),
|
|
1275
|
+
version,
|
|
1276
|
+
replace: Boolean(options.replace),
|
|
1277
|
+
});
|
|
1278
|
+
for (const warning of registration.warnings) {
|
|
1279
|
+
printer.warn('clients', warning);
|
|
1280
|
+
}
|
|
1281
|
+
for (const rel of registration.changed) {
|
|
1282
|
+
printer.ok('registration', `wrote ${rel}`);
|
|
1283
|
+
}
|
|
1284
|
+
if (registration.changed.length === 0) {
|
|
1285
|
+
printer.ok('registration', `${selection.clients.map((client) => client.id).join(', ')} already up to date`);
|
|
1286
|
+
}
|
|
1287
|
+
return { selection, registration };
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
async function cmdMcpSetup({ cwd, provider, options, printer, packageRoot, modules, version }) {
|
|
1291
|
+
const providers = provider === 'all' ? ['gitlab', 'yandex'] : [provider];
|
|
1292
|
+
const results = [];
|
|
1293
|
+
|
|
1294
|
+
for (const current of providers) {
|
|
1295
|
+
const credentialResult = current === 'gitlab'
|
|
1296
|
+
? await credentials.setupGitlab({ cwd, options, envfile: modules.envfile })
|
|
1297
|
+
: await credentials.setupYandex({ cwd, options, io: {}, yandex: modules.yandex, envfile: modules.envfile });
|
|
1298
|
+
|
|
1299
|
+
for (const warning of credentialResult.warnings || []) {
|
|
1300
|
+
printer.warn('credentials', warning);
|
|
1301
|
+
}
|
|
1302
|
+
if (!credentialResult.ok) {
|
|
1303
|
+
printer.fail(credentialResult.kind === 'runtime' ? 'runtime' : 'credentials', credentialResult.detail);
|
|
1304
|
+
if (credentialResult.next) {
|
|
1305
|
+
printer.next(credentialResult.next);
|
|
1306
|
+
}
|
|
1307
|
+
printer.result({ command: 'setup', ok: false, provider: current, detail: credentialResult.detail });
|
|
1308
|
+
process.exit(1);
|
|
1309
|
+
}
|
|
1310
|
+
printer.ok('credentials', credentialResult.detail);
|
|
1311
|
+
|
|
1312
|
+
const registered = registerProvider({ cwd, provider: current, options, version, printer });
|
|
1313
|
+
if (!registered) {
|
|
1314
|
+
printer.result({ command: 'setup', ok: false, provider: current, detail: 'no MCP client detected' });
|
|
1315
|
+
process.exit(1);
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
const doctor = await runDoctor({
|
|
1319
|
+
cwd,
|
|
1320
|
+
provider: current,
|
|
1321
|
+
packageRoot,
|
|
1322
|
+
version,
|
|
1323
|
+
envfile: modules.envfile,
|
|
1324
|
+
yandex: modules.yandex,
|
|
1325
|
+
options,
|
|
1326
|
+
});
|
|
1327
|
+
renderDoctor(doctor, printer);
|
|
1328
|
+
|
|
1329
|
+
results.push({
|
|
1330
|
+
provider: current,
|
|
1331
|
+
credentials: credentialResult.detail,
|
|
1332
|
+
clients: registered.selection.clients.map((client) => client.id),
|
|
1333
|
+
changed: registered.registration.changed,
|
|
1334
|
+
servers: publicServers(doctor.servers),
|
|
1335
|
+
});
|
|
1336
|
+
|
|
1337
|
+
const credentialClass = doctor.servers.some(
|
|
1338
|
+
(server) => ['runtime', 'registration', 'credentials'].some((area) => server.checks[area].status === 'fail'),
|
|
1339
|
+
);
|
|
1340
|
+
const upstreamCredentialClass = doctor.servers.some(
|
|
1341
|
+
(server) => server.checks.upstream.status === 'fail' && /401|organization/i.test(server.checks.upstream.detail),
|
|
1342
|
+
);
|
|
1343
|
+
if (credentialClass || upstreamCredentialClass) {
|
|
1344
|
+
printer.result({ command: 'setup', ok: false, providers: results });
|
|
1345
|
+
process.exit(1);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
printer.next('restart the MCP server in your client');
|
|
1350
|
+
printer.result({ command: 'setup', ok: true, providers: results });
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
function cmdMcpAdd({ cwd, provider, options, printer, version }) {
|
|
1354
|
+
const registered = registerProvider({ cwd, provider, options, version, printer });
|
|
1355
|
+
if (!registered) {
|
|
1356
|
+
printer.result({ command: 'add', ok: false, provider });
|
|
1357
|
+
process.exit(1);
|
|
1358
|
+
}
|
|
1359
|
+
printer.result({
|
|
1360
|
+
command: 'add',
|
|
1361
|
+
ok: true,
|
|
1362
|
+
provider,
|
|
1363
|
+
clients: registered.selection.clients.map((client) => client.id),
|
|
1364
|
+
changed: registered.registration.changed,
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
function cmdMcpRemove({ cwd, provider, options, printer }) {
|
|
1369
|
+
const selection = selectClients({ cwd, tools: options.tools, markers: TOOL_INSTALL_MARKERS });
|
|
1370
|
+
for (const warning of selection.warnings) {
|
|
1371
|
+
printer.warn('clients', warning);
|
|
1372
|
+
}
|
|
1373
|
+
const removal = removeServers({ cwd, clients: selection.clients, servers: serversFor(provider) });
|
|
1374
|
+
for (const warning of removal.warnings) {
|
|
1375
|
+
printer.warn('clients', warning);
|
|
1376
|
+
}
|
|
1377
|
+
printer.ok(
|
|
1378
|
+
'registration',
|
|
1379
|
+
removal.removed.length > 0
|
|
1380
|
+
? `removed ${removal.removed.join(', ')}`
|
|
1381
|
+
: 'no owned entries to remove',
|
|
1382
|
+
);
|
|
1383
|
+
const purged = options.purge ? credentials.purgeCredentials(cwd) : [];
|
|
1384
|
+
if (purged.length > 0) {
|
|
1385
|
+
printer.ok('credentials', `deleted ${purged.join(', ')}`);
|
|
1386
|
+
}
|
|
1387
|
+
printer.result({
|
|
1388
|
+
command: 'remove',
|
|
1389
|
+
ok: true,
|
|
1390
|
+
provider,
|
|
1391
|
+
removed: removal.removed,
|
|
1392
|
+
changed: removal.changed,
|
|
1393
|
+
purged,
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
async function cmdMcpDoctor({ cwd, provider, options, printer, packageRoot, modules, version }) {
|
|
1398
|
+
const doctor = await runDoctor({
|
|
1399
|
+
cwd,
|
|
1400
|
+
provider,
|
|
1401
|
+
packageRoot,
|
|
1402
|
+
version,
|
|
1403
|
+
envfile: modules.envfile,
|
|
1404
|
+
yandex: modules.yandex,
|
|
1405
|
+
options,
|
|
1406
|
+
});
|
|
1407
|
+
renderDoctor(doctor, printer);
|
|
1408
|
+
printer.result({ servers: publicServers(doctor.servers) });
|
|
1409
|
+
process.exitCode = doctor.exitCode;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
function cmdMcpRefresh({ cwd, options, packageRoot }) {
|
|
1413
|
+
const entry = runtimeEntryPath(packageRoot, 'mcp/yandex-token-refresh.mjs');
|
|
1414
|
+
if (!fs.existsSync(entry)) {
|
|
1415
|
+
console.error(`fail runtime missing ${entry}`);
|
|
1416
|
+
console.error(`next: reinstall @bonesofspring/ai-rules@${packageVersion(packageRoot)}`);
|
|
1417
|
+
process.exit(1);
|
|
1418
|
+
}
|
|
1419
|
+
if (options.json && options.print) {
|
|
1420
|
+
console.error('fail refresh --json and --print cannot be combined');
|
|
1421
|
+
console.error('next: ai-rules mcp refresh yandex --print');
|
|
1422
|
+
process.exit(1);
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
const args = [entry];
|
|
1426
|
+
if (options.print) {
|
|
1427
|
+
args.push('--print');
|
|
1428
|
+
}
|
|
1429
|
+
const env = { ...process.env };
|
|
1430
|
+
if (options.ycBin) {
|
|
1431
|
+
env.YC_BIN = options.ycBin;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
if (options.json) {
|
|
1435
|
+
const result = spawnSync(process.execPath, args, {
|
|
1436
|
+
cwd,
|
|
1437
|
+
env,
|
|
1438
|
+
stdio: ['inherit', 'pipe', 'inherit'],
|
|
1439
|
+
encoding: 'utf8',
|
|
1440
|
+
});
|
|
1441
|
+
const exitCode = result.status ?? 1;
|
|
1442
|
+
process.stdout.write(`${JSON.stringify({ command: 'refresh', provider: 'yandex', ok: exitCode === 0, exitCode }, null, 2)}\n`);
|
|
1443
|
+
process.exit(exitCode);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
const child = spawnSync(process.execPath, args, { cwd, env, stdio: 'inherit' });
|
|
1447
|
+
process.exit(child.status ?? 1);
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
async function cmdMcpRun({ slug, options, packageRoot }) {
|
|
1451
|
+
const server = serverBySlug(slug);
|
|
1452
|
+
if (!server) {
|
|
1453
|
+
console.error(`Unknown server: ${slug ?? '(none)'}. Use gitlab, yandex-tracker, or yandex-wiki.`);
|
|
1454
|
+
process.exit(1);
|
|
1455
|
+
}
|
|
1456
|
+
if (!options.printEnv && (process.stdin.isTTY || process.stdout.isTTY)) {
|
|
1457
|
+
console.error('fail runtime mcp run speaks MCP over stdio; run `ai-rules mcp doctor`');
|
|
1458
|
+
console.error('next: ai-rules mcp doctor');
|
|
1459
|
+
process.exit(1);
|
|
1460
|
+
}
|
|
1461
|
+
if (options.printEnv && server.provider !== 'gitlab') {
|
|
1462
|
+
console.error('--print-env is supported for gitlab only.');
|
|
1463
|
+
process.exit(1);
|
|
1464
|
+
}
|
|
1465
|
+
const entry = runtimeEntryPath(packageRoot, server.entry);
|
|
1466
|
+
if (!fs.existsSync(entry)) {
|
|
1467
|
+
console.error(`fail runtime missing ${server.entry}`);
|
|
1468
|
+
console.error(`next: reinstall @bonesofspring/ai-rules@${packageVersion(packageRoot)}`);
|
|
1469
|
+
process.exit(1);
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
if (server.provider === 'yandex') {
|
|
1473
|
+
const modules = await loadPackModules(packageRoot);
|
|
1474
|
+
try {
|
|
1475
|
+
const config = modules.yandex.loadYandexConfig({ root: resolveProjectRoot() });
|
|
1476
|
+
if (!modules.yandex.ycAvailable(config.ycBin)) {
|
|
1477
|
+
throw new Error('yc not found');
|
|
1478
|
+
}
|
|
1479
|
+
} catch (error) {
|
|
1480
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1481
|
+
console.error(`fail runtime ${detail}`);
|
|
1482
|
+
const next = error instanceof Error && error.next
|
|
1483
|
+
? error.next
|
|
1484
|
+
: /YANDEX_ORG_ID/.test(detail)
|
|
1485
|
+
? 'ai-rules mcp setup yandex'
|
|
1486
|
+
: 'install the Yandex Cloud CLI (https://yandex.cloud/docs/cli/install)';
|
|
1487
|
+
console.error(`next: ${next}`);
|
|
1488
|
+
process.exit(1);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
const args = [entry, ...server.argv];
|
|
1493
|
+
if (options.printEnv) {
|
|
1494
|
+
args.push('--print-env');
|
|
1495
|
+
}
|
|
1496
|
+
const child = spawn(process.execPath, args, { stdio: 'inherit' });
|
|
1497
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
1498
|
+
process.on(signal, () => {
|
|
1499
|
+
if (!child.killed) {
|
|
1500
|
+
child.kill(signal);
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
child.on('error', (error) => {
|
|
1505
|
+
console.error(`fail runtime ${error.message}`);
|
|
1506
|
+
process.exit(1);
|
|
1507
|
+
});
|
|
1508
|
+
child.on('exit', (code) => {
|
|
1509
|
+
process.exit(code ?? 1);
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
async function cmdMcp(argv) {
|
|
1514
|
+
let options;
|
|
1515
|
+
try {
|
|
1516
|
+
options = parseMcpArgs(argv);
|
|
1517
|
+
} catch (error) {
|
|
1518
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1519
|
+
process.exit(1);
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
if (options.help) {
|
|
1523
|
+
printMcpHelp();
|
|
1524
|
+
process.exit(0);
|
|
1525
|
+
}
|
|
1526
|
+
if (options._.length === 0) {
|
|
1527
|
+
printMcpHelp();
|
|
1528
|
+
process.exit(1);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
const [command, providerArg, extra] = options._;
|
|
1532
|
+
if (extra !== undefined) {
|
|
1533
|
+
console.error(`Unexpected argument: ${extra}`);
|
|
1534
|
+
process.exit(1);
|
|
1535
|
+
}
|
|
1536
|
+
if (!MCP_COMMANDS.has(command)) {
|
|
1537
|
+
console.error(`Unknown mcp command: ${command}. Use setup, add, remove, doctor, refresh, or run.`);
|
|
1538
|
+
process.exit(1);
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
if (!assertNodeFloor(process.versions.node, 20)) {
|
|
1542
|
+
console.error(`fail runtime node ${process.versions.node} < 20`);
|
|
1543
|
+
console.error('next: install Node 20 LTS or newer');
|
|
1544
|
+
process.exit(1);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
if (options.tools !== undefined) {
|
|
1548
|
+
if (!['setup', 'add', 'remove'].includes(command)) {
|
|
1549
|
+
console.error(`Option --tools does not apply to mcp ${command}.`);
|
|
1550
|
+
process.exit(1);
|
|
1551
|
+
}
|
|
1552
|
+
try {
|
|
1553
|
+
options.tools = parseMcpTools(options.tools);
|
|
1554
|
+
} catch (error) {
|
|
1555
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1556
|
+
process.exit(1);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
const packageRoot = getPackageRoot();
|
|
1561
|
+
const version = packageVersion(packageRoot);
|
|
1562
|
+
|
|
1563
|
+
if (command === 'run') {
|
|
1564
|
+
if (options.cwd) {
|
|
1565
|
+
console.error('mcp run does not take --cwd; the client starts it in the project root.');
|
|
1566
|
+
process.exit(1);
|
|
1567
|
+
}
|
|
1568
|
+
await cmdMcpRun({ slug: providerArg, options, packageRoot });
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
const cwd = resolveTargetCwd(options.cwd);
|
|
1573
|
+
|
|
1574
|
+
if (command === 'refresh') {
|
|
1575
|
+
if (providerArg !== 'yandex') {
|
|
1576
|
+
console.error('Missing or invalid provider. Use: mcp refresh yandex');
|
|
1577
|
+
process.exit(1);
|
|
1578
|
+
}
|
|
1579
|
+
cmdMcpRefresh({ cwd, options, packageRoot });
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
let provider;
|
|
1584
|
+
if (command === 'doctor') {
|
|
1585
|
+
provider = providerArg ?? 'all';
|
|
1586
|
+
} else {
|
|
1587
|
+
if (providerArg === undefined) {
|
|
1588
|
+
console.error(`Missing provider. Use: mcp ${command} <gitlab|yandex|all>`);
|
|
1589
|
+
process.exit(1);
|
|
1590
|
+
}
|
|
1591
|
+
provider = providerArg;
|
|
1592
|
+
}
|
|
1593
|
+
if (!['gitlab', 'yandex', 'all'].includes(provider)) {
|
|
1594
|
+
console.error(`Unknown provider: ${provider}. Use gitlab, yandex, or all.`);
|
|
1595
|
+
process.exit(1);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
const modules = await loadPackModules(packageRoot);
|
|
1599
|
+
const printer = createMcpPrinter(Boolean(options.json));
|
|
1600
|
+
|
|
1601
|
+
if (command === 'setup') {
|
|
1602
|
+
await cmdMcpSetup({ cwd, provider, options, printer, packageRoot, modules, version });
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1605
|
+
if (command === 'add') {
|
|
1606
|
+
cmdMcpAdd({ cwd, provider, options, printer, version });
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
if (command === 'remove') {
|
|
1610
|
+
cmdMcpRemove({ cwd, provider, options, printer });
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
await cmdMcpDoctor({ cwd, provider, options, printer, packageRoot, modules, version });
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1124
1616
|
function main() {
|
|
1125
1617
|
const argv = process.argv.slice(2);
|
|
1126
1618
|
if (argv.length === 0) {
|
|
@@ -1128,6 +1620,14 @@ function main() {
|
|
|
1128
1620
|
process.exit(0);
|
|
1129
1621
|
}
|
|
1130
1622
|
|
|
1623
|
+
if (argv[0] === 'mcp') {
|
|
1624
|
+
cmdMcp(argv.slice(1)).catch((error) => {
|
|
1625
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1626
|
+
process.exit(1);
|
|
1627
|
+
});
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1131
1631
|
const parsed = parseArgs(argv);
|
|
1132
1632
|
if (parsed.help) {
|
|
1133
1633
|
printHelp();
|
|
@@ -1178,6 +1678,10 @@ function main() {
|
|
|
1178
1678
|
return;
|
|
1179
1679
|
}
|
|
1180
1680
|
if (command === 'clean') {
|
|
1681
|
+
if (parsed.mergeAiLocal || parsed.checkAiLocal) {
|
|
1682
|
+
console.error('--merge-ai-local and --check apply to init and update.');
|
|
1683
|
+
process.exit(1);
|
|
1684
|
+
}
|
|
1181
1685
|
if (tool === 'multi') {
|
|
1182
1686
|
console.error('clean multi is not supported. Clean each tool: cursor, claude, mavis, opencode.');
|
|
1183
1687
|
process.exit(1);
|