Skip to content

feat: add OpenCode Zen provider with dashboard scraping#140

Draft
vmvarela wants to merge 1 commit into
slkiser:mainfrom
vmvarela:feat/opencode-zen-provider
Draft

feat: add OpenCode Zen provider with dashboard scraping#140
vmvarela wants to merge 1 commit into
slkiser:mainfrom
vmvarela:feat/opencode-zen-provider

Conversation

@vmvarela

Copy link
Copy Markdown
Contributor

Summary

Adds OpenCode Zen provider support with real-time balance scraping from the billing page at opencode.ai/workspace/{id}/billing.

How it works

Unlike the original proposal in #106 (local estimation from opencode.db token usage × models.dev pricing), this implementation scrapes the actual balance from the OpenCode Zen billing page, the same way the existing OpenCode Go provider scrapes the workspace dashboard.

Why scraping instead of local estimation:

  • Real balance, not an estimate — no drift from cached session data or stale pricing
  • No dependency on opencode.db — works even without session history
  • Same pattern as OpenCode Go — both providers use the auth cookie from opencode.ai and reuse the same scraper infrastructure
  • Configuration is identical — workspace ID + auth cookie, same acquisition steps

Changes included

  • New opencode provider (src/providers/opencode.ts)
  • Config resolver with env var and file support (src/lib/opencode-zen-config.ts)
  • Billing page scraper (src/lib/opencode-zen.ts)
  • Shared config file reader utility (src/lib/config-file-reader.ts)
  • Provider metadata, registry, types, and format updates
  • Quota status diagnostics for Zen config
  • README docs with workspace ID and auth cookie acquisition instructions
  • Complete test coverage

Closes #106

Add OpenCode Zen (opencode) provider that scrapes the billing page at
opencode.ai/workspace/{id}/billing for real-time balance data.

Key changes:
- New OpenCode Zen provider (src/providers/opencode.ts)
- Zen config resolver with env var and file support
  (src/lib/opencode-zen-config.ts)
- Zen billing page scraper (src/lib/opencode-zen.ts)
- Shared config file reader utility (src/lib/config-file-reader.ts)
- Provider metadata, registry, types, and format updates
- Quota status diagnostics for Zen config
- README docs: setup instructions with cookie/workspace ID acquisition
- Complete test coverage for all new modules

Closes slkiser#106
@vmvarela vmvarela marked this pull request as draft June 23, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature]: Add OpenCode Zen provider support

1 participant