Add support for opencode v2 #3

Open
elpoelma wants to merge 6 commits from feature/opencode-v2-support into master
3 changed files with 70 additions and 58 deletions

View File

@@ -54,7 +54,7 @@ changes the current session; to change the default for every session, edit
### Change the default model ### Change the default model
Edit `model` (and optionally `small_model`) in Edit `model` (and optionally `agents.title.model`) in
[`config/opencode/opencode.json`](config/opencode/opencode.json), then apply the [`config/opencode/opencode.json`](config/opencode/opencode.json), then apply the
change: change:
@@ -67,13 +67,17 @@ needed.
### Register a new weave model ### Register a new weave model
Add the model under `provider.weave.models` in `opencode.json`: Add the model under `providers.weave.models` in `opencode.json`:
```json ```json
"provider": { "provider": {
"weave": { "weave": {
"models": { "models": {
"my-new-model": { "tools": true } "my-new-model": {
"capabilities" {
"tools": true
}
}
} }
} }
} }
@@ -118,17 +122,17 @@ name** from that stack's compose and `<port>` is the container's *internal* port
### `opencode.json` keys ### `opencode.json` keys
- **`model` / `small_model`** — default model and the model used for lighter - **`model`** — default model.
tasks. Both default to `weave/glm-5.2`. - **`agents.title.model`** — model used to generate session titles (replaces deprecated `small_model`)
- **`provider.weave`** — the weave provider, using the - **`providers.weave`** — the weave provider, using the
`@ai-sdk/openai-compatible` adapter against `https://weave.redpencil.io/v1` `@opencode/ai/providers/openai-compatible` adapter against `https://weave.redpencil.io/v1`
with the key from `WEAVE_API_KEY`. with the key from `WEAVE_API_KEY`.
- **`provider.weave.models`** — the models offered in `/models`. - **`providers.weave.models`** — the models offered in `/models`.
- **`lsp`** — language servers baked into the image: - **`permissions`** — set to `ask` for read, edit, bash, and external-directory
`typescript-language-server` for TS/JS and `pyright` for Python.
- **`permission`** — set to `ask` for read, edit, bash, and external-directory
actions, so opencode prompts before acting. actions, so opencode prompts before acting.
Check-out https://opencode.ai/v2/docs/config/ for more options.
### Caveats ### Caveats
- Copy from the TUI over Docker needs the `Shift`+click / `Ctrl`+`Shift`+`C` - Copy from the TUI over Docker needs the `Shift`+click / `Ctrl`+`Shift`+`C`

View File

@@ -1,75 +1,83 @@
{ {
"$schema": "https://opencode.ai/config.json", "$schema": "https://opencode.ai/config.json",
"model": "weave/glm-5.3-flash", "model": "weave/glm-5.3-flash",
"small_model": "weave/glm-5.3-flash", "agents": {
"lsp": { "title": {
"typescript": { "model": "weave/glm-5.3-flash"
"command": [
"typescript-language-server",
"--stdio"
],
"extensions": [
".ts",
".tsx",
".js",
".jsx",
".mjs",
".cjs",
".mts",
".cts"
]
},
"pyright": {
"command": [
"pyright-langserver",
"--stdio"
],
"extensions": [
".py",
".pyi"
]
} }
}, },
"provider": { "providers": {
"weave": { "weave": {
"npm": "@ai-sdk/openai-compatible", "package": "@opencode/ai/providers/openai-compatible",
"options": { "settings": {
"baseURL": "https://weave.redpencil.io/v1", "baseURL": "https://weave.redpencil.io/v1",
"apiKey": "{env:WEAVE_API_KEY}" "apiKey": "{env:WEAVE_API_KEY}"
}, },
"models": { "models": {
"kimi-K2.7-code": { "kimi-K2.7-code": {
"capabilities": {
"tools": true "tools": true
}
}, },
"glm-5.3": { "glm-5.3": {
"capabilities": {
"tools": true "tools": true
}
}, },
"glm-5.3-flash": { "glm-5.3-flash": {
"capabilities": {
"tools": true "tools": true
}
}, },
"mistral-glm-5.2": { "mistral-glm-5.2": {
"capabilities": {
"tools": true, "tools": true,
"reasoning": true, "reasoning": {
"options": { "supported": true
}
},
"settings": {
"reasoningEffort": "xhigh" "reasoningEffort": "xhigh"
} }
}, },
"devstral": { "devstral": {
"capabilities": {
"tools": true "tools": true
}
}, },
"local-qwen3.6:27b": { "local-qwen3.6:27b": {
"capabilities": {
"tools": true "tools": true
}
}, },
"mistral-medium": { "mistral-medium": {
"capabilities": {
"tools": true "tools": true
} }
} }
} }
}
}, },
"permission": { "permissions": [
"read": "ask", {
"edit": "ask", "action": "read",
"bash": "ask", "resource": "*",
"external_directory": "ask" "effect": "ask",
} },
{
"action": "edit",
"resource": "*",
"effect": "ask",
},
{
"action": "shell",
"resource": "*",
"effect": "ask",
},
{
"action": "external_directory",
"resource": "*",
"effect": "ask",
},
],
} }

View File

@@ -1,6 +1,6 @@
services: services:
opencode: opencode:
image: redpencil/opencode:0.0.2 image: redpencil/opencode:feature-opencode-v2
volumes: volumes:
- ./data/opencode/share:/root/.local/share/opencode - ./data/opencode/share:/root/.local/share/opencode
- ./config/opencode/opencode.json:/root/.config/opencode/opencode.json - ./config/opencode/opencode.json:/root/.config/opencode/opencode.json