codetree 0.1.2

AI-native version control system for autonomous agents
Documentation
use crate::error::{Context, Result};

use crate::freeze::FrozenPaths;

pub async fn freeze_command(path: String) -> Result<()> {
    let current_dir = std::env::current_dir()
        .context("Failed to get current directory")?;
    let frozen_path = current_dir.join(".codetree").join("frozen.json");
    let mut frozen = FrozenPaths::load(frozen_path)?;
    if frozen.freeze(&path) {
        frozen.save()?;
        println!("Frozen: {}", path);
    } else {
        println!("Already frozen: {}", path);
    }
    Ok(())
}

pub async fn unfreeze_command(path: String, _force: bool) -> Result<()> {
    let current_dir = std::env::current_dir()
        .context("Failed to get current directory")?;
    let frozen_path = current_dir.join(".codetree").join("frozen.json");
    let mut frozen = FrozenPaths::load(frozen_path)?;
    if frozen.unfreeze(&path) {
        frozen.save()?;
        println!("Unfrozen: {}", path);
    } else {
        println!("Not frozen: {}", path);
    }
    Ok(())
}

pub async fn frozen_command() -> Result<()> {
    let current_dir = std::env::current_dir()
        .context("Failed to get current directory")?;
    let frozen_path = current_dir.join(".codetree").join("frozen.json");
    let frozen = FrozenPaths::load(frozen_path)?;
    if frozen.is_empty() {
        println!("No frozen paths");
        return Ok(());
    }
    println!("Frozen paths:");
    for path in frozen.list() {
        println!("  {}", path);
    }
    Ok(())
}