Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AllEvents = []Event{ PreEdit, PostEdit, PreCommand, PostCommand, PreSession, PostSession, PreCommit, PostCommit, OnError, OnToolCall, OnPermissionRequest, PrePlan, PostPlan, PreFleet, PostFleet, OnAgentSpawn, OnAgentComplete, OnTokenLimit, OnCronTick, }
AllEvents lists every valid lifecycle event for documentation and validation.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event string
Event is a lifecycle event that can trigger hooks.
const ( PreEdit Event = "pre-edit" PostEdit Event = "post-edit" PreCommand Event = "pre-command" PostCommand Event = "post-command" PreSession Event = "pre-session" PostSession Event = "post-session" PreCommit Event = "pre-commit" PostCommit Event = "post-commit" OnError Event = "on-error" OnToolCall Event = "on-tool-call" OnPermissionRequest Event = "on-permission-request" // Plan lifecycle PrePlan Event = "pre-plan" PostPlan Event = "post-plan" // Fleet lifecycle PreFleet Event = "pre-fleet" PostFleet Event = "post-fleet" // Agent lifecycle OnAgentSpawn Event = "on-agent-spawn" OnAgentComplete Event = "on-agent-complete" // Token and cron events OnTokenLimit Event = "on-token-limit" OnCronTick Event = "on-cron-tick" )
type HookConfig ¶
HookConfig holds the full hooks configuration.
func Load ¶
func Load(workingDir string) (*HookConfig, error)
Load reads hook configs from ~/.ratchet/hooks.yaml and .ratchet/hooks.yaml. Project-level hooks (.ratchet/hooks.yaml) override global ones.
func (*HookConfig) Run ¶
func (hc *HookConfig) Run(event Event, data map[string]string) error
Run executes all hooks for the given event, expanding templates with data. data keys include: "file", "command", "error", "tool", "session_id", "plan_id", "fleet_id", "agent_name", "agent_role", "cron_id", "tokens_used", "tokens_limit"
Click to show internal directories.
Click to hide internal directories.