Help us shape the future of Go! Take the 2026 Go Developer Survey

hooks

package
v1.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package hooks provides pre/post tool-use hook parsing and execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor runs pre/post tool-use hooks.

func NewExecutor

func NewExecutor(hooks []Hook, workspace string) *Executor

NewExecutor creates an Executor for the given hooks and workspace directory.

func (*Executor) RunPostToolUse

func (e *Executor) RunPostToolUse(toolName string, input map[string]any) (*HookResult, error)

RunPostToolUse runs all matching PostToolUse hooks.

func (*Executor) RunPreToolUse

func (e *Executor) RunPreToolUse(toolName string, input map[string]any) (*HookResult, error)

RunPreToolUse runs all matching PreToolUse hooks. Returns the first blocking result, or an approve result if all pass.

type Hook

type Hook struct {
	Event   string // "PreToolUse", "PostToolUse", "PreCommit"
	Tool    string // tool name or "*"
	Command string // shell command with {{variables}}
	Timeout int    // seconds, default 30
}

Hook represents a parsed hook definition ready for execution.

func ParseFromGrimoire

func ParseFromGrimoire(g *grimoire.Grimoire) []Hook

ParseFromGrimoire converts grimoire HookEntry items into Hook structs.

type HookResult

type HookResult struct {
	Decision string // "approve" or "block"
	Output   string
	ExitCode int
}

HookResult holds the outcome of running a hook.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL