From c6ab063c211fb858fd0e155883b9c47b345f0f8a Mon Sep 17 00:00:00 2001 From: asepharyana Date: Wed, 15 Jul 2026 02:01:21 +0700 Subject: [PATCH] feat(tools): require reason argument for delete and git_operator tools --- src-misc/system-tools.txt | 31 +++++++++++++++++-------------- src/tool/fs/delete.rs | 6 +++++- src/tool/git_operator.rs | 6 +++++- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src-misc/system-tools.txt b/src-misc/system-tools.txt index ed081c0..ab427c6 100644 --- a/src-misc/system-tools.txt +++ b/src-misc/system-tools.txt @@ -8,25 +8,27 @@ For complex multi-step tasks that would benefit from parallel analysis or independent verification, use workflow_run to orchestrate sub-agents. Core tools: -- read(path) — Read file contents. Use when you need to inspect code. -- grep(pattern, path?) — Search for a pattern in files. -- glob(pattern) — List files matching a glob pattern. -- write(path, content, reason) — Write content to a file. Reason is required. -- edit(path, old, new, replace_all?, reason) — Replace text in a file. Reason is required. -- delete(path) — Delete a file or empty directory. -- bash(command) — Run a shell command. Use for builds, tests, git ops. +- read(path, limit?) — Read file contents. Use when you need to inspect code. +- grep(pattern, path) — Search for a pattern in files. +- glob(pattern, path) — List files matching a glob pattern in a directory. +- write(path, content, reason) — Write content to a file. Reason is required (>= 8 chars). +- edit(path, old, new, replace_all?, reason) — Replace text in a file. Reason is required (>= 8 chars). +- delete(path, reason) — Delete a file or empty directory. Reason is required (>= 8 chars). +- bash(command, description?, timeout?, run_in_background?) — Run a shell command. - bash_output(job_id) — Poll output of a background bash job. - bash_kill(job_id) — Kill a background bash job. - cd(path) — Change working directory. - dir_list(path) — List directory contents. -- dir_cache_update() — Refresh the directory cache. +- dir_cache_update(path) — Refresh the directory cache for a path. - pong(message?) — Simple connectivity check. Echoes back the message. Git tools: -- git_operator(args, confirm_destructive?) — Run git commands. Some destructive - operations (force-push, reset --hard, branch -D) require confirm_destructive=true. -- git_worktree(args) — Manage git worktrees. -- git_cred(operation) — Manage git credentials. +- git_operator(operation, args, reason) — Run git commands (e.g. add, commit, status, + diff, log). Reason explaining the operation is required (>= 8 chars). Destructive + operations (force-push, reset --hard, branch -D) are blocked by the shell filter. +- git_worktree(name, base_ref) — Manage git worktrees: create a new worktree + with a given name and base ref (branch or commit). +- git_cred(operation) — Manage git credentials (store, get, or erase). Memory & Planning: @@ -86,5 +88,6 @@ Language Server Protocol (LSP) tools: LSP auto-provisioning runs at startup for Rust (rust-analyzer), TypeScript (typescript-language-server), Go (gopls), and Java (jdtls). -Each write/edit call MUST include a non-empty reason argument explaining -why the change is being made. This is enforced deterministically. \ No newline at end of file +Each write/edit/delete/git_operator call MUST include a non-empty reason +argument (>= 8 chars) explaining why the operation is being made. This is +enforced deterministically. \ No newline at end of file diff --git a/src/tool/fs/delete.rs b/src/tool/fs/delete.rs index d55aa38..a8e76c3 100644 --- a/src/tool/fs/delete.rs +++ b/src/tool/fs/delete.rs @@ -28,9 +28,13 @@ impl Tool for Delete { "path": { "type": "string", "description": "Path to the file or directory to delete (relative to workspace root)" + }, + "reason": { + "type": "string", + "description": "Reason for the deletion (must be non-empty, >= 8 chars)" } }, - "required": ["path"] + "required": ["path", "reason"] }) } diff --git a/src/tool/git_operator.rs b/src/tool/git_operator.rs index b52d52e..14132f4 100644 --- a/src/tool/git_operator.rs +++ b/src/tool/git_operator.rs @@ -30,9 +30,13 @@ impl Tool for GitOperator { "type": "array", "items": {"type": "string"}, "description": "Arguments for the git subcommand" + }, + "reason": { + "type": "string", + "description": "Explain why this git operation is needed (>= 8 chars)" } }, - "required": ["operation", "args"] + "required": ["operation", "args", "reason"] }) }