From 02c6d3c8bc637be49a4abb8bb130f8c25f491106 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Mon, 30 Nov 2026 10:33:18 -0500 Subject: [PATCH] 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. --- .../skills/reverse-engineer-anything/SKILL.md | 6 +++ .../skills/reverse-engineer-anything/SKILL.md | 6 +++ README.md | 3 +- src/application/Update.test.ts | 6 +++ src/application/Update.ts | 3 +- src/cli/discovery.ts | 4 +- src/cli/runCliCommand.ts | 4 +- src/cli/updateNotice.ts | 41 +++++++++++++----- tests/acceptance/cliTerminalNotices.test.ts | 42 +++++++++++++++++++ 9 files changed, 100 insertions(+), 15 deletions(-) diff --git a/.agents/skills/reverse-engineer-anything/SKILL.md b/.agents/skills/reverse-engineer-anything/SKILL.md index 0fc797e97b..abfbf7334f 100644 --- a/.agents/skills/reverse-engineer-anything/SKILL.md +++ b/.agents/skills/reverse-engineer-anything/SKILL.md @@ -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 diff --git a/.cursor-plugin/skills/reverse-engineer-anything/SKILL.md b/.cursor-plugin/skills/reverse-engineer-anything/SKILL.md index 0fc797e97b..abfbf7334f 100644 --- a/.cursor-plugin/skills/reverse-engineer-anything/SKILL.md +++ b/.cursor-plugin/skills/reverse-engineer-anything/SKILL.md @@ -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 diff --git a/README.md b/README.md index 6ff7e02d5e..3297a6e8ca 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/application/Update.test.ts b/src/application/Update.test.ts index e64d3f4d84..090945c884 100644 --- a/src/application/Update.test.ts +++ b/src/application/Update.test.ts @@ -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([]); }); diff --git a/src/application/Update.ts b/src/application/Update.ts index 85ee3d33b0..8aa2c64d93 100644 --- a/src/application/Update.ts +++ b/src/application/Update.ts @@ -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, diff --git a/src/cli/discovery.ts b/src/cli/discovery.ts index 6675ef9b43..bf5464a585 100644 --- a/src/cli/discovery.ts +++ b/src/cli/discovery.ts @@ -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, diff --git a/src/cli/runCliCommand.ts b/src/cli/runCliCommand.ts index 1701c813c5..3b821711d9 100644 --- a/src/cli/runCliCommand.ts +++ b/src/cli/runCliCommand.ts @@ -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 ? [] diff --git a/src/cli/updateNotice.ts b/src/cli/updateNotice.ts index ba9855f2f4..cd6097fd53 100644 --- a/src/cli/updateNotice.ts +++ b/src/cli/updateNotice.ts @@ -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 ( diff --git a/tests/acceptance/cliTerminalNotices.test.ts b/tests/acceptance/cliTerminalNotices.test.ts index 71a6aaea74..cc7d3a0af0 100644 --- a/tests/acceptance/cliTerminalNotices.test.ts +++ b/tests/acceptance/cliTerminalNotices.test.ts @@ -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>) => { + 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"); + }, +);