File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 128128 (when (fs/exists? path)
129129 (flatten (search path))))))
130130
131- (defn ^:private grep [arguments db]
131+ (defn ^:private grep
132+ " Searches for files containing patterns using regular expressions.
133+
134+ This function provides a fast content search across files using three different
135+ backends depending on what's available:
136+ 1. ripgrep (rg) - fastest, preferred when available
137+ 2. grep - standard Unix tool fallback
138+ 3. Pure Java implementation - slow, but cross-platform fallback
139+
140+ Returns matching file paths, prioritizing by modification time when possible.
141+ Validates that the search path is within allowed workspace directories."
142+ [arguments db]
132143 (or (invalid-arguments arguments (concat (path-validations db)
133144 [[" path" fs/readable? " File $path is not readable" ]
134145 [" pattern" #(and % (not (string/blank? %))) " Invalid content regex pattern '$pattern'" ]
149160 :else
150161 (run-java-grep path pattern include))
151162 (take max-results))]
163+ ; ; TODO sort by modification time.
152164 (single-text-content (if (seq paths)
153165 (string/join " \n " paths)
154166 " No files found for given pattern" )))))
You can’t perform that action at this time.
0 commit comments