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-autocompacter

v0.1.0

Published

Agent-led context compaction for Pi sessions and subagents

Readme

Pi Autocompacter

Autocompacter adds agent-led context checkpoints to Pi. It works at turn boundaries. It preserves the active task in a summary and resumes unfinished work.

Requirements

  • Pi 1.4.x
  • Node.js 24 or newer for development and tests

Install

Install the published package globally for your Pi agent and child processes:

pi install npm:pi-autocompacter

For a source checkout, run pi install "$PWD" from the package directory instead.

Restart Pi or run /reload. The package installs the extension and the autocompacter skill.

For a local project install, use pi install -l "$PWD". Trust the project when Pi asks. Review the source before you trust it.

To test the extension without installation, run:

pi --extension ./src/index.ts --skill ./skills/autocompacter

Use

The agent can call self-compact. The tool accepts an optional handoff note. The note should contain the task state, key paths, constraints, and next action.

The extension queues the checkpoint. It waits for the current turn and all its tool results. It then uses Pi's summary generator and active model. Work continues after a requested checkpoint.

| Command | Action | | --- | --- | | /autocompacter | Compact now. If Pi is busy, queue the checkpoint. | | /autocompacter Preserve the release checklist | Add a user focus to a manual checkpoint. | | /autocompacter status | Show token use, active limits, settings path, and errors. | | /autocompacter-config | Open the setup wizard. | | /autocompacter-config set 200k, 225k, 235k | Set notice, warning, and force limits without the wizard. | | /autocompacter-config reset | Restore the default limits. |

The wizard accepts counts such as 200000, 200k, 0.2m, and two hundred thousand.

Context levels

The terminal status bar fills as token use grows. Colored vertical marks show the three levels.

| Level | Default | Behavior | | --- | ---: | --- | | Notice | 200k | Ask the agent to prepare a checkpoint. | | Warning | 225k | Ask the agent to compact after the current safe step. | | Force | 235k | Compact automatically at the turn boundary. |

The force limit cannot exceed 270k. Notice must be below warning. Warning must be below force.

For a smaller model window, the extension lowers all three limits. It keeps 20% of the window free for the response and summary work. Use /autocompacter status to see the active limits.

The extension saves project settings in .pi/autocompacter.json. Example:

{
  "notice": 200000,
  "warning": 225000,
  "force": 235000
}

An invalid settings file pauses automatic compaction. Manual checkpoints remain available. Run /autocompacter-config to replace the file.

Child Pi processes

Each child Pi process must load the extension. A personal package installation normally provides it to child processes. A --extension flag applies only to that invocation. Pass the extension path to each child that uses explicit flags.

The skill gives usage instructions. It does not register the tool by itself.

Failure behavior

A failed summary does not replace the original context. The extension uses a short retry delay at later turn boundaries. It pauses automatic attempts after three failures. Run /autocompacter to retry.

Develop

Run these commands from a source checkout:

npm install
npm run check

Tests cover parsing, configuration, threshold scaling, UI state, turn lifecycle, failures, and continuation.

Live smoke test

Use a source checkout and a low-cost model with tool support. This example uses OpenAI:

OPENAI_API_KEY=... npm run smoke:live

The default model is openai/gpt-4.1-mini. To select another model:

AUTOCOMPACTER_MODEL=openrouter/openai/gpt-4.1-mini \
OPENROUTER_API_KEY=... \
npm run smoke:live

The script checks the tool call, the autocompacter checkpoint, and the reply after compaction. It keeps Pi state in .cache/smoke-live. Provider charges and network access apply.

See behavior details and verification results.