Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractFilePath ¶
ExtractFilePath attempts to extract a file path from common tool argument patterns.
Types ¶
type Hook ¶
type Hook struct {
Match string `yaml:"match"` // glob pattern to match tool names
Command string `yaml:"command"` // shell command to run
InjectOutput bool `yaml:"inject_output"` // for post hooks: inject stdout into tool result
}
Hook represents a single pre or post tool-use hook.
type HookConfig ¶
type HookConfig struct {
PreToolUse []Hook `yaml:"pre_tool_use"`
PostToolUse []Hook `yaml:"post_tool_use"`
}
HookConfig holds all hooks from configuration.
type HookEnv ¶
type HookEnv struct {
ToolName string
FilePath string // extracted from tool arguments when applicable
WorkingDir string
RawInput string // raw JSON tool arguments
}
HookEnv holds environment variables available to hook commands.
type HookResult ¶
type HookResult struct {
Allowed bool // false means block the tool execution (pre-hook only)
Output string // captured stdout (for inject_output)
Err error
}
HookResult is the result of running a hook.
func RunPostHooks ¶
func RunPostHooks(hooks []Hook, env HookEnv) HookResult
RunPostHooks runs all matching post-tool-use hooks. Collects output from hooks with inject_output=true.
func RunPreHooks ¶
func RunPreHooks(hooks []Hook, env HookEnv) HookResult
RunPreHooks runs all matching pre-tool-use hooks. Returns HookResult with Allowed=false if any hook blocks execution.
Click to show internal directories.
Click to hide internal directories.