Synthèse
Hooks are the nervous system of PAI. They fire automatically at specific lifecycle events: EventWhen It FiresExample HooksSessionStartNew conversation beginsLoadContext — injects SKILL.md + Steering RulesUserPromptSubmitEvery user messageFormatReminder — detects response mode, routes capabilitiesExplicitRatingCapture — captures 1-10 ratingsImplicitSentimentCapture — detects emotional toneUpdateTabTitle — sets terminal tab to current taskPreToolUseBefore any tool executesSecurityValidator — block
Hooks are the nervous system of PAI. They fire automatically at specific lifecycle events: EventWhen It FiresExample HooksSessionStartNew conversation beginsLoadContext — injects SKILL. md + Steering RulesUserPromptSubmitEvery user messageFormatReminder — detects response mode, routes capabilitiesExplicitRatingCapture — captures 1-10 ratingsImplicitSentimentCapture — detects emotional toneUpdateTabTitle — sets terminal tab to current taskPreToolUseBefore any tool executesSecurityValidator — blocks injection attemptsPostToolUseAfter tool completesObservability loggingStopSession endsStopOrchestrator — rebuilds SKILL. md, captures learningsSubagentStopBackground agent finishesAgentOutputCapture — collects results PAI v2. 4 runs 17 hooks across these events.
They all execute in under 50ms. Here's the FormatReminder hook in action—it detects what kind of response is needed and routes to the right capabilities: typescript// FormatReminder. hook. ts (simplified) const CAPABILITY_ROUTING = [ { keywords: ['research', 'investigate', 'explore'], capability: 'Research skill', agents: 'GeminiResearcher, ClaudeResearcher, GrokResearcher', }, { keywords: ['build', 'implement', 'code', 'fix'], capability: 'Engineer Agent', agents: 'Engineer (subagent_type=Engineer)', }, { keywords: ['design', 'architecture'], capability: 'Architect Agent', agents: 'Architect (subagent_type=Architect)', }, ]; function detectMode(prompt: string): 'FULL' | 'ITERATION' | 'MINIMAL' { // Greetings, ratings, acknowledgments → MINIMAL if (/^(hi|hey|thanks|ok|cool)\.? $/i.
test(lower)) return 'MINIMAL'; // Continuing existing work → ITERATION if (/^(ok|yes)[\s,]*(now|then|try|but)/i. test(lower)) return 'ITERATION'; // Everything else → FULL Algorithm return 'FULL'; }1234567891011121314151617181920212223242526272829 Every user message gets classified. Every response gets the right structure. Automatic.
The Hook System: Event-Driven Automation
· 26 juil.
The Hook System: Event-driven automation
· 26 juil.
The Power of Automation
· 26 juil.
How Hooks Enable the Other Systems
· 26 juil.
The Hook System: Event-driven automation
· 26 juil.