From 531f0f19f298e28b42dfb216f6008a1cbc6164d3 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 16 May 2026 01:18:35 -0500 Subject: feat(gptel-tools): wire update_text_file as a local tool with tests I rewrote `update_text_file.el` in pure Elisp. The previous version shelled out to sed for everything, had a stray quote terminator at EOF (line 149) that broke loading, produced literal backslash-n where actual newlines were expected, and prompted via `y-or-n-p` redundantly with gptel's own `:confirm t` flag. The five operations -- replace, append, prepend, insert-at-line, delete-lines -- split into pure string transforms that test without touching the disk. The file-level wrapper validates the path, enforces a 10MB size limit, takes a timestamped backup, and writes atomically. No backup is created when the operation is a no-op. Patterns are literal substrings (not regex) so the model can't trip over metacharacter quoting. `tests/test-update-text-file.el` covers Normal / Boundary / Error per operation plus the file-level wrapper. 48 tests green. Added `update_text_file` to `cj/gptel-local-tool-features` so gptel exposes the tool after restart. --- modules/ai-config.el | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/ai-config.el b/modules/ai-config.el index 2783bc18..bc896704 100644 --- a/modules/ai-config.el +++ b/modules/ai-config.el @@ -52,6 +52,7 @@ '(read_buffer read_text_file write_text_file + update_text_file list_directory_files move_to_trash) "Feature symbols for optional local GPTel tool modules." -- cgit v1.2.3