summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--llm-tools.el16
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 "\
184Recursively search for lines matching a regexp pattern in files under a 186Recursively 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 "\
202Optional file or directory path to search within, relative to the 204Optional file or directory path to search within, relative to the
203working directory. Defaults to current directory if omitted." 205working directory. Defaults to current directory if omitted."
206 :optional t)
207 (:name "glob"
208 :type string
209 :description "\
210Optional restricts search to files matching the glob
211pattern. (e.g. \"*.el\", \"*.org\", \"*.c\")"
204 :optional t)) 212 :optional t))
205 :async nil 213 :async nil
206 :confirm nil 214 :confirm nil