Skip to content

[Bug] write_file tool creates empty file/directories on disk even when user rejects changes #274

@TommyAmberson

Description

@TommyAmberson

Environment

  • mcphub.nvim version: latest
  • Neovim version: 0.11+
  • OS: Linux
  • Chat plugin: CodeCompanion.nvim

Description

When write_file targets a path that doesn't exist yet, the file and any parent directories are created on disk before the interactive diff is shown. If the user rejects all changes, the empty file and directories remain.

Steps to Reproduce

  1. In a chat with the neovim tools enabled, ask the LLM to create a new file (e.g. lua/foo/bar.lua)
  2. The interactive diff UI appears — reject all changes
  3. The empty file and parent directory still exist on disk

Expected Behavior

Rejecting changes should leave the filesystem unchanged. No file or directory should be created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions