Skip to content

search — regex search across files

search runs a regex across the environment’s files and returns matching lines in path:lineno: line format. Supply a glob filter to narrow by filename.

ArgTypeRequiredDefaultDescription
patternstringyesRegex pattern (Python re flavor).
pathstringno.File or directory to search in.
globstringnonullGlob filter applied to the filename, e.g. *.py.
{"pattern": "class .+Tool\\(BaseTool\\):", "path": "chimera/tools", "glob": "*.py"}
from chimera.tools.search import SearchTool
tool = SearchTool()
result = tool.execute(
{"pattern": "TODO\\(", "path": ".", "glob": "*.md"},
env=local_env,
)
print(result.output)
chimera/tools/bash.py:14: class BashTool(BaseTool):
chimera/tools/edit.py:12: class EditFileTool(BaseTool):
chimera/tools/git.py:18: class GitTool(BaseTool):

An invalid regex returns error="Invalid regex: ..." and an empty output.