aia 0.9.24 → 0.11.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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc +7 -0
  3. data/.version +1 -1
  4. data/CHANGELOG.md +133 -3
  5. data/README.md +185 -59
  6. data/bin/aia +6 -0
  7. data/docs/cli-reference.md +339 -76
  8. data/docs/configuration.md +458 -162
  9. data/docs/examples/tools/index.md +2 -2
  10. data/docs/faq.md +18 -15
  11. data/docs/guides/available-models.md +11 -11
  12. data/docs/guides/basic-usage.md +18 -17
  13. data/docs/guides/chat.md +57 -11
  14. data/docs/guides/executable-prompts.md +15 -15
  15. data/docs/guides/first-prompt.md +2 -2
  16. data/docs/guides/getting-started.md +6 -6
  17. data/docs/guides/image-generation.md +24 -24
  18. data/docs/guides/index.md +1 -0
  19. data/docs/guides/local-models.md +7 -5
  20. data/docs/guides/models.md +135 -46
  21. data/docs/guides/shared-tools.md +254 -0
  22. data/docs/guides/tools.md +10 -35
  23. data/docs/index.md +16 -0
  24. data/docs/installation.md +19 -10
  25. data/docs/mcp-integration.md +44 -29
  26. data/docs/prompt_management.md +11 -11
  27. data/docs/security.md +3 -3
  28. data/docs/workflows-and-pipelines.md +1 -1
  29. data/examples/README.md +6 -6
  30. data/examples/headlines +3 -3
  31. data/lib/aia/aia_completion.bash +2 -2
  32. data/lib/aia/aia_completion.fish +4 -4
  33. data/lib/aia/aia_completion.zsh +2 -2
  34. data/lib/aia/chat_processor_service.rb +31 -21
  35. data/lib/aia/config/cli_parser.rb +420 -401
  36. data/lib/aia/config/defaults.yml +221 -0
  37. data/lib/aia/config/mcp_parser.rb +151 -0
  38. data/lib/aia/config/model_spec.rb +67 -0
  39. data/lib/aia/config/validator.rb +474 -124
  40. data/lib/aia/config.rb +335 -17
  41. data/lib/aia/directive_processor.rb +14 -6
  42. data/lib/aia/directives/configuration.rb +24 -10
  43. data/lib/aia/directives/models.rb +3 -4
  44. data/lib/aia/directives/utility.rb +3 -2
  45. data/lib/aia/directives/web_and_file.rb +50 -47
  46. data/lib/aia/logger.rb +328 -0
  47. data/lib/aia/prompt_handler.rb +18 -22
  48. data/lib/aia/ruby_llm_adapter.rb +593 -69
  49. data/lib/aia/session.rb +9 -8
  50. data/lib/aia/ui_presenter.rb +20 -16
  51. data/lib/aia/utility.rb +50 -18
  52. data/lib/aia.rb +85 -66
  53. data/lib/extensions/ruby_llm/modalities.rb +2 -0
  54. data/mcp_servers/README.md +20 -0
  55. data/mcp_servers/apple-mcp.json +8 -0
  56. data/mcp_servers/mcp_server_chart.json +11 -0
  57. data/mcp_servers/playwright_one.json +8 -0
  58. data/mcp_servers/playwright_two.json +8 -0
  59. data/mcp_servers/tavily_mcp_server.json +8 -0
  60. data/mkdocs.yml +1 -0
  61. metadata +79 -22
  62. data/lib/aia/config/base.rb +0 -308
  63. data/lib/aia/config/defaults.rb +0 -91
  64. data/lib/aia/config/file_loader.rb +0 -163
  65. data/mcp_servers/imcp.json +0 -7
  66. data/mcp_servers/launcher.json +0 -11
  67. 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: b583dae0c86c40fc70dc5d71e39cc6781283e93af38a5773bfcfe92fbbdb9c65
4
+ data.tar.gz: ed7b710bee9a484c1f25bf450a2bcfb7ed1db701a5962a9829bc7f9404c0b370
5
5
  SHA512:
6
- metadata.gz: 5e8b63a8ca892346e4dd1090ef487e4fc6dc6b9395238ecc6208128d8908a5dca87d730a9193a15b05dbb005b8d9eb84e2bb7f63100982130eeec69e0bb9483d
7
- data.tar.gz: 660c1c40117300223a7bd88c67ec826225a44ada72d459ee6c8fd3e3c015e81a7874a9618220c4dc7caf3de930ee140d29ef1c7c8dfc205ecfeedef8e629b36a
6
+ metadata.gz: c00641d58b7feda9cb3930561857fd203fa7f623137e4758e87193e3528106a173a0faf1e12a57fe2dd326d6506ba4e26d4d7c33c1eda90e58ee6bd3fca4d947
7
+ data.tar.gz: b9707f94782fc48566da722b1144a7e60d90f6a8b1507e4ccb5148cd84cccbe088b066e176893500caf052cf295cfe3c20a1c80415eb2623d42180b270ae7e52
data/.envrc CHANGED
@@ -2,3 +2,10 @@ source_up
2
2
 
3
3
  export RR=`pwd`
4
4
  # PATH_add $RR/bin
5
+
6
+ # see aia --help for --model option
7
+ # The format of a "model" is [provider/]model_name[=roll_id]
8
+ # where provider and roll_id are optional
9
+ # Use a comma to seperate the models in a multi-model setup
10
+ #
11
+ # export AIA_MODEL=claude-haiku-4-5,gpt-4o-mini
data/.version CHANGED
@@ -1 +1 @@
1
- 0.9.24
1
+ 0.11.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,121 @@
1
1
  # Changelog
2
- ## [Unreleased]
2
+ ## [0.11.0] - 2026-02-02
3
+
4
+ ### New Features
5
+ - **`--list-tools` CLI Option**: List all available tools and exit
6
+ - Shows tools loaded via `--require` and `--tools` options
7
+ - Dual-mode output: plain text (word-wrapped, 3-sentence summaries) for terminal, full markdown with nested headings when STDOUT is redirected to a file or pipe
8
+ - Combine with `--mcp-list` to also initialize and list tools from MCP servers, grouped by source
9
+ - Example: `aia --require shared_tools --list-tools > tools.md`
10
+
11
+ - **`--mcp-list` Filtering**: `--mcp-list` now respects `--mcp-use` and `--mcp-skip` filters
12
+ - When filters are active, header changes from "Configured MCP Servers" to "Active MCP Servers"
13
+ - Shows only the servers that would actually be connected during a session
14
+
15
+ - **`--mcp-use` and `--mcp-skip` Server Selection**: Select or exclude specific MCP servers by name
16
+ - `--mcp-use server1,server2` - whitelist specific servers (takes precedence)
17
+ - `--mcp-skip server3` - blacklist specific servers
18
+
19
+ - **Multi-Model Environment Variable Support**: `AIA_MODEL` now supports inline role syntax
20
+ - Example: `export AIA_MODEL="gpt-4o=architect,claude=security"`
21
+
22
+ ### Breaking Changes
23
+ - **Removed `--adapter` CLI Option**: The LLM adapter configuration has been removed
24
+ - AIA now exclusively uses `ruby_llm` as its AI interface layer
25
+ - The `ai_client` adapter option is no longer available
26
+
27
+ ### Improvements
28
+ - **CLI Refactoring**: Streamlined CLI option names and improved help text
29
+ - Cleaner option grouping and descriptions in `--help` output
30
+
31
+ ### Documentation
32
+ - **`--list-tools` and `--mcp-list`**: Added comprehensive documentation to `docs/cli-reference.md` with examples, output format tables, and usage patterns
33
+ - **README.md**: Added `--mcp-list` and `--list-tools` to Key Command-Line Options table
34
+ - **MCP Integration Guide**: Updated `docs/mcp-integration.md` with current CLI syntax and examples
35
+ - **Shared Tools Guide**: Created dedicated `docs/guides/shared-tools.md` with all 17 tools organized by category (Data & Analysis, Database, File & System Operations, Web & Network, Code Execution, Documents, Scheduling & Time, Workflow & Weather, Development & Reference)
36
+ - **MkDocs Navigation**: Added Shared Tools guide to site navigation
37
+
38
+ ### Technical Changes
39
+ - Added `list_tools` attribute to `AIA::Config` for runtime flag storage
40
+ - Added `--list-tools` option to CLI parser in `setup_tool_options`
41
+ - Added `handle_list_tools` to `ConfigValidator` with dual-mode output (terminal vs redirected)
42
+ - Added `load_local_tools` with gem activation and Zeitwerk lazy-loading support for `--require` libraries
43
+ - Added `load_mcp_tools_grouped` returning tools organized by server name
44
+ - Added `quiet_mcp_logger` to suppress MCP connection noise during tool listing
45
+ - Added `filter_mcp_servers` and `mcp_filter_active?` to `ConfigValidator` for `--mcp-use`/`--mcp-skip` support
46
+ - Added `nest_markdown_headings` to properly nest markdown headings in tool descriptions under parent heading level
47
+ - Added `first_sentences` helper for terminal-mode description truncation
48
+ - Uses `word_wrapper` gem for terminal word wrapping
49
+ - Removed adapter selection logic and `--adapter` CLI option
50
+
51
+ ## [0.10.2] - 2025-12-25
52
+
53
+ **Merry Christmas!**
54
+
55
+ ### Breaking Changes
56
+ - **Renamed `--metrics` to `--tokens`**: The CLI flag for displaying token usage has been renamed
57
+ - `--metrics` → `--tokens`
58
+ - Environment variable: `AIA_FLAGS__TOKENS`
59
+ - The `--cost` flag now automatically enables `--tokens`
60
+
61
+ ### New Features
62
+ - **Parallel MCP Connections**: Replaced serial MCP server connections with fiber-based parallel execution using SimpleFlow
63
+ - MCP servers now connect concurrently instead of sequentially
64
+ - Total connection time reduced from sum(timeouts) to max(timeouts)
65
+ - Added `simple_flow` gem dependency for lightweight pipeline-based concurrency
66
+
67
+ ### Improvements
68
+ - **MCP Failure Feedback**: Added per-server error messages when MCP connections fail
69
+ - Users now see which specific server failed and why (e.g., "⚠️ MCP: 'iMCP' failed - Connection timed out")
70
+ - Previously only showed generic timeout message without identifying the failing server
71
+
72
+ ### Bug Fixes
73
+ - **Ruby 4.0 Compatibility**: Fixed `NameError` in `lib/extensions/ruby_llm/modalities.rb`
74
+ - Added `require 'ruby_llm'` before extending `RubyLLM::Model::Modalities`
75
+ - Resolves "uninitialized constant RubyLLM" error on Ruby 4.0.0-preview2
76
+
77
+ ### Technical Changes
78
+ - Added `simple_flow` gem dependency to gemspec
79
+ - Refactored MCP connection code in `lib/aia/ruby_llm_adapter.rb`:
80
+ - Added `support_mcp_with_simple_flow` method using SimpleFlow::Pipeline
81
+ - Added `build_mcp_connection_step`, `register_single_mcp_client`, `extract_mcp_results`, `report_mcp_connection_results` helper methods
82
+ - Removed old serial methods: `support_mcp_lazy`, `register_mcp_clients`, `start_mcp_clients`, `reconcile_mcp_server_status`, `check_mcp_client_status`
83
+ - Net reduction of ~60 lines of code with cleaner architecture
84
+
85
+ ### Documentation
86
+ - **Multi-Model Concurrent Comparison**: Added prominent documentation highlighting the ability to query multiple LLMs simultaneously
87
+ - Added "Concurrent Multi-Model Comparison" spotlight section to README.md
88
+ - Added "Token Usage and Cost Tracking" subsection to Multi-Model Support in README.md
89
+ - Added comprehensive "Token Usage and Cost Tracking" section to `docs/guides/models.md`
90
+ - **Token and Cost Flags**: Added documentation for `--tokens` and `--cost` flags
91
+ - Updated `docs/cli-reference.md` with full flag descriptions
92
+ - Updated `docs/configuration.md` with environment variable examples
93
+ - Added "Token Usage and Cost Tracking" section to `docs/guides/chat.md`
94
+ - Updated README.md Key Command-Line Options and Configuration tables
95
+
96
+ ## [0.10.0] - 2025-12-23
97
+
98
+ ### Breaking Changes
99
+ - **Environment Variable Naming Convention**: Updated to use nested naming with double underscore (`__`)
100
+ - `AIA_PROMPTS_DIR` → `AIA_PROMPTS__DIR`
101
+ - `AIA_OUT_FILE` → `AIA_OUTPUT__FILE`
102
+ - `AIA_VERBOSE` → `AIA_FLAGS__VERBOSE`
103
+ - `AIA_DEBUG` → `AIA_FLAGS__DEBUG`
104
+ - `AIA_CHAT` → `AIA_FLAGS__CHAT`
105
+ - `AIA_TEMPERATURE` → `AIA_LLM__TEMPERATURE`
106
+ - `AIA_MARKDOWN` → `AIA_OUTPUT__MARKDOWN`
107
+ - Note: `AIA_MODEL` remains unchanged (top-level, not nested)
108
+
109
+ ### Bug Fixes
110
+ - **MCP Tool Timeout Handling**: Fixed issue where MCP tool timeouts corrupted conversation history
111
+ - Added `repair_incomplete_tool_calls` method to add synthetic tool results when timeouts occur
112
+ - Prevents "assistant message with 'tool_calls' must be followed by tool messages" API errors
113
+ - Conversation can now continue gracefully after tool timeouts
114
+
115
+ - **Tool Crash Handling**: Fixed crash when tools throw non-StandardError exceptions (e.g., LoadError)
116
+ - Changed `rescue StandardError` to `rescue Exception` to catch all error types
117
+ - Added `handle_tool_crash` method that logs errors with 5-line traceback
118
+ - Tool crashes no longer crash AIA - conversation continues gracefully
3
119
 
4
120
  ## [0.9.24] 2025-12-17
5
121
  ### Fixes
@@ -12,6 +128,20 @@
12
128
  - Shows "No tools match the filter: [filter]" when no matches found
13
129
  - Header indicates when filtering is active: "Available Tools (filtered by 'filter')"
14
130
 
131
+ ### Documentation
132
+ - Updated all shell completion scripts (`aia_completion.bash`, `aia_completion.zsh`, `aia_completion.fish`) to use new nested naming convention
133
+ - Updated `docs/configuration.md` with comprehensive environment variable documentation
134
+ - Updated `docs/cli-reference.md` environment variables section
135
+ - Updated `docs/prompt_management.md` with correct envar names
136
+ - Updated `docs/faq.md` with correct envar names
137
+ - Updated `docs/guides/basic-usage.md` shell setup examples
138
+
139
+ ### Technical Changes
140
+ - Enhanced `lib/aia/ruby_llm_adapter.rb`:
141
+ - Added `repair_incomplete_tool_calls` method for conversation integrity
142
+ - Added `handle_tool_crash` method for graceful error handling
143
+ - Removed debug statements
144
+
15
145
  ## [0.9.23] 2025-12-06
16
146
 
17
147
  ### New Features
@@ -178,7 +308,7 @@ Now with the fix:
178
308
  ### Usage Examples
179
309
  ```bash
180
310
  # 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
311
+ bin/aia --chat --model lms/openai/gpt-oss-20b,ollama/gpt-oss:20b --tokens
182
312
 
183
313
  > pick a random language and say hello
184
314
  # LMS: "Habari!" (Swahili)
@@ -313,7 +443,7 @@ aia --model ollama/llama3.2 --chat
313
443
 
314
444
  ## [0.9.13] 2025-09-02
315
445
  ### New Features
316
- - **NEW FEATURE**: Added `--metrics` flag to show token counts for each model
446
+ - **NEW FEATURE**: Added `--tokens` flag to show token counts for each model
317
447
  - **NEW FEATURE**: Added `--cost` flag to enable cost estimation for each model
318
448
 
319
449
  ### Improvements
data/README.md CHANGED
@@ -5,6 +5,22 @@
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.* ⚠️
11
+ >
12
+ > **Version 0.10.0 introduces breaking changes affecting:**
13
+ >
14
+ > - **Environment Variables** — Naming conventions now use double underscore (`__`) for nested config sections (e.g., `AIA_LLM__TEMPERATURE`, `AIA_FLAGS__DEBUG`). See [Environment Variables](https://madbomber.github.io/aia/configuration/#environment-variables) for the complete list.
15
+ >
16
+ > - **Configuration Files** — Configuration now uses a nested YAML structure with sections like `llm:`, `prompts:`, `output:`, `flags:`, etc. The [defaults.yml](lib/aia/config/defaults.yml) file is the single source of truth for all configuration options. See [Configuration Guide](https://madbomber.github.io/aia/configuration/) for details.
17
+ >
18
+ > - **File Locations** — Configuration files now follow the XDG Base Directory Specification. The default config file location is `~/.config/aia/aia.yml`. See [Installation Guide](https://madbomber.github.io/aia/installation/) for setup instructions.
19
+ >
20
+ > **Review the [Configuration Guide](https://madbomber.github.io/aia/configuration/) before upgrading to v0.10.0.**
21
+
22
+ ---
23
+
8
24
  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
25
 
10
26
  AIA leverages the following Ruby gems:
@@ -65,6 +81,47 @@ For more information on AIA visit these locations:
65
81
 
66
82
  ```
67
83
 
84
+ ---
85
+
86
+ ## Concurrent Multi-Model Comparison
87
+
88
+ 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.
89
+
90
+ ```bash
91
+ # Compare responses from 3 models with token counts and cost estimates
92
+ aia --chat -m gpt-4o,claude-3-5-sonnet,gemini-1.5-pro --tokens --cost
93
+ ```
94
+
95
+ **Example output:**
96
+ ```
97
+ You: What's the best approach for handling database migrations in a microservices architecture?
98
+
99
+ from: gpt-4o
100
+ Use a versioned migration strategy with backward compatibility...
101
+
102
+ from: claude-3-5-sonnet
103
+ Consider the Expand-Contract pattern for zero-downtime migrations...
104
+
105
+ from: gemini-1.5-pro
106
+ Implement a schema registry with event-driven synchronization...
107
+
108
+ ┌─────────────────────────────────────────────────────────────────┐
109
+ │ Model │ Input Tokens │ Output Tokens │ Cost │
110
+ ├─────────────────────────────────────────────────────────────────┤
111
+ │ gpt-4o │ 156 │ 342 │ $0.0089 │
112
+ │ claude-3-5-sonnet │ 156 │ 418 │ $0.0063 │
113
+ │ gemini-1.5-pro │ 156 │ 387 │ $0.0041 │
114
+ └─────────────────────────────────────────────────────────────────┘
115
+ ```
116
+
117
+ **Why this matters:**
118
+ - **Compare reasoning approaches** - See how different models tackle the same problem
119
+ - **Identify blind spots** - One model might catch something others miss
120
+ - **Cost optimization** - Find the best price/performance ratio for your use case
121
+ - **Consensus building** - Use `--consensus` to synthesize the best answer from all models
122
+
123
+ ---
124
+
68
125
  <!-- Tocer[start]: Auto-generated, don't remove. -->
69
126
 
70
127
  ## Table of Contents
@@ -190,7 +247,7 @@ aia --chat [--role ROLE] [--model MODEL]
190
247
  aia --model gpt-4 my_prompt
191
248
 
192
249
  # Specify output file
193
- aia --out_file result.md my_prompt
250
+ aia --output result.md my_prompt
194
251
 
195
252
  # Use a role/system prompt
196
253
  aia --role expert my_prompt
@@ -209,8 +266,12 @@ aia --fuzzy
209
266
  | `--no-consensus` | Force individual responses | `aia --no-consensus` |
210
267
  | `--role ROLE` | Use a role/system prompt (default for all models) | `aia --role expert` |
211
268
  | `--list-roles` | List available role files | `aia --list-roles` |
212
- | `--out_file FILE` | Specify output file | `aia --out_file results.md` |
269
+ | `--output FILE` | Specify output file | `aia --output results.md` |
213
270
  | `--fuzzy` | Use fuzzy search for prompts | `aia --fuzzy` |
271
+ | `--tokens` | Display token usage in chat mode | `aia --chat --tokens` |
272
+ | `--cost` | Include cost calculations with token usage | `aia --chat --cost` |
273
+ | `--mcp-list` | List configured MCP servers and exit | `aia --mcp-list` |
274
+ | `--list-tools` | List available tools and exit | `aia --require shared_tools --list-tools` |
214
275
  | `--help` | Show complete help | `aia --help` |
215
276
 
216
277
  ### Directory Structure
@@ -235,7 +296,7 @@ The most commonly used configuration options:
235
296
  |--------|---------|-------------|
236
297
  | `model` | `gpt-4o-mini` | AI model to use |
237
298
  | `prompts_dir` | `~/.prompts` | Directory containing prompts |
238
- | `out_file` | `temp.md` | Default output file |
299
+ | `output` | `temp.md` | Default output file |
239
300
  | `temperature` | `0.7` | Model creativity (0.0-1.0) |
240
301
  | `chat` | `false` | Start in chat mode |
241
302
 
@@ -254,8 +315,8 @@ AIA determines configuration settings using this order (highest to lowest priori
254
315
  **Environment Variables:**
255
316
  ```bash
256
317
  export AIA_MODEL=gpt-4
257
- export AIA_PROMPTS_DIR=~/my-prompts
258
- export AIA_TEMPERATURE=0.8
318
+ export AIA_PROMPTS__DIR=~/my-prompts
319
+ export AIA_LLM__TEMPERATURE=0.8
259
320
  ```
260
321
 
261
322
  **Configuration File** (`~/.aia/config.yml`):
@@ -283,48 +344,52 @@ Your prompt content here...
283
344
  |------------------|-------------|---------------|---------------------|
284
345
  | adapter | --adapter | ruby_llm | AIA_ADAPTER |
285
346
  | 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 |
347
+ | append | -a, --append | false | AIA_FLAGS__APPEND |
348
+ | chat | --chat | false | AIA_FLAGS__CHAT |
349
+ | clear | --clear | false | AIA_FLAGS__CLEAR |
350
+ | config_file | -c, --config-file | ~/.aia/config.yml | AIA_CONFIG_FILE |
351
+ | debug | -d, --debug | false | AIA_FLAGS__DEBUG |
352
+ | embedding_model | --em, --embedding_model | text-embedding-ada-002 | AIA_LLM__EMBEDDING_MODEL |
353
+ | erb | | true | AIA_FLAGS__ERB |
354
+ | frequency_penalty | --frequency-penalty | 0.0 | AIA_LLM__FREQUENCY_PENALTY |
355
+ | fuzzy | -f, --fuzzy | false | AIA_FLAGS__FUZZY |
356
+ | image_quality | --iq, --image-quality | standard | AIA_IMAGE__QUALITY |
357
+ | image_size | --is, --image-size | 1024x1024 | AIA_IMAGE__SIZE |
358
+ | image_style | --style, --image-style | vivid | AIA_IMAGE__STYLE |
359
+ | history_file | --history-file | ~/.prompts/_prompts.log | AIA_OUTPUT__HISTORY_FILE |
360
+ | markdown | --md, --markdown | true | AIA_OUTPUT__MARKDOWN |
361
+ | max_tokens | --max-tokens | 2048 | AIA_LLM__MAX_TOKENS |
301
362
  | model | -m, --model | gpt-4o-mini | AIA_MODEL |
302
363
  | 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 |
364
+ | output | -o, --output | temp.md | AIA_OUTPUT__FILE |
365
+ | parameter_regex | --regex | '(?-mix:(\[[A-Z _\|]+\]))' | AIA_PROMPTS__PARAMETER_REGEX |
305
366
  | 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 |
367
+ | presence_penalty | --presence-penalty | 0.0 | AIA_LLM__PRESENCE_PENALTY |
368
+ | prompt_extname | | .txt | AIA_PROMPTS__EXTNAME |
369
+ | prompts_dir | --prompts-dir | ~/.prompts | AIA_PROMPTS__DIR |
370
+ | refresh | --refresh | 7 (days) | AIA_REGISTRY__REFRESH |
310
371
  | require_libs | --rq --require | [] | AIA_REQUIRE_LIBS |
311
372
  | 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 |
373
+ | roles_dir | | ~/.prompts/roles | AIA_ROLES__DIR |
374
+ | roles_prefix | --roles-prefix | roles | AIA_ROLES__PREFIX |
375
+ | shell | | true | AIA_FLAGS__SHELL |
376
+ | speak | --speak | false | AIA_FLAGS__SPEAK |
377
+ | speak_command | | afplay | AIA_SPEECH__COMMAND |
378
+ | speech_model | --sm, --speech-model | tts-1 | AIA_SPEECH__MODEL |
379
+ | system_prompt | --system-prompt | | AIA_SYSTEM_PROMPT |
380
+ | temperature | -t, --temperature | 0.7 | AIA_LLM__TEMPERATURE |
381
+ | terse | --terse | false | AIA_FLAGS__TERSE |
382
+ | tokens | --tokens | false | AIA_FLAGS__TOKENS |
383
+ | cost | --cost | false | AIA_FLAGS__COST |
384
+ | tool_paths | --tools | [] | AIA_TOOLS__PATHS |
385
+ | allowed_tools | --at, --allowed-tools | nil | AIA_TOOLS__ALLOWED |
386
+ | rejected_tools | --rt, --rejected-tools | nil | AIA_TOOLS__REJECTED |
387
+ | mcp_use | --mu, --mcp-use | ~ | AIA_MCP_USE |
388
+ | mcp_skip | --ms, --mcp-skip | ~ | AIA_MCP_SKIP |
389
+ | top_p | --top-p | 1.0 | AIA_LLM__TOP_P |
390
+ | transcription_model | --tm, --transcription-model | whisper-1 | AIA_TRANSCRIPTION__MODEL |
391
+ | verbose | -v, --verbose | false | AIA_FLAGS__VERBOSE |
392
+ | voice | --voice | alloy | AIA_SPEECH__VOICE |
328
393
 
329
394
  </details>
330
395
 
@@ -566,6 +631,39 @@ Model Details:
566
631
  - **Error Handling**: Invalid models are reported but don't prevent valid models from working
567
632
  - **Batch Mode Support**: Multi-model responses are properly formatted in output files
568
633
 
634
+ #### Token Usage and Cost Tracking
635
+
636
+ Monitor token consumption and estimate costs across all models with `--tokens` and `--cost`:
637
+
638
+ ```bash
639
+ # Display token usage for each model
640
+ aia my_prompt -m gpt-4o,claude-3-sonnet --tokens
641
+
642
+ # Include cost estimates (automatically enables --tokens)
643
+ aia my_prompt -m gpt-4o,claude-3-sonnet --cost
644
+
645
+ # In chat mode with full tracking
646
+ aia --chat -m gpt-4o,claude-3-sonnet,gemini-pro --cost
647
+ ```
648
+
649
+ **Token Usage Output:**
650
+ ```
651
+ from: gpt-4o
652
+ Here's my analysis of the code...
653
+
654
+ from: claude-3-sonnet
655
+ Looking at this code, I notice...
656
+
657
+ Tokens: gpt-4o: input=245, output=312 | claude-3-sonnet: input=245, output=287
658
+ Cost: gpt-4o: $0.0078 | claude-3-sonnet: $0.0045 | Total: $0.0123
659
+ ```
660
+
661
+ **Use Cases for Token/Cost Tracking:**
662
+ - **Budget management** - Monitor API costs in real-time during development
663
+ - **Model comparison** - Identify which models are most cost-effective for your tasks
664
+ - **Optimization** - Find the right balance between response quality and cost
665
+ - **Billing insights** - Track usage patterns across different model providers
666
+
569
667
  ### Local Model Support
570
668
 
571
669
  AIA supports running local AI models through Ollama and LM Studio, providing privacy, offline capability, and cost savings.
@@ -721,7 +819,7 @@ Provide comprehensive background information.
721
819
 
722
820
  **analyze.txt:**
723
821
  ```
724
- //config out_file = analysis.md
822
+ //config output = analysis.md
725
823
  //next summarize
726
824
 
727
825
  Analyze the research data and identify key insights.
@@ -729,7 +827,7 @@ Analyze the research data and identify key insights.
729
827
 
730
828
  **summarize.txt:**
731
829
  ```
732
- //config out_file = summary.md
830
+ //config output = summary.md
733
831
 
734
832
  Create a concise summary of the analysis with actionable recommendations.
735
833
  ```
@@ -897,8 +995,8 @@ aia --tools ~/my-tools/ --chat
897
995
  aia --tools weather.rb,calculator.rb --chat
898
996
 
899
997
  # Filter tools
900
- aia --tools ~/tools/ --allowed_tools weather,calc
901
- aia --tools ~/tools/ --rejected_tools deprecated
998
+ aia --tools ~/tools/ --allowed-tools weather,calc
999
+ aia --tools ~/tools/ --rejected-tools deprecated
902
1000
  ```
903
1001
 
904
1002
  **Tool Examples** (see `examples/tools/` directory):
@@ -1180,13 +1278,13 @@ aia --chat -m gpt-4o-mini,gpt-3.5-turbo --consensus
1180
1278
 
1181
1279
  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
1280
 
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.
1281
+ 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
1282
 
1185
1283
  Create executable prompts:
1186
1284
 
1187
1285
  **weather_report** (make executable with `chmod +x`):
1188
1286
  ```bash
1189
- #!/usr/bin/env aia run --no-out_file --exec
1287
+ #!/usr/bin/env aia run --no-output --exec
1190
1288
  # Get current storm activity for the east and south coast of the US
1191
1289
 
1192
1290
  Summarize the tropical storm outlook fpr the Atlantic, Caribbean Sea and Gulf of America.
@@ -1222,13 +1320,13 @@ Usage: `aia ad_hoc` - perfect for any quick one-shot question without cluttering
1222
1320
  #### Recommended Shell Setup
1223
1321
  ```bash
1224
1322
  # ~/.bashrc_aia
1225
- export AIA_PROMPTS_DIR=~/.prompts
1226
- export AIA_OUT_FILE=./temp.md
1323
+ export AIA_PROMPTS__DIR=~/.prompts
1324
+ export AIA_OUTPUT__FILE=./temp.md
1227
1325
  export AIA_MODEL=gpt-4o-mini
1228
- export AIA_VERBOSE=true # Shows spinner while waiting for LLM response
1326
+ export AIA_FLAGS__VERBOSE=true # Shows spinner while waiting for LLM response
1229
1327
 
1230
1328
  alias chat='aia --chat --terse'
1231
- ask() { echo "$1" | aia run --no-out_file; }
1329
+ ask() { echo "$1" | aia run --no-output; }
1232
1330
  ```
1233
1331
 
1234
1332
  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 +1385,7 @@ chmod 600 ~/.prompts/*.txt
1287
1385
  **Prompt not found:**
1288
1386
  ```bash
1289
1387
  # Check prompts directory
1290
- ls $AIA_PROMPTS_DIR
1388
+ ls $AIA_PROMPTS__DIR
1291
1389
 
1292
1390
  # Verify prompt file exists
1293
1391
  ls ~/.prompts/my_prompt.txt
@@ -1299,7 +1397,7 @@ aia --fuzzy
1299
1397
  **Model errors:**
1300
1398
  ```bash
1301
1399
  # List available models
1302
- aia --available_models
1400
+ aia --available-models
1303
1401
 
1304
1402
  # Check model name spelling
1305
1403
  aia --model gpt-4o # Correct
@@ -1327,27 +1425,55 @@ aia --debug --config
1327
1425
  | Error | Cause | Solution |
1328
1426
  |-------|-------|----------|
1329
1427
  | "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 |
1428
+ | "Model not available" | Invalid model name | Use `--available-models` to list valid models |
1331
1429
  | "Shell command failed" | Invalid shell syntax | Test shell commands separately first |
1332
1430
  | "Configuration error" | Invalid config syntax | Check config file YAML syntax |
1333
1431
 
1334
- ### Debug Mode
1432
+ ### Debug Mode and Log Level Options
1433
+
1434
+ AIA provides multiple log level options to control the verbosity of logging output. These options set the log level for all three loggers:
1435
+ - **aia**: Used within the AIA codebase for application-level logging
1436
+ - **llm**: Passed to the RubyLLM gem's configuration (`RubyLLM.logger`)
1437
+ - **mcp**: Passed to the RubyLLM::MCP process (`RubyLLM::MCP.logger`)
1335
1438
 
1336
- Enable debug output for troubleshooting:
1439
+ | Option | Description |
1440
+ |--------|-------------|
1441
+ | `-d, --debug` | Enable debug output (most verbose) and set all loggers to DEBUG level |
1442
+ | `--no-debug` | Disable debug output |
1443
+ | `--info` | Set all loggers to INFO level |
1444
+ | `--warn` | Set all loggers to WARN level (default) |
1445
+ | `--error` | Set all loggers to ERROR level |
1446
+ | `--fatal` | Set all loggers to FATAL level (least verbose) |
1337
1447
 
1338
1448
  ```bash
1339
- # Enable debug mode
1449
+ # Enable debug mode (most verbose - shows all log messages)
1340
1450
  aia --debug my_prompt
1341
1451
 
1342
1452
  # Combine with verbose for maximum output
1343
1453
  aia --debug --verbose my_prompt
1454
+
1455
+ # Use info level for moderate logging
1456
+ aia --info my_prompt
1457
+
1458
+ # Use error level to only see errors and fatal messages
1459
+ aia --error my_prompt
1460
+
1461
+ # Use fatal level for minimal logging (only critical errors)
1462
+ aia --fatal --chat
1344
1463
  ```
1345
1464
 
1465
+ **Log Level Hierarchy** (from most to least verbose):
1466
+ 1. **debug** - All messages including detailed debugging information
1467
+ 2. **info** - Informational messages and above
1468
+ 3. **warn** - Warnings, errors, and fatal messages (default)
1469
+ 4. **error** - Only errors and fatal messages
1470
+ 5. **fatal** - Only critical/fatal messages
1471
+
1346
1472
  ### Performance Issues
1347
1473
 
1348
1474
  **Slow model responses:**
1349
1475
  - Try smaller/faster models: `--model gpt-4o-mini`
1350
- - Reduce max_tokens: `--max_tokens 1000`
1476
+ - Reduce max_tokens: `--max-tokens 1000`
1351
1477
  - Use lower temperature for faster responses: `--temperature 0.1`
1352
1478
 
1353
1479
  **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