Class: OllamaAgent::Tools::GitDiff
- Defined in:
- lib/ollama_agent/tools/git_tools.rb
Overview
Git diff — read-only
Constant Summary collapse
- MAX_DIFF_BYTES =
32_768
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#description, #input_schema, #name, #output_schema, #requires_approval, #risk_level
Instance Method Summary collapse
Methods inherited from Base
#initialize, #to_anthropic_schema, #to_ollama_schema, #to_s, tool_description, tool_name, tool_output_schema, tool_requires_approval, tool_risk, tool_schema
Constructor Details
This class inherits a constructor from OllamaAgent::Tools::Base
Instance Method Details
#call(args, context: {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ollama_agent/tools/git_tools.rb', line 63 def call(args, context: {}) root = context[:root] || Dir.pwd ref = args["ref"] cached = args["cached"] ? "--cached" : "" path = args["path"] cmd_parts = ["git diff", cached, ref, "--", path].compact.reject(&:empty?) output = git_run(cmd_parts.join(" "), cwd: root) output.byteslice(0, MAX_DIFF_BYTES).then { |o| output.bytesize > MAX_DIFF_BYTES ? "#{o}\n...[truncated]" : o } end |