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.
Files changed (236) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/CHANGELOG.md +151 -228
  4. data/README.md +42 -19
  5. data/bin/aia +8 -3
  6. data/lib/aia/aia_completion.bash +2 -3
  7. data/lib/aia/aia_completion.fish +6 -5
  8. data/lib/aia/aia_completion.zsh +2 -3
  9. data/lib/aia/chat_loop.rb +24 -66
  10. data/lib/aia/config/cli_parser.rb +164 -123
  11. data/lib/aia/config/defaults.yml +12 -39
  12. data/lib/aia/config/mcp_parser.rb +42 -40
  13. data/lib/aia/config/model_spec.rb +8 -14
  14. data/lib/aia/config/validator.rb +144 -156
  15. data/lib/aia/config/value_caster.rb +76 -0
  16. data/lib/aia/config.rb +72 -54
  17. data/lib/aia/content_extractor.rb +2 -0
  18. data/lib/aia/cost_calculator.rb +1 -0
  19. data/lib/aia/crew.rb +29 -19
  20. data/lib/aia/debate_handler.rb +45 -20
  21. data/lib/aia/delegate_handler.rb +7 -3
  22. data/lib/aia/directive.rb +10 -8
  23. data/lib/aia/directives/configuration_directives.rb +164 -109
  24. data/lib/aia/directives/context_directives.rb +55 -40
  25. data/lib/aia/directives/execution_directives.rb +25 -25
  26. data/lib/aia/directives/model_directives.rb +112 -195
  27. data/lib/aia/directives/trakflow_directives.rb +27 -9
  28. data/lib/aia/directives/utility_directives.rb +86 -87
  29. data/lib/aia/directives/web_and_file_directives.rb +83 -63
  30. data/lib/aia/fact_asserter.rb +3 -3
  31. data/lib/aia/history_transfer.rb +64 -24
  32. data/lib/aia/layered_orchestrator.rb +66 -43
  33. data/lib/aia/logger.rb +27 -62
  34. data/lib/aia/mcp_config_normalizer.rb +27 -14
  35. data/lib/aia/mcp_connection_manager.rb +193 -186
  36. data/lib/aia/mcp_discovery.rb +43 -15
  37. data/lib/aia/mcp_grouper.rb +2 -1
  38. data/lib/aia/mcp_server_config.rb +48 -0
  39. data/lib/aia/mcp_utility.rb +28 -20
  40. data/lib/aia/mention_router.rb +22 -52
  41. data/lib/aia/modality_query.rb +36 -0
  42. data/lib/aia/model_alias_registry.rb +11 -11
  43. data/lib/aia/model_registry.rb +75 -0
  44. data/lib/aia/network_builder.rb +17 -11
  45. data/lib/aia/network_memory_manager.rb +6 -6
  46. data/lib/aia/patches/ruby_llm_streaming_error.rb +21 -4
  47. data/lib/aia/patches/ruby_llm_tool_param_compat.rb +18 -0
  48. data/lib/aia/pipeline_orchestrator.rb +88 -45
  49. data/lib/aia/plugin_monitor.rb +9 -6
  50. data/lib/aia/prompt_decomposer.rb +6 -4
  51. data/lib/aia/prompt_handler.rb +90 -69
  52. data/lib/aia/provider_registry.rb +105 -0
  53. data/lib/aia/robot_builder.rb +1 -1
  54. data/lib/aia/robot_factory.rb +77 -69
  55. data/lib/aia/robot_namer.rb +2 -8
  56. data/lib/aia/robot_sync.rb +79 -0
  57. data/lib/aia/role_catalog.rb +89 -0
  58. data/lib/aia/session.rb +32 -14
  59. data/lib/aia/session_tracker.rb +39 -41
  60. data/lib/aia/similarity_scorer.rb +5 -3
  61. data/lib/aia/skill_utils.rb +60 -19
  62. data/lib/aia/spawn_handler.rb +16 -4
  63. data/lib/aia/spawn_spec_parser.rb +6 -7
  64. data/lib/aia/special_mode_handler.rb +80 -57
  65. data/lib/aia/speech.rb +103 -0
  66. data/lib/aia/startup_coordinator.rb +17 -91
  67. data/lib/aia/streaming_runner.rb +16 -5
  68. data/lib/aia/system_prompt_assembler.rb +20 -15
  69. data/lib/aia/task_board.rb +60 -0
  70. data/lib/aia/task_coordinator.rb +10 -5
  71. data/lib/aia/timing.rb +15 -0
  72. data/lib/aia/tool_approver.rb +205 -0
  73. data/lib/aia/tool_filter.rb +1 -9
  74. data/lib/aia/tool_filter_strategy.rb +39 -25
  75. data/lib/aia/tool_introspection.rb +25 -0
  76. data/lib/aia/tool_loader.rb +71 -31
  77. data/lib/aia/tool_utility.rb +6 -5
  78. data/lib/aia/tools/delegate_to_foreman_tool.rb +6 -4
  79. data/lib/aia/tools/recruit_robot_tool.rb +12 -12
  80. data/lib/aia/tools/reskill_robot_tool.rb +7 -7
  81. data/lib/aia/tools/task_board_tool.rb +17 -16
  82. data/lib/aia/trakflow_bridge.rb +19 -11
  83. data/lib/aia/turn_state.rb +32 -8
  84. data/lib/aia/ui_presenter.rb +83 -59
  85. data/lib/aia/utility.rb +8 -24
  86. data/lib/aia/variable_input_collector.rb +1 -3
  87. data/lib/aia/verification_network.rb +10 -12
  88. data/lib/aia.rb +49 -8
  89. metadata +27 -162
  90. data/.better-commits.json +0 -150
  91. data/.config/tocer/configuration.yml +0 -6
  92. data/.envrc +0 -15
  93. data/.loki +0 -231
  94. data/.quality/flay_baseline.txt +0 -1
  95. data/.quality/flog_baseline.txt +0 -29
  96. data/.quality/reek_baseline.txt +0 -80
  97. data/.rubocop.yml +0 -116
  98. data/COMMITS.md +0 -196
  99. data/IMPLEMENTATION_PLAN.md +0 -506
  100. data/Rakefile +0 -160
  101. data/architecture_review.md +0 -314
  102. data/docs/AGENTS.md +0 -40
  103. data/docs/advanced-prompting.md +0 -814
  104. data/docs/assets/images/aia.png +0 -0
  105. data/docs/cli-reference.md +0 -1241
  106. data/docs/configuration.md +0 -747
  107. data/docs/contributing.md +0 -386
  108. data/docs/directives-reference.md +0 -1145
  109. data/docs/examples/index.md +0 -277
  110. data/docs/examples/mcp/index.md +0 -475
  111. data/docs/examples/prompts/analysis/index.md +0 -78
  112. data/docs/examples/prompts/automation/index.md +0 -109
  113. data/docs/examples/prompts/development/index.md +0 -125
  114. data/docs/examples/prompts/index.md +0 -333
  115. data/docs/examples/prompts/learning/index.md +0 -127
  116. data/docs/examples/prompts/writing/index.md +0 -62
  117. data/docs/examples/tools/index.md +0 -282
  118. data/docs/faq.md +0 -578
  119. data/docs/guides/available-models.md +0 -366
  120. data/docs/guides/basic-usage.md +0 -478
  121. data/docs/guides/chat.md +0 -680
  122. data/docs/guides/crew.md +0 -239
  123. data/docs/guides/executable-prompts.md +0 -331
  124. data/docs/guides/first-prompt.md +0 -454
  125. data/docs/guides/getting-started.md +0 -455
  126. data/docs/guides/image-generation.md +0 -507
  127. data/docs/guides/index.md +0 -48
  128. data/docs/guides/local-models.md +0 -306
  129. data/docs/guides/migrate-prompts.md +0 -335
  130. data/docs/guides/models.md +0 -1017
  131. data/docs/guides/shared-tools.md +0 -254
  132. data/docs/guides/tools.md +0 -831
  133. data/docs/index.md +0 -259
  134. data/docs/installation.md +0 -274
  135. data/docs/mcp-integration.md +0 -603
  136. data/docs/prompt_management.md +0 -665
  137. data/docs/security.md +0 -674
  138. data/docs/special_projects_guide.md +0 -386
  139. data/docs/tools-and-mcp-examples.md +0 -1211
  140. data/docs/workflows-and-pipelines.md +0 -636
  141. data/examples/.gitignore +0 -2
  142. data/examples/00_setup_aia.sh +0 -111
  143. data/examples/01_basic_usage.sh +0 -23
  144. data/examples/02_frontmatter.sh +0 -33
  145. data/examples/03_shell_integration.sh +0 -55
  146. data/examples/04_erb_templating.sh +0 -56
  147. data/examples/05_shell_then_erb.sh +0 -38
  148. data/examples/06_prompt_chaining.sh +0 -59
  149. data/examples/07_pipeline.sh +0 -46
  150. data/examples/08_context_files.sh +0 -43
  151. data/examples/09_roles.sh +0 -67
  152. data/examples/10_stdin_piping.sh +0 -49
  153. data/examples/11_multi_model.sh +0 -65
  154. data/examples/12_token_usage.sh +0 -52
  155. data/examples/13_cost_tracking.sh +0 -68
  156. data/examples/14_output_file.sh +0 -91
  157. data/examples/15_parameters.sh +0 -68
  158. data/examples/16_directives.sh +0 -113
  159. data/examples/17_require_and_conditionals.sh +0 -68
  160. data/examples/18_tools.sh +0 -61
  161. data/examples/19_local_tools.sh +0 -34
  162. data/examples/20_mcp_servers.sh +0 -102
  163. data/examples/21_executable_prompts.sh +0 -78
  164. data/examples/22_chat_mode.sh +0 -217
  165. data/examples/23_verify.sh +0 -139
  166. data/examples/24_decompose.sh +0 -139
  167. data/examples/25_spawn.sh +0 -139
  168. data/examples/26_debate.sh +0 -97
  169. data/examples/27_mention_routing.sh +0 -157
  170. data/examples/28_model_switching.sh +0 -106
  171. data/examples/29_agent_harness.sh +0 -177
  172. data/examples/README.md +0 -321
  173. data/examples/advanced_multi_robot_capabilities_without_examples.md +0 -106
  174. data/examples/aia_config.yml +0 -22
  175. data/examples/aia_config_orchestrator.yml +0 -45
  176. data/examples/aia_config_with_mcp.yml +0 -21
  177. data/examples/common.sh +0 -39
  178. data/examples/context/project_goals.md +0 -6
  179. data/examples/context/tech_stack.md +0 -7
  180. data/examples/directives/timestamp_directive.rb +0 -22
  181. data/examples/mcp/filesystem.json +0 -9
  182. data/examples/prompts_dir/analyze.md +0 -2
  183. data/examples/prompts_dir/brainstorm.md +0 -2
  184. data/examples/prompts_dir/conditional.md +0 -17
  185. data/examples/prompts_dir/creative.md +0 -4
  186. data/examples/prompts_dir/erbinfo.md +0 -5
  187. data/examples/prompts_dir/erbinfo_raw.md +0 -8
  188. data/examples/prompts_dir/evaluate.md +0 -2
  189. data/examples/prompts_dir/explain_joke.md +0 -1
  190. data/examples/prompts_dir/explain_recursion.md +0 -1
  191. data/examples/prompts_dir/fun_fact +0 -3
  192. data/examples/prompts_dir/greeting.md +0 -8
  193. data/examples/prompts_dir/greeting_required.md +0 -7
  194. data/examples/prompts_dir/hello.md +0 -1
  195. data/examples/prompts_dir/includes/ruby_facts.md +0 -4
  196. data/examples/prompts_dir/limerick.md +0 -1
  197. data/examples/prompts_dir/list_with_mcp.md +0 -3
  198. data/examples/prompts_dir/pick_best.md +0 -2
  199. data/examples/prompts_dir/project_summary +0 -12
  200. data/examples/prompts_dir/quiz_with_include.md +0 -6
  201. data/examples/prompts_dir/require_demo.md +0 -5
  202. data/examples/prompts_dir/roles/formal.md +0 -3
  203. data/examples/prompts_dir/roles/orchestrator.md +0 -21
  204. data/examples/prompts_dir/roles/pirate.md +0 -3
  205. data/examples/prompts_dir/shell_then_erb.md +0 -6
  206. data/examples/prompts_dir/sort_compare.md +0 -2
  207. data/examples/prompts_dir/summarize_context.md +0 -2
  208. data/examples/prompts_dir/sysinfo.md +0 -5
  209. data/examples/prompts_dir/sysinfo_raw.md +0 -8
  210. data/examples/prompts_dir/tagline.md +0 -1
  211. data/examples/prompts_dir/tell_joke.md +0 -1
  212. data/examples/prompts_dir/tell_joke_with_next.md +0 -4
  213. data/examples/prompts_dir/use_local_tool.md +0 -8
  214. data/examples/prompts_dir/use_tools.md +0 -8
  215. data/examples/prompts_dir/weather.md +0 -2
  216. data/examples/prompts_dir/whats_new.md +0 -2
  217. data/examples/prompts_dir/with_timestamp.md +0 -5
  218. data/examples/requirements/sinatra_taskflow_app.md +0 -139
  219. data/examples/rules/01_classify_ruby.rb +0 -16
  220. data/examples/rules/02_prefer_claude_for_code.rb +0 -19
  221. data/examples/rules/03_gate_prompt_length.rb +0 -19
  222. data/examples/rules/04_tool_selection.rb +0 -41
  223. data/examples/rules/README.md +0 -30
  224. data/examples/run_all.sh +0 -294
  225. data/examples/tools/word_count_tool.rb +0 -30
  226. data/lib/AGENTS.md +0 -57
  227. data/lib/aia/model_switch_handler.rb +0 -100
  228. data/mcp_servers/README.md +0 -110
  229. data/mcp_servers/apple-mcp.json +0 -8
  230. data/mcp_servers/filesystem.json +0 -9
  231. data/mcp_servers/mcp_server_chart.json +0 -11
  232. data/mcp_servers/playwright_one.json +0 -8
  233. data/mcp_servers/playwright_server_definition.json +0 -9
  234. data/mcp_servers/playwright_two.json +0 -8
  235. data/mcp_servers/tavily_mcp_server.json +0 -8
  236. 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::InvalidOption, OptionParser::MissingArgument => e
27
- $stderr.puts "ERROR: #{e.message}"
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
- list_available_roles
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 PROMPT_ID", "Set system prompt for chat sessions") do |prompt_id|
203
- options[:system_prompt] = prompt_id
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: dall-e-3)") do |model|
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
- - MCP Client Docs: https://github.com/patvice/ruby_llm-mcp/blob/main/README.md
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 ArgumentError, "Invalid model syntax: '#{spec}'. Expected format: MODEL[=ROLE]"
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
- def validate_role_exists(role_id)
489
- if AIA::SkillUtils.path_based_id?(role_id)
490
- expanded = File.expand_path(role_id)
491
- expanded += '.md' if File.extname(expanded).empty?
492
- raise ArgumentError, "Role file not found: #{expanded}" unless File.exist?(expanded)
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
- return
495
- end
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
- prompts_dir = ENV.fetch('AIA_PROMPTS__DIR', File.join(Dir.home, '.prompts'))
498
- roles_prefix = ENV.fetch('AIA_PROMPTS__ROLES_PREFIX', 'roles')
517
+ require_listed_libs(options)
518
+ list_available_providers
519
+ end
499
520
 
500
- unless role_id.start_with?(roles_prefix)
501
- role_id = "#{roles_prefix}/#{role_id}"
502
- end
521
+ def list_available_providers
522
+ AIA::ProviderRegistry.load_installed_gems
503
523
 
504
- role_file_path = File.join(prompts_dir, "#{role_id}.md")
524
+ entries = AIA::ProviderRegistry.providers.sort.map { |slug, klass| provider_entry(slug, klass) }
505
525
 
506
- return if File.exist?(role_file_path)
507
- available_roles = list_available_role_names(prompts_dir, roles_prefix)
526
+ puts <<~OUTPUT
508
527
 
509
- error_msg = "Role file not found: #{role_file_path}\n\n"
528
+ Registered RubyLLM providers:
529
+ #{'-' * 60}
530
+ #{entries.join("\n")}
510
531
 
511
- if available_roles.empty?
512
- error_msg += "No roles directory found at #{File.join(prompts_dir, roles_prefix)}\n"
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
- raise ArgumentError, error_msg
535
+ exit
521
536
  end
522
537
 
523
- def list_available_roles
524
- prompts_dir = ENV.fetch('AIA_PROMPTS__DIR', File.join(Dir.home, '.prompts'))
525
- roles_prefix = ENV.fetch('AIA_PROMPTS__ROLES_PREFIX', 'roles')
526
- roles_dir = File.join(prompts_dir, roles_prefix)
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
- unless Dir.exist?(roles_dir)
529
- puts "No roles directory found at #{roles_dir}"
530
- puts "Create this directory and add role files to use roles."
531
- return
532
- end
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
- roles = list_available_role_names(prompts_dir, roles_prefix)
555
+ !ENV.fetch("#{slug.upcase}_API_KEY", '').empty?
556
+ end
535
557
 
536
- if roles.empty?
537
- puts "No role files found in #{roles_dir}"
538
- puts "Create .md files in this directory to define roles."
539
- return
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
- roles.each do |role_id|
543
- role_file = File.join(roles_dir, "#{role_id}.md")
544
- front_matter = AIA::SkillUtils.parse_front_matter(role_file)
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
- puts "## #{role_id}"
547
- puts
548
- puts "| Key | Value |"
549
- puts "|-----|-------|"
550
- front_matter.each do |key, value|
551
- safe_value = value.to_s.gsub('|', '\\|')
552
- puts "| #{key} | #{safe_value} |"
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
- def list_available_role_names(prompts_dir, roles_prefix)
559
- roles_dir = File.join(prompts_dir, roles_prefix)
560
- return [] unless Dir.exist?(roles_dir)
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
- Dir.glob("**/*.md", base: roles_dir)
563
- .map { |f| f.chomp('.md') }
564
- .reject { |f| f.split('/').any? { |part| part.start_with?('_') } }
565
- .sort
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
- # rubocop:disable Metrics/AbcSize
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 = if query.nil?
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
- q1 = query.select { |q| q.include?('_to_') }.map { |q| q[0] == ':' ? q[1..] : q }
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
 
@@ -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: dall-e-3
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.config_file, AIA.config.paths.plugins_dir
217
- # Env: AIA_PATHS__AIA_DIR, AIA_PATHS__CONFIG_FILE
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 (replay messages), summarize (summary)
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: clean
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)