@bonesofspring/ai-rules 0.2.56 → 0.2.60
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 +116 -1
- package/README.md +68 -3
- package/bin/cli.js +399 -27
- package/bin/lib/engine-scripts.js +3 -0
- package/bin/lib/mcp/catalog.js +97 -0
- package/bin/lib/mcp/clients.js +35 -2
- package/bin/lib/mcp/credentials.js +85 -1
- package/bin/lib/mcp/doctor.js +93 -17
- package/bin/lib/mcp/registry.js +10 -4
- package/bin/lib/seed-ai-local-team.js +8 -5
- package/docs/MCP-CATALOG.md +56 -0
- package/docs/MCP-SETUP.md +38 -6
- package/docs/PRESET-CONTRIBUTION.md +14 -1
- package/docs/TEAM-DB.md +34 -1
- package/docs/openapi/team-db.v1.json +17 -2
- package/mcp/github-proxy.mjs +133 -0
- package/mcp/lib/github.mjs +187 -0
- package/mcp/lib/streamable-http.mjs +185 -0
- package/mcp/lib/yandex.mjs +16 -137
- package/package.json +4 -1
- package/presets/_shared/ai-local/scripts/check-write-scope.mjs +212 -0
- package/presets/_shared/ai-local/scripts/rule-improver.mjs +674 -74
- package/presets/_shared/ai-local/scripts/run.mjs +143 -9
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +1 -0
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +6 -1
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +1 -1
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +79 -9
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +29 -6
- package/presets/_shared/core/quality/self-review-and-context-hygiene.md +3 -1
- package/presets/_shared/core/review/code-review-mr.md +10 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +163 -16
- package/presets/claude/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/claude/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/claude/android-kotlin/agents/debugger.md +1 -1
- package/presets/claude/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/claude/android-kotlin/commands/update.md +1 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/android-kotlin/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/go/agents/build-verifier.md +1 -1
- package/presets/claude/go/agents/code-reviewer.md +1 -1
- package/presets/claude/go/agents/debugger.md +1 -1
- package/presets/claude/go/agents/feature-developer.md +1 -1
- package/presets/claude/go/agents/task-analyst.md +1 -1
- package/presets/claude/go/commands/update.md +1 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/go/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/ios-swift/agents/build-verifier.md +1 -1
- package/presets/claude/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/claude/ios-swift/agents/debugger.md +1 -1
- package/presets/claude/ios-swift/agents/feature-developer.md +1 -1
- package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
- package/presets/claude/ios-swift/commands/update.md +1 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/ios-swift/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/java/agents/build-verifier.md +1 -1
- package/presets/claude/java/agents/code-reviewer.md +1 -1
- package/presets/claude/java/agents/debugger.md +1 -1
- package/presets/claude/java/agents/feature-developer.md +1 -1
- package/presets/claude/java/agents/task-analyst.md +1 -1
- package/presets/claude/java/commands/update.md +1 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/java/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/claude/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/claude/mcp-ts/commands/update.md +1 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/mcp-ts/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/mol/agents/build-verifier.md +1 -1
- package/presets/claude/mol/agents/code-reviewer.md +1 -1
- package/presets/claude/mol/agents/debugger.md +1 -1
- package/presets/claude/mol/agents/feature-developer.md +1 -1
- package/presets/claude/mol/agents/task-analyst.md +1 -1
- package/presets/claude/mol/commands/update.md +1 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/mol/rules/tooling-and-review/code-review-mr.md +10 -0
- package/presets/claude/next/agents/build-verifier.md +18 -1
- package/presets/claude/next/agents/code-reviewer.md +9 -1
- package/presets/claude/next/agents/debugger.md +1 -1
- package/presets/claude/next/agents/feature-developer.md +13 -1
- package/presets/claude/next/agents/task-analyst.md +1 -1
- package/presets/claude/next/agents/task-router.md +10 -0
- package/presets/claude/next/commands/task-continue.md +3 -1
- package/presets/claude/next/commands/update.md +1 -0
- package/presets/claude/next/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/next/rules/tooling-and-review/code-review-mr.md +12 -1
- package/presets/claude/nuxt/agents/build-verifier.md +1 -1
- package/presets/claude/nuxt/agents/code-reviewer.md +1 -1
- package/presets/claude/nuxt/agents/debugger.md +1 -1
- package/presets/claude/nuxt/agents/feature-developer.md +1 -1
- package/presets/claude/nuxt/agents/task-analyst.md +1 -1
- package/presets/claude/nuxt/commands/update.md +1 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/nuxt/rules/tooling-and-review/code-review-mr.md +10 -0
- package/presets/claude/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/claude/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/claude/php-hexagonal/agents/debugger.md +1 -1
- package/presets/claude/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/claude/php-hexagonal/commands/update.md +1 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/php-hexagonal/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/php-laravel/agents/build-verifier.md +1 -1
- package/presets/claude/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/claude/php-laravel/agents/debugger.md +1 -1
- package/presets/claude/php-laravel/agents/feature-developer.md +1 -1
- package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
- package/presets/claude/php-laravel/commands/update.md +1 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/php-laravel/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/svelte/agents/build-verifier.md +1 -1
- package/presets/claude/svelte/agents/code-reviewer.md +1 -1
- package/presets/claude/svelte/agents/debugger.md +1 -1
- package/presets/claude/svelte/agents/feature-developer.md +1 -1
- package/presets/claude/svelte/agents/task-analyst.md +1 -1
- package/presets/claude/svelte/commands/update.md +1 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +163 -16
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +29 -6
- package/presets/claude/svelte/rules/tooling-and-review/code-review-mr.md +10 -0
- package/presets/cursor/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/cursor/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/cursor/android-kotlin/agents/debugger.md +1 -1
- package/presets/cursor/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/cursor/android-kotlin/commands/update.md +1 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/android-kotlin/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/go/agents/build-verifier.md +1 -1
- package/presets/cursor/go/agents/code-reviewer.md +1 -1
- package/presets/cursor/go/agents/debugger.md +1 -1
- package/presets/cursor/go/agents/feature-developer.md +1 -1
- package/presets/cursor/go/agents/task-analyst.md +1 -1
- package/presets/cursor/go/commands/update.md +1 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/go/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/ios-swift/agents/build-verifier.md +1 -1
- package/presets/cursor/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/cursor/ios-swift/agents/debugger.md +1 -1
- package/presets/cursor/ios-swift/agents/feature-developer.md +1 -1
- package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
- package/presets/cursor/ios-swift/commands/update.md +1 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/ios-swift/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/java/agents/build-verifier.md +1 -1
- package/presets/cursor/java/agents/code-reviewer.md +1 -1
- package/presets/cursor/java/agents/debugger.md +1 -1
- package/presets/cursor/java/agents/feature-developer.md +1 -1
- package/presets/cursor/java/agents/task-analyst.md +1 -1
- package/presets/cursor/java/commands/update.md +1 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/java/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/cursor/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/cursor/mcp-ts/commands/update.md +1 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mcp-ts/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/mol/MCP.md +4 -3
- package/presets/cursor/mol/agents/build-verifier.md +1 -1
- package/presets/cursor/mol/agents/code-reviewer.md +1 -1
- package/presets/cursor/mol/agents/debugger.md +1 -1
- package/presets/cursor/mol/agents/feature-developer.md +1 -1
- package/presets/cursor/mol/agents/task-analyst.md +1 -1
- package/presets/cursor/mol/commands/update.md +1 -0
- package/presets/cursor/mol/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mol/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/next/MCP.md +4 -3
- package/presets/cursor/next/agents/README.md +2 -0
- package/presets/cursor/next/agents/build-verifier.md +18 -1
- package/presets/cursor/next/agents/code-reviewer.md +9 -1
- package/presets/cursor/next/agents/debugger.md +1 -1
- package/presets/cursor/next/agents/feature-developer.md +13 -1
- package/presets/cursor/next/agents/task-analyst.md +1 -1
- package/presets/cursor/next/agents/task-router.md +10 -0
- package/presets/cursor/next/commands/task-continue.md +3 -1
- package/presets/cursor/next/commands/update.md +1 -0
- package/presets/cursor/next/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/rules/code-review-mr.mdc +12 -1
- package/presets/cursor/next/team/fixtures/feature-l2-lite.json +27 -0
- package/presets/cursor/nuxt/agents/build-verifier.md +1 -1
- package/presets/cursor/nuxt/agents/code-reviewer.md +1 -1
- package/presets/cursor/nuxt/agents/debugger.md +1 -1
- package/presets/cursor/nuxt/agents/feature-developer.md +1 -1
- package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
- package/presets/cursor/nuxt/commands/update.md +1 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/nuxt/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/cursor/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/cursor/php-hexagonal/agents/debugger.md +1 -1
- package/presets/cursor/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/cursor/php-hexagonal/commands/update.md +1 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-hexagonal/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/php-laravel/agents/build-verifier.md +1 -1
- package/presets/cursor/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/cursor/php-laravel/agents/debugger.md +1 -1
- package/presets/cursor/php-laravel/agents/feature-developer.md +1 -1
- package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
- package/presets/cursor/php-laravel/commands/update.md +1 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-laravel/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/svelte/agents/build-verifier.md +1 -1
- package/presets/cursor/svelte/agents/code-reviewer.md +1 -1
- package/presets/cursor/svelte/agents/debugger.md +1 -1
- package/presets/cursor/svelte/agents/feature-developer.md +1 -1
- package/presets/cursor/svelte/agents/task-analyst.md +1 -1
- package/presets/cursor/svelte/commands/update.md +1 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +163 -16
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/svelte/rules/code-review-mr.mdc +10 -0
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/mavis/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/mavis/android-kotlin/agents/debugger.md +1 -1
- package/presets/mavis/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/mavis/android-kotlin/commands/update.md +1 -0
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/android-kotlin/rules/code-review-mr.md +10 -0
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/agents/build-verifier.md +1 -1
- package/presets/mavis/go/agents/code-reviewer.md +1 -1
- package/presets/mavis/go/agents/debugger.md +1 -1
- package/presets/mavis/go/agents/feature-developer.md +1 -1
- package/presets/mavis/go/agents/task-analyst.md +1 -1
- package/presets/mavis/go/commands/update.md +1 -0
- package/presets/mavis/go/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/go/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/go/rules/code-review-mr.md +10 -0
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/agents/build-verifier.md +1 -1
- package/presets/mavis/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/mavis/ios-swift/agents/debugger.md +1 -1
- package/presets/mavis/ios-swift/agents/feature-developer.md +1 -1
- package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
- package/presets/mavis/ios-swift/commands/update.md +1 -0
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/ios-swift/rules/code-review-mr.md +10 -0
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/agents/build-verifier.md +1 -1
- package/presets/mavis/java/agents/code-reviewer.md +1 -1
- package/presets/mavis/java/agents/debugger.md +1 -1
- package/presets/mavis/java/agents/feature-developer.md +1 -1
- package/presets/mavis/java/agents/task-analyst.md +1 -1
- package/presets/mavis/java/commands/update.md +1 -0
- package/presets/mavis/java/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/java/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/java/rules/code-review-mr.md +10 -0
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/mavis/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/mavis/mcp-ts/commands/update.md +1 -0
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/mcp-ts/rules/code-review-mr.md +10 -0
- package/presets/mavis/mol/MCP.md +4 -3
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/agents/build-verifier.md +1 -1
- package/presets/mavis/mol/agents/code-reviewer.md +1 -1
- package/presets/mavis/mol/agents/debugger.md +1 -1
- package/presets/mavis/mol/agents/feature-developer.md +1 -1
- package/presets/mavis/mol/agents/task-analyst.md +1 -1
- package/presets/mavis/mol/commands/update.md +1 -0
- package/presets/mavis/mol/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/mol/rules/code-review-mr.md +10 -0
- package/presets/mavis/next/MCP.md +4 -3
- package/presets/mavis/next/adapter-map.json +9 -1
- package/presets/mavis/next/agents/build-verifier.md +18 -1
- package/presets/mavis/next/agents/code-reviewer.md +9 -1
- package/presets/mavis/next/agents/debugger.md +1 -1
- package/presets/mavis/next/agents/feature-developer.md +13 -1
- package/presets/mavis/next/agents/task-analyst.md +1 -1
- package/presets/mavis/next/agents/task-router.md +10 -0
- package/presets/mavis/next/commands/task-continue.md +3 -1
- package/presets/mavis/next/commands/update.md +1 -0
- package/presets/mavis/next/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/next/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/next/rules/code-review-mr.md +12 -1
- package/presets/mavis/next/team/fixtures/feature-l2-lite.json +27 -0
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/agents/build-verifier.md +1 -1
- package/presets/mavis/nuxt/agents/code-reviewer.md +1 -1
- package/presets/mavis/nuxt/agents/debugger.md +1 -1
- package/presets/mavis/nuxt/agents/feature-developer.md +1 -1
- package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
- package/presets/mavis/nuxt/commands/update.md +1 -0
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/nuxt/rules/code-review-mr.md +10 -0
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/mavis/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/debugger.md +1 -1
- package/presets/mavis/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/mavis/php-hexagonal/commands/update.md +1 -0
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/php-hexagonal/rules/code-review-mr.md +10 -0
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/agents/build-verifier.md +1 -1
- package/presets/mavis/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-laravel/agents/debugger.md +1 -1
- package/presets/mavis/php-laravel/agents/feature-developer.md +1 -1
- package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
- package/presets/mavis/php-laravel/commands/update.md +1 -0
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/php-laravel/rules/code-review-mr.md +10 -0
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/agents/build-verifier.md +1 -1
- package/presets/mavis/svelte/agents/code-reviewer.md +1 -1
- package/presets/mavis/svelte/agents/debugger.md +1 -1
- package/presets/mavis/svelte/agents/feature-developer.md +1 -1
- package/presets/mavis/svelte/agents/task-analyst.md +1 -1
- package/presets/mavis/svelte/commands/update.md +1 -0
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +163 -16
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +29 -6
- package/presets/mavis/svelte/rules/code-review-mr.md +10 -0
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/opencode/android-kotlin/agents/debugger.md +1 -1
- package/presets/opencode/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/opencode/android-kotlin/commands/update.md +1 -0
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/android-kotlin/rules/code-review-mr.md +10 -0
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/agents/build-verifier.md +1 -1
- package/presets/opencode/go/agents/code-reviewer.md +1 -1
- package/presets/opencode/go/agents/debugger.md +1 -1
- package/presets/opencode/go/agents/feature-developer.md +1 -1
- package/presets/opencode/go/agents/task-analyst.md +1 -1
- package/presets/opencode/go/commands/update.md +1 -0
- package/presets/opencode/go/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/go/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/go/rules/code-review-mr.md +10 -0
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/opencode/ios-swift/agents/debugger.md +1 -1
- package/presets/opencode/ios-swift/agents/feature-developer.md +1 -1
- package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/opencode/ios-swift/commands/update.md +1 -0
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/ios-swift/rules/code-review-mr.md +10 -0
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/agents/build-verifier.md +1 -1
- package/presets/opencode/java/agents/code-reviewer.md +1 -1
- package/presets/opencode/java/agents/debugger.md +1 -1
- package/presets/opencode/java/agents/feature-developer.md +1 -1
- package/presets/opencode/java/agents/task-analyst.md +1 -1
- package/presets/opencode/java/commands/update.md +1 -0
- package/presets/opencode/java/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/java/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/java/rules/code-review-mr.md +10 -0
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/opencode/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/opencode/mcp-ts/commands/update.md +1 -0
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/mcp-ts/rules/code-review-mr.md +10 -0
- package/presets/opencode/mol/MCP.md +4 -3
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/agents/build-verifier.md +1 -1
- package/presets/opencode/mol/agents/code-reviewer.md +1 -1
- package/presets/opencode/mol/agents/debugger.md +1 -1
- package/presets/opencode/mol/agents/feature-developer.md +1 -1
- package/presets/opencode/mol/agents/task-analyst.md +1 -1
- package/presets/opencode/mol/commands/update.md +1 -0
- package/presets/opencode/mol/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/mol/rules/code-review-mr.md +10 -0
- package/presets/opencode/next/MCP.md +4 -3
- package/presets/opencode/next/adapter-map.json +9 -1
- package/presets/opencode/next/agents/build-verifier.md +18 -1
- package/presets/opencode/next/agents/code-reviewer.md +9 -1
- package/presets/opencode/next/agents/debugger.md +1 -1
- package/presets/opencode/next/agents/feature-developer.md +13 -1
- package/presets/opencode/next/agents/task-analyst.md +1 -1
- package/presets/opencode/next/agents/task-router.md +10 -0
- package/presets/opencode/next/commands/task-continue.md +3 -1
- package/presets/opencode/next/commands/update.md +1 -0
- package/presets/opencode/next/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/next/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/next/rules/code-review-mr.md +12 -1
- package/presets/opencode/next/team/fixtures/feature-l2-lite.json +27 -0
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/agents/build-verifier.md +1 -1
- package/presets/opencode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/opencode/nuxt/agents/debugger.md +1 -1
- package/presets/opencode/nuxt/agents/feature-developer.md +1 -1
- package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
- package/presets/opencode/nuxt/commands/update.md +1 -0
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/nuxt/rules/code-review-mr.md +10 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/debugger.md +1 -1
- package/presets/opencode/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/opencode/php-hexagonal/commands/update.md +1 -0
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/php-hexagonal/rules/code-review-mr.md +10 -0
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-laravel/agents/debugger.md +1 -1
- package/presets/opencode/php-laravel/agents/feature-developer.md +1 -1
- package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/opencode/php-laravel/commands/update.md +1 -0
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/php-laravel/rules/code-review-mr.md +10 -0
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/agents/build-verifier.md +1 -1
- package/presets/opencode/svelte/agents/code-reviewer.md +1 -1
- package/presets/opencode/svelte/agents/debugger.md +1 -1
- package/presets/opencode/svelte/agents/feature-developer.md +1 -1
- package/presets/opencode/svelte/agents/task-analyst.md +1 -1
- package/presets/opencode/svelte/commands/update.md +1 -0
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +163 -16
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +29 -6
- package/presets/opencode/svelte/rules/code-review-mr.md +10 -0
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/zcode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/zcode/android-kotlin/agents/debugger.md +1 -1
- package/presets/zcode/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/zcode/android-kotlin/commands/update.md +1 -0
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/android-kotlin/rules/code-review-mr.md +10 -0
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/agents/build-verifier.md +1 -1
- package/presets/zcode/go/agents/code-reviewer.md +1 -1
- package/presets/zcode/go/agents/debugger.md +1 -1
- package/presets/zcode/go/agents/feature-developer.md +1 -1
- package/presets/zcode/go/agents/task-analyst.md +1 -1
- package/presets/zcode/go/commands/update.md +1 -0
- package/presets/zcode/go/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/go/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/go/rules/code-review-mr.md +10 -0
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/zcode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/zcode/ios-swift/agents/debugger.md +1 -1
- package/presets/zcode/ios-swift/agents/feature-developer.md +1 -1
- package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/zcode/ios-swift/commands/update.md +1 -0
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/ios-swift/rules/code-review-mr.md +10 -0
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/agents/build-verifier.md +1 -1
- package/presets/zcode/java/agents/code-reviewer.md +1 -1
- package/presets/zcode/java/agents/debugger.md +1 -1
- package/presets/zcode/java/agents/feature-developer.md +1 -1
- package/presets/zcode/java/agents/task-analyst.md +1 -1
- package/presets/zcode/java/commands/update.md +1 -0
- package/presets/zcode/java/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/java/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/java/rules/code-review-mr.md +10 -0
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/zcode/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/zcode/mcp-ts/commands/update.md +1 -0
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/mcp-ts/rules/code-review-mr.md +10 -0
- package/presets/zcode/mol/MCP.md +4 -3
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/agents/build-verifier.md +1 -1
- package/presets/zcode/mol/agents/code-reviewer.md +1 -1
- package/presets/zcode/mol/agents/debugger.md +1 -1
- package/presets/zcode/mol/agents/feature-developer.md +1 -1
- package/presets/zcode/mol/agents/task-analyst.md +1 -1
- package/presets/zcode/mol/commands/update.md +1 -0
- package/presets/zcode/mol/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/mol/rules/code-review-mr.md +10 -0
- package/presets/zcode/next/MCP.md +4 -3
- package/presets/zcode/next/adapter-map.json +9 -1
- package/presets/zcode/next/agents/build-verifier.md +18 -1
- package/presets/zcode/next/agents/code-reviewer.md +9 -1
- package/presets/zcode/next/agents/debugger.md +1 -1
- package/presets/zcode/next/agents/feature-developer.md +13 -1
- package/presets/zcode/next/agents/task-analyst.md +1 -1
- package/presets/zcode/next/agents/task-router.md +10 -0
- package/presets/zcode/next/commands/task-continue.md +3 -1
- package/presets/zcode/next/commands/update.md +1 -0
- package/presets/zcode/next/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/next/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/next/rules/code-review-mr.md +12 -1
- package/presets/zcode/next/team/fixtures/feature-l2-lite.json +27 -0
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/agents/build-verifier.md +1 -1
- package/presets/zcode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/zcode/nuxt/agents/debugger.md +1 -1
- package/presets/zcode/nuxt/agents/feature-developer.md +1 -1
- package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
- package/presets/zcode/nuxt/commands/update.md +1 -0
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/nuxt/rules/code-review-mr.md +10 -0
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/zcode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/zcode/php-hexagonal/agents/debugger.md +1 -1
- package/presets/zcode/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/zcode/php-hexagonal/commands/update.md +1 -0
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/php-hexagonal/rules/code-review-mr.md +10 -0
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/zcode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/zcode/php-laravel/agents/debugger.md +1 -1
- package/presets/zcode/php-laravel/agents/feature-developer.md +1 -1
- package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/zcode/php-laravel/commands/update.md +1 -0
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/php-laravel/rules/code-review-mr.md +10 -0
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/agents/build-verifier.md +1 -1
- package/presets/zcode/svelte/agents/code-reviewer.md +1 -1
- package/presets/zcode/svelte/agents/debugger.md +1 -1
- package/presets/zcode/svelte/agents/feature-developer.md +1 -1
- package/presets/zcode/svelte/agents/task-analyst.md +1 -1
- package/presets/zcode/svelte/commands/update.md +1 -0
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +163 -16
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +29 -6
- package/presets/zcode/svelte/rules/code-review-mr.md +10 -0
|
@@ -413,13 +413,14 @@ Load these when editing files under `packages/ai-rules/presets/**`, `.cursor/**`
|
|
|
413
413
|
| `scripts/check-preset-twin-drift.mjs` / `yarn check:preset-twin-drift` | **FAIL** when a hand-maintained Claude twin (`presets/claude/<stack>/{commands,skills}/**/*.md`) drifts further from its Cursor source than `scripts/_lib/claude-twin-drift-baseline.json` records, when the recorded divergence between the twins changes while the line delta does not, when a command/skill has no twin on the other side, when a new pair has no baseline row, when a baseline row has no live pair, or when the baseline itself is missing its hash rows. Full parity is not required: mirror a change in both twins (delta and divergence unchanged) or record a deliberate divergence with `--update`. Raising an allowance needs `--update --widen`; dropping a row needs `--update --prune`. Fixture `test-preset-twin-drift.mjs`. |
|
|
414
414
|
| `scripts/check-claude-agent-parity.mjs` / `yarn check:claude-agent-parity` | **FAIL** when a hand-maintained Claude `agents/*.md` twin drifts from its Cursor source beyond `scripts/_lib/claude-agent-parity-baseline.json`: a grown or shrunk normalized line delta, a one-sided rewrite at an unchanged delta, a changed divergence hash, a missing twin, an unrecorded pair, an orphan row, or a pair in the static `parity` allowlist that is not at delta 0. Normalization masks packaging only — YAML frontmatter, the `## Rules to load (subagent context)` block, `<!-- shared-core -->` markers, the two anti-hallucination load lines, the `.cursor/` / `.claude/` root, and `.mdc` → `.md` — and reuses the twin-drift diff helpers. `--update` re-records deltas and hashes; `--widen` / `--prune` gate a raised allowance or a dropped row; `parity` is never edited by `--update`. Fixture `test-claude-agent-parity.mjs` proves one-sided Claude FAIL, one-sided Cursor FAIL and mirrored PASS. Wired into `check-preset-structure.sh` next to `claude-agent-blocks`. |
|
|
415
415
|
| `scripts/check-consumer-links.mjs` / `yarn check:consumer-links` | **FAIL** when a generated Claude rule or agent carries a source-only `.cursor/` path or a `.mdc` reference whose stem resolves through `claude/<stack>/rules/README.md`; `README.md` and `preset-*.md` are exempt by class. `scripts/_lib/claude-consumer-link-allowlist.json` records the legitimate lines one hash at a time; a stale row fails, and a planted line in an allowlisted file still fails unless it matches the recorded hash. `--update` re-hashes recorded rows only and refuses to add one. Scans `next` by default; `--stack` opts another stack in. Fixture `test-consumer-links.mjs`. Wired into `check-preset-structure.sh` next to `generated-drift`. |
|
|
416
|
-
| `scripts/check-preset-token-budget.sh` / `yarn check:preset-token-budget` | **FAIL** if Cursor `alwaysApply: true` or Claude no-`paths:` (excl. README) count is outside **3–10**, `preset-*` always-on, or intended body sum > **4000**. Stacks include `nuxt`, `svelte`. |
|
|
416
|
+
| `scripts/check-preset-token-budget.sh` / `yarn check:preset-token-budget` | **FAIL** if Cursor `alwaysApply: true` or Claude no-`paths:` (excl. README) count is outside **3–10**, `preset-*` always-on, or intended body sum > **4000**. Stacks include `nuxt`, `svelte`. CI also compares the baseline to the base revision (`--base`); a widening needs `--update --widen`. |
|
|
417
417
|
| `scripts/check-preset-leakage.sh` / `yarn check:preset-leakage` | **FAIL** on forbidden stems in `hooks/**/*.sh` (recursive), wrong-stack agent filenames, or **positive** (non-negation) agent body mentions; **FAIL** if chain scripts are byte-identical across stacks. Explicit **negation** of forbidden stems in agent bodies is **suppressed** (INFO summary count only — not a merge blocker). Non-negation mentions in `build-verifier` → **WARN only**. |
|
|
418
418
|
| `scripts/check-preset-prompt-persistence.sh` / `yarn check:preset-structure` | **FAIL** if the prompt-persistence contract (`prompt.md` + the append-only `prompt-log.md` ledger, both on the `routing` entry) is missing from any platform × stack command (`task.md` + `task-continue.md`), orchestrator, or intake body, from the **always-on** root `REPO_AGENTS.md` entry (check **E** — reachability without `/task`), or a core `agent-artifact-contracts` anchor (`## Prompt artifact` / `## Prompt log`) is gone; **refuses vacuous PASS** when the iteration set is empty. Wired into `check-preset-structure.sh` next to `goal-contract`; fixture `test-preset-prompt-persistence-fixtures.mjs`. |
|
|
419
419
|
| `scripts/check-preset-reachability.sh` / `yarn check:preset-reachability` | **FAIL** if a non-`preset-*` OpenCode/Mavis rule is reachable by neither a direct reference (entry / agent / command / skill) nor the transitive closure of rule→rule references from the `root-entry` rules. `preset-*` meta rules are exempt as preset-authoring-only. **Refuses vacuous PASS** on an empty iteration set. Wired into `check-preset-structure.sh` next to `prompt-persistence`. |
|
|
420
420
|
| `scripts/check-preset-language-policy.sh` / `yarn check:preset-structure` | **FAIL** if the native-language policy is absent: the core `_shared/core/agent-team/language-policy.md` tokens, the `language-policy` consumer + `<!-- shared-core -->` marker, the Cursor `globs:`/`alwaysApply: false` + Claude `paths:` shape, the `## Language` setting home (with a BCP-47 marker) in `ai-local/conventions.md`, the always-on anchors (`ai-local-overlay` + `<app-core>` + `REPO_AGENTS.md` must contain `native language` and `every user message`), or the `language:` persistence token in `commands/task.md`; **refuses vacuous PASS** when the iteration set is empty. Wired into `check-preset-structure.sh` next to `goal-contract` / `prompt-persistence`; fixture `test-preset-language-policy-fixtures.mjs`. |
|
|
421
421
|
| `scripts/check-preset-self-review-contract.sh` / `yarn check:preset-structure` | **FAIL** if the producer-side self-review / context-hygiene contract is absent: the core `_shared/core/quality/self-review-and-context-hygiene.md` tokens (G0 non-vacuous guard), the `<!-- shared-core: quality/self-review-and-context-hygiene.md -->` marker on `task-analyst` / `feature-developer` / `build-verifier` (×10) and on `debugger` / `code-reviewer` where present (skip-if-absent → `mcp-ts`), the `Self-review` + `re-anchor` tokens on every orchestrator rule, `Self-review` in `team/README.md` + `commands/task.md`, and leakage-free core + docs; **refuses vacuous PASS** when the iteration set is empty. Also holds two prose contracts: the canonical self-learning-loop sentence must not be followed by unsanctioned prose (an allowlist of sanctioned clauses; the tail is bounded by the carrier's **section**, not by a blank line, so prose moved one paragraph down still fails — a tail in a later `## ` section is out of scope), and every retro carrier (command, skill, rule) must state `finding_category`. Wired into `check-preset-structure.sh` next to `goal-contract`; fixture `test-preset-self-review-contract-fixtures.mjs`. |
|
|
422
422
|
| `scripts/check-anti-hallucination-coverage.mjs` | **FAIL** when the shared contract, a Cursor load-line embed, a writer stack floor, or a generated Rules-to-load stem is missing. Writer roles are `implementer`, `unit-test`, `e2e`, `qa`, and `reviewer` (`code-reviewer` loads `STACK_FLOOR_STEMS` plus the contract). `/task` and the orchestrator must not name a floor stem. Does not scan consumer `app/**` and does not call Context7. Fixture `test-anti-hallucination-coverage.mjs` deletes `anti-hallucination-contract` from `next.reviewer` in memory and expects FAIL mentioning `next` and `reviewer`. Wired into `check-preset-structure.sh` immediately after `check-claude-agent-blocks.mjs`. |
|
|
423
|
+
| `presets/_shared/ai-local/scripts/check-write-scope.mjs` | Read-only post-step audit: compares the actual changed paths with the current `pipeline.json` step's `writeScopes` and labels each path `declared`, `derived` (task folder, engine mirror, generated platform tree/golden/hook, dogfood tree, adapter map), or `out-of-scope`, with the source named. Shipped to consumers as `.ai.local/scripts/check-write-scope.mjs` (`ENGINE_SCRIPTS`). `--slug <slug> [--step <id>] [--base <ref>] [--root <project>] [--paths a,b] [--json]`. The baseline defaults to `HEAD` (uncommitted change-set, untracked included); pass `--base` for a committed change-set. Exit `1` for an out-of-scope path on an implementation step, `0` for a reviewer/verifier step (advisory), `2` on a usage/config error. Fixture `test-write-scope.mjs`; wired into the build-verifier and code-reviewer prompts, never a hook. |
|
|
423
424
|
| `scripts/check-preset-structure.sh` / `yarn check:preset-structure` | Orchestrator: twin-map + token-budget + leakage + shared-core drift + anti-hallucination coverage + rule-eval (**all hard**; drift via `AI_RULES_DRIFT_FAIL=1`). |
|
|
424
425
|
| `scripts/check-product-specs.sh` / `yarn check:product-specs` | Opt-in consumer tree check: frontmatter v1 keys + required body headings on `docs/specs/**` (bash; does **not** run JSON Schema). Ships in the npm package `files` (`scripts/`). **WARN** by default; **`--strict`** exits non-zero. |
|
|
425
426
|
| `yarn check:product-specs:dogfood` | Same script against monorepo `dogfood/mcp-ts-sample`. Soft WARN inside `check:preset-structure` + CI step (`continue-on-error`); not a hard consumer CI gate. |
|
|
@@ -466,6 +467,18 @@ Skills are behavior-shaping, not essays. When adding or editing `skills/**/SKILL
|
|
|
466
467
|
|
|
467
468
|
Author-only: this section is **not** copied by `init`.
|
|
468
469
|
|
|
470
|
+
### Advisory tier (rule authoring)
|
|
471
|
+
|
|
472
|
+
`scripts/check-preset-authoring-advisory.mjs` is the third tier: it reports, it never blocks.
|
|
473
|
+
|
|
474
|
+
- Expect four finding classes: `restated-stem`, `paraphrased-when-do`, `unjustified-body-size`, `issue-number-density`.
|
|
475
|
+
- Expect one line per finding and a final `advisory-findings: <n>`; the checker always exits `0`.
|
|
476
|
+
- Read a finding as a review item, never as a gate failure.
|
|
477
|
+
- Run it through `check:preset-structure`: the `authoring-advisory` row is non-blocking (`<<< authoring-advisory: WARN (<n> finding(s); not a hard gate)`), so `check:all` stays green with findings present.
|
|
478
|
+
- Read the per-rule body threshold (`advisoryPerRuleBodyCap`) from `scripts/_lib/preset-token-budget-baseline.json` — the same baseline the blocking token-budget gate reads. The advisory tier holds no cap literal of its own; the threshold is advisory metadata, not one of the five ratcheted hard caps.
|
|
479
|
+
- Fix a `restated-stem` finding by linking the sibling stem instead of repeating its sentence.
|
|
480
|
+
- Keep the tier out of the pipeline hook tree: it is a repository gate, not a hook.
|
|
481
|
+
|
|
469
482
|
### B1–B5 stems (all stacks)
|
|
470
483
|
|
|
471
484
|
| Stem | Drift mode | Why | Consumers |
|
package/docs/TEAM-DB.md
CHANGED
|
@@ -157,13 +157,44 @@ and sets `content_omitted=size` (binary content sets `binary`). Raw content olde
|
|
|
157
157
|
days on an absent task is nulled only by `sync --maintain`; `sync --vacuum` checkpoints WAL and
|
|
158
158
|
runs `VACUUM`. The `sync_runs` table keeps the newest 200 runs.
|
|
159
159
|
|
|
160
|
+
### FTS shape registry
|
|
161
|
+
|
|
162
|
+
`team-db-schema.mjs` enumerates the released search layouts in `FTS_SHAPES`, oldest-first, with the current shape
|
|
163
|
+
last. One shape is released today: `fts5-v1` — columns `task_slug UNINDEXED`, `doc_path UNINDEXED`, `kind
|
|
164
|
+
UNINDEXED`, `body`, tokenizer `unicode61 remove_diacritics 2`. `CURRENT_FTS_SHAPE` is the last entry; append the next
|
|
165
|
+
layout, never edit a released one in place.
|
|
166
|
+
|
|
167
|
+
The shape identity is recorded in `schema_meta` under the key `search_fts_shape`, next to the `search` mode row. The
|
|
168
|
+
token is written **only when the search table is created**: a database that predates the registry keeps an absent
|
|
169
|
+
token and keeps being reported.
|
|
170
|
+
|
|
171
|
+
`detectFtsShapeDrift(db)` returns one of five states:
|
|
172
|
+
|
|
173
|
+
| State | Meaning |
|
|
174
|
+
|---|---|
|
|
175
|
+
| `absent` | no `search_fts` table — the runtime stayed on the `LIKE` path |
|
|
176
|
+
| `current` | the recorded token is the current shape and the installed columns match it |
|
|
177
|
+
| `unrecorded` | the table exists and no `search_fts_shape` row does — a pre-registry database |
|
|
178
|
+
| `superseded` | the recorded token names a released, older shape |
|
|
179
|
+
| `unknown` | the token names no released shape, or the installed columns differ from the recorded shape |
|
|
180
|
+
|
|
181
|
+
Drift is **reported, never repaired**: the live table is never dropped, altered, or rebuilt, the database stays
|
|
182
|
+
readable, and the existing rebuild path (`team-db.mjs sync --rebuild`) stays the remedy. `team-db.mjs check` names a
|
|
183
|
+
drifted state in its `search-shape <state>` field.
|
|
184
|
+
|
|
185
|
+
The registry is not a migration chain: `MIGRATIONS` and `SCHEMA_VERSION` are unchanged, `E_SCHEMA_NEWER` still fails
|
|
186
|
+
closed, and FTS5 stays a **runtime capability** — a runtime without FTS5 records `like` in `schema_meta`, so the
|
|
187
|
+
registry never turns FTS5 into a hard schema dependency.
|
|
188
|
+
|
|
160
189
|
## Dashboard and API
|
|
161
190
|
|
|
162
191
|
`team-db.mjs serve` prints one line with the bound URL (default
|
|
163
192
|
`http://127.0.0.1:4178`). The dashboard is a single no-build HTML document at `/`, its CSS and
|
|
164
193
|
JS are served from `/assets/`, and the OpenAPI 3.1 document is at `/openapi.json`. The frozen
|
|
165
194
|
document is checked in at `packages/ai-rules/docs/openapi/team-db.v1.json`; the gate is
|
|
166
|
-
`node scripts/check-team-db-contract.mjs`.
|
|
195
|
+
`node scripts/check-team-db-contract.mjs`. The server loads its modules at start: restart
|
|
196
|
+
`serve` after an update to take a new route or method set — a stale process keeps answering
|
|
197
|
+
the old surface (for example, `405` on a route the new code serves).
|
|
167
198
|
|
|
168
199
|
The API exposes the delete as `DELETE /api/v1/tasks/{slug}` — the same canonical deletion
|
|
169
200
|
as the CLI, executed as one bounded child. It answers `200` with `{"slug":"<S>"}` on
|
|
@@ -180,6 +211,8 @@ Security boundary: loopback bind by default (`--host` outside loopback needs
|
|
|
180
211
|
`--allow-remote`, and a wildcard address is refused), exact `Host`/`Origin` allow-list,
|
|
181
212
|
no `Access-Control-*` header, hardened response headers, request bodies bounded at 1 KiB,
|
|
182
213
|
document chunks at 1 MiB, exports at 5 MiB, parameterized SQL only, and no outbound call.
|
|
214
|
+
`--allow-remote` also exposes the confirmed delete and the rescan to the named interface
|
|
215
|
+
without authentication.
|
|
183
216
|
|
|
184
217
|
## Privacy and retention
|
|
185
218
|
|
|
@@ -4782,13 +4782,24 @@
|
|
|
4782
4782
|
"string",
|
|
4783
4783
|
"null"
|
|
4784
4784
|
]
|
|
4785
|
+
},
|
|
4786
|
+
"capabilities": {
|
|
4787
|
+
"type": "array",
|
|
4788
|
+
"items": {
|
|
4789
|
+
"type": "string",
|
|
4790
|
+
"enum": [
|
|
4791
|
+
"sync",
|
|
4792
|
+
"delete"
|
|
4793
|
+
]
|
|
4794
|
+
}
|
|
4785
4795
|
}
|
|
4786
4796
|
},
|
|
4787
4797
|
"required": [
|
|
4788
4798
|
"status",
|
|
4789
4799
|
"db",
|
|
4790
4800
|
"tasks",
|
|
4791
|
-
"projectedAt"
|
|
4801
|
+
"projectedAt",
|
|
4802
|
+
"capabilities"
|
|
4792
4803
|
],
|
|
4793
4804
|
"examples": [
|
|
4794
4805
|
{
|
|
@@ -4804,7 +4815,11 @@
|
|
|
4804
4815
|
"total": 90,
|
|
4805
4816
|
"absent": 0
|
|
4806
4817
|
},
|
|
4807
|
-
"projectedAt": "2026-11-06T08:00:04.000Z"
|
|
4818
|
+
"projectedAt": "2026-11-06T08:00:04.000Z",
|
|
4819
|
+
"capabilities": [
|
|
4820
|
+
"sync",
|
|
4821
|
+
"delete"
|
|
4822
|
+
]
|
|
4808
4823
|
}
|
|
4809
4824
|
]
|
|
4810
4825
|
},
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* GitHub MCP server (stdio JSON-RPC 2.0 ↔ streamable HTTP).
|
|
4
|
+
*
|
|
5
|
+
* The client starts this through `npx -y @bonesofspring/ai-rules@<version> mcp
|
|
6
|
+
* run github`. It forwards every JSON-RPC message to the official remote GitHub
|
|
7
|
+
* MCP server with the token from `.env.github` (or the shell), so no token ever
|
|
8
|
+
* reaches a client config or an argv.
|
|
9
|
+
*/
|
|
10
|
+
import { createInterface } from 'node:readline';
|
|
11
|
+
import run from '../bin/lib/mcp/run.js';
|
|
12
|
+
import { ConfigError } from './lib/envfile.mjs';
|
|
13
|
+
import { loadGitHubConfig, printEnv } from './lib/github.mjs';
|
|
14
|
+
import { HttpStatusError, TransportError, postStreamable } from './lib/streamable-http.mjs';
|
|
15
|
+
|
|
16
|
+
const { resolveProjectRoot } = run;
|
|
17
|
+
|
|
18
|
+
let config;
|
|
19
|
+
let sessionId;
|
|
20
|
+
let protocolVersion;
|
|
21
|
+
|
|
22
|
+
function write(message) {
|
|
23
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function fail(id, code, message) {
|
|
27
|
+
write({ jsonrpc: '2.0', id, error: { code, message } });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function relay(message) {
|
|
31
|
+
const isInitialize = message.method === 'initialize';
|
|
32
|
+
|
|
33
|
+
const result = await postStreamable({
|
|
34
|
+
url: config.mcpUrl,
|
|
35
|
+
headers: { Authorization: `Bearer ${config.token}` },
|
|
36
|
+
sessionId,
|
|
37
|
+
protocolVersion: isInitialize ? undefined : protocolVersion,
|
|
38
|
+
message,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (result.sessionId) {
|
|
42
|
+
sessionId = result.sessionId;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (isInitialize) {
|
|
46
|
+
const negotiated = result.messages.find((entry) => entry && entry.result)?.result?.protocolVersion;
|
|
47
|
+
protocolVersion = typeof negotiated === 'string' ? negotiated : undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return result.messages;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function handle(message) {
|
|
54
|
+
const { id, method } = message;
|
|
55
|
+
|
|
56
|
+
if (method === undefined) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const messages = await relay(message);
|
|
62
|
+
|
|
63
|
+
if (id === undefined) {
|
|
64
|
+
return; // notification — no response expected
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
for (const emitted of messages) {
|
|
68
|
+
write(emitted);
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (id === undefined) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (error instanceof HttpStatusError) {
|
|
76
|
+
fail(id, -32603, `GitHub MCP server → HTTP ${error.status}`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (error instanceof TransportError) {
|
|
81
|
+
fail(id, -32603, `GitHub MCP server is unreachable: ${error.reason}`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
fail(id, -32603, error instanceof Error ? error.message : String(error));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function main() {
|
|
90
|
+
config = loadGitHubConfig({ root: resolveProjectRoot() });
|
|
91
|
+
|
|
92
|
+
if (process.argv.includes('--print-env')) {
|
|
93
|
+
printEnv(config);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const reader = createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
98
|
+
let chain = Promise.resolve();
|
|
99
|
+
|
|
100
|
+
reader.on('line', (line) => {
|
|
101
|
+
const trimmed = line.trim();
|
|
102
|
+
|
|
103
|
+
if (!trimmed) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let message;
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
message = JSON.parse(trimmed);
|
|
111
|
+
} catch {
|
|
112
|
+
fail(null, -32700, 'Parse error');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
chain = chain.then(() => handle(message)).catch(() => undefined);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
reader.on('close', () => {
|
|
120
|
+
chain.then(() => process.exit(0));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
main();
|
|
126
|
+
} catch (error) {
|
|
127
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
128
|
+
process.stderr.write(`${message}\n`);
|
|
129
|
+
if (error instanceof ConfigError) {
|
|
130
|
+
process.stderr.write('next: add GITHUB_TOKEN to .env.github and reconnect the MCP server\n');
|
|
131
|
+
}
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub MCP support: the official remote GitHub MCP server over streamable HTTP.
|
|
3
|
+
*
|
|
4
|
+
* The package never writes a GitHub token. The token is read from the shell
|
|
5
|
+
* environment or from the project's `.env.github` (`GITHUB_TOKEN` /
|
|
6
|
+
* `GITHUB_PERSONAL_ACCESS_TOKEN`). Both endpoints are overridable
|
|
7
|
+
* (`GITHUB_MCP_URL`, `GITHUB_API_URL`) so a stub or an enterprise relay can
|
|
8
|
+
* be used instead of the public endpoints.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import run from '../../bin/lib/mcp/run.js';
|
|
13
|
+
import { ConfigError, readEnvFile } from './envfile.mjs';
|
|
14
|
+
import { HttpStatusError, TransportError, postStreamable } from './streamable-http.mjs';
|
|
15
|
+
|
|
16
|
+
const { resolveProjectRoot } = run;
|
|
17
|
+
|
|
18
|
+
export const CREDENTIALS_FILE = '.env.github';
|
|
19
|
+
export const DEFAULT_MCP_URL = 'https://api.githubcopilot.com/mcp/';
|
|
20
|
+
export const DEFAULT_API_URL = 'https://api.github.com';
|
|
21
|
+
|
|
22
|
+
const TOKEN_KEYS = ['GITHUB_TOKEN', 'GITHUB_PERSONAL_ACCESS_TOKEN'];
|
|
23
|
+
const MCP_URL_KEY = 'GITHUB_MCP_URL';
|
|
24
|
+
const API_URL_KEY = 'GITHUB_API_URL';
|
|
25
|
+
|
|
26
|
+
/** The shell environment wins over the file; the first key wins inside each. */
|
|
27
|
+
function firstToken(env, fileValues) {
|
|
28
|
+
for (const key of TOKEN_KEYS) {
|
|
29
|
+
const value = env[key];
|
|
30
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
31
|
+
return { value: value.trim(), key, origin: 'the environment' };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const key of TOKEN_KEYS) {
|
|
35
|
+
const value = fileValues[key];
|
|
36
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
37
|
+
return { value: value.trim(), key, origin: CREDENTIALS_FILE };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function firstUrl(env, fileValues, key, fallback) {
|
|
44
|
+
for (const source of [env[key], fileValues[key]]) {
|
|
45
|
+
if (typeof source === 'string' && source.trim() !== '') {
|
|
46
|
+
return source.trim();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return fallback;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Resolve the GitHub MCP configuration for a project.
|
|
54
|
+
*
|
|
55
|
+
* @param {object} [options]
|
|
56
|
+
* @param {NodeJS.ProcessEnv} [options.env]
|
|
57
|
+
* @param {string} [options.root] Project root; the credentials file is read there.
|
|
58
|
+
* @returns {{ token: string | null, tokenKey: string | null, tokenOrigin: string | null, credentialsPath: string, hasCredentialsFile: boolean, fileHasToken: boolean, mcpUrl: string, apiUrl: string }}
|
|
59
|
+
*/
|
|
60
|
+
export function resolveGithubConfig({ env = process.env, root = resolveProjectRoot() } = {}) {
|
|
61
|
+
const credentialsPath = join(root, CREDENTIALS_FILE);
|
|
62
|
+
const fileValues = readEnvFile(credentialsPath);
|
|
63
|
+
const token = firstToken(env, fileValues);
|
|
64
|
+
const fileToken = firstToken({}, fileValues);
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
token: token?.value ?? null,
|
|
68
|
+
tokenKey: token?.key ?? null,
|
|
69
|
+
tokenOrigin: token?.origin ?? null,
|
|
70
|
+
credentialsPath,
|
|
71
|
+
hasCredentialsFile: existsSync(credentialsPath),
|
|
72
|
+
// A secret at rest: the file holds a token even when the shell shadows it.
|
|
73
|
+
fileHasToken: Boolean(fileToken),
|
|
74
|
+
mcpUrl: firstUrl(env, fileValues, MCP_URL_KEY, DEFAULT_MCP_URL),
|
|
75
|
+
apiUrl: firstUrl(env, fileValues, API_URL_KEY, DEFAULT_API_URL),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Same as {@link resolveGithubConfig}, but a missing token is an error.
|
|
81
|
+
*
|
|
82
|
+
* @returns {{ token: string, tokenKey: string, tokenOrigin: string, credentialsPath: string, hasCredentialsFile: boolean, fileHasToken: boolean, mcpUrl: string, apiUrl: string }}
|
|
83
|
+
*/
|
|
84
|
+
export function loadGitHubConfig(options = {}) {
|
|
85
|
+
const config = resolveGithubConfig(options);
|
|
86
|
+
|
|
87
|
+
if (!config.token) {
|
|
88
|
+
throw new ConfigError(
|
|
89
|
+
`GITHUB_TOKEN is not set. Add GITHUB_TOKEN to ${CREDENTIALS_FILE} or export it in the shell.`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return config;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** `--print-env` is a masked mapping: the token value never reaches stdout. */
|
|
97
|
+
export function printEnv(config) {
|
|
98
|
+
process.stdout.write('GITHUB_TOKEN=***\n');
|
|
99
|
+
process.stdout.write(`GITHUB_MCP_URL=${config.mcpUrl}\n`);
|
|
100
|
+
process.stdout.write(`GITHUB_API_URL=${config.apiUrl}\n`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Check the token against the GitHub REST API.
|
|
105
|
+
*
|
|
106
|
+
* @returns {Promise<{ ok: boolean, status: number, detail: string, login?: string }>}
|
|
107
|
+
*/
|
|
108
|
+
export async function verifyGithubToken({ token, apiUrl = DEFAULT_API_URL, timeoutMs = 15_000 } = {}) {
|
|
109
|
+
let response;
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
response = await fetch(`${apiUrl.replace(/\/+$/, '')}/user`, {
|
|
113
|
+
headers: {
|
|
114
|
+
Authorization: `Bearer ${token}`,
|
|
115
|
+
Accept: 'application/vnd.github+json',
|
|
116
|
+
'User-Agent': 'ai-rules-mcp',
|
|
117
|
+
},
|
|
118
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
119
|
+
});
|
|
120
|
+
} catch {
|
|
121
|
+
return { ok: false, status: 0, detail: 'the GitHub API is not reachable' };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (response.status === 200) {
|
|
125
|
+
let login = null;
|
|
126
|
+
try {
|
|
127
|
+
const body = await response.json();
|
|
128
|
+
login = typeof body?.login === 'string' ? body.login : null;
|
|
129
|
+
} catch {
|
|
130
|
+
login = null;
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
ok: true,
|
|
134
|
+
status: 200,
|
|
135
|
+
detail: login ? `token valid for ${login}` : 'token valid',
|
|
136
|
+
login,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (response.status === 401 || response.status === 403) {
|
|
141
|
+
return { ok: false, status: response.status, detail: `token rejected (${response.status})` };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return { ok: false, status: response.status, detail: `GET /user → ${response.status}` };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Open an MCP session against the GitHub MCP server and report whether the
|
|
149
|
+
* endpoint and the token are both usable.
|
|
150
|
+
*
|
|
151
|
+
* @returns {Promise<{ ok: boolean, status: number, detail: string }>}
|
|
152
|
+
*/
|
|
153
|
+
export async function probeGithubUpstream({ token, mcpUrl = DEFAULT_MCP_URL, timeoutMs = 30_000 } = {}) {
|
|
154
|
+
const message = {
|
|
155
|
+
jsonrpc: '2.0',
|
|
156
|
+
id: 1,
|
|
157
|
+
method: 'initialize',
|
|
158
|
+
params: {
|
|
159
|
+
protocolVersion: '2025-06-18',
|
|
160
|
+
capabilities: {},
|
|
161
|
+
clientInfo: { name: 'ai-rules-doctor', version: '1.0.0' },
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
const result = await postStreamable({
|
|
167
|
+
url: mcpUrl,
|
|
168
|
+
headers: { Authorization: `Bearer ${token}`, 'User-Agent': 'ai-rules-mcp' },
|
|
169
|
+
message,
|
|
170
|
+
timeoutMs,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const initialized = result.messages.find((entry) => entry && entry.id === 1 && entry.result);
|
|
174
|
+
if (initialized) {
|
|
175
|
+
return { ok: true, status: 200, detail: 'initialize → 200' };
|
|
176
|
+
}
|
|
177
|
+
return { ok: false, status: 200, detail: 'initialize → no result' };
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (error instanceof HttpStatusError) {
|
|
180
|
+
return { ok: false, status: error.status, detail: `initialize → HTTP ${error.status}` };
|
|
181
|
+
}
|
|
182
|
+
if (error instanceof TransportError) {
|
|
183
|
+
return { ok: false, status: 0, detail: `initialize failed: ${error.reason}` };
|
|
184
|
+
}
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared MCP streamable-HTTP transport.
|
|
3
|
+
*
|
|
4
|
+
* One POST per JSON-RPC message; the response is either a JSON body or an SSE
|
|
5
|
+
* stream. Providers own the headers, the session, the error wording and the
|
|
6
|
+
* token redaction — this module owns the wire format only.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** The server answered with a non-2xx status. */
|
|
10
|
+
export class HttpStatusError extends Error {
|
|
11
|
+
constructor(status, detail) {
|
|
12
|
+
super(`HTTP ${status}`);
|
|
13
|
+
this.name = 'HttpStatusError';
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.detail = detail ?? '';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The request never reached the server (DNS, TLS, timeout, refused). */
|
|
20
|
+
export class TransportError extends Error {
|
|
21
|
+
constructor(reason) {
|
|
22
|
+
super(reason);
|
|
23
|
+
this.name = 'TransportError';
|
|
24
|
+
this.reason = reason;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function readSessionId(response) {
|
|
29
|
+
return response.headers.get('Mcp-Session-Id') ?? response.headers.get('mcp-session-id') ?? undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function safeText(response) {
|
|
33
|
+
try {
|
|
34
|
+
return await response.text();
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function truncate(text, limit = 1000) {
|
|
41
|
+
return text.length > limit ? `${text.slice(0, limit)}…` : text;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A JSON body carries one message or a batch; both become a message list. */
|
|
45
|
+
export async function readJsonMessage(response) {
|
|
46
|
+
const text = await safeText(response);
|
|
47
|
+
if (!text) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(text);
|
|
52
|
+
return Array.isArray(parsed) ? parsed : [parsed];
|
|
53
|
+
} catch {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function readSseMessages(response) {
|
|
59
|
+
const reader = response.body.getReader();
|
|
60
|
+
const decoder = new TextDecoder();
|
|
61
|
+
const messages = [];
|
|
62
|
+
let buffer = '';
|
|
63
|
+
let dataLines = [];
|
|
64
|
+
|
|
65
|
+
const flush = () => {
|
|
66
|
+
if (dataLines.length === 0) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const data = dataLines.join('\n');
|
|
71
|
+
dataLines = [];
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
messages.push(JSON.parse(data));
|
|
75
|
+
} catch {
|
|
76
|
+
// Skip non-JSON SSE payloads (keep-alive comments, partial events).
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
while (true) {
|
|
81
|
+
const { done, value } = await reader.read();
|
|
82
|
+
|
|
83
|
+
if (done) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
buffer += decoder.decode(value, { stream: true });
|
|
88
|
+
|
|
89
|
+
const lines = buffer.split(/\r?\n/);
|
|
90
|
+
buffer = lines.pop() ?? '';
|
|
91
|
+
|
|
92
|
+
for (const rawLine of lines) {
|
|
93
|
+
const line = rawLine.trim();
|
|
94
|
+
|
|
95
|
+
if (line === '') {
|
|
96
|
+
flush();
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (line.startsWith(':')) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (line.startsWith('data:')) {
|
|
105
|
+
dataLines.push(line.slice(5).trimStart());
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (buffer.trim() !== '') {
|
|
111
|
+
const line = buffer.trim();
|
|
112
|
+
|
|
113
|
+
if (line.startsWith('data:')) {
|
|
114
|
+
dataLines.push(line.slice(5).trimStart());
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
flush();
|
|
119
|
+
|
|
120
|
+
return messages;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Forward one JSON-RPC message and return the messages the server sent back.
|
|
125
|
+
*
|
|
126
|
+
* @param {object} options
|
|
127
|
+
* @param {string} options.url
|
|
128
|
+
* @param {Record<string, string>} [options.headers]
|
|
129
|
+
* @param {string} [options.sessionId]
|
|
130
|
+
* @param {string} [options.protocolVersion]
|
|
131
|
+
* @param {object} options.message
|
|
132
|
+
* @param {number} [options.timeoutMs]
|
|
133
|
+
* @returns {Promise<{ sessionId: string | undefined, messages: object[] }>}
|
|
134
|
+
*/
|
|
135
|
+
export async function postStreamable({
|
|
136
|
+
url,
|
|
137
|
+
headers = {},
|
|
138
|
+
sessionId,
|
|
139
|
+
protocolVersion,
|
|
140
|
+
message,
|
|
141
|
+
timeoutMs = 120_000,
|
|
142
|
+
}) {
|
|
143
|
+
const requestHeaders = {
|
|
144
|
+
'Content-Type': 'application/json',
|
|
145
|
+
Accept: 'application/json, text/event-stream',
|
|
146
|
+
...headers,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
if (sessionId) {
|
|
150
|
+
requestHeaders['Mcp-Session-Id'] = sessionId;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (protocolVersion) {
|
|
154
|
+
requestHeaders['MCP-Protocol-Version'] = protocolVersion;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
let response;
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
response = await fetch(url, {
|
|
161
|
+
method: 'POST',
|
|
162
|
+
headers: requestHeaders,
|
|
163
|
+
body: JSON.stringify(message),
|
|
164
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
165
|
+
});
|
|
166
|
+
} catch (error) {
|
|
167
|
+
throw new TransportError(error instanceof Error ? error.message : String(error));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (response.status === 202 || response.status === 204) {
|
|
171
|
+
return { sessionId: readSessionId(response), messages: [] };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (!response.ok) {
|
|
175
|
+
throw new HttpStatusError(response.status, await safeText(response));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const nextSessionId = readSessionId(response);
|
|
179
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
180
|
+
const messages = contentType.includes('text/event-stream')
|
|
181
|
+
? await readSseMessages(response)
|
|
182
|
+
: await readJsonMessage(response);
|
|
183
|
+
|
|
184
|
+
return { sessionId: nextSessionId, messages };
|
|
185
|
+
}
|