Skip to content

code-yeongyu/oh-my-openagent / .agents/skills/opencode-qa

opencode-qa

Verified

QA opencode itself, per case: verify the CLI/terminal (opencode run, db, serve, export), prove a specific plugin hook/action/event fired via the SSE event stream, smoke-test the TUI under tmux, and investigate sessions in opencode's SQLite DB by id, title/name, or message text. Ships tested helper scripts (each with a --self-test) plus per-domain references. Use whenever someone wants to QA, smoke-test, verify, or debug opencode's CLI, HTTP server, plugin hooks/events, or TUI, or to find/inspect opencode sessions in the database. Triggers: opencode qa, qa opencode, test opencode, verify opencode hook, opencode session db, find opencode session by id/name/text, opencode tui test, opencode server health, opencode event stream.

FileKindSize
SKILL.mdskill md11.3 KB
references/cli-commands.mdmarkdown3.8 KB
references/db-investigation.mdmarkdown5.8 KB
references/docker-qa.mdmarkdown3.2 KB
references/events-hooks.mdmarkdown4.5 KB
references/sdk.mdmarkdown4.1 KB
references/server-api.mdmarkdown6.5 KB
references/testing-harness.mdmarkdown6.2 KB
references/tui-tmux.mdmarkdown4.0 KB
scripts/db-session-by-id.shexecutablescript1.7 KB
scripts/db-session-by-name.shexecutablescript1.9 KB
scripts/db-session-by-text.shexecutablescript6.6 KB
scripts/export-roundtrip.shexecutablescript2.8 KB
scripts/lib/common.shexecutablescript9.5 KB
scripts/lib/fake-openai-branches.mjsscript1.2 KB
scripts/lib/fake-openai-events.mjsscript2.3 KB
scripts/lib/fake-openai-server.mjsexecutablescript3.7 KB
scripts/lsp-e2e.shexecutablescript134.1 KB
scripts/serve-wake-split-probe.shexecutablescript38.2 KB
scripts/server-smoke.shexecutablescript2.1 KB
scripts/sse-hook-probe.shexecutablescript4.4 KB
scripts/tui-smoke.shexecutablescript3.6 KB

references/events-hooks.md

View on GitHub
# QAing opencode hooks, actions, and events (Case B)

opencode publishes lifecycle events over Server-Sent Events. Plugins observe the SAME events via the `event` hook, so confirming an event on the wire proves a hook would fire. The bundled probe is `scripts/sse-hook-probe.sh`.

## Table of Contents

- [The two SSE endpoints](#the-two-sse-endpoints)
- [Watch the stream](#watch-the-stream)
- [Important event types](#important-event-types)
- [Hook-fired recipe (watch + trigger + assert)](#hook-fired-recipe-watch--trigger--assert)
- [Plugin hooks (the 21 hook points a plugin can implement)](#plugin-hooks-the-21-hook-points-a-plugin-can-implement)
- [Loading a local plugin for QA](#loading-a-local-plugin-for-qa)

## The two SSE endpoints

- GET /event?directory=<dir> - per-instance stream; the FIRST event is `server.connected`, a `server.heartbeat` arrives every 10s, and the stream ends on `server.instance.disposed`.
- GET /global/event - all events, no instance filter.
- Frames look like `data: {"type":"...","properties":{...}}` (one per line). Consume with `curl -N`.

## Watch the stream

```
curl -N -u opencode:$PASS "http://127.0.0.1:4096/event?directory=$PWD"
```

Bundled, with assertions + auto-teardown:

```
scripts/sse-hook-probe.sh --self-test
```

(spawns an isolated server, asserts server.connected)

```
scripts/sse-hook-probe.sh --attach http://127.0.0.1:4096 --password "$PASS" --directory "$PWD" --event message.part.updated --timeout 30
```

(watch your real server for a specific event)

## Important event types (type - properties)

- `session.created` / `session.updated` / `session.deleted` (sessionID, info)
- `message.updated` (sessionID, info)
- `message.removed` (sessionID, messageID)
- `message.part.updated` (sessionID, part, time)
- `message.part.delta` (sessionID, messageID, partID, field, delta)
- `message.part.removed`
- `permission.asked` (id, sessionID, permission, tool?)
- `permission.replied`
- `session.error` (sessionID?, error)
- `session.diff` (sessionID, diff)
- `question.asked` / `question.replied` / `question.rejected`
- `file.watcher.updated` (file, event)
- `project.updated`
- `lsp.updated`
- `pty.created` / `pty.updated` / `pty.exited` / `pty.deleted`
- `server.connected`
- `server.heartbeat`
- `server.instance.disposed`
- `global.disposed`
- `plugin.added`

## Hook-fired recipe (watch + trigger + assert)

Two-shell pattern (or use the script):

```
# shell 1: watch (kill with Ctrl-C when done)
curl -N -u opencode:$PASS "http://127.0.0.1:4096/event?directory=$PWD" \
  | grep --line-buffered '"type":"message.part.updated"'

# shell 2: trigger an action (fire-and-forget)
curl -X POST -u opencode:$PASS -H 'Content-Type: application/json' \
  -d '{"parts":[{"type":"text","text":"say hi"}]}' \
  "http://127.0.0.1:4096/session/<ses_id>/prompt_async?directory=$PWD"
```

A `message.part.updated` (text/tool) confirms the prompt action drove the model and any tool/permission hook path. Note: a real prompt requires a configured provider/auth, so this runs against your real server, not the isolated sandbox (the sandbox only proves the SSE plumbing via server.connected).

## Plugin hooks (the 21 hook points a plugin can implement)

`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.session.compacting`, `experimental.compaction.autocontinue`, `experimental.text.complete`.

- A plugin is a module default-exporting `{ id?, server: (input, options) => Promise<Hooks> }`.
- Minimal example implementing `event` and `tool.execute.before` that console.log the activity:

```typescript
export default {
  id: "qa-logger",
  async server(input, options) {
    return {
      event: async (event) => {
        console.log("[event]", event.type, event.properties);
      },
      "tool.execute.before": async (tool, args, context) => {
        console.log("[tool.before]", tool.name, args);
      },
    };
  },
};
```

## Loading a local plugin for QA

- Add an absolute path or npm spec to the opencode config `plugin` / `plugin_origins` array (project `.opencode/` config or user config), then restart opencode. On load it emits `plugin.added`.
- To QA a hook: load the plugin, watch /event (or the plugin's own logging), trigger the relevant action, and assert.

---

Pair this with references/server-api.md (how to start the server, auth, prompt routes).
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 197kUpdated Claude CodeCodexVerifiedInstall