forked from ai-tools/app-opencode
Compare commits
12 Commits
feature/do
...
feature/op
| Author | SHA1 | Date | |
|---|---|---|---|
| 218dc1d0d1 | |||
| 9246decc9f | |||
| 1ce6cea6c9 | |||
| 5b7c1f98bd | |||
| 5bd2eb398e | |||
| 3e373104e7 | |||
| b98130e648 | |||
| 581e5ed5ac | |||
| ca7eaf3776 | |||
| 4b430129e6 | |||
| 520943689a | |||
| 5b240e8d95 |
48
README.md
48
README.md
@@ -9,10 +9,6 @@ The docs below are split into three parts: a **Getting started** walkthrough to
|
|||||||
run it the first time, **How-to guides** for specific tasks, and a **Reference**
|
run it the first time, **How-to guides** for specific tasks, and a **Reference**
|
||||||
for the moving parts.
|
for the moving parts.
|
||||||
|
|
||||||
> `drc` in the examples is shorthand for `docker compose`
|
|
||||||
> (`alias drc='docker compose'`). Substitute `docker compose` if you don't have
|
|
||||||
> the alias.
|
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
A first run from a clean checkout.
|
A first run from a clean checkout.
|
||||||
@@ -58,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:
|
||||||
|
|
||||||
@@ -71,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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,39 +114,25 @@ networks:
|
|||||||
```
|
```
|
||||||
|
|
||||||
opencode can then reach it at `http://app:<port>`, where `app` is the **service
|
opencode can then reach it at `http://app:<port>`, where `app` is the **service
|
||||||
name** from that stack's compose and `<port>` is the container's *internal* port —
|
name** from that stack's compose and `<port>` is the container's *internal* port.
|
||||||
no `ports:` publishing needed.
|
|
||||||
|
|
||||||
Note: Bring the opencode stack up first, so `app-opencode_default` exists before adding to your app.
|
> Note: Bring the opencode stack up first, so `app-opencode_default` exists before adding to your app.
|
||||||
|
|
||||||
### Executing docker commands from opencode
|
|
||||||
The stack runs a dedicated dind (docker in docker) container, and opencode can drive it as a client (`DOCKER_HOST=tcp://dind:2375`). So from inside opencode you can build images, run containers, and `docker compose up` a project's stack. The agent can spin up and test the services it's working on.
|
|
||||||
|
|
||||||
A few things that differ from a normal host, because the daemon lives in dind:
|
|
||||||
|
|
||||||
- Containers and published ports you start run on the **dind** daemon. Reach a running service at `dind:<port>`, **not** `localhost:<port>`. opencode does not
|
|
||||||
share dind's network namespace, so `localhost` won't reach the stack.
|
|
||||||
- The repo needs to be mounted at the same absolute path (`/workspace/repo`) in both the opencode and dind containers, so compose bind-mounts resolve correctly. Work on the checkout there; edits elsewhere won't be visible to the containers dind runs.
|
|
||||||
- The dind image store is cached in `./data/dind-cache`, so pulled images stay warm across restarts.
|
|
||||||
- To access the services from the host machine, you will need to connect to the dind container or publish the necessary ports from the dind container to your host.
|
|
||||||
|
|
||||||
> Note: Opencode itself doesn't run in a privileged container so it can't do privileged actions directly, but it can use the docker daemon in dind to do the same things. Because dind is privileged and in the host user namespace, a container started inside dind can mount the host's raw disk devices and reach the **entire** host filesystem, not only what you shared. This needs opencode to actively do it, but it's a well-known technique, not a theoretical edge case.
|
|
||||||
|
|
||||||
## Reference
|
## Reference
|
||||||
|
|
||||||
### `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`
|
||||||
|
|||||||
@@ -1,68 +1,83 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://opencode.ai/config.json",
|
"$schema": "https://opencode.ai/config.json",
|
||||||
"model": "weave/glm-5.2",
|
"model": "weave/glm-5.3-flash",
|
||||||
"small_model": "weave/glm-5.2",
|
"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.2": {
|
"glm-5.3": {
|
||||||
|
"capabilities": {
|
||||||
"tools": true
|
"tools": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"glm-5.3-flash": {
|
||||||
|
"capabilities": {
|
||||||
|
"tools": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mistral-glm-5.2": {
|
||||||
|
"capabilities": {
|
||||||
|
"tools": true,
|
||||||
|
"reasoning": {
|
||||||
|
"supported": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"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": {
|
||||||
"tools": true
|
"capabilities": {
|
||||||
},
|
|
||||||
"claude-sonnet": {
|
|
||||||
"tools": true
|
"tools": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"permission": {
|
|
||||||
"read": "ask",
|
|
||||||
"edit": "ask",
|
|
||||||
"bash": "ask",
|
|
||||||
"external_directory": "ask"
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"action": "read",
|
||||||
|
"resource": "*",
|
||||||
|
"effect": "ask",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "edit",
|
||||||
|
"resource": "*",
|
||||||
|
"effect": "ask",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "shell",
|
||||||
|
"resource": "*",
|
||||||
|
"effect": "ask",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "external_directory",
|
||||||
|
"resource": "*",
|
||||||
|
"effect": "ask",
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
@@ -1,30 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
opencode:
|
opencode:
|
||||||
image: redpencil/opencode:feature-with-docker
|
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
|
||||||
# - ./config/opencode:/root/.config/opencode
|
|
||||||
depends_on:
|
|
||||||
dind:
|
|
||||||
condition: service_healthy
|
|
||||||
environment:
|
|
||||||
DOCKER_HOST: "tcp://dind:2375"
|
|
||||||
|
|
||||||
dind:
|
|
||||||
image: docker:29.6-dind
|
|
||||||
privileged: true
|
|
||||||
# userns mode only required if you use user namespaces
|
|
||||||
userns_mode: "host"
|
|
||||||
environment:
|
|
||||||
DOCKER_TLS_CERTDIR: ""
|
|
||||||
volumes:
|
|
||||||
- ./data/dind-cache:/var/lib/docker
|
|
||||||
command:
|
|
||||||
- "--registry-mirror=https://docker-registry-mirror.redpencil.io"
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "docker", "info"]
|
|
||||||
interval: 5s
|
|
||||||
timeout: 3s
|
|
||||||
retries: 20
|
|
||||||
start_period: 10s
|
|
||||||
|
|||||||
Reference in New Issue
Block a user