pi-dump-session

Pi extension: /dump starts a new session and erases the old one from disk; /incognito auto-erases the current session's file when the session ends. Incognito mode for pi.

Packages

Package details

extension

Install pi-dump-session from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-dump-session
Package
pi-dump-session
Version
0.1.1
Published
Aug 26, 2026
Downloads
348/mo · 11/wk
Author
zliu250
License
MIT
Types
extension
Size
10.1 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./extensions/dump-session.ts"
  ]
}

Security note

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

README

pi-dump-session

Incognito mode for Pi sessions.

Every pi session is saved forever as a .jsonl file under ~/.pi/agent/sessions/. /new only starts a new file — nothing ever deletes old ones. This package is the eraser.

pi install npm:pi-dump-session

Part of the pi-extensions collection. Want to wipe only the screen and keep the session? That's pi-clear-screen.

/dump — new session + shred the old one

Exactly like /new, but after the replacement session starts, the abandoned session's file is deleted from disk. It disappears from /resume and is not recoverable.

  • Deletion happens inside newSession({ withSession }), i.e. only after the old runtime is fully torn down — nothing can still be writing the file.
  • If another extension cancels the switch (via session_before_switch, e.g. a confirm-guard), nothing is deleted.
  • If deletion fails (e.g. file locked), you get the path so you can remove it manually.

/incognito — private-window mode for the current session

Toggle it once; while ON, the session's file is deleted from disk when the session ends — quit pi, /new, or /resume away. Like a private browser window: close it and it never happened.

  • The flag is persisted in the session itself (pi.appendEntry), so it survives /reload and even resuming the session later. A footer status shows incognito while active.
  • /reload does not delete (the same session continues); /fork does not delete the parent file (the fork references it) — but the fork inherits the incognito flag, since forks copy entries.
  • Deletes on session_shutdown reasons quit, new, and resume.

Limitations

  • SIGKILL or a crash skips session_shutdown, so an incognito session file can survive a hard kill. Run /dump or delete it manually afterwards.
  • Deleted means deleted. There is no trash can. That is the point.

Only pi's own session file is touched

pi-dump-session deletes exactly one file: ctx.sessionManager.getSessionFile(). It never scans directories or deletes anything else.

Development

See the monorepo README. Quick loop:

npm test -w packages/pi-dump-session
pi -e ./packages/pi-dump-session

test/smoke.test.ts pins the documented pi APIs this package relies on (newSession/withSession signature, session_shutdown reason union, appendEntry, getSessionFile, CustomEntry shape) against the actually installed Pi, so version drift fails CI before users hit it.

License

MIT