Skip to content

[plugin] Add OpenCode 2 support - #314

Merged
molebox merged 5 commits into
mainfrom
vincentvoyer/opencode-2-plugin
Oct 8, 2026
Merged

molebox merged 5 commits into
mainfrom
vincentvoyer/opencode-2-plugin

Conversation

@vvo

@vvo vvo commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

tl;dr; lets OpenCode 2 users install the Vercel plugin with opencode plugin add github:vercel/vercel-plugin, by adding a native OpenCode entry that reuses the plugin's existing skills, commands, agents, MCP config and session hooks.

Problem

  • OpenCode users can't install the plugin: the repo has no OpenCode entry and the vercel-plugin npm name is a placeholder (#69).
  • Teams that run agents across Claude Code, Codex and OpenCode have to leave OpenCode out when they use the plugin.

Solution

  • OpenCode 2 gets all 33 skills, the 3 agents as subagents, /vercel:deploy, /vercel:env, /vercel:status, /vercel:bootstrap, and the Vercel MCP server.
  • Vercel, Next.js, eve and empty projects get the same session-start context as in Claude Code, including the missing or outdated Vercel CLI notice.
  • Skill telemetry works like Claude's, tagged with a new opencode harness value.
  • We renamed the build script to build:all, because OpenCode 2 can't install a Git package that has a build script.
Implementation details
  • hooks/src/opencode-plugin.mts compiles to hooks/opencode-plugin.mjs, which package.json exports points at. It runs inside the long-lived OpenCode server and imports the hook modules instead of spawning them. Existing hooks only gain a few exports and the harness value.
  • Session context is a context hook computed once per lead session and reused verbatim, so the system prompt stays cache-friendly. Child sessions get none, like Claude subagents. A test checks it matches the inject-claude-md output byte for byte. The CLI check is async, cached for an hour, and a session waits at most 3s for it.
  • User skills, agents and MCP servers with the same ID win over the plugin's. Agents may read the plugin's own skills/ folder without an external_directory prompt, since skills point at reference files in the plugin's install directory. Telemetry counts only the plugin's own copy of a skill and honors VERCEL_PLUGIN_TELEMETRY=off and a telemetry: false plugin option. The opencode harness value needs no server change, the same way kimi and grok shipped.
  • OpenCode 2.0.24's bundled npm "prepares" Git deps that have a build, prepare or install script by spawning the opencode binary instead of npm, so the install fails (anomalyco/opencode#49704). Reproduced with a 2-file repo.
  • Verified on a real opencode serve 2.0.24 with a fake model provider, installing this branch through opencode plugin add: 19/19 checks pass. Also used on a real setup with a real model: session context, skill loads, reference reads and /vercel:status all work.

vvo added 4 commits October 7, 2026 15:51
Ship a native OpenCode 2 plugin entry (hooks/opencode-plugin.mjs, loaded
through package.json exports) that registers the same skills, commands,
agents and Vercel MCP server as the Claude Code plugin, turns the
SessionStart profiler and inject-claude-md output into a per-session
context hook, and reports skill:invoked with an opencode harness.

Install: opencode plugin add github:vercel/vercel-plugin
A package.json `build` script makes npm "prepare" Git installs, and
OpenCode 2's bundled npm cannot run that step, so
`opencode plugin add github:vercel/vercel-plugin` failed.
Keep only the entry point exported, store the telemetry session ID with
the session state, run the Vercel CLI check only when the profiler would,
and skip SSE servers, which OpenCode cannot connect to. Tests now go
through the plugin itself, including the real CLI check against stub
binaries.
…prompt

Skills point at reference files in the plugin's install directory, which
is outside the project, so OpenCode asked for external_directory
permission on every read. Found while using the preview.
@molebox
molebox merged commit 2a1e58d into main Oct 8, 2026
5 checks passed
@molebox
molebox deleted the vincentvoyer/opencode-2-plugin branch October 8, 2026 08:10
@molebox molebox mentioned this pull request Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants