@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
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ai-rules mcp doctor`: four areas per server (runtime, registration,
|
|
3
|
+
* credentials, upstream), one next command per failing check, no token output.
|
|
4
|
+
* Reads the client configs and the credential files directly — no state file.
|
|
5
|
+
*/
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const { spawnSync } = require('child_process');
|
|
9
|
+
const { resolveManagedPath } = require('../safe-path');
|
|
10
|
+
const { isPlainObject } = require('../fs-utils');
|
|
11
|
+
const { TOOL_INSTALL_MARKERS } = require('../tool-installs');
|
|
12
|
+
const { assertNodeFloor, resolveProjectRootDetailed } = require('./run');
|
|
13
|
+
const { detectClientIds, readClientConfig } = require('./clients');
|
|
14
|
+
const { checkIgnored, CREDENTIALS_REL, CONFIG_REL } = require('./credentials');
|
|
15
|
+
const { ownsEntry, registeredPin, tokenFinding } = require('./registry');
|
|
16
|
+
|
|
17
|
+
const AREAS = ['runtime', 'registration', 'credentials', 'upstream'];
|
|
18
|
+
|
|
19
|
+
function oneLine(text) {
|
|
20
|
+
return String(text).replace(/\s+/g, ' ').trim();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let npxCached = null;
|
|
24
|
+
|
|
25
|
+
function npxResolves() {
|
|
26
|
+
if (npxCached !== null) {
|
|
27
|
+
return npxCached;
|
|
28
|
+
}
|
|
29
|
+
const npx = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
30
|
+
if (spawnSync(npx, ['--version'], { stdio: 'ignore' }).status === 0) {
|
|
31
|
+
npxCached = true;
|
|
32
|
+
return npxCached;
|
|
33
|
+
}
|
|
34
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
35
|
+
npxCached = spawnSync(npm, ['--version'], { stdio: 'ignore' }).status === 0;
|
|
36
|
+
return npxCached;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function firstWith(statuses, status) {
|
|
40
|
+
return statuses.find((entry) => entry.status === status);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function unwrap(statuses) {
|
|
44
|
+
const status = firstWith(statuses, 'fail')
|
|
45
|
+
?? firstWith(statuses, 'warn')
|
|
46
|
+
?? firstWith(statuses, 'skipped')
|
|
47
|
+
?? statuses[0]
|
|
48
|
+
?? { status: 'ok', detail: 'ok' };
|
|
49
|
+
return {
|
|
50
|
+
status: status.status,
|
|
51
|
+
detail: statuses.map((entry) => entry.detail).filter(Boolean).join('; '),
|
|
52
|
+
next: status.next,
|
|
53
|
+
kind: status.kind,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function checkGitlabCredentials(cwd, envfile) {
|
|
58
|
+
const abs = resolveManagedPath(cwd, CREDENTIALS_REL);
|
|
59
|
+
const fail = (detail) => ({ status: 'fail', detail, next: 'ai-rules mcp setup gitlab' });
|
|
60
|
+
if (!abs || !fs.existsSync(abs)) {
|
|
61
|
+
return fail(`${CREDENTIALS_REL} is missing`);
|
|
62
|
+
}
|
|
63
|
+
const values = envfile.readEnvFile(abs);
|
|
64
|
+
if (!values.GITLAB_URL || !values.GITLAB_TOKEN) {
|
|
65
|
+
return fail(`${CREDENTIALS_REL} needs GITLAB_URL and GITLAB_TOKEN`);
|
|
66
|
+
}
|
|
67
|
+
if (process.platform !== 'win32') {
|
|
68
|
+
const mode = fs.statSync(abs).mode & 0o777;
|
|
69
|
+
if (mode !== 0o600) {
|
|
70
|
+
return fail(`mode 0${mode.toString(8)} is not 0600`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const ignored = checkIgnored(cwd, CREDENTIALS_REL);
|
|
74
|
+
if (ignored.status === 'fail') {
|
|
75
|
+
return fail(`${CREDENTIALS_REL} is not ignored`);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
status: ignored.status === 'warn' ? 'warn' : 'ok',
|
|
79
|
+
detail: process.platform === 'win32' ? '0600 (not checked on win32)' : '0600, ignored',
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function checkGitlabUpstream(url, token) {
|
|
84
|
+
const host = (() => {
|
|
85
|
+
try {
|
|
86
|
+
return new URL(url).host;
|
|
87
|
+
} catch {
|
|
88
|
+
return url;
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
try {
|
|
92
|
+
const response = await fetch(`${url}/api/v4/user`, {
|
|
93
|
+
headers: { 'PRIVATE-TOKEN': token },
|
|
94
|
+
signal: AbortSignal.timeout(15_000),
|
|
95
|
+
});
|
|
96
|
+
if (response.status === 200) {
|
|
97
|
+
return { status: 'ok', detail: 'GET /api/v4/user → 200' };
|
|
98
|
+
}
|
|
99
|
+
if (response.status === 401) {
|
|
100
|
+
return { status: 'fail', detail: 'GET /api/v4/user → 401', next: 'ai-rules mcp setup gitlab' };
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
status: 'fail',
|
|
104
|
+
detail: `GET /api/v4/user → ${response.status}`,
|
|
105
|
+
next: `check network access to ${host}`,
|
|
106
|
+
};
|
|
107
|
+
} catch {
|
|
108
|
+
return { status: 'fail', detail: 'GET /api/v4/user failed', next: `check network access to ${host}` };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function checkRegistration(server, cwd, version) {
|
|
113
|
+
const clients = detectClientIds(cwd, TOOL_INSTALL_MARKERS);
|
|
114
|
+
if (clients.length === 0) {
|
|
115
|
+
return { status: 'warn', detail: 'no MCP client detected', next: null };
|
|
116
|
+
}
|
|
117
|
+
const statuses = [];
|
|
118
|
+
|
|
119
|
+
for (const id of clients) {
|
|
120
|
+
const file = {
|
|
121
|
+
cursor: '.cursor/mcp.json',
|
|
122
|
+
claude: '.mcp.json',
|
|
123
|
+
mavis: '.mavis/mcp.json',
|
|
124
|
+
opencode: 'opencode.json',
|
|
125
|
+
}[id];
|
|
126
|
+
const key = id === 'opencode' ? 'mcp' : 'mcpServers';
|
|
127
|
+
const shape = id === 'opencode' ? 'local' : 'object';
|
|
128
|
+
const next = `ai-rules mcp add ${server.provider} --tools ${id}`;
|
|
129
|
+
let config;
|
|
130
|
+
try {
|
|
131
|
+
config = readClientConfig(cwd, { id, file, key, shape });
|
|
132
|
+
} catch (error) {
|
|
133
|
+
statuses.push({
|
|
134
|
+
status: 'fail',
|
|
135
|
+
detail: `${id}: ${error instanceof Error ? error.message : String(error)}`,
|
|
136
|
+
next,
|
|
137
|
+
});
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (config.existing === null) {
|
|
141
|
+
statuses.push({ status: 'fail', detail: `${id}: ${file} is missing`, next });
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const entry = isPlainObject(config.existing[key]) ? config.existing[key][server.id] : undefined;
|
|
145
|
+
if (entry === undefined) {
|
|
146
|
+
statuses.push({ status: 'fail', detail: `${id}: no "${server.id}" entry`, next });
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (!ownsEntry(entry)) {
|
|
150
|
+
statuses.push({ status: 'fail', detail: `${id}: "${server.id}" is not an ai-rules entry`, next });
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const pin = registeredPin(entry);
|
|
154
|
+
if (pin !== version) {
|
|
155
|
+
statuses.push({ status: 'warn', detail: `${id}: pin ${pin} != ${version}`, next: `ai-rules mcp add ${server.provider}` });
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const finding = tokenFinding(entry);
|
|
159
|
+
if (finding) {
|
|
160
|
+
statuses.push({ status: 'fail', detail: `${id}: token-looking ${finding} under our id`, next });
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
statuses.push({ status: 'ok', detail: `${id}: ${pin}` });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return unwrap(statuses);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Shared Yandex credential state: one `yc` probe for both servers. */
|
|
170
|
+
async function checkYandexCredentials(cwd, options, yandex) {
|
|
171
|
+
let config;
|
|
172
|
+
try {
|
|
173
|
+
config = yandex.loadYandexConfig({ root: cwd });
|
|
174
|
+
} catch {
|
|
175
|
+
return {
|
|
176
|
+
check: { status: 'fail', detail: 'YANDEX_ORG_ID is not set', next: 'ai-rules mcp setup yandex' },
|
|
177
|
+
config: null,
|
|
178
|
+
token: null,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const ycBin = options.ycBin || config.ycBin;
|
|
183
|
+
if (!yandex.ycAvailable(ycBin)) {
|
|
184
|
+
return {
|
|
185
|
+
check: {
|
|
186
|
+
status: 'fail',
|
|
187
|
+
detail: 'yc not found',
|
|
188
|
+
next: 'install the Yandex Cloud CLI (https://yandex.cloud/en/docs/cli/operations/install-cli)',
|
|
189
|
+
},
|
|
190
|
+
config: null,
|
|
191
|
+
token: null,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (checkIgnored(cwd, CONFIG_REL).status === 'fail') {
|
|
196
|
+
return {
|
|
197
|
+
check: { status: 'fail', detail: `${CONFIG_REL} is not ignored`, next: 'ai-rules mcp setup yandex' },
|
|
198
|
+
config: null,
|
|
199
|
+
token: null,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
try {
|
|
204
|
+
const { token } = await yandex.fetchToken({ interactive: false, ycBin, noProxy: config.noProxy });
|
|
205
|
+
return {
|
|
206
|
+
check: { status: 'ok', detail: `organization ${config.orgId}, yc found` },
|
|
207
|
+
config,
|
|
208
|
+
token,
|
|
209
|
+
};
|
|
210
|
+
} catch (error) {
|
|
211
|
+
const name = error instanceof Error ? error.name : '';
|
|
212
|
+
if (name === 'YcSpawnError') {
|
|
213
|
+
return {
|
|
214
|
+
check: {
|
|
215
|
+
status: 'fail',
|
|
216
|
+
detail: 'yc not found',
|
|
217
|
+
next: 'install the Yandex Cloud CLI (https://yandex.cloud/en/docs/cli/operations/install-cli)',
|
|
218
|
+
},
|
|
219
|
+
config: null,
|
|
220
|
+
token: null,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
check: {
|
|
225
|
+
status: 'fail',
|
|
226
|
+
detail: error instanceof Error ? oneLine(error.message) : 'yc iam create-token failed',
|
|
227
|
+
next: 'ai-rules mcp refresh yandex',
|
|
228
|
+
},
|
|
229
|
+
config,
|
|
230
|
+
token: null,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
async function checkYandexUpstream(server, config, token, yandex) {
|
|
236
|
+
const url = yandex.resolveTarget(server.argv[0]);
|
|
237
|
+
try {
|
|
238
|
+
await yandex.postJsonRpc({
|
|
239
|
+
url,
|
|
240
|
+
token,
|
|
241
|
+
orgId: config.orgId,
|
|
242
|
+
protocolVersion: '2024-11-05',
|
|
243
|
+
message: {
|
|
244
|
+
jsonrpc: '2.0',
|
|
245
|
+
id: 1,
|
|
246
|
+
method: 'initialize',
|
|
247
|
+
params: {
|
|
248
|
+
protocolVersion: '2024-11-05',
|
|
249
|
+
capabilities: {},
|
|
250
|
+
clientInfo: { name: 'ai-rules-doctor', version: '1.0.0' },
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
return { status: 'ok', detail: 'POST initialize → 2xx' };
|
|
255
|
+
} catch (error) {
|
|
256
|
+
if (error instanceof Error && error.name === 'UnauthorizedError') {
|
|
257
|
+
return {
|
|
258
|
+
status: 'fail',
|
|
259
|
+
kind: 'yandex-session',
|
|
260
|
+
detail: 'POST initialize → 401',
|
|
261
|
+
next: 'ai-rules mcp refresh yandex',
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
265
|
+
if (/organization/i.test(message)) {
|
|
266
|
+
return { status: 'fail', detail: 'upstream rejected the organization id', next: 'ai-rules mcp setup yandex' };
|
|
267
|
+
}
|
|
268
|
+
return { status: 'fail', detail: oneLine(message), next: 'check NO_PROXY / network' };
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function checkRuntime(server, cwd, packageRoot, version) {
|
|
273
|
+
const statuses = [];
|
|
274
|
+
if (assertNodeFloor(process.versions.node, 20)) {
|
|
275
|
+
statuses.push({ status: 'ok', detail: `node ${process.versions.node}` });
|
|
276
|
+
} else {
|
|
277
|
+
statuses.push({ status: 'fail', detail: `node ${process.versions.node}`, next: 'install Node 20 LTS or newer' });
|
|
278
|
+
}
|
|
279
|
+
statuses.push(
|
|
280
|
+
npxResolves()
|
|
281
|
+
? { status: 'ok', detail: 'npx found' }
|
|
282
|
+
: { status: 'fail', detail: 'npx not found', next: 'install Node.js 20+ (npm/npx)' },
|
|
283
|
+
);
|
|
284
|
+
statuses.push(
|
|
285
|
+
fs.existsSync(path.join(packageRoot, server.entry))
|
|
286
|
+
? { status: 'ok', detail: server.entry }
|
|
287
|
+
: { status: 'fail', detail: `missing ${server.entry}`, next: `reinstall @bonesofspring/ai-rules@${version}` },
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
try {
|
|
291
|
+
const resolved = resolveProjectRootDetailed({ cwd });
|
|
292
|
+
const rel = path.relative(cwd, resolved.root) || '.';
|
|
293
|
+
if (resolved.source === 'cwd') {
|
|
294
|
+
statuses.push({ status: 'warn', detail: `root ${rel} (no project marker; using cwd)` });
|
|
295
|
+
} else {
|
|
296
|
+
statuses.push({
|
|
297
|
+
status: 'ok',
|
|
298
|
+
detail: `root ${rel}${resolved.source === 'env' ? ' (AI_RULES_PROJECT_ROOT)' : ''}`,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
} catch (error) {
|
|
302
|
+
statuses.push({
|
|
303
|
+
status: 'fail',
|
|
304
|
+
detail: oneLine(error instanceof Error ? error.message : String(error)),
|
|
305
|
+
next: error instanceof Error && error.next ? error.next : 'start the client from the repository root or set AI_RULES_PROJECT_ROOT',
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return { check: unwrap(statuses), ready: !statuses.some((entry) => entry.status === 'fail') };
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @returns {Promise<{ servers: object[], exitCode: 0|1|2 }>}
|
|
314
|
+
*/
|
|
315
|
+
async function runDoctor({ cwd, provider, packageRoot, version, envfile, yandex, options = {} }) {
|
|
316
|
+
const { serversFor } = require('./registry');
|
|
317
|
+
const servers = [];
|
|
318
|
+
const failures = [];
|
|
319
|
+
|
|
320
|
+
const gitlabAbs = resolveManagedPath(cwd, CREDENTIALS_REL);
|
|
321
|
+
const gitlabValues = gitlabAbs && fs.existsSync(gitlabAbs) ? envfile.readEnvFile(gitlabAbs) : {};
|
|
322
|
+
const yandexState = provider === 'gitlab'
|
|
323
|
+
? null
|
|
324
|
+
: await checkYandexCredentials(cwd, options, yandex);
|
|
325
|
+
|
|
326
|
+
for (const server of serversFor(provider)) {
|
|
327
|
+
const checks = {};
|
|
328
|
+
const nexts = [];
|
|
329
|
+
const put = (area, check) => {
|
|
330
|
+
checks[area] = { status: check.status, detail: check.detail };
|
|
331
|
+
if (check.next) {
|
|
332
|
+
nexts.push(check.next);
|
|
333
|
+
}
|
|
334
|
+
if (check.status === 'fail') {
|
|
335
|
+
failures.push({ server: server.id, area, kind: check.kind ?? 'other', next: check.next });
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
const runtime = checkRuntime(server, cwd, packageRoot, version);
|
|
340
|
+
put('runtime', runtime.check);
|
|
341
|
+
|
|
342
|
+
if (!runtime.ready) {
|
|
343
|
+
for (const area of ['registration', 'credentials', 'upstream']) {
|
|
344
|
+
checks[area] = { status: 'skipped', detail: 'runtime not ready' };
|
|
345
|
+
}
|
|
346
|
+
servers.push({
|
|
347
|
+
id: server.id,
|
|
348
|
+
checks,
|
|
349
|
+
next: nexts[0] ?? null,
|
|
350
|
+
nexts,
|
|
351
|
+
ready: false,
|
|
352
|
+
});
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
put('registration', await checkRegistration(server, cwd, version));
|
|
357
|
+
|
|
358
|
+
if (server.provider === 'gitlab') {
|
|
359
|
+
const credentials = await checkGitlabCredentials(cwd, envfile);
|
|
360
|
+
put('credentials', credentials);
|
|
361
|
+
if (credentials.status === 'fail') {
|
|
362
|
+
checks.upstream = { status: 'skipped', detail: 'credentials not ready' };
|
|
363
|
+
} else {
|
|
364
|
+
put('upstream', await checkGitlabUpstream(gitlabValues.GITLAB_URL, gitlabValues.GITLAB_TOKEN));
|
|
365
|
+
}
|
|
366
|
+
} else {
|
|
367
|
+
put('credentials', yandexState.check);
|
|
368
|
+
if (yandexState.check.status === 'fail' || !yandexState.token) {
|
|
369
|
+
checks.upstream = { status: 'skipped', detail: 'credentials not ready' };
|
|
370
|
+
} else {
|
|
371
|
+
put('upstream', await checkYandexUpstream(server, yandexState.config, yandexState.token, yandex));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
servers.push({
|
|
376
|
+
id: server.id,
|
|
377
|
+
checks: Object.fromEntries(AREAS.map((area) => [area, checks[area]])),
|
|
378
|
+
next: nexts[0] ?? null,
|
|
379
|
+
nexts,
|
|
380
|
+
ready: AREAS.every((area) => ['ok', 'warn'].includes(checks[area].status)),
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const hardFailures = failures.filter((entry) => entry.status !== 'warn');
|
|
385
|
+
const exitCode = hardFailures.length === 0
|
|
386
|
+
? 0
|
|
387
|
+
: hardFailures.every((entry) => entry.kind === 'yandex-session')
|
|
388
|
+
? 2
|
|
389
|
+
: 1;
|
|
390
|
+
|
|
391
|
+
return { servers, exitCode };
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
module.exports = { runDoctor, AREAS };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive input for `ai-rules mcp setup`.
|
|
3
|
+
*
|
|
4
|
+
* `readSecret` never echoes: a TTY uses a readline interface whose output is a
|
|
5
|
+
* muted writer, so the terminal driver receives no character; a pipe is read as
|
|
6
|
+
* one plain line. `stty` is not used (Windows parity).
|
|
7
|
+
*/
|
|
8
|
+
const readline = require('node:readline');
|
|
9
|
+
const { Writable } = require('node:stream');
|
|
10
|
+
|
|
11
|
+
let pipedReader = null;
|
|
12
|
+
let pipedClosed = false;
|
|
13
|
+
const pipedLines = [];
|
|
14
|
+
const pipedWaiters = [];
|
|
15
|
+
|
|
16
|
+
function settlePiped(line) {
|
|
17
|
+
const waiter = pipedWaiters.shift();
|
|
18
|
+
if (waiter) {
|
|
19
|
+
waiter(line);
|
|
20
|
+
} else {
|
|
21
|
+
pipedLines.push(line);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function ensurePipedReader() {
|
|
26
|
+
if (pipedReader) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
pipedReader = readline.createInterface({ input: process.stdin, terminal: false });
|
|
30
|
+
pipedReader.on('line', (line) => settlePiped(line));
|
|
31
|
+
pipedReader.on('close', () => {
|
|
32
|
+
pipedClosed = true;
|
|
33
|
+
while (pipedWaiters.length > 0) {
|
|
34
|
+
pipedWaiters.shift()('');
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** One line from a pipe; concurrent/sequential reads queue instead of competing for stdin. */
|
|
40
|
+
function readPipedLine() {
|
|
41
|
+
ensurePipedReader();
|
|
42
|
+
if (pipedLines.length > 0) {
|
|
43
|
+
return Promise.resolve(pipedLines.shift());
|
|
44
|
+
}
|
|
45
|
+
if (pipedClosed) {
|
|
46
|
+
return Promise.resolve('');
|
|
47
|
+
}
|
|
48
|
+
return new Promise((resolve) => pipedWaiters.push(resolve));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function readTtyLine(secret) {
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
const muted = new Writable({
|
|
54
|
+
write(chunk, encoding, callback) {
|
|
55
|
+
callback();
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
muted.columns = 80;
|
|
59
|
+
const rl = readline.createInterface({
|
|
60
|
+
input: process.stdin,
|
|
61
|
+
output: secret ? muted : process.stderr,
|
|
62
|
+
terminal: true,
|
|
63
|
+
});
|
|
64
|
+
let settled = false;
|
|
65
|
+
|
|
66
|
+
rl.once('line', (line) => {
|
|
67
|
+
settled = true;
|
|
68
|
+
rl.close();
|
|
69
|
+
if (secret) {
|
|
70
|
+
process.stderr.write('\n');
|
|
71
|
+
}
|
|
72
|
+
resolve(line);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
rl.once('SIGINT', () => {
|
|
76
|
+
process.stderr.write('\n');
|
|
77
|
+
rl.close();
|
|
78
|
+
resolve('');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
rl.once('close', () => {
|
|
82
|
+
if (!settled) {
|
|
83
|
+
resolve('');
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function readLine(secret) {
|
|
90
|
+
return process.stdin.isTTY ? readTtyLine(secret) : readPipedLine();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Plain prompt (non-secret); `defaultValue` is returned for an empty line. */
|
|
94
|
+
async function ask(question, { defaultValue } = {}) {
|
|
95
|
+
const suffix = defaultValue === undefined || defaultValue === '' ? '' : ` [${defaultValue}]`;
|
|
96
|
+
process.stderr.write(`${question}${suffix}: `);
|
|
97
|
+
const line = await readLine(false);
|
|
98
|
+
if (!process.stdin.isTTY) {
|
|
99
|
+
process.stderr.write('\n');
|
|
100
|
+
}
|
|
101
|
+
const value = line.trim();
|
|
102
|
+
return value === '' && defaultValue !== undefined ? defaultValue : value;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Hidden prompt for a token; the typed bytes are never echoed or logged. */
|
|
106
|
+
async function readSecret(question) {
|
|
107
|
+
process.stderr.write(`${question}: `);
|
|
108
|
+
const line = await readLine(true);
|
|
109
|
+
if (!process.stdin.isTTY) {
|
|
110
|
+
process.stderr.write('\n');
|
|
111
|
+
}
|
|
112
|
+
return line.trim();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = { ask, readSecret };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One logical MCP server registry, rendered into each client's native schema.
|
|
3
|
+
*
|
|
4
|
+
* Slugs are the `ai-rules mcp run <slug>` argument; ids are the keys the four
|
|
5
|
+
* client configs already use. Ownership lives in the entry itself — no state
|
|
6
|
+
* file — so a fresh clone can answer "which entries are ours?".
|
|
7
|
+
*/
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { isPlainObject } = require('../fs-utils');
|
|
11
|
+
|
|
12
|
+
const PACKAGE_NAME = '@bonesofspring/ai-rules';
|
|
13
|
+
const PIN_RE = /^@bonesofspring\/ai-rules@(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
14
|
+
|
|
15
|
+
const SERVERS = [
|
|
16
|
+
{ id: 'gitlab', slug: 'gitlab', provider: 'gitlab', entry: 'mcp/gitlab.mjs', argv: [] },
|
|
17
|
+
{
|
|
18
|
+
id: 'yandex tracker',
|
|
19
|
+
slug: 'yandex-tracker',
|
|
20
|
+
provider: 'yandex',
|
|
21
|
+
entry: 'mcp/yandex-mcp-proxy.mjs',
|
|
22
|
+
argv: ['tracker'],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'yandex wiki',
|
|
26
|
+
slug: 'yandex-wiki',
|
|
27
|
+
provider: 'yandex',
|
|
28
|
+
entry: 'mcp/yandex-mcp-proxy.mjs',
|
|
29
|
+
argv: ['wiki'],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const CLIENTS = [
|
|
34
|
+
{ id: 'cursor', root: '.cursor', file: '.cursor/mcp.json', key: 'mcpServers', shape: 'object' },
|
|
35
|
+
{ id: 'claude', root: '.claude', file: '.mcp.json', key: 'mcpServers', shape: 'object' },
|
|
36
|
+
{ id: 'mavis', root: '.mavis', file: '.mavis/mcp.json', key: 'mcpServers', shape: 'object' },
|
|
37
|
+
{ id: 'opencode', root: '.opencode', file: 'opencode.json', key: 'mcp', shape: 'local' },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const CLIENT_IDS = CLIENTS.map((client) => client.id);
|
|
41
|
+
|
|
42
|
+
function serversFor(provider) {
|
|
43
|
+
return provider === 'all' ? SERVERS.slice() : SERVERS.filter((server) => server.provider === provider);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function serverBySlug(slug) {
|
|
47
|
+
return SERVERS.find((server) => server.slug === slug) || null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function clientById(id) {
|
|
51
|
+
return CLIENTS.find((client) => client.id === id) || null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function argsFor(server, version) {
|
|
55
|
+
return ['-y', `${PACKAGE_NAME}@${version}`, 'mcp', 'run', server.slug];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function renderEntry(client, server, version) {
|
|
59
|
+
const args = argsFor(server, version);
|
|
60
|
+
if (client.shape === 'local') {
|
|
61
|
+
return { type: 'local', command: ['npx', ...args] };
|
|
62
|
+
}
|
|
63
|
+
return { command: 'npx', args };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Normalize the two client shapes to one argv array; null for anything else. */
|
|
67
|
+
function entryArgv(entry) {
|
|
68
|
+
if (!isPlainObject(entry)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
if (entry.type === 'local' && Array.isArray(entry.command)) {
|
|
72
|
+
return entry.command.filter((item) => typeof item === 'string');
|
|
73
|
+
}
|
|
74
|
+
if (typeof entry.command === 'string' && Array.isArray(entry.args)) {
|
|
75
|
+
return [entry.command, ...entry.args.filter((item) => typeof item === 'string')];
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The ownership proof, stored in the entry: `npx -y @bonesofspring/ai-rules@<exact> mcp run <slug>`. */
|
|
81
|
+
function ownsEntry(entry) {
|
|
82
|
+
const argv = entryArgv(entry);
|
|
83
|
+
if (!argv) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return (
|
|
87
|
+
argv[0] === 'npx'
|
|
88
|
+
&& argv[1] === '-y'
|
|
89
|
+
&& typeof argv[2] === 'string'
|
|
90
|
+
&& PIN_RE.test(argv[2])
|
|
91
|
+
&& argv[3] === 'mcp'
|
|
92
|
+
&& argv[4] === 'run'
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function registeredPin(entry) {
|
|
97
|
+
const argv = entryArgv(entry);
|
|
98
|
+
const match = argv && typeof argv[2] === 'string' ? PIN_RE.exec(argv[2]) : null;
|
|
99
|
+
return match ? match[1] : null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function registeredSlug(entry) {
|
|
103
|
+
const argv = entryArgv(entry);
|
|
104
|
+
return argv ? argv[5] ?? null : null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Migration window: the pre-pack `node scripts/*-mcp.mjs` entries. */
|
|
108
|
+
function isLegacyEntry(entry, server) {
|
|
109
|
+
const argv = entryArgv(entry);
|
|
110
|
+
if (!argv) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
const joined = argv.join(' ');
|
|
114
|
+
if (server.provider === 'gitlab') {
|
|
115
|
+
return joined.includes('gitlab-mcp.mjs');
|
|
116
|
+
}
|
|
117
|
+
return joined.includes('yandex-mcp-proxy.mjs');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const SECRET_KEY_RE = /(TOKEN|SECRET|PASSWORD|PRIVATE|AUTH)/i;
|
|
121
|
+
const SECRET_VALUE_RE = /(glpat-|PRIVATE KEY|Bearer\s+\S)/;
|
|
122
|
+
|
|
123
|
+
/** Name of a token-looking key under our id, or null. Never returns the value. */
|
|
124
|
+
function tokenFinding(entry) {
|
|
125
|
+
if (!isPlainObject(entry)) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
for (const blockName of ['env', 'headers', 'environment']) {
|
|
129
|
+
const block = entry[blockName];
|
|
130
|
+
if (!isPlainObject(block)) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
for (const [key, value] of Object.entries(block)) {
|
|
134
|
+
const stringValue = typeof value === 'string' ? value : '';
|
|
135
|
+
if (SECRET_KEY_RE.test(key) || SECRET_VALUE_RE.test(stringValue)) {
|
|
136
|
+
return `${blockName}.${key}`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** `present` = an install marker exists or the client's MCP config exists. */
|
|
144
|
+
function clientPresent(cwd, client, markers) {
|
|
145
|
+
if (fs.existsSync(path.join(cwd, client.file))) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
const markerRels = markers[client.root] || [];
|
|
149
|
+
return markerRels.some((rel) => fs.existsSync(path.join(cwd, rel)));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
module.exports = {
|
|
153
|
+
PACKAGE_NAME,
|
|
154
|
+
PIN_RE,
|
|
155
|
+
SERVERS,
|
|
156
|
+
CLIENTS,
|
|
157
|
+
CLIENT_IDS,
|
|
158
|
+
serversFor,
|
|
159
|
+
serverBySlug,
|
|
160
|
+
clientById,
|
|
161
|
+
argsFor,
|
|
162
|
+
renderEntry,
|
|
163
|
+
entryArgv,
|
|
164
|
+
ownsEntry,
|
|
165
|
+
registeredPin,
|
|
166
|
+
registeredSlug,
|
|
167
|
+
isLegacyEntry,
|
|
168
|
+
tokenFinding,
|
|
169
|
+
clientPresent,
|
|
170
|
+
};
|