fix(setup): read an OpenCode V2 server named type as a table entry (#866)

Only a string type is the V1 entry discriminator; a native mcp.servers
table may hold a server object named type.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-07 13:20:02 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent bb19c9477e
commit 4e17be5705
2 changed files with 33 additions and 2 deletions
@@ -322,6 +322,33 @@ describe("OpenCode V2 native server table", () => {
});
});
it("treats a V2 table holding a server named type as native", async () => {
const { home, client } = await openCodeClient("rea-opencode-type-server-");
const typeServer = { type: "local", command: ["node", "type.js"] };
await writeFile(
client.configPath,
`${JSON.stringify({ mcp: { servers: { type: typeServer, rea: { type: "local", command } } } })}\n`,
);
expect(await readClientRegistrationStatuses(home)).toEqual(
expect.arrayContaining([
expect.objectContaining({
client: "opencode",
state: "aligned",
command,
}),
]),
);
expect((await systemUninstallHost(home).removeClient(client)).status).toBe(
"removed",
);
expect(
parseOpenCode(await readFile(client.configPath, "utf8")).mcp,
).toEqual({
servers: { type: typeServer },
});
});
it("keeps a V1 server named servers in the V1 table", async () => {
const { client } = await openCodeClient("rea-opencode-v1-servers-");
const servers = { type: "local", command: ["node", "servers.js"] };