aia 0.9.24 → 0.10.2

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/CHANGELOG.md +84 -3
  4. data/README.md +179 -59
  5. data/bin/aia +6 -0
  6. data/docs/cli-reference.md +145 -72
  7. data/docs/configuration.md +156 -19
  8. data/docs/examples/tools/index.md +2 -2
  9. data/docs/faq.md +11 -11
  10. data/docs/guides/available-models.md +11 -11
  11. data/docs/guides/basic-usage.md +18 -17
  12. data/docs/guides/chat.md +57 -11
  13. data/docs/guides/executable-prompts.md +15 -15
  14. data/docs/guides/first-prompt.md +2 -2
  15. data/docs/guides/getting-started.md +6 -6
  16. data/docs/guides/image-generation.md +24 -24
  17. data/docs/guides/local-models.md +2 -2
  18. data/docs/guides/models.md +96 -18
  19. data/docs/guides/tools.md +4 -4
  20. data/docs/installation.md +2 -2
  21. data/docs/prompt_management.md +11 -11
  22. data/docs/security.md +3 -3
  23. data/docs/workflows-and-pipelines.md +1 -1
  24. data/examples/README.md +6 -6
  25. data/examples/headlines +3 -3
  26. data/lib/aia/aia_completion.bash +2 -2
  27. data/lib/aia/aia_completion.fish +4 -4
  28. data/lib/aia/aia_completion.zsh +2 -2
  29. data/lib/aia/chat_processor_service.rb +31 -21
  30. data/lib/aia/config/cli_parser.rb +403 -403
  31. data/lib/aia/config/config_section.rb +87 -0
  32. data/lib/aia/config/defaults.yml +219 -0
  33. data/lib/aia/config/defaults_loader.rb +147 -0
  34. data/lib/aia/config/mcp_parser.rb +151 -0
  35. data/lib/aia/config/model_spec.rb +67 -0
  36. data/lib/aia/config/validator.rb +185 -136
  37. data/lib/aia/config.rb +336 -17
  38. data/lib/aia/directive_processor.rb +14 -6
  39. data/lib/aia/directives/configuration.rb +24 -10
  40. data/lib/aia/directives/models.rb +3 -4
  41. data/lib/aia/directives/utility.rb +3 -2
  42. data/lib/aia/directives/web_and_file.rb +50 -47
  43. data/lib/aia/logger.rb +328 -0
  44. data/lib/aia/prompt_handler.rb +18 -22
  45. data/lib/aia/ruby_llm_adapter.rb +572 -69
  46. data/lib/aia/session.rb +9 -8
  47. data/lib/aia/ui_presenter.rb +20 -16
  48. data/lib/aia/utility.rb +50 -18
  49. data/lib/aia.rb +91 -66
  50. data/lib/extensions/ruby_llm/modalities.rb +2 -0
  51. data/mcp_servers/apple-mcp.json +8 -0
  52. data/mcp_servers/mcp_server_chart.json +11 -0
  53. data/mcp_servers/playwright_one.json +8 -0
  54. data/mcp_servers/playwright_two.json +8 -0
  55. data/mcp_servers/tavily_mcp_server.json +8 -0
  56. metadata +83 -25
  57. data/lib/aia/config/base.rb +0 -308
  58. data/lib/aia/config/defaults.rb +0 -91
  59. data/lib/aia/config/file_loader.rb +0 -163
  60. data/mcp_servers/imcp.json +0 -7
  61. data/mcp_servers/launcher.json +0 -11
  62. data/mcp_servers/timeserver.json +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9592d9ea1bbbbdc04f92dc822cfbdae91c1e04084530583e50f6cdb8a90460d
4
- data.tar.gz: 897e53ec02de0fcc46a0e5ddcf15ca13a462b7cc20e4f355950f5872e5b04f00
3
+ metadata.gz: 07ebe0842c8ba2a8d1a24a072066564fe83954157b272b3c02ba07f86ce6e8c9
4
+ data.tar.gz: 8e0e9f0b7963bed6db571e0670cedc38e4c540efca48c2b0d8ffe69545c4ba48
5
5
  SHA512:
6
- metadata.gz: 5e8b63a8ca892346e4dd1090ef487e4fc6dc6b9395238ecc6208128d8908a5dca87d730a9193a15b05dbb005b8d9eb84e2bb7f63100982130eeec69e0bb9483d
7
- data.tar.gz: 660c1c40117300223a7bd88c67ec826225a44ada72d459ee6c8fd3e3c015e81a7874a9618220c4dc7caf3de930ee140d29ef1c7c8dfc205ecfeedef8e629b36a
6
+ metadata.gz: e248f19290dc0f2b0cb132c952e1d6a3e50cc3bf8435a2cfad5a8f7e342790a0bb23a958eee2c50bb993a0943f273b30df1e72be03ca29b929789f3885c27e17
7
+ data.tar.gz: 18985b3f3348e6ed359bd5920ef44b675976ca09c40aa6e9abb17950b9260f682df0fb16a15f673e958b0cc6f2300669e92ba90b925ec73fc0620a7577863baa
data/.version CHANGED
@@ -1 +1 @@
1
- 0.9.24
1
+ 0.10.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,72 @@
1
1
  # Changelog
2
- ## [Unreleased]
2
+ ## [0.10.2] - 2025-12-25
3
+
4
+ **Merry Christmas!**
5
+
6
+ ### Breaking Changes
7
+ - **Renamed `--metrics` to `--tokens`**: The CLI flag for displaying token usage has been renamed
8
+ - `--metrics` → `--tokens`
9
+ - Environment variable: `AIA_FLAGS__TOKENS`
10
+ - The `--cost` flag now automatically enables `--tokens`
11
+
12
+ ### New Features
13
+ - **Parallel MCP Connections**: Replaced serial MCP server connections with fiber-based parallel execution using SimpleFlow
14
+ - MCP servers now connect concurrently instead of sequentially
15
+ - Total connection time reduced from sum(timeouts) to max(timeouts)
16
+ - Added `simple_flow` gem dependency for lightweight pipeline-based concurrency
17
+
18
+ ### Improvements
19
+ - **MCP Failure Feedback**: Added per-server error messages when MCP connections fail
20
+ - Users now see which specific server failed and why (e.g., "⚠️ MCP: 'iMCP' failed - Connection timed out")
21
+ - Previously only showed generic timeout message without identifying the failing server
22
+
23
+ ### Bug Fixes
24
+ - **Ruby 4.0 Compatibility**: Fixed `NameError` in `lib/extensions/ruby_llm/modalities.rb`
25
+ - Added `require 'ruby_llm'` before extending `RubyLLM::Model::Modalities`
26
+ - Resolves "uninitialized constant RubyLLM" error on Ruby 4.0.0-preview2
27
+
28
+ ### Technical Changes
29
+ - Added `simple_flow` gem dependency to gemspec
30
+ - Refactored MCP connection code in `lib/aia/ruby_llm_adapter.rb`:
31
+ - Added `support_mcp_with_simple_flow` method using SimpleFlow::Pipeline
32
+ - Added `build_mcp_connection_step`, `register_single_mcp_client`, `extract_mcp_results`, `report_mcp_connection_results` helper methods
33
+ - Removed old serial methods: `support_mcp_lazy`, `register_mcp_clients`, `start_mcp_clients`, `reconcile_mcp_server_status`, `check_mcp_client_status`
34
+ - Net reduction of ~60 lines of code with cleaner architecture
35
+
36
+ ### Documentation
37
+ - **Multi-Model Concurrent Comparison**: Added prominent documentation highlighting the ability to query multiple LLMs simultaneously
38
+ - Added "Concurrent Multi-Model Comparison" spotlight section to README.md
39
+ - Added "Token Usage and Cost Tracking" subsection to Multi-Model Support in README.md
40
+ - Added comprehensive "Token Usage and Cost Tracking" section to `docs/guides/models.md`
41
+ - **Token and Cost Flags**: Added documentation for `--tokens` and `--cost` flags
42
+ - Updated `docs/cli-reference.md` with full flag descriptions
43
+ - Updated `docs/configuration.md` with environment variable examples
44
+ - Added "Token Usage and Cost Tracking" section to `docs/guides/chat.md`
45
+ - Updated README.md Key Command-Line Options and Configuration tables
46
+
47
+ ## [0.10.0] - 2025-12-23
48
+
49
+ ### Breaking Changes
50
+ - **Environment Variable Naming Convention**: Updated to use nested naming with double underscore (`__`)
51
+ - `AIA_PROMPTS_DIR` → `AIA_PROMPTS__DIR`
52
+ - `AIA_OUT_FILE` → `AIA_OUTPUT__FILE`
53
+ - `AIA_VERBOSE` → `AIA_FLAGS__VERBOSE`
54
+ - `AIA_DEBUG` → `AIA_FLAGS__DEBUG`
55
+ - `AIA_CHAT` → `AIA_FLAGS__CHAT`
56
+ - `AIA_TEMPERATURE` → `AIA_LLM__TEMPERATURE`
57
+ - `AIA_MARKDOWN` → `AIA_OUTPUT__MARKDOWN`
58
+ - Note: `AIA_MODEL` remains unchanged (top-level, not nested)
59
+
60
+ ### Bug Fixes
61
+ - **MCP Tool Timeout Handling**: Fixed issue where MCP tool timeouts corrupted conversation history
62
+ - Added `repair_incomplete_tool_calls` method to add synthetic tool results when timeouts occur
63
+ - Prevents "assistant message with 'tool_calls' must be followed by tool messages" API errors
64
+ - Conversation can now continue gracefully after tool timeouts
65
+
66
+ - **Tool Crash Handling**: Fixed crash when tools throw non-StandardError exceptions (e.g., LoadError)
67
+ - Changed `rescue StandardError` to `rescue Exception` to catch all error types
68
+ - Added `handle_tool_crash` method that logs errors with 5-line traceback
69
+ - Tool crashes no longer crash AIA - conversation continues gracefully
3
70
 
4
71
  ## [0.9.24] 2025-12-17
5
72
  ### Fixes
@@ -12,6 +79,20 @@
12
79
  - Shows "No tools match the filter: [filter]" when no matches found
13
80
  - Header indicates when filtering is active: "Available Tools (filtered by 'filter')"
14
81
 
82
+ ### Documentation
83
+ - Updated all shell completion scripts (`aia_completion.bash`, `aia_completion.zsh`, `aia_completion.fish`) to use new nested naming convention
84
+ - Updated `docs/configuration.md` with comprehensive environment variable documentation
85
+ - Updated `docs/cli-reference.md` environment variables section
86
+ - Updated `docs/prompt_management.md` with correct envar names
87
+ - Updated `docs/faq.md` with correct envar names
88
+ - Updated `docs/guides/basic-usage.md` shell setup examples
89
+
90
+ ### Technical Changes
91
+ - Enhanced `lib/aia/ruby_llm_adapter.rb`:
92
+ - Added `repair_incomplete_tool_calls` method for conversation integrity
93
+ - Added `handle_tool_crash` method for graceful error handling
94
+ - Removed debug statements
95
+
15
96
  ## [0.9.23] 2025-12-06
16
97
 
17
98
  ### New Features
@@ -178,7 +259,7 @@ Now with the fix:
178
259
  ### Usage Examples
179
260
  ```bash
180
261
  # Multi-model chat now properly isolates each model's context
181
- bin/aia --chat --model lms/openai/gpt-oss-20b,ollama/gpt-oss:20b --metrics
262
+ bin/aia --chat --model lms/openai/gpt-oss-20b,ollama/gpt-oss:20b --tokens
182
263
 
183
264
  > pick a random language and say hello
184
265
  # LMS: "Habari!" (Swahili)
@@ -313,7 +394,7 @@ aia --model ollama/llama3.2 --chat
313
394
 
314
395
  ## [0.9.13] 2025-09-02
315
396
  ### New Features
316
- - **NEW FEATURE**: Added `--metrics` flag to show token counts for each model
397
+ - **NEW FEATURE**: Added `--tokens` flag to show token counts for each model
317
398
  - **NEW FEATURE**: Added `--cost` flag to enable cost estimation for each model
318
399
 
319
400
  ### Improvements
data/README.md CHANGED
@@ -5,6 +5,20 @@
5
5
  <p>Check out the new <a href="http://madbomber.github.io/aia/guides/models/?h=inline+role+syntax#inline-role-syntax">Inline Role Syntax</a> when working with multiple concurrent models.</p>
6
6
  </div>
7
7
 
8
+ ---
9
+
10
+ > ## ⚠️ BREAKING CHANGES IN v0.10.0 ⚠️
11
+ >
12
+ > **Version 0.10.0 will introduce breaking changes affecting:**
13
+ >
14
+ > - **Environment Variables** — Naming conventions for system environment variables will change
15
+ > - **Configuration Files** — Both the content format and structure of configuration files will be updated
16
+ > - **File Locations** — Expected locations for configuration files will change
17
+ >
18
+ > **Please review the migration guide (coming soon) before upgrading to v0.10.0.**
19
+
20
+ ---
21
+
8
22
  AIA is a command-line utility that facilitates interaction with AI models through dynamic prompt management. It automates the management of pre-compositional prompts and executes generative AI commands with enhanced features including embedded directives, shell integration, embedded Ruby, history management, interactive chat, and prompt workflows.
9
23
 
10
24
  AIA leverages the following Ruby gems:
@@ -65,6 +79,47 @@ For more information on AIA visit these locations:
65
79
 
66
80
  ```
67
81
 
82
+ ---
83
+
84
+ ## Concurrent Multi-Model Comparison
85
+
86
+ One of AIA's most powerful features is the ability to send a single prompt to multiple AI models simultaneously and compare their responses side-by-side—complete with token usage and cost tracking.
87
+
88
+ ```bash
89
+ # Compare responses from 3 models with token counts and cost estimates
90
+ aia --chat -m gpt-4o,claude-3-5-sonnet,gemini-1.5-pro --tokens --cost
91
+ ```
92
+
93
+ **Example output:**
94
+ ```
95
+ You: What's the best approach for handling database migrations in a microservices architecture?
96
+
97
+ from: gpt-4o
98
+ Use a versioned migration strategy with backward compatibility...
99
+
100
+ from: claude-3-5-sonnet
101
+ Consider the Expand-Contract pattern for zero-downtime migrations...
102
+
103
+ from: gemini-1.5-pro
104
+ Implement a schema registry with event-driven synchronization...
105
+
106
+ ┌─────────────────────────────────────────────────────────────────┐
107
+ │ Model │ Input Tokens │ Output Tokens │ Cost │
108
+ ├─────────────────────────────────────────────────────────────────┤
109
+ │ gpt-4o │ 156 │ 342 │ $0.0089 │
110
+ │ claude-3-5-sonnet │ 156 │ 418 │ $0.0063 │
111
+ │ gemini-1.5-pro │ 156 │ 387 │ $0.0041 │
112
+ └─────────────────────────────────────────────────────────────────┘
113
+ ```
114
+
115
+ **Why this matters:**
116
+ - **Compare reasoning approaches** - See how different models tackle the same problem
117
+ - **Identify blind spots** - One model might catch something others miss
118
+ - **Cost optimization** - Find the best price/performance ratio for your use case
119
+ - **Consensus building** - Use `--consensus` to synthesize the best answer from all models
120
+
121
+ ---
122
+
68
123
  <!-- Tocer[start]: Auto-generated, don't remove. -->
69
124
 
70
125
  ## Table of Contents
@@ -190,7 +245,7 @@ aia --chat [--role ROLE] [--model MODEL]
190
245
  aia --model gpt-4 my_prompt
191
246
 
192
247
  # Specify output file
193
- aia --out_file result.md my_prompt
248
+ aia --output result.md my_prompt
194
249
 
195
250
  # Use a role/system prompt
196
251
  aia --role expert my_prompt
@@ -209,8 +264,10 @@ aia --fuzzy
209
264
  | `--no-consensus` | Force individual responses | `aia --no-consensus` |
210
265
  | `--role ROLE` | Use a role/system prompt (default for all models) | `aia --role expert` |
211
266
  | `--list-roles` | List available role files | `aia --list-roles` |
212
- | `--out_file FILE` | Specify output file | `aia --out_file results.md` |
267
+ | `--output FILE` | Specify output file | `aia --output results.md` |
213
268
  | `--fuzzy` | Use fuzzy search for prompts | `aia --fuzzy` |
269
+ | `--tokens` | Display token usage in chat mode | `aia --chat --tokens` |
270
+ | `--cost` | Include cost calculations with token usage | `aia --chat --cost` |
214
271
  | `--help` | Show complete help | `aia --help` |
215
272
 
216
273
  ### Directory Structure
@@ -235,7 +292,7 @@ The most commonly used configuration options:
235
292
  |--------|---------|-------------|
236
293
  | `model` | `gpt-4o-mini` | AI model to use |
237
294
  | `prompts_dir` | `~/.prompts` | Directory containing prompts |
238
- | `out_file` | `temp.md` | Default output file |
295
+ | `output` | `temp.md` | Default output file |
239
296
  | `temperature` | `0.7` | Model creativity (0.0-1.0) |
240
297
  | `chat` | `false` | Start in chat mode |
241
298
 
@@ -254,8 +311,8 @@ AIA determines configuration settings using this order (highest to lowest priori
254
311
  **Environment Variables:**
255
312
  ```bash
256
313
  export AIA_MODEL=gpt-4
257
- export AIA_PROMPTS_DIR=~/my-prompts
258
- export AIA_TEMPERATURE=0.8
314
+ export AIA_PROMPTS__DIR=~/my-prompts
315
+ export AIA_LLM__TEMPERATURE=0.8
259
316
  ```
260
317
 
261
318
  **Configuration File** (`~/.aia/config.yml`):
@@ -283,48 +340,50 @@ Your prompt content here...
283
340
  |------------------|-------------|---------------|---------------------|
284
341
  | adapter | --adapter | ruby_llm | AIA_ADAPTER |
285
342
  | aia_dir | | ~/.aia | AIA_DIR |
286
- | append | -a, --append | false | AIA_APPEND |
287
- | chat | --chat | false | AIA_CHAT |
288
- | clear | --clear | false | AIA_CLEAR |
289
- | config_file | -c, --config_file | ~/.aia/config.yml | AIA_CONFIG_FILE |
290
- | debug | -d, --debug | false | AIA_DEBUG |
291
- | embedding_model | --em, --embedding_model | text-embedding-ada-002 | AIA_EMBEDDING_MODEL |
292
- | erb | | true | AIA_ERB |
293
- | frequency_penalty | --frequency_penalty | 0.0 | AIA_FREQUENCY_PENALTY |
294
- | fuzzy | -f, --fuzzy | false | AIA_FUZZY |
295
- | image_quality | --iq, --image_quality | standard | AIA_IMAGE_QUALITY |
296
- | image_size | --is, --image_size | 1024x1024 | AIA_IMAGE_SIZE |
297
- | image_style | --style, --image_style | vivid | AIA_IMAGE_STYLE |
298
- | log_file | -l, --log_file | ~/.prompts/_prompts.log | AIA_LOG_FILE |
299
- | markdown | --md, --markdown | true | AIA_MARKDOWN |
300
- | max_tokens | --max_tokens | 2048 | AIA_MAX_TOKENS |
343
+ | append | -a, --append | false | AIA_FLAGS__APPEND |
344
+ | chat | --chat | false | AIA_FLAGS__CHAT |
345
+ | clear | --clear | false | AIA_FLAGS__CLEAR |
346
+ | config_file | -c, --config-file | ~/.aia/config.yml | AIA_CONFIG_FILE |
347
+ | debug | -d, --debug | false | AIA_FLAGS__DEBUG |
348
+ | embedding_model | --em, --embedding_model | text-embedding-ada-002 | AIA_LLM__EMBEDDING_MODEL |
349
+ | erb | | true | AIA_FLAGS__ERB |
350
+ | frequency_penalty | --frequency-penalty | 0.0 | AIA_LLM__FREQUENCY_PENALTY |
351
+ | fuzzy | -f, --fuzzy | false | AIA_FLAGS__FUZZY |
352
+ | image_quality | --iq, --image-quality | standard | AIA_IMAGE__QUALITY |
353
+ | image_size | --is, --image-size | 1024x1024 | AIA_IMAGE__SIZE |
354
+ | image_style | --style, --image-style | vivid | AIA_IMAGE__STYLE |
355
+ | history_file | --history-file | ~/.prompts/_prompts.log | AIA_OUTPUT__HISTORY_FILE |
356
+ | markdown | --md, --markdown | true | AIA_OUTPUT__MARKDOWN |
357
+ | max_tokens | --max-tokens | 2048 | AIA_LLM__MAX_TOKENS |
301
358
  | model | -m, --model | gpt-4o-mini | AIA_MODEL |
302
359
  | next | -n, --next | nil | AIA_NEXT |
303
- | out_file | -o, --out_file | temp.md | AIA_OUT_FILE |
304
- | parameter_regex | --regex | '(?-mix:(\[[A-Z _\|]+\]))' | AIA_PARAMETER_REGEX |
360
+ | output | -o, --output | temp.md | AIA_OUTPUT__FILE |
361
+ | parameter_regex | --regex | '(?-mix:(\[[A-Z _\|]+\]))' | AIA_PROMPTS__PARAMETER_REGEX |
305
362
  | pipeline | --pipeline | [] | AIA_PIPELINE |
306
- | presence_penalty | --presence_penalty | 0.0 | AIA_PRESENCE_PENALTY |
307
- | prompt_extname | | .txt | AIA_PROMPT_EXTNAME |
308
- | prompts_dir | -p, --prompts_dir | ~/.prompts | AIA_PROMPTS_DIR |
309
- | refresh | --refresh | 7 (days) | AIA_REFRESH |
363
+ | presence_penalty | --presence-penalty | 0.0 | AIA_LLM__PRESENCE_PENALTY |
364
+ | prompt_extname | | .txt | AIA_PROMPTS__EXTNAME |
365
+ | prompts_dir | --prompts-dir | ~/.prompts | AIA_PROMPTS__DIR |
366
+ | refresh | --refresh | 7 (days) | AIA_REGISTRY__REFRESH |
310
367
  | require_libs | --rq --require | [] | AIA_REQUIRE_LIBS |
311
368
  | role | -r, --role | | AIA_ROLE |
312
- | roles_dir | | ~/.prompts/roles | AIA_ROLES_DIR |
313
- | roles_prefix | --roles_prefix | roles | AIA_ROLES_PREFIX |
314
- | shell | | true | AIA_SHELL |
315
- | speak | --speak | false | AIA_SPEAK |
316
- | speak_command | | afplay | AIA_SPEAK_COMMAND |
317
- | speech_model | --sm, --speech_model | tts-1 | AIA_SPEECH_MODEL |
318
- | system_prompt | --system_prompt | | AIA_SYSTEM_PROMPT |
319
- | temperature | -t, --temperature | 0.7 | AIA_TEMPERATURE |
320
- | terse | --terse | false | AIA_TERSE |
321
- | tool_paths | --tools | [] | AIA_TOOL_PATHS |
322
- | allowed_tools | --at --allowed_tools | nil | AIA_ALLOWED_TOOLS |
323
- | rejected_tools | --rt --rejected_tools | nil | AIA_REJECTED_TOOLS |
324
- | top_p | --top_p | 1.0 | AIA_TOP_P |
325
- | transcription_model | --tm, --transcription_model | whisper-1 | AIA_TRANSCRIPTION_MODEL |
326
- | verbose | -v, --verbose | false | AIA_VERBOSE |
327
- | voice | --voice | alloy | AIA_VOICE |
369
+ | roles_dir | | ~/.prompts/roles | AIA_ROLES__DIR |
370
+ | roles_prefix | --roles-prefix | roles | AIA_ROLES__PREFIX |
371
+ | shell | | true | AIA_FLAGS__SHELL |
372
+ | speak | --speak | false | AIA_FLAGS__SPEAK |
373
+ | speak_command | | afplay | AIA_SPEECH__COMMAND |
374
+ | speech_model | --sm, --speech-model | tts-1 | AIA_SPEECH__MODEL |
375
+ | system_prompt | --system-prompt | | AIA_SYSTEM_PROMPT |
376
+ | temperature | -t, --temperature | 0.7 | AIA_LLM__TEMPERATURE |
377
+ | terse | --terse | false | AIA_FLAGS__TERSE |
378
+ | tokens | --tokens | false | AIA_FLAGS__TOKENS |
379
+ | cost | --cost | false | AIA_FLAGS__COST |
380
+ | tool_paths | --tools | [] | AIA_TOOLS__PATHS |
381
+ | allowed_tools | --at, --allowed-tools | nil | AIA_TOOLS__ALLOWED |
382
+ | rejected_tools | --rt, --rejected-tools | nil | AIA_TOOLS__REJECTED |
383
+ | top_p | --top-p | 1.0 | AIA_LLM__TOP_P |
384
+ | transcription_model | --tm, --transcription-model | whisper-1 | AIA_TRANSCRIPTION__MODEL |
385
+ | verbose | -v, --verbose | false | AIA_FLAGS__VERBOSE |
386
+ | voice | --voice | alloy | AIA_SPEECH__VOICE |
328
387
 
329
388
  </details>
330
389
 
@@ -566,6 +625,39 @@ Model Details:
566
625
  - **Error Handling**: Invalid models are reported but don't prevent valid models from working
567
626
  - **Batch Mode Support**: Multi-model responses are properly formatted in output files
568
627
 
628
+ #### Token Usage and Cost Tracking
629
+
630
+ Monitor token consumption and estimate costs across all models with `--tokens` and `--cost`:
631
+
632
+ ```bash
633
+ # Display token usage for each model
634
+ aia my_prompt -m gpt-4o,claude-3-sonnet --tokens
635
+
636
+ # Include cost estimates (automatically enables --tokens)
637
+ aia my_prompt -m gpt-4o,claude-3-sonnet --cost
638
+
639
+ # In chat mode with full tracking
640
+ aia --chat -m gpt-4o,claude-3-sonnet,gemini-pro --cost
641
+ ```
642
+
643
+ **Token Usage Output:**
644
+ ```
645
+ from: gpt-4o
646
+ Here's my analysis of the code...
647
+
648
+ from: claude-3-sonnet
649
+ Looking at this code, I notice...
650
+
651
+ Tokens: gpt-4o: input=245, output=312 | claude-3-sonnet: input=245, output=287
652
+ Cost: gpt-4o: $0.0078 | claude-3-sonnet: $0.0045 | Total: $0.0123
653
+ ```
654
+
655
+ **Use Cases for Token/Cost Tracking:**
656
+ - **Budget management** - Monitor API costs in real-time during development
657
+ - **Model comparison** - Identify which models are most cost-effective for your tasks
658
+ - **Optimization** - Find the right balance between response quality and cost
659
+ - **Billing insights** - Track usage patterns across different model providers
660
+
569
661
  ### Local Model Support
570
662
 
571
663
  AIA supports running local AI models through Ollama and LM Studio, providing privacy, offline capability, and cost savings.
@@ -721,7 +813,7 @@ Provide comprehensive background information.
721
813
 
722
814
  **analyze.txt:**
723
815
  ```
724
- //config out_file = analysis.md
816
+ //config output = analysis.md
725
817
  //next summarize
726
818
 
727
819
  Analyze the research data and identify key insights.
@@ -729,7 +821,7 @@ Analyze the research data and identify key insights.
729
821
 
730
822
  **summarize.txt:**
731
823
  ```
732
- //config out_file = summary.md
824
+ //config output = summary.md
733
825
 
734
826
  Create a concise summary of the analysis with actionable recommendations.
735
827
  ```
@@ -897,8 +989,8 @@ aia --tools ~/my-tools/ --chat
897
989
  aia --tools weather.rb,calculator.rb --chat
898
990
 
899
991
  # Filter tools
900
- aia --tools ~/tools/ --allowed_tools weather,calc
901
- aia --tools ~/tools/ --rejected_tools deprecated
992
+ aia --tools ~/tools/ --allowed-tools weather,calc
993
+ aia --tools ~/tools/ --rejected-tools deprecated
902
994
  ```
903
995
 
904
996
  **Tool Examples** (see `examples/tools/` directory):
@@ -1180,13 +1272,13 @@ aia --chat -m gpt-4o-mini,gpt-3.5-turbo --consensus
1180
1272
 
1181
1273
  The `--exec` flag is used to create executable prompts. If it is not present on the shebang line then the prompt file will be treated like any other context file. That means that the file will be included as context in the prompt but no dynamic content integration or directives will be processed. All other AIA options are, well, optional. All you need is an initial prompt ID and the --exec flag.
1182
1274
 
1183
- In the example below the option `--no-out_file` is used to direct the output from the LLM processing of the prompt to STDOUT. This way the executable prompts can be good citizens on the *nix command line receiving piped in input via STDIN and send its output to STDOUT.
1275
+ In the example below the option `--no-output` is used to direct the output from the LLM processing of the prompt to STDOUT. This way the executable prompts can be good citizens on the *nix command line receiving piped in input via STDIN and send its output to STDOUT.
1184
1276
 
1185
1277
  Create executable prompts:
1186
1278
 
1187
1279
  **weather_report** (make executable with `chmod +x`):
1188
1280
  ```bash
1189
- #!/usr/bin/env aia run --no-out_file --exec
1281
+ #!/usr/bin/env aia run --no-output --exec
1190
1282
  # Get current storm activity for the east and south coast of the US
1191
1283
 
1192
1284
  Summarize the tropical storm outlook fpr the Atlantic, Caribbean Sea and Gulf of America.
@@ -1222,13 +1314,13 @@ Usage: `aia ad_hoc` - perfect for any quick one-shot question without cluttering
1222
1314
  #### Recommended Shell Setup
1223
1315
  ```bash
1224
1316
  # ~/.bashrc_aia
1225
- export AIA_PROMPTS_DIR=~/.prompts
1226
- export AIA_OUT_FILE=./temp.md
1317
+ export AIA_PROMPTS__DIR=~/.prompts
1318
+ export AIA_OUTPUT__FILE=./temp.md
1227
1319
  export AIA_MODEL=gpt-4o-mini
1228
- export AIA_VERBOSE=true # Shows spinner while waiting for LLM response
1320
+ export AIA_FLAGS__VERBOSE=true # Shows spinner while waiting for LLM response
1229
1321
 
1230
1322
  alias chat='aia --chat --terse'
1231
- ask() { echo "$1" | aia run --no-out_file; }
1323
+ ask() { echo "$1" | aia run --no-output; }
1232
1324
  ```
1233
1325
 
1234
1326
  The `chat` alias and the `ask` function (shown above in HASH) are two powerful tools for interacting with the AI assistant. The `chat` alias allows you to engage in an interactive conversation with the AI assistant, while the `ask` function allows you to ask a question and receive a response. Later in this document the `run` prompt ID is discussed. Besides using the run prompt ID here its also used in making executable prompt files.
@@ -1287,7 +1379,7 @@ chmod 600 ~/.prompts/*.txt
1287
1379
  **Prompt not found:**
1288
1380
  ```bash
1289
1381
  # Check prompts directory
1290
- ls $AIA_PROMPTS_DIR
1382
+ ls $AIA_PROMPTS__DIR
1291
1383
 
1292
1384
  # Verify prompt file exists
1293
1385
  ls ~/.prompts/my_prompt.txt
@@ -1299,7 +1391,7 @@ aia --fuzzy
1299
1391
  **Model errors:**
1300
1392
  ```bash
1301
1393
  # List available models
1302
- aia --available_models
1394
+ aia --available-models
1303
1395
 
1304
1396
  # Check model name spelling
1305
1397
  aia --model gpt-4o # Correct
@@ -1327,27 +1419,55 @@ aia --debug --config
1327
1419
  | Error | Cause | Solution |
1328
1420
  |-------|-------|----------|
1329
1421
  | "Prompt not found" | Missing prompt file | Check file exists and spelling |
1330
- | "Model not available" | Invalid model name | Use `--available_models` to list valid models |
1422
+ | "Model not available" | Invalid model name | Use `--available-models` to list valid models |
1331
1423
  | "Shell command failed" | Invalid shell syntax | Test shell commands separately first |
1332
1424
  | "Configuration error" | Invalid config syntax | Check config file YAML syntax |
1333
1425
 
1334
- ### Debug Mode
1426
+ ### Debug Mode and Log Level Options
1427
+
1428
+ AIA provides multiple log level options to control the verbosity of logging output. These options set the log level for all three loggers:
1429
+ - **aia**: Used within the AIA codebase for application-level logging
1430
+ - **llm**: Passed to the RubyLLM gem's configuration (`RubyLLM.logger`)
1431
+ - **mcp**: Passed to the RubyLLM::MCP process (`RubyLLM::MCP.logger`)
1335
1432
 
1336
- Enable debug output for troubleshooting:
1433
+ | Option | Description |
1434
+ |--------|-------------|
1435
+ | `-d, --debug` | Enable debug output (most verbose) and set all loggers to DEBUG level |
1436
+ | `--no-debug` | Disable debug output |
1437
+ | `--info` | Set all loggers to INFO level |
1438
+ | `--warn` | Set all loggers to WARN level (default) |
1439
+ | `--error` | Set all loggers to ERROR level |
1440
+ | `--fatal` | Set all loggers to FATAL level (least verbose) |
1337
1441
 
1338
1442
  ```bash
1339
- # Enable debug mode
1443
+ # Enable debug mode (most verbose - shows all log messages)
1340
1444
  aia --debug my_prompt
1341
1445
 
1342
1446
  # Combine with verbose for maximum output
1343
1447
  aia --debug --verbose my_prompt
1448
+
1449
+ # Use info level for moderate logging
1450
+ aia --info my_prompt
1451
+
1452
+ # Use error level to only see errors and fatal messages
1453
+ aia --error my_prompt
1454
+
1455
+ # Use fatal level for minimal logging (only critical errors)
1456
+ aia --fatal --chat
1344
1457
  ```
1345
1458
 
1459
+ **Log Level Hierarchy** (from most to least verbose):
1460
+ 1. **debug** - All messages including detailed debugging information
1461
+ 2. **info** - Informational messages and above
1462
+ 3. **warn** - Warnings, errors, and fatal messages (default)
1463
+ 4. **error** - Only errors and fatal messages
1464
+ 5. **fatal** - Only critical/fatal messages
1465
+
1346
1466
  ### Performance Issues
1347
1467
 
1348
1468
  **Slow model responses:**
1349
1469
  - Try smaller/faster models: `--model gpt-4o-mini`
1350
- - Reduce max_tokens: `--max_tokens 1000`
1470
+ - Reduce max_tokens: `--max-tokens 1000`
1351
1471
  - Use lower temperature for faster responses: `--temperature 0.1`
1352
1472
 
1353
1473
  **Large prompt processing:**
data/bin/aia CHANGED
@@ -3,4 +3,10 @@
3
3
 
4
4
  require_relative '../lib/aia'
5
5
 
6
+ # Handle Ctrl-C gracefully
7
+ Signal.trap('INT') do
8
+ warn "\nInterrupted. Exiting..."
9
+ exit 130
10
+ end
11
+
6
12
  AIA.run