Skip to content

[FEATURE]: Add expanded hook events to the plugin system to enable more powerful plugin capabilities. #21075

@reactive-end

Description

@reactive-end

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions