use crate::db::Database;
use crate::models::downloader::{is_dense_model_installed, is_model_installed};
use anyhow::Result;
use colored::Colorize;
use std::env;
pub fn run() -> Result<()> {
let project_root = env::current_dir()?;
if !Database::minni_dir_exists(&project_root) {
println!(
"{} Minni is not initialized in this directory.",
"!".yellow()
);
println!("Run {} to initialize.", "minni init".cyan());
return Ok(());
}
let db = Database::open(&project_root)?;
let stats = db.get_stats()?;
let project_name = project_root
.file_name()
.and_then(|s| s.to_str())
.unwrap_or("unknown");
println!("{} Minni Status\n", "→".blue());
println!("Project: {}", project_name.cyan().bold());
println!("Path: {}\n", project_root.display());
println!("{}", "Index:".bold());
println!(" Files indexed: {}", stats.file_count.to_string().cyan());
println!(" Code chunks: {}", stats.chunk_count.to_string().cyan());
if let Some(last) = &stats.last_indexed {
println!(" Last indexed: {}", last.yellow());
}
println!();
println!("{}", "Contexts:".bold());
println!(
" Saved contexts: {}",
stats.context_count.to_string().cyan()
);
let model_status = if is_model_installed() {
"installed".green().to_string()
} else {
"not installed (will download on first search)"
.yellow()
.to_string()
};
let dense_status = if is_dense_model_installed() {
"installed".green().to_string()
} else {
"not installed (will download on first search)"
.yellow()
.to_string()
};
println!();
println!("{}", "Search:".bold());
println!(" BM25 index: {}", "active".green());
println!(" Reranker model: {}", model_status);
println!(" Dense model: {}", dense_status);
Ok(())
}