Class: OllamaAgent::RuntimeCommandSystem::CommandRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/runtime_command_system/command_registry.rb

Overview

Central source of command metadata and command-aware completer bindings.

Defined Under Namespace

Classes: CommandSpec

Instance Method Summary collapse

Constructor Details

#initializeCommandRegistry

Returns a new instance of CommandRegistry.



13
14
15
# File 'lib/ollama_agent/runtime_command_system/command_registry.rb', line 13

def initialize
  @commands = {}
end

Instance Method Details

#allObject



37
38
39
# File 'lib/ollama_agent/runtime_command_system/command_registry.rb', line 37

def all
  @commands.values
end

#find(name) ⇒ Object



28
29
30
# File 'lib/ollama_agent/runtime_command_system/command_registry.rb', line 28

def find(name)
  @commands[normalize_name(name)]
end

#matching_prefix(prefix) ⇒ Object



32
33
34
35
# File 'lib/ollama_agent/runtime_command_system/command_registry.rb', line 32

def matching_prefix(prefix)
  normalized = normalize_name(prefix)
  @commands.values.select { |spec| spec.name.start_with?(normalized) }
end

#register(name:, description:, completer: nil, validator: nil, executor: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/ollama_agent/runtime_command_system/command_registry.rb', line 17

def register(name:, description:, completer: nil, validator: nil, executor: nil)
  normalized = normalize_name(name)
  @commands[normalized] = CommandSpec.new(
    name: normalized,
    description: description.to_s,
    completer: completer,
    validator: validator,
    executor: executor
  )
end