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

v0.1.0

Published

Reduce Pi session context by rebuilding the current branch with only the message types you keep.

Readme

pi-reduce

pi-reduce is a Pi package that rebuilds the current branch into a smaller session.

It keeps only the message types you want, drops the rest, and writes the result into a brand new Pi session that you continue from immediately.

No summaries are generated in v1. The reduction is deterministic: keep, drop, and truncate only.

Install

pi install npm:pi-reduce

Or from git:

pi install git:github.com/toorusr/pi-reduce

Commands

  • /reduce [chat|reasoning|tools|no-tools|advanced|last]
  • /reduce-advanced

Presets

  • chat — keep user messages and final assistant output only
  • reasoning — keep user messages, assistant thinking, assistant comments, and final output
  • tools — keep user messages plus tool calls and tool results
  • no-tools — keep user messages plus assistant comments and final output
  • last — rerun the last reduce config
  • advanced — open the full reducer UI

What gets reduced

/reduce always starts from the current active branch context. It does not rewrite your source session. Instead it:

  1. reads the current branch context
  2. filters messages by type
  3. optionally filters tools by name
  4. optionally truncates tool arguments and tool results
  5. creates a new session
  6. switches into the new session immediately

The current model and thinking level are copied to the new session.

Advanced options

/reduce-advanced lets you configure:

Message categories

  • user messages
  • assistant thinking
  • assistant comments from tool-using turns
  • assistant final messages
  • assistant status / aborted / error messages
  • tool calls
  • tool results
  • user bash executions (! / !!)
  • custom / extension messages
  • existing branch summaries
  • existing compaction summaries

Tool filters

  • keep all tools
  • keep only selected tools
  • exclude selected tools

Truncation

  • tool call approx-token budget
  • tool call char budget
  • tool call line budget
  • tool result approx-token budget
  • tool result char budget
  • tool result line budget
  • head or tail truncation for tool results

Output

The final notification shows a compact before/after summary with:

  • context reduction bar
  • approximate context tokens before vs after
  • kept vs removed messages
  • key block reductions (thinking, tool calls, tool results)
  • recorded source usage totals

The new reduced session also stores provenance in a reduce-source custom entry.

Notes

  • Copied messages do not preserve historical assistant usage tags, so the new session starts with 0 recorded usage until you continue chatting.
  • Approximate token counts use Pi's own conservative chars / 4 heuristic.
  • Tool-result details are replaced with compact reduced metadata so the new session stays light.

Local development

npm install
npm run check

For a quick local test without installing the package:

pi -e /absolute/path/to/pi-reduce