From d57c422cddf657fab565411ffe9956a32ff37230 Mon Sep 17 00:00:00 2001 From: Vineet Kumar Date: Sat, 23 May 2026 23:25:40 -0400 Subject: declare second tool (find_files) --- gptel-tools.el | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/gptel-tools.el b/gptel-tools.el index bd76a98..1e8453c 100644 --- a/gptel-tools.el +++ b/gptel-tools.el @@ -31,7 +31,31 @@ longer match after external changes." ;; TODO bash_readonly (shell-command-to-string, whitelisted commands) ;; TODO bash (shell-command-to-string, needs heavy filtering) -;; TODO find_files (directory-files-decursively) +;; find_files (directory-files-recursively) +(gptel-make-tool + :name "find_files" + :function (lambda (dir &optional pattern) + (let ((git-dir (concat (file-name-as-directory dir) ".git"))) + (delq nil (mapcar (lambda (f) + (unless (string-prefix-p git-dir f) f)) + (directory-files-recursively dir (or pattern "")))))) + :description "\ +Recursively find all files in a given directory, excluding files within +.git directories. Returns a list of absolute file paths. Optionally +accepts a pattern to filter file names (e.g., `*.el' for Emacs Lisp +files). Use this to discover files in a project directory before reading +or editing them." + :args (list '(:name "directory" + :type string + :description "Path to the directory to be read, relative to the working directory.") + '(:name "pattern" + :type string + :description "Optional file name pattern to filter results, e.g. `*.el' or `*.txt'." + :optional t)) + :async nil + :confirm nil + :include t) + ;; TODO grep (just grep :D) ;; TODO fetch_url (use gptel-agent's one as a base, but needs mime handling like PDFs and images) ;; TODO web_search (use gptel-agent's eww/shr method as a base) -- cgit v1.2.3