MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / install_hooks_into

Function install_hooks_into

atomic-agent/src/hooks/claude_code/mod.rs:330–351  ·  view source on GitHub ↗

Install all hook definitions into a `ClaudeHooks` struct. Returns the number of newly installed hooks.

(hooks: &mut ClaudeHooks, _settings_path: &Path)

Source from the content-addressed store, hash-verified

328///
329/// Returns the number of newly installed hooks.
330fn install_hooks_into(hooks: &mut ClaudeHooks, _settings_path: &Path) -> AgentResult<usize> {
331 let mut count = 0;
332 for (_label, matcher, verb) in HOOK_DEFS {
333 let command = format!("test -d .atomic && {} {} || true", ATOMIC_HOOK_PREFIX, verb);
334
335 let matchers = match *verb {
336 "session-start" => &mut hooks.session_start,
337 "session-end" => &mut hooks.session_end,
338 "stop" => &mut hooks.stop,
339 "user-prompt-submit" => &mut hooks.user_prompt_submit,
340 "pre-task" => &mut hooks.pre_tool_use,
341 "post-task" | "post-todo" | "post-tool" => &mut hooks.post_tool_use,
342 _ => continue,
343 };
344
345 if !settings::hook_command_exists(matchers, matcher, &command) {
346 settings::add_hook_to_matcher(matchers, matcher, &command);
347 count += 1;
348 }
349 }
350 Ok(count)
351}

Callers 2

install_globalMethod · 0.85
installMethod · 0.85

Calls 2

hook_command_existsFunction · 0.70
add_hook_to_matcherFunction · 0.70

Tested by

no test coverage detected