Skip to content

Add a Settings button that installs the bb CLI for use outside bb - #5441

Merged
SawyerHood merged 1 commit into
mainfrom
bb-install-on-path
Oct 13, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb-install-on-path

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

bb had no supported way to use the bb CLI outside bb. Threads get bb on their PATH from the host daemon, but a terminal, a script, or an agent running outside bb (Claude Code, Codex) only had bb after a global npm install -g bb-app, and desktop app users had no route at all. The packaged CLI also started through a #!/usr/bin/env node shebang, so it failed with env: 'node': No such file or directory on a machine with no Node on PATH, which is the normal desktop case.

What changed

Settings → General → Command line has a new bb CLI row with Install and Remove. Nothing changes PATH until the user chooses Install.

  • Launcher (packages/bb-app/src/cli-launcher.ts, launcher.ts): every packaged bb-app start writes <dataDir>/bin/bb (bb.cmd on Windows). It runs the install's bb CLI with the install's own runtime, including Electron-as-Node and AppImage installs. The launcher passes the path to its server child as BB_CLI_LAUNCHER. Source checkouts write no launcher, so the row is hidden there.
  • Bundled CLI runtime (resolveBundledCliLaunch): without a BB_CLI override, the bb entry now runs the bundled CLI with the launcher's own Node runtime instead of relying on node being on PATH.
  • Server (apps/server/src/services/system/cli-command.ts, routes/system.ts): GET /api/v1/system/cli-command, POST .../install, POST .../remove. Install links the launcher into the first usable folder of /opt/homebrew/bin and /usr/local/bin (macOS), ~/.local/bin, and ~/bin, preferring one already on PATH; on Windows it appends <dataDir>\bin to the user PATH. It never replaces another bb: install returns 409 cli_command_blocked while one comes first on PATH, and the status names it (an npm-installed bb-app, the machine installer's ~/.local/bin/bb, or anything else). Remove deletes only links that point at a bb launcher. Machine credentials get 403. The action runs on the server's own computer; there is no host-daemon wire change.
  • SDK: system.experimental_cliCommand(), experimental_installCliCommand(), experimental_removeCliCommand(), with an entry in docs/api_to_audit.md. @get-bb/plugin-sdk is bumped to 0.6.43 because its bundled types change.
  • CLI: bb settings cli-command (show), install, remove.
  • App: CliCommandSettingsSection, rendered above the existing bb CLI skills row.
  • Docs: docs/configuration.md, both READMEs, the guide template, the bb-cli skill references and command index, the plugin backend SDK table, and the uninstall page.

How you verified

  • New tests: launcher scripts executed through sh (argument passing, missing install, AppImage argument handling), server service tests with real symlinks in a fake home and an injected Windows PATH reader, route tests (unsupported, install/remove, machine credentials), a CLI command-output test, and a Settings row component test.
  • pnpm exec turbo run lint typecheck --filter='...[origin/main]' passes (137 tasks).
  • pnpm exec turbo run test for @bb/server, @bb/cli, @bb/sdk, @bb/config, bb-app, @bb/web, @bb/templates, bb-plugin-bb-guide, and @bb/demo-server passes. @bb/app passes all 5,743 tests; one run reported two unhandled timer errors from splitDragSession.test.ts, which passes alone and is not touched here.
  • node apps/app/scripts/check-bundle-budget.mjs and node packages/plugin-sdk/scripts/check-npm-version-guard.mjs pass.
  • Real app: built bb-app, started it with a sandboxed HOME, clicked Install in Settings, and ran bb from a clean shell with no Node on PATH against that server. Remove deleted the link, and a different bb earlier on PATH blocked install with the 409.
  • Desktop layout: an earlier build of the same launcher code was overlaid into the extracted 0.46.0 Linux AppImage and run under Electron-as-Node through the real AppRun; bb worked with no Node on PATH.
  • Not run: real Windows and real macOS. The Windows PATH logic is covered only by unit tests with an injected registry reader.

🤖 Generated with Claude Code

AGENT GENERATED

Threads in bb already have `bb` on their PATH, but a terminal, a script, or
an agent running outside bb (Claude Code, Codex) had no `bb` unless the user
installed bb-app globally with npm. Desktop users had no way to get it.

Settings → General → Command line now has a "bb CLI" row with Install and
Remove. Nothing changes PATH until the user chooses Install.

- Every packaged bb-app start writes a launcher to <dataDir>/bin/bb (bb.cmd
  on Windows) that runs the install's bb CLI with the install's own runtime,
  including Electron-as-Node and AppImage installs, and passes its path to the
  server as BB_CLI_LAUNCHER. Source checkouts write none, so the row is hidden.
- The server links the launcher into a PATH folder (or appends <dataDir>\bin
  to the Windows user PATH) and never replaces another bb: install is refused
  with 409 while one comes first on PATH.
- The same action is available as `bb settings cli-command [install|remove]`
  and as system.experimental_cliCommand / experimental_installCliCommand /
  experimental_removeCliCommand in the SDK.
- The bundled CLI now runs with the launcher's runtime instead of relying on
  `node` being on PATH.

Co-Authored-By: Claude Code <[email protected]>
@SawyerHood
SawyerHood merged commit 81a2b5a into main Oct 13, 2026
48 checks passed
@SawyerHood
SawyerHood deleted the bb-install-on-path branch October 13, 2026 18:47
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