Add opencode skill + MCP server installation to installers#22
Merged
Conversation
opencode reads MCP configuration from ~/.config/opencode/opencode.json using a distinct schema: 'mcp' key (not 'mcpServers'), 'type: local', a single 'command' array, and explicit 'enabled: true'. Changes: - install.sh: add ~/.config/opencode/skills/devcontainer-mcp to SKILL_DIRS and write the opencode MCP entry via a dedicated configure_opencode_mcp function (preserves existing schema/model/sibling MCP entries). - install.ps1: mirror the skill directory addition and add Set-OpencodeMcpConfig that writes the wsl-bridge command array. - README.md: list opencode alongside the other supported clients. opencode has no documented PreToolUse/SessionStart hook system, so the host-protection guard and skill-loader hooks are not configured for it. Verified end-to-end inside the project's devcontainer: fresh install, idempotent rerun, and merge into a pre-existing config with sibling schema/model/MCP entries — all preserved.
7 tasks
Owner
Author
|
Follow-up issue for opencode host-protection hooks: #23 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds opencode (https://opencode.ai) as a first-class target in both installers, alongside the existing GitHub Copilot CLI, Claude Code, VS Code, and Cursor support.
Why
opencode is gaining traction as an MCP-compatible coding agent. Until now, users had to hand-edit
~/.config/opencode/opencode.jsonafter running the installer. This PR makes it just work.What changed
opencode reads MCP configuration from
~/.config/opencode/opencode.jsonusing a distinct schema from themcpServersconvention used by every other client we support:mcp(notmcpServers)"type": "local"commandis a single array (binary + args combined) — not separatecommandstring +argsarray"enabled": trueThat meant a dedicated config function in each installer rather than reusing the existing
configure_mcp_client/Set-McpConfighelpers.install.sh~/.config/opencode/skills/devcontainer-mcptoSKILL_DIRSsoSKILL.mdlands at opencode's documented global skills path.configure_opencode_mcpfunction. Creates the file if missing; otherwise merges via python3 — preserves any existing$schema,model, sibling MCP entries, and other settings.install.ps1Set-OpencodeMcpConfigthat writes the WSL-bridge form:command: ["wsl", "~/.local/bin/devcontainer-mcp", "serve"].README.mdScope note: host-protection hooks
opencode does have a hook mechanism, but it works very differently from Claude Code's
PreToolUse/SessionStart(JSON pointing at a shell script). opencode uses a JS/TS plugin system (docs) where plugins live in~/.config/opencode/plugins/and subscribe to events liketool.execute.beforeandsession.created.Wiring our
devcontainer-guard.shanddevcontainer-skill-loader.shinto that model requires writing a thin JS plugin that spawns the existing bash hooks — out of scope for this PR. Tracked as a follow-up issue.Verification
Spun up the project's own devcontainer (debian-bookworm + rust + node + docker-in-docker) and ran
install.shinside. All checks pass:~/.config/opencode/opencode.jsonwith valid schemaSKILL.mdplaced at~/.config/opencode/skills/devcontainer-mcp/$schema,mcp.devcontainer-mcp.{type,command,enabled}correct$schema,model, and a sibling MCP entrycommand[0]launches correctly (devcontainer-mcp --helpsucceeds)Sample of the file the installer produces:
{ "$schema": "https://opencode.ai/config.json", "mcp": { "devcontainer-mcp": { "type": "local", "command": ["/home/vscode/.local/bin/devcontainer-mcp", "serve"], "enabled": true } } }