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