Skip to content

fix(tool): include ignored files for empty grep glob discovery#4710

Merged
can1357 merged 1 commit into
mainfrom
farm/4a9a15c0/fix-grep-glob-discovery
Jul 6, 2026
Merged

fix(tool): include ignored files for empty grep glob discovery#4710
can1357 merged 1 commit into
mainfrom
farm/4a9a15c0/fix-grep-glob-discovery

Conversation

@roboomp

@roboomp roboomp commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Repro

In a temp project with flake.nix, home-common.nix, and nested modules/common/*.nix, the original failure returns empty results for discovery calls like glob(path="*.nix"), glob(path="modules/**/*.nix"), glob(path="modules"), grep(pattern="home\\.packages", path="."), and grep(pattern="home\\.packages", path="modules"), while exact-file controls glob(path="flake.nix"), glob(path="modules/common/zsh.nix"), and grep(..., path="home-common.nix") still work. The follow-up case is reproducible without a project .gitignore when Git ignore sources such as .git/info/exclude hide the same paths; bun .wt/repro-grep-glob-no-dotgitignore.ts confirmed the branch now returns discovery matches by default and still returns empty for explicit gitignore:true controls.

Cause

GlobTool.execute and GrepTool.execute pass omitted gitignore as true into the native filesystem walkers (packages/coding-agent/src/tools/glob.ts, packages/coding-agent/src/tools/grep.ts). The walkers honor the full Git ignore stack, not only project .gitignore, so directory/glob discovery can silently produce zero matches even when exact-file paths work because exact files bypass the walker.

Fix

  • Added a default-only fallback in GlobTool that retries with ignored files included when the first gitignore-aware discovery pass returns no files.
  • Added the same default-only fallback in GrepTool for filesystem discovery scans that return no matches.
  • Kept explicit gitignore:true strict: callers that opt into ignored-file filtering still receive empty results for ignored paths.
  • Added focused regression coverage for glob and grep discovery fallback, explicit gitignore:true, and exact-file grep controls.

Verification

bun test packages/coding-agent/src/tools/__tests__/glob.test.ts packages/coding-agent/test/tools/grep-gitignore-discovery.test.ts passed with 7 tests and 30 assertions. bun .wt/repro-grep-glob-no-dotgitignore.ts passed on the branch: no project .gitignore, default discovery returns the .nix matches, and explicit gitignore:true returns empty controls. bun run fix completed successfully before commit; gh_push_branch completed its pre-publish gate and pushed d8434d1c3636. Fixes #4706

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@github-actions github-actions Bot added the vouched Passed the vouch gate label Jul 6, 2026
Stop pi-walker from applying .gitignore/.ignore files from unrelated ancestors above an explicit non-repository search root. Preserve repo-root ignore inheritance when scanning a subdirectory inside a repository.

Fixes #4706
@roboomp roboomp force-pushed the farm/4a9a15c0/fix-grep-glob-discovery branch from d8434d1 to 1aa31c0 Compare July 6, 2026 14:08
@can1357 can1357 merged commit c72d964 into main Jul 6, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouched Passed the vouch gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grep & glob still creating broken results

2 participants