(&self)
| 267 | |
| 268 | impl Command for MemoryList { |
| 269 | fn run(&self) -> CliResult<()> { |
| 270 | let root = find_repository_root()?; |
| 271 | let repo = Repository::open(&root).map_err(CliError::Repository)?; |
| 272 | |
| 273 | let verifier = resolve_verifier(&self.identity)?; |
| 274 | |
| 275 | // Enumerate via the SAME call `atomic vault memory list` makes; the |
| 276 | // `memory/` prefix already excludes attestation entries, and the filter |
| 277 | // is a belt-and-suspenders guard (mirrors memory/mod.rs' invariant test). |
| 278 | let entries = repo |
| 279 | .vault_list("memory/", None) |
| 280 | .map_err(CliError::Repository)?; |
| 281 | let mut items: Vec<(String, String)> = entries |
| 282 | .iter() |
| 283 | .filter(|e| !e.path.starts_with("attestations/")) |
| 284 | // The default `memory/MEMORY.md` index scaffold is NOT a canonical |
| 285 | // memory (no `uid`/`memoryKind`; its frontmatter is `type:index`). |
| 286 | // Skip it so the attestation-aware list only shows real memories. |
| 287 | .filter(|e| !is_index_scaffold(&repo, &e.path)) |
| 288 | .map(|e| (bridge::memory_id(&e.path), e.updated_at.clone())) |
| 289 | .collect(); |
| 290 | // Most-recent first (`updated_at` is RFC 3339, so lexical == chronological); |
| 291 | // id as a stable tiebreaker. |
| 292 | items.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(&b.0))); |
| 293 | if let Some(limit) = self.limit { |
| 294 | items.truncate(limit); |
| 295 | } |
| 296 | |
| 297 | let rows: Vec<Row> = items |
| 298 | .iter() |
| 299 | .map(|(id, _)| compute_row(&repo, id, verifier.as_ref())) |
| 300 | .collect(); |
| 301 | |
| 302 | if self.json { |
| 303 | let json: Vec<serde_json::Value> = rows |
| 304 | .iter() |
| 305 | .map(|r| { |
| 306 | serde_json::json!({ |
| 307 | "id": r.id, |
| 308 | "kind": r.kind, |
| 309 | "status": r.status, |
| 310 | "about": r.about, |
| 311 | "attested": r.attested.json(), |
| 312 | "verifies": r.verifies.json(), |
| 313 | }) |
| 314 | }) |
| 315 | .collect(); |
| 316 | println!("{}", serde_json::to_string_pretty(&json).unwrap()); |
| 317 | return Ok(()); |
| 318 | } |
| 319 | |
| 320 | if rows.is_empty() { |
| 321 | println!("No memories found."); |
| 322 | return Ok(()); |
| 323 | } |
| 324 | |
| 325 | // Fixed-width, left-aligned columns with a header row. |
| 326 | let id_w = col_width(rows.iter().map(|r| r.id.chars().count()), "id"); |
nothing calls this directly
no test coverage detected