Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/cli/src/setup/opencode-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export async function editOpenCodeServer(
filePath: string,
entry?: Record<string, unknown>
): Promise<void> {
const servers = Object.keys(((await readJsonConfig(filePath)).mcp ?? {}) as object);
const servers = Object.keys(((await readJsonConfig(filePath)).mcp?.servers ?? {}) as object);
const raw = await readFile(filePath, "utf-8").catch(() => "");
const source = raw.trim() ? raw : "{}\n";
// modify() leaves `{ , }` when it deletes the only property of an object that
// has a trailing comma, so empty the `mcp` object instead.
const edits =
!entry && servers.join() === "context7"
? modify(source, ["mcp"], {}, options)
: modify(source, ["mcp", "context7"], entry, options);
: modify(source, ["mcp", "servers", "context7"], entry, options);
await mkdir(dirname(filePath), { recursive: true });
await writeFile(filePath, applyEdits(source, edits), "utf-8");
}