diff options
| author | Vineet Kumar <git@vineetk.net> | 2026-05-25 13:29:26 -0400 |
|---|---|---|
| committer | Vineet Kumar <git@vineetk.net> | 2026-05-25 13:29:26 -0400 |
| commit | 53b08a2bc462a55a333f5a6b26886ce1c56ddbb2 (patch) | |
| tree | 52f29901b13b42fd5fcf37e2af5165157eb713fa | |
| parent | 008cb42c3cd44c2220944966dfd9095edf12b98e (diff) | |
add glob optional argument to grep
I didn't see that gptel-agent had its own Grep tool, and saw this
within it.
| -rw-r--r-- | llm-tools.el | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/llm-tools.el b/llm-tools.el index 855f12f..cf86b6b 100644 --- a/llm-tools.el +++ b/llm-tools.el | |||
| @@ -167,18 +167,20 @@ or editing them." | |||
| 167 | ;; grep (just grep (or git grep) :D) | 167 | ;; grep (just grep (or git grep) :D) |
| 168 | (gptel-make-tool | 168 | (gptel-make-tool |
| 169 | :name "grep" | 169 | :name "grep" |
| 170 | :function (lambda (regexp &optional path) | 170 | :function (lambda (regexp &optional glob path) |
| 171 | (with-temp-buffer | 171 | (with-temp-buffer |
| 172 | (if (magit-gitdir) | 172 | (if (magit-gitdir) |
| 173 | (call-process "git" nil t nil | 173 | (call-process "git" nil t nil |
| 174 | "grep" | 174 | "grep" |
| 175 | "-rnEH" | 175 | "-rnEH" |
| 176 | regexp | 176 | regexp |
| 177 | (and glob (format "--include=%s" glob)) | ||
| 177 | (or path ".")) | 178 | (or path ".")) |
| 178 | (call-process "grep" nil t nil | 179 | (call-process "grep" nil t nil |
| 179 | "-rnEH" | 180 | "-rnEH" |
| 180 | regexp | 181 | regexp |
| 181 | (or path "."))) | 182 | (and glob (format "--include=%s" glob)) |
| 183 | (or path "."))) | ||
| 182 | (buffer-string))) | 184 | (buffer-string))) |
| 183 | :description "\ | 185 | :description "\ |
| 184 | Recursively search for lines matching a regexp pattern in files under a | 186 | Recursively search for lines matching a regexp pattern in files under a |
| @@ -201,6 +203,12 @@ Regular expression pattern to search for. Uses GNU grep extended syntax.") | |||
| 201 | :description "\ | 203 | :description "\ |
| 202 | Optional file or directory path to search within, relative to the | 204 | Optional file or directory path to search within, relative to the |
| 203 | working directory. Defaults to current directory if omitted." | 205 | working directory. Defaults to current directory if omitted." |
| 206 | :optional t) | ||
| 207 | (:name "glob" | ||
| 208 | :type string | ||
| 209 | :description "\ | ||
| 210 | Optional restricts search to files matching the glob | ||
| 211 | pattern. (e.g. \"*.el\", \"*.org\", \"*.c\")" | ||
| 204 | :optional t)) | 212 | :optional t)) |
| 205 | :async nil | 213 | :async nil |
| 206 | :confirm nil | 214 | :confirm nil |
