diff options
| author | Vineet Kumar <git@vineetk.net> | 2026-05-23 22:47:15 -0400 |
|---|---|---|
| committer | Vineet Kumar <git@vineetk.net> | 2026-05-23 23:14:05 -0400 |
| commit | c1f458c46ccf874d5d26089871a41c35992b2c1e (patch) | |
| tree | ef3db39443f7849f2b3cbda4d50f009dd6f1818d | |
| parent | 44cad762d23930e849a24fdf3bdb43506f1943f6 (diff) | |
declare first tool (read_file)
| -rw-r--r-- | gptel-tools.el | 37 |
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 "\ | ||
| 6 | Read an entire file and return its contents in hashline format. Each | ||
| 7 | line is represented as LINE_NUMBER HASH|CONTENT, where LINE_NUMBER is | ||
| 8 | the 1-based line number, HASH is a 2-character content-derived bigram, | ||
| 9 | and CONTENT is the verbatim line text. Example output: | ||
| 10 | |||
| 11 | 1aa|const char *TITLE = \"Mr\"; | ||
| 12 | 2ab|void greet(char *name) { | ||
| 13 | 3cd| return name; | ||
| 14 | |||
| 15 | The LINE_NUMBER and HASH together form an anchor (e.g., 1aa, 2ab) that | ||
| 16 | uniquely identifies a line by position and content. Copy anchors | ||
| 17 | verbatim from the output when referencing lines in edit operations. Do | ||
| 18 | not fabricate or modify hashes. Call this tool before editing any file | ||
| 19 | to obtain current content and valid anchors. Re-call if anchors no | ||
| 20 | longer 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) | ||
