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

opencode-total-session-cost

v1.3.2

Published

Real-time cumulative cost tracker for Opencode sessions, aggregating costs from parent sessions, archived messages, and all child sub-agent tasks.

Downloads

856

Readme

Opencode Total Session Cost Tracker 💰

npm version npm downloads npm provenance CI Status License: MIT GitHub stars

A real-time, lightweight plugin for Opencode that tracks and displays the actual cumulative cost of your active session, including all background tasks, sub-agents, and child sessions.

Why this plugin?

By default, Opencode only displays the cost of your active main session. However, any background tasks or specialized sub-agents (like explore, coder, or custom test executors) invoked during your conversation run in their own child sub-sessions, keeping their costs hidden.

Without tracking these sub-sessions, you might see a main session cost of a few cents, while the background agents have spent significantly more.

This plugin solves that. It automatically aggregates the costs of your main session and all its nested child tasks, displaying your real, total spending in real-time directly inside the main session.

Features

  • Sidebar-Independent: The cost indicator stays visible even when the Opencode sidebar is closed.
  • Recursive Sub-Agent Tracking: Automatically detects and sums up the costs of all child tasks spawned during your session.
  • Detailed Cost Breakdown: Offers a /total_cost slash command to show a detailed popup separating your active session cost from child task and sub-agent costs.
  • Session List Cost View: Offers a /sessions_cost command that opens a dialog with the sessions of the last 7 days grouped by day, showing the total cost (including sub-agents) of each session and of each day.
  • Provider & Model Breakdown: Displays the exact costs accumulated per model across all session hierarchy levels.
  • Mouse Click Interaction: Left-clicking on the cost bar in the prompt header right panel triggers the same detailed breakdown popup, while right-clicking opens the session costs list.

Installation

Install it globally with:

opencode plugin opencode-total-session-cost -g

Cost categories

The breakdown separates costs into three buckets:

  • Session: the cost of the active/root session.
  • Task: child sessions spawned through the Task tool by the explore and general agents.
  • Sub-agent: any other child session.

Example /total_cost output:

By session
Session:   $0.12
Task:      $0.34
Sub-agent: $0.08
---------------
Total:     $0.54

By provider/model
anthropic/claude-sonnet-4: $0.40
openai/gpt-5:              $0.14
------------------------------
Total:                     $0.54

Cost that cannot be tied to a model (for example spend recorded in the session total without a matching step or message) is reported as unknown/unknown instead of being guessed onto the currently selected model.

Session list costs

Run /sessions_cost (or /session_costs) to open a centered, read-only dialog with the sessions of the last 7 days grouped by day. Each day header shows the total of its sessions and each session row shows its recursive total (session plus every child sub-session). Use the up/down arrows to move the selection and enter to open a session; esc closes the dialog.

Session Costs                                  last 7 days
Today                                              $0.54
  Refactor the parser                              $0.41
  Add integration tests                            $0.13
Wed Sep 16 2026                                    $0.22
  Fix flaky test                                    $0.22

How it works

The plugin runs inside Opencode's TUI framework, recursively fetching session data:

  1. It reads the core cost of your active session.
  2. It recursively queries all child sub-sessions spawned by sub-agents.
  3. It displays the combined sum dynamically in the TUI.

Development

npm install
npm run typecheck
npm test

License

MIT