codetree 0.1.1

AI-native version control system for autonomous agents
Documentation
//! Simple library usage example for CodeTree
//!
//! This example demonstrates how to use CodeTree as a library in your own application.
//! Run with: cargo run --example simple_usage

use codetree::{BranchManager, Config, VcsManager};
use codetree::error::Result;

#[tokio::main]
async fn main() -> Result<()> {
    println!("CodeTree Library Usage Example\n");

    // 1. Load or create configuration
    let config_path = std::path::Path::new("codetree.toml");
    let config = if config_path.exists() {
        Config::load(config_path).await?
    } else {
        Config::default()
    };

    println!("Configuration loaded");

    // 2. Create a VCS manager for repository operations
    let current_dir = std::env::current_dir()?;
    let _vcs_manager = VcsManager::new(current_dir.clone())?;

    println!("VCS manager created");

    // 3. Create a branch manager to track branches
    let codetree_dir = current_dir.join(".codetree");
    let branches_path = codetree_dir.join("branches.json");
    let _branch_manager = BranchManager::new(branches_path).await?;
    println!("Branch manager created");

    // 4. Demonstrate manual branch creation
    println!("\nCreating a sample branch...");
    let sample_branch_name = "example-feature";
    let sample_files = vec![
        "src/main.rs".to_string(),
        "src/lib.rs".to_string(),
    ];
    let sample_description = "Example feature branch".to_string();

    println!("  Branch name: {}", sample_branch_name);
    println!("  Files: {:?}", sample_files);
    println!("  Description: {}", sample_description);

    // 5. Demonstrate configuration access
    println!("\nConfiguration Summary:");
    println!("  Git:");
    println!("    - Branch prefix: {}", config.git.branch_prefix);
    println!("    - Base branch: {}", config.git.base_branch);

    println!("\nExample completed successfully!");
    println!("\nNote: This example demonstrates the library API. For MCP server integration,");
    println!("run 'codetree-mcp' to start the Model Context Protocol server.");

    Ok(())
}