commit 53b08a2bc462a55a333f5a6b26886ce1c56ddbb2
parent 008cb42c3cd44c2220944966dfd9095edf12b98e
Author: Vineet Kumar <git@vineetk.net>
Date: Mon, 25 May 2026 13:29:26 -0400
add glob optional argument to grep
I didn't see that gptel-agent had its own Grep tool, and saw this
within it.
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/llm-tools.el b/llm-tools.el
@@ -167,18 +167,20 @@ or editing them."
;; grep (just grep (or git grep) :D)
(gptel-make-tool
:name "grep"
- :function (lambda (regexp &optional path)
+ :function (lambda (regexp &optional glob path)
(with-temp-buffer
(if (magit-gitdir)
(call-process "git" nil t nil
"grep"
"-rnEH"
regexp
+ (and glob (format "--include=%s" glob))
(or path "."))
(call-process "grep" nil t nil
- "-rnEH"
- regexp
- (or path ".")))
+ "-rnEH"
+ regexp
+ (and glob (format "--include=%s" glob))
+ (or path ".")))
(buffer-string)))
:description "\
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.")
:description "\
Optional file or directory path to search within, relative to the
working directory. Defaults to current directory if omitted."
+ :optional t)
+ (:name "glob"
+ :type string
+ :description "\
+Optional restricts search to files matching the glob
+pattern. (e.g. \"*.el\", \"*.org\", \"*.c\")"
:optional t))
:async nil
:confirm nil