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
|
@@ -12,10 +12,13 @@ require_relative 'skill_utils'
|
|
|
12
12
|
module AIA
|
|
13
13
|
class PipelineOrchestrator
|
|
14
14
|
include ContentExtractor
|
|
15
|
+
include Speech
|
|
15
16
|
include SkillUtils
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
# :reek:LongParameterList -- collaborators injected for isolated testing
|
|
19
|
+
def initialize(robot:, prompt_handler:, input_collector:, ui_presenter:, session_tracker:, robot_sync: nil)
|
|
18
20
|
@robot = robot
|
|
21
|
+
@robot_sync = robot_sync
|
|
19
22
|
@prompt_handler = prompt_handler
|
|
20
23
|
@input_collector = input_collector
|
|
21
24
|
@ui = ui_presenter
|
|
@@ -24,52 +27,70 @@ module AIA
|
|
|
24
27
|
|
|
25
28
|
# Process all prompts in the pipeline.
|
|
26
29
|
#
|
|
30
|
+
# Shift-based loop: prompt front matter that sets config.pipeline
|
|
31
|
+
# (`next:` or `pipeline:`) is picked up on the next iteration.
|
|
32
|
+
#
|
|
27
33
|
# @param config [AIA::Config]
|
|
34
|
+
# :reek:DuplicateMethodCall -- config.pipeline is deliberately re-read each iteration because prompt front matter mutates it mid-loop
|
|
28
35
|
def process(config)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
bridge
|
|
36
|
+
# Only --track-pipeline starts TrakFlow for a pipeline run. The bridge
|
|
37
|
+
# does nothing when TrakFlow isn't available.
|
|
38
|
+
bridge = config.flags.track_pipeline ? TrakFlowBridge.new : nil
|
|
39
|
+
bridge&.create_plan_from_pipeline(config.pipeline)
|
|
33
40
|
|
|
34
|
-
# Use shift-based loop so that prompt front matter which sets
|
|
35
|
-
# config.pipeline (via `next:` or `pipeline:`) is picked up on
|
|
36
|
-
# the next iteration rather than being silently ignored.
|
|
37
41
|
until config.pipeline.empty?
|
|
38
42
|
prompt_id = config.pipeline.shift
|
|
39
43
|
next if prompt_id.nil? || prompt_id.empty?
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
bridge.update_step_status(prompt_id, :started) if tracking
|
|
43
|
-
|
|
44
|
-
prompt_text = build_prompt_text(prompt_id, config)
|
|
45
|
-
next if prompt_text.nil? || prompt_text.strip.empty?
|
|
46
|
-
|
|
47
|
-
result, content = compute_result(prompt_text, config)
|
|
48
|
-
|
|
49
|
-
bridge.update_step_status(prompt_id, :completed) if tracking
|
|
50
|
-
|
|
51
|
-
@tracker.record_turn(
|
|
52
|
-
model: config.models.first.name,
|
|
53
|
-
input: prompt_text,
|
|
54
|
-
result: result
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
@ui.display_ai_response(content)
|
|
58
|
-
output_to_file(content, config)
|
|
59
|
-
display_metrics(result, config)
|
|
60
|
-
@ui.display_separator
|
|
61
|
-
rescue StandardError => e
|
|
62
|
-
bridge.update_step_status(prompt_id, :failed, reason: e.message) if tracking
|
|
63
|
-
raise
|
|
64
|
-
end
|
|
45
|
+
run_step(prompt_id, config, bridge)
|
|
65
46
|
end
|
|
66
47
|
end
|
|
67
48
|
|
|
68
49
|
# Allow robot to be updated (after model switch)
|
|
69
50
|
attr_writer :robot
|
|
70
51
|
|
|
52
|
+
# The parameter names in a PM "Missing required parameters: a, b" message.
|
|
53
|
+
def self.missing_parameter_names(message)
|
|
54
|
+
message.to_s.sub(/\AMissing required parameters:/, '').split(',').map(&:strip).reject(&:empty?)
|
|
55
|
+
end
|
|
56
|
+
|
|
71
57
|
private
|
|
72
58
|
|
|
59
|
+
# Run one pipeline prompt, recording its progress on +bridge+ (a
|
|
60
|
+
# TrakFlowBridge, or nil when the run isn't tracked).
|
|
61
|
+
#
|
|
62
|
+
# :reek:TooManyStatements -- build, sync, run, record and present one step, with its tracking interleaved
|
|
63
|
+
def run_step(prompt_id, config, bridge)
|
|
64
|
+
bridge&.update_step_status(prompt_id, :started)
|
|
65
|
+
|
|
66
|
+
prompt_text = build_prompt_text(prompt_id, config)
|
|
67
|
+
return if prompt_text.nil? || prompt_text.strip.empty?
|
|
68
|
+
|
|
69
|
+
# Front matter may have changed the model or its settings
|
|
70
|
+
@robot = @robot_sync.call(@robot) if @robot_sync
|
|
71
|
+
|
|
72
|
+
result, content = compute_result(prompt_text, config)
|
|
73
|
+
bridge&.update_step_status(prompt_id, :completed)
|
|
74
|
+
|
|
75
|
+
@tracker.record_turn(model: config.models.first.name, input: prompt_text, result: result)
|
|
76
|
+
present_result(content, result, config)
|
|
77
|
+
rescue StandardError => e
|
|
78
|
+
bridge&.update_step_status(prompt_id, :failed, reason: e.message)
|
|
79
|
+
raise
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Show a step's response, then save and speak it. A --paint step saved
|
|
83
|
+
# an image next to the output file, so there is no text to keep or speak.
|
|
84
|
+
def present_result(content, result, config)
|
|
85
|
+
@ui.display_ai_response(content)
|
|
86
|
+
unless AIA.paint?
|
|
87
|
+
output_to_file(content, config)
|
|
88
|
+
speak(content)
|
|
89
|
+
end
|
|
90
|
+
display_metrics(result, config)
|
|
91
|
+
@ui.display_separator
|
|
92
|
+
end
|
|
93
|
+
|
|
73
94
|
# Returns [result, displayable_content] for one prompt — image when in paint
|
|
74
95
|
# mode, otherwise the LLM text response.
|
|
75
96
|
def compute_result(prompt_text, config)
|
|
@@ -82,16 +103,19 @@ module AIA
|
|
|
82
103
|
end
|
|
83
104
|
end
|
|
84
105
|
|
|
106
|
+
# :reek:TooManyStatements -- image request assembly, spinner-wrapped generation, then save/display of the result
|
|
85
107
|
def generate_image(prompt_text, config)
|
|
86
108
|
img_cfg = config.image
|
|
109
|
+
quality = img_cfg.quality
|
|
110
|
+
style = img_cfg.style
|
|
87
111
|
params = {}
|
|
88
|
-
params[:quality] =
|
|
89
|
-
params[:style] =
|
|
112
|
+
params[:quality] = quality if quality && !quality.to_s.strip.empty?
|
|
113
|
+
params[:style] = style if style && !style.to_s.strip.empty?
|
|
90
114
|
|
|
91
115
|
image = @ui.with_spinner("Generating image") do
|
|
92
116
|
RubyLLM.paint(
|
|
93
117
|
prompt_text,
|
|
94
|
-
model: img_cfg.model || '
|
|
118
|
+
model: img_cfg.model || 'gpt-image-1',
|
|
95
119
|
size: img_cfg.size || '1024x1024',
|
|
96
120
|
params: params
|
|
97
121
|
)
|
|
@@ -124,15 +148,15 @@ module AIA
|
|
|
124
148
|
end
|
|
125
149
|
|
|
126
150
|
# Check if concurrent MCP mode should be used
|
|
151
|
+
# :reek:TooManyStatements -- ordered eligibility gates (server count, auto/forced, discovery, grouping threshold) before the build
|
|
127
152
|
def maybe_use_concurrent_mcp(prompt_text, config)
|
|
128
153
|
return nil unless (config.mcp_servers || []).size > 1
|
|
129
154
|
|
|
155
|
+
turn_state = AIA.turn_state
|
|
130
156
|
concurrency = config.respond_to?(:concurrency) ? config.concurrency : nil
|
|
131
|
-
return nil unless concurrency&.auto ||
|
|
157
|
+
return nil unless concurrency&.auto || turn_state.force_concurrent_mcp
|
|
132
158
|
|
|
133
|
-
|
|
134
|
-
AIA.turn_state.force_concurrent_mcp = false
|
|
135
|
-
end
|
|
159
|
+
turn_state.clear_mode(:concurrent_mcp)
|
|
136
160
|
|
|
137
161
|
discovery = MCPDiscovery.new
|
|
138
162
|
relevant_servers = discovery.discover(config)
|
|
@@ -151,16 +175,18 @@ module AIA
|
|
|
151
175
|
end
|
|
152
176
|
|
|
153
177
|
# Build prompt text from a prompt_id
|
|
178
|
+
# :reek:TooManyStatements -- layered prompt assembly: parameters, role prefix, skills, stdin, context files, in a fixed order
|
|
154
179
|
def build_prompt_text(prompt_id, config)
|
|
155
180
|
parsed = @prompt_handler.fetch_prompt(prompt_id)
|
|
156
181
|
return nil unless parsed
|
|
157
182
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
values
|
|
183
|
+
parameters = parsed.respond_to?(:parameters) ? parsed.parameters : nil
|
|
184
|
+
if parameters && !parameters.empty?
|
|
185
|
+
values = @input_collector.collect(parameters)
|
|
186
|
+
values.each { |k, v| parameters[k] = v }
|
|
161
187
|
end
|
|
162
188
|
|
|
163
|
-
prompt_text = parsed
|
|
189
|
+
prompt_text = render_prompt(parsed)
|
|
164
190
|
|
|
165
191
|
role = config.prompts.role
|
|
166
192
|
if role && !role.empty?
|
|
@@ -180,14 +206,31 @@ module AIA
|
|
|
180
206
|
prompt_text = "#{prompt_text}\n\n#{skill_content}" if skill_content
|
|
181
207
|
end
|
|
182
208
|
|
|
183
|
-
|
|
184
|
-
|
|
209
|
+
stdin_content = config.stdin_content
|
|
210
|
+
if stdin_content && !stdin_content.strip.empty?
|
|
211
|
+
prompt_text = "#{prompt_text}\n\n#{stdin_content}"
|
|
185
212
|
config.stdin_content = nil
|
|
186
213
|
end
|
|
187
214
|
|
|
188
215
|
add_context_files(prompt_text, config)
|
|
189
216
|
end
|
|
190
217
|
|
|
218
|
+
# Render +parsed+, asking for any required parameter that only an
|
|
219
|
+
# included file declares. Such a parameter is not known until the
|
|
220
|
+
# include runs, so each MissingParameterError names more to ask for;
|
|
221
|
+
# rendering stops retrying once it names nothing new.
|
|
222
|
+
def render_prompt(parsed)
|
|
223
|
+
extra = {}
|
|
224
|
+
loop do
|
|
225
|
+
return parsed.to_s(extra)
|
|
226
|
+
rescue PM::MissingParameterError => e
|
|
227
|
+
names = self.class.missing_parameter_names(e.message) - extra.keys
|
|
228
|
+
raise if names.empty?
|
|
229
|
+
|
|
230
|
+
extra.merge!(@input_collector.collect(names.to_h { [it, nil] }))
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
191
234
|
# Append context file contents to prompt
|
|
192
235
|
def add_context_files(prompt_text, config)
|
|
193
236
|
context_files = config.context_files
|
data/lib/aia/plugin_monitor.rb
CHANGED
|
@@ -13,6 +13,7 @@ module AIA
|
|
|
13
13
|
# CPU). If `listen` cannot be loaded, it falls back to a background thread that
|
|
14
14
|
# polls file signatures ([mtime, size]). Either way the same #react logic drives
|
|
15
15
|
# {PluginLoader}, so behavior is identical — only latency differs.
|
|
16
|
+
# :reek:TooManyInstanceVariables -- holds both backends' state (listener vs polling thread) plus watch config and callbacks
|
|
16
17
|
class PluginMonitor
|
|
17
18
|
DEFAULT_INTERVAL = 1.0 # seconds (polling fallback only)
|
|
18
19
|
|
|
@@ -83,9 +84,11 @@ module AIA
|
|
|
83
84
|
#
|
|
84
85
|
# @return [Array<Array(Symbol, String)>] e.g. [[:added, "/p/foo.rb"], ...]
|
|
85
86
|
def detect_changes(old_snapshot, new_snapshot)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
old_keys = old_snapshot.keys
|
|
88
|
+
new_keys = new_snapshot.keys
|
|
89
|
+
added = (new_keys - old_keys).map { |path| [:added, path] }
|
|
90
|
+
removed = (old_keys - new_keys).map { |path| [:removed, path] }
|
|
91
|
+
modified = (old_keys & new_keys)
|
|
89
92
|
.reject { |path| new_snapshot[path] == old_snapshot[path] }
|
|
90
93
|
.map { |path| [:modified, path] }
|
|
91
94
|
added + removed + modified
|
|
@@ -115,9 +118,9 @@ module AIA
|
|
|
115
118
|
# Map a listen callback into per-file reactions, ignoring anything that is
|
|
116
119
|
# not a top-level file of the plugins directory (listen watches recursively).
|
|
117
120
|
def handle_listen_events(modified, added, removed)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
{ added: added, modified: modified, removed: removed }.each do |event, paths|
|
|
122
|
+
Array(paths).each { |path| react(event, path) if top_level?(path) }
|
|
123
|
+
end
|
|
121
124
|
end
|
|
122
125
|
|
|
123
126
|
# listen reports resolved (symlink-free) paths, and on macOS the plugins
|
|
@@ -75,7 +75,9 @@ module AIA
|
|
|
75
75
|
#
|
|
76
76
|
# @param prompt [String] the user's prompt
|
|
77
77
|
# @return [Array<String>] sub-task descriptions (empty if not decomposable)
|
|
78
|
+
# :reek:TooManyStatements -- schema vs JSON-fallback probe setup, run, extraction, and rescue reporting in one flow
|
|
78
79
|
def decompose(prompt)
|
|
80
|
+
logger = AIA.logger
|
|
79
81
|
probe = build_probe_robot
|
|
80
82
|
use_schema = structured_output?
|
|
81
83
|
|
|
@@ -83,17 +85,17 @@ module AIA
|
|
|
83
85
|
probe.with_schema(SUBTASKS_SCHEMA)
|
|
84
86
|
full_prompt = DECOMPOSITION_PROMPT % { prompt: prompt }
|
|
85
87
|
else
|
|
86
|
-
|
|
88
|
+
logger.warn("PromptDecomposer: configured model does not support structured output — using JSON prompt fallback")
|
|
87
89
|
full_prompt = (DECOMPOSITION_PROMPT + FALLBACK_JSON_INSTRUCTION) % { prompt: prompt }
|
|
88
90
|
end
|
|
89
91
|
|
|
90
92
|
result = probe.run(full_prompt, mcp: :none, tools: :none)
|
|
91
93
|
content = extract_content(result)
|
|
92
|
-
|
|
94
|
+
logger.debug("PromptDecomposer#decompose content class=#{content.class}")
|
|
93
95
|
subtasks = extract_subtasks(content)
|
|
94
96
|
subtasks.is_a?(Array) ? subtasks.select { |t| t.is_a?(String) && !t.empty? } : []
|
|
95
97
|
rescue StandardError => e
|
|
96
|
-
|
|
98
|
+
logger.warn("PromptDecomposer#decompose failed: #{e.class}: #{e.message}")
|
|
97
99
|
[]
|
|
98
100
|
end
|
|
99
101
|
|
|
@@ -116,7 +118,7 @@ module AIA
|
|
|
116
118
|
private
|
|
117
119
|
|
|
118
120
|
def structured_output?
|
|
119
|
-
RubyLLM.models.find(AIA.config.models.first.internal_id).structured_output
|
|
121
|
+
RubyLLM.models.find(AIA.config.models.first.internal_id).supports?(:structured_output)
|
|
120
122
|
rescue StandardError
|
|
121
123
|
false
|
|
122
124
|
end
|
data/lib/aia/prompt_handler.rb
CHANGED
|
@@ -4,15 +4,10 @@ require 'pm'
|
|
|
4
4
|
require 'erb'
|
|
5
5
|
|
|
6
6
|
module AIA
|
|
7
|
+
# :reek:TooManyMethods -- prompt/role fetching, front-matter merging, and fzf search form one lookup pipeline of small named steps
|
|
7
8
|
class PromptHandler
|
|
8
9
|
include AIA::SkillUtils
|
|
9
10
|
|
|
10
|
-
# Struct for path-based role content (bypasses PM parsing)
|
|
11
|
-
RoleContent = Struct.new(:content) do
|
|
12
|
-
def to_s = content
|
|
13
|
-
def metadata = nil
|
|
14
|
-
end
|
|
15
|
-
|
|
16
11
|
# Root-level YAML keys that are shorthands for deeper config paths
|
|
17
12
|
SHORTHAND_KEYS = %w[model temperature top_p next pipeline shell erb].freeze
|
|
18
13
|
|
|
@@ -29,15 +24,35 @@ module AIA
|
|
|
29
24
|
|
|
30
25
|
def initialize
|
|
31
26
|
@prompts_dir = AIA.config.prompts.dir
|
|
32
|
-
@roles_dir = AIA.config.prompts.roles_dir
|
|
33
27
|
|
|
28
|
+
flags = AIA.config.flags
|
|
34
29
|
PM.configure do |c|
|
|
35
30
|
c.prompts_dir = @prompts_dir
|
|
31
|
+
# flags.shell / flags.erb are the defaults; a file's front matter can still override them
|
|
32
|
+
c.shell = self.class.flag_enabled?(flags, :shell)
|
|
33
|
+
c.erb = self.class.flag_enabled?(flags, :erb)
|
|
36
34
|
end
|
|
37
35
|
|
|
38
36
|
register_pm_directives
|
|
39
37
|
end
|
|
40
38
|
|
|
39
|
+
# A shell/erb flag is on unless it is explicitly false.
|
|
40
|
+
#
|
|
41
|
+
# @param flags [#shell, #erb, nil]
|
|
42
|
+
# @param name [Symbol] :shell or :erb
|
|
43
|
+
# @return [Boolean]
|
|
44
|
+
def self.flag_enabled?(flags, name)
|
|
45
|
+
return true unless flags.respond_to?(name)
|
|
46
|
+
|
|
47
|
+
flags.public_send(name) != false
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# A pipeline from front matter: a list, or a comma-separated String
|
|
51
|
+
# ("a, b"), as a list of prompt IDs.
|
|
52
|
+
def self.pipeline_list(value)
|
|
53
|
+
Array(value).flat_map { it.to_s.split(',') }.map(&:strip).reject(&:empty?)
|
|
54
|
+
end
|
|
55
|
+
|
|
41
56
|
def fetch_prompt(prompt_id)
|
|
42
57
|
if prompt_id == '__FUZZY_SEARCH__'
|
|
43
58
|
return fuzzy_search_prompt('')
|
|
@@ -47,10 +62,10 @@ module AIA
|
|
|
47
62
|
return fetch_executable_prompt
|
|
48
63
|
end
|
|
49
64
|
|
|
50
|
-
prompt_file_path =
|
|
65
|
+
prompt_file_path = prompt_path(prompt_id)
|
|
51
66
|
|
|
52
67
|
parsed = if File.exist?(prompt_file_path)
|
|
53
|
-
|
|
68
|
+
parse_prompt_file(prompt_id)
|
|
54
69
|
else
|
|
55
70
|
$stderr.puts "Warning: Invalid prompt ID or file not found: #{prompt_id}"
|
|
56
71
|
logger.warn("Invalid prompt ID or file not found: #{prompt_id}")
|
|
@@ -65,16 +80,15 @@ module AIA
|
|
|
65
80
|
return handle_missing_role("roles/") if role_id.nil?
|
|
66
81
|
return fetch_role_from_path(role_id) if path_based_id?(role_id)
|
|
67
82
|
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
prompts_cfg = AIA.config.prompts
|
|
84
|
+
unless role_id.start_with?(prompts_cfg.roles_prefix)
|
|
85
|
+
role_id = "#{prompts_cfg.roles_prefix}/#{role_id}"
|
|
70
86
|
end
|
|
71
87
|
|
|
72
|
-
role_file_path = File.join(@prompts_dir, "#{role_id}#{
|
|
88
|
+
role_file_path = File.join(@prompts_dir, "#{role_id}#{prompts_cfg.extname}")
|
|
73
89
|
|
|
74
90
|
parsed = if File.exist?(role_file_path)
|
|
75
|
-
|
|
76
|
-
# and returns the ID string as content. Parse from raw file content instead.
|
|
77
|
-
PM.parse_string(File.read(role_file_path))
|
|
91
|
+
parse_prompt_file(role_id)
|
|
78
92
|
else
|
|
79
93
|
$stderr.puts "Warning: Invalid role ID or file not found: #{role_id}"
|
|
80
94
|
logger.warn("Invalid role ID or file not found: #{role_id}")
|
|
@@ -131,7 +145,7 @@ module AIA
|
|
|
131
145
|
|
|
132
146
|
def fetch_executable_prompt
|
|
133
147
|
content = AIA.config.executable_prompt_content
|
|
134
|
-
parsed = PM.
|
|
148
|
+
parsed = PM.parse_string(content)
|
|
135
149
|
apply_metadata_config(parsed) if parsed
|
|
136
150
|
parsed
|
|
137
151
|
end
|
|
@@ -171,56 +185,47 @@ module AIA
|
|
|
171
185
|
end
|
|
172
186
|
|
|
173
187
|
# Apply root-level shorthand keys to AIA.config
|
|
174
|
-
#
|
|
188
|
+
# :reek:TooManyStatements -- one guarded assignment per supported front-matter shorthand key
|
|
175
189
|
def apply_root_shorthands(meta_hash)
|
|
176
|
-
|
|
177
|
-
model_val = meta_hash['model'] || meta_hash[:model]
|
|
178
|
-
if model_val
|
|
179
|
-
AIA.config.models = [model_val]
|
|
180
|
-
end
|
|
190
|
+
cfg = AIA.config
|
|
181
191
|
|
|
182
|
-
#
|
|
183
|
-
|
|
184
|
-
if
|
|
185
|
-
AIA.config.llm.temperature = temp_val
|
|
186
|
-
end
|
|
192
|
+
# model → cfg.models (replace; a String or list becomes ModelSpecs)
|
|
193
|
+
model_val = shorthand(meta_hash, :model)
|
|
194
|
+
cfg.models = Config::TO_MODEL_SPECS.call(Array(model_val)) if model_val
|
|
187
195
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if top_p_val
|
|
191
|
-
AIA.config.llm.top_p = top_p_val
|
|
192
|
-
end
|
|
196
|
+
temp_val = shorthand(meta_hash, :temperature)
|
|
197
|
+
cfg.llm.temperature = temp_val if temp_val
|
|
193
198
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if next_val
|
|
197
|
-
if AIA.config.pipeline.any?
|
|
198
|
-
logger.info "Prompt metadata 'next: #{next_val}' overrides remaining pipeline #{AIA.config.pipeline.inspect}"
|
|
199
|
-
end
|
|
200
|
-
AIA.config.pipeline = [next_val]
|
|
201
|
-
end
|
|
199
|
+
top_p_val = shorthand(meta_hash, :top_p)
|
|
200
|
+
cfg.llm.top_p = top_p_val if top_p_val
|
|
202
201
|
|
|
203
|
-
# pipeline →
|
|
204
|
-
|
|
205
|
-
if
|
|
206
|
-
if AIA.config.pipeline.any?
|
|
207
|
-
logger.info "Prompt metadata 'pipeline' overrides remaining pipeline #{AIA.config.pipeline.inspect}"
|
|
208
|
-
end
|
|
209
|
-
AIA.config.pipeline = Array(pipeline_val)
|
|
210
|
-
end
|
|
202
|
+
# next / pipeline → cfg.pipeline (replace)
|
|
203
|
+
next_val = shorthand(meta_hash, :next)
|
|
204
|
+
apply_pipeline_shorthand(cfg, next_val, "next: #{next_val}") if next_val
|
|
211
205
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
206
|
+
pipeline_val = shorthand(meta_hash, :pipeline)
|
|
207
|
+
apply_pipeline_shorthand(cfg, pipeline_val, "pipeline") if pipeline_val
|
|
208
|
+
|
|
209
|
+
# shell / erb → cfg.flags (and PM's shell/erb via metadata)
|
|
210
|
+
shell_val = shorthand(meta_hash, :shell)
|
|
211
|
+
cfg.flags.shell = shell_val unless shell_val.nil?
|
|
212
|
+
|
|
213
|
+
erb_val = shorthand(meta_hash, :erb)
|
|
214
|
+
cfg.flags.erb = erb_val unless erb_val.nil?
|
|
215
|
+
end
|
|
217
216
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
217
|
+
# Fetch a front-matter shorthand value by string or symbol key.
|
|
218
|
+
def shorthand(meta_hash, key)
|
|
219
|
+
meta_hash[key.to_s] || meta_hash[key]
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Replace cfg.pipeline, logging when a remaining pipeline is overridden.
|
|
223
|
+
def apply_pipeline_shorthand(cfg, new_pipeline, label)
|
|
224
|
+
if cfg.pipeline.any?
|
|
225
|
+
logger.info "Prompt metadata '#{label}' overrides remaining pipeline #{cfg.pipeline.inspect}"
|
|
226
|
+
end
|
|
227
|
+
cfg.pipeline = self.class.pipeline_list(new_pipeline)
|
|
222
228
|
end
|
|
223
|
-
# rubocop:enable Metrics/AbcSize
|
|
224
229
|
|
|
225
230
|
def logger
|
|
226
231
|
@logger ||= LoggerManager.aia_logger
|
|
@@ -237,6 +242,10 @@ module AIA
|
|
|
237
242
|
if sub_config
|
|
238
243
|
deep_merge_into_config(sub_config, value)
|
|
239
244
|
end
|
|
245
|
+
elsif key == :pipeline
|
|
246
|
+
target.pipeline = self.class.pipeline_list(value)
|
|
247
|
+
elsif key == :models
|
|
248
|
+
target.models = Config::TO_MODEL_SPECS.call(Array(value))
|
|
240
249
|
elsif target.respond_to?(:"#{key}=")
|
|
241
250
|
target.send(:"#{key}=", value)
|
|
242
251
|
end
|
|
@@ -293,8 +302,7 @@ module AIA
|
|
|
293
302
|
end
|
|
294
303
|
|
|
295
304
|
def fetch_role_from_path(role_id)
|
|
296
|
-
expanded =
|
|
297
|
-
expanded += '.md' if File.extname(expanded).empty?
|
|
305
|
+
expanded = prompt_path(role_id)
|
|
298
306
|
|
|
299
307
|
unless File.exist?(expanded)
|
|
300
308
|
$stderr.puts "Warning: Role file not found at path: #{expanded}"
|
|
@@ -302,7 +310,9 @@ module AIA
|
|
|
302
310
|
return handle_missing_role(role_id)
|
|
303
311
|
end
|
|
304
312
|
|
|
305
|
-
|
|
313
|
+
parsed = PM.parse(Pathname.new(expanded))
|
|
314
|
+
apply_metadata_config(parsed)
|
|
315
|
+
parsed
|
|
306
316
|
end
|
|
307
317
|
|
|
308
318
|
def fuzzy_search_prompt(prompt_id)
|
|
@@ -312,7 +322,7 @@ module AIA
|
|
|
312
322
|
raise "Error: Could not find prompt with ID: #{prompt_id} even with fuzzy search"
|
|
313
323
|
end
|
|
314
324
|
|
|
315
|
-
|
|
325
|
+
parse_prompt_file(new_prompt_id)
|
|
316
326
|
end
|
|
317
327
|
|
|
318
328
|
def handle_missing_role(role_id)
|
|
@@ -336,7 +346,19 @@ module AIA
|
|
|
336
346
|
raise "Error: Could not find role with ID: #{role_id} even with fuzzy search"
|
|
337
347
|
end
|
|
338
348
|
|
|
339
|
-
|
|
349
|
+
parse_prompt_file(new_role_id)
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
# Full path of the prompt file for +prompt_id+ (relative to the prompts dir).
|
|
353
|
+
def prompt_path(prompt_id)
|
|
354
|
+
SkillUtils.prompt_file_path(prompt_id, dir: @prompts_dir, extname: AIA.config.prompts.extname)
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
# Parse the prompt file for +prompt_id+. PM.parse only treats a single
|
|
358
|
+
# \w+ word as a file name, so IDs such as "code-review" or "dev/review"
|
|
359
|
+
# would be parsed as literal text; a Pathname is always read as a file.
|
|
360
|
+
def parse_prompt_file(prompt_id)
|
|
361
|
+
PM.parse(Pathname.new(prompt_path(prompt_id)))
|
|
340
362
|
end
|
|
341
363
|
|
|
342
364
|
def search_prompt_id_with_fzf(initial_query)
|
|
@@ -353,11 +375,12 @@ module AIA
|
|
|
353
375
|
end
|
|
354
376
|
|
|
355
377
|
def search_role_id_with_fzf(initial_query)
|
|
356
|
-
|
|
357
|
-
|
|
378
|
+
prompts_cfg = AIA.config.prompts
|
|
379
|
+
prefix = prompts_cfg.roles_prefix
|
|
380
|
+
role_files = RoleCatalog.names(@prompts_dir, prefix, extname: prompts_cfg.extname)
|
|
358
381
|
fzf = AIA::Fzf.new(
|
|
359
382
|
list: role_files,
|
|
360
|
-
directory: @prompts_dir,
|
|
383
|
+
directory: File.join(@prompts_dir, prefix.to_s),
|
|
361
384
|
query: initial_query,
|
|
362
385
|
subject: 'Role IDs',
|
|
363
386
|
prompt: 'Select a role ID:'
|
|
@@ -369,9 +392,7 @@ module AIA
|
|
|
369
392
|
raise "No role ID selected"
|
|
370
393
|
end
|
|
371
394
|
|
|
372
|
-
unless role.start_with?(
|
|
373
|
-
role = AIA.config.prompts.roles_prefix + '/' + role
|
|
374
|
-
end
|
|
395
|
+
role = "#{prefix}/#{role}" unless role.start_with?(prefix)
|
|
375
396
|
|
|
376
397
|
role
|
|
377
398
|
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# lib/aia/provider_registry.rb
|
|
2
|
+
#
|
|
3
|
+
# Generic gateway to RubyLLM's provider registry (ruby_llm >= 2.0).
|
|
4
|
+
# AIA hardcodes no provider names: a model prefix counts as a provider
|
|
5
|
+
# exactly when RubyLLM has it registered — built-in providers, provider gems
|
|
6
|
+
# the user loaded (e.g. `aia --require ruby_llm-providers-xyzzy`), or a gem
|
|
7
|
+
# following the conventional `ruby_llm/providers/<slug>` require path that
|
|
8
|
+
# can be loaded on demand the first time its slug is seen.
|
|
9
|
+
|
|
10
|
+
module AIA
|
|
11
|
+
module ProviderRegistry
|
|
12
|
+
module_function
|
|
13
|
+
|
|
14
|
+
# All registered provider slugs, as strings.
|
|
15
|
+
def slugs
|
|
16
|
+
RubyLLM::Provider.providers.keys.map(&:to_s)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Registered providers as {slug (String) => provider class}.
|
|
20
|
+
def providers
|
|
21
|
+
RubyLLM::Provider.providers.transform_keys(&:to_s)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# True when RubyLLM already has this slug registered.
|
|
25
|
+
def registered?(slug)
|
|
26
|
+
return false unless slug
|
|
27
|
+
|
|
28
|
+
RubyLLM::Provider.providers.key?(slug.to_sym)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# True when the slug names a registered provider, loading the
|
|
32
|
+
# conventional provider gem on demand the first time it is seen.
|
|
33
|
+
def available?(slug)
|
|
34
|
+
registered?(slug) || load(slug)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Attempt to require the conventional gem path for a provider slug.
|
|
38
|
+
# Returns true when the provider ends up registered. Failed lookups are
|
|
39
|
+
# cached so repeated non-provider prefixes (model ids also use "/")
|
|
40
|
+
# don't pay the require cost every time.
|
|
41
|
+
def load(slug)
|
|
42
|
+
slug = slug.to_s
|
|
43
|
+
return false unless slug.match?(/\A[a-z0-9_]+\z/)
|
|
44
|
+
|
|
45
|
+
@load_attempts ||= {}
|
|
46
|
+
return @load_attempts[slug] if @load_attempts.key?(slug)
|
|
47
|
+
|
|
48
|
+
@load_attempts[slug] =
|
|
49
|
+
begin
|
|
50
|
+
require "ruby_llm/providers/#{slug}"
|
|
51
|
+
registered?(slug)
|
|
52
|
+
rescue LoadError
|
|
53
|
+
false
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# A provider instance ready for API calls (model listing etc.).
|
|
58
|
+
# Raises RubyLLM's own errors for unknown or unconfigured providers.
|
|
59
|
+
def instantiate(slug)
|
|
60
|
+
RubyLLM::Provider.resolve!(slug.to_sym).new(RubyLLM.config)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Slugs of conventionally named provider gems visible to the bundle
|
|
64
|
+
# (ruby_llm-providers-<slug>), whether or not they are loaded yet.
|
|
65
|
+
def installed_gem_slugs
|
|
66
|
+
Gem::Specification.filter_map do |spec|
|
|
67
|
+
spec.name.delete_prefix('ruby_llm-providers-') if spec.name.start_with?('ruby_llm-providers-')
|
|
68
|
+
end.uniq
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Register every installed conventional provider gem, so a full listing
|
|
72
|
+
# reflects what is available, not just what has been referenced so far.
|
|
73
|
+
def load_installed_gems
|
|
74
|
+
installed_gem_slugs.each { |slug| load(slug) }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Endpoints for local servers that RubyLLM leaves unset, so they work
|
|
78
|
+
# without an environment variable when running on their usual port.
|
|
79
|
+
DEFAULT_ENDPOINTS = { 'ollama' => 'http://localhost:11434/v1' }.freeze
|
|
80
|
+
|
|
81
|
+
# Generic env-var endpoint overrides: for every registered provider,
|
|
82
|
+
# <SLUG>_API_BASE sets RubyLLM.config.<slug>_api_base when the provider
|
|
83
|
+
# defines that option (RubyLLM registers the accessor with the provider).
|
|
84
|
+
# A provider in DEFAULT_ENDPOINTS with no endpoint set gets its default.
|
|
85
|
+
def apply_env_endpoints
|
|
86
|
+
RubyLLM.configure do |c|
|
|
87
|
+
slugs.each do |slug|
|
|
88
|
+
setter = :"#{slug}_api_base="
|
|
89
|
+
next unless c.respond_to?(setter)
|
|
90
|
+
|
|
91
|
+
value = ENV.fetch("#{slug.upcase}_API_BASE", nil) || default_endpoint(c, slug)
|
|
92
|
+
c.public_send(setter, value) if value
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# The default endpoint for +slug+ when RubyLLM has none configured.
|
|
98
|
+
def default_endpoint(ruby_llm_config, slug)
|
|
99
|
+
getter = :"#{slug}_api_base"
|
|
100
|
+
return nil if ruby_llm_config.respond_to?(getter) && ruby_llm_config.public_send(getter)
|
|
101
|
+
|
|
102
|
+
DEFAULT_ENDPOINTS[slug.to_s]
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
data/lib/aia/robot_builder.rb
CHANGED
|
@@ -27,7 +27,7 @@ module AIA
|
|
|
27
27
|
name: robot_name,
|
|
28
28
|
system_prompt: system_prompt,
|
|
29
29
|
local_tools: ToolLoader.filtered_tools(config),
|
|
30
|
-
|
|
30
|
+
mcp: RobotFactory.mcp_servers(config),
|
|
31
31
|
on_content: nil,
|
|
32
32
|
config: RobotFactory.build_run_config(config)
|
|
33
33
|
)
|