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

Method run_global

atomic-cli/src/commands/agent/enable.rs:586–726  ·  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

584 /// agy is intentionally absent: its plugin is inherently global and is
585 /// installed by the integrations engine via the standard `enable` path.
586 fn run_global(&self) -> CliResult<()> {
587 use atomic_agent::hooks::claude_code::ClaudeCodeHook;
588 use atomic_agent::hooks::codex::CodexHook;
589 use atomic_agent::hooks::gemini_cli::GeminiCliHook;
590
591 let agent_name = self.agent.as_deref().unwrap_or("claude-code");
592
593 match agent_name {
594 "claude-code" => {
595 let hook = ClaudeCodeHook::new();
596
597 if !self.force && hook.is_installed_global() {
598 print_success("Global hooks already installed in ~/.claude/settings.json.");
599 println!(" Use --force to reinstall.");
600 return Ok(());
601 }
602
603 match hook.install_global(self.force) {
604 Ok(count) if count > 0 => {
605 print_success(&format!(
606 "Installed {} global hook{} for Claude Code",
607 count,
608 if count == 1 { "" } else { "s" },
609 ));
610 println!();
611 println!("Hooks written to: ~/.claude/settings.json");
612 println!();
613 println!("Every Claude Code session in a project with .atomic/ will now:");
614 println!(" • Record each turn as an Atomic change with full provenance");
615 println!(" • Track session metadata (turn number, timing, files)");
616 println!(" • Create attestations at session end");
617 }
618 Ok(_) => {
619 print_success("Global hooks already up to date.");
620 }
621 Err(e) => {
622 print_error(&format!("Failed to install global hooks: {}", e));
623 }
624 }
625 }
626
627 "gemini-cli" => {
628 let hook = GeminiCliHook::new();
629
630 if !self.force && hook.is_installed_global() {
631 print_success("Global hooks already installed in ~/.gemini/settings.json.");
632 println!(" Use --force to reinstall.");
633 return Ok(());
634 }
635
636 match hook.install_global(self.force) {
637 Ok(count) if count > 0 => {
638 print_success(&format!(
639 "Installed {} global hook{} for Gemini CLI",
640 count,
641 if count == 1 { "" } else { "s" },
642 ));
643 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