opencode/packages/plugin
Luke Parker 085dee256b fix(core): list tools and evaluate calls from one ruleset
Before, a step listed tools, skills and MCP servers from
merge(agent, session) built in SessionContext.select, while calls were
evaluated from the same merge built separately in Permission. A plugin
that changed how calls were decided (the browser plugin's evaluate
hook) could not change what was listed, so the two disagreed.

Now Permission.rules(hooks, { session, agent }) is the only place that
builds the ruleset. Permission's evaluation (assert, ask,
assertNotDenied, allows), SessionContext.select (tool snapshot, Code
Mode catalog and search, skill and MCP instructions) and scheduled
code checks all use it.

Permission.rules triggers a new experimental plugin hook,
permission "experimental.rules". The hook gets the session ID, the
agent ID, the session's own rules (read-only), and the merged rules
(agent, then session). The hook can append rules, which are evaluated
last. Core does not restrict what a hook writes. Hooks are trusted in
the same way as permission.evaluate hooks, which can already set any
effect. With no hook registered, the result is the same as the old
merge.

Agent resolution changes from agents.resolve to agents.select. This
gives the same agent info, and the hook gets an agent ID even when the
default agent is used. An agent that cannot be resolved still gets
the deny-all rule.

The tool-hiding predicate (the last rule matching the action is a deny
on "*") moves to @opencode/schema/permission as deniesAll. Plugins can
then apply the same predicate as Tool.snapshot. Tool.snapshot and
Tool.check use it with the same matching as before (case-insensitive
on Windows).
2026-11-17 08:12:24 +10:00
..
script feat(plugin): add OpenCode Desktop GUI plugins (#55246) 2026-10-27 10:54:50 +10:00
src fix(core): list tools and evaluate calls from one ruleset 2026-11-17 08:12:24 +10:00
test feat(plugin): add OpenCode Desktop GUI plugins (#55246) 2026-10-27 10:54:50 +10:00
.gitignore wip: plugins 2025-08-02 18:50:19 -04:00
AGENTS.md feat(plugin): add OpenCode Desktop GUI plugins (#55246) 2026-10-27 10:54:50 +10:00
package.json release: v2.3.0 (#63719) 2026-11-13 09:04:03 +00:00
README.md chore: upgrade Effect to 4.0.1 (#54198) 2026-10-10 00:55:24 -07:00
tsconfig.build.json feat(plugin): add OpenCode Desktop GUI plugins (#55246) 2026-10-27 10:54:50 +10:00
tsconfig.json chore: upgrade typecheck to TypeScript 7.0.2 (#56300) 2026-10-17 13:26:46 -07:00

@opencode/plugin

Authoring interfaces and runtime loader support for OpenCode V2 plugins:

  • @opencode/plugin — Promise plugin API
  • @opencode/plugin/effect — Effect plugin API
  • @opencode/plugin/rpc — portable RPC contract definitions
  • @opencode/plugin/tui — terminal UI plugin API

Packaging And Runtime effect

When the OpenCode CLI loads server or TUI plugins, it resolves imports of effect, exported effect/* subpaths, and @opencode/plugin entrypoints (including imports from dependencies inside a plugin's node_modules) to the host's runtime module instances so fibers, loggers, and Schema parsers share one copy.

  • Declare "effect": "^4.0.0" as a peerDependency (and devDependency for local type-checking and testing) rather than a bundled runtime dependency.
  • Do not bundle effect into published plugin files; if you build with a bundler, keep effect and effect/* external. Two copies of effect do not share fiber, logger, or Schema internals.
  • Plugins and their node_modules dependencies always receive OpenCode's host effect instance. Use effect APIs and module paths compatible with the OpenCode release you target; dependencies built on another effect major (such as Effect 3) are not supported.
  • Only public effect subpaths are provided. A plugin that imports one of Effect's private internal modules fails to load with an error naming the path.
  • The compiled OpenCode binary does not include the Scalar and Swagger UI assets used by Effect's HTTP API docs pages; serving those pages from a plugin shows a notice instead.