npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@maxdai/pi-session-modify

v0.1.0

Published

Pi extension: edit one message or drop one turn of the current session in place, then reload it

Readme

@maxdai/pi-session-modify

A Pi extension that edits the current session's history in place: rewrite one message, or drop one whole turn.

Two commands:

| Command | What it does | |---|---| | /psm-edit | Pick one message on the current branch (user / assistant / toolResult), edit its text in Pi's own editor, then reload | | /psm-remove | Pick one turn (a user message and everything it caused) and delete it, then reload |

Both work by rewriting the affected lines of the session JSONL and reloading that same file, so the transcript redraws from disk and the model sees the new content on the next request.

Install

pi install npm:@maxdai/pi-session-modify

Or add it to ~/.pi/agent/settings.json:

{
  "packages": ["npm:@maxdai/pi-session-modify"]
}

Usage

/psm-edit      → list of messages → pick one → edit → Enter
/psm-remove    → list of turns    → pick one → confirm
  • The list is windowed (↑↓ / jk / PgUp PgDn / g G), oldest at the top, cursor starts on the newest entry
  • /psm-edit opens Pi's editor: Enter submit, Shift+Enter newline, Ctrl+G hand off to $EDITOR
  • Edits replace the text blocks only; thinking, toolCall and image blocks are kept as they are
  • Text-only assistant turns (toolCall without text) are not offered for editing
  • /psm-remove keeps bookkeeping entries (usage, model_change, labels, context_edit, …) and reparents them, so only the conversation goes away

What it touches on disk

Next to the session file, in the same directory:

| File | Purpose | |---|---| | <session>.psm-log | append-only undo log: the original line for every edit, the removed lines for every delete, and every parentId change | | <session>.psm-tmp | transient temp file, renamed over the session on success |

Nothing else. Files ending in .psm-log / .psm-tmp are ignored by Pi's session list.

Safety

  • The session file is version-checked before writing and re-read afterwards: entry count, id set and every parentId must still resolve, or the command reports a failure
  • The log line is written before the session file, so a crash between the two leaves a record, not a silent change
  • /psm-remove refuses to run when the turn contains a compaction.firstKeptEntryId (deleting it would silently drop the context that follows) or when another branch hangs off the removed range
  • Writes are synchronous end to end, so a background writer in the same Pi process cannot interleave between reading and renaming
  • The whole-file backup is deliberately not taken: it would discard entries appended after the edit. The .psm-log restores any single change exactly

Requirements

  • Pi ≥ 1.4.0
  • Session format version 3
  • Reloading happens through ctx.switchSession(). The TUI redraws itself; pi-web needs ≥ 1.2.10 to refresh the browser on an extension-driven session change (older versions: reload the page manually)
  • One Pi process per session file (Pi does not lock session files)

Limits

Not supported on purpose:

  • inserting a new message into the middle of a history
  • editing custom_message entries
  • editing across branches (only the current branch is listed)
  • remembering the previous selection (one command, one change, done)

License

MIT