Expand description
Shared helpers for the SessionStart / UserPromptSubmit hook commands (sub-plan C): the Claude Code hook-output JSON shape for injecting context, the pure decision logic for when to inject, and the shared resolve-binding-then-inject flow used by both hook commands.
Structs§
- Hook
Output - Claude Code hook output. Field names are camelCase to match CC’s contract
(the shared protocol
HookResponseis snake_case and server-facing; this is the CLI-local shape used only for hook stdout). - Hook
Specific Output
Functions§
- cap_
context - Cap injected context. Oversize policy text is truncated to its first
HEAD_LENchars with a suffix pointing attracevault repo status— unliketracevault agent-policies,repo statusworks in workspace mode (no.tracevault/config.tomlrequired), so the fallback is reachable in every install mode. - resolve_
and_ inject - Resolve the session’s effective binding (auto-binding an unbound session
from its checkout’s remote, whose “not registered” notice goes to the user
as
systemMessage) and, ifshould_inject(event, ...), best-effort fetch + print policies asadditionalContextand persistlast_injected_repo. Always prints a validHookOutput; never hard-fails. - should_
inject - Whether to inject policies for this hook event.