Class: Legion::CLI::Chat::Tools::WriteFile
- Inherits:
-
Tools::Base
- Object
- Tools::Base
- Legion::CLI::Chat::Tools::WriteFile
- Defined in:
- lib/legion/cli/chat/tools/write_file.rb
Class Method Summary collapse
Methods inherited from Tools::Base
deferred, deferred?, description, error_response, extension, handle_exception, input_schema, log, mcp_category, mcp_tier, runner, sticky, tags, text_response, tool_name, trigger_words
Class Method Details
.call(path:, content:) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/legion/cli/chat/tools/write_file.rb', line 22 def self.call(path:, content:) = File.(path) require 'legion/cli/chat/checkpoint' Checkpoint.save() FileUtils.mkdir_p(File.dirname()) File.write(, content, encoding: 'utf-8') "Wrote #{content.lines.count} lines to #{}" rescue StandardError => e Legion::Logging.warn("WriteFile#execute failed for #{path}: #{e.}") if defined?(Legion::Logging) "Error writing #{path}: #{e.}" end |