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
|
@@ -13,8 +13,8 @@ module AIA
|
|
|
13
13
|
desc "Execute Ruby code (requires allow_ruby_eval: true in config)"
|
|
14
14
|
def ruby(args, context_manager = nil)
|
|
15
15
|
unless AIA.config.flags.allow_ruby_eval
|
|
16
|
-
puts "ERROR: /ruby is disabled. Set `allow_ruby_eval: true` in " \
|
|
17
|
-
"~/.aia/
|
|
16
|
+
puts "ERROR: /ruby is disabled. Set `flags: { allow_ruby_eval: true }` in " \
|
|
17
|
+
"~/.config/aia/aia.yml or pass --allow-ruby-eval to enable it. " \
|
|
18
18
|
"Note: this executes arbitrary Ruby with full process privileges."
|
|
19
19
|
return ""
|
|
20
20
|
end
|
|
@@ -35,46 +35,46 @@ module AIA
|
|
|
35
35
|
|
|
36
36
|
desc "Use text-to-speech to speak the text"
|
|
37
37
|
def say(args, context_manager = nil)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else
|
|
45
|
-
system(env, 'say', *args)
|
|
38
|
+
# Without text, `say` reads stdin and speaks every line the user types
|
|
39
|
+
# next — hijacking the chat session — so never invoke it bare.
|
|
40
|
+
text = Array(args).join(' ').strip
|
|
41
|
+
if text.empty?
|
|
42
|
+
puts "Usage: /say TEXT"
|
|
43
|
+
return nil
|
|
46
44
|
end
|
|
45
|
+
|
|
46
|
+
Speech.speak_text(text)
|
|
47
47
|
""
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
desc "Execute next prompt with concurrent MCP server access"
|
|
51
51
|
def concurrent(args, context_manager = nil)
|
|
52
|
-
AIA.turn_state.
|
|
52
|
+
AIA.turn_state.request(:concurrent_mcp)
|
|
53
53
|
"Concurrent MCP mode enabled for next prompt."
|
|
54
54
|
end
|
|
55
55
|
alias conc concurrent
|
|
56
56
|
|
|
57
57
|
desc "Run next prompt through verification (two independent answers + reconciliation)"
|
|
58
58
|
def verify(args, context_manager = nil)
|
|
59
|
-
AIA.turn_state.
|
|
59
|
+
AIA.turn_state.request(:verify)
|
|
60
60
|
"Verification mode enabled for next prompt."
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
desc "Decompose next prompt into parallel sub-tasks"
|
|
64
64
|
def decompose(args, context_manager = nil)
|
|
65
|
-
AIA.turn_state.
|
|
65
|
+
AIA.turn_state.request(:decompose)
|
|
66
66
|
"Decomposition mode enabled for next prompt."
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
desc "Multi-round debate between robots in the network"
|
|
70
70
|
def debate(args, context_manager = nil)
|
|
71
|
-
AIA.turn_state.
|
|
71
|
+
AIA.turn_state.request(:debate)
|
|
72
72
|
"Debate mode enabled for next prompt."
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
desc "Delegate subtasks to specific robots via TrakFlow plan"
|
|
76
76
|
def delegate(args, context_manager = nil)
|
|
77
|
-
AIA.turn_state.
|
|
77
|
+
AIA.turn_state.request(:delegate)
|
|
78
78
|
"Delegation mode enabled for next prompt."
|
|
79
79
|
end
|
|
80
80
|
alias del delegate
|
|
@@ -82,18 +82,13 @@ module AIA
|
|
|
82
82
|
desc "Spawn a specialist robot for the next prompt. " \
|
|
83
83
|
"Usage: /spawn | /spawn <type> | /spawn <name> <provider/model> <system prompt>"
|
|
84
84
|
def spawn(args, context_manager = nil)
|
|
85
|
-
state = AIA.turn_state
|
|
86
|
-
state.force_spawn = true
|
|
87
|
-
|
|
88
85
|
if args.size >= 2
|
|
89
86
|
spec = AIA::SpawnSpecParser.parse(args)
|
|
90
|
-
|
|
91
|
-
state.spawn_type = nil
|
|
87
|
+
AIA.turn_state.request(:spawn, spec: spec)
|
|
92
88
|
"Spawn mode enabled: '#{spec[:name]}' (#{spawn_model_summary(spec)}) for next prompt."
|
|
93
89
|
else
|
|
94
90
|
type = args.first
|
|
95
|
-
|
|
96
|
-
state.spawn_type = type
|
|
91
|
+
AIA.turn_state.request(:spawn, type: type)
|
|
97
92
|
type_msg = type ? " (#{type})" : " (auto-detect)"
|
|
98
93
|
"Spawn mode enabled#{type_msg} for next prompt."
|
|
99
94
|
end
|
|
@@ -139,7 +134,7 @@ module AIA
|
|
|
139
134
|
|
|
140
135
|
desc "3-tier layered orchestration: orchestrator → lead agents → specialists"
|
|
141
136
|
def orchestrate(args, context_manager = nil)
|
|
142
|
-
AIA.turn_state.
|
|
137
|
+
AIA.turn_state.request(:orchestrate)
|
|
143
138
|
"Orchestration mode enabled. Your next prompt is the application requirements."
|
|
144
139
|
end
|
|
145
140
|
alias orch orchestrate
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
# lib/aia/directives/model_directives.rb
|
|
2
2
|
|
|
3
|
+
require_relative '../modality_query'
|
|
4
|
+
|
|
3
5
|
module AIA
|
|
4
6
|
class ModelDirectives < Directive
|
|
5
7
|
desc "List all available AI models"
|
|
6
8
|
def available_models(args = nil, context_manager = nil)
|
|
7
|
-
current_models = AIA.config.models
|
|
8
|
-
|
|
9
|
-
model_names = current_models.map do |m|
|
|
10
|
-
m.respond_to?(:name) ? m.name : m.to_s
|
|
11
|
-
end
|
|
12
|
-
|
|
13
9
|
positive_terms, negative_terms = parse_search_terms(Array(args))
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
provider_slugs = configured_provider_slugs(AIA.config.models)
|
|
16
12
|
|
|
17
|
-
if
|
|
18
|
-
|
|
13
|
+
if provider_slugs.any?
|
|
14
|
+
show_provider_models(provider_slugs, positive_terms, negative_terms)
|
|
19
15
|
else
|
|
20
16
|
show_rubyllm_models(positive_terms, negative_terms)
|
|
21
17
|
end
|
|
@@ -49,10 +45,10 @@ module AIA
|
|
|
49
45
|
|
|
50
46
|
# --- helpers (no desc → not registered) ---
|
|
51
47
|
|
|
52
|
-
# Split a //compare arg list into [prompt, models];
|
|
53
|
-
#
|
|
48
|
+
# Split a //compare arg list into [prompt, models]; every word that is
|
|
49
|
+
# not part of `--models a,b,c` belongs to the prompt.
|
|
54
50
|
def parse_compare_args(args)
|
|
55
|
-
|
|
51
|
+
words = []
|
|
56
52
|
models = []
|
|
57
53
|
|
|
58
54
|
i = 0
|
|
@@ -61,12 +57,13 @@ module AIA
|
|
|
61
57
|
models = args[i + 1].split(',')
|
|
62
58
|
i += 2
|
|
63
59
|
else
|
|
64
|
-
|
|
60
|
+
words << args[i]
|
|
65
61
|
i += 1
|
|
66
62
|
end
|
|
67
63
|
end
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
prompt = words.join(' ').strip
|
|
66
|
+
[prompt.empty? ? nil : prompt, models]
|
|
70
67
|
end
|
|
71
68
|
|
|
72
69
|
def compare_with_model(model_name, prompt)
|
|
@@ -87,68 +84,43 @@ module AIA
|
|
|
87
84
|
nil
|
|
88
85
|
end
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
api_base = ENV.fetch('OLLAMA_API_BASE', 'http://localhost:11434')
|
|
102
|
-
api_base = api_base.gsub(%r{/v1/?$}, '')
|
|
103
|
-
show_ollama_models(api_base, positive_terms, negative_terms)
|
|
104
|
-
elsif model_spec.start_with?('lms/')
|
|
105
|
-
api_base = ENV.fetch('LMS_API_BASE', 'http://localhost:1234')
|
|
106
|
-
show_lms_models(api_base, positive_terms, negative_terms)
|
|
87
|
+
# Provider slugs referenced by the configured models — from ModelSpec#provider
|
|
88
|
+
# when present, else from a registered "<slug>/" name prefix (raw string
|
|
89
|
+
# model specs). Entirely registry-driven; no provider names are hardcoded.
|
|
90
|
+
def configured_provider_slugs(models)
|
|
91
|
+
Array(models).filter_map do |m|
|
|
92
|
+
if m.respond_to?(:provider) && m.provider
|
|
93
|
+
m.provider.to_s
|
|
94
|
+
else
|
|
95
|
+
name = (m.respond_to?(:name) ? m.name : m).to_s
|
|
96
|
+
prefix = name.split('/', 2).first if name.include?('/')
|
|
97
|
+
prefix if AIA::ProviderRegistry.registered?(prefix)
|
|
107
98
|
end
|
|
108
|
-
end
|
|
99
|
+
end.uniq
|
|
109
100
|
end
|
|
110
101
|
|
|
111
|
-
#
|
|
112
|
-
|
|
102
|
+
# List each provider's live models through RubyLLM's own provider API
|
|
103
|
+
# (Provider#list_models), the same path every registered provider —
|
|
104
|
+
# built-in or gem-supplied — implements.
|
|
105
|
+
# :reek:TooManyStatements -- sequential terminal report per provider: header, listing, connection guard
|
|
106
|
+
def show_provider_models(provider_slugs, positive_terms = nil, negative_terms = nil)
|
|
113
107
|
positive_terms, negative_terms = normalized_model_search_terms(positive_terms, negative_terms)
|
|
114
108
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
puts "
|
|
118
|
-
return
|
|
119
|
-
end
|
|
109
|
+
provider_slugs.each do |slug|
|
|
110
|
+
puts "\n#{slug} models:"
|
|
111
|
+
puts "-" * 60
|
|
120
112
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
113
|
+
entries = provider_model_entries(slug)
|
|
114
|
+
print_filtered_entries(entries, positive_terms, negative_terms, "#{slug} model(s) available")
|
|
115
|
+
rescue StandardError => e
|
|
116
|
+
puts "❌ Cannot list models for provider '#{slug}': #{e.message}"
|
|
125
117
|
end
|
|
126
|
-
|
|
127
|
-
puts "Ollama Models (#{api_base}):"
|
|
128
|
-
puts "-" * 60
|
|
129
|
-
|
|
130
|
-
entries = models.map { |model| format_ollama_entry(model) }
|
|
131
|
-
print_filtered_entries(entries, positive_terms, negative_terms, "Ollama model(s) available")
|
|
132
|
-
rescue StandardError => e
|
|
133
|
-
puts "❌ Error fetching Ollama models: #{e.message}"
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def format_ollama_entry(model)
|
|
137
|
-
size = model['size'] ? format_bytes(model['size']) : 'unknown'
|
|
138
|
-
modified = model['modified_at'] ? Time.parse(model['modified_at']).strftime('%Y-%m-%d') : 'unknown'
|
|
139
|
-
"- ollama/#{model['name']} (size: #{size}, modified: #{modified})"
|
|
140
118
|
end
|
|
141
119
|
|
|
142
|
-
#
|
|
143
|
-
def
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
http.open_timeout = 5
|
|
147
|
-
http.read_timeout = 5
|
|
148
|
-
response = http.request(Net::HTTP::Get.new(uri))
|
|
149
|
-
return nil unless response.is_a?(Net::HTTPSuccess)
|
|
150
|
-
|
|
151
|
-
JSON.parse(response.body)
|
|
120
|
+
# One "- <slug>/<model-id>" line per model the provider reports.
|
|
121
|
+
def provider_model_entries(slug)
|
|
122
|
+
provider = AIA::ProviderRegistry.instantiate(slug)
|
|
123
|
+
provider.list_models.map { |model| "- #{slug}/#{model.id}" }
|
|
152
124
|
end
|
|
153
125
|
|
|
154
126
|
# The entry is a String; Array#intersect? would raise TypeError
|
|
@@ -171,41 +143,6 @@ module AIA
|
|
|
171
143
|
puts
|
|
172
144
|
end
|
|
173
145
|
|
|
174
|
-
# :reek:TooManyStatements -- sequential terminal report: fetch, connection guards, filtered listing
|
|
175
|
-
def show_lms_models(api_base, positive_terms = nil, negative_terms = nil)
|
|
176
|
-
positive_terms, negative_terms = normalized_model_search_terms(positive_terms, negative_terms)
|
|
177
|
-
|
|
178
|
-
data = fetch_json("#{api_base.gsub(%r{/v1/?$}, '')}/v1/models")
|
|
179
|
-
if data.nil?
|
|
180
|
-
puts "❌ Cannot connect to LM Studio at #{api_base}"
|
|
181
|
-
return
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
models = data['data'] || []
|
|
185
|
-
if models.empty?
|
|
186
|
-
puts "No LM Studio models found"
|
|
187
|
-
return
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
puts "LM Studio Models (#{api_base}):"
|
|
191
|
-
puts "-" * 60
|
|
192
|
-
|
|
193
|
-
entries = models.map { |model| "- lms/#{model['id']}" }
|
|
194
|
-
print_filtered_entries(entries, positive_terms, negative_terms, "LM Studio model(s) available")
|
|
195
|
-
rescue StandardError => e
|
|
196
|
-
puts "❌ Error fetching LM Studio models: #{e.message}"
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def format_bytes(bytes)
|
|
200
|
-
units = %w[B KB MB GB TB]
|
|
201
|
-
return "0 B" if bytes.zero?
|
|
202
|
-
|
|
203
|
-
exp = (Math.log(bytes) / Math.log(1024)).to_i
|
|
204
|
-
exp = [exp, units.length - 1].min
|
|
205
|
-
|
|
206
|
-
"%.1f %s" % [bytes.to_f / (1024**exp), units[exp]]
|
|
207
|
-
end
|
|
208
|
-
|
|
209
146
|
# :reek:TooManyStatements -- sequential terminal report: header, filtered model listing, summary
|
|
210
147
|
def show_rubyllm_models(positive_terms = nil, negative_terms = nil)
|
|
211
148
|
positive_terms, negative_terms = normalized_model_search_terms(positive_terms, negative_terms)
|
|
@@ -218,7 +155,7 @@ module AIA
|
|
|
218
155
|
|
|
219
156
|
# modality terms (e.g. "text_to_text") trigger capability checks; the rest
|
|
220
157
|
# are plain substring filters applied to the formatted entry string
|
|
221
|
-
modality_terms, substring_terms = positive_terms.partition { |q|
|
|
158
|
+
modality_terms, substring_terms = positive_terms.partition { |q| ModalityQuery.modality_term?(q) }
|
|
222
159
|
|
|
223
160
|
counter = 0
|
|
224
161
|
RubyLLM.models.all.each do |llm|
|
|
@@ -249,7 +186,7 @@ module AIA
|
|
|
249
186
|
end
|
|
250
187
|
|
|
251
188
|
def rubyllm_entry_visible?(llm, entry, modality_terms, substring_terms, negative_terms)
|
|
252
|
-
modality_terms.all? { |q| llm.modalities
|
|
189
|
+
modality_terms.all? { |q| ModalityQuery.matches?(llm.modalities, q) } &&
|
|
253
190
|
substring_terms.all? { |q| entry.include?(q) } &&
|
|
254
191
|
negative_terms.none? { |q| entry.downcase.include?(q) }
|
|
255
192
|
end
|
|
@@ -135,7 +135,7 @@ module AIA
|
|
|
135
135
|
def tools_by_server(connected, mcp_tools)
|
|
136
136
|
grouped = connected.to_h { |name| [name, []] }
|
|
137
137
|
mcp_tools.each do |tool|
|
|
138
|
-
server_name = tool
|
|
138
|
+
server_name = mcp_server_name_for(tool)
|
|
139
139
|
grouped[server_name] << tool if server_name && grouped.key?(server_name)
|
|
140
140
|
end
|
|
141
141
|
grouped
|
|
@@ -237,26 +237,25 @@ module AIA
|
|
|
237
237
|
end
|
|
238
238
|
end
|
|
239
239
|
|
|
240
|
-
#
|
|
241
|
-
#
|
|
242
|
-
# or other gems that use RubyLLM::MCP.add_client directly.
|
|
240
|
+
# The MCP tools aia connected at startup (shared by every robot), or the
|
|
241
|
+
# robot's own when no connection manager ran.
|
|
243
242
|
def all_mcp_tools
|
|
243
|
+
manager = AIA.mcp_manager
|
|
244
|
+
return manager.connected_tools if manager&.connected?
|
|
245
|
+
|
|
244
246
|
robot = AIA.client
|
|
245
|
-
if robot
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
end
|
|
247
|
+
robot = robot.chief if robot && !robot.respond_to?(:mcp_tools) && robot.respond_to?(:chief)
|
|
248
|
+
robot.respond_to?(:mcp_tools) ? Array(robot.mcp_tools) : []
|
|
249
|
+
end
|
|
249
250
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
# Name of the MCP server that offers +tool+, or nil for a local tool.
|
|
252
|
+
def mcp_server_name_for(tool)
|
|
253
|
+
by_server = AIA.mcp_manager&.tools_by_server || {}
|
|
254
|
+
owner, = by_server.find { |_, tools| tools.any? { it.equal?(tool) } }
|
|
255
|
+
return owner if owner
|
|
255
256
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return [] unless defined?(RubyLLM::MCP)
|
|
259
|
-
RubyLLM::MCP.clients.values.flat_map(&:tools)
|
|
257
|
+
robot = AIA.client
|
|
258
|
+
robot.respond_to?(:mcp_server_for) ? robot.mcp_server_for(tool)&.name : nil
|
|
260
259
|
end
|
|
261
260
|
end
|
|
262
261
|
end
|
|
@@ -68,25 +68,17 @@ module AIA
|
|
|
68
68
|
return report_skill_error("Error: /skill requires a skill name. Use /skills to list available skills.")
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
if path_based_id?(skill_name) && non_markdown_skill_file?(File.expand_path(skill_name))
|
|
72
|
+
return report_skill_error("Error: #{non_markdown_skill_message(skill_name)}.")
|
|
73
|
+
end
|
|
74
|
+
|
|
71
75
|
dir = aia_skills_dir
|
|
72
76
|
skill_dir = find_skill_dir(skill_name, dir)
|
|
73
77
|
unless skill_dir
|
|
74
78
|
return report_skill_error("Error: No skill matching '#{skill_name}' found in #{dir}. Use /skills to list available skills.")
|
|
75
79
|
end
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
skill_path = File.join(skill_dir, 'SKILL.md')
|
|
80
|
-
unless File.exist?(skill_path)
|
|
81
|
-
msg = if path_based_id?(skill_name)
|
|
82
|
-
"Error: No skill matching '#{skill_name}' found in #{dir}. Use /skills to list available skills."
|
|
83
|
-
else
|
|
84
|
-
"Error: Skill '#{File.basename(skill_dir)}' has no SKILL.md in #{dir}."
|
|
85
|
-
end
|
|
86
|
-
return report_skill_error(msg)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
File.read(skill_path)
|
|
81
|
+
read_skill_text(skill_name, skill_dir, dir)
|
|
90
82
|
end
|
|
91
83
|
|
|
92
84
|
desc "Paste content from the system clipboard"
|
|
@@ -131,6 +123,21 @@ module AIA
|
|
|
131
123
|
|
|
132
124
|
# Log and print a /skill error message; returns nil so callers can
|
|
133
125
|
# `return report_skill_error(msg)` from any guard.
|
|
126
|
+
# The text of a found skill: the file itself, or the folder's SKILL.md.
|
|
127
|
+
def read_skill_text(skill_name, skill_dir, dir)
|
|
128
|
+
return File.read(skill_dir) if File.file?(skill_dir)
|
|
129
|
+
|
|
130
|
+
skill_path = File.join(skill_dir, 'SKILL.md')
|
|
131
|
+
return File.read(skill_path) if File.exist?(skill_path)
|
|
132
|
+
|
|
133
|
+
msg = if path_based_id?(skill_name)
|
|
134
|
+
"Error: No skill matching '#{skill_name}' found in #{dir}. Use /skills to list available skills."
|
|
135
|
+
else
|
|
136
|
+
"Error: Skill '#{File.basename(skill_dir)}' has no SKILL.md in #{dir}."
|
|
137
|
+
end
|
|
138
|
+
report_skill_error(msg)
|
|
139
|
+
end
|
|
140
|
+
|
|
134
141
|
def report_skill_error(msg)
|
|
135
142
|
AIA::LoggerManager.aia_logger.error(msg)
|
|
136
143
|
puts msg
|
|
@@ -142,7 +149,7 @@ module AIA
|
|
|
142
149
|
skills = AIA.respond_to?(:config) ? AIA.config&.skills : nil
|
|
143
150
|
return skills.dir if skills.respond_to?(:dir) && skills.dir
|
|
144
151
|
|
|
145
|
-
ENV.fetch('AIA_SKILLS__DIR'
|
|
152
|
+
ENV.fetch('AIA_SKILLS__DIR') { File.expand_path('~/.prompts/skills') }
|
|
146
153
|
end
|
|
147
154
|
|
|
148
155
|
def terminal_width
|
data/lib/aia/fact_asserter.rb
CHANGED
|
@@ -10,10 +10,10 @@ module AIA
|
|
|
10
10
|
class FactAsserter
|
|
11
11
|
# Extract the tool's name as a non-nil String.
|
|
12
12
|
#
|
|
13
|
-
# @param tool [Object]
|
|
14
|
-
# @return [String]
|
|
13
|
+
# @param tool [Object] a tool instance or RubyLLM::Tool class
|
|
14
|
+
# @return [String] the name the model calls it by (see ToolIntrospection.tool_name)
|
|
15
15
|
def tool_name(tool)
|
|
16
|
-
String(
|
|
16
|
+
String(ToolIntrospection.tool_name(tool)).strip
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# Extract the tool's description as a non-nil String.
|
data/lib/aia/history_transfer.rb
CHANGED
|
@@ -4,24 +4,68 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Stateless module for transferring conversation history between robots.
|
|
6
6
|
# Extracted from RobotFactory to isolate the history transfer concern.
|
|
7
|
+
#
|
|
8
|
+
# Both arguments may be a single RobotLab::Robot or a RobotLab::Network (the
|
|
9
|
+
# interactive session always runs a crew). History is read from the old
|
|
10
|
+
# runnable's chief — the robot the user has been talking to — and carried to
|
|
11
|
+
# every member of the new crew.
|
|
7
12
|
|
|
8
13
|
module AIA
|
|
9
14
|
module HistoryTransfer
|
|
15
|
+
MODES = %i[clean replay summarize].freeze
|
|
16
|
+
DEFAULT_MODE = :summarize
|
|
17
|
+
|
|
10
18
|
module_function
|
|
11
19
|
|
|
20
|
+
# The history mode configured for model switches (config.model_switch_history),
|
|
21
|
+
# falling back to DEFAULT_MODE when it is unset or not a known mode.
|
|
22
|
+
#
|
|
23
|
+
# @param config [AIA::Config, nil]
|
|
24
|
+
# @return [Symbol] one of MODES
|
|
25
|
+
def mode_for(config)
|
|
26
|
+
value = config.respond_to?(:model_switch_history) ? config.model_switch_history : nil
|
|
27
|
+
mode = value.to_s.strip.downcase.to_sym
|
|
28
|
+
MODES.include?(mode) ? mode : DEFAULT_MODE
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# The user/assistant turns of +runnable+'s chief, oldest first. System
|
|
32
|
+
# prompts and tool traffic are left out: they belong to the old robot.
|
|
33
|
+
#
|
|
34
|
+
# @param runnable [RobotLab::Robot, RobotLab::Network, nil]
|
|
35
|
+
# @return [Array<RubyLLM::Message>]
|
|
36
|
+
def conversation(runnable)
|
|
37
|
+
chief = chief_of(runnable)
|
|
38
|
+
return [] unless chief.respond_to?(:messages)
|
|
39
|
+
|
|
40
|
+
Array(chief.messages).select do |msg|
|
|
41
|
+
msg.respond_to?(:role) && %i[user assistant].include?(msg.role) && !msg.content.to_s.strip.empty?
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# The robot whose conversation the user sees: a network's chief, or the robot itself.
|
|
46
|
+
def chief_of(runnable)
|
|
47
|
+
runnable.respond_to?(:chief) ? runnable.chief : runnable
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# The robots that should receive the transferred history.
|
|
51
|
+
#
|
|
52
|
+
# @param runnable [RobotLab::Robot, RobotLab::Network]
|
|
53
|
+
# @return [Array<RobotLab::Robot>]
|
|
54
|
+
def recipients(runnable)
|
|
55
|
+
runnable.respond_to?(:crew) ? Array(runnable.crew) : [runnable]
|
|
56
|
+
end
|
|
57
|
+
|
|
12
58
|
# Replay conversation history from an old robot to a new one.
|
|
13
59
|
#
|
|
14
|
-
# Performance: O(N) API calls where N = number of user
|
|
15
|
-
# Each user message triggers a full LLM round-trip on the new
|
|
16
|
-
#
|
|
17
|
-
# For a cloud model (~2-5s/turn), expect 20-50s. MCP/tools are disabled
|
|
18
|
-
# during replay to avoid side effects.
|
|
60
|
+
# Performance: O(N) API calls per recipient, where N = number of user
|
|
61
|
+
# messages. Each user message triggers a full LLM round-trip on the new
|
|
62
|
+
# model. MCP/tools are disabled during replay to avoid side effects.
|
|
19
63
|
def replay_history(old_robot, new_robot)
|
|
20
|
-
|
|
64
|
+
user_turns = conversation(old_robot).select { it.role == :user }
|
|
65
|
+
return if user_turns.empty?
|
|
21
66
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
new_robot.run(msg.content, mcp: :none, tools: :none)
|
|
67
|
+
recipients(new_robot).each do |robot|
|
|
68
|
+
user_turns.each { robot.run(it.content.to_s, mcp: :none, tools: :none) }
|
|
25
69
|
end
|
|
26
70
|
rescue StandardError => e
|
|
27
71
|
$stderr.puts "Warning: History replay failed: #{e.message}"
|
|
@@ -29,25 +73,21 @@ module AIA
|
|
|
29
73
|
|
|
30
74
|
# Summarize conversation history and inject into new robot.
|
|
31
75
|
#
|
|
32
|
-
# Performance:
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
# Faster than :replay for conversations with >2 turns, but loses
|
|
36
|
-
# per-turn context fidelity. Total latency ~4-10s for cloud models.
|
|
76
|
+
# Performance: one summary call on the old model, plus one injection call
|
|
77
|
+
# per recipient, regardless of conversation length. Faster than :replay
|
|
78
|
+
# for conversations with >2 turns, but loses per-turn context fidelity.
|
|
37
79
|
def summarize_history(old_robot, new_robot)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
summary_lines = old_robot.messages.map do |msg|
|
|
41
|
-
"#{msg.role}: #{msg.content}" if msg.respond_to?(:role)
|
|
42
|
-
end.compact
|
|
80
|
+
turns = conversation(old_robot)
|
|
81
|
+
return if turns.empty?
|
|
43
82
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
summary = old_robot.run(summary_prompt, mcp: :none, tools: :none)
|
|
83
|
+
transcript = turns.map { "#{it.role}: #{it.content}" }.join("\n")
|
|
84
|
+
summary = chief_of(old_robot).run("Summarize this conversation concisely for context transfer:\n#{transcript}",
|
|
85
|
+
mcp: :none, tools: :none)
|
|
48
86
|
content = summary.respond_to?(:reply) ? summary.reply : summary.to_s
|
|
49
87
|
|
|
50
|
-
new_robot.
|
|
88
|
+
recipients(new_robot).each do |robot|
|
|
89
|
+
robot.run("Context from previous conversation: #{content}", mcp: :none, tools: :none)
|
|
90
|
+
end
|
|
51
91
|
rescue StandardError => e
|
|
52
92
|
$stderr.puts "Warning: History summarization failed: #{e.message}"
|
|
53
93
|
end
|