fix(setup): treat empty client config files as new documents (#1117)
* fix(setup): treat empty client config files as new documents An empty MCP config file (for example Antigravity's mcp_config.json, which the client can create with zero bytes) was reported as malformed, which blocked rea setup from configuring every other detected agent. Parse a whitespace- or BOM-only JSON/JSONC file as an empty document and write a fresh document over it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(setup): use explicit unicode escape for BOM-only empty config case --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
morluto
parent
567a82f8d4
commit
9fd65ce071
@@ -149,3 +149,33 @@ it("restores original BOM-prefixed JSONC bytes after update and removal", async
|
||||
});
|
||||
expect(await readFile(client.configPath, "utf8")).toBe(original);
|
||||
});
|
||||
|
||||
it.each(["", "\n \n", "\uFEFF"])(
|
||||
"configures an empty client file %j as a new document",
|
||||
async (original) => {
|
||||
const home = await createTestTempDirectory("rea-client-config-empty-");
|
||||
const client = supportedClients(home, "linux", {}).find(
|
||||
(candidate) => candidate.name === "antigravity",
|
||||
);
|
||||
if (client?.format !== "json")
|
||||
throw new Error("missing Antigravity JSON config");
|
||||
await mkdir(dirname(client.configPath), { recursive: true });
|
||||
await writeFile(client.configPath, original);
|
||||
const command = [join(home, "rea"), "mcp"];
|
||||
|
||||
expect(await inspectClientConfiguration(client, {}, command)).toEqual({
|
||||
status: "update",
|
||||
backupPath: `${client.configPath}.rea.backup`,
|
||||
});
|
||||
expect(await configureClientConfiguration(client, {}, command)).toEqual({
|
||||
status: "configured",
|
||||
backupPath: `${client.configPath}.rea.backup`,
|
||||
});
|
||||
expect(JSON.parse(await readFile(client.configPath, "utf8"))).toEqual({
|
||||
mcpServers: { rea: clientRegistrationEntry(client.format, command, {}) },
|
||||
});
|
||||
expect(await inspectClientConfiguration(client, {}, command)).toEqual({
|
||||
status: "already_current",
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user