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-gateway
lex-codegen lex-exec lex-lex lex-telemetry lex-audit lex-detect].freeze
- AI =
%w[lex-claude lex-openai lex-gemini].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', '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.
25
26
27
28
29
30
31
32
|
# File 'lib/legion/tty/screens/extensions.rb', line 25
def initialize(app, output: $stdout)
super(app)
@output = output
@gems = []
@selected = 0
@detail = false
@filter = nil
end
|
Instance Method Details
#activate ⇒ Object
34
35
36
|
# File 'lib/legion/tty/screens/extensions.rb', line 34
def activate
@gems = discover_extensions
end
|
#discover_extensions ⇒ Object
38
39
40
41
42
|
# File 'lib/legion/tty/screens/extensions.rb', line 38
def discover_extensions
Gem::Specification.select { |s| s.name.start_with?('lex-') }
.sort_by(&:name)
.map { |s| build_entry(s) }
end
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/legion/tty/screens/extensions.rb', line 57
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
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/legion/tty/screens/extensions.rb', line 44
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
|