MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / format_provenance_graph

Method format_provenance_graph

atomic-cli/src/commands/change/command.rs:597–675  ·  view source on GitHub ↗

Format the provenance decision graph for display.

(&self, change_hash: &Hash, repo: &Repository)

Source from the content-addressed store, hash-verified

595
596 /// Format the provenance decision graph for display.
597 fn format_provenance_graph(&self, change_hash: &Hash, repo: &Repository) -> String {
598 let mut output = String::new();
599
600 let graphs = match repo.find_provenance_for_change(change_hash) {
601 Ok(g) if !g.is_empty() => g,
602 Ok(_) => {
603 output.push_str(&format!(
604 "{}\n",
605 hint("No provenance graph found for this change.")
606 ));
607 return output;
608 }
609 Err(e) => {
610 output.push_str(&format!(
611 "{}\n",
612 hint(&format!("Failed to load provenance: {}", e))
613 ));
614 return output;
615 }
616 };
617
618 for (_graph_hash, graph) in &graphs {
619 output.push_str(&format!("{}\n", emphasis("Provenance Graph:")));
620 output.push_str(&format!(" Session: {}\n", info(&graph.session_id)));
621 output.push_str(&format!(
622 " Agent: {} ({})\n",
623 info(&graph.agent_display_name),
624 hint(&graph.agent_vendor)
625 ));
626 output.push_str(&format!(
627 " Nodes: {} Edges: {} Changes: {}\n",
628 graph.node_count(),
629 graph.edge_count(),
630 graph.change_count()
631 ));
632 output.push('\n');
633
634 // Display nodes
635 for node in &graph.nodes {
636 let kind_str = format!("{}", node.kind);
637 let kind_styled = format!("{}", style(&kind_str).bold().cyan());
638 let duration = node
639 .duration_ms
640 .map(|ms| format!(" ({}ms)", ms))
641 .unwrap_or_default();
642 let tool = node.tool_name.as_deref().unwrap_or("");
643 let tool_str = if tool.is_empty() {
644 String::new()
645 } else {
646 format!(" {}", hint(&format!("[{}]", tool)))
647 };
648
649 output.push_str(&format!(
650 " {} {} {}{}{}\n",
651 kind_styled,
652 hint("\u{00bb}"),
653 node.summary,
654 tool_str,

Callers 1

format_defaultMethod · 0.80

Calls 4

is_emptyMethod · 0.45
pushMethod · 0.45
edge_countMethod · 0.45

Tested by

no test coverage detected