MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / search_files

Function search_files

tools/shell_tools.py:70–85  ·  view source on GitHub ↗

Search for files matching pattern. Uses subprocess list args to prevent injection.

(pattern: str, path: str = ".")

Source from the content-addressed store, hash-verified

68 return f"[ERROR] {e}"
69
70def search_files(pattern: str, path: str = ".") -> str:
71 """Search for files matching pattern. Uses subprocess list args to prevent injection."""
72 try:
73 result = subprocess.run(
74 ["find", path, "-name", pattern],
75 capture_output=True, text=True, timeout=15
76 )
77 lines = (result.stdout + result.stderr).strip().splitlines()
78 lines = [l for l in lines if l.strip()][:50]
79 return "\n".join(lines) if lines else "(no matches)"
80 except subprocess.TimeoutExpired:
81 return "[ERROR] Search timed out"
82 except FileNotFoundError:
83 return "[ERROR] 'find' command not available"
84 except Exception as e:
85 return f"[ERROR] {e}"

Callers 1

agent.pyFile · 0.90

Calls 1

runMethod · 0.80

Tested by

no test coverage detected