Class: LLM::Tool::Rg

Inherits:
LLM::Tool show all
Defined in:
lib/llm/tools/rg.rb

Overview

The LLM::Tool::Rg class implements a frontend to the popular 'rg' tool. The tool can recursively search the current working directory for one or more patterns.

Instance Method Summary collapse

Methods inherited from LLM::Tool

a2a, a2a?, #a2a?, clear_registry!, description, find_by_name!, function, #function, inherited, mcp, mcp?, #mcp?, name, #on_cancel, #on_interrupt, params, register, registry, skill?, #skill?, unregister

Methods included from Param

#param, #required

Methods included from Function::Registry

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

Instance Method Details

#call(patterns:, path: Dir.getwd) ⇒ Hash

Parameters:

  • pattern (String)

Returns:

  • (Hash)


21
22
23
24
25
# File 'lib/llm/tools/rg.rb', line 21

def call(patterns:, path: Dir.getwd)
  validate!(patterns:, path:)
  command = spawn(patterns:, path:)
  {ok: command.success?, stdout: command.stdout, stderr: command.stderr}
end