Skip to main content

coding_agent_hooks/
lib.rs

1//! Agent-agnostic hook protocol types and adapters for AI coding agents.
2//!
3//! This crate provides the building blocks for writing hook-based middleware
4//! that works with any AI coding agent (Claude Code, Gemini CLI, Codex CLI,
5//! Amazon Q, OpenCode, Copilot CLI, etc.).
6//!
7//! # Core Concepts
8//!
9//! - [`AgentKind`] identifies which agent is calling.
10//! - [`HookProtocol`](protocol::HookProtocol) abstracts agent-specific JSON formats.
11//! - [`ToolUseHookInput`](input::ToolUseHookInput) and friends are the normalized
12//!   input types parsed from any agent's hook JSON.
13//! - [`HookOutput`](output::HookOutput) is a structured response type (used
14//!   directly by Claude Code; other agents convert via protocol methods).
15//! - Tool and permission-mode name resolution normalizes across agents.
16//!
17//! # Adding a New Agent
18//!
19//! Implement [`HookProtocol`](protocol::HookProtocol) — only two methods are
20//! required (`agent` and `parse_tool_use`). Add entries to the tool and mode
21//! alias tables in [`agents`] so policy evaluation uses consistent names.
22
23pub mod agents;
24pub mod input;
25pub mod output;
26pub mod protocol;
27
28// Re-export core types at the crate root for convenience.
29pub use agents::AgentKind;
30pub use input::{HookInput, SessionStartHookInput, StopHookInput, ToolUseHookInput};
31pub use output::{
32    Effect, HookOutput, HookSpecificOutput, PermissionBehavior, PermissionDecision,
33    PermissionRequestOutput, PostToolUseOutput, PreToolUseOutput, SessionStartOutput,
34};
35pub use protocol::HookProtocol;