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

@carlitose86/pi-auto-compact

v0.2.3

Published

Automatic compaction for Pi before the context fills up, with a threshold per model

Readme

pi-auto-compact

Automatic compaction for Pi: summarize the session before the context window fills up, at a threshold you choose, and a different threshold per model if you want.

A fork of @henryqw/pi-auto-compact 4.0.0 (MIT) with lifecycle repairs, one retry for truncated summaries, plain notices for cancelled or failed compactions, and per-model thresholds.

Install

pi install npm:@carlitose86/pi-auto-compact

It refuses to start while Pi's built-in compaction is on, so the two never compete. Turn that off in Pi's settings.json:

{ "compaction": { "enabled": false } }

Load only one auto-compact package: remove npm:@henryqw/pi-auto-compact if you had it.

Usage

| Command | Effect | |---|---| | /auto-compact | Set the general threshold, in percent of the context window (25 to 99, default 70) | | /auto-compact model | Set the threshold for the current model only; answer default to remove it |

The threshold is checked before each turn, after each tool turn and at the end of a run, against the model the session is using at that moment. Switching model applies its threshold at the next check.

Pi starts a compaction only after the running turn has stopped. A turn that starts in that gap, for example one triggered by a background-terminal notice, is stopped too, so the summary does not wait for it; the turn continues once the summary is in.

Configuration

The commands write <agent-dir>/config/pi-auto-compact/config.json (usually ~/.pi/agent/config/pi-auto-compact/config.json). You can also edit it by hand; open sessions pick up the edit at their next check, without /reload (an invalid edit is ignored and the thresholds in use stay):

{
  "autoCompactThreshold": 70,
  "modelThresholds": {
    "anthropic/claude-opus-5-5": 30,
    "gpt-6-luna": 90
  }
}

A key is provider/id or just the model id.

To cover many models at once, modelPatterns is an ordered list of JavaScript regular expressions tested against provider/id; the first that matches gives the threshold. For example, Anthropic models at 30% and OpenAI models at 90%:

{
  "autoCompactThreshold": 70,
  "modelPatterns": [
    { "match": "^anthropic/", "threshold": 30 },
    { "match": "^openai", "threshold": 90 }
  ]
}

For each check the most specific match wins: modelThresholds by provider/id, then by id, then the first matching modelPatterns entry, then autoCompactThreshold. /auto-compact model writes only modelThresholds; edit patterns in the file. A value out of range, an empty key, an empty or invalid pattern makes the whole file invalid: the extension says so and uses 70% until you fix it.

Summary model

With @henryqw/pi-task-models you can route the summary to a cheaper model (task pi-auto-compact/autoCompact). Without a route, Pi summarizes with the session model.

Log

Cancelled and failed compactions are also appended to <agent-dir>/pi-auto-compact.log, rotated once past 512 KiB. The log holds no session content, summaries or credentials.

Development

npm test
npm run smoke -- <path to the installed Pi SDK dist/index.js>
npm run smoke:recovery -- <path to the installed Pi SDK dist/index.js>

License

MIT. See LICENSE; the original notice is kept.