Skip to content

Update managed Pi installs with pi update instead of npm - #6869

Merged
ymichael merged 2 commits into
mainfrom
bb/fix-bb-detection-of-managed-pi-installs-thr_8nnix6m53a
Nov 2, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/fix-bb-detection-of-managed-pi-installs-thr_8nnix6m53a

Conversation

@ymichael

@ymichael ymichael commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Pi's installers (pi.dev/install.sh, install.ps1) create a managed install: a launcher in ~/.pi/agent/bin (on Unix, symlinked from a PATH directory such as ~/.local/bin) and releases under ~/.pi/agent/install, marked by managed-install.json. Pi updates it with pi update. The Pi provider's maintenance bridge only knew Bun and npm global installs. It reported the managed install as external but still offered npm install -g @earendil-works/pi-coding-agent@latest for any install that wasn't Bun. Running that adds a second, npm-installed Pi and leaves the managed one on the old version.

Reproduced with Pi's real installers pinned to 1.4.0 (served from a local API) on macOS with a sandbox HOME, and on the Windows 11 ARM64 VM with a sandbox PI_CODING_AGENT_DIR. Both called getPiProviderInstallationStatus / getPiProviderInstallationRun on main:

macOS    installSource "external"  installAction.command "npm install -g @earendil-works/pi-coding-agent@latest"
Windows  installSource "external"  run.command "npm.cmd install -g @earendil-works/pi-coding-agent@latest"   (executablePath ...\agent\bin\pi.cmd)

What changed

  • plugins/provider-pi/src/bridge/pi-managed-install.ts (new): resolvePiManagedInstallRoot resolves the pi on PATH with realpath and reads <agent>/install/managed-install.json (BOM tolerated, validated with zod: kind, schemaVersion: 1, layout: "releases-v1"). Carry the Pi bridge channel over a socket so every launcher works #6857 removed the earlier Windows-only marker check, so this is now the only one.
  • provider-maintenance.ts: chooses the install or update command in this order:
    1. Fresh install: npm, as before.
    2. Managed install: pi update --self. This is checked before npm, so a managed launcher placed in npm's bin directory isn't treated as an npm install.
    3. Bun: bun add -g, as before.
    4. npm global: npm, as before.
    5. Anything else: pi update --self instead of npm. Pi detects its own npm, pnpm, yarn or Bun install, or a configured update command, and fails with its own instructions when it can't.
  • Install gate: the "older than the supported minimum" message now gives the command that matches the install.
  • installSource is unchanged. Managed installs report external, as Claude's native installs do, so there's no wire or SDK change and no protocol bump.
  • README updated.

Related to #3166: this stops bb from creating a duplicate npm Pi. It doesn't add the general detection #3166 asks for, which would recognise installs owned by another package manager across all providers.

How you verified

  • New provider-maintenance.install-source.test.ts:
    • covers a managed launcher inside npm's bin directory, the installer's relative PATH symlink, an invalid marker layout (still npm), an unclassified install, and the install-gate message;
    • four of the five tests fail on main; the fifth checks that a real npm install still gets npm.
  • pnpm exec turbo run test typecheck lint --filter=bb-plugin-provider-pi: 39 files, 348 passed, 5 skipped.
  • macOS, rebased onto c236529: the 1.4.0 managed sandbox now offers pi update --self. Before the rebase, running that command updated the managed install to 1.5.0 and left the npm Pi at 1.4.0. Status afterwards showed currentVersion 1.5.0, installAction null.
  • Windows VM, before the rebase: the bundled status reported pi update --self for ...\agent\bin\pi.cmd. cmd.exe /d /s /c "pi update --self" updated it from 1.4.0 to 1.5.0, the npm Pi stayed at 1.4.0, and status afterwards was clean. The user PATH was unchanged and the sandbox was removed.

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 2 commits November 2, 2026 14:29
Pi's installers (pi.dev/install.sh and install.ps1) create a managed
install: a launcher in ~/.pi/agent/bin, optionally symlinked from
another PATH directory, and releases under ~/.pi/agent/install with a
managed-install.json marker. bb reported it as an external install and
offered npm install -g, which leaves a second npm-installed Pi beside
the managed one instead of updating it.

Detect the managed install from its marker, following the PATH
symlink (resolvePiManagedInstallRoot), and offer `pi update --self` for managed installs, ahead of the
npm and Bun checks. Installs bb cannot classify also get
`pi update --self`: Pi detects its own npm, pnpm, yarn, Bun or
configured update command and fails with its own instructions when it
cannot. Fresh installs still go through npm. The install gate's
too-old message points managed installs at pi update too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit ba6e3c8 into main Nov 2, 2026
45 checks passed
@ymichael
ymichael deleted the bb/fix-bb-detection-of-managed-pi-installs-thr_8nnix6m53a branch November 2, 2026 22:58
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