From 92502ef36371366fd57000218974b8a064eb2070 Mon Sep 17 00:00:00 2001 From: Kristof Lemmens Date: Wed, 21 Oct 2026 11:03:14 +0200 Subject: [PATCH 1/5] docs: explain how to update the plugin in opencode opencode reuses its cached copy of a plugin package and never checks for a newer version, so pin the version and bump it; and a short-lived command can exit before the install finishes. Co-Authored-By: Claude Opus 5.5 --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index fb99118..b39ab5e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,20 @@ The tier only steers the router; the chosen model runs with its normal settings. Sign in to GitHub Copilot in opencode as usual; the plugin uses that connection. +### Updating + +opencode installs a plugin package once and keeps using the cached copy: it does not +look for newer versions, not even for an unversioned name. Pin the version and bump it +to update: + +```jsonc +{ "plugin": ["@klconsultancy/opencode-copilot-auto@1.0.1"] } +``` + +opencode installs a new version on the next start. Start the TUI for that: a +short-lived command such as `opencode run` or `opencode models` can exit before the +install finishes, and then the plugin is missing for that run. + From a local checkout (`bun install && bun run build`), use the `dist` directory for opencode 2 (it only accepts a directory) and `dist/index.js` for opencode 1. From 0758e16ebc48e33c82c7cc02ec71d8c41e54e115 Mon Sep 17 00:00:00 2001 From: Kristof Lemmens Date: Wed, 21 Oct 2026 11:48:24 +0200 Subject: [PATCH 2/5] chore: add a devcontainer with both opencode lines, and pin bun with mise - .devcontainer: Node 24 image with bun 1.4.3, opencode 1.19.2 and opencode 2.0.30 in separate prefixes. `oc1` / `oc2` start each with its own config, login and logs under ~/.oc (a volume), loading the plugin from dist/; `plugin-log 1|2` follows the plugin log. xdg-open prints URLs for the device login. - .mise.toml pins bun 1.4.3, as in CI. - CI builds the devcontainer and checks that both opencode versions start and opencode 2 loads the plugin build. - README: development setup. Co-Authored-By: Claude Opus 5.5 --- .devcontainer/Dockerfile | 22 ++++++++++++++++++++++ .devcontainer/bin/oc1 | 14 ++++++++++++++ .devcontainer/bin/oc2 | 14 ++++++++++++++ .devcontainer/bin/plugin-log | 10 ++++++++++ .devcontainer/devcontainer.json | 12 ++++++++++++ .github/workflows/ci.yml | 15 +++++++++++++++ .mise.toml | 3 +++ README.md | 21 +++++++++++++++++++++ 8 files changed, 111 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100755 .devcontainer/bin/oc1 create mode 100755 .devcontainer/bin/oc2 create mode 100755 .devcontainer/bin/plugin-log create mode 100644 .devcontainer/devcontainer.json create mode 100644 .mise.toml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..1097e0e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,22 @@ +FROM mcr.microsoft.com/devcontainers/javascript-node:5-24-bookworm + +ARG BUN_VERSION=1.4.3 +ARG OPENCODE1_VERSION=1.19.2 +ARG OPENCODE2_VERSION=2.0.30 + +# Both opencode packages install an `opencode` command, so each gets its own prefix; +# oc1 and oc2 pick the right one. +RUN npm install -g bun@${BUN_VERSION} \ + && npm install -g --prefix /opt/opencode1 opencode-ai@${OPENCODE1_VERSION} \ + && npm install -g --prefix /opt/opencode2 @opencode/cli@${OPENCODE2_VERSION} \ + && npm cache clean --force + +# No browser in the container: Copilot's device login prints the URL instead. +RUN printf '#!/bin/sh\necho "open in your browser: $*" >&2\n' > /usr/local/bin/xdg-open \ + && chmod +x /usr/local/bin/xdg-open + +COPY bin/ /usr/local/bin/ + +# Logins, sessions and plugin logs of both opencode versions; a volume keeps them +# across rebuilds. +RUN mkdir -p /home/node/.oc && chown node:node /home/node/.oc diff --git a/.devcontainer/bin/oc1 b/.devcontainer/bin/oc1 new file mode 100755 index 0000000..7e05d4e --- /dev/null +++ b/.devcontainer/bin/oc1 @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# opencode 1 with this repo's plugin build (dist/index.js), isolated in ~/.oc/1. +# Run `bun run build` (or `bun run dev`) first. Plugin options go in +# ~/.oc/1/config/opencode/opencode.json. +set -euo pipefail +root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)" +home="$HOME/.oc/1" +export XDG_CONFIG_HOME="$home/config" XDG_DATA_HOME="$home/data" XDG_STATE_HOME="$home/state" XDG_CACHE_HOME="$home/cache" +config="$XDG_CONFIG_HOME/opencode/opencode.json" +if [ ! -f "$config" ]; then + mkdir -p "$(dirname "$config")" + printf '{\n "$schema": "https://opencode.ai/config.json",\n "plugin": [["%s/dist/index.js", {}]]\n}\n' "$root" > "$config" +fi +exec /opt/opencode1/bin/opencode "$@" diff --git a/.devcontainer/bin/oc2 b/.devcontainer/bin/oc2 new file mode 100755 index 0000000..0d06cec --- /dev/null +++ b/.devcontainer/bin/oc2 @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# opencode 2 with this repo's plugin build (the dist directory: opencode 2 only +# loads local plugins from a directory), isolated in ~/.oc/2. Run `bun run build` +# (or `bun run dev`) first. Plugin options go in ~/.oc/2/config/opencode/opencode.json. +set -euo pipefail +root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)" +home="$HOME/.oc/2" +export XDG_CONFIG_HOME="$home/config" XDG_DATA_HOME="$home/data" XDG_STATE_HOME="$home/state" XDG_CACHE_HOME="$home/cache" +config="$XDG_CONFIG_HOME/opencode/opencode.json" +if [ ! -f "$config" ]; then + mkdir -p "$(dirname "$config")" + printf '{\n "$schema": "https://opencode.ai/config.json",\n "plugins": [{ "package": "%s/dist", "options": {} }]\n}\n' "$root" > "$config" +fi +exec /opt/opencode2/bin/opencode2 "$@" diff --git a/.devcontainer/bin/plugin-log b/.devcontainer/bin/plugin-log new file mode 100755 index 0000000..a074270 --- /dev/null +++ b/.devcontainer/bin/plugin-log @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Follow the plugin log of opencode 1 or 2 in this devcontainer: plugin-log 1|2 +set -euo pipefail +case "${1:-}" in + 1|2) ;; + *) echo "usage: plugin-log 1|2" >&2; exit 2 ;; +esac +log="$HOME/.oc/$1/state/opencode-copilot-auto/plugin.log" +mkdir -p "$(dirname "$log")" && touch "$log" +exec tail -n 50 -F "$log" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..12b961a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,12 @@ +{ + "name": "opencode-copilot-auto", + "build": { "dockerfile": "Dockerfile", "context": "." }, + "remoteUser": "node", + "mounts": ["source=opencode-copilot-auto-oc,target=/home/node/.oc,type=volume"], + "postCreateCommand": "bun install && bun run build", + "customizations": { + "vscode": { + "extensions": ["oven.bun-vscode"] + } + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24f64ba..afcddd0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,3 +20,18 @@ jobs: - run: bun run typecheck - run: bun run build - run: bun test + + devcontainer: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - run: docker build -t devcontainer .devcontainer + # Both opencode versions start and see the plugin build. + - run: | + docker run --rm -u node -v "$PWD:/workspaces/repo" -w /workspaces/repo devcontainer bash -euc ' + git config --global --add safe.directory /workspaces/repo + bun install --frozen-lockfile && bun run build + oc1 --version + oc2 --version + oc2 models --standalone --print-logs --log-level info 2>&1 | grep "loading plugin" + ' diff --git a/.mise.toml b/.mise.toml new file mode 100644 index 0000000..a61fec6 --- /dev/null +++ b/.mise.toml @@ -0,0 +1,3 @@ +# Same bun as CI and the devcontainer. +[tools] +bun = "1.4.3" diff --git a/README.md b/README.md index b39ab5e..d6e95a0 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,27 @@ request model gpt-5.4 -> gpt-6-luna ## Development +The repo pins bun 1.4.3 in `.mise.toml` (for [mise](https://mise.jdx.dev)) and in CI. + +### Devcontainer + +`.devcontainer/` gives a container with bun and both opencode lines side by side, +isolated from any opencode you use day to day: + +| Command | Runs | Loads the plugin from | +|---------|------|------------------------| +| `oc1` | opencode 1.19.2 | `dist/index.js` | +| `oc2` | opencode 2.0.30 | `dist/` (opencode 2 only loads a directory) | +| `plugin-log 1` / `plugin-log 2` | follows that version's plugin log | | + +Each keeps its own config, login and logs under `~/.oc/1` or `~/.oc/2`, on a volume that +survives rebuilds. Sign in to Copilot once per version (`oc1 auth login`, `oc2 auth +login github-copilot`); the device login prints a URL to open on the host. Plugin options +go in `~/.oc/<1|2>/config/opencode/opencode.json`. Run `bun run dev` to rebuild `dist/` on +every change. + +### Commands + ```sh bun install bun run typecheck From 5032592506fbdbd2594c369beb415188dc6ce22e Mon Sep 17 00:00:00 2001 From: Kristof Lemmens Date: Wed, 21 Oct 2026 11:55:42 +0200 Subject: [PATCH 3/5] ci: run the devcontainer check on a copy of the checkout The checkout belongs to the runner's user, so `node` in the container could not write node_modules; work on a copy instead. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afcddd0..bc406ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,11 +26,13 @@ jobs: steps: - uses: actions/checkout@v7 - run: docker build -t devcontainer .devcontainer - # Both opencode versions start and see the plugin build. + # Both opencode versions start and see the plugin build. The checkout belongs to + # the runner's user, so the container works on a copy as `node`. - run: | - docker run --rm -u node -v "$PWD:/workspaces/repo" -w /workspaces/repo devcontainer bash -euc ' - git config --global --add safe.directory /workspaces/repo - bun install --frozen-lockfile && bun run build + docker run --rm -u node -v "$PWD:/src:ro" devcontainer bash -euc ' + cp -r /src ~/repo && cd ~/repo + bun install --frozen-lockfile + bun run build oc1 --version oc2 --version oc2 models --standalone --print-logs --log-level info 2>&1 | grep "loading plugin" From 92b5f982f42bbde0b0fdfba59d7a943dceba5497 Mon Sep 17 00:00:00 2001 From: Kristof Lemmens Date: Wed, 21 Oct 2026 13:14:10 +0200 Subject: [PATCH 4/5] chore: add Dependabot for dev dependencies, actions and the devcontainer image Co-Authored-By: Claude Opus 5.5 --- .github/dependabot.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0bd56cd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,40 @@ +# Only dev dependencies, actions and the devcontainer image: none of these updates +# changes the published package, so the commit prefixes (chore/ci) cut no release. +version: 2 +updates: + - package-ecosystem: bun + directory: / + schedule: + interval: weekly + cooldown: + default-days: 7 + commit-message: + prefix: chore + include: scope + groups: + # The plugin types and the SDK are released together; keep them in step. + opencode: + patterns: ["@opencode-ai/*", "@opencode/*"] + dev-tools: + patterns: ["*"] + + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + cooldown: + default-days: 7 + commit-message: + prefix: ci + include: scope + groups: + actions: + patterns: ["*"] + + - package-ecosystem: docker + directory: /.devcontainer + schedule: + interval: weekly + commit-message: + prefix: chore + include: scope From cc969234fa15754b64574d5b1eb7c7af9b18cac5 Mon Sep 17 00:00:00 2001 From: Kristof Lemmens Date: Wed, 21 Oct 2026 13:14:28 +0200 Subject: [PATCH 5/5] chore: keep mise config local Co-Authored-By: Claude Opus 5.5 --- .gitignore | 2 ++ .mise.toml | 3 --- README.md | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 .mise.toml diff --git a/.gitignore b/.gitignore index f06235c..2f91b00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules dist +.mise.toml +.mise.local.toml diff --git a/.mise.toml b/.mise.toml deleted file mode 100644 index a61fec6..0000000 --- a/.mise.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Same bun as CI and the devcontainer. -[tools] -bun = "1.4.3" diff --git a/README.md b/README.md index d6e95a0..a206bfc 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ request model gpt-5.4 -> gpt-6-luna ## Development -The repo pins bun 1.4.3 in `.mise.toml` (for [mise](https://mise.jdx.dev)) and in CI. +CI and the devcontainer use bun 1.4.3. ### Devcontainer