r/opencode • u/fcomovaz • 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: theinsightssubcommand 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 (
cp1252crashes) and replaced hardcoded/tmppaths. - Drop-in CLI compatibility: installs both
opencode-usageandopencode-usage-v2commands. - Original MIT license and credit to
rchardxare fully preserved.
Run / Install
Run directly without installing:
Or install it:
# or
Example usage:
(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
u/c_tanaka-719 15h ago
Is updating `insights` for the v2 schema on the roadmap, or is the migration still in progress?