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

Method format_change_ledger

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

Format the change ledger (causal decision DAG) for display. Displays the structured provenance graph stored in the `.provenance` file: goals, tool executions, explorations, commitments, and patch proposals that led to this change.

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

Source from the content-addressed store, hash-verified

573 /// file: goals, tool executions, explorations, commitments, and patch
574 /// proposals that led to this change.
575 fn format_change_ledger(&self, change_hash: &Hash, repo: &Repository) -> String {
576 let mut output = String::new();
577
578 let graphs = match repo.find_provenance_for_change(change_hash) {
579 Ok(g) if !g.is_empty() => g,
580 Ok(_) => {
581 output.push_str(&format!(
582 "{}\n",
583 hint("No provenance graph found for this change.")
584 ));
585 return output;
586 }
587 Err(e) => {
588 output.push_str(&format!(
589 "{}\n",
590 hint(&format!("Failed to load provenance: {}", e))
591 ));
592 return output;
593 }
594 };
595
596 for (_graph_hash, graph) in &graphs {
597 output.push_str(&format!("{}\n", emphasis("=== Change Ledger ===")));
598 output.push_str(&format!(" Session: {}\n", info(&graph.session_id)));
599 output.push_str(&format!(
600 " Agent: {} ({})\n",
601 info(&graph.agent_display_name),
602 hint(&graph.agent_vendor)
603 ));
604 output.push_str(&format!(
605 " Nodes: {} Edges: {} Changes: {}\n",
606 graph.node_count(),
607 graph.edge_count(),
608 graph.change_count()
609 ));
610 output.push('\n');
611
612 // Display nodes
613 for node in &graph.nodes {
614 let kind_str = format!("{}", node.kind);
615 let kind_styled = format!("{}", style(&kind_str).bold().cyan());
616 let duration = node
617 .duration_ms
618 .map(|ms| format!(" ({}ms)", ms))
619 .unwrap_or_default();
620 let tool = node.tool_name.as_deref().unwrap_or("");
621 let tool_str = if tool.is_empty() {
622 String::new()
623 } else {
624 format!(" {}", hint(&format!("[{}]", tool)))
625 };
626
627 // Extract a one-line detail string from the structured detail JSON
628 let detail_str = node
629 .detail
630 .as_ref()
631 .and_then(|d| format_node_detail(d))
632 .map(|s| format!("\n {}", hint(&s)))

Callers 1

format_defaultMethod · 0.80

Calls 5

format_node_detailFunction · 0.85
as_refMethod · 0.80
is_emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected