一键导入
opencode-plugin
Build plugins for OpenCode. Use only when the user explicitly invokes `opencode-plugin` or `$opencode-plugin`; do not auto-invoke from context.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Build plugins for OpenCode. Use only when the user explicitly invokes `opencode-plugin` or `$opencode-plugin`; do not auto-invoke from context.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
A relentless interview to sharpen a plan or design, maintain the domain language, and chart large efforts until their route is clear. Use only when the user explicitly invokes `grill` or `$grill`; do not auto-invoke from context.
Implement a piece of work based on a spec or set of tickets. Use only when the user explicitly invokes `implement` or `$implement`; do not auto-invoke from context.
Turn the current conversation into a spec and save it under .scratch/specs/ — no interview, just synthesis of what you've already discussed. Use only when the user explicitly invokes `to-spec` or `$to-spec`; do not auto-invoke from context.
Break a plan, spec, or the current conversation into tracer-bullet tickets under .scratch/, each declaring its blocking edges. Use only when the user explicitly invokes `to-tickets` or `$to-tickets`; do not auto-invoke from context.
Save a brief Architecture Decision Record (ADR) from the current session. Use only when the user explicitly invokes `adr` or `$adr`; do not auto-invoke from context.
Build extensions for Pi. Use only when the user explicitly invokes `pi-extension` or `$pi-extension`; do not auto-invoke from context.
基于 SOC 职业分类
| name | opencode-plugin |
| description | Build plugins for OpenCode. Use only when the user explicitly invokes `opencode-plugin` or `$opencode-plugin`; do not auto-invoke from context. |
Manual invocation only: use this skill only when the user explicitly invokes opencode-plugin or $opencode-plugin; do not auto-invoke from task context.
Build opencode plugins that extend server behavior with hooks/tools/auth/providers or extend the terminal UI with commands, routes, slots, notifications, themes, and keymaps.
import type { Plugin, PluginModule } from "@opencode-ai/plugin"
import { tool } from "@opencode-ai/plugin"
const server: Plugin = async ({ client, project, directory }) => ({
tool: {
greet: tool({
description: "Greet someone by name",
args: { name: tool.schema.string() },
async execute(args, context) {
context.metadata({ title: `Greeting ${args.name}` })
return `Hello ${args.name} from ${context.directory}`
},
}),
},
})
export default { id: "acme.server", server } satisfies PluginModule & { id: string }
import type { TuiPlugin, TuiPluginModule } from "@opencode-ai/plugin/tui"
const tui: TuiPlugin = async (api, options, meta) => {
api.keymap.registerLayer({
mode: "base",
commands: [{ name: "acme.hello", title: "Hello", category: "Plugin", namespace: "palette", run: () => api.ui.toast({ message: `Hello from ${meta.id}` }) }],
bindings: [{ key: "ctrl+shift+h", cmd: "acme.hello", desc: "Say hello" }],
})
}
export default { id: "acme.tui", tui } satisfies TuiPluginModule & { id: string }
{ id?, server } or { id?, tui }, never both.Plugin/PluginModule from @opencode-ai/plugin and TuiPlugin/TuiPluginModule from @opencode-ai/plugin/tui.id; npm plugins may omit id and fall back to package name.input, mutate output in place, and return void.experimental.* hooks may change between versions.api.keymap.registerLayer over deprecated api.command.prompts[].condition is deprecated. Use when: { key, op: "eq" | "neq", value }.opencode.json under plugin or auto-discovered from .opencode/plugin(s)/*.{ts,js} and config-scope plugin dirs.tui.json under plugin; TUI plugins are not auto-discovered from .opencode/plugins/."pkg", "pkg@1.2.3", "./plugin.ts", "file:///abs/plugin.js", or ["pkg", { "option": true }].exports["./server"], then package.json main.exports["./tui"] or valid oc-themes; TUI never falls back to main or exports["."].package.json can fall back to index.ts, index.tsx, index.js, index.mjs, or index.cjs.@opencode-ai/plugin after opencode installs config-dir deps with Bun.package.json engines.opencode compatibility.exports["./server"].config and exports["./tui"].config provide default options during install.api.lifecycle.signal is aborted before cleanup handlers run.keymap, route, event, slots, mode, and attention.soundboard.registerPack; component-level cleanup is still recommended.plugin_enabled is keyed by plugin id; persisted TUI KV state overrides config on startup.PluginInput: client, project, directory, worktree, $, serverUrl, experimental_workspace.TuiPluginApi: app, attention, keys, keymap, mode, route, ui, tuiConfig, kv, state, theme, client, event, renderer, slots, plugins, lifecycle.TuiPluginMeta: state, id, source, spec, target, requested, version, modified, first_time, last_time, time_changed, load_count, fingerprint.api.plugins.install(spec, options?) patches config but does not load into the current session; call api.plugins.add(spec) after install to load now.api.plugins.activate/deactivate(id) persists desired state into KV; active means initialized.client.app.log() for structured server logging. Avoid relying on console.log in production plugins.dispose, event, config, tool, auth, provider, chat.message, chat.params, chat.headers, permission.ask, command.execute.before, tool.execute.before, tool.execute.after, tool.definition, shell.env, experimental.chat.messages.transform, experimental.chat.system.transform, experimental.provider.small_model, experimental.session.compacting, experimental.compaction.autocontinue, experimental.text.complete.
event hook is typed with v1 Event from @opencode-ai/sdk; TUI api.event.on is typed with v2 Event from @opencode-ai/sdk/v2.references/events.md for typed server/TUI event lists and differences.references/server-hooks.ts for complete server hook examples.references/tui-plugin.tsx for complete TUI API examples.