aia 2.0.0.0.pre.beta2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/CHANGELOG.md +146 -228
  4. data/README.md +41 -18
  5. data/bin/aia +8 -3
  6. data/lib/aia/aia_completion.bash +2 -3
  7. data/lib/aia/aia_completion.fish +6 -5
  8. data/lib/aia/aia_completion.zsh +2 -3
  9. data/lib/aia/chat_loop.rb +16 -14
  10. data/lib/aia/config/cli_parser.rb +123 -91
  11. data/lib/aia/config/defaults.yml +12 -39
  12. data/lib/aia/config/mcp_parser.rb +30 -36
  13. data/lib/aia/config/model_spec.rb +8 -14
  14. data/lib/aia/config/validator.rb +102 -103
  15. data/lib/aia/config/value_caster.rb +76 -0
  16. data/lib/aia/config.rb +70 -53
  17. data/lib/aia/crew.rb +29 -19
  18. data/lib/aia/debate_handler.rb +27 -10
  19. data/lib/aia/directives/configuration_directives.rb +55 -14
  20. data/lib/aia/directives/context_directives.rb +24 -12
  21. data/lib/aia/directives/execution_directives.rb +18 -23
  22. data/lib/aia/directives/model_directives.rb +41 -104
  23. data/lib/aia/directives/utility_directives.rb +16 -17
  24. data/lib/aia/directives/web_and_file_directives.rb +21 -14
  25. data/lib/aia/fact_asserter.rb +3 -3
  26. data/lib/aia/history_transfer.rb +64 -24
  27. data/lib/aia/logger.rb +10 -45
  28. data/lib/aia/mcp_config_normalizer.rb +27 -14
  29. data/lib/aia/mcp_connection_manager.rb +181 -184
  30. data/lib/aia/mcp_discovery.rb +43 -15
  31. data/lib/aia/mcp_grouper.rb +2 -1
  32. data/lib/aia/mcp_server_config.rb +20 -2
  33. data/lib/aia/mcp_utility.rb +24 -19
  34. data/lib/aia/mention_router.rb +15 -2
  35. data/lib/aia/modality_query.rb +36 -0
  36. data/lib/aia/model_alias_registry.rb +11 -11
  37. data/lib/aia/model_registry.rb +75 -0
  38. data/lib/aia/network_builder.rb +8 -7
  39. data/lib/aia/patches/ruby_llm_streaming_error.rb +21 -4
  40. data/lib/aia/patches/ruby_llm_tool_param_compat.rb +18 -0
  41. data/lib/aia/pipeline_orchestrator.rb +71 -38
  42. data/lib/aia/prompt_decomposer.rb +1 -1
  43. data/lib/aia/prompt_handler.rb +56 -29
  44. data/lib/aia/provider_registry.rb +105 -0
  45. data/lib/aia/robot_builder.rb +1 -1
  46. data/lib/aia/robot_factory.rb +67 -63
  47. data/lib/aia/robot_sync.rb +79 -0
  48. data/lib/aia/role_catalog.rb +89 -0
  49. data/lib/aia/session.rb +25 -11
  50. data/lib/aia/skill_utils.rb +60 -19
  51. data/lib/aia/spawn_handler.rb +16 -4
  52. data/lib/aia/spawn_spec_parser.rb +6 -7
  53. data/lib/aia/special_mode_handler.rb +28 -25
  54. data/lib/aia/speech.rb +70 -34
  55. data/lib/aia/startup_coordinator.rb +17 -92
  56. data/lib/aia/streaming_runner.rb +10 -2
  57. data/lib/aia/system_prompt_assembler.rb +12 -11
  58. data/lib/aia/task_board.rb +60 -0
  59. data/lib/aia/tool_approver.rb +205 -0
  60. data/lib/aia/tool_filter.rb +1 -10
  61. data/lib/aia/tool_filter_strategy.rb +12 -1
  62. data/lib/aia/tool_introspection.rb +9 -1
  63. data/lib/aia/tool_loader.rb +67 -33
  64. data/lib/aia/tool_utility.rb +6 -5
  65. data/lib/aia/tools/delegate_to_foreman_tool.rb +6 -4
  66. data/lib/aia/tools/recruit_robot_tool.rb +12 -12
  67. data/lib/aia/tools/reskill_robot_tool.rb +7 -7
  68. data/lib/aia/tools/task_board_tool.rb +16 -16
  69. data/lib/aia/trakflow_bridge.rb +14 -8
  70. data/lib/aia/turn_state.rb +31 -8
  71. data/lib/aia/ui_presenter.rb +16 -0
  72. data/lib/aia/utility.rb +6 -24
  73. data/lib/aia/variable_input_collector.rb +0 -3
  74. data/lib/aia/verification_network.rb +9 -10
  75. data/lib/aia.rb +33 -8
  76. metadata +19 -160
  77. data/.better-commits.json +0 -150
  78. data/.config/tocer/configuration.yml +0 -6
  79. data/.envrc +0 -19
  80. data/.loki +0 -11
  81. data/.reek.yml +0 -160
  82. data/.rubocop.yml +0 -116
  83. data/.rubocop_strict.yml +0 -15
  84. data/COMMITS.md +0 -196
  85. data/IMPLEMENTATION_PLAN.md +0 -506
  86. data/Rakefile +0 -47
  87. data/_typos.toml +0 -10
  88. data/aia.gemspec +0 -92
  89. data/architecture_review.md +0 -314
  90. data/config/aia.yml +0 -13
  91. data/docs/AGENTS.md +0 -40
  92. data/docs/advanced-prompting.md +0 -814
  93. data/docs/assets/images/aia.png +0 -0
  94. data/docs/cli-reference.md +0 -1241
  95. data/docs/configuration.md +0 -747
  96. data/docs/contributing.md +0 -386
  97. data/docs/directives-reference.md +0 -1145
  98. data/docs/examples/index.md +0 -277
  99. data/docs/examples/mcp/index.md +0 -475
  100. data/docs/examples/prompts/analysis/index.md +0 -78
  101. data/docs/examples/prompts/automation/index.md +0 -109
  102. data/docs/examples/prompts/development/index.md +0 -125
  103. data/docs/examples/prompts/index.md +0 -333
  104. data/docs/examples/prompts/learning/index.md +0 -127
  105. data/docs/examples/prompts/writing/index.md +0 -62
  106. data/docs/examples/tools/index.md +0 -282
  107. data/docs/faq.md +0 -578
  108. data/docs/guides/available-models.md +0 -366
  109. data/docs/guides/basic-usage.md +0 -478
  110. data/docs/guides/chat.md +0 -680
  111. data/docs/guides/crew.md +0 -239
  112. data/docs/guides/executable-prompts.md +0 -331
  113. data/docs/guides/first-prompt.md +0 -454
  114. data/docs/guides/getting-started.md +0 -455
  115. data/docs/guides/image-generation.md +0 -507
  116. data/docs/guides/index.md +0 -48
  117. data/docs/guides/local-models.md +0 -306
  118. data/docs/guides/migrate-prompts.md +0 -335
  119. data/docs/guides/models.md +0 -1017
  120. data/docs/guides/shared-tools.md +0 -254
  121. data/docs/guides/tools.md +0 -831
  122. data/docs/index.md +0 -259
  123. data/docs/installation.md +0 -274
  124. data/docs/mcp-integration.md +0 -603
  125. data/docs/prompt_management.md +0 -665
  126. data/docs/security.md +0 -674
  127. data/docs/special_projects_guide.md +0 -386
  128. data/docs/tools-and-mcp-examples.md +0 -1211
  129. data/docs/workflows-and-pipelines.md +0 -636
  130. data/examples/.gitignore +0 -2
  131. data/examples/00_setup_aia.sh +0 -111
  132. data/examples/01_basic_usage.sh +0 -23
  133. data/examples/02_frontmatter.sh +0 -33
  134. data/examples/03_shell_integration.sh +0 -55
  135. data/examples/04_erb_templating.sh +0 -56
  136. data/examples/05_shell_then_erb.sh +0 -38
  137. data/examples/06_prompt_chaining.sh +0 -59
  138. data/examples/07_pipeline.sh +0 -46
  139. data/examples/08_context_files.sh +0 -43
  140. data/examples/09_roles.sh +0 -67
  141. data/examples/10_stdin_piping.sh +0 -49
  142. data/examples/11_multi_model.sh +0 -65
  143. data/examples/12_token_usage.sh +0 -52
  144. data/examples/13_cost_tracking.sh +0 -68
  145. data/examples/14_output_file.sh +0 -91
  146. data/examples/15_parameters.sh +0 -68
  147. data/examples/16_directives.sh +0 -113
  148. data/examples/17_require_and_conditionals.sh +0 -68
  149. data/examples/18_tools.sh +0 -61
  150. data/examples/19_local_tools.sh +0 -34
  151. data/examples/20_mcp_servers.sh +0 -102
  152. data/examples/21_executable_prompts.sh +0 -78
  153. data/examples/22_chat_mode.sh +0 -217
  154. data/examples/23_verify.sh +0 -139
  155. data/examples/24_decompose.sh +0 -139
  156. data/examples/25_spawn.sh +0 -139
  157. data/examples/26_debate.sh +0 -97
  158. data/examples/27_mention_routing.sh +0 -157
  159. data/examples/28_model_switching.sh +0 -106
  160. data/examples/29_agent_harness.sh +0 -177
  161. data/examples/README.md +0 -321
  162. data/examples/advanced_multi_robot_capabilities_without_examples.md +0 -106
  163. data/examples/aia_config.yml +0 -22
  164. data/examples/aia_config_orchestrator.yml +0 -45
  165. data/examples/aia_config_with_mcp.yml +0 -21
  166. data/examples/common.sh +0 -39
  167. data/examples/context/project_goals.md +0 -6
  168. data/examples/context/tech_stack.md +0 -7
  169. data/examples/directives/timestamp_directive.rb +0 -22
  170. data/examples/mcp/filesystem.json +0 -9
  171. data/examples/prompts_dir/analyze.md +0 -2
  172. data/examples/prompts_dir/brainstorm.md +0 -2
  173. data/examples/prompts_dir/conditional.md +0 -17
  174. data/examples/prompts_dir/creative.md +0 -4
  175. data/examples/prompts_dir/erbinfo.md +0 -5
  176. data/examples/prompts_dir/erbinfo_raw.md +0 -8
  177. data/examples/prompts_dir/evaluate.md +0 -2
  178. data/examples/prompts_dir/explain_joke.md +0 -1
  179. data/examples/prompts_dir/explain_recursion.md +0 -1
  180. data/examples/prompts_dir/fun_fact +0 -3
  181. data/examples/prompts_dir/greeting.md +0 -8
  182. data/examples/prompts_dir/greeting_required.md +0 -7
  183. data/examples/prompts_dir/hello.md +0 -1
  184. data/examples/prompts_dir/includes/ruby_facts.md +0 -4
  185. data/examples/prompts_dir/limerick.md +0 -1
  186. data/examples/prompts_dir/list_with_mcp.md +0 -3
  187. data/examples/prompts_dir/pick_best.md +0 -2
  188. data/examples/prompts_dir/project_summary +0 -12
  189. data/examples/prompts_dir/quiz_with_include.md +0 -6
  190. data/examples/prompts_dir/require_demo.md +0 -5
  191. data/examples/prompts_dir/roles/formal.md +0 -3
  192. data/examples/prompts_dir/roles/orchestrator.md +0 -21
  193. data/examples/prompts_dir/roles/pirate.md +0 -3
  194. data/examples/prompts_dir/shell_then_erb.md +0 -6
  195. data/examples/prompts_dir/sort_compare.md +0 -2
  196. data/examples/prompts_dir/summarize_context.md +0 -2
  197. data/examples/prompts_dir/sysinfo.md +0 -5
  198. data/examples/prompts_dir/sysinfo_raw.md +0 -8
  199. data/examples/prompts_dir/tagline.md +0 -1
  200. data/examples/prompts_dir/tell_joke.md +0 -1
  201. data/examples/prompts_dir/tell_joke_with_next.md +0 -4
  202. data/examples/prompts_dir/use_local_tool.md +0 -8
  203. data/examples/prompts_dir/use_tools.md +0 -8
  204. data/examples/prompts_dir/weather.md +0 -2
  205. data/examples/prompts_dir/whats_new.md +0 -2
  206. data/examples/prompts_dir/with_timestamp.md +0 -5
  207. data/examples/requirements/sinatra_taskflow_app.md +0 -139
  208. data/examples/rules/01_classify_ruby.rb +0 -16
  209. data/examples/rules/02_prefer_claude_for_code.rb +0 -19
  210. data/examples/rules/03_gate_prompt_length.rb +0 -19
  211. data/examples/rules/04_tool_selection.rb +0 -41
  212. data/examples/rules/README.md +0 -30
  213. data/examples/run_all.sh +0 -294
  214. data/examples/tools/word_count_tool.rb +0 -30
  215. data/lib/AGENTS.md +0 -57
  216. data/lib/aia/model_switch_handler.rb +0 -100
  217. data/mcp_servers/README.md +0 -110
  218. data/mcp_servers/apple-mcp.json +0 -8
  219. data/mcp_servers/filesystem.json +0 -9
  220. data/mcp_servers/mcp_server_chart.json +0 -11
  221. data/mcp_servers/playwright_one.json +0 -8
  222. data/mcp_servers/playwright_server_definition.json +0 -9
  223. data/mcp_servers/playwright_two.json +0 -8
  224. data/mcp_servers/tavily_mcp_server.json +0 -8
  225. data/mkdocs.yml +0 -169
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4bbfc1e0e1f0e293c55ce308b069b4a36af679797fcdaa2daeb47f05211d31f
4
- data.tar.gz: 2d358bec6a2dfd8e57c55266099dcbd5ab96c776532fd6829862df30cd668323
3
+ metadata.gz: 0f3c92628b523cd32fa77fa52f1546f1ec43ee9b65c645b33adb508086ef0c13
4
+ data.tar.gz: cc9e9aab97552cff87e4b05b001d8330a99a5fea9000c6d2b76f07b1e1a7054e
5
5
  SHA512:
6
- metadata.gz: a62160a13b4b6827b837191a7b0001fe6d075cc3a3e628f1c943f82c970da7c22c6ed031e11792e0d43a188e2b5e2895994cfd5a5265309bbf81d849537be569
7
- data.tar.gz: dae8328bdbc222221ac6380e71037d4ea0d32df2f6f04d091beac65632bc3c58e9b190735854440e71df20e1368509313c8b678d5f765870433ce2b0687ec43a
6
+ metadata.gz: abf1b9d9f077b6d8aadd6c259e1cf3125007718b7912be857003f4189d57be4c20451093e87c6ec47f0a3be06c4ddf7cf767ffff5dc55be4177241e2d6fa8d7d
7
+ data.tar.gz: 14e85d72e471d1bf8572d8fb2b417a6e1e0c641bc34e376b8748dd8b2f55665221fa6ff78966692f0ecce65ee990067c65a898db0d96f718ad713ec8f02048ec
data/.version CHANGED
@@ -1 +1 @@
1
- 2.0.0.0-beta2
1
+ 2.0.0
data/CHANGELOG.md CHANGED
@@ -1,112 +1,168 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased]
3
+ ## [2.0.0] 2026-11-02
4
4
 
5
- This section captures all changes since v1.1.0.
5
+ AIA 2.0 rebuilds the CLI on [robot_lab](https://github.com/MadBomber/robot_lab): every session is a crew of robots, MCP servers come from ruby_llm 2.1's built-in client, and any provider RubyLLM registers can be used. This entry summarizes everything since 1.1.1, the last 1.x release, including the `2.0.0.pre.alpha` and `2.0.0.pre.beta2` pre-releases.
6
6
 
7
- ## [2.0.0.pre.beta2] 2026-09-09
7
+ **Requires** Ruby >= 4.0.9 · robot_lab `~> 0.6` · ruby_llm 2.1 (through robot_lab)
8
8
 
9
- Using robot_lab v0.2.5
10
- Using lumberjack v2.1.0
9
+ ### Upgrading from 1.x
11
10
 
12
- ### Added
13
-
14
- - **`--[no-]thinking` flag** (`lib/aia/config/cli_parser.rb`, `lib/aia/config/defaults.yml`, `lib/aia/config.rb`, `lib/aia/streaming_runner.rb`): Controls whether raw reasoning blocks from local models (e.g. `qwen3` on Ollama) are shown. Such models stream their chain-of-thought wrapped in `<think>...</think>` tags; AIA now filters these out by default so only the final answer is displayed. Pass `--thinking` to show the reasoning. The `StreamingRunner` strips the tags inline, tracking open spans across chunk boundaries. Config key: `flags.thinking` (env: `AIA_FLAGS__THINKING`); default `false`.
15
-
16
- - **Crews — every session is a team of robots** (`lib/aia/crew.rb`, `lib/aia/mention_router.rb`, `lib/aia/directives/execution_directives.rb`): Every chat session is now a crew (a `RobotLab::Network`), even with a single model; the lead robot is the **chief**.
17
- - **`/add_recruit <name> [provider/model] [system prompt]`** (alias `/add`): Adds a persistent member to the crew that survives the session, shows in `/robots`, and answers to `@name`. Omit the model to inherit the chief's; use `-`/`inherit` to inherit explicitly. Recruits inherit the chief's local tools and connected MCP servers.
18
- - **`/drop_recruit <name>`** (alias `/drop`): Removes a member; the chief cannot be dropped.
19
- - **Skill assignment to recruits**: `/add_recruit` accepts `skill:<id>` tokens (comma-separate or repeat for several) that load named skills as the recruit's role/system prompt — letting the chief divide labor across the crew (e.g. a security reviewer + a performance reviewer). Unknown skill ids are reported rather than silently dropped. The chief's `recruit_robot` tool gained a matching `skills` param so it can assign roles itself.
20
- - **`/reskill <name> [skill:<id>...] [system prompt]`**: Resets a member to a clean slate (fresh conversation) keeping its name and model, and applies a new skill/role. Backed by `Crew.reskill` and a `reskill_robot` chief tool. Useful for recovering an off-task member or moving the crew through phases.
21
- - **`@crew` broadcast handle**: Sends a prompt to every member concurrently. `crew` is reserved as a member name.
22
- - **Position-aware `@mention` routing**: A leading address (`@a @b ...`) runs the addressees concurrently; a `@name` woven into the body runs the members sequentially as a pipeline, sharing each reply into the others' context so later members build on earlier ones.
23
- - **`/spawn` extended** to the explicit form `/spawn <name> <provider/model> <system prompt>` alongside the existing `/spawn` and `/spawn <type>` forms. `/spawn` remains a one-shot specialist for the next prompt; `/add_recruit` is its persistent counterpart.
24
- - **Docs**: new [Crews guide](docs/guides/crew.md); README `@mention`/crew section and `docs/directives-reference.md` updated for `/add_recruit`, `/drop_recruit`, and the extended `/spawn`.
25
-
26
- - **`--history-file` fully implemented** (`lib/aia/ui_presenter.rb`): `chat_history_file` now checks `config.output.history_file` first — uses the configured path when set, returns `nil` when `--no-history-file` is given (disabling history). `load_chat_history` and `save_chat_history` both guard against `nil` so disabling history is a clean no-op. Resolution order: `config.output.history_file` → `paths.aia_dir/chat_history` → `~/.config/aia/chat_history`.
27
-
28
- - **`--speech-model` fully implemented** (`lib/aia/robot_factory.rb`, `lib/aia/chat_loop.rb`, `lib/aia/mention_router.rb`): `configure_audio` stores the value and passes it as the `SPEECH_MODEL` environment variable to the speak subprocess, allowing custom TTS scripts to select a model. `--voice` wires to `say -v VOICE` for the macOS `say` command.
29
-
30
- - **`--transcription-model` fully implemented** (`lib/aia/robot_factory.rb`): `configure_audio` calls `RubyLLM.configure { |c| c.default_transcription_model = ... }` so the transcription model is active for the entire session.
11
+ These changes can break an existing setup. [Upgrading to 2.0](docs/appendix/upgrading-2.0.md) has the details.
31
12
 
32
- - **`--speak-command CMD`** (`lib/aia/config/cli_parser.rb`, `lib/aia/config.rb`): New CLI option to set `audio.speak_command` at runtime without editing config. Enables full OpenAI TTS pipeline from the command line: `aia --speak --speak-command ~/.config/aia/tts.sh --speech-model tts-1-hd --voice nova my_prompt`.
13
+ - **Ruby 4.0.9 or newer.**
14
+ - **Removed options:** `--terse`, `--regex`, `--skills-prefix` and `--md` / `--[no-]markdown`. Passing one now stops AIA with an invalid-option error. The config keys `flags.terse`, `prompts.parameter_regex`, `prompts.skills_prefix` and `output.markdown` are gone too, along with these keys nothing read: `flags.clear`, `embedding.model`, `tools.dir`, `roles.dir`, `prompts.roles_dir`, `prompts.tool`, `prompts.tools_prefix` and `paths.config_file`. Old config files that still set them load as before. Use `--skills-dir` in place of `--skills-prefix`.
15
+ - **Changed defaults:** `llm.max_tokens` is `32767` (was `2048`) and `llm.top_p` is `nil` (was `1.0`). `audio.speak_command` is `say`; it was `afplay`, which plays audio files, not text. `audio.voice`, `audio.speech_model` and `audio.transcription_model` are `nil` (were `alloy`, `tts-1` and `whisper-1`).
16
+ - **Custom tools must use the ruby_llm 2 DSL.** `param :text, desc: "..."` is now `parameter :text, description: "..."`. A tool still written the 1.x way raises `NoMethodError` when it loads.
17
+ - **MCP runs on ruby_llm 2.1's own client.** The `ruby_llm-mcp` gem is no longer used and cannot be loaded alongside ruby_llm 2.1. Servers listed under `mcp_servers:` keep working. Also:
18
+ - Server classes loaded with `--require` must subclass `RubyLLM::MCP`.
19
+ - `sse` and `ws` transports are gone; use the server's Streamable HTTP `url:` or a stdio `command:`.
20
+ - When two servers offer a tool with the same name, the second now fails to connect. Give one of them a `prefix:`.
21
+ - **`/terse` has been removed.**
22
+ - **`/ruby` is off by default.** Enable it with `--allow-ruby-eval`.
23
+ - **`/model` keeps the conversation.** Switching models hands the new model a summary of the conversation so far. Set `model_switch_history: clean` to start fresh, as 1.x did.
24
+ - **Embedding AIA in Ruby code:** `AIA.client` is a `RobotLab::Robot` or `RobotLab::Network`. `RubyLLMAdapter` and `lib/aia/adapter/` are gone. `AIA::HistoryManager` is now `AIA::VariableInputCollector`, and `AIA::ConfigSection` is now `MywayConfig::ConfigSection`.
25
+ - **The gem no longer ships `docs/`, `examples/` or `mcp_servers/`.** They are in the [repository](https://github.com/MadBomber/aia).
33
26
 
34
- - **Three-stage `--speak` pipeline with per-stage spinners** (`lib/aia/chat_loop.rb`, `lib/aia/mention_router.rb`): After text streams to the terminal, `--speak` now shows distinct progress feedback for each stage — `Converting to audio...` while the TTS command runs, then `Speaking...` while the audio plays. For the local macOS `say` command (which converts and plays in one step) only `Speaking...` is shown. Custom TTS scripts receive the output file path as `$2`; AIA creates the temp file and calls `afplay` itself.
27
+ If you used a 2.0 pre-release: the KBS rule engine, `/rules`, user-defined rule hooks and `--tool-filter-kbs` have been removed. Tool filtering is TF-IDF only and on by default, toggled with `-A` / `--[no-]auto-tool-filter`, which replaces `tool_filter_a`.
35
28
 
36
- - **`~/.config/aia/tts.sh`**: OpenAI TTS helper script installed at the AIA config directory. Accepts text as `$1` and output path as `$2`; reads `SPEECH_MODEL` and `AIA_AUDIO__VOICE` env vars; calls `api.openai.com/v1/audio/speech` via `curl`. Does not call `afplay` — AIA handles playback.
37
-
38
- - **`--skill` / `-s` fully implemented**: Injects skill content into the AI context; mode-aware — in `--chat` mode skills are appended to the system prompt once (persists across all turns); in pipeline mode skills are appended to each individual prompt text after the role content.
39
- - **`SkillUtils#skills_base_dir`**: New resolver centralising skills path computation — returns `skills.dir` when `skills_prefix` is unset, or `skills.dir / prefix` when prefix is set; shared by `SystemPromptAssembler` (chat mode) and `PipelineOrchestrator` (pipeline mode).
40
- - **`SkillUtils#load_skills_content` / `#load_single_skill_content`**: Load and join skill bodies from one or more skill IDs; strip YAML front matter; warn and skip missing skills without aborting.
41
-
42
- ### Changed
43
-
44
- - **`skills_prefix` default changed from `"skills"` to `nil`**: When unset and no `--skills-dir` is given, the skills directory falls back to `~/.prompts/skills`; setting `--skills-prefix` appends to `--prompts-dir` (or `AIA_PROMPTS__DIR`) rather than to a fixed default.
45
- - **`--skills-prefix` path resolution** (`lib/aia/config/cli_parser.rb`): Three-branch logic — explicit `--skills-dir` + prefix → `skills_dir/prefix`; no `--skills-dir` but prefix set → `prompts_dir/prefix`; neither given → `AIA_SKILLS__DIR` or `~/.prompts/skills`.
46
- - **Docs updated for skills options**: `docs/cli-reference.md` — `--skills-prefix` default and resolution, chat-vs-pipeline injection note in `--skill`; `docs/configuration.md` — `skills_prefix` default, prompt assembly order section rewritten; `docs/directives-reference.md` — `/skill` directory resolution description.
47
-
48
- - **`.loki` asgard task runner**: Added per-project task file with quality gates (`test`, `flog`, `flay`, `rubocop`), each capturing output to `*_output.txt`; `quality` task runs all gates via `system()` and prints a per-gate pass/fail summary table; `aia` passthrough task runs `bin/aia` with arbitrary arguments from any working directory.
49
- - **`.rubocop.yml`**: Project-level RuboCop configuration achieving 0 offenses — disables intentional-pattern cops (`Style/FormatStringToken`, `Style/SafeNavigationChainLength`, `Lint/DuplicateBranch`), adds test-file exclusions for cops that conflict with minitest patterns, and raises Metrics thresholds to match actual method complexity.
29
+ ### Added
50
30
 
51
- - **`LayeredOrchestrator`**: 3-tier agent orchestration — Tobor decomposes requirements, lead agents break them into specialist tasks, specialists produce artifacts. Activated via `/orchestrate`.
52
- - **`TaskDecomposer` + `TaskExecutor`**: Break complex prompts into parallel subtasks and execute them via TrakFlow.
53
- - **`OrchestratorError`, `DebateError`, `DecomposeError`**: Typed error classes for orchestration and debate failure paths (`lib/aia/errors.rb`).
54
- - **`tool_filter.timeout_s` config key**: Configurable TF-IDF filter timeout; defaults to 10 seconds.
55
- - **Parallel LLM calls**: Multi-model network turns now run concurrently via `Async::Barrier`.
56
- - **Session cleanup**: `at_exit` hook in `AIA.run` calls `Session#cleanup!` to release MCP connections, flush caches, and close TrakFlow.
57
- - **`state_setting!` DSL**: Directive subclasses declare their exclusive mode with `state_setting! :debate, :spawn, ...`; `ChatLoop` no longer maintains a hardcoded prefix list.
58
- - **Demo 29**: End-to-end agent harness demo building a Sinatra/Sequel application from a requirements document.
59
- - **`BATCH_MODE` support**: Demos 23–28 skip live `--chat` sessions when `BATCH_MODE=true`, enabling `run_all.sh` CI automation.
31
+ **Crews and multi-robot work**
32
+ - Every chat session is a crew, even with one model; its lead robot is the chief.
33
+ - `/add_recruit` (`/add`) adds persistent members, `/drop_recruit` (`/drop`) removes them, and `/reskill` resets a member with a new role.
34
+ - `skill:<id>` assigns roles from skills, and the chief can recruit and reskill members itself.
35
+ - `@crew` sends a prompt to every member. Leading `@a @b` addresses run concurrently, and a `@name` inside the body runs members as a pipeline.
36
+ - `/spawn <name> <provider/model> <prompt>` creates a one-shot specialist.
37
+ - Orchestration patterns:
38
+ - multi-model parallel, consensus and pipeline networks
39
+ - `/verify`: two independent answers plus a reconciler
40
+ - `/debate`, which ends when the robots' answers converge
41
+ - `/decompose` and `/delegate`
42
+ - `/orchestrate`: three-tier lead and specialist planning
43
+ - Multi-model turns run their LLM calls concurrently.
44
+ - TrakFlow task tracking: the `/plan`, `/task` and `/tasks` directives, plus the `TaskBoardTool` and `DelegateToForemanTool` tools.
45
+
46
+ **MCP**
47
+ - All configured servers connect in parallel before the first robot is built. Each server process starts once and is shared by every robot, crewmate and network worker.
48
+ - Streamable HTTP servers can be configured with `url:`, `headers:` and `bearer_token:`.
49
+ - Servers accept `prefix:`, `only:`, `except:`, `requires_approval:` and `description:`.
50
+ - An `mcp_servers:` entry can name a `RubyLLM::MCP` subclass, such as `SharedTools::MCP::GitHub`. The class supplies its own command or URL, environment and timeout, and the server is known by the class's default name (`github`). A class whose `available?` returns false (a missing API key, say) is skipped with a note naming the missing variables. `--require` libraries load before servers connect, so the classes they define can be used.
51
+ - `tools.approval` (`--tool-approval ask|approve|deny`) handles approval-gated tool calls and servers' requests for input. `ask`, the default, prompts on the terminal.
52
+
53
+ **Providers and models**
54
+ - `AIA::ProviderRegistry` takes its provider list from RubyLLM. It loads `ruby_llm-providers-<slug>` gems on demand, and a `<SLUG>_API_BASE` variable overrides a provider's endpoint.
55
+ - `--provider` sets the default for model names without a provider prefix. `--list-providers` shows each provider, marked as local or as having an API key; `--list-models` lists a provider's live models.
56
+ - `/model` switches models mid-session, with fuzzy name matching. `model_switch_history` decides how the conversation carries over: `summarize` (default), `replay` or `clean`.
57
+ - `--[no-]thinking` hides or shows the `<think>` reasoning that local models stream.
58
+
59
+ **Skills, audio and output**
60
+ - `--skill` / `-s` injects skills into the system prompt in chat mode, and into each prompt in pipeline mode. The `SKILL.md` skills system itself arrived in 1.1.0.
61
+ - Audio:
62
+ - `--speak-command` runs your own TTS script; `~/.config/aia/tts.sh` is a ready-made OpenAI one.
63
+ - `--speech-model`, `--transcription-model` and `--voice` now take effect.
64
+ - `--speak` shows a spinner for converting and for speaking.
65
+ - `--history-file` and `--no-history-file` now work.
66
+ - `tool_filter.timeout_s` sets the TF-IDF filter's timeout.
60
67
 
61
68
  ### Changed
62
69
 
63
- - **TF-IDF as sole tool filter strategy**: Zvec (B), SqliteVec (C), and LSI (D) strategies removed (~2,150 LOC deleted).
64
- - **`auto_tool_filter` flag**: Replaces `tool_filter_a`; enabled by default; toggled via `--[no-]auto-tool-filter`.
65
- - **`robot_lab` dependency**: Updated from `~> 0.0.9` to `~> 0.1.0`.
66
- - **Lazy handler instantiation**: `SpawnHandler`, `DebateHandler`, `DelegateHandler`, and `LayeredOrchestrator` are memoized and created on first use.
67
- - **Lazy-require for heavy subsystems**: `VerificationNetwork`, `PromptDecomposer`, and all TrakFlow infrastructure required only when invoked.
68
- - **`shared_tools` optional runtime dependencies**: `dentaku`, `sequel`, and `openweathermap` moved to dev dependencies; each tool guards its `require` with a boolean constant and exposes `available?`; `bigdecimal >= 4.0` pinned conditionally for Ruby >= 4.0.
69
- - **`README.md`**: Added badges, "Why AIA?" feature comparison table, and Prompt Directives reorganized into seven category subsections.
70
+ - The example scripts and configs run on Anthropic (`claude-haiku-4-5`, `claude-sonnet-4-6`) and need only `ANTHROPIC_API_KEY`. The example tool plugins moved to `examples/plugins/`. New example 30 uses every shared_tools tool and MCP server.
71
+ - `/debate` shows each robot's response as soon as it finishes, under a `Round N · Name` heading, with one progress line per round. The transcript is still written to `--output`.
72
+ - Tool allowlists (`--allowed-tools`, `--rejected-tools`) and the chat tool filter match a tool class by the name the model calls it (`dns`), not its Ruby class name (`SharedTools::Tools::DnsTool`).
73
+ - Heavy subsystems load only when used: verification, decomposition, TrakFlow and the special-mode handlers.
74
+ - "Exiting AIA application..." now appears only when a chat session ends, not after `--version`, `--help` or a one-shot run.
75
+ - **One special mode per turn is now enforced.** `/verify`, `/decompose`, `/concurrent`, `/debate`, `/delegate`, `/spawn` and `/orchestrate` go through `TurnState#request`, so a later directive replaces an earlier one instead of both staying set. The `TurnState` `force_*` flags are read-only; handlers take the active mode with `TurnState#consume!`.
70
76
 
71
77
  ### Removed
72
78
 
73
- - **Zvec, SqliteVec, LSI tool filter strategies** and their test files.
74
- - **`zvec`, `sqlite-vec`, `informers` gem dependencies** from gemspec.
75
- - **KBS gem and rule engine**: `kbs` gem and all KBS infrastructure (RuleRouter, KBDefinitions, FactAsserter, DynamicRuleBuilder, RulesDSL, DecisionApplier, ExpertRouter) deleted.
76
- - **`-A`/`--tool-filter-kbs` CLI flag**, `/rules` chat directive, and user-defined rule hooks.
77
- - **`build_streaming_callback`**: Dead code path in `RobotFactory`.
79
+ - KBS rule engine: `RuleRouter`, `ExpertRouter`, `DynamicRuleBuilder`, `DecisionApplier` and the rules DSL.
80
+ - The zvec, sqlite-vec and LSI tool filters.
81
+ - Dependencies: `kbs`, `ruby_llm-mcp`, `zvec`, `sqlite-vec`, `informers`, `ostruct`, `securerandom`.
82
+ - The `--terse`, `--regex` and `--skills-prefix` options, the `/terse` directive, and their config keys.
83
+ - The unused `rules:` config section (`AIA_RULES__*`).
84
+ - Options and keys that had no effect: `--expert-routing`, `--load`, `--save`, `--md`, their `flags.*` / `output.markdown` keys, `concurrency.independent_servers`, the MCP server key `independent:`, and the config keys listed under Upgrading.
85
+ - `ModelSwitchHandler`, the disabled plain-language model switcher ("switch to claude"). `/model` switches models.
86
+ - Compatibility shims: the `AIA::HistoryManager` and `AIA::ConfigSection` aliases, and the `RobotFactory` forwarding methods `clear_tool_cache!`, `filtered_tools`, `resolve_system_prompt` and `build_identity_prompt` (call `ToolLoader` and `SystemPromptAssembler` directly).
78
87
 
79
88
  ### Fixed
80
89
 
81
- - **`--no-mcp` flag ignored by `RobotBuilder`** (`lib/aia/robot_builder.rb`): Was directly mapping `config.mcp_servers` without checking `config.flags.no_mcp`; now delegates to `RobotFactory.mcp_server_configs(config)` which honours the flag — preventing MCP servers from connecting and tools from overflowing the model's 128-tool limit.
82
- - **`load_extra_config` falls through on missing file in tests** (`lib/aia/config.rb`): Restored `return` after `exit 1`; tests mock `exit` as a no-op, so without the guard the method continued to `YAML.safe_load_file` on the nonexistent path and raised `Errno::ENOENT`.
83
- - **`warn` → `$stderr.puts` across all lib files** (19 files): Ruby 4.0 suppresses `Kernel#warn` output by default (requires `-W` flag); messages were silently dropped — including unknown-option errors, missing-file warnings, and audio failures. Replaced all `warn` calls with `$stderr.puts` which always writes unconditionally. Test suite updated: replaced `stubs(:warn)` + `stderr_messages` patterns with `capture_io` to capture real `$stderr` output.
84
- - **`--speak` produced `AudioFileOpen failed` error** (`lib/aia/config/defaults.yml`, `~/.config/aia/aia.yml`): Default `speak_command` was `afplay` (an audio file player) instead of `say` (macOS TTS); passing response text to `afplay` caused it to interpret the text as a file path and fail. Default changed to `say`; `voice` and `speech_model` defaults cleared to `nil` so `say` uses the system default voice with no API call.
85
-
86
- - **`DebateHandler` convergence short-circuit** (`lib/aia/debate_handler.rb`): Added `all_signaled_convergence?` fast path — when all robots say `CONVERGED` after minimum rounds the debate ends immediately, without waiting for similarity scoring to catch up.
87
- - **`SpecialModeHandler` keyword argument crash** (`lib/aia/special_mode_handler.rb`): `network.run(prompt)` → `network.run(message: prompt)` to match `RobotLab::Network#run`'s keyword-only API.
88
- - **`ToolLoader` gem loading under Bundler** (`lib/aia/tool_loader.rb`): `Gem::LoadError` (`ScriptError`, not `StandardError`) now caught; added `eager_load_namespace_fallback` for Zeitwerk recovery; `activate_unbundled_gem` falls back to `Gem.default_dir`/`Gem.user_dir` scanning when Bundler blocks `gem name`.
89
- - **Demo 18 tool overload** (`examples/18_tools.sh`): Added `--allowed-tools` to expose only 3 tools; 35+ tools caused `gpt-4.1` to narrate instead of invoke.
90
- - **Demo 26/27 robot name** (`examples/26_debate.sh`, `examples/27_mention_routing.sh`): `RobotNamer` assigns "Vanguard" to `gpt-4.1-mini`, not "Quark"; corrected in both scripts.
91
- - **Ollama model tag resolution** (`lib/aia/verification_network.rb`, `lib/aia/prompt_decomposer.rb`): Pass `model.internal_id` (e.g. `ollama/qwen3:latest`) to `RobotLab.build` instead of `model.name`.
92
- - **Dynamic pipeline iteration** (`lib/aia/pipeline_orchestrator.rb`): Changed `config.pipeline.each` to `until config.pipeline.empty?` + `shift` so mid-run `next:`/`pipeline:` replacements are picked up immediately.
93
- - **AI response written to output file twice** (`lib/aia/ui_presenter.rb`): Removed file-writing from `display_ai_response`; file output exclusively owned by `output_to_file`.
94
- - **Unknown `@mention` falls through to broadcast** (`lib/aia/mention_router.rb`): Returns `true` and reports unrecognized names instead of silently broadcasting to all robots.
95
- - **Custom directive classes unavailable in ERB prompts** (`lib/aia/tool_loader.rb`): `PM::Directive.register_all` now called at the end of `ToolLoader#load_tools` so tool-provided directives are registered before the first prompt render.
96
- - **Demo scripts using untagged Ollama model names**: Updated to `phi4:latest` and `phi4-mini:latest`.
97
- - **`/ruby` directive security gate**: `eval` now guarded by `AIA.config.flags.allow_ruby_eval`.
98
- - **`RobotFactory` namer state leak**: `@namer` initialized once in `RobotFactory.setup` instead of reset on every robot build.
99
- - **`at_exit` hook registered multiple times**: Moved from `Session#start` to `AIA.run`, registered exactly once per process.
100
- - **GPT-5/OpenAI token parameter mismatch**: Models with `temperature: false` skip temperature; `max_tokens` translated to `max_completion_tokens` for o-series models.
101
- - **Installed gem BigDecimal activation conflict** (`lib/aia.rb`): AIA activates `bigdecimal >= 4.0` before loading transitive dependencies.
102
- - **Pipeline token metrics crash**: `display_metrics` uses `result.raw` instead of non-existent `result.output`.
103
- - **Skill symlink path containment**: Skill resolution checks real paths against the skills directory boundary.
104
- - **`--list-skills` CLI directory options**: Now honors `--prompts-dir` and `--skills-prefix` regardless of option order.
105
-
106
- ### Known Issues
107
-
108
- - **`--skill` injection in RobotLab flow**: The RobotLab prompt execution path does not yet prepend configured skills to pipeline prompts and chat startup context.
109
- - **Path-based direct skill file restrictions**: `/skill` accepts any readable file path; should be limited to markdown files to prevent arbitrary injection.
90
+ - **MCP:**
91
+ - `--no-mcp` is honored.
92
+ - Streamable HTTP servers keep their `url`.
93
+ - `--mcp-list --list-tools` uses the same connection path as the robots.
94
+ - **Model switching:** conversation history now carries over to crews. Prompt decomposition uses structured output again instead of always falling back to JSON parsing.
95
+ - **Errors and warnings now reach the terminal** (aia now writes them with `$stderr.puts` instead of `warn`).
96
+ - **Command-line errors:** an invalid option value (`-t hot`, `--tool-approval maybe`), a malformed `-m` spec or a missing `-m MODEL=ROLE` role file now prints a one-line `ERROR:` message and exits 1 instead of a Ruby backtrace.
97
+ - **Model search:** `--available-models` and `/available_models` capability terms such as `text_to_image` work again under ruby_llm 2.1 instead of crashing with `NoMethodError`.
98
+ - **Front-matter `model:`** no longer crashes the run after the model replies.
99
+ - **Settings changed while aia runs now reach the model:**
100
+ - A prompt's front-matter `model:` switches models before that prompt runs; `temperature:`, `top_p:` and `config: llm:` retune the running robot.
101
+ - `/temperature`, `/top_p` and `/config llm.*` apply from the next chat turn, to every crewmate, without losing the conversation.
102
+ - `/config` converts values to the setting's type (numbers, true/false, lists) for every key, not just seven switches.
103
+ - **`model_switch_history` and `model_aliases` are loaded** from the config file, `-c` files and the environment. `/model` accepts aliases such as `sonnet` or `cheap`.
104
+ - **Environment variables are typed:** `AIA_FLAGS__X=false` turns a switch off, numbers such as `AIA_LLM__TEMPERATURE=0.2` become numbers, and `AIA_TOOLS__ALLOWED`, `AIA_TOOLS__REJECTED` and `AIA_TOOLS__PATHS` are split on commas.
105
+ - **`flags.shell` and `flags.erb`** set the default for every prompt; front matter still overrides them.
106
+ - **`tool_filter.timeout_s`** sets the chat tool filter's time limit.
107
+ - **`--dump`** includes `tool_filter`, `model_switch_history` and `model_aliases`, and `-c` files can set `tool_filter`.
108
+ - **Prompt loading:**
109
+ - Prompt IDs with hyphens or subfolders (`code-review`, `dev/review`) load their file instead of being sent to the model as text. A prompt ID can also be a path (`./drafts/idea`).
110
+ - `aia -p a,b` with no prompt ID runs `a` then `b`, and `aia -r role` alone runs the role file as the prompt.
111
+ - The "prompt ID is required" message no longer says context files are enough.
112
+ - A mistyped prompt ID reports `No prompt named 'x'` with spelling suggestions instead of `The following files do not exist`.
113
+ - Piped text drops a leading `#!` line and keeps its front matter, and piped text that is one word or ends in `.md` is no longer read as a file name.
114
+ - A required parameter declared only in an included file is asked for instead of stopping the run.
115
+ - Parameters named after Ruby built-ins such as `format` or `test` render their values instead of failing with `ArgumentError` (prompt_manager 1.2.0; aia now requires `prompt_manager ~> 1.2`).
116
+ - Front-matter `pipeline:` may be a comma-separated string.
117
+ - **Roles and skills:**
118
+ - `--list-roles` and the `-m MODEL=ROLE` check use the configured prompts directory (`--prompts-dir`, config file), not only `AIA_PROMPTS__DIR`.
119
+ - A role given as a path reaches the system prompt, in chat too.
120
+ - The role in the system prompt is processed like a prompt: front matter removed, ERB and `$(...)` expanded.
121
+ - `--skill` warns when the skills directory doesn't exist, and path skills load without one.
122
+ - `--help` describes `--system-prompt` as literal text.
123
+ - **Chat and crews:**
124
+ - `/compare` sends the whole argument string as the prompt, not just its first word.
125
+ - An `@word` that names no crew member (an email address, `@deprecated`) goes to the model; only a mistyped name at the start of a message is held back.
126
+ - `/spawn` specialists get the chief's tools and MCP servers, and `skill:<id>` in `/spawn` is applied.
127
+ - The task-board tool reaches the robots: TrakFlow starts before the robot collects its tools.
128
+ - `/verify` builds its robots with the model's provider, so `ollama/…` and other non-default providers work.
129
+ - `/drop_recruit`, `/reskill` and duplicate-name checks ignore case, as `@mentions` do.
130
+ - `/say` uses `--speak-command`, and its usage message is no longer sent to the model.
131
+ - **Tools, MCP and providers:**
132
+ - `--list-tools` loads tools the way a session does (lazily loaded gems such as `shared_tools` included) and applies `--allowed-tools` / `--rejected-tools`.
133
+ - `--mcp-list` and the banner apply `--mcp-use` and `--mcp-skip` together, as a session does.
134
+ - `--mcp` JSON servers accept every YAML server key (`prefix`, `only`, `except`, `requires_approval`, `url`, `headers` …) in both JSON forms, and a `url` with no `type` is Streamable HTTP.
135
+ - Ollama works without `OLLAMA_API_BASE`: it defaults to `http://localhost:11434/v1`, and `--list-models` honors `<PROVIDER>_API_BASE`.
136
+ - The default image model is `gpt-image-1` (`dall-e-3` is no longer in RubyLLM's catalogue).
137
+ - **Output, speech and side effects:**
138
+ - `--speak` speaks one-shot prompts and each pipeline step, not only chat replies.
139
+ - New `audio.player` (`AIA_AUDIO__PLAYER`) plays the file a custom speak command writes. Unset, AIA uses the first of `afplay`, `mpv`, `ffplay` and `mpg123` on the `PATH` instead of always calling `afplay`.
140
+ - TrakFlow starts on first use, so a session that records no tasks no longer creates `.trak_flow/` in the current directory. Pipelines touch TrakFlow only with `--track-pipeline`.
141
+ - `--paint` no longer writes "Image saved to: …" into the output file.
142
+ - `--completion` with an unsupported shell exits 1.
143
+ - The completion scripts fall back to `~/.prompts` when `AIA_PROMPTS__DIR` is unset.
144
+ - `--track-pipeline` updates the steps of the plan it created, in order, instead of matching any task whose title contains the prompt ID.
145
+ - **`--refresh DAYS` works again.** AIA keeps its model list in `<paths.aia_dir>/models.json` and refreshes it from the providers every `registry.refresh` days (default 7, `0` = never), as 1.x did. A failed refresh warns and keeps the existing list.
146
+ - **`bin/migrate_prompts`:**
147
+ - `//shell COMMAND` becomes ``<%= `COMMAND` %>``, which inserts the command's output; it used to become `<%= system(...) %>`, which inserted `true`.
148
+ - `//config` settings land where aia reads them: `model`, `temperature`, `top_p`, `next`, `pipeline`, `shell` and `erb` at the top of the front matter, everything else under `config:` at its place in the configuration. Unknown keys are kept under `config:` with a warning.
149
+ - The report prints even when `RUBYOPT=-W0` silences Ruby warnings.
150
+ - **The fuzzy role picker** (`--fuzzy` with a role that isn't found) lists roles from `prompts.dir`/`prompts.roles_prefix`, including subdirectories, the same roles `--list-roles` shows.
151
+ - **Examples:** `16_directives.sh` lists the real directives, `15_parameters.sh` says AIA asks for every parameter, `21_executable_prompts.sh` notes that a piped file's shebang options are not applied, and `aia_config_orchestrator.yml` no longer claims to extend the base config.
152
+ - **Skill paths must be markdown.** A skill given as a file path (`--skill ./x.md`, `/skill ./x.md`) must end in `.md` or `.markdown`; any other file is refused with a warning instead of being sent to the model. Skill folders and skills by name are unchanged.
153
+ - **Unknown config keys are dropped at load.** Keys `defaults.yml` doesn't define, from a config file or an `AIA_*` variable, no longer linger in the configuration or show up in `--dump`.
154
+ - **Smaller fixes:**
155
+ - The AI response is no longer written to the output file twice.
156
+ - An unknown `@mention` is reported instead of being broadcast to every robot.
157
+ - A pipeline's `next:` and `pipeline:` changes take effect mid-run.
158
+ - Directives supplied by `--tools` work inside ERB prompts.
159
+ - Ollama model tags resolve.
160
+ - GPT-5 and o-series models get the right token and temperature parameters.
161
+ - Pipeline metrics no longer crash.
162
+ - `/clear`, `/checkpoint`, `/restore` and `/review` work with crews.
163
+ - `/say` with no text no longer captures stdin.
164
+ - Skill paths are confined to the skills directory.
165
+ - `bin/aia` works with a relative `BUNDLE_GEMFILE`.
110
166
 
111
167
  ## [1.1.1] - 2026-05-01
112
168
 
@@ -141,144 +197,6 @@ Using lumberjack v2.1.0
141
197
  - **Model and skill filtering consistency**: `/llms` and `/skills` use the shared positive/negative search term behavior.
142
198
  - **Skills CLI option placement**: Skill-related CLI flags now appear under Prompt Options.
143
199
 
144
- ## [2.0.9.alpha] - 2026-03-28
145
-
146
- ### Improvements (Section 9 — Design Correctness)
147
-
148
- - **`MCPConfigNormalizer.filter_servers` eliminated** (`lib/aia/mcp_config_normalizer.rb`, `lib/aia/robot_builder.rb`, `lib/aia/robot_factory.rb`): `filter_servers` duplicated use/skip filtering logic that `MCPDiscovery` already owns, and used a different activation source (`TurnState.active_mcp_servers` vs. `Decisions.mcp_activations`), creating a split-brain risk. Removed `filter_servers` entirely. `RobotBuilder` now passes all configured servers normalized (`Array(config.mcp_servers).map { |s| MCPConfigNormalizer.normalize(s) }`). `RobotFactory.mcp_server_configs` (used by network builders) follows the same pattern. MCPDiscovery is now the single authoritative filter.
149
- - **`Utility` converted from class to module** (`lib/aia/utility.rb`): `class Utility` with only `class << self` methods is a Ruby anti-pattern. Changed to `module Utility` — semantically identical for callers (`AIA::Utility.mcp_servers?` etc.) but idiomatically correct. Nothing can be accidentally instantiated.
150
- - **Banner methods returned to `Utility`** (`lib/aia/utility.rb`, `lib/aia/mcp_utility.rb`, `lib/aia/tool_utility.rb`): `banner_mcp`, `mcp_client_labels`, and `banner_tools` were mixed into `MCPUtility`/`ToolUtility` — display concerns in data-query modules. Moved all banner private methods back into `Utility`. `MCPUtility` and `ToolUtility` are now pure query interfaces with no formatting logic.
151
- - **`MCPDiscovery` takes `decisions` directly** (`lib/aia/mcp_discovery.rb`, `startup_coordinator.rb`, `pipeline_orchestrator.rb`, `special_mode_handler.rb`): `MCPDiscovery` only ever used `rule_router.decisions` — passing the whole `rule_router` was over-coupling. Constructor changed to `MCPDiscovery.new(decisions)`; all three callers updated to pass `@rule_router.decisions`. Dependency is now explicit and narrow.
152
- - **`history_manager.rb` shim deleted** (`lib/aia/session.rb`): The backward-compat shim (`require_relative 'variable_input_collector'`) had served its purpose. `session.rb` updated to require `variable_input_collector` directly. The Ruby-level `HistoryManager = VariableInputCollector` alias in `variable_input_collector.rb` remains for callers that reference the old constant name.
153
-
154
- ## [2.0.8.alpha] - 2026-03-28
155
-
156
- ### Improvements (Section 8 — Backlog Cleanup)
157
-
158
- - **Consolidate `server_name` inline patterns** (`fact_asserter.rb`, `config/validator.rb`, `mcp_discovery.rb`): Replaced 5 occurrences of `server[:name] || server['name']` with `Utility.server_name(server)` (or `AIA::Utility.server_name(server)`). `Utility.server_name` already handled Hash symbol/string keys, object `.name` methods, and `to_s` fallback — the inline pattern was a redundant re-implementation. (P3-28 / 8.1)
159
- - **`MCPUtility` and `ToolUtility` extracted from `Utility`** (`lib/aia/mcp_utility.rb`, `lib/aia/tool_utility.rb`, `lib/aia/utility.rb`): `Utility` was a grab-bag class mixing MCP server query methods, tool query methods, and display/banner concerns. Extracted `MCPUtility` (6 public methods: `mcp_servers?`, `mcp_server_names`, `connected_mcp_servers?`, `failed_mcp_servers`, `effective_mcp_server_names`, `server_name`; 2 private: `mcp_client_labels`, `banner_mcp`) and `ToolUtility` (4 public methods: `tools?`, `total_tool_count`, `user_tools?`, `supports_tools?`; 1 private: `banner_tools`). Both modules are included into `Utility` via `class << self include`. `utility.rb` now holds only display, banner, and model-refresh concerns. (P3-30 / 8.2)
160
- - **Pin `robot_lab` and `kbs` version constraints** (`aia.gemspec`): Simplified redundant double-constraint notation (`'~> 0.0', '>= 0.0.9'`) to single pessimistic constraints: `robot_lab '~> 0.0.9'` and `kbs '~> 0.2.1'`. Semantically equivalent but cleaner. (P3-32 / 8.3)
161
- - **Rename `HistoryManager` → `VariableInputCollector`** (`lib/aia/variable_input_collector.rb`, `lib/aia/history_manager.rb`, `lib/aia/input_collector.rb`): `HistoryManager` was misnamed — it only prompts for prompt variable values. New canonical name is `VariableInputCollector`. `history_manager.rb` is now a one-line shim requiring the new file. `HistoryManager = VariableInputCollector` alias preserved for backward compatibility. `lib/aia.rb` updated to require `variable_input_collector`. New test file `test/aia/variable_input_collector_test.rb` mirrors the original tests plus an alias assertion. (P3-33 / 8.4)
162
-
163
- ## [2.0.7.alpha] - 2026-03-28
164
-
165
- ### Improvements (Section 7 — MCPDiscovery Decision)
166
-
167
- - **`MCPDiscovery` wired into `StartupCoordinator`** (`lib/aia/startup_coordinator.rb`): The startup MCP connection path now routes through `MCPDiscovery#discover` instead of the indirect `MCPConfigNormalizer.filter_servers → TurnState` bridge. `MCPDiscovery` is the canonical authority for which servers are activated at startup — reading `--mcp-use`, `--mcp-skip`, and KBS `mcp_activate` decisions directly. Each discovered server is then normalized by `MCPConfigNormalizer.normalize` before being passed to `MCPConnectionManager`. (P2-20 / 7.1)
168
- - **`MCPDiscovery` bug fix** (`lib/aia/mcp_discovery.rb`): `config.mcp_use` truthiness check changed from `if config.mcp_use` to `if Array(config.mcp_use).any?`. In Ruby, `[]` is truthy, so an empty `mcp_use` list previously triggered explicit-server filtering and returned zero servers. An empty list now correctly falls through to KBS-activation or all-servers fallback. (7.1)
169
- - **`MCPDiscovery` now respects `--mcp-skip`** (`lib/aia/mcp_discovery.rb`): Added `apply_skip_filter` that removes servers whose names appear in `config.mcp_skip` after the primary selection (explicit, KBS-activated, or all). Skip is applied regardless of which selection path was taken. (7.1)
170
- - **Refactored `MCPDiscovery` internals** (`lib/aia/mcp_discovery.rb`): Extracted `select_servers` (selection strategy dispatcher), `apply_skip_filter` (post-selection skip), and `select_by_names` (name-list filter) private helpers. The public `discover` interface is unchanged. (7.1)
171
-
172
- ## [2.0.6.alpha] - 2026-03-28
173
-
174
- ### Improvements (Section 6 — Structural Decompositions)
175
-
176
- - **`ConfigValidator` early-exit refactor** (`lib/aia/config/validator.rb`): Replaced all `raise AIA::EarlyExit` calls with `return :early_exit`. `tailor()` propagates the signal via `return :early_exit if <step>(config) == :early_exit`. Removed the `EarlyExit` exception class from `lib/aia/errors.rb` and the `rescue AIA::EarlyExit` clause from `lib/aia.rb`. The exception-as-goto anti-pattern is gone. (P2-18 / 6.1)
177
- - **`ExpertRouter` integration** (`lib/aia/expert_router.rb`): `ExpertRouter` is now instantiated in `ChatLoop` and called as part of the turn pipeline. Verified via `test_expert_router_is_integrated_into_chat_loop`. (P2-19 / 6.2)
178
- - **`TaskDecomposer` + `TaskExecutor`** (`lib/aia/task_decomposer.rb`, `lib/aia/task_executor.rb`): Extracted from `DelegateHandler`. `TaskDecomposer#decompose` calls the lead robot with a JSON decomposition prompt and returns `[{title:, assignee:}]`. `TaskExecutor#execute` claims, runs, and completes a single TrakFlow step. `DelegateHandler` is now a thin coordinator. (P2-23 / 6.3)
179
- - **`StartupCoordinator`** (`lib/aia/startup_coordinator.rb`): New class extracting all session startup concerns from `Session`: MCP server connection, tool collection, filter registry initialization, TrakFlow bootstrap, and bus attachment. `StartupCoordinator.new(robot:, rule_router:, ui_presenter:).run(config)` runs all startup tasks and exposes `filters` and `mcp_manager` attributes. (P2-16 / 6.4)
180
- - **`PipelineOrchestrator`** (`lib/aia/pipeline_orchestrator.rb`): New class extracting per-prompt pipeline processing from `Session`: prompt building (role, stdin, context files), concurrent MCP detection, robot dispatch, result display, metrics, and TrakFlow step tracking. `PipelineOrchestrator.new(...).process(config)` replaces `Session#process_pipeline` and all its private helpers. (P2-16 / 6.4)
181
- - **`Session` thinned** (`lib/aia/session.rb`): `Session#start` now delegates to `StartupCoordinator#run` and `PipelineOrchestrator#process`. The 12 extracted private methods (`connect_mcp_servers`, `process_pipeline`, `execute_prompt`, `maybe_use_concurrent_mcp`, `build_prompt_text`, `add_context_files`, `display_metrics`, etc.) have been removed. Session is a thin shell sequencing startup → pipeline → chat. (P2-16 / 6.4)
182
- - **`MCPConfigNormalizer`** (`lib/aia/mcp_config_normalizer.rb`): New class extracting MCP server filtering and normalization from `RobotFactory`. `MCPConfigNormalizer.filter_servers(config)` applies use/skip/KBS lists and returns normalized configs. `MCPConfigNormalizer.normalize(server)` converts flat format to robot_lab's nested transport format. `RobotFactory#mcp_server_configs` and `#normalize_mcp_config` now delegate to it. (P2-17 / 6.5)
183
- - **`NetworkMemoryManager`** (`lib/aia/network_memory_manager.rb`): New class extracting network shared-memory setup from `RobotFactory`. `NetworkMemoryManager.initialize_memory(network, config)` seeds session metadata. `NetworkMemoryManager.setup_subscriptions(network, config)` wires debug-logging and completion-count subscriptions. `RobotFactory#initialize_network_memory` and `#setup_memory_subscriptions` now delegate to it. (P2-17 / 6.5)
184
- - **`RobotBuilder`** (`lib/aia/robot_builder.rb`): New class extracting single-robot construction from `RobotFactory`. `RobotBuilder.build(config, namer:)` assembles the system prompt, resolves MCP configs via `MCPConfigNormalizer`, and calls `RobotLab.build`. `RobotFactory#build_single_robot` now delegates to it. (P2-17 / 6.5)
185
-
186
- ## [2.0.5.alpha] - 2026-03-27
187
-
188
- ### Improvements (Section 5 — State Machine & Lifecycle)
189
-
190
- - **`TurnState#request(mode)` mutual exclusion** (`lib/aia/turn_state.rb`): Added `EXCLUSIVE_MODES` constant and `request(mode, type: nil)` method. Calling `request` clears all other exclusive `force_*` flags before setting the new one, enforcing that only one special mode is active at a time. Added `active_mode` helper returning the currently active mode symbol. Direct `attr_accessor` assignment still works for backward compatibility and test assertions. (P1-13)
191
- - **`SpawnHandler` lifecycle** (`lib/aia/spawn_handler.rb`): Added `MAX_CACHE_SIZE = 5` constant. When a new specialist is spawned and the cache is full, the oldest entry is evicted (insertion-order LRU via Ruby Hash). Added `cleanup!` method that clears all cached specialists — called on session end to release resources. (P2-22)
192
- - **`DebateHandler` convergence** (`lib/aia/debate_handler.rb`): Replaced the fragile `"CONVERGED"` string check with semantic similarity scoring using `SimilarityScorer`. Added `MIN_ROUNDS = 2` and `SIMILARITY_THRESHOLD = 0.85`. Convergence is only evaluated after `MIN_ROUNDS` rounds; it triggers when the combined response text from consecutive rounds scores ≥ threshold. One robot mentioning "CONVERGED" incidentally no longer ends the debate prematurely. (P2-21)
193
- - **`MentionRouter` mention stripping** (`lib/aia/mention_router.rb`): After matching `@mention` tokens to robots, all mention tokens are stripped from the prompt (`gsub(/@\w+\s*/i, '').strip`) before routing to the target robot. The robot now receives only the query, not the routing prefix. (P3-26)
194
- - **`ModelSwitchHandler#model_exists?` caching** (`lib/aia/model_switch_handler.rb`): Added `@model_exists_cache` instance hash. Each model name is looked up via `RubyLLM.models.find(name)` at most once per handler instance; subsequent calls for the same name return the cached boolean without hitting the provider. (P3-27)
195
-
196
- ## [2.0.4.alpha] - 2026-03-27
197
-
198
- ### Improvements (Section 4 — Tool Infrastructure)
199
-
200
- - **`ToolLoader` converted to class** (`lib/aia/tool_loader.rb`): `module_function` with a module-level `@tool_cache` was replaced by a class with per-instance `@tool_cache`. Class-level convenience methods delegate to a resettable default instance via `ToolLoader.instance`. `ToolLoader.reset_instance!` (and `AIA.reset!`) discard the singleton for clean test isolation. Two `ToolLoader.new` instances now have independent caches. (P1-12)
201
- - **`ToolFilterRegistry`** (`lib/aia/tool_filter_registry.rb`): New class with `build_from_config(config, tools, rule_router:)`. Extracts the five identical `if/prep/assign` blocks from `Session#start` into a single, independently testable method. Session now calls one line. (P1-7)
202
- - **`EmbeddingModelLoader` mixin** (`lib/aia/tool_filter/embedding_model_loader.rb`): New module with `load_embedding_model(label, model_name)`. Included by both `ToolFilter::Zvec` and `ToolFilter::SqliteVec`, removing two identical 3-line embedding-load sequences. (P3-25)
203
- - **`ToolFilter::SqliteVec` rowid mapping** (`lib/aia/tool_filter/sqlite_vec.rb`): Replaced fragile `@tool_entries[rowid - 1]` positional lookup with `@tool_index` hash (`rowid → entry`). Both `create_database` and `load_persisted` populate the index; `do_filter_with_scores` uses `@tool_index[rowid]`. Lookup is now stable across deletions and reinsertions. (P3-31)
204
- - **`ToolFilter::TFIDF` vectorizer caching** (`lib/aia/tool_filter/tfidf.rb`): `Classifier::TFIDF.new`, `fit`, and full-corpus `transform` were called on every user turn. Now the vectorizer is fitted and all tool vectors are computed once in `do_prep` and cached as `@tfidf` / `@tool_vectors`. Per-turn cost is reduced to a single `@tfidf.transform(prompt)` call. (P3-24)
205
-
206
- ## [2.0.3.alpha] - 2026-03-27
207
-
208
- ### Improvements (Section 3 — Handler Cleanup)
209
-
210
- - **`ContentExtractor#extract_content`**: Replaced three identical `extract_reply` private methods in `SpawnHandler`, `DebateHandler`, and `DelegateHandler` with a single call to the shared `ContentExtractor#extract_content`. (P1-9)
211
- - **`HandlerProtocol` module** (`lib/aia/handler_protocol.rb`): New module defining the `handle(context)` interface. All five turn-level handlers now `include HandlerProtocol` and raise `NotImplementedError` from the base if `handle` is not overridden.
212
- - **`HandlerContext` struct** (`lib/aia/handler_context.rb`): New value object carrying `robot`, `prompt`, `decisions`, `config`, and `specialist_type` — replaces five incompatible handler signatures with a single unified protocol. All five handlers (`SpawnHandler`, `DebateHandler`, `DelegateHandler`, `MentionRouter`, `ModelSwitchHandler`) migrated to `handle(context)`. All call sites in `SpecialModeHandler` and `ChatLoop` updated. (P1-8)
213
- - **`Fzf`**: Removed dead code — `tempfile_path` method, `unlink_tempfile` method, and the `ensure` block that called `unlink_tempfile`. `fzf` now passes list items via `stdin_data:` only; no tempfile is created. (P3-29)
214
- - **Section 3.4** was completed as part of Section 2.5 (`UIPresenter#calculate_cost` already delegates to `CostCalculator`).
215
-
216
- ## [2.0.2.alpha] - 2026-03-27
217
-
218
- ### Improvements (Section 2 — Correctness Completions)
219
-
220
- - **`DecisionApplier`**: When `build_temp_robot` returns nil, now emits a `warn` and explicitly sets `context.model_overridden = false` before returning. Previously the turn fell through silently with no indication the model switch failed. (C4)
221
- - **`FactAsserter`**: Changed `config.models.each` → `Array(config.models).each` to prevent `NoMethodError` when `config.models` is nil during early KBS evaluation. (P1-10)
222
- - **`RuleRouter`**: Changed silent `next unless kb` to emit a structured warning (`[RuleRouter] Warning: knowledge base '#{name}' not found in pipeline — skipping`) when a KB from `KB_ORDER` is absent. Missing KBs no longer cause silent rule failures. (C5)
223
- - **`TrakFlowBridge`**: `attr_reader :db` moved from `private` to public. The database accessor is now part of the public API.
224
- - **`TaskCoordinator`**: Replaced `bridge.send(:db)` with `bridge.db`, removing the private-access workaround.
225
- - **New `AIA::CostCalculator` module** (`lib/aia/cost_calculator.rb`): Extracts the duplicated cost calculation logic that previously lived in `SessionTracker` and `UIPresenter`. Single entry point: `AIA::CostCalculator.calculate(model_id:, input_tokens:, output_tokens:)` → `{ available:, total_cost:, input_cost:, output_cost: }`. (P1-15)
226
- - **`SessionTracker`**: `compute_cost_for_model` and `compute_cost` now delegate to `CostCalculator`.
227
- - **`UIPresenter`**: `calculate_cost` now delegates to `CostCalculator`.
228
-
229
- ## [2.0.1.alpha] - 2026-03-27
230
-
231
- ### Improvements (Section 1 — Safety Net)
232
-
233
- - **`MCPConnectionManager`**: All reads of `@connected_clients`, `@connected_tools`, and `@connected_servers` are now wrapped in `@mutex.synchronize`. Eliminates data races between `connect_one` threads and callers of `inject_into`, `update_config`, `any_tools?`, `connected_server_names`, and `failed_server_names`. (C1)
234
- - **`AIA.reset!`**: New class method that nils all seven mutable singletons (`@config`, `@client`, `@session_tracker`, `@turn_state`, `@task_coordinator`, `@decisions`, `@rule_router`) for clean test isolation. (C2)
235
- - **`Decisions#add(:model_decision)`**: Now raises `ArgumentError` when `:model` is nil, preventing silent propagation of invalid model decisions downstream. (C3)
236
- - **`HistoryManager`**: All three `exit(1)` calls replaced with `raise AIA::Error`. Callers can now rescue or propagate the error; `AIA.run` catches it and exits with a message. (C7)
237
- - **`ToolFilter::TFIDF`**: Replaced undefined `logger.warn` in the rescue path with `Kernel#warn`, eliminating a `NoMethodError` that would mask the original classifier error. (P1-16)
238
-
239
- ## [2.0.0.alpha] - 2026-03-26
240
-
241
- ### Breaking Changes
242
- - **New execution engine**: AIA is now powered by `robot_lab` and `kbs`. The `RubyLLMAdapter` and the entire `lib/aia/adapter/` layer have been removed.
243
- - **`AIA.client` is now a `RobotLab::Robot` or `RobotLab::Network`**, built by `AIA::RobotFactory`. Code that references `AIA::RubyLLMAdapter` directly must be updated.
244
- - **Removed gems**: `ostruct` and `securerandom` are no longer dependencies.
245
-
246
- ### New Features
247
- - **`RobotFactory`**: Single entry point for building the AI backend. Supports single robot, parallel multi-model, consensus network, and pipeline network modes.
248
- - **`RuleRouter` with multi-KB architecture**: RETE-based rule engine (via `kbs` gem) with five specialized knowledge bases — input classification, model selection, MCP/tool routing, quality gates, and post-response learning.
249
- - **`NetworkBuilder`**: Extracted network construction for pipeline, parallel, and consensus topologies.
250
- - **Dynamic model switching**: Mid-session model changes via `ModelSwitchHandler`, `ModelAliasRegistry` (fuzzy name matching), and `HistoryTransfer` (conversation continuity across switches).
251
- - **`@mention` routing**: `MentionRouter` routes prompts to named robots via `@model-name` syntax in chat.
252
- - **MCP concurrency**: `McpConnectionManager` maintains persistent stdio connections; `McpDiscovery` and `McpGrouper` classify and route servers by capability.
253
- - **TrakFlow integration**: `TrakFlowBridge` creates plans from prompt pipelines and tracks task state. New `/trak` directives. TrakFlow MCP server config included.
254
- - **Advanced RobotLab patterns**:
255
- - `VerificationNetwork` — two robots answer independently, a reconciler produces a verified result
256
- - `DebateHandler` — multi-round debate between robots with convergence detection (max 5 rounds)
257
- - `PromptDecomposer` — breaks complex prompts into parallel subtasks
258
- - `ExpertRouter` — KBS-driven routing to domain-specialist robots with tailored model and MCP selection
259
- - `SpawnHandler` / `DelegateHandler` — dynamic robot spawning and subtask delegation
260
- - **Built-in tools**: `DelegateToForemanTool` and `TaskBoardTool` as `RubyLLM::Tool` subclasses.
261
- - **`DynamicRuleBuilder`**: Generates KBS route rules at runtime from discovered local tools and MCP servers, matching domains to activate the appropriate tools per turn.
262
- - **Semantic tool filtering**: Multiple backends in `lib/aia/tool_filter/` — KBS, LSI, TF-IDF, sqlite-vec, and zvec.
263
- - **`SessionTracker` and `TurnState`**: Per-session and per-turn state containers for metrics and cost tracking.
264
- - **`SystemPromptAssembler`**: Extracted system prompt resolution including role loading.
265
- - **`RobotNamer`**: Deterministic unique robot name generation.
266
-
267
- ### Improvements
268
- - `RobotFactory` decomposed into focused collaborators (`NetworkBuilder`, `ToolLoader`, `ToolFilter`, `SystemPromptAssembler`, `RobotNamer`)
269
- - `RuleRouter` refactored from single-KB to multi-KB registry with typed `Decisions` struct
270
- - `FactAsserter` and `DecisionApplier` extracted for testability; `FactAsserter` now supports asserting additional fact types
271
- - `StreamingRunner` extracted from `ChatLoop`
272
- - New `rules_dsl.rb` provides a user-facing DSL for writing custom routing rules
273
- - `ChatLoop` refactored AI response handling for cleaner robot tool execution and logging
274
- - `ChatLoop` improved empty user input handling — empty input exits cleanly (break) rather than looping
275
- - `Decisions` gains `group_by_mcp_server` — groups tool activations by their originating MCP server
276
-
277
- ### Dependencies
278
- - Added: `robot_lab ~> 0.0, >= 0.0.9`, `kbs ~> 0.2, >= 0.2.1`, `trak_flow`, `classifier`, `zvec`, `sqlite-vec`, `informers`
279
- - Removed: `ruby_llm` adapter layer (still used transitively via `robot_lab`)
280
- - `Gemfile.lock` added to `.gitignore`
281
-
282
200
  ## [1.0.0] - 2026-02-22
283
201
 
284
202
  ### Security Fixes