Repository navigation
feat(update): update Bun global installations - #1735
Conversation
`rea update` only recognized npm global installations and looked up releases with `npm view`, so a `bun add --global rea-agents` install on a machine without npm failed with `spawn npm ENOENT`. Detect the running package inside Bun's global directory (BUN_INSTALL_GLOBAL_DIR, $BUN_INSTALL/install/global, $XDG_CACHE_HOME/.bun/install/global, ~/.bun/install/global), resolve the latest release with `bun info`, install with `bun add --global --ignore-scripts`, then verify the installed entry point and plan integration maintenance exactly as for npm. Bun commands run inside the owning global directory with BUN_INSTALL_GLOBAL_DIR pinned, so the caller's current project is never selected. A global directory without package.json is not treated as an owned installation: Bun then installs into the nearest ancestor project. npm installations keep their existing commands and messages.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e1111b5f2e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Great PR! Thanks! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5963280de9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
rea updateonly knew npm global installs. If you installed REA withbun add --global rea-agentson a machine that has Bun but no npm, it stopped right away:{"status":"failed","currentVersion":"6.4.0","latestVersion":null,"reason":"version-check","remediation":"REA could not resolve the latest release: spawn npm ENOENT..."}With this PR,
rea updaterecognizes a Bun global installation of the running package. It looks up the latest release with Bun, installs it with Bun into the same global directory, checks the installed entry point's version, and plans integration maintenance the same way it does for npm. npm installations use the same commands and messages as before.No linked issue. The problem was seen on a Bun-only Windows machine.
Problem and expected behavior
rea updatefrom abun add --globalinstall ($BUN_INSTALL/install/global/node_modules/rea-agents, with~/.bunas the defaultBUN_INSTALL).detectNpmInstallationrecognizes only npm's global root or a<prefix>/lib/node_modules/rea-agentslayout. A Bun install becomes "unknown", so the release lookup falls back tonpm view. Without npm, that fails withspawn npm ENOENT. With npm present, the update can only fail withunknown-install-method.Change and scope
Update.ts(workflow): an installation is nowNpmInstallation | BunInstallation, with amanagerdiscriminant.installMethodreports"npm","bun", or"unknown". For Bun,updateInstallCommandreturnsbun add --global --ignore-scripts rea-agents@<version>. Install and verification remediation messages name the manager and its location; for npm the text is unchanged.UpdateRuntime.ts(system host):bunGlobalDirectoryfollows Bun's precedence for the global project directory:BUN_INSTALL_GLOBAL_DIR, then$BUN_INSTALL/install/global, then$XDG_CACHE_HOME/.bun/install/global, then~/.bun/install/global. The home directory comes from the existinghomeDirectoryFromEnvironment, so it isUSERPROFILEon Windows. I checked each step with throwaway roots under Bun 1.4.2 on Windows.detectBunInstallationmatches only when the canonical package root equals<globalDir>/node_modules/rea-agentsand<globalDir>/package.jsonexists. It is location-based, so a Bun global install running under Node is still detected. It runs before npm detection, so Bun installs don't spawnnpm. npm detection is unchanged.bun info rea-agents dist-tags.latest --json, which honors Bun's registry configuration. Its output (a JSON string) goes through the existingnpmReleaseLookupparser.bun infoandbun add) run withcwdset to the owning global directory andBUN_INSTALL_GLOBAL_DIRset to that same directory. This plays the role of npm's--prefix.runUpdateCommandgot an optional working-directory parameter for this. npm subprocesses keep the caller's working directory and environment as before.package.json,bun add --globalwalks up to the nearest ancestorpackage.jsonand installs into that project. I hit this while probing: withBUN_INSTALLpointed at a temp directory underC:\Users\<user>\AppData\Local\Temp,bun add -g [email protected]rewroteC:\Users\<user>\package.json,bun.lockandnode_modules(restored right away). Also,bun inforefuses to run unless its working directory is inside a project. Guards:<globalDir>/package.json. Without it, the installation is not treated as Bun-owned, sorea updatenever runsbun addthere.bunfig.tomlinstall.globalDir, which REA cannot see without parsing bunfig; layouts where Bun already installed into an ancestor project because of the walk-up above;bunxinvocations (still "unknown", asnpxis); and the release lookup for unknown installations, which still uses npm as before.Contract and boundary impact
src/application/Update.ts(installation model, install command) andsrc/application/UpdateRuntime.ts(detection and package-manager effects).rea updateJSON result can now reportinstallMethod: "bun", with a Buncommand. No other fields changed and no MCP tools changed.rea updatecan now spawnbun infoandbun add --global --ignore-scripts, always with the owning Bun global directory ascwdandBUN_INSTALL_GLOBAL_DIR. Arguments go throughcross-spawnas literals, like the npm path.docs/public/product-catalog.json), package, or installation impact: no generated metadata or package changes. UpdatedREADME.md(Update section and bug FAQ) anddocs/installation.md(update behavior and the "Diagnose, update, and remove" section).Evidence and regression coverage
tests/process-global/updateMaintenance.test.ts› "updates a Bun global installation from inside its global project": runsrunUpdatewith the realsystemUpdateHostand real subprocesses. A recordingbunexecutable (bun.cmdon Windows, a shell script elsewhere) onPATHplays the registry and installer. The test checksinstallMethod: "bun", the exactbun addcommand, the verified version read back from the package's ownscripts/rea.mjs, and that bothbun infoandbun addran withcwdandBUN_INSTALL_GLOBAL_DIRequal to the owning global directory. Mutation check: when I removed the working-directory pin, this test failed because the recordedcwdwas the repository root.src/application/Update.test.ts: Bun update and current paths throughrunUpdate; Bun ownership (match, missing globalpackage.json, package roots outside the global project, unresolvable path);bunGlobalDirectoryprecedence, including WindowsUSERPROFILE. Existing npm ownership assertions now includemanager: "npm".src/application/UpdateRuntime.release.test.ts,src/cliLogging.test.ts: fixtures updated for themanagerdiscriminant.bun add -gfrom a cwd inside an unrelated project with its ownpackage.jsonleft that project untouched.bun add -gwith an empty global directory below an ancestorpackage.jsoninstalled into the ancestor (the hazard above).bun info rea-agents dist-tags.latest --jsonprinted"6.4.0"inside the global directory. Outside any project it printederror: Bun could not find a package.json file to install from.BUN_INSTALL_GLOBAL_DIRandXDG_CACHE_HOMEwere both honored for the global directory.Created a temp root
C:\rea-bun-smoke-<random>(outside the user's home tree), withBUN_INSTALL=<root>\bunandHOME/USERPROFILE=<root>\home. Ranbun add -g [email protected]from<root>.Overlaid this branch's compiled
dist/,scripts/andpackage.jsononto<root>\bun\install\global\node_modules\rea-agents, then set itspackage.jsonversion anddist/generatedPackageMetadata.jsversion to6.3.0.bun <pkg>\scripts\rea.mjs --versionprinted6.3.0.Created an unrelated project
<root>\project\package.jsonand recorded its hash, plus hashes and mtimes of the real~/package.json,~/bun.lock,~/node_modules/rea-agents,~/.bun/bin/*,~/.bun/install/global, and the worktree'sgit status.From
cwd=<root>\project, ranbun <root>\bun\install\global\node_modules\rea-agents\scripts\rea.mjs update --format json. It exited 0, wrote nothing to stderr, and printed:{"status":"updated","previousVersion":"6.3.0","latestVersion":"6.4.0","installedVersion":"6.4.0","installMethod":"bun","command":["bun","add","--global","--ignore-scripts","[email protected]"],"maintenance":{"status":"current","plannedActions":[]},"remediation":"REA is updated. Restart agents running this installation to load the new version."}Afterwards:
<root>\bun\install\global\package.jsonlists"rea-agents": "6.4.0". The installed package is the registry 6.4.0 (the overlay is gone andgeneratedPackageMetadata.jssays6.4.0). The regenerated shim<root>\bun\bin\rea.exe --versionprinted6.4.0.<root>\projectstill held only its originalpackage.jsonwith the same hash. The before/after snapshot of everything outside the temp root was identical. I deleted the temp root.bunGlobalDirectoryunit cases. The Node-runtime-with-Bun-install combination was not run (Node is not installed here); detection does not depend on the runtime. Bun's walk-up was observed only on Windows.bunfig.tomlinstall.globalDiris not detected.For evidence-bearing changes: not applicable (no Evidence records change).
Validation performed
Local validation ran under Bun 1.4.2 on Windows x64 without Node.js or npm, on this commit rebased onto
mainat e36c82b. CI covers Node.bun --bun run compileand everyartifacts:*generator (skills,mcp-catalog,product-catalog,managed-evidence,error-schema): succeeded.bun --bun run test:local -- src/application/Update.test.ts src/application/UpdateRuntime.release.test.ts src/cliLogging.test.ts: 3 files, 50 tests passed.bun --bun node_modules/vitest/vitest.mjs run tests/process-global/updateMaintenance.test.ts: 18 tests passed. Before the rebase, removing the working-directory pin made the new Bun test fail on the recordedcwd; it passed again after restoring the pin.bun --bun node_modules/vitest/vitest.mjs run tests/boundary/cli/cliStartupImports.test.ts(covers the deferredupdatecommand loading onmain): 2 passed, 3 failed. The same 3 fail onmainunder Bun: the test records imports through--importhooks fromnode:module, and under Bun the recorded lists come back empty.bun --bun run typecheck: passed.bun --bun run lint(oxlint plus module-boundary check): exit 0, no warnings in changed files.bun --bun node_modules/.bin/oxfmt --checkon LF-normalized copies of all 8 changed files: passed. (The Windows checkout uses CRLF, which oxfmt flags in every file.)bun --bun run docs:check:built: exit 0. Thedocs:checkwrapper could not run because it requires npm'snode_modules/.package-lock.json.rea updateexited 0 with the JSON shown, the globalpackage.jsonlistsrea-agents6.4.0, the shim prints6.4.0, the unrelated project was untouched, and the snapshot outside the temp root was identical.Compatibility, safety, and release
rea updateresult type gainsinstallMethod: "bun". npm installs keep the same detection, commands, and message text.NpmInstallationgains amanager: "npm"field; it is internal and not part of the CLI/MCP contract.bun add --globalruns with--ignore-scripts. It is confined to the detected Bun global directory bycwdandBUN_INSTALL_GLOBAL_DIR, and it never runs when that directory lackspackage.json, which would otherwise let Bun modify an ancestor project such as the user's home directory. The environment override applies only to that child process and is not persisted.Review checklist
type(scope): outcome.