It updates the currently installed pi, from an active session.
If there is a newer version of pi, it installs it and builds the
command to resume the session (pi --session <session-ID>), which you
can paste and continue where you left off.
Why this stop & paste to resume the session?
Because ctx.reload() only reloads extensions/resources within the
current running process. It does not replace the already-loaded pi
core code in memory after npm install -g updates files on disk. To
guarantee the new global pi version is actually running, the command
exits (ctx.shutdown()) and gives you a resume command for the same
session.
- Checks currently installed global version of
@mariozechner/pi-coding-agent - Checks latest available version from npm (
npm view ... version) - If versions differ, installs the new version globally
Then:
- If a newer version was installed successfully:
- builds
pi --session <session-ref>(prefersgetSessionFile(), fallbackgetSessionId()) - copies that command to clipboard (best-effort)
- prints
Resume previous pi session: pi --session <session-ref> - calls
ctx.shutdown()
- builds
- If already up to date:
- no install, no restart
Clipboard backends tried (order): pbcopy, wl-copy, xclip, clip.exe.
Project-local:
.pi/extensions/update.ts
Global:
~/.pi/agent/extensions/update.ts
Quick test:
pi -e ./update.ts