Skip to content

Add OpenCode Go collector for the Agents panel - #7687

Closed
Kristijan-K wants to merge 7 commits into
omacom:quattrofrom
Kristijan-K:opencode-collector-vendor
Closed

Kristijan-K wants to merge 7 commits into
omacom:quattrofrom
Kristijan-K:opencode-collector-vendor

Conversation

@Kristijan-K

@Kristijan-K Kristijan-K commented Aug 21, 2026 •

Copy link
Copy Markdown

Add OpenCode Go collector for the Agents panel

Omarchy ships collectors for claude, codex, and fireworks. This adds the missing opencode collector for the OpenCode Go subscription so the Agents panel can show Go limits and usage (Rolling / Weekly / Monthly) alongside the others.

What it does

  • New file bin/omarchy-agent-usage-opencode — standalone #!/usr/bin/python3 with the same omarchy:summary / args=[--force] [--limits-only] / hidden=true header as the other omarchy-agent-usage-* collectors. Discovered by omarchy-agent-usage-update and writing ~/.local/state/omarchy/agents/usage/opencode.json.
  • Reads both OpenCode generations from the same ~/.local/share/opencode/opencode.db: session/message (classic) and session_v2/session_message (v2). Same trailing window derived from Go limits (https://opencode.ai/zen/go/v1/usage) and exact providerID == "opencode-go" filtering.
  • Go limits via https://opencode.ai/zen/go/v1/usage with Rolling (5h) / Weekly / Monthly windows and auth (OPENCODE_API_KEY or ~/.local/share/opencode/auth.json).

Screenshots

screenshot-2026-08-21_17-35-12

Replace the bash wrapper that required an external sibling checkout with
a self-contained Python collector. The vendored collector now reads both
classic (session/message) and v2 (session_v2/session_message) tables so
Go usage is complete for both OpenCode generations, keeping exact
providerID == "opencode-go" matching and the existing rolling/weekly/
monthly window logic. Output remains the panel's expected JSON
(schemaVersion, id=opencode, limits, today*, recentDays, modelUsage)
and honors --force / --limits-only like the other agent collectors.

Test: external collector still passes 11 tests; vendored --force now
reports 1282 prompts vs 36 before, matching v1(18)+v2(1287) Go messages
in the current window.
Copilot AI balanced review requested due to automatic review settings August 21, 2026 15:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Kristijan-K Kristijan-K changed the title Vendor OpenCode collector with v1+v2 and OOTB compatibility Add OpenCode Go collector for the Agents panel Aug 21, 2026
The panel counted the entire OpenCode history and missed v2 entirely,
so the Codex card showed ~11 months of accumulated usage and omitted
most recent traffic (e.g. gpt-5.6-terra via OpenCode v2).

- Restrict OpenCode OpenAI scans to the trailing 30 days via the
  indexed time_created column, skipping unrelated providers in SQL
- Keep exact providerID == "openai" matching (exclude opencode-go,
  opencode, deepseek, copilot, etc.)
- Read OpenCode v2 messages from session_message in addition to the
  classic message table; both use the same window and provider filter
- Share the 30-day horizon with the native Codex file scan via
  SCAN_WINDOW_SECONDS
- Bump the local-stats cache schema so stale pre-v2 snapshots expire
- Add regression test that recent OpenAI counts, old and Go traffic do not

Test: test/shell.d/agent-usage-codex-scanner-test.sh (19 tests)
Co-locate the window fixture with TEST_HOME so later traps that
rm TEST_HOME also clean it, avoiding a leaked mktemp on every run.
…or-vendor

# Conflicts:
#	bin/omarchy-agent-usage-codex
@bjarneo

bjarneo commented Sep 20, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #8065, which covers the same OpenCode usage collector. I keep that one open and close this one to consolidate review.

If you feel this is the wrong decision, please open the PR again with a note on the difference.

@bjarneo bjarneo closed this Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants