Expand description
Hook protocol handling.
This module handles JSON input/output for supported hook protocols (Claude Code, Codex CLI, Copilot, Gemini, and Hermes Agent). It parses incoming hook requests and formats denial responses.
Structs§
- Allow
Once Info - Allow-once metadata for denial output.
- Copilot
Hook Output - Copilot-compatible denial output for pre-tool-use hooks.
- Gemini
Hook Output - Gemini-compatible denial output for
BeforeToolhooks. - Grok
Hook Output - Grok (xAI) denial output for
PreToolUsehooks. - Hermes
Hook Output - Hermes Agent denial output for shell
pre_tool_callhooks. - Hook
Input - Input structure from supported hook protocols.
- Hook
Output - Output structure for denying a command.
- Hook
Specific Output - Hook-specific output with decision and reason.
- Remediation
- Remediation suggestions for blocked commands.
- Tool
Input - Tool-specific input containing the command to execute.
Enums§
- Hook
Protocol - Hook protocol variant for response formatting.
- Hook
Read Error - Error type for reading and parsing hook input.
- Hook
Result - Result of processing a hook request.
Functions§
- configure_
colors - Configure colored output based on TTY detection.
- detect_
protocol - Detect which hook protocol should be used for output formatting.
- extract_
command - Extract the command string from hook input.
- extract_
command_ with_ protocol - Extract command and protocol from hook input.
- format_
denial_ message - Format the denial message for the JSON output (plain text).
- log_
blocked_ command - Log a blocked command to a file (if logging is enabled).
- log_
budget_ skip - Log a budget skip to a file (if logging is enabled).
- output_
denial - Output a denial response to stdout (JSON for hook protocol).
- output_
denial_ for_ protocol - Output a denial response to stdout (JSON for hook protocol).
- output_
warning_ for_ protocol - Output a warning for a warn-severity match.
- print_
colorful_ warning - Print a colorful warning to stderr for human visibility.
- read_
hook_ input - Read and parse hook input from stdin.
- write_
denial_ to - Write a denial response to arbitrary stdout/stderr writers.