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

Method run_global

atomic-cli/src/commands/agent/enable.rs:613–753  ·  view source on GitHub ↗

Install hooks globally to the agent's user-level settings. Supports: - `claude-code` → `~/.claude/settings.json` - `gemini-cli` → `~/.gemini/settings.json` - `codex` → `~/.codex/hooks.json` agy is intentionally absent: its plugin is inherently global and is installed by the integrations engine via the standard `enable` path.

(&self)

Source from the content-addressed store, hash-verified

611 /// agy is intentionally absent: its plugin is inherently global and is
612 /// installed by the integrations engine via the standard `enable` path.
613 fn run_global(&self) -> CliResult<()> {
614 use atomic_agent::hooks::claude_code::ClaudeCodeHook;
615 use atomic_agent::hooks::codex::CodexHook;
616 use atomic_agent::hooks::gemini_cli::GeminiCliHook;
617
618 let agent_name = self.agent.as_deref().unwrap_or("claude-code");
619
620 match agent_name {
621 "claude-code" => {
622 let hook = ClaudeCodeHook::new();
623
624 if !self.force && hook.is_installed_global() {
625 print_success("Global hooks already installed in ~/.claude/settings.json.");
626 println!(" Use --force to reinstall.");
627 return Ok(());
628 }
629
630 match hook.install_global(self.force) {
631 Ok(count) if count > 0 => {
632 print_success(&format!(
633 "Installed {} global hook{} for Claude Code",
634 count,
635 if count == 1 { "" } else { "s" },
636 ));
637 println!();
638 println!("Hooks written to: ~/.claude/settings.json");
639 println!();
640 println!("Every Claude Code session in a project with .atomic/ will now:");
641 println!(" • Record each turn as an Atomic change with full provenance");
642 println!(" • Track session metadata (turn number, timing, files)");
643 println!(" • Create attestations at session end");
644 }
645 Ok(_) => {
646 print_success("Global hooks already up to date.");
647 }
648 Err(e) => {
649 print_error(&format!("Failed to install global hooks: {}", e));
650 }
651 }
652 }
653
654 "gemini-cli" => {
655 let hook = GeminiCliHook::new();
656
657 if !self.force && hook.is_installed_global() {
658 print_success("Global hooks already installed in ~/.gemini/settings.json.");
659 println!(" Use --force to reinstall.");
660 return Ok(());
661 }
662
663 match hook.install_global(self.force) {
664 Ok(count) if count > 0 => {
665 print_success(&format!(
666 "Installed {} global hook{} for Gemini CLI",
667 count,
668 if count == 1 { "" } else { "s" },
669 ));
670 println!();

Callers 1

runMethod · 0.45

Calls 5

print_successFunction · 0.85
print_errorFunction · 0.85
print_warningFunction · 0.85
is_installed_globalMethod · 0.45
install_globalMethod · 0.45

Tested by

no test coverage detected