This repository is a Bun + TypeScript CLI that launches Claude Code against a local Anthropic-compatible proxy.
bun run src/index.ts
bun run build
bun run typecheck
bun test
opencode-go
opencode-go --setup
opencode-go --oauth-login
opencode-go --oauth-logout
opencode-go --qwen-login
opencode-go --qwen-list
opencode-go --qwen-test
opencode-go --qwen-remove <id-or-email>
opencode-go --zai-login
opencode-go --proxy --port 8080
opencode-go --install-statusline
opencode-go --statusline-snippet
opencode-go --statusline-debug-on
opencode-go --statusline-debug-show
opencode-go --statusline-debug-offThe project has two runtime modes:
- Interactive mode: Start or Settings, then provider -> model -> permission mode -> proxy launch -> Claude Code launch.
- Proxy mode:
--proxystarts the local HTTP bridge directly on a chosen port. - Statusline install mode:
--install-statuslineinstalls the Claude CodestatusLinescript and safely merges user settings.
Supported providers:
opencode: OpenCode Go API keyopenai: OpenAI/Codex OAuthqwen: Qwen device flow with saved-account rotationzai: Z.ai free GLM models via browser-assisted login
- Anthropic request ->
convertAnthropicRequestToOpenAI()-> Chat Completions API - Response ->
streamOpenAIToAnthropic()orconvertOpenAIResponseToAnthropic()
- Anthropic request ->
convertAnthropicRequestToResponses()-> Codex Responses API - Response ->
streamResponsesToAnthropic()orconvertResponsesApiToAnthropic()
- Request enters
handleQwenRequest() - Rotator selects an account from SQLite
- Token refresh runs when needed
- Upstream failures can place model locks and fall back to another account before streaming starts
- Request enters
handleZaiRequest() - Handler validates the saved token
- A chat is created, the request is signed, and the Z.ai stream is translated back into Anthropic SSE
| File | Responsibility |
|---|---|
src/cli.ts |
Main CLI flow, menus, auth entry points, Claude Code launch |
src/constants.ts |
Providers, models, endpoints, config paths |
src/config.ts |
JSON config load/save/delete |
src/env.ts |
Claude Code environment construction |
src/auth/oauth.ts |
OpenAI OAuth exchange and refresh |
src/auth/qwen/* |
Qwen device flow, PKCE, refresh |
src/auth/zai/* |
Z.ai browser-assisted token capture |
src/db/* |
SQLite bootstrap, accounts, locks, settings |
src/rotator/* |
Qwen account selection and fallback policy |
src/providers/openai-models.ts |
OpenAI/Codex account-specific model discovery |
src/providers/openai-usage.ts |
Codex/ChatGPT usage window fetch and statusline mapping |
src/proxy/server.ts |
Bun server and provider routing |
src/proxy/qwen-handler.ts |
Qwen request orchestration |
src/proxy/zai-handler.ts |
Z.ai request orchestration |
src/proxy/zai-stream.ts |
Z.ai SSE -> Anthropic SSE conversion |
src/search/searxng.ts |
Local SearXNG lifecycle and queries |
src/statusline/* |
Claude Code statusLine formatter, state, script, installer |
~/.opencode-go-cli/config.json: OpenCode Go key, OpenAI tokens, Z.ai token, last provider/model, preferred proxy port~/.opencode-go-cli/qwen.db: Qwen accounts, per-model locks, rotator settings~/.opencode-go-cli/openai-models.json: cached OpenAI/Codex model registry for the authenticated account~/.opencode-go-cli/searxng/settings.yml: generated SearXNG config~/.opencode-go-cli/statusline.js: installed Claude Code statusLine script~/.opencode-go-cli/statusline-state.json: safe provider/model launch metadata, latest proxy token usage fallback, and cached OpenAI5h/7dusage windows~/.opencode-go-cli/statusline-debug-latest.json: latest captured statusLine JSON when debug is enabled~/.opencode-go-cli/statusline-debug.jsonl: bounded statusLine debug history
- Runtime is Bun, not plain Node.
- Streaming translation is the core behavior. Preserve Anthropic SSE semantics.
- Qwen fallback only happens before the first upstream bytes are streamed back to Claude Code.
- Z.ai login depends on a Chromium-based browser being available to the local machine.
bun testshould cover the full suite before release work.