diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-16 01:18:35 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-16 01:18:35 -0500 |
| commit | 531f0f19f298e28b42dfb216f6008a1cbc6164d3 (patch) | |
| tree | 050af9cc602ccbdccd4affb442657639eb1fd136 /todo.org | |
| parent | b5793851bfdc9e539b45f9d6830d093208cf0a86 (diff) | |
| download | dotemacs-531f0f19f298e28b42dfb216f6008a1cbc6164d3.tar.gz dotemacs-531f0f19f298e28b42dfb216f6008a1cbc6164d3.zip | |
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.
Diffstat (limited to 'todo.org')
| -rw-r--r-- | todo.org | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -2583,18 +2583,23 @@ In scope: Out of scope: the F9 =ai-vterm= Claude-Code launcher (=modules/ai-vterm.el=) — separate module, working well. -*** TODO [#B] Wire update_text_file into cj/gptel-local-tool-features, then harden it :refactor:tests: - -The tool exists at =gptel-tools/update_text_file.el= (replace / append / prepend / insert-at-line / delete-lines, with diff preview and timestamped backups), but it's incomplete and needs hardening before it goes live in =cj/gptel-local-tool-features=. - -Scope: - -1. *Read the tool end-to-end* against the gptel-tools convention used by =read_buffer.el=, =write_text_file.el=, =move_to_trash.el=, and the other already-wired tools. Note where =update_text_file.el= diverges in shape (argument naming, error handling, return-value structure, backup placement). -2. *Refactor for completeness and consistency.* Bring it in line with the other tools: same argument-validation style, same diff-preview surface, same backup directory and naming, same error categories. Extract pure helpers where the current shape forces wrapper-heavy testing. -3. *Add ERT coverage targeting ~100%.* Normal / Boundary / Error per the standard project discipline: each verb (=replace=, =append=, =prepend=, =insert-at-line=, =delete-lines=) gets at least one Normal, one Boundary (empty file, single line, EOF, unicode), and one Error (missing file, line-range out of range, permission denied, write-conflict). Diff preview and backup creation get their own focused tests. -4. *Wire it into =cj/gptel-local-tool-features=* in =modules/ai-config.el= -- one-line addition to the defcustom default -- only once 1-3 are green. - -Acceptance: after restart, =gptel-tools= (the transient context view) shows =update_text_file= alongside =read_buffer=, =read_text_file=, =write_text_file=, =list_directory_files=, =move_to_trash=. =make test-file FILE=test-update-text-file.el= exits 0. =make coverage= reports =gptel-tools/update_text_file.el= at ≥95%. +*** 2026-05-16 Sat @ 01:17:58 -0500 Rewrote update_text_file.el and wired it into cj/gptel-local-tool-features + +I rewrote =gptel-tools/update_text_file.el= in pure Elisp. The previous +version shelled out to sed for everything, had a stray quote terminator +at EOF, 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 +the 10MB size limit, takes a timestamped backup, and writes atomically. +No backup is created when the operation is a no-op. + +=tests/test-update-text-file.el= covers Normal / Boundary / Error per +operation plus the wrapper -- 48 tests green. Added =update_text_file= +to =cj/gptel-local-tool-features= so gptel exposes it on next restart. *** TODO [#B] Fix gptel-magit triggers :bug: |
