r/opencode • • 1d ago

Revival of opencode-usage with OpenCode v1 & v2 support (opencode-usage-v2)

If you used opencode-usage to track your local OpenCode token usage and costs from the terminal, you might have noticed the original GitHub repo (by rchardx) and its PyPI package were recently deleted (404).

I still had a fork that I had updated to support OpenCode v2 alongside v1. Since the upstream project is gone, I cleaned up the packaging, fixed a few cross-platform bugs, and published it to PyPI under a new package name (opencode-usage-v2) instead of taking over the deleted name.

What's new / changed

  • OpenCode v1 & v2 support for usage tracking (--by model, daily trends, costs, cache reads/writes). (Note: the insights subcommand still targets the v1 schema for now.)
  • Works with both paid and free models: tracks token and cache usage even when API cost is $0 / N/A.
  • Windows fixes: resolved UTF-8 file/subprocess encoding issues (cp1252 crashes) and replaced hardcoded /tmp paths.
  • Drop-in CLI compatibility: installs both opencode-usage and opencode-usage-v2 commands.
  • Original MIT license and credit to rchardx are fully preserved.

Run / Install

Run directly without installing:

uvx opencode-usage-v2 --since 1d --by model

Or install it:

pip install opencode-usage-v2
# or
uv tool install opencode-usage-v2

Example usage:

opencode-usage --since 5m --by model

(Heads-up: if you still have the old opencode-usage installed in the same virtual environment, uninstall it first—both packages share the opencode_usage module namespace.)

Links to PyPI and the GitHub repo are in the comments below. Bug reports, edge cases with v2 databases, and PRs are welcome.🎉🎉

Links:

  • PyPI: https://pypi.org/project/opencode-usage-v2/
  • GitHub: https://github.com/fcomovaz/opencode-usage-v2-supp
2 Upvotes

2 comments sorted by

2

u/c_tanaka-719 15h ago

Is updating `insights` for the v2 schema on the roadmap, or is the migration still in progress?

1

u/fcomovaz 9h ago edited 4h ago

[FIXED] Hey, thanks for noticing it, I thought "empty" was the expected output but not really, the fix is coming up in some hours, after that, I think everything is (at far as my concern) done😀

You can now check the new version with the insights in chore(main): release 0.2.6 by github-actions[bot] · Pull Request #2 · fcomovaz/opencode-usage-v2-supp

(.venv) PS C:\> pip index versions opencode-usage-v2
opencode-usage-v2 (0.2.6)
Available versions: 0.2.6, 0.2.5
  INSTALLED: 0.2.6
  LATEST:    0.2.6