Summary
Replace the single global OpenCode connection with a multi-connection model so one Emacs session can talk to several OpenCode servers.
Disclaimers and status
- Done with LLM assistance -- but with heavy couching, thorough manual cleanup, and some amount of dogfooding.
- My usage of the package is, I suspect, relatively pedestrian. Caveat emptor re: dogfooding.
- Past experience suggests high possibility of run-on fixes in coming days. :/
What changed
- New
opencode-serversdefcustom: an alist of named connections, each a plist of:host,:port,:base-url,:username,:password. Default is'((default)). - New
opencode-find-server-functiondefcustom: called with a directory, returns a server name fromopencode-servers(or nil to fall through to default resolution). opencode-host,opencode-port,opencode-server-username,opencode-server-passwordare now fallbacks foropencode-serversentries that omit the matching field. Existing single-server configs keep working unchanged.opencode--connectionstruct now carries per-connection host/port/auth.
Breaking changes / migration
opencode-file-edited-functions,opencode-files-finished-editing-functionsandopencode-project-files-finished-editing-functionsnow receive a leadingcontextargument (which is just the connection, but they don't need to know that). Existing hook functions need to add an (ignored or used) first parameter.- Users with custom
opencode-host/opencode-port/opencode-server-username/opencode-server-passwordsettings need no change — these still work as the fallback for the default((default))server entry.
## Summary
Replace the single global OpenCode connection with a multi-connection model so one Emacs session can talk to several OpenCode servers.
## Disclaimers and status
- Done with LLM assistance -- but with heavy couching, thorough manual cleanup, and some amount of dogfooding.
- My usage of the package is, I suspect, relatively pedestrian. Caveat emptor re: dogfooding.
- Past experience suggests high possibility of run-on fixes in coming days. :/
## What changed
- New `opencode-servers` defcustom: an alist of named connections, each a plist of `:host`, `:port`, `:base-url`, `:username`, `:password`. Default is `'((default))`.
- New `opencode-find-server-function` defcustom: called with a directory, returns a server name from `opencode-servers` (or nil to fall through to default resolution).
- `opencode-host`, `opencode-port`, `opencode-server-username`, `opencode-server-password` are now fallbacks for `opencode-servers` entries that omit the matching field. Existing single-server configs keep working unchanged.
- `opencode--connection` struct now carries per-connection host/port/auth.
## Breaking changes / migration
- `opencode-file-edited-functions`, `opencode-files-finished-editing-functions` and `opencode-project-files-finished-editing-functions` now receive a leading `context` argument (which is just the connection, but they don't need to know that). Existing hook functions need to add an (ignored or used) first parameter.
- Users with custom `opencode-host` / `opencode-port` / `opencode-server-username` / `opencode-server-password` settings need no change — these still work as the fallback for the default `((default))` server entry.