Documentation
¶
Overview ¶
Package hook is f10's one entry point for Claude Code hook events: a skill starting seeds the run's badge, a Bash call or a file write becomes typed observations, Stop backs up the most-dropped badge call, and SessionStart keeps the status line wired and the state directory small. Across them, a run's waits on the user (a turn, a question, a permission dialog) are recorded as they open and end.
Nothing here fails a run: a payload it cannot read, a state file it cannot write, an observer that errors - each is dropped, and the hook exits 0.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Env ¶
type Env struct {
StateDir string
Home string
PluginRoot string // where bin/f10-state.sh, the status-line renderer, lives
Debug bool // F10_STATE_DEBUG: append every payload to hooks.log
Now func() time.Time
// StorageRoot is the checkout's storage root for a cwd, in-repo or
// out-of-tree; empty when it cannot tell.
StorageRoot func(ctx context.Context, cwd string) string
// TaskID is the tracker task id a created issue's url names, in the
// project's id format; empty when it cannot tell.
TaskID func(ctx context.Context, cwd, url string) string
// PromptTyped is told of every prompt submitted, with the session's
// cwd: one typed in an asking agent's pane answers its ask.
PromptTyped func(ctx context.Context, cwd, prompt string)
// StatusText is what `f10 status` prints for a session, and whether it
// holds a question to relay, which needs a model turn.
StatusText func(ctx context.Context, session string) (string, bool)
// Observers receive every observation after the badge has applied it.
Observers []observe.Observer
}
Env is everything a hook reaches outside its payload, so a test can point it at a temp directory and stub what needs a real project.
type Payload ¶
type Payload struct {
Event string `json:"hook_event_name"`
Session string `json:"session_id"`
Cwd string `json:"cwd"`
Source string `json:"source"` // SessionStart: startup, resume, clear, compact
CommandName string `json:"command_name"` // UserPromptExpansion
CommandArgs string `json:"command_args"`
ToolName string `json:"tool_name"` // PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest
ToolUseID string `json:"tool_use_id"`
ToolInput json.RawMessage `json:"tool_input"`
ToolResponse json.RawMessage `json:"tool_response"`
Prompt string `json:"prompt"` // UserPromptSubmit
}
Payload is the part of a hook event's JSON the arms read, decoded once.