Class: RobotLab::To::Tools::FileTool

Inherits:
RobotLab::Tool
  • Object
show all
Defined in:
lib/robot_lab/to/tools/file_tool.rb

Overview

Base for robot_lab-to's built-in workspace tools. RubyLLM derives a fully-namespaced tool name (e.g. "robot_lab--to--tools--read"); small models do far better with the short, conventional names the guards and skill docs reference, so we expose the bare last segment ("read", "write", "edit", "bash", ...).

Direct Known Subclasses

Bash, Edit, Read, Write

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.name_segmentString?

Subclasses may override the derived short name.

Returns:

  • (String, nil)


28
# File 'lib/robot_lab/to/tools/file_tool.rb', line 28

def self.name_segment = nil

.short_nameString

Returns last class path segment, snake_cased.

Returns:

  • (String)

    last class path segment, snake_cased



18
19
20
21
22
23
24
# File 'lib/robot_lab/to/tools/file_tool.rb', line 18

def self.short_name
  name_segment ||
    to_s.split("::").last
        .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
        .gsub(/([a-z\d])([A-Z])/, '\1_\2')
        .downcase
end

Instance Method Details

#nameString

Returns the short, lowercase tool name.

Returns:

  • (String)

    the short, lowercase tool name



13
14
15
# File 'lib/robot_lab/to/tools/file_tool.rb', line 13

def name
  self.class.short_name
end