Repository navigation
fix(bootstrap): install pi globally so pi update self-updates and persists - #111
Merged
Merged
Conversation
…f-updates The runtime pi was a bun-workspace devDep symlinked to /usr/local/bin, which pi's self-updater refuses: getSelfUpdateCommand -> isManagedByGlobalPackageManager only accepts a package dir under `npm root -g` or the `<prefix>/lib/node_modules` shape, and `<ws>/node_modules/...` is neither. Install pi globally to the persistent /root/.npm-global prefix (version pinned from package.json's devDep so they never diverge), landing at /root/.npm-global/lib/node_modules/... — the exact layout the updater accepts. /root/.npm-global/bin is first on PATH in every shell, so this global pi is the runtime pi; /usr/local/bin/pi is repointed to it. Idempotent (skips when the pinned version is already global) and non-fatal (a registry hiccup falls back to the node_modules/.bin pi, which still boots). The bun devDeps stay: typecheck + the pinned-type tests need them; the global install is additive for the runtime CLI only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…n note + guards Fold in review fixes on the pi global-install self-update change: - Fallback (global install absent) now symlinks the bun devDep into the writable, PATH-first npm-global prefix ($NPM_PREFIX/bin/pi) instead of pointing at $PWD/node_modules/.bin/pi. On ATA the agent PATH has no node_modules/.bin and a baked pi at /opt/zipbox/harnesses/defaults/bin outranks /usr/local/bin, so the old fallback split `which pi` between the agent (baked) and login shells (devDep). Symlinking into the prefix makes the SAME 0.80.3 pi win first on PATH in every shell. Non-fatal. - Correct the do-not-`pi update` NOTE: pin is 0.80.3 (was stale 0.79.8), and document that a user's own `pi update` intentionally moves the runtime pi ahead of the pinned devDep/extensions — the shipped feature, not a bug. - Guard the version read with a numeric `case [0-9]*` so a missing devDep key (node -p prints "undefined") or a stray range never becomes `npm i -g @…@undefined`. - Hardcode the NPM_PREFIX fallback to /root/.npm-global; $HOME/.npm-global is wrong on ATA where HOME=/root/workspace. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On an ATA box,
pi updatefails:bootstrap.shinstalls pi as a bun workspace devDependency and symlinks/usr/local/bin/pitonode_modules/.bin/pi. pi's self-updater refuses that layout — verified against pi 0.80.3's owndist/config.js:isManagedByGlobalPackageManagerrequires the package undernpm root -gor a<prefix>/lib/node_modulesshape, which a bun workspace devDep is neither.Fix
Install the pinned pi globally so the updater accepts it, on ATA's persistent home so the update sticks:
bun install,install_pi_global()reads the exact pin frompackage.jsondevDependencies and runsnpm install -g @earendil-works/pi-coding-agent@<ver>(prefix/root/.npm-global, which is on/dev/vda— the persistent per-box disk, and first on PATH in both the agent and login shells)./usr/local/bin/piat the global bin, with a fallback if the global install didn't land.pi updatewrites to the persistent prefix (pi's update command is prefix-explicit) and survives reboot. The ata bootstrap runs once per box (workspace on vda), so a reboot never re-runs it to downgrade an updated pi back to the pin.Verified against pi's own code: the global layout is ACCEPTED (
getSelfUpdateCommandreturns a real npm command); the bun devDep is REFUSED, exactly as reported.Consistency + safety (from review)
npm i -ghiccups, the fallback now symlinks the devDep into/root/.npm-global/bin(PATH-first in every shell) rather than relying onnode_modules/.bin. Without this, the agent shell would run the baked pi (0.80.10) while a login shell ran the devDep 0.80.3 —which pisplit between shells. Now both the success and fallback paths put the same 0.80.3 pi first on PATH everywhere.case(rejects an empty read,node -p's literal"undefined", and a stray range).PiSettingsContract.testimport them) — the global install is additive for the runtime CLI.pi updatemoves the runtime pi ahead of the 0.80.3-pinned extensions — that's the shipped feature.Verification
sh -n/bash -nclean; shellcheck no new warnings. Eligibility proven by running pi's owngetSelfUpdateCommandagainst the global layout (ACCEPTED) and the devDep layout (REFUSED). PATH order,NPM_CONFIG_PREFIX, and vda persistence were measured on a live box running the same platform image.Not verified here: a full end-to-end ATA boot and an actual
pi updatemutation (eligibility verified via pi's shipped code, not a live update run).