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
data/lib/aia/ui_presenter.rb
CHANGED
|
@@ -5,8 +5,10 @@ require 'tty-spinner'
|
|
|
5
5
|
require 'tty-table'
|
|
6
6
|
require 'reline'
|
|
7
7
|
require 'fileutils'
|
|
8
|
+
require 'stringio'
|
|
8
9
|
|
|
9
10
|
module AIA
|
|
11
|
+
# :reek:TooManyMethods -- one small builder per table/report section keeps each display testable in isolation
|
|
10
12
|
class UIPresenter
|
|
11
13
|
USER_PROMPT = "Follow up (cntl-D or 'exit' to end) #=> ".freeze
|
|
12
14
|
HISTORY_FILE = File.join(Dir.home, '.config', 'aia', 'chat_history')
|
|
@@ -25,6 +27,22 @@ module AIA
|
|
|
25
27
|
format_chat_response(response)
|
|
26
28
|
end
|
|
27
29
|
|
|
30
|
+
# Show one robot's turn (a debate round, say) under a heading. The block is
|
|
31
|
+
# rendered into a buffer and written in one call, so robots finishing
|
|
32
|
+
# concurrently cannot interleave their lines.
|
|
33
|
+
#
|
|
34
|
+
# @param heading [String] e.g. "Round 1 · Tobor"
|
|
35
|
+
# @param response [String, RubyLLM::Message, #reply]
|
|
36
|
+
# @param output [IO]
|
|
37
|
+
def display_robot_turn(heading, response, output = $stdout)
|
|
38
|
+
buffer = StringIO.new
|
|
39
|
+
buffer.puts "\n#{heading}:"
|
|
40
|
+
format_chat_response(response, buffer)
|
|
41
|
+
output.write(buffer.string)
|
|
42
|
+
output.flush
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# :reek:TooManyStatements -- line-by-line rendering with a code-fence state machine; the states share locals
|
|
28
46
|
def format_chat_response(response, output = $stdout)
|
|
29
47
|
indent = ' '
|
|
30
48
|
|
|
@@ -121,6 +139,7 @@ module AIA
|
|
|
121
139
|
result
|
|
122
140
|
end
|
|
123
141
|
|
|
142
|
+
# :reek:TooManyStatements -- one metrics table with header/row/alignment variants for cost vs no-cost display
|
|
124
143
|
def display_token_metrics(metrics)
|
|
125
144
|
return unless metrics
|
|
126
145
|
|
|
@@ -160,83 +179,87 @@ module AIA
|
|
|
160
179
|
write_to_output_file(rendered)
|
|
161
180
|
end
|
|
162
181
|
|
|
163
|
-
#
|
|
182
|
+
# :reek:TooManyStatements -- table assembly: rows, totals, render, output; each piece delegated to a builder
|
|
164
183
|
def display_multi_model_metrics(metrics_list)
|
|
165
184
|
return unless metrics_list && !metrics_list.empty?
|
|
166
185
|
|
|
167
186
|
show_cost = AIA.config.flags.cost
|
|
168
187
|
show_similarity = metrics_list.any? { |m| m.key?(:similarity) }
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
188
|
+
totals = MultiModelTotals.new(0, 0, 0.0, 0.0)
|
|
189
|
+
|
|
190
|
+
rows = metrics_list.map { |metrics| multi_model_row(metrics, totals, show_cost, show_similarity) }
|
|
191
|
+
rows << :separator
|
|
192
|
+
rows << multi_model_totals_row(totals, show_cost, show_similarity)
|
|
193
|
+
|
|
194
|
+
table = TTY::Table.new(multi_model_header(show_cost, show_similarity), rows)
|
|
195
|
+
rendered = table.render(:unicode, resize: true,
|
|
196
|
+
alignments: multi_model_alignments(show_cost, show_similarity),
|
|
197
|
+
padding: [0, 1])
|
|
173
198
|
|
|
199
|
+
puts "\nMulti-Model Token Usage"
|
|
200
|
+
puts rendered
|
|
201
|
+
write_to_output_file("Multi-Model Token Usage\n#{rendered}")
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
private
|
|
205
|
+
|
|
206
|
+
# Running totals accumulated while building multi-model table rows.
|
|
207
|
+
MultiModelTotals = Struct.new(:input, :output, :cost, :max_elapsed)
|
|
208
|
+
|
|
209
|
+
def multi_model_header(show_cost, show_similarity)
|
|
174
210
|
header = %w[Model Input Output Total]
|
|
175
211
|
header += %w[Cost x1000] if show_cost
|
|
176
212
|
header << "Time"
|
|
177
213
|
header << "Sim" if show_similarity
|
|
214
|
+
header
|
|
215
|
+
end
|
|
178
216
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if cost_data[:available]
|
|
196
|
-
row << "$#{'%.5f' % cost_data[:total_cost]}"
|
|
197
|
-
row << "$#{'%.2f' % (cost_data[:total_cost] * 1000)}"
|
|
198
|
-
total_cost += cost_data[:total_cost]
|
|
199
|
-
else
|
|
200
|
-
row += ["N/A", "N/A"]
|
|
201
|
-
end
|
|
202
|
-
end
|
|
217
|
+
def multi_model_row(metrics, totals, show_cost, show_similarity)
|
|
218
|
+
input_tokens = metrics[:input_tokens] || 0
|
|
219
|
+
output_tokens = metrics[:output_tokens] || 0
|
|
220
|
+
elapsed = metrics[:elapsed]
|
|
221
|
+
|
|
222
|
+
totals.input += input_tokens
|
|
223
|
+
totals.output += output_tokens
|
|
224
|
+
totals.max_elapsed = [totals.max_elapsed, elapsed || 0].max
|
|
225
|
+
|
|
226
|
+
row = [(metrics[:model_id] || metrics[:display_name]).to_s,
|
|
227
|
+
input_tokens, output_tokens, input_tokens + output_tokens]
|
|
228
|
+
row += multi_model_cost_cells(metrics, totals) if show_cost
|
|
229
|
+
row << format_elapsed(elapsed)
|
|
230
|
+
row << format_similarity(metrics[:similarity]) if show_similarity
|
|
231
|
+
row
|
|
232
|
+
end
|
|
203
233
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
234
|
+
# Cost cells for one row; adds to totals only when pricing is available.
|
|
235
|
+
def multi_model_cost_cells(metrics, totals)
|
|
236
|
+
cost_data = calculate_cost(metrics)
|
|
237
|
+
return %w[N/A N/A] unless cost_data[:available]
|
|
208
238
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
239
|
+
cost = cost_data[:total_cost]
|
|
240
|
+
totals.cost += cost
|
|
241
|
+
format_cost_cells(cost)
|
|
242
|
+
end
|
|
213
243
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
244
|
+
def format_cost_cells(cost)
|
|
245
|
+
["$#{'%.5f' % cost}", "$#{'%.2f' % (cost * 1000)}"]
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def multi_model_totals_row(totals, show_cost, show_similarity)
|
|
249
|
+
row = ["TOTAL", totals.input, totals.output, totals.input + totals.output]
|
|
250
|
+
row += totals.cost.positive? ? format_cost_cells(totals.cost) : ["", ""] if show_cost
|
|
251
|
+
row << format_elapsed(totals.max_elapsed)
|
|
252
|
+
row << "" if show_similarity
|
|
253
|
+
row
|
|
254
|
+
end
|
|
224
255
|
|
|
256
|
+
def multi_model_alignments(show_cost, show_similarity)
|
|
225
257
|
alignments = %i[left right right right]
|
|
226
258
|
alignments += %i[right right] if show_cost
|
|
227
259
|
alignments << :right
|
|
228
260
|
alignments << :right if show_similarity
|
|
229
|
-
|
|
230
|
-
table = TTY::Table.new(header, rows)
|
|
231
|
-
rendered = table.render(:unicode, resize: true, alignments: alignments, padding: [0, 1])
|
|
232
|
-
|
|
233
|
-
puts "\nMulti-Model Token Usage"
|
|
234
|
-
puts rendered
|
|
235
|
-
write_to_output_file("Multi-Model Token Usage\n#{rendered}")
|
|
261
|
+
alignments
|
|
236
262
|
end
|
|
237
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
238
|
-
|
|
239
|
-
private
|
|
240
263
|
|
|
241
264
|
def save_chat_history
|
|
242
265
|
history_file = chat_history_file
|
|
@@ -255,8 +278,9 @@ module AIA
|
|
|
255
278
|
return nil if hf == false # --no-history-file disables chat history
|
|
256
279
|
return File.expand_path(hf) if hf
|
|
257
280
|
end
|
|
258
|
-
|
|
259
|
-
|
|
281
|
+
paths = config.respond_to?(:paths) ? config.paths : nil
|
|
282
|
+
if paths.respond_to?(:aia_dir) && paths.aia_dir
|
|
283
|
+
return File.join(File.expand_path(paths.aia_dir), 'chat_history')
|
|
260
284
|
end
|
|
261
285
|
HISTORY_FILE
|
|
262
286
|
end
|
data/lib/aia/utility.rb
CHANGED
|
@@ -4,12 +4,6 @@ require 'word_wrapper'
|
|
|
4
4
|
require 'simple_flow'
|
|
5
5
|
require 'trak_flow'
|
|
6
6
|
require 'tty-table'
|
|
7
|
-
begin
|
|
8
|
-
require 'ruby_llm/mcp'
|
|
9
|
-
rescue LoadError, StandardError
|
|
10
|
-
# ruby_llm-mcp may not be installed
|
|
11
|
-
end
|
|
12
|
-
|
|
13
7
|
require_relative 'mcp_utility'
|
|
14
8
|
require_relative 'tool_utility'
|
|
15
9
|
|
|
@@ -102,7 +96,6 @@ module AIA
|
|
|
102
96
|
|
|
103
97
|
def banner_libs
|
|
104
98
|
parts = ["ruby_llm v#{RubyLLM::VERSION}"]
|
|
105
|
-
parts << "ruby_llm-mcp v#{RubyLLM::MCP::VERSION}" if defined?(RubyLLM::MCP::VERSION)
|
|
106
99
|
parts << "robot_lab v#{RobotLab::VERSION}" if defined?(RobotLab::VERSION)
|
|
107
100
|
parts << "simple_flow v#{SimpleFlow::VERSION}" if defined?(SimpleFlow::VERSION)
|
|
108
101
|
parts << "trak_flow v#{TrakFlow::VERSION}" if defined?(TrakFlow::VERSION)
|
|
@@ -129,25 +122,16 @@ module AIA
|
|
|
129
122
|
parts.join(' | ')
|
|
130
123
|
end
|
|
131
124
|
|
|
132
|
-
#
|
|
133
|
-
# mcp_server_tool_counts provides per-server tool counts.
|
|
134
|
-
# Pre-connection fallback: read live from RubyLLM::MCP.clients (--require clients).
|
|
125
|
+
# connected_mcp_servers (set by MCPConnectionManager) is the authoritative
|
|
126
|
+
# name list; mcp_server_tool_counts provides per-server tool counts.
|
|
135
127
|
def mcp_client_labels
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
connected = AIA.config&.connected_mcp_servers
|
|
139
|
-
unless connected.nil?
|
|
140
|
-
counts = AIA.config&.mcp_server_tool_counts || {}
|
|
141
|
-
return connected.map do |name|
|
|
142
|
-
count = counts[name]
|
|
143
|
-
count ? "#{name}(#{count})" : name
|
|
144
|
-
end
|
|
145
|
-
end
|
|
128
|
+
cfg = AIA.config
|
|
129
|
+
return [] if cfg&.flags&.no_mcp
|
|
146
130
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
count =
|
|
150
|
-
"#{name}(#{count})"
|
|
131
|
+
counts = cfg&.mcp_server_tool_counts || {}
|
|
132
|
+
Array(cfg&.connected_mcp_servers).map do |name|
|
|
133
|
+
count = counts[name]
|
|
134
|
+
count ? "#{name}(#{count})" : name
|
|
151
135
|
end
|
|
152
136
|
end
|
|
153
137
|
|
|
@@ -9,6 +9,7 @@ module AIA
|
|
|
9
9
|
# No prompt dependency — just handles user input for parameter collection
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
# :reek:TooManyStatements -- one Reline round-trip: question build, readline, Ctrl+D/empty fallbacks, prompt_proc restore
|
|
12
13
|
def request_variable_value(variable_name:, default_value: nil)
|
|
13
14
|
Reline::HISTORY.clear
|
|
14
15
|
|
|
@@ -44,7 +45,4 @@ module AIA
|
|
|
44
45
|
end
|
|
45
46
|
end
|
|
46
47
|
end
|
|
47
|
-
|
|
48
|
-
# Backward-compatibility alias — prefer VariableInputCollector in new code.
|
|
49
|
-
HistoryManager = VariableInputCollector
|
|
50
48
|
end
|
|
@@ -15,35 +15,34 @@ module AIA
|
|
|
15
15
|
model = config.models.first
|
|
16
16
|
run_config = RobotFactory.build_run_config(config)
|
|
17
17
|
tools = ToolLoader.filtered_tools(config)
|
|
18
|
-
mcp = RobotFactory.
|
|
19
|
-
model_id = model.internal_id
|
|
18
|
+
mcp = RobotFactory.mcp_servers(config)
|
|
20
19
|
|
|
21
|
-
# rubocop:disable Metrics/BlockLength
|
|
20
|
+
# rubocop:disable-next Metrics/BlockLength
|
|
22
21
|
RobotLab.create_network(name: "aia-verification") do
|
|
23
|
-
worker_a =
|
|
22
|
+
worker_a = RobotFactory.build_robot(
|
|
23
|
+
model,
|
|
24
24
|
name: "verifier-a",
|
|
25
|
-
model: model_id,
|
|
26
25
|
system_prompt: "Answer the following question. Be thorough and precise.",
|
|
27
26
|
local_tools: tools,
|
|
28
|
-
|
|
27
|
+
mcp: mcp,
|
|
29
28
|
config: run_config
|
|
30
29
|
)
|
|
31
30
|
task :verify_a, worker_a, depends_on: :none
|
|
32
31
|
|
|
33
|
-
worker_b =
|
|
32
|
+
worker_b = RobotFactory.build_robot(
|
|
33
|
+
model,
|
|
34
34
|
name: "verifier-b",
|
|
35
|
-
model: model_id,
|
|
36
35
|
system_prompt: "Answer the following question independently. " \
|
|
37
36
|
"Focus on correctness and completeness.",
|
|
38
37
|
local_tools: tools,
|
|
39
|
-
|
|
38
|
+
mcp: mcp,
|
|
40
39
|
config: run_config
|
|
41
40
|
)
|
|
42
41
|
task :verify_b, worker_b, depends_on: :none
|
|
43
42
|
|
|
44
|
-
reconciler =
|
|
43
|
+
reconciler = RobotFactory.build_robot(
|
|
44
|
+
model,
|
|
45
45
|
name: "reconciler",
|
|
46
|
-
model: model_id,
|
|
47
46
|
system_prompt: "Compare two independent answers to the same question. " \
|
|
48
47
|
"Identify agreements and disagreements. " \
|
|
49
48
|
"Produce a final, reconciled answer that is most accurate. " \
|
|
@@ -52,7 +51,6 @@ module AIA
|
|
|
52
51
|
)
|
|
53
52
|
task :reconcile, reconciler, depends_on: %i[verify_a verify_b]
|
|
54
53
|
end
|
|
55
|
-
# rubocop:enable Metrics/BlockLength
|
|
56
54
|
end
|
|
57
55
|
end
|
|
58
56
|
end
|
data/lib/aia.rb
CHANGED
|
@@ -8,15 +8,29 @@ require 'bigdecimal'
|
|
|
8
8
|
require 'robot_lab'
|
|
9
9
|
require 'pm'
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
# Patches disabled 2026-09-16 (per DVH) — re-enable by uncommenting.
|
|
12
|
+
# NOTE: with ruby_llm_tool_param_compat disabled, the 2.0-style tool DSL
|
|
13
|
+
# (`parameter`/`description:`) in lib/aia/tools/ requires ruby_llm >= 2.0.
|
|
14
|
+
# require_relative 'aia/patches/ruby_llm_tool_error'
|
|
15
|
+
# require_relative 'aia/patches/ruby_llm_streaming_error'
|
|
16
|
+
# require_relative 'aia/patches/ruby_llm_tool_param_compat'
|
|
13
17
|
|
|
14
18
|
require_relative 'aia/errors'
|
|
19
|
+
require_relative 'aia/timing'
|
|
20
|
+
require_relative 'aia/tool_introspection'
|
|
15
21
|
require_relative 'aia/turn_state'
|
|
16
22
|
require_relative 'aia/content_extractor'
|
|
23
|
+
require_relative 'aia/speech'
|
|
17
24
|
require_relative 'aia/utility'
|
|
25
|
+
require_relative 'aia/mcp_server_config'
|
|
18
26
|
require_relative 'aia/skill_utils'
|
|
27
|
+
require_relative 'aia/role_catalog'
|
|
28
|
+
require_relative 'aia/model_registry'
|
|
29
|
+
require_relative 'aia/task_board'
|
|
30
|
+
require_relative 'aia/trakflow_bridge'
|
|
31
|
+
require_relative 'aia/task_coordinator'
|
|
19
32
|
require_relative 'aia/version'
|
|
33
|
+
require_relative 'aia/provider_registry'
|
|
20
34
|
require_relative 'aia/config'
|
|
21
35
|
require_relative 'aia/logger'
|
|
22
36
|
|
|
@@ -33,7 +47,9 @@ require_relative 'aia/tools/reskill_robot_tool'
|
|
|
33
47
|
require_relative 'aia/system_prompt_assembler'
|
|
34
48
|
require_relative 'aia/mcp_config_normalizer'
|
|
35
49
|
require_relative 'aia/network_memory_manager'
|
|
50
|
+
require_relative 'aia/tool_approver'
|
|
36
51
|
require_relative 'aia/robot_factory'
|
|
52
|
+
require_relative 'aia/robot_sync'
|
|
37
53
|
require_relative 'aia/robot_builder'
|
|
38
54
|
require_relative 'aia/directive_processor'
|
|
39
55
|
require_relative 'aia/variable_input_collector'
|
|
@@ -42,7 +58,6 @@ require_relative 'aia/input_collector'
|
|
|
42
58
|
require_relative 'aia/handler_context'
|
|
43
59
|
require_relative 'aia/handler_protocol'
|
|
44
60
|
require_relative 'aia/model_alias_registry'
|
|
45
|
-
require_relative 'aia/model_switch_handler'
|
|
46
61
|
require_relative 'aia/mcp_discovery'
|
|
47
62
|
require_relative 'aia/mcp_grouper'
|
|
48
63
|
require_relative 'aia/cost_calculator'
|
|
@@ -70,9 +85,7 @@ module AIA
|
|
|
70
85
|
$DEBUG_ME = false
|
|
71
86
|
DebugMeDefaultOptions[:skip1] = true
|
|
72
87
|
|
|
73
|
-
at_exit
|
|
74
|
-
$stderr.puts 'Exiting AIA application...'
|
|
75
|
-
end
|
|
88
|
+
at_exit { AIA.announce_exit }
|
|
76
89
|
|
|
77
90
|
@config = nil
|
|
78
91
|
@client = nil
|
|
@@ -80,7 +93,23 @@ module AIA
|
|
|
80
93
|
@turn_state = TurnState.new
|
|
81
94
|
|
|
82
95
|
class << self
|
|
83
|
-
attr_accessor :config, :client, :session_tracker, :turn_state, :
|
|
96
|
+
attr_accessor :config, :client, :session_tracker, :turn_state, :mcp_manager
|
|
97
|
+
attr_writer :task_coordinator
|
|
98
|
+
|
|
99
|
+
# The TrakFlow task coordinator, started the first time it is asked for.
|
|
100
|
+
#
|
|
101
|
+
# @return [AIA::TaskCoordinator, nil]
|
|
102
|
+
def task_coordinator
|
|
103
|
+
@task_coordinator ||= TaskBoard.coordinator
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Say goodbye when an interactive chat session ends. One-shot commands
|
|
107
|
+
# (--version, --help, --mcp-list, piped prompts) exit silently.
|
|
108
|
+
#
|
|
109
|
+
# @param io [IO]
|
|
110
|
+
def announce_exit(io = $stderr)
|
|
111
|
+
io.puts 'Exiting AIA application...' if chat?
|
|
112
|
+
end
|
|
84
113
|
|
|
85
114
|
def logger
|
|
86
115
|
AIA::LoggerManager.aia_logger
|
|
@@ -88,7 +117,7 @@ module AIA
|
|
|
88
117
|
|
|
89
118
|
def reset!
|
|
90
119
|
@config = @client = @session_tracker = @turn_state =
|
|
91
|
-
@task_coordinator = nil
|
|
120
|
+
@task_coordinator = @mcp_manager = nil
|
|
92
121
|
ToolLoader.reset_instance!
|
|
93
122
|
end
|
|
94
123
|
|
|
@@ -142,11 +171,14 @@ module AIA
|
|
|
142
171
|
@config&.output&.append == true
|
|
143
172
|
end
|
|
144
173
|
|
|
174
|
+
# :reek:TooManyStatements -- application boot sequence: parse, validate, log, load plugins, build robots, start session
|
|
145
175
|
def run
|
|
146
176
|
cli_overrides = CLIParser.parse
|
|
147
177
|
@config = Config.setup(cli_overrides)
|
|
148
178
|
return if ConfigValidator.tailor(@config) == :early_exit
|
|
149
179
|
|
|
180
|
+
log_startup
|
|
181
|
+
|
|
150
182
|
PluginLoader.load!(@config)
|
|
151
183
|
start_plugin_monitor
|
|
152
184
|
RobotFactory.setup(@config)
|
|
@@ -162,6 +194,15 @@ module AIA
|
|
|
162
194
|
|
|
163
195
|
private
|
|
164
196
|
|
|
197
|
+
# Record startup in all three log files. Only aia.log gets the full
|
|
198
|
+
# configuration dump; llm.log and mcp.log just note that AIA started,
|
|
199
|
+
# since their configuration is already covered by the aia.log entry.
|
|
200
|
+
def log_startup
|
|
201
|
+
LoggerManager.aia_logger.debug('AIA started up.', @config.to_h)
|
|
202
|
+
LoggerManager.llm_logger.debug('AIA started up.')
|
|
203
|
+
LoggerManager.mcp_logger.debug('AIA started up.')
|
|
204
|
+
end
|
|
205
|
+
|
|
165
206
|
def start_plugin_monitor
|
|
166
207
|
return unless @config.flags.chat
|
|
167
208
|
|