opencode-plugin-development

Build and audit OpenCode plugins and SDK bridges against source-verified API contracts.

1|Updated Mar 15, 2025
One-click install
npx skills add https://github.com/adikpb/dotfiles --skill opencode-plugin-development-adikpb
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: opencode-plugin-development
Source: https://github.com/adikpb/dotfiles/tree/main/.hermes/skills/autonomous-ai-agents/opencode-plugin-development
Command: npx skills add https://github.com/adikpb/dotfiles --skill opencode-plugin-development-adikpb

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @opencode-ai/sdk, @opencode-ai/plugin, and includes references (resource) components.

What problem does it solve? Building plugins or programmatic bridges against OpenCode's HTTP API fails when developers trust documentation over source: routes drift between v1 and v2 surfaces, declared endpoints turn out to be 503 stubs, and SSE streams behave differently per schema. This Skill encodes source-verified wire contracts, migration audit loops, and integration pitfalls so a Hermes-to-OpenCode bridge works against the real server behavior. ## Core Features & Use Cases - Source-first API verification: Pin the opencode repo tag, diff intended wire calls against packages/sdk/openapi.json, and distinguish route declaration from handler implementation before writing any client code. - v1/v2 surface navigation: Know which endpoints genuinely work (v2 interrupt, replay stream) versus stubs (/api/session/{id}/wait always 503s) and which event families exist on each of the three SSE surfaces. - Iterative migration audits: Run looped multi-agent fan-out audits (source/tests, docs, wire-shape lenses) that re-dispatch until zero findings confirm a v1-only migration left no residue. - Use Case: When migrating a Hermes-OpenCode bridge plugin from the v2 API back to v1-only, use this Skill to grep for deleted route names across code and docs, verify payload field names like messageID against the OpenAPI spec, and prove correctness with simulated event-sequence tests. ## Quick Start Use the opencode-plugin-development skill to verify my plugin's session prompt calls against the v1.18.13 OpenAPI spec and audit for leftover v2 API usage.

Frequently Asked Questions about opencode-plugin-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build an OpenCode plugin with the plugin API?▼

A v1 plugin is a function taking PluginInput (client, project, directory, serverUrl, shell) and returning a Hooks object with fields like tool, config, event, and chat.message. Local path plugins must export an id; npm plugins use the package name. Verify hook trigger call-sites in the opencode source at your target tag.

How do I inject messages into an OpenCode session programmatically?▼

Use client.session.prompt from @opencode-ai/sdk with a parts-based body containing TextPartInput, FilePartInput, or AgentPartInput entries posted to the session message endpoint. Plugin-injected clients take precedence over TUI append methods for message injection.

What is the difference between OpenCode v1 and v2 API surfaces?▼

V1 and v2 use separate permission stores, different event families, and different prompt body shapes; v2 prompt takes a prompt object while legacy takes parts. Several v2 routes are declared but stubbed with 503 errors, so verify each endpoint in openapi.json and handler code before adopting it.

Why does my OpenCode SSE event stream hang or die silently?▼

The v2 /api/event stream throws a schema encode error and kills the connection when legacy events like session.status cross the shared bus. Also, Python http.client read(n) aggregates chunks and blocks on quiet streams; use read1() for per-chunk reads, and pass the directory as a query parameter rather than a header.

How do I audit a plugin migration for leftover v2 API usage?▼

Grep for deleted method names, routes, event families, and output fields across all files including scripts, since unit tests miss e2e helpers. Classify each mention as executable code path, stale documentation, or allowed explanatory reference, then re-dispatch the audit until a round returns zero findings.

Can I rely on the OpenCode wait endpoint for blocking handoffs?▼

No. The session wait route is a declared but stubbed endpoint that always returns 503. Blocking handoffs must watch for session.status idle events on the legacy event stream or poll the session status map, where an absent entry means idle.