@butcool/pi-copy-resume

Copy the `pi --session <id>` resume command to the clipboard when Pi exits

Packages

Package details

extension

Install @butcool/pi-copy-resume from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@butcool/pi-copy-resume
Package
@butcool/pi-copy-resume
Version
0.1.1
Published
Nov 3, 2026
Downloads
504/mo · 504/wk
Author
butcool
License
MIT
Types
extension
Size
7 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@butcool/pi-copy-resume

Copy the pi --session <id> resume command to the clipboard when Pi exits.

What it solves

Pi ends an interactive run with a line like:

To resume this session: pi --session 1f2c0a7e-...

That line arrives after the terminal is restored, when the transcript is already scrolled away. This extension puts the same command on the clipboard during shutdown, so the next run can be started by pasting it.

Install

pi install npm:@butcool/pi-copy-resume

Requires Pi 1.5.0 or newer.

Behaviour

  • Copies on quit in interactive mode, for a session that was written to disk.
  • The copied text is identical to the command Pi prints, including --session-dir and single quotes when the session directory lies outside the default location or contains characters a shell would split.
  • Ephemeral runs (--no-session), runs that never wrote a turn, and non-interactive modes (print, JSON, RPC) leave the clipboard untouched.
  • Prints a dim Resume command copied to clipboard line immediately before Pi's own resume line, so both appear together after the screen is restored.

Clipboard writes go through Pi's own clipboard support: the native pasteboard on macOS, xclip or wl-copy on Linux, PowerShell on WSL, termux-clipboard-set on Termux, and OSC 52 in addition when Pi detects a remote session. PI_CLIPBOARD_OSC52=1 forces OSC 52.

Development

npm install
npm run typecheck
npm test                                   # unit tests for the command builder
uv run --with pexpect python tests/clipboard_exit_test.py

The end-to-end script needs models.json and auth.json in ~/.pi/agent, network access for one model turn per case, and it overwrites the system clipboard while it runs. It starts the real TUI in a temporary agent directory with this package installed, quits it, and compares the clipboard against the resume line Pi printed.

Release

Pushing to main publishes through npm trusted publishing (OIDC) with provenance; the repository holds no token. A push only publishes when the version in package.json is not on the registry yet:

npm version patch --no-git-tag-version
# update CHANGELOG.md
git commit -am "release: v0.1.1"
git push

License

MIT