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

v0.2.1

Published

Pi coding agent extension that trims Pi-specific identity and documentation from the system prompt to reduce context usage.

Downloads

693

Readme

pi-trim

Less Pi in Pi.

Strip Pi-specific identity and documentation from the system prompt. Keep the coding assistant, tools, and your instructions.

CI npm License: MIT Pi 1.0

简体中文 · Measured results · Source

Pi's default system text: 540 to 274 tokens, measured with o200k_base

pi install npm:pi-trim

Then start a new Pi process, or use /reload in an existing session.

GitHub installation also works:

pi install git:github.com/zhexusun10/pi-trim

What changes?

What happens if Pi knows less about Pi?

Pi already keeps its default prompt small. This package removes three recognizable pieces of its own boilerplate:

| Before | After | | --- | --- | | You are an expert coding assistant operating inside pi, a coding agent harness. | You are an expert coding assistant. | | Pi's <docs> section: pointers to its README, SDK, extensions, themes, skills, and TUI documentation | Removed from the provider-bound system messages | | The exact rule telling the model to inspect PI_* environment variables | Removed |

Tool descriptions and schemas, other rules, project instructions, skills, addenda, custom sections, and conversation messages remain intact. A user-defined docs section with different contents is preserved. This is a targeted transformation, not a filter for every occurrence of pi or docs.

You can still ask the model about Pi, but its automatic documentation pointers are gone. Provide the relevant paths or links yourself when doing Pi SDK or extension work.

Inspect it

/pi-trim
/pi-trim status
/pi-trim diff

status reports original and remaining character counts, a chars / 4 token estimate, and changed sections. diff shows the exact removed or replaced text.

Before the first model request, the command previews the base prompt. Afterwards, it describes the system text in the most recent request, including system-message updates. Tool schemas are excluded. Other extensions running later can change that request again.

Illustrated pi-trim command demo, based on the measured fixture

The animation is an illustrated command demo, not a recording of a live model session.

Measured prompt reduction

| Pi 1.0 default system text | Tokens | | --- | ---: | | Before | 540 | | After | 274 | | Removed | 266 (49.3%) |

Measured using gpt-tokenizer 4.0.0, o200k_base, with default read/bash/edit/write tool snippets and guidelines. Installation paths are normalized to /opt/pi, and the working directory to /workspace. No project instructions, skills, or addenda. Tool schemas and provider formatting are excluded.

These are tokenizer counts for the published fixture, not provider billing totals. Adding your project context reduces the percentage saved. Smaller prompts do not establish better task success, latency, or cost; see the benchmark methodology and results.

npm ci --ignore-scripts
npm run benchmark

Coding-task comparison

A single paired pass over ten small JavaScript tasks with openai-codex / gpt-6-sol:

| Metric | Default Pi | pi-trim | | --- | ---: | ---: | | Task success | 10 / 10 | 10 / 10 | | Total input tokens, including cached input | 63,903 | 50,699 (-20.7%) | | Median first text delta (includes CLI startup) | 14.179 s | 13.673 s | | Pi-reported model-price cost estimate | $0.090297 | $0.095274 (+5.5%) |

Aggregate tool-call counts were identical. This run does not establish better latency, quality, or cost: it is small, cache state was uncontrolled, and there were timing outliers. Raw data, full metrics, and caveats.

How it works

The extension hooks context_with_system before each model call. It clones recognized system messages, transforms only the relevant content or named sections, and returns the replacement messages. It preserves tool additions/removals and section-deletion markers in mid-session updates. Pi's stored transcript is not rewritten.

The extension itself makes no network requests, telemetry, model calls, file reads, or file writes. It only transforms system messages in memory and shows reports on request. Pi's own behavior and installation operations are separate.

Tested with Pi 1.0 and Node.js 22.19+. The manifest follows Pi's host-provided peer dependency convention; it does not bundle Pi. Earlier Pi versions without context_with_system are unsupported. Upstream prompt changes may require new matching rules; unknown content passes through.

Update and remove

pi update npm:pi-trim
pi remove npm:pi-trim

For a GitHub install, use git:github.com/zhexusun10/pi-trim as the source instead. Restart Pi or run /reload after removal.

Migrating from the old strip-pi-docs.ts script? See the migration guide, especially if it previously patched your Pi installation.

Development

npm ci --ignore-scripts
npm run check
npm test
npm run benchmark
pi -e .

No build step or runtime dependencies. Pi loads the TypeScript extension directly. Tests cover preservation of project context, tools, custom sections, text blocks, and mid-session updates.

For real coding-task comparisons, see benchmarks/README.md. Contributions and bug reports are welcome; include the Pi version and a minimal prompt example with private content removed.

License

MIT. An independent community package, not an official Pi product.