Class: Legion::TTY::Screens::Extensions
- Inherits:
-
Base
- Object
- Base
- Legion::TTY::Screens::Extensions
show all
- Includes:
- Logging::Helper
- Defined in:
- lib/legion/tty/screens/extensions.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary
collapse
- CORE =
%w[lex-node lex-tasker lex-scheduler lex-conditioner lex-transformer
lex-synapse lex-health lex-log lex-ping lex-metering lex-llm-ledger
lex-codegen lex-exec lex-lex lex-telemetry lex-audit lex-detect].freeze
- AI =
%w[lex-azure-ai lex-bedrock lex-claude lex-foundry lex-gemini lex-llamacpp
lex-mlx lex-ollama lex-openai lex-uais lex-xai lex-llm lex-llm-anthropic
lex-llm-azure-foundry lex-llm-bedrock lex-llm-gemini lex-llm-mlx
lex-llm-ollama lex-llm-openai lex-llm-vertex lex-llm-vllm].freeze
- LEGACY =
%w[lex-llm-gateway].freeze
- SERVICE =
%w[lex-http lex-vault lex-github lex-consul lex-kerberos lex-tfe
lex-redis lex-memcached lex-elasticsearch lex-s3].freeze
- CATEGORIES =
[nil, 'Core', 'AI', 'Service', 'Agentic', 'Legacy', 'Other'].freeze
Instance Attribute Summary
Attributes inherited from Base
#app
Instance Method Summary
collapse
Methods inherited from Base
#deactivate, #needs_input_bar?, #teardown
Constructor Details
#initialize(app, output: $stdout) ⇒ Extensions
Returns a new instance of Extensions.
30
31
32
33
34
35
36
37
|
# File 'lib/legion/tty/screens/extensions.rb', line 30
def initialize(app, output: $stdout)
super(app)
@output = output
@gems = []
@selected = 0
@detail = false
@filter = nil
end
|
Instance Method Details
#activate ⇒ Object
39
40
41
|
# File 'lib/legion/tty/screens/extensions.rb', line 39
def activate
@gems = discover_extensions
end
|
#discover_extensions ⇒ Object
43
44
45
46
47
|
# File 'lib/legion/tty/screens/extensions.rb', line 43
def discover_extensions
Gem::Specification.select { |s| s.name.start_with?('lex-') }
.sort_by(&:name)
.map { |s| build_entry(s) }
end
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/legion/tty/screens/extensions.rb', line 62
def handle_input(key)
case key
when :up
@selected = [(@selected - 1), 0].max
:handled
when :down
max = [current_gems.size - 1, 0].max
@selected = [(@selected + 1), max].min
:handled
when :enter
@detail = !@detail
:handled
when 'q', :escape
handle_back_key
else
handle_action_key(key)
end
end
|
#render(_width, height) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/legion/tty/screens/extensions.rb', line 49
def render(_width, height)
filter_label = @filter ? Theme.c(:warning, " filter: #{@filter}") : ''
= [Theme.c(:accent, ' LEX Extensions'), filter_label].reject(&:empty?)
lines = + ['']
lines += if @detail && current_gems[@selected]
detail_lines(current_gems[@selected])
else
list_lines(height - 4)
end
lines += ['', Theme.c(:muted, ' Enter=detail o=open f=filter c=clear q=back')]
pad_lines(lines, height)
end
|