Skip to content

feat(usage): OpenCode z.ai coding-plan usage source #1104

Closed

Description

@Juliusolsson05

Motivation

z.ai GLM Coding Plan users (via OpenCode) have no usage surface. Research (spec §Readers/opencode:zai) verified live: GET https://api.z.ai/api/monitor/usage/quota/limit with the raw opencode zai-coding-plan key as Authorization (no Bearer — Bearer 401s), key from ~/.local/share/opencode/auth.json.

Spec: docs/superpowers/specs/2026-09-20-provider-usage-enablement-design.md §Readers/opencode:zai.

Intended behavior

  • Settings: OpenCode usage-source dropdown becomes live (none | zai), greyed with a hint when OpenCode is disabled or no credential exists.
  • Registry source opencode:zai active when OpenCode enabled AND source = zai.
  • Response mapping: classify CREDIT_LIMIT windows by unit (3 = 5-hour, 6 = weekly; never positional), nextResetTime epoch ms → reset, plan = data.level, both rows all-models; HTTP 200 with success:false inner envelope ⇒ error row; unclassifiable layout ⇒ error, not a guess.
  • Security: single read-only request; key only in memory + header; opencode auth.json read-only.

Phase 3 of the spec. Depends on Phase 1 (registry + settings dropdown plumbing).

Acceptance criteria

  • Reader mapping unit tested with order-shuffled fixtures, inner-failure envelope, unclassifiable layout.
  • Dropdown state logic tested (disabled cases + credential absence).
  • z.ai row renders in modal rail/detail; exhaustion integration works (all-models scope).
  • Live-verified response fixture captured 2026-09-20 committed (no key material).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions