@darthph0enix/commandcode-go-opencode-provider 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +121 -0
- package/index.ts +28 -0
- package/models.json +2954 -0
- package/package.json +61 -0
- package/plugin.ts +75 -0
- package/src/auth.ts +42 -0
- package/src/convert.ts +308 -0
- package/src/model-sync.ts +345 -0
- package/src/model.ts +159 -0
- package/src/stream.ts +188 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brent Weatherall
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# commandcode-go-opencode-provider
|
|
2
|
+
|
|
3
|
+
[Command Code](https://commandcode.ai) API provider for [opencode](https://opencode.ai). Use Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax, Step, and other models through a single API key.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### 1. Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
opencode plugin commandcode-go-opencode-provider
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This installs the provider and registers all available models automatically.
|
|
14
|
+
|
|
15
|
+
### 2. Connect
|
|
16
|
+
|
|
17
|
+
Run `/connect` in opencode, search for **Command Code**, and enter your API key:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
/connect
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 3. Select a model
|
|
24
|
+
|
|
25
|
+
Run `/models` to pick from available models:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
/models
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Manual Configuration
|
|
32
|
+
|
|
33
|
+
If you prefer to configure manually, add this to your `opencode.json`:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"plugin": ["commandcode-go-opencode-provider/server"],
|
|
38
|
+
"provider": {
|
|
39
|
+
"commandcode": {
|
|
40
|
+
"npm": "commandcode-go-opencode-provider",
|
|
41
|
+
"name": "Command Code",
|
|
42
|
+
"env": ["COMMANDCODE_API_KEY"]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"model": "commandcode/deepseek-v4-flash"
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The plugin auto-registers models from [`models.json`](./models.json) at startup. You only need the `provider.commandcode` block — no need to list individual models.
|
|
50
|
+
|
|
51
|
+
### Environment Variable
|
|
52
|
+
|
|
53
|
+
Set `COMMANDCODE_API_KEY` instead of using `/connect`:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
COMMANDCODE_API_KEY=your-key opencode
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Available Models
|
|
60
|
+
|
|
61
|
+
| Model ID | Name | Tier | Reasoning | Context |
|
|
62
|
+
|---|---|---|---|---|
|
|
63
|
+
| `claude-haiku-4-5-20251001` | Claude Haiku 4.5 | premium | no | 200K |
|
|
64
|
+
| `claude-opus-4-7` | Claude Opus 4.7 | premium | yes | 1M |
|
|
65
|
+
| `claude-sonnet-4-6` | Claude Sonnet 4.6 | premium | yes | 1M |
|
|
66
|
+
| `gpt-5.3-codex` | GPT-5.3 Codex | premium | yes | 400K |
|
|
67
|
+
| `gpt-5.4` | GPT-5.4 | premium | yes | 400K |
|
|
68
|
+
| `gpt-5.4-mini` | GPT-5.4 Mini | premium | yes | 400K |
|
|
69
|
+
| `gpt-5.5` | GPT-5.5 | premium | yes | 256K |
|
|
70
|
+
| `deepseek/deepseek-v4-flash` | DeepSeek V4 Flash | open-source | yes | 1M |
|
|
71
|
+
| `deepseek/deepseek-v4-pro` | DeepSeek V4 Pro | open-source | yes | 1M |
|
|
72
|
+
| `google/gemini-3.1-flash-lite` | Gemini 3.1 Flash Lite | open-source | yes | 1M |
|
|
73
|
+
| `google/gemini-3.5-flash` | Gemini 3.5 Flash | open-source | yes | 1M |
|
|
74
|
+
| `zai-org/GLM-5` | GLM-5 | open-source | no | 200K |
|
|
75
|
+
| `zai-org/GLM-5.1` | GLM-5.1 | open-source | no | 200K |
|
|
76
|
+
| `moonshotai/Kimi-K2.5` | Kimi K2.5 | open-source | no | 256K |
|
|
77
|
+
| `moonshotai/Kimi-K2.6` | Kimi K2.6 | open-source | no | 256K |
|
|
78
|
+
| `MiniMaxAI/MiniMax-M2.5` | MiniMax M2.5 | open-source | no | 200K |
|
|
79
|
+
| `MiniMaxAI/MiniMax-M2.7` | MiniMax M2.7 | open-source | no | 1M |
|
|
80
|
+
| `Qwen/Qwen3.6-Max-Preview` | Qwen 3.6 Max Preview | open-source | yes | 1M |
|
|
81
|
+
| `Qwen/Qwen3.6-Plus` | Qwen 3.6 Plus | open-source | yes | 1M |
|
|
82
|
+
| `Qwen/Qwen3.7-Max` | Qwen 3.7 Max | open-source | yes | 1M |
|
|
83
|
+
| `stepfun/Step-3.5-Flash` | Step 3.5 Flash | open-source | yes | 1M |
|
|
84
|
+
|
|
85
|
+
Full model list is maintained in [`models.json`](./models.json). Run `bun run sync` to refresh from the latest Command Code CLI release on npm.
|
|
86
|
+
|
|
87
|
+
## Development
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git clone https://github.com/brent-weatherall/commandcode-go-opencode-provider.git
|
|
91
|
+
cd commandcode-go-opencode-provider
|
|
92
|
+
bun install
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For local testing, create `opencode.local.json` (gitignored) with `file://` paths:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"plugin": ["file:///path/to/commandcode-go-opencode-provider/server"],
|
|
100
|
+
"provider": {
|
|
101
|
+
"commandcode": {
|
|
102
|
+
"npm": "file:///path/to/commandcode-go-opencode-provider",
|
|
103
|
+
"name": "Command Code (local)",
|
|
104
|
+
"env": ["COMMANDCODE_API_KEY"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Run `opencode --config opencode.local.json` to test with your local build.
|
|
111
|
+
|
|
112
|
+
### Sync Models
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
bun run sync # update models.json from Command Code
|
|
116
|
+
bun run sync:global # update models.json + write to ~/.config/opencode/opencode.jsonc
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
package/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { resolveApiKey } from "./src/auth.js"
|
|
2
|
+
import { CommandCodeLanguageModel } from "./src/model.js"
|
|
3
|
+
|
|
4
|
+
export interface CommandCodeProviderOptions {
|
|
5
|
+
name?: string
|
|
6
|
+
apiKey?: string
|
|
7
|
+
baseURL?: string
|
|
8
|
+
headers?: Record<string, string>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createCommandCode(options: CommandCodeProviderOptions = {}) {
|
|
12
|
+
const apiKey = resolveApiKey({ apiKey: options.apiKey })
|
|
13
|
+
if (!apiKey) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
"Command Code API key not found. Set COMMANDCODE_API_KEY env var, create ~/.commandcode/auth.json, or pass apiKey option.",
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
languageModel(modelId: string): CommandCodeLanguageModel {
|
|
21
|
+
return new CommandCodeLanguageModel(modelId, {
|
|
22
|
+
apiKey,
|
|
23
|
+
baseURL: typeof options.baseURL === "string" ? options.baseURL : undefined,
|
|
24
|
+
headers: typeof options.headers === "object" && options.headers !== null ? options.headers as Record<string, string> : undefined,
|
|
25
|
+
})
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
}
|