aia 2.0.0.0.pre.alpha → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/CHANGELOG.md +151 -228
- data/README.md +42 -19
- data/bin/aia +8 -3
- data/lib/aia/aia_completion.bash +2 -3
- data/lib/aia/aia_completion.fish +6 -5
- data/lib/aia/aia_completion.zsh +2 -3
- data/lib/aia/chat_loop.rb +24 -66
- data/lib/aia/config/cli_parser.rb +164 -123
- data/lib/aia/config/defaults.yml +12 -39
- data/lib/aia/config/mcp_parser.rb +42 -40
- data/lib/aia/config/model_spec.rb +8 -14
- data/lib/aia/config/validator.rb +144 -156
- data/lib/aia/config/value_caster.rb +76 -0
- data/lib/aia/config.rb +72 -54
- data/lib/aia/content_extractor.rb +2 -0
- data/lib/aia/cost_calculator.rb +1 -0
- data/lib/aia/crew.rb +29 -19
- data/lib/aia/debate_handler.rb +45 -20
- data/lib/aia/delegate_handler.rb +7 -3
- data/lib/aia/directive.rb +10 -8
- data/lib/aia/directives/configuration_directives.rb +164 -109
- data/lib/aia/directives/context_directives.rb +55 -40
- data/lib/aia/directives/execution_directives.rb +25 -25
- data/lib/aia/directives/model_directives.rb +112 -195
- data/lib/aia/directives/trakflow_directives.rb +27 -9
- data/lib/aia/directives/utility_directives.rb +86 -87
- data/lib/aia/directives/web_and_file_directives.rb +83 -63
- data/lib/aia/fact_asserter.rb +3 -3
- data/lib/aia/history_transfer.rb +64 -24
- data/lib/aia/layered_orchestrator.rb +66 -43
- data/lib/aia/logger.rb +27 -62
- data/lib/aia/mcp_config_normalizer.rb +27 -14
- data/lib/aia/mcp_connection_manager.rb +193 -186
- data/lib/aia/mcp_discovery.rb +43 -15
- data/lib/aia/mcp_grouper.rb +2 -1
- data/lib/aia/mcp_server_config.rb +48 -0
- data/lib/aia/mcp_utility.rb +28 -20
- data/lib/aia/mention_router.rb +22 -52
- data/lib/aia/modality_query.rb +36 -0
- data/lib/aia/model_alias_registry.rb +11 -11
- data/lib/aia/model_registry.rb +75 -0
- data/lib/aia/network_builder.rb +17 -11
- data/lib/aia/network_memory_manager.rb +6 -6
- data/lib/aia/patches/ruby_llm_streaming_error.rb +21 -4
- data/lib/aia/patches/ruby_llm_tool_param_compat.rb +18 -0
- data/lib/aia/pipeline_orchestrator.rb +88 -45
- data/lib/aia/plugin_monitor.rb +9 -6
- data/lib/aia/prompt_decomposer.rb +6 -4
- data/lib/aia/prompt_handler.rb +90 -69
- data/lib/aia/provider_registry.rb +105 -0
- data/lib/aia/robot_builder.rb +1 -1
- data/lib/aia/robot_factory.rb +77 -69
- data/lib/aia/robot_namer.rb +2 -8
- data/lib/aia/robot_sync.rb +79 -0
- data/lib/aia/role_catalog.rb +89 -0
- data/lib/aia/session.rb +32 -14
- data/lib/aia/session_tracker.rb +39 -41
- data/lib/aia/similarity_scorer.rb +5 -3
- data/lib/aia/skill_utils.rb +60 -19
- data/lib/aia/spawn_handler.rb +16 -4
- data/lib/aia/spawn_spec_parser.rb +6 -7
- data/lib/aia/special_mode_handler.rb +80 -57
- data/lib/aia/speech.rb +103 -0
- data/lib/aia/startup_coordinator.rb +17 -91
- data/lib/aia/streaming_runner.rb +16 -5
- data/lib/aia/system_prompt_assembler.rb +20 -15
- data/lib/aia/task_board.rb +60 -0
- data/lib/aia/task_coordinator.rb +10 -5
- data/lib/aia/timing.rb +15 -0
- data/lib/aia/tool_approver.rb +205 -0
- data/lib/aia/tool_filter.rb +1 -9
- data/lib/aia/tool_filter_strategy.rb +39 -25
- data/lib/aia/tool_introspection.rb +25 -0
- data/lib/aia/tool_loader.rb +71 -31
- data/lib/aia/tool_utility.rb +6 -5
- data/lib/aia/tools/delegate_to_foreman_tool.rb +6 -4
- data/lib/aia/tools/recruit_robot_tool.rb +12 -12
- data/lib/aia/tools/reskill_robot_tool.rb +7 -7
- data/lib/aia/tools/task_board_tool.rb +17 -16
- data/lib/aia/trakflow_bridge.rb +19 -11
- data/lib/aia/turn_state.rb +32 -8
- data/lib/aia/ui_presenter.rb +83 -59
- data/lib/aia/utility.rb +8 -24
- data/lib/aia/variable_input_collector.rb +1 -3
- data/lib/aia/verification_network.rb +10 -12
- data/lib/aia.rb +49 -8
- metadata +27 -162
- data/.better-commits.json +0 -150
- data/.config/tocer/configuration.yml +0 -6
- data/.envrc +0 -15
- data/.loki +0 -231
- data/.quality/flay_baseline.txt +0 -1
- data/.quality/flog_baseline.txt +0 -29
- data/.quality/reek_baseline.txt +0 -80
- data/.rubocop.yml +0 -116
- data/COMMITS.md +0 -196
- data/IMPLEMENTATION_PLAN.md +0 -506
- data/Rakefile +0 -160
- data/architecture_review.md +0 -314
- data/docs/AGENTS.md +0 -40
- data/docs/advanced-prompting.md +0 -814
- data/docs/assets/images/aia.png +0 -0
- data/docs/cli-reference.md +0 -1241
- data/docs/configuration.md +0 -747
- data/docs/contributing.md +0 -386
- data/docs/directives-reference.md +0 -1145
- data/docs/examples/index.md +0 -277
- data/docs/examples/mcp/index.md +0 -475
- data/docs/examples/prompts/analysis/index.md +0 -78
- data/docs/examples/prompts/automation/index.md +0 -109
- data/docs/examples/prompts/development/index.md +0 -125
- data/docs/examples/prompts/index.md +0 -333
- data/docs/examples/prompts/learning/index.md +0 -127
- data/docs/examples/prompts/writing/index.md +0 -62
- data/docs/examples/tools/index.md +0 -282
- data/docs/faq.md +0 -578
- data/docs/guides/available-models.md +0 -366
- data/docs/guides/basic-usage.md +0 -478
- data/docs/guides/chat.md +0 -680
- data/docs/guides/crew.md +0 -239
- data/docs/guides/executable-prompts.md +0 -331
- data/docs/guides/first-prompt.md +0 -454
- data/docs/guides/getting-started.md +0 -455
- data/docs/guides/image-generation.md +0 -507
- data/docs/guides/index.md +0 -48
- data/docs/guides/local-models.md +0 -306
- data/docs/guides/migrate-prompts.md +0 -335
- data/docs/guides/models.md +0 -1017
- data/docs/guides/shared-tools.md +0 -254
- data/docs/guides/tools.md +0 -831
- data/docs/index.md +0 -259
- data/docs/installation.md +0 -274
- data/docs/mcp-integration.md +0 -603
- data/docs/prompt_management.md +0 -665
- data/docs/security.md +0 -674
- data/docs/special_projects_guide.md +0 -386
- data/docs/tools-and-mcp-examples.md +0 -1211
- data/docs/workflows-and-pipelines.md +0 -636
- data/examples/.gitignore +0 -2
- data/examples/00_setup_aia.sh +0 -111
- data/examples/01_basic_usage.sh +0 -23
- data/examples/02_frontmatter.sh +0 -33
- data/examples/03_shell_integration.sh +0 -55
- data/examples/04_erb_templating.sh +0 -56
- data/examples/05_shell_then_erb.sh +0 -38
- data/examples/06_prompt_chaining.sh +0 -59
- data/examples/07_pipeline.sh +0 -46
- data/examples/08_context_files.sh +0 -43
- data/examples/09_roles.sh +0 -67
- data/examples/10_stdin_piping.sh +0 -49
- data/examples/11_multi_model.sh +0 -65
- data/examples/12_token_usage.sh +0 -52
- data/examples/13_cost_tracking.sh +0 -68
- data/examples/14_output_file.sh +0 -91
- data/examples/15_parameters.sh +0 -68
- data/examples/16_directives.sh +0 -113
- data/examples/17_require_and_conditionals.sh +0 -68
- data/examples/18_tools.sh +0 -61
- data/examples/19_local_tools.sh +0 -34
- data/examples/20_mcp_servers.sh +0 -102
- data/examples/21_executable_prompts.sh +0 -78
- data/examples/22_chat_mode.sh +0 -217
- data/examples/23_verify.sh +0 -139
- data/examples/24_decompose.sh +0 -139
- data/examples/25_spawn.sh +0 -139
- data/examples/26_debate.sh +0 -97
- data/examples/27_mention_routing.sh +0 -157
- data/examples/28_model_switching.sh +0 -106
- data/examples/29_agent_harness.sh +0 -177
- data/examples/README.md +0 -321
- data/examples/advanced_multi_robot_capabilities_without_examples.md +0 -106
- data/examples/aia_config.yml +0 -22
- data/examples/aia_config_orchestrator.yml +0 -45
- data/examples/aia_config_with_mcp.yml +0 -21
- data/examples/common.sh +0 -39
- data/examples/context/project_goals.md +0 -6
- data/examples/context/tech_stack.md +0 -7
- data/examples/directives/timestamp_directive.rb +0 -22
- data/examples/mcp/filesystem.json +0 -9
- data/examples/prompts_dir/analyze.md +0 -2
- data/examples/prompts_dir/brainstorm.md +0 -2
- data/examples/prompts_dir/conditional.md +0 -17
- data/examples/prompts_dir/creative.md +0 -4
- data/examples/prompts_dir/erbinfo.md +0 -5
- data/examples/prompts_dir/erbinfo_raw.md +0 -8
- data/examples/prompts_dir/evaluate.md +0 -2
- data/examples/prompts_dir/explain_joke.md +0 -1
- data/examples/prompts_dir/explain_recursion.md +0 -1
- data/examples/prompts_dir/fun_fact +0 -3
- data/examples/prompts_dir/greeting.md +0 -8
- data/examples/prompts_dir/greeting_required.md +0 -7
- data/examples/prompts_dir/hello.md +0 -1
- data/examples/prompts_dir/includes/ruby_facts.md +0 -4
- data/examples/prompts_dir/limerick.md +0 -1
- data/examples/prompts_dir/list_with_mcp.md +0 -3
- data/examples/prompts_dir/pick_best.md +0 -2
- data/examples/prompts_dir/project_summary +0 -12
- data/examples/prompts_dir/quiz_with_include.md +0 -6
- data/examples/prompts_dir/require_demo.md +0 -5
- data/examples/prompts_dir/roles/formal.md +0 -3
- data/examples/prompts_dir/roles/orchestrator.md +0 -21
- data/examples/prompts_dir/roles/pirate.md +0 -3
- data/examples/prompts_dir/shell_then_erb.md +0 -6
- data/examples/prompts_dir/sort_compare.md +0 -2
- data/examples/prompts_dir/summarize_context.md +0 -2
- data/examples/prompts_dir/sysinfo.md +0 -5
- data/examples/prompts_dir/sysinfo_raw.md +0 -8
- data/examples/prompts_dir/tagline.md +0 -1
- data/examples/prompts_dir/tell_joke.md +0 -1
- data/examples/prompts_dir/tell_joke_with_next.md +0 -4
- data/examples/prompts_dir/use_local_tool.md +0 -8
- data/examples/prompts_dir/use_tools.md +0 -8
- data/examples/prompts_dir/weather.md +0 -2
- data/examples/prompts_dir/whats_new.md +0 -2
- data/examples/prompts_dir/with_timestamp.md +0 -5
- data/examples/requirements/sinatra_taskflow_app.md +0 -139
- data/examples/rules/01_classify_ruby.rb +0 -16
- data/examples/rules/02_prefer_claude_for_code.rb +0 -19
- data/examples/rules/03_gate_prompt_length.rb +0 -19
- data/examples/rules/04_tool_selection.rb +0 -41
- data/examples/rules/README.md +0 -30
- data/examples/run_all.sh +0 -294
- data/examples/tools/word_count_tool.rb +0 -30
- data/lib/AGENTS.md +0 -57
- data/lib/aia/model_switch_handler.rb +0 -100
- data/mcp_servers/README.md +0 -110
- data/mcp_servers/apple-mcp.json +0 -8
- data/mcp_servers/filesystem.json +0 -9
- data/mcp_servers/mcp_server_chart.json +0 -11
- data/mcp_servers/playwright_one.json +0 -8
- data/mcp_servers/playwright_server_definition.json +0 -9
- data/mcp_servers/playwright_two.json +0 -8
- data/mcp_servers/tavily_mcp_server.json +0 -8
- data/mkdocs.yml +0 -169
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
# lib/aia/directives/model_directives.rb
|
|
2
2
|
|
|
3
|
+
require_relative '../modality_query'
|
|
4
|
+
|
|
3
5
|
module AIA
|
|
4
6
|
class ModelDirectives < Directive
|
|
5
7
|
desc "List all available AI models"
|
|
6
8
|
def available_models(args = nil, context_manager = nil)
|
|
7
|
-
current_models = AIA.config.models
|
|
8
|
-
|
|
9
|
-
model_names = current_models.map do |m|
|
|
10
|
-
m.respond_to?(:name) ? m.name : m.to_s
|
|
11
|
-
end
|
|
12
|
-
|
|
13
9
|
positive_terms, negative_terms = parse_search_terms(Array(args))
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
provider_slugs = configured_provider_slugs(AIA.config.models)
|
|
16
12
|
|
|
17
|
-
if
|
|
18
|
-
|
|
13
|
+
if provider_slugs.any?
|
|
14
|
+
show_provider_models(provider_slugs, positive_terms, negative_terms)
|
|
19
15
|
else
|
|
20
16
|
show_rubyllm_models(positive_terms, negative_terms)
|
|
21
17
|
end
|
|
@@ -29,250 +25,171 @@ module AIA
|
|
|
29
25
|
alias llms available_models
|
|
30
26
|
|
|
31
27
|
desc "Compare responses from multiple models"
|
|
32
|
-
# rubocop:disable Metrics/MethodLength
|
|
33
28
|
def compare(args, context_manager = nil)
|
|
34
|
-
|
|
29
|
+
prompt, models = parse_compare_args(args)
|
|
35
30
|
|
|
36
|
-
prompt
|
|
37
|
-
models
|
|
38
|
-
|
|
39
|
-
i = 0
|
|
40
|
-
while i < args.length
|
|
41
|
-
if args[i] == '--models' && i + 1 < args.length
|
|
42
|
-
models = args[i + 1].split(',')
|
|
43
|
-
i += 2
|
|
44
|
-
else
|
|
45
|
-
prompt ||= args[i]
|
|
46
|
-
i += 1
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
return 'Error: No prompt provided for comparison' unless prompt
|
|
51
|
-
return 'Error: No models specified. Use --models model1,model2,model3' if models.empty?
|
|
31
|
+
return report_error('Error: No prompt provided for comparison') unless prompt
|
|
32
|
+
return report_error('Error: No models specified. Use --models model1,model2,model3') if models.empty?
|
|
52
33
|
|
|
53
34
|
puts "\nComparing responses for: #{prompt}\n"
|
|
54
35
|
puts '=' * 80
|
|
55
36
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
models.each do |model_name|
|
|
59
|
-
model_name.strip!
|
|
60
|
-
puts "\n🤖 **#{model_name}:**"
|
|
61
|
-
puts '-' * 40
|
|
62
|
-
|
|
63
|
-
begin
|
|
64
|
-
chat = RubyLLM.chat(model: model_name)
|
|
65
|
-
response = chat.ask(prompt)
|
|
66
|
-
content = response.content
|
|
67
|
-
|
|
68
|
-
puts content
|
|
69
|
-
results[model_name] = content
|
|
70
|
-
rescue StandardError => e
|
|
71
|
-
error_msg = "Error with #{model_name}: #{e.message}"
|
|
72
|
-
puts error_msg
|
|
73
|
-
results[model_name] = error_msg
|
|
74
|
-
end
|
|
75
|
-
end
|
|
37
|
+
models.each { |model_name| compare_with_model(model_name.strip, prompt) }
|
|
76
38
|
|
|
77
39
|
puts "\n" + ('=' * 80)
|
|
78
40
|
puts "\nComparison complete!"
|
|
79
41
|
|
|
80
42
|
''
|
|
81
43
|
end
|
|
82
|
-
# rubocop:enable Metrics/MethodLength
|
|
83
44
|
alias cmp compare
|
|
84
45
|
|
|
85
46
|
# --- helpers (no desc → not registered) ---
|
|
86
47
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
puts "\nLocal LLM Models:"
|
|
94
|
-
puts
|
|
48
|
+
# Split a //compare arg list into [prompt, models]; every word that is
|
|
49
|
+
# not part of `--models a,b,c` belongs to the prompt.
|
|
50
|
+
def parse_compare_args(args)
|
|
51
|
+
words = []
|
|
52
|
+
models = []
|
|
95
53
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
54
|
+
i = 0
|
|
55
|
+
while i < args.length
|
|
56
|
+
if args[i] == '--models' && i + 1 < args.length
|
|
57
|
+
models = args[i + 1].split(',')
|
|
58
|
+
i += 2
|
|
59
|
+
else
|
|
60
|
+
words << args[i]
|
|
61
|
+
i += 1
|
|
104
62
|
end
|
|
105
63
|
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
109
|
-
def show_ollama_models(api_base, positive_terms = nil, negative_terms = nil)
|
|
110
|
-
positive_terms, negative_terms = normalized_model_search_terms(positive_terms, negative_terms)
|
|
111
64
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
http.open_timeout = 5
|
|
116
|
-
http.read_timeout = 5
|
|
117
|
-
response = http.request(Net::HTTP::Get.new(uri))
|
|
118
|
-
|
|
119
|
-
unless response.is_a?(Net::HTTPSuccess)
|
|
120
|
-
puts "❌ Cannot connect to Ollama at #{api_base}"
|
|
121
|
-
return
|
|
122
|
-
end
|
|
65
|
+
prompt = words.join(' ').strip
|
|
66
|
+
[prompt.empty? ? nil : prompt, models]
|
|
67
|
+
end
|
|
123
68
|
|
|
124
|
-
|
|
125
|
-
|
|
69
|
+
def compare_with_model(model_name, prompt)
|
|
70
|
+
puts "\n🤖 **#{model_name}:**"
|
|
71
|
+
puts '-' * 40
|
|
126
72
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
73
|
+
response = RubyLLM.chat(model: model_name).ask(prompt)
|
|
74
|
+
puts response.content
|
|
75
|
+
rescue StandardError => e
|
|
76
|
+
puts "Error with #{model_name}: #{e.message}"
|
|
77
|
+
end
|
|
131
78
|
|
|
132
|
-
|
|
133
|
-
|
|
79
|
+
# Log and print a directive error, then return nil so the chat loop
|
|
80
|
+
# skips forwarding it to the robot (an error is not conversational output).
|
|
81
|
+
def report_error(msg)
|
|
82
|
+
AIA::LoggerManager.aia_logger.error(msg)
|
|
83
|
+
puts msg
|
|
84
|
+
nil
|
|
85
|
+
end
|
|
134
86
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
show_it &&= negative_terms.none? { |q| entry_lc.include?(q) }
|
|
147
|
-
if show_it
|
|
148
|
-
puts entry
|
|
149
|
-
counter += 1
|
|
150
|
-
end
|
|
87
|
+
# Provider slugs referenced by the configured models — from ModelSpec#provider
|
|
88
|
+
# when present, else from a registered "<slug>/" name prefix (raw string
|
|
89
|
+
# model specs). Entirely registry-driven; no provider names are hardcoded.
|
|
90
|
+
def configured_provider_slugs(models)
|
|
91
|
+
Array(models).filter_map do |m|
|
|
92
|
+
if m.respond_to?(:provider) && m.provider
|
|
93
|
+
m.provider.to_s
|
|
94
|
+
else
|
|
95
|
+
name = (m.respond_to?(:name) ? m.name : m).to_s
|
|
96
|
+
prefix = name.split('/', 2).first if name.include?('/')
|
|
97
|
+
prefix if AIA::ProviderRegistry.registered?(prefix)
|
|
151
98
|
end
|
|
152
|
-
|
|
153
|
-
puts
|
|
154
|
-
puts "#{counter} Ollama model(s) available"
|
|
155
|
-
puts
|
|
156
|
-
rescue StandardError => e
|
|
157
|
-
puts "❌ Error fetching Ollama models: #{e.message}"
|
|
158
|
-
end
|
|
99
|
+
end.uniq
|
|
159
100
|
end
|
|
160
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
161
101
|
|
|
162
|
-
#
|
|
163
|
-
|
|
102
|
+
# List each provider's live models through RubyLLM's own provider API
|
|
103
|
+
# (Provider#list_models), the same path every registered provider —
|
|
104
|
+
# built-in or gem-supplied — implements.
|
|
105
|
+
# :reek:TooManyStatements -- sequential terminal report per provider: header, listing, connection guard
|
|
106
|
+
def show_provider_models(provider_slugs, positive_terms = nil, negative_terms = nil)
|
|
164
107
|
positive_terms, negative_terms = normalized_model_search_terms(positive_terms, negative_terms)
|
|
165
108
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
|
169
|
-
http.open_timeout = 5
|
|
170
|
-
http.read_timeout = 5
|
|
171
|
-
response = http.request(Net::HTTP::Get.new(uri))
|
|
172
|
-
|
|
173
|
-
unless response.is_a?(Net::HTTPSuccess)
|
|
174
|
-
puts "❌ Cannot connect to LM Studio at #{api_base}"
|
|
175
|
-
return
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
data = JSON.parse(response.body)
|
|
179
|
-
models = data['data'] || []
|
|
180
|
-
|
|
181
|
-
if models.empty?
|
|
182
|
-
puts "No LM Studio models found"
|
|
183
|
-
return
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
puts "LM Studio Models (#{api_base}):"
|
|
109
|
+
provider_slugs.each do |slug|
|
|
110
|
+
puts "\n#{slug} models:"
|
|
187
111
|
puts "-" * 60
|
|
188
112
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
name = model['id']
|
|
192
|
-
entry = "- lms/#{name}"
|
|
193
|
-
entry_lc = entry.downcase
|
|
194
|
-
|
|
195
|
-
# entry_lc is a String; Array#intersect? would raise TypeError
|
|
196
|
-
show_it = positive_terms.empty? || positive_terms.any? { |q| entry_lc.include?(q) }
|
|
197
|
-
show_it &&= negative_terms.none? { |q| entry_lc.include?(q) }
|
|
198
|
-
if show_it
|
|
199
|
-
puts entry
|
|
200
|
-
counter += 1
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
puts
|
|
205
|
-
puts "#{counter} LM Studio model(s) available"
|
|
206
|
-
puts
|
|
113
|
+
entries = provider_model_entries(slug)
|
|
114
|
+
print_filtered_entries(entries, positive_terms, negative_terms, "#{slug} model(s) available")
|
|
207
115
|
rescue StandardError => e
|
|
208
|
-
puts "❌
|
|
116
|
+
puts "❌ Cannot list models for provider '#{slug}': #{e.message}"
|
|
209
117
|
end
|
|
210
118
|
end
|
|
211
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
212
119
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
120
|
+
# One "- <slug>/<model-id>" line per model the provider reports.
|
|
121
|
+
def provider_model_entries(slug)
|
|
122
|
+
provider = AIA::ProviderRegistry.instantiate(slug)
|
|
123
|
+
provider.list_models.map { |model| "- #{slug}/#{model.id}" }
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# The entry is a String; Array#intersect? would raise TypeError
|
|
127
|
+
def entry_matches?(entry_lc, positive_terms, negative_terms)
|
|
128
|
+
(positive_terms.empty? || positive_terms.any? { |q| entry_lc.include?(q) }) &&
|
|
129
|
+
negative_terms.none? { |q| entry_lc.include?(q) }
|
|
130
|
+
end
|
|
216
131
|
|
|
217
|
-
|
|
218
|
-
|
|
132
|
+
def print_filtered_entries(entries, positive_terms, negative_terms, summary_label)
|
|
133
|
+
counter = 0
|
|
134
|
+
entries.each do |entry|
|
|
135
|
+
next unless entry_matches?(entry.downcase, positive_terms, negative_terms)
|
|
136
|
+
|
|
137
|
+
puts entry
|
|
138
|
+
counter += 1
|
|
139
|
+
end
|
|
219
140
|
|
|
220
|
-
|
|
141
|
+
puts
|
|
142
|
+
puts "#{counter} #{summary_label}"
|
|
143
|
+
puts
|
|
221
144
|
end
|
|
222
145
|
|
|
223
|
-
#
|
|
146
|
+
# :reek:TooManyStatements -- sequential terminal report: header, filtered model listing, summary
|
|
224
147
|
def show_rubyllm_models(positive_terms = nil, negative_terms = nil)
|
|
225
148
|
positive_terms, negative_terms = normalized_model_search_terms(positive_terms, negative_terms)
|
|
226
149
|
|
|
227
150
|
# expand comma-separated terms passed as a single token
|
|
228
|
-
if positive_terms.size == 1
|
|
229
|
-
positive_terms = positive_terms.first.split(',')
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
header = "\nAvailable LLMs"
|
|
233
|
-
header += " for #{positive_terms.join(' and ')}" if positive_terms.any?
|
|
234
|
-
header += " (excluding: #{negative_terms.join(', ')})" if negative_terms.any?
|
|
151
|
+
positive_terms = positive_terms.first.split(',') if positive_terms.size == 1
|
|
235
152
|
|
|
236
|
-
puts
|
|
153
|
+
puts rubyllm_header(positive_terms, negative_terms)
|
|
237
154
|
puts
|
|
238
155
|
|
|
239
156
|
# modality terms (e.g. "text_to_text") trigger capability checks; the rest
|
|
240
157
|
# are plain substring filters applied to the formatted entry string
|
|
241
|
-
|
|
158
|
+
modality_terms, substring_terms = positive_terms.partition { |q| ModalityQuery.modality_term?(q) }
|
|
242
159
|
|
|
243
160
|
counter = 0
|
|
244
|
-
|
|
245
161
|
RubyLLM.models.all.each do |llm|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
inputs = llm.modalities.input.join(',')
|
|
249
|
-
outputs = llm.modalities.output.join(',')
|
|
250
|
-
mode = "#{inputs} to #{outputs}"
|
|
251
|
-
in_1m = llm.pricing.text_tokens.standard.to_h[:input_per_million]
|
|
252
|
-
entry = "- #{llm.id} (#{llm.provider}) in: $#{in_1m} cw: #{cw} mode: #{mode} caps: #{caps}"
|
|
253
|
-
|
|
254
|
-
if positive_terms.empty? && negative_terms.empty?
|
|
255
|
-
counter += 1
|
|
256
|
-
puts entry
|
|
257
|
-
next
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
show_it = true
|
|
261
|
-
q1.each { |q| show_it &&= llm.modalities.send("#{q}?") }
|
|
262
|
-
q2.each { |q| show_it &&= entry.include?(q) }
|
|
263
|
-
negative_terms.each { |q| show_it &&= !entry.downcase.include?(q) }
|
|
162
|
+
entry = format_rubyllm_entry(llm)
|
|
163
|
+
next unless rubyllm_entry_visible?(llm, entry, modality_terms, substring_terms, negative_terms)
|
|
264
164
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
puts entry
|
|
268
|
-
end
|
|
165
|
+
counter += 1
|
|
166
|
+
puts entry
|
|
269
167
|
end
|
|
270
168
|
|
|
271
169
|
puts if counter.positive?
|
|
272
170
|
puts "#{counter} LLMs matching your query"
|
|
273
171
|
puts
|
|
274
172
|
end
|
|
275
|
-
|
|
173
|
+
|
|
174
|
+
def rubyllm_header(positive_terms, negative_terms)
|
|
175
|
+
header = "\nAvailable LLMs"
|
|
176
|
+
header += " for #{positive_terms.join(' and ')}" if positive_terms.any?
|
|
177
|
+
header += " (excluding: #{negative_terms.join(', ')})" if negative_terms.any?
|
|
178
|
+
header + ':'
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def format_rubyllm_entry(llm)
|
|
182
|
+
modalities = llm.modalities
|
|
183
|
+
mode = "#{modalities.input.join(',')} to #{modalities.output.join(',')}"
|
|
184
|
+
in_1m = llm.pricing.text_tokens.standard.to_h[:input_per_million]
|
|
185
|
+
"- #{llm.id} (#{llm.provider}) in: $#{in_1m} cw: #{llm.context_window} mode: #{mode} caps: #{llm.capabilities.join(',')}"
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def rubyllm_entry_visible?(llm, entry, modality_terms, substring_terms, negative_terms)
|
|
189
|
+
modality_terms.all? { |q| ModalityQuery.matches?(llm.modalities, q) } &&
|
|
190
|
+
substring_terms.all? { |q| entry.include?(q) } &&
|
|
191
|
+
negative_terms.none? { |q| entry.downcase.include?(q) }
|
|
192
|
+
end
|
|
276
193
|
|
|
277
194
|
def normalized_model_search_terms(positive_terms, negative_terms = nil)
|
|
278
195
|
return parse_search_terms(Array(positive_terms)) if negative_terms.nil?
|
|
@@ -9,12 +9,12 @@ module AIA
|
|
|
9
9
|
desc "Show TrakFlow ready tasks and project summary"
|
|
10
10
|
def tasks(args, context_manager = nil)
|
|
11
11
|
bridge = TrakFlowBridge.new
|
|
12
|
-
return "TrakFlow not available. Run 'tf init' to initialize a project." unless bridge.available?
|
|
12
|
+
return report_error("TrakFlow not available. Run 'tf init' to initialize a project.") unless bridge.available?
|
|
13
13
|
|
|
14
14
|
if args.first == "summary"
|
|
15
|
-
bridge.project_summary || "No summary available."
|
|
15
|
+
bridge.project_summary || report_status("No summary available.")
|
|
16
16
|
else
|
|
17
|
-
bridge.check_ready_tasks || "No ready tasks found."
|
|
17
|
+
bridge.check_ready_tasks || report_status("No ready tasks found.")
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
alias tf tasks
|
|
@@ -22,23 +22,41 @@ module AIA
|
|
|
22
22
|
desc "Create a TrakFlow plan from a description"
|
|
23
23
|
def plan(args, context_manager = nil)
|
|
24
24
|
bridge = TrakFlowBridge.new
|
|
25
|
-
return "TrakFlow not available. Run 'tf init' to initialize a project." unless bridge.available?
|
|
25
|
+
return report_error("TrakFlow not available. Run 'tf init' to initialize a project.") unless bridge.available?
|
|
26
26
|
|
|
27
27
|
description = args.join(' ')
|
|
28
|
-
return "Usage: /plan <description>" if description.empty?
|
|
28
|
+
return report_error("Usage: /plan <description>") if description.empty?
|
|
29
29
|
|
|
30
|
-
bridge.create_task(description) || "Failed to create plan."
|
|
30
|
+
bridge.create_task(description) || report_error("Failed to create plan.")
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
desc "Create a TrakFlow task"
|
|
34
34
|
def task(args, context_manager = nil)
|
|
35
35
|
bridge = TrakFlowBridge.new
|
|
36
|
-
return "TrakFlow not available. Run 'tf init' to initialize a project." unless bridge.available?
|
|
36
|
+
return report_error("TrakFlow not available. Run 'tf init' to initialize a project.") unless bridge.available?
|
|
37
37
|
|
|
38
38
|
title = args.join(' ')
|
|
39
|
-
return "Usage: /task <title>" if title.empty?
|
|
39
|
+
return report_error("Usage: /task <title>") if title.empty?
|
|
40
40
|
|
|
41
|
-
bridge.create_task(title) || "Failed to create task."
|
|
41
|
+
bridge.create_task(title) || report_error("Failed to create task.")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
# Log and print a directive error, then return nil so the chat loop
|
|
47
|
+
# skips forwarding it to the robot (an error is not conversational output).
|
|
48
|
+
def report_error(msg)
|
|
49
|
+
AIA::LoggerManager.aia_logger.error(msg)
|
|
50
|
+
puts msg
|
|
51
|
+
nil
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Same as report_error, but for a non-error empty-result status
|
|
55
|
+
# (e.g. "no ready tasks found") rather than a failure.
|
|
56
|
+
def report_status(msg)
|
|
57
|
+
AIA::LoggerManager.aia_logger.info(msg)
|
|
58
|
+
puts msg
|
|
59
|
+
nil
|
|
42
60
|
end
|
|
43
61
|
end
|
|
44
62
|
end
|