Repository navigation
feat(opencode-usage): add OpenCode Go usage status extension - #89
Conversation
Review complete — no repair-worthy findingsBoth axes reviewed the full PR diff at Report-only (recorded in audit): Validation (fresh at Scope: no live API request was made (no real provider key); Repairs: none · Attempts: 0/10 · Human input: none Full review reports and audit detailsStandards (complete report, verbatim)Verification run: tsc --noEmit clean, biome check extensions/opencode-usage clean, npm test 438 pass / 1 skip. Flake output, packages+checks wiring, README table row + section, AGENTS Repo Layout bullet, ADR format, default-export extension shape, and test placement all conform. Documented-standard breaches:
Note (not a breach): AGENTS.md:47's example filename Baseline smells (judgement calls):
Orchestrator verification of line refs: README.md:10,65,175 and index.ts:2,196 do contain "status bar" (all added lines); GLOSSARY.md:89 says "status slot", GLOSSARY.md:92-95 is the status-slot entry; no file references Spec (complete report, verbatim, with corrected line numbers)(a) Missing or partial: Nothing in Implementation scope or the Behavior/Failure tables is unimplemented. All artifacts landed: nix/modules/pi-package.nix:41-51 derivation + packages/checks (:145,149), README (package list :34, table row :66, feature bullet :10, (b) Not asked for:
(c) Implemented but wrong:
Orchestrator-verified line numbers (ground truth): session_start 171-179; model_select 183-191; registerCommand 195-204; hasUI guards 172,184,198; no-key branch 134-141; HTTP error 88-93; malformed 95-96; partial 129-132; getApiKeyForProvider at 71 outside try at 79; Judge ledger and classifications (complete)Prior actionable IDs: none — fresh run, 0 issue comments, 0 review comments, 0 reviews, no run markers; round 1, repairs used 0/10. No reconciliation needed.
F-001 — report-only (spec ambiguity). Provenance: Spec (c)1. Evidence: extensions/opencode-usage/index.ts:195-204 handler guards only F-002 — refuted. Provenance: Spec (c)2. Evidence: SDK F-003 — refuted. Provenance: Standards #2 / Spec (b). Evidence: PR 89 body contains F-004 — report-only. Provenance: Standards #2 residual / Spec (b). Evidence: F-005 — report-only. Provenance: Standards #1. Evidence: F-006 — report-only. Provenance: Standards #3. Evidence: F-007 — report-only. Provenance: Standards #4. Evidence: extensions/opencode-usage/index.ts:63 type, returned by F-008 — refuted. Provenance: Spec (b) minor. Evidence: parse.ts:96 F-009 — judge independent requirement-deviation pass found nothing. Verified at 83efb84: no module-level fetch/timer (index.ts:38-49); session_start (:171-179) hasUI + provider gate, otherwise clear + bump generation; model_select (:183-191) both directions with generation bump preventing stale apply; registerCommand (:195-204) hasUI guard, failures only, silent success; failure matrix no key → clear + warning (:134-141), non-2xx → Audit record
|
Closes #88.
Adds the
opencode-usageextension: a footer status slot showing OpenCode Go consumed allowance percentages asopencode-go: <rolling>% / <weekly>% / <monthly>%.Screenshot
Live capture from the
tuterminal with the extension loaded andopencode-go/deepseek-v4.1-flashselected.What changed
extensions/opencode-usage/index.ts— refreshes onsession_start(when the model isopencode-go),model_selecttoopencode-go, and/opencode-usage-refresh; clears the slot for other providers and invalidates in-flight fetches. Reusesctx.modelRegistry.getApiKeyForProvider("opencode-go")and sends a non-genericUser-Agent. No polling, no timer, no new configuration.extensions/opencode-usage/parse.ts— pureparseUsage/formatUsage/isUnknownUsagehelpers for the undocumentedGET https://opencode.ai/inference/go/v1/usageresponse (consumed 0..100 percentages, clamped; non-okmeters become?). Reset timestamps are deliberately ignored.extensions/opencode-usage/parse.test.ts— 27 parser/formatter tests, no network.ollama-usage: missing key clears the slot silently; HTTP/network/parse failures render the dimopencode-go: ? / ? / ?; partial results render known values; automatic refreshes stay silent and only/opencode-usage-refreshreports failures.nix/modules/pi-package.nix—pi-opencode-usagepackage in bothpackagesandchecks.docs/adr/0002-opencode-usage-reads-undocumented-inference-meters.md..github/assets/opencode-usage.png— the screenshot above, used by this PR description.Verification
npm run format,npm run lint,npm run typecheck,npm test(438 pass, 1 skipped, 0 fail),nix flake check— all pass.tuterminal with the extension loaded:session_startonopencode-go/deepseek-v4.1-flashrenderedopencode-go: 5% / 2% / 1%.ollama-cloudcleared the slot; cycling back restored it./opencode-usage-refreshwas silent on success.opencode-go: ? / ? / ?and the manual command reportedFailed to fetch OpenCode usage (HTTP 401 Unauthorized).