Skip to content

Commit d63881f

Browse files
committed
Add Zed support
1 parent a5ec559 commit d63881f

File tree

4 files changed

+51
-30
lines changed

4 files changed

+51
-30
lines changed

packages/cli-v3/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
"dependencies": {
8383
"@clack/prompts": "0.11.0",
8484
"@depot/cli": "0.0.1-cli.2.80.0",
85-
"@iarna/toml": "^2.2.5",
8685
"@modelcontextprotocol/sdk": "^1.17.0",
8786
"@opentelemetry/api": "1.9.0",
8887
"@opentelemetry/api-logs": "0.203.0",
@@ -102,6 +101,7 @@
102101
"chokidar": "^3.6.0",
103102
"cli-table3": "^0.6.3",
104103
"commander": "^9.4.1",
104+
"confbox": "^0.2.2",
105105
"defu": "^6.1.4",
106106
"dotenv": "^16.4.5",
107107
"esbuild": "^0.23.0",

packages/cli-v3/src/commands/install-mcp.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { intro, isCancel, multiselect, select, spinner, log, outro, confirm } from "@clack/prompts";
1+
import { confirm, intro, isCancel, log, multiselect, select, spinner } from "@clack/prompts";
2+
import chalk from "chalk";
23
import { Command } from "commander";
4+
import { extname } from "node:path";
35
import { z } from "zod";
46
import { OutroCommandError, wrapCommandAction } from "../cli/common.js";
7+
import { cliLink } from "../utilities/cliOutput.js";
8+
import { writeConfigHasSeenMCPInstallPrompt } from "../utilities/configFiles.js";
59
import {
610
expandTilde,
7-
safeReadJSONFile,
11+
safeReadJSONCFile,
812
safeReadTomlFile,
913
writeJSONFile,
1014
writeTomlFile,
1115
} from "../utilities/fileSystem.js";
1216
import { printStandloneInitialBanner } from "../utilities/initialBanner.js";
1317
import { VERSION } from "../version.js";
14-
import chalk from "chalk";
15-
import { cliLink } from "../utilities/cliOutput.js";
16-
import { extname } from "node:path";
17-
import { writeConfigHasSeenMCPInstallPrompt } from "../utilities/configFiles.js";
1818

1919
const cliVersion = VERSION as string;
2020
const cliTag = cliVersion.includes("v4-beta") ? "v4-beta" : "latest";
@@ -23,6 +23,7 @@ const clients = [
2323
"claude-code",
2424
"cursor",
2525
"vscode",
26+
"zed",
2627
"windsurf",
2728
"gemini-cli",
2829
"crush",
@@ -56,6 +57,9 @@ const clientScopes: ClientScopes = {
5657
user: "~/Library/Application Support/Code/User/mcp.json",
5758
project: "./.vscode/mcp.json",
5859
},
60+
zed: {
61+
user: "~/.config/zed/settings.json",
62+
},
5963
windsurf: {
6064
user: "~/.codeium/windsurf/mcp_config.json",
6165
},
@@ -83,6 +87,7 @@ const clientLabels: ClientLabels = {
8387
"claude-code": "Claude Code",
8488
cursor: "Cursor",
8589
vscode: "VSCode",
90+
zed: "Zed",
8691
windsurf: "Windsurf",
8792
"gemini-cli": "Gemini CLI",
8893
crush: "Charm Crush",
@@ -344,7 +349,7 @@ async function writeMcpServerConfig(
344349

345350
switch (extension) {
346351
case ".json": {
347-
let existingConfig = await safeReadJSONFile(fullPath);
352+
let existingConfig = await safeReadJSONCFile(fullPath);
348353

349354
if (!existingConfig) {
350355
existingConfig = {};
@@ -426,6 +431,9 @@ function resolveMcpServerConfigJsonPath(
426431
case "amp": {
427432
return ["amp.mcpServers", "trigger"];
428433
}
434+
case "zed": {
435+
return ["context_servers", "trigger"];
436+
}
429437
case "claude-code": {
430438
if (scope.scope === "local") {
431439
const projectPath = process.cwd();
@@ -519,6 +527,13 @@ function resolveMcpServerConfig(
519527
args,
520528
};
521529
}
530+
case "zed": {
531+
return {
532+
source: "custom",
533+
command: "npx",
534+
args,
535+
};
536+
}
522537
}
523538
}
524539

packages/cli-v3/src/utilities/fileSystem.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fsModule, { writeFile } from "fs/promises";
33
import fs from "node:fs";
44
import { homedir, tmpdir } from "node:os";
55
import pathModule from "node:path";
6-
import TOML from "@iarna/toml";
6+
import { parseJSONC, stringifyJSONC, parseTOML, stringifyTOML } from "confbox";
77

88
// Creates a file at the given path, if the directory doesn't exist it will be created
99
export async function createFile(
@@ -123,19 +123,29 @@ export async function createTempDir(): Promise<string> {
123123
}
124124

125125
export async function safeReadTomlFile(path: string) {
126-
try {
127-
const fileExists = await pathExists(path);
126+
const fileExists = await pathExists(path);
128127

129-
if (!fileExists) return;
128+
if (!fileExists) return;
130129

131-
const fileContents = await readFile(path);
130+
const fileContents = await readFile(path);
132131

133-
return TOML.parse(fileContents.replace(/\r\n/g, "\n"));
134-
} catch {
135-
return;
136-
}
132+
return parseTOML(fileContents.replace(/\r\n/g, "\n"));
137133
}
138134

139135
export async function writeTomlFile(path: string, toml: any) {
140-
await safeWriteFile(path, TOML.stringify(toml));
136+
await safeWriteFile(path, stringifyTOML(toml));
137+
}
138+
139+
export async function safeReadJSONCFile(path: string) {
140+
const fileExists = await pathExists(path);
141+
142+
if (!fileExists) return;
143+
144+
const fileContents = await readFile(path);
145+
146+
return parseJSONC(fileContents.replace(/\r\n/g, "\n"));
147+
}
148+
149+
export async function writeJSONCFile(path: string, json: any) {
150+
await safeWriteFile(path, stringifyJSONC(json));
141151
}

pnpm-lock.yaml

Lines changed: 8 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)