Class: RubyLLM::Toolbox::Tools::GitAdd
- Includes:
- GitHelpers
- Defined in:
- lib/ruby_llm/toolbox/tools/git_add.rb
Overview
EXEC. Stages changes in the repo at fs_root.
Constant Summary
Constants included from GitHelpers
RubyLLM::Toolbox::Tools::GitHelpers::GIT_ENV, RubyLLM::Toolbox::Tools::GitHelpers::REF_RE
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods included from GitHelpers
#git_result, #repo_relative, #run_git, #valid_ref?
Methods inherited from Base
#call, exec_tool!, exec_tool?, #initialize, #name
Constructor Details
This class inherits a constructor from RubyLLM::Toolbox::Base
Instance Method Details
#execute(paths: nil, all: false) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ruby_llm/toolbox/tools/git_add.rb', line 24 def execute(paths: nil, all: false) rels = Array(paths).filter_map { |p| repo_relative(p) } if all args = ["add", "-A"] elsif rels.empty? return error("provide paths or set all: true", code: :nothing_to_add) else args = ["add", "--", *rels] end out, err, status = run_git(*args) result = git_result(out, err, status) return result if result.is_a?(Hash) all ? "Staged all changes" : "Staged: #{rels.join(', ')}" rescue Safety::PathJail::Jailbreak => e error(e., code: :path_denied) end |