Skip to main content

Module hook

Module hook 

Source
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§

AllowOnceInfo
Allow-once metadata for denial output.
CopilotHookOutput
Copilot-compatible denial output for pre-tool-use hooks.
GeminiHookOutput
Gemini-compatible denial output for BeforeTool hooks.
GrokHookOutput
Grok (xAI) denial output for PreToolUse hooks.
HermesHookOutput
Hermes Agent denial output for shell pre_tool_call hooks.
HookInput
Input structure from supported hook protocols.
HookOutput
Output structure for denying a command.
HookSpecificOutput
Hook-specific output with decision and reason.
Remediation
Remediation suggestions for blocked commands.
ToolInput
Tool-specific input containing the command to execute.

Enums§

HookProtocol
Hook protocol variant for response formatting.
HookReadError
Error type for reading and parsing hook input.
HookResult
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.