Documentation
¶
Overview ¶
Package hook parses harness lifecycle-hook events (Claude Code / Codex) and maps them onto engine write operations. Parsing is tolerant: unknown fields are ignored so upstream schema drift never breaks the binary.
Index ¶
Constants ¶
const ( PromptMaxRunes = 2000 ObservationMaxRunes = 500 )
Variables ¶
This section is empty.
Functions ¶
func MapToolActionClass ¶
func WorkspaceFromCwd ¶
WorkspaceFromCwd derives the memory workspace from the event's cwd by taking its base directory name (spec §2: cwd directory name).
Types ¶
type Harness ¶
type Harness = string
Harness names the event source; it lands in the OperationEvent Agent field. stdin JSON is identical across harnesses, so the caller passes it explicitly (CLI --harness flag, written by `ladym hook install`).
type Payload ¶
type Payload struct {
HookEventName string `json:"hook_event_name"`
SessionID string `json:"session_id"`
TranscriptPath string `json:"transcript_path"`
Cwd string `json:"cwd"`
ToolName string `json:"tool_name"`
ToolInput map[string]any `json:"tool_input"`
ToolResponse any `json:"tool_response"`
Prompt string `json:"prompt"`
Source string `json:"source"`
}
Payload is the tolerant parse of a hook event JSON document. The two harnesses use near-identical shapes, so one struct serves both.
func (*Payload) ToOperation ¶
func (p *Payload) ToOperation(harness Harness) *engine.OperationEvent
ToOperation maps the payload onto an engine write. It returns nil when the event is outside the V1 set (spec §4.2): the CLI then exits 0 silently.