Skip to content

Add glob tool for file search by name pattern #28

@pavelanni

Description

@pavelanni

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions