From c151093d857c2949a27146bac02654aadd967f3a Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 8 Sep 2025 17:18:16 -0300 Subject: [PATCH] fix: make grep regex implementation skip hidden files to match ripgrep behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The regex fallback implementation for grep was including hidden files (starting with '.') while ripgrep naturally excludes them by default. This caused inconsistent behavior between the two search implementations. This change adds explicit hidden file filtering to the regex implementation to ensure both search methods behave consistently and match the documented behavior. Fixes failing TestSearchImplementations/regex test. 💖 Generated with Crush Co-Authored-By: Crush --- internal/llm/tools/grep.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/llm/tools/grep.go b/internal/llm/tools/grep.go index 4d0fbd75e1000e446523eae36c756da530b309ea..f18e60a741e5e072d63221f4819354994035b299 100644 --- a/internal/llm/tools/grep.go +++ b/internal/llm/tools/grep.go @@ -365,6 +365,12 @@ func searchFilesWithRegex(pattern, rootPath, include string) ([]grepMatch, error return nil } + // Skip hidden files (starting with a dot) to match ripgrep's default behavior + base := filepath.Base(path) + if base != "." && strings.HasPrefix(base, ".") { + return nil + } + if includePattern != nil && !includePattern.MatchString(path) { return nil }