aia 2.0.0.0.pre.beta2 → 2.0.1
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/CHANGELOG.md +152 -223
- data/README.md +41 -18
- 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 +16 -14
- data/lib/aia/config/cli_parser.rb +123 -91
- data/lib/aia/config/defaults.yml +18 -40
- data/lib/aia/config/mcp_parser.rb +30 -36
- data/lib/aia/config/model_spec.rb +8 -14
- data/lib/aia/config/validator.rb +102 -103
- data/lib/aia/config/value_caster.rb +76 -0
- data/lib/aia/config.rb +70 -53
- data/lib/aia/crew.rb +29 -19
- data/lib/aia/debate_handler.rb +27 -10
- data/lib/aia/directives/configuration_directives.rb +55 -14
- data/lib/aia/directives/context_directives.rb +24 -12
- data/lib/aia/directives/execution_directives.rb +18 -23
- data/lib/aia/directives/model_directives.rb +41 -104
- data/lib/aia/directives/utility_directives.rb +16 -17
- data/lib/aia/directives/web_and_file_directives.rb +21 -14
- data/lib/aia/fact_asserter.rb +3 -3
- data/lib/aia/history_transfer.rb +64 -24
- data/lib/aia/logger.rb +14 -46
- data/lib/aia/mcp_config_normalizer.rb +27 -14
- data/lib/aia/mcp_connection_manager.rb +181 -184
- data/lib/aia/mcp_discovery.rb +43 -15
- data/lib/aia/mcp_grouper.rb +2 -1
- data/lib/aia/mcp_server_config.rb +20 -2
- data/lib/aia/mcp_utility.rb +24 -19
- data/lib/aia/mention_router.rb +15 -2
- 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 +8 -7
- data/lib/aia/patches/mcp_stdio_stderr.rb +102 -0
- 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 +71 -38
- data/lib/aia/prompt_decomposer.rb +1 -1
- data/lib/aia/prompt_handler.rb +56 -29
- data/lib/aia/provider_registry.rb +105 -0
- data/lib/aia/robot_builder.rb +1 -1
- data/lib/aia/robot_factory.rb +67 -63
- data/lib/aia/robot_sync.rb +79 -0
- data/lib/aia/role_catalog.rb +89 -0
- data/lib/aia/session.rb +25 -11
- 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 +28 -25
- data/lib/aia/speech.rb +70 -34
- data/lib/aia/startup_coordinator.rb +17 -92
- data/lib/aia/streaming_runner.rb +10 -2
- data/lib/aia/system_prompt_assembler.rb +12 -11
- data/lib/aia/task_board.rb +60 -0
- data/lib/aia/tool_approver.rb +205 -0
- data/lib/aia/tool_filter.rb +1 -10
- data/lib/aia/tool_filter_strategy.rb +12 -1
- data/lib/aia/tool_introspection.rb +9 -1
- data/lib/aia/tool_loader.rb +67 -33
- 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 +16 -16
- data/lib/aia/trakflow_bridge.rb +14 -8
- data/lib/aia/turn_state.rb +31 -8
- data/lib/aia/ui_presenter.rb +16 -0
- data/lib/aia/utility.rb +6 -24
- data/lib/aia/variable_input_collector.rb +0 -3
- data/lib/aia/verification_network.rb +9 -10
- data/lib/aia/version.rb +1 -9
- data/lib/aia.rb +34 -8
- metadata +20 -161
- data/.better-commits.json +0 -150
- data/.config/tocer/configuration.yml +0 -6
- data/.envrc +0 -19
- data/.loki +0 -11
- data/.reek.yml +0 -160
- data/.rubocop.yml +0 -116
- data/.rubocop_strict.yml +0 -15
- data/.version +0 -1
- data/COMMITS.md +0 -196
- data/IMPLEMENTATION_PLAN.md +0 -506
- data/Rakefile +0 -47
- data/_typos.toml +0 -10
- data/aia.gemspec +0 -92
- data/architecture_review.md +0 -314
- data/config/aia.yml +0 -13
- 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/config/defaults.yml
CHANGED
|
@@ -61,19 +61,12 @@ defaults:
|
|
|
61
61
|
extname: .md
|
|
62
62
|
#
|
|
63
63
|
role: ~
|
|
64
|
-
roles_dir: ~/.prompts/roles
|
|
65
64
|
roles_prefix: roles
|
|
66
65
|
#
|
|
67
66
|
skills: []
|
|
68
67
|
#
|
|
69
|
-
tool: ~
|
|
70
|
-
tools_prefix: tools
|
|
71
|
-
#
|
|
72
68
|
system_prompt: ~
|
|
73
69
|
|
|
74
|
-
roles:
|
|
75
|
-
dir: ~/.prompts/roles
|
|
76
|
-
|
|
77
70
|
skills:
|
|
78
71
|
dir: ~/.prompts/skills
|
|
79
72
|
|
|
@@ -85,7 +78,6 @@ defaults:
|
|
|
85
78
|
output:
|
|
86
79
|
file: temp.md
|
|
87
80
|
append: false
|
|
88
|
-
markdown: true
|
|
89
81
|
history_file: ~/.prompts/_prompts.log
|
|
90
82
|
|
|
91
83
|
# ---------------------------------------------------------------------------
|
|
@@ -96,6 +88,7 @@ defaults:
|
|
|
96
88
|
audio:
|
|
97
89
|
voice: ~
|
|
98
90
|
speak_command: say
|
|
91
|
+
player: ~
|
|
99
92
|
speech_model: ~
|
|
100
93
|
transcription_model: ~
|
|
101
94
|
|
|
@@ -105,29 +98,24 @@ defaults:
|
|
|
105
98
|
# Env: AIA_IMAGE__MODEL, AIA_IMAGE__SIZE, etc.
|
|
106
99
|
# ---------------------------------------------------------------------------
|
|
107
100
|
image:
|
|
108
|
-
model:
|
|
101
|
+
model: gpt-image-1
|
|
109
102
|
size: 1024x1024
|
|
110
103
|
quality: standard
|
|
111
104
|
style: vivid
|
|
112
105
|
|
|
113
|
-
# ---------------------------------------------------------------------------
|
|
114
|
-
# Embedding Configuration
|
|
115
|
-
# Access: AIA.config.embedding.model
|
|
116
|
-
# Env: AIA_EMBEDDING__MODEL
|
|
117
|
-
# ---------------------------------------------------------------------------
|
|
118
|
-
embedding:
|
|
119
|
-
model: text-embedding-ada-002
|
|
120
|
-
|
|
121
106
|
# ---------------------------------------------------------------------------
|
|
122
107
|
# Tools Configuration
|
|
123
108
|
# Access: AIA.config.tools.paths, AIA.config.tools.allowed, etc.
|
|
124
109
|
# Env: AIA_TOOLS__PATHS, AIA_TOOLS__ALLOWED, etc.
|
|
125
110
|
# ---------------------------------------------------------------------------
|
|
126
111
|
tools:
|
|
127
|
-
dir: ~/.prompts/tools
|
|
128
112
|
paths: []
|
|
129
113
|
allowed: ~
|
|
130
114
|
rejected: ~
|
|
115
|
+
# Tool calls that require approval (an MCP server's requires_approval:)
|
|
116
|
+
# and MCP input requests: ask (prompt on the terminal; refuse when there
|
|
117
|
+
# is none), approve (allow them all), or deny (refuse them all).
|
|
118
|
+
approval: ask
|
|
131
119
|
|
|
132
120
|
# ---------------------------------------------------------------------------
|
|
133
121
|
# Flags (Boolean Options)
|
|
@@ -145,13 +133,9 @@ defaults:
|
|
|
145
133
|
speak: false
|
|
146
134
|
shell: true
|
|
147
135
|
erb: true
|
|
148
|
-
clear: false
|
|
149
136
|
consensus: false
|
|
150
137
|
track_pipeline: false
|
|
151
|
-
expert_routing: false
|
|
152
138
|
auto_tool_filter: true
|
|
153
|
-
tool_filter_load: false
|
|
154
|
-
tool_filter_save: false
|
|
155
139
|
allow_ruby_eval: false
|
|
156
140
|
paint: false
|
|
157
141
|
thinking: false
|
|
@@ -178,10 +162,15 @@ defaults:
|
|
|
178
162
|
file: STDOUT
|
|
179
163
|
level: warn
|
|
180
164
|
flush: true
|
|
165
|
+
# MCP connection logging goes to a file so warnings never interleave
|
|
166
|
+
# with the "Connecting MCP servers" spinner; failures still appear in
|
|
167
|
+
# the startup banner's FAILED list.
|
|
181
168
|
mcp:
|
|
182
|
-
file:
|
|
169
|
+
file: ~/.config/aia/logs/mcp.log
|
|
183
170
|
level: warn
|
|
184
171
|
flush: true
|
|
172
|
+
# stderr of stdio MCP server processes: a file path, STDERR, or null
|
|
173
|
+
server_stderr: ~/.config/aia/logs/mcp_servers.log
|
|
185
174
|
|
|
186
175
|
# ---------------------------------------------------------------------------
|
|
187
176
|
# Pipeline/Workflow Configuration
|
|
@@ -213,13 +202,12 @@ defaults:
|
|
|
213
202
|
|
|
214
203
|
# ---------------------------------------------------------------------------
|
|
215
204
|
# Paths Configuration
|
|
216
|
-
# Access: AIA.config.paths.aia_dir, AIA.config.paths.
|
|
217
|
-
# Env: AIA_PATHS__AIA_DIR
|
|
205
|
+
# Access: AIA.config.paths.aia_dir, AIA.config.paths.plugins_dir
|
|
206
|
+
# Env: AIA_PATHS__AIA_DIR
|
|
218
207
|
# Special-case env: AIA_PLUGINS_DIR
|
|
219
208
|
# ---------------------------------------------------------------------------
|
|
220
209
|
paths:
|
|
221
210
|
aia_dir: ~/.config/aia
|
|
222
|
-
config_file: ~/.config/aia/aia.yml
|
|
223
211
|
plugins_dir: ~
|
|
224
212
|
|
|
225
213
|
# ---------------------------------------------------------------------------
|
|
@@ -231,10 +219,12 @@ defaults:
|
|
|
231
219
|
# ---------------------------------------------------------------------------
|
|
232
220
|
# Model Switch History Mode
|
|
233
221
|
# Controls conversation history transfer when switching models mid-chat.
|
|
234
|
-
# Values: clean (fresh start), replay (
|
|
222
|
+
# Values: clean (fresh start), replay (re-send every user message to the
|
|
223
|
+
# new model), summarize (old model summarizes; the new model gets the summary)
|
|
224
|
+
# Used by the /model directive.
|
|
235
225
|
# Access: AIA.config.model_switch_history
|
|
236
226
|
# ---------------------------------------------------------------------------
|
|
237
|
-
model_switch_history:
|
|
227
|
+
model_switch_history: summarize
|
|
238
228
|
|
|
239
229
|
# ---------------------------------------------------------------------------
|
|
240
230
|
# Concurrency Configuration
|
|
@@ -243,21 +233,9 @@ defaults:
|
|
|
243
233
|
# ---------------------------------------------------------------------------
|
|
244
234
|
concurrency:
|
|
245
235
|
auto: false
|
|
246
|
-
independent_servers: []
|
|
247
236
|
threshold: 2
|
|
248
237
|
mcp_timeout: 120
|
|
249
238
|
|
|
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
239
|
# ---------------------------------------------------------------------------
|
|
262
240
|
# Context Files (set at runtime)
|
|
263
241
|
# Access: AIA.config.context_files (array of file paths)
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
# transport: { type: "stdio", command: "npx", args: [...], env: {...} },
|
|
12
12
|
# timeout: 8000,
|
|
13
13
|
# topics: ["routing"], # AIA routing metadata (optional)
|
|
14
|
-
# independent: false, # AIA concurrency metadata (optional)
|
|
15
14
|
# group: "services" # AIA grouping metadata (optional)
|
|
16
15
|
# }
|
|
17
16
|
#
|
|
@@ -39,6 +38,12 @@ require 'json'
|
|
|
39
38
|
|
|
40
39
|
module AIA
|
|
41
40
|
module McpParser
|
|
41
|
+
# Keys that describe how to reach the server; they go into :transport.
|
|
42
|
+
TRANSPORT_KEYS = %w[type command args env url headers bearer_token oauth cwd directory].freeze
|
|
43
|
+
|
|
44
|
+
# Server settings robot_lab understands, carried through as written.
|
|
45
|
+
SERVER_KEYS = %w[prefix only except requires_approval description].freeze
|
|
46
|
+
|
|
42
47
|
class << self
|
|
43
48
|
# Parse MCP server configuration files and return array of server configs
|
|
44
49
|
# in robot_lab's nested transport format.
|
|
@@ -93,20 +98,29 @@ module AIA
|
|
|
93
98
|
# @param mcp_servers [Hash] the mcpServers hash from JSON
|
|
94
99
|
# @return [Array<Hash>] array of server configurations
|
|
95
100
|
def convert_mcp_servers_format(mcp_servers)
|
|
96
|
-
mcp_servers.map
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
mcp_servers.map { |name, config| build_server(name, config) }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# One server in robot_lab's format. Both JSON forms accept the same keys.
|
|
105
|
+
def build_server(name, config)
|
|
106
|
+
server = { name: name, transport: build_transport(config) }
|
|
107
|
+
server[:timeout] = config['timeout'].to_i if config['timeout']
|
|
108
|
+
SERVER_KEYS.each { |key| server[key.to_sym] = config[key] if config.key?(key) }
|
|
109
|
+
server.merge!(routing_metadata(config))
|
|
101
110
|
end
|
|
102
111
|
|
|
112
|
+
# The transport hash. With no "type", a url means Streamable HTTP and
|
|
113
|
+
# anything else stdio. A "command" given as an array holds the command
|
|
114
|
+
# followed by its arguments.
|
|
103
115
|
def build_transport(config)
|
|
104
|
-
transport =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
transport = config.slice(*TRANSPORT_KEYS).transform_keys(&:to_sym)
|
|
117
|
+
command = transport[:command]
|
|
118
|
+
if command.is_a?(Array)
|
|
119
|
+
transport[:command] = command.first
|
|
120
|
+
transport[:args] = Array(command[1..]) + Array(transport[:args])
|
|
121
|
+
end
|
|
122
|
+
transport[:args] = Array(transport[:args]) if transport.key?(:args)
|
|
123
|
+
transport[:type] ||= transport[:url] && !transport[:command] ? 'streamable-http' : 'stdio'
|
|
110
124
|
transport
|
|
111
125
|
end
|
|
112
126
|
|
|
@@ -114,38 +128,18 @@ module AIA
|
|
|
114
128
|
def routing_metadata(config)
|
|
115
129
|
meta = {}
|
|
116
130
|
meta[:topics] = Array(config['topics']) if config['topics']
|
|
117
|
-
meta[:independent] = config['independent'] unless config['independent'].nil?
|
|
118
131
|
meta[:group] = config['group'] if config['group']
|
|
119
132
|
meta
|
|
120
133
|
end
|
|
121
134
|
|
|
122
|
-
# Convert simple format to robot_lab nested transport format
|
|
135
|
+
# Convert simple format to robot_lab nested transport format. The
|
|
136
|
+
# server is named after the file ("filesystem.json" -> "filesystem").
|
|
123
137
|
#
|
|
124
|
-
# @param parsed [Hash]
|
|
138
|
+
# @param parsed [Hash] one server's settings
|
|
125
139
|
# @param file_path [String] file path for deriving server name
|
|
126
140
|
# @return [Array<Hash>] array with single server configuration
|
|
127
141
|
def convert_simple_format(parsed, file_path)
|
|
128
|
-
|
|
129
|
-
name = File.basename(file_path, '.*')
|
|
130
|
-
|
|
131
|
-
transport = { type: parsed['type'] || 'stdio' }
|
|
132
|
-
|
|
133
|
-
command = parsed['command']
|
|
134
|
-
if command.is_a?(Array)
|
|
135
|
-
# Command is an array: first element is command, rest are args
|
|
136
|
-
transport[:command] = command.first
|
|
137
|
-
transport[:args] = command[1..] || []
|
|
138
|
-
elsif command
|
|
139
|
-
transport[:command] = command
|
|
140
|
-
transport[:args] = parsed['args'] || []
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
transport[:env] = parsed['env'] if parsed['env']
|
|
144
|
-
|
|
145
|
-
server = { name: name, transport: transport }
|
|
146
|
-
server[:timeout] = parsed['timeout'].to_i if parsed['timeout']
|
|
147
|
-
|
|
148
|
-
[server]
|
|
142
|
+
[build_server(File.basename(file_path, '.*'), parsed)]
|
|
149
143
|
end
|
|
150
144
|
end
|
|
151
145
|
end
|
|
@@ -15,14 +15,6 @@ module AIA
|
|
|
15
15
|
class ModelSpec
|
|
16
16
|
attr_accessor :name, :role, :instance, :internal_id, :provider
|
|
17
17
|
|
|
18
|
-
# Provider prefixes that map to RubyLLM provider slugs.
|
|
19
|
-
# 'lms' is stored as-is; RobotFactory maps it to the openai provider
|
|
20
|
-
# with a custom API base so it doesn't conflict with real OpenAI models.
|
|
21
|
-
PROVIDER_ALIASES = {
|
|
22
|
-
'ollama' => 'ollama',
|
|
23
|
-
'lms' => 'lms'
|
|
24
|
-
}.freeze
|
|
25
|
-
|
|
26
18
|
def initialize(hash = {})
|
|
27
19
|
hash = hash.transform_keys(&:to_sym) if hash.respond_to?(:transform_keys)
|
|
28
20
|
|
|
@@ -32,7 +24,7 @@ module AIA
|
|
|
32
24
|
@internal_id = hash[:internal_id] || @name
|
|
33
25
|
@provider = hash[:provider]
|
|
34
26
|
|
|
35
|
-
# Extract provider from name if prefixed (e.g., "
|
|
27
|
+
# Extract provider from name if prefixed (e.g., "<provider>/<model-id>")
|
|
36
28
|
extract_provider_from_name! unless @provider
|
|
37
29
|
end
|
|
38
30
|
|
|
@@ -84,15 +76,17 @@ module AIA
|
|
|
84
76
|
|
|
85
77
|
private
|
|
86
78
|
|
|
87
|
-
# Extract provider prefix from model name.
|
|
88
|
-
#
|
|
89
|
-
#
|
|
79
|
+
# Extract a provider prefix from the model name. The prefix is a provider
|
|
80
|
+
# exactly when RubyLLM knows it (registered already, or loadable as a
|
|
81
|
+
# conventional ruby_llm-providers-<prefix> gem) — no provider names are
|
|
82
|
+
# hardcoded here. Names whose first segment is not a provider (registry
|
|
83
|
+
# ids like "meta-llama/llama-4-maverick") pass through untouched.
|
|
90
84
|
def extract_provider_from_name!
|
|
91
85
|
return unless @name&.include?('/')
|
|
92
86
|
|
|
93
87
|
prefix, rest = @name.split('/', 2)
|
|
94
|
-
return unless
|
|
95
|
-
@provider =
|
|
88
|
+
return unless ProviderRegistry.available?(prefix)
|
|
89
|
+
@provider = prefix
|
|
96
90
|
@name = rest
|
|
97
91
|
end
|
|
98
92
|
end
|
data/lib/aia/config/validator.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'timeout'
|
|
4
|
+
require 'did_you_mean'
|
|
3
5
|
require 'word_wrapper'
|
|
4
6
|
require_relative '../skill_utils'
|
|
7
|
+
require_relative '../role_catalog'
|
|
5
8
|
|
|
6
9
|
# lib/aia/config/validator.rb
|
|
7
10
|
#
|
|
@@ -34,12 +37,13 @@ module AIA
|
|
|
34
37
|
handle_executable_prompt(config)
|
|
35
38
|
handle_stdin_as_prompt(config)
|
|
36
39
|
return :early_exit if handle_early_exits(config) == :early_exit
|
|
37
|
-
|
|
40
|
+
adopt_pipeline_head(config)
|
|
38
41
|
process_role_configuration(config)
|
|
42
|
+
validate_model_roles(config)
|
|
43
|
+
validate_required_prompt_id(config)
|
|
39
44
|
validate_plugins_dir(config)
|
|
40
45
|
handle_fuzzy_search_prompt_id(config)
|
|
41
46
|
normalize_boolean_flags(config)
|
|
42
|
-
validate_final_prompt_requirements(config)
|
|
43
47
|
prepare_pipeline(config)
|
|
44
48
|
validate_pipeline_prompts(config)
|
|
45
49
|
|
|
@@ -51,6 +55,7 @@ module AIA
|
|
|
51
55
|
return :early_exit if handle_mcp_list(config) == :early_exit
|
|
52
56
|
return :early_exit if handle_list_tools(config) == :early_exit
|
|
53
57
|
return :early_exit if handle_list_skills(config) == :early_exit
|
|
58
|
+
return :early_exit if handle_list_roles(config) == :early_exit
|
|
54
59
|
:early_exit if handle_completion_script(config) == :early_exit
|
|
55
60
|
end
|
|
56
61
|
|
|
@@ -93,6 +98,7 @@ module AIA
|
|
|
93
98
|
"Did you mean: #{suggestions}?\n" \
|
|
94
99
|
"Flags require a dash prefix (e.g., -B not _B)."
|
|
95
100
|
end
|
|
101
|
+
raise AIA::ConfigurationError, missing_prompt_message(config, bad_files) if missing_prompt_id?(config, remaining_args, bad_files)
|
|
96
102
|
raise AIA::ConfigurationError, "The following files do not exist: #{bad_files.join(', ')}"
|
|
97
103
|
end
|
|
98
104
|
|
|
@@ -100,6 +106,31 @@ module AIA
|
|
|
100
106
|
config.context_files += remaining_args
|
|
101
107
|
end
|
|
102
108
|
|
|
109
|
+
# The first argument looks like a prompt ID (no extension) but names
|
|
110
|
+
# neither a prompt nor a file.
|
|
111
|
+
def missing_prompt_id?(config, remaining_args, bad_files)
|
|
112
|
+
word = remaining_args.first
|
|
113
|
+
config.prompt_id.nil? && bad_files.first == word && File.extname(word).empty?
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def missing_prompt_message(config, bad_files)
|
|
117
|
+
word, *others = bad_files
|
|
118
|
+
dir = config.prompts.dir
|
|
119
|
+
message = "No prompt named '#{word}' in #{dir} (and no file by that name)."
|
|
120
|
+
suggestions = prompt_suggestions(word, dir, config.prompts.extname)
|
|
121
|
+
message += "\nDid you mean: #{suggestions.join(', ')}?" if suggestions.any?
|
|
122
|
+
message += "\nThe following files do not exist: #{others.join(', ')}" if others.any?
|
|
123
|
+
message
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Prompt IDs under +dir+ that are close spellings of +word+.
|
|
127
|
+
def prompt_suggestions(word, dir, extname)
|
|
128
|
+
return [] unless dir && Dir.exist?(dir)
|
|
129
|
+
|
|
130
|
+
ids = Dir.glob("**/*#{extname}", base: dir).map { it.delete_suffix(extname) }
|
|
131
|
+
DidYouMean::SpellChecker.new(dictionary: ids).correct(word).first(3)
|
|
132
|
+
end
|
|
133
|
+
|
|
103
134
|
def handle_executable_prompt(config)
|
|
104
135
|
return unless config.prompt_id.nil?
|
|
105
136
|
|
|
@@ -122,20 +153,34 @@ module AIA
|
|
|
122
153
|
content = config.stdin_content
|
|
123
154
|
return unless content && !content.strip.empty?
|
|
124
155
|
|
|
125
|
-
|
|
126
|
-
content = content.lines[1..].join
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
config.executable_prompt_content = content
|
|
156
|
+
config.executable_prompt_content = strip_shebang(content)
|
|
130
157
|
config.stdin_content = nil
|
|
131
158
|
config.prompt_id = '__EXECUTABLE_PROMPT__'
|
|
132
159
|
end
|
|
133
160
|
|
|
161
|
+
# Piped text arrives with a leading newline (see process_stdin_content).
|
|
162
|
+
# Drop it, and a "#!" line if the text starts with one, so the front
|
|
163
|
+
# matter that follows is recognized.
|
|
164
|
+
def strip_shebang(content)
|
|
165
|
+
text = content.delete_prefix("\n")
|
|
166
|
+
text.start_with?('#!') ? text.lines[1..].join : text
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# With no prompt ID, --pipeline's first prompt is the one to run.
|
|
170
|
+
def adopt_pipeline_head(config)
|
|
171
|
+
return unless config.prompt_id.nil? || config.prompt_id.empty?
|
|
172
|
+
|
|
173
|
+
head = Array(config.pipeline).first
|
|
174
|
+
config.prompt_id = head unless head.nil? || head.empty?
|
|
175
|
+
end
|
|
176
|
+
|
|
134
177
|
def validate_required_prompt_id(config)
|
|
135
178
|
return unless config.prompt_id.nil? && config.flags.chat != true && config.flags.fuzzy != true
|
|
136
179
|
|
|
137
180
|
raise AIA::ConfigurationError,
|
|
138
|
-
"A prompt ID is required unless
|
|
181
|
+
"A prompt ID is required unless you use --chat, --fuzzy, --pipeline or --role, " \
|
|
182
|
+
"pipe the prompt in, or run an executable prompt. Context files alone are not a prompt. " \
|
|
183
|
+
"Use -h or --help for help."
|
|
139
184
|
end
|
|
140
185
|
|
|
141
186
|
def process_role_configuration(config)
|
|
@@ -149,8 +194,6 @@ module AIA
|
|
|
149
194
|
prompts.role = role
|
|
150
195
|
end
|
|
151
196
|
|
|
152
|
-
prompts.roles_dir ||= File.join(prompts.dir, roles_prefix.to_s)
|
|
153
|
-
|
|
154
197
|
return if config.flags&.chat == true
|
|
155
198
|
|
|
156
199
|
return unless config.prompt_id.nil? || config.prompt_id.empty?
|
|
@@ -223,7 +266,11 @@ module AIA
|
|
|
223
266
|
def print_mcp_server(server_config)
|
|
224
267
|
args_str = server_config.args.empty? ? '' : " #{server_config.args.join(' ')}"
|
|
225
268
|
puts " #{server_config.name || '(unnamed)'}"
|
|
226
|
-
|
|
269
|
+
if server_config.command.nil? && server_config.url
|
|
270
|
+
puts " url: #{server_config.url}"
|
|
271
|
+
else
|
|
272
|
+
puts " command: #{server_config.command || '(no command)'}#{args_str}"
|
|
273
|
+
end
|
|
227
274
|
puts
|
|
228
275
|
end
|
|
229
276
|
|
|
@@ -320,18 +367,13 @@ module AIA
|
|
|
320
367
|
end
|
|
321
368
|
end
|
|
322
369
|
|
|
370
|
+
# The servers --mcp-use/--mcp-skip keep. --require libraries are loaded
|
|
371
|
+
# first and entries naming a RubyLLM::MCP subclass are resolved to it,
|
|
372
|
+
# exactly as a session does before connecting.
|
|
323
373
|
def filter_mcp_servers(config)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if !use_list.empty?
|
|
329
|
-
servers.select { |s| use_list.include?(s[:name] || s['name']) }
|
|
330
|
-
elsif !skip_list.empty?
|
|
331
|
-
servers.reject { |s| skip_list.include?(s[:name] || s['name']) }
|
|
332
|
-
else
|
|
333
|
-
servers
|
|
334
|
-
end
|
|
374
|
+
AIA::ToolLoader.require_libs(config)
|
|
375
|
+
selected = AIA::MCPDiscovery.select(config.mcp_servers || [], use: config.mcp_use, skip: config.mcp_skip)
|
|
376
|
+
AIA::MCPDiscovery.new.resolve_entries(selected)
|
|
335
377
|
end
|
|
336
378
|
|
|
337
379
|
def mcp_filter_active?(config)
|
|
@@ -361,38 +403,34 @@ module AIA
|
|
|
361
403
|
:early_exit
|
|
362
404
|
end
|
|
363
405
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
instantiable_tool_classes
|
|
368
|
-
end
|
|
406
|
+
# --list-roles, from the configured prompts directory and roles prefix.
|
|
407
|
+
def handle_list_roles(config)
|
|
408
|
+
return unless config.respond_to?(:list_roles) && config.list_roles
|
|
369
409
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
require lib
|
|
374
|
-
rescue LoadError => e
|
|
375
|
-
$stderr.puts "Warning: Failed to require '#{lib}': #{e.message}"
|
|
376
|
-
$stderr.puts "Hint: Make sure the gem is installed: gem install #{lib}"
|
|
377
|
-
rescue StandardError => e
|
|
378
|
-
$stderr.puts "Warning: Error in library '#{lib}': #{e.class} - #{e.message}"
|
|
379
|
-
end
|
|
410
|
+
prompts = config.prompts
|
|
411
|
+
puts AIA::RoleCatalog.listing(prompts.dir, prompts.roles_prefix, extname: prompts.extname)
|
|
412
|
+
:early_exit
|
|
380
413
|
end
|
|
381
414
|
|
|
382
|
-
#
|
|
383
|
-
def
|
|
384
|
-
|
|
385
|
-
|
|
415
|
+
# Every -m MODEL=ROLE role must exist in the configured prompts directory.
|
|
416
|
+
def validate_model_roles(config)
|
|
417
|
+
prompts = config.prompts
|
|
418
|
+
Array(config.models).each do |spec|
|
|
419
|
+
role = spec.respond_to?(:role) ? spec.role : nil
|
|
420
|
+
next if role.nil? || role.to_s.empty?
|
|
386
421
|
|
|
387
|
-
|
|
388
|
-
klass.new
|
|
389
|
-
true
|
|
390
|
-
rescue StandardError
|
|
391
|
-
false
|
|
392
|
-
end
|
|
422
|
+
AIA::RoleCatalog.validate!(role, dir: prompts.dir, prefix: prompts.roles_prefix, extname: prompts.extname)
|
|
393
423
|
end
|
|
394
424
|
end
|
|
395
425
|
|
|
426
|
+
# The local tools a session would offer: loaded the same way
|
|
427
|
+
# (--require gems, --tools files, lazily loaded tool gems) and narrowed
|
|
428
|
+
# by --allowed-tools / --rejected-tools.
|
|
429
|
+
def load_local_tools(config)
|
|
430
|
+
ToolLoader.load_tools(config)
|
|
431
|
+
ToolLoader.filtered_tools(config)
|
|
432
|
+
end
|
|
433
|
+
|
|
396
434
|
def first_sentences(text, count)
|
|
397
435
|
normalized = text.gsub(/\s*\n\s*/, ' ').gsub(/\s{2,}/, ' ').strip
|
|
398
436
|
sentences = normalized.scan(/[^.!?]*[.!?]/)
|
|
@@ -405,61 +443,31 @@ module AIA
|
|
|
405
443
|
servers = filter_mcp_servers(config)
|
|
406
444
|
return {} if servers.empty?
|
|
407
445
|
|
|
408
|
-
quiet_mcp_logger
|
|
409
|
-
|
|
410
446
|
servers.each_with_object({}) do |server, groups|
|
|
411
447
|
server_config = McpServerConfig.from_hash(server)
|
|
412
448
|
$stderr.print "MCP: Connecting to #{server_config.name}..."
|
|
413
449
|
$stderr.flush
|
|
414
450
|
|
|
415
|
-
tools = collect_server_tools(server_config)
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
$stderr.puts " #{tools.size} tools"
|
|
419
|
-
else
|
|
420
|
-
$stderr.puts " failed"
|
|
421
|
-
end
|
|
451
|
+
tools = collect_server_tools(server, server_config)
|
|
452
|
+
groups[server_config.name] = tools
|
|
453
|
+
$stderr.puts " #{tools.size} tools"
|
|
422
454
|
rescue StandardError => e
|
|
423
455
|
$stderr.puts " error: #{e.message}"
|
|
424
456
|
end
|
|
425
457
|
end
|
|
426
458
|
|
|
427
|
-
#
|
|
428
|
-
#
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
end
|
|
437
|
-
|
|
438
|
-
def mcp_add_client(server_config)
|
|
439
|
-
mcp_config = { command: server_config.command, args: server_config.args }
|
|
440
|
-
mcp_config[:env] = server_config.env unless server_config.env.empty?
|
|
441
|
-
|
|
442
|
-
RubyLLM::MCP.add_client(
|
|
443
|
-
name: server_config.name, transport_type: :stdio,
|
|
444
|
-
config: mcp_config, request_timeout: server_config.timeout_ms, start: false
|
|
445
|
-
)
|
|
446
|
-
rescue ArgumentError
|
|
447
|
-
# Older ruby_llm-mcp versions do not accept request_timeout
|
|
448
|
-
RubyLLM::MCP.add_client(
|
|
449
|
-
name: server_config.name, transport_type: :stdio,
|
|
450
|
-
config: mcp_config, start: false
|
|
451
|
-
)
|
|
459
|
+
# Build the server the way MCPConnectionManager does (RobotLab::MCP.build,
|
|
460
|
+
# so --list-tools shows exactly the RubyLLM::MCP::Tools a robot would be
|
|
461
|
+
# handed) and return its tools. Connection failures raise. The server is
|
|
462
|
+
# closed before returning.
|
|
463
|
+
def collect_server_tools(server, server_config)
|
|
464
|
+
mcp = RobotLab::MCP.build(MCPConfigNormalizer.normalize(server))
|
|
465
|
+
Timeout.timeout(server_config.timeout_ms / 1000.0) { mcp.tools }
|
|
466
|
+
ensure
|
|
467
|
+
mcp&.close
|
|
452
468
|
end
|
|
453
469
|
# rubocop:enable Metrics/ModuleLength
|
|
454
470
|
|
|
455
|
-
def quiet_mcp_logger
|
|
456
|
-
return unless defined?(RubyLLM::MCP) && RubyLLM::MCP.respond_to?(:config)
|
|
457
|
-
mcp_config = RubyLLM::MCP.config
|
|
458
|
-
return unless mcp_config.respond_to?(:logger=)
|
|
459
|
-
quiet = Logger.new(File::NULL)
|
|
460
|
-
mcp_config.logger = quiet
|
|
461
|
-
end
|
|
462
|
-
|
|
463
471
|
def handle_completion_script(config)
|
|
464
472
|
return unless config.completion
|
|
465
473
|
|
|
@@ -470,21 +478,12 @@ module AIA
|
|
|
470
478
|
def generate_completion_script(shell)
|
|
471
479
|
script_path = File.join(File.dirname(__FILE__), "../aia_completion.#{shell}")
|
|
472
480
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
$stderr.puts "ERROR: The shell '#{shell}' is not supported or the completion script is missing."
|
|
481
|
+
unless File.exist?(script_path)
|
|
482
|
+
raise AIA::ConfigurationError,
|
|
483
|
+
"ERROR: The shell '#{shell}' is not supported (use bash, zsh or fish)."
|
|
477
484
|
end
|
|
478
|
-
end
|
|
479
485
|
|
|
480
|
-
|
|
481
|
-
chat_mode = config.flags.chat == true
|
|
482
|
-
fuzzy_mode = config.flags.fuzzy == true
|
|
483
|
-
no_prompt = config.prompt_id.nil? || config.prompt_id.empty?
|
|
484
|
-
no_context = config.context_files.nil? || config.context_files.empty?
|
|
485
|
-
return unless !chat_mode && !fuzzy_mode && no_prompt && no_context
|
|
486
|
-
raise AIA::ConfigurationError,
|
|
487
|
-
"A prompt ID is required unless using --chat, --fuzzy, or providing context files. Use -h or --help for help."
|
|
486
|
+
puts File.read(script_path)
|
|
488
487
|
end
|
|
489
488
|
|
|
490
489
|
def prepare_pipeline(config)
|
|
@@ -502,7 +501,7 @@ module AIA
|
|
|
502
501
|
config.pipeline.each do |prompt_id|
|
|
503
502
|
next if prompt_id.nil? || prompt_id.empty? || prompt_id == '__FUZZY_SEARCH__' || prompt_id == '__EXECUTABLE_PROMPT__'
|
|
504
503
|
|
|
505
|
-
prompt_file_path =
|
|
504
|
+
prompt_file_path = AIA::SkillUtils.prompt_file_path(prompt_id, dir: config.prompts.dir, extname: config.prompts.extname)
|
|
506
505
|
unless File.exist?(prompt_file_path)
|
|
507
506
|
$stderr.puts "Error: Prompt ID '#{prompt_id}' does not exist at #{prompt_file_path}"
|
|
508
507
|
and_exit = true
|