Class: OllamaAgent::RuntimeCommandSystem::CommandPalette

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

Overview

Facade for the AI Runtime Shell command palette.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commands:, session: {}) ⇒ CommandPalette

Returns a new instance of CommandPalette.



15
16
17
18
19
20
21
22
# File 'lib/ollama_agent/runtime_command_system/command_palette.rb', line 15

def initialize(commands:, session: {})
  @session = session
  @registry = CommandRegistry.new
  @suggestion_engine = SuggestionEngine.new(registry: @registry)
  @ghost_renderer = GhostTextRenderer.new(@suggestion_engine)
  @menu = InteractiveMenu.new
  register_commands(commands)
end

Instance Attribute Details

#ghost_rendererObject (readonly)

Returns the value of attribute ghost_renderer.



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

def ghost_renderer
  @ghost_renderer
end

Returns the value of attribute menu.



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

def menu
  @menu
end

#registryObject (readonly)

Returns the value of attribute registry.



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

def registry
  @registry
end

#suggestion_engineObject (readonly)

Returns the value of attribute suggestion_engine.



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

def suggestion_engine
  @suggestion_engine
end

Instance Method Details

#accept_ghost(input, cursor_pos = nil) ⇒ Object



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

def accept_ghost(input, cursor_pos = nil)
  ghost_text(input, cursor_pos)&.full_completion
end

#ghost_text(input, cursor_pos = nil) ⇒ Object



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

def ghost_text(input, cursor_pos = nil)
  @ghost_renderer.ghost_text(input: input, cursor_pos: cursor_pos || input.to_s.length, session: @session)
end

#suggestions(input, cursor_pos = nil) ⇒ Object



24
25
26
# File 'lib/ollama_agent/runtime_command_system/command_palette.rb', line 24

def suggestions(input, cursor_pos = nil)
  @suggestion_engine.complete(input: input, cursor_pos: cursor_pos || input.to_s.length, session: @session)
end