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

Method run

atomic-cli/src/commands/intent/graph.rs:44–106  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

42
43impl Command for IntentGraph {
44 fn run(&self) -> CliResult<()> {
45 let graph = crate::commands::rpc::intent_graph(&self.id, self.max_nodes as usize)
46 .map_err(|error| {
47 if error.to_string().contains("KgNeedsRebuild") {
48 CliError::InvalidArgument {
49 message: "workflow graph needs an explicit upgrade; run atomic query reindex --full, then retry intent graph".into(),
50 }
51 } else { error }
52 })?;
53 let output = if self.json {
54 serde_json::to_string_pretty(&graph).map_err(|e| CliError::Internal(e.into()))? + "\n"
55 } else if self.dot {
56 let mut nodes = graph.nodes.clone();
57 annotate(&graph, &mut nodes);
58 let mut dot = crate::commands::query::emit_dot(&nodes, &graph.edges);
59 let notes = graph
60 .diagnostics
61 .iter()
62 .map(|s| format!("// {}\n", s.replace(['\n', '\r'], " ")))
63 .collect::<String>();
64 dot.insert_str(0, &notes);
65 dot
66 } else if self.html {
67 let mut nodes = graph.nodes.clone();
68 annotate(&graph, &mut nodes);
69 let title = format!(
70 "Intent {} — {} implementing, {} intent-artifact recording, {} dependency-only changes{}",
71 self.id,
72 graph.implementing_changes.len(),
73 graph.recording_changes.len(),
74 graph.dependency_changes.len(),
75 if graph.truncated { " [TRUNCATED]" } else { "" }
76 );
77 let html = crate::commands::query::emit_html(&title, &nodes, &graph.edges);
78 let notes = format!(
79 "<details style=\"position:absolute;top:8px;left:16px;z-index:15;max-width:min(650px, calc(100% - 32px));background:#1a1a2e;padding:10px\"><summary>Scope and evidence notes</summary><pre style=\"white-space:pre-wrap\">{}</pre></details>",
80 escape_html(&format!("Snapshot: {}\nScope: {}\n{}", graph.snapshot_identity, graph.scope, graph.diagnostics.join("\n")))
81 );
82 html.replacen(
83 "<canvas id=\"graph\">",
84 &format!("{notes}<canvas id=\"graph\">"),
85 1,
86 )
87 } else if self.details {
88 render_details(&graph)
89 } else {
90 render_text(&graph)
91 };
92 // Text already includes the notes; exports keep diagnostics off stdout.
93 if self.json || self.dot || self.html {
94 for diagnostic in &graph.diagnostics {
95 eprintln!("Note: {diagnostic}");
96 }
97 }
98 if self.html && !self.no_open {
99 write_and_open_html(&output, self.output.as_deref(), |url| open::that(url))?;
100 } else if let Some(path) = &self.output {
101 std::fs::write(path, output)?;

Callers

nothing calls this directly

Calls 11

intent_graphFunction · 0.85
emit_dotFunction · 0.85
emit_htmlFunction · 0.85
render_detailsFunction · 0.85
annotateFunction · 0.70
render_textFunction · 0.70
write_and_open_htmlFunction · 0.70
writeFunction · 0.50
containsMethod · 0.45
cloneMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected