Class: LLM::Tool::Rg

Inherits:
LLM::Tool show all
Includes:
Utils
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 included from Utils

#now, #wait

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

#defaults, #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, timeout: 5) ⇒ Hash

Parameters:

  • patterns (Array<String>)
  • path (String) (defaults to: Dir.getwd)

Returns:

  • (Hash)


25
26
27
28
29
30
# File 'lib/llm/tools/rg.rb', line 25

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