use crate::core::db::DbManager;
use crate::core::{db_path, find_project_root, AGENTLOG_DIR};
use anyhow::Result;
use colored::Colorize;
pub async fn execute() -> Result<()> {
match find_project_root() {
Ok(root) => {
println!("{}", "AgentLog Status".bold().underline());
println!();
println!("Project root: {}", root.display());
let agentlog_dir = root.join(AGENTLOG_DIR);
println!("AgentLog dir: {}", agentlog_dir.display());
let db_file = db_path(&root);
if db_file.exists() {
let metadata = std::fs::metadata(&db_file)?;
let size_kb = metadata.len() as f64 / 1024.0;
println!("Database: {} ({:.2} KB)", db_file.display(), size_kb);
let db = DbManager::open(&db_file)?;
let event_count = db.get_event_count()?;
println!("Total events: {}", event_count);
} else {
println!("Database: {} {}", db_file.display(), "(not found)".red());
}
println!();
println!("{}", "AgentLog is initialized and ready.".green());
}
Err(_) => {
println!("{}", "AgentLog is not initialized.".red().bold());
println!();
println!("Run 'agentlog init' to set up AgentLog in this project.");
}
}
Ok(())
}