List all attestations in the repository.
(&self, repo: &Repository)
| 261 | |
| 262 | /// List all attestations in the repository. |
| 263 | fn list_all(&self, repo: &Repository) -> CliResult<()> { |
| 264 | let mut attestations: Vec<(Hash, Attestation)> = Vec::new(); |
| 265 | |
| 266 | for result in repo.change_store().iter_attestations() { |
| 267 | let hash = match result { |
| 268 | Ok(h) => h, |
| 269 | Err(e) => { |
| 270 | print_warning(&format!("Skipping corrupt attestation: {}", e)); |
| 271 | continue; |
| 272 | } |
| 273 | }; |
| 274 | |
| 275 | match repo.load_attestation(&hash) { |
| 276 | Ok(attest) => attestations.push((hash, attest)), |
| 277 | Err(e) => { |
| 278 | print_warning(&format!( |
| 279 | "Failed to load attestation {}: {}", |
| 280 | format_hash(&hash, false), |
| 281 | e |
| 282 | )); |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | if attestations.is_empty() { |
| 288 | println!("No attestations in this repository."); |
| 289 | println!(); |
| 290 | println!("Attestations are created when AI agent sessions end."); |
| 291 | println!("They capture cost, token usage, and model breakdown."); |
| 292 | return Ok(()); |
| 293 | } |
| 294 | |
| 295 | // Sort by timestamp descending (newest first) |
| 296 | attestations.sort_by_key(|a| std::cmp::Reverse(a.1.timestamp)); |
| 297 | |
| 298 | println!( |
| 299 | "{} attestation{}", |
| 300 | attestations.len(), |
| 301 | if attestations.len() == 1 { "" } else { "s" } |
| 302 | ); |
| 303 | println!(); |
| 304 | |
| 305 | for (hash, attest) in &attestations { |
| 306 | self.print_summary(hash, attest); |
| 307 | |
| 308 | if self.verbose { |
| 309 | self.print_models(attest); |
| 310 | println!(); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | let total_changes: usize = attestations.iter().map(|(_, a)| a.change_count()).sum(); |
| 315 | let total_cost: f64 = attestations.iter().map(|(_, a)| a.cost_usd).sum(); |
| 316 | let total_tokens: u64 = attestations.iter().map(|(_, a)| a.total_tokens()).sum(); |
| 317 | |
| 318 | println!("──────────────────────────────────────────"); |
| 319 | let mut summary = format!( |
| 320 | "{} {} covered", |
no test coverage detected