Skip to content

fix(grep): scope the search to the PATH argument#48

Merged
RioPlay merged 1 commit into
mainfrom
fix/grep-path-scoping
Jun 20, 2026
Merged

fix(grep): scope the search to the PATH argument#48
RioPlay merged 1 commit into
mainfrom
fix/grep-path-scoping

Conversation

@RioPlay

@RioPlay RioPlay commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the grep PATH-scoping bug I flagged in #47 and reproduced while testing the installed CLI.

aden grep <pat> <PATH> used PATH only to locate the project root, then always discovered files from that root. So grep <pat> some/file.rs silently searched the whole repo — scoping to one file returned 787 hits across 8 files including a vendored 3d-force-graph.min.js, and could dump megabytes when it matched minified asset lines.

Now discovery is scoped to PATH:

  • a file searches just that file,
  • a subdirectory searches under it,
  • the project root (.) searches everything (unchanged).

Symbol attribution still keys off the project root, so hits keep their enclosing-symbol tags.

Implementation: discover_source_files is now a thin wrapper over a new discover_source_files_scoped(scope, root) (ignore rules still resolve relative to root). Single-file PATH is handled directly in cmd_grep.

Verified end-to-end on the built binary:

  • grep "fn " crates/aden-cli/src/main.rs → 2 hits in 1 file (was 787 across 8)
  • grep "fn " crates/aden-store → 87 hits, all under aden-store
  • grep "fn " . → 10184 hits, repo-wide (unchanged)

Test plan

  • cargo test -p aden-cli green (new discover_source_files_scoped_narrows_to_subtree)
  • cargo clippy --workspace clean
  • cargo fmt --all applied
  • Manual end-to-end (above)

License checklist

  • No dependency changes — license checklist not applicable

`aden grep <pat> <PATH>` used PATH only to locate the project root, then
always discovered from that root — so `grep <pat> some/file.rs` silently
searched the WHOLE repo (and could dump megabytes when it matched minified
asset lines). Reported while testing the installed CLI: scoping to one file
returned 787 hits across 8 files including a vendored .min.js.

Scope discovery to PATH: a file searches just that file, a subdirectory
searches under it, the project root searches everything. Symbol attribution
still keys off the project root, so hits keep their enclosing-symbol tags.

Adds discover_source_files_scoped(scope, root) (discover_source_files is now
a thin wrapper) plus a unit test asserting a scoped walk sees only its
subtree.
@RioPlay RioPlay merged commit a744328 into main Jun 20, 2026
6 checks passed
@RioPlay RioPlay deleted the fix/grep-path-scoping branch June 20, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant