Skip to content

fix(agents): detect agent CLIs installed outside a version manager - #18336

Merged
nwparker merged 5 commits into
mainfrom
nwparker/crash-agent-cli-path-resolution
Sep 4, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/crash-agent-cli-path-resolution

Conversation

@nwparker

@nwparker nwparker commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​299 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​299
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​98 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​81

What

Cluster G6 / agent-cli-path-resolution, 1 field report (report #3 in the G6 bucket): "安装的智能体扫描不到,Codex、Cursor、OpenCode,全识别不到" — "the installed agents can't be scanned, Codex / Cursor / OpenCode, none of them are recognized." Reported on macOS, Orca v1.4.194.

Orca answers "is this agent CLI installed?" two ways: scan PATH, and if that misses, probe a hard-coded list of install directories. That fallback list — getBaseVersionManagerDirectories, consumed at src/shared/node-cli-command-resolution.ts:270 (resolveCliCommand) and :286 (resolveCliCommands) on origin/main — contained only version-manager bin dirs (nvm, asdf, mise, volta, fnm, pnpm, bun, yarn, ~/.local/bin). It contained no Homebrew prefix, no npm default global prefix, no snap, no nix, and neither of the two installer-owned dirs #829 named (~/.opencode/bin, ~/.vite-plus/bin).

So a codex / cursor-agent / opencode installed by Homebrew, npm -g, snap, nix, or the CLI's own installer read as not installed whenever the PATH scan missed it. src/main/preflight/agent-detection.ts:160,166 and src/cli/handlers/skills.ts:167 both route through that list.

Two more asymmetries fixed alongside it, because the whole point of the fallback is that it match what Orca does elsewhere:

  • patchPackagedProcessPath (src/main/startup/configure-process.ts:114) already seeds every one of these dirs onto process.env.PATH (:140-156; eight across darwin and linux, six on any single platform). The fallback list did not, so the same install answered "installed" or "not installed" depending on which list ran.
  • The WSL guest prelude (src/shared/posix-version-manager-bin-dirs.ts) — whose docstring already claimed parity with the native list — had /usr/local/bin and nothing else, so a WSL user on Linuxbrew/snap/nix hit [Bug]: Agent detection failed on Windows (WSL) #9725 while the same user on native did not.

The change adds src/shared/system-cli-install-dirs.ts (getSystemCliInstallDirectories — /opt/homebrew/bin on darwin, then /usr/local/bin, /snap/bin + /home/linuxbrew/.linuxbrew/bin on linux, /nix/var/nix/profiles/default/bin, ~/.nix-profile/bin, ~/.opencode/bin, ~/.vite-plus/bin), appends it last in both resolvers, and mirrors it into the WSL prelude. win32 returns [] — the Windows branch is byte-for-byte unchanged.

Scope honesty, stated up front

This does not explain the reporter's packaged macOS v1.4.194 failure, and must not close G6 report #3. patchPackagedProcessPath returns early unless app.isPackaged (configure-process.ts:114-117), and when packaged it seeds every one of those dirs onto PATH at main-process-preflight.ts:147, before any detection runs; mergePathSegments (hydrate-shell-path.ts:382-385) never deletes them. So in the packaged desktop app the PATH scan reaches those dirs first and this fallback never fires for them.

Round 5 checked this against the reporter's exact build rather than against main, and it is even more decisive there: git show v1.4.194:src/main/startup/configure-process.ts shows all of /opt/homebrew/bin, /usr/local/bin, /nix/var/nix/profiles/default/bin, ~/.nix-profile/bin, ~/.opencode/bin, ~/.vite-plus/bin in extraPaths, prepended ([...missing, ...currentPath]) — not appended as on main today. On v1.4.194 those dirs led PATH before any detection ran. ~/.opencode/bin has been seeded since #843 (2026-04-19).

The fallback is decisive for exactly these populations: the orca CLI (src/cli/handlers/skills.ts:167, src/cli/handlers/account.ts:97 — src/cli/index.ts seeds no PATH), unpackaged / dev runs, and WSL guests via the prelude. Earlier revisions of this body also named the SSH host runtime; that was wrong and is retracted — see Trade-offs → SSH hosts and Round 4. That report stays open. This PR must not be merged with a closing keyword pointed at it, and there is none in this body or in any of the four commit messages (grep -inE 'fixes #|closes #|resolves #' → no match in either).

Fix evidence

Every command in this section was re-run at HEAD 2666af8 immediately before this revision was published. Nothing here is quoted from an earlier round.

Regression test RED with the production hunks reverted to origin/main

$ git checkout origin/main -- src/shared/node-cli-command-resolution.ts src/shared/posix-version-manager-bin-dirs.ts
$ git diff --stat origin/main -- src/shared/node-cli-command-resolution.ts src/shared/posix-version-manager-bin-dirs.ts
(empty output = files identical to origin/main)

$ ./node_modules/.bin/vitest run --config config/vitest.config.ts src/shared/agent-cli-install-dir-fallback.test.ts

 ❯ src/shared/agent-cli-install-dir-fallback.test.ts (8 tests | 5 failed) 11ms
     × finds macOS CLIs installed outside a version manager 6ms
     × finds Linux CLIs in Linuxbrew, snap and nix prefixes, not the macOS brew prefix 1ms
     × ranks system install dirs in the same order as the PATH seed 0ms
     × reports a system-installed CLI as detected, not just resolved 1ms
     × carries the system install dirs into the POSIX guest fallback prelude 0ms

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 5 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  ... > finds macOS CLIs installed outside a version manager
AssertionError: expected { …(4) } to deeply equal { …(4) }

- Expected
+ Received

  {
    "claude": "/Users/tester/.local/bin/claude",
-   "codex": "/opt/homebrew/bin/codex",
-   "cursor-agent": "/usr/local/bin/cursor-agent",
-   "opencode": "/Users/tester/.opencode/bin/opencode",
+   "codex": "codex",
+   "cursor-agent": "cursor-agent",
+   "opencode": "opencode",
  }

 FAIL  ... > finds Linux CLIs in Linuxbrew, snap and nix prefixes, not the macOS brew prefix
AssertionError: expected { codex: 'codex', …(3) } to deeply equal { …(4) }

  {
    "claude": "claude",
-   "codex": "/home/linuxbrew/.linuxbrew/bin/codex",
-   "cursor-agent": "/snap/bin/cursor-agent",
-   "opencode": "/home/tester/.nix-profile/bin/opencode",
+   "codex": "codex",
+   "cursor-agent": "cursor-agent",
+   "opencode": "opencode",
  }

 FAIL  ... > ranks system install dirs in the same order as the PATH seed
AssertionError: expected { opencode: 'opencode' } to deeply equal { opencode: '/usr/local/bin/opencode' }

 FAIL  ... > reports a system-installed CLI as detected, not just resolved
AssertionError: expected Set{} to deeply equal Set{ 'codex', 'opencode', 'pi' }

- Set {
-   "codex",
-   "opencode",
-   "pi",
- }
+ Set {}

 FAIL  ... > carries the system install dirs into the POSIX guest fallback prelude
AssertionError: expected false to be true // Object.is equality

 Test Files  1 failed (1)
      Tests  5 failed | 3 passed (8)

The first red row reproduces the field report's symptom shape — claude resolves, codex + cursor-agent + opencode do not. It is not a reproduction of the reporter's machine, and per Scope honesty above this fallback is not the code path their packaged build took; read it as "this omission is capable of producing that symptom", nothing stronger.

The reports a system-installed CLI as detected, not just resolved case asserts through detectCommandsInInstallDirs — the exact function src/cli/handlers/skills.ts:167 and src/main/preflight/agent-detection.ts:166 call — with a stubbed GUI-launch PATH, so it pins the real "absolute path means installed" contract, not just the resolver.

GREEN with the production hunks restored

$ git checkout HEAD -- src/shared/node-cli-command-resolution.ts src/shared/posix-version-manager-bin-dirs.ts
$ git status --short
(clean)

$ ./node_modules/.bin/vitest run --config config/vitest.config.ts src/shared/agent-cli-install-dir-fallback.test.ts

 Test Files  1 passed (1)
      Tests  8 passed (8)

The 3 cases green in both states are the no-regression guards: win32 returns []; a version-manager install still outranks a system one; and the system dirs stay out of getVersionManagerBinPaths, whose result is prepended to PATH (#18234).

Blast-radius suites, typecheck, lint

$ ./node_modules/.bin/vitest run --config config/vitest.config.ts \
    src/shared/agent-cli-install-dir-fallback.test.ts src/shared/nvm-default-alias.test.ts \
    src/main/startup/configure-process.test.ts src/main/preflight \
    src/main/ipc/preflight-agent-detection.test.ts \
    src/main/ipc/preflight-wsl-agent-detection.test.ts \
    src/shared/cli-runtime-pairing-boundary.test.ts src/cli/skills.test.ts

 Test Files  7 passed (7)
      Tests  161 passed (161)

$ ./node_modules/.bin/tsc --noEmit -p config/tsconfig.node.json      ; echo exit=$?
exit=0
$ ./node_modules/.bin/tsc --noEmit -p config/tsconfig.tc.cli.json    ; echo exit=$?
exit=0

$ ./node_modules/.bin/oxlint src/shared/agent-cli-install-dir-fallback.test.ts \
    src/shared/node-cli-command-resolution.ts src/shared/posix-version-manager-bin-dirs.ts \
    src/shared/system-cli-install-dirs.ts src/main/startup/configure-process.test.ts ; echo OXLINT_EXIT=$?
OXLINT_EXIT=0

$ node config/scripts/check-changed-code-quality.mjs   # what `pnpm run check:code-quality:changed` invokes
code quality: 0 new finding(s) across 5 changed file(s).
type-aware code quality: 0 new finding(s) across 5 changed file(s).
React Doctor: 0 new finding(s) across 5 changed file(s).
Changed-code quality gate passed since 76836b30ea6c.

Note on that last command: an earlier revision quoted it as pnpm run check:code-quality:changed reporting 4 changed files. Both details were stale — the branch has covered 5 files since bcd5948 added configure-process.test.ts, and on this machine the pnpm run wrapper aborts in its own preinstall step (ERR_PNPM_CMD_SHIM_CHMOD on electron-osx-sign) before the gate runs, so the underlying script is invoked directly. The gate itself passes.

Round-4 fix: the ~/.vite-plus/bin gap, pinned against the previous HEAD

$ git checkout HEAD~1 -- src/shared/system-cli-install-dirs.ts src/shared/posix-version-manager-bin-dirs.ts
$ ./node_modules/.bin/vitest run --config config/vitest.config.ts src/shared/agent-cli-install-dir-fallback.test.ts

     × ranks system install dirs in the same order as the PATH seed
     × reports a system-installed CLI as detected, not just resolved
     × carries the system install dirs into the POSIX guest fallback prelude

AssertionError: expected { opencode: 'opencode' } to deeply equal { Object (opencode) }
-   "opencode": "/home/tester/.vite-plus/bin/opencode",
+   "opencode": "opencode",

AssertionError: expected Set{ 'codex', 'opencode' } to deeply equal Set{ 'codex', 'opencode', 'pi' }
  Set {
    "codex",
    "opencode",
-   "pi",

 Tests  3 failed | 5 passed (8)

i.e. at round-3 HEAD (bcd5948) a pi installed by its own installer into ~/.vite-plus/bin was reported not installed by the widened fallback. Green again at 2666af8. The worktree was restored to clean (git status --short empty) after both experiments.

Round-5 check: is the relay really unreachable from this module?

The claim under Trade-offs → SSH hosts is that nothing in the SSH relay can reach node-cli-command-resolution.ts. Round 5 falsified the reason the previous revision gave for it, so the claim was re-derived by walking the actual import graph from all 182 non-test src/relay/*.ts files (a superset of the real esbuild entrypoints src/relay/relay.ts, ai-vault-service-entry.ts, wsl-transcript-fs-process-entry.ts, …):

relay entrypoints: 182
transitive modules reached: 884
node-cli-command-resolution.ts reachable: false
system-cli-install-dirs.ts reachable: false
posix-version-manager-bin-dirs.ts reachable: false

What is NOT proven — stated plainly

  • No live reproduction of the field report exists, and this change probably did not cause it. As shown in Scope honesty, the packaged app — and v1.4.194 in particular, which prepended these dirs — already had them on PATH before detection ran, so this fallback is not reached for them there. There is no crash dump, no user log, and no repro that ties the reporter's machine to this code path.
  • An investigation artifact produced earlier in this cluster is not evidence and is withdrawn. It simulated a GUI PATH of /usr/bin:/bin:/usr/sbin:/sbin with no seed applied. No packaged build has ever had that PATH, because patchPackagedProcessPath runs first. It demonstrated the mechanism, not the reporter's machine, and is not cited as support anywhere in this body.
  • Telemetry gathered during the investigation (PostHog project 406068, onboarding_agent_picked, 90d) actively argues against the "login-shell hydration failed, so the fallback ran and lost the agents" story: on darwin, sessions that fell back to the seed-only PATH reported zero detected agents 2.9% of the time (198/6936) versus 7.9% (15205/192306) for sessions with a successful shell hydration. That comparison is confounded by selection, so it is not causal in either direction — but it does not support the hypothesis, and it is reported as it came back rather than omitted.
  • What is proven is narrower and exactly what the test shows: the fallback list omitted every non-version-manager install location, and that omission makes the reporter's four CLIs resolve as claude-only. This closes a demonstrated asymmetry between three lists that are documented to agree. It is not a proven cure.

ELI5

To run a coding agent, Orca first has to find its program on your computer. It looks in two places: the list of folders your system normally searches, and — if that comes up empty — a short built-in list of backup folders.

That backup list only had folders used by "version managers": tools some developers use to juggle multiple versions of Node. If you installed Codex or OpenCode or Cursor the ordinary way — Homebrew, npm, snap, or the tool's own installer — your copy lived somewhere that was not on the backup list at all. Orca would look, not find it, and tell you the agent wasn't installed, even though it was sitting right there.

This change adds the ordinary install folders to that backup list, on Mac, Linux and inside the Linux environment that Windows users run Orca through. The backup folders are always checked last, after the ones your system already searches, so on Mac and Linux nothing Orca finds today can start pointing at a different copy — the only change is that something previously reported missing is now found. (One small exception, in the Windows-through-Linux case only: two of the backup folders swapped places. That could only matter for someone who keeps two copies of the same tool in exactly those two folders, and even then Orca is only checking whether the tool is there at all.)

Being straight about it: we could not prove this is what happened to the one user who reported it. Their version of Orca already searched those folders a different way. So this fixes a real hole we can demonstrate with a test, but the original report stays open.

Trade-offs

Everything below is confined to the "PATH missed this command entirely" branch. In the two native resolvers (resolveCliCommand, resolveCliCommands) PATH is scanned first and the new entries are appended last within the fallback list, so no command that resolves natively today can resolve differently. That statement does not extend to the WSL guest prelude, which contains one ordering change — see the WSL guests bullet below, which states it rather than denying it.

  • Newly-resolving commands. A command previously returned as a bare name (i.e. reported not-installed) can now resolve to an absolute path under /opt/homebrew/bin, /usr/local/bin, /snap/bin, /home/linuxbrew/.linuxbrew/bin, /nix/var/nix/profiles/default/bin, ~/.nix-profile/bin, ~/.opencode/bin or ~/.vite-plus/bin. This is the intended behaviour change. Affects orca CLI users, dev/unpackaged runs, and WSL guests; packaged desktop users are already covered by the PATH seed.

  • Real cost — runtime pairing. withCliRuntimeOnPath (node-cli-command-resolution.ts:343) prepends a resolved binary's own directory onto the spawned child's PATH when that directory also ships a sibling node (the [Bug]: CLI agents crash after nvm install <newer> — Orca picks newest nvm node for PATH but spawns CLIs from older nvm node (ABI mismatch) #10932 binary/runtime pairing rule). A fallback hit in /usr/local/bin or /opt/homebrew/bin therefore now hoists that system dir ahead of the user's version-manager node for the spawned agent only. This is a genuine behaviour change, disclosed rather than buried. It fires only when PATH contained no copy of the CLI at all — and in that situation the alternative is not running the agent, so the trade is favourable. In the packaged app the PATH scan already returned those same absolute paths, so the prepend already happened before this change.

  • Widened spawn set, and the shadowing it could have introduced. These resolvers do not only detect: resolveCliCommand / resolveCodexCommand / resolveClaudeCommand feed ~15 spawn sites (codex login, app-server, session-index heal, state-dir ops, orca CLI account/skills). A fallback hit in /usr/local/bin or /opt/homebrew/bin is therefore a binary Orca will run, and those are shared prefixes where a same-named, unrelated binary can live. Two things bound that, and the second is new in this revision:

    1. The system block is strictly last: PATH → nvm → version managers / ~/.local/bin / pnpm / yarn / bun → system dirs. A CLI the user has anywhere a version manager or their own PATH knows about always wins; a system dir is only ever consulted for a command that nothing else on the machine has.
    2. That ordering is now built once (getCliInstallDirectories in node-cli-command-resolution.ts) and shared by both native resolvers instead of being two hand-spelled spreads — the singular resolver (the one every spawn site calls) had its own copy. agent-cli-install-dir-fallback.test.ts pins the guarantee on both resolvers, on darwin and linux, for a version-manager hit, a ~/.local/bin hit, and a PATH hit each outranking a staged system copy; and a derived test asserts the WSL guest prelude keeps every native version-manager dir ahead of the native system block, in the native order. All six new assertions go RED when the system block is hoisted first or the guest list drifts (verified by reverting the ordering).

    Not done, deliberately: an identity check on the resolved binary (--version sniff, shebang read) before spawning. Every spawn site here already runs the tool and surfaces its failure, a probe would cost a process launch per resolution on a path that exists to be cheap, and the packaged app has spawned from exactly these dirs via the PATH seed for months without one. Ordering, not identity, is the guard.

  • WSL guests get six extra [ -d ]-guarded PATH entries (/snap/bin, /home/linuxbrew/.linuxbrew/bin, /nix/var/nix/profiles/default/bin, $HOME/.nix-profile/bin, $HOME/.opencode/bin, $HOME/.vite-plus/bin), appended not prepended, per that file's own rule.
    Plus one ordering change to an existing entry, stated explicitly: "/usr/local/bin" moved from before "$HOME"/.nvm/versions/node/*/bin to after it, so the guest ranks version-manager dirs ahead of system ones the way the native lists do. Bounds on it: the whole prelude is appended behind a resolved login PATH, so it can only re-rank a command the login PATH did not contain at all and which exists in two different fallback dirs; and both consumers (detectWslCommandsOnPath, which discards the resolved path and returns only command names, and runPreflightCommandInWsl, used by isCommandAvailable/isCommandOnPath) test presence, not identity. It is also not full parity, and the docstring no longer claims it is: a shell glob expands lexicographically, whereas native getNvmVersionDirectories orders nvm dirs default-alias-first for [Bug]: CLI agents crash after nvm install <newer> — Orca picks newest nvm node for PATH but spawns CLIs from older nvm node (ABI mismatch) #10932 reasons a glob cannot reproduce.

  • Latency: up to 7 extra statSync probes per unresolved command, only on the PATH-miss path. Immeasurable next to the 10s login-shell probe this backstops.

  • Windows: getSystemCliInstallDirectories returns [] on win32; the Windows branch is unchanged and pinned by a test.

  • Remote wire: none. No RPC params, stream frames, or published content change; KNOWN_TUI_AGENT_DETECTION_COMMANDS and resolveDetectedTuiAgentIds are untouched, so the set of agent ids a host can publish to an older client is unchanged — only which subset a given machine reports.

  • SSH hosts get nothing from this change — stated as a correction, with the reasoning itself corrected. An earlier revision claimed "a remote host runs its own copy of this code". It does not. detectRemoteAgents (src/main/preflight/agent-detection.ts:241-252) sends preflight.detectAgents with a commands param, and the handler for that param is src/relay/preflight-handler.ts:48 → detectAgents (:57) → isCommandOnPath (:122-123) → isCommandOnPathForRelay (:171-195), which runs where.exe on win32 or a trusted POSIX login shell and never calls resolveCliCommands / getSystemCliInstallDirectories. The other preflight.detectAgents (src/main/runtime/rpc/methods/preflight.ts:28, params: null) is the client's runtime per docs/reference/ssh-execution-boundary.md, i.e. a packaged desktop already covered by the PATH seed.
    A second correction, from round 5: the previous revision justified the unreachability with "the relay is a separate esbuild bundle (config/tsconfig.relay.json includes only ../src/relay/**/* plus two src/main/pty files), so it cannot reach this module at all." That inference was invalid — src/relay imports ~160 files' worth of src/shared/* modules despite that include list, because a tsconfig include does not bound esbuild's import graph. The conclusion survives, but on evidence rather than inference: a transitive walk from all 182 non-test src/relay/*.ts files reaches 884 modules and none of node-cli-command-resolution.ts, system-cli-install-dirs.ts, or posix-version-manager-bin-dirs.ts (output under Fix evidence). Residual risk, unguarded: that walk is a one-time manual check, not a test. A future relay file importing any shared module that transitively pulls in the resolver would silently falsify this bullet with every suite still green — Follow-up Fix update checker 406 error and add menu feedback #8.
    The relay's login-shell lookup still has no install-dir fallback of any kind; that gap is untouched here and is Follow-up Improve terminal font rendering, per-pane zoom, and UI zoom #7.

  • Newly-swallowed errors: none. No catch was added or widened.

  • Folder workspaces vs git worktrees: irrelevant to this path; it never touches repo layout.

  • Honest cost: this ships a small, demonstrably-correct list fix whose field impact is unproven and, per the telemetry above, probably small. Reports Linux support #1, Fix Ctrl+Backspace not deleting word in terminal #2 and Add Ctrl+Click to open links in terminal #4 in the G6 bucket are untouched.

Adversarial review

5 rounds total; converged clean = true at round 5. Round 5 returned no blocking findings, having re-run every piece of evidence in this body from scratch rather than reading it. Rounds 1-4 produced 7 blocking findings; all 7 were accepted, none was rebutted. Six were fixed in code or in claims; one — the unproven link to the field report — is carried as an explicit disclosed limitation with G6 report #3 left open, because no code on this branch can close it. Round 5's top-ranked non-blocking finding was a live claim defect in this body and is fixed in this revision (details below); it is the reason the Trade-offs → SSH hosts bullet now argues from an import walk instead of from a tsconfig include.

Round 1 — 2 blocking, both accepted, neither rebutted.

  1. The commit message asserted a mechanism that provably cannot occur in the shipped app. It claimed "a GUI-launched app missed codex/opencode/cursor-agent installed by Homebrew…", but patchPackagedProcessPath seeds those exact dirs onto process.env.PATH for every packaged posix run, before detection, test-pinned at configure-process.test.ts:75/76/97/98. Fixed by rewriting the commit message (and this PR body) to state where the fallback is actually decisive — the orca CLI, dev runs, WSL guests — and to say explicitly that G6 report Add Shift+Enter to insert newline in terminal #3 stays open.
  2. The subject claimed Homebrew coverage while omitting Linux Homebrew. /opt/homebrew is macOS-only; Linuxbrew is /home/linuxbrew/.linuxbrew/bin, and /snap/bin and the nix prefixes were missing too — all four already seeded by configure-process.ts:140-147. Fixed by adding them to both the fallback list and the WSL prelude, rather than by narrowing the claim.
    Round 1 also confirmed the evidence independently: the reviewer reverted the production files, reproduced the identical red output, restored, and re-ran 10,950 tests across the affected areas clean. "The test is not theatre."

Round 2 — 1 blocking, accepted; process finding, not a code defect.
The handoff summary given to the reviewer described a 2-file / +38 line change with 3 new macOS dirs, while HEAD was 4 files / +227 with 6 lookup dirs plus WSL-prelude entries, the function had moved into a new module, and the quoted failing test names no longer existed — all consequences of the round-1 fixes, but never restated. The reviewer's point was that a decision record authorizing "+38, 3 dirs" cannot authorize something 6× larger that also changes Linux and WSL-guest resolution. Fixed by restating the claims against HEAD (this PR body is written against HEAD, verified by re-running everything above myself).
Round 2's non-blocking findings drove the second commit: (a) the three lists disagreed on order while claiming to be kept in step, so a CLI present in both /usr/local/bin and /snap/bin could resolve to a different binary than the seeded PATH scan found — all three now share the seed's relative order, pinned by a duplicate-install test and an offset assertion; (b) the parity docstring's claim was false — it also omitted ~/.vite-plus/bin and /opt/homebrew off darwin, all three gaps then named as deliberate — round 4 showed the ~/.vite-plus/bin one was not deliberate but wrong, and it is now closed; (c) the detectCommandsInInstallDirs case read the ambient process.env.PATH, so on a box with /usr/local/bin on PATH it wasn't exercising the fallback — it now stubs a GUI-launch PATH; (d) the test built paths with host join so it holds on a Windows dev machine.

Round 3 — 2 blocking, both accepted, neither rebutted.

  1. The claims/evidence block handed to the reviewer described HEAD~2, not HEAD, in six specific ways — a 2-file/+38 stat against a 4-file/+273 change; getSystemCliInstallDirectories cited at node-cli-command-resolution.ts:124-146 when it lives in src/shared/system-cli-install-dirs.ts; 3 claimed lookup dirs against 6 across two platforms; the WSL prelude described as a single added entry; "6 cases / 3 failed | 3 passed" against a file with 8; and a blanket "no existing resolution can change" that the WSL /usr/local/bin move contradicts. Round 2 had raised the same class of defect and the restatement never reached the round-3 input. Accepted. The stale artifact is retired: this body is the record, and every number in it is re-derived at HEAD 2666af8 (git diff --stat origin/main...HEAD = 5 files, +339/-5; prod 3 files, +89/-5; test 2 files, +250), the function is cited at its real path, all eight dirs are enumerated, the eight test cases and their real names are quoted from a run performed for this revision, and the "nothing can resolve differently" claim is scoped to the native resolvers with the WSL ordering change spelled out in Trade-offs. No code change was invented to satisfy it — it was a claims defect and it got a claims fix.

  2. The branch does not fix the report it is filed under, confirmed independently by the reviewer rather than taken from the author's disclaimer: patchPackagedProcessPath seeds all of them at main-process-preflight.ts:147 before detection, mergePathSegments never removes them, and on posix buildLocalPreflightEnv() returns undefined, so the packaged macOS PATH scan reads the seeded env and this fallback is never consulted for those dirs. Accepted as a disclosed limitation, not remediable by code on this branch: it is stated in Scope honesty, stated up front, in What is NOT proven, and in Follow-up Linux support #1, and G6 report Add Shift+Enter to insert newline in terminal #3 stays open. Round 3's verdict named three beneficiary populations as the merge basis — orca CLI, unpackaged/dev runs, "and the SSH-host runtime that serves preflight.detectAgents". Round 4 falsified the SSH third of that sentence, so the merge basis is now orca CLI + unpackaged/dev runs + WSL guests.

Round 3 also confirmed the evidence independently: it exported origin/main with git archive, added only the test file, and got 5 failed / 3 passed (8), then 8 passed at HEAD — "the test is not theatre" — and re-derived the ordering safety and the win32/SSH/folder-workspace/remote-wire angles by hand.

Its non-blocking findings drove the third commit (bcd5948), all three accepted:
(a) the new docstring's ordering-parity claim was false across the version-manager/system block boundary — claude in both ~/.local/bin and /opt/homebrew/bin resolves to ~/.local/bin via the fallback but /opt/homebrew/bin via the seeded PATH, because ~/.local/bin comes from getBaseVersionManagerDirectories, which leads. The claim is now scoped to within the system block and the gap is named, not asserted away; it is left unclosed on purpose, since closing it means hoisting a system dir over a version-manager one (#18234).
(b) the WSL reorder's justification ("a version manager still wins in the guest, as it does natively") was wrong, because a shell glob expands lexicographically while native orders nvm dirs default-alias-first (#10932). Docstring corrected and the move recorded as this file's one behavior change, with its bounds.
(c) the #18234 seed-leak guard asserted only 2 of the 6 new dirs were absent from getVersionManagerBinPaths. It now spells out all eight across darwin and linux — spelled out rather than derived from getSystemCliInstallDirectories, which would pass vacuously against exactly the refactor it guards.

Round 4 — 2 blocking, both accepted, neither rebutted.

  1. The docstring and Follow-up Add Shift+Enter to insert newline in terminal #3 claimed — "verified by enumerating getTuiAgentDetectionProbeCommands" — that ~/.vite-plus/bin maps to no probed agent command. False, and the repo says so: src/shared/tui-agent-config.ts:137 defines pi: { detectCmd: 'pi' } with no detectUnsupportedRuntimes, so KNOWN_TUI_AGENT_DETECTION_COMMANDS yields pi on every runtime, and configure-process.ts:155-156 + configure-process.test.ts:71-73 document ~/.vite-plus/bin as the Pi installer's location whose absence makes Orca report Pi "Not installed". The branch had added one of the two [Bug]: OpenCode and PI CLI not detected #829 dirs and skipped the other on a false premise, in the native fallback and the WSL prelude alike. Fixed in code (2666af8), not by narrowing the claim: ~/.vite-plus/bin is now in getSystemCliInstallDirectories and POSIX_VERSION_MANAGER_BIN_DIRS, with a pi case in the detection test that goes red against the previous HEAD (evidence above).

  2. The body named "the SSH host runtime that answers preflight.detectAgents on the remote side" as a beneficiary and asserted "a remote host runs its own copy of this code". Neither holds. Accepted; fixed as a claims defect — the SSH leg is retracted in Scope honesty and replaced by a positive statement of what actually runs there in Trade-offs → SSH hosts, with the relay's missing fallback recorded as Follow-up Improve terminal font rendering, per-pane zoom, and UI zoom #7. The claim had been imported verbatim from round 3's note rather than re-derived. The shipping beneficiary set is now stated as orca CLI invocations with a degraded PATH, plus unpackaged/dev runs, plus WSL guests via the prelude.

Round 4 also confirmed the evidence independently a second time (clean git archive of origin/main + the test file alone: 5 failed / 3 passed of 8; 8/8 at HEAD), re-derived the append-last ordering safety and the getVersionManagerBinPaths unreachability by hand, and confirmed win32 returns []. Its non-blocking findings drove the rest of 2666af8: the seed-order guard now derives its expected order from getSystemCliInstallDirectories inside configure-process.test.ts (so reordering either list fails, where before both were hardcoded copies); /snap/bin + Linuxbrew now gate on linux exactly like the seed instead of every non-darwin posix; the /opt/homebrew-off-darwin gap is restated without the claim the seed contradicts; and the "lookup-only" paragraph now names the withCliRuntimeOnPath prepend exception that the body already disclosed.

Round 5 — 0 blocking; converged clean. Every attack failed on re-execution, and one non-blocking claim defect was found in this body and is fixed here.

Round 5 explicitly re-ran the evidence rather than reading it: reverting the production hunks to origin/main reproduced 5 failed | 3 passed (8) byte-matching the quoted output including the assertion diffs; restoring gave 8/8; the round-4 HEAD~1 experiment reproduced 3 failed | 5 passed (8) with the same Set{'codex','opencode'} vs Set{'codex','opencode','pi'} diff. Both typechecks exit 0, oxlint on all 5 changed files exits 0, the changed-code quality gate reports 0 findings, and the 7-file / 161-test blast radius passes. A full run of src/shared src/main/startup src/cli src/main/ipc src/main/preflight src/main/agent-hooks gave 12,670 passed with one failure, src/shared/remote-runtime-shared-control-connection.test.ts:652 — a known load-sensitive vi.waitFor flake that passes 28/28 in isolation and lives in a module this diff does not touch. It also strengthened the scope disclaimer independently by reading v1.4.194 (see Scope honesty) and confirmed there is no Fixes #/Closes #/Resolves # keyword in the body or in any of the four commits. I re-ran all of the above myself before publishing this revision; results are quoted verbatim under Fix evidence.

Round 5's non-blocking findings, and what happened to each:

  1. Top-ranked — accepted and fixed in this revision. The SSH retraction (the round-4 blocking fix) rested on a false premise. The body argued "the relay is a separate esbuild bundle (config/tsconfig.relay.json includes only ../src/relay/**/* plus two src/main/pty files), so it cannot reach this module at all." That inference is invalid — src/relay imports src/shared/* in ~160 files despite that include list, so a tsconfig include does not bound esbuild's import graph. This is the same defect class as rounds 1-4: a claim asserted from evidence that does not support it, in a fix for exactly that defect class. The conclusion is nonetheless true, and round 5 proved it with a transitive import walk, which I reproduced (884 modules reached from 182 relay files; the resolver is not among them). The bullet now argues from that walk. Its residual risk — nothing guards the property, so a future relay import could silently falsify it with all suites green — is now disclosed in the bullet and tracked as Follow-up Fix update checker 406 error and add menu feedback #8 rather than left implicit.
  2. The earlier investigation artifact ("live repro") is not valid evidence for report Add Shift+Enter to insert newline in terminal #3 — it simulated a GUI PATH with no seed, which no packaged build has. Accepted; it is not cited as support anywhere, and it is now explicitly withdrawn under What is NOT proven rather than merely absent.

Not taken, from earlier rounds, with reasons:

  • The three-list duplication (round 4 non-blocking). configure-process.ts's seed, system-cli-install-dirs.ts, and POSIX_VERSION_MANAGER_BIN_DIRS remain three hand-maintained literals, which is real duplication under AGENTS.md "Reuse Before Reimplementing". Deferred to Follow-up Fix PTY listener leak, use local restty with selection support #5 because the fix is a refactor of a startup-critical PATH seed, not an edit to this diff; the drift it enables is currently caught by the order-parity test in configure-process.test.ts, which derives its expectation from getSystemCliInstallDirectories.
  • /opt/homebrew/bin off darwin (round 4 non-blocking). Deliberate: a Linux brew install lands in the Linuxbrew prefix, which is covered, so the seed's /opt/homebrew/bin entry is a phantom stat on Linux. Round 4 correctly noted the seed and the fallback therefore disagree on this one dir; the disagreement is stated in the docstring rather than asserted away, and the residual effect is that a Linux user who manually installed to /opt/homebrew/bin is still under-detected by the fallback. Pinned as intended by agent-cli-install-dir-fallback.test.ts.
  • Ordering parity across the version-manager/system boundary (round 3 non-blocking (a)) — Follow-up Add Ctrl+Click to open links in terminal #4. Left open on purpose: closing it means ranking a system dir above a version-manager dir, which is the [Bug]: gh api user/starred child processes spin at 100% CPU indefinitely and are respawned continuously #18234 defect class.

Follow-ups

  1. G6 report Add Shift+Enter to insert newline in terminal #3 is not closed by this PR. "Codex / Cursor / OpenCode all undetected, packaged macOS v1.4.194" still has no established cause. Next step: instrument or obtain a log from a packaged macOS run showing detectInstalledAgents' per-command installedOnPath result plus the effective process.env.PATH, since the seed makes the current hypothesis untestable from telemetry alone.
  2. Windows has no install-dir fallback at all. getSystemCliInstallDirectories returns [] on win32, and patchPackagedProcessPath's system block is POSIX-only, so %USERPROFILE%\.opencode\bin and npm's Windows global prefix have never had coverage in either list. Pre-existing and deliberately unchanged here; worth its own ticket.
  3. ~/.vite-plus/bin is omitted from the fallback list; no probed agent command maps to it. Withdrawn as false and fixed in 2666af8. pi is a probed detect command on every runtime (src/shared/tui-agent-config.ts:137, no detectUnsupportedRuntimes), and ~/.vite-plus/bin is the Pi installer's default — configure-process.test.ts:71-73 documents both ~/.opencode/bin and ~/.vite-plus/bin as the [Bug]: OpenCode and PI CLI not detected #829 install locations. Both are now in getSystemCliInstallDirectories and POSIX_VERSION_MANAGER_BIN_DIRS, pinned by the pi case in reports a system-installed CLI as detected, not just resolved.
  4. Ordering parity holds inside the system block, not across the boundary above it. ~/.local/bin precedes the system dirs in the fallback but follows them in patchPackagedProcessPath's seed, so a CLI installed in both ~/.local/bin and a Homebrew prefix resolves differently through the two paths. Pre-existing, documented in system-cli-install-dirs.ts, and deliberately not closed here — the only fix is to re-rank a version-manager dir against a system one, which is the [Bug]: gh api user/starred child processes spin at 100% CPU indefinitely and are respawned continuously #18234 defect class.
  5. The three lists are kept in step by convention and a test, not by construction. configure-process.ts's seed, system-cli-install-dirs.ts, and POSIX_VERSION_MANAGER_BIN_DIRS are three hand-maintained literals (the two native resolvers now share one, getCliInstallDirectories, and a derived test checks the guest prelude against the native lists, so drift between native and WSL fails a test rather than shipping — but the seed is still a separate literal). Deriving all three from one source (with per-platform and prepend/append policy as parameters) would remove the whole class of drift these commits fixed.
  6. G6 reports Linux support #1, Fix Ctrl+Backspace not deleting word in terminal #2 and Add Ctrl+Click to open links in terminal #4 remain uninvestigated.
  7. The SSH relay has no install-dir fallback. isCommandOnPathForRelay (src/relay/preflight-handler.ts:171) asks a login shell or where.exe and stops; if that shell's PATH misses a Homebrew/snap/nix/installer-owned agent, the remote host reports it missing with no backstop. Closing it means either giving the relay bundle its own copy of these dirs or having the client send them — a wire change, so capability-negotiated per docs/reference/remote-wire-compatibility.md. Out of scope here; worth its own ticket.
  8. Nothing guards "the relay cannot reach the CLI resolver". Trade-offs → SSH hosts rests on a manual transitive import walk, not a test. A ratchet in the style of config/scripts/check-runtime-electron-ratchet.mjs — assert src/shared/node-cli-command-resolution.ts is absent from the relay bundle's import graph — would convert it from a claim into an invariant. Until then, a future relay import can falsify that bullet with every suite green.

The install-dir fallback that answers "is this agent installed?" when the
login-shell PATH probe fails listed only version-manager bin dirs, so
codex/opencode/cursor-agent installed by Homebrew, npm's default global
prefix, snap, nix, or the CLI's own installer read as not installed.

Where this is decisive, corrected from the previous message: the `orca` CLI,
whose detectSkillsCliAgentKeys (src/cli/handlers/skills.ts) calls
detectCommandsInInstallDirs directly and whose entry point seeds no PATH, plus
unpackaged/dev runs. NOT the packaged desktop app: patchPackagedProcessPath
(configure-process.ts:114) appends /opt/homebrew/bin, /usr/local/bin,
~/.opencode/bin and the Linux/nix prefixes onto process.env.PATH at
main-process-preflight.ts:147, before any detection, and mergePathSegments
preserves them, so the PATH scan reaches those dirs first and this fallback
never fires for them. That means this does NOT explain the packaged macOS
v1.4.194 report of codex/cursor-agent/opencode all undetected -- that report
stays open and uninvestigated.

Second correction: the fallback now carries the prefixes Homebrew actually
uses on Linux (/home/linuxbrew/.linuxbrew/bin), plus /snap/bin and the two nix
profile dirs, matching what patchPackagedProcessPath already seeds. The WSL
guest prelude gains the same entries. Leaving them out closed the native/WSL
asymmetry on darwin only, on the platforms where the fallback is decisive.

Appended last so a version-manager install still wins, and kept out of
getVersionManagerBinPaths, whose result is PREPENDED to PATH (#18234). Lives in
its own module so node-cli-command-resolution.ts stays under max-lines.

The test stages every path through `join` and asserts via
detectCommandsInInstallDirs as well as resolveCliCommands, so it holds on a
Windows dev machine and pins the "absolute path means installed" contract.
Round-2 review remediation. The blocking finding was about the handoff
artifact, not the code: the summary handed to review described a 2-file/+38
change with 3 new macOS dirs, while HEAD is 4 files/+227 with 6 lookup dirs
plus 5 new WSL-guest prelude entries, and the quoted failing test names never
existed. Restated against HEAD in the handoff; no rebuttal, the reviewer was
right.

Justification for the entries the summary never described: the fallback exists
to close the native/WSL asymmetry for a CLI no version manager installed, and
patchPackagedProcessPath already seeds Linuxbrew, /snap/bin and both nix
profile dirs (configure-process.ts:141-158). Shipping only the darwin subset
would have left a Linux or WSL user with a snap/nix install still reading as
not installed while the packaged macOS user did not -- the asymmetry the change
is for.

Code changes, all from the non-blocking list:

- The three lists disagreed on order while claiming to be kept in step, so a
  CLI in both /usr/local/bin and /snap/bin could resolve to a different binary
  than the seeded PATH scan or the WSL guest probe found. All three now use the
  seed's relative order, pinned by a new duplicate-install test and an offset
  assertion on the prelude. The prelude's system block also moved after the nvm
  glob so a version manager still wins in the guest, as it does natively.
- The parity docstring asserted "the same set patchPackagedProcessPath appends,
  minus the sbin dirs and the generic ~/bin", which was false: it also omits
  ~/.vite-plus/bin (seeded by configure-process.ts:156, but no probed agent
  command maps to it) and /opt/homebrew off darwin. All three gaps are now
  named as deliberate.
- win32 returns [] and stays that way, but the branch now says why:
  %USERPROFILE%\.opencode\bin has never had install-dir coverage in either
  list, and the seed's system block is POSIX-only too. Pre-existing, unchanged.
- The detectCommandsInInstallDirs case read the ambient process.env.PATH, so on
  a box with /usr/local/bin on PATH only the opencode assertion exercised the
  fallback. It now stubs the GUI-launch PATH, so both do.

Unchanged and restated: this does NOT explain the packaged macOS v1.4.194
report of codex/cursor-agent/opencode all undetected, and must not close G6
report #3. patchPackagedProcessPath returns early unless app.isPackaged and
seeds all six dirs before any detection, and mergePathSegments never deletes
them, so the packaged PATH scan reaches them first and this fallback never
fires there. Decisive only for the `orca` CLI's detectSkillsCliAgentKeys and
unpackaged/dev runs.

Verification: the suite is red without the production hunks (5 failed/3 passed)
and green with them (8 passed); 11 related suites pass (197 tests); tc:node,
tc:cli, oxlint, oxfmt and the max-lines ratchet are clean.
@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: c5a9c575-d1a5-48d2-acff-424de09c29d6

📥 Commits

Reviewing files that changed from the base of the PR and between 672cf5a and 813dc63.

📒 Files selected for processing (5)
  • src/main/startup/configure-process.test.ts
  • src/shared/agent-cli-install-dir-fallback.test.ts
  • src/shared/node-cli-command-resolution.ts
  • src/shared/posix-version-manager-bin-dirs.ts
  • src/shared/system-cli-install-dirs.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change adds a platform-aware system CLI install-directory lookup. CLI resolution now uses one ordered fallback list for single and batch lookups. Windows returns no system directories. POSIX fallback paths now include snap, Linuxbrew, nix, .opencode/bin, and .vite-plus/bin. Tests cover platform paths, ordering, PATH exclusion, CLI detection, seeded PATH order, and POSIX guest behavior.

Merge Risk: ⚪ Minimal · up to 813dc

This change finds supported CLI installations missed by PATH while retaining existing PATH and version-manager precedence. Platform behavior and fallback ordering are covered, with no remaining merge-readiness risk identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description provides extensive technical context, scope, rationale, limitations, follow-ups, and test evidence. However, it omits several required template sections or equivalents, including Linke… Add the missing template sections. Include the linked issue using Fixes #<issue>, or document the required issue reference. Add N/A with a reason under Visual Proof if no UI or interaction changed. Complete AI Disclosure, Review, Agent …
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: detecting agent CLIs installed outside Node version managers.
Full details: Description check

Explanation

The description provides extensive technical context, scope, rationale, limitations, follow-ups, and test evidence. However, it omits several required template sections or equivalents, including Linked Issue with a Fixes # reference, Visual Proof with N/A and a reason, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the Checklist.

Resolution

Add the missing template sections. Include the linked issue using Fixes #&lt;issue&gt;, or document the required issue reference. Add N/A with a reason under Visual Proof if no UI or interaction changed. Complete AI Disclosure, Review, Agent skill upstream boundary, Notes, and all applicable Checklist items. Keep the existing technical evidence under clearly labeled What Changed, Why, and Testing sections.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes

A narrow, well-scoped fix that extends the CLI install-dir fallback to cover install locations no version manager owns (Homebrew, npm global prefix, snap, nix, ~/.opencode/bin), in both resolveCliCommand and resolveCliCommands, and mirrors the same dirs into the WSL guest PATH prelude. win32 is deliberately unchanged.

  • New getSystemCliInstallDirectories (src/shared/system-cli-install-dirs.ts) — appended last in the fallback list, ordered to match the packaged-app PATH seed, and kept out of the prepended getVersionManagerBinPaths list (#18234).
  • Resolver wiring (src/shared/node-cli-command-resolution.ts) — appends the system dirs after the version-manager dirs in both resolvers, so a version-manager install still outranks a system one.
  • WSL prelude parity (src/shared/posix-version-manager-bin-dirs.ts) — adds the system dirs (appended) and moves the nvm glob ahead of /usr/local/bin so a version-manager install outranks a system one in the guest, matching native.
  • Regression tests (src/shared/agent-cli-install-dir-fallback.test.ts) — 8 cases pinning macOS/Linux resolution, ordering vs the PATH seed, the version-manager-over-system rule, the win32 no-op, and the detection contract through detectCommandsInInstallDirs.

The tests are genuinely strong (exact toEqual, ordering pinned by iterative deletion, the detectCommandsInInstallDirs case stubs a GUI-launch PATH so it exercises the fallback), not theatre. I verified the suite passes locally (8/8). The scope honesty in the PR body — that this does not explain the packaged macOS v1.4.194 report and must not close G6 report #3 — is correct and worth keeping.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…ak guard

Round-3 review found two docstring claims that are false as written and one
guard that only asserted a third of its list.

- system-cli-install-dirs.ts claimed a CLI in two of these dirs resolves the
  same here as in the packaged PATH seed. True inside the system block, false
  across it: `claude` in both ~/.local/bin and /opt/homebrew/bin resolves to
  ~/.local/bin via the fallback (getBaseVersionManagerDirectories leads) and to
  /opt/homebrew/bin via the seed, which appends ~/.local/bin last. Scope the
  claim to the block and name the gap instead of asserting it away. No behavior
  change: closing it would hoist a system dir over a version-manager one
  (#18234).
- posix-version-manager-bin-dirs.ts justified moving "/usr/local/bin" after the
  nvm glob with "a version manager still wins in the guest, as it does
  natively". The glob expands lexicographically; native orders nvm dirs
  default-alias-first (#10932), so that is not parity. Record the move as the
  one behavior change in the file and bound it: entries are appended behind a
  resolved login PATH, and both consumers only test presence.
- The #18234 seed-leak guard asserted only /opt/homebrew/bin and /usr/local/bin
  were absent from getVersionManagerBinPaths, leaving the four other new dirs
  unpinned. It now spells out all seven across darwin and linux -- spelled out
  rather than derived from getSystemCliInstallDirectories, which would pass
  vacuously against exactly the refactor it guards.

Tests 8 passed (8); 5 failed / 3 passed with the production hunks reverted to
origin/main. tsc node + cli clean, oxlint clean.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This delta (bcd5948) retires the prior review's one open thread and hardens the seed-leak guard. No production behavior changed.

  • Ordering-parity claims corrected (src/shared/posix-version-manager-bin-dirs.ts) — the "same relative order as the other two lists" claim is narrowed to a block-level lead/trail statement, the /usr/local/bin move is now described accurately, and the nvm-glob non-parity is named (#10932).
  • Parity scoped to within the system block (src/shared/system-cli-install-dirs.ts) — the claim no longer crosses the block boundary; the ~/.local/bin-vs-Homebrew divergence is stated rather than asserted away.
  • Seed-leak guard widened (src/shared/agent-cli-install-dir-fallback.test.ts) — the guard now asserts all seven system dirs stay out of getVersionManagerBinPaths on both darwin and linux, spelled out rather than derived from the list under test so it cannot pass vacuously.

The widened guard is a real assertion (it fails if a system dir leaks into the prepended list), not theatre. Verified agent-cli-install-dir-fallback.test.ts passes locally (8/8).

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

The fallback added `~/.opencode/bin` but skipped `~/.vite-plus/bin` on the
claim that no probed agent command maps to it. False: `pi` is a probed detect
command on every runtime (`tui-agent-config.ts`, no `detectUnsupportedRuntimes`)
and `~/.vite-plus/bin` is the Pi installer's default — the two dirs #829 named
and `patchPackagedProcessPath` seeds together. Added to both the native
fallback and the WSL guest prelude, so a Pi installed by its own script is
found by the `orca` CLI and in WSL, not just on a seeded packaged PATH.

Also, all narrower:
- `/snap/bin` + Linuxbrew now gate on `linux` like the seed does, instead of
  every non-darwin posix.
- Docstring: `/opt/homebrew` off darwin is the one remaining seed gap and says
  why; the "lookup-only" paragraph names the `withCliRuntimeOnPath` exception.
- New seed-order test derives the expected order from
  `getSystemCliInstallDirectories`, so reordering either list fails.

The PR body's claim that SSH hosts benefit is dropped: they answer
`preflight.detectAgents` from `src/relay/preflight-handler.ts` via
`isCommandOnPathForRelay`, a separate bundle that never reaches this module.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Added ~/.vite-plus/bin to the install-dir fallback (src/shared/system-cli-install-dirs.ts, src/shared/posix-version-manager-bin-dirs.ts) — the Pi installer's default (#829), so a pi installed by its own script resolves as detected rather than "not installed"; mirrored into the WSL guest prelude too.
  • Narrowed snap/Linuxbrew gating to platform === 'linux' (src/shared/system-cli-install-dirs.ts) — previously every non-darwin POSIX got phantom /snap/bin and Linuxbrew stats; now gated exactly like the PATH seed.
  • Derived the seed-order parity guard (src/main/startup/configure-process.test.ts) — the new test checks patchPackagedProcessPath's system block against getSystemCliInstallDirectories order rather than a second hardcoded literal, so reordering either list fails.
  • Widened the tests (src/shared/agent-cli-install-dir-fallback.test.ts) — added pi to the detection case and ~/.vite-plus/bin to the ordering and seed-leak guards.

This closes the round-4 ~/.vite-plus/bin gap: the premise that no probed agent command maps to it was falsified (pi is probed on every runtime via tui-agent-config.ts), and the dir is now covered in the native fallback, the WSL prelude, and the tests. The platform === 'linux' narrowing matches patchPackagedProcessPath byte-for-byte and is pinned by the new parity guard.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

… on both resolvers

resolveCliCommand (every spawn site) and resolveCliCommands (detection) each
spelled the nvm -> version-manager -> system-dir order by hand, which is how
the native and WSL lists drifted apart before. One getCliInstallDirectories
now feeds both, and the test pins system dirs LAST on both resolvers, on
darwin and linux, plus a derived check that the WSL guest prelude keeps every
native version-manager dir ahead of the native system block.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Since the prior review (2666af8), this delta is a behavior-preserving refactor plus test hardening:

  • Consolidated the fallback order into one shared list (src/shared/node-cli-command-resolution.ts) — a new getCliInstallDirectories builds the nvm → version-manager → system-dir order once, and both resolveCliCommand (the spawn-site path) and resolveCliCommands (detection) now consume it, removing the two hand-spelled spreads that were the drift vector.
  • Pinned the ordering on both resolvers and both platforms (src/shared/agent-cli-install-dir-fallback.test.ts) — the version-manager / ~/.local/bin / PATH-outrank-a-system-copy cases now run through resolveCliCommand as well as resolveCliCommands, over darwin and linux via describe.each.
  • Added a derived WSL-prelude parity guard (src/shared/agent-cli-install-dir-fallback.test.ts) — asserts every native version-manager dir from getVersionManagerBinPaths precedes the first system dir in the guest prelude, scoped to the block boundary rather than intra-block order.

The resolved directory order is identical before and after the refactor. Verified the touched suites pass (agent-cli-install-dir-fallback.test.ts 14 tests, configure-process.test.ts 41 tests).

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 901c677 into main Sep 4, 2026
28 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#18336)

* fix(agents): detect agent CLIs installed outside a version manager

The install-dir fallback that answers "is this agent installed?" when the
login-shell PATH probe fails listed only version-manager bin dirs, so
codex/opencode/cursor-agent installed by Homebrew, npm's default global
prefix, snap, nix, or the CLI's own installer read as not installed.

Where this is decisive, corrected from the previous message: the `orca` CLI,
whose detectSkillsCliAgentKeys (src/cli/handlers/skills.ts) calls
detectCommandsInInstallDirs directly and whose entry point seeds no PATH, plus
unpackaged/dev runs. NOT the packaged desktop app: patchPackagedProcessPath
(configure-process.ts:114) appends /opt/homebrew/bin, /usr/local/bin,
~/.opencode/bin and the Linux/nix prefixes onto process.env.PATH at
main-process-preflight.ts:147, before any detection, and mergePathSegments
preserves them, so the PATH scan reaches those dirs first and this fallback
never fires for them. That means this does NOT explain the packaged macOS
v1.4.194 report of codex/cursor-agent/opencode all undetected -- that report
stays open and uninvestigated.

Second correction: the fallback now carries the prefixes Homebrew actually
uses on Linux (/home/linuxbrew/.linuxbrew/bin), plus /snap/bin and the two nix
profile dirs, matching what patchPackagedProcessPath already seeds. The WSL
guest prelude gains the same entries. Leaving them out closed the native/WSL
asymmetry on darwin only, on the platforms where the fallback is decisive.

Appended last so a version-manager install still wins, and kept out of
getVersionManagerBinPaths, whose result is PREPENDED to PATH (stablyai#18234). Lives in
its own module so node-cli-command-resolution.ts stays under max-lines.

The test stages every path through `join` and asserts via
detectCommandsInInstallDirs as well as resolveCliCommands, so it holds on a
Windows dev machine and pins the "absolute path means installed" contract.

* fix(agents): align system install-dir order across the three PATH lists

Round-2 review remediation. The blocking finding was about the handoff
artifact, not the code: the summary handed to review described a 2-file/+38
change with 3 new macOS dirs, while HEAD is 4 files/+227 with 6 lookup dirs
plus 5 new WSL-guest prelude entries, and the quoted failing test names never
existed. Restated against HEAD in the handoff; no rebuttal, the reviewer was
right.

Justification for the entries the summary never described: the fallback exists
to close the native/WSL asymmetry for a CLI no version manager installed, and
patchPackagedProcessPath already seeds Linuxbrew, /snap/bin and both nix
profile dirs (configure-process.ts:141-158). Shipping only the darwin subset
would have left a Linux or WSL user with a snap/nix install still reading as
not installed while the packaged macOS user did not -- the asymmetry the change
is for.

Code changes, all from the non-blocking list:

- The three lists disagreed on order while claiming to be kept in step, so a
  CLI in both /usr/local/bin and /snap/bin could resolve to a different binary
  than the seeded PATH scan or the WSL guest probe found. All three now use the
  seed's relative order, pinned by a new duplicate-install test and an offset
  assertion on the prelude. The prelude's system block also moved after the nvm
  glob so a version manager still wins in the guest, as it does natively.
- The parity docstring asserted "the same set patchPackagedProcessPath appends,
  minus the sbin dirs and the generic ~/bin", which was false: it also omits
  ~/.vite-plus/bin (seeded by configure-process.ts:156, but no probed agent
  command maps to it) and /opt/homebrew off darwin. All three gaps are now
  named as deliberate.
- win32 returns [] and stays that way, but the branch now says why:
  %USERPROFILE%\.opencode\bin has never had install-dir coverage in either
  list, and the seed's system block is POSIX-only too. Pre-existing, unchanged.
- The detectCommandsInInstallDirs case read the ambient process.env.PATH, so on
  a box with /usr/local/bin on PATH only the opencode assertion exercised the
  fallback. It now stubs the GUI-launch PATH, so both do.

Unchanged and restated: this does NOT explain the packaged macOS v1.4.194
report of codex/cursor-agent/opencode all undetected, and must not close G6
report stablyai#3. patchPackagedProcessPath returns early unless app.isPackaged and
seeds all six dirs before any detection, and mergePathSegments never deletes
them, so the packaged PATH scan reaches them first and this fallback never
fires there. Decisive only for the `orca` CLI's detectSkillsCliAgentKeys and
unpackaged/dev runs.

Verification: the suite is red without the production hunks (5 failed/3 passed)
and green with them (8 passed); 11 related suites pass (197 tests); tc:node,
tc:cli, oxlint, oxfmt and the max-lines ratchet are clean.

* fix(agents): correct the ordering-parity claims and widen the seed-leak guard

Round-3 review found two docstring claims that are false as written and one
guard that only asserted a third of its list.

- system-cli-install-dirs.ts claimed a CLI in two of these dirs resolves the
  same here as in the packaged PATH seed. True inside the system block, false
  across it: `claude` in both ~/.local/bin and /opt/homebrew/bin resolves to
  ~/.local/bin via the fallback (getBaseVersionManagerDirectories leads) and to
  /opt/homebrew/bin via the seed, which appends ~/.local/bin last. Scope the
  claim to the block and name the gap instead of asserting it away. No behavior
  change: closing it would hoist a system dir over a version-manager one
  (stablyai#18234).
- posix-version-manager-bin-dirs.ts justified moving "/usr/local/bin" after the
  nvm glob with "a version manager still wins in the guest, as it does
  natively". The glob expands lexicographically; native orders nvm dirs
  default-alias-first (stablyai#10932), so that is not parity. Record the move as the
  one behavior change in the file and bound it: entries are appended behind a
  resolved login PATH, and both consumers only test presence.
- The stablyai#18234 seed-leak guard asserted only /opt/homebrew/bin and /usr/local/bin
  were absent from getVersionManagerBinPaths, leaving the four other new dirs
  unpinned. It now spells out all seven across darwin and linux -- spelled out
  rather than derived from getSystemCliInstallDirectories, which would pass
  vacuously against exactly the refactor it guards.

Tests 8 passed (8); 5 failed / 3 passed with the production hunks reverted to
origin/main. tsc node + cli clean, oxlint clean.

* fix(agents): find Pi's own installer dir in the CLI install-dir fallback

The fallback added `~/.opencode/bin` but skipped `~/.vite-plus/bin` on the
claim that no probed agent command maps to it. False: `pi` is a probed detect
command on every runtime (`tui-agent-config.ts`, no `detectUnsupportedRuntimes`)
and `~/.vite-plus/bin` is the Pi installer's default — the two dirs stablyai#829 named
and `patchPackagedProcessPath` seeds together. Added to both the native
fallback and the WSL guest prelude, so a Pi installed by its own script is
found by the `orca` CLI and in WSL, not just on a seeded packaged PATH.

Also, all narrower:
- `/snap/bin` + Linuxbrew now gate on `linux` like the seed does, instead of
  every non-darwin posix.
- Docstring: `/opt/homebrew` off darwin is the one remaining seed gap and says
  why; the "lookup-only" paragraph names the `withCliRuntimeOnPath` exception.
- New seed-order test derives the expected order from
  `getSystemCliInstallDirectories`, so reordering either list fails.

The PR body's claim that SSH hosts benefit is dropped: they answer
`preflight.detectAgents` from `src/relay/preflight-handler.ts` via
`isCommandOnPathForRelay`, a separate bundle that never reaches this module.

* fix(agents): build the CLI install-dir fallback order once and pin it on both resolvers

resolveCliCommand (every spawn site) and resolveCliCommands (detection) each
spelled the nvm -> version-manager -> system-dir order by hand, which is how
the native and WSL lists drifted apart before. One getCliInstallDirectories
now feeds both, and the test pins system dirs LAST on both resolvers, on
darwin and linux, plus a derived check that the WSL guest prelude keeps every
native version-manager dir ahead of the native system block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant