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

Function node_details

atomic-cli/src/commands/intent/graph.rs:317–362  ·  view source on GitHub ↗
(graph: &Graph, node: &atomic_core::KgNode)

Source from the content-addressed store, hash-verified

315}
316
317fn node_details(graph: &Graph, node: &atomic_core::KgNode) -> Vec<String> {
318 let mut lines = vec![
319 format!("ID: {}", one_line(&node.id)),
320 format!("Type: {}", compact(node.primary_type())),
321 ];
322 let label = if node.has_type(Class::File) {
323 metadata_text(node, "path").unwrap_or(&node.label)
324 } else {
325 &node.label
326 };
327 if console::measure_text_width(&one_line(label)) > 100 {
328 lines.push(format!("Label: {}", one_line(label)));
329 }
330 let mut annotated = [node.clone()];
331 annotate(graph, &mut annotated);
332 if let Some(summary) = &annotated[0].summary {
333 let summary = one_line(summary);
334 let summary = summary.trim();
335 // Context is the fallback role, not evidence or a useful summary.
336 let summary = summary.strip_prefix("[context]").unwrap_or(summary).trim();
337 if !summary.is_empty() {
338 lines.push(format!("Summary: {summary}"));
339 }
340 }
341 // References preserve graph direction without recursively expanding shared
342 // targets or cycles, so details cannot change the tree's grouping.
343 let mut edges: Vec<_> = graph
344 .edges
345 .iter()
346 .filter(|edge| edge.from_id == node.id)
347 .collect();
348 edges.sort_by(|a, b| (a.kind, &a.to_id).cmp(&(b.kind, &b.to_id)));
349 for edge in edges {
350 let mut line = format!("{} → {}", compact(edge.kind.iri()), one_line(&edge.to_id));
351 if let Some(evidence) = edge
352 .metadata
353 .as_ref()
354 .and_then(|m| m.get("declarationEvidence"))
355 .and_then(|v| v.as_str())
356 {
357 line.push_str(&format!(" [Declaration evidence: {}]", one_line(evidence)));
358 }
359 lines.push(line);
360 }
361 lines
362}
363
364fn metadata_text<'a>(node: &'a atomic_core::KgNode, key: &str) -> Option<&'a str> {
365 node.metadata.as_ref()?.get(key)?.as_str()

Callers 2

render_treeFunction · 0.85

Calls 13

metadata_textFunction · 0.85
has_typeMethod · 0.80
as_refMethod · 0.80
one_lineFunction · 0.70
annotateFunction · 0.70
getMethod · 0.65
pushMethod · 0.45
cloneMethod · 0.45
is_emptyMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
cmpMethod · 0.45

Tested by 1