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-mono-context-guard

v1.6.0

Published

Pi extension that guards context window growth by auto-limiting read and rg output

Readme

context-guard extension

Keeps pi sessions lean by preventing common context-window waste during tool use.

What it does

This extension intercepts tool calls and applies three safeguards:

  1. Auto-limit read calls
    If the model calls read without a limit, context-guard injects a default limit of 120 lines and shows a notification. The model can continue with offset to paginate.

  2. Deduplicate unchanged read calls
    If the same file is read again with the same offset and limit, and the file has not changed on disk, the extension blocks the duplicate read and returns a short stub instead of sending the file content again.

  3. Bound raw rg output in bash
    If a bash command uses rg without an output-bounding operator such as head, tail, or wc, the extension appends | head -60 automatically.

Why it helps

These guards reduce unnecessary token usage and make it harder for long sessions to burn context on repeated or unbounded file output.

Current defaults

  • read auto-limit: 120
  • rg head limit: 60
  • read guard: enabled
  • read dedup guard: enabled
  • raw rg guard: enabled

Read dedup behavior

The dedup cache is scoped to the current session.

A cached read entry is only reused when all of the following are true:

  • the same file path is requested
  • the same offset is requested
  • the same limit is requested
  • the file's modification time has not changed

When a file changes, the cache entry is invalidated. The extension also listens for the context-guard:file-modified event so companion extensions such as multi-edit can evict stale cache entries immediately after writes.

Example behaviors

read without a limit

Input:

{ "path": "src/index.ts" }

Effective call:

{ "path": "src/index.ts", "limit": 120 }

Duplicate read of an unchanged file

Instead of re-sending the file contents, the extension returns a short message telling the agent to reuse the earlier read result.

Raw rg inside bash

Input:

rg "TODO" src

Effective command:

rg "TODO" src | head -60

Files

  • index.ts — extension entry point
  • package.json — package metadata
  • CHANGELOG.md — release history