feat(tools): add remove_file tool#276
Merged
LeeCheneler merged 1 commit intomainfrom Apr 10, 2026
Merged
Conversation
Adds a new remove_file tool that lets the model delete files directly
instead of escaping into run_command rm. Mirrors the write_file shape:
path arg, dedicated cwdRemoveFile/globalRemoveFile permission keys with
confirmation prompts when not pre-granted, and errors for missing paths
or directory paths (pointing at the future remove_dir tool).
Also refactors toolsSchema to give every tool a field-level default so
adding new tools doesn't break existing configs that already have a
tools: block — uses .prefault({}) on the configSchema side to work
around zod v4's output-type default constraint.
Closes #252
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
remove_filetool so the model can delete files directly without escaping intorun_command rm. Mirrors the write_file shape with its own permission keys and confirmation flow.GitHub Issue
Closes #252
What Changed
New tool.
remove_filetakes apatharg, errors clearly on missing paths or directory paths (directing the model to the futureremove_dirtool), and uses the existingcheckFilePermissionhelper for permission resolution.FileOperationis now"read" | "write" | "remove", and the branching insidecheckFilePermissionwas replaced with a small key-lookup table so the three operation types are handled uniformly.Permissions. Two new permission keys —
cwdRemoveFileandglobalRemoveFile— follow the existing optional-boolean pattern. Both default to undefined/false so confirmation is prompted unless explicitly granted. Surfaced in the/settings → Permissionsmenu alongside the existing read/write toggles.Schema refactor.
toolsSchemanow gives every tool a field-level.default(...)matching its enabled state. This means adding a new tool in the future is non-breaking for existing configs that already have atools:block. Required.prefault({})instead of.default({})on theconfigSchema.toolsside because zod v4's.default()expects the output type, not the input type.Settings UI. New "Remove File" entry in the tools toggle list and two "Remove files (current directory / global)" entries in the permissions toggle list.
Docs. README tools table, permissions YAML example, and CONTRIBUTING's
src/tree comment updated.Notes for Reviewers
executematters:isDirectoryis checked beforefileExistsbecause the mock-fs treats a directory path as non-existent for file lookups but detects nested files forisDirectory. If this ordering flipped, the "errors on directory path" test would report "does not exist" instead.stub-context.ts(the test helper) now defaultscwdRemoveFile: truefor convenience so happy-path tests don't need an explicit permission override. Permission-matrix tests still pin explicit values.remove_dir), which is a separate follow-up.