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

Function render_tree

atomic-cli/src/commands/intent/graph.rs:171–304  ·  view source on GitHub ↗
(graph: &Graph, details: bool)

Source from the content-addressed store, hash-verified

169}
170
171fn render_tree(graph: &Graph, details: bool) -> String {
172 use std::collections::BTreeMap;
173
174 let root = graph.nodes.iter().find(|node| node.id == graph.root);
175 let mut out = match root {
176 Some(node) => {
177 let key = metadata_text(node, "human_key");
178 let label = tree_label(node);
179 format!(
180 "Intent{} — {label}\n",
181 key.map(|s| format!(" {s}")).unwrap_or_default()
182 )
183 }
184 None => "Intent [root missing]\n".into(),
185 };
186 out.push_str(&format!(
187 "{} nodes · {} implementing · {} recording · {} dependency-only{}\n",
188 graph.nodes.len(),
189 graph.implementing_changes.len(),
190 graph.recording_changes.len(),
191 graph.dependency_changes.len(),
192 if graph.truncated {
193 " · [TRUNCATED]"
194 } else {
195 ""
196 },
197 ));
198
199 // These are presentation groups, not newly asserted graph edges. Each
200 // selected node appears once, even when it has multiple incoming edges.
201 let mut groups: BTreeMap<(u8, String), Vec<&atomic_core::KgNode>> = BTreeMap::new();
202 for node in graph.nodes.iter().filter(|node| node.id != graph.root) {
203 let group = if graph.implementing_changes.contains(&node.id) {
204 (0, "Implementing changes".into())
205 } else if graph.recording_changes.contains(&node.id) {
206 (1, "Intent recording evidence (not implementation)".into())
207 } else if graph.dependency_changes.contains(&node.id) {
208 (2, "Dependency-only changes".into())
209 } else if graph.reviewed_changes.contains(&node.id) {
210 (
211 2,
212 "Review scope and evidence (not implementation attribution)".into(),
213 )
214 } else if graph.intent_artifact.as_ref() == Some(&node.id) {
215 (3, "Intent artifact".into())
216 } else if node.has_type(Class::Task) {
217 (4, "Tasks".into())
218 } else if node.has_type(Class::AcceptanceCriterion) {
219 (5, "Acceptance criteria".into())
220 } else if node.has_type(Class::ScopeItem) {
221 (6, "Scope".into())
222 } else if node.has_type(Class::Constraint) {
223 (7, "Constraints".into())
224 } else if node.has_type(Class::File) {
225 (8, "Files".into())
226 } else {
227 (
228 9,

Callers 2

render_textFunction · 0.85
render_detailsFunction · 0.85

Calls 15

metadata_textFunction · 0.85
tree_labelFunction · 0.85
node_detailsFunction · 0.85
write_tree_childrenFunction · 0.85
as_refMethod · 0.80
has_typeMethod · 0.80
primary_typeMethod · 0.80
extendMethod · 0.80
compactFunction · 0.50
iterMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected