This is opencode-qoder-plugin — an opencode plugin that injects Qoder AI models via a config hook. No manual provider configuration needed by users.
opencode-qoder-plugin/
├── index.ts # Plugin entry — config hook + auth hook
├── provider.ts # Exports createQoderProvider() (opencode npm loader entry)
├── src/
│ ├── models.ts # 10 built-in model definitions (injected by config hook)
│ ├── qoder-language-model.ts # LanguageModelV2 implementation (doGenerate + doStream)
│ ├── prompt-builder.ts # AI SDK CallOptions → Qoder prompt / multimodal builder
│ └── vendor/
│ ├── qoder-agent-sdk.mjs # Vendored Qoder Agent SDK — DO NOT modify
│ └── qoder-agent-sdk.d.ts # SDK type declarations — DO NOT modify
└── tests/
├── models.test.ts
├── plugin.test.ts
├── qoder-language-model.test.ts
└── integration/
├── real-api.test.ts # Requires `qoder login`
└── opencode-cli.test.ts
- Plugin, not provider config —
index.tsuses theconfighook to injectprovider.qoderautomatically. Users only need"plugin": ["opencode-qoder-plugin"]in theiropencode.json. - Auth hook — checks
~/.qoder/.auth/userfor login state. If absent, surfaces a prompt telling users to runqoder login. - Vendored SDK —
src/vendor/qoder-agent-sdk.mjsis a bundled copy of@ali/qoder-agent-sdk(internal registry). Do not replace it without testing the full streaming pipeline. - Model merging — builtin models from
src/models.tsare injected first; anyprovider.qoder.modelsoverrides in the user'sopencode.jsontake precedence.
opencode → QoderLanguageModel.doStream()
→ buildPromptFromOptions() # text or multimodal (base64 image)
→ resolveQoderCLI() # finds latest ~/.qoder/bin/qodercli/qodercli-<version>
→ SDK query() # streams SDKMessage events
├─ stream_event path # incremental text / tool-input deltas (preferred)
└─ assistant path # full-block fallback
→ ReadableStream<V2StreamPart>
npm install
npm test # unit tests, no network requiredReleases are automated via GitHub Actions:
- Update
versioninpackage.json - Commit and push:
git commit -m "chore: release vX.Y.Z" - Tag and push:
git tag vX.Y.Z && git push origin vX.Y.Z - The Publish workflow triggers automatically and publishes to npmjs.com using
NPM_TOKENsecret
NPM_TOKEN must be set in GitHub repo Settings → Secrets →
NPM_TOKEN.
Use an Automation type token from https://www.npmjs.com/settings/~/tokens to bypass OTP.
The authoritative source for model parameters is the local Qoder auth cache:
~/.qoder/.auth/models # JSON written by Qoder CLI on login/refresh
When Qoder releases new models or changes parameters, update src/models.ts to match the assistant array in that file. Field mapping:
~/.qoder/.auth/models field |
QoderModelDefinition field |
Notes |
|---|---|---|
key |
id |
model identifier passed to SDK |
is_vl |
attachment |
vision/multimodal support |
is_reasoning |
reasoning |
extended thinking mode |
max_input_tokens |
limit.context |
|
max_output_tokens |
limit.output |
After editing src/models.ts, also update the model table in README.md (both English and Chinese sections).
| Model ID | Name | Context | Output | Attachment (is_vl) |
Reasoning (is_reasoning) |
|---|---|---|---|---|---|
auto |
Auto (1.0x) | 180K | 32768 | ✓ | ✗ |
ultimate |
Ultimate (1.6x) | 180K | 32768 | ✓ | ✓ |
performance |
Performance (1.1x) | 180K | 32768 | ✓ | ✗ |
efficient |
Efficient (0.3x) | 180K | 32768 | ✓ | ✗ |
lite |
Lite (free) | 180K | 32768 | ✗ | ✗ |
qmodel |
Qwen-Coder-Qoder-1.0 (0.2x) | 180K | 32768 | ✓ | ✗ |
q35model |
Qwen3.5-Plus (0.2x) | 180K | 32768 | ✓ | ✗ |
gmodel |
GLM-5 (0.5x) | 180K | 32768 | ✓ | ✗ |
kmodel |
Kimi-K2.5 (0.3x) | 180K | 32768 | ✓ | ✗ |
mmodel |
MiniMax-M2.7 (0.2x) | 180K | 32768 | ✓ | ✗ |
- Do not modify
src/vendor/files without thorough integration testing - Do not add a
provider.qoderblock toopencode.json— the plugin injects it automatically - Do not move
@opencode-ai/pluginback todevDependencies— it must be independenciesso opencode's Bun installer pulls it