mirror of
https://github.com/morluto/rea.git
synced 2026-11-23 15:05:51 +00:00
* feat(setup): discover project-scoped MCP registrations in doctor and uninstall * fix(setup): preserve OpenCode layer fields, user launcher provenance, and user fallback * fix(setup): restore working directory in tests and refine replacement and launcher provenance * fix(setup): bound OpenCode discovery to worktree and enforce Pi project trust * fix(setup): preserve Pi project trust failures in doctor and prevent skipping project registrations in uninstall * fix(setup): defer cross-setting environment validation and decouple OpenCode launcher ownership * fix(setup): separate OpenCode readiness schema from launcher ownership and fix cross-setting test * fix(doctor): include project remediation when disabled project registration inherits outdated user launcher * fix(setup): scope status properties to project-scoped registrations Omit scope and launcher_scope when no project-level configuration was discovered or evaluated, ensuring user-level registrations retain their exact unextended status contract in isolated environments without project files. * fix(setup): prevent activating unowned launchers during uninstall and align array normalization Prevent activating unowned or foreign launchers hidden in lower-precedence configurations during project-scoped uninstall, normalize array command arguments uniformly in OpenCode ownership parsing without appending separate args, and clarify field inheritance in client configuration documentation. * fix(setup): check effective remaining launcher on uninstall and preserve cleanup failure * fix(uninstall): preserve user configuration path in project client to check fallback ownership * fix(uninstall): scope fallback configuration paths only to project-scoped clients * fix(doctor): validate effective merged Pi flags and preserve MSIX selection during uninstall * fix(uninstall): preserve surviving OpenCode project registrations across complete configuration layers * fix(uninstall): require surviving OpenCode server to carry a launcher when checking layered activation * fix(uninstall): rely on full layered check for OpenCode instead of lower-only fallback * fix(doctor): preserve source paths for inherited environment failures When a trusted Pi project partial override or an OpenCode project registration inherits an invalid REA environment value from user configuration (or an ancestor configuration), attribute the resulting doctor invalid registration error to the contributing configuration source rather than the winning project file. Preserves source evidence provenance across merged configuration layers so doctor remediation points the user to the file that actually requires repair. * test(doctor): exercise effective cross-setting merge failure in inherited environment tests Replace scalar validation errors with cross-setting constraints (REA_GHIDRA_PROGRAM_NAME without REA_GHIDRA_PROJECT_PATH) in inherited environment regression tests so individual fragments pass and the failure is only triggered during effective layer merge, directly protecting contributingEnvironmentSource provenance lookup. * fix(uninstall): allow cleaning up owned entries in untrusted Pi projects Evaluate Pi project trust in unownedLowerLayerFallback so owned entries in untrusted Pi projects can be cleanly removed without falsely claiming that removal would activate an unowned user launcher. * fix(uninstall): require confirmed untrusted decision to skip Pi fallback check Only skip the unowned lower-layer fallback check when Pi project trust is confirmed untrusted (trust.ok && !trust.value). When Pi trust reading or parsing fails (!trust.ok), preserve the unresolved state and conservatively inspect the lower layer so that an unowned user launcher is not inadvertently exposed if the project was trusted. * fix(doctor): track activation provenance across layers and normalize platform path identity - Track activation source provenance (activationScope, activationConfigPath) across Pi and OpenCode configuration layers so activation drift remediation points to the exact file contributing the disable/enable flag rather than nearest fragment. - Normalize path identity case-insensitively on Windows and macOS when deduplicating user configuration from OpenCode hierarchy and Pi project candidates. - Qualify Pi project registration docs with trusted projects prerequisite and fallback semantics. * fix(doctor): isolate platform casing tests and restore cwd mocks * fix(doctor): use filesystem identity for path normalization and verify present files in case tests * fix(doctor): preserve inherited schema provenance and include activation in project package remediation * fix(doctor): report the contributing registration and activation sources * test(doctor): exercise combined Pi activation and launcher repairs * fix(doctor): honor OpenCode activation by config dialect * fix(doctor): share project registration activation and provenance * fix(setup): plan project removals before writes and isolate provider probes * fix(doctor): preserve OpenCode registration and launcher provenance * fix(doctor): use shared registration error and path provenance * fix(doctor): gate desktop probes on registration authority * fix(uninstall): skip absent project configuration candidates * fix(uninstall): compare effective project registration before removal * fix(doctor): guide project package launcher migration * test(doctor): verify OpenCode project launcher migration advice * fix(uninstall): separate project load order from write targets * fix(doctor): preserve OpenCode directory alias precedence * fix(uninstall): preserve unchanged remote project registrations --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
522 lines
18 KiB
TypeScript
522 lines
18 KiB
TypeScript
import { mkdir, readFile, symlink, writeFile } from "node:fs/promises";
|
|
import { dirname, join } from "node:path";
|
|
import { expect } from "vitest";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../../support/cli/cliFixture.js";
|
|
import { registrationEnvironment } from "../../support/cli/registrationEnvironment.js";
|
|
|
|
const put = async (
|
|
path: string,
|
|
document: Record<string, unknown> | string,
|
|
) => {
|
|
await mkdir(dirname(path), { recursive: true });
|
|
const text =
|
|
typeof document === "string" ? document : JSON.stringify(document);
|
|
await writeFile(path, text);
|
|
return text;
|
|
};
|
|
|
|
const piRegistration = {
|
|
command: "npx",
|
|
args: ["-y", "rea-agents", "mcp"],
|
|
enabled: false,
|
|
};
|
|
const openCodeRegistration = {
|
|
type: "local",
|
|
command: ["npx", "-y", "rea-agents", "mcp"],
|
|
};
|
|
const openCodePeer = { type: "local", command: ["unrelated", "mcp"] };
|
|
const openCodeRemote = { type: "remote", url: "https://example.invalid/mcp" };
|
|
|
|
for (const distinctAlias of [false, true]) {
|
|
cliTest.skipIf(distinctAlias && process.platform === "win32")(
|
|
distinctAlias
|
|
? "project uninstall still refuses distinct paths to the same configuration file"
|
|
: "project uninstall edits a configuration in a selected .opencode directory once",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory(
|
|
"rea-project-path-occurrences-",
|
|
);
|
|
const project = join(root, ".opencode");
|
|
const path = join(project, "opencode.json");
|
|
const alias = join(project, "opencode.jsonc");
|
|
const original = await put(path, {
|
|
mcp: { servers: { rea: openCodeRegistration, peer: openCodePeer } },
|
|
});
|
|
if (distinctAlias) await symlink(path, alias);
|
|
const result = await cli.run({
|
|
arguments: ["uninstall", "--project", project, "--json"],
|
|
environment: await registrationEnvironment(join(root, "home")),
|
|
cwd: root,
|
|
});
|
|
if (distinctAlias) {
|
|
expect(result.exitCode, result.stdout).toBe(1);
|
|
expect(result.json).toMatchObject({
|
|
status: "failed",
|
|
items: expect.arrayContaining([
|
|
expect.objectContaining({
|
|
name: "opencode",
|
|
detail: expect.stringContaining(
|
|
"Multiple selected configuration paths alias",
|
|
),
|
|
}),
|
|
]),
|
|
});
|
|
expect(await readFile(path, "utf8")).toBe(original);
|
|
await expect(readFile(`${path}.rea.backup`)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
return;
|
|
}
|
|
expect(result.exitCode, result.stdout).toBe(0);
|
|
expect(result.json).toMatchObject({
|
|
status: "complete",
|
|
items: expect.arrayContaining([
|
|
expect.objectContaining({
|
|
name: "opencode",
|
|
status: "removed",
|
|
configuration_path: path,
|
|
}),
|
|
]),
|
|
});
|
|
expect(JSON.parse(await readFile(path, "utf8"))).toEqual({
|
|
mcp: { servers: { peer: openCodePeer } },
|
|
});
|
|
expect(await readFile(`${path}.rea.backup`, "utf8")).toBe(original);
|
|
},
|
|
);
|
|
}
|
|
|
|
cliTest(
|
|
"uninstall selects an explicit project, including disabled owned rows, while leaving ancestor and user files intact",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-project-uninstall-");
|
|
const home = join(root, "home");
|
|
const parent = join(root, "workspace");
|
|
const project = join(parent, "selected");
|
|
const piPath = join(project, ".pi", "mcp.json");
|
|
const openCodePath = join(project, "opencode.jsonc");
|
|
const environment = await registrationEnvironment(home);
|
|
const piUser = join(home, ".pi", "agent", "mcp.json");
|
|
const userOriginal = await put(piUser, {
|
|
mcpServers: { peer: { command: "unrelated" } },
|
|
});
|
|
await put(join(home, ".pi", "agent", "trust.json"), { [project]: true });
|
|
const ancestor = join(parent, "opencode.json");
|
|
const ancestorOriginal = await put(ancestor, {
|
|
mcp: { servers: { ancestor: openCodePeer } },
|
|
});
|
|
const piOriginal = await put(piPath, {
|
|
mcpServers: { rea: piRegistration, peer: { command: "unrelated" } },
|
|
});
|
|
const openCodeOriginal = await put(openCodePath, {
|
|
mcp: { servers: { rea: openCodeRegistration, peer: openCodePeer } },
|
|
});
|
|
const run = (cwd: string, ...arguments_: string[]) =>
|
|
cli.run({
|
|
arguments: ["uninstall", ...arguments_, "--json"],
|
|
environment,
|
|
cwd,
|
|
});
|
|
|
|
const ordinary = await run(project);
|
|
expect(ordinary.exitCode, ordinary.stdout).toBe(0);
|
|
expect(await readFile(piPath, "utf8")).toBe(piOriginal);
|
|
expect(await readFile(openCodePath, "utf8")).toBe(openCodeOriginal);
|
|
|
|
const incompatible = await run(root, "--project", project, "--purge-data");
|
|
expect(incompatible.exitCode, incompatible.stdout).toBe(1);
|
|
expect(await readFile(piPath, "utf8")).toBe(piOriginal);
|
|
|
|
const selected = await run(root, "--project", project);
|
|
expect(selected.exitCode, selected.stdout).toBe(0);
|
|
expect(selected.json).toMatchObject({
|
|
status: "complete",
|
|
items: expect.arrayContaining([
|
|
expect.objectContaining({
|
|
name: "pi",
|
|
status: "removed",
|
|
configuration_path: piPath,
|
|
}),
|
|
expect.objectContaining({
|
|
name: "opencode",
|
|
status: "removed",
|
|
configuration_path: openCodePath,
|
|
}),
|
|
]),
|
|
});
|
|
expect(JSON.parse(await readFile(piPath, "utf8"))).toEqual({
|
|
mcpServers: { peer: { command: "unrelated" } },
|
|
});
|
|
expect(JSON.parse(await readFile(openCodePath, "utf8"))).toEqual({
|
|
mcp: { servers: { peer: openCodePeer } },
|
|
});
|
|
expect(await readFile(`${piPath}.rea.backup`, "utf8")).toBe(piOriginal);
|
|
expect(await readFile(`${openCodePath}.rea.backup`, "utf8")).toBe(
|
|
openCodeOriginal,
|
|
);
|
|
expect(await readFile(ancestor, "utf8")).toBe(ancestorOriginal);
|
|
expect(await readFile(piUser, "utf8")).toBe(userOriginal);
|
|
},
|
|
);
|
|
|
|
for (const { kind, retained } of [
|
|
{
|
|
kind: "foreign local",
|
|
retained: { type: "local", command: ["npx", "-y", "other-package", "mcp"] },
|
|
},
|
|
{ kind: "remote", retained: openCodeRemote },
|
|
]) {
|
|
cliTest(
|
|
`uninstall removes shadowed OpenCode and Pi registrations while retaining the effective ${kind} row`,
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory(
|
|
"rea-project-shadowed-uninstall-",
|
|
);
|
|
const home = join(root, "home");
|
|
const project = join(root, "selected");
|
|
const lower = join(project, "opencode.json");
|
|
const higher = join(project, "opencode.jsonc");
|
|
const pi = join(project, ".pi", "mcp.json");
|
|
const environment = await registrationEnvironment(home);
|
|
await put(join(home, ".pi", "agent", "trust.json"), { [project]: true });
|
|
const lowerOriginal = await put(lower, {
|
|
mcp: { servers: { rea: openCodeRegistration, peer: openCodePeer } },
|
|
});
|
|
const higherOriginal = await put(higher, {
|
|
mcp: { servers: { rea: retained } },
|
|
});
|
|
const piOriginal = await put(pi, {
|
|
mcpServers: { rea: piRegistration, peer: { command: "unrelated" } },
|
|
});
|
|
|
|
const result = await cli.run({
|
|
arguments: ["uninstall", "--project", project, "--json"],
|
|
environment,
|
|
cwd: root,
|
|
});
|
|
expect(result.exitCode, result.stdout).toBe(0);
|
|
expect(result.json).toMatchObject({ status: "complete" });
|
|
expect(JSON.parse(await readFile(lower, "utf8"))).toEqual({
|
|
mcp: { servers: { peer: openCodePeer } },
|
|
});
|
|
expect(JSON.parse(await readFile(pi, "utf8"))).toEqual({
|
|
mcpServers: { peer: { command: "unrelated" } },
|
|
});
|
|
expect(await readFile(`${lower}.rea.backup`, "utf8")).toBe(lowerOriginal);
|
|
expect(await readFile(`${pi}.rea.backup`, "utf8")).toBe(piOriginal);
|
|
expect(await readFile(higher, "utf8")).toBe(higherOriginal);
|
|
await expect(readFile(`${higher}.rea.backup`)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
cliTest(
|
|
"uninstall skips a project candidate beneath a regular file before reading unrelated user data",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-project-absent-uninstall-");
|
|
const home = join(root, "home");
|
|
const project = join(root, "selected");
|
|
const piUser = join(home, ".pi", "agent", "mcp.json");
|
|
const blocker = join(project, ".pi");
|
|
const openCode = join(project, "opencode.json");
|
|
const environment = await registrationEnvironment(home);
|
|
const userOriginal = await put(piUser, "{ malformed");
|
|
const blockerOriginal = await put(blocker, "ordinary file");
|
|
const original = await put(openCode, {
|
|
mcp: { servers: { rea: openCodeRegistration, peer: openCodePeer } },
|
|
});
|
|
|
|
const result = await cli.run({
|
|
arguments: ["uninstall", "--project", project, "--json"],
|
|
environment,
|
|
cwd: root,
|
|
});
|
|
expect(result.exitCode, result.stdout).toBe(0);
|
|
expect(result.json).toMatchObject({
|
|
status: "complete",
|
|
items: expect.arrayContaining([
|
|
expect.objectContaining({ name: "opencode", status: "removed" }),
|
|
]),
|
|
});
|
|
expect(result.json).not.toMatchObject({
|
|
items: expect.arrayContaining([expect.objectContaining({ name: "pi" })]),
|
|
});
|
|
expect(JSON.parse(await readFile(openCode, "utf8"))).toEqual({
|
|
mcp: { servers: { peer: openCodePeer } },
|
|
});
|
|
expect(await readFile(`${openCode}.rea.backup`, "utf8")).toBe(original);
|
|
expect(await readFile(piUser, "utf8")).toBe(userOriginal);
|
|
expect(await readFile(blocker, "utf8")).toBe(blockerOriginal);
|
|
},
|
|
);
|
|
|
|
for (const [scenario, trusted, fallback, status = "failed"] of [
|
|
["Pi trust is denied", false, undefined],
|
|
["a user fallback would become active", true, { command: "unrelated" }],
|
|
[
|
|
"the user fallback carries only a foreign disabled flag",
|
|
true,
|
|
{ command: "unrelated", disabled: true },
|
|
],
|
|
["a user fallback is malformed", true, "{ bad"],
|
|
[
|
|
"the user fallback stays disabled under Pi's enabled flag",
|
|
true,
|
|
{ command: "unrelated", enabled: false },
|
|
"removed",
|
|
],
|
|
] as const) {
|
|
cliTest(
|
|
`project uninstall reports ${status} when ${scenario}`,
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory(
|
|
"rea-project-uninstall-fallback-",
|
|
);
|
|
const home = join(root, "home");
|
|
const project = join(root, "selected");
|
|
const environment = await registrationEnvironment(home);
|
|
await put(join(home, ".pi", "agent", "trust.json"), {
|
|
[project]: trusted,
|
|
});
|
|
const piUser = join(home, ".pi", "agent", "mcp.json");
|
|
const userOriginal =
|
|
fallback === undefined
|
|
? undefined
|
|
: await put(
|
|
piUser,
|
|
typeof fallback === "string"
|
|
? fallback
|
|
: { mcpServers: { rea: fallback } },
|
|
);
|
|
const piPath = join(project, ".pi", "mcp.json");
|
|
const original = await put(piPath, {
|
|
mcpServers: { rea: piRegistration },
|
|
});
|
|
|
|
const result = await cli.run({
|
|
arguments: ["uninstall", "--project", project, "--json"],
|
|
environment,
|
|
cwd: root,
|
|
});
|
|
expect(result.exitCode, result.stdout).toBe(status === "removed" ? 0 : 1);
|
|
expect(result.json).toMatchObject({
|
|
status: status === "removed" ? "complete" : "failed",
|
|
items: expect.arrayContaining([
|
|
expect.objectContaining({ name: "pi", status }),
|
|
]),
|
|
});
|
|
const updated = await readFile(piPath, "utf8");
|
|
if (status === "removed") {
|
|
expect(JSON.parse(updated)).toEqual({ mcpServers: {} });
|
|
expect(await readFile(`${piPath}.rea.backup`, "utf8")).toBe(original);
|
|
} else {
|
|
expect(updated).toBe(original);
|
|
await expect(readFile(`${piPath}.rea.backup`)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
}
|
|
if (userOriginal !== undefined)
|
|
expect(await readFile(piUser, "utf8")).toBe(userOriginal);
|
|
},
|
|
);
|
|
}
|
|
|
|
for (const scope of ["outside", "user"] as const) {
|
|
cliTest.skipIf(process.platform === "win32")(
|
|
`project uninstall refuses a registration symlink to the ${scope} configuration`,
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-project-uninstall-link-");
|
|
const home = join(root, "home");
|
|
const project = join(root, "selected");
|
|
const external =
|
|
scope === "outside"
|
|
? join(root, "elsewhere", "opencode.json")
|
|
: join(home, ".config", "opencode", "opencode.json");
|
|
const environment = await registrationEnvironment(home);
|
|
const original = await put(external, {
|
|
mcp: { servers: { rea: openCodeRegistration } },
|
|
});
|
|
await mkdir(project);
|
|
const link = join(project, "opencode.json");
|
|
await symlink(external, link);
|
|
|
|
const result = await cli.run({
|
|
arguments: ["uninstall", "--project", project, "--json"],
|
|
environment,
|
|
cwd: root,
|
|
});
|
|
expect(result.exitCode, result.stdout).toBe(1);
|
|
expect(result.json).toMatchObject({
|
|
status: "failed",
|
|
items: expect.arrayContaining([
|
|
expect.objectContaining({
|
|
name: "opencode",
|
|
status: "failed",
|
|
detail: expect.stringContaining(
|
|
scope === "outside"
|
|
? "outside the project directory"
|
|
: "aliases user configuration",
|
|
),
|
|
}),
|
|
]),
|
|
});
|
|
expect(await readFile(external, "utf8")).toBe(original);
|
|
await expect(readFile(`${link}.rea.backup`)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
cliTest(
|
|
"project uninstall removes an owned launcher with invalid REA environment settings",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory(
|
|
"rea-project-uninstall-invalid-owned-",
|
|
);
|
|
const environment = await registrationEnvironment(join(root, "home"));
|
|
const selected = join(root, "selected");
|
|
const configuration = join(selected, "opencode.json");
|
|
const original = await put(configuration, {
|
|
mcp: {
|
|
servers: {
|
|
rea: {
|
|
...openCodeRegistration,
|
|
environment: { REA_GHIDRA_STARTUP_TIMEOUT_MS: "bad" },
|
|
},
|
|
peer: openCodePeer,
|
|
},
|
|
},
|
|
});
|
|
|
|
const result = await cli.run({
|
|
arguments: ["uninstall", "--project", selected, "--json"],
|
|
environment,
|
|
cwd: root,
|
|
});
|
|
expect(result.exitCode, result.stdout).toBe(0);
|
|
expect(result.json).toMatchObject({
|
|
status: "complete",
|
|
items: expect.arrayContaining([
|
|
expect.objectContaining({ name: "opencode", status: "removed" }),
|
|
]),
|
|
});
|
|
expect(JSON.parse(await readFile(configuration, "utf8"))).toEqual({
|
|
mcp: { servers: { peer: openCodePeer } },
|
|
});
|
|
expect(await readFile(`${configuration}.rea.backup`, "utf8")).toBe(
|
|
original,
|
|
);
|
|
},
|
|
);
|
|
|
|
for (const { label, entry, permitsRemoval } of [
|
|
{ label: "no fallback", entry: undefined, permitsRemoval: true },
|
|
{
|
|
label: "a foreign local fallback",
|
|
entry: openCodePeer,
|
|
permitsRemoval: false,
|
|
},
|
|
{
|
|
label: "an enabled remote fallback",
|
|
entry: openCodeRemote,
|
|
permitsRemoval: false,
|
|
},
|
|
{
|
|
label: "a disabled remote fallback",
|
|
entry: { ...openCodeRemote, disabled: true },
|
|
permitsRemoval: true,
|
|
},
|
|
{
|
|
label: "a remote fallback with malformed activation",
|
|
entry: { ...openCodeRemote, disabled: "true" },
|
|
permitsRemoval: false,
|
|
},
|
|
]) {
|
|
cliTest(
|
|
permitsRemoval
|
|
? `project uninstall removes all owned files with ${label}`
|
|
: `project uninstall preserves the whole selected set when removal would expose ${label}`,
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory(
|
|
"rea-project-uninstall-multi-file-",
|
|
);
|
|
const environment = await registrationEnvironment(join(root, "home"));
|
|
const selected = join(root, "selected");
|
|
const firstPath = join(selected, "opencode.json");
|
|
const secondPath = join(selected, "opencode.jsonc");
|
|
const first = await put(firstPath, {
|
|
mcp: { servers: { rea: openCodeRegistration, first: openCodePeer } },
|
|
});
|
|
const second = await put(secondPath, {
|
|
mcp: { servers: { rea: openCodeRegistration, second: openCodePeer } },
|
|
});
|
|
const lowerPath = join(root, "opencode.json");
|
|
const lower =
|
|
entry === undefined
|
|
? undefined
|
|
: await put(lowerPath, { mcp: { servers: { rea: entry } } });
|
|
const run = () =>
|
|
cli.run({
|
|
arguments: ["uninstall", "--project", selected, "--json"],
|
|
environment,
|
|
cwd: root,
|
|
});
|
|
|
|
const result = await run();
|
|
if (!permitsRemoval) {
|
|
expect(result.exitCode, result.stdout).toBe(1);
|
|
expect(result.json).toMatchObject({ status: "failed" });
|
|
expect(await readFile(firstPath, "utf8")).toBe(first);
|
|
expect(await readFile(secondPath, "utf8")).toBe(second);
|
|
expect(await readFile(lowerPath, "utf8")).toBe(lower);
|
|
await expect(readFile(`${firstPath}.rea.backup`)).rejects.toMatchObject(
|
|
{
|
|
code: "ENOENT",
|
|
},
|
|
);
|
|
await expect(
|
|
readFile(`${secondPath}.rea.backup`),
|
|
).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
return;
|
|
}
|
|
expect(result.exitCode, result.stdout).toBe(0);
|
|
expect(result.json).toMatchObject({
|
|
status: "complete",
|
|
items: expect.arrayContaining([
|
|
expect.objectContaining({
|
|
name: "opencode",
|
|
status: "removed",
|
|
actions: expect.arrayContaining([
|
|
expect.objectContaining({
|
|
configuration_path: firstPath,
|
|
status: "removed",
|
|
}),
|
|
expect.objectContaining({
|
|
configuration_path: secondPath,
|
|
status: "removed",
|
|
}),
|
|
]),
|
|
}),
|
|
]),
|
|
});
|
|
if (lower !== undefined)
|
|
expect(await readFile(lowerPath, "utf8")).toBe(lower);
|
|
expect(JSON.parse(await readFile(firstPath, "utf8"))).toEqual({
|
|
mcp: { servers: { first: openCodePeer } },
|
|
});
|
|
expect(JSON.parse(await readFile(secondPath, "utf8"))).toEqual({
|
|
mcp: { servers: { second: openCodePeer } },
|
|
});
|
|
expect(await readFile(`${firstPath}.rea.backup`, "utf8")).toBe(first);
|
|
expect(await readFile(`${secondPath}.rea.backup`, "utf8")).toBe(second);
|
|
expect((await run()).exitCode).toBe(0);
|
|
},
|
|
);
|
|
}
|