Skip to content

feat(opencode-go): add OpenCode Go plugin with tracking and limits#270

Open
praveenjuge wants to merge 3 commits intorobinebers:mainfrom
praveenjuge:feat/opencode-go
Open

feat(opencode-go): add OpenCode Go plugin with tracking and limits#270
praveenjuge wants to merge 3 commits intorobinebers:mainfrom
praveenjuge:feat/opencode-go

Conversation

@praveenjuge
Copy link

@praveenjuge praveenjuge commented Mar 6, 2026

Description

Adds a new plugin for OpenCode Go that tracks local spend against published plan limits.

Related Issue

#170

Type of Change

  • Bug fix
  • New feature
  • New provider plugin
  • Documentation
  • Performance improvement
  • Other (describe below)

Testing

  • I ran bun run build and it succeeded
  • I ran bun run test and all tests pass
  • I tested the change locally with bun tauri dev

Screenshots

Screenshot 2026-03-06 at 18 51 32

Checklist

  • I read CONTRIBUTING.md
  • My PR targets the main branch
  • I did not introduce new dependencies without justification

Summary by cubic

Adds the opencode-go provider plugin to track local spend and show progress against 5h, weekly, and monthly limits. Fulfills #170.

  • New Features

    • Detects via ~/.local/share/opencode/auth.json key or existing local history; hidden otherwise.
    • Reads ~/.local/share/opencode/opencode.db to sum assistant message cost; no cross-device or remote estimates.
    • Shows 5h, Weekly, Monthly progress vs limits $12/$30/$60; clamps at 100%.
    • Windows: 5h rolling; Weekly = UTC Mon→Mon; Monthly anchored to first local Go usage (fallback to calendar month).
    • Adds docs (docs/providers/opencode-go.md), README entry, and tests.
  • Bug Fixes

    • Show a grey “Status: No usage data” badge when SQLite is unreadable or returns malformed JSON, while keeping the provider visible.

Written for commit 933ff2c. Summary will update on new commits.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

@davidarny
Copy link
Collaborator

@codex review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new "OpenCode Go" plugin that tracks local AI coding spend against published plan limits by reading from OpenCode's local SQLite database. Linked to issue #170 (which describes broader OpenCode integration), this PR focuses specifically on the Go plan with a local-history approach rather than the cookie-based dashboard parsing proposed in the issue.

Changes:

  • New plugin (plugin.js, plugin.json, icon.svg) that reads OpenCode's local SQLite database and auth file to compute rolling 5-hour, weekly, and monthly usage as percentages of published dollar limits ($12/$30/$60)
  • Comprehensive test suite covering detection, time-window aggregation, clamping, and graceful degradation on database failures
  • Provider documentation and README entry for OpenCode Go

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
plugins/opencode-go/plugin.js Core plugin logic: auth detection, SQLite history queries, time-window aggregation (5h rolling, weekly UTC Monday, anchored monthly), and progress line building
plugins/opencode-go/plugin.json Plugin manifest with metadata, brand color, links, and line layout definition
plugins/opencode-go/plugin.test.js Tests for detection, time-window calculations, edge cases, clamping, and soft fallback on DB errors
plugins/opencode-go/icon.svg OpenCode logo SVG icon
docs/providers/opencode-go.md Provider documentation covering detection, data source, limits, window rules, and failure behavior
README.md Adds OpenCode Go to the supported providers list in alphabetical order

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22a1719e36

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Collaborator

@davidarny davidarny left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants