agent_trace/commands/
info.rs1use crate::observability::CliOutput;
2use crate::store::Store;
3use anyhow::Result;
4use std::path::Path;
5
6pub fn run(store_root: &Path, file: &Path, output: &dyn CliOutput) -> Result<()> {
7 let store = Store::open(store_root)?;
8 let entry = store
9 .manifest
10 .find_by_path(file)
11 .ok_or_else(|| anyhow::anyhow!("File not tracked: {}", file.display()))?;
12
13 let version_count = store.git.count_file_commits(file)? as u32;
15
16 let history = store.git.log_file(file, version_count as usize)?;
21 let created = history
22 .last()
23 .map(|e| e.timestamp.to_string())
24 .unwrap_or_else(|| "unknown".into());
25 let last_modified = history
26 .first()
27 .map(|e| e.timestamp.to_string())
28 .unwrap_or_else(|| "unknown".into());
29 let created_by = history
30 .last()
31 .map(|e| e.actor.to_string())
32 .unwrap_or_else(|| "unknown".into());
33
34 output.line(&format!("Path: {}", entry.path.display()))?;
35 output.line(&format!("Type: {}", entry.doc_type))?;
36 output.line(&format!("ID: {}", entry.id))?;
37 output.line(&format!("Tags: {}", entry.tags.join(", ")))?;
38 output.line(&format!("Description: {}", entry.description))?;
39 output.line(&format!("Agent: {}", entry.agent_name))?;
40 output.line(&format!("Versions: {version_count}"))?;
41 output.line(&format!("Created: {created}"))?;
42 output.line(&format!("Last modified: {last_modified}"))?;
43 output.line(&format!("Created by: {created_by}"))?;
44
45 Ok(())
46}