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

Method exec_list_entities

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

Source from the content-addressed store, hash-verified

1022 }
1023
1024 fn exec_list_entities(&self, args: &serde_json::Value) -> Result<String, String> {
1025 let path_str = args["path"]
1026 .as_str()
1027 .ok_or("missing required parameter: path")?;
1028
1029 if !atomic_semantic::is_supported(path_str) {
1030 return Err(format!("unsupported file type: {path_str}"));
1031 }
1032
1033 let full_path = self.root.join(path_str);
1034 let source = std::fs::read_to_string(&full_path)
1035 .map_err(|e| format!("cannot read {path_str}: {e}"))?;
1036
1037 let mut registry = atomic_semantic::ParserRegistry::new();
1038 let entities = registry.extract(path_str, &source);
1039
1040 // Serialize a compact representation.
1041 let compact: Vec<serde_json::Value> = entities
1042 .iter()
1043 .map(|e| {
1044 let mut obj = json!({
1045 "name": e.name,
1046 "kind": e.kind.as_str(),
1047 "line": e.line,
1048 "end_line": e.end_line,
1049 "exported": e.exported,
1050 });
1051 if let Some(sig) = &e.signature {
1052 obj["signature"] = json!(sig);
1053 }
1054 obj
1055 })
1056 .collect();
1057
1058 serde_json::to_string_pretty(&compact).map_err(|e| format!("serialize error: {e}"))
1059 }
1060}
1061
1062// ── Helpers ─────────────────────────────────────────────────────

Callers 1

executeMethod · 0.80

Calls 5

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

Tested by

no test coverage detected