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

v0.1.2

Published

Pi extension that shows session cost including subagent sessions, not just the main thread

Readme

pi-inclusive-cost

A Pi coding agent extension that shows session cost including subagent sessions, not just the current thread.

The problem

Pi's built-in statusline sums cost from the current session's own message history only. If you use a subagent extension (e.g. one that spawns background workers, reviewers, researchers, etc.), those subagent sessions are written to their own nested session files and are invisible to the built-in cost total — so the number in your statusline can understate what a task actually cost by a wide margin.

What this does

Subagent sessions get linked back to their parent chat in one of two ways, and this extension walks both to a fixed point:

  • Nested descendants — fan-out/background subagents whose session files live under <root-session>/**/session.jsonl (a directory named after the parent session's own file, sans extension).
  • Flat siblings with a parentSession header — single-shot/consult-style subagents whose session file sits next to the parent as a plain top-level .jsonl, but whose first line (type: "session") carries a parentSession field pointing back to the parent's file path.

Either kind can itself parent the other kind, so discovery keeps expanding from both mechanisms until nothing new is found, then:

  • Sums usage.cost.total across the root session and every descendant found this way.
  • Adds an incl $X.XX segment to the statusline (via ctx.ui.setStatus) whenever descendant sessions exist — additive, next to the built-in direct-cost number, not a replacement.
  • Refreshes on session start, at the end of every turn, and when the agent run ends — the same cadence the built-in cost figure updates at, not just once the whole task finishes.
  • Adds a /cost command for an on-demand breakdown: direct cost, inclusive cost, and the number of subagent sessions folded in.

It intentionally does not attempt token-based cost estimation — it only sums usage.cost.total as already recorded in the session file. That field is itself a client-side estimate computed by the agent's model registry (input/output/cache token counts × that model's listed per-token price), not a number returned by your provider's billing API — so treat it as an estimate, not an authoritative bill. If your provider doesn't populate usage.cost.total at all, the inclusive total will read as $0.00.

Install

pi install npm:pi-inclusive-cost

or directly from source:

pi install git:github.com/serhii-chernenko/pi-inclusive-cost

Restart Pi, or run /reload.

Commands

  • /cost — direct vs. inclusive cost breakdown for the current chat, plus subagent session count.

Known limitation: newer artifacts-only subagent storage isn't covered yet

pi-subagents has changed how it persists at least one subagent mode (parallel/fork batches) between versions. Older versions always wrote a full session file for every subagent invocation, nested or as a flat sibling — the two mechanisms above. A newer mode instead writes only to <project-cwd>/.pi-subagents/artifacts/<runId>_<agent>_<index>_meta.json (plus a _transcript.jsonl with a different record schema), with no corresponding session file anywhere — nested or sibling. That cost is currently invisible to this extension.

This wasn't skipped by accident: there's no reliable way to attribute a given artifacts file back to one specific chat. The only correlation lead found (a session_info entry naming the subagent, written into the parent's own session file) turns out to depend on the pi-intercom package being installed — not a safe thing to build a core feature on. A worktree-wide sum without that correlation would also reintroduce exactly the cross-chat over-counting problem this extension was built to avoid in the first place (multiple unrelated chats in the same project folder getting lumped together). Until there's a first-party, version-stable way to scope this correctly, it's left uncovered rather than shipped fragile or wrong.

Don't expect this to match your provider's billing dashboard exactly

usage.cost.total is computed locally from token counts and a local price table — it is not your provider's authoritative bill. Even with accurate, current pricing, a locally-summed total can diverge from what your provider's own usage dashboard reports, for reasons outside this extension's control: reporting lag on the provider's side, per-request billing multipliers instead of per-token metering, or negotiated/enterprise rates that differ from the public price list. If you need a number that reconciles with billing, treat this as a fast local signal, not a substitute for your provider's own dashboard.

For a full project-wide audit across every chat (not just the current one), use a dedicated usage-dashboard tool — this extension is meant for a quick, live, per-chat signal in the statusline.

License

MIT