mirror of
https://github.com/morluto/rea.git
synced 2026-12-01 11:01:11 +00:00
* fix(cli): suggest npx rea-agents@latest setup in the update notice under npx A package-runner launch has no installed rea to run --update on, and its agent registrations point at that run's cache, so the notice now suggests rerunning setup at @latest through the same runner. * fix(update): tell npx users how to update REA in plain words rea update cannot upgrade a copy it did not install. Its message now tells npx users to run npx rea-agents@latest setup and that they can ask their agent to do it. The skill tells agents which update command to run, and the README mentions asking the agent.
99 lines
3.5 KiB
TypeScript
99 lines
3.5 KiB
TypeScript
import { expect } from "vitest";
|
|
|
|
import { PRODUCT_IDENTITY } from "../../src/identity.js";
|
|
import { workspaceCliTest } from "../support/cli/workspaceCliFixture.js";
|
|
|
|
workspaceCliTest.skipIf(process.platform === "win32")(
|
|
"keeps terminal update notices outside selected result documents",
|
|
async ({ cli, workspace }) => {
|
|
await workspace.write("sample.bin", Buffer.from("notice fixture"));
|
|
await workspace.write(
|
|
`cache/incur/updates/${PRODUCT_IDENTITY.packageName}.json`,
|
|
JSON.stringify({ checkedAt: Date.now(), latest: "999.0.0" }),
|
|
);
|
|
const environment = {
|
|
...workspace.environment,
|
|
XDG_CACHE_HOME: workspace.path("cache"),
|
|
npm_config_registry: "http://127.0.0.1:9/",
|
|
};
|
|
const run = async (
|
|
arguments_: readonly string[],
|
|
stderrContains?: string,
|
|
) => {
|
|
const result = await cli.run({
|
|
arguments: arguments_,
|
|
cwd: workspace.root,
|
|
environment,
|
|
terminal: true,
|
|
});
|
|
expect(result.exitCode, result.stderr).toBe(0);
|
|
if (stderrContains === undefined) expect(result.stderr).toBe("");
|
|
else expect(result.stderr).toContain(stderrContains);
|
|
return result.stdout;
|
|
};
|
|
const entropy = ["inspect-byte-entropy", workspace.path("sample.bin")];
|
|
const notice = "Update available for rea-agents:";
|
|
expect(await run(entropy)).toContain(notice);
|
|
expect(await run([...entropy, "--full-output"])).toContain(notice);
|
|
for (const flags of [[], ["--full-output"], ["--token-limit", "10"]]) {
|
|
const output = await run([
|
|
...entropy,
|
|
"--filter-output",
|
|
"normalized_result.window",
|
|
...flags,
|
|
]);
|
|
expect(output).toContain("offset");
|
|
expect(output).not.toContain(notice);
|
|
}
|
|
// Suppressed agent-only output leaves the terminal notice visible.
|
|
expect(
|
|
await run(
|
|
["setup", "--dry-run", "--client", "codex", "--token-limit", "1"],
|
|
"Dry run complete. No changes were made.",
|
|
),
|
|
).toContain(notice);
|
|
},
|
|
);
|
|
|
|
workspaceCliTest.skipIf(process.platform === "win32")(
|
|
"suggests the package-runner upgrade when REA runs through npx or bunx",
|
|
async ({ cli, workspace }) => {
|
|
await workspace.write(
|
|
`cache/incur/updates/${PRODUCT_IDENTITY.packageName}.json`,
|
|
JSON.stringify({ checkedAt: Date.now(), latest: "999.0.0" }),
|
|
);
|
|
const run = async (launch: Readonly<Record<string, string>>) => {
|
|
const result = await cli.run({
|
|
arguments: ["setup", "--dry-run", "--client", "codex"],
|
|
cwd: workspace.root,
|
|
environment: {
|
|
...workspace.environment,
|
|
XDG_CACHE_HOME: workspace.path("cache"),
|
|
npm_config_registry: "http://127.0.0.1:9/",
|
|
...launch,
|
|
},
|
|
terminal: true,
|
|
});
|
|
expect(result.exitCode, result.stderr).toBe(0);
|
|
return result.stdout;
|
|
};
|
|
const upgrade = (runner: string) =>
|
|
`${runner} ${PRODUCT_IDENTITY.packageName}@latest setup`;
|
|
const npx = await run({
|
|
npm_command: "exec",
|
|
npm_config_user_agent: "npm/11.16.0 node/v24.22.1 darwin arm64",
|
|
});
|
|
expect(npx).toContain(upgrade("npx"));
|
|
expect(npx).not.toContain("rea --update");
|
|
expect(
|
|
await run({
|
|
npm_command: "exec",
|
|
npm_config_user_agent: "bun/1.3.0 npm/? node/v24.3.0 darwin arm64",
|
|
}),
|
|
).toContain(upgrade("bunx"));
|
|
const installed = await run({});
|
|
expect(installed).toContain("rea --update");
|
|
expect(installed).not.toContain("@latest setup");
|
|
},
|
|
);
|