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-cost-switch

v0.1.0

Published

Pi extension: preview next-turn model/thinking cost with hit, cold, and cache-tax estimates before switching

Readme

pi-cost-switch

Pi extension that estimates next-turn cost before you change model or thinking level.

Built-in /model and thinking controls only notify after the change. This extension owns a pre-change switch UX with:

  • hit — warm continuation for the current model at the observed cache hit rate (~85% (assumed) when unknown); n/a for other models (prompt cache does not transfer)
  • cold — base uncached total through cache-write-premium upper bound
  • tax — extra cost from re-billing only the previous cacheable prefix

Install

From a local clone (development / sharing a path)

pi install /absolute/path/to/pi-cost-switch
# or from the package directory:
pi install .

From git (once published)

pi install git:github.com/BlockedPath/pi-cost-switch
# optional pin:
pi install git:github.com/BlockedPath/[email protected]

From npm (once published)

pi install npm:pi-cost-switch

Temporary try without installing

pi -e /absolute/path/to/pi-cost-switch

Reload after install:

/reload

Commands

| Command | What it does | |---|---| | /cost-switch [filter] | Pick model + thinking with $ estimates, then apply | | /cost-estimate [filter] | Comparison table only (no switch) | | /cost-switch status | Toggle status-bar next≈… · miss … (in-memory only; resets on /reload) | | /cost-switch help | Quick help |

Status bar

Shows something like:

next≈$0.162 · miss $1.35 · hit ~85% (assumed)
  • next≈ — estimated warm (cache-hit) next-turn total
  • miss — estimated base-cold total if the cache is lost
  • hit — rate used for the warm estimate (72% observed, or ~85% (assumed) when unknown)

Toggle with /cost-switch status. The toggle is in-memory only — it resets to on after /reload.

How estimates work

| Field | Meaning | |---|---| | hit | Current model only: continue with observed session cache hit rate (~85% (assumed) when unknown). Other models show n/a — cache does not transfer across models/providers | | cold | Range: normal uncached total → cache-write premium upper bound | | tax | Extra vs cache-read for the previous cacheable prefix only |

Model switches and reasoning changes are treated as cache-miss risks. List estimates clamp thinking to each candidate’s supported levels. Output/reasoning is a heuristic from session averages × thinking effort multipliers — not provider-exact.

Subscription / zero-priced models show sub instead of $0.00.

Dev layout

pi-cost-switch/
├── package.json          # pi-package manifest + test script
├── README.md
├── LICENSE
├── test/
│   ├── estimate.test.ts  # pure cost helper unit tests (node:test)
│   └── hit-rate.test.ts  # observed vs assumed hit-rate policy
└── extensions/
    └── cost-switch/
        ├── index.ts      # extension entrypoint
        ├── estimate.ts   # pure cost math
        ├── format.ts     # pure $ / token formatters
        ├── hit-rate.ts   # observed vs assumed hit-rate policy
        └── rank.ts       # pure model filter/rank

Tests

npm test
# or:
node --test --experimental-strip-types test/**/*.test.ts

Local auto-discovery (optional): symlink into the global extensions tree:

ln -sfn "$(pwd)/extensions/cost-switch" ~/.pi/agent/extensions/cost-switch

Or use pi install . so settings point at this package path.

Security

Like all pi extensions, this runs with full system permissions. Review source before installing third-party copies.

License

MIT