Summary
Add a glob tool that finds files by name pattern within the workspace. Essential for discovering project structure and locating files.
Motivation
A coding agent needs to answer questions like "find all Go test files", "where is the main.go", "list all YAML configs." The exec tool can run find, but a dedicated tool provides:
- Workspace boundary enforcement
- Structured output (sorted file list)
- No shell injection risk
- Consistent cross-platform behavior
Proposed interface
{
"name": "glob",
"parameters": {
"pattern": "string — glob pattern, e.g. '**/*.go', 'cmd/*/main.go'",
"path": "string — optional subdirectory to search (default: workspace root)",
"max_results": "integer — maximum files to return (default: 100)"
}
}
Implementation notes
- Use
github.com/bmatcuk/doublestar/v4 for ** support (Go's filepath.Glob doesn't support **)
- Or: shell out to
fd if available, fall back to filepath.Walk + filepath.Match
- Enforce workspace boundary (same logic as
read_file)
- Respect
.gitignore if in a git repo
- Sort results by path for deterministic output
- Return one file path per line
Related
Summary
Add a
globtool that finds files by name pattern within the workspace. Essential for discovering project structure and locating files.Motivation
A coding agent needs to answer questions like "find all Go test files", "where is the main.go", "list all YAML configs." The
exectool can runfind, but a dedicated tool provides:Proposed interface
{ "name": "glob", "parameters": { "pattern": "string — glob pattern, e.g. '**/*.go', 'cmd/*/main.go'", "path": "string — optional subdirectory to search (default: workspace root)", "max_results": "integer — maximum files to return (default: 100)" } }Implementation notes
github.com/bmatcuk/doublestar/v4for**support (Go'sfilepath.Globdoesn't support**)fdif available, fall back tofilepath.Walk+filepath.Matchread_file).gitignoreif in a git repoRelated