MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / run_hooks

Method run_hooks

crates/chat-cli/src/cli/chat/context.rs:246–260  ·  view source on GitHub ↗

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:

Source from the content-addressed store, hash-verified

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.

Callers 4

tool_use_executeMethod · 0.45
handle_responseMethod · 0.45
validate_toolsMethod · 0.45

Calls 3

to_stringMethod · 0.80
current_dirMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected