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

v0.1.12

Published

OpenCode TUI plugin that shows the session cost in Brazilian Reais (R$)

Downloads

1,731

Readme

opencode-brl-cost

OpenCode TUI plugin that pins cost tracking to the bottom bar, in Brazilian Reais (R$).

Note: currently integrates only with OpenRouter for balance display. Other providers are tracked for cost (day/week/month) but the balance feature is OpenRouter-only.

Provider balance integration

| Provider | Balance display | | ----------- | --------------- | | OpenRouter | ✅ Available | | OpenAI | ⏳ Pending | | Anthropic | ⏳ Pending | | Google | ⏳ Pending | | Mistral | ⏳ Pending | | xAI (Grok) | ⏳ Pending |

Screenshot

opencode-brl-cost example

How it works

  • Renders a fixed status bar via the app_bottom TUI slot.
  • Bottom-left shows aggregated spend across ALL opencode sessions (every project, not just the current one) since the start of today, this week (Monday), and this month.
  • The month figure is followed by a month-end projection (mês: R$ 45,67 → R$ 52,30): it averages the spend of the completed days so far (up to yesterday) and extrapolates to the rest of the month. Hidden on the 1st, on the last day, and when the month cost is zero.
  • Bottom-right shows the active session's total cost (session.cost, USD).
  • Costs come from each session's cumulative cost (session.cost, USD), attributed to the day it was created, converted with the USD→BRL quote of that day (see below).
  • Sessions are enumerated via the SDK's global endpoint (experimental.session.list, with fallback to session.list) on load, and kept fresh through session.* events.
  • Falls back to R$ 0,00 when there's no data.
  • Currency formatting uses Intl.NumberFormat with pt-BR (e.g. R$ 1,23).

Daily USD→BRL quote

  • Fetched once per day from AwesomeAPI (GET https://economia.awesomeapi.com.br/json/last/USD-BRL, field bid) — no auth, on plugin load, non-blocking.
  • Cached in <state>/brl-cost-rate.json ({ rate, date, timestamp }). A cached quote from today (or yesterday) is reused instead of calling the API again.
  • Each session is stamped with the quote of the day it was created, so day/week/month totals are computed with each session's own rate — not a single global rate.
  • Shown bottom-right as ◆ USD: R$ 5,12 (muted when fresh, yellow/warning when the cache is from yesterday, -- when 2+ days stale or never fetched — costs then fall back to R$ 5.00).

Your session's cost is shown bottom-right (◆ session), the OpenRouter balance is shown on the right of the bar, and the native bar below the prompt still shows the USD price (tokens + $cost). With a plugin option you can replace that native bar with a cost-free prompt that keeps the model name:

{
  "plugin": [["opencode-brl-cost", { "hideNativeCost": true }]]
}

When hideNativeCost is enabled, the plugin registers the session_prompt slot (mode: "replace") and renders the prompt with the model name only — no USD price, no tokens. Drop the option (or set false) to restore the native bar.

OpenRouter balance (pilot)

  • Reads the OpenRouter key from <state>/auth.json (field openrouter.key) and calls GET https://openrouter.ai/api/v1/credits on load, +2s, and every ~60s.
  • On the home screen (home_bottom) and on the session bar (app_bottom), shows the remaining credits in BRL (total_credits - total_usage, × the daily quote).
  • No OpenRouter key found → nothing extra is rendered, plugin behaves as before.

Install

Add the plugin to tui.json:

{
  "plugin": ["opencode-brl-cost"]
}

Then restart OpenCode. The bottom bar appears at the bottom.

Pin a version for stability: "[email protected]".

Why this shape

OpenCode loads TUI plugins from npm as pre-built JavaScript — the runtime does not transpile .tsx/.ts from node_modules. So this package ships dist/index.js (esbuild output) via the exports["./tui"] entrypoint, never raw .tsx.

Local development

npm install
npm run build      # → dist/index.js
npm run typecheck

To test a local checkout without publishing, point tui.json at the built file:

{
  "plugin": ["file:///absolute/path/to/opencode-brl-cost/dist/index.js"]
}

Publish

npm version patch
npm publish

Roadmap

  • Per-day rate tracking inside a single long session (sessions use the quote of their creation day)
  • Session cost delta per last response
  • Token counters (input/output)
  • Balance for providers other than OpenRouter (pilot only)

Contributing

Contributions are welcome! Feel free to open issues, suggest features, or submit pull requests. Keep commits atomic and follow the existing code style.

License

AGPL-3.0 · Copyright (C) 2025 oporpino [email protected]

OpenCode Plugin