omp packages

pi-auto-reload0.2.2

Reload a pi session automatically, when idle, after the installed pi packages change (e.g. after kempt update or pi update).

GitHub Actions Published 2 days ago MIT ~378 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

pi-auto-reload

Reloads a pi session automatically, when it is idle, after the installed pi packages change on disk. That covers updates from pi update, pi install, or a tool that manages pi packages for you, such as kempt. It also reloads when the program behind a channels.tools channel server is upgraded, so the session restarts that server on the new version.

Why

A running pi session keeps the code it loaded at startup, but it loads anything it needs later from the files on disk. After an in-place package update, a session can run a mix of old and new code until you type /reload. That's easy to miss when you have several sessions open.

How it works

  • At session start it records a fingerprint: the packages list in settings.json, plus the version and modification time of each installed npm package, plus the modification time of each channel server's executable. The channel servers are read from ~/.pi/agent/channels.json and the project's .pi/channels.json, and a bare command name is looked up on PATH.
  • Every 15 seconds, and whenever the agent finishes a run, it checks the fingerprint again. When it changes, the status bar shows update installed · reloading when idle.
  • It reloads only when the session is idle: no response streaming, no queued messages, no permission or other prompt open, and no pi-subagents agent running or queued (a reload would abort them). A busy session reloads when it finishes.
  • The reload is pi's own /reload: the extension runs a hidden /auto-reload-now command that calls reload(). Nothing is sent to the model, and a half-typed draft in the editor is kept.

Install

pi install npm:pi-auto-reload

Testing it

Set PI_AUTO_RELOAD_EXTRA to a comma-separated list of extra files to watch. Touching one of them counts as a package update:

PI_AUTO_RELOAD_EXTRA=/tmp/pi-auto-reload-probe pi
# in another terminal
touch /tmp/pi-auto-reload-probe

PI_CODING_AGENT_DIR is honored for the location of settings.json and installed packages.

License

MIT