Versions in this module Expand all Collapse all v0 v0.12.0 Mar 9, 2026 v0.11.0 Mar 2, 2026 Changes in this version + const DefaultFileMode + var DefaultRegistry = NewAdapterRegistry() + var ErrBothCommandAndPrompt = errors.New("hook cannot have both command and prompt") + var ErrEmptyConfig = errors.New("configuration is empty") + var ErrInvalidMatcher = errors.New("invalid matcher pattern") + var ErrNoCommandOrPrompt = errors.New("hook must have either command or prompt") + var ErrUnsupportedEvent = errors.New("event not supported by this tool") + func Convert(data []byte, from, to string) ([]byte, error) + func Register(adapter Adapter) + type Adapter interface + DefaultPaths func() []string + Marshal func(cfg *Config) ([]byte, error) + Name func() string + Parse func(data []byte) (*Config, error) + ReadFile func(path string) (*Config, error) + SupportedEvents func() []Event + WriteFile func(cfg *Config, path string) error + func GetAdapter(name string) (Adapter, bool) + type AdapterRegistry struct + func NewAdapterRegistry() *AdapterRegistry + func (r *AdapterRegistry) Convert(data []byte, from, to string) ([]byte, error) + func (r *AdapterRegistry) Get(name string) (Adapter, bool) + func (r *AdapterRegistry) Names() []string + func (r *AdapterRegistry) Register(adapter Adapter) + type Config struct + AllowManagedHooksOnly bool + DisableAllHooks bool + Hooks map[Event][]HookEntry + Version int + func NewConfig() *Config + func ReadFile(path string) (*Config, error) + func (c *Config) AddHook(event Event, hook Hook) + func (c *Config) AddHookWithMatcher(event Event, matcher string, hook Hook) + func (c *Config) Events() []Event + func (c *Config) FilterByTool(tool string) *Config + func (c *Config) GetAllHooksForEvent(event Event) []Hook + func (c *Config) GetHooks(event Event) []HookEntry + func (c *Config) HasHooks() bool + func (c *Config) HookCount() int + func (c *Config) MarshalJSON() ([]byte, error) + func (c *Config) Merge(other *Config) + func (c *Config) RemoveHooks(event Event) + func (c *Config) UnmarshalJSON(data []byte) error + func (c *Config) Validate() error + func (c *Config) WriteFile(path string) error + func (c *Config) WriteFileWithMode(path string, mode fs.FileMode) error + type ConversionError struct + Err error + Event Event + From string + To string + func (e *ConversionError) Error() string + func (e *ConversionError) Unwrap() error + type Event string + const AfterCommand + const AfterFileRead + const AfterFileWrite + const AfterMCP + const AfterResponse + const AfterTabEdit + const AfterThought + const BeforeCommand + const BeforeCompact + const BeforeFileRead + const BeforeFileWrite + const BeforeMCP + const BeforePrompt + const BeforeTabRead + const OnNotification + const OnPermission + const OnSessionEnd + const OnSessionStart + const OnStop + const OnSubagentStop + func AllEvents() []Event + func (e Event) CanBlock() bool + func (e Event) GetToolSupport() ToolSupport + func (e Event) IsAfterEvent() bool + func (e Event) IsBeforeEvent() bool + func (e Event) String() string + type Hook struct + Command string + Prompt string + ShowOutput bool + Timeout int + Type HookType + WorkingDir string + func NewCommandHook(command string) Hook + func NewPromptHook(prompt string) Hook + func (h *Hook) IsCommand() bool + func (h *Hook) IsPrompt() bool + func (h *Hook) Validate() error + func (h Hook) WithShowOutput(show bool) Hook + func (h Hook) WithTimeout(seconds int) Hook + func (h Hook) WithWorkingDir(dir string) Hook + type HookEntry struct + Hooks []Hook + Matcher string + type HookType string + const HookTypeCommand + const HookTypePrompt + type HookValidationError struct + EntryIndex int + Err error + Event Event + HookIndex int + func (e *HookValidationError) Error() string + func (e *HookValidationError) Unwrap() error + type ParseError struct + Err error + Format string + Path string + func (e *ParseError) Error() string + func (e *ParseError) Unwrap() error + type ToolSupport struct + Claude bool + Cursor bool + Windsurf bool + type WriteError struct + Err error + Format string + Path string + func (e *WriteError) Error() string + func (e *WriteError) Unwrap() error