//! ctx-compress: fit repositories into context windows. mod heat; mod tokenize; pub struct Budget(pub usize); #[derive(Default)] pub struct Packed { pub summary: String, pub kept: Vec, pub elided: usize, pub tokens: usize, } pub fn pack(root: &Path, budget: Budget) -> Result { let tree = scan(root)?; let ranked = heat::rank(&tree); let mut out = Packed::default(); for file in ranked { let cost = tokenize::count(&file); if out.tokens + cost > budget.0 { out.elided += 1; continue; } out.kept.push(file.path.clone()); out.tokens += cost; } out.summary = render(&tree, &out.kept); Ok(out) }