llm-tools.el

Opinionated tools for use by a (local) LLM
Log | Files | Refs | LICENSE

commit 26ae5c282bafde789848edc05d2899ed828c9aaf
parent 6cb91f228a2f0433a7bc93205df8a5f3bd3b2304
Author: Vineet Kumar <git@vineetk.net>
Date:   Sun, 24 May 2026 14:20:53 -0400

add write_file tool

Diffstat:
Mllm-tools.el | 33++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/llm-tools.el b/llm-tools.el @@ -25,7 +25,38 @@ longer match after external changes." :confirm nil :include t) -;; TODO write_file (with-temp-buffer + insert) +;; write_file (write-region) +(gptel-make-tool + :name "write_file" + :function (lambda (file contents) + (write-region contents nil file)) + :description "\ +Overwrite an entire file with new contents. This is a destructive +operation that replaces all existing content. Use this tool for: + +- Creating new files from scratch +- Completely replacing small files where the new content is the + intended final state +- Writing generated output, configuration files, or test fixtures + +Do NOT use this for partial edits, appending, or modifying existing +files. Use `edit_file` instead for surgical changes to existing +content. Always call `read_file` first if the file already exists to +preserve content you intend to keep. This tool requires user +confirmation before executing." + :args '((:name "file" + :type string + :description "Path to the file to write to, relative to the working directory.") + (:name "contents" + :type string + :description "\ +Full file contents to write. This will replace all existing +content. Include newlines and indentation as they should appear in the +final file.")) + :async nil + :confirm t + :include t) + ;; TODO edit_file (hashline + patch apply) ;; TODO bash_readonly (shell-command-to-string, whitelisted commands)