7 Commits

Author SHA1 Message Date
b0e2b6eeb8 introduce separate weave-proxy service which holds the API key
This prevents opencode from having access to the `WEAVE_API_KEY` enviroment variable.
2026-10-20 13:56:08 +02:00
b98130e648 bump opencode container to 0.0.2
provides more tools in the base image
2026-10-07 07:32:31 +00:00
581e5ed5ac make glm-5.3-flash the default 2026-10-06 11:11:01 +00:00
ca7eaf3776 update model config
- made glm-5.3 the default
- added glm-5.3-flash as the small default
- replaced glm-5.2 with mistral glm-5.2
- dropped sonnet
2026-09-08 11:46:44 +02:00
4b430129e6 Revert "run opencode in "interactive shell" mode"
This reverts commit 520943689a.
2026-09-08 11:36:54 +02:00
520943689a run opencode in "interactive shell" mode
this should resolve any clipboard issues with copying and pasting text
2026-07-07 12:05:59 +00:00
5b240e8d95 improve readme readability and add some tutorials 2026-07-06 12:55:36 +02:00
4 changed files with 36 additions and 56 deletions

View File

@@ -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**
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
A first run from a clean checkout.
@@ -26,9 +22,10 @@ A first run from a clean checkout.
```yaml
services:
opencode:
weave-proxy:
environment:
WEAVE_API_KEY: "your-key-here"
opencode:
volumes:
- /path/to/your/repo:/workspace/repo
```
@@ -114,23 +111,9 @@ networks:
```
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 —
no `ports:` publishing needed.
name** from that stack's compose and `<port>` is the container's *internal* port.
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.
> Note: Bring the opencode stack up first, so `app-opencode_default` exists before adding to your app.
## Reference
@@ -139,8 +122,7 @@ A few things that differ from a normal host, because the daemon lives in dind:
- **`model` / `small_model`** — default model and the model used for lighter
tasks. Both default to `weave/glm-5.2`.
- **`provider.weave`** — the weave provider, using the
`@ai-sdk/openai-compatible` adapter against `https://weave.redpencil.io/v1`
with the key from `WEAVE_API_KEY`.
`@ai-sdk/openai-compatible` adapter against `http://weave-proxy/v1`.
- **`provider.weave.models`** — the models offered in `/models`.
- **`lsp`** — language servers baked into the image:
`typescript-language-server` for TS/JS and `pyright` for Python.

View File

@@ -0,0 +1,11 @@
server {
listen 80;
location / {
proxy_pass https://weave.redpencil.io;
proxy_ssl_server_name on;
proxy_set_header Host weave.redpencil.io;
proxy_set_header Authorization "Bearer ${WEAVE_API_KEY}";
proxy_buffering off; # SSE streaming
proxy_read_timeout 600s; # match opencode's 5-min defaults
}
}

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://opencode.ai/config.json",
"model": "weave/glm-5.2",
"small_model": "weave/glm-5.2",
"model": "weave/glm-5.3-flash",
"small_model": "weave/glm-5.3-flash",
"lsp": {
"typescript": {
"command": [
@@ -34,16 +34,26 @@
"weave": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://weave.redpencil.io/v1",
"apiKey": "{env:WEAVE_API_KEY}"
"baseURL": "http://weave-proxy/v1",
"apiKey": "not-needed"
},
"models": {
"kimi-K2.7-code": {
"tools": true
},
"glm-5.2": {
"glm-5.3": {
"tools": true
},
"glm-5.3-flash": {
"tools": true
},
"mistral-glm-5.2": {
"tools": true,
"reasoning": true,
"options": {
"reasoningEffort": "xhigh"
}
},
"devstral": {
"tools": true
},
@@ -52,9 +62,6 @@
},
"mistral-medium": {
"tools": true
},
"claude-sonnet": {
"tools": true
}
}
}

View File

@@ -1,30 +1,10 @@
services:
weave-proxy:
image: nginx:1.31.7-alpine
volumes:
- ./config/nginx/templates:/etc/nginx/templates:ro
opencode:
image: redpencil/opencode:feature-with-docker
image: redpencil/opencode:0.0.2
volumes:
- ./data/opencode/share:/root/.local/share/opencode
- ./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