Skip to content

feat: add OpenCode Go quota usage - #1545

Merged
Wibias merged 1 commit into
lidge-jun:devfrom
Wibias:feat/opencode-go-quota
Aug 12, 2026
Merged

feat: add OpenCode Go quota usage#1545
Wibias merged 1 commit into
lidge-jun:devfrom
Wibias:feat/opencode-go-quota

Conversation

@Wibias

@Wibias Wibias commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

Add OpenCode Go quota reporting through the official authenticated GET /zen/go/v1/usage endpoint.

  • maps the rolling window to the canonical 5-hour quota fields
  • maps weekly and monthly percentages and reset times
  • only probes the canonical OpenCode Go destination
  • uses Bearer auth and rejects redirects so configured keys are not sent to lookalike hosts

Verification

  • bun test tests/opencode-go-quota.test.ts
  • bun run typecheck

Both pass.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features

    • Added quota reporting for OpenCode Go, including rolling, weekly, and monthly usage windows.
    • Displays normalized usage percentages and reset times.
    • Handles unavailable or invalid quota information gracefully.
    • Supports secure authorization and canonical usage endpoints.
  • Bug Fixes

    • Prevents quota checks for unsupported destinations.
    • Distinguishes temporary service failures from terminal client errors.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 31fece76-334d-442b-a540-9dbe0a726ba7

📥 Commits

Reviewing files that changed from the base of the PR and between cce6311 and 22de3b3.

📒 Files selected for processing (2)
  • src/providers/quota.ts
  • tests/opencode-go-quota.test.ts

📝 Walkthrough

Walkthrough

OpenCode Go quota support now validates the canonical endpoint, fetches /usage with bearer authentication, maps rolling, weekly, and monthly windows, handles response failures, and routes key-authenticated providers through the quota probe dispatcher. Tests cover request behavior, parsing, redaction, caching, and endpoint validation.

Changes

OpenCode Go quota reporting

Layer / File(s) Summary
Quota fetching and probe dispatch
src/providers/quota.ts
The provider defines canonical OpenCode Go endpoints, validates the base URL, fetches /usage, maps rolling five-hour, weekly, and monthly usage with reset timestamps, handles malformed and failed responses, and wires key-authenticated providers into quota probing.
Quota behavior validation
tests/opencode-go-quota.test.ts
Tests verify request URLs and headers, redirect rejection, quota mapping, reset timestamps, API key redaction, cache cleanup, and suppression for noncanonical destinations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant QuotaProbeDispatcher
  participant OpenCodeGoQuotaFetcher
  participant OpenCodeGoUsageEndpoint
  QuotaProbeDispatcher->>OpenCodeGoQuotaFetcher: request quota for key-authenticated opencode-go
  OpenCodeGoQuotaFetcher->>OpenCodeGoUsageEndpoint: GET /usage with bearer API key
  OpenCodeGoUsageEndpoint-->>OpenCodeGoQuotaFetcher: usage windows or failure response
  OpenCodeGoQuotaFetcher-->>QuotaProbeDispatcher: normalized quota report or probe status
Loading

Possibly related PRs

  • lidge-jun/opencodex#1543: Adds overlapping OpenCode Go quota support and tests for the same endpoint, authentication, quota windows, and redaction behavior.
  • lidge-jun/opencodex#493: Adds provider-specific quota fetching in src/providers/quota.ts.
  • lidge-jun/opencodex#693: Adds provider-specific quota probing and routing for canonical key-authenticated providers.

Suggested reviewers: lidge-jun, luvs01, ingwannu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding OpenCode Go quota usage reporting.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Aug 12, 2026
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently. If no CodeRabbit review appears, comment @coderabbitai review to request one.
Maintainers: @lidge-jun @Ingwannu

@github-actions github-actions Bot added the intake: hygiene-blocked Deterministic PR hygiene checks failed label Aug 12, 2026
@Wibias
Wibias force-pushed the feat/opencode-go-quota branch from 7df755c to 22de3b3 Compare August 12, 2026 17:03
@github-actions github-actions Bot removed the intake: hygiene-blocked Deterministic PR hygiene checks failed label Aug 12, 2026
@Wibias
Wibias marked this pull request as ready for review August 12, 2026 17:04
@github-actions
github-actions Bot marked this pull request as draft August 12, 2026 17:04

Wibias commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Wibias
Wibias marked this pull request as ready for review August 12, 2026 17:08
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] The PR readiness gate is complete. CodeRabbit has already reviewed the current commits.

You are interacting with an AI system.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] The PR readiness gate is complete for head SHA 22de3b3aa0ec9bcbcdd8c0f9204f7ca0bd25a0a3. The pull request is ready for maintainer review.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.

You are interacting with an AI system.

@Wibias
Wibias merged commit c125b61 into lidge-jun:dev Aug 12, 2026
36 of 38 checks passed
@Wibias
Wibias deleted the feat/opencode-go-quota branch August 12, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant