Class: Agentic::CLI::Capabilities

Inherits:
Thor
  • Object
show all
Defined in:
lib/agentic/cli/capabilities.rb

Overview

Command-line interface for managing capabilities

Instance Method Summary collapse

Instance Method Details

#listObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
# File 'lib/agentic/cli/capabilities.rb', line 10

def list
  # Initialize agent assembly system
  Agentic.initialize_agent_assembly
  registry = Agentic.agent_capability_registry

  capabilities = registry.list(include_providers: options[:detailed])

  if capabilities.empty?
    puts UI.box(
      "Available Capabilities",
      "No capabilities registered yet.\n\n" \
      "You can register capabilities programmatically via Agentic.register_capability.",
      padding: [1, 2, 1, 2],
      style: {border: {fg: :blue}}
    )
    return
  end

  output = ""
  capabilities.each do |name, info|
    output += "#{UI.colorize(name, :blue)}:\n"
    output += "  Available versions: #{info[:versions].join(", ")}\n"
    output += "  Latest version: #{UI.colorize(info[:latest], :green)}\n"

    if options[:detailed] && info[:providers]
      # Get a capability to show more details
      capability = registry.get(name, info[:latest])
      if capability
        output += "  Description: #{capability.description}\n"

        unless capability.inputs.empty?
          output += "  Inputs:\n"
          capability.inputs.each do |input_name, input_spec|
            required = input_spec[:required] ? " (required)" : ""
            output += "    - #{input_name}#{required}: #{input_spec[:type] || "any"}\n"
            output += "      #{input_spec[:description]}\n" if input_spec[:description]
          end
        end

        unless capability.outputs.empty?
          output += "  Outputs:\n"
          capability.outputs.each do |output_name, output_spec|
            output += "    - #{output_name}: #{output_spec[:type] || "any"}\n"
            output += "      #{output_spec[:description]}\n" if output_spec[:description]
          end
        end

        unless capability.dependencies.empty?
          output += "  Dependencies:\n"
          capability.dependencies.each do |dep|
            output += "    - #{dep[:name]} (#{dep[:version] || "any version"})\n"
          end
        end
      end
    end

    output += "\n"
  end

  puts UI.box(
    "Available Capabilities",
    output,
    padding: [1, 2, 1, 2],
    style: {border: {fg: :blue}}
  )
end

#search(query) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/agentic/cli/capabilities.rb', line 140

def search(query)
  # Initialize agent assembly system
  Agentic.initialize_agent_assembly
  registry = Agentic.agent_capability_registry

  # Search by name and description
  capabilities = registry.list
  results = {}

  capabilities.each do |name, info|
    # Check if query matches capability name
    if name.downcase.include?(query.downcase)
      results[name] = info
      next
    end

    # Check if query matches capability description
    capability = registry.get(name, info[:latest])
    if capability && capability.description.downcase.include?(query.downcase)
      results[name] = info
    end
  end

  if results.empty?
    puts UI.box(
      "Search Results",
      "No capabilities found matching '#{UI.colorize(query, :yellow)}'.",
      padding: [1, 2, 1, 2],
      style: {border: {fg: :blue}}
    )
    return
  end

  output = ""
  results.each do |name, info|
    capability = registry.get(name, info[:latest])

    output += "#{UI.colorize(name, :blue)}:\n"
    output += "  Latest version: #{UI.colorize(info[:latest], :green)}\n"
    output += "  Description: #{capability.description}\n\n"
  end

  puts UI.box(
    "Search Results",
    output,
    padding: [1, 2, 1, 2],
    style: {border: {fg: :blue}}
  )
end

#show(name) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/agentic/cli/capabilities.rb', line 80

def show(name)
  # Initialize agent assembly system
  Agentic.initialize_agent_assembly
  registry = Agentic.agent_capability_registry

  capability = registry.get(name, options[:version])

  unless capability
    available = registry.list.keys.join(", ")
    available_text = available.empty? ? "No capabilities registered yet." : "Available: #{available}"

    puts UI.box(
      "Error",
      "Capability '#{UI.colorize(name, :yellow)}' not found.\n\n#{available_text}",
      padding: [1, 2, 1, 2],
      style: {border: {fg: :red}}
    )
    exit 1
  end

  output = ""
  output += "Name: #{UI.colorize(capability.name, :blue)}\n"
  output += "Version: #{UI.colorize(capability.version, :green)}\n"
  output += "Description: #{capability.description}\n\n"

  unless capability.inputs.empty?
    output += "Inputs:\n"
    capability.inputs.each do |input_name, input_spec|
      required = input_spec[:required] ? " (required)" : ""
      output += "  - #{UI.colorize(input_name, :yellow)}#{required}: #{input_spec[:type] || "any"}\n"
      output += "    #{input_spec[:description]}\n" if input_spec[:description]
    end
    output += "\n"
  end

  unless capability.outputs.empty?
    output += "Outputs:\n"
    capability.outputs.each do |output_name, output_spec|
      output += "  - #{UI.colorize(output_name, :yellow)}: #{output_spec[:type] || "any"}\n"
      output += "    #{output_spec[:description]}\n" if output_spec[:description]
    end
    output += "\n"
  end

  unless capability.dependencies.empty?
    output += "Dependencies:\n"
    capability.dependencies.each do |dep|
      output += "  - #{UI.colorize(dep[:name], :magenta)} (#{dep[:version] || "any version"})\n"
    end
  end

  puts UI.box(
    "Capability Details",
    output,
    padding: [1, 2, 1, 2],
    style: {border: {fg: :blue}}
  )
end