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

@loka1/pi-auto-compact

v0.3.2

Published

Automatically compacts pi's context when it drops to a configurable percentage remaining, settable globally or per model, with a live status-bar indicator.

Readme

pi-auto-compact

preview

A pi extension that automatically compacts the conversation context when it reaches a configurable percentage of the context window used (default 80%).

The limit can be set globally (all models) or per model, and a footer status bar shows the active limit.

Features

  • Auto-compaction fires when context usage reaches your threshold — keeps the context small and predictable.
  • Global or per-model limits: set one default for everything, then override specific models by provider/id or bare id.
  • Live status bar: auto-compact @20% used shows the active limit, updated every turn and on model change.
  • Easy commands to view and change the limit on the fly.

Install

As a package (from git or npm):

pi install git:github.com/loka1/pi-auto-compact
# or
pi install npm:@loka1/pi-auto-compact

Or drop the file at ~/.pi/agent/extensions/ (global) / .pi/extensions/ (project-local) and /reload.

Configuration

Config is merged from JSON files (project wins over global), or set interactively:

| File | Scope | |------|-------| | ~/.pi/agent/auto-compact.json | Global | | .pi/auto-compact.json | Project-local (wins) |

{
  "enabled": true,
  "compactAtPercent": 20,
  "cooldownTurns": 1,
  "continueAfterCompact": true,
  "continuePrompt": "Context was automatically compacted. Continue the task you were working on...",
  "models": {
    "deepseek/deepseek-v4-pro": 15,
    "gpt-4o": 25
  }
}
  • compactAtPercent — global default: compact when this % of the context window is used (20 = compact when 20% used; higher = wait longer, lower = compact sooner).
  • models — per-model overrides (win over global). Key by "provider/id" or bare "id".
  • cooldownTurns — minimum turns between automatic compactions.
  • continueAfterCompact — resume the agent after auto-compaction (default true).
  • continuePrompt — the message sent to resume work after compaction.

Resume after compaction

pi's manual compaction API (ctx.compact()) aborts the running turn and does not resume it. Without help, the agent stops right after an auto-compaction (you'll see an aborted tool call). With continueAfterCompact enabled (the default), the extension sends a follow-up message once compaction finishes so the agent keeps working from where it left off.

The nudge is skipped if the context is still above the threshold after compaction, to avoid a compact → resume → compact loop.

Commands

/autocompact                            → show config + effective limit for current model
/autocompact set <percent>              → set the GLOBAL limit (compact when this % used)
/autocompact model <id> <percent>       → set a PER-MODEL limit (overrides global)
/autocompact unset <id>                 → remove a per-model override
/autocompact toggle                     → enable/disable auto-compaction
/autocompact continue [on|off]          → enable/disable resuming after compaction

# Quick one-command aliases (value = % of context USED at which to compact):
/set-auto-compact-limit 20                     → compact at 20% used (global)
/set-auto-compact-limit 10 model gpt-4o        → compact at 10% used for "gpt-4o"

Per-model limits always win over the global one. Use the provider/id or bare id of the model, e.g. inferx/deepseek-v4-flash-0731, deepseek/deepseek-v4-pro, or just gpt-4o. To make a model follow the global limit instead, remove its override with /autocompact unset <id>.

All changes are saved to the config file and take effect immediately (no reload needed); the footer status bar shows the active limit, e.g. auto-compact @20% used.

License

MIT