Skip to content

feat: tool for removing files #252

@LeeCheneler

Description

@LeeCheneler

User Story

As a user,
I want a tool for removing files,
so that the LLM can manage the filesystem directly from within Tomo without escaping into run_command rm.

Acceptance Criteria

Tool shape

  • New remove_file tool registered alongside existing tools at src/tools/remove-file.ts, follows existing tool patterns (zod schema, Tool interface, colocated test file, registered in src/app.tsx)
  • Arguments: path (required, absolute or relative to cwd)
  • Tool description explains: only removes files (not directories), use remove_dir for directories, fails clearly on missing path or directory path
  • formatCall returns the path for the collapsed tool header
  • New entry in toolsSchema in src/config/schema.ts so the tool can be enabled/disabled (default enabled: true)

Permissions

  • New permission keys added to permissionsSchema in src/config/schema.ts:
    • cwdRemoveFile (default false) — allows removing files within the cwd without confirmation
    • globalRemoveFile (default false) — allows removing files outside the cwd without confirmation
  • Permission check uses the existing isPathWithinCwd helper from src/tools/permissions.ts
  • Permission resolution mirrors the existing read/write pattern: granted → skip confirm, ungranted → prompt
  • Either extend checkFilePermission with a "remove" operation type or add a parallel helper — implementer's call, just keep the shape consistent with the existing read/write logic

Confirmation

  • When permission is not granted, the confirmation prompt shows the resolved file path (label "Remove file?")
  • User denial returns a denied result; flow follows the same pattern as write-file.ts

Validation and behaviour

  • Errors clearly when the path does not exist
  • Errors clearly when the path is a directory (suggest remove_dir)
  • Errors clearly on permission/IO errors from the OS
  • On success, returns a plain ok result confirming the path was removed

Tests

  • Mock the filesystem at the boundary; do not mock internal helpers
  • Tool behaviour: removes a file in cwd, removes a file outside cwd, errors on missing path, errors on directory path
  • Permissions matrix: cwd granted skips confirm, cwd ungranted prompts and on approval removes, cwd ungranted prompts and on denial returns denied and leaves the file in place; same set of cases for global
  • Confirmation prompt shape matches the existing pattern (label, detail)

Additional Context

run_command rm already covers this case but at the cost of shell quoting, cross-platform inconsistency, and a confirmation prompt on every call that doesn't match allowedCommands. A dedicated remove_file tool with its own permission gate gives cleaner ergonomics for the common refactor/rename workflow and lets the user grant cwd-scoped trust for file removal without having to allowlist rm patterns globally.

Pairs with #251 (remove_dir). Together they cover the destructive filesystem operations the LLM currently has to do via run_command.

Implementation references:

  • src/tools/write-file.ts for the permission + confirm flow shape
  • src/tools/permissions.ts for checkFilePermission and isPathWithinCwd
  • src/config/schema.ts:19 for the permissions schema where the new keys go

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions