Class: OllamaAgent::RuntimeCommandSystem::SuggestionEngine
- Inherits:
-
Object
- Object
- OllamaAgent::RuntimeCommandSystem::SuggestionEngine
- Defined in:
- lib/ollama_agent/runtime_command_system/suggestion_engine.rb
Overview
Routes slash-command input to command, model, provider, or plugin completers.
Instance Method Summary collapse
- #complete(input:, cursor_pos: nil, session: {}) ⇒ Object
-
#initialize(registry:) ⇒ SuggestionEngine
constructor
A new instance of SuggestionEngine.
Constructor Details
#initialize(registry:) ⇒ SuggestionEngine
Returns a new instance of SuggestionEngine.
10 11 12 |
# File 'lib/ollama_agent/runtime_command_system/suggestion_engine.rb', line 10 def initialize(registry:) @registry = registry end |
Instance Method Details
#complete(input:, cursor_pos: nil, session: {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ollama_agent/runtime_command_system/suggestion_engine.rb', line 14 def complete(input:, cursor_pos: nil, session: {}) text = input.to_s return [] unless text.start_with?("/") ast = AST::Parser.parse(text, cursor_pos || text.length) return [] unless ast command = @registry.find(ast.name) return command_completions(ast.name) unless command && ast.argument_context? command.completer&.suggestions(ast: ast, cursor_pos: cursor_pos || text.length, session: session) || [] end |