feat(hooks): add user-configurable hook system#2757
Conversation
… handle PreToolUse blocking in orchestrator
…ay for UserHookEventName
| #[test] | ||
| fn test_no_matcher_group_fires_unconditionally() { | ||
| let json = r#"{ | ||
| "PostToolUse": [ |
# Conflicts: # crates/forge_app/src/app.rs # crates/forge_app/src/orch_spec/orch_setup.rs # crates/forge_config/src/config.rs # crates/forge_domain/src/env.rs # crates/forge_infra/src/env.rs # crates/forge_main/src/info.rs
|
great looking forward for this ! |
|
Went through the full diff. Really nice work, the layering between config/executor/handler/service is clean and the exit code convention (0/1/2) is simple enough that hook authors won't have to think twice. The A few things I noticed: The
The SessionStart hooks can't block, but the code doesn't make that obvious. The handler runs the hooks and checks for Regex gets recompiled on every event. Small thing: the Cleanup: the Overall this is solid. The main things before merge are the |
| let feedback_msg = format!( | ||
| "<hook_feedback>\n<event>UserPromptSubmit</event>\n<status>blocked</status>\n<reason>{reason}</reason>\n</hook_feedback>" | ||
| ); | ||
| context |
| ChatResponse::HookError { tool_name, reason } => { | ||
| writer.finish()?; | ||
| self.spinner.stop(None)?; | ||
| self.writeln_title(TitleFormat::error(format!( | ||
| "PreToolUse:{tool_name} hook error: {reason}" | ||
| )))?; | ||
| self.spinner.start(None)?; |
There was a problem hiding this comment.
The error message format is incorrect. It displays PreToolUse:{tool_name} which will produce output like PreToolUse:Bash without a space. Should format as:
self.writeln_title(TitleFormat::error(format!(
"PreToolUse: {} - Hook error: {}", tool_name, reason
)))?;| ChatResponse::HookError { tool_name, reason } => { | |
| writer.finish()?; | |
| self.spinner.stop(None)?; | |
| self.writeln_title(TitleFormat::error(format!( | |
| "PreToolUse:{tool_name} hook error: {reason}" | |
| )))?; | |
| self.spinner.start(None)?; | |
| ChatResponse::HookError { tool_name, reason } => { | |
| writer.finish()?; | |
| self.spinner.stop(None)?; | |
| self.writeln_title(TitleFormat::error(format!( | |
| "PreToolUse: {} - Hook error: {}", tool_name, reason | |
| )))?; | |
| self.spinner.start(None)?; | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
No description provided.