Help us shape the future of Go! Take the 2026 Go Developer Survey

opencode

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 11 Imported by: 0

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

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

func (Adapter) Detect(env install.Env) bool

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

func (Adapter) InstallPlan(env install.Env, opts adapters.InstallOptions) (install.Plan, error)

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) Name

func (Adapter) Name() hookapi.Agent

Name returns the --agent identifier.

func (Adapter) Notes

func (Adapter) Notes(env install.Env) []string

Notes returns post-install reminders.

func (Adapter) ParseEvent

func (Adapter) ParseEvent(event hookapi.Event, raw []byte, _ []string) (hookapi.HookEvent, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL