Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
The current OpenCode plugin system lacks many useful hook events that would allow plugins to intercept and customize agent behavior at key points. This makes it difficult to build powerful plugins that can:
- Monitor session lifecycle (start/end)
- Intercept tool execution (modify arguments, log results)
- React to agent stopping events
- Handle permission requests
- Participate in session compaction
Proposed Solution
Expand the hook events system with new lifecycle hooks:
session.start / session.end - Session lifecycle
stop - Agent stop event
preToolUse / postToolUse - Tool execution interception
permission.request - Permission request event
preCompact / postCompact - Session compaction events
All hooks include functional triggers in the codebase.
Files Changed
packages/plugin/src/index.ts - Hook type definitions
packages/opencode/src/session/index.ts - session.start/end triggers
packages/opencode/src/session/processor.ts - stop trigger
packages/opencode/src/session/prompt.ts - preToolUse/postToolUse triggers
packages/opencode/src/session/compaction.ts - preCompact/postCompact triggers
packages/opencode/src/permission/index.ts - permission.request trigger
Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
The current OpenCode plugin system lacks many useful hook events that would allow plugins to intercept and customize agent behavior at key points. This makes it difficult to build powerful plugins that can:
Proposed Solution
Expand the hook events system with new lifecycle hooks:
session.start/session.end- Session lifecyclestop- Agent stop eventpreToolUse/postToolUse- Tool execution interceptionpermission.request- Permission request eventpreCompact/postCompact- Session compaction eventsAll hooks include functional triggers in the codebase.
Files Changed
packages/plugin/src/index.ts- Hook type definitionspackages/opencode/src/session/index.ts- session.start/end triggerspackages/opencode/src/session/processor.ts- stop triggerpackages/opencode/src/session/prompt.ts- preToolUse/postToolUse triggerspackages/opencode/src/session/compaction.ts- preCompact/postCompact triggerspackages/opencode/src/permission/index.ts- permission.request trigger