[emacs] Fix the project root tool

This commit is contained in:
John Doty 2025-05-26 07:42:44 -07:00
parent 1a9ccb2554
commit 4b549f8a1f

View file

@ -523,13 +523,26 @@ Returns file path, modified status, major mode, size, line count, and more."
(gptel-make-tool
:name "get_project_root"
:function #'project-root
:function #'doty-tools--get-project-root
:description "Get the root directory of the current project."
:args ()
:category "reading"
:confirm nil
:include t)
(ert-deftest doty-tools--test--get_project_root ()
"Tests for the emacs_insert_line tool."
(let* ((tf (make-temp-file "test-project-" t)))
(unwind-protect
(with-temp-buffer
(let ((default-directory tf))
(call-process "git" nil t nil "init" ".")
(should
(equal (file-name-as-directory tf)
(doty-tools--test--invoke-tool "get_project_root" ())))))
(delete-directory tf t))))
(defun doty-tools--search-project-regex (callback regex)
"Search the current project for instances of a given REGEX.