Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

opencode-plugin-authoring

БесплатноБез исполняемых скриптовНе проверен

Build opencode (opencode-ai) plugins — the lifecycle pattern, the event surface for notifications/hooks, and local from-source install. Use when creating an…

ericmjlот ericmjl★ 45 звёзд на GitHub

Об этом скилле

Opencode Plugin Authoring

Build opencode (opencode-ai) plugins — the lifecycle pattern, the event surface for notifications/hooks, and local from-source install.

Plugin lifecycle (verified shape)

import type { Plugin } from "@opencode-ai/plugin"

type Options = {
  backend?: string
  url?: string
  // ... your config keys
}

const plugin: Plugin = async ({ $, directory, project, client, worktree }, options: Options = {}) => {
  // $        = Bun shell template literal for subprocess calls (auto-escaped)
  // directory = project working-directory path (derive project name from it)
  // options   = plugin config object from opencode.json (second positional arg)

  return {
    event: async ({ event }) => {
      // event.type values include: "session.idle", "session.error", and others
      if (event.type === "session.idle") {
        // TURN COMPLETE — agent finished, waiting for user input
        // This is THE event for "notify me when done" notifications
        await $`osascript -e 'display notification "Done!" with title "opencode"'`
      }
    },
  }
}

export default plugin

Key facts:

  • The default export is an async function taking (context, options).
  • options is the second positional arg — it comes from the plugin's config in opencode.json.
  • The returned object's event handler receives { event } where event.type is a string enum.

Event surface

event.type meaning
session.idle Turn complete — agent finished, waiting
session.error Session errored

session.idle is the canonical "notify me when done" event. Do NOT look for session.complete, session.end, or session.finish — they don't exist.

The $ shell helper

The destructured $ is a Bun shell template literal. Template expressions are auto-escaped (safe for user-provided values):

await $`curl -s -m 10 -X POST -H "Content-Type: application/json" -d ${jsonPayload} ${url}`

Never use child_process.exec or string concatenation — $ is the provided mechanism.

Configuration: plugin options vs env vars

Two config channels, both valid:

  1. Plugin options (in opencode.json) — takes precedence:
{
  "plugin": [
    ["~/github/opencode-push", { "backend": "ntfy", "ntfy_url": "http://gb10" }]
  ]
}

Schema (verified against https://opencode.ai/config.json): each plugin entry is either a plain string (path or npm name) OR a 2-element tuple [path, optionsObject]. The object form { "path": ..., "options": ... } is REJECTED with "Expected string | array, got {...} plugin.N" — it does NOT work. ALWAYS check the live schema before writing an opencode.json plugin entry; do not trust secondhand examples.

  1. Environment variables (in ~/.zshenv — NOT ~/.zshrc, which daemon/launchd-launched opencode does not source; see daemon-env-var-gotcha below) — read via process.env. The opencode-push plugin supports TWO backends (bark and ntfy), switchable WITHOUT any code change — set the env vars and the plugin picks them up at load time:
# Backend selection (default: "bark"; set to "ntfy" to switch)
export NOTIFY_BACKEND="ntfy"

# ntfy backend config (self-hosted ntfy server — e.g. on a gb10 box)
export NTFY_URL="http://gb10"        # ntfy server base URL (MagicDNS hostname works)
export NTFY_TOPIC="opencode"         # topic name (default: "opencode")

# bark backend config (the alternative backend)
export BARK_URL="https://api.day.app/<your-key>"

# Host label — which machine this notification originates from
export NOTIFY_HOST="mac"

A first(options.x, process.env.X) helper lets the plugin fall back from options to env. Secrets (API keys, tokens) must NEVER be committed to the plugin repo — use env vars or opencode.json (which is local config, not in the repo).

Switching backends is config-only (07-09): the plugin already supports both bark and ntfy internally; no source edit is needed. Just set NOTIFY_BACKEND and the corresponding backend's URL/topic env vars (or plugin options), then restart opencode.

Install: local from-source (two mechanisms)

Mechanism A — auto-load symlink (preferred for active development):

mkdir -p ~/.config/opencode/plugins
ln -sf ~/github/<your-plugin>/index.ts ~/.config/opencode/plugins/<name>.ts

Opencode auto-loads any .ts/.js file in ~/.config/opencode/plugins/. A symlink to your git-repo source keeps the repo as source-of-truth — no opencode.json change needed.

Mechanism B — plugin array in opencode.json:

{
  "plugin": [
    "~/github/<your-plugin>",
    "/absolute/path/to/index.ts",
    ["~/github/<your-plugin>", { "some_option": "value" }]
  ]
}

Entries are strings OR [path, options] tuples (see schema note in "Configuration" section). If switching from the

Полный SKILL.md на GitHub

Установить opencode-plugin-authoring в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

PURPOSE.md

FAQ

Что делает скилл opencode-plugin-authoring?

Build opencode (opencode-ai) plugins — the lifecycle pattern, the event surface for notifications/hooks, and local from-source install. Use when creating an opencode plugin, writing a notification/hook plugin, wiring session.idle/session.error events, deciding how to install a local plugin (symlink vs plugin array), reading the @opencode-ai/plugin types, using the Bun $ shell helper inside a plugin, checking npm/GitHub name availability for an opencode plugin package, or configuring plugin secrets via env vars vs plugin options. ALSO covers opencode2 (v2 beta) dual-stack support: the 'plugins' config key, plain-object v2 plugin exports, v2 event names (session.inbox.enqueued, session.text.ended, session.step.ended, session.execution.*), the shared .mjs core pattern, and 'opencode2 api delete' cleanup.

Как установить скилл opencode-plugin-authoring?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл opencode-plugin-authoring запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить opencode-plugin-authoring с