Research: verified opencode v2 plugin API #2

Closed
opened 2026-10-03 13:44:09 +00:00 by haylan · 1 comment
Owner

Map: #1

Question

What is the real opencode v2 plugin API per https://opencode.ai/v2/docs/plugins? Specifically: plugin entry/definition shape, how a plugin is registered and loaded in config (local path vs npm package), how plugin options are passed, whether and how a plugin can provide or replace the websearch provider, how websearch.provider is selected, and what a search result must look like. Record where the user's sketch (Plugin.define, ctx.websearch.transform, plugins[].package/options) is right or wrong.

Map: #1 ## Question What is the real opencode v2 plugin API per https://opencode.ai/v2/docs/plugins? Specifically: plugin entry/definition shape, how a plugin is registered and loaded in config (local path vs npm package), how plugin options are passed, whether and how a plugin can provide or replace the websearch provider, how `websearch.provider` is selected, and what a search result must look like. Record where the user's sketch (`Plugin.define`, `ctx.websearch.transform`, `plugins[].package/options`) is right or wrong.
haylan added the wayfinder:research label 2026-10-03 13:44:09 +00:00
haylan added a new dependency 2026-10-03 13:44:41 +00:00
haylan added a new dependency 2026-10-03 13:44:43 +00:00
Author
Owner

Research resolved (not closing): findings in docs/research/opencode-v2-plugin-api.md (uncommitted). Sketch is essentially correct: Plugin.define({id, setup(ctx)}) from @opencode/plugin, ctx.websearch.transform(editor => editor.add({id,name,execute({query},{signal}) -> [{url,title,content,time}]}); editor.default.set(id)), config key is plural 'plugins' with {package, options} (options read via ctx.options), websearch.provider selects by id. Gaps: id is required; exact TS types, 'time' shape and precedence of config provider vs editor.default.set are unverified (opencode source not inspected).

Research resolved (not closing): findings in docs/research/opencode-v2-plugin-api.md (uncommitted). Sketch is essentially correct: Plugin.define({id, setup(ctx)}) from @opencode/plugin, ctx.websearch.transform(editor => editor.add({id,name,execute({query},{signal}) -> [{url,title,content,time}]}); editor.default.set(id)), config key is plural 'plugins' with {package, options} (options read via ctx.options), websearch.provider selects by id. Gaps: id is required; exact TS types, 'time' shape and precedence of config provider vs editor.default.set are unverified (opencode source not inspected).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Blocks
#6 Grilling: packaging and distribution
haylan/fastcrw-opencode-websearch
Reference: haylan/fastcrw-opencode-websearch#2