Documentation
¶
Overview ¶
Package hooks implements auto-capture hooks for lifecycle events. Hooks are invoked at key lifecycle events and automatically capture observations into the Yaad memory graph.
Index ¶
- func PhaseAwareRelevance(phase PipelinePhase, toolName, input, output, toolError string) float64
- func PhaseAwareShouldCapture(phase PipelinePhase, toolName, input, output, toolError string) bool
- func ScoreRelevance(toolName, input, output, toolError string) float64
- func ShouldCapture(toolName, input, output, toolError string) bool
- type ConversationCapture
- type ConversationCaptureSummary
- type ConversationMessage
- type HookInput
- type PipelinePhase
- type Runner
- func (r *Runner) PostToolUse(ctx context.Context, in *HookInput) error
- func (r *Runner) SessionEnd(ctx context.Context, in *HookInput) error
- func (r *Runner) SessionStart(ctx context.Context, in *HookInput) error
- func (r *Runner) StoreToolEvent(ctx context.Context, in *HookInput, store storage.Storage) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PhaseAwareRelevance ¶ added in v0.1.3
func PhaseAwareRelevance(phase PipelinePhase, toolName, input, output, toolError string) float64
PhaseAwareRelevance adjusts the base relevance score from ScoreRelevance based on the pipeline phase in which the tool call occurs. Phase-specific tuning ensures yaad captures the right memories at the right time:
- localize: file reads become more interesting (they reveal search targets)
- repair: writes/edits are the primary signal; everything else is background
- validate: test and lint outputs are the primary signal
- review: any write or decision is high-signal (review phase drives cost)
func PhaseAwareShouldCapture ¶ added in v0.1.3
func PhaseAwareShouldCapture(phase PipelinePhase, toolName, input, output, toolError string) bool
PhaseAwareShouldCapture returns true if the observation passes the relevance threshold after phase-specific adjustment.
func ScoreRelevance ¶
ScoreRelevance determines if a tool observation is worth storing. Returns a score 0.0-1.0 where higher = more worth remembering. No LLM needed — heuristic-based on content signals.
func ShouldCapture ¶
ShouldCapture returns true if the observation passes the relevance threshold.
Types ¶
type ConversationCapture ¶
type ConversationCapture struct {
// contains filtered or unexported fields
}
ConversationCapture extracts memories from conversation messages. Unlike PostToolUse (which captures tool observations), ConversationCapture analyzes the semantic content of messages to identify decisions, conventions, learnings, and action items worth remembering.
func NewConversationCapture ¶
func NewConversationCapture(eng *engine.Engine, project string) *ConversationCapture
NewConversationCapture creates a conversation capture hook.
func (*ConversationCapture) CaptureMessages ¶
func (cc *ConversationCapture) CaptureMessages(ctx context.Context, messages []ConversationMessage, sessionID, agent string) int
CaptureMessages analyzes a slice of conversation messages and stores significant observations as memories. Returns the number of memories created.
func (*ConversationCapture) CaptureWithSummary ¶
func (cc *ConversationCapture) CaptureWithSummary(ctx context.Context, messages []ConversationMessage, sessionID, agent string) ConversationCaptureSummary
CaptureWithSummary is like CaptureMessages but returns a detailed summary.
type ConversationCaptureSummary ¶
type ConversationCaptureSummary struct {
TotalMessages int
MemoriesStored int
ByType map[string]int
}
ConversationCaptureSummary reports how many memories were captured.
func (ConversationCaptureSummary) FormatSummary ¶
func (s ConversationCaptureSummary) FormatSummary() string
FormatSummary returns a human-readable capture summary.
type ConversationMessage ¶
ConversationMessage represents a single message in a conversation for auto-capture processing.
type HookInput ¶
type HookInput struct {
// Common
SessionID string `json:"session_id"`
Project string `json:"project"`
Agent string `json:"agent"`
// PostToolUse
ToolName string `json:"tool_name"`
ToolInput string `json:"tool_input"`
ToolOutput string `json:"tool_output"`
ToolError string `json:"tool_error"`
// UserPromptSubmit
Prompt string `json:"prompt"`
// SessionEnd
Summary string `json:"summary"`
}
HookInput is the JSON payload passed to hooks via stdin.
type PipelinePhase ¶ added in v0.1.3
type PipelinePhase string
PipelinePhase identifies the step of the localize → repair → validate pipeline in which a tool call occurs. These constants match hawk-core-contracts/sessions.Phase; they are duplicated here to keep yaad free of the hawk-core-contracts go.mod dependency.
const ( PipelinePhaseLocalize PipelinePhase = "localize" PipelinePhaseRepair PipelinePhase = "repair" PipelinePhaseValidate PipelinePhase = "validate" PipelinePhaseReview PipelinePhase = "review" PipelinePhaseUnknown PipelinePhase = "" )
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner executes hook logic.
func (*Runner) PostToolUse ¶
PostToolUse is called after each tool use. Captures the observation.
func (*Runner) SessionEnd ¶
SessionEnd is called when a session ends. Compresses and stores summary.
func (*Runner) SessionStart ¶
SessionStart is called when an agent session begins. Outputs hot-tier context to stdout for injection into the session.