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.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc +5 -1
  3. data/.loki +231 -0
  4. data/.quality/flay_baseline.txt +1 -0
  5. data/.quality/flog_baseline.txt +29 -0
  6. data/.quality/reek_baseline.txt +80 -0
  7. data/.rubocop.yml +116 -0
  8. data/.version +1 -1
  9. data/CHANGELOG.md +259 -50
  10. data/IMPLEMENTATION_PLAN.md +506 -0
  11. data/README.md +266 -238
  12. data/Rakefile +118 -5
  13. data/architecture_review.md +314 -0
  14. data/bin/aia +16 -0
  15. data/docs/AGENTS.md +40 -0
  16. data/docs/advanced-prompting.md +67 -3
  17. data/docs/cli-reference.md +312 -56
  18. data/docs/configuration.md +130 -19
  19. data/docs/contributing.md +56 -2
  20. data/docs/directives-reference.md +593 -78
  21. data/docs/faq.md +85 -3
  22. data/docs/guides/available-models.md +1 -1
  23. data/docs/guides/basic-usage.md +6 -6
  24. data/docs/guides/chat.md +40 -16
  25. data/docs/guides/crew.md +239 -0
  26. data/docs/guides/executable-prompts.md +1 -1
  27. data/docs/guides/index.md +1 -0
  28. data/docs/guides/models.md +15 -0
  29. data/docs/index.md +29 -2
  30. data/docs/installation.md +44 -17
  31. data/docs/mcp-integration.md +40 -0
  32. data/docs/prompt_management.md +85 -86
  33. data/docs/security.md +47 -0
  34. data/docs/special_projects_guide.md +386 -0
  35. data/docs/tools-and-mcp-examples.md +23 -0
  36. data/docs/workflows-and-pipelines.md +84 -7
  37. data/examples/.gitignore +1 -0
  38. data/examples/00_setup_aia.sh +27 -44
  39. data/examples/11_multi_model.sh +4 -14
  40. data/examples/12_token_usage.sh +3 -12
  41. data/examples/18_tools.sh +10 -2
  42. data/examples/22_chat_mode.sh +0 -10
  43. data/examples/23_verify.sh +139 -0
  44. data/examples/24_decompose.sh +139 -0
  45. data/examples/25_spawn.sh +139 -0
  46. data/examples/26_debate.sh +97 -0
  47. data/examples/27_mention_routing.sh +157 -0
  48. data/examples/28_model_switching.sh +106 -0
  49. data/examples/29_agent_harness.sh +177 -0
  50. data/examples/README.md +65 -0
  51. data/examples/advanced_multi_robot_capabilities_without_examples.md +106 -0
  52. data/examples/aia_config.yml +1 -1
  53. data/examples/aia_config_orchestrator.yml +45 -0
  54. data/examples/common.sh +18 -6
  55. data/examples/context/tech_stack.md +2 -2
  56. data/examples/prompts_dir/roles/orchestrator.md +21 -0
  57. data/examples/requirements/sinatra_taskflow_app.md +139 -0
  58. data/examples/rules/01_classify_ruby.rb +16 -0
  59. data/examples/rules/02_prefer_claude_for_code.rb +19 -0
  60. data/examples/rules/03_gate_prompt_length.rb +19 -0
  61. data/examples/rules/04_tool_selection.rb +41 -0
  62. data/examples/rules/README.md +30 -0
  63. data/examples/run_all.sh +48 -15
  64. data/examples/tools/word_count_tool.rb +1 -1
  65. data/lib/AGENTS.md +57 -0
  66. data/lib/aia/chat_loop.rb +304 -164
  67. data/lib/aia/config/cli_parser.rb +174 -111
  68. data/lib/aia/config/defaults.yml +62 -33
  69. data/lib/aia/config/mcp_parser.rb +39 -46
  70. data/lib/aia/config/model_spec.rb +34 -2
  71. data/lib/aia/config/validator.rb +108 -142
  72. data/lib/aia/config.rb +110 -145
  73. data/lib/aia/content_extractor.rb +153 -0
  74. data/lib/aia/cost_calculator.rb +38 -0
  75. data/lib/aia/crew.rb +164 -0
  76. data/lib/aia/debate_handler.rb +166 -0
  77. data/lib/aia/delegate_handler.rb +112 -0
  78. data/lib/aia/directive.rb +33 -18
  79. data/lib/aia/directive_processor.rb +16 -7
  80. data/lib/aia/directives/configuration_directives.rb +160 -20
  81. data/lib/aia/directives/context_directives.rb +38 -26
  82. data/lib/aia/directives/execution_directives.rb +136 -4
  83. data/lib/aia/directives/model_directives.rb +76 -34
  84. data/lib/aia/directives/trakflow_directives.rb +44 -0
  85. data/lib/aia/directives/utility_directives.rb +203 -6
  86. data/lib/aia/directives/web_and_file_directives.rb +96 -60
  87. data/lib/aia/errors.rb +15 -0
  88. data/lib/aia/fact_asserter.rb +27 -0
  89. data/lib/aia/fzf.rb +9 -31
  90. data/lib/aia/handler_context.rb +17 -0
  91. data/lib/aia/handler_protocol.rb +19 -0
  92. data/lib/aia/history_transfer.rb +55 -0
  93. data/lib/aia/input_collector.rb +3 -3
  94. data/lib/aia/layered_orchestrator.rb +448 -0
  95. data/lib/aia/logger.rb +24 -4
  96. data/lib/aia/mcp_config_normalizer.rb +35 -0
  97. data/lib/aia/mcp_connection_manager.rb +305 -0
  98. data/lib/aia/mcp_discovery.rb +44 -0
  99. data/lib/aia/mcp_grouper.rb +33 -0
  100. data/lib/aia/mcp_utility.rb +57 -0
  101. data/lib/aia/mention_router.rb +260 -0
  102. data/lib/aia/model_alias_registry.rb +97 -0
  103. data/lib/aia/model_switch_handler.rb +100 -0
  104. data/lib/aia/network_builder.rb +155 -0
  105. data/lib/aia/network_memory_manager.rb +55 -0
  106. data/lib/aia/patches/ruby_llm_streaming_error.rb +43 -0
  107. data/lib/aia/patches/ruby_llm_tool_error.rb +96 -0
  108. data/lib/aia/pipeline_orchestrator.rb +262 -0
  109. data/lib/aia/plugin_loader.rb +170 -0
  110. data/lib/aia/plugin_monitor.rb +208 -0
  111. data/lib/aia/prompt_decomposer.rb +157 -0
  112. data/lib/aia/prompt_handler.rb +19 -39
  113. data/lib/aia/robot_builder.rb +51 -0
  114. data/lib/aia/robot_factory.rb +334 -0
  115. data/lib/aia/robot_namer.rb +116 -0
  116. data/lib/aia/session.rb +83 -17
  117. data/lib/aia/session_tracker.rb +209 -0
  118. data/lib/aia/similarity_scorer.rb +39 -0
  119. data/lib/aia/skill_utils.rb +105 -1
  120. data/lib/aia/spawn_handler.rb +129 -0
  121. data/lib/aia/spawn_spec_parser.rb +65 -0
  122. data/lib/aia/special_mode_handler.rb +302 -0
  123. data/lib/aia/startup_coordinator.rb +150 -0
  124. data/lib/aia/streaming_runner.rb +169 -0
  125. data/lib/aia/system_prompt_assembler.rb +88 -0
  126. data/lib/aia/task_coordinator.rb +202 -0
  127. data/lib/aia/task_decomposer.rb +57 -0
  128. data/lib/aia/task_executor.rb +51 -0
  129. data/lib/aia/tfidf_math.rb +27 -0
  130. data/lib/aia/tool_filter/tfidf.rb +116 -0
  131. data/lib/aia/tool_filter/wordnet_expander.rb +127 -0
  132. data/lib/aia/tool_filter.rb +82 -0
  133. data/lib/aia/tool_filter_registry.rb +30 -0
  134. data/lib/aia/tool_filter_strategy.rb +143 -0
  135. data/lib/aia/tool_loader.rb +210 -0
  136. data/lib/aia/tool_utility.rb +30 -0
  137. data/lib/aia/tools/delegate_to_foreman_tool.rb +70 -0
  138. data/lib/aia/tools/recruit_robot_tool.rb +60 -0
  139. data/lib/aia/tools/reskill_robot_tool.rb +44 -0
  140. data/lib/aia/tools/task_board_tool.rb +114 -0
  141. data/lib/aia/trakflow_bridge.rb +173 -0
  142. data/lib/aia/turn_state.rb +94 -0
  143. data/lib/aia/ui_presenter.rb +166 -198
  144. data/lib/aia/utility.rb +134 -87
  145. data/lib/aia/{history_manager.rb → variable_input_collector.rb} +8 -9
  146. data/lib/aia/verification_network.rb +58 -0
  147. data/lib/aia.rb +108 -63
  148. data/mkdocs.yml +1 -0
  149. metadata +179 -56
  150. data/justfile +0 -215
  151. data/lib/aia/adapter/chat_execution.rb +0 -242
  152. data/lib/aia/adapter/error_handler.rb +0 -68
  153. data/lib/aia/adapter/gem_activator.rb +0 -57
  154. data/lib/aia/adapter/mcp_connector.rb +0 -274
  155. data/lib/aia/adapter/modality_handlers.rb +0 -167
  156. data/lib/aia/adapter/model_registry.rb +0 -81
  157. data/lib/aia/adapter/multi_model_chat.rb +0 -218
  158. data/lib/aia/adapter/provider_configurator.rb +0 -59
  159. data/lib/aia/adapter/tool_filter.rb +0 -85
  160. data/lib/aia/adapter/tool_loader.rb +0 -90
  161. data/lib/aia/chat_processor_service.rb +0 -178
  162. data/lib/aia/prompt_pipeline.rb +0 -183
  163. data/lib/aia/ruby_llm_adapter.rb +0 -95
  164. data/lib/extensions/openstruct_merge.rb +0 -48
  165. data/lib/extensions/ruby_llm/.irbrc +0 -56
  166. data/lib/extensions/ruby_llm/modalities.rb +0 -36
  167. data/lib/extensions/ruby_llm/provider_fix.rb +0 -79
  168. data/lib/refinements/string.rb +0 -16
  169. data/main.just +0 -76
data/docs/faq.md CHANGED
@@ -1,3 +1,79 @@
1
+ <!-- Tocer[start]: Auto-generated, don't remove. -->
2
+
3
+ ## Table of Contents
4
+
5
+ - [Frequently Asked Questions](#frequently-asked-questions)
6
+ - [Installation and Setup](#installation-and-setup)
7
+ - [Q: What Ruby version is required for AIA?](#q-what-ruby-version-is-required-for-aia)
8
+ - [Q: How do I install AIA?](#q-how-do-i-install-aia)
9
+ - [Q: Where should I store my API keys?](#q-where-should-i-store-my-api-keys)
10
+ - [Q: Can I use AIA without internet access?](#q-can-i-use-aia-without-internet-access)
11
+ - [Q: How do I list available local models?](#q-how-do-i-list-available-local-models)
12
+ - [Q: What's the difference between Ollama and LM Studio?](#q-whats-the-difference-between-ollama-and-lm-studio)
13
+ - [Q: Can I mix local and cloud models?](#q-can-i-mix-local-and-cloud-models)
14
+ - [Q: Why does my lms/ model show an error?](#q-why-does-my-lms-model-show-an-error)
15
+ - [Basic Usage](#basic-usage)
16
+ - [Q: How do I create my first prompt?](#q-how-do-i-create-my-first-prompt)
17
+ - [Q: What's the difference between batch mode and chat mode?](#q-whats-the-difference-between-batch-mode-and-chat-mode)
18
+ - [Q: How do I use fuzzy search for prompts?](#q-how-do-i-use-fuzzy-search-for-prompts)
19
+ - [Configuration](#configuration)
20
+ - [Q: Where is the configuration file located?](#q-where-is-the-configuration-file-located)
21
+ - [Q: How do I change the default AI model?](#q-how-do-i-change-the-default-ai-model)
22
+ - [Q: How do I set a custom prompts directory?](#q-how-do-i-set-a-custom-prompts-directory)
23
+ - [Prompts and Directives](#prompts-and-directives)
24
+ - [Q: What are directives and how do I use them?](#q-what-are-directives-and-how-do-i-use-them)
25
+ - [Q: How do I include files in prompts?](#q-how-do-i-include-files-in-prompts)
26
+ - [Q: Can I use Ruby code in prompts?](#q-can-i-use-ruby-code-in-prompts)
27
+ - [Q: How do I create prompt workflows?](#q-how-do-i-create-prompt-workflows)
28
+ - [Models and Performance](#models-and-performance)
29
+ - [Q: Which AI model should I use?](#q-which-ai-model-should-i-use)
30
+ - [Q: How do I use multiple models simultaneously?](#q-how-do-i-use-multiple-models-simultaneously)
31
+ - [Q: How do I reduce token usage and costs?](#q-how-do-i-reduce-token-usage-and-costs)
32
+ - [Q: What's consensus mode?](#q-whats-consensus-mode)
33
+ - [Tools and Integration](#tools-and-integration)
34
+ - [Q: What are RubyLLM tools?](#q-what-are-rubyllm-tools)
35
+ - [Q: How do I use tools with AIA?](#q-how-do-i-use-tools-with-aia)
36
+ - [Q: What's the difference between tools and MCP clients?](#q-whats-the-difference-between-tools-and-mcp-clients)
37
+ - [Q: How do I create custom tools?](#q-how-do-i-create-custom-tools)
38
+ - [Chat Mode](#chat-mode)
39
+ - [Q: How do I start a chat session?](#q-how-do-i-start-a-chat-session)
40
+ - [Q: How do I save chat conversations?](#q-how-do-i-save-chat-conversations)
41
+ - [Q: Can I use tools in chat mode?](#q-can-i-use-tools-in-chat-mode)
42
+ - [Q: How do I send a message to just one robot in a multi-model session?](#q-how-do-i-send-a-message-to-just-one-robot-in-a-multi-model-session)
43
+ - [Q: Can I save my place in a conversation and return to it later?](#q-can-i-save-my-place-in-a-conversation-and-return-to-it-later)
44
+ - [Q: How do I clear chat history?](#q-how-do-i-clear-chat-history)
45
+ - [Troubleshooting](#troubleshooting)
46
+ - [Q: "Command not found: aia"](#q-command-not-found-aia)
47
+ - [Q: "No models available" error](#q-no-models-available-error)
48
+ - [Q: "Permission denied" errors](#q-permission-denied-errors)
49
+ - [Q: Prompts are slow or timing out](#q-prompts-are-slow-or-timing-out)
50
+ - [Q: "Tool not found" errors](#q-tool-not-found-errors)
51
+ - [Advanced Usage](#advanced-usage)
52
+ - [Q: How do I use AIA for code review?](#q-how-do-i-use-aia-for-code-review)
53
+ - [Q: Can I use AIA for data analysis?](#q-can-i-use-aia-for-data-analysis)
54
+ - [Q: How do I integrate AIA into my development workflow?](#q-how-do-i-integrate-aia-into-my-development-workflow)
55
+ - [Q: How do I backup my prompts?](#q-how-do-i-backup-my-prompts)
56
+ - [Getting Help](#getting-help)
57
+ - [Q: Where can I find more examples?](#q-where-can-i-find-more-examples)
58
+ - [Q: How do I report bugs or request features?](#q-how-do-i-report-bugs-or-request-features)
59
+ - [Q: Is there a community or forum?](#q-is-there-a-community-or-forum)
60
+ - [Q: Where can I find the latest documentation?](#q-where-can-i-find-the-latest-documentation)
61
+ - [Tips and Best Practices](#tips-and-best-practices)
62
+ - [Q: What are some general best practices for prompts?](#q-what-are-some-general-best-practices-for-prompts)
63
+ - [Q: How do I optimize for performance?](#q-how-do-i-optimize-for-performance)
64
+ - [Q: Security considerations?](#q-security-considerations)
65
+ - [Troubleshooting](#troubleshooting-1)
66
+ - [Q: "Prompt not found" error](#q-prompt-not-found-error)
67
+ - [Q: Model errors or "Model not available"](#q-model-errors-or-model-not-available)
68
+ - [Q: Shell integration not working](#q-shell-integration-not-working)
69
+ - [Q: Configuration issues](#q-configuration-issues)
70
+ - [Q: Performance issues with slow responses](#q-performance-issues-with-slow-responses)
71
+ - [Q: Large prompt processing issues](#q-large-prompt-processing-issues)
72
+ - [Q: Debug mode - how to get more information?](#q-debug-mode---how-to-get-more-information)
73
+ - [Q: Common error messages and solutions](#q-common-error-messages-and-solutions)
74
+
75
+ <!-- Tocer[finish]: Auto-generated, don't remove. -->
76
+
1
77
  # Frequently Asked Questions
2
78
 
3
79
  Common questions and answers about using AIA.
@@ -202,7 +278,7 @@ See the [Directives Reference](directives-reference.md) for all available direct
202
278
 
203
279
  ### Q: Which AI model should I use?
204
280
  **A:** It depends on your needs:
205
- - **GPT-3.5 Turbo**: Fast, cost-effective for simple tasks
281
+ - **GPT-4o Mini**: Fast, cost-effective for simple tasks
206
282
  - **GPT-4**: Best quality for complex reasoning
207
283
  - **Claude-3 Sonnet**: Great for long documents and analysis
208
284
  - **Claude-3 Haiku**: Fast and economical
@@ -216,7 +292,7 @@ aia --model "gpt-4,claude-3-sonnet" my_prompt
216
292
  ### Q: How do I reduce token usage and costs?
217
293
  **A:**
218
294
  - Use shorter prompts when possible
219
- - Choose appropriate models (GPT-3.5 for simple tasks)
295
+ - Choose appropriate models (`gpt-4o-mini` for simple tasks)
220
296
  - Use temperature settings wisely
221
297
  - Clear chat context regularly with `/clear`
222
298
 
@@ -277,6 +353,12 @@ aia --chat --output conversation.md
277
353
  aia --chat --tools ./tools/
278
354
  ```
279
355
 
356
+ ### Q: How do I send a message to just one robot in a multi-model session?
357
+ **A:** Use @mention syntax: prefix the robot's name with `@` (e.g., `@tobor explain this`). Use `/robots` to see the active robots and their names. Only the mentioned robot responds; others stay silent.
358
+
359
+ ### Q: Can I save my place in a conversation and return to it later?
360
+ **A:** Yes, use `/checkpoint name` to create a named checkpoint and `/restore name` to return to it. Use `/checkpoints` to list all checkpoints. `/clear` removes all history and checkpoints.
361
+
280
362
  ### Q: How do I clear chat history?
281
363
  **A:** Use the `/clear` command or `/clear` directive:
282
364
  ```
@@ -305,7 +387,7 @@ You: /clear
305
387
 
306
388
  ### Q: Prompts are slow or timing out
307
389
  **A:**
308
- 1. Try a faster model like `gpt-3.5-turbo`
390
+ 1. Try a faster model like `gpt-4o-mini`
309
391
  2. Reduce prompt length or complexity
310
392
  3. Check your internet connection
311
393
  4. Use `--debug` to see what's happening
@@ -1,6 +1,6 @@
1
1
  # Available Models
2
2
 
3
- AIA supports a wide range of AI models through the RubyLLM gem. This comprehensive list shows all supported models, their capabilities, and best use cases.
3
+ AIA supports a wide range of AI models via robot_lab orchestration and ruby_llm LLM abstraction. This comprehensive list shows all supported models, their capabilities, and best use cases.
4
4
 
5
5
  ## Viewing Available Models
6
6
 
@@ -311,7 +311,7 @@ jobs:
311
311
  - name: Setup Ruby
312
312
  uses: ruby/setup-ruby@v1
313
313
  with:
314
- ruby-version: 3.1
314
+ ruby-version: 4.0.0
315
315
  - name: Install AIA
316
316
  run: gem install aia
317
317
  - name: Run Analysis
@@ -381,16 +381,16 @@ The `run` prompt is a configuration-only prompt that serves as a foundation for
381
381
  **Usage Examples:**
382
382
  ```bash
383
383
  # Direct question via pipe
384
- echo "What is the meaning of life?" | aia run
384
+ echo "What is the meaning of life?" | aia
385
385
 
386
386
  # File analysis
387
- aia run my_code.py
387
+ aia my_code.py
388
388
 
389
389
  # Multiple files
390
- aia run *.txt
390
+ aia *.txt
391
391
 
392
392
  # With custom configuration
393
- echo "Explain quantum computing" | aia run --model gpt-4 --temperature 1.0
393
+ echo "Explain quantum computing" | aia --model gpt-4 --temperature 1.0
394
394
  ```
395
395
 
396
396
  ### The Ad Hoc One-Shot Prompt
@@ -425,7 +425,7 @@ export AIA_FLAGS__VERBOSE=true # Shows spinner while waiting for LLM response
425
425
  alias chat='aia --chat --terse'
426
426
 
427
427
  # Quick question function
428
- ask() { echo "$1" | aia run --no-output; }
428
+ ask() { echo "$1" | aia --no-output; }
429
429
  ```
430
430
 
431
431
  **Usage Examples:**
data/docs/guides/chat.md CHANGED
@@ -42,6 +42,7 @@ Once in chat mode, you can use these commands:
42
42
  - **`/temperature 0.8`**: Adjust creativity level
43
43
  - **`/tools`**: List available tools
44
44
  - **`/context`**: Show current context
45
+ - **`/robots`**: List active robots and their `@mention` handles
45
46
 
46
47
  ### Special Features
47
48
 
@@ -78,6 +79,9 @@ which files are over 1 week old?
78
79
 
79
80
  ### Multi-Model Conversations
80
81
 
82
+ #### @mention Routing
83
+ In a multi-model network, direct your message to a specific robot by prefixing its name with `@` (e.g., `@tobor What do you think?`). Use `/robots` to see active robot names and their `@mention` handles.
84
+
81
85
  #### Consensus Mode
82
86
  ```bash
83
87
  # Start chat with multiple models seeking consensus
@@ -273,15 +277,43 @@ AI: Absolutely! Let's use a simple example everyone can relate to...
273
277
  ## Voice and Audio Features
274
278
 
275
279
  ### Text-to-Speech
280
+
281
+ `--speak` runs a three-stage pipeline after each AI response:
282
+
283
+ 1. **Generation** — LLM streams text to the terminal (`Processing...`)
284
+ 2. **Conversion** — text is converted to an audio file (`Converting to audio...`)
285
+ 3. **Playback** — audio file is played (`Speaking...`)
286
+
287
+ **Local TTS (default):** the macOS `say` command handles both conversion and
288
+ playback in one step, so it shows a single `Speaking...` spinner.
289
+
276
290
  ```bash
277
- # Enable speech output
291
+ # Enable speech (uses macOS say, system default voice)
278
292
  aia --chat --speak
279
293
 
280
- # Choose specific voice
281
- aia --chat --speak --voice nova
294
+ # Choose a specific macOS voice (run `say -v '?'` to list available voices)
295
+ aia --chat --speak --voice Samantha
296
+ aia --chat --speak --voice Alex
297
+ ```
298
+
299
+ **OpenAI TTS:** point `speak_command` at `~/.config/aia/tts.sh` (installed with
300
+ AIA). The script converts text to an audio file; AIA plays it with `afplay` and
301
+ shows separate spinners for each stage.
302
+
303
+ ```bash
304
+ aia --chat --speak \
305
+ --speak-command ~/.config/aia/tts.sh \
306
+ --speech-model tts-1-hd \
307
+ --voice nova \
308
+ my_prompt
309
+ ```
282
310
 
283
- # Use high-quality speech model
284
- aia --chat --speak --speech-model tts-1-hd
311
+ ```yaml
312
+ # ~/.config/aia/aia.yml
313
+ audio:
314
+ speak_command: ~/.config/aia/tts.sh
315
+ speech_model: tts-1-hd # passed as SPEECH_MODEL env var to the script
316
+ voice: nova # passed as AIA_AUDIO__VOICE env var
285
317
  ```
286
318
 
287
319
  ### Audio Input
@@ -290,14 +322,6 @@ aia --chat --speak --speech-model tts-1-hd
290
322
  aia --chat --transcription-model whisper-1 audio_input.wav
291
323
  ```
292
324
 
293
- ### Interactive Voice Chat
294
- ```bash
295
- # Full voice interaction
296
- aia --chat --speak --voice echo --transcription-model whisper-1
297
-
298
- # Great for hands-free operation or accessibility
299
- ```
300
-
301
325
  ## Session Management
302
326
 
303
327
  ### Saving Conversations
@@ -476,10 +500,10 @@ llm:
476
500
  temperature: 0.7
477
501
  max_tokens: 2048
478
502
 
479
- # Audio for /say directive
503
+ # Audio for --speak and /say directive
480
504
  audio:
481
- voice: alloy
482
- speak_command: afplay
505
+ voice: ~ # macOS system default; set e.g. "Samantha" to pick a voice
506
+ speak_command: say # macOS local TTS; use ~/.config/aia/tts.sh for OpenAI TTS
483
507
  ```
484
508
 
485
509
  Start chat with specific options via CLI:
@@ -0,0 +1,239 @@
1
+ # Crews
2
+
3
+ Every AIA chat session is a **crew** — a small team of robots that share the
4
+ conversation. Even when you start with a single model, that model is the crew's
5
+ **chief**, and you can add more members on the fly, address them individually or
6
+ together, and have them build on each other's answers.
7
+
8
+ This guide covers how the crew works, how to address members, and how to grow or
9
+ shrink the crew while you chat.
10
+
11
+ ## What a crew is
12
+
13
+ A crew is a network of robots backing one chat session:
14
+
15
+ - The **chief** is the lead robot — the first (or only) model you started with.
16
+ It answers plain turns and is the model your `/model`, consensus, and
17
+ history-transfer behavior revolve around.
18
+ - **Members** (also called recruits) are additional robots you add during the
19
+ session. Each has a name, a provider/model, and its own system prompt, and is
20
+ reachable by `@name`.
21
+
22
+ A single-model session is simply a crew of one. Multi-model sessions
23
+ (`-m model1,model2,...`) start as a crew with one member per model.
24
+
25
+ <svg width="640" height="280" viewBox="0 0 640 280" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Crew topology: a chief robot with recruited members addressed by @mention">
26
+ <style>
27
+ .lbl { font: 13px -apple-system, Segoe UI, sans-serif; fill: #e6e6e6; }
28
+ .sub { font: 11px -apple-system, Segoe UI, sans-serif; fill: #9aa4b2; }
29
+ .chief { fill: #1f6feb; }
30
+ .member { fill: #2ea043; }
31
+ .you { fill: #8957e5; }
32
+ .edge { stroke: #6e7681; stroke-width: 1.5; fill: none; }
33
+ .edge-bc { stroke: #d29922; stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; }
34
+ </style>
35
+ <!-- You -->
36
+ <rect class="you" x="20" y="120" rx="8" width="110" height="44"/>
37
+ <text class="lbl" x="75" y="140" text-anchor="middle">You</text>
38
+ <text class="sub" x="75" y="156" text-anchor="middle">the prompt</text>
39
+ <!-- Chief -->
40
+ <rect class="chief" x="250" y="120" rx="8" width="130" height="44"/>
41
+ <text class="lbl" x="315" y="140" text-anchor="middle">chief</text>
42
+ <text class="sub" x="315" y="156" text-anchor="middle">lead robot</text>
43
+ <!-- Members -->
44
+ <rect class="member" x="490" y="30" rx="8" width="130" height="44"/>
45
+ <text class="lbl" x="555" y="50" text-anchor="middle">@researcher</text>
46
+ <text class="sub" x="555" y="66" text-anchor="middle">gpt-4o</text>
47
+ <rect class="member" x="490" y="120" rx="8" width="130" height="44"/>
48
+ <text class="lbl" x="555" y="140" text-anchor="middle">@critic</text>
49
+ <text class="sub" x="555" y="156" text-anchor="middle">claude</text>
50
+ <rect class="member" x="490" y="210" rx="8" width="130" height="44"/>
51
+ <text class="lbl" x="555" y="230" text-anchor="middle">@local</text>
52
+ <text class="sub" x="555" y="246" text-anchor="middle">ollama/qwen</text>
53
+ <!-- edges -->
54
+ <path class="edge" d="M130 142 H250"/>
55
+ <path class="edge" d="M380 142 C 430 142, 440 52, 490 52"/>
56
+ <path class="edge" d="M380 142 H490"/>
57
+ <path class="edge" d="M380 142 C 430 142, 440 232, 490 232"/>
58
+ <text class="sub" x="190" y="135" text-anchor="middle">plain turn</text>
59
+ <text class="sub" x="435" y="120" text-anchor="middle">@name / @crew</text>
60
+ </svg>
61
+
62
+ ## Seeing the crew
63
+
64
+ Use `/robots` to list the active crew, each member's model, and its `@mention`
65
+ handle:
66
+
67
+ ```text
68
+ /robots
69
+ ```
70
+
71
+ By default a robot's name is derived from its model name; recruited robots use
72
+ the name you give them.
73
+
74
+ ## Addressing members with @mention
75
+
76
+ Prefix a name with `@` to direct a prompt at one member instead of the chief:
77
+
78
+ ```text
79
+ > @critic Does this API design have any obvious flaws?
80
+ ```
81
+
82
+ Only the addressed robot responds; the `@critic` prefix is stripped before the
83
+ prompt reaches it. Unknown names are reported (with the list of available
84
+ members) rather than silently broadcast.
85
+
86
+ ### Addressing several members at once
87
+
88
+ You can mention more than one member. **Where** the mentions appear changes how
89
+ they run:
90
+
91
+ - **Leading address → concurrent.** When the prompt is nothing but `@names`
92
+ followed by the message, every addressee runs at the same time, each in its
93
+ own thread, and replies render as they finish:
94
+
95
+ ```text
96
+ > @researcher @critic what are the trade-offs of optimistic locking?
97
+ ```
98
+
99
+ - **Body mention → sequential pipeline.** When a `@name` is woven into the body
100
+ of the message, the mentioned members run one at a time, and each reply is
101
+ injected into the other members' conversations so later members build on what
102
+ earlier ones said:
103
+
104
+ ```text
105
+ > draft a plan @researcher then have @critic poke holes in it
106
+ ```
107
+
108
+ Here `@researcher` runs first; its answer is shared into `@critic`'s context
109
+ before `@critic` runs, so the critique responds to the actual draft.
110
+
111
+ ### Broadcasting to the whole crew
112
+
113
+ `@crew` is a reserved handle that broadcasts the message to **every** member,
114
+ concurrently:
115
+
116
+ ```text
117
+ > @crew in one sentence, what is your specialty?
118
+ ```
119
+
120
+ Because `crew` is reserved for broadcast, you cannot name a member `crew`.
121
+
122
+ > **Local models and concurrency.** A leading-address or `@crew` broadcast runs
123
+ > its members **concurrently** — several HTTP requests at once. When every member
124
+ > shares one local model server (e.g. all on `ollama/qwen3.6:latest`), those
125
+ > requests compete for the same instance: the server processes only
126
+ > `OLLAMA_NUM_PARALLEL` at a time and the rest queue, so a big task can blow past
127
+ > the per-request timeout and you'll see `Net::ReadTimeout` for several members.
128
+ > If you hit this, raise Ollama's parallelism (`OLLAMA_NUM_PARALLEL=4`,
129
+ > `OLLAMA_MAX_LOADED_MODELS=1`), give each member a smaller scoped task (see
130
+ > [skills](#giving-a-recruit-a-role-with-skills)), or address members one at a
131
+ > time (a body mention runs them sequentially) instead of broadcasting.
132
+
133
+ ## Building a crew at runtime
134
+
135
+ ### Recruiting a member
136
+
137
+ `/add_recruit` (alias `/add`) adds a persistent member to the crew. It stays for
138
+ the rest of the session and is reachable by `@name`.
139
+
140
+ ```text
141
+ # Inherit the chief's model; give it a default persona
142
+ /add_recruit researcher
143
+
144
+ # Pick an explicit provider/model and write its system prompt
145
+ /add_recruit critic anthropic/claude-3-5-sonnet You are a ruthless design critic. Find flaws.
146
+
147
+ # A local model member
148
+ /add_recruit local ollama/qwen3.6:latest You are concise and fast.
149
+ ```
150
+
151
+ Syntax:
152
+
153
+ ```text
154
+ /add_recruit <name> [provider/model] [system prompt...]
155
+ ```
156
+
157
+ - **`<name>`** — required, unique within the crew (and not `crew`).
158
+ - **`provider/model`** — optional. Omit it (give only a name) to inherit the
159
+ chief's model and provider. Use `-` or `inherit` as the model token to inherit
160
+ explicitly while still supplying a system prompt. `lms/...` maps to the
161
+ `openai` provider for LM Studio.
162
+ - **system prompt** — everything after the model becomes the member's system
163
+ prompt. Without one, the member gets a simple default persona.
164
+
165
+ Recruits inherit the chief's local tools and any connected MCP servers, so a new
166
+ member can do the same file/shell/MCP work the chief can without reopening
167
+ connections.
168
+
169
+ ### Giving a recruit a role with skills
170
+
171
+ A bare crew of identical robots all do the same undifferentiated work. To divide
172
+ labor, assign each member a **skill** — a named, reusable system prompt (the same
173
+ skills used by `--skill` and `/skill`; list them with `/skills`). A skill becomes
174
+ the recruit's role:
175
+
176
+ ```text
177
+ # One skill as the recruit's role
178
+ /add_recruit reviewer skill:security-review
179
+
180
+ # Skill + explicit model, then an extra instruction appended after the skill
181
+ /add_recruit reviewer ollama/qwen3.6:latest skill:security-review focus on the auth module
182
+
183
+ # Several skills at once (repeat the token or comma-separate)
184
+ /add_recruit reviewer - skill:security-review,ruby-style
185
+ ```
186
+
187
+ The `skill:<id>` token may appear anywhere after the name; everything else is
188
+ parsed as the model (position 1) and an optional trailing system prompt. The
189
+ final role is the skill bodies joined, followed by any explicit prompt. An
190
+ unknown skill id is reported rather than silently ignored, so the recruit always
191
+ gets the role you intended.
192
+
193
+ This is how you turn a `@crew` broadcast from four identical answers into a real
194
+ division of labor — e.g. a security reviewer, a performance reviewer, a test
195
+ reviewer, and a style reviewer, each with its own skill.
196
+
197
+ ### Re-skilling a member
198
+
199
+ `/reskill` resets a member to a **clean slate** (a fresh conversation) and gives
200
+ it a new role. The member keeps its `@name` and model:
201
+
202
+ ```text
203
+ # Repurpose larry for the next phase
204
+ /reskill larry skill:test-writing
205
+
206
+ # Or hand it a freeform role
207
+ /reskill larry - you now summarize the other members' findings
208
+ ```
209
+
210
+ Use it to recover a member that drifted off task, or to move the crew through
211
+ phases (review → fix → summarize) without re-creating robots.
212
+
213
+ ### Dropping a member
214
+
215
+ `/drop_recruit` (alias `/drop`) removes a member by name:
216
+
217
+ ```text
218
+ /drop_recruit researcher
219
+ ```
220
+
221
+ The chief cannot be dropped — it is the session's lead robot.
222
+
223
+ ## Recruits vs. spawned specialists
224
+
225
+ `/add_recruit` and `/spawn` look similar but serve different needs:
226
+
227
+ | | `/add_recruit` (`/add`) | `/spawn` |
228
+ |---|---|---|
229
+ | Lifetime | Persists for the whole session | One-shot, for the **next** prompt only |
230
+ | Joins the crew | Yes — shows in `/robots`, answers to `@name` | No — handles a single subtask, then is set aside |
231
+ | Best for | A standing teammate you'll address repeatedly | A throwaway specialist for one focused task |
232
+
233
+ Both accept the same explicit `name provider/model system prompt` form, so a
234
+ specialist you find yourself reaching for repeatedly is a good candidate to
235
+ promote from `/spawn` to `/add_recruit`.
236
+
237
+ See the [Directives Reference](../directives-reference.md) for the full
238
+ directive list and the [Working with Models](models.md) guide for multi-model
239
+ sessions, consensus mode, and dynamic model switching.
@@ -267,7 +267,7 @@ jobs:
267
267
  - uses: actions/checkout@v4
268
268
  - uses: ruby/setup-ruby@v1
269
269
  with:
270
- ruby-version: '3.3'
270
+ ruby-version: '4.0.0'
271
271
  - run: gem install aia
272
272
  - name: Run Analysis
273
273
  run: cat ./prompts/pr_analyzer.md | aia --no-output --no-mcp
data/docs/guides/index.md CHANGED
@@ -12,6 +12,7 @@ Welcome to the AIA guides section! These comprehensive guides will help you mast
12
12
 
13
13
  - [Chat Mode](chat.md) - Interactive conversations with AI models
14
14
  - [Working with Models](models.md) - Multi-model support and configuration
15
+ - [Crews](crew.md) - Address robots with @mention, broadcast with @crew, and recruit members at runtime
15
16
  - [Available Models](available-models.md) - Complete list of supported AI models
16
17
  - [Image Generation](image-generation.md) - Generate images with AI
17
18
  - [Tools Integration](tools.md) - Extend AIA with custom Ruby tools
@@ -690,6 +690,21 @@ aia --model ollama/llama3.2 --chat
690
690
  aia --model ollama/llama3.2,gpt-4o-mini,claude-3-sonnet my_prompt
691
691
  ```
692
692
 
693
+ #### Reasoning models and `--thinking`
694
+
695
+ Reasoning models such as `qwen3` emit their chain-of-thought wrapped in
696
+ `<think>...</think>` tags as part of the streamed response. By default AIA
697
+ hides these blocks so you only see the final answer. Use `--thinking` to show
698
+ the reasoning as well:
699
+
700
+ ```bash
701
+ # Hide reasoning (default)
702
+ aia --chat --model ollama/qwen3:latest
703
+
704
+ # Show the model's reasoning
705
+ aia --chat --thinking --model ollama/qwen3:latest
706
+ ```
707
+
693
708
  #### Configuration
694
709
 
695
710
  ```yaml
data/docs/index.md CHANGED
@@ -1,3 +1,28 @@
1
+ <!-- Tocer[start]: Auto-generated, don't remove. -->
2
+
3
+ ## Table of Contents
4
+
5
+ - [AIA - AI Assistant](#aia---ai-assistant)
6
+ - [Key Features](#key-features)
7
+ - [🚀 Dynamic Prompt Management](#-dynamic-prompt-management)
8
+ - [🎭 Roles & 🎓 Skills](#-roles---skills)
9
+ - [🔧 Powerful Integration](#-powerful-integration)
10
+ - [💬 Interactive Chat Sessions](#-interactive-chat-sessions)
11
+ - [🎯 Advanced Features](#-advanced-features)
12
+ - [Quick Start](#quick-start)
13
+ - [Core Architecture](#core-architecture)
14
+ - [Component Overview](#component-overview)
15
+ - [Core Components](#core-components)
16
+ - [External Dependencies](#external-dependencies)
17
+ - [Documentation Structure](#documentation-structure)
18
+ - [Getting Started](#getting-started)
19
+ - [Guides](#guides)
20
+ - [Reference](#reference)
21
+ - [Community & Support](#community--support)
22
+ - [License](#license)
23
+
24
+ <!-- Tocer[finish]: Auto-generated, don't remove. -->
25
+
1
26
  # AIA - AI Assistant
2
27
 
3
28
  <table border="0">
@@ -185,7 +210,8 @@ graph TD
185
210
  - **AIA::PromptHandler** - Main prompt processing orchestrator
186
211
  - **AIA::ChatProcessorService** - Interactive chat session management
187
212
  - **AIA::DirectiveProcessor** - Processes embedded directives (`/command params`)
188
- - **AIA::RubyLLMAdapter** - Interfaces with the ruby_llm gem for AI model communication (manages conversation history via RubyLLM's Chat.@messages)
213
+ - **AIA::RubyLLMAdapter** - Replaced in v2 by `RobotFactory` which builds `RobotLab::Robot` or `RobotLab::Network` instances powered by the `robot_lab` gem.
214
+ - **AIA::RobotFactory** - Builds `RobotLab::Robot` or `RobotLab::Network` instances; the primary AI execution backend in v2
189
215
  - **AIA::ShellCommandExecutor** - Executes shell commands safely within prompts
190
216
  - **AIA::HistoryManager** - Manages prompt parameter history and user input
191
217
  - **AIA::UIPresenter** - Terminal output formatting and presentation
@@ -196,7 +222,8 @@ graph TD
196
222
  ### External Dependencies
197
223
 
198
224
  - **prompt_manager gem** - Core prompt management functionality
199
- - **ruby_llm gem** - AI model interface layer
225
+ - **robot_lab gem** - Robot/network execution engine (replaces direct ruby_llm usage in v2)
226
+ - **ruby_llm gem** - AI model interface layer (used internally by robot_lab)
200
227
  - **fzf** - Command-line fuzzy finder (external CLI tool)
201
228
 
202
229
  ## Documentation Structure
data/docs/installation.md CHANGED
@@ -1,3 +1,46 @@
1
+ <!-- Tocer[start]: Auto-generated, don't remove. -->
2
+
3
+ ## Table of Contents
4
+
5
+ - [Installation](#installation)
6
+ - [Prerequisites](#prerequisites)
7
+ - [Required](#required)
8
+ - [Recommended](#recommended)
9
+ - [Installation Methods](#installation-methods)
10
+ - [Method 1: Install from RubyGems (Recommended)](#method-1-install-from-rubygems-recommended)
11
+ - [Method 2: Install from Source](#method-2-install-from-source)
12
+ - [Method 3: Using Bundler](#method-3-using-bundler)
13
+ - [Verify Installation](#verify-installation)
14
+ - [Initial Setup](#initial-setup)
15
+ - [1. Create Prompts Directory](#1-create-prompts-directory)
16
+ - [2. Create Configuration Directory](#2-create-configuration-directory)
17
+ - [3. Basic Configuration File (Optional)](#3-basic-configuration-file-optional)
18
+ - [4. Set Up API Keys](#4-set-up-api-keys)
19
+ - [OpenAI](#openai)
20
+ - [Anthropic Claude](#anthropic-claude)
21
+ - [Google Gemini](#google-gemini)
22
+ - [Ollama (Local models)](#ollama-local-models)
23
+ - [Optional Dependencies](#optional-dependencies)
24
+ - [Install fzf for Fuzzy Search](#install-fzf-for-fuzzy-search)
25
+ - [macOS (using Homebrew)](#macos-using-homebrew)
26
+ - [Ubuntu/Debian](#ubuntudebian)
27
+ - [Other systems](#other-systems)
28
+ - [Testing Your Installation](#testing-your-installation)
29
+ - [1. Check Available Models](#1-check-available-models)
30
+ - [2. Test Basic Functionality](#2-test-basic-functionality)
31
+ - [3. Test Chat Mode](#3-test-chat-mode)
32
+ - [Troubleshooting](#troubleshooting)
33
+ - [Common Issues](#common-issues)
34
+ - ["Command not found: aia"](#command-not-found-aia)
35
+ - ["No models available"](#no-models-available)
36
+ - ["fzf not found" warning](#fzf-not-found-warning)
37
+ - [Permission errors](#permission-errors)
38
+ - [Getting Help](#getting-help)
39
+ - [Next Steps](#next-steps)
40
+ - [Updating AIA](#updating-aia)
41
+
42
+ <!-- Tocer[finish]: Auto-generated, don't remove. -->
43
+
1
44
  # Installation
2
45
 
3
46
  This guide will help you install AIA and get it running on your system.
@@ -5,7 +48,7 @@ This guide will help you install AIA and get it running on your system.
5
48
  ## Prerequisites
6
49
 
7
50
  ### Required
8
- - **Ruby**: Version 3.2 or higher
51
+ - **Ruby**: Version >= 4.0.0
9
52
  - **RubyGems**: Usually comes with Ruby
10
53
 
11
54
  ### Recommended
@@ -84,7 +127,6 @@ Create a basic configuration file at `~/.config/aia/aia.yml`:
84
127
  # Uses nested structure - see docs/configuration.md for full reference
85
128
 
86
129
  llm:
87
- adapter: ruby_llm
88
130
  temperature: 0.7
89
131
 
90
132
  models:
@@ -142,21 +184,6 @@ apt-get install fzf
142
184
  #### Other systems
143
185
  See the [fzf installation guide](https://github.com/junegunn/fzf#installation).
144
186
 
145
- ### Install Additional Ruby Gems
146
-
147
- Some features may require additional gems:
148
-
149
- ```bash
150
- # For advanced audio processing
151
- gem install ruby-audio
152
-
153
- # For advanced image processing
154
- gem install mini_magick
155
-
156
- # For enhanced terminal features
157
- gem install tty-prompt
158
- ```
159
-
160
187
  ## Testing Your Installation
161
188
 
162
189
  ### 1. Check Available Models