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-read-before-write

v0.1.3

Published

Pi extension that blocks stale edit/write operations when files changed since the agent last read them.

Readme

pi-read-before-write

Pi package that blocks stale edit and destructive existing-file write operations when files changed since the agent last read them.

Disclaimer: this is clanker slop. Use at your own risk.

Why

This adds Claude Code-style stale-file protection to Pi without patching Pi core. It reduces accidental clobbers when a file is edited externally, by another agent, or by a parallel workflow after the current agent last read it.

Install

From npm:

pi install npm:pi-read-before-write

From GitHub:

pi install git:github.com/SteelDynamite/pi-read-before-write

For project-local install:

pi install -l npm:pi-read-before-write

For local development/testing:

npm install
npm run build
pi -e ./dist/index.js

Behavior

  • Successful read calls record a SHA-256 fingerprint of the full file on disk.
  • edit is blocked unless the file was read in the current Pi session and is unchanged.
  • write to an existing file is blocked unless the file was read in the current Pi session and is unchanged.
  • write to a new file is allowed.
  • If a previously read file is deleted before edit or write, the operation is blocked.
  • Successful edit/write calls refresh the recorded fingerprint.
  • Fingerprints are held in a bounded LRU cache: 100 files or 1MB of fingerprint metadata, whichever is hit first.
  • Paths are resolved against Pi's current working directory, normalize Unicode spaces, strip a leading @, expand ~, support file:// URLs, and use realpath() when possible so symlink aliases share one fingerprint.

Block messages

Unread file:

Blocked stale write: file has not been read in this session. Read it before editing: path/to/file.ts

Changed file:

Blocked stale write: file changed on disk since the last read. Read it again before editing: path/to/file.ts

Deleted file:

Blocked stale write: file was deleted since the last read: path/to/file.ts

Limitations

  1. It does not block file mutations through bash, external scripts, or other custom tools.
  2. It cannot fully close the small race between extension preflight and Pi's built-in write execution without core support.
  3. Fingerprints are in memory and are lost when Pi restarts; resumed sessions should re-read files before editing.
  4. Multiple Pi processes do not share fingerprint state.
  5. Large files are hashed in full.
  6. Fingerprints can be evicted from the bounded LRU cache; evicted files must be read again before editing.

Development

npm install
npm run typecheck
npm test
npm run test:pack
npm run audit:release
npm run build

The implementation lives in src/index.ts. The original design notes are in docs/PLAN.md.

License

MIT