Class: RubyCoded::Tools::ReadFileTool
- Defined in:
- lib/ruby_coded/tools/read_file_tool.rb
Overview
Read the contents of a file at the given path relative to the project root
Constant Summary collapse
- DEFAULT_MAX_LINES =
200
Constants inherited from BaseTool
BaseTool::CONFIRM_RISK, BaseTool::DANGEROUS_RISK, BaseTool::SAFE_RISK
Instance Method Summary collapse
Methods inherited from BaseTool
Constructor Details
This class inherits a constructor from RubyCoded::Tools::BaseTool
Instance Method Details
#execute(path:, offset: nil, max_lines: nil) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/ruby_coded/tools/read_file_tool.rb', line 22 def execute(path:, offset: nil, max_lines: nil) full_path = validate_path!(path) return full_path if full_path.is_a?(Hash) return { error: "File not found: #{path}" } unless File.exist?(full_path) return { error: "Not a file: #{path}" } unless File.file?(full_path) read_file_section(full_path, offset, max_lines) end |