#![allow(dead_code, unused_imports, unused_variables)]
use super::{HookConfig, HookEvent};
pub fn format_on_save_rust() -> HookConfig {
HookConfig {
event: HookEvent::PostToolUse,
command: "cargo fmt -- {path}".to_string(),
match_tools: vec!["file_write".to_string(), "file_edit".to_string()],
timeout_secs: 30,
}
}
pub fn lint_after_edit_rust() -> HookConfig {
HookConfig {
event: HookEvent::PostToolUse,
command: "cargo clippy --quiet -- -D warnings 2>&1 | head -20".to_string(),
match_tools: vec!["file_write".to_string(), "file_edit".to_string()],
timeout_secs: 60,
}
}
pub fn test_on_stop_rust() -> HookConfig {
HookConfig {
event: HookEvent::Stop,
command: "cargo test --quiet 2>&1 | tail -5".to_string(),
match_tools: vec![],
timeout_secs: 120,
}
}
pub fn auto_commit() -> HookConfig {
HookConfig {
event: HookEvent::PostToolUse,
command: "git add {path} && git commit -m \"[selfware] auto-commit: {tool} {path}\" --no-verify 2>/dev/null || true".to_string(),
match_tools: vec!["file_write".to_string(), "file_edit".to_string()],
timeout_secs: 15,
}
}
pub fn format_on_save_python() -> HookConfig {
HookConfig {
event: HookEvent::PostToolUse,
command: "ruff format {path} 2>/dev/null || black {path} 2>/dev/null || true".to_string(),
match_tools: vec!["file_write".to_string(), "file_edit".to_string()],
timeout_secs: 15,
}
}
pub fn format_on_save_node() -> HookConfig {
HookConfig {
event: HookEvent::PostToolUse,
command: "npx prettier --write {path} 2>/dev/null || true".to_string(),
match_tools: vec!["file_write".to_string(), "file_edit".to_string()],
timeout_secs: 15,
}
}
#[cfg(test)]
#[path = "../../tests/unit/hooks/builtin/builtin_test.rs"]
mod tests;