Class: LLM::Tool::Git::Commit

Inherits:
LLM::Tool::Git show all
Defined in:
lib/llm/tools/git/commit.rb

Overview

The Commit class implements a tool that records changes to the repository.

Constant Summary

Constants inherited from LLM::Tool::Git

DEFAULT_TIMEOUT

Instance Method Summary collapse

Methods inherited from LLM::Tool

NotFound, a2a, a2a?, #a2a?, abstract!, abstract?, clear_registry!, description, find_by_name!, #function, function, inherited, mcp, #mcp?, mcp?, name, #on_cancel, #on_interrupt, params, register, registry, set, subclasses, unregister

Methods included from Param

#defaults, #param, #required

Methods included from Function::Registry

#clear_registry!, #find_by_name, #lock, #register, #registry, #registry_key, #tool_name, #unregister

Instance Method Details

#call(message:, paths: [], all: false, timeout: DEFAULT_TIMEOUT, cwd: Dir.getwd) ⇒ Hash

Parameters:

  • message (String) —

    The commit message

  • paths (Array<String>) (defaults to: []) —

    One or more paths to commit

  • all (Boolean) (defaults to: false) —

    Whether to commit every tracked change

  • timeout (Integer) (defaults to: DEFAULT_TIMEOUT) —

    The maximum time to allow git to run, in seconds

Returns:

  • (Hash)

Raises:

  • (LLM::Error) —

    When all: and paths: are given together



29
30
31
32
33
# File 'lib/llm/tools/git/commit.rb', line 29

def call(message:, paths: [], all: false, timeout: DEFAULT_TIMEOUT, cwd: Dir.getwd)
  Exec
    .new(env:)
    .call(command: "git", arguments: ["-C", cwd, *parse!(message:, paths:, all:)], timeout:)
end