use anyhow::Result;
use clap::{Arg, Command};
use colored::Colorize;
use env_logger;
use log::{debug, info};
use std::path::PathBuf;
mod cli;
mod tools;
mod claude;
mod config;
use cli::ChatInterface;
use config::Config;
fn get_config_path() -> PathBuf {
let mut config_dir = dirs::config_dir().unwrap_or_else(|| PathBuf::from("."));
config_dir.push("tiny-trae");
config_dir.push("config.toml");
if config_dir.exists() {
return config_dir;
}
PathBuf::from("config.toml")
}
#[tokio::main]
async fn main() -> Result<()> {
env_logger::init();
let matches = Command::new("tiny-trae")
.version("0.1.0")
.author("Tiny Trae Team")
.about("An AI coding assistant with tool integration")
.arg(
Arg::new("config")
.short('c')
.long("config")
.value_name("FILE")
.help("Sets a custom config file")
)
.arg(
Arg::new("verbose")
.short('v')
.long("verbose")
.action(clap::ArgAction::SetTrue)
.help("Turn on verbose output")
)
.get_matches();
let config_path = if let Some(custom_path) = matches.get_one::<String>("config") {
PathBuf::from(custom_path)
} else {
get_config_path()
};
let verbose = matches.get_flag("verbose");
if verbose {
std::env::set_var("RUST_LOG", "debug");
}
println!("{}", "🤖 Tiny Trae AI Coding Agent v1.0".cyan().bold());
println!("{}", "Initializing...".yellow());
let config = Config::load(&config_path)?;
info!("Configuration loaded from: {}", config_path.display());
let mut chat_interface = ChatInterface::new(config).await?;
chat_interface.run().await?;
Ok(())
}