mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 03:33:25 +00:00
* feat(setup): manage fx registrations with its private profile modes fx becomes a client-table row, so doctor, update and uninstall see the registration rea mcp add wrote, and setup offers fx when ~/.fx or FX_HOME exists. Setup now publishes a private profile through the same owner as mcp add (folder 0700, file 0600) and repairs those modes when the row is otherwise current. Doctor parses fx's array launcher instead of reporting it invalid. * fix(setup): judge fx's private profile by its targets and keep its cleanup owner Address review: privateProfileModesCurrent reads the modes of the canonical file and folder, so a linked profile becomes current; clientConfigurationAligned applies the same modes rule as plan and apply; a private-folder close failure reaches the caller with its cleanup owner instead of becoming a write failure; and the setup plan names the folder and file modes it sets. * fix(setup): keep fx's recovery backups owner-only beside a linked profile Setup and uninstall copied a private profile's original bytes with copyFile, so a backup beside a linked ~/.fx/mcp.json kept the target's readable mode outside the folder setup secures. Both now use the owner-only backup owner that mcp add already used. * feat(setup): manage Junie registrations and apply its location policy (#10712) * feat(setup): manage Junie registrations and apply its location policy Junie becomes a client-table row, so doctor, update and uninstall see the registration rea mcp add wrote, and setup offers Junie when its home exists. Whether Junie loads its default user MCP file now has one owner, read through the client policy block that setup, doctor and mcp add already consult: setup and mcp add refuse, and doctor reports, a registration Junie would not load. * fix(setup): read Junie's user configuration as strict JSON Address review: Junie loads config.json as strict JSON, so comments, trailing commas or an empty file leave its MCP location choice unknown, as before the move into the row. Filesystem tests also clear JUNIE_*, FX_HOME and MCPORTER_CONFIG so a developer's own client locations cannot be inspected or removed. * test(setup): keep the detected client order out of the lifecycle suite body The expected detection order grew with each folded client until the suite callback exceeded the max-lines-per-function lint limit. * fix(update): report a client whose policy setup refuses instead of failing maintenance Junie's disabled default locations (and Gemini's settings policy) make doctor report the registration stale, but setup refuses that client, so selecting it failed every other client's maintenance. The registration inspection now carries the setup blocker, and maintenance lists that client with its reason instead of selecting it. * refactor(setup): read fx's private-profile host through HOST_PLATFORM The fx private-profile mode checks and permissions describe the host REA runs on, so they take it from the host-platform owner instead of reading process.platform (refused by the ratchet from #10911). * feat(setup): manage Goose registrations across its configuration layers (#10715) * feat(setup): manage Goose registrations across its configuration layers Goose becomes a client-table row, so doctor, update and uninstall see the registration rea mcp add wrote, and setup offers Goose when its user file or system file exists. Goose loads its system file and GOOSE_ADDITIONAL_CONFIG_FILES beneath the user file and overlays each extension one field deep; doctor now reports that effective registration, while setup, update and uninstall change only the user file. Doctor also parses Goose's cmd launcher instead of reporting it invalid. * fix(setup): keep Goose's layered environment and load order through setup and uninstall Address review: read Goose's env alias and apply requested settings over envs; keep an inherited lower envs map instead of masking it with an empty default; keep each layer's last load so a repeated user file keeps its precedence; split GOOSE_ADDITIONAL_CONFIG_FILES with Windows quoting; validate only the effective environment across read-only layers; refuse uninstall while a read-only layer keeps REA enabled; and clear Goose's location variables in tests. * fix(setup): apply requested Goose settings over the inherited environment * fix(setup): leave lower-layer Goose settings in force and read admin layers read-only Setup no longer writes its default timeout, enabled, name or description into Goose's user entry when only a lower layer declares that setting, so the inherited value keeps applying and a repeat setup stays current. Uninstall reads Goose's read-only lower layers where Goose reads them, without the write target's ownership check, so an administrator-owned system file no longer blocks removal. The client table accepts an injected Goose system-config path so tests no longer read or skip on the host's /etc/goose/config.yaml; adds a shadowed-invalid-lower-layer regression. * fix(setup): keep an inherited Goose env alias's spelling when writing the user entry Goose overlays each extension field separately, so writing envs into the user file beside a lower layer's env alias left both in force, which readers reject as ambiguous. Setup now writes the user map under the alias a lower layer declares, and mcp add neither adds a default envs map beside an inherited alias nor renames a user alias the lower layer shares. * test(setup): inject Goose's system layer into mcp add selection resolveMcpRegistrationClients accepts the caller's system configuration paths, so the Goose layers test no longer reads the host's /etc/goose/config.yaml. * fix(setup): report REA's Goose registration that only a read-only layer defines * test(setup): pass an isolated Goose system path through update maintenance and the mcp add table * fix(setup): judge Goose uninstall by the merged entry and stop on an unreadable lower layer * fix(setup): select Goose's env alias by presence so a null alias stays malformed * fix(setup): use the shared record predicate for Goose's layered merge after #10588 * feat(setup): give Kilo a client-table row with an async layered location (#10823) * feat(setup): give Kilo a client-table row with an async layered location The client table gains a layeredLocation hook and resolveSupportedClients, which awaits it. Kilo's row resolves its user-scope layers through the same owner rea mcp add uses (KiloClientLocation), so both pick the same write target; the synchronous row keeps kilo.json in Kilo's config root with every candidate layer. The table refuses a relative KILO_CONFIG, KILO_CONFIG_DIR or XDG_CONFIG_HOME because Kilo's working directory is unknown. Refs #7181 * fix(setup): treat every folder Kilo reads as evidence that it is installed * fix(setup): normalize Kilo's absolute table paths and parse its command array * feat(setup): resolve the client table's layered locations in setup, doctor, update and uninstall (#10832) SetupHost (detection and the selectable table), ClientRegistrationStatus, uninstall, doctor's selected-registration environment and the mcp add catalog now read resolveSupportedClients, so each sees the Kilo layer Kilo writes rather than the synchronous default. Refs #7181 * docs(adr): record the one-client-table decision for setup and mcp add * fix(setup): refuse to read a client row whose location is unresolved Doctor's selected-client settings read a Kilo row whose relative KILO_CONFIG left only path evidence, so it inspected a file relative to REA's folder. The shared configuration reader now refuses such a row, so every reader reports the registration as unreadable. * docs(adr): name the row's layeredLocation hook * feat(setup): read KILO_CONFIG_CONTENT as Kilo's top read-only layer (#10851) * feat(setup): read KILO_CONFIG_CONTENT as Kilo's top read-only layer * fix(setup): refuse a Kilo uninstall that would expose or keep another layer's rea entry (#10852) * fix(setup): recheck KILO_CONFIG_CONTENT at write time and name it in doctor's recovery * refactor(mcp): register Kilo through its table row and remove the registration-only catalog kind (#10862) * refactor(mcp): register Kilo through its table row and remove the registration-only catalog kind * refactor(mcp): resolve user-scope targets in the catalog so location modules never import the client table * test(setup): cover Kilo's KILO_CONFIG, home-folder and inline-only layers * fix(setup): report REA's Kilo entry that only KILO_CONFIG_CONTENT sets during uninstall Doctor reports a registration that KILO_CONFIG_CONTENT alone defines, but uninstall found no file entry and reported Kilo as skipped. Uninstall now reports it once as failed and names the variable to edit. * docs(adr): record Kilo's inline layer in the client-table decision * fix(setup): compare Windows environment names without case when a higher layer overrides REA's entry Kilo's inline-layer check and Gemini's system-override check compared environment maps by exact key, so an equal Path beside PATH on Windows was reported as an override and setup refused the client. Both compare the entry as the client launches it. * fix(update): leave a stale Kilo registration KILO_CONFIG_CONTENT sets out of maintenance Setup refuses a refresh the inline layer would override, and one refused client failed every other client's maintenance. The registration inspection now names the inline layer as the setup blocker of a stale entry, and maintenance reports Kilo with that recovery instead of selecting it. * fix(setup): refuse relative JUNIE_HOME and Cline CLI overrides like the other client roots (#10909) * fix(setup): refuse relative JUNIE_HOME and Cline CLI overrides like the other client roots * fix(setup): refuse Windows client paths without a drive that follow the client's current drive * fix(update): select maintenance clients through setup's own refresh refusal check Maintenance predicted setup's refusal with its own rule: any inline rea entry blocked a stale registration, while an aligned one was never checked. A harmless KILO_CONFIG_CONTENT entry (enabled: true) kept a stale Kilo launcher pinned, and an inline value setup would not write (an extra environment variable) let an aligned Kilo registration block every client's maintenance. Setup's refusal checks (client policy, then the inline override comparison of the entry it would write) now live in one reader that setup's alignment check and maintenance share. Maintenance asks it for every owned enabled candidate and reports a refused client with setup's remediation and its real state. * fix(update): keep failed refresh-check reads owned by the supplied maintenance scope clientRefreshRefusal read the client's layers, target file and policy without the caller's resource scope, so a close that failed during those reads threw a cleanup failure no scope retained; maintenance then reported it as text and the scope's close could not retry the descriptor. The refresh reader now takes the scope and passes it to every read. * fix(setup): take the Kilo layer readers' default host from HOST_PLATFORM and the shared record predicate After rebasing on main (#10911, #10588): the new inlineRegistrationOverride and resolveSupportedClients defaults read the running host through the host-platform owner, and the layered launcher merge uses isRecord. * fix(update): keep an unreadable layer's reason in the refresh refusal check readClientRefresh returned undefined for an unreadable or malformed layer, so clientRefreshRefusal reported no refusal and maintenance selected a client whose setup preflight then failed. The reader returns the typed file failure, and the refusal check reports its detail like setup's preflight does. * fix(setup): count REA's entry in KILO_CONFIG_CONTENT as Kilo lifecycle evidence Doctor, update and uninstall inspected a client only when one of its folders existed, so a registration set only by KILO_CONFIG_CONTENT was skipped. A read-only inline layer that sets REA's entry is now evidence on its own. * fix(update): report a client whose only conflict is a discovered provider path as needing setup * fix(update): match discovered settings by the platform's environment identity * fix(update): preflight maintenance with setup's write-target checks and treat discovered inline paths as unknown
1001 lines
33 KiB
TypeScript
1001 lines
33 KiB
TypeScript
import { UpdateCommandRunner } from "../../src/application/UpdateCommandRunner.js";
|
|
import { mkdir, readFile, rm, writeFile, access } from "node:fs/promises";
|
|
import { delimiter, dirname, join, relative, resolve } from "node:path";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
import { err, ok } from "../../src/domain/result.js";
|
|
import { runUpdate, type UpdateResult } from "../../src/application/Update.js";
|
|
import { PRODUCT_IDENTITY } from "../../src/identity.js";
|
|
import { supportedClients } from "../../src/application/SupportedClients.js";
|
|
import { readClientRegistrationInspections } from "../../src/application/ClientRegistrationStatus.js";
|
|
import {
|
|
existingMaintenanceScope,
|
|
planIntegrationMaintenance,
|
|
} from "../../src/application/UpdateMaintenance.js";
|
|
import { systemUpdateHost } from "../../src/application/UpdateRuntime.js";
|
|
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../support/cli/cliFixture.js";
|
|
|
|
const UPDATE_COMMAND_OUTPUT_BYTES = 4 * 1024 * 1024;
|
|
const entryPoint = resolve("scripts/rea.mjs");
|
|
let home: string;
|
|
|
|
beforeEach(async () => {
|
|
home = await createTestTempDirectory("rea-update-maintenance-");
|
|
for (const [name, value] of Object.entries({
|
|
HOME: home,
|
|
USERPROFILE: home,
|
|
APPDATA: join(home, "AppData", "Roaming"),
|
|
LOCALAPPDATA: join(home, "AppData", "Local"),
|
|
CLAUDE_CONFIG_DIR: home,
|
|
CODEX_HOME: join(home, ".codex"),
|
|
COPILOT_HOME: join(home, ".copilot"),
|
|
GROK_HOME: join(home, ".grok"),
|
|
SAND_DATA_ROOT: join(home, ".grokbot"),
|
|
XDG_CONFIG_HOME: join(home, ".config"),
|
|
OPENCODE_CONFIG: join(home, ".config", "opencode", "opencode.jsonc"),
|
|
OMP_PROFILE: undefined,
|
|
PI_CODING_AGENT_DIR: undefined,
|
|
PI_CONFIG_DIR: undefined,
|
|
PI_PROFILE: undefined,
|
|
}))
|
|
vi.stubEnv(name, value);
|
|
});
|
|
|
|
afterEach(async () => {
|
|
vi.unstubAllEnvs();
|
|
await rm(home, { recursive: true, force: true });
|
|
});
|
|
|
|
/** Keep Goose's system layer inside the temporary home. */
|
|
const isolated = () => ({
|
|
systemPaths: { gooseSystemConfig: join(home, "goose-system.yaml") },
|
|
});
|
|
|
|
const plan = (
|
|
execute: Parameters<typeof planIntegrationMaintenance>[3],
|
|
): ReturnType<typeof planIntegrationMaintenance> =>
|
|
planIntegrationMaintenance(
|
|
home,
|
|
entryPoint,
|
|
process.env,
|
|
execute,
|
|
isolated(),
|
|
);
|
|
|
|
const writeClient = async (id: string, content: string): Promise<string> => {
|
|
const client = supportedClients(home).find(({ name }) => name === id);
|
|
if (client === undefined) throw new Error(`Unknown test client ${id}`);
|
|
await mkdir(dirname(client.configPath), { recursive: true });
|
|
await writeFile(client.configPath, content);
|
|
return client.configPath;
|
|
};
|
|
|
|
const writeSkill = async (content: string): Promise<string> => {
|
|
const path = join(
|
|
home,
|
|
".agents",
|
|
"skills",
|
|
PRODUCT_IDENTITY.skillName,
|
|
"SKILL.md",
|
|
);
|
|
await mkdir(dirname(path), { recursive: true });
|
|
await writeFile(path, content);
|
|
return path;
|
|
};
|
|
|
|
const staleCodex =
|
|
'[mcp_servers.rea]\ncommand = "npx"\nargs = ["-y", "rea-agents@0.1.0", "mcp"]\n';
|
|
const action = {
|
|
id: "configure_client:codex",
|
|
kind: "configure_client",
|
|
label: "Codex",
|
|
target: "/test/.codex/config.toml",
|
|
detail: "Refresh the pinned REA version",
|
|
external: false,
|
|
operation: "update",
|
|
backupPath: "/test/.codex/config.toml.rea.backup",
|
|
commands: ["rea mcp"],
|
|
};
|
|
|
|
describe("OMP integration maintenance", () => {
|
|
it("refreshes an OMP entry that enabledServers forces on", async () => {
|
|
const entry = { type: "stdio", command: entryPoint, args: ["mcp"] };
|
|
await writeClient(
|
|
"omp",
|
|
JSON.stringify({ mcpServers: { rea: { ...entry, enabled: false } } }),
|
|
);
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toMatchObject({ clients: [] });
|
|
await writeClient(
|
|
"omp",
|
|
JSON.stringify({
|
|
mcpServers: { rea: { ...entry, enabled: false } },
|
|
enabledServers: ["rea"],
|
|
}),
|
|
);
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toMatchObject({ clients: ["omp"] });
|
|
});
|
|
|
|
it("preserves Grok Build disabled_mcp_servers during maintenance planning", async () => {
|
|
// Strict identity: a user-disabled integration must never be selected
|
|
// for maintenance, even with a healthy owned entry underneath.
|
|
const registration = `[mcp_servers.rea]\ncommand = ${JSON.stringify(process.execPath)}\nargs = [${JSON.stringify(entryPoint)}, "mcp"]\nstartup_timeout_sec = 30\n`;
|
|
const configPath = await writeClient(
|
|
"grok_build",
|
|
`disabled_mcp_servers = ["rea", "other"]\n${registration}`,
|
|
);
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toMatchObject({ clients: [] });
|
|
expect(await readFile(configPath, "utf8")).toContain(
|
|
'disabled_mcp_servers = ["rea", "other"]',
|
|
);
|
|
await writeFile(
|
|
configPath,
|
|
`disabled_mcp_servers = ["other"]\n${registration}`,
|
|
);
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toMatchObject({ clients: ["grok_build"] });
|
|
});
|
|
});
|
|
|
|
describe("maintenance activation and layered configuration", () => {
|
|
it("keeps unresolved registrations out of writes without calling them current", async () => {
|
|
await writeClient("codex", staleCodex);
|
|
const cursor = await writeClient(
|
|
"cursor",
|
|
JSON.stringify({
|
|
mcpServers: {
|
|
rea: { command: join(home, "removed-release", "rea"), args: ["mcp"] },
|
|
},
|
|
}),
|
|
);
|
|
const before = await readFile(cursor, "utf8");
|
|
const commands: (readonly string[])[] = [];
|
|
const result = await plan(async (command) => {
|
|
commands.push(command);
|
|
return ok(
|
|
JSON.stringify({
|
|
status: "planned",
|
|
// An action for the unresolved client is outside the scope.
|
|
plannedActions: [{ ...action, id: "configure_client:cursor" }],
|
|
}),
|
|
);
|
|
});
|
|
expect(result).toMatchObject({ status: "unavailable" });
|
|
expect(commands[0]).not.toContain("cursor");
|
|
const planned = await plan(async () =>
|
|
ok(JSON.stringify({ status: "planned", plannedActions: [action] })),
|
|
);
|
|
expect(planned).toMatchObject({
|
|
status: "planned",
|
|
scope: {
|
|
clients: ["codex"],
|
|
unresolved: [
|
|
expect.objectContaining({
|
|
client: "cursor",
|
|
state: "unknown",
|
|
config_path: cursor,
|
|
}),
|
|
],
|
|
},
|
|
});
|
|
expect(await readFile(cursor, "utf8")).toBe(before);
|
|
});
|
|
|
|
it("leaves an inherited disabled OpenCode V2 registration outside maintenance", async () => {
|
|
const upper = await writeClient(
|
|
"opencode",
|
|
JSON.stringify({ mcp: { servers: {} }, theme: "user-selected" }),
|
|
);
|
|
const lower = join(home, ".config", "opencode", "config.json");
|
|
const originalLower = JSON.stringify({
|
|
mcp: {
|
|
servers: {
|
|
rea: { type: "local", command: [entryPoint, "mcp"], disabled: true },
|
|
},
|
|
},
|
|
});
|
|
await writeFile(lower, originalLower);
|
|
const originalUpper = await readFile(upper, "utf8");
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toMatchObject({ clients: [] });
|
|
expect(await readFile(lower, "utf8")).toBe(originalLower);
|
|
expect(await readFile(upper, "utf8")).toBe(originalUpper);
|
|
});
|
|
|
|
it("leaves a natively disabled ZCode registration outside maintenance", async () => {
|
|
const configPath = await writeClient(
|
|
"zcode",
|
|
JSON.stringify({
|
|
mcp: {
|
|
servers: {
|
|
rea: { command: entryPoint, args: ["mcp"], enable: false },
|
|
},
|
|
},
|
|
}),
|
|
);
|
|
const original = await readFile(configPath, "utf8");
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toMatchObject({ clients: [] });
|
|
expect(await readFile(configPath, "utf8")).toBe(original);
|
|
});
|
|
|
|
it("selects a ZCode registration loaded from the same-scope fallback", async () => {
|
|
await writeClient("zcode", JSON.stringify({ mcp: { servers: {} } }));
|
|
const fallbackPath = join(home, ".agents", "mcp.json");
|
|
await mkdir(join(home, ".agents"), { recursive: true });
|
|
await writeFile(
|
|
fallbackPath,
|
|
JSON.stringify({
|
|
mcpServers: { rea: { command: entryPoint, args: ["mcp"] } },
|
|
}),
|
|
);
|
|
|
|
// The fallback row is also FreeBuff's registration, and FreeBuff is the
|
|
// setup action that rewrites it, so both views stay in maintenance scope.
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toMatchObject({ clients: ["freebuff", "zcode"] });
|
|
});
|
|
|
|
it("selects an enabled registration inherited through layered OpenCode files", async () => {
|
|
const directory = join(home, ".config", "opencode");
|
|
await mkdir(directory, { recursive: true });
|
|
await writeFile(
|
|
join(directory, "opencode.json"),
|
|
JSON.stringify({
|
|
mcp: { rea: { type: "local", command: [entryPoint, "mcp"] } },
|
|
}),
|
|
);
|
|
await writeClient("opencode", JSON.stringify({ theme: "user-selected" }));
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toMatchObject({ clients: ["opencode"] });
|
|
});
|
|
});
|
|
|
|
describe("unknown client locations in maintenance", () => {
|
|
it("maintains other clients while an unresolved MCPorter location stays unknown", async () => {
|
|
vi.stubEnv("MCPORTER_CONFIG", "config/mcporter.json");
|
|
await writeClient("codex", staleCodex);
|
|
const scope = await existingMaintenanceScope(
|
|
home,
|
|
entryPoint,
|
|
process.env,
|
|
isolated(),
|
|
);
|
|
expect(scope).toMatchObject({
|
|
clients: ["codex"],
|
|
unresolved: [
|
|
{
|
|
client: "mcporter",
|
|
state: "unknown",
|
|
command: [],
|
|
remediation: expect.stringContaining("MCPORTER_CONFIG is relative"),
|
|
},
|
|
],
|
|
});
|
|
const current = await plan(async () =>
|
|
ok(JSON.stringify({ status: "planned", plannedActions: [] })),
|
|
);
|
|
// Nothing else needs maintenance, yet the unknown client is not hidden.
|
|
expect(current).toMatchObject({
|
|
status: "current",
|
|
unresolved: [{ client: "mcporter", state: "unknown" }],
|
|
});
|
|
});
|
|
|
|
it("names an unknown MCPorter client when planning the known clients fails", async () => {
|
|
vi.stubEnv("MCPORTER_CONFIG", "config/mcporter.json");
|
|
await writeClient("codex", staleCodex);
|
|
const failed = await plan(async () => err("EACCES codex backup"));
|
|
expect(failed).toMatchObject({
|
|
status: "unavailable",
|
|
remediation: expect.stringMatching(
|
|
/^EACCES codex backup REA did not maintain one client .*MCPORTER_CONFIG is relative/u,
|
|
),
|
|
scope: { unresolved: [{ client: "mcporter", state: "unknown" }] },
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("registration ownership in maintenance", () => {
|
|
it("selects owned registrations while preserving unconfigured, foreign, and disabled choices", async () => {
|
|
await writeClient("codex", staleCodex);
|
|
await writeClient("claude_code", '{"mcpServers":{}}');
|
|
await writeClient(
|
|
"cursor",
|
|
'{"mcpServers":{"rea":{"command":"foreign-server","args":[]}}}',
|
|
);
|
|
await writeClient(
|
|
"opencode",
|
|
'{"mcp":{"rea":{"type":"local","command":["npx","-y","rea-agents@0.1.0","mcp"],"enabled":false}}}',
|
|
);
|
|
await writeClient(
|
|
"vscode",
|
|
JSON.stringify({
|
|
servers: { rea: { type: "stdio", command: entryPoint, args: ["mcp"] } },
|
|
}),
|
|
);
|
|
expect(
|
|
await readClientRegistrationInspections(home, entryPoint, {
|
|
environment: process.env,
|
|
}),
|
|
).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
status: expect.objectContaining({
|
|
client: "codex",
|
|
state: "stale",
|
|
command_identity: "owned",
|
|
}),
|
|
activation: "enabled",
|
|
}),
|
|
expect.objectContaining({
|
|
status: expect.objectContaining({
|
|
client: "cursor",
|
|
state: "stale",
|
|
command_identity: "foreign",
|
|
}),
|
|
activation: "enabled",
|
|
}),
|
|
expect.objectContaining({
|
|
status: expect.objectContaining({
|
|
client: "opencode",
|
|
state: "stale",
|
|
command_identity: "owned",
|
|
}),
|
|
activation: "disabled",
|
|
}),
|
|
expect.objectContaining({
|
|
status: expect.objectContaining({
|
|
client: "claude_code",
|
|
state: "missing",
|
|
command_identity: "unknown",
|
|
}),
|
|
activation: "unknown",
|
|
}),
|
|
]),
|
|
);
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toEqual({
|
|
clients: ["codex", "vscode"],
|
|
skill: false,
|
|
skillDestinations: [],
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("existing REA integration maintenance", () => {
|
|
it("does not install a missing skill or overwrite an unrelated skill", async () => {
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toEqual({
|
|
clients: [],
|
|
skill: false,
|
|
skillDestinations: [],
|
|
});
|
|
await writeSkill("---\nname: another-skill\n---\nUser-authored content\n");
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toEqual({
|
|
clients: [],
|
|
skill: false,
|
|
skillDestinations: [],
|
|
});
|
|
});
|
|
|
|
it("includes an existing REA skill and leaves files untouched", async () => {
|
|
const path = await writeSkill(
|
|
`---\nname: ${PRODUCT_IDENTITY.skillName}\nmetadata:\n version: "1"\n---\n# REA\n`,
|
|
);
|
|
const original = await readFile(path, "utf8");
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toEqual({
|
|
clients: [],
|
|
skill: true,
|
|
skillDestinations: [
|
|
{
|
|
client: "shared",
|
|
path: join(home, ".agents", "skills", PRODUCT_IDENTITY.skillName),
|
|
},
|
|
],
|
|
});
|
|
expect(await readFile(path, "utf8")).toBe(original);
|
|
});
|
|
|
|
it("skips setup entirely when there is no existing integration", async () => {
|
|
let invoked = false;
|
|
const result = await plan(async () => {
|
|
invoked = true;
|
|
return err("Unexpected setup");
|
|
});
|
|
expect(result).toEqual({ status: "current", plannedActions: [] });
|
|
expect(invoked).toBe(false);
|
|
});
|
|
|
|
it("returns exact backup and command evidence with a scoped unapplied setup command", async () => {
|
|
await writeClient("codex", staleCodex);
|
|
const recorded: string[][] = [];
|
|
const result = await plan(async (command) => {
|
|
recorded.push([...command]);
|
|
return ok(
|
|
JSON.stringify({ status: "planned", plannedActions: [action] }),
|
|
);
|
|
});
|
|
expect(recorded).toEqual([
|
|
[
|
|
process.execPath,
|
|
entryPoint,
|
|
"setup",
|
|
"--client",
|
|
"codex",
|
|
"--skill=false",
|
|
"--dry-run",
|
|
"--json",
|
|
],
|
|
]);
|
|
expect(result).toEqual({
|
|
status: "planned",
|
|
scope: { clients: ["codex"], skill: false, skillDestinations: [] },
|
|
command: recorded[0]?.slice(0, -2),
|
|
plannedActions: [action],
|
|
});
|
|
});
|
|
|
|
it.each([
|
|
"{broken",
|
|
JSON.stringify({ status: "ready", plannedActions: [action] }),
|
|
JSON.stringify({
|
|
status: "planned",
|
|
plannedActions: [{ ...action, kind: "install_hopper", external: true }],
|
|
}),
|
|
JSON.stringify({
|
|
status: "planned",
|
|
plannedActions: [{ ...action, id: "configure_client:cursor" }],
|
|
}),
|
|
])("rejects malformed or out-of-scope subprocess plans", async (output) => {
|
|
await writeClient("codex", staleCodex);
|
|
expect(await plan(async () => ok(output))).toMatchObject({
|
|
status: "unavailable",
|
|
});
|
|
});
|
|
|
|
it("preserves actual setup failure diagnostics", async () => {
|
|
await writeClient("codex", staleCodex);
|
|
expect(
|
|
await plan(async () => err("EACCES /test/.codex/config.toml")),
|
|
).toMatchObject({
|
|
status: "unavailable",
|
|
remediation: "EACCES /test/.codex/config.toml",
|
|
scope: { clients: ["codex"] },
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("shared registration maintenance", () => {
|
|
it("refreshes an owned shared registration without its product profile", async () => {
|
|
// FreeBuff's registration lives in the shared user agents file. The row is
|
|
// owned, so maintenance must refresh it even though no FreeBuff profile
|
|
// exists to establish product applicability.
|
|
await writeClient(
|
|
"freebuff",
|
|
JSON.stringify({
|
|
mcpServers: {
|
|
other: { command: "other-server" },
|
|
rea: { command: entryPoint, args: ["mcp"] },
|
|
},
|
|
}),
|
|
);
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toEqual({
|
|
clients: ["freebuff"],
|
|
skill: false,
|
|
skillDestinations: [],
|
|
});
|
|
});
|
|
|
|
it("retains FreeBuff when ZCode reads the shared fallback", async () => {
|
|
// Both products load the one shared row, but their setup actions write
|
|
// different files: ZCode writes ~/.zcode/cli/config.json and deliberately
|
|
// leaves ~/.agents/mcp.json untouched (docs/getting-started/client-configuration.md), so
|
|
// its fallback view cannot cover FreeBuff's registration. The shared row
|
|
// would stay pinned to the old version without FreeBuff's own action.
|
|
await writeClient("zcode", JSON.stringify({ mcp: { servers: {} } }));
|
|
await mkdir(join(home, ".config", "freebuff-desktop"), {
|
|
recursive: true,
|
|
});
|
|
await writeClient(
|
|
"freebuff",
|
|
JSON.stringify({
|
|
mcpServers: {
|
|
rea: { command: "npx", args: ["-y", "rea-agents@0.1.0", "mcp"] },
|
|
},
|
|
}),
|
|
);
|
|
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toMatchObject({ clients: ["freebuff", "zcode"] });
|
|
});
|
|
|
|
it("leaves a foreign shared registration out of maintenance", async () => {
|
|
await writeClient(
|
|
"freebuff",
|
|
JSON.stringify({
|
|
mcpServers: { rea: { command: "foreign-server", args: [] } },
|
|
}),
|
|
);
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toEqual({
|
|
clients: [],
|
|
skill: false,
|
|
skillDestinations: [],
|
|
});
|
|
});
|
|
|
|
it("leaves a ZCode-disabled shared row out of maintenance", async () => {
|
|
// The shared file doubles as ZCode's fallback, where `enable: false`
|
|
// disables the registration. Ownership evidence must not let maintenance
|
|
// rewrite the row as a FreeBuff registration and drop that flag.
|
|
const configPath = await writeClient(
|
|
"freebuff",
|
|
JSON.stringify({
|
|
mcpServers: {
|
|
rea: { command: entryPoint, args: ["mcp"], enable: false },
|
|
},
|
|
}),
|
|
);
|
|
const original = await readFile(configPath, "utf8");
|
|
await expect(
|
|
existingMaintenanceScope(home, entryPoint, process.env, isolated()),
|
|
).resolves.toEqual({
|
|
clients: [],
|
|
skill: false,
|
|
skillDestinations: [],
|
|
});
|
|
expect(await readFile(configPath, "utf8")).toBe(original);
|
|
});
|
|
});
|
|
|
|
describe("updated executable maintenance planning", () => {
|
|
it("runs real setup as a noninteractive dry run and creates no new integrations or backups", async () => {
|
|
const configPath = await writeClient("codex", staleCodex);
|
|
const untouched = await writeClient("claude_code", '{"mcpServers":{}}');
|
|
const skillContent = `---\nname: ${PRODUCT_IDENTITY.skillName}\nmetadata:\n version: "1"\n---\n# REA\n`;
|
|
const skillPath = await writeSkill(skillContent);
|
|
vi.stubEnv("npm_command", "exec");
|
|
const result = await plan(async (command) => {
|
|
const result = await updateCommands.runProbe(command, process.env);
|
|
return result.ok ? result : err(result.error.detail);
|
|
});
|
|
expect(result).toMatchObject({
|
|
status: "planned",
|
|
scope: {
|
|
clients: ["codex"],
|
|
skill: true,
|
|
skillDestinations: [{ client: "shared", path: dirname(skillPath) }],
|
|
},
|
|
});
|
|
if (result.status !== "planned") throw new Error(JSON.stringify(result));
|
|
expect(result.plannedActions).toEqual([
|
|
expect.objectContaining({
|
|
id: "configure_client:codex",
|
|
kind: "configure_client",
|
|
}),
|
|
expect.objectContaining({
|
|
id: "install_skill",
|
|
kind: "install_skill",
|
|
target: dirname(skillPath),
|
|
}),
|
|
]);
|
|
expect(await readFile(configPath, "utf8")).toBe(staleCodex);
|
|
expect(await readFile(untouched, "utf8")).toBe('{"mcpServers":{}}');
|
|
expect(await readFile(skillPath, "utf8")).toBe(skillContent);
|
|
await expect(access(`${configPath}.rea.backup`)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
await expect(access(`${skillPath}.rea.backup`)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
await expect(
|
|
access(join(home, ".claude", "skills", PRODUCT_IDENTITY.skillName)),
|
|
).rejects.toMatchObject({ code: "ENOENT" });
|
|
});
|
|
});
|
|
|
|
describe("update subprocess boundaries", () => {
|
|
cliTest("exposes update in CLI help", async ({ cli }) => {
|
|
const help = await cli.run({
|
|
arguments: ["--help"],
|
|
environment: process.env,
|
|
});
|
|
expect(help.exitCode, help.stderr).toBe(0);
|
|
expect(help.stdout).toMatch(/^\s{2}update\s/mu);
|
|
expect(help.stdout).not.toMatch(/^\s{2}upgrade\s/mu);
|
|
});
|
|
|
|
cliTest("rejects the removed upgrade CLI command", async ({ cli }) => {
|
|
const removed = await cli.run({
|
|
arguments: ["upgrade", "--json"],
|
|
environment: process.env,
|
|
});
|
|
expect(removed.exitCode, removed.stderr).toBe(1);
|
|
expect(removed.json).toMatchObject({ code: "COMMAND_NOT_FOUND" });
|
|
});
|
|
it("captures output through stream closure and keeps arguments literal", async () => {
|
|
const literal = 'space and $(echo bad); & | "quotes"';
|
|
const result = await updateCommands.runProbe(
|
|
[
|
|
process.execPath,
|
|
"-e",
|
|
'process.stdout.write("x".repeat(1024 * 1024) + process.argv[1])',
|
|
literal,
|
|
],
|
|
process.env,
|
|
);
|
|
expect(result).toEqual(ok(`${"x".repeat(1024 * 1024)}${literal}`));
|
|
});
|
|
|
|
it("reports actual stderr and launch failures", async () => {
|
|
await expect(
|
|
updateCommands.runProbe(
|
|
[
|
|
process.execPath,
|
|
"-e",
|
|
'process.stderr.write("EACCES /test/install"); process.exitCode = 2',
|
|
],
|
|
process.env,
|
|
),
|
|
).resolves.toEqual(
|
|
err({ kind: "execution", detail: "EACCES /test/install" }),
|
|
);
|
|
const missing = await updateCommands.runProbe(
|
|
[join(home, "missing-executable")],
|
|
process.env,
|
|
);
|
|
expect(missing).toMatchObject({ ok: false });
|
|
if (!missing.ok)
|
|
expect(missing.error).toMatchObject({
|
|
kind: "launch",
|
|
detail: expect.stringContaining("ENOENT"),
|
|
});
|
|
});
|
|
|
|
it("verifies the requested package entry rather than PATH's rea", async () => {
|
|
const packageRoot = join(home, "package");
|
|
const script = join(packageRoot, "scripts", "rea.mjs");
|
|
await mkdir(dirname(script), { recursive: true });
|
|
await writeFile(script, 'process.stdout.write("3.3.0\\n")');
|
|
await expect(
|
|
systemUpdateHost(packageRoot, home).installedVersion({
|
|
manager: "npm",
|
|
prefix: home,
|
|
packageRoot,
|
|
}),
|
|
).resolves.toEqual(ok("3.3.0"));
|
|
});
|
|
});
|
|
|
|
const createBunUpdateFixture = async (
|
|
root: string,
|
|
bunVersion: string,
|
|
installOutputBytes: number,
|
|
installExitCode: number,
|
|
) => {
|
|
const globalDirectory = join(root, "bun", "install", "global");
|
|
const packageRoot = join(
|
|
globalDirectory,
|
|
"node_modules",
|
|
PRODUCT_IDENTITY.packageName,
|
|
);
|
|
const versionPath = join(root, "installed-version");
|
|
const logPath = join(root, "bun-invocations.jsonl");
|
|
await mkdir(join(packageRoot, "scripts"), { recursive: true });
|
|
await writeFile(
|
|
join(globalDirectory, "package.json"),
|
|
'{"dependencies":{"rea-agents":"3.2.1"}}\n',
|
|
);
|
|
await writeFile(versionPath, "3.2.1");
|
|
await writeFile(
|
|
join(packageRoot, "scripts", "rea.mjs"),
|
|
`import { readFileSync } from "node:fs";\nprocess.stdout.write(readFileSync(${JSON.stringify(versionPath)}, "utf8") + "\\n");\n`,
|
|
);
|
|
const binDirectory = join(root, "bin");
|
|
const recorder = join(binDirectory, "record-bun.mjs");
|
|
await mkdir(binDirectory);
|
|
await writeFile(
|
|
recorder,
|
|
[
|
|
'import { appendFileSync, writeFileSync } from "node:fs";',
|
|
"const args = process.argv.slice(2);",
|
|
`appendFileSync(${JSON.stringify(logPath)}, JSON.stringify({ args, cwd: process.cwd(), globalDirectory: process.env.BUN_INSTALL_GLOBAL_DIR }) + "\\n");`,
|
|
`if (JSON.stringify(args) === '["--version"]') console.log(${JSON.stringify(bunVersion)});`,
|
|
`else if (JSON.stringify(args) === ${JSON.stringify(JSON.stringify(["info", PRODUCT_IDENTITY.packageName, "dist-tags.latest", "--json"]))}) process.stdout.write('"3.3.0"\\n');`,
|
|
`else if (JSON.stringify(args) === ${JSON.stringify(JSON.stringify(["add", "--global", "--ignore-scripts", `${PRODUCT_IDENTITY.packageName}@3.3.0`]))}) process.stderr.write('x'.repeat(${installOutputBytes}), () => { ${installExitCode === 0 ? `writeFileSync(${JSON.stringify(versionPath)}, "3.3.0");` : "process.exitCode = 2;"} });`,
|
|
"else process.exitCode = 2;",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
if (process.platform === "win32") {
|
|
await writeFile(
|
|
join(binDirectory, "bun.cmd"),
|
|
`@"${process.execPath}" "${recorder}" %*\r\n`,
|
|
);
|
|
} else {
|
|
await writeFile(
|
|
join(binDirectory, "bun"),
|
|
`#!/bin/sh\nexec ${JSON.stringify(process.execPath)} ${JSON.stringify(recorder)} "$@"\n`,
|
|
{ mode: 0o755 },
|
|
);
|
|
}
|
|
return { globalDirectory, packageRoot, versionPath, logPath, binDirectory };
|
|
};
|
|
|
|
it.skipIf(process.platform === "win32")(
|
|
"distinguishes a missing npm metadata launcher from a started registry probe",
|
|
async () => {
|
|
const root = await createTestTempDirectory("rea-npm-probe-failure-");
|
|
const bin = join(root, "bin");
|
|
await mkdir(bin);
|
|
const host = systemUpdateHost(root, home, { ...process.env, PATH: bin });
|
|
const installation = {
|
|
manager: "npm" as const,
|
|
prefix: root,
|
|
packageRoot: root,
|
|
};
|
|
try {
|
|
expect(await host.latestVersion(installation)).toMatchObject({
|
|
ok: false,
|
|
error: {
|
|
kind: "package-manager-unavailable",
|
|
manager: "npm",
|
|
detail: expect.stringContaining("ENOENT"),
|
|
},
|
|
});
|
|
await writeFile(
|
|
join(bin, "npm"),
|
|
"#!/bin/sh\nprintf 'registry fixture failed\\n' >&2\nexit 7\n",
|
|
{ mode: 0o755 },
|
|
);
|
|
expect(await host.latestVersion(installation)).toEqual(
|
|
err({ kind: "unavailable", detail: "registry fixture failed" }),
|
|
);
|
|
} finally {
|
|
await host.close?.();
|
|
}
|
|
},
|
|
);
|
|
|
|
it.skipIf(process.platform === "win32")(
|
|
"reports a Bun metadata launcher lost after a successful version probe",
|
|
async () => {
|
|
const root = await createTestTempDirectory("rea-bun-metadata-launch-");
|
|
const fixture = await createBunUpdateFixture(root, "1.4.2", 0, 0);
|
|
await writeFile(
|
|
join(fixture.binDirectory, "bun"),
|
|
"#!/bin/sh\n/bin/rm \"$0\"\nprintf '1.4.2\\n'\n",
|
|
{ mode: 0o755 },
|
|
);
|
|
const host = systemUpdateHost(fixture.packageRoot, home, {
|
|
...process.env,
|
|
PATH: fixture.binDirectory,
|
|
BUN_INSTALL_GLOBAL_DIR: fixture.globalDirectory,
|
|
});
|
|
try {
|
|
expect(
|
|
await host.latestVersion({
|
|
manager: "bun",
|
|
globalDirectory: fixture.globalDirectory,
|
|
packageRoot: fixture.packageRoot,
|
|
}),
|
|
).toMatchObject({
|
|
ok: false,
|
|
error: {
|
|
kind: "package-manager-unavailable",
|
|
manager: "bun",
|
|
detail: expect.stringContaining("ENOENT"),
|
|
},
|
|
});
|
|
} finally {
|
|
await host.close?.();
|
|
}
|
|
},
|
|
);
|
|
|
|
it.skipIf(process.platform === "win32").each(["failed", "missing"] as const)(
|
|
"reports a %s local Bun probe without attempting release lookup",
|
|
async (mode) => {
|
|
const root = await createTestTempDirectory("rea-bun-probe-failure-");
|
|
const fixture = await createBunUpdateFixture(root, "1.4.2", 0, 0);
|
|
const executable = join(fixture.binDirectory, "bun");
|
|
if (mode === "missing") await rm(executable);
|
|
else
|
|
await writeFile(
|
|
executable,
|
|
`#!/bin/sh\nprintf 'probe\\n' > ${JSON.stringify(fixture.logPath)}\nprintf 'fixture: bun cannot start\\n' >&2\nexit 7\n`,
|
|
{ mode: 0o755 },
|
|
);
|
|
const result = await runUpdate(
|
|
"3.2.1",
|
|
systemUpdateHost(fixture.packageRoot, home, {
|
|
...process.env,
|
|
PATH: fixture.binDirectory,
|
|
BUN_INSTALL_GLOBAL_DIR: fixture.globalDirectory,
|
|
}),
|
|
"structured",
|
|
);
|
|
expect(result).toMatchObject({
|
|
status: "failed",
|
|
reason: "version-check",
|
|
latestVersion: null,
|
|
remediation: expect.stringContaining(
|
|
mode === "failed" ? "fixture: bun cannot start" : "ENOENT",
|
|
),
|
|
});
|
|
expect(result).toHaveProperty(
|
|
"remediation",
|
|
expect.stringContaining("repair its launcher"),
|
|
);
|
|
expect(result).toHaveProperty(
|
|
"remediation",
|
|
expect.not.stringContaining("registry access"),
|
|
);
|
|
if (mode === "failed")
|
|
expect(await readFile(fixture.logPath, "utf8")).toBe("probe\n");
|
|
else
|
|
await expect(access(fixture.logPath)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
expect(await readFile(fixture.versionPath, "utf8")).toBe("3.2.1");
|
|
},
|
|
);
|
|
|
|
describe("Bun global installation update", () => {
|
|
it.each([
|
|
["1.4.2", "updated", "absolute", UPDATE_COMMAND_OUTPUT_BYTES + 1, 0],
|
|
["1.4.2", "install-failed", "absolute", UPDATE_COMMAND_OUTPUT_BYTES + 1, 2],
|
|
["1.2.17", "updated", "absolute", 0, 0],
|
|
["1.2.17", "updated", "relative", 0, 0],
|
|
["1.2.14", "failed", "absolute", 0, 0],
|
|
["1.2.17-canary.1", "failed", "absolute", 0, 0],
|
|
["unknown", "failed", "absolute", 0, 0],
|
|
] as const)(
|
|
"handles Bun %s with outcome %s using %s global-directory configuration",
|
|
async (
|
|
bunVersion,
|
|
status,
|
|
directoryMode,
|
|
installOutputBytes,
|
|
installExitCode,
|
|
) => {
|
|
// A recording `bun` on PATH crosses the real subprocess boundary without registry access.
|
|
const root = await createTestTempDirectory("rea-update-bun-");
|
|
const {
|
|
globalDirectory,
|
|
packageRoot,
|
|
versionPath,
|
|
logPath,
|
|
binDirectory,
|
|
} = await createBunUpdateFixture(
|
|
root,
|
|
bunVersion,
|
|
installOutputBytes,
|
|
installExitCode,
|
|
);
|
|
const pathKey =
|
|
Object.keys(process.env).find((key) => key.toUpperCase() === "PATH") ??
|
|
"PATH";
|
|
const environment: NodeJS.ProcessEnv = {
|
|
...process.env,
|
|
[pathKey]: `${binDirectory}${delimiter}${process.env[pathKey] ?? ""}`,
|
|
BUN_INSTALL: join(root, "bun"),
|
|
};
|
|
delete environment.BUN_INSTALL_GLOBAL_DIR;
|
|
if (directoryMode === "relative")
|
|
environment.BUN_INSTALL_GLOBAL_DIR = relative(root, globalDirectory);
|
|
|
|
const callerDirectory = process.cwd();
|
|
let result: UpdateResult;
|
|
try {
|
|
process.chdir(root);
|
|
result = await runUpdate(
|
|
"3.2.1",
|
|
systemUpdateHost(packageRoot, home, environment),
|
|
"structured",
|
|
);
|
|
} finally {
|
|
process.chdir(callerDirectory);
|
|
}
|
|
|
|
const invocations = (await readFile(logPath, "utf8"))
|
|
.trim()
|
|
.split("\n")
|
|
.map((line): unknown => JSON.parse(line));
|
|
const versionInvocation = {
|
|
args: ["--version"],
|
|
cwd: globalDirectory,
|
|
globalDirectory,
|
|
};
|
|
if (status === "failed") {
|
|
expect(result).toEqual({
|
|
status: "failed",
|
|
currentVersion: "3.2.1",
|
|
latestVersion: null,
|
|
reason: "version-check",
|
|
remediation: `REA updates for Bun global installations require Bun 1.2.17 or later; bun --version returned ${JSON.stringify(bunVersion)}. Upgrade Bun manually, then rerun rea update.`,
|
|
});
|
|
expect(invocations).toEqual([versionInvocation]);
|
|
expect(await readFile(versionPath, "utf8")).toBe("3.2.1");
|
|
return;
|
|
}
|
|
|
|
if (status === "install-failed") {
|
|
expect(result).toMatchObject({
|
|
status: "failed",
|
|
reason: "install",
|
|
remediation: expect.stringContaining("diagnostics truncated"),
|
|
});
|
|
expect(await readFile(versionPath, "utf8")).toBe("3.2.1");
|
|
} else
|
|
expect(result).toMatchObject({
|
|
status: "updated",
|
|
installMethod: "bun",
|
|
installedVersion: "3.3.0",
|
|
command: [
|
|
"bun",
|
|
"add",
|
|
"--global",
|
|
"--ignore-scripts",
|
|
`${PRODUCT_IDENTITY.packageName}@3.3.0`,
|
|
],
|
|
});
|
|
// `bun info` needs a project in its working directory, and the caller's
|
|
// directory must never be selected, so all commands run in the owner.
|
|
expect(invocations).toEqual([
|
|
versionInvocation,
|
|
{
|
|
args: [
|
|
"info",
|
|
PRODUCT_IDENTITY.packageName,
|
|
"dist-tags.latest",
|
|
"--json",
|
|
],
|
|
cwd: globalDirectory,
|
|
globalDirectory,
|
|
},
|
|
{
|
|
args: [
|
|
"add",
|
|
"--global",
|
|
"--ignore-scripts",
|
|
`${PRODUCT_IDENTITY.packageName}@3.3.0`,
|
|
],
|
|
cwd: globalDirectory,
|
|
globalDirectory,
|
|
},
|
|
]);
|
|
},
|
|
);
|
|
});
|
|
|
|
let updateCommands: UpdateCommandRunner;
|
|
beforeEach(() => {
|
|
updateCommands = new UpdateCommandRunner();
|
|
});
|
|
afterEach(async () => {
|
|
await updateCommands.close();
|
|
});
|