Documentation
¶
Overview ¶
Package hooks implements the lifecycle hooks system for automation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor struct{}
Executor runs hook commands
func (*Executor) Run ¶
func (e *Executor) Run(ctx context.Context, event HookEvent, config HookConfig, data EventData) (*HookResult, error)
Run executes a hook command with timeout
type HookConfig ¶
type HookConfig struct {
Command string `yaml:"command" json:"command"`
Matcher map[string]string `yaml:"matcher,omitempty" json:"matcher,omitempty"`
Timeout int `yaml:"timeout,omitempty" json:"timeout,omitempty"` // seconds
}
HookConfig defines a single hook's configuration
func (*HookConfig) Validate ¶
func (h *HookConfig) Validate() error
Validate checks if the hook configuration is valid
type HookEvent ¶
type HookEvent string
HookEvent represents a lifecycle event that can trigger hooks
const ( SessionStart HookEvent = "SessionStart" SessionEnd HookEvent = "SessionEnd" UserPromptSubmit HookEvent = "UserPromptSubmit" ModelResponseDone HookEvent = "ModelResponseDone" PreToolUse HookEvent = "PreToolUse" PostToolUse HookEvent = "PostToolUse" PreCommit HookEvent = "PreCommit" PostCommit HookEvent = "PostCommit" OnError HookEvent = "OnError" PlanModeEnter HookEvent = "PlanModeEnter" )
Lifecycle hook events that can trigger hook execution
type HookResult ¶
HookResult contains the result of hook execution
type HooksConfig ¶
type HooksConfig map[HookEvent][]HookConfig
HooksConfig maps hook events to their configurations
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages hook execution for lifecycle events
func NewManager ¶
func NewManager(config HooksConfig) *Manager
NewManager creates a new hook manager
func (*Manager) Trigger ¶
func (m *Manager) Trigger(ctx context.Context, event HookEvent, data EventData) ([]*HookResult, error)
Trigger executes all hooks for a given event
func (*Manager) TriggerAsync ¶
TriggerAsync executes hooks without blocking