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

pi-session-anchor

v0.3.0

Published

Remember your conversation tree position across pi restarts. Drop an anchor with /tree or /rewind, and pi will return to that spot next time you start (unless you chatted past it).

Readme

pi-session-anchor

Drop an anchor in your conversation tree — pi will return to that spot after a restart.

What it does

When you use /tree or /rewind to navigate to an earlier point in your session, pi-session-anchor saves that position (leafId) to a small sidecar file.

The next time you start pi (or resume the session), it restores the tree position so you pick up exactly where you left off — not at the latest message.

This fills the gap left by pi-rewind (which saves file state but not conversation tree position) and pi-undo-redo (which only incidentally saves position as a side-effect of its redo stack).

Resume switching (fixed!)

When you use /resume to switch between sessions and switch back, the anchor is now correctly restored — including the visual display. This was a two-part fix:

  1. Never overwrite the anchor with the current position.
    Only session_tree (explicit navigation) saves the anchor. session_shutdown does NOT overwrite it.

  2. Apply the anchor at session-file load, before any render.
    SessionManager.open() is patched to read the sidecar and call branch() immediately after _buildIndex() runs. This means renderInitialMessages() always sees the correct leafId — no timing gap.

How it works

/tree → navigate to older message
  │
  ├─► pi-session-anchor saves newLeafId → sidecar
  │
  ▼ restart or /resume
  │
  ├─► SessionManager.open() loads the session file
  ├─► patched open() reads sidecar, calls branch(anchor)
  ├─► renderInitialMessages() → correct tree displayed
  └─► ✅ conversation tree shows the anchored position

No session entries are modified. The anchor is kept in ~/.pi/agent/state/session-anchor/<sessionId>.json — clean, separable, inspectable.

Commands

| Command | Description | |---------|-------------| | /pin | Manually save the current tree position as an anchor | | /anchor | Show the saved anchor for the current session |

The anchor is also auto-saved on every /tree or /rewind navigation.

Edge cases handled

| Situation | Behaviour | |-----------|-----------| | Target entry compacted away | Silent fallback to latest position | | Navigation to root (before first message) | Saved as leafId: null, restored via resetLeaf() | | Sidecar file deleted / corrupted | Treated as "no anchor", normal startup | | Multiple sessions | Separate sidecar per session ID | | Anchor then continue chatting | New messages are children of the anchored position; anchor stays until next /tree overwrites it | | /resume switch away and back | Anchor applied at SessionManager.open() — correct from first render | | Extension reload | SessionManager.open patch is re-applied; no side effects |

Installation

# If published on npm:
pi install pi-session-anchor

# Or copy to extensions directory:
cp -r pi-session-anchor ~/.pi/agent/extensions/

Then reload pi or restart.

Configuration (optional)

No configuration is required. If you want to disable auto-restore, remove the sidecar file for that session from ~/.pi/agent/state/session-anchor/.