Class: Brute::Tools::FSRemove

Inherits:
LLM::Tool
  • Object
show all
Defined in:
lib/brute/tools/fs_remove.rb

Instance Method Summary collapse

Instance Method Details

#call(path:) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/brute/tools/fs_remove.rb', line 18

def call(path:)
  target = File.expand_path(path)
  Brute::FileMutationQueue.serialize(target) do
    raise "Path not found: #{target}" unless File.exist?(target)

    Brute::SnapshotStore.save(target) if File.file?(target)

    if File.directory?(target)
      Dir.rmdir(target)
    else
      File.delete(target)
    end

    {success: true, path: target}
  end
end