Repository navigation
fix(setup): register a stable launcher when run through bunx - #1731
Merged
Merged
Conversation
Setup run through bunx or bun x registered the bin inside bun's temporary package cache. Detect bun's package-runner launch from npm_command=exec with a bun user agent and register the pinned bunx launcher, wrapped in cmd.exe on Windows like the npx launcher. Doctor, update maintenance and uninstall recognize it as REA-owned, and setup's printed commands name the runner that launched it. Read the runner variables case-insensitively on Windows, where the CLI environment snapshot upper-cases variable names and setup run through npx also fell back to the cache path.
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. |
Owner
|
This fixes a tricky setup edge across two package runners, @xeropresence: Bunx registrations now point at a pinned |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bunx rea-agents setupis Bun's version of the README quick start,npx rea-agents setup. When run that way, setup registered the bin inside Bun's temporary bunx cache. That registration stops working once the cache is cleared. Setup now detects a bunx (orbun x) launch and registers the pinnedbunx rea-agents@<version> mcplauncher, handled the same way as the existing npx launcher. Doctor, update maintenance, and uninstall treat the bunx launcher as REA-owned. Setup's printed next steps now saybunx rea-agentswhen setup was started through bunx.The fix also covers a Windows-only cause that affected npx as well. The CLI's environment snapshot upper-cases variable names on Windows, so the old lookup of
environment.npm_commandnever matched there. As a result, setup run through npx on Windows also registered the cache path, notcmd.exe /d /c npx -y rea-agents@<version> mcp.No issue is linked. The problem was found by running
bunx rea-agents@6.4.0 setupon Windows.Problem and expected behavior
Trigger (observed on Windows x64, Bun 1.4.2, published 6.4.0):
The broken invariant: a persistent registration must not depend on a package runner's temporary cache. Setup already does this for npx (
setupRegistrationCommand→npxRegistrationCommandwhennpm_command === "exec").Two causes, both confirmed by testing:
npm_command=execvariable as npx, plusnpm_config_user_agent=bun/1.4.2 npm/? node/v26.3.0 win32 x64andnpm_lifecycle_event=bunx. A probe bin run viabunx --package file:<tgz>, and a--preloadprobe run throughbunx rea-agents@6.4.0andbun x rea-agents@6.4.0, all showed these values. Before this change REA could not tell bunx apart from npx. On POSIX it would have registered annpxlauncher, which needs npm on the machine.snapshotEnvironmentupper-cases keys (NPM_COMMAND), soenvironment.npm_commandwas alwaysundefined. Setup then fell back to the directprocess.execPath+process.argv[1]registration, and under any package runnerargv[1]is in that runner's cache. The same snapshot also meantrunUpdateCommand'sdelete environment.npm_commanddid nothing on Windows.Expected: setup run through bunx/
bun xregistersbunx rea-agents@<version> mcp(cmd.exe /d /c bunx rea-agents@<version> mcpon Windows). Setup run through npx registers the npx launcher on every platform. Direct installs keep their current registration.Change and scope
ClientRegistrationIdentity.ts(application layer, which already owns the npx launcher identity):PackageRunner = "npx" | "bunx".invokingPackageRunner(environment, platform)readsnpm_commandandnpm_config_user_agent. On Windows the lookup ignores case.execwith abun/user agent →bunx;execwith anything else →npx(same as before); otherwise none.bun runreportsnpm_command=run-script(checked), so it is not detected as a runner.packageRunnerRegistrationCommand(runner, platform)buildsnpx -y <spec> mcporbunx <spec> mcp, wrapped incmd.exe /d /con Windows.npxRegistrationCommandnow calls it, so the npx launcher stays one definition.isOwnedClientRegistrationCommandalso acceptsbunx rea-agents[@<exact version>] mcp, with or without thecmd /c/cmd.exe /d /cwrapper. Other bunx shapes, other packages, and extra arguments are still not owned.withoutPackageRunnerIdentitytakes over the update subprocess's removal ofnpm_command, ignoring case on Windows.SetupHost.setupRegistrationCommand(platform, packageRunner)takes the detected runner instead of a boolean.ClientRegistrationStatusreports either runner's exact launcher asaligned.interactiveSetupprintsnpx rea-agentsorbunx rea-agents, matching the runner, in its next-step hints.docs/installation.md(start setup, Windows registrations, update/remove, MCP Registry note) and the README update section now mention bunx.Why
bunx rea-agents@<version> mcpand not Bun's absolute executable (<bun.exe> x rea-agents@<version> mcp):PATH, the version is pinned, and on Windows it goes throughcmd.exe /d /c. That keeps one ownership, alignment, and uninstall rule for both runners.cmd.exewrapper also works whenbunxis a.cmdshim (Bun installed through npm or another shim manager). A standard Bun install ships a realbunx.exe, and the smoke run below used it.process.execPathcan point to a versioned install path, such as a Homebrew Cellar directory, that disappears when Bun is upgraded. Writing it into the registration would swap one unstable path for another.--bunflag, so bunx uses the same runtime for the registered server that it used for setup.Not included:
rea updatestill updates only npm global installs, and its remediation text for other installs still mentionsnpx rea-agents@latest. Detecting a runner forrea update, the npm-onlyinstall.sh, and the MCP RegistryruntimeHint(which staysnpx) are unchanged.Contract and boundary impact
src/application/ClientRegistrationIdentity.ts, when setup builds the registration command.aligned.cmd.exe /d /cwrapper, as the npx launcher already does. POSIX clients getbunxdirectly.npm_commandremoved on Windows too, as the code already intended.docs/public/product-catalog.json), package, or installation impact: none. No generated files changed.Evidence and regression coverage
tests/boundary/cli/packageRunnerRegistration.test.ts(new): for npx and bunx environments, runs the real built CLIsetup --client omp --no-skill --yes --jsonin an isolated HOME. It checks that the written command equals the runner launcher for the host platform, thatdoctor --client omp --jsonreportsaligned, and that a repeatedsetup --dry-runplans nothing. On Windows this goes through the real CLI environment snapshot, so the upper-cased-variable bug is covered too.src/setupEnvironment.test.ts: a Windows-canonicalized snapshot (NPM_COMMAND,NPM_CONFIG_USER_AGENT) resolves to the right runner and setup registration, andwithoutPackageRunnerIdentityremoves the upper-cased key. This test fails on the base revision, where the lookup misses the upper-cased key.tests/boundary/filesystem/windowsNpxRegistration.test.ts: the Codex TOML align/idempotency/uninstall test now runs for both runners. Invalidbunxcommand shapes stay retained on uninstall. The native.cmdshim test now starts both annpx.cmdand abunx.cmdregistration as a stdio MCP server through the MCP client SDK (Windows only).tests/boundary/filesystem/clientConfigurationDialects.test.ts: bunx ownership for prior exact versions, and rejection of foreign bunx packages.tests/boundary/cli/cliSetup.test.ts: the completion hint printsbunx rea-agentsfor a bunx launch.Setup.configuration.test.tsandSetup.fixture.ts.bun x, andbun runlaunches as described in "Problem".Add the REA MCP registration for OMP; preserve unrelated configuration. Command: "cmd.exe" "/d" "/c" "bunx" "rea-agents@6.4.0" "mcp".npxrun. Node.js and npm are not installed on this machine, so the Windows npx fix is covered by the snapshot unit test, the boundary test's simulated npx environment, and thenpx.cmdshim test. bunx on macOS/Linux was not run locally. POSIX behavior is covered by CI running the same boundary test.Validation performed
All local validation ran under Bun 1.4.2 on Windows x64 without Node.js or npm installed. CI covers Node.
bun --bun run compileandbun --bun run artifacts:skills— passed.bun --bun run typecheck— passed.bun --bun run lint— exit 0. No new warnings. TheisOwnedClientRegistrationCommandcomplexity warning present on the base is gone, and the existingregistrationAlignedcomplexity warning dropped from 32 to 31.bun --bun node_modules/.bin/oxfmt --check <changed files>— all files formatted.bun --bun run test:local -- src/setupEnvironment.test.ts src/application/Setup.configuration.test.ts src/application/Update.test.ts— 45 passed.bun --bun node_modules/vitest/vitest.mjs run tests/boundary/cli/packageRunnerRegistration.test.ts tests/boundary/filesystem/windowsNpxRegistration.test.ts tests/process-global/updateMaintenance.test.ts— all passed (2 + 7 + 17), including the newnpx.cmdandbunx.cmdstdio MCP launches.bun --bun node_modules/vitest/vitest.mjs run tests/boundary/cli/cliSetup.test.ts tests/boundary/filesystem/clientConfigurationDialects.test.ts— the new and changed cases pass (three completion-hint cases; the bunx ownership assertions run before the existing POSIX-path assertion). 28 other tests in these files fail the same way on the unmodified base under Bun on Windows (POSIX path expectations and the interactive journey harness), so these failures predate this change.bun --bun node_modules/vitest/vitest.mjs run tests/boundary/filesystem/clientRegistrationStatus.test.ts tests/boundary/filesystem/setupConfig.test.ts tests/boundary/filesystem/ompClientConfiguration.test.ts tests/boundary/filesystem/hermesClientConfiguration.test.ts— 13 failures, the same 13 as on the unmodified base under Bun on Windows.bun --bun run test:local -- src/application/Setup.initialSnapshot.test.ts src/application/Setup.planning.test.ts src/application/Setup.recovery.test.ts— 2 failures inSetup.planning.test.ts, also the same on the base.bun --bun node_modules/vitest/vitest.mjs run tests/conformance/readmeConsistency.test.ts— 2 passed.bun --bun run docs:check:built(afterartifacts:product-catalog,artifacts:error-schema,artifacts:mcp-catalog,artifacts:managed-evidence) — passed. (docs:checkitself fails before running any checks becausecheck-dependency-install.mjsrequires npm'snode_modules/.package-lock.json.)C:\rea-bunx-smoke-6e3fas cwd, withHOME,USERPROFILE,APPDATA,LOCALAPPDATA, andBUN_INSTALLall pointed inside it. The patched package was packed withbun pm pack --ignore-scripts.bunx --package file:<tgz> rea setup --client omp --yes --json→status: ready.home\.omp\agent\mcp.jsoncontains{"type":"stdio","command":"cmd.exe","args":["/d","/c","bunx","rea-agents@6.4.0","mcp"]}, with no reference to the bunx temp cache.bunx --package file:<tgz> rea doctor --client omp --json→identity.registrations: [{client: "omp", command: ["cmd.exe","/d","/c","bunx","rea-agents@6.4.0","mcp"], state: "aligned"}].cmd.exe /d /c bunx rea-agents@6.4.0 mcp) and sent JSON-RPC over stdio.initializereturnedserverInfo {name: "rea", version: "6.4.0"}with protocol2025-06-18.tools/listreturned 170 tools. The registered pin resolves the published 6.4.0 from the registry, since the packed build has the same version number.bunx --package file:<tgz> rea uninstall --json→status: complete. Thereaentry was removed from the OMP config.Compatibility, safety, and release
bunx.exe) and a real MCP stdio launch. No provider is involved.bunxthroughcmd.exe /d /c, with fixed arguments and a pinned exact version, the same as the npx launcher. Ownership matching rejects shell-joined or extra-argument variants, and tests cover that. The update subprocess now drops the runner marker on Windows as well.Review checklist
type(scope): outcome.