aia 1.1.1 → 2.0.0.0.pre.alpha
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/.envrc +5 -1
- data/.loki +231 -0
- data/.quality/flay_baseline.txt +1 -0
- data/.quality/flog_baseline.txt +29 -0
- data/.quality/reek_baseline.txt +80 -0
- data/.rubocop.yml +116 -0
- data/.version +1 -1
- data/CHANGELOG.md +259 -50
- data/IMPLEMENTATION_PLAN.md +506 -0
- data/README.md +266 -238
- data/Rakefile +118 -5
- data/architecture_review.md +314 -0
- data/bin/aia +16 -0
- data/docs/AGENTS.md +40 -0
- data/docs/advanced-prompting.md +67 -3
- data/docs/cli-reference.md +312 -56
- data/docs/configuration.md +130 -19
- data/docs/contributing.md +56 -2
- data/docs/directives-reference.md +593 -78
- data/docs/faq.md +85 -3
- data/docs/guides/available-models.md +1 -1
- data/docs/guides/basic-usage.md +6 -6
- data/docs/guides/chat.md +40 -16
- data/docs/guides/crew.md +239 -0
- data/docs/guides/executable-prompts.md +1 -1
- data/docs/guides/index.md +1 -0
- data/docs/guides/models.md +15 -0
- data/docs/index.md +29 -2
- data/docs/installation.md +44 -17
- data/docs/mcp-integration.md +40 -0
- data/docs/prompt_management.md +85 -86
- data/docs/security.md +47 -0
- data/docs/special_projects_guide.md +386 -0
- data/docs/tools-and-mcp-examples.md +23 -0
- data/docs/workflows-and-pipelines.md +84 -7
- data/examples/.gitignore +1 -0
- data/examples/00_setup_aia.sh +27 -44
- data/examples/11_multi_model.sh +4 -14
- data/examples/12_token_usage.sh +3 -12
- data/examples/18_tools.sh +10 -2
- data/examples/22_chat_mode.sh +0 -10
- data/examples/23_verify.sh +139 -0
- data/examples/24_decompose.sh +139 -0
- data/examples/25_spawn.sh +139 -0
- data/examples/26_debate.sh +97 -0
- data/examples/27_mention_routing.sh +157 -0
- data/examples/28_model_switching.sh +106 -0
- data/examples/29_agent_harness.sh +177 -0
- data/examples/README.md +65 -0
- data/examples/advanced_multi_robot_capabilities_without_examples.md +106 -0
- data/examples/aia_config.yml +1 -1
- data/examples/aia_config_orchestrator.yml +45 -0
- data/examples/common.sh +18 -6
- data/examples/context/tech_stack.md +2 -2
- data/examples/prompts_dir/roles/orchestrator.md +21 -0
- data/examples/requirements/sinatra_taskflow_app.md +139 -0
- data/examples/rules/01_classify_ruby.rb +16 -0
- data/examples/rules/02_prefer_claude_for_code.rb +19 -0
- data/examples/rules/03_gate_prompt_length.rb +19 -0
- data/examples/rules/04_tool_selection.rb +41 -0
- data/examples/rules/README.md +30 -0
- data/examples/run_all.sh +48 -15
- data/examples/tools/word_count_tool.rb +1 -1
- data/lib/AGENTS.md +57 -0
- data/lib/aia/chat_loop.rb +304 -164
- data/lib/aia/config/cli_parser.rb +174 -111
- data/lib/aia/config/defaults.yml +62 -33
- data/lib/aia/config/mcp_parser.rb +39 -46
- data/lib/aia/config/model_spec.rb +34 -2
- data/lib/aia/config/validator.rb +108 -142
- data/lib/aia/config.rb +110 -145
- data/lib/aia/content_extractor.rb +153 -0
- data/lib/aia/cost_calculator.rb +38 -0
- data/lib/aia/crew.rb +164 -0
- data/lib/aia/debate_handler.rb +166 -0
- data/lib/aia/delegate_handler.rb +112 -0
- data/lib/aia/directive.rb +33 -18
- data/lib/aia/directive_processor.rb +16 -7
- data/lib/aia/directives/configuration_directives.rb +160 -20
- data/lib/aia/directives/context_directives.rb +38 -26
- data/lib/aia/directives/execution_directives.rb +136 -4
- data/lib/aia/directives/model_directives.rb +76 -34
- data/lib/aia/directives/trakflow_directives.rb +44 -0
- data/lib/aia/directives/utility_directives.rb +203 -6
- data/lib/aia/directives/web_and_file_directives.rb +96 -60
- data/lib/aia/errors.rb +15 -0
- data/lib/aia/fact_asserter.rb +27 -0
- data/lib/aia/fzf.rb +9 -31
- data/lib/aia/handler_context.rb +17 -0
- data/lib/aia/handler_protocol.rb +19 -0
- data/lib/aia/history_transfer.rb +55 -0
- data/lib/aia/input_collector.rb +3 -3
- data/lib/aia/layered_orchestrator.rb +448 -0
- data/lib/aia/logger.rb +24 -4
- data/lib/aia/mcp_config_normalizer.rb +35 -0
- data/lib/aia/mcp_connection_manager.rb +305 -0
- data/lib/aia/mcp_discovery.rb +44 -0
- data/lib/aia/mcp_grouper.rb +33 -0
- data/lib/aia/mcp_utility.rb +57 -0
- data/lib/aia/mention_router.rb +260 -0
- data/lib/aia/model_alias_registry.rb +97 -0
- data/lib/aia/model_switch_handler.rb +100 -0
- data/lib/aia/network_builder.rb +155 -0
- data/lib/aia/network_memory_manager.rb +55 -0
- data/lib/aia/patches/ruby_llm_streaming_error.rb +43 -0
- data/lib/aia/patches/ruby_llm_tool_error.rb +96 -0
- data/lib/aia/pipeline_orchestrator.rb +262 -0
- data/lib/aia/plugin_loader.rb +170 -0
- data/lib/aia/plugin_monitor.rb +208 -0
- data/lib/aia/prompt_decomposer.rb +157 -0
- data/lib/aia/prompt_handler.rb +19 -39
- data/lib/aia/robot_builder.rb +51 -0
- data/lib/aia/robot_factory.rb +334 -0
- data/lib/aia/robot_namer.rb +116 -0
- data/lib/aia/session.rb +83 -17
- data/lib/aia/session_tracker.rb +209 -0
- data/lib/aia/similarity_scorer.rb +39 -0
- data/lib/aia/skill_utils.rb +105 -1
- data/lib/aia/spawn_handler.rb +129 -0
- data/lib/aia/spawn_spec_parser.rb +65 -0
- data/lib/aia/special_mode_handler.rb +302 -0
- data/lib/aia/startup_coordinator.rb +150 -0
- data/lib/aia/streaming_runner.rb +169 -0
- data/lib/aia/system_prompt_assembler.rb +88 -0
- data/lib/aia/task_coordinator.rb +202 -0
- data/lib/aia/task_decomposer.rb +57 -0
- data/lib/aia/task_executor.rb +51 -0
- data/lib/aia/tfidf_math.rb +27 -0
- data/lib/aia/tool_filter/tfidf.rb +116 -0
- data/lib/aia/tool_filter/wordnet_expander.rb +127 -0
- data/lib/aia/tool_filter.rb +82 -0
- data/lib/aia/tool_filter_registry.rb +30 -0
- data/lib/aia/tool_filter_strategy.rb +143 -0
- data/lib/aia/tool_loader.rb +210 -0
- data/lib/aia/tool_utility.rb +30 -0
- data/lib/aia/tools/delegate_to_foreman_tool.rb +70 -0
- data/lib/aia/tools/recruit_robot_tool.rb +60 -0
- data/lib/aia/tools/reskill_robot_tool.rb +44 -0
- data/lib/aia/tools/task_board_tool.rb +114 -0
- data/lib/aia/trakflow_bridge.rb +173 -0
- data/lib/aia/turn_state.rb +94 -0
- data/lib/aia/ui_presenter.rb +166 -198
- data/lib/aia/utility.rb +134 -87
- data/lib/aia/{history_manager.rb → variable_input_collector.rb} +8 -9
- data/lib/aia/verification_network.rb +58 -0
- data/lib/aia.rb +108 -63
- data/mkdocs.yml +1 -0
- metadata +179 -56
- data/justfile +0 -215
- data/lib/aia/adapter/chat_execution.rb +0 -242
- data/lib/aia/adapter/error_handler.rb +0 -68
- data/lib/aia/adapter/gem_activator.rb +0 -57
- data/lib/aia/adapter/mcp_connector.rb +0 -274
- data/lib/aia/adapter/modality_handlers.rb +0 -167
- data/lib/aia/adapter/model_registry.rb +0 -81
- data/lib/aia/adapter/multi_model_chat.rb +0 -218
- data/lib/aia/adapter/provider_configurator.rb +0 -59
- data/lib/aia/adapter/tool_filter.rb +0 -85
- data/lib/aia/adapter/tool_loader.rb +0 -90
- data/lib/aia/chat_processor_service.rb +0 -178
- data/lib/aia/prompt_pipeline.rb +0 -183
- data/lib/aia/ruby_llm_adapter.rb +0 -95
- data/lib/extensions/openstruct_merge.rb +0 -48
- data/lib/extensions/ruby_llm/.irbrc +0 -56
- data/lib/extensions/ruby_llm/modalities.rb +0 -36
- data/lib/extensions/ruby_llm/provider_fix.rb +0 -79
- data/lib/refinements/string.rb +0 -16
- data/main.just +0 -76
data/examples/run_all.sh
CHANGED
|
@@ -9,15 +9,18 @@
|
|
|
9
9
|
# differences (missing sections, crashes, changed command output).
|
|
10
10
|
#
|
|
11
11
|
# What it skips:
|
|
12
|
-
# - 00_setup_aia.sh
|
|
13
|
-
# - 15_parameters.sh
|
|
14
|
-
# - 20_mcp_servers.sh
|
|
15
|
-
# - 22_chat_mode.sh
|
|
16
|
-
#
|
|
12
|
+
# - 00_setup_aia.sh — run manually first (pulls models, writes config)
|
|
13
|
+
# - 15_parameters.sh — Part 2 prompts interactively for a required param
|
|
14
|
+
# - 20_mcp_servers.sh — requires Node.js/npx + MCP filesystem server
|
|
15
|
+
# - 22_chat_mode.sh — interactive chat (Parts 1-4 use expect; Part 5
|
|
16
|
+
# opens a live session)
|
|
17
|
+
# - 29_agent_harness.sh — 3-tier orchestration (10-20 min runtime)
|
|
18
|
+
#
|
|
19
|
+
# Scripts 23-28 run with BATCH_MODE=true, which skips their interactive
|
|
20
|
+
# "your turn" sections but still executes the automated expect-based parts.
|
|
17
21
|
#
|
|
18
22
|
# Prerequisites:
|
|
19
|
-
# - Run 00_setup_aia.sh first
|
|
20
|
-
# - Ollama running with qwen3 model available
|
|
23
|
+
# - Run 00_setup_aia.sh first (OPENAI_API_KEY must be set)
|
|
21
24
|
#
|
|
22
25
|
# Usage:
|
|
23
26
|
# cd examples
|
|
@@ -61,14 +64,17 @@ Comparing runs:
|
|
|
61
64
|
diff output/run_PREV.log output/run_LATEST.log
|
|
62
65
|
|
|
63
66
|
Skipped scripts (require manual or interactive setup):
|
|
64
|
-
00_setup_aia.sh
|
|
65
|
-
15_parameters.sh
|
|
66
|
-
20_mcp_servers.sh
|
|
67
|
-
22_chat_mode.sh
|
|
67
|
+
00_setup_aia.sh — run manually first (pulls models, writes config)
|
|
68
|
+
15_parameters.sh — Part 2 prompts interactively for a required param
|
|
69
|
+
20_mcp_servers.sh — requires Node.js/npx + MCP filesystem server
|
|
70
|
+
22_chat_mode.sh — interactive chat session
|
|
71
|
+
29_agent_harness.sh — 3-tier orchestration (10-20 min runtime)
|
|
72
|
+
|
|
73
|
+
Scripts 23-28 run with BATCH_MODE=true, which skips their interactive
|
|
74
|
+
"your turn" sections but still runs the automated expect-based parts.
|
|
68
75
|
|
|
69
76
|
Prerequisites:
|
|
70
|
-
1. Run 00_setup_aia.sh first
|
|
71
|
-
2. Ollama running with the qwen3 model available
|
|
77
|
+
1. Run 00_setup_aia.sh first (OPENAI_API_KEY must be set)
|
|
72
78
|
|
|
73
79
|
Exit codes:
|
|
74
80
|
0 All scripts completed (some may have non-fatal warnings)
|
|
@@ -129,12 +135,20 @@ SCRIPTS=(
|
|
|
129
135
|
# 20_mcp_servers.sh — skipped: requires npx + MCP server
|
|
130
136
|
21_executable_prompts.sh
|
|
131
137
|
# 22_chat_mode.sh — skipped: interactive chat session
|
|
138
|
+
23_verify.sh
|
|
139
|
+
24_decompose.sh
|
|
140
|
+
25_spawn.sh
|
|
141
|
+
26_debate.sh
|
|
142
|
+
27_mention_routing.sh
|
|
143
|
+
28_model_switching.sh
|
|
144
|
+
# 29_agent_harness.sh — skipped: 3-tier orchestration, 10-20 min runtime
|
|
132
145
|
)
|
|
133
146
|
|
|
134
147
|
SKIPPED=(
|
|
135
|
-
"15_parameters.sh
|
|
148
|
+
"15_parameters.sh (interactive parameter input)"
|
|
136
149
|
"20_mcp_servers.sh (requires Node.js/npx + MCP server)"
|
|
137
|
-
"22_chat_mode.sh
|
|
150
|
+
"22_chat_mode.sh (interactive chat session)"
|
|
151
|
+
"29_agent_harness.sh (3-tier orchestration, 10-20 min runtime)"
|
|
138
152
|
)
|
|
139
153
|
|
|
140
154
|
# --- Set up output ---
|
|
@@ -200,6 +214,16 @@ run_script() {
|
|
|
200
214
|
return ${status}
|
|
201
215
|
}
|
|
202
216
|
|
|
217
|
+
# Scripts that require BATCH_MODE=true to skip their interactive sessions
|
|
218
|
+
BATCH_MODE_SCRIPTS=(
|
|
219
|
+
23_verify.sh
|
|
220
|
+
24_decompose.sh
|
|
221
|
+
25_spawn.sh
|
|
222
|
+
26_debate.sh
|
|
223
|
+
27_mention_routing.sh
|
|
224
|
+
28_model_switching.sh
|
|
225
|
+
)
|
|
226
|
+
|
|
203
227
|
# --- Main ---
|
|
204
228
|
|
|
205
229
|
main() {
|
|
@@ -214,6 +238,13 @@ main() {
|
|
|
214
238
|
local script="${SCRIPTS[$i]}"
|
|
215
239
|
local index=$((i + 1))
|
|
216
240
|
|
|
241
|
+
# Enable batch mode for scripts with interactive "your turn" sessions
|
|
242
|
+
if printf '%s\n' "${BATCH_MODE_SCRIPTS[@]}" | grep -qx "${script}"; then
|
|
243
|
+
export BATCH_MODE=true
|
|
244
|
+
else
|
|
245
|
+
unset BATCH_MODE
|
|
246
|
+
fi
|
|
247
|
+
|
|
217
248
|
if run_script "${script}" "${index}" "${total}"; then
|
|
218
249
|
((passed++))
|
|
219
250
|
else
|
|
@@ -222,6 +253,8 @@ main() {
|
|
|
222
253
|
fi
|
|
223
254
|
done
|
|
224
255
|
|
|
256
|
+
unset BATCH_MODE
|
|
257
|
+
|
|
225
258
|
echo "================================================================================"
|
|
226
259
|
echo " Summary"
|
|
227
260
|
echo "================================================================================"
|
|
@@ -6,7 +6,7 @@ require 'ruby_llm/tool'
|
|
|
6
6
|
class WordCountTool < RubyLLM::Tool
|
|
7
7
|
def self.name = 'word_count'
|
|
8
8
|
|
|
9
|
-
description <<~
|
|
9
|
+
description <<~DESC
|
|
10
10
|
Count words, characters, lines, and sentences in a given text.
|
|
11
11
|
Useful for text analysis and content length checks.
|
|
12
12
|
DESC
|
data/lib/AGENTS.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
### Local Agent Context: lib
|
|
2
|
+
|
|
3
|
+
## Setup & Commands
|
|
4
|
+
|
|
5
|
+
- To run the AIA application, use: `ruby lib/aia.rb`
|
|
6
|
+
- Set up configurations by editing `lib/aia/config/defaults.yml` or using environment variables prefixed with `AIA_`.
|
|
7
|
+
|
|
8
|
+
## Code Style & Patterns
|
|
9
|
+
|
|
10
|
+
- Use single source of truth for configs: defined in `lib/aia/config/defaults.yml`
|
|
11
|
+
- CLI flags are mapped to nested config locations using the `CLI_TO_NESTED_MAP` hash within `aia/config.rb`.
|
|
12
|
+
- Initialize new components within the AIA module using `AIA` namespace, e.g., `AIA::ChatLoop`.
|
|
13
|
+
|
|
14
|
+
## Implementation Details
|
|
15
|
+
|
|
16
|
+
### Entry Point - `lib/aia.rb`
|
|
17
|
+
- Main application entry starts by loading essential modules and patches.
|
|
18
|
+
- Use `AIA.run` as the entrypoint method which initializes configuration, validates it, and starts the session.
|
|
19
|
+
|
|
20
|
+
### Configuring AIA - `lib/aia/config.rb`
|
|
21
|
+
- Configurations are merged from sources in priority: defaults => user config => ENV => CLI.
|
|
22
|
+
- Use `Config.setup(cli_overrides)` to initialize configuration with CLI argument overrides.
|
|
23
|
+
- Ensure `lib/aia/config/model_spec.rb` is loaded for model specification handling.
|
|
24
|
+
- Top-level config sections include: `service`, `llm`, `prompts`, `roles`, `skills`, `output`, `audio`, `image`, `embedding`, `tools`, `flags`, `registry`, `paths`, `logger`, `rules`, `concurrency`, `tool_filter`.
|
|
25
|
+
- `roles` and `skills` are proper config sections; `AIA.config.skills.dir` returns the resolved skills directory.
|
|
26
|
+
|
|
27
|
+
### Directive System - `lib/aia/directive.rb` and `lib/aia/directives/`
|
|
28
|
+
- `AIA::Directive` (base class) inherits from `PM::Directive` and adds AIA-specific concerns.
|
|
29
|
+
- `DIRECTIVE_PREFIX = '/'` — all chat directives use a single slash, not `//`.
|
|
30
|
+
- The base class provides `parse_search_terms(args)` as a private instance method available to all directive subclasses. It splits args into `[positive_terms, negative_terms]`: bare terms and `+prefix` are positive (AND); `-`, `~`, or `!` prefix marks AND NOT terms.
|
|
31
|
+
- Directive subclasses live in `lib/aia/directives/`:
|
|
32
|
+
- `web_and_file_directives.rb` — `/skill`, `/skills`, `/webpage`, `/paste`
|
|
33
|
+
- `model_directives.rb` — `/llms` (and aliases), `/compare`
|
|
34
|
+
- `context_directives.rb`, `execution_directives.rb`, `navigation_directives.rb`, `special_mode_directives.rb`, `config_directives.rb`
|
|
35
|
+
|
|
36
|
+
### `/skill` and `/skills` Directives - `lib/aia/directives/web_and_file_directives.rb`
|
|
37
|
+
- Skills directory resolves via `aia_skills_dir`: `AIA.config.skills.dir` → `$AIA_SKILLS__DIR` → `~/.prompts/skills`.
|
|
38
|
+
- A skill is a subdirectory containing a `SKILL.md` file with YAML front matter (`name`, `description`).
|
|
39
|
+
- `/skill <id>` reads and returns the full `SKILL.md` content. On error, prints to stdout and returns `nil` (nothing injected into the AI prompt).
|
|
40
|
+
- `/skills [terms...]` prints `skill_id: name\n description\n\n` to stdout for each matching skill; returns `nil`. Supports AND logic for positive terms and AND NOT for `-`/`~`/`!`-prefixed terms.
|
|
41
|
+
|
|
42
|
+
### `/llms` Directive - `lib/aia/directives/model_directives.rb`
|
|
43
|
+
- `available_models` (aliased as `/llms`, `/models`, etc.) parses args with `parse_search_terms` into `positive_terms` and `negative_terms`.
|
|
44
|
+
- Passes both to `show_rubyllm_models(positive_terms, negative_terms)`, `show_ollama_models(api_base, positive_terms, negative_terms)`, and `show_lms_models(api_base, positive_terms, negative_terms)`.
|
|
45
|
+
- Negative terms apply AND NOT filtering: models whose entry string contains any negative term are excluded.
|
|
46
|
+
|
|
47
|
+
### Chat Loop Operation - `lib/aia/chat_loop.rb`
|
|
48
|
+
- `AIA::ChatLoop` handles the interactive chat REPL loop.
|
|
49
|
+
- Initialize the chat loop with components: `robot`, `ui_presenter`, `directive_processor`.
|
|
50
|
+
- Start the chat loop with `ChatLoop#start`, which sets up the session, processes context, and runs the interactive loop.
|
|
51
|
+
|
|
52
|
+
### Error Handling
|
|
53
|
+
- Use `AIA.debug_warn(msg, exc: nil)` to log warnings with optional debug backtrace.
|
|
54
|
+
- Catch `AIA::ConfigurationError` and `AIA::Error` in the run method to handle config and general errors gracefully.
|
|
55
|
+
|
|
56
|
+
### Resetting State
|
|
57
|
+
- `AIA.reset!` reinitializes key components, suitable for stateful parts (e.g., `config`, `client`).
|