PYPI PACKAGE AUDIT v0.2.5 Healthy Package

opencode-usage-v2

CLI tool to track and display OpenCode token usage statistics (v1 and v2)

PyPkgScore opencode-usage-v2
Methodology & Criteria โ™ฅ Donate
755 / 1000
Quick Install
pip install opencode-usage-v2
1. Governance
50/200
2. PEP Metadata
200/200
3. Security
200/200
4. Docs & SEO
105/200
5. CI Engineering
200/200
๐Ÿ“ฃ Share Audit: Share this report and visual preview in the current language
Advertisement
PYPI TELEMETRY

Downloads & Community Adoption

Last 30 days (without mirrors)
Last 7 days
114
Last 30 days
114
Total (180 days)
114
Metric / Ecosystem Status / Value Source
Downloads (30d / 180d) โ€” PyPI Stats (without mirrors)
Trusted Publishing (PEP 740) โœ“ Verified OIDC PyPI Integrity / Sigstore
Django Packages โ€” djangopackages.org
PyTech / PyPkgScore 755 / 1000 PyPkgScore Engine

Health & Engineering Analysis (5 Pillars)

1. Governance & Community50 / 200 โ–พ
LICENSEโœ“ 50 pts
SECURITY.mdโœ• 0 pts
CONTRIBUTING.mdโœ• 0 pts
CODE_OF_CONDUCT.mdโœ• 0 pts
2. PEP Metadata & Packaging200 / 200 โ–พ
Wheel (.whl)โœ“ 50 pts
pyproject.tomlโœ“ 50 pts
Project URLsโœ“ 50 pts
Trove Classifiersโœ“ 50 pts
3. Security & Supply Chain200 / 200 โ–พ
Zero CVEs (OSV)โœ“ 60 pts
Trusted Publishing (OIDC)โœ“ 50 pts
Snyk / Audit Linkโœ“ 40 pts
HTTPS Repositoryโœ“ 50 pts
4. Documentation, SEO & Ecosystem105 / 200 โ–พ
Structured READMEโœ“ 60 pts
Read the Docsโœ• 0 pts
Django Packagesโœ• 0 pts
Website / Technical Articlesโœ“ 45 pts
5. Engineering, CI & Quality200 / 200 โ–พ
Automated Testsโœ“ 65 pts
GitHub Actions CIโœ“ 65 pts
CHANGELOG.mdโœ“ 35 pts
Env & Lockfile (uv/rye/poetry/pdm/hatch)โœ“ 35 pts
Advertisement
README & DOCS

Official Documentation & Usage Guide โ€” opencode-usage-v2

PyPI Metadata v0.2.5
Show full original documentation (English README) โ–พ

opencode-usage-v2

CI PyPI version Python versions License: MIT

Maintained fork: opencode-usage-v2 is a maintained fork of the deleted upstream opencode-usage repository (rchardx/opencode-usage), updated with full support for OpenCode v1, OpenCode v2, and migrated mixed SQLite schemas.

CLI tool to track and display OpenCode token usage statistics. Reads directly from OpenCode's local SQLite database โ€” no API keys or external services needed for basic usage.

Features

  • OpenCode v1 & v2 support โ€” reads legacy message/session, current session_message/session_v2, and migrated mixed databases without double-counting
  • Daily breakdown โ€” token usage and cost per day
  • Group by dimension โ€” model, agent, provider, or session
  • Agent ร— Model view โ€” see which model each agent uses
  • Time filtering โ€” last N days, relative durations (7d, 2w), or ISO dates
  • Period comparison โ€” compare current vs previous period with --compare
  • JSON output โ€” pipe to jq or other tools
  • LLM-powered insights โ€” analyze session transcripts and generate a self-contained HTML report
  • Cross-platform โ€” macOS, Linux, Windows

Installation

From PyPI (Recommended)

Run directly without installing using uvx:

uvx opencode-usage-v2
uvx opencode-usage-v2 run --by model

Or install globally / into a virtual environment:

# With uv
uv tool install opencode-usage-v2

# With pip
pip install opencode-usage-v2

Installing opencode-usage-v2 exposes both opencode-usage-v2 and opencode-usage CLI commands (drop-in compatible).

Warning: Do not install opencode-usage-v2 into the same virtual environment as the legacy opencode-usage package. Both distributions provide the opencode_usage Python namespace and opencode-usage script, so co-installing them in one environment causes file conflicts. Uninstall opencode-usage first if upgrading in an existing environment.

From source (local development)

# Clone repository
git clone https://github.com/fcomovaz/opencode-usage-v2-supp.git
cd opencode-usage-v2-supp

# Option 1: with standard Python venv & pip
python -m venv .venv
# macOS / Linux:
source .venv/bin/activate
# Windows (PowerShell):
.venv\Scripts\Activate.ps1
# Windows (Command Prompt):
.venv\Scripts\activate.bat
pip install -e .

# Option 2: with uv
uv sync
uv tool install -e .

Usage

Both opencode-usage-v2 and opencode-usage invoke the same CLI, which has two subcommands: run (default) and insights. You can also invoke it as python -m opencode_usage.

run โ€” Token usage statistics

# Default: last 7 days, daily breakdown
opencode-usage-v2

# Time filtering
opencode-usage-v2 run --days 30
opencode-usage-v2 run --since 7d
opencode-usage-v2 run --since 2025-01-01

# Group by dimension
opencode-usage-v2 run --by model
opencode-usage-v2 run --by agent          # shows model per agent
opencode-usage-v2 run --by provider
opencode-usage-v2 run --by session --limit 10

# JSON output
opencode-usage-v2 run --json
opencode-usage-v2 run --by model --json | jq '.rows[].label'

# Compare with previous period
opencode-usage-v2 run --since 7d --compare

insights โ€” LLM-powered analysis

Analyze your OpenCode sessions and generate an HTML report with workflow insights, friction patterns, agent performance, and actionable suggestions.

# Interactive model picker
opencode-usage-v2 insights

# Specific model
opencode-usage-v2 insights --model gpt-4o-mini

# Customize analysis
opencode-usage-v2 insights --days 30 --concurrency 4 --output report.html

# Force re-analysis (ignore cache)
opencode-usage-v2 insights --force

Requires an API key for the LLM provider โ€” set via environment variable (e.g. OPENAI_API_KEY) or OpenCode's auth.json.

Note: The insights extraction queries currently target the legacy v1 schema tables (session, message, part). Token usage reporting (run) supports both v1 and v2 schemas.

Example output

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ OpenCode Usage โ€” Last 7 days โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚   Calls: 1,280  โ”‚  Tokens: 52.3M  โ”‚  Cost: $0.00             โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

               Usage by Agent (Last 7 days)
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Agent                  โ”ƒ Model        โ”ƒ Calls โ”ƒ   Total โ”ƒ    Cost โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ build                  โ”‚ deepseek-r1  โ”‚   420 โ”‚   18.2M โ”‚       - โ”‚
โ”‚                        โ”‚ qwen-3-coder โ”‚   105 โ”‚    4.7M โ”‚       - โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ explore                โ”‚ gemma-3      โ”‚   310 โ”‚   12.5M โ”‚       - โ”‚
โ”‚                        โ”‚ minimax-m2.5 โ”‚   198 โ”‚    8.1M โ”‚       - โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ librarian              โ”‚ llama-4      โ”‚   156 โ”‚    5.8M โ”‚       - โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ oracle                 โ”‚ qwen-3-coder โ”‚    91 โ”‚    3.0M โ”‚       - โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Schema Support

opencode-usage-v2 supports both OpenCode v1 and v2 database schemas, as well as migrated (mixed) databases:

OpenCode Version Session Table Message Table Status
v1 (legacy) session message (role = 'assistant') Supported
v2 (current) session_v2 session_message (type = 'assistant') Supported
Mixed / Migrated Both tables present Both tables present Supported (deduplicated by ID)

In mixed databases migrated from v1 to v2, messages present in both tables are automatically deduplicated by message ID to prevent double-counting.

Configuration

Environment Variable Description
OPENCODE_DB Override database path (default: auto-detected per platform)
NO_COLOR Disable colored output when set (see no-color.org)
{PROVIDER}_API_KEY API key for insights LLM provider (e.g. OPENAI_API_KEY)
{PROVIDER}_BASE_URL Base URL override for insights LLM provider

Default database locations:

  • All platforms (macOS, Linux, Windows): ~/.local/share/opencode/opencode.db

Development

git clone https://github.com/fcomovaz/opencode-usage-v2-supp.git
cd opencode-usage-v2-supp
uv sync

# Run tests
uv run pytest

# Lint & format
uvx ruff check .
uvx ruff format --check .

# Install pre-commit hooks
uvx pre-commit install

License

MIT