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

@bacnh85/pi-budget

v0.1.2

Published

Spend cap enforcement for Pi — halts the agent when session cost exceeds a --budget USD limit. Companion to pi-sub (which renders usage); this one enforces.

Downloads

485

Readme

pi-budget

Spend cap enforcement for Pi — halts the agent when cumulative session cost exceeds a --budget <usd> limit. Companion to pi-sub: pi-sub renders subscription usage in the footer; pi-budget enforces a spend policy.

Zero dependencies. Plain JS.

Install

pi install npm:@bacnh85/pi-budget

Usage

pi --budget 0.50          # abort the session once spend hits $0.50
pi --budget 5             # a whole-dollar cap works too

When the cumulative cost of assistant responses reaches the cap:

  • The current turn is aborted (ctx.abort()).
  • A warning notification is shown.
  • A budget-exceeded custom entry is appended to the session record.
  • The footer shows Budget $X.XX / $Y.YY (red when exceeded, yellow below 20% remaining).

The budget resets on a new session. Context compaction does not reset it (compaction is mid-session). No cap set → the extension stays silent and shows no footer.

How it works

  • pi.registerFlag("budget") reads --budget <usd> once at startup.
  • message_end events accumulate message.usage.cost.total for assistant messages.
  • ctx.abort() stops the turn when the cap is crossed; an exceeded guard ensures the abort fires exactly once per session.

Limitations

  • Parent-session only. pi-subagent children are separate sessions, so child spend is not visible to this extension. Child aggregation from tool_result is a possible follow-up (tracked in the CHANGELOG).
  • Accuracy follows providers. Enforcement is only as accurate as each provider's usage.cost.total reporting.

Development

npm test   # node --test (no framework)

License

MIT