aia 0.9.11 → 0.9.12

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/CHANGELOG.md +66 -2
  4. data/README.md +133 -4
  5. data/docs/advanced-prompting.md +721 -0
  6. data/docs/cli-reference.md +582 -0
  7. data/docs/configuration.md +347 -0
  8. data/docs/contributing.md +332 -0
  9. data/docs/directives-reference.md +490 -0
  10. data/docs/examples/index.md +277 -0
  11. data/docs/examples/mcp/index.md +479 -0
  12. data/docs/examples/prompts/analysis/index.md +78 -0
  13. data/docs/examples/prompts/automation/index.md +108 -0
  14. data/docs/examples/prompts/development/index.md +125 -0
  15. data/docs/examples/prompts/index.md +333 -0
  16. data/docs/examples/prompts/learning/index.md +127 -0
  17. data/docs/examples/prompts/writing/index.md +62 -0
  18. data/docs/examples/tools/index.md +292 -0
  19. data/docs/faq.md +414 -0
  20. data/docs/guides/available-models.md +366 -0
  21. data/docs/guides/basic-usage.md +477 -0
  22. data/docs/guides/chat.md +474 -0
  23. data/docs/guides/executable-prompts.md +417 -0
  24. data/docs/guides/first-prompt.md +454 -0
  25. data/docs/guides/getting-started.md +455 -0
  26. data/docs/guides/image-generation.md +507 -0
  27. data/docs/guides/index.md +46 -0
  28. data/docs/guides/models.md +507 -0
  29. data/docs/guides/tools.md +856 -0
  30. data/docs/index.md +173 -0
  31. data/docs/installation.md +238 -0
  32. data/docs/mcp-integration.md +612 -0
  33. data/docs/prompt_management.md +579 -0
  34. data/docs/security.md +629 -0
  35. data/docs/tools-and-mcp-examples.md +1186 -0
  36. data/docs/workflows-and-pipelines.md +563 -0
  37. data/examples/tools/mcp/github_mcp_server.json +11 -0
  38. data/examples/tools/mcp/imcp.json +7 -0
  39. data/lib/aia/chat_processor_service.rb +19 -3
  40. data/lib/aia/config/base.rb +224 -0
  41. data/lib/aia/config/cli_parser.rb +409 -0
  42. data/lib/aia/config/defaults.rb +88 -0
  43. data/lib/aia/config/file_loader.rb +131 -0
  44. data/lib/aia/config/validator.rb +184 -0
  45. data/lib/aia/config.rb +10 -860
  46. data/lib/aia/directive_processor.rb +27 -372
  47. data/lib/aia/directives/configuration.rb +114 -0
  48. data/lib/aia/directives/execution.rb +37 -0
  49. data/lib/aia/directives/models.rb +178 -0
  50. data/lib/aia/directives/registry.rb +120 -0
  51. data/lib/aia/directives/utility.rb +70 -0
  52. data/lib/aia/directives/web_and_file.rb +71 -0
  53. data/lib/aia/prompt_handler.rb +23 -3
  54. data/lib/aia/ruby_llm_adapter.rb +307 -128
  55. data/lib/aia/session.rb +27 -14
  56. data/lib/aia/utility.rb +12 -8
  57. data/lib/aia.rb +11 -2
  58. data/lib/extensions/ruby_llm/.irbrc +56 -0
  59. data/mkdocs.yml +165 -0
  60. metadata +77 -20
  61. /data/{images → docs/assets/images}/aia.png +0 -0
data/docs/index.md ADDED
@@ -0,0 +1,173 @@
1
+ # AIA - AI Assistant
2
+
3
+ <table border="0">
4
+ <tr>
5
+ <td width="30%" valign="top">
6
+ <img src="assets/images/aia.png" alt="AIA - May I take your prompt?" width="200" />
7
+ <div align="center">
8
+ <strong>The Prompt is the Code</strong>
9
+ </div>
10
+ </td>
11
+ <td width="70%" valign="top">
12
+
13
+ Welcome to AIA, your powerful CLI tool for dynamic prompt management and AI interaction.
14
+ <br/><br/>
15
+ <strong>AIA (AI Assistant)</strong> is a Ruby-based command-line tool that revolutionizes how you interact with AI models. It's designed for generative AI workflows, enabling you to effortlessly manage AI prompts, integrate seamlessly with shell and embedded Ruby (ERB), run batch processes, and engage in interactive chats with user-defined directives, tools, and MCP clients.
16
+ </td>
17
+ </tr>
18
+ </table>
19
+
20
+ <div align="center">
21
+ AIA treats prompts as executable programs, complete with configuration, logic, and workflows.
22
+ </div>
23
+
24
+ ## Key Features
25
+
26
+ ### 🚀 Dynamic Prompt Management
27
+ - **Hierarchical Configuration**: Embedded directives > CLI args > environment variables > config files > defaults
28
+ - **Prompt Sequences and Workflows**: Chain prompts together for complex AI workflows
29
+ - **Role-based Prompts**: Use predefined roles to context your AI interactions
30
+ - **Fuzzy Search**: Find prompts quickly with fuzzy matching (requires `fzf`)
31
+
32
+ ### 🔧 Powerful Integration
33
+ - **Shell Integration**: Execute shell commands directly within prompts
34
+ - **Ruby (ERB) Processing**: Use Ruby code in your prompts for dynamic content
35
+ - **RubyLLM::Tool Support**: Function callbacks for enhanced AI capabilities
36
+ - **MCP Client Support**: Integrate with Model Context Protocol clients
37
+
38
+ ### 💬 Interactive Chat Sessions
39
+ - **Context Management**: Maintain conversation history and context
40
+ - **Multi-model Support**: Use multiple AI models simultaneously
41
+ - **Consensus Mode**: Get consensus responses from multiple models
42
+ - **Voice Support**: Convert text to speech and back
43
+
44
+ ### 🎯 Advanced Features
45
+ - **Executable Prompts**: Run prompts as executable scripts
46
+ - **Parameter Extraction**: Use regex to extract parameters from prompts
47
+ - **Image Generation**: Generate images with customizable parameters
48
+ - **Tool Integration**: Use custom Ruby tools for enhanced functionality
49
+
50
+ ## Quick Start
51
+
52
+ 1. **Install AIA:**
53
+ ```bash
54
+ gem install aia
55
+ ```
56
+
57
+ 2. **Install dependencies:**
58
+ ```bash
59
+ brew install fzf
60
+ ```
61
+
62
+ 3. **Create your first prompt:**
63
+ ```bash
64
+ mkdir -p ~/.prompts
65
+ echo "What is [TOPIC]?" > ~/.prompts/what_is.txt
66
+ ```
67
+
68
+ 4. **Run your prompt:**
69
+ ```bash
70
+ aia what_is
71
+ ```
72
+ You'll be prompted to enter a value for `[TOPIC]`, then AIA will send your question to the AI model.
73
+
74
+ 5. **Start an interactive chat:**
75
+ ```bash
76
+ aia --chat
77
+
78
+ # Or use multiple models for comparison
79
+ aia --chat --model "gpt-4o-mini,gpt-3.5-turbo"
80
+ ```
81
+
82
+ When AIA starts, you'll see the friendly robot mascot:
83
+
84
+ ```plain
85
+
86
+ , ,
87
+ (\____/) AI Assistant (v0.9.7) is Online
88
+ (_oo_) ["gpt-4o-mini", "gpt-5-mini"]
89
+ (O) using ruby_llm (v1.6.4 MCP v0.6.1)
90
+ __||__ \) model db was last refreshed on
91
+ [/______\] / 2025-08-27
92
+ / \__AI__/ \/ You can share my tools
93
+ / /__\
94
+ (\ /____\
95
+
96
+ ```
97
+
98
+ ## Core Architecture
99
+
100
+ AIA follows a modular Ruby gem structure with clear separation of concerns:
101
+
102
+ ### Component Overview
103
+
104
+ ```mermaid
105
+ graph TD
106
+ A[CLI Input] --> B[Config System]
107
+ B --> C[Prompt Handler]
108
+ C --> D[Directive Processor]
109
+ D --> E[Context Manager]
110
+ E --> F[RubyLLM Adapter]
111
+ F --> G[AI Models]
112
+
113
+ H[Prompt Files] --> C
114
+ I[Role Files] --> C
115
+ J[Tools] --> F
116
+ K[MCP Clients] --> F
117
+
118
+ C --> L[Chat Processor Service]
119
+ L --> M[UI Presenter]
120
+ M --> N[Terminal Output]
121
+ ```
122
+
123
+ ### Core Components
124
+
125
+ - **AIA::Config** - Configuration management with hierarchical precedence
126
+ - **AIA::PromptHandler** - Main prompt processing orchestrator
127
+ - **AIA::ChatProcessorService** - Interactive chat session management
128
+ - **AIA::DirectiveProcessor** - Processes embedded directives (`//command params`)
129
+ - **AIA::ContextManager** - Manages conversation context and history
130
+ - **AIA::RubyLLMAdapter** - Interfaces with the ruby_llm gem for AI model communication
131
+ - **AIA::ShellCommandExecutor** - Executes shell commands safely within prompts
132
+ - **AIA::HistoryManager** - Manages prompt parameter history and user input
133
+ - **AIA::UIPresenter** - Terminal output formatting and presentation
134
+ - **AIA::Session** - Manages chat sessions and state
135
+ - **AIA::Fzf** - Fuzzy finder integration for prompt selection
136
+
137
+ ### External Dependencies
138
+
139
+ - **prompt_manager gem** - Core prompt management functionality
140
+ - **ruby_llm gem** - AI model interface layer
141
+ - **fzf** - Command-line fuzzy finder (external CLI tool)
142
+
143
+ ## Documentation Structure
144
+
145
+ ### Getting Started
146
+ - [Installation](installation.md) - Get AIA up and running
147
+ - [Configuration](configuration.md) - Configure AIA for your needs
148
+ - [Getting Started Guide](guides/getting-started.md) - Your first steps with AIA
149
+
150
+ ### Guides
151
+ - [Chat Mode](guides/chat.md) - Interactive conversations with AI
152
+ - [Working with Models](guides/models.md) - Multi-model support and configuration
153
+ - [Tools Integration](guides/tools.md) - Extend AIA with custom tools
154
+ - [Advanced Prompting](advanced-prompting.md) - Master complex prompt techniques
155
+
156
+ ### Reference
157
+ - [CLI Parameters](cli-reference.md) - Complete command-line reference
158
+ - [Directives Reference](directives-reference.md) - All available directives
159
+ - [Examples](examples/index.md) - Practical examples and use cases
160
+
161
+ ## Community & Support
162
+
163
+ - **GitHub**: [madbomber/aia](https://github.com/MadBomber/aia)
164
+ - **Issues**: [Report bugs and request features](https://github.com/MadBomber/aia/issues)
165
+ - **RubyGems**: [aia gem](https://rubygems.org/gems/aia)
166
+
167
+ ## License
168
+
169
+ AIA is open source software. See the [LICENSE](https://github.com/MadBomber/aia/blob/main/LICENSE) file for details.
170
+
171
+ ---
172
+
173
+ Ready to get started? Head to the [Installation](installation.md) guide to begin your AIA journey!
@@ -0,0 +1,238 @@
1
+ # Installation
2
+
3
+ This guide will help you install AIA and get it running on your system.
4
+
5
+ ## Prerequisites
6
+
7
+ ### Required
8
+ - **Ruby**: Version 3.0 or higher
9
+ - **RubyGems**: Usually comes with Ruby
10
+
11
+ ### Recommended
12
+ - **fzf**: For fuzzy prompt searching
13
+ - **git**: For prompt management with version control
14
+
15
+ ## Installation Methods
16
+
17
+ ### Method 1: Install from RubyGems (Recommended)
18
+
19
+ The easiest way to install AIA is through RubyGems:
20
+
21
+ ```bash
22
+ gem install aia
23
+ ```
24
+
25
+ ### Method 2: Install from Source
26
+
27
+ If you want the latest development version:
28
+
29
+ ```bash
30
+ git clone https://github.com/MadBomber/aia.git
31
+ cd aia
32
+ bundle install
33
+ rake install
34
+ ```
35
+
36
+ ### Method 3: Using Bundler
37
+
38
+ Add to your Gemfile:
39
+
40
+ ```ruby
41
+ gem 'aia'
42
+ ```
43
+
44
+ Then run:
45
+
46
+ ```bash
47
+ bundle install
48
+ ```
49
+
50
+ ## Verify Installation
51
+
52
+ After installation, verify that AIA is working:
53
+
54
+ ```bash
55
+ aia --version
56
+ ```
57
+
58
+ You should see the version number printed.
59
+
60
+ ## Initial Setup
61
+
62
+ ### 1. Create Prompts Directory
63
+
64
+ AIA stores prompts in a directory (default: `~/.prompts`). Create it:
65
+
66
+ ```bash
67
+ mkdir -p ~/.prompts
68
+ ```
69
+
70
+ ### 2. Create Configuration Directory
71
+
72
+ Create the configuration directory:
73
+
74
+ ```bash
75
+ mkdir -p ~/.aia
76
+ ```
77
+
78
+ ### 3. Basic Configuration File (Optional)
79
+
80
+ Create a basic configuration file at `~/.aia/config.yml`:
81
+
82
+ ```yaml
83
+ # Basic AIA configuration
84
+ adapter: ruby_llm
85
+ model: gpt-3.5-turbo
86
+ prompts_dir: ~/.prompts
87
+ temperature: 0.7
88
+ verbose: false
89
+ ```
90
+
91
+ ### 4. Set Up API Keys
92
+
93
+ AIA uses the RubyLLM gem, which supports multiple AI providers. Set up your API keys as environment variables:
94
+
95
+ #### OpenAI
96
+ ```bash
97
+ export OPENAI_API_KEY="your_openai_api_key_here"
98
+ ```
99
+
100
+ #### Anthropic Claude
101
+ ```bash
102
+ export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
103
+ ```
104
+
105
+ #### Google Gemini
106
+ ```bash
107
+ export GOOGLE_API_KEY="your_google_api_key_here"
108
+ ```
109
+
110
+ #### Ollama (Local models)
111
+ ```bash
112
+ export OLLAMA_URL="http://localhost:11434"
113
+ ```
114
+
115
+ Add these to your shell profile (`.bashrc`, `.zshrc`, etc.) to make them permanent.
116
+
117
+ ## Optional Dependencies
118
+
119
+ ### Install fzf for Fuzzy Search
120
+
121
+ AIA supports fuzzy searching for prompts using `fzf`. Install it:
122
+
123
+ #### macOS (using Homebrew)
124
+ ```bash
125
+ brew install fzf
126
+ ```
127
+
128
+ #### Ubuntu/Debian
129
+ ```bash
130
+ apt-get install fzf
131
+ ```
132
+
133
+ #### Other systems
134
+ See the [fzf installation guide](https://github.com/junegunn/fzf#installation).
135
+
136
+ ### Install Additional Ruby Gems
137
+
138
+ Some features may require additional gems:
139
+
140
+ ```bash
141
+ # For advanced audio processing
142
+ gem install ruby-audio
143
+
144
+ # For advanced image processing
145
+ gem install mini_magick
146
+
147
+ # For enhanced terminal features
148
+ gem install tty-prompt
149
+ ```
150
+
151
+ ## Testing Your Installation
152
+
153
+ ### 1. Check Available Models
154
+
155
+ ```bash
156
+ aia --available_models
157
+ ```
158
+
159
+ This will show all available AI models.
160
+
161
+ ### 2. Test Basic Functionality
162
+
163
+ Create a simple prompt file:
164
+
165
+ ```bash
166
+ echo "Hello, what can you help me with today?" > ~/.prompts/hello.txt
167
+ ```
168
+
169
+ Run it:
170
+
171
+ ```bash
172
+ aia hello
173
+ ```
174
+
175
+ ### 3. Test Chat Mode
176
+
177
+ ```bash
178
+ aia --chat
179
+ ```
180
+
181
+ This should start an interactive chat session.
182
+
183
+ ## Troubleshooting
184
+
185
+ ### Common Issues
186
+
187
+ #### "Command not found: aia"
188
+ - Make sure Ruby's bin directory is in your PATH
189
+ - Try reinstalling: `gem uninstall aia && gem install aia`
190
+
191
+ #### "No models available"
192
+ - Check that your API keys are set correctly
193
+ - Verify your internet connection
194
+ - Try: `aia --available_models` to diagnose
195
+
196
+ #### "fzf not found" warning
197
+ - Install fzf as described above
198
+ - Or disable fuzzy search: `aia --no-fuzzy`
199
+
200
+ #### Permission errors
201
+ - Try installing with: `gem install aia --user-install`
202
+ - Or use `sudo` (not recommended): `sudo gem install aia`
203
+
204
+ ### Getting Help
205
+
206
+ If you encounter issues:
207
+
208
+ 1. Check the [FAQ](faq.md)
209
+ 2. Search existing [GitHub issues](https://github.com/MadBomber/aia/issues)
210
+ 3. Create a new issue with:
211
+ - Your OS and Ruby version
212
+ - The exact error message
213
+ - Steps to reproduce
214
+
215
+ ## Next Steps
216
+
217
+ Once AIA is installed:
218
+
219
+ 1. Read the [Configuration Guide](configuration.md)
220
+ 2. Follow the [Getting Started Guide](guides/getting-started.md)
221
+ 3. Explore [Examples](examples/index.md)
222
+
223
+ ## Updating AIA
224
+
225
+ To update to the latest version:
226
+
227
+ ```bash
228
+ gem update aia
229
+ ```
230
+
231
+ Or if installed from source:
232
+
233
+ ```bash
234
+ cd path/to/aia
235
+ git pull
236
+ bundle install
237
+ rake install
238
+ ```