@uncarved/jade 0.3.1 → 0.4.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/api.d.ts +1 -1
- package/dist/api.js +1 -1
- package/dist/host.d.ts +2 -0
- package/dist/host.js +39 -5
- package/dist/host.js.map +1 -1
- package/dist/remote.js +5 -0
- package/dist/remote.js.map +1 -1
- package/dist/session.d.ts +7 -0
- package/dist/session.js +482 -27
- package/dist/session.js.map +1 -1
- package/package.json +4 -4
- package/plugins/approval/index.ts +36 -14
- package/plugins/approval/policy.ts +15 -10
- package/plugins/approval/review.ts +9 -5
- package/plugins/checks/checks.ts +10 -7
- package/plugins/checks/index.ts +13 -13
- package/plugins/checks/plugin.json +1 -1
- package/plugins/checks/project.ts +37 -38
- package/plugins/commands/index.ts +27 -3
- package/plugins/compact/compact.ts +13 -5
- package/plugins/compact/index.ts +20 -3
- package/plugins/compact/style.ts +13 -14
- package/plugins/completions/index.ts +35 -0
- package/plugins/completions/plugin.json +7 -0
- package/plugins/copy/index.ts +46 -0
- package/plugins/copy/plugin.json +7 -0
- package/plugins/editor/index.ts +10 -4
- package/plugins/fs/diff.ts +7 -6
- package/plugins/fs/fs.ts +8 -4
- package/plugins/fs/grep.ts +42 -9
- package/plugins/fs/index.ts +2 -7
- package/plugins/fs/plugin.json +1 -1
- package/plugins/fs/renderers.ts +16 -15
- package/plugins/fs/style.ts +16 -15
- package/plugins/hooks/index.ts +3 -2
- package/plugins/keys/index.ts +5 -1
- package/plugins/mcp/index.ts +197 -78
- package/plugins/mcp/install.ts +5 -3
- package/plugins/mcp/mcp.ts +163 -11
- package/plugins/mcp/plugin.json +2 -1
- package/plugins/mcp/project.ts +47 -50
- package/plugins/memory/index.ts +4 -4
- package/plugins/memory/style.ts +13 -14
- package/plugins/mentions/candidates.ts +67 -0
- package/plugins/mentions/index.ts +12 -5
- package/plugins/mentions/plugin.json +1 -1
- package/plugins/mentions/style.ts +13 -14
- package/plugins/models/configure.ts +10 -9
- package/plugins/models/index.ts +27 -1
- package/plugins/modes/index.ts +13 -2
- package/plugins/print/index.ts +7 -4
- package/plugins/prompts/index.ts +0 -0
- package/plugins/renderers/index.ts +10 -5
- package/plugins/repeats/index.ts +8 -8
- package/plugins/schedule/index.ts +2 -0
- package/plugins/screenshot/browser.ts +10 -0
- package/plugins/sessions/index.ts +48 -2
- package/plugins/shell/index.ts +20 -25
- package/plugins/shell/plugin.json +1 -2
- package/plugins/shell/renderers.ts +9 -7
- package/plugins/shell/shell.ts +3 -1
- package/plugins/skills/index.ts +28 -19
- package/plugins/skills/project.ts +12 -7
- package/plugins/steer/index.ts +5 -4
- package/plugins/task/index.ts +80 -50
- package/plugins/task/plugin.json +6 -2
- package/plugins/task/style.ts +13 -14
- package/plugins/task/subagent.ts +67 -184
- package/plugins/todo/index.ts +39 -9
- package/plugins/tools/index.ts +9 -2
- package/plugins/tui/frontend.ts +139 -89
- package/plugins/tui/index.ts +2 -3
- package/plugins/tui/mentions.ts +11 -80
- package/plugins/tui/plugin.json +1 -1
- package/plugins/tui/screen.ts +55 -5
- package/plugins/tui/transcript.ts +17 -7
- package/plugins/tui/tui.ts +337 -101
- package/plugins/tui/vendor.ts +1 -1
- package/plugins/undo/checkpoint.ts +5 -3
- package/plugins/undo/index.ts +43 -14
- package/plugins/undo/style.ts +13 -14
- package/plugins/web/index.ts +7 -18
- package/plugins/web/plugin.json +1 -1
- package/plugins-dist/approval/index.js +363 -418
- package/plugins-dist/approval/policy.js +391 -508
- package/plugins-dist/approval/review.js +132 -158
- package/plugins-dist/approval/schema.js +50 -55
- package/plugins-dist/ask/index.js +115 -129
- package/plugins-dist/budget/index.js +27 -31
- package/plugins-dist/checks/checks.js +293 -329
- package/plugins-dist/checks/index.js +119 -139
- package/plugins-dist/checks/plugin.json +2 -1
- package/plugins-dist/checks/project.js +57 -65
- package/plugins-dist/commands/index.js +47 -29
- package/plugins-dist/compact/compact.js +233 -249
- package/plugins-dist/compact/index.js +98 -95
- package/plugins-dist/compact/style.js +9 -14
- package/plugins-dist/completions/index.js +30 -0
- package/plugins-dist/completions/plugin.json +9 -0
- package/plugins-dist/continue/index.js +40 -52
- package/plugins-dist/copy/index.js +40 -0
- package/plugins-dist/copy/plugin.json +9 -0
- package/plugins-dist/cost/index.js +98 -115
- package/plugins-dist/custom-commands/index.js +55 -72
- package/plugins-dist/editor/index.js +64 -72
- package/plugins-dist/fs/diff.js +111 -124
- package/plugins-dist/fs/fs.js +426 -469
- package/plugins-dist/fs/grep.js +262 -253
- package/plugins-dist/fs/index.js +20 -34
- package/plugins-dist/fs/plugin.json +1 -2
- package/plugins-dist/fs/renderers.js +100 -112
- package/plugins-dist/fs/style.js +11 -15
- package/plugins-dist/fs/sys.js +31 -43
- package/plugins-dist/hooks/index.js +107 -127
- package/plugins-dist/keys/index.js +27 -31
- package/plugins-dist/mcp/index.js +271 -199
- package/plugins-dist/mcp/install.js +123 -137
- package/plugins-dist/mcp/mcp.js +638 -577
- package/plugins-dist/mcp/plugin.json +3 -1
- package/plugins-dist/mcp/project.js +98 -115
- package/plugins-dist/memory/index.js +83 -88
- package/plugins-dist/memory/memory.js +111 -128
- package/plugins-dist/memory/style.js +9 -14
- package/plugins-dist/mentions/attach.js +91 -99
- package/plugins-dist/mentions/candidates.js +49 -0
- package/plugins-dist/mentions/index.js +71 -81
- package/plugins-dist/mentions/plugin.json +2 -1
- package/plugins-dist/mentions/style.js +9 -14
- package/plugins-dist/models/config.js +29 -43
- package/plugins-dist/models/configure.js +392 -473
- package/plugins-dist/models/context.js +14 -22
- package/plugins-dist/models/index.js +182 -189
- package/plugins-dist/models/provider.js +243 -307
- package/plugins-dist/models/saved.js +59 -71
- package/plugins-dist/modes/index.js +138 -165
- package/plugins-dist/plugins/index.js +34 -34
- package/plugins-dist/print/index.js +192 -175
- package/plugins-dist/prompts/index.js +81 -89
- package/plugins-dist/prompts/notes.js +31 -37
- package/plugins-dist/prompts/prompts.js +155 -193
- package/plugins-dist/prompts/results.js +40 -53
- package/plugins-dist/prompts/sys.js +39 -50
- package/plugins-dist/renderers/index.js +32 -32
- package/plugins-dist/repeats/index.js +131 -174
- package/plugins-dist/schedule/cron.js +49 -56
- package/plugins-dist/schedule/index.js +229 -247
- package/plugins-dist/schedule/store.js +93 -109
- package/plugins-dist/scratch/index.js +12 -18
- package/plugins-dist/screenshot/browser.js +136 -154
- package/plugins-dist/screenshot/index.js +37 -46
- package/plugins-dist/screenshot/sys.js +53 -65
- package/plugins-dist/screenshot/tool.js +98 -126
- package/plugins-dist/sessions/index.js +149 -117
- package/plugins-dist/shell/index.js +115 -135
- package/plugins-dist/shell/plugin.json +1 -2
- package/plugins-dist/shell/renderers.js +28 -33
- package/plugins-dist/shell/service.js +17 -23
- package/plugins-dist/shell/shell.js +307 -362
- package/plugins-dist/shell/sys.js +64 -79
- package/plugins-dist/skills/index.js +193 -211
- package/plugins-dist/skills/install.js +122 -149
- package/plugins-dist/skills/project.js +65 -73
- package/plugins-dist/skills/skills.js +135 -171
- package/plugins-dist/steer/index.js +108 -125
- package/plugins-dist/suggest/index.js +235 -259
- package/plugins-dist/task/index.js +130 -117
- package/plugins-dist/task/plugin.json +5 -2
- package/plugins-dist/task/style.js +9 -14
- package/plugins-dist/task/subagent.js +156 -279
- package/plugins-dist/todo/index.js +79 -63
- package/plugins-dist/tools/index.js +36 -42
- package/plugins-dist/tui/editor.js +145 -160
- package/plugins-dist/tui/frontend.js +639 -678
- package/plugins-dist/tui/history.js +34 -37
- package/plugins-dist/tui/index.js +16 -18
- package/plugins-dist/tui/markdown.js +203 -247
- package/plugins-dist/tui/mascot.js +266 -355
- package/plugins-dist/tui/mentions.js +67 -144
- package/plugins-dist/tui/plugin.json +1 -2
- package/plugins-dist/tui/render.js +35 -45
- package/plugins-dist/tui/screen.js +197 -180
- package/plugins-dist/tui/transcript.js +436 -468
- package/plugins-dist/tui/tui.js +1554 -1656
- package/plugins-dist/undo/checkpoint.js +95 -118
- package/plugins-dist/undo/index.js +185 -192
- package/plugins-dist/undo/snapshot.js +83 -99
- package/plugins-dist/undo/style.js +9 -14
- package/plugins-dist/update/index.js +26 -28
- package/plugins-dist/web/env.js +55 -68
- package/plugins-dist/web/index.js +80 -110
- package/plugins-dist/web/plugin.json +1 -2
- package/plugins-dist/web/renderers.js +4 -5
- package/plugins-dist/web/web.js +514 -593
- package/sdk/python/__pycache__/jade_plugin.cpython-312.pyc +0 -0
- package/sdk/python/jade_plugin.py +9 -2
- package/src/api.ts +1 -1
- package/src/host.ts +39 -4
- package/src/remote.ts +6 -1
- package/src/session.ts +489 -34
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
// /mcp add|remove(终端里是 jade mcp add|remove):往配置文件里加一个 MCP 服务或删掉它,不用手改 JSON。
|
|
2
|
-
//
|
|
3
|
-
// 不加 --project 写 $JADE_HOME/mcp.json,加了写 <工作目录>/.jade/mcp.json;文件里其他的内容原样保留。
|
|
4
|
-
// 这里只写配置,不启动服务:进程里的服务只在第一个会话打开时连接,新加的重启 jade 后生效。
|
|
5
|
-
// 项目层的服务照旧在第一次启动前请用户确认:命令不顺带记下确认。这个命令也有命令行的写法(jade mcp add),
|
|
6
|
-
// 模型能经 shell 跑它;如果加了就算确认,模型就能绕过确认。
|
|
7
1
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
8
2
|
import path from "node:path";
|
|
9
3
|
import { checkConfig, describeServer } from "./mcp.js";
|
|
10
4
|
import { display } from "./project.js";
|
|
11
|
-
/** cmd 是 "/mcp" 或 "jade mcp" */
|
|
12
5
|
export const manageUsage = (cmd) => `usage: ${cmd} add <name> [--project] [--env KEY=VALUE]… [--force] [--] <command> [args…]
|
|
13
6
|
${cmd} add <name> --url <url> [--project] [--header "Name: value"]… [--force]
|
|
14
7
|
${cmd} remove <name> [--project]
|
|
@@ -18,143 +11,136 @@ export const manageUsage = (cmd) => `usage: ${cmd} add <name> [--project] [--env
|
|
|
18
11
|
--header an HTTP header for a --url server; values may use \${VAR}
|
|
19
12
|
--force replace a server with the same name
|
|
20
13
|
Everything after <command> is passed to it unchanged, e.g. ${cmd} add fs npx -y @modelcontextprotocol/server-filesystem .`;
|
|
21
|
-
|
|
22
|
-
export const mcpConfigFile = (home, cwd, project) => (project ? path.join(cwd, ".jade", "mcp.json") : path.join(home, "mcp.json"));
|
|
23
|
-
/** add / remove,参数已经切好;返回给用户看的结果,用法错误或失败时抛错。cmd 用在提示里 */
|
|
14
|
+
export const mcpConfigFile = (home, cwd, project) => project ? path.join(cwd, ".jade", "mcp.json") : path.join(home, "mcp.json");
|
|
24
15
|
export async function manageMcp(argv, env) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
16
|
+
const usage = manageUsage(env.cmd);
|
|
17
|
+
const [sub, ...tail] = argv;
|
|
18
|
+
if (sub === "-h" || sub === "--help")
|
|
19
|
+
return usage;
|
|
20
|
+
if (sub === "add") {
|
|
21
|
+
const { name, project, force, config } = parseAdd(tail, usage);
|
|
22
|
+
const file = mcpConfigFile(env.home, env.cwd, project);
|
|
23
|
+
await edit(file, (servers) => {
|
|
24
|
+
if (servers[name] !== undefined && !force)
|
|
25
|
+
throw new Error(`${display(env.cwd, file)} already has an MCP server named ${name}; add --force to replace it`);
|
|
26
|
+
servers[name] = config;
|
|
27
|
+
});
|
|
28
|
+
return [
|
|
29
|
+
`added MCP server ${name} to ${display(env.cwd, file)}: ${describeServer(config)}`,
|
|
30
|
+
env.live ? `jade starts it now${project ? " (after you confirm it)" : ""}; its tools are available from the next turn` : `restart jade to start it${project ? "; jade asks you to confirm it the first time" : ""}`
|
|
31
|
+
].join(`
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
if (sub === "remove" || sub === "rm") {
|
|
35
|
+
const project = tail.includes("--project");
|
|
36
|
+
const rest = tail.filter((a) => a !== "--project");
|
|
37
|
+
if (rest.length !== 1 || rest[0].startsWith("-"))
|
|
38
|
+
throw new Error(usage);
|
|
39
|
+
const name = rest[0];
|
|
40
|
+
const file = mcpConfigFile(env.home, env.cwd, project);
|
|
41
|
+
await edit(file, (servers) => {
|
|
42
|
+
if (servers[name] === undefined)
|
|
43
|
+
throw new Error(`${display(env.cwd, file)} has no MCP server named ${name}`);
|
|
44
|
+
delete servers[name];
|
|
45
|
+
});
|
|
46
|
+
return `removed MCP server ${name} from ${display(env.cwd, file)}; ${env.live ? "jade stops it and its tools go away from the next turn" : "restart jade to stop it"}`;
|
|
47
|
+
}
|
|
48
|
+
throw new Error(usage);
|
|
57
49
|
}
|
|
58
50
|
function parseAdd(tail, usage) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
name = a;
|
|
102
|
-
else {
|
|
103
|
-
// 名字之后第一个不是选项的参数是服务的命令,后面的都原样交给它(npx -y … 里的 -y 不是 jade 的选项)
|
|
104
|
-
command = tail.slice(i);
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (name === undefined)
|
|
109
|
-
throw new Error(usage);
|
|
110
|
-
if (url !== undefined && command?.length)
|
|
111
|
-
throw new Error(`give either --url or a command, not both\n${usage}`);
|
|
112
|
-
if (url === undefined && !command?.length)
|
|
113
|
-
throw new Error(`give a command or --url\n${usage}`);
|
|
114
|
-
let config;
|
|
115
|
-
if (url !== undefined) {
|
|
116
|
-
// 含 ${VAR} 的地址要到读配置时才知道展开后是什么,那时再检查
|
|
117
|
-
if (!/^https?:\/\//.test(url) && !url.includes("${"))
|
|
118
|
-
throw new Error(`--url must start with http:// or https://`);
|
|
119
|
-
if (Object.keys(envVars).length)
|
|
120
|
-
throw new Error("--env is for servers started with a command; a --url server takes --header");
|
|
121
|
-
config = { type: "http", url, ...(Object.keys(headers).length ? { headers } : {}) };
|
|
122
|
-
}
|
|
51
|
+
let name;
|
|
52
|
+
let project = false;
|
|
53
|
+
let force = false;
|
|
54
|
+
let url;
|
|
55
|
+
const envVars = {};
|
|
56
|
+
const headers = {};
|
|
57
|
+
let command;
|
|
58
|
+
for (let i = 0;i < tail.length; i++) {
|
|
59
|
+
const a = tail[i];
|
|
60
|
+
const value = () => {
|
|
61
|
+
const v = tail[++i];
|
|
62
|
+
if (v === undefined)
|
|
63
|
+
throw new Error(`${a} needs a value
|
|
64
|
+
${usage}`);
|
|
65
|
+
return v;
|
|
66
|
+
};
|
|
67
|
+
if (a === "--") {
|
|
68
|
+
command = tail.slice(i + 1);
|
|
69
|
+
break;
|
|
70
|
+
} else if (a === "--project")
|
|
71
|
+
project = true;
|
|
72
|
+
else if (a === "--force" || a === "-f")
|
|
73
|
+
force = true;
|
|
74
|
+
else if (a === "--url")
|
|
75
|
+
url = value();
|
|
76
|
+
else if (a === "--env" || a === "-e") {
|
|
77
|
+
const v = value();
|
|
78
|
+
const eq = v.indexOf("=");
|
|
79
|
+
if (eq <= 0)
|
|
80
|
+
throw new Error(`--env needs KEY=VALUE, got ${JSON.stringify(v)}`);
|
|
81
|
+
envVars[v.slice(0, eq)] = v.slice(eq + 1);
|
|
82
|
+
} else if (a === "--header" || a === "-H") {
|
|
83
|
+
const v = value();
|
|
84
|
+
const colon = v.indexOf(":");
|
|
85
|
+
if (colon <= 0)
|
|
86
|
+
throw new Error(`--header needs "Name: value", got ${JSON.stringify(v)}`);
|
|
87
|
+
headers[v.slice(0, colon).trim()] = v.slice(colon + 1).trim();
|
|
88
|
+
} else if (a.startsWith("-"))
|
|
89
|
+
throw new Error(`unknown option ${a}
|
|
90
|
+
${usage}`);
|
|
91
|
+
else if (name === undefined)
|
|
92
|
+
name = a;
|
|
123
93
|
else {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const [cmd, ...args] = command;
|
|
127
|
-
config = { command: cmd, ...(args.length ? { args } : {}), ...(Object.keys(envVars).length ? { env: envVars } : {}) };
|
|
94
|
+
command = tail.slice(i);
|
|
95
|
+
break;
|
|
128
96
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
97
|
+
}
|
|
98
|
+
if (name === undefined)
|
|
99
|
+
throw new Error(usage);
|
|
100
|
+
if (url !== undefined && command?.length)
|
|
101
|
+
throw new Error(`give either --url or a command, not both
|
|
102
|
+
${usage}`);
|
|
103
|
+
if (url === undefined && !command?.length)
|
|
104
|
+
throw new Error(`give a command or --url
|
|
105
|
+
${usage}`);
|
|
106
|
+
let config;
|
|
107
|
+
if (url !== undefined) {
|
|
108
|
+
if (!/^https?:\/\//.test(url) && !url.includes("${"))
|
|
109
|
+
throw new Error(`--url must start with http:// or https://`);
|
|
110
|
+
if (Object.keys(envVars).length)
|
|
111
|
+
throw new Error("--env is for servers started with a command; a --url server takes --header");
|
|
112
|
+
config = { type: "http", url, ...Object.keys(headers).length ? { headers } : {} };
|
|
113
|
+
} else {
|
|
114
|
+
if (Object.keys(headers).length)
|
|
115
|
+
throw new Error("--header is for --url servers; a command takes --env");
|
|
116
|
+
const [cmd, ...args] = command;
|
|
117
|
+
config = { command: cmd, ...args.length ? { args } : {}, ...Object.keys(envVars).length ? { env: envVars } : {} };
|
|
118
|
+
}
|
|
119
|
+
const problem = checkConfig(name, config);
|
|
120
|
+
if (problem)
|
|
121
|
+
throw new Error(`MCP server ${JSON.stringify(name)}: ${problem}`);
|
|
122
|
+
return { name, project, force, config };
|
|
133
123
|
}
|
|
134
|
-
/** 读配置文件、改 mcpServers、写回;文件坏了时报错,不覆盖 */
|
|
135
124
|
async function edit(file, change) {
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
let json = {};
|
|
126
|
+
let text;
|
|
127
|
+
try {
|
|
128
|
+
text = await readFile(file, "utf8");
|
|
129
|
+
} catch {}
|
|
130
|
+
if (text !== undefined && text.trim()) {
|
|
138
131
|
try {
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// 还没有这个文件
|
|
143
|
-
}
|
|
144
|
-
if (text !== undefined && text.trim()) {
|
|
145
|
-
try {
|
|
146
|
-
json = JSON.parse(text);
|
|
147
|
-
}
|
|
148
|
-
catch (e) {
|
|
149
|
-
throw new Error(`${file}: ${e instanceof Error ? e.message : String(e)}; fix it by hand first`);
|
|
150
|
-
}
|
|
151
|
-
if (typeof json !== "object" || json === null || Array.isArray(json))
|
|
152
|
-
throw new Error(`${file}: expected { "mcpServers": { ... } }; fix it by hand first`);
|
|
132
|
+
json = JSON.parse(text);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
throw new Error(`${file}: ${e instanceof Error ? e.message : String(e)}; fix it by hand first`);
|
|
153
135
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
136
|
+
if (typeof json !== "object" || json === null || Array.isArray(json))
|
|
137
|
+
throw new Error(`${file}: expected { "mcpServers": { ... } }; fix it by hand first`);
|
|
138
|
+
}
|
|
139
|
+
const servers = json.mcpServers ??= {};
|
|
140
|
+
if (typeof servers !== "object" || servers === null || Array.isArray(servers))
|
|
141
|
+
throw new Error(`${file}: "mcpServers" is not an object; fix it by hand first`);
|
|
142
|
+
change(servers);
|
|
143
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
144
|
+
await writeFile(file, JSON.stringify(json, null, 2) + `
|
|
145
|
+
`);
|
|
160
146
|
}
|