Files
oh-my-opencode/src/plugin/AGENTS.md
T
YeonGyu-Kim 73453a7191 docs(agents): update hook counts 44→46, add hashline-edit documentation
- Update root AGENTS.md: hook count 44→46, commit fcb90d92, generated 2026-02-24
- Update src/AGENTS.md: core hooks 35→37, session hooks 21→23
- Update src/hooks/AGENTS.md: 46 hooks total, add modelFallback/noSisyphusGpt/noHephaestusNonGpt/runtimeFallback, jsonErrorRecovery moved to tool-guard (tier 2)
- Create src/tools/hashline-edit/AGENTS.md (93 lines): documents three-op model, LINE#ID format, execution pipeline
- Refresh timestamps: 2026-02-21→2026-02-24 on 28 files
- Update plugin/AGENTS.md hook composition counts

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2026-02-25 00:02:05 +09:00

2.5 KiB

src/plugin/ — 8 OpenCode Hook Handlers + Hook Composition

Generated: 2026-02-24

OVERVIEW

Core glue layer. 20 source files assembling the 8 OpenCode hook handlers and composing 46 hooks into the PluginInterface. Every handler file corresponds to one OpenCode hook type.

HANDLER FILES

File OpenCode Hook Purpose
chat-message.ts chat.message First-message variant, session setup, keyword detection
chat-params.ts chat.params Anthropic effort level, think mode
event.ts event Session lifecycle (created, deleted, idle, error)
tool-execute-before.ts tool.execute.before Pre-tool guards (file guard, label truncator, rules injector)
tool-execute-after.ts tool.execute.after Post-tool hooks (output truncation, comment checker, metadata)
messages-transform.ts experimental.chat.messages.transform Context injection, thinking block validation
tool-registry.ts tool 26 tools assembled from factories
skill-context.ts Skill/browser/category context for tool creation

HOOK COMPOSITION (hooks/ subdir)

File Tier Count
create-session-hooks.ts Session 21
create-tool-guard-hooks.ts Tool Guard 10
create-session-hooks.ts Session 23
create-tool-guard-hooks.ts Tool Guard 10
create-skill-hooks.ts Skill 2
create-core-hooks.ts Aggregator Session + Guard + Transform = 37

SUPPORT FILES

File Purpose
available-categories.ts Build AvailableCategory[] for agent prompt injection
session-agent-resolver.ts Resolve which agent owns a session
session-status-normalizer.ts Normalize session status across OpenCode versions
recent-synthetic-idles.ts Dedup rapid idle events
unstable-agent-babysitter.ts Track unstable agent behavior across sessions
types.ts PluginContext, PluginInterface, ToolsRecord, TmuxConfig
ultrawork-model-override.ts Ultrawork mode model override logic
ultrawork-db-model-override.ts DB-level model override for ultrawork

KEY PATTERNS

  • Each handler exports a function receiving (hookRecord, ctx, pluginConfig, managers) → returns OpenCode hook function
  • Handlers iterate over hook records, calling each hook with (input, output) in sequence
  • safeHook() wrapper in composition files catches errors per-hook without breaking the chain
  • Tool registry uses filterDisabledTools() before returning