(&self)
| 47 | |
| 48 | impl Command for IntentGraph { |
| 49 | fn run(&self) -> CliResult<()> { |
| 50 | let review = self |
| 51 | .review_file |
| 52 | .as_deref() |
| 53 | .map(crate::commands::triage::read_publication_review) |
| 54 | .transpose()?; |
| 55 | let graph = crate::commands::rpc::intent_graph(&self.id, self.max_nodes as usize, review.as_ref()) |
| 56 | .map_err(|error| { |
| 57 | if error.to_string().contains("KgNeedsRebuild") { |
| 58 | CliError::InvalidArgument { |
| 59 | message: "workflow graph needs an explicit upgrade; run atomic query reindex --full, then retry intent graph".into(), |
| 60 | } |
| 61 | } else { error } |
| 62 | })?; |
| 63 | let output = if self.json { |
| 64 | serde_json::to_string_pretty(&graph).map_err(|e| CliError::Internal(e.into()))? + "\n" |
| 65 | } else if self.dot { |
| 66 | let mut nodes = graph.nodes.clone(); |
| 67 | annotate(&graph, &mut nodes); |
| 68 | let mut dot = crate::commands::query::emit_dot(&nodes, &graph.edges); |
| 69 | let notes = graph |
| 70 | .diagnostics |
| 71 | .iter() |
| 72 | .map(|s| format!("// {}\n", s.replace(['\n', '\r'], " "))) |
| 73 | .collect::<String>(); |
| 74 | dot.insert_str(0, ¬es); |
| 75 | dot |
| 76 | } else if self.html { |
| 77 | let mut nodes = graph.nodes.clone(); |
| 78 | annotate(&graph, &mut nodes); |
| 79 | let title = format!( |
| 80 | "Intent {} — {} implementing, {} intent-artifact recording, {} dependency-only changes{}", |
| 81 | self.id, |
| 82 | graph.implementing_changes.len(), |
| 83 | graph.recording_changes.len(), |
| 84 | graph.dependency_changes.len(), |
| 85 | if graph.truncated { " [TRUNCATED]" } else { "" } |
| 86 | ); |
| 87 | let html = crate::commands::query::emit_html(&title, &nodes, &graph.edges); |
| 88 | let notes = format!( |
| 89 | "<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>", |
| 90 | escape_html(&format!("Snapshot: {}\nScope: {}\n{}", graph.snapshot_identity, graph.scope, graph.diagnostics.join("\n"))) |
| 91 | ); |
| 92 | html.replacen( |
| 93 | "<canvas id=\"graph\">", |
| 94 | &format!("{notes}<canvas id=\"graph\">"), |
| 95 | 1, |
| 96 | ) |
| 97 | } else if self.details { |
| 98 | render_details(&graph) |
| 99 | } else { |
| 100 | render_text(&graph) |
| 101 | }; |
| 102 | // Text already includes the notes; exports keep diagnostics off stdout. |
| 103 | if self.json || self.dot || self.html { |
| 104 | for diagnostic in &graph.diagnostics { |
| 105 | eprintln!("Note: {diagnostic}"); |
| 106 | } |
nothing calls this directly
no test coverage detected