Repository navigation
[plugin] Add OpenCode 2 support - #314
Merged
Merged
Conversation
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.
vvo
marked this pull request as ready for review
October 7, 2026 14:36
Melkeydev
approved these changes
Oct 8, 2026
…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
approved these changes
Oct 8, 2026
Merged
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.
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
vercel-pluginnpm name is a placeholder (#69).Solution
/vercel:deploy,/vercel:env,/vercel:status,/vercel:bootstrap, and the Vercel MCP server.opencodeharness value.buildscript tobuild:all, because OpenCode 2 can't install a Git package that has abuildscript.Implementation details
hooks/src/opencode-plugin.mtscompiles tohooks/opencode-plugin.mjs, whichpackage.jsonexportspoints 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.contexthook 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 theinject-claude-mdoutput byte for byte. The CLI check is async, cached for an hour, and a session waits at most 3s for it.skills/folder without anexternal_directoryprompt, since skills point at reference files in the plugin's install directory. Telemetry counts only the plugin's own copy of a skill and honorsVERCEL_PLUGIN_TELEMETRY=offand atelemetry: falseplugin option. Theopencodeharness value needs no server change, the same waykimiandgrokshipped.build,prepareor install script by spawning the opencode binary instead of npm, so the install fails (anomalyco/opencode#49704). Reproduced with a 2-file repo.opencode serve2.0.24 with a fake model provider, installing this branch throughopencode plugin add: 19/19 checks pass. Also used on a real setup with a real model: session context, skill loads, reference reads and/vercel:statusall work.