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.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/CHANGELOG.md +66 -2
- data/README.md +133 -4
- data/docs/advanced-prompting.md +721 -0
- data/docs/cli-reference.md +582 -0
- data/docs/configuration.md +347 -0
- data/docs/contributing.md +332 -0
- data/docs/directives-reference.md +490 -0
- data/docs/examples/index.md +277 -0
- data/docs/examples/mcp/index.md +479 -0
- data/docs/examples/prompts/analysis/index.md +78 -0
- data/docs/examples/prompts/automation/index.md +108 -0
- data/docs/examples/prompts/development/index.md +125 -0
- data/docs/examples/prompts/index.md +333 -0
- data/docs/examples/prompts/learning/index.md +127 -0
- data/docs/examples/prompts/writing/index.md +62 -0
- data/docs/examples/tools/index.md +292 -0
- data/docs/faq.md +414 -0
- data/docs/guides/available-models.md +366 -0
- data/docs/guides/basic-usage.md +477 -0
- data/docs/guides/chat.md +474 -0
- data/docs/guides/executable-prompts.md +417 -0
- data/docs/guides/first-prompt.md +454 -0
- data/docs/guides/getting-started.md +455 -0
- data/docs/guides/image-generation.md +507 -0
- data/docs/guides/index.md +46 -0
- data/docs/guides/models.md +507 -0
- data/docs/guides/tools.md +856 -0
- data/docs/index.md +173 -0
- data/docs/installation.md +238 -0
- data/docs/mcp-integration.md +612 -0
- data/docs/prompt_management.md +579 -0
- data/docs/security.md +629 -0
- data/docs/tools-and-mcp-examples.md +1186 -0
- data/docs/workflows-and-pipelines.md +563 -0
- data/examples/tools/mcp/github_mcp_server.json +11 -0
- data/examples/tools/mcp/imcp.json +7 -0
- data/lib/aia/chat_processor_service.rb +19 -3
- data/lib/aia/config/base.rb +224 -0
- data/lib/aia/config/cli_parser.rb +409 -0
- data/lib/aia/config/defaults.rb +88 -0
- data/lib/aia/config/file_loader.rb +131 -0
- data/lib/aia/config/validator.rb +184 -0
- data/lib/aia/config.rb +10 -860
- data/lib/aia/directive_processor.rb +27 -372
- data/lib/aia/directives/configuration.rb +114 -0
- data/lib/aia/directives/execution.rb +37 -0
- data/lib/aia/directives/models.rb +178 -0
- data/lib/aia/directives/registry.rb +120 -0
- data/lib/aia/directives/utility.rb +70 -0
- data/lib/aia/directives/web_and_file.rb +71 -0
- data/lib/aia/prompt_handler.rb +23 -3
- data/lib/aia/ruby_llm_adapter.rb +307 -128
- data/lib/aia/session.rb +27 -14
- data/lib/aia/utility.rb +12 -8
- data/lib/aia.rb +11 -2
- data/lib/extensions/ruby_llm/.irbrc +56 -0
- data/mkdocs.yml +165 -0
- metadata +77 -20
- /data/{images → docs/assets/images}/aia.png +0 -0
@@ -0,0 +1,490 @@
|
|
1
|
+
# Directives Reference
|
2
|
+
|
3
|
+
Directives are special commands embedded in prompts that provide dynamic functionality. All directives begin with `//` and are processed before the prompt is sent to the AI model.
|
4
|
+
|
5
|
+
## Directive Syntax
|
6
|
+
|
7
|
+
```markdown
|
8
|
+
//directive_name arguments
|
9
|
+
```
|
10
|
+
|
11
|
+
Examples:
|
12
|
+
```markdown
|
13
|
+
//config model gpt-4
|
14
|
+
//include my_file.txt
|
15
|
+
//shell ls -la
|
16
|
+
|
17
|
+
<%= "Hello World" %>
|
18
|
+
```
|
19
|
+
|
20
|
+
## Configuration Directives
|
21
|
+
|
22
|
+
### `//config`
|
23
|
+
Configure AIA settings from within prompts.
|
24
|
+
|
25
|
+
**Syntax**: `//config [option] [value]`
|
26
|
+
|
27
|
+
**Examples**:
|
28
|
+
```markdown
|
29
|
+
//config model gpt-4
|
30
|
+
//config temperature 0.8
|
31
|
+
//config max_tokens 2000
|
32
|
+
//config verbose true
|
33
|
+
```
|
34
|
+
|
35
|
+
**Usage**:
|
36
|
+
- `//config` - Display all configuration
|
37
|
+
- `//config option` - Display specific configuration option
|
38
|
+
- `//config option value` - Set configuration option
|
39
|
+
|
40
|
+
**Aliases**: `//cfg`
|
41
|
+
|
42
|
+
### `//model`
|
43
|
+
Display or configure the AI model.
|
44
|
+
|
45
|
+
**Syntax**: `//model [model_name]`
|
46
|
+
|
47
|
+
**Examples**:
|
48
|
+
```markdown
|
49
|
+
//model gpt-4
|
50
|
+
//model claude-3-sonnet
|
51
|
+
//model
|
52
|
+
```
|
53
|
+
|
54
|
+
**Usage**:
|
55
|
+
- `//model` - Display current model configuration and details
|
56
|
+
- `//model name` - Set the model to use
|
57
|
+
|
58
|
+
For multi-model configurations, displays:
|
59
|
+
- Model count and primary model
|
60
|
+
- Consensus mode status
|
61
|
+
- Detailed information for each model including provider, context window, costs, and capabilities
|
62
|
+
|
63
|
+
### `//temperature`
|
64
|
+
Set the creativity/randomness of AI responses.
|
65
|
+
|
66
|
+
**Syntax**: `//temperature value`
|
67
|
+
|
68
|
+
**Examples**:
|
69
|
+
```markdown
|
70
|
+
//temperature 0.1 # Very focused
|
71
|
+
//temperature 0.7 # Balanced (default)
|
72
|
+
//temperature 1.2 # Creative
|
73
|
+
//temperature 2.0 # Very creative
|
74
|
+
```
|
75
|
+
|
76
|
+
**Aliases**: `//temp`
|
77
|
+
|
78
|
+
### `//top_p`
|
79
|
+
Set nucleus sampling parameter (alternative to temperature).
|
80
|
+
|
81
|
+
**Syntax**: `//top_p value`
|
82
|
+
|
83
|
+
**Examples**:
|
84
|
+
```markdown
|
85
|
+
//top_p 0.1 # Very focused
|
86
|
+
//top_p 0.9 # More diverse
|
87
|
+
```
|
88
|
+
|
89
|
+
**Aliases**: `//topp`
|
90
|
+
|
91
|
+
## File and Web Directives
|
92
|
+
|
93
|
+
### `//include`
|
94
|
+
Include content from files or websites.
|
95
|
+
|
96
|
+
**Syntax**: `//include path_or_url`
|
97
|
+
|
98
|
+
**Examples**:
|
99
|
+
```markdown
|
100
|
+
//include README.md
|
101
|
+
//include /path/to/config.yml
|
102
|
+
//include ~/Documents/notes.txt
|
103
|
+
//include https://example.com/page
|
104
|
+
```
|
105
|
+
|
106
|
+
**Features**:
|
107
|
+
- Supports tilde (`~`) and environment variable expansion
|
108
|
+
- Prevents circular inclusions
|
109
|
+
- Can include web pages (requires PUREMD_API_KEY)
|
110
|
+
- Handles both absolute and relative file paths
|
111
|
+
|
112
|
+
**Aliases**: `//import`
|
113
|
+
|
114
|
+
### `//webpage`
|
115
|
+
Include content from web pages (requires PUREMD_API_KEY).
|
116
|
+
|
117
|
+
**Syntax**: `//webpage url`
|
118
|
+
|
119
|
+
**Examples**:
|
120
|
+
```markdown
|
121
|
+
//webpage https://docs.example.com/api
|
122
|
+
//webpage https://github.com/user/repo/blob/main/README.md
|
123
|
+
```
|
124
|
+
|
125
|
+
**Prerequisites**:
|
126
|
+
Set the PUREMD_API_KEY environment variable:
|
127
|
+
```bash
|
128
|
+
export PUREMD_API_KEY="your_api_key"
|
129
|
+
```
|
130
|
+
|
131
|
+
**Aliases**: `//website`, `//web`
|
132
|
+
|
133
|
+
## Execution Directives
|
134
|
+
|
135
|
+
### `//shell`
|
136
|
+
Execute shell commands and include their output.
|
137
|
+
|
138
|
+
**Syntax**: `//shell command arguments`
|
139
|
+
|
140
|
+
**Examples**:
|
141
|
+
```markdown
|
142
|
+
//shell ls -la
|
143
|
+
//shell git status
|
144
|
+
//shell grep -n "TODO" *.rb
|
145
|
+
//shell ps aux | grep ruby
|
146
|
+
//shell curl -s https://api.github.com/user | jq '.name'
|
147
|
+
```
|
148
|
+
|
149
|
+
**Security Note**: Use with caution in shared environments. Commands execute with your current user permissions.
|
150
|
+
|
151
|
+
**Aliases**: `//sh`
|
152
|
+
|
153
|
+
### `//ruby`
|
154
|
+
Execute one line of Ruby code and include the result.
|
155
|
+
|
156
|
+
**Syntax**: `//ruby` (followed by Ruby code)
|
157
|
+
|
158
|
+
**Examples**:
|
159
|
+
```markdown
|
160
|
+
//ruby Time.now
|
161
|
+
|
162
|
+
//ruby Dir.pwd
|
163
|
+
|
164
|
+
//ruby File.read('config.yml')
|
165
|
+
|
166
|
+
//ruby [1,2,3,4,5].sum
|
167
|
+
|
168
|
+
//ruby "Hello, #{ENV['USER']}!"
|
169
|
+
|
170
|
+
//ruby require 'json'; JSON.pretty_generate({hello: 'world'})
|
171
|
+
```
|
172
|
+
|
173
|
+
**Features**:
|
174
|
+
- Full Ruby environment available
|
175
|
+
- Can use require for additional libraries (use `--require` CLI option)
|
176
|
+
- Access to all Ruby standard library
|
177
|
+
- Error handling with descriptive messages
|
178
|
+
|
179
|
+
**Aliases**: `//rb`
|
180
|
+
|
181
|
+
### `//say`
|
182
|
+
Speak text using system text-to-speech (macOS/Linux).
|
183
|
+
|
184
|
+
**Syntax**: `//say text to speak`
|
185
|
+
|
186
|
+
**Examples**:
|
187
|
+
```markdown
|
188
|
+
//say Build completed successfully
|
189
|
+
//say Warning: Check the logs
|
190
|
+
```
|
191
|
+
|
192
|
+
**Platform Support**:
|
193
|
+
- macOS: Uses built-in `say` command
|
194
|
+
- Linux: Requires `espeak` or similar TTS software
|
195
|
+
|
196
|
+
## Utility Directives
|
197
|
+
|
198
|
+
### `//tools`
|
199
|
+
Display available RubyLLM tools.
|
200
|
+
|
201
|
+
**Syntax**: `//tools`
|
202
|
+
|
203
|
+
**Example Output**:
|
204
|
+
```
|
205
|
+
Available Tools
|
206
|
+
===============
|
207
|
+
|
208
|
+
FileReader
|
209
|
+
----------
|
210
|
+
Read and analyze file contents with support for multiple formats
|
211
|
+
including text, JSON, YAML, and CSV files.
|
212
|
+
|
213
|
+
WebScraper
|
214
|
+
----------
|
215
|
+
Extract and parse content from web pages with customizable
|
216
|
+
selectors and filters.
|
217
|
+
```
|
218
|
+
|
219
|
+
### `//next`
|
220
|
+
Set the next prompt to execute in a workflow.
|
221
|
+
|
222
|
+
**Syntax**: `//next prompt_id`
|
223
|
+
|
224
|
+
**Examples**:
|
225
|
+
```markdown
|
226
|
+
//next analyze_results
|
227
|
+
//next generate_report
|
228
|
+
```
|
229
|
+
|
230
|
+
**Usage**:
|
231
|
+
- `//next` - Display current next prompt
|
232
|
+
- `//next prompt_id` - Set next prompt in workflow
|
233
|
+
|
234
|
+
### `//pipeline`
|
235
|
+
Define or modify a prompt workflow sequence.
|
236
|
+
|
237
|
+
**Syntax**: `//pipeline prompt1,prompt2,prompt3`
|
238
|
+
|
239
|
+
**Examples**:
|
240
|
+
```markdown
|
241
|
+
//pipeline extract_data,analyze,report
|
242
|
+
//pipeline code_review,optimize,test
|
243
|
+
```
|
244
|
+
|
245
|
+
**Usage**:
|
246
|
+
- `//pipeline` - Display current pipeline
|
247
|
+
- `//pipeline prompts` - Set pipeline sequence
|
248
|
+
- Can use comma-separated or space-separated prompt IDs
|
249
|
+
|
250
|
+
**Aliases**: `//workflow`
|
251
|
+
|
252
|
+
### `//terse`
|
253
|
+
Add instruction for brief responses.
|
254
|
+
|
255
|
+
**Syntax**: `//terse`
|
256
|
+
|
257
|
+
**Example**:
|
258
|
+
```markdown
|
259
|
+
//terse
|
260
|
+
Explain machine learning algorithms.
|
261
|
+
```
|
262
|
+
|
263
|
+
Adds: "Keep your response short and to the point." to the prompt.
|
264
|
+
|
265
|
+
### `//robot`
|
266
|
+
Generate ASCII art robot.
|
267
|
+
|
268
|
+
**Syntax**: `//robot`
|
269
|
+
|
270
|
+
Inserts a fun ASCII robot character for visual breaks in prompts.
|
271
|
+
|
272
|
+
## Context Management Directives
|
273
|
+
|
274
|
+
### `//clear`
|
275
|
+
Clear conversation context in chat mode.
|
276
|
+
|
277
|
+
**Syntax**: `//clear`
|
278
|
+
|
279
|
+
**Usage**: Only available during chat sessions. Clears the conversation history while keeping the session active.
|
280
|
+
|
281
|
+
### `//review`
|
282
|
+
Display current conversation context.
|
283
|
+
|
284
|
+
**Syntax**: `//review`
|
285
|
+
|
286
|
+
**Aliases**: `//context`
|
287
|
+
|
288
|
+
Shows the current context manager state, including conversation history and metadata.
|
289
|
+
|
290
|
+
## Model and Information Directives
|
291
|
+
|
292
|
+
### `//available_models`
|
293
|
+
List available AI models with filtering.
|
294
|
+
|
295
|
+
**Syntax**: `//available_models [filter1,filter2,...]`
|
296
|
+
|
297
|
+
**Examples**:
|
298
|
+
```markdown
|
299
|
+
//available_models
|
300
|
+
//available_models openai
|
301
|
+
//available_models gpt,4
|
302
|
+
//available_models text_to_image
|
303
|
+
//available_models claude,sonnet
|
304
|
+
```
|
305
|
+
|
306
|
+
**Filter Options**:
|
307
|
+
- Provider names: `openai`, `anthropic`, `google`, etc.
|
308
|
+
- Model names: `gpt`, `claude`, `gemini`, etc.
|
309
|
+
- Capabilities: `vision`, `function_calling`, `image_generation`
|
310
|
+
- Modalities: `text_to_text`, `text_to_image`, `image_to_text`
|
311
|
+
|
312
|
+
**Output includes**:
|
313
|
+
- Model name and provider
|
314
|
+
- Input cost per million tokens
|
315
|
+
- Context window size
|
316
|
+
- Input/output modalities
|
317
|
+
- Capabilities
|
318
|
+
|
319
|
+
**Aliases**: `//am`, `//available`, `//models`, `//all_models`, `//llms`
|
320
|
+
|
321
|
+
### `//compare`
|
322
|
+
Compare responses from multiple models.
|
323
|
+
|
324
|
+
**Syntax**: `//compare prompt --models model1,model2,model3`
|
325
|
+
|
326
|
+
**Examples**:
|
327
|
+
```markdown
|
328
|
+
//compare "Explain quantum computing" --models gpt-4,claude-3-sonnet,gemini-pro
|
329
|
+
//compare "Write a Python function to sort a list" --models gpt-3.5-turbo,gpt-4,claude-3-haiku
|
330
|
+
```
|
331
|
+
|
332
|
+
**Features**:
|
333
|
+
- Side-by-side model comparison
|
334
|
+
- Error handling for unavailable models
|
335
|
+
- Formatted output with clear model labels
|
336
|
+
|
337
|
+
**Aliases**: `//cmp`
|
338
|
+
|
339
|
+
### `//help`
|
340
|
+
Display available directives and their descriptions.
|
341
|
+
|
342
|
+
**Syntax**: `//help`
|
343
|
+
|
344
|
+
**Output**: Complete list of all directives with descriptions and aliases.
|
345
|
+
|
346
|
+
## Directive Processing Order
|
347
|
+
|
348
|
+
Directives are processed in the order they appear in the prompt:
|
349
|
+
|
350
|
+
1. **Configuration directives** (like `//config`, `//model`) are processed first
|
351
|
+
2. **File inclusion directives** (`//include`, `//webpage`) are processed next
|
352
|
+
3. **Execution directives** (`//shell`, `//ruby`) are processed
|
353
|
+
4. **Utility directives** are processed last
|
354
|
+
|
355
|
+
## Advanced Usage Patterns
|
356
|
+
|
357
|
+
### Combining Directives
|
358
|
+
|
359
|
+
```markdown
|
360
|
+
//config model gpt-4
|
361
|
+
//config temperature 0.3
|
362
|
+
//include project_context.md
|
363
|
+
|
364
|
+
Based on the project information above:
|
365
|
+
//shell git log --oneline -5
|
366
|
+
|
367
|
+
Analyze these recent commits and suggest improvements.
|
368
|
+
```
|
369
|
+
|
370
|
+
### Dynamic Configuration
|
371
|
+
|
372
|
+
```markdown
|
373
|
+
<% model_name = ENV['PREFERRED_MODEL'] || 'gpt-3.5-turbo' %>
|
374
|
+
//config model <%= model_name %>
|
375
|
+
//config temperature <%= ENV['AI_TEMPERATURE'] || '0.7' %>
|
376
|
+
|
377
|
+
Process this data with optimized settings.
|
378
|
+
```
|
379
|
+
|
380
|
+
### Conditional Execution
|
381
|
+
|
382
|
+
```markdown
|
383
|
+
<% if File.exist?('production.yml') %>
|
384
|
+
//include production.yml
|
385
|
+
<% else %>
|
386
|
+
//include development.yml
|
387
|
+
<% end %>
|
388
|
+
|
389
|
+
Configure the system based on environment.
|
390
|
+
```
|
391
|
+
|
392
|
+
### Workflow Automation
|
393
|
+
|
394
|
+
```markdown
|
395
|
+
//pipeline data_extraction,data_cleaning,analysis,reporting
|
396
|
+
//config model claude-3-sonnet
|
397
|
+
//config temperature 0.2
|
398
|
+
|
399
|
+
Begin automated data processing workflow.
|
400
|
+
```
|
401
|
+
|
402
|
+
## Error Handling
|
403
|
+
|
404
|
+
### Common Errors
|
405
|
+
|
406
|
+
**File Not Found**:
|
407
|
+
```
|
408
|
+
Error: File 'missing.txt' is not accessible
|
409
|
+
```
|
410
|
+
|
411
|
+
**Ruby Execution Error**:
|
412
|
+
```
|
413
|
+
This ruby code failed: invalid_syntax
|
414
|
+
SyntaxError: unexpected token
|
415
|
+
```
|
416
|
+
|
417
|
+
**Web Access Error**:
|
418
|
+
```
|
419
|
+
ERROR: PUREMD_API_KEY is required in order to include a webpage
|
420
|
+
```
|
421
|
+
|
422
|
+
**Missing Context Manager**:
|
423
|
+
```
|
424
|
+
Error: Context manager not available for //clear directive.
|
425
|
+
```
|
426
|
+
|
427
|
+
### Custom Directives
|
428
|
+
|
429
|
+
You can extend AIA with custom directives by creating Ruby files that define new directive methods:
|
430
|
+
|
431
|
+
```ruby
|
432
|
+
# examples/directives/ask.rb
|
433
|
+
module AIA
|
434
|
+
class DirectiveProcessor
|
435
|
+
private
|
436
|
+
desc "A meta-prompt to LLM making its response available as part of the primary prompt"
|
437
|
+
def ask(args, context_manager=nil)
|
438
|
+
meta_prompt = args.empty? ? "What is meta-prompting?" : args.join(' ')
|
439
|
+
AIA.config.client.chat(meta_prompt)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
443
|
+
```
|
444
|
+
|
445
|
+
**Usage:** Load custom directives with the --tools option:
|
446
|
+
|
447
|
+
```bash
|
448
|
+
# Load custom directive
|
449
|
+
aia --tools examples/directives/ask.rb --chat
|
450
|
+
|
451
|
+
# Use the custom directive in prompts
|
452
|
+
//ask gather the latest closing data for the DOW, NASDAQ, and S&P 500
|
453
|
+
```
|
454
|
+
|
455
|
+
### Best Practices
|
456
|
+
|
457
|
+
1. **Test directives individually** before combining them
|
458
|
+
2. **Use absolute paths** for file includes when possible
|
459
|
+
3. **Handle errors gracefully** with conditional Ruby code
|
460
|
+
4. **Validate environment variables** before using them
|
461
|
+
5. **Use appropriate models** for different task types
|
462
|
+
|
463
|
+
## Security Considerations
|
464
|
+
|
465
|
+
- **Shell directives** execute with your user permissions
|
466
|
+
- **Ruby directives** have full access to the Ruby environment
|
467
|
+
- **File inclusion** can access any readable file
|
468
|
+
- **Web access** requires API keys and network access
|
469
|
+
|
470
|
+
### Safe Usage Tips
|
471
|
+
|
472
|
+
1. **Avoid shell commands** that modify system state in shared prompts
|
473
|
+
2. **Use environment variables** for sensitive data, not hardcoded values
|
474
|
+
3. **Validate inputs** in Ruby code before execution
|
475
|
+
4. **Limit file access** to necessary directories only
|
476
|
+
5. **Review prompts** from untrusted sources before execution
|
477
|
+
|
478
|
+
## Environment Variables for Directives
|
479
|
+
|
480
|
+
- `PUREMD_API_KEY` - Required for web page inclusion
|
481
|
+
- `PREFERRED_MODEL` - Default model selection
|
482
|
+
- `AI_TEMPERATURE` - Default temperature setting
|
483
|
+
- `AI_MAX_TOKENS` - Default token limit
|
484
|
+
|
485
|
+
## Related Documentation
|
486
|
+
|
487
|
+
- [CLI Reference](cli-reference.md) - Command-line options
|
488
|
+
- [Configuration](configuration.md) - Configuration file options
|
489
|
+
- [Advanced Prompting](advanced-prompting.md) - Advanced prompt techniques
|
490
|
+
- [Getting Started](guides/getting-started.md) - Basic usage tutorial
|