feat: add usage limits plugin package

Merged
MY
4mo ago
+3470-14

Summary

  • add the OpenCode TUI usage limits plugin package
  • add Codex and ZAI provider support
  • add Changesets setup, schema, and example config

Validation

  • bun run check
  • JSON config/schema parse check

Summary by cubic

Adds the oc-usage-limits-plugin for OpenCode TUI to show Codex and ZAI usage limits in the sidebar and prompt footer. Clarifies usage text to “NN% used”, adds ZAI authPath support, and defaults the Codex label to “Codex” in config and docs.

  • New Features

    • Sidebar panel shows per‑provider usage with reset times; prompt footer shows the active provider. Handles loading/error/stale states and falls back to last good data.
    • Supports Codex and ZAI; reads auth from OpenCode auth, provider auth files, or {env:...}; optional authorizationScheme and baseUrl.
    • Configurable via usage-limits.schema.json and examples/usage-limits.jsonc (enabled, refreshIntervalSeconds≥15, requestTimeoutMs, showErrors, per‑provider settings). Adds Changesets and CI/release workflows; publishes with peers on @opencode-ai/plugin, @opentui/core, @opentui/solid, and solid-js.
  • Bug Fixes

    • ZAI provider respects authPath for key discovery.
    • Usage text now reads “NN% used”, with rounded values and “?” when unknown.

[!NOTE]

Add usage limits plugin package for OpenCode TUI

  • Adds a new oc-usage-limits-plugin package that periodically fetches usage data from Codex and ZAI Coding Plan providers and displays it in the OpenCode TUI sidebar and prompt footer.
  • The plugin registers two UI slots: sidebar_content renders a UsageLimitsPanel with per-provider windows, stale/error states, and reset countdowns; session_prompt_right renders a compact BottomUsage indicator.
  • Provider credentials are resolved from multiple sources (OpenCode auth, CLI auth files, env references), and stale data from the last successful fetch is shown during errors.
  • CI, release, and Changesets workflows are included alongside a full test suite covering config loading, formatting, provider fetching, and session scanning.
  • Risk: readJsonFile in src/utils.ts references stripJsonComments which is not defined in that file and will throw a ReferenceError at runtime.

Macroscope summarized d036b89.