repotoire 0.8.2

Graph-powered code analysis CLI. 110 detectors for security, architecture, bus factor, and code quality.
Documentation
//! Remove our Claude Code hook entries from settings.json.

use anyhow::{Context, Result};

use super::settings::{
    atomic_write, cleanup_empty_containers, filter_pretool_entries, is_repotoire_hook_command,
    read_settings_or_empty, settings_path,
};

pub fn run() -> Result<()> {
    let path = match settings_path() {
        Ok(p) => p,
        Err(_) => {
            // No home and no CLAUDE_CONFIG_DIR — silently no-op. (Spec error table:
            // uninstall is fail-open on home_dir() returning None.)
            return Ok(());
        }
    };
    if !path.exists() {
        eprintln!("\u{2139} No settings.json to update.");
        return Ok(());
    }

    let mut root = read_settings_or_empty(&path)
        .with_context(|| format!("read settings.json at {}", path.display()))?;

    let removed = filter_pretool_entries(&mut root, is_repotoire_hook_command);
    if removed == 0 {
        eprintln!("\u{2139} No repotoire hooks found in settings.json.");
        return Ok(());
    }

    cleanup_empty_containers(&mut root);

    let out = serde_json::to_string_pretty(&root)?;
    atomic_write(&path, out.as_bytes())
        .with_context(|| format!("atomic write {}", path.display()))?;

    println!(
        "\u{2713} Uninstalled. Removed {removed} hook entr{}.",
        if removed == 1 { "y" } else { "ies" }
    );
    Ok(())
}