You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a grep tool that searches file contents by regex pattern within the workspace. Essential for code navigation and analysis tasks.
Motivation
A coding agent needs to find where functions are defined, where variables are used, where errors are thrown. The exec tool can run grep commands, but a dedicated tool provides:
Structured output (file, line number, match) instead of raw stdout
Output truncation to stay within token budgets
No shell injection risk from pattern arguments
Proposed interface
{
"name": "grep",
"parameters": {
"pattern": "string — regex pattern to search for",
"path": "string — optional subdirectory or file to search (default: workspace root)",
"glob": "string — optional file pattern filter, e.g. '*.go' (default: all files)",
"context_lines": "integer — lines of context around each match (default: 0)",
"max_results": "integer — maximum number of matches to return (default: 50)"
}
}
Implementation notes
Option A: Shell out to ripgrep (rg) if available, fall back to grep -rn
Option B: Use Go's regexp + filepath.Walk for zero external dependencies
Summary
Add a
greptool that searches file contents by regex pattern within the workspace. Essential for code navigation and analysis tasks.Motivation
A coding agent needs to find where functions are defined, where variables are used, where errors are thrown. The
exectool can run grep commands, but a dedicated tool provides:Proposed interface
{ "name": "grep", "parameters": { "pattern": "string — regex pattern to search for", "path": "string — optional subdirectory or file to search (default: workspace root)", "glob": "string — optional file pattern filter, e.g. '*.go' (default: all files)", "context_lines": "integer — lines of context around each match (default: 0)", "max_results": "integer — maximum number of matches to return (default: 50)" } }Implementation notes
ripgrep(rg) if available, fall back togrep -rnregexp+filepath.Walkfor zero external dependenciesread_file)exec)file:line: matched_line.gitignorepatterns if in a git repoRelated