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
@@ -0,0 +1,477 @@
1
+ # Basic Usage
2
+
3
+ Learn the fundamental patterns and workflows for using AIA effectively in your daily tasks.
4
+
5
+ ## Core Usage Patterns
6
+
7
+ ### 1. Simple Prompt Execution
8
+ The most basic usage pattern - running a single prompt:
9
+
10
+ ```bash
11
+ # Execute a prompt with context
12
+ aia my_prompt input_file.txt
13
+
14
+ # Execute without additional context
15
+ aia general_question
16
+ ```
17
+
18
+ ### 2. Model Selection
19
+ Choose the appropriate model for your task:
20
+
21
+ ```bash
22
+ # Fast and economical for simple tasks
23
+ aia --model gpt-3.5-turbo quick_question
24
+
25
+ # High quality for complex analysis
26
+ aia --model gpt-4 complex_analysis data.csv
27
+
28
+ # Best for long documents
29
+ aia --model claude-3-sonnet document_review long_doc.pdf
30
+ ```
31
+
32
+ ### 3. Output Management
33
+ Control where and how AIA saves results:
34
+
35
+ ```bash
36
+ # Save to file
37
+ aia --out_file result.md analysis_prompt data.csv
38
+
39
+ # Append to existing file
40
+ aia --out_file log.md --append status_check
41
+
42
+ # Format with markdown
43
+ aia --out_file report.md --markdown comprehensive_analysis
44
+ ```
45
+
46
+ ## Common Workflow Patterns
47
+
48
+ ### Research and Analysis
49
+ Typical workflow for research tasks:
50
+
51
+ ```bash
52
+ # Step 1: Gather information
53
+ aia information_gathering --topic "AI trends 2024" --sources "web,papers"
54
+
55
+ # Step 2: Analyze findings
56
+ aia trend_analysis --data research_output.md --focus "enterprise adoption"
57
+
58
+ # Step 3: Generate insights
59
+ aia insight_generation --analysis analysis_output.md --format "executive_summary"
60
+ ```
61
+
62
+ ### Code Review and Development
63
+ Standard development workflow:
64
+
65
+ ```bash
66
+ # Code quality check
67
+ aia code_review src/main.py --focus "security,performance"
68
+
69
+ # Generate documentation
70
+ aia generate_docs --code src/ --format "markdown" --audience "developers"
71
+
72
+ # Create tests
73
+ aia test_generator --code src/main.py --framework "pytest" --coverage "comprehensive"
74
+ ```
75
+
76
+ ### Content Creation
77
+ Content development workflow:
78
+
79
+ ```bash
80
+ # Research phase
81
+ aia content_research --topic "microservices architecture" --depth "comprehensive"
82
+
83
+ # Outline creation
84
+ aia create_outline --topic "microservices" --audience "developers" --length "3000 words"
85
+
86
+ # Content generation
87
+ aia write_content --outline outline.md --style "technical" --examples "include"
88
+ ```
89
+
90
+ ## Configuration Patterns
91
+
92
+ ### Environment-Specific Configurations
93
+ Set up different configurations for different environments:
94
+
95
+ ```yaml
96
+ # ~/.aia/dev_config.yml
97
+ model: gpt-3.5-turbo
98
+ temperature: 0.7
99
+ verbose: true
100
+ debug: true
101
+
102
+ # ~/.aia/prod_config.yml
103
+ model: gpt-4
104
+ temperature: 0.3
105
+ verbose: false
106
+ debug: false
107
+ ```
108
+
109
+ ```bash
110
+ # Use environment-specific configs
111
+ aia --config_file ~/.aia/dev_config.yml development_task
112
+ aia --config_file ~/.aia/prod_config.yml production_analysis
113
+ ```
114
+
115
+ ### Task-Specific Model Selection
116
+ Choose models based on task characteristics:
117
+
118
+ ```bash
119
+ # Creative tasks - higher temperature
120
+ aia --model gpt-4 --temperature 1.2 creative_writing
121
+
122
+ # Analysis tasks - lower temperature
123
+ aia --model claude-3-sonnet --temperature 0.2 data_analysis
124
+
125
+ # Quick tasks - fast model
126
+ aia --model gpt-3.5-turbo --temperature 0.5 quick_summary
127
+ ```
128
+
129
+ ## File and Context Management
130
+
131
+ ### Working with Multiple Files
132
+ Handle multiple input files effectively:
133
+
134
+ ```bash
135
+ # Single file context
136
+ aia code_review main.py
137
+
138
+ # Multiple related files
139
+ aia architecture_review src/*.py
140
+
141
+ # Directory-based analysis
142
+ aia project_analysis ./src/ --recursive --include "*.py,*.rb"
143
+ ```
144
+
145
+ ### Context Preparation
146
+ Prepare context effectively for better results:
147
+
148
+ ```bash
149
+ # Include relevant documentation
150
+ aia --include README.md,ARCHITECTURE.md code_review new_feature.py
151
+
152
+ # Add configuration context
153
+ aia --include config/database.yml,config/redis.yml deployment_review
154
+
155
+ # Include test context
156
+ aia --include tests/ code_quality_check src/
157
+ ```
158
+
159
+ ## Parameter and Variable Usage
160
+
161
+ ### ERB Template Variables
162
+ Use variables to make prompts reusable:
163
+
164
+ ```markdown
165
+ # ~/.prompts/parameterized_review.txt
166
+ Review the <%= file_type %> file for <%= focus_areas %>:
167
+
168
+ File: //include <%= file_path %>
169
+
170
+ Provide <%= detail_level %> analysis with recommendations.
171
+ ```
172
+
173
+ ```bash
174
+ # Use with parameters
175
+ aia parameterized_review \
176
+ --file_type "Python script" \
177
+ --focus_areas "security and performance" \
178
+ --file_path "app.py" \
179
+ --detail_level "comprehensive"
180
+ ```
181
+
182
+ ### Environment Variable Integration
183
+ Use environment variables for dynamic configuration:
184
+
185
+ ```bash
186
+ # Set environment-specific variables
187
+ export PROJECT_NAME="my-app"
188
+ export ENVIRONMENT="staging"
189
+ export REVIEW_FOCUS="security"
190
+
191
+ # Use in prompts
192
+ aia deployment_review --project "${PROJECT_NAME}" --env "${ENVIRONMENT}"
193
+ ```
194
+
195
+ ## Error Handling and Recovery
196
+
197
+ ### Graceful Failure Handling
198
+ Handle common failure scenarios:
199
+
200
+ ```bash
201
+ # Retry with different model on failure
202
+ aia --model gpt-4 analysis_task || aia --model claude-3-sonnet analysis_task
203
+
204
+ # Fallback to simpler approach
205
+ aia comprehensive_analysis data.csv || aia simple_analysis data.csv
206
+
207
+ # Debug mode for troubleshooting
208
+ aia --debug --verbose problematic_task
209
+ ```
210
+
211
+ ### Input Validation
212
+ Validate inputs before processing:
213
+
214
+ ```bash
215
+ # Check file exists before processing
216
+ test -f input.csv && aia data_analysis input.csv || echo "Input file not found"
217
+
218
+ # Verify model availability
219
+ aia --available_models | grep -q "gpt-4" && aia --model gpt-4 task || aia task
220
+ ```
221
+
222
+ ## Performance Optimization
223
+
224
+ ### Efficient Model Usage
225
+ Optimize for speed and cost:
226
+
227
+ ```bash
228
+ # Use appropriate model for task complexity
229
+ aia --model gpt-3.5-turbo simple_tasks # Fast and economical
230
+ aia --model gpt-4 complex_reasoning # High quality when needed
231
+ aia --model claude-3-haiku batch_processing # Fast for large batches
232
+ ```
233
+
234
+ ### Batch Processing
235
+ Handle multiple similar tasks efficiently:
236
+
237
+ ```bash
238
+ # Process multiple files
239
+ for file in *.py; do
240
+ aia code_review "$file" --out_file "reviews/${file%.py}_review.md"
241
+ done
242
+
243
+ # Parallel processing
244
+ parallel -j4 aia analysis_task {} --out_file {.}_analysis.md ::: *.csv
245
+ ```
246
+
247
+ ### Caching and Reuse
248
+ Avoid redundant processing:
249
+
250
+ ```bash
251
+ # Check if output exists before processing
252
+ output_file="analysis_$(date +%Y%m%d).md"
253
+ test -f "$output_file" || aia daily_analysis --out_file "$output_file"
254
+
255
+ # Reuse previous analysis
256
+ aia followup_analysis --previous_analysis yesterday_analysis.md
257
+ ```
258
+
259
+ ## Integration Patterns
260
+
261
+ ### Shell Integration
262
+ Integrate AIA into shell workflows:
263
+
264
+ ```bash
265
+ #!/bin/bash
266
+ # Automated analysis script
267
+
268
+ echo "Starting analysis..."
269
+ aia system_health_check --out_file health_$(date +%Y%m%d_%H%M).md
270
+
271
+ if [ $? -eq 0 ]; then
272
+ echo "Health check complete"
273
+ aia generate_report --source health_*.md --out_file daily_report.md
274
+ else
275
+ echo "Health check failed, investigating..."
276
+ aia troubleshoot_system --debug --verbose
277
+ fi
278
+ ```
279
+
280
+ ### Git Hooks Integration
281
+ Use AIA in Git workflows:
282
+
283
+ ```bash
284
+ #!/bin/sh
285
+ # .git/hooks/pre-commit
286
+
287
+ # Review changed files before commit
288
+ changed_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(py|rb|js)$')
289
+
290
+ if [ -n "$changed_files" ]; then
291
+ echo "Running AIA code review..."
292
+ for file in $changed_files; do
293
+ aia quick_code_review "$file" || exit 1
294
+ done
295
+ fi
296
+ ```
297
+
298
+ ### CI/CD Integration
299
+ Integrate into continuous integration:
300
+
301
+ ```yaml
302
+ # .github/workflows/aia-analysis.yml
303
+ name: AIA Code Analysis
304
+ on: [pull_request]
305
+
306
+ jobs:
307
+ analyze:
308
+ runs-on: ubuntu-latest
309
+ steps:
310
+ - uses: actions/checkout@v3
311
+ - name: Setup Ruby
312
+ uses: ruby/setup-ruby@v1
313
+ with:
314
+ ruby-version: 3.1
315
+ - name: Install AIA
316
+ run: gem install aia
317
+ - name: Run Analysis
318
+ run: |
319
+ aia pr_analysis --diff_only --out_file analysis.md
320
+ cat analysis.md >> $GITHUB_STEP_SUMMARY
321
+ env:
322
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
323
+ ```
324
+
325
+ ## Troubleshooting Common Issues
326
+
327
+ ### Model and API Issues
328
+ ```bash
329
+ # Test model availability
330
+ aia --available_models | grep "gpt-4" || echo "GPT-4 not available"
331
+
332
+ # Test API connection
333
+ aia --model gpt-3.5-turbo --debug simple_test_prompt
334
+
335
+ # Check API key
336
+ echo $OPENAI_API_KEY | cut -c1-10 # Show first 10 chars only
337
+ ```
338
+
339
+ ### File and Permission Issues
340
+ ```bash
341
+ # Check file permissions
342
+ ls -la ~/.prompts/my_prompt.txt
343
+ chmod 644 ~/.prompts/my_prompt.txt
344
+
345
+ # Verify directory access
346
+ test -r ~/.prompts && echo "Prompts directory accessible" || echo "Permission issue"
347
+
348
+ # Check prompt syntax
349
+ aia --debug --dry-run my_prompt # Dry run to check syntax
350
+ ```
351
+
352
+ ### Performance Issues
353
+ ```bash
354
+ # Monitor token usage
355
+ aia --verbose --debug resource_intensive_task 2>&1 | grep -i token
356
+
357
+ # Profile execution time
358
+ time aia complex_analysis large_dataset.csv
359
+
360
+ # Use faster model for testing
361
+ aia --model gpt-3.5-turbo quick_test
362
+ ```
363
+
364
+ ## Essential Prompt Patterns
365
+
366
+ ### The `run` Prompt Pattern
367
+
368
+ The `run` prompt is a configuration-only prompt that serves as a foundation for flexible AI interactions:
369
+
370
+ ```bash
371
+ # ~/.prompts/run.txt
372
+ # Desc: A configuration only prompt file for use with executable prompts
373
+ # Put whatever you want here to setup the configuration desired.
374
+ # You could also add a system prompt to preface your intended prompt
375
+
376
+ //config model = gpt-4o-mini
377
+ //config temperature = 0.7
378
+ //config terse = true
379
+ ```
380
+
381
+ **Usage Examples:**
382
+ ```bash
383
+ # Direct question via pipe
384
+ echo "What is the meaning of life?" | aia run
385
+
386
+ # File analysis
387
+ aia run my_code.py
388
+
389
+ # Multiple files
390
+ aia run *.txt
391
+
392
+ # With custom configuration
393
+ echo "Explain quantum computing" | aia run --model gpt-4 --temperature 1.0
394
+ ```
395
+
396
+ ### The Ad Hoc One-Shot Prompt
397
+
398
+ Perfect for quick questions without cluttering your prompt collection:
399
+
400
+ ```bash
401
+ # ~/.prompts/ad_hoc.txt
402
+ [WHAT_NOW_HUMAN]
403
+ ```
404
+
405
+ **Usage:**
406
+ ```bash
407
+ aia ad_hoc
408
+ # You'll be prompted: "Enter value for WHAT_NOW_HUMAN:"
409
+ # Type your question and get an instant response
410
+ ```
411
+
412
+ ### Recommended Shell Setup
413
+
414
+ Add these powerful aliases and functions to your shell configuration:
415
+
416
+ ```bash
417
+ # ~/.bashrc_aia (or add to ~/.bashrc)
418
+ export AIA_PROMPTS_DIR=~/.prompts
419
+ export AIA_OUT_FILE=./temp.md
420
+ export AIA_MODEL=gpt-4o-mini
421
+ export AIA_VERBOSE=true # Shows spinner while waiting for LLM response
422
+
423
+ # Quick chat alias
424
+ alias chat='aia --chat --terse'
425
+
426
+ # Quick question function
427
+ ask() { echo "$1" | aia run --no-out_file; }
428
+ ```
429
+
430
+ **Usage Examples:**
431
+ ```bash
432
+ # Start quick chat
433
+ chat
434
+
435
+ # Ask quick questions
436
+ ask "How do I install Docker on Ubuntu?"
437
+ ask "What's the difference between REST and GraphQL?"
438
+ ask "Explain the MVC pattern"
439
+ ```
440
+
441
+ ## Best Practices Summary
442
+
443
+ ### Model Selection
444
+ - Use `gpt-3.5-turbo` for simple, fast tasks
445
+ - Use `gpt-4` for complex reasoning and critical analysis
446
+ - Use `claude-3-sonnet` for long documents and detailed analysis
447
+ - Use `claude-3-haiku` for batch processing and quick tasks
448
+
449
+ ### Prompt Organization
450
+ - Group related prompts in directories
451
+ - Use descriptive, consistent naming
452
+ - Include usage examples in prompt comments
453
+ - Version control your prompt collection
454
+
455
+ ### Configuration Management
456
+ - Use environment variables for secrets
457
+ - Create environment-specific configs
458
+ - Document your configuration choices
459
+ - Test configurations in safe environments
460
+
461
+ ### Performance Optimization
462
+ - Choose appropriate models for each task
463
+ - Use batch processing for similar tasks
464
+ - Cache results when appropriate
465
+ - Monitor usage and costs
466
+
467
+ ## Related Documentation
468
+
469
+ - [Getting Started](getting-started.md) - Initial setup and first steps
470
+ - [Chat Mode](chat.md) - Interactive usage patterns
471
+ - [Working with Models](models.md) - Model selection strategies
472
+ - [Advanced Prompting](../advanced-prompting.md) - Complex usage patterns
473
+ - [Configuration](../configuration.md) - Detailed configuration options
474
+
475
+ ---
476
+
477
+ Master these basic patterns first, then explore the advanced features as your needs grow!