fix(file-ops): allow file search in hidden roots - #16672
Conversation
|
I can confirm this still reproduces on current In a live Hermes gateway session, The root cause appears unchanged on current hidden_exclude = "-not -path '*/.*'"Because the explicit search root itself contains a hidden path component ( I reapplied this PR's fix locally and verified the repro succeeds: it returns the expected file under the explicit hidden root while still excluding hidden descendants like Local verification: So this is still affecting current users after update; it would be great to get this merged or consolidated with the newer related PRs (#18487 / #18645). |
|
Salvaged via #19878 onto current main - your commit authorship was preserved. Thanks! |
… search roots Two bugs in _search_with_grep() when ripgrep is unavailable: 1. BRE mode: grep -rnH uses Basic Regular Expression mode, where | is a literal character. ripgrep ships with Rust regex (| = alternation), so patterns with alternation silently fail on the grep fallback. Fix: add -E to enable ERE (Extended Regular Expression) mode. 2. --exclude-dir='.*': GNU grep applies this to all directory components INCLUDING command-line arguments, so a search under ~/.hermes/workspace skips the entire tree because .hermes matches .*. Ripgrep only applies globs to subdirectories, not the root. Fix: only add --exclude-dir when no path component is hidden, mirroring the logic already used by _search_files (merged in NousResearch#16672). Both bugs produce silent false-negatives: search_files returns total_count=0 without any error. Cross-reference NousResearch#18473, NousResearch#18645, NousResearch#34017. Fixes NousResearch#18473
Summary
search_files(target="files")to return results when the explicit search root is inside a hidden directory, e.g.~/.hermes/logsfindfallback excluding hidden descendant files/directories for normal rootsRoot cause
When
rgis unavailable, the file search fallback usesfind ... -not -path '*/.*'to mimic ripgrep's hidden-directory behavior. If the caller explicitly searches a hidden root like/Users/me/.hermes/logs, every result path contains/.hermes/, so the filter removes all files and returnstotal_count=0.Test plan
scripts/run_tests.sh tests/tools/test_file_operations.py -q -k 'SearchFilesFallbackHiddenPaths or SearchPathValidation'scripts/run_tests.sh tests/tools/test_file_operations.py -q