summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVineet Kumar <git@vineetk.net>2026-05-24 14:20:53 -0400
committerVineet Kumar <git@vineetk.net>2026-05-24 14:20:53 -0400
commit26ae5c282bafde789848edc05d2899ed828c9aaf (patch)
treeb8b2f9af74077b955f42c75c1d130098026a7b13
parent6cb91f228a2f0433a7bc93205df8a5f3bd3b2304 (diff)
add write_file tool
-rw-r--r--llm-tools.el33
1 files changed, 32 insertions, 1 deletions
diff --git a/llm-tools.el b/llm-tools.el
index 6476d15..a125e55 100644
--- a/llm-tools.el
+++ b/llm-tools.el
@@ -25,7 +25,38 @@ longer match after external changes."
25 :confirm nil 25 :confirm nil
26 :include t) 26 :include t)
27 27
28;; TODO write_file (with-temp-buffer + insert) 28;; write_file (write-region)
29(gptel-make-tool
30 :name "write_file"
31 :function (lambda (file contents)
32 (write-region contents nil file))
33 :description "\
34Overwrite an entire file with new contents. This is a destructive
35operation that replaces all existing content. Use this tool for:
36
37- Creating new files from scratch
38- Completely replacing small files where the new content is the
39 intended final state
40- Writing generated output, configuration files, or test fixtures
41
42Do NOT use this for partial edits, appending, or modifying existing
43files. Use `edit_file` instead for surgical changes to existing
44content. Always call `read_file` first if the file already exists to
45preserve content you intend to keep. This tool requires user
46confirmation before executing."
47 :args '((:name "file"
48 :type string
49 :description "Path to the file to write to, relative to the working directory.")
50 (:name "contents"
51 :type string
52 :description "\
53Full file contents to write. This will replace all existing
54content. Include newlines and indentation as they should appear in the
55final file."))
56 :async nil
57 :confirm t
58 :include t)
59
29;; TODO edit_file (hashline + patch apply) 60;; TODO edit_file (hashline + patch apply)
30 61
31;; TODO bash_readonly (shell-command-to-string, whitelisted commands) 62;; TODO bash_readonly (shell-command-to-string, whitelisted commands)