mirror of
https://github.com/morluto/rea.git
synced 2026-12-02 13:11:18 -05:00
fix(cli): suggest npx rea-agents@latest setup in the update notice under npx (#15251)
* 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.
This commit is contained in:
@@ -52,6 +52,12 @@ JADX, Kuna, Binwalk, or Unblob. Use existing prerequisites; do not install unrel
|
||||
software to repair MCP registration. For an unsupported client, use manual stdio
|
||||
registration with an existing installation’s absolute runtime and entry script, or continue through the CLI.
|
||||
|
||||
When a person asks you to update REA, run `rea update` for a global npm or Bun
|
||||
installation. Otherwise, including a setup made with `npx rea-agents setup`, run
|
||||
`npx rea-agents@latest setup` from a trusted directory outside the target
|
||||
project. Show its setup plan, apply it only after their approval, then ask them
|
||||
to restart this agent so it loads the new version.
|
||||
|
||||
A concrete CLI fallback for an operator-supplied JavaScript tree or ASAR is:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -52,6 +52,12 @@ JADX, Kuna, Binwalk, or Unblob. Use existing prerequisites; do not install unrel
|
||||
software to repair MCP registration. For an unsupported client, use manual stdio
|
||||
registration with an existing installation’s absolute runtime and entry script, or continue through the CLI.
|
||||
|
||||
When a person asks you to update REA, run `rea update` for a global npm or Bun
|
||||
installation. Otherwise, including a setup made with `npx rea-agents setup`, run
|
||||
`npx rea-agents@latest setup` from a trusted directory outside the target
|
||||
project. Show its setup plan, apply it only after their approval, then ask them
|
||||
to restart this agent so it loads the new version.
|
||||
|
||||
A concrete CLI fallback for an operator-supplied JavaScript tree or ASAR is:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -144,7 +144,8 @@ If you use `npx`, refresh your agent setup with:
|
||||
npx rea-agents@latest setup
|
||||
```
|
||||
|
||||
Review the setup changes and restart your agent. See
|
||||
Review the setup changes and restart your agent. You can also ask your agent
|
||||
to update REA for you. See
|
||||
[update and uninstall instructions](docs/getting-started/installation.md#diagnose-update-and-remove)
|
||||
for package runner options and troubleshooting.
|
||||
|
||||
|
||||
@@ -433,6 +433,12 @@ describe("update failures and version boundaries", () => {
|
||||
"remediation",
|
||||
expect.not.stringContaining("npm install --global"),
|
||||
);
|
||||
expect(result).toHaveProperty(
|
||||
"remediation",
|
||||
expect.stringContaining(
|
||||
"If you set up REA with npx, run npx rea-agents@latest setup",
|
||||
),
|
||||
);
|
||||
expect(host.installedVersions).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
@@ -226,8 +226,7 @@ const runUpdateWorkflow = async (
|
||||
currentVersion,
|
||||
latestVersion: targetVersion,
|
||||
reason: "unknown-install-method",
|
||||
remediation:
|
||||
"Update this installation with the package manager or source checkout that owns it. For a one-off latest invocation, use npx rea-agents@latest.",
|
||||
remediation: `This copy of REA was not installed with npm or Bun, so rea update cannot upgrade it. If you set up REA with npx, run npx ${PRODUCT_IDENTITY.packageSpecifier} setup to get the latest version and refresh your agents. You can also ask your agent to update REA for you. If you installed REA another way, update it with the tool you used.`,
|
||||
};
|
||||
const installed = await host.installVersion(
|
||||
installation,
|
||||
|
||||
@@ -391,7 +391,9 @@ const unknownCommandAnswer = (
|
||||
? availableUpdate(cli.name, PRODUCT_IDENTITY.packageVersion, environment)
|
||||
: undefined;
|
||||
const notice =
|
||||
update === undefined ? [] : updateNoticeCta(cli.name, update).commands;
|
||||
update === undefined
|
||||
? []
|
||||
: updateNoticeCta(cli.name, update, environment).commands;
|
||||
const { command, cta, failure } = unknownCommandReply({
|
||||
name: cli.name,
|
||||
global,
|
||||
|
||||
@@ -137,7 +137,9 @@ export const runCliCommand = async (
|
||||
? availableUpdate(cli.name, PRODUCT_IDENTITY.packageVersion, environment)
|
||||
: undefined;
|
||||
const cta =
|
||||
update === undefined ? undefined : updateNoticeCta(cli.name, update);
|
||||
update === undefined
|
||||
? undefined
|
||||
: updateNoticeCta(cli.name, update, environment);
|
||||
const sensitive =
|
||||
entry.definition.options?.shape.sensitiveValue === undefined
|
||||
? []
|
||||
|
||||
+31
-10
@@ -26,6 +26,8 @@ import { mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
||||
import { userInfo } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
import { invokingPackageRunner } from "../application/ClientRegistrationIdentity.js";
|
||||
|
||||
/**
|
||||
* The terminal update notice. On a terminal without an explicit format, a
|
||||
* command's output (and an unknown-command error) ends with "Update available"
|
||||
@@ -295,16 +297,35 @@ export const availableUpdate = (
|
||||
return { name: target.name, current: target.current, latest: cached.latest };
|
||||
};
|
||||
|
||||
/** The notice's suggested-command block for an available update. */
|
||||
export const updateNoticeCta = (cli: string, update: AvailableUpdate) => ({
|
||||
description: `Update available for ${update.name}:`,
|
||||
commands: [
|
||||
{
|
||||
command: `${cli} --update`,
|
||||
description: `upgrade from ${update.current} to ${update.latest}`,
|
||||
},
|
||||
],
|
||||
});
|
||||
/**
|
||||
* The notice's suggested-command block for an available update. A package
|
||||
* runner launch has no installed `rea` to upgrade, and its agent registrations
|
||||
* point at that run's cache, so rerunning setup at `@latest` is the upgrade.
|
||||
*/
|
||||
export const updateNoticeCta = (
|
||||
cli: string,
|
||||
update: AvailableUpdate,
|
||||
environment: UpdateEnvironment,
|
||||
) => {
|
||||
const runner = invokingPackageRunner(
|
||||
environment.variables,
|
||||
environment.platform,
|
||||
);
|
||||
return {
|
||||
description: `Update available for ${update.name}:`,
|
||||
commands: [
|
||||
runner === undefined
|
||||
? {
|
||||
command: `${cli} --update`,
|
||||
description: `upgrade from ${update.current} to ${update.latest}`,
|
||||
}
|
||||
: {
|
||||
command: `${runner} ${update.name}@latest setup`,
|
||||
description: `upgrade from ${update.current} to ${update.latest} and refresh your agent setup`,
|
||||
},
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
/** The detached refresh: record the registry's latest version. Never throws. */
|
||||
export const refreshUpdateCache = async (
|
||||
|
||||
@@ -54,3 +54,45 @@ workspaceCliTest.skipIf(process.platform === "win32")(
|
||||
).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");
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user