Repository navigation
Add OpenCode Go usage collector with rate limits to the agents plugin - #7082
tharinfernando wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds OpenCode Go support to the agents usage panel by introducing a new local collector, wiring it into the plugin config/docs, and validating behavior via a dedicated shell test.
Changes:
- Add
omarchy-agent-usage-opencodecollector to emit OpenCode Go usage + limits as a panel-ready JSON record. - Enable
opencode-goin the agents plugin manifest and document the new provider. - Add an end-to-end shell test and a new SVG asset for the provider.
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/shell.d/agent-usage-opencode-scanner-test.sh | New shell test validating OpenCode Go scanning, limits mapping, offline behavior, and caching behavior. |
| shell/plugins/agents/manifest.json | Adds opencode-go provider toggle and updates plugin description to include OpenCode Go. |
| shell/plugins/agents/assets/opencode-go.svg | Adds the OpenCode Go icon asset. |
| shell/plugins/agents/README.md | Documents the opencode-go provider and clarifies where stats/limits come from. |
| bin/omarchy-agent-usage-opencode | New Python collector that scans opencode DB for local stats and fetches limits from OpenCode Go usage endpoint. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| TEST_HOME=$(mktemp -d) | ||
| trap 'rm -rf "$TEST_HOME"' EXIT |
| OFFLINE_HOME=$(mktemp -d) | ||
| trap 'rm -rf "$TEST_HOME" "$OFFLINE_HOME"' EXIT |
| FRESH_HOME=$(mktemp -d) | ||
| trap 'rm -rf "$TEST_HOME" "$FRESH_HOME"' EXIT |
| every transcript still on disk, and OpenCode Go's cover every opencode | ||
| message still in the database. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (4)
test/shell.d/agent-usage-opencode-scanner-test.sh:104
- This final trap replaces the preceding cleanup and drops
OFFLINE_HOME, so every successful test run leaks that temporary directory.
trap 'rm -rf "$TEST_HOME" "$FRESH_HOME"' EXIT
test/shell.d/agent-usage-opencode-scanner-test.sh:91
- This “unreachable endpoint” case has no auth store, so
auth_key()returns early and thefile:///nonexistentURL is never opened. SeedOFFLINE_HOMEwith the test key before invoking the collector so the endpoint-failure path is actually covered.
mkdir -p "$OFFLINE_HOME/bin"
offline=$(HOME="$OFFLINE_HOME" XDG_DATA_HOME="$OFFLINE_HOME/.local/share" \
OPENCODE_GO_USAGE_URL="file:///nonexistent" \
"$ROOT/bin/omarchy-agent-usage-opencode" --force)
shell/plugins/agents/README.md:68
- The local database scan does not require an API key; only the usage endpoint does. Saying both require the key contradicts the collector's offline/no-key behavior and may lead users to think local token stats are unavailable without authentication.
signed in there. OpenCode Go reads opencode's own database (honoring
`XDG_DATA_HOME`) and its usage endpoint (honoring `OPENCODE_GO_USAGE_URL`
for tests); both need the opencode-go key in the same auth store.
shell/plugins/agents/Agent.qml:23
FileView.atomicWritescontrols how writes performed by thatFileVieware committed; it does not make a read-only watcher follow an inode replaced by the updater'smv. SinceupdateProcess.onExitedonly rescans filenames and preserves existingAgentobjects, a refresh can still leave their records stale until the panel is reopened. Explicitly reload existing records after the updater exits (and adjust this assertion/comment) rather than relying on this property.
// The update command rebuilds each record with an atomic rename, which
// swaps out the watched inode. Watch for those replacements so the panel
// picks up new numbers without being told to reload.
atomicWrites: true
|
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. |
Adds OpenCode Go (
opencode-go) as a fourth subscription in the Agents panel,alongside Claude Code, Codex, and Fireworks. The agents panel is display-only
and discovers any record in
~/.local/state/omarchy/agents/usage/, so this isa new collector plus its mark, docs, and tests — no plugin changes needed.
Changes
bin/omarchy-agent-usage-opencode— new collector that:(
~/.local/share/opencode/opencode.db), filtered to messages that ran onthe
opencode-goprovider (same schema handling, scan cache, and--force/--limits-onlyflags as the other collectors).(
https://opencode.ai/zen/go/v1/usage) using the opencode-go API key fromopencode's auth store — the rolling 5-hour, weekly, and monthly dollar
windows render as the panel's LIMITS meters.
empty limits + a status note, with local token usage still shown.
shell/plugins/agents/assets/opencode-go.svg— opencode mark for the tab.shell/plugins/agents/manifest.json— enablesopencode-goby default.shell/plugins/agents/README.md— documents the collector and its limits.test/shell.d/agent-usage-opencode-scanner-test.sh— 10 assertions:provider filtering, token/model aggregation, session counting, limit window
mapping (endpoint mocked via
OPENCODE_GO_USAGE_URL), and the offlinefallback. Existing agent usage/panel tests still pass.
Notes
limits but has no balance — no
balancefield.OPENCODE_GO_USAGE_URLis honored so the limits probe can be pointed at amock endpoint in tests.