Class: AIA::Utility

Inherits:
Object
  • Object
show all
Defined in:
lib/aia/utility.rb

Class Method Summary collapse

Class Method Details

.mcp_server_namesObject



20
21
22
23
# File 'lib/aia/utility.rb', line 20

def mcp_server_names
  return [] unless mcp_servers?
  AIA.config.mcp_servers.map { |s| s[:name] || s["name"] }.compact
end

.mcp_servers?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/aia/utility.rb', line 16

def mcp_servers?
  AIA.config&.mcp_servers && !AIA.config.mcp_servers.empty?
end

.robotObject

Displays the AIA robot ASCII art Yes, its slightly frivolous but it does contain some useful configuration information.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/aia/utility.rb', line 33

def robot
  indent  = 18
  spaces  = " "*indent
  width   = TTY::Screen.width - indent - 2

  mcp_version = defined?(RubyLLM::MCP::VERSION) ? " MCP v" + RubyLLM::MCP::VERSION : ''

  # Extract model names from config (handles hash format from ADR-005)
  model_display = if AIA.config&.model
    models = AIA.config.model
    if models.is_a?(String)
      models
    elsif models.is_a?(Array)
      if models.first.is_a?(Hash)
        models.map { |spec| spec[:model] }.join(', ')
      else
        models.join(', ')
      end
    else
      models.to_s
    end
  else
    'unknown-model'
  end

  mcp_line = mcp_servers? ? "MCP: #{mcp_server_names.join(', ')}" : ''

  puts "\n ,      ,\n (\\\\____/) AI Assistant (v\#{AIA::VERSION}) is Online\n  (_oo_)   \#{model_display}\#{supports_tools? ? ' (supports tools)' : ''}\n   (O)       using \#{AIA.config&.adapter || 'unknown-adapter'} (v\#{RubyLLM::VERSION}\#{mcp_version})\n __||__    \\\\) model db was last refreshed on\n     [/______\\\\]  /    \#{AIA.config&.last_refresh || 'unknown'}\n    / \\\\__AI__/ \\\\/      \#{user_tools? ? 'I will also use your tools' : (tools? ? 'You can share my tools' : 'I did not bring any tools')}\n   /    /__\\\\              \#{mcp_line}\n  (\\\\   /____\\\\   \#{user_tools? && tools? ? 'My Toolbox contains:' : ''}\n  ROBOT\n  if user_tools? && tools?\n    tool_names = AIA.config.respond_to?(:tool_names) ? AIA.config.tool_names : AIA.config.tools\n    if tool_names && !tool_names.to_s.empty?\n      puts WordWrapper::MinimumRaggedness.new(\n          width,\n          tool_names.to_s # String of tool names, comma separated\n        ).wrap\n        .split(\"\\n\")\n        .map{|s| spaces+s+\"\\n\"}\n        .join\n    end\n  end\nend\n"

.supports_tools?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/aia/utility.rb', line 25

def supports_tools?
  AIA.config&.client&.model&.supports_functions? || false
end

.tools?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/aia/utility.rb', line 8

def tools?
  AIA.config&.tool_names && !AIA.config.tool_names.empty?
end

.user_tools?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/aia/utility.rb', line 12

def user_tools?
  AIA.config&.tool_paths && !AIA.config.tool_paths.empty?
end