omp packages

@butcool/pi-copy-resume0.1.1

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

GitHub Actions Published 10 days ago MIT ~504 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

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