cuenv_hooks/lib.rs
1//! Hook execution system for cuenv
2//!
3//! This crate provides the core hook execution functionality, including:
4//! - Hook definition and serialization
5//! - Background hook execution with state tracking
6//! - Approval-based security system
7//! - Shell integration support
8//!
9//! # Overview
10//!
11//! The hooks system enables environment-triggered command execution:
12//! - `onEnter` hooks run when entering a directory with a cuenv configuration
13//! - `onExit` hooks run when leaving such a directory
14//! - `prePush` hooks run before git push operations
15//!
16//! # Security
17//!
18//! All hook configurations must be approved by the user before execution.
19//! This prevents malicious configurations from executing arbitrary commands.
20//! In CI environments, hooks are auto-approved since the environment is
21//! assumed to be already secured.
22
23// TODO(hooks-docs): Add # Errors documentation to all fallible public functions
24#![expect(
25 clippy::missing_errors_doc,
26 reason = "Error documentation to be added incrementally"
27)]
28
29mod approval;
30mod error;
31mod executor;
32mod state;
33mod types;
34
35// Re-export error types at crate root
36pub use error::{Error, Result};
37
38// Re-export types
39pub use types::{ExecutionStatus, Hook, HookExecutionConfig, HookResult, Hooks};
40
41// Re-export state management
42pub use state::{HookExecutionState, StateManager, compute_execution_hash, compute_instance_hash};
43
44// Re-export executor
45pub use executor::{HookExecutor, execute_hooks};
46
47// Re-export approval management
48pub use approval::{
49 ApprovalManager, ApprovalRecord, ApprovalStatus, ConfigSummary, check_approval_status,
50 compute_approval_hash, compute_directory_key, is_ci,
51};