(&self)
| 60 | |
| 61 | impl Command for Summaries { |
| 62 | fn run(&self) -> CliResult<()> { |
| 63 | let root = find_repository_root()?; |
| 64 | let repo = Repository::open(&root).map_err(CliError::Repository)?; |
| 65 | |
| 66 | let prefix = match &self.goal { |
| 67 | Some(name) => format!("goals/{}/", name), |
| 68 | None => "goals/".to_string(), |
| 69 | }; |
| 70 | |
| 71 | let entries = repo |
| 72 | .vault_list(&prefix, Some(VaultEntryType::ToolResult)) |
| 73 | .map_err(CliError::Repository)?; |
| 74 | |
| 75 | let mut summaries = serde_json::Map::new(); |
| 76 | for meta in &entries { |
| 77 | // Extract tool_use_id from filename |
| 78 | // e.g., "goals/abc/toolu_xyz.md" -> "toolu_xyz" |
| 79 | let filename = meta.path.rsplit('/').next().unwrap_or(&meta.path); |
| 80 | let id = filename.strip_suffix(".md").unwrap_or(filename); |
| 81 | |
| 82 | // Get a preview (first 200 chars of content) |
| 83 | if let Ok(Some(entry)) = repo.vault_retrieve(&meta.path) { |
| 84 | let content = String::from_utf8_lossy(&entry.content_bytes); |
| 85 | let preview: String = content.chars().take(200).collect(); |
| 86 | summaries.insert(id.to_string(), serde_json::Value::String(preview)); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | let output = serde_json::Value::Object(summaries); |
| 91 | println!("{}", serde_json::to_string_pretty(&output).unwrap()); |
| 92 | |
| 93 | Ok(()) |
| 94 | } |
| 95 | } |
nothing calls this directly
no test coverage detected