Repository navigation
Find and launch provider CLIs on native Windows - #4661
Conversation
On Windows bb resolved npm's extensionless `codex` shim, could not spawn the Codex or Pi CLI through its `.cmd` launcher, and did not find Claude Code's native install, which is not on PATH. - Prefer the `where` result whose extension is in PATHEXT. - Export `experimental_spawnPortableProcess` from the provider-bridge SDK and launch the Codex and Pi CLIs with it. - Find Claude Code at `%USERPROFILE%\.local\bin\claude.exe` and offer its PowerShell installer on Windows. - Bump the plugin SDK to 0.6.13 for the new export. Co-Authored-By: Claude Code <[email protected]>
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. |
💡 Codex Review.cmd launches
On native Windows with an npm-installed CLI, this helper returns the bb/packages/plugin-sdk/src/provider-bridge.ts Line 266 in a465489 This public SDK export is recorded in AGENTS.md reference: AGENTS.md:L29-L29 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Co-Authored-By: Claude Code <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88fddcba3f
ℹ️ 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".
| ) ?? | ||
| candidates[0] ?? | ||
| null |
There was a problem hiding this comment.
Return null when no PATHEXT candidate is runnable
When PATHEXT is defined but excludes every result from where.exe—for example, .EXE with only npm's extensionless codex shim and codex.cmd present—this fallback returns the extensionless shell shim that Windows cannot execute. Callers then treat the provider as installed because the resolved path is non-null, recreating the false-positive detection this change is intended to prevent; return null when no candidate has an allowed extension.
Useful? React with 👍 / 👎.
…ction - Add experimental_killPortableProcess: on Windows it terminates the child's whole process tree, since an npm .cmd shim makes the child a cmd.exe wrapper. The Codex and Pi bridges stop their CLIs with it. - Report no executable when PATHEXT admits none of the where results, instead of returning a shim Windows cannot run. - List both portable-process exports in the Plugin Guide and the plugin-authoring index. Co-Authored-By: Claude Code <[email protected]>
## Human comments ## What was wrong Two Windows npm-shim issues remain after #4661. `probePiVersion()` uses `execFile("pi", ["--version"])`, which cannot launch the npm `pi.cmd` shim and can report `ENOENT` despite Pi being installed. The RPC launcher can execute that shim through `cmd.exe`, but the intermediate shell does not forward BB's extra stdio descriptors 3 and 4; the extension then fails with `Unsupported fd type: UNKNOWN`. These were reproduced with BB 0.45.0 and Pi 0.85.1, and the version-probe issue also reproduces with Pi 1.1.0. The unchanged probe is visible in the [branch base](https://github.com/get-bb/bb/blob/81f98d635d98e5c6f97e56362cfb9f4fbe8cb6fe/plugins/provider-pi/src/bridge/provider-maintenance.ts#L132-L145). ## What changed - Keep `resolvePiLaunch()` as the original configuration resolver. Installation identity, executable metadata, cache keys, and npm/Bun maintenance continue to describe Pi, not its Node interpreter. - Add a separate provider-local process-launch resolver, used only by the version probe and RPC spawn. On Windows, unwrap recognized npm Node `pi.cmd` shims into Node plus the validated package CLI. Resolve against the child's environment/cwd, prefer sibling `node.exe`, otherwise resolve Node from the child's PATH, and preserve configured prefix arguments. - Support both global npm prefixes and local `node_modules/.bin` layouts. Validate manifest/bin contents and physical CLI containment; only accept standard npm shim templates targeting that manifest CLI. Custom wrappers remain unchanged, including custom files named `pi.cmd` beside a valid Pi package. - When the shim has no sibling `node.exe`, look up `node` with `.JS` removed from `PATHEXT`, as the npm shim does, so a `node.js` file in the thread's working directory is not chosen as the Node executable. - Keep ordinary `node:child_process` `execFile` for probing, including its existing 15 s timeout, stdout-only parsing, output bound, and failure diagnostics. RPC launches retain both the ordinary stream and the extra bidirectional extension channel. - Retain real-process probe/error tests, npm-layout/manifest/bin/wrapper tests, native Windows extra-FD regressions, installation-identity assertions, and default npm-shim model/list tests using the real injected extension. Following review feedback, this PR no longer introduces an SDK export or version bump. The earlier SDK/docs changes and unrelated attachment-preview fix have been removed. The resulting diff is confined to `provider-pi` and its `which-command` lockfile entry. No host protocol, CLI, user-facing configuration, or installed-plugin changes. ## How you verified Linux: ```sh pnpm exec turbo run lint typecheck test prepare:bundled --filter=bb-plugin-provider-pi --concurrency=2 node .github/workflows/check-plugin-sdk-version.mjs node .github/workflows/check-version-lockstep.mjs git diff --check ``` The final Turbo run passed **11/11 tasks**: **233 tests passed, 7 skipped**, plus lint, typecheck and bundled preparation. Windows-only tests are skipped on Linux. Both accepted npm templates and LF/CRLF handling are covered; custom-wrapper tests retain a valid npm target while injecting additional commands, so they test actual wrapper rejection rather than merely a mismatched target. Native Windows, Node **24.18.0**: bundled the final upstream implementation into a temporary standalone module without installing dependencies or modifying the running BB service. Global and local canonical npm fixtures verify version probing/install-gate success, original `pi.cmd` installation identity, configured arguments, custom-wrapper preservation, ordinary RPC, and descriptor 4 → CLI → descriptor 3 round trips. ```text global: original Pi identity + plain execFile probe/install gate + explicit shim/prefix + RPC/fd4/fd3 PASS local: original Pi identity + plain execFile probe/install gate + explicit shim/prefix + RPC/fd4/fd3 PASS Installed Pi version: 1.1.0 installation identity: pi.cmd Installed Pi live catalog: 31 real BB extension extra pipes and refresh PASS (automatic user extensions disabled) ALL SIMPLIFIED WINDOWS CHECKS PASSED ``` The live smoke uses the machine's existing Pi **1.1.0**, `--no-session --no-extensions`, and an explicit temporary BB extension. An initial run with automatically loaded user extensions timed out; disabling those extensions isolated this launch fix and passed. No model prompt or full thread turn was sent, no native session was persisted, and installed providers/configuration were not changed. Windows regressions were exercised through equivalent standalone bundles, not a full native Windows Vitest run. CI and review still validate integration before merge. Fixes #5332 > AGENT GENERATED --------- Co-authored-by: Sawyer Hood <[email protected]> Co-authored-by: Claude Code <[email protected]>
Human comments
What was wrong
On native Windows the installed provider CLIs were detected wrongly or could not be started:
resolveExecutablePathtook the first line ofwhere codex. npm installs an extensionlessshshim besidecodex.cmd, andwherelists the shim first, so bb reported an executable path Windows cannot run.node:child_processspawn("codex" | "pi"). Node'sspawnonly finds.exeand.comby name, so an npm install (codex.cmd) failed andprovider models codexreturnedmissing_executable.claude.exein%USERPROFILE%\.local\bin, which is not on PATH. bb looked only on PATH (and in$HOME, which is unset on Windows), so it reported Claude Code as not installed and offered thecurl … | bashinstaller.Part of #1206.
What changed
provider-maintenance-kit.ts:resolveExecutablePathpicks the firstwhereresult whose extension is inPATHEXT(new pureselectResolvedExecutable) and reports the CLI as missing when none has one; macOS and Linux still take the firstwhichresult.downloadedInstallerCommandtakes an optional{ powershellUrl }and returnspowershell.exe … "irm <url> | iex"on Windows when one is given.@get-bb/plugin-sdk/provider-bridgeexportsexperimental_spawnPortableProcess(the daemon's existing cross-spawn launcher). The Codex app-server connection and the Pi RPC child use it in place ofspawn. Entries added todocs/api_to_audit.mdand to the Agent providers surface of the Plugin Guide (plugins/plugin-api-docs/src/surfaces.ts); the plugin SDK version goes to 0.6.13.experimental_killPortableProcess. For an npm-installed CLI the launcher's child is thecmd.exethat runs the.cmdshim, and killing only that wrapper leaves the provider running. On Windows the new function stops the child's whole process tree; elsewhere it sends the signal as before. The Codex connection and the Pi RPC child use it at every place they killed the child.%USERPROFILE%\.local\bin\claude.exeon Windows whenclaudeis not on PATH, the session resolver looks forclaude.exeon PATH and at that location, and the install action useshttps://claude.ai/install.ps1on Windows.Behavior on macOS and Linux is unchanged. The Cursor installer action is still the bash script on Windows; that needs Cursor's Windows install command and is not part of this PR.
How you verified
Windows 11 Enterprise VM (build 26300) with
npm install -g @openai/codex(0.160.0) and Claude Code installed by its PowerShell installer (2.1.287, not on PATH), on a branch with this change on top of Start bb and run the bb CLI on native Windows #4657 (needed to build on Windows):bb machine provider-cli status: CodexexecutablePathis…\npm\codex.cmd(was…\npm\codex), Claude Code isinstalled: trueatC:\Users\bb\.local\bin\claude.exeversion 2.1.287 (wasinstalled: false).bb provider models codexandbb provider models claude-codelist models (both returnedmissing_executablebefore).Linux:
turbo run lint typecheck testfor@bb/provider-bridge-protocol,@get-bb/plugin-sdk,@bb/domain, and the Claude Code, Codex, and Pi provider plugins passes (22 of 22 tasks).check-plugin-sdk-version.mjsreports the surface change with a version bump, andcheck-npm-version-guard.mjspasses (0.6.13 is not on npm).New kit tests cover the PATHEXT selection, the missing result when no candidate is runnable, and the Windows installer command.
packages/process-utils/test/portable-process.test.tshas a Windows-only test that launches a.cmdshim, kills it through the new function, and checks the shim's child process is gone; it passes on the VM (5 passed, 1 POSIX-only skipped) and a POSIX test pins the plain signal.Real sessions, same VM, on an installed build that also contains the other open Windows changes, after signing both CLIs in: a Codex thread and a Claude Code thread each provisioned a worktree, ran the repository's setup hook, and completed a turn. Each agent ran
bb statusand reported its own thread id, created a file in the worktree, and reported Windows PowerShell as its shell with the worktree as the working directory.Not verified: stopping a hung Codex or Pi session on Windows through the app (the tree kill is covered by the test above, not by a hung provider); the Pi CLI on Windows, which is not installed there; the Claude Code PowerShell install action run from bb's Settings (I ran the same installer by hand).
🤖 Generated with Claude Code