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-omni-compact

v0.1.2

Published

Pi extension that delegates compaction to a large-context model subprocess

Readme

pi-omni-compact

pi-omni-compact banner

npm version License

A pi extension that replaces default context compaction with a large-context model subprocess. Pi normally summarizes with the active conversation model. This extension spawns a separate pi instance using a large-context model that reads the entire conversation at once, producing higher-fidelity summaries.

Installation

pi install npm:pi-omni-compact

Or from git:

pi install git:github.com/Whamp/pi-omni-compact

Requirements

  • pi installed
  • An API key for a large-context model configured in pi's model registry

Configuration

Edit settings.json in the extension directory to configure which models to try. The extension uses the first model with a valid API key:

{
  "models": [
    { "provider": "google-antigravity", "id": "gemini-3-flash", "thinking": "high" },
    { "provider": "google-antigravity", "id": "gemini-3-pro-low", "thinking": "high" }
  ],
  "debugCompactions": false,
  "minSummaryChars": 100
}

You will need to update the models array to match a provider and model available in your pi setup. A model with a 1M+ token context window is highly recommended — the whole point is reading the full conversation at once.

| Setting | Default | Description | |---------|---------|-------------| | models | See above | Ordered list of models to try. First with a valid API key wins. | | debugCompactions | false | Save input/output JSON to ~/.pi/agent/extensions/pi-omni-compact/compactions/ for diagnosing bad summaries. | | minSummaryChars | 100 | Minimum summary length. Shorter output triggers fallback to default compaction. |

API keys are resolved through pi's model registry — no separate key configuration needed.

Optional: pi-read-map

If you have pi-read-map installed, the summarizer subprocess will use it automatically. It provides structural file maps so the summarizer can navigate the codebase faster and produce more accurate summaries.

How it works

The extension hooks two pi events:

  • session_before_compact — fires when the context window fills up and pi needs to summarize conversation history
  • session_before_tree — fires when the user abandons a conversation branch and pi needs to preserve what happened

For both events, the extension:

  1. Analyzes the full session for structural metadata — tool usage patterns, friction signals (error loops, rephrasing cascades), file operations, and session boundaries
  2. Serializes the conversation and metadata into a hybrid text format
  3. Resolves the first configured model with a valid API key
  4. Spawns a pi subprocess with read-only tools (read, grep, find, ls) and pi-read-map if installed
  5. The subprocess reads the conversation and referenced source files, then returns a structured summary

On any failure — no API key, subprocess crash, output too short — the extension returns undefined and pi falls back to its default compaction.

Summary format

The output follows a fixed structure:

  • Goal — the original user request, quoted verbatim
  • Constraints & Preferences — requirements and style decisions
  • Progress — done, in progress, blocked
  • Key Decisions — what was decided, why, and alternatives rejected
  • File Changes — paths and what changed
  • Code Patterns Established — conventions and architectural choices the codebase follows
  • Implicit Dependencies — environment variables, config, non-obvious coupling
  • Open Questions — deferred decisions, unresolved issues
  • Error History — errors encountered and fixes applied
  • Remaining Work — unfinished tasks
  • Next Steps — ordered list of recommended actions
  • Critical Context — specific values, references, and data needed to continue

Benchmark results

Evaluated against 14 real coding sessions (25k–165k tokens) using pi-compression-benchmark with probe-response scoring:

| Strategy | Avg Score | Min | Max | |----------|-----------|-----|-----| | pi-omni-compact | 57.1 | 35 | 89 | | pi-agentic-compaction | 46.2 | 30 | 70 | | pi-default | 46.1 | 20 | 85 |

Strongest on sessions with concrete implementation work. Weakest on pure exploration/research sessions with no clear goal structure.

Development

npm run validate   # typecheck + lint + format check
npm test           # unit + integration tests
npm run test:e2e   # end-to-end tests (requires real API key)
npm run build      # compile to dist/

Architecture

src/
  index.ts              Event handlers for session_before_compact, session_before_tree
  models.ts             Resolve first configured model with valid API key
  serializer.ts         Convert pi messages to LLM input format
  session-analysis.ts   Extract structural metadata (friction, boundaries, file ops)
  prompts.ts            System prompts (initial, incremental, branch)
  subprocess.ts         Spawn pi subprocess, parse JSON event stream
  settings.ts           Load and validate settings.json
  debug.ts              Save compaction input/output as debug artifacts

License

MIT