@agent-deck/cli 2.4.0 → 2.5.0
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/dist/agent-harness.js +1 -1
- package/dist/bin.js +0 -0
- package/dist/codex-plugin.d.ts +33 -8
- package/dist/codex-plugin.d.ts.map +1 -1
- package/dist/codex-plugin.js +80 -16
- package/dist/codex-plugin.js.map +1 -1
- package/dist/cursor-mcp-inspect.d.ts +7 -6
- package/dist/cursor-mcp-inspect.d.ts.map +1 -1
- package/dist/cursor-mcp-inspect.js +59 -30
- package/dist/cursor-mcp-inspect.js.map +1 -1
- package/dist/debug-mcp.d.ts.map +1 -1
- package/dist/debug-mcp.js +50 -12
- package/dist/debug-mcp.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/launcher-migration.d.ts +22 -0
- package/dist/launcher-migration.d.ts.map +1 -0
- package/dist/launcher-migration.js +274 -0
- package/dist/launcher-migration.js.map +1 -0
- package/dist/mcp-bridge.d.ts.map +1 -1
- package/dist/mcp-bridge.js +5 -0
- package/dist/mcp-bridge.js.map +1 -1
- package/dist/mcp-config.d.ts +112 -52
- package/dist/mcp-config.d.ts.map +1 -1
- package/dist/mcp-config.js +504 -195
- package/dist/mcp-config.js.map +1 -1
- package/dist/mcp-launcher.d.ts.map +1 -1
- package/dist/mcp-launcher.js +7 -0
- package/dist/mcp-launcher.js.map +1 -1
- package/dist/muse-skills/agent-deck-session/SKILL.md +9 -6
- package/dist/muse-skills/agent-deck-setup/SKILL.md +21 -5
- package/dist/setup.d.ts +3 -1
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +152 -42
- package/dist/setup.js.map +1 -1
- package/dist/start.d.ts +4 -1
- package/dist/start.d.ts.map +1 -1
- package/dist/start.js +8 -5
- package/dist/start.js.map +1 -1
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +33 -5
- package/dist/upgrade.js.map +1 -1
- package/dist/use.d.ts +1 -1
- package/dist/use.d.ts.map +1 -1
- package/dist/use.js +92 -48
- package/dist/use.js.map +1 -1
- package/package.json +3 -3
- package/dist/coordinator.d.ts +0 -2
- package/dist/coordinator.d.ts.map +0 -1
- package/dist/coordinator.js +0 -153
- package/dist/coordinator.js.map +0 -1
- package/dist/grant-issue.d.ts +0 -39
- package/dist/grant-issue.d.ts.map +0 -1
- package/dist/grant-issue.js +0 -133
- package/dist/grant-issue.js.map +0 -1
- package/dist/grant-store.d.ts +0 -35
- package/dist/grant-store.d.ts.map +0 -1
- package/dist/grant-store.js +0 -302
- package/dist/grant-store.js.map +0 -1
- package/dist/run-adapter.d.ts +0 -100
- package/dist/run-adapter.d.ts.map +0 -1
- package/dist/run-adapter.js +0 -73
- package/dist/run-adapter.js.map +0 -1
- package/dist/run-claude.d.ts +0 -41
- package/dist/run-claude.d.ts.map +0 -1
- package/dist/run-claude.js +0 -91
- package/dist/run-claude.js.map +0 -1
- package/dist/run-codex.d.ts +0 -75
- package/dist/run-codex.d.ts.map +0 -1
- package/dist/run-codex.js +0 -337
- package/dist/run-codex.js.map +0 -1
- package/dist/run-cursor.d.ts +0 -79
- package/dist/run-cursor.d.ts.map +0 -1
- package/dist/run-cursor.js +0 -455
- package/dist/run-cursor.js.map +0 -1
- package/dist/run-muse.d.ts +0 -127
- package/dist/run-muse.d.ts.map +0 -1
- package/dist/run-muse.js +0 -499
- package/dist/run-muse.js.map +0 -1
package/dist/mcp-config.js
CHANGED
|
@@ -7,22 +7,32 @@ exports.MUSE_SCHEMA_VERSION = exports.CURSOR_MCP_RECOVERY_HINT = void 0;
|
|
|
7
7
|
exports.buildMcpUrl = buildMcpUrl;
|
|
8
8
|
exports.resolveMuseGlobalConfigDir = resolveMuseGlobalConfigDir;
|
|
9
9
|
exports.resolveConfigPath = resolveConfigPath;
|
|
10
|
+
exports.buildCodexAgentDeckEntry = buildCodexAgentDeckEntry;
|
|
11
|
+
exports.buildGlobalFallbackHttpEntry = buildGlobalFallbackHttpEntry;
|
|
10
12
|
exports.buildAgentDeckEntry = buildAgentDeckEntry;
|
|
13
|
+
exports.isHttpAgentDeckEntry = isHttpAgentDeckEntry;
|
|
14
|
+
exports.readHttpWorkspaceHeader = readHttpWorkspaceHeader;
|
|
11
15
|
exports.isLegacyBareHttpAgentDeckEntry = isLegacyBareHttpAgentDeckEntry;
|
|
12
16
|
exports.isMcpLaunchEntry = isMcpLaunchEntry;
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.formatCursorGlobalMcpEnsureMessage = formatCursorGlobalMcpEnsureMessage;
|
|
17
|
+
exports.isLegacyClaudeLaunchEntry = isLegacyClaudeLaunchEntry;
|
|
18
|
+
exports.isLegacyMuseLaunchEntry = isLegacyMuseLaunchEntry;
|
|
16
19
|
exports.readJsonFile = readJsonFile;
|
|
17
20
|
exports.mergeMuseServerConfig = mergeMuseServerConfig;
|
|
18
21
|
exports.mergeMcpServerConfig = mergeMcpServerConfig;
|
|
19
22
|
exports.writeJsonFile = writeJsonFile;
|
|
23
|
+
exports.readTextFile = readTextFile;
|
|
24
|
+
exports.writeTextFile = writeTextFile;
|
|
25
|
+
exports.escapeTomlBasicString = escapeTomlBasicString;
|
|
26
|
+
exports.formatCodexMcpSection = formatCodexMcpSection;
|
|
27
|
+
exports.formatCodexGlobalFallbackSection = formatCodexGlobalFallbackSection;
|
|
28
|
+
exports.codexTomlHasLauncherEntry = codexTomlHasLauncherEntry;
|
|
29
|
+
exports.mergeCodexTomlConfig = mergeCodexTomlConfig;
|
|
20
30
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
21
31
|
const node_os_1 = __importDefault(require("node:os"));
|
|
22
32
|
const node_path_1 = __importDefault(require("node:path"));
|
|
23
33
|
const strip_ansi_1 = require("./strip-ansi");
|
|
24
|
-
/** Shared recovery sentence for Cursor MCP diagnostics and docs (NOT-50). */
|
|
25
|
-
exports.CURSOR_MCP_RECOVERY_HINT =
|
|
34
|
+
/** Shared recovery sentence for Cursor MCP diagnostics and docs (NOT-50, pure-MCP form NOT-567). */
|
|
35
|
+
exports.CURSOR_MCP_RECOVERY_HINT = 'If Agent Deck tools are missing in Cursor, run `agent-deck setup --client cursor`, approve the project agent-deck server, run `agent-deck use <deck>` in the folder, then reload MCP.';
|
|
26
36
|
/** Muse user settings require this exact schema version (NOT-387). */
|
|
27
37
|
exports.MUSE_SCHEMA_VERSION = 1;
|
|
28
38
|
function buildMcpUrl({ host, mcpPort }) {
|
|
@@ -57,74 +67,146 @@ function resolveConfigPath(client, scope, cwd = process.cwd()) {
|
|
|
57
67
|
return node_path_1.default.join(cwd, '.mcp.json');
|
|
58
68
|
}
|
|
59
69
|
return node_path_1.default.join(resolveMuseGlobalConfigDir(home), 'muse', 'settings.json');
|
|
70
|
+
case 'codex':
|
|
71
|
+
return scope === 'project'
|
|
72
|
+
? node_path_1.default.join(cwd, '.codex', 'config.toml')
|
|
73
|
+
: node_path_1.default.join(home, '.codex', 'config.toml');
|
|
60
74
|
default:
|
|
61
75
|
throw new Error(`Unsupported client: ${client}`);
|
|
62
76
|
}
|
|
63
77
|
}
|
|
64
78
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
79
|
+
* Pure-HTTP entry for a Codex project config (`<folder>/.codex/config.toml`).
|
|
80
|
+
* The daemon resolves the deck from `.agent-deck/use.json` — no deck id here.
|
|
81
|
+
*/
|
|
82
|
+
function buildCodexAgentDeckEntry(endpoint, options) {
|
|
83
|
+
return {
|
|
84
|
+
url: buildMcpUrl(endpoint),
|
|
85
|
+
http_headers: {
|
|
86
|
+
'x-agent-deck-workspace': node_path_1.default.resolve(options.workspaceRoot),
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Global headerless HTTP fallback entry (NOT-565, design §4): folders with
|
|
92
|
+
* no assignment connect everywhere over pure MCP and land in the existing
|
|
93
|
+
* unassigned (explain-only) session. No headers, no executable lookup.
|
|
94
|
+
* Per-folder entries written by `agent-deck use` use the same server name,
|
|
95
|
+
* so they shadow this fallback where an assignment exists.
|
|
96
|
+
*/
|
|
97
|
+
function buildGlobalFallbackHttpEntry(endpoint) {
|
|
98
|
+
return {
|
|
99
|
+
type: 'http',
|
|
100
|
+
url: buildMcpUrl(endpoint),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* MCP client entry for the agent-deck server. Codex, Claude, Cursor, and
|
|
105
|
+
* Muse connect over pure HTTP (NOT-563/565/567/570/571): the workspace
|
|
106
|
+
* header names the folder and the daemon resolves the deck from
|
|
107
|
+
* `.agent-deck/use.json` — no deck id in tracked config, no executable
|
|
108
|
+
* lookup.
|
|
109
|
+
*
|
|
110
|
+
* A `workspaceRoot` selects the per-folder HTTP form; without one the
|
|
111
|
+
* client gets the global headerless HTTP fallback (NOT-565/567/570).
|
|
112
|
+
* Claude Desktop still uses the trusted local launcher, which reads the
|
|
113
|
+
* folder assignment at runtime. The retired Muse launcher shape (NOT-387:
|
|
114
|
+
* command/args/env only, no type or workspace pin) is never built —
|
|
115
|
+
* legacy entries are detected with {@link isLegacyMuseLaunchEntry} and
|
|
116
|
+
* converted by the upgrade path (NOT-572).
|
|
67
117
|
*/
|
|
68
118
|
function buildAgentDeckEntry(client, endpoint, options) {
|
|
119
|
+
if (client === 'codex') {
|
|
120
|
+
if (!options?.workspaceRoot) {
|
|
121
|
+
throw new Error('buildAgentDeckEntry(codex) requires options.workspaceRoot for the x-agent-deck-workspace header');
|
|
122
|
+
}
|
|
123
|
+
return buildCodexAgentDeckEntry(endpoint, { workspaceRoot: options.workspaceRoot });
|
|
124
|
+
}
|
|
69
125
|
if (client === 'claude-desktop') {
|
|
70
126
|
return {
|
|
71
127
|
command: 'agent-deck',
|
|
72
128
|
args: ['mcp-launch'],
|
|
73
129
|
};
|
|
74
130
|
}
|
|
75
|
-
if (client === 'muse') {
|
|
76
|
-
// Muse
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}
|
|
131
|
+
if (client === 'muse' || client === 'claude') {
|
|
132
|
+
// NOT-571: Muse writes the identical entry Claude writes (NOT-563) —
|
|
133
|
+
// the same <folder>/.mcp.json, the same shape — so the two clients no
|
|
134
|
+
// longer overwrite each other's agent-deck entry.
|
|
135
|
+
if (options?.workspaceRoot) {
|
|
136
|
+
// Per-folder pure-MCP entry: the daemon resolves the deck from
|
|
137
|
+
// `.agent-deck/use.json` — no deck id in the file.
|
|
138
|
+
return {
|
|
139
|
+
type: 'http',
|
|
140
|
+
url: buildMcpUrl(endpoint),
|
|
141
|
+
headers: {
|
|
142
|
+
'x-agent-deck-workspace': node_path_1.default.resolve(options.workspaceRoot),
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
// Global setup fallback: headerless pure HTTP, no launcher and no
|
|
147
|
+
// executable lookup. (The per-folder form above already returned, so
|
|
148
|
+
// no workspaceRoot is in scope here.)
|
|
149
|
+
return buildGlobalFallbackHttpEntry(endpoint);
|
|
90
150
|
}
|
|
91
|
-
if (client === '
|
|
92
|
-
const env = {
|
|
93
|
-
AGENT_DECK_MCP_PORT: String(endpoint.mcpPort),
|
|
94
|
-
AGENT_DECK_HOST: endpoint.host,
|
|
95
|
-
};
|
|
151
|
+
if (client === 'cursor') {
|
|
96
152
|
if (options?.workspaceRoot) {
|
|
97
|
-
|
|
153
|
+
// NOT-567 per-folder pure-MCP entry: the daemon resolves the deck
|
|
154
|
+
// from `.agent-deck/use.json` — no deck id in the file. Cursor
|
|
155
|
+
// does not interpolate `${workspaceFolder}` in header values, so
|
|
156
|
+
// the absolute folder path is written out.
|
|
157
|
+
return {
|
|
158
|
+
url: buildMcpUrl(endpoint),
|
|
159
|
+
headers: {
|
|
160
|
+
'x-agent-deck-workspace': node_path_1.default.resolve(options.workspaceRoot),
|
|
161
|
+
},
|
|
162
|
+
};
|
|
98
163
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
164
|
+
// NOT-567 global setup fallback: headerless pure HTTP, no launcher
|
|
165
|
+
// and no executable lookup. Unassigned folders connect through it
|
|
166
|
+
// and land in the explain-only session.
|
|
167
|
+
return {
|
|
168
|
+
url: buildMcpUrl(endpoint),
|
|
104
169
|
};
|
|
105
|
-
return entry;
|
|
106
170
|
}
|
|
107
|
-
|
|
108
|
-
AGENT_DECK_MCP_PORT: String(endpoint.mcpPort),
|
|
109
|
-
AGENT_DECK_HOST: endpoint.host,
|
|
110
|
-
};
|
|
111
|
-
if (options?.workspaceRoot) {
|
|
112
|
-
env.AGENT_DECK_WORKSPACE = node_path_1.default.resolve(options.workspaceRoot);
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
command: 'agent-deck',
|
|
116
|
-
args: ['mcp-launch'],
|
|
117
|
-
env,
|
|
118
|
-
};
|
|
171
|
+
throw new Error(`Unsupported client: ${client}`);
|
|
119
172
|
}
|
|
120
|
-
/**
|
|
121
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Pure-MCP HTTP entry (NOT-567): a `url` with no `command` — the
|
|
175
|
+
* per-folder entry carrying the workspace header, or the headerless
|
|
176
|
+
* global fallback. No executable lookup on the connection path.
|
|
177
|
+
*/
|
|
178
|
+
function isHttpAgentDeckEntry(entry) {
|
|
122
179
|
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
123
180
|
return false;
|
|
124
181
|
}
|
|
125
182
|
const record = entry;
|
|
126
183
|
return typeof record.url === 'string' && typeof record.command !== 'string';
|
|
127
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Raw `x-agent-deck-workspace` header value from a pure-MCP HTTP entry
|
|
187
|
+
* (NOT-567). Returned as-is: Cursor sends header values literally, so a
|
|
188
|
+
* value carrying `${...}` interpolation is for the caller to flag, never
|
|
189
|
+
* to resolve.
|
|
190
|
+
*/
|
|
191
|
+
function readHttpWorkspaceHeader(entry) {
|
|
192
|
+
if (!isHttpAgentDeckEntry(entry)) {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
const headers = entry.headers;
|
|
196
|
+
if (!headers || typeof headers !== 'object' || Array.isArray(headers)) {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
const workspaceRoot = headers['x-agent-deck-workspace'];
|
|
200
|
+
return typeof workspaceRoot === 'string' && workspaceRoot.length > 0 ? workspaceRoot : undefined;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Pre-1.7 Cursor/HTTP entries used bare `url` with no deck-assignment
|
|
204
|
+
* launcher. Same url-without-command shape as {@link isHttpAgentDeckEntry};
|
|
205
|
+
* kept under this name for the Claude legacy paths.
|
|
206
|
+
*/
|
|
207
|
+
function isLegacyBareHttpAgentDeckEntry(entry) {
|
|
208
|
+
return isHttpAgentDeckEntry(entry);
|
|
209
|
+
}
|
|
128
210
|
function isMcpLaunchEntry(entry) {
|
|
129
211
|
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
130
212
|
return false;
|
|
@@ -140,161 +222,46 @@ function isMcpLaunchEntry(entry) {
|
|
|
140
222
|
const args = record.args;
|
|
141
223
|
return Array.isArray(args) && args.length === 1 && args[0] === 'mcp-launch';
|
|
142
224
|
}
|
|
143
|
-
|
|
225
|
+
/**
|
|
226
|
+
* True when a JSON `agent-deck` entry is a legacy Claude Code launcher
|
|
227
|
+
* entry (NOT-566): an `agent-deck mcp-launch` entry carrying
|
|
228
|
+
* `type: 'stdio'` or an `AGENT_DECK_WORKSPACE` env pin. Every launcher
|
|
229
|
+
* entry `use`/`setup --client claude` ever wrote carries at least one of
|
|
230
|
+
* those markers — project entries carry both, global entries the type.
|
|
231
|
+
*
|
|
232
|
+
* Muse-shaped launcher entries carry the same command/args but never
|
|
233
|
+
* `type` or the workspace pin, so they never match here; they match
|
|
234
|
+
* {@link isLegacyMuseLaunchEntry} instead, and the upgrade rewrite
|
|
235
|
+
* handles each marker with its own conversion (NOT-572).
|
|
236
|
+
*/
|
|
237
|
+
function isLegacyClaudeLaunchEntry(entry) {
|
|
144
238
|
if (!isMcpLaunchEntry(entry)) {
|
|
145
|
-
return
|
|
239
|
+
return false;
|
|
146
240
|
}
|
|
147
|
-
const
|
|
241
|
+
const record = entry;
|
|
242
|
+
if (record.type === 'stdio') {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
const env = record.env;
|
|
148
246
|
if (!env || typeof env !== 'object' || Array.isArray(env)) {
|
|
149
|
-
return
|
|
247
|
+
return false;
|
|
150
248
|
}
|
|
151
249
|
const workspaceRoot = env.AGENT_DECK_WORKSPACE;
|
|
152
|
-
return typeof workspaceRoot === 'string' && workspaceRoot.length > 0
|
|
153
|
-
? node_path_1.default.resolve(workspaceRoot)
|
|
154
|
-
: undefined;
|
|
250
|
+
return typeof workspaceRoot === 'string' && workspaceRoot.length > 0;
|
|
155
251
|
}
|
|
156
252
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
253
|
+
* True when a JSON `agent-deck` entry is a legacy Muse launcher entry
|
|
254
|
+
* (NOT-387 shape, retired NOT-572): an `agent-deck mcp-launch` entry
|
|
255
|
+
* with neither Claude marker — no `type: 'stdio'`, no
|
|
256
|
+
* `AGENT_DECK_WORKSPACE` env pin. Every launcher entry older
|
|
257
|
+
* `use --client muse` and `setup --client muse --scope project` wrote
|
|
258
|
+
* has exactly this shape (command/args/env only). Nothing builds it;
|
|
259
|
+
* the upgrade path converts it to the HTTP shape (or removes it when
|
|
260
|
+
* the folder has no assignment), and setup/use only detect it for
|
|
261
|
+
* legacy warnings.
|
|
164
262
|
*/
|
|
165
|
-
function
|
|
166
|
-
|
|
167
|
-
const existingConfig = readJsonFile(configPath);
|
|
168
|
-
const servers = existingConfig.mcpServers && typeof existingConfig.mcpServers === 'object'
|
|
169
|
-
? existingConfig.mcpServers
|
|
170
|
-
: {};
|
|
171
|
-
const existing = servers['agent-deck'];
|
|
172
|
-
const workspaceRoot = options?.workspaceRoot ? node_path_1.default.resolve(options.workspaceRoot) : undefined;
|
|
173
|
-
const desired = buildAgentDeckEntry('cursor', endpoint, { workspaceRoot });
|
|
174
|
-
if (existing === undefined) {
|
|
175
|
-
if (!workspaceRoot) {
|
|
176
|
-
return { action: 'diagnostic', path: configPath, reason: 'missing' };
|
|
177
|
-
}
|
|
178
|
-
writeJsonFile(configPath, mergeMcpServerConfig(existingConfig, desired));
|
|
179
|
-
return { action: 'created', path: configPath, reason: 'missing', workspaceRoot };
|
|
180
|
-
}
|
|
181
|
-
if (isLegacyBareHttpAgentDeckEntry(existing)) {
|
|
182
|
-
if (!workspaceRoot) {
|
|
183
|
-
return { action: 'diagnostic', path: configPath, reason: 'bare-url' };
|
|
184
|
-
}
|
|
185
|
-
writeJsonFile(configPath, mergeMcpServerConfig(existingConfig, desired));
|
|
186
|
-
return {
|
|
187
|
-
action: 'upgraded',
|
|
188
|
-
path: configPath,
|
|
189
|
-
reason: 'bare-url',
|
|
190
|
-
workspaceRoot,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
if (!isMcpLaunchEntry(existing)) {
|
|
194
|
-
return workspaceRoot
|
|
195
|
-
? { action: 'skipped', path: configPath, reason: 'custom-entry' }
|
|
196
|
-
: { action: 'diagnostic', path: configPath, reason: 'custom-entry' };
|
|
197
|
-
}
|
|
198
|
-
const currentWorkspace = readCursorWorkspaceRoot(existing);
|
|
199
|
-
const existingEnv = existing.env;
|
|
200
|
-
const env = existingEnv && typeof existingEnv === 'object' && !Array.isArray(existingEnv)
|
|
201
|
-
? existingEnv
|
|
202
|
-
: {};
|
|
203
|
-
const endpointChanged = env.AGENT_DECK_HOST !== endpoint.host ||
|
|
204
|
-
env.AGENT_DECK_MCP_PORT !== String(endpoint.mcpPort);
|
|
205
|
-
if (!workspaceRoot) {
|
|
206
|
-
if (!currentWorkspace) {
|
|
207
|
-
return { action: 'diagnostic', path: configPath, reason: 'missing-workspace' };
|
|
208
|
-
}
|
|
209
|
-
if (endpointChanged) {
|
|
210
|
-
return {
|
|
211
|
-
action: 'diagnostic',
|
|
212
|
-
path: configPath,
|
|
213
|
-
reason: 'endpoint-changed',
|
|
214
|
-
workspaceRoot: currentWorkspace,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
return { action: 'ok', path: configPath, workspaceRoot: currentWorkspace };
|
|
218
|
-
}
|
|
219
|
-
if (currentWorkspace === workspaceRoot && !endpointChanged) {
|
|
220
|
-
return { action: 'ok', path: configPath, workspaceRoot };
|
|
221
|
-
}
|
|
222
|
-
const reason = !currentWorkspace
|
|
223
|
-
? 'missing-workspace'
|
|
224
|
-
: currentWorkspace !== workspaceRoot
|
|
225
|
-
? 'workspace-changed'
|
|
226
|
-
: 'endpoint-changed';
|
|
227
|
-
const currentRecord = existing;
|
|
228
|
-
const desiredEnv = desired.env;
|
|
229
|
-
const repaired = {
|
|
230
|
-
...currentRecord,
|
|
231
|
-
...desired,
|
|
232
|
-
env: {
|
|
233
|
-
...env,
|
|
234
|
-
...desiredEnv,
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
writeJsonFile(configPath, mergeMcpServerConfig(existingConfig, repaired));
|
|
238
|
-
return reason === 'workspace-changed'
|
|
239
|
-
? {
|
|
240
|
-
action: 'updated',
|
|
241
|
-
path: configPath,
|
|
242
|
-
reason,
|
|
243
|
-
workspaceRoot,
|
|
244
|
-
previousWorkspaceRoot: currentWorkspace,
|
|
245
|
-
}
|
|
246
|
-
: { action: 'updated', path: configPath, reason, workspaceRoot };
|
|
247
|
-
}
|
|
248
|
-
function formatCursorGlobalMcpEnsureMessage(result) {
|
|
249
|
-
if (result.action === 'ok') {
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
if (result.action === 'skipped') {
|
|
253
|
-
return [
|
|
254
|
-
`Cursor MCP: left custom agent-deck entry unchanged in ${result.path}.`,
|
|
255
|
-
' Configure that wrapper to run `agent-deck mcp-launch` with AGENT_DECK_WORKSPACE set to this workspace.',
|
|
256
|
-
].join('\n');
|
|
257
|
-
}
|
|
258
|
-
if (result.action === 'diagnostic') {
|
|
259
|
-
const detail = result.reason === 'missing'
|
|
260
|
-
? 'no user-level agent-deck entry exists'
|
|
261
|
-
: result.reason === 'bare-url'
|
|
262
|
-
? 'legacy bare URL has no deck-assignment launcher'
|
|
263
|
-
: result.reason === 'missing-workspace'
|
|
264
|
-
? 'mcp-launch has no AGENT_DECK_WORKSPACE pin'
|
|
265
|
-
: result.reason === 'endpoint-changed'
|
|
266
|
-
? 'the configured Agent Deck endpoint is stale'
|
|
267
|
-
: 'a custom agent-deck wrapper cannot be validated automatically';
|
|
268
|
-
return [
|
|
269
|
-
`Cursor MCP diagnostic: ${detail} in ${result.path}. No changes made.`,
|
|
270
|
-
` ${exports.CURSOR_MCP_RECOVERY_HINT}`,
|
|
271
|
-
].join('\n');
|
|
272
|
-
}
|
|
273
|
-
if (result.action === 'created') {
|
|
274
|
-
return [
|
|
275
|
-
`Cursor MCP: created ${result.path} and pinned it to ${result.workspaceRoot}.`,
|
|
276
|
-
' Reload Cursor MCP (or restart Cursor). Cursor mcp_auth is not required.',
|
|
277
|
-
].join('\n');
|
|
278
|
-
}
|
|
279
|
-
if (result.action === 'upgraded') {
|
|
280
|
-
return [
|
|
281
|
-
`Cursor MCP: upgraded the legacy bare URL in ${result.path} to mcp-launch and pinned it to ${result.workspaceRoot}.`,
|
|
282
|
-
' Reload Cursor MCP (or restart Cursor). Cursor mcp_auth is not required.',
|
|
283
|
-
].join('\n');
|
|
284
|
-
}
|
|
285
|
-
if (result.reason === 'workspace-changed') {
|
|
286
|
-
return [
|
|
287
|
-
`Cursor MCP: moved the user-level workspace pin from ${result.previousWorkspaceRoot} to ${result.workspaceRoot} in ${result.path}.`,
|
|
288
|
-
' Cursor user-level Agent Deck is last explicit `agent-deck use` wins; reload Cursor MCP (or restart Cursor).',
|
|
289
|
-
].join('\n');
|
|
290
|
-
}
|
|
291
|
-
const detail = result.reason === 'missing-workspace'
|
|
292
|
-
? `added the missing workspace pin ${result.workspaceRoot}`
|
|
293
|
-
: `updated the endpoint while keeping workspace ${result.workspaceRoot}`;
|
|
294
|
-
return [
|
|
295
|
-
`Cursor MCP: repaired ${result.path}; ${detail}.`,
|
|
296
|
-
' Reload Cursor MCP (or restart Cursor). Cursor mcp_auth is not required.',
|
|
297
|
-
].join('\n');
|
|
263
|
+
function isLegacyMuseLaunchEntry(entry) {
|
|
264
|
+
return isMcpLaunchEntry(entry) && !isLegacyClaudeLaunchEntry(entry);
|
|
298
265
|
}
|
|
299
266
|
function readJsonFile(filePath) {
|
|
300
267
|
if (!node_fs_1.default.existsSync(filePath)) {
|
|
@@ -343,4 +310,346 @@ function writeJsonFile(filePath, data) {
|
|
|
343
310
|
node_fs_1.default.mkdirSync(node_path_1.default.dirname(filePath), { recursive: true });
|
|
344
311
|
node_fs_1.default.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
|
|
345
312
|
}
|
|
313
|
+
function readTextFile(filePath) {
|
|
314
|
+
if (!node_fs_1.default.existsSync(filePath)) {
|
|
315
|
+
return '';
|
|
316
|
+
}
|
|
317
|
+
return node_fs_1.default.readFileSync(filePath, 'utf8');
|
|
318
|
+
}
|
|
319
|
+
function writeTextFile(filePath, text) {
|
|
320
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(filePath), { recursive: true });
|
|
321
|
+
node_fs_1.default.writeFileSync(filePath, text, 'utf8');
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Matches our managed Codex section headers: the `[mcp_servers.agent-deck]`
|
|
325
|
+
* parent plus any `[mcp_servers.agent-deck.<sub>]` sub-table (the layout
|
|
326
|
+
* `codex mcp add --env` writes). Bare or quoted key, whitespace-tolerant,
|
|
327
|
+
* with any trailing comment. Never matches a merely prefixed sibling such
|
|
328
|
+
* as `[mcp_servers.agent-deck-env]`.
|
|
329
|
+
*/
|
|
330
|
+
const CODEX_AGENT_DECK_SECTION_RE = /^\s*\[\s*mcp_servers\s*\.\s*("agent-deck"|'agent-deck'|agent-deck)\s*(\.\s*[^\]#]+)?\]\s*(?:#.*)?$/;
|
|
331
|
+
/** Matches a bare `[mcp_servers]` section header holding dotted/inline keys. */
|
|
332
|
+
const CODEX_MCP_SERVERS_SECTION_RE = /^\s*\[\s*("mcp_servers"|'mcp_servers'|mcp_servers)\s*\]\s*(?:#.*)?$/;
|
|
333
|
+
/** Matches an `agent-deck` key definition start inside `[mcp_servers]`. */
|
|
334
|
+
const CODEX_MCP_SERVERS_AGENT_DECK_KEY_RE = /^\s*("agent-deck"|'agent-deck'|agent-deck)\s*(?=[.=])/;
|
|
335
|
+
function isTomlSectionHeader(line) {
|
|
336
|
+
return line.trimStart().startsWith('[');
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Net `{`/`[` minus `}`/`]` depth change of one TOML line, ignoring string
|
|
340
|
+
* literals and `#` comments so braces inside values never unbalance the
|
|
341
|
+
* scan. Used to skip multi-line inline tables when removing stale keys.
|
|
342
|
+
*/
|
|
343
|
+
function tomlBracketDelta(line) {
|
|
344
|
+
let code = '';
|
|
345
|
+
let i = 0;
|
|
346
|
+
while (i < line.length) {
|
|
347
|
+
const ch = line[i];
|
|
348
|
+
if (ch === '"') {
|
|
349
|
+
i += 1;
|
|
350
|
+
while (i < line.length && line[i] !== '"') {
|
|
351
|
+
i += line[i] === '\\' ? 2 : 1;
|
|
352
|
+
}
|
|
353
|
+
i += 1;
|
|
354
|
+
}
|
|
355
|
+
else if (ch === "'") {
|
|
356
|
+
i += 1;
|
|
357
|
+
while (i < line.length && line[i] !== "'") {
|
|
358
|
+
i += 1;
|
|
359
|
+
}
|
|
360
|
+
i += 1;
|
|
361
|
+
}
|
|
362
|
+
else if (ch === '#') {
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
code += ch;
|
|
367
|
+
i += 1;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
let delta = 0;
|
|
371
|
+
for (const c of code) {
|
|
372
|
+
if (c === '{' || c === '[') {
|
|
373
|
+
delta += 1;
|
|
374
|
+
}
|
|
375
|
+
else if (c === '}' || c === ']') {
|
|
376
|
+
delta -= 1;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return delta;
|
|
380
|
+
}
|
|
381
|
+
function escapeTomlBasicString(value) {
|
|
382
|
+
return value
|
|
383
|
+
.replaceAll('\\', '\\\\')
|
|
384
|
+
.replaceAll('"', '\\"')
|
|
385
|
+
.replaceAll('\n', '\\n')
|
|
386
|
+
.replaceAll('\r', '\\r')
|
|
387
|
+
.replaceAll('\t', '\\t');
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Canonical `[mcp_servers.agent-deck]` TOML block (NOT-563). No trailing
|
|
391
|
+
* newline — the merge helper owns file framing.
|
|
392
|
+
*/
|
|
393
|
+
function formatCodexMcpSection(entry) {
|
|
394
|
+
const headers = Object.entries(entry.http_headers)
|
|
395
|
+
.map(([name, value]) => `"${escapeTomlBasicString(name)}" = "${escapeTomlBasicString(value)}"`)
|
|
396
|
+
.join(', ');
|
|
397
|
+
return [
|
|
398
|
+
'[mcp_servers.agent-deck]',
|
|
399
|
+
`url = "${escapeTomlBasicString(entry.url)}"`,
|
|
400
|
+
`http_headers = { ${headers} }`,
|
|
401
|
+
].join('\n');
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Canonical headerless `[mcp_servers.agent-deck]` TOML block: the global
|
|
405
|
+
* unassigned-folder fallback (NOT-565, design §4). Same-name per-folder
|
|
406
|
+
* entries written by `agent-deck use` shadow it. No trailing newline —
|
|
407
|
+
* the merge helper owns file framing.
|
|
408
|
+
*/
|
|
409
|
+
function formatCodexGlobalFallbackSection(endpoint) {
|
|
410
|
+
return [
|
|
411
|
+
'[mcp_servers.agent-deck]',
|
|
412
|
+
`url = "${escapeTomlBasicString(buildMcpUrl(endpoint))}"`,
|
|
413
|
+
].join('\n');
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* True when Codex TOML defines the `agent-deck` server through the legacy
|
|
417
|
+
* stdio launcher (NOT-566): a managed `[mcp_servers.agent-deck]` section
|
|
418
|
+
* (or sub-table) whose body mentions `mcp-launch`, or a dotted/inline
|
|
419
|
+
* `agent-deck` key under a bare `[mcp_servers]` section mentioning it.
|
|
420
|
+
* Pure-HTTP sections, custom entries, and other servers never match —
|
|
421
|
+
* only what the legacy-upgrade rewrite owns.
|
|
422
|
+
*/
|
|
423
|
+
function codexTomlHasLauncherEntry(existingText) {
|
|
424
|
+
if (!existingText.includes('mcp-launch')) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
const lines = existingText.split('\n');
|
|
428
|
+
const headerKind = new Map();
|
|
429
|
+
for (const [index, line] of lines.entries()) {
|
|
430
|
+
if (!isTomlSectionHeader(line)) {
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
if (CODEX_AGENT_DECK_SECTION_RE.test(line)) {
|
|
434
|
+
headerKind.set(index, 'managed');
|
|
435
|
+
}
|
|
436
|
+
else if (CODEX_MCP_SERVERS_SECTION_RE.test(line)) {
|
|
437
|
+
headerKind.set(index, 'servers');
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
headerKind.set(index, 'other');
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const headerIdxs = [...headerKind.keys()];
|
|
444
|
+
const rangeEnd = (headerIdx) => {
|
|
445
|
+
for (const candidate of headerIdxs) {
|
|
446
|
+
if (candidate > headerIdx) {
|
|
447
|
+
return candidate;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return lines.length;
|
|
451
|
+
};
|
|
452
|
+
for (const [headerIdx, kind] of headerKind) {
|
|
453
|
+
const end = rangeEnd(headerIdx);
|
|
454
|
+
if (kind === 'managed') {
|
|
455
|
+
for (let index = headerIdx + 1; index < end; index += 1) {
|
|
456
|
+
if (lines[index].includes('mcp-launch')) {
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
if (kind !== 'servers') {
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
// Dotted/inline agent-deck definitions, same top-level-key rule as
|
|
466
|
+
// the merge: a nested `agent-deck` key inside another server's inline
|
|
467
|
+
// table belongs to that server, not to us.
|
|
468
|
+
let depth = 0;
|
|
469
|
+
let index = headerIdx + 1;
|
|
470
|
+
while (index < end) {
|
|
471
|
+
const line = lines[index];
|
|
472
|
+
if (depth === 0 && CODEX_MCP_SERVERS_AGENT_DECK_KEY_RE.test(line)) {
|
|
473
|
+
let block = line;
|
|
474
|
+
depth += tomlBracketDelta(line);
|
|
475
|
+
index += 1;
|
|
476
|
+
while (depth > 0 && index < end) {
|
|
477
|
+
block += `\n${lines[index]}`;
|
|
478
|
+
depth += tomlBracketDelta(lines[index]);
|
|
479
|
+
index += 1;
|
|
480
|
+
}
|
|
481
|
+
depth = 0;
|
|
482
|
+
if (block.includes('mcp-launch')) {
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
depth += tomlBracketDelta(line);
|
|
488
|
+
if (depth < 0) {
|
|
489
|
+
depth = 0;
|
|
490
|
+
}
|
|
491
|
+
index += 1;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Merge our managed section into existing Codex TOML, preserving every
|
|
498
|
+
* unrelated byte. Stale agent-deck content in any form is removed first:
|
|
499
|
+
* the parent section, every `[mcp_servers.agent-deck.<sub>]` sub-table
|
|
500
|
+
* wherever it sits, and dotted/inline `agent-deck` keys under a bare
|
|
501
|
+
* `[mcp_servers]` section (multi-line inline tables included). The first
|
|
502
|
+
* managed section is replaced in place with its header normalized to the
|
|
503
|
+
* bare form; otherwise the section is appended after a blank separator.
|
|
504
|
+
* Idempotent: merging twice yields byte-identical text. The result ends
|
|
505
|
+
* with exactly one newline when the section is the last content.
|
|
506
|
+
*/
|
|
507
|
+
function mergeCodexTomlConfig(existingText, section) {
|
|
508
|
+
const lines = existingText.split('\n');
|
|
509
|
+
const headerKind = new Map();
|
|
510
|
+
for (const [index, line] of lines.entries()) {
|
|
511
|
+
if (!isTomlSectionHeader(line)) {
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
if (CODEX_AGENT_DECK_SECTION_RE.test(line)) {
|
|
515
|
+
headerKind.set(index, 'managed');
|
|
516
|
+
}
|
|
517
|
+
else if (CODEX_MCP_SERVERS_SECTION_RE.test(line)) {
|
|
518
|
+
headerKind.set(index, 'servers');
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
headerKind.set(index, 'other');
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const headerIdxs = [...headerKind.keys()];
|
|
525
|
+
const rangeEnd = (headerIdx) => {
|
|
526
|
+
for (const candidate of headerIdxs) {
|
|
527
|
+
if (candidate > headerIdx) {
|
|
528
|
+
return candidate;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return lines.length;
|
|
532
|
+
};
|
|
533
|
+
// Dotted/inline agent-deck definitions inside bare [mcp_servers] bodies.
|
|
534
|
+
// Only top-level keys count, so a nested `agent-deck` key inside another
|
|
535
|
+
// server's inline table is left alone.
|
|
536
|
+
const removed = new Set();
|
|
537
|
+
for (const [headerIdx, kind] of headerKind) {
|
|
538
|
+
if (kind !== 'servers') {
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
const end = rangeEnd(headerIdx);
|
|
542
|
+
let depth = 0;
|
|
543
|
+
let index = headerIdx + 1;
|
|
544
|
+
while (index < end) {
|
|
545
|
+
const line = lines[index];
|
|
546
|
+
if (depth === 0 && CODEX_MCP_SERVERS_AGENT_DECK_KEY_RE.test(line)) {
|
|
547
|
+
depth += tomlBracketDelta(line);
|
|
548
|
+
removed.add(index);
|
|
549
|
+
index += 1;
|
|
550
|
+
while (depth > 0 && index < end) {
|
|
551
|
+
depth += tomlBracketDelta(lines[index]);
|
|
552
|
+
removed.add(index);
|
|
553
|
+
index += 1;
|
|
554
|
+
}
|
|
555
|
+
depth = 0;
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
depth += tomlBracketDelta(line);
|
|
559
|
+
if (depth < 0) {
|
|
560
|
+
depth = 0;
|
|
561
|
+
}
|
|
562
|
+
index += 1;
|
|
563
|
+
}
|
|
564
|
+
// A removed key block takes one following blank separator with it when
|
|
565
|
+
// it sits right after the header or between blank lines, so no doubled
|
|
566
|
+
// blank line is left behind.
|
|
567
|
+
for (let i = headerIdx + 1; i < end; i += 1) {
|
|
568
|
+
if (!removed.has(i) || (i > headerIdx + 1 && removed.has(i - 1))) {
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
let blockEnd = i;
|
|
572
|
+
while (blockEnd + 1 < end && removed.has(blockEnd + 1)) {
|
|
573
|
+
blockEnd += 1;
|
|
574
|
+
}
|
|
575
|
+
const after = blockEnd + 1;
|
|
576
|
+
const beforeIsSeparator = i === headerIdx + 1 || lines[i - 1].trim() === '';
|
|
577
|
+
if (after < end && !removed.has(after) && lines[after].trim() === '' && beforeIsSeparator) {
|
|
578
|
+
removed.add(after);
|
|
579
|
+
}
|
|
580
|
+
i = blockEnd;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
const managedHeaders = headerIdxs.filter((index) => headerKind.get(index) === 'managed');
|
|
584
|
+
const appendSection = (text) => {
|
|
585
|
+
let framed = text;
|
|
586
|
+
if (framed !== '' && !framed.endsWith('\n')) {
|
|
587
|
+
framed += '\n';
|
|
588
|
+
}
|
|
589
|
+
if (framed !== '' && !framed.endsWith('\n\n')) {
|
|
590
|
+
framed += '\n';
|
|
591
|
+
}
|
|
592
|
+
return `${framed}${section}\n`;
|
|
593
|
+
};
|
|
594
|
+
if (managedHeaders.length === 0) {
|
|
595
|
+
if (removed.size === 0) {
|
|
596
|
+
return appendSection(existingText);
|
|
597
|
+
}
|
|
598
|
+
// Only dotted/inline definitions: drop them, then append. Inserting a
|
|
599
|
+
// section header mid-body would reparent the remaining [mcp_servers]
|
|
600
|
+
// keys under agent-deck.
|
|
601
|
+
return appendSection(lines.filter((_, index) => !removed.has(index)).join('\n'));
|
|
602
|
+
}
|
|
603
|
+
for (const headerIdx of managedHeaders) {
|
|
604
|
+
const end = rangeEnd(headerIdx);
|
|
605
|
+
for (let index = headerIdx; index < end; index += 1) {
|
|
606
|
+
removed.add(index);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const first = managedHeaders[0];
|
|
610
|
+
const firstEnd = rangeEnd(first);
|
|
611
|
+
let nextKept = firstEnd;
|
|
612
|
+
while (nextKept < lines.length && removed.has(nextKept)) {
|
|
613
|
+
nextKept += 1;
|
|
614
|
+
}
|
|
615
|
+
// Keep one blank separator before the next surviving content when the
|
|
616
|
+
// removed block had any: trailing blanks of the replaced range or blanks
|
|
617
|
+
// in the gap up to the next kept line.
|
|
618
|
+
let hadSeparator = false;
|
|
619
|
+
for (let index = firstEnd - 1; index > first; index -= 1) {
|
|
620
|
+
if (lines[index].trim() === '') {
|
|
621
|
+
hadSeparator = true;
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (!hadSeparator) {
|
|
628
|
+
for (let index = firstEnd; index < nextKept; index += 1) {
|
|
629
|
+
if (lines[index].trim() === '') {
|
|
630
|
+
hadSeparator = true;
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
const out = [];
|
|
636
|
+
for (let index = 0; index < first; index += 1) {
|
|
637
|
+
if (!removed.has(index)) {
|
|
638
|
+
out.push(lines[index]);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
out.push(...section.split('\n'));
|
|
642
|
+
const rest = [];
|
|
643
|
+
for (let index = nextKept; index < lines.length; index += 1) {
|
|
644
|
+
if (!removed.has(index)) {
|
|
645
|
+
rest.push(lines[index]);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (hadSeparator && rest.some((line) => line.trim() !== '')) {
|
|
649
|
+
out.push('');
|
|
650
|
+
}
|
|
651
|
+
out.push(...rest);
|
|
652
|
+
const merged = out.join('\n');
|
|
653
|
+
return merged.endsWith('\n') ? merged : `${merged}\n`;
|
|
654
|
+
}
|
|
346
655
|
//# sourceMappingURL=mcp-config.js.map
|