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

Method exec_list_entities

atomic-repository/src/ai/tools.rs:999–1034  ·  view source on GitHub ↗
(&self, args: &serde_json::Value)

Source from the content-addressed store, hash-verified

997 }
998
999 fn exec_list_entities(&self, args: &serde_json::Value) -> Result<String, String> {
1000 let path_str = args["path"]
1001 .as_str()
1002 .ok_or("missing required parameter: path")?;
1003
1004 if !atomic_semantic::is_supported(path_str) {
1005 return Err(format!("unsupported file type: {path_str}"));
1006 }
1007
1008 let full_path = self.root.join(path_str);
1009 let source = std::fs::read_to_string(&full_path)
1010 .map_err(|e| format!("cannot read {path_str}: {e}"))?;
1011
1012 let mut registry = atomic_semantic::ParserRegistry::new();
1013 let entities = registry.extract(path_str, &source);
1014
1015 // Serialize a compact representation.
1016 let compact: Vec<serde_json::Value> = entities
1017 .iter()
1018 .map(|e| {
1019 let mut obj = json!({
1020 "name": e.name,
1021 "kind": e.kind.as_str(),
1022 "line": e.line,
1023 "end_line": e.end_line,
1024 "exported": e.exported,
1025 });
1026 if let Some(sig) = &e.signature {
1027 obj["signature"] = json!(sig);
1028 }
1029 obj
1030 })
1031 .collect();
1032
1033 serde_json::to_string_pretty(&compact).map_err(|e| format!("serialize error: {e}"))
1034 }
1035}
1036
1037// ── Helpers ─────────────────────────────────────────────────────

Callers 1

executeMethod · 0.80

Calls 4

is_supportedFunction · 0.85
as_strMethod · 0.45
extractMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected