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

@henryqw/pi-auto-compact

v5.3.3

Published

Trim repeated reads and compact Pi context at a configurable threshold.

Readme

@henryqw/pi-auto-compact

Keep free context space with read trim before summary compaction. Normal compaction preserves completed tool turns and does not restart a final answer.

Install

Requires Pi 1.5.0 or later in the 1.x series. Registry streaming applies authentication, provider settings, and virtual model routes at request time.

pi install npm:@henryqw/pi-task-models
pi install npm:@henryqw/pi-auto-compact

Configure fast in /task-models. The compaction task uses fast unless a task entry overrides it.

Disable Pi's built-in compaction in ~/.pi/agent/settings.json:

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

Restart Pi after installation or settings changes. Activation requires effective compaction.enabled: false; check that trusted .pi/settings.json files do not override it with true.

Works with

| Package | Relationship | Purpose | | --- | --- | --- | | @henryqw/pi-task-models | Required | Provides shared compaction routes. |

Use

Run /auto-compact without arguments and enter a threshold. Pi confirms Auto-compact threshold set to <value>%.

| Surface | Type | Purpose | | --- | --- | --- | | /auto-compact | command | For users: set the context-use threshold interactively. | | pi-auto-compact/autoCompact | task | For Task Models users: configure compaction model routes. |

Read trim has no separate switch. Disable or remove this extension to opt out.

Flow

Auto-compact flowchart: completed boundaries trim duplicate reads before summarizing; oversized requests use a separate emergency guard

  • Context measurement matches Pi's status bar: latest provider usage plus estimates for later messages. Without usage data, including after compaction, estimates use about four characters per token. Replayed reasoning can make estimates too high until the next response.
  • Between completed turns, read trim replaces older successful, text-only read results only if identical full reads remain in protected recent context. Tool names, arguments, and text must match. Failed, changed, already edited, and image results stay intact. Sufficient read trim avoids a summary request.
  • Otherwise, summary compaction sends older effective context to the configured primary route, fallback route, then the current session model. Malformed shared config also selects the current session model.
  • Resumed or forked sessions and oversized fresh input can require emergency compaction. This interrupts the current task, then resumes it.

Config

Package-owned: ~/.pi/agent/config/pi-auto-compact/config.json

| Name | Description | Values | Default | | --- | --- | --- | --- | | autoCompactThreshold | Context-use percentage above which compaction starts. | Number from 25 inclusive to below 100. | 70 |

Problems show at startup. A file problem uses the default threshold. Obsolete model keys are unknown keys, so the extension ignores them. For the shared rules, see Config files.

Only /auto-compact writes config. It rereads and reports problems when opened. Writes are atomic. Valid-file updates preserve concurrent changes. Replacing a problem file removes unknown keys and invalid values, but fails without writing if another session changed it during input.

State and storage

Compaction changes only future context for the active session. Raw history, exports, UI display, and historical usage stay unchanged. Providers do not refund earlier tokens. Older-prefix edits can decrease provider cache reuse.

This does not erase secrets.

Limits and recovery

If fresh input cannot fit safely, Pi reports the limit without discarding the request. Shorten the input or run /compact.

If all summary requests fail, no checkpoint is saved. Check model routes and authentication, then run /compact to try again.