use crate::core::repomap;
pub fn handle(
project_root: &str,
max_tokens: usize,
focus_files: &[String],
session_files: &[String],
) -> String {
let graph = repomap::RepoGraph::build(project_root);
if graph.files.is_empty() {
return format!(
"No indexable files found in '{project_root}'. \
Ensure it contains source files (.rs, .ts, .py, etc.)."
);
}
let ranked = repomap::rank_symbols(&graph, session_files, focus_files);
if ranked.is_empty() {
return format!(
"No symbols extracted from {} files in '{project_root}'.",
graph.files.len()
);
}
repomap::fit_to_budget(&ranked, max_tokens)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn nonexistent_root_returns_helpful_message() {
let result = handle("/tmp/nonexistent_repo_map_test_dir", 2048, &[], &[]);
assert!(
result.contains("No indexable files") || result.contains("No symbols"),
"unexpected: {result}"
);
}
}