Class: OllamaAgent::RuntimeCommandSystem::Suggestion

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

Overview

Immutable completion candidate for the AI Runtime Shell command palette.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, type:, description: nil, metadata: {}, capabilities: [], replacement_start: 0) ⇒ Suggestion

Returns a new instance of Suggestion.



9
10
11
12
13
14
15
16
# File 'lib/ollama_agent/runtime_command_system/suggestion.rb', line 9

def initialize(text:, type:, description: nil, metadata: {}, capabilities: [], replacement_start: 0)
  @text = text.to_s
  @type = type.to_sym
  @description = description
  @metadata = .transform_keys(&:to_sym)
  @capabilities = Array(capabilities).map(&:to_sym)
  @replacement_start = replacement_start.to_i
end

Instance Attribute Details

#capabilitiesObject (readonly)

Returns the value of attribute capabilities.



7
8
9
# File 'lib/ollama_agent/runtime_command_system/suggestion.rb', line 7

def capabilities
  @capabilities
end

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/ollama_agent/runtime_command_system/suggestion.rb', line 7

def description
  @description
end

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/ollama_agent/runtime_command_system/suggestion.rb', line 7

def 
  @metadata
end

#replacement_startObject (readonly)

Returns the value of attribute replacement_start.



7
8
9
# File 'lib/ollama_agent/runtime_command_system/suggestion.rb', line 7

def replacement_start
  @replacement_start
end

#textObject (readonly)

Returns the value of attribute text.



7
8
9
# File 'lib/ollama_agent/runtime_command_system/suggestion.rb', line 7

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/ollama_agent/runtime_command_system/suggestion.rb', line 7

def type
  @type
end

Instance Method Details

#display_textObject



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

def display_text
  name_col = text.ljust(30)
  details = []
  details << description if description && !description.empty?
  badge_str = capabilities.map { |c| "[#{c}]" }.join(" ")
  return text if details.empty? && badge_str.empty?

  suffix = details.empty? ? badge_str : "#{details.join(" ")}  #{badge_str}".rstrip
  "#{name_col}#{suffix}"
end