Skip to content

feat(tools): add remove_file tool#276

Merged
LeeCheneler merged 1 commit intomainfrom
feat/252-remove-file-tool
Apr 10, 2026
Merged

feat(tools): add remove_file tool#276
LeeCheneler merged 1 commit intomainfrom
feat/252-remove-file-tool

Conversation

@LeeCheneler
Copy link
Copy Markdown
Owner

Summary

Adds a new remove_file tool so the model can delete files directly without escaping into run_command rm. Mirrors the write_file shape with its own permission keys and confirmation flow.

GitHub Issue

Closes #252

What Changed

New tool. remove_file takes a path arg, errors clearly on missing paths or directory paths (directing the model to the future remove_dir tool), and uses the existing checkFilePermission helper for permission resolution. FileOperation is now "read" | "write" | "remove", and the branching inside checkFilePermission was replaced with a small key-lookup table so the three operation types are handled uniformly.

Permissions. Two new permission keys — cwdRemoveFile and globalRemoveFile — follow the existing optional-boolean pattern. Both default to undefined/false so confirmation is prompted unless explicitly granted. Surfaced in the /settings → Permissions menu alongside the existing read/write toggles.

Schema refactor. toolsSchema now 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 a tools: block. Required .prefault({}) instead of .default({}) on the configSchema.tools side 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

  • Check order in execute matters: isDirectory is checked before fileExists because the mock-fs treats a directory path as non-existent for file lookups but detects nested files for isDirectory. If this ordering flipped, the "errors on directory path" test would report "does not exist" instead.
  • stub-context.ts (the test helper) now defaults cwdRemoveFile: true for convenience so happy-path tests don't need an explicit permission override. Permission-matrix tests still pin explicit values.
  • Pairs with feat: tool for removing directories #251 (remove_dir), which is a separate follow-up.

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
@LeeCheneler LeeCheneler merged commit 86a9668 into main Apr 10, 2026
4 checks passed
@LeeCheneler LeeCheneler deleted the feat/252-remove-file-tool branch April 10, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: tool for removing files

1 participant