Class: RosettAi::Thor::Tasks::Engines
- Inherits:
-
Thor
- Object
- Thor
- RosettAi::Thor::Tasks::Engines
- Defined in:
- lib/rosett_ai/thor/tasks/engines.rb
Overview
Thor task for engine detection and management
Instance Method Summary collapse
Instance Method Details
#detect ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rosett_ai/thor/tasks/engines.rb', line 54 def detect rows = RosettAi::Engines::Registry.available.filter_map do |name| manifest = RosettAi::Engines::Registry.manifest(name) next unless manifest.dig('components', 'detector') result = build_detector(name).detect result[:checks].map do |check| status = check[:passed] ? Rainbow(t('found')).green : Rainbow(t('not_found')).red [result[:display_name], check[:type], check[:name], status] end rescue StandardError => e [[name, 'manifest', '-', Rainbow("error: #{e.}").red]] end.flatten(1) table = ::Terminal::Table.new( title: Rainbow(t('detect_title')).bright, headings: [t('engine'), t('check_type'), t('check_name'), t('status')], rows: rows, style: { border: :unicode_round } ) puts table end |
#list ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rosett_ai/thor/tasks/engines.rb', line 26 def list rows = RosettAi::Engines::Registry.available.map do |name| manifest = RosettAi::Engines::Registry.manifest(name) [manifest['name'], manifest['display_name'], manifest['version']] rescue StandardError => e [name, Rainbow("error: #{e.}").red, '?'] end table = ::Terminal::Table.new( title: Rainbow(t('list_title')).bright, headings: [t('name'), t('display_name'), t('version')], rows: rows, style: { border: :unicode_round } ) puts table end |
#plugins ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/rosett_ai/thor/tasks/engines.rb', line 123 def plugins plugin_engines = RosettAi::Plugins::Registry.available(:engine) if plugin_engines.empty? puts Rainbow(t('no_plugins')).yellow return end rows = plugin_engines.map do |name| plugin = RosettAi::Plugins::Registry.plugin_module(:engine, name) version = plugin.respond_to?(:version) ? plugin.version : '?' display = plugin.respond_to?(:display_name) ? plugin.display_name : name [name, display, version] end table = ::Terminal::Table.new( title: Rainbow(t('plugins_title')).bright, headings: [t('name'), t('display_name'), t('version')], rows: rows, style: { border: :unicode_round } ) puts table end |
#status ⇒ Object
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 |
# File 'lib/rosett_ai/thor/tasks/engines.rb', line 88 def status default_engine = RosettAi.rai_config.default_engine puts "#{t('default_engine')}: #{Rainbow(default_engine).bright}" puts rows = RosettAi::Engines::Registry.available.map do |name| manifest = RosettAi::Engines::Registry.manifest(name) detected = if manifest.dig('components', 'detector') result = build_detector(name).detect result[:detected] ? Rainbow(t('yes')).green : Rainbow(t('no')).red else Rainbow(t('no_detector')).yellow end is_default = name == default_engine ? Rainbow(t('yes')).green : t('no') [manifest['display_name'], detected, is_default] rescue StandardError => e [name, Rainbow("error: #{e.}").red, '?'] end table = ::Terminal::Table.new( title: Rainbow(t('status_title')).bright, headings: [t('engine'), t('detected'), t('default')], rows: rows, style: { border: :unicode_round } ) puts table end |