@bonesofspring/ai-rules 0.2.57 → 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 +50 -0
- package/README.md +41 -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 +1 -0
- 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 +3 -1
- package/presets/_shared/ai-local/scripts/check-write-scope.mjs +212 -0
- package/presets/_shared/ai-local/scripts/rule-improver.mjs +343 -50
- package/presets/_shared/ai-local/scripts/run.mjs +122 -3
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +12 -0
- package/presets/_shared/core/review/code-review-mr.md +10 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +143 -1
- package/presets/claude/android-kotlin/commands/update.md +1 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +143 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/go/commands/update.md +1 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +143 -1
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/go/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/ios-swift/commands/update.md +1 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +143 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/java/commands/update.md +1 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +143 -1
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/java/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/mcp-ts/commands/update.md +1 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +143 -1
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/mol/commands/update.md +1 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +143 -1
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/mol/rules/tooling-and-review/code-review-mr.md +10 -0
- package/presets/claude/next/agents/build-verifier.md +2 -0
- package/presets/claude/next/agents/code-reviewer.md +8 -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 +143 -1
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/next/rules/tooling-and-review/code-review-mr.md +10 -0
- package/presets/claude/nuxt/commands/update.md +1 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +143 -1
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/nuxt/rules/tooling-and-review/code-review-mr.md +10 -0
- package/presets/claude/php-hexagonal/commands/update.md +1 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +143 -1
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/php-laravel/commands/update.md +1 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +143 -1
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/code-review.md +10 -0
- package/presets/claude/svelte/commands/update.md +1 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +143 -1
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +12 -0
- package/presets/claude/svelte/rules/tooling-and-review/code-review-mr.md +10 -0
- package/presets/cursor/android-kotlin/commands/update.md +1 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +143 -1
- package/presets/cursor/android-kotlin/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/go/commands/update.md +1 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +143 -1
- package/presets/cursor/go/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/ios-swift/commands/update.md +1 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +143 -1
- package/presets/cursor/ios-swift/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/java/commands/update.md +1 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +143 -1
- package/presets/cursor/java/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/mcp-ts/commands/update.md +1 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +143 -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/commands/update.md +1 -0
- package/presets/cursor/mol/hooks/chain-team-phases.sh +143 -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/build-verifier.md +2 -0
- package/presets/cursor/next/agents/code-reviewer.md +8 -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 +143 -1
- package/presets/cursor/next/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/nuxt/commands/update.md +1 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +143 -1
- package/presets/cursor/nuxt/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/php-hexagonal/commands/update.md +1 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +143 -1
- package/presets/cursor/php-hexagonal/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/php-laravel/commands/update.md +1 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +143 -1
- package/presets/cursor/php-laravel/rules/code-review-mr.mdc +10 -0
- package/presets/cursor/svelte/commands/update.md +1 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +143 -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/commands/update.md +1 -0
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +143 -1
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/mavis/go/hooks/chain-team-phases.sh +143 -1
- package/presets/mavis/go/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +143 -1
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/mavis/java/hooks/chain-team-phases.sh +143 -1
- package/presets/mavis/java/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +143 -1
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/mavis/mol/hooks/chain-team-phases.sh +143 -1
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +12 -0
- 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 +1 -1
- package/presets/mavis/next/agents/build-verifier.md +2 -0
- package/presets/mavis/next/agents/code-reviewer.md +8 -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 +143 -1
- package/presets/mavis/next/rules/agent-team-orchestrator.md +12 -0
- package/presets/mavis/next/rules/code-review-mr.md +10 -0
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/commands/update.md +1 -0
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +143 -1
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +143 -1
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +143 -1
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +143 -1
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +143 -1
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/opencode/go/hooks/chain-team-phases.sh +143 -1
- package/presets/opencode/go/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +143 -1
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/opencode/java/hooks/chain-team-phases.sh +143 -1
- package/presets/opencode/java/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +143 -1
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/opencode/mol/hooks/chain-team-phases.sh +143 -1
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +12 -0
- 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 +1 -1
- package/presets/opencode/next/agents/build-verifier.md +2 -0
- package/presets/opencode/next/agents/code-reviewer.md +8 -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 +143 -1
- package/presets/opencode/next/rules/agent-team-orchestrator.md +12 -0
- package/presets/opencode/next/rules/code-review-mr.md +10 -0
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/commands/update.md +1 -0
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +143 -1
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +143 -1
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +143 -1
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +143 -1
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +143 -1
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/zcode/go/hooks/chain-team-phases.sh +143 -1
- package/presets/zcode/go/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +143 -1
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/zcode/java/hooks/chain-team-phases.sh +143 -1
- package/presets/zcode/java/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +143 -1
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/zcode/mol/hooks/chain-team-phases.sh +143 -1
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +12 -0
- 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 +1 -1
- package/presets/zcode/next/agents/build-verifier.md +2 -0
- package/presets/zcode/next/agents/code-reviewer.md +8 -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 +143 -1
- package/presets/zcode/next/rules/agent-team-orchestrator.md +12 -0
- package/presets/zcode/next/rules/code-review-mr.md +10 -0
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/commands/update.md +1 -0
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +143 -1
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +143 -1
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +143 -1
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +12 -0
- 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/commands/update.md +1 -0
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +143 -1
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +12 -0
- package/presets/zcode/svelte/rules/code-review-mr.md +10 -0
package/bin/cli.js
CHANGED
|
@@ -32,12 +32,14 @@ const {
|
|
|
32
32
|
stripMergedConfigs,
|
|
33
33
|
} = require('./lib/merged-config');
|
|
34
34
|
const { otherToolInstallPresent, TOOL_INSTALL_MARKERS } = require('./lib/tool-installs');
|
|
35
|
+
const { ENGINE_SCRIPTS, ENGINE_SOURCE_RELATIVE } = require('./lib/engine-scripts');
|
|
35
36
|
const {
|
|
36
37
|
CLIENT_IDS,
|
|
37
38
|
serverBySlug,
|
|
38
39
|
serversFor,
|
|
39
40
|
} = require('./lib/mcp/registry');
|
|
40
|
-
const {
|
|
41
|
+
const { CATALOG, catalogNames, resolveCatalogName } = require('./lib/mcp/catalog');
|
|
42
|
+
const { selectClients, registerServers, registerCatalogServers, removeServers } = require('./lib/mcp/clients');
|
|
41
43
|
const credentials = require('./lib/mcp/credentials');
|
|
42
44
|
const { runDoctor, AREAS } = require('./lib/mcp/doctor');
|
|
43
45
|
const {
|
|
@@ -106,18 +108,22 @@ function printHelp() {
|
|
|
106
108
|
Usage:
|
|
107
109
|
ai-rules init <cursor|claude|mavis|opencode|zcode|multi> [--preset <name>]
|
|
108
110
|
ai-rules init <cursor|claude|mavis|opencode|zcode|multi> <preset-name>
|
|
111
|
+
ai-rules init mcp <name...|--all> [--tools <list>] [--cwd <dir>]
|
|
109
112
|
ai-rules update [--merge-ai-local | --check] [--cwd <dir>]
|
|
113
|
+
ai-rules doctor [--json] [--cwd <dir>]
|
|
110
114
|
ai-rules clean <cursor|claude|mavis|opencode|zcode> [--cwd <dir>]
|
|
111
|
-
ai-rules mcp setup <gitlab|yandex|all> [--tools <list>] [--yes] [--replace] [--url <url>] [--org-id <id>] [--json] [--cwd <dir>]
|
|
112
|
-
ai-rules mcp add <gitlab|yandex|all> [--tools <list>] [--replace] [--json] [--cwd <dir>]
|
|
113
|
-
ai-rules mcp remove <gitlab|yandex|all> [--tools <list>] [--purge] [--json] [--cwd <dir>]
|
|
114
|
-
ai-rules mcp doctor [gitlab|yandex|all] [--json] [--cwd <dir>]
|
|
115
|
+
ai-rules mcp setup <gitlab|github|yandex|all> [--tools <list>] [--yes] [--replace] [--url <url>] [--org-id <id>] [--json] [--cwd <dir>]
|
|
116
|
+
ai-rules mcp add <gitlab|github|yandex|all> [--tools <list>] [--replace] [--json] [--cwd <dir>]
|
|
117
|
+
ai-rules mcp remove <gitlab|github|yandex|all> [--tools <list>] [--purge] [--json] [--cwd <dir>]
|
|
118
|
+
ai-rules mcp doctor [gitlab|github|yandex|all] [--json] [--cwd <dir>]
|
|
115
119
|
ai-rules mcp refresh yandex [--print] [--json] [--yc-bin <path>] [--cwd <dir>]
|
|
116
|
-
ai-rules mcp run <gitlab|yandex-tracker|yandex-wiki> [--print-env] (internal — used by the client config)
|
|
120
|
+
ai-rules mcp run <gitlab|github|yandex-tracker|yandex-wiki> [--print-env] (internal — used by the client config)
|
|
117
121
|
|
|
118
122
|
Options:
|
|
119
123
|
--preset <name> Preset name (default: ${DEFAULT_PRESET})
|
|
120
124
|
--cwd <dir> Target project directory (default: current working directory)
|
|
125
|
+
--all init mcp: every server in the catalog
|
|
126
|
+
--tools <list> init mcp: comma-separated clients (default: detected)
|
|
121
127
|
--merge-ai-local Fast-forward .ai.local/ files whose recorded base still matches
|
|
122
128
|
--check Print each .ai.local/ drift rel and write nothing
|
|
123
129
|
the preset template; a file you edited is kept and its diff is
|
|
@@ -152,14 +158,19 @@ Notes:
|
|
|
152
158
|
All init targets also copy REPO_AGENTS.md → <cwd>/AGENTS.md (repo-root cross-tool agents file; overwrite; all next platforms ship the same file).
|
|
153
159
|
init multi installs every platform that has released the preset (cursor, claude, plus mavis/opencode when listed in releasedStacks). Not a clean target.
|
|
154
160
|
update reinstalls each tool that already has <tool>/.ai-rules-install.json, using the preset field that init wrote. Tools without a manifest stay uninstalled. The recorded preset is kept. update does not accept --preset or a tool name; --merge-ai-local is allowed on update and on init.
|
|
161
|
+
doctor is read-only: for every installed platform it reports missing/modified managed files, a manifest/package version mismatch, and the shared .ai.local/scripts/ engine set against presets/_shared/ai-local/scripts/ (stale-engine / missing-engine). It has no --fix and writes nothing; --json prints one object. Exit 0 = clean, 1 = findings, 2 = usage error.
|
|
155
162
|
When <cwd>/docs/specs/ is absent, init also seeds INDEX.md stub + _templates/* from package assets (never overwrites an existing INDEX).
|
|
156
163
|
clean removes only files the last init copied and that are unchanged since; consumer files are kept.
|
|
157
164
|
Merged configs are never deleted wholesale: clean strips the entries init added (shipped MCP servers, preset
|
|
158
165
|
settings.json permissions/hooks, opencode.json instructions/bash keys) and removes the file only when nothing
|
|
159
166
|
else is left in a file init created. Shared <cwd>/AGENTS.md is removed only when no other tool install remains.
|
|
160
167
|
Command forms: "init cursor --preset next", "init cursor next", "--preset next init cursor", "cursor init --preset next".
|
|
168
|
+
init mcp <name> registers a third-party server from the shipped catalog into every installed client
|
|
169
|
+
(or --tools only). Names: context7, playwright, chrome-devtools, figma-desktop (alias: figma), figma-cloud;
|
|
170
|
+
--all selects every one. Entries merge like init: extra servers and consumer env/headers stay.
|
|
161
171
|
mcp setup obtains and validates credentials, writes the client entries and runs the doctor. GitLab credentials live in
|
|
162
|
-
.ai-rules/mcp/credentials.env (0600); Yandex settings live in .ai-rules/mcp/config.env (no token)
|
|
172
|
+
.ai-rules/mcp/credentials.env (0600); Yandex settings live in .ai-rules/mcp/config.env (no token); the GitHub token is read
|
|
173
|
+
from the shell or from .env.github in the project root and is never written by the package. The two settings files sit in a
|
|
163
174
|
self-ignoring .ai-rules/ (the root .gitignore is never modified). Only clients already installed are registered; --tools
|
|
164
175
|
narrows or names a client explicitly. mcp commands require Node 20+ (the GitLab child declares engines >=20).
|
|
165
176
|
|
|
@@ -195,14 +206,18 @@ Examples:
|
|
|
195
206
|
npx @bonesofspring/ai-rules clean mavis
|
|
196
207
|
npx @bonesofspring/ai-rules clean opencode
|
|
197
208
|
npx @bonesofspring/ai-rules clean cursor
|
|
209
|
+
npx @bonesofspring/ai-rules init mcp context7
|
|
210
|
+
npx @bonesofspring/ai-rules init mcp figma-desktop chrome-devtools
|
|
211
|
+
npx @bonesofspring/ai-rules init mcp --all
|
|
198
212
|
npx @bonesofspring/ai-rules mcp setup gitlab
|
|
213
|
+
npx @bonesofspring/ai-rules mcp setup github
|
|
199
214
|
npx @bonesofspring/ai-rules mcp setup yandex
|
|
200
215
|
npx @bonesofspring/ai-rules mcp doctor
|
|
201
216
|
npx @bonesofspring/ai-rules mcp refresh yandex
|
|
202
217
|
`);
|
|
203
218
|
}
|
|
204
219
|
|
|
205
|
-
function parseArgs(argv) {
|
|
220
|
+
function parseArgs(argv, options = {}) {
|
|
206
221
|
const args = { _: [], cwd: undefined, preset: undefined, presetError: undefined };
|
|
207
222
|
for (let i = 0; i < argv.length; i++) {
|
|
208
223
|
const a = argv[i];
|
|
@@ -257,6 +272,11 @@ function parseArgs(argv) {
|
|
|
257
272
|
args.checkAiLocal = true;
|
|
258
273
|
continue;
|
|
259
274
|
}
|
|
275
|
+
if (a === '--json') {
|
|
276
|
+
if (options.json) args.json = true;
|
|
277
|
+
else args.unknownOption = a;
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
260
280
|
if (a.startsWith('-') && a !== '-') {
|
|
261
281
|
args.unknownOption = a;
|
|
262
282
|
continue;
|
|
@@ -586,21 +606,21 @@ function presetHasAnySource(base, cfg) {
|
|
|
586
606
|
return false;
|
|
587
607
|
}
|
|
588
608
|
|
|
589
|
-
function resolveTargetCwd(cwdOption) {
|
|
609
|
+
function resolveTargetCwd(cwdOption, usageExitCode = 1) {
|
|
590
610
|
// Reject empty string explicitly: `path.resolve('')` silently returns cwd,
|
|
591
611
|
// turning `--cwd ""` into a footgun that mutates the wrong directory.
|
|
592
612
|
if (cwdOption !== undefined && cwdOption === '') {
|
|
593
613
|
console.error('--cwd requires a non-empty path (use --cwd <dir> or omit for current directory)');
|
|
594
|
-
process.exit(
|
|
614
|
+
process.exit(usageExitCode);
|
|
595
615
|
}
|
|
596
616
|
const cwd = cwdOption ? path.resolve(cwdOption) : process.cwd();
|
|
597
617
|
if (!fs.existsSync(cwd)) {
|
|
598
618
|
console.error(`Target directory does not exist: ${cwd}`);
|
|
599
|
-
process.exit(
|
|
619
|
+
process.exit(usageExitCode);
|
|
600
620
|
}
|
|
601
621
|
if (!fs.statSync(cwd).isDirectory()) {
|
|
602
622
|
console.error(`Target path is not a directory: ${cwd}`);
|
|
603
|
-
process.exit(
|
|
623
|
+
process.exit(usageExitCode);
|
|
604
624
|
}
|
|
605
625
|
return cwd;
|
|
606
626
|
}
|
|
@@ -785,6 +805,147 @@ function cmdUpdate(cwdOption, opts) {
|
|
|
785
805
|
console.log(`\nDone. update reinstalled ${plan}`);
|
|
786
806
|
}
|
|
787
807
|
|
|
808
|
+
/**
|
|
809
|
+
* Read-only install-state doctor.
|
|
810
|
+
*
|
|
811
|
+
* Per installed platform (`.ai-rules-install.json`): missing or modified managed
|
|
812
|
+
* files and a `packageVersion` mismatch. Once per project: the shared engine set
|
|
813
|
+
* (`.ai.local/scripts/` vs the package's `presets/_shared/ai-local/scripts/`)
|
|
814
|
+
* reported as `stale-engine` / `missing-engine`. Never writes and has no `--fix`
|
|
815
|
+
* (a prior non-adoption): the report is the whole contract.
|
|
816
|
+
*/
|
|
817
|
+
function collectDoctorState(cwd, packageRoot) {
|
|
818
|
+
const packageVersion = getPackageVersion(packageRoot);
|
|
819
|
+
const platforms = [];
|
|
820
|
+
for (const { tool, root } of UPDATE_TARGETS) {
|
|
821
|
+
const rel = `${root}/.ai-rules-install.json`;
|
|
822
|
+
const abs = resolveManagedPath(cwd, rel);
|
|
823
|
+
if (!abs || !fs.existsSync(abs)) continue;
|
|
824
|
+
const findings = [];
|
|
825
|
+
let manifest = null;
|
|
826
|
+
try {
|
|
827
|
+
const parsed = JSON.parse(fs.readFileSync(abs, 'utf8'));
|
|
828
|
+
manifest = isPlainObject(parsed) ? parsed : null;
|
|
829
|
+
} catch {
|
|
830
|
+
manifest = null;
|
|
831
|
+
}
|
|
832
|
+
if (!manifest) {
|
|
833
|
+
findings.push({ code: 'missing', path: rel, detail: 'install manifest is not readable JSON' });
|
|
834
|
+
} else {
|
|
835
|
+
if (typeof manifest.packageVersion === 'string' && manifest.packageVersion !== packageVersion) {
|
|
836
|
+
findings.push({
|
|
837
|
+
code: 'version-mismatch',
|
|
838
|
+
path: rel,
|
|
839
|
+
detail: `manifest records ${manifest.packageVersion}, package is ${packageVersion}`,
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
if (typeof manifest.schemaVersion === 'number' && manifest.schemaVersion < MANIFEST_SCHEMA_VERSION) {
|
|
843
|
+
findings.push({
|
|
844
|
+
code: 'legacy-manifest',
|
|
845
|
+
path: rel,
|
|
846
|
+
detail: 'schema v1 hashes consumer files too; re-run init to record a current manifest',
|
|
847
|
+
});
|
|
848
|
+
} else if (!isPlainObject(manifest.managedFiles) || Object.keys(manifest.managedFiles).length === 0) {
|
|
849
|
+
findings.push({
|
|
850
|
+
code: 'missing',
|
|
851
|
+
path: rel,
|
|
852
|
+
detail: 'schema v2 manifest has no managedFiles map; re-run init for this platform',
|
|
853
|
+
});
|
|
854
|
+
} else {
|
|
855
|
+
for (const [managedRel, expectedHash] of Object.entries(manifest.managedFiles)) {
|
|
856
|
+
const managedAbs = resolveManagedPath(cwd, managedRel);
|
|
857
|
+
if (!managedAbs || !fs.existsSync(managedAbs) || !fs.lstatSync(managedAbs).isFile()) {
|
|
858
|
+
findings.push({ code: 'missing', path: managedRel, detail: 'managed file is absent' });
|
|
859
|
+
continue;
|
|
860
|
+
}
|
|
861
|
+
if (typeof expectedHash === 'string' && sha256File(managedAbs) !== expectedHash) {
|
|
862
|
+
findings.push({ code: 'modified', path: managedRel, detail: 'bytes differ from the install manifest' });
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
platforms.push({
|
|
868
|
+
platform: tool,
|
|
869
|
+
root,
|
|
870
|
+
preset: manifest && typeof manifest.preset === 'string' ? manifest.preset : null,
|
|
871
|
+
packageVersion: manifest && typeof manifest.packageVersion === 'string' ? manifest.packageVersion : null,
|
|
872
|
+
ok: findings.length === 0,
|
|
873
|
+
findings,
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
const engineFindings = [];
|
|
878
|
+
const engineRel = '.ai.local/scripts';
|
|
879
|
+
const engineDir = resolveManagedPath(cwd, engineRel);
|
|
880
|
+
const sourceDir = path.join(packageRoot, 'presets', ...ENGINE_SOURCE_RELATIVE.split('/'));
|
|
881
|
+
const engineInstalled = Boolean(engineDir && fs.existsSync(engineDir) && fs.statSync(engineDir).isDirectory());
|
|
882
|
+
if (platforms.length === 0 && !engineInstalled) {
|
|
883
|
+
// Nothing is installed; a missing engine is not a finding for a bare tree.
|
|
884
|
+
} else if (!engineInstalled) {
|
|
885
|
+
engineFindings.push({ code: 'missing-engine', path: engineRel, detail: 'engine directory is absent' });
|
|
886
|
+
} else {
|
|
887
|
+
for (const name of ENGINE_SCRIPTS) {
|
|
888
|
+
const rel = `${engineRel}/${name}`;
|
|
889
|
+
const installed = path.join(engineDir, name);
|
|
890
|
+
const source = path.join(sourceDir, name);
|
|
891
|
+
if (!fs.existsSync(installed)) {
|
|
892
|
+
engineFindings.push({ code: 'missing-engine', path: rel, detail: `engine module ${name} is absent` });
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
if (fs.existsSync(source) && sha256File(installed) !== sha256File(source)) {
|
|
896
|
+
engineFindings.push({
|
|
897
|
+
code: 'stale-engine',
|
|
898
|
+
path: rel,
|
|
899
|
+
detail: `${name} differs from presets/${ENGINE_SOURCE_RELATIVE}/${name}`,
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
const engine = { root: engineRel, ok: engineFindings.length === 0, findings: engineFindings };
|
|
906
|
+
return {
|
|
907
|
+
schemaVersion: 1,
|
|
908
|
+
packageVersion,
|
|
909
|
+
ok: platforms.every((platform) => platform.ok) && engine.ok,
|
|
910
|
+
platforms,
|
|
911
|
+
engine,
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
function printDoctorReport(state) {
|
|
916
|
+
console.log('@bonesofspring/ai-rules doctor (read-only)');
|
|
917
|
+
console.log(`package: ${state.packageVersion}`);
|
|
918
|
+
if (state.platforms.length === 0) {
|
|
919
|
+
console.log('installed platforms: none (.ai-rules-install.json not found)');
|
|
920
|
+
} else {
|
|
921
|
+
console.log(`installed platforms: ${state.platforms.map((platform) => `${platform.platform} (${platform.preset ?? 'unknown'})`).join(', ')}`);
|
|
922
|
+
}
|
|
923
|
+
for (const platform of state.platforms) {
|
|
924
|
+
console.log(`${platform.platform}: ${platform.ok ? 'OK' : `${platform.findings.length} finding(s)`}`);
|
|
925
|
+
for (const finding of platform.findings) {
|
|
926
|
+
console.log(` ${finding.code} ${finding.path} — ${finding.detail}`);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
console.log(`engine: ${state.engine.ok ? 'OK' : `${state.engine.findings.length} finding(s)`}`);
|
|
930
|
+
for (const finding of state.engine.findings) {
|
|
931
|
+
console.log(` ${finding.code} ${finding.path} — ${finding.detail}`);
|
|
932
|
+
}
|
|
933
|
+
const total = state.platforms.reduce((sum, platform) => sum + platform.findings.length, 0)
|
|
934
|
+
+ state.engine.findings.length;
|
|
935
|
+
console.log(`result: ${state.ok ? 'OK' : `FINDINGS (${total})`}`);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
function cmdDoctor(cwdOption, opts) {
|
|
939
|
+
const cwd = resolveTargetCwd(cwdOption, 2);
|
|
940
|
+
const state = collectDoctorState(cwd, getPackageRoot());
|
|
941
|
+
if (opts && opts.json) {
|
|
942
|
+
console.log(JSON.stringify(state, null, 2));
|
|
943
|
+
} else {
|
|
944
|
+
printDoctorReport(state);
|
|
945
|
+
}
|
|
946
|
+
process.exit(state.ok ? 0 : 1);
|
|
947
|
+
}
|
|
948
|
+
|
|
788
949
|
function cmdInit(tool, preset, cwdOption, opts) {
|
|
789
950
|
const mergeAiLocal = Boolean(opts && opts.mergeAiLocal);
|
|
790
951
|
const checkAiLocal = Boolean(opts && opts.checkAiLocal);
|
|
@@ -1133,12 +1294,12 @@ function printMcpHelp() {
|
|
|
1133
1294
|
console.log(`ai-rules mcp
|
|
1134
1295
|
|
|
1135
1296
|
Usage:
|
|
1136
|
-
ai-rules mcp setup <gitlab|yandex|all> [--tools <list>] [--yes] [--replace] [--url <url>] [--org-id <id>] [--json] [--cwd <dir>]
|
|
1137
|
-
ai-rules mcp add <gitlab|yandex|all> [--tools <list>] [--replace] [--json] [--cwd <dir>]
|
|
1138
|
-
ai-rules mcp remove <gitlab|yandex|all> [--tools <list>] [--purge] [--json] [--cwd <dir>]
|
|
1139
|
-
ai-rules mcp doctor [gitlab|yandex|all] [--json] [--cwd <dir>]
|
|
1297
|
+
ai-rules mcp setup <gitlab|github|yandex|all> [--tools <list>] [--yes] [--replace] [--url <url>] [--org-id <id>] [--json] [--cwd <dir>]
|
|
1298
|
+
ai-rules mcp add <gitlab|github|yandex|all> [--tools <list>] [--replace] [--json] [--cwd <dir>]
|
|
1299
|
+
ai-rules mcp remove <gitlab|github|yandex|all> [--tools <list>] [--purge] [--json] [--cwd <dir>]
|
|
1300
|
+
ai-rules mcp doctor [gitlab|github|yandex|all] [--json] [--cwd <dir>]
|
|
1140
1301
|
ai-rules mcp refresh yandex [--print] [--json] [--yc-bin <path>] [--cwd <dir>]
|
|
1141
|
-
ai-rules mcp run <gitlab|yandex-tracker|yandex-wiki> [--print-env]
|
|
1302
|
+
ai-rules mcp run <gitlab|github|yandex-tracker|yandex-wiki> [--print-env]
|
|
1142
1303
|
|
|
1143
1304
|
Options:
|
|
1144
1305
|
--tools <list> Comma-separated clients (cursor, claude, mavis, opencode); default: detected
|
|
@@ -1151,7 +1312,7 @@ Options:
|
|
|
1151
1312
|
--print refresh: print the fresh IAM token to stdout (opt-in)
|
|
1152
1313
|
--json One JSON document on stdout; human text moves to stderr
|
|
1153
1314
|
--cwd <dir> Target project directory (default: current working directory)
|
|
1154
|
-
--print-env run (gitlab): print the masked child env mapping and exit
|
|
1315
|
+
--print-env run (gitlab, github): print the masked child env mapping and exit
|
|
1155
1316
|
|
|
1156
1317
|
Commands:
|
|
1157
1318
|
setup Credentials + registration + doctor for one provider (the normal entry point)
|
|
@@ -1162,9 +1323,176 @@ Commands:
|
|
|
1162
1323
|
run Internal — the client config starts it; speaks MCP over stdio
|
|
1163
1324
|
|
|
1164
1325
|
Node 20+ is required for every mcp command. Nothing here writes a token into a client config.
|
|
1326
|
+
The GitHub token is read from the shell or from .env.github in the project root; the pack never writes it.
|
|
1327
|
+
Third-party servers without credentials are installed with ai-rules init mcp <name...|--all>.
|
|
1328
|
+
`);
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
function printInitMcpHelp() {
|
|
1332
|
+
const width = Math.max(...CATALOG.map((server) => server.slug.length));
|
|
1333
|
+
const lines = CATALOG.map((server) => {
|
|
1334
|
+
const notes = [];
|
|
1335
|
+
if (server.ids && server.ids.claude) {
|
|
1336
|
+
notes.push(`Claude id: ${server.ids.claude}`);
|
|
1337
|
+
}
|
|
1338
|
+
if (server.aliases && server.aliases.length > 0) {
|
|
1339
|
+
notes.push(`alias: ${server.aliases.join(', ')}`);
|
|
1340
|
+
}
|
|
1341
|
+
const suffix = notes.length > 0 ? ` (${notes.join('; ')})` : '';
|
|
1342
|
+
return ` ${server.slug.padEnd(width)} ${server.title}${suffix}`;
|
|
1343
|
+
});
|
|
1344
|
+
console.log(`ai-rules init mcp
|
|
1345
|
+
|
|
1346
|
+
Usage:
|
|
1347
|
+
ai-rules init mcp <name...> [--tools <list>] [--cwd <dir>]
|
|
1348
|
+
ai-rules init mcp --all [--tools <list>] [--cwd <dir>]
|
|
1349
|
+
|
|
1350
|
+
Servers:
|
|
1351
|
+
${lines.join('\n')}
|
|
1352
|
+
|
|
1353
|
+
Options:
|
|
1354
|
+
--all Every server above
|
|
1355
|
+
--tools <list> Comma-separated clients (cursor, claude, mavis, opencode, zcode); default: detected
|
|
1356
|
+
--cwd <dir> Target project directory (default: current working directory)
|
|
1357
|
+
-h, --help Print this help
|
|
1358
|
+
|
|
1359
|
+
Each client gets its native shape; entries merge like init, so other servers and consumer
|
|
1360
|
+
env/headers stay.
|
|
1165
1361
|
`);
|
|
1166
1362
|
}
|
|
1167
1363
|
|
|
1364
|
+
const INIT_MCP_VALUE_OPTIONS = new Set(['--tools', '--cwd']);
|
|
1365
|
+
|
|
1366
|
+
function parseInitMcpArgs(argv) {
|
|
1367
|
+
const options = { _: [] };
|
|
1368
|
+
for (let i = 0; i < argv.length; i++) {
|
|
1369
|
+
const token = argv[i];
|
|
1370
|
+
if (token === '--') {
|
|
1371
|
+
options._.push(...argv.slice(i + 1));
|
|
1372
|
+
break;
|
|
1373
|
+
}
|
|
1374
|
+
if (token === '--all') {
|
|
1375
|
+
options.all = true;
|
|
1376
|
+
continue;
|
|
1377
|
+
}
|
|
1378
|
+
if (token === '-h' || token === '--help') {
|
|
1379
|
+
options.help = true;
|
|
1380
|
+
continue;
|
|
1381
|
+
}
|
|
1382
|
+
if (INIT_MCP_VALUE_OPTIONS.has(token)) {
|
|
1383
|
+
const value = argv[i + 1];
|
|
1384
|
+
if (value === undefined || value === '' || value.startsWith('-')) {
|
|
1385
|
+
throw new Error(`Missing value for ${token}`);
|
|
1386
|
+
}
|
|
1387
|
+
options[camelOption(token)] = value;
|
|
1388
|
+
i++;
|
|
1389
|
+
continue;
|
|
1390
|
+
}
|
|
1391
|
+
const equals = token.indexOf('=');
|
|
1392
|
+
if (token.startsWith('--') && equals > 0) {
|
|
1393
|
+
const name = token.slice(0, equals);
|
|
1394
|
+
if (INIT_MCP_VALUE_OPTIONS.has(name)) {
|
|
1395
|
+
const value = token.slice(equals + 1);
|
|
1396
|
+
if (value === '') {
|
|
1397
|
+
throw new Error(`Missing value after ${name}=`);
|
|
1398
|
+
}
|
|
1399
|
+
options[camelOption(name)] = value;
|
|
1400
|
+
continue;
|
|
1401
|
+
}
|
|
1402
|
+
throw new Error(`Unknown option: ${name}`);
|
|
1403
|
+
}
|
|
1404
|
+
if (token.startsWith('-') && token !== '-') {
|
|
1405
|
+
throw new Error(`Unknown option: ${token}`);
|
|
1406
|
+
}
|
|
1407
|
+
options._.push(token);
|
|
1408
|
+
}
|
|
1409
|
+
return options;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
function cmdInitMcp(argv) {
|
|
1413
|
+
let options;
|
|
1414
|
+
try {
|
|
1415
|
+
options = parseInitMcpArgs(argv);
|
|
1416
|
+
} catch (error) {
|
|
1417
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1418
|
+
process.exit(1);
|
|
1419
|
+
}
|
|
1420
|
+
if (options.help) {
|
|
1421
|
+
printInitMcpHelp();
|
|
1422
|
+
process.exit(0);
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
const names = options._;
|
|
1426
|
+
if (options.all && names.length > 0) {
|
|
1427
|
+
console.error('init mcp: --all takes no server names.');
|
|
1428
|
+
process.exit(1);
|
|
1429
|
+
}
|
|
1430
|
+
if (!options.all && names.length === 0) {
|
|
1431
|
+
console.error('init mcp: name at least one server or pass --all.');
|
|
1432
|
+
printInitMcpHelp();
|
|
1433
|
+
process.exit(1);
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
let servers;
|
|
1437
|
+
if (options.all) {
|
|
1438
|
+
servers = CATALOG.slice();
|
|
1439
|
+
} else {
|
|
1440
|
+
servers = [];
|
|
1441
|
+
for (const name of names) {
|
|
1442
|
+
const server = resolveCatalogName(name);
|
|
1443
|
+
if (!server) {
|
|
1444
|
+
console.error(`Unknown server: ${name}. Use ${catalogNames().join(', ')}, or --all.`);
|
|
1445
|
+
process.exit(1);
|
|
1446
|
+
}
|
|
1447
|
+
if (!servers.some((item) => item.slug === server.slug)) {
|
|
1448
|
+
servers.push(server);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
let tools;
|
|
1454
|
+
if (options.tools !== undefined) {
|
|
1455
|
+
try {
|
|
1456
|
+
tools = parseMcpTools(options.tools);
|
|
1457
|
+
} catch (error) {
|
|
1458
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1459
|
+
process.exit(1);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
const cwd = resolveTargetCwd(options.cwd);
|
|
1464
|
+
const selection = selectClients({ cwd, tools, markers: TOOL_INSTALL_MARKERS });
|
|
1465
|
+
const printer = createMcpPrinter(false);
|
|
1466
|
+
for (const warning of selection.warnings) {
|
|
1467
|
+
printer.warn('clients', warning);
|
|
1468
|
+
}
|
|
1469
|
+
if (selection.clients.length === 0) {
|
|
1470
|
+
printer.fail('clients', 'no MCP client detected');
|
|
1471
|
+
printer.next('ai-rules init <cursor|claude|mavis|opencode|zcode> --preset <stack>');
|
|
1472
|
+
process.exit(1);
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
let registration;
|
|
1476
|
+
try {
|
|
1477
|
+
registration = registerCatalogServers({ cwd, clients: selection.clients, servers });
|
|
1478
|
+
} catch (error) {
|
|
1479
|
+
console.error(`init mcp failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1480
|
+
process.exit(1);
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
const clientIds = selection.clients.map((client) => client.id).join(', ');
|
|
1484
|
+
printer.ok('servers', servers.map((server) => server.slug).join(', '));
|
|
1485
|
+
printer.ok('clients', clientIds);
|
|
1486
|
+
if (registration.changed.length === 0) {
|
|
1487
|
+
printer.ok('registration', `${clientIds} already up to date`);
|
|
1488
|
+
} else {
|
|
1489
|
+
for (const rel of registration.changed) {
|
|
1490
|
+
printer.ok('registration', `wrote ${rel}`);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
printer.next('restart the MCP server in your client');
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1168
1496
|
const MCP_COMMANDS = new Set(['setup', 'add', 'remove', 'doctor', 'refresh', 'run']);
|
|
1169
1497
|
const MCP_VALUE_OPTIONS = new Set(['--tools', '--url', '--org-id', '--yc-bin', '--cwd']);
|
|
1170
1498
|
const MCP_BOOL_OPTIONS = new Set(['--yes', '--json', '--replace', '--purge', '--print', '--print-env', '--help', '-h']);
|
|
@@ -1271,7 +1599,8 @@ function publicServers(servers) {
|
|
|
1271
1599
|
async function loadPackModules(packageRoot) {
|
|
1272
1600
|
const envfile = await import(pathToFileURL(path.join(packageRoot, 'mcp', 'lib', 'envfile.mjs')).href);
|
|
1273
1601
|
const yandex = await import(pathToFileURL(path.join(packageRoot, 'mcp', 'lib', 'yandex.mjs')).href);
|
|
1274
|
-
|
|
1602
|
+
const github = await import(pathToFileURL(path.join(packageRoot, 'mcp', 'lib', 'github.mjs')).href);
|
|
1603
|
+
return { envfile, yandex, github };
|
|
1275
1604
|
}
|
|
1276
1605
|
|
|
1277
1606
|
function parseMcpTools(value) {
|
|
@@ -1319,7 +1648,7 @@ function registerProvider({ cwd, provider, options, version, printer, selection:
|
|
|
1319
1648
|
}
|
|
1320
1649
|
|
|
1321
1650
|
async function cmdMcpSetup({ cwd, provider, options, printer, packageRoot, modules, version }) {
|
|
1322
|
-
const providers = provider === 'all' ? ['gitlab', 'yandex'] : [provider];
|
|
1651
|
+
const providers = provider === 'all' ? ['gitlab', 'yandex', 'github'] : [provider];
|
|
1323
1652
|
const results = [];
|
|
1324
1653
|
|
|
1325
1654
|
for (const current of providers) {
|
|
@@ -1333,7 +1662,9 @@ async function cmdMcpSetup({ cwd, provider, options, printer, packageRoot, modul
|
|
|
1333
1662
|
|
|
1334
1663
|
const credentialResult = current === 'gitlab'
|
|
1335
1664
|
? await credentials.setupGitlab({ cwd, options, envfile: modules.envfile })
|
|
1336
|
-
:
|
|
1665
|
+
: current === 'github'
|
|
1666
|
+
? await credentials.setupGithub({ cwd, options, github: modules.github })
|
|
1667
|
+
: await credentials.setupYandex({ cwd, options, io: {}, yandex: modules.yandex, envfile: modules.envfile });
|
|
1337
1668
|
|
|
1338
1669
|
for (const warning of credentialResult.warnings || []) {
|
|
1339
1670
|
printer.warn('credentials', warning);
|
|
@@ -1361,6 +1692,7 @@ async function cmdMcpSetup({ cwd, provider, options, printer, packageRoot, modul
|
|
|
1361
1692
|
version,
|
|
1362
1693
|
envfile: modules.envfile,
|
|
1363
1694
|
yandex: modules.yandex,
|
|
1695
|
+
github: modules.github,
|
|
1364
1696
|
options,
|
|
1365
1697
|
});
|
|
1366
1698
|
renderDoctor(doctor, printer);
|
|
@@ -1441,6 +1773,7 @@ async function cmdMcpDoctor({ cwd, provider, options, printer, packageRoot, modu
|
|
|
1441
1773
|
version,
|
|
1442
1774
|
envfile: modules.envfile,
|
|
1443
1775
|
yandex: modules.yandex,
|
|
1776
|
+
github: modules.github,
|
|
1444
1777
|
options,
|
|
1445
1778
|
});
|
|
1446
1779
|
renderDoctor(doctor, printer);
|
|
@@ -1489,7 +1822,7 @@ function cmdMcpRefresh({ cwd, options, packageRoot }) {
|
|
|
1489
1822
|
async function cmdMcpRun({ slug, options, packageRoot }) {
|
|
1490
1823
|
const server = serverBySlug(slug);
|
|
1491
1824
|
if (!server) {
|
|
1492
|
-
console.error(`Unknown server: ${slug ?? '(none)'}. Use gitlab, yandex-tracker, or yandex-wiki.`);
|
|
1825
|
+
console.error(`Unknown server: ${slug ?? '(none)'}. Use gitlab, github, yandex-tracker, or yandex-wiki.`);
|
|
1493
1826
|
process.exit(1);
|
|
1494
1827
|
}
|
|
1495
1828
|
if (!options.printEnv && (process.stdin.isTTY || process.stdout.isTTY)) {
|
|
@@ -1497,8 +1830,8 @@ async function cmdMcpRun({ slug, options, packageRoot }) {
|
|
|
1497
1830
|
console.error('next: ai-rules mcp doctor');
|
|
1498
1831
|
process.exit(1);
|
|
1499
1832
|
}
|
|
1500
|
-
if (options.printEnv && server.provider
|
|
1501
|
-
console.error('--print-env is supported for gitlab only.');
|
|
1833
|
+
if (options.printEnv && !['gitlab', 'github'].includes(server.provider)) {
|
|
1834
|
+
console.error('--print-env is supported for gitlab and github only.');
|
|
1502
1835
|
process.exit(1);
|
|
1503
1836
|
}
|
|
1504
1837
|
const entry = runtimeEntryPath(packageRoot, server.entry);
|
|
@@ -1528,6 +1861,18 @@ async function cmdMcpRun({ slug, options, packageRoot }) {
|
|
|
1528
1861
|
}
|
|
1529
1862
|
}
|
|
1530
1863
|
|
|
1864
|
+
if (server.provider === 'github') {
|
|
1865
|
+
const modules = await loadPackModules(packageRoot);
|
|
1866
|
+
try {
|
|
1867
|
+
modules.github.loadGitHubConfig({ root: resolveProjectRoot() });
|
|
1868
|
+
} catch (error) {
|
|
1869
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1870
|
+
console.error(`fail runtime ${detail}`);
|
|
1871
|
+
console.error('next: add GITHUB_TOKEN to .env.github in the project root, then rerun ai-rules mcp setup github');
|
|
1872
|
+
process.exit(1);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1531
1876
|
const args = [entry, ...server.argv];
|
|
1532
1877
|
if (options.printEnv) {
|
|
1533
1878
|
args.push('--print-env');
|
|
@@ -1624,13 +1969,13 @@ async function cmdMcp(argv) {
|
|
|
1624
1969
|
provider = providerArg ?? 'all';
|
|
1625
1970
|
} else {
|
|
1626
1971
|
if (providerArg === undefined) {
|
|
1627
|
-
console.error(`Missing provider. Use: mcp ${command} <gitlab|yandex|all>`);
|
|
1972
|
+
console.error(`Missing provider. Use: mcp ${command} <gitlab|github|yandex|all>`);
|
|
1628
1973
|
process.exit(1);
|
|
1629
1974
|
}
|
|
1630
1975
|
provider = providerArg;
|
|
1631
1976
|
}
|
|
1632
|
-
if (!['gitlab', 'yandex', 'all'].includes(provider)) {
|
|
1633
|
-
console.error(`Unknown provider: ${provider}. Use gitlab, yandex, or all.`);
|
|
1977
|
+
if (!['gitlab', 'github', 'yandex', 'all'].includes(provider)) {
|
|
1978
|
+
console.error(`Unknown provider: ${provider}. Use gitlab, github, yandex, or all.`);
|
|
1634
1979
|
process.exit(1);
|
|
1635
1980
|
}
|
|
1636
1981
|
|
|
@@ -1659,6 +2004,11 @@ function main() {
|
|
|
1659
2004
|
process.exit(0);
|
|
1660
2005
|
}
|
|
1661
2006
|
|
|
2007
|
+
if (argv[0] === 'init' && argv[1] === 'mcp') {
|
|
2008
|
+
cmdInitMcp(argv.slice(2));
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
|
|
1662
2012
|
if (argv[0] === 'mcp') {
|
|
1663
2013
|
cmdMcp(argv.slice(1)).catch((error) => {
|
|
1664
2014
|
console.error(error instanceof Error ? error.message : String(error));
|
|
@@ -1667,6 +2017,28 @@ function main() {
|
|
|
1667
2017
|
return;
|
|
1668
2018
|
}
|
|
1669
2019
|
|
|
2020
|
+
if (argv[0] === 'doctor') {
|
|
2021
|
+
const parsed = parseArgs(argv.slice(1), { json: true });
|
|
2022
|
+
if (parsed.help) {
|
|
2023
|
+
printHelp();
|
|
2024
|
+
process.exit(0);
|
|
2025
|
+
}
|
|
2026
|
+
if (parsed.unknownOption) {
|
|
2027
|
+
console.error(`Unknown option: ${parsed.unknownOption}`);
|
|
2028
|
+
process.exit(2);
|
|
2029
|
+
}
|
|
2030
|
+
if (parsed.preset || parsed.presetError || parsed.cwdError) {
|
|
2031
|
+
console.error('doctor takes --json and --cwd only.');
|
|
2032
|
+
process.exit(2);
|
|
2033
|
+
}
|
|
2034
|
+
if (parsed._.length > 0) {
|
|
2035
|
+
console.error('doctor takes no positional argument.');
|
|
2036
|
+
process.exit(2);
|
|
2037
|
+
}
|
|
2038
|
+
cmdDoctor(parsed.cwd, parsed);
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2041
|
+
|
|
1670
2042
|
const parsed = parseArgs(argv);
|
|
1671
2043
|
if (parsed.help) {
|
|
1672
2044
|
printHelp();
|
|
@@ -29,6 +29,9 @@ const ENGINE_SCRIPTS = [
|
|
|
29
29
|
'team-db-api.mjs',
|
|
30
30
|
'team-db-openapi.mjs',
|
|
31
31
|
'team-db-dashboard.mjs',
|
|
32
|
+
// Read-only post-step write-scope audit used by build-verifier and code-reviewer.
|
|
33
|
+
// Shells out to git, so it is not part of the self-learning loop module set.
|
|
34
|
+
'check-write-scope.mjs',
|
|
32
35
|
];
|
|
33
36
|
|
|
34
37
|
/** Preset-root-relative directory holding the engine source of truth. */
|