anomalyco / anomalyco/opencode
Plugin hook parity with Claude Code lifecycle events (7 gaps)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 384
Description
Plugin hook parity with Claude Code's lifecycle events
I'm a plugin author (opencode plugin driving a knowledge-base lifecycle: capture on stop, retrieval on prompt, tooling-finding harvest on subagent stop). Mapping Claude Code's 33 documented hook events (https://code.claude.com/docs/en/hooks) against the opencode plugin API, most of the core loop ports cleanly — thank you. The gaps below are all cases where the information exists inside opencode but no plugin surface exposes it. One consolidated issue rather than seven; happy to split if you prefer.
What already ports (for context)
SessionStart→chat.system.transform, UserPromptSubmit→chat.message, PreToolUse→tool.execute.before (throw=block works), PostToolUse→tool.execute.after, SubagentStart/Stop→task before/after, Stop→session.idle, PreCompact→session.compacting, SessionEnd→session.deleted, StopFailure→session.error, PostCompact→session.compacted.
The gaps
PostToolUseFailurehas no documented signal.tool.execute.afterreceives{title, output, metadata}— but nothing says whether it fires when the tool call fails, or how a failure surfaces in that payload. A documentederror/statusfield (or a dedicated hook) would let plugins react to failures vs successes differently.- No
PostToolBatch. Parallel tool calls resolving as a batch is invisible; plugins see N individual afters with no grouping. - Notifications are send-only. Plugins can push
tui.toast, but there is no event for receiving notification-worthy moments (permission prompts, idle) the way Claude'sNotificationevent provides. - No
CwdChanged/DirectoryAdded. Session cwd tracking is invisible to plugins. Concrete cost: path-scoped guards (e.g. "refuse broadgit addonly inside repo X") cannot be written safely. - No
PreModelSwitch/PostModelSwitch. Model changes mid-session are invisible. - Tool hooks carry no
cwd.tool.execute.before/afterinput is{tool, sessionID, callID}(+argson output for before). Without cwd, any guard that should only fire in one project must match on command text, which is fragile. This is the single highest-value addition for guard authors. - No per-agent hooks. Claude lets subagent/skill frontmatter declare hooks that live only while that agent runs. In opencode every enforcement must live in the global plugin with manual agent-name matching.
Environment
opencode with @opencode-ai/plugin + @opencode-ai/sdk (types as installed 2026-09-20). Willing to test early cuts of any of these.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the @opencode-ai/plugin and @opencode-ai/sdk surfaces described in the issue, then compare their lifecycle events with Claude Code's documented hooks. Determine which of the seven gaps can share an API design and how existing plugin events expose their payloads. Done means the selected gaps have an agreed implementation or documentation path, with behavior and failure cases specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100