summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVineet Kumar <git@vineetk.net>2026-05-23 22:47:15 -0400
committerVineet Kumar <git@vineetk.net>2026-05-23 23:14:05 -0400
commitc1f458c46ccf874d5d26089871a41c35992b2c1e (patch)
treeef3db39443f7849f2b3cbda4d50f009dd6f1818d
parent44cad762d23930e849a24fdf3bdb43506f1943f6 (diff)
declare first tool (read_file)
-rw-r--r--gptel-tools.el37
1 files changed, 37 insertions, 0 deletions
diff --git a/gptel-tools.el b/gptel-tools.el
new file mode 100644
index 0000000..bd76a98
--- /dev/null
+++ b/gptel-tools.el
@@ -0,0 +1,37 @@
1;; read_file (hl-file-read)
2(gptel-make-tool
3 :name "read_file"
4 :function 'hl-file-read
5 :description "\
6Read an entire file and return its contents in hashline format. Each
7line is represented as LINE_NUMBER HASH|CONTENT, where LINE_NUMBER is
8the 1-based line number, HASH is a 2-character content-derived bigram,
9and CONTENT is the verbatim line text. Example output:
10
111aa|const char *TITLE = \"Mr\";
122ab|void greet(char *name) {
133cd| return name;
14
15The LINE_NUMBER and HASH together form an anchor (e.g., 1aa, 2ab) that
16uniquely identifies a line by position and content. Copy anchors
17verbatim from the output when referencing lines in edit operations. Do
18not fabricate or modify hashes. Call this tool before editing any file
19to obtain current content and valid anchors. Re-call if anchors no
20longer match after external changes."
21 :args (list '(:name "file"
22 :type string
23 :description "Path to the file to read, relative to the working directory."))
24 :async nil
25 :confirm nil
26 :include t)
27
28;; TODO write_file (with-temp-buffer + insert)
29;; TODO edit_file (hashline + patch apply)
30
31;; TODO bash_readonly (shell-command-to-string, whitelisted commands)
32;; TODO bash (shell-command-to-string, needs heavy filtering)
33
34;; TODO find_files (directory-files-decursively)
35;; TODO grep (just grep :D)
36;; TODO fetch_url (use gptel-agent's one as a base, but needs mime handling like PDFs and images)
37;; TODO web_search (use gptel-agent's eww/shr method as a base)