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
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
require 'optparse'
|
|
9
9
|
require 'yaml'
|
|
10
10
|
require_relative 'model_spec'
|
|
11
|
+
require_relative '../errors'
|
|
11
12
|
require_relative '../skill_utils'
|
|
13
|
+
require_relative '../modality_query'
|
|
12
14
|
|
|
13
15
|
module AIA
|
|
14
16
|
# rubocop:disable Metrics/ModuleLength
|
|
@@ -23,12 +25,15 @@ module AIA
|
|
|
23
25
|
begin
|
|
24
26
|
parser = create_option_parser(options)
|
|
25
27
|
parser.parse!
|
|
26
|
-
rescue OptionParser::
|
|
27
|
-
|
|
28
|
-
$stderr.puts " use --help for usage report"
|
|
29
|
-
exit 1
|
|
28
|
+
rescue OptionParser::ParseError, AIA::ConfigurationError => e
|
|
29
|
+
report_parse_error(e)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
# Post-parse so these work regardless of flag order (and after any
|
|
33
|
+
# --require libs have been noted).
|
|
34
|
+
handle_list_providers(options)
|
|
35
|
+
handle_list_models(options)
|
|
36
|
+
|
|
32
37
|
# Store remaining args for prompt_id and context files
|
|
33
38
|
options[:remaining_args] = ARGV.dup
|
|
34
39
|
|
|
@@ -56,6 +61,7 @@ module AIA
|
|
|
56
61
|
"aia [options] --chat [PROMPT_ID] [CONTEXT_FILE]*"
|
|
57
62
|
end
|
|
58
63
|
|
|
64
|
+
# :reek:TooManyStatements -- one opts.on registration per CLI flag; splitting the group would scatter related flags
|
|
59
65
|
def setup_mode_options(opts, options)
|
|
60
66
|
opts.separator "\nMode Options:"
|
|
61
67
|
|
|
@@ -71,10 +77,6 @@ module AIA
|
|
|
71
77
|
options[:fuzzy] = true
|
|
72
78
|
end
|
|
73
79
|
|
|
74
|
-
opts.on("--expert-routing", "Route each prompt to a specialist robot based on domain classification") do
|
|
75
|
-
options[:expert_routing] = true
|
|
76
|
-
end
|
|
77
|
-
|
|
78
80
|
opts.on("--track-pipeline", "Track pipeline execution in TrakFlow") do
|
|
79
81
|
options[:track_pipeline] = true
|
|
80
82
|
end
|
|
@@ -86,16 +88,9 @@ module AIA
|
|
|
86
88
|
opts.on("-A", "--[no-]auto-tool-filter", "Use TF-IDF similarity-based tool filtering (default: on)") do |v|
|
|
87
89
|
options[:auto_tool_filter] = v
|
|
88
90
|
end
|
|
89
|
-
|
|
90
|
-
opts.on("--load", "Load persisted tool filter databases from ~/.config/aia/") do
|
|
91
|
-
options[:tool_filter_load] = true
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
opts.on("--save", "Save tool filter databases to ~/.config/aia/") do
|
|
95
|
-
options[:tool_filter_save] = true
|
|
96
|
-
end
|
|
97
91
|
end
|
|
98
92
|
|
|
93
|
+
# :reek:TooManyStatements -- one opts.on registration per CLI flag; splitting the group would scatter related flags
|
|
99
94
|
def setup_model_options(opts, options)
|
|
100
95
|
opts.separator "\nModel Options:"
|
|
101
96
|
|
|
@@ -103,6 +98,20 @@ module AIA
|
|
|
103
98
|
list_available_models(query)
|
|
104
99
|
end
|
|
105
100
|
|
|
101
|
+
opts.on('--provider SLUG',
|
|
102
|
+
'Default provider for models given without a provider/ prefix; ' \
|
|
103
|
+
'also scopes --list-models (any RubyLLM-registered provider)') do |slug|
|
|
104
|
+
options[:provider] = slug
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
opts.on('--list-models', 'List the live models served by the --provider and exit') do
|
|
108
|
+
options[:list_models] = true
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
opts.on('--list-providers', 'List the registered RubyLLM providers and exit') do
|
|
112
|
+
options[:list_providers] = true
|
|
113
|
+
end
|
|
114
|
+
|
|
106
115
|
opts.on("-m MODEL", "--model MODEL",
|
|
107
116
|
"Set LLM model(s). Format: MODEL[=ROLE][,MODEL[=ROLE]]... " \
|
|
108
117
|
"Multiple models run in parallel; use --consensus to synthesize results") do |model_string|
|
|
@@ -114,8 +123,7 @@ module AIA
|
|
|
114
123
|
end
|
|
115
124
|
|
|
116
125
|
opts.on("--list-roles", "List available roles and exit") do
|
|
117
|
-
|
|
118
|
-
exit 0
|
|
126
|
+
options[:list_roles] = true
|
|
119
127
|
end
|
|
120
128
|
|
|
121
129
|
opts.on("--sm", "--speech-model MODEL", "Set speech model") do |model|
|
|
@@ -127,6 +135,7 @@ module AIA
|
|
|
127
135
|
end
|
|
128
136
|
end
|
|
129
137
|
|
|
138
|
+
# :reek:TooManyStatements -- one opts.on registration per CLI flag; splitting the group would scatter related flags
|
|
130
139
|
def setup_file_options(opts, options)
|
|
131
140
|
opts.separator "\nFile & Output Options:"
|
|
132
141
|
|
|
@@ -151,12 +160,10 @@ module AIA
|
|
|
151
160
|
opts.on("--[no-]history-file [FILE]", "Set conversation history file path") do |file|
|
|
152
161
|
options[:history_file] = file
|
|
153
162
|
end
|
|
154
|
-
|
|
155
|
-
opts.on("--md", "--[no-]markdown", "Enable Markdown formatting") do |md|
|
|
156
|
-
options[:markdown] = md
|
|
157
|
-
end
|
|
158
163
|
end
|
|
159
164
|
|
|
165
|
+
# :reek:TooManyStatements -- one opts.on registration per CLI flag; splitting the group would scatter related flags
|
|
166
|
+
# :reek:DuplicateMethodCall -- options[:pipeline] is appended inside two separate OptionParser closures
|
|
160
167
|
def setup_prompt_options(opts, options)
|
|
161
168
|
opts.separator "\nPrompt Options:"
|
|
162
169
|
|
|
@@ -199,8 +206,8 @@ module AIA
|
|
|
199
206
|
options[:pipeline] += pipeline.split(',').map(&:strip)
|
|
200
207
|
end
|
|
201
208
|
|
|
202
|
-
opts.on("--system-prompt
|
|
203
|
-
options[:system_prompt] =
|
|
209
|
+
opts.on("--system-prompt TEXT", "Set the system prompt (literal text)") do |text|
|
|
210
|
+
options[:system_prompt] = text
|
|
204
211
|
end
|
|
205
212
|
end
|
|
206
213
|
|
|
@@ -228,6 +235,7 @@ module AIA
|
|
|
228
235
|
end
|
|
229
236
|
end
|
|
230
237
|
|
|
238
|
+
# :reek:TooManyStatements -- one opts.on registration per CLI flag; splitting the group would scatter related flags
|
|
231
239
|
def setup_audio_image_options(opts, options)
|
|
232
240
|
opts.separator "\nAudio & Image Options:"
|
|
233
241
|
|
|
@@ -247,7 +255,7 @@ module AIA
|
|
|
247
255
|
options[:paint] = true
|
|
248
256
|
end
|
|
249
257
|
|
|
250
|
-
opts.on("--im", "--image-model MODEL", "Set image model for generation (default:
|
|
258
|
+
opts.on("--im", "--image-model MODEL", "Set image model for generation (default: gpt-image-1)") do |model|
|
|
251
259
|
options[:image_model] = model
|
|
252
260
|
end
|
|
253
261
|
|
|
@@ -264,6 +272,7 @@ module AIA
|
|
|
264
272
|
end
|
|
265
273
|
end
|
|
266
274
|
|
|
275
|
+
# :reek:TooManyStatements -- one opts.on registration per CLI flag; splitting the group would scatter related flags
|
|
267
276
|
def setup_tool_options(opts, options)
|
|
268
277
|
opts.separator "\nTool & Extension Options:"
|
|
269
278
|
|
|
@@ -290,6 +299,11 @@ module AIA
|
|
|
290
299
|
options[:rejected_tools] += tools_list.split(',').map(&:strip)
|
|
291
300
|
end
|
|
292
301
|
|
|
302
|
+
opts.on("--tool-approval MODE", %w[ask approve deny],
|
|
303
|
+
"Tool calls that require approval: ask (default), approve, or deny") do |mode|
|
|
304
|
+
options[:tool_approval] = mode
|
|
305
|
+
end
|
|
306
|
+
|
|
293
307
|
opts.on("--list-tools", "List available tools and exit (combine with --mcp-list for MCP tools)") do
|
|
294
308
|
options[:list_tools] = true
|
|
295
309
|
end
|
|
@@ -303,6 +317,7 @@ module AIA
|
|
|
303
317
|
setup_meta_options(opts, options)
|
|
304
318
|
end
|
|
305
319
|
|
|
320
|
+
# :reek:TooManyStatements -- one opts.on registration per CLI flag; splitting the group would scatter related flags
|
|
306
321
|
def setup_logging_options(opts, options)
|
|
307
322
|
opts.on("--log-level LEVEL", "Set log level (debug|info|warn|error|fatal)") do |level|
|
|
308
323
|
level = level.downcase
|
|
@@ -337,6 +352,7 @@ module AIA
|
|
|
337
352
|
end
|
|
338
353
|
end
|
|
339
354
|
|
|
355
|
+
# :reek:TooManyStatements -- one opts.on registration per CLI flag; splitting the group would scatter related flags
|
|
340
356
|
def setup_output_options(opts, options)
|
|
341
357
|
opts.on("--[no-]thinking", "Show raw thinking/reasoning blocks in output (default: off)") do |v|
|
|
342
358
|
options[:thinking] = v
|
|
@@ -364,6 +380,7 @@ module AIA
|
|
|
364
380
|
end
|
|
365
381
|
end
|
|
366
382
|
|
|
383
|
+
# :reek:TooManyStatements -- one opts.on registration per CLI flag; splitting the group would scatter related flags
|
|
367
384
|
def setup_mcp_options(opts, options)
|
|
368
385
|
opts.on("--mcp FILE", "Load MCP server(s) from JSON file (repeatable)") do |file|
|
|
369
386
|
options[:mcp_files] ||= []
|
|
@@ -431,7 +448,7 @@ module AIA
|
|
|
431
448
|
- PromptManager Docs: https://madbomber.github.io/prompt_manager
|
|
432
449
|
- ERB Documentation: https://docs.ruby-lang.org/en/master/ERB.html
|
|
433
450
|
- MCP Specification: https://modelcontextprotocol.io
|
|
434
|
-
-
|
|
451
|
+
- RobotLab Docs: https://github.com/MadBomber/robot_lab
|
|
435
452
|
|
|
436
453
|
EXTRA
|
|
437
454
|
end
|
|
@@ -440,16 +457,17 @@ module AIA
|
|
|
440
457
|
#
|
|
441
458
|
# @param model_string [String] comma-separated models with optional roles
|
|
442
459
|
# @return [Array<Hash>] array of model specs
|
|
460
|
+
# :reek:TooManyStatements -- one-pass parser over MODEL[=ROLE] specs sharing the instance counter
|
|
443
461
|
def parse_models_with_roles(model_string)
|
|
444
462
|
models = []
|
|
445
463
|
model_counts = Hash.new(0)
|
|
446
464
|
|
|
447
|
-
# rubocop:disable Metrics/BlockLength
|
|
465
|
+
# rubocop:disable-next Metrics/BlockLength
|
|
448
466
|
model_string.split(',').each do |spec|
|
|
449
467
|
spec.strip!
|
|
450
468
|
|
|
451
469
|
if spec =~ /^=|=$/
|
|
452
|
-
raise
|
|
470
|
+
raise AIA::ConfigurationError, "Invalid model syntax: '#{spec}'. Expected format: MODEL[=ROLE]"
|
|
453
471
|
end
|
|
454
472
|
|
|
455
473
|
if spec.include?('=')
|
|
@@ -457,8 +475,6 @@ module AIA
|
|
|
457
475
|
model_name.strip!
|
|
458
476
|
role_name.strip!
|
|
459
477
|
|
|
460
|
-
validate_role_exists(role_name)
|
|
461
|
-
|
|
462
478
|
model_counts[model_name] += 1
|
|
463
479
|
instance = model_counts[model_name]
|
|
464
480
|
|
|
@@ -480,133 +496,130 @@ module AIA
|
|
|
480
496
|
}
|
|
481
497
|
end
|
|
482
498
|
end
|
|
483
|
-
# rubocop:enable Metrics/BlockLength
|
|
484
499
|
|
|
485
500
|
models
|
|
486
501
|
end
|
|
487
502
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
503
|
+
# Print a command-line error without a backtrace and exit 1. Covers every
|
|
504
|
+
# OptionParser failure (unknown option, missing or invalid argument) and
|
|
505
|
+
# configuration errors raised while options are parsed (e.g. a missing role).
|
|
506
|
+
def report_parse_error(error)
|
|
507
|
+
$stderr.puts "ERROR: #{error.message}"
|
|
508
|
+
$stderr.puts ' use --help for usage report' if error.is_a?(OptionParser::ParseError)
|
|
509
|
+
exit 1
|
|
510
|
+
end
|
|
493
511
|
|
|
494
|
-
|
|
495
|
-
|
|
512
|
+
# Post-parse handler for `--list-providers`. Lists every provider
|
|
513
|
+
# registered with RubyLLM (built-ins plus any --require'd gems) and exits.
|
|
514
|
+
def handle_list_providers(options)
|
|
515
|
+
return unless options[:list_providers]
|
|
496
516
|
|
|
497
|
-
|
|
498
|
-
|
|
517
|
+
require_listed_libs(options)
|
|
518
|
+
list_available_providers
|
|
519
|
+
end
|
|
499
520
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
end
|
|
521
|
+
def list_available_providers
|
|
522
|
+
AIA::ProviderRegistry.load_installed_gems
|
|
503
523
|
|
|
504
|
-
|
|
524
|
+
entries = AIA::ProviderRegistry.providers.sort.map { |slug, klass| provider_entry(slug, klass) }
|
|
505
525
|
|
|
506
|
-
|
|
507
|
-
available_roles = list_available_role_names(prompts_dir, roles_prefix)
|
|
526
|
+
puts <<~OUTPUT
|
|
508
527
|
|
|
509
|
-
|
|
528
|
+
Registered RubyLLM providers:
|
|
529
|
+
#{'-' * 60}
|
|
530
|
+
#{entries.join("\n")}
|
|
510
531
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
error_msg += "Create the directory and add role files to use this feature."
|
|
514
|
-
else
|
|
515
|
-
error_msg += "Available roles:\n"
|
|
516
|
-
error_msg += available_roles.map { |r| " - #{r}" }.join("\n")
|
|
517
|
-
error_msg += "\n\nCreate the role file or use an existing role."
|
|
518
|
-
end
|
|
532
|
+
#{entries.size} provider(s) registered
|
|
533
|
+
OUTPUT
|
|
519
534
|
|
|
520
|
-
|
|
535
|
+
exit
|
|
521
536
|
end
|
|
522
537
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
538
|
+
# One listing line per provider, annotated with what the provider
|
|
539
|
+
# declares about itself: " (local)" and/or " (has API key)".
|
|
540
|
+
def provider_entry(slug, klass)
|
|
541
|
+
entry = "- #{slug}"
|
|
542
|
+
entry += ' (local)' if klass.respond_to?(:local?) && klass.local?
|
|
543
|
+
entry += ' (has API key)' if provider_api_key?(slug)
|
|
544
|
+
entry
|
|
545
|
+
end
|
|
527
546
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
547
|
+
# Generic API-key detection: RubyLLM.config's <slug>_api_key (set by
|
|
548
|
+
# robot_lab or the user), or the conventional <SLUG>_API_KEY env var
|
|
549
|
+
# that robot_lab maps into it at session start.
|
|
550
|
+
def provider_api_key?(slug)
|
|
551
|
+
key_attr = :"#{slug}_api_key"
|
|
552
|
+
config = RubyLLM.config
|
|
553
|
+
return true if config.respond_to?(key_attr) && !config.public_send(key_attr).to_s.empty?
|
|
533
554
|
|
|
534
|
-
|
|
555
|
+
!ENV.fetch("#{slug.upcase}_API_KEY", '').empty?
|
|
556
|
+
end
|
|
535
557
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
end
|
|
558
|
+
# Post-parse handler for `--provider SLUG --list-models`. Lists the
|
|
559
|
+
# provider's live models (via RubyLLM's Provider#list_models) and exits.
|
|
560
|
+
def handle_list_models(options)
|
|
561
|
+
return unless options[:list_models]
|
|
541
562
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
563
|
+
slug = options[:provider]
|
|
564
|
+
if slug
|
|
565
|
+
require_listed_libs(options)
|
|
566
|
+
AIA::ProviderRegistry.apply_env_endpoints
|
|
567
|
+
list_provider_models(slug)
|
|
568
|
+
else
|
|
569
|
+
$stderr.puts "ERROR: --list-models requires --provider SLUG " \
|
|
570
|
+
"(use --available-models to search the full model registry)"
|
|
571
|
+
exit 1
|
|
572
|
+
end
|
|
573
|
+
end
|
|
545
574
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
end
|
|
554
|
-
puts
|
|
575
|
+
# `--require` libs may register additional RubyLLM providers, so load
|
|
576
|
+
# them before resolving the provider slug.
|
|
577
|
+
def require_listed_libs(options)
|
|
578
|
+
Array(options[:require_libs]).each do |lib|
|
|
579
|
+
require lib
|
|
580
|
+
rescue LoadError => e
|
|
581
|
+
$stderr.puts "Warning: Failed to require '#{lib}': #{e.message}"
|
|
555
582
|
end
|
|
556
583
|
end
|
|
557
584
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
585
|
+
# :reek:TooManyStatements -- sequential --list-models report: resolve provider, list, summary, exit
|
|
586
|
+
def list_provider_models(slug)
|
|
587
|
+
if AIA::ProviderRegistry.available?(slug)
|
|
588
|
+
entries = AIA::ProviderRegistry.instantiate(slug).list_models.map { |model| "- #{slug}/#{model.id}" }
|
|
589
|
+
|
|
590
|
+
puts <<~OUTPUT
|
|
591
|
+
|
|
592
|
+
#{slug} models:
|
|
593
|
+
#{'-' * 60}
|
|
594
|
+
#{entries.join("\n")}
|
|
595
|
+
|
|
596
|
+
#{entries.size} #{slug} model(s) available
|
|
597
|
+
OUTPUT
|
|
561
598
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
599
|
+
exit
|
|
600
|
+
else
|
|
601
|
+
$stderr.puts "ERROR: unknown provider '#{slug}'. Registered providers: " \
|
|
602
|
+
"#{AIA::ProviderRegistry.slugs.sort.join(', ')}"
|
|
603
|
+
exit 1
|
|
604
|
+
end
|
|
605
|
+
rescue StandardError => e
|
|
606
|
+
$stderr.puts "ERROR: cannot list models for provider '#{slug}': #{e.message}"
|
|
607
|
+
exit 1
|
|
566
608
|
end
|
|
567
609
|
|
|
568
|
-
#
|
|
610
|
+
# :reek:TooManyStatements -- sequential --available-models report: parse query, print matches, summary, exit
|
|
569
611
|
def list_available_models(query)
|
|
570
612
|
require 'ruby_llm'
|
|
571
613
|
|
|
572
|
-
query =
|
|
573
|
-
|
|
574
|
-
else
|
|
575
|
-
query.split(',')
|
|
576
|
-
end
|
|
577
|
-
# rubocop:enable Metrics/AbcSize
|
|
614
|
+
query = query.nil? ? [] : query.split(',')
|
|
615
|
+
modality_terms, substring_terms = parse_model_query(query)
|
|
578
616
|
|
|
579
617
|
header = "\nAvailable LLMs"
|
|
580
618
|
header += " for #{query.join(' and ')}" if query.any?
|
|
581
|
-
|
|
582
619
|
puts header + ':'
|
|
583
620
|
puts
|
|
584
621
|
|
|
585
|
-
|
|
586
|
-
q2 = query.reject { |q| q.include?('_to_') }
|
|
587
|
-
|
|
588
|
-
counter = 0
|
|
589
|
-
|
|
590
|
-
RubyLLM.models.all.each do |llm|
|
|
591
|
-
inputs = llm.modalities.input.join(',')
|
|
592
|
-
outputs = llm.modalities.output.join(',')
|
|
593
|
-
entry = "- #{llm.id} (#{llm.provider}) #{inputs} to #{outputs}"
|
|
594
|
-
|
|
595
|
-
if query.nil? || query.empty?
|
|
596
|
-
counter += 1
|
|
597
|
-
puts entry
|
|
598
|
-
next
|
|
599
|
-
end
|
|
600
|
-
|
|
601
|
-
show_it = true
|
|
602
|
-
q1.each { |q| show_it &&= llm.modalities.send("#{q}?") }
|
|
603
|
-
q2.each { |q| show_it &&= entry.include?(q) }
|
|
604
|
-
|
|
605
|
-
if show_it
|
|
606
|
-
counter += 1
|
|
607
|
-
puts entry
|
|
608
|
-
end
|
|
609
|
-
end
|
|
622
|
+
counter = print_matching_models(modality_terms, substring_terms)
|
|
610
623
|
|
|
611
624
|
puts if counter.positive?
|
|
612
625
|
puts "#{counter} LLMs matching your query"
|
|
@@ -614,8 +627,36 @@ module AIA
|
|
|
614
627
|
|
|
615
628
|
exit
|
|
616
629
|
end
|
|
630
|
+
|
|
631
|
+
# Print each matching model entry; returns the number printed.
|
|
632
|
+
def print_matching_models(modality_terms, substring_terms)
|
|
633
|
+
RubyLLM.models.all.count do |llm|
|
|
634
|
+
entry = format_model_entry(llm)
|
|
635
|
+
visible = model_entry_visible?(llm, entry, modality_terms, substring_terms)
|
|
636
|
+
puts entry if visible
|
|
637
|
+
visible
|
|
638
|
+
end
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
# Split a query into modality terms (e.g. "text_to_text", leading ':'
|
|
642
|
+
# stripped) and plain substring terms.
|
|
643
|
+
def parse_model_query(query)
|
|
644
|
+
modality, substrings = query.partition { |q| ModalityQuery.modality_term?(q) }
|
|
645
|
+
[modality.map { |q| q.delete_prefix(':') }, substrings]
|
|
646
|
+
end
|
|
647
|
+
|
|
648
|
+
def format_model_entry(llm)
|
|
649
|
+
modalities = llm.modalities
|
|
650
|
+
"- #{llm.id} (#{llm.provider}) #{modalities.input.join(',')} to #{modalities.output.join(',')}"
|
|
651
|
+
end
|
|
652
|
+
|
|
653
|
+
def model_entry_visible?(llm, entry, modality_terms, substring_terms)
|
|
654
|
+
modality_terms.all? { |q| ModalityQuery.matches?(llm.modalities, q) } &&
|
|
655
|
+
substring_terms.all? { |q| entry.include?(q) }
|
|
656
|
+
end
|
|
617
657
|
# rubocop:enable Metrics/ModuleLength
|
|
618
658
|
|
|
659
|
+
# :reek:DuplicateMethodCall -- each `exit 1` terminates a distinct validation failure; there is no value to hoist
|
|
619
660
|
def process_tools_paths(path_list)
|
|
620
661
|
paths = []
|
|
621
662
|
|
data/lib/aia/config/defaults.yml
CHANGED
|
@@ -61,19 +61,12 @@ defaults:
|
|
|
61
61
|
extname: .md
|
|
62
62
|
#
|
|
63
63
|
role: ~
|
|
64
|
-
roles_dir: ~/.prompts/roles
|
|
65
64
|
roles_prefix: roles
|
|
66
65
|
#
|
|
67
66
|
skills: []
|
|
68
67
|
#
|
|
69
|
-
tool: ~
|
|
70
|
-
tools_prefix: tools
|
|
71
|
-
#
|
|
72
68
|
system_prompt: ~
|
|
73
69
|
|
|
74
|
-
roles:
|
|
75
|
-
dir: ~/.prompts/roles
|
|
76
|
-
|
|
77
70
|
skills:
|
|
78
71
|
dir: ~/.prompts/skills
|
|
79
72
|
|
|
@@ -85,7 +78,6 @@ defaults:
|
|
|
85
78
|
output:
|
|
86
79
|
file: temp.md
|
|
87
80
|
append: false
|
|
88
|
-
markdown: true
|
|
89
81
|
history_file: ~/.prompts/_prompts.log
|
|
90
82
|
|
|
91
83
|
# ---------------------------------------------------------------------------
|
|
@@ -96,6 +88,7 @@ defaults:
|
|
|
96
88
|
audio:
|
|
97
89
|
voice: ~
|
|
98
90
|
speak_command: say
|
|
91
|
+
player: ~
|
|
99
92
|
speech_model: ~
|
|
100
93
|
transcription_model: ~
|
|
101
94
|
|
|
@@ -105,29 +98,24 @@ defaults:
|
|
|
105
98
|
# Env: AIA_IMAGE__MODEL, AIA_IMAGE__SIZE, etc.
|
|
106
99
|
# ---------------------------------------------------------------------------
|
|
107
100
|
image:
|
|
108
|
-
model:
|
|
101
|
+
model: gpt-image-1
|
|
109
102
|
size: 1024x1024
|
|
110
103
|
quality: standard
|
|
111
104
|
style: vivid
|
|
112
105
|
|
|
113
|
-
# ---------------------------------------------------------------------------
|
|
114
|
-
# Embedding Configuration
|
|
115
|
-
# Access: AIA.config.embedding.model
|
|
116
|
-
# Env: AIA_EMBEDDING__MODEL
|
|
117
|
-
# ---------------------------------------------------------------------------
|
|
118
|
-
embedding:
|
|
119
|
-
model: text-embedding-ada-002
|
|
120
|
-
|
|
121
106
|
# ---------------------------------------------------------------------------
|
|
122
107
|
# Tools Configuration
|
|
123
108
|
# Access: AIA.config.tools.paths, AIA.config.tools.allowed, etc.
|
|
124
109
|
# Env: AIA_TOOLS__PATHS, AIA_TOOLS__ALLOWED, etc.
|
|
125
110
|
# ---------------------------------------------------------------------------
|
|
126
111
|
tools:
|
|
127
|
-
dir: ~/.prompts/tools
|
|
128
112
|
paths: []
|
|
129
113
|
allowed: ~
|
|
130
114
|
rejected: ~
|
|
115
|
+
# Tool calls that require approval (an MCP server's requires_approval:)
|
|
116
|
+
# and MCP input requests: ask (prompt on the terminal; refuse when there
|
|
117
|
+
# is none), approve (allow them all), or deny (refuse them all).
|
|
118
|
+
approval: ask
|
|
131
119
|
|
|
132
120
|
# ---------------------------------------------------------------------------
|
|
133
121
|
# Flags (Boolean Options)
|
|
@@ -145,13 +133,9 @@ defaults:
|
|
|
145
133
|
speak: false
|
|
146
134
|
shell: true
|
|
147
135
|
erb: true
|
|
148
|
-
clear: false
|
|
149
136
|
consensus: false
|
|
150
137
|
track_pipeline: false
|
|
151
|
-
expert_routing: false
|
|
152
138
|
auto_tool_filter: true
|
|
153
|
-
tool_filter_load: false
|
|
154
|
-
tool_filter_save: false
|
|
155
139
|
allow_ruby_eval: false
|
|
156
140
|
paint: false
|
|
157
141
|
thinking: false
|
|
@@ -213,13 +197,12 @@ defaults:
|
|
|
213
197
|
|
|
214
198
|
# ---------------------------------------------------------------------------
|
|
215
199
|
# Paths Configuration
|
|
216
|
-
# Access: AIA.config.paths.aia_dir, AIA.config.paths.
|
|
217
|
-
# Env: AIA_PATHS__AIA_DIR
|
|
200
|
+
# Access: AIA.config.paths.aia_dir, AIA.config.paths.plugins_dir
|
|
201
|
+
# Env: AIA_PATHS__AIA_DIR
|
|
218
202
|
# Special-case env: AIA_PLUGINS_DIR
|
|
219
203
|
# ---------------------------------------------------------------------------
|
|
220
204
|
paths:
|
|
221
205
|
aia_dir: ~/.config/aia
|
|
222
|
-
config_file: ~/.config/aia/aia.yml
|
|
223
206
|
plugins_dir: ~
|
|
224
207
|
|
|
225
208
|
# ---------------------------------------------------------------------------
|
|
@@ -231,10 +214,12 @@ defaults:
|
|
|
231
214
|
# ---------------------------------------------------------------------------
|
|
232
215
|
# Model Switch History Mode
|
|
233
216
|
# Controls conversation history transfer when switching models mid-chat.
|
|
234
|
-
# Values: clean (fresh start), replay (
|
|
217
|
+
# Values: clean (fresh start), replay (re-send every user message to the
|
|
218
|
+
# new model), summarize (old model summarizes; the new model gets the summary)
|
|
219
|
+
# Used by the /model directive.
|
|
235
220
|
# Access: AIA.config.model_switch_history
|
|
236
221
|
# ---------------------------------------------------------------------------
|
|
237
|
-
model_switch_history:
|
|
222
|
+
model_switch_history: summarize
|
|
238
223
|
|
|
239
224
|
# ---------------------------------------------------------------------------
|
|
240
225
|
# Concurrency Configuration
|
|
@@ -243,21 +228,9 @@ defaults:
|
|
|
243
228
|
# ---------------------------------------------------------------------------
|
|
244
229
|
concurrency:
|
|
245
230
|
auto: false
|
|
246
|
-
independent_servers: []
|
|
247
231
|
threshold: 2
|
|
248
232
|
mcp_timeout: 120
|
|
249
233
|
|
|
250
|
-
# ---------------------------------------------------------------------------
|
|
251
|
-
# Rules Configuration (Enhanced Multi-KB in v2)
|
|
252
|
-
# Access: AIA.config.rules.dir, AIA.config.rules.enabled, etc.
|
|
253
|
-
# Env: AIA_RULES__DIR, AIA_RULES__ENABLED
|
|
254
|
-
# ---------------------------------------------------------------------------
|
|
255
|
-
rules:
|
|
256
|
-
dir: ~/.config/aia/rules
|
|
257
|
-
enabled: true
|
|
258
|
-
store: memory
|
|
259
|
-
db_path: ~/.config/aia/rules.db
|
|
260
|
-
|
|
261
234
|
# ---------------------------------------------------------------------------
|
|
262
235
|
# Context Files (set at runtime)
|
|
263
236
|
# Access: AIA.config.context_files (array of file paths)
|