Module: Ace::Search::Atoms::ToolChecker

Defined in:
lib/ace/search/atoms/tool_checker.rb

Overview

ToolChecker verifies availability of external tools (rg, fd, fzf) This is an atom - pure function for tool availability checking

Class Method Summary collapse

Class Method Details

.check_all_toolsObject

Check all required tools and return status



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ace/search/atoms/tool_checker.rb', line 49

def check_all_tools
  {
    ripgrep: {
      available: ripgrep_available?,
      version: ripgrep_available? ? tool_version("rg") : nil
    },
    fd: {
      available: fd_available?,
      version: fd_available? ? tool_version("fd") : nil
    },
    fzf: {
      available: fzf_available?,
      version: fzf_available? ? tool_version("fzf") : nil,
      required: false
    }
  }
end

.check_tool(tool_name) ⇒ Object

Check if a tool is available in PATH



29
30
31
32
33
34
# File 'lib/ace/search/atoms/tool_checker.rb', line 29

def check_tool(tool_name)
  stdout, _stderr, status = Open3.capture3("which #{tool_name}")
  status.success? && !stdout.strip.empty?
rescue
  false
end

.fd_available?Boolean

Check if fd is available

Returns:

  • (Boolean)


19
20
21
# File 'lib/ace/search/atoms/tool_checker.rb', line 19

def fd_available?
  check_tool("fd")
end

.fzf_available?Boolean

Check if fzf is available

Returns:

  • (Boolean)


24
25
26
# File 'lib/ace/search/atoms/tool_checker.rb', line 24

def fzf_available?
  check_tool("fzf")
end

.ripgrep_available?Boolean

Check if ripgrep is available

Returns:

  • (Boolean)


14
15
16
# File 'lib/ace/search/atoms/tool_checker.rb', line 14

def ripgrep_available?
  check_tool("rg")
end

.tool_version(tool_name) ⇒ Object

Get tool version



37
38
39
40
41
42
43
44
45
46
# File 'lib/ace/search/atoms/tool_checker.rb', line 37

def tool_version(tool_name)
  stdout, _stderr, status = Open3.capture3("#{tool_name} --version")
  return nil unless status.success?

  # Extract version number from output
  version_match = stdout.match(/([\d.]+)/)
  version_match ? version_match[1] : nil
rescue
  nil
end