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

Method exec_code_search

atomic-repository/src/ai/tools.rs:969–1003  ·  view source on GitHub ↗

Search recorded source in this working copy's desired view. Renders bytes from the graph through the view's closure rather than consulting the working-copy content index, so results match `atomic query code`, are filtered by the view, and cover recorded files that are not materialized on disk.

(&self, args: &serde_json::Value)

Source from the content-addressed store, hash-verified

967 /// `atomic query code`, are filtered by the view, and cover recorded
968 /// files that are not materialized on disk.
969 fn exec_code_search(&self, args: &serde_json::Value) -> Result<String, String> {
970 let pattern = args["pattern"]
971 .as_str()
972 .ok_or("missing required parameter: pattern")?;
973
974 let opts = crate::content_search::ContentSearchOptions {
975 path_filter: args["path_filter"].as_str().map(String::from),
976 file_type: args["file_type"].as_str().map(String::from),
977 exclude_type: None,
978 max_results: Some(args["max_results"].as_u64().unwrap_or(30) as usize),
979 case_insensitive: false,
980 };
981
982 let view = self
983 .desired_view()
984 .map_err(|e| format!("code_search failed: {e}"))?;
985 match self.repo.search_content_on_view(&view, pattern, opts) {
986 Ok(result) => {
987 if result.matches.is_empty() {
988 Ok("No matches found.".into())
989 } else {
990 // Build a compact response with matches + metadata
991 let response = json!({
992 "matches": result.matches,
993 "total_matches": result.total_matches,
994 "showing": result.matches.len(),
995 "dir_facets": result.dir_facets,
996 });
997 serde_json::to_string_pretty(&response)
998 .map_err(|e| format!("serialize error: {e}"))
999 }
1000 }
1001 Err(e) => Err(format!("code_search failed: {e}")),
1002 }
1003 }
1004
1005 fn exec_vault_read(&self, args: &serde_json::Value) -> Result<String, String> {
1006 let path = args["path"]

Callers 1

executeMethod · 0.80

Calls 5

as_u64Method · 0.80
desired_viewMethod · 0.80
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected