Run all the currently enabled hooks from both the global and profile contexts. # Returns A vector containing pairs of a [`Hook`] definition and its execution output
(
&mut self,
trigger: HookTrigger,
output: &mut impl Write,
os: &crate::os::Os,
prompt: Option<&str>,
tool_context: Option<crate::cli::chat::cli::hooks:
| 244 | /// # Returns |
| 245 | /// A vector containing pairs of a [`Hook`] definition and its execution output |
| 246 | pub async fn run_hooks( |
| 247 | &mut self, |
| 248 | trigger: HookTrigger, |
| 249 | output: &mut impl Write, |
| 250 | os: &crate::os::Os, |
| 251 | prompt: Option<&str>, |
| 252 | tool_context: Option<crate::cli::chat::cli::hooks::ToolContext>, |
| 253 | ) -> Result<Vec<((HookTrigger, Hook), HookOutput)>, ChatError> { |
| 254 | let mut hooks = self.hooks.clone(); |
| 255 | hooks.retain(|t, _| *t == trigger); |
| 256 | let cwd = os.env.current_dir()?.to_string_lossy().to_string(); |
| 257 | self.hook_executor |
| 258 | .run_hooks(hooks, output, &cwd, prompt, tool_context) |
| 259 | .await |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | /// Calculates the maximum context files size to use for the given model id. |
no test coverage detected