summaryrefslogtreecommitdiffhomepage
path: root/.rules/changelog/2026-03
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-03-28 05:28:11 +0900
committerAdam Malczewski <[email protected]>2026-03-28 05:28:11 +0900
commit9dd666cff5c2653c3572bd1368080313545e91c6 (patch)
tree881632547ebef0cd4a43e746b16faf24ee4fe2f2 /.rules/changelog/2026-03
parentff4fd494811d326986cfe0305f35b89e37dd493c (diff)
downloadai-pulse-obsidian-plugin-9dd666cff5c2653c3572bd1368080313545e91c6.tar.gz
ai-pulse-obsidian-plugin-9dd666cff5c2653c3572bd1368080313545e91c6.zip
add pre-validation for all tool calls
Diffstat (limited to '.rules/changelog/2026-03')
-rw-r--r--.rules/changelog/2026-03/28/06.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/.rules/changelog/2026-03/28/06.md b/.rules/changelog/2026-03/28/06.md
new file mode 100644
index 0000000..a3b1295
--- /dev/null
+++ b/.rules/changelog/2026-03/28/06.md
@@ -0,0 +1,24 @@
+# Pre-validate tool calls before approval prompt
+
+## Summary
+
+Replaced the narrow `isNoOpEdit` function with a comprehensive `preValidateTool` system that checks all deterministic failure conditions for approval-requiring tools before showing the user an approval prompt. This speeds up the AI agent loop by immediately feeding errors back to the model instead of waiting for user interaction on calls that would fail regardless.
+
+## Changes
+
+### `src/ollama-client.ts`
+
+- Added `TFile` to the `obsidian` import.
+- Removed `isNoOpEdit` function.
+- Added `parseArrayArg` helper (local to ollama-client, needed by batch validators).
+- Added `preValidateTool` dispatcher function with validators for all 9 approval-requiring tools:
+ - `preValidateEditFile` — missing file_path, old_text === new_text, file not found.
+ - `preValidateCreateFile` — missing file_path, file already exists.
+ - `preValidateDeleteFile` — missing file_path, file not found.
+ - `preValidateMoveFile` — missing file_path/new_path, source not found, destination exists.
+ - `preValidateSetFrontmatter` — missing file_path, invalid/empty properties, file not found.
+ - `preValidateBatchEditFile` — empty operations, all no-ops, all files missing.
+ - `preValidateBatchDeleteFile` — empty file_paths, all files missing.
+ - `preValidateBatchMoveFile` — empty operations, all sources missing, all destinations exist.
+ - `preValidateBatchSetFrontmatter` — empty operations, all files missing.
+- Updated `chatAgentLoop` to call `preValidateTool` before the approval prompt; if validation fails, the error is used as the tool result directly.