Documentation
¶
Overview ¶
Package opencode integrates graphmaster with OpenCode (v1.x).
OpenCode has no command hooks; it loads JavaScript plugins instead. The adapter therefore installs a small generated plugin (~/.config/opencode/plugins/graphmaster.js) that spawns `graphmaster hook <event> --agent opencode` and speaks a private JSON protocol with it (see hookio.go). Because graphmaster writes both ends, the wire format is ours; OpenCode only defines what the plugin can do:
- tool.execute.before can block a call (throw) or rewrite its args;
- tool.execute.after and bus events (session.created, file.edited) are notifications only;
- experimental.session.compacting can append context to the compaction prompt. Nothing else can inject context without denying.
Index ¶
- type Adapter
- func (Adapter) Detect(env install.Env) bool
- func (Adapter) InstallPlan(env install.Env, opts adapters.InstallOptions) (install.Plan, error)
- func (Adapter) Name() hookapi.Agent
- func (Adapter) Notes(env install.Env) []string
- func (Adapter) ParseEvent(event hookapi.Event, raw []byte, _ []string) (hookapi.HookEvent, error)
- func (Adapter) RenderDecision(ev hookapi.HookEvent, d hookapi.Decision) adapters.HookOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct{}
Adapter implements adapters.Agent for OpenCode.
func (Adapter) Detect ¶
Detect reports whether OpenCode appears installed: its global config directory exists, the install script's binary (~/.opencode/bin) exists, or an opencode executable is on PATH.
func (Adapter) InstallPlan ¶
InstallPlan registers the MCP server in the global OpenCode config, generates the hook plugin and adds the instruction block to the global AGENTS.md.
func (Adapter) ParseEvent ¶
ParseEvent converts a plugin payload into the neutral event.
func (Adapter) RenderDecision ¶
RenderDecision converts a decision into the plugin's reply. Only pre-tool-use can block or rewrite input, and only pre-compact can carry context; everything else degrades to "no opinion" so a notification can never block OpenCode. "ask" has no plugin equivalent and is dropped.