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