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,579 @@
1
+ # Prompt Management
2
+
3
+ AIA provides sophisticated prompt management capabilities through the PromptManager gem, enabling you to organize, version, and efficiently use large collections of prompts.
4
+
5
+ ## Directory Structure
6
+
7
+ ### Default Structure
8
+ ```
9
+ ~/.prompts/
10
+ ├── README.md # Documentation for your prompt collection
11
+ ├── roles/ # Role-based prompts for context setting
12
+ │ ├── assistant.txt
13
+ │ ├── code_expert.txt
14
+ │ └── teacher.txt
15
+ ├── development/ # Development-related prompts
16
+ │ ├── code_review.txt
17
+ │ ├── debug_help.txt
18
+ │ └── documentation.txt
19
+ ├── writing/ # Content creation prompts
20
+ │ ├── blog_post.txt
21
+ │ ├── technical_docs.txt
22
+ │ └── creative_writing.txt
23
+ ├── analysis/ # Data and research analysis
24
+ │ ├── data_analysis.txt
25
+ │ ├── research_summary.txt
26
+ │ └── report_generation.txt
27
+ └── workflows/ # Multi-step prompt sequences
28
+ ├── code_pipeline.txt
29
+ ├── content_pipeline.txt
30
+ └── analysis_pipeline.txt
31
+ ```
32
+
33
+ ### Custom Structure
34
+ ```bash
35
+ # Set custom prompts directory
36
+ export AIA_PROMPTS_DIR="/path/to/custom/prompts"
37
+ aia --prompts_dir /path/to/custom/prompts
38
+
39
+ # Use project-specific prompts
40
+ aia --prompts_dir ./project_prompts my_prompt
41
+ ```
42
+
43
+ ## Prompt File Formats
44
+
45
+ ### Basic Text Prompts
46
+ ```markdown
47
+ # ~/.prompts/simple_question.txt
48
+ Please answer this question clearly and concisely:
49
+
50
+ <%= question %>
51
+
52
+ Provide examples where helpful.
53
+ ```
54
+
55
+ ### Prompts with Directives
56
+ ```markdown
57
+ # ~/.prompts/code_analysis.txt
58
+ //config model gpt-4
59
+ //config temperature 0.3
60
+
61
+ # Code Analysis and Review
62
+
63
+ Analyze the following code for:
64
+ - Security vulnerabilities
65
+ - Performance issues
66
+ - Best practice violations
67
+ - Potential bugs
68
+
69
+ ## Code to Review:
70
+ //include <%= file %>
71
+
72
+ Provide specific recommendations with code examples.
73
+ ```
74
+
75
+ ### ERB Template Prompts
76
+ ```erb
77
+ # ~/.prompts/blog_post_generator.txt
78
+ //config model <%= model || "gpt-4" %>
79
+ //config temperature <%= creativity || "0.8" %>
80
+ //config max_tokens <%= length || "2000" %>
81
+
82
+ # Blog Post: <%= title %>
83
+
84
+ Write a <%= tone || "professional" %> blog post about <%= topic %>.
85
+
86
+ Target audience: <%= audience || "general" %>
87
+ Word count: <%= word_count || "1000-1500" %> words
88
+
89
+ <% if include_seo %>
90
+ Include SEO-friendly headings and meta description.
91
+ <% end %>
92
+
93
+ <% if code_examples %>
94
+ Include practical code examples where relevant.
95
+ <% end %>
96
+
97
+ Structure:
98
+ 1. Engaging introduction
99
+ 2. Main content with clear sections
100
+ 3. Actionable takeaways
101
+ 4. Compelling conclusion
102
+ ```
103
+
104
+ ### Executable Prompts
105
+ ```markdown
106
+ # ~/.prompts/system_report.txt
107
+ //config executable true
108
+ //shell hostname
109
+ //shell uptime
110
+ //shell df -h
111
+ //shell free -h
112
+ //shell ps aux | head -10
113
+
114
+ System Status Report
115
+ ===================
116
+
117
+ Please analyze this system information and provide:
118
+ 1. Overall system health assessment
119
+ 2. Potential issues or concerns
120
+ 3. Recommendations for optimization
121
+ 4. Any immediate actions needed
122
+ ```
123
+
124
+ ## Prompt Discovery and Search
125
+
126
+ ### Basic Search
127
+ ```bash
128
+ # List all prompts
129
+ aia --prompts_dir ~/.prompts
130
+
131
+ # Search by pattern
132
+ find ~/.prompts -name "*code*" -type f
133
+
134
+ # Search content
135
+ grep -r "code review" ~/.prompts/
136
+ ```
137
+
138
+ ### Fuzzy Search (with fzf)
139
+ ```bash
140
+ # Interactive prompt selection
141
+ aia --fuzzy
142
+
143
+ # This opens an interactive interface showing:
144
+ # - Prompt names and paths
145
+ # - Recent usage
146
+ # - Preview of prompt content
147
+ ```
148
+
149
+ ### Advanced Search
150
+ ```bash
151
+ # Search by category
152
+ aia --fuzzy development/
153
+
154
+ # Search by role
155
+ aia --fuzzy roles/
156
+
157
+ # Search in specific subdirectory
158
+ aia --prompts_dir ~/.prompts/analysis --fuzzy
159
+ ```
160
+
161
+ ## Prompt Organization Strategies
162
+
163
+ ### By Domain/Category
164
+ ```
165
+ ~/.prompts/
166
+ ├── software_development/
167
+ ├── data_science/
168
+ ├── content_creation/
169
+ ├── business_analysis/
170
+ └── personal/
171
+ ```
172
+
173
+ ### By Complexity
174
+ ```
175
+ ~/.prompts/
176
+ ├── quick_tasks/ # Simple, fast prompts
177
+ ├── standard_workflows/ # Regular multi-step processes
178
+ ├── complex_analysis/ # Deep analysis prompts
179
+ └── specialized/ # Domain-specific expert prompts
180
+ ```
181
+
182
+ ### By Model Type
183
+ ```
184
+ ~/.prompts/
185
+ ├── gpt4_prompts/ # Prompts optimized for GPT-4
186
+ ├── claude_prompts/ # Prompts optimized for Claude
187
+ ├── vision_prompts/ # Prompts for vision models
188
+ └── code_prompts/ # Prompts for code models
189
+ ```
190
+
191
+ ### By Workflow Stage
192
+ ```
193
+ ~/.prompts/
194
+ ├── input_processing/ # Initial data/content processing
195
+ ├── analysis/ # Analysis and evaluation
196
+ ├── generation/ # Content/code generation
197
+ ├── review/ # Quality review and validation
198
+ └── finalization/ # Final output formatting
199
+ ```
200
+
201
+ ## Parameterized Prompts
202
+
203
+ ### ERB Variables
204
+ ```erb
205
+ # ~/.prompts/parameterized_analysis.txt
206
+ //config model <%= model || "gpt-4" %>
207
+
208
+ Analyze <%= subject %> focusing on <%= focus_area %>.
209
+
210
+ <% if detailed %>
211
+ Provide comprehensive analysis including:
212
+ - Background context
213
+ - Detailed findings
214
+ - Implications and recommendations
215
+ <% else %>
216
+ Provide a concise summary of key findings.
217
+ <% end %>
218
+
219
+ Context:
220
+ //include <%= context_file if context_file %>
221
+ ```
222
+
223
+ ### Usage with Parameters
224
+ ```bash
225
+ # Pass parameters via environment or command line
226
+ export subject="market trends"
227
+ export focus_area="growth opportunities"
228
+ export detailed="true"
229
+ aia parameterized_analysis
230
+
231
+ # Or using AIA's parameter system
232
+ aia parameterized_analysis --subject "user behavior" --focus_area "conversion rates"
233
+ ```
234
+
235
+ ### Parameter Extraction
236
+ ```bash
237
+ # Use regex to extract parameters from prompts
238
+ aia --regex '\{\{(\w+)\}\}' template_prompt
239
+ aia --regex '<%=\s*(\w+)\s*%>' erb_prompt
240
+ ```
241
+
242
+ ## Roles and Context
243
+
244
+ ### Role Definitions
245
+ ```markdown
246
+ # ~/.prompts/roles/software_architect.txt
247
+ You are a senior software architect with 15+ years of experience designing scalable systems.
248
+
249
+ Your expertise includes:
250
+ - Microservices architecture
251
+ - Cloud-native design patterns
252
+ - Performance optimization
253
+ - Security best practices
254
+ - Team leadership and mentoring
255
+
256
+ When providing advice:
257
+ - Consider scalability and maintainability
258
+ - Suggest industry best practices
259
+ - Provide concrete architectural examples
260
+ - Address potential trade-offs
261
+ - Consider operational aspects
262
+
263
+ Communicate in a professional but approachable manner, suitable for both senior and junior developers.
264
+ ```
265
+
266
+ ### Using Roles
267
+ ```bash
268
+ # Apply role to prompt
269
+ aia --role software_architect system_design
270
+
271
+ # Role with specific prompts
272
+ aia --role code_expert code_review main.py
273
+
274
+ # Custom roles directory
275
+ aia --roles_prefix personas --role mentor learning_session
276
+ ```
277
+
278
+ ### Context Layering
279
+ ```markdown
280
+ # ~/.prompts/layered_context.txt
281
+ //include roles/<%= role || "assistant" %>.txt
282
+
283
+ //config model <%= model || "gpt-4" %>
284
+
285
+ Project Context:
286
+ //include README.md
287
+ //include ARCHITECTURE.md
288
+
289
+ Current Task:
290
+ <%= task_description %>
291
+
292
+ Please provide guidance consistent with the project architecture and your role as <%= role %>.
293
+ ```
294
+
295
+ ## Prompt Workflows and Pipelines
296
+
297
+ ### Simple Workflows
298
+ ```markdown
299
+ # ~/.prompts/data_workflow_start.txt
300
+ //next data_cleaning
301
+ //pipeline analysis,visualization,reporting
302
+
303
+ Begin data processing workflow for: <%= dataset %>
304
+
305
+ Initial data examination:
306
+ //shell head -10 <%= dataset %>
307
+ //shell wc -l <%= dataset %>
308
+
309
+ Proceed to data cleaning stage.
310
+ ```
311
+
312
+ ### Complex Pipelines
313
+ ```bash
314
+ # Multi-stage analysis pipeline
315
+ aia --pipeline "extract_data,validate_data,analyze_patterns,generate_insights,create_report" dataset.csv
316
+ ```
317
+
318
+ ### Conditional Workflows
319
+ ```ruby
320
+ # ~/.prompts/adaptive_workflow.txt
321
+ //ruby
322
+ data_size = File.size('<%= input_file %>')
323
+ complexity = data_size > 1000000 ? 'complex' : 'simple'
324
+
325
+ if complexity == 'complex'
326
+ puts "//pipeline prepare_data,chunk_processing,merge_results,final_analysis"
327
+ else
328
+ puts "//pipeline quick_analysis,summary_report"
329
+ end
330
+
331
+ puts "Selected #{complexity} workflow for #{data_size} byte dataset"
332
+ ```
333
+
334
+ ## Version Control for Prompts
335
+
336
+ ### Git Integration
337
+ ```bash
338
+ # Initialize prompt repository
339
+ cd ~/.prompts
340
+ git init
341
+ git add .
342
+ git commit -m "Initial prompt collection"
343
+
344
+ # Track changes
345
+ git add modified_prompt.txt
346
+ git commit -m "Improved code review prompt with security focus"
347
+
348
+ # Branch for experiments
349
+ git checkout -b experimental_prompts
350
+ # ... make changes ...
351
+ git checkout main
352
+ git merge experimental_prompts
353
+ ```
354
+
355
+ ### Backup and Sync
356
+ ```bash
357
+ # Backup to remote repository
358
+ git remote add origin git@github.com:username/my-prompts.git
359
+ git push -u origin main
360
+
361
+ # Sync across machines
362
+ git pull origin main
363
+ ```
364
+
365
+ ### Versioned Prompts
366
+ ```markdown
367
+ # ~/.prompts/versioned/code_review_v2.txt
368
+ //config version 2.0
369
+ //config changelog "Added security analysis, improved output format"
370
+
371
+ # Code Review v2.0
372
+ Enhanced code review with security focus and structured output.
373
+ ```
374
+
375
+ ## Prompt Sharing and Collaboration
376
+
377
+ ### Team Prompt Libraries
378
+ ```bash
379
+ # Shared team prompts
380
+ git clone git@github.com:team/shared-prompts.git ~/.prompts/shared/
381
+ aia --prompts_dir ~/.prompts/shared/ team_code_review
382
+
383
+ # Personal + shared prompts
384
+ export AIA_PROMPTS_DIR="~/.prompts:~/.prompts/shared:./project_prompts"
385
+ ```
386
+
387
+ ### Prompt Documentation
388
+ ```markdown
389
+ # ~/.prompts/README.md
390
+ # Team Prompt Library
391
+
392
+ ## Categories
393
+ - `development/` - Code review, debugging, architecture
394
+ - `analysis/` - Data analysis, research, reporting
395
+ - `content/` - Writing, documentation, marketing
396
+
397
+ ## Usage Guidelines
398
+ 1. Test prompts before sharing
399
+ 2. Include parameter documentation
400
+ 3. Add examples in comments
401
+ 4. Follow naming conventions
402
+
403
+ ## Contributing
404
+ 1. Create feature branch
405
+ 2. Add/modify prompts
406
+ 3. Test thoroughly
407
+ 4. Submit pull request
408
+ ```
409
+
410
+ ### Prompt Standards
411
+ ```markdown
412
+ # Prompt file header standard
413
+ # Title: Brief description
414
+ # Purpose: What this prompt accomplishes
415
+ # Parameters: List of expected variables
416
+ # Models: Recommended models
417
+ # Example: aia prompt_name --param value
418
+ # Author: Your name
419
+ # Version: 1.0
420
+ # Updated: YYYY-MM-DD
421
+ ```
422
+
423
+ ## Performance and Optimization
424
+
425
+ ### Prompt Efficiency
426
+ ```bash
427
+ # Monitor prompt performance
428
+ aia --verbose --debug optimized_prompt
429
+
430
+ # Compare prompt variations
431
+ time aia version1_prompt input.txt
432
+ time aia version2_prompt input.txt
433
+ ```
434
+
435
+ ### Caching Strategies
436
+ ```ruby
437
+ # Cache expensive computations
438
+ //ruby
439
+ cache_file = "/tmp/analysis_cache_#{File.basename('<%= input %>')}.json"
440
+ if File.exist?(cache_file) && (Time.now - File.mtime(cache_file)) < 3600
441
+ cached_data = JSON.parse(File.read(cache_file))
442
+ puts "Using cached analysis: #{cached_data}"
443
+ else
444
+ # Perform expensive analysis
445
+ # Save to cache
446
+ end
447
+ ```
448
+
449
+ ### Batch Processing
450
+ ```bash
451
+ # Batch process multiple files
452
+ for file in data/*.csv; do
453
+ aia batch_analysis_prompt "$file" --out_file "results/$(basename $file .csv)_analysis.md"
454
+ done
455
+
456
+ # Parallel processing
457
+ parallel -j4 aia analysis_prompt {} --out_file {.}_result.md ::: data/*.txt
458
+ ```
459
+
460
+ ## Troubleshooting Prompts
461
+
462
+ ### Debugging Tools
463
+ ```bash
464
+ # Debug prompt processing
465
+ aia --debug --verbose problematic_prompt
466
+
467
+ # Test directive processing
468
+ aia --debug prompt_with_directives
469
+
470
+ # Validate ERB syntax
471
+ erb -T - ~/.prompts/template_prompt.txt < /dev/null
472
+ ```
473
+
474
+ ### Common Issues
475
+
476
+ #### Missing Parameters
477
+ ```bash
478
+ # Check required parameters
479
+ aia --regex '<%=\s*(\w+)\s*%>' my_prompt
480
+ # Ensure all extracted parameters are provided
481
+ ```
482
+
483
+ #### File Not Found
484
+ ```bash
485
+ # Verify file paths in //include directives
486
+ find ~/.prompts -name "missing_file.txt"
487
+ # Use absolute paths or verify relative paths
488
+ ```
489
+
490
+ #### Permission Errors
491
+ ```bash
492
+ # Check prompt file permissions
493
+ ls -la ~/.prompts/problematic_prompt.txt
494
+ chmod 644 ~/.prompts/problematic_prompt.txt
495
+ ```
496
+
497
+ ## Advanced Prompt Techniques
498
+
499
+ ### Dynamic Prompt Generation
500
+ ```ruby
501
+ # Generate prompts based on context
502
+ //ruby
503
+ project_type = `git config --get remote.origin.url`.include?('rails') ? 'rails' : 'general'
504
+ prompt_template = File.read("templates/#{project_type}_review.txt")
505
+ puts prompt_template
506
+ ```
507
+
508
+ ### Prompt Composition
509
+ ```markdown
510
+ # ~/.prompts/composed_prompt.txt
511
+ //include base/standard_instructions.txt
512
+ //include domain/#{<%= domain %>}_expertise.txt
513
+ //include format/#{<%= output_format %>}_template.txt
514
+
515
+ Task: <%= specific_task %>
516
+ ```
517
+
518
+ ### Adaptive Prompts
519
+ ```ruby
520
+ # Adjust based on model capabilities
521
+ //ruby
522
+ model = AIA.config.model
523
+ if model.include?('gpt-4')
524
+ puts "Use advanced reasoning and detailed analysis."
525
+ elsif model.include?('3.5')
526
+ puts "Focus on clear, direct responses."
527
+ end
528
+ ```
529
+
530
+ ## Best Practices
531
+
532
+ ### Prompt Design
533
+ 1. **Clear Structure**: Use headers and sections
534
+ 2. **Specific Instructions**: Be precise about desired output
535
+ 3. **Context Setting**: Provide necessary background
536
+ 4. **Parameter Documentation**: Document all variables
537
+ 5. **Error Handling**: Account for edge cases
538
+
539
+ ### Organization
540
+ 1. **Consistent Naming**: Use clear, descriptive names
541
+ 2. **Logical Grouping**: Organize by category or purpose
542
+ 3. **Version Control**: Track changes and improvements
543
+ 4. **Documentation**: Maintain usage guides
544
+ 5. **Regular Cleanup**: Remove obsolete prompts
545
+
546
+ #### Recommended Directory Structure
547
+ ```
548
+ ~/.prompts/
549
+ ├── daily/ # Daily workflow prompts
550
+ ├── development/ # Coding and review prompts
551
+ ├── research/ # Research and analysis
552
+ ├── roles/ # System prompts
553
+ └── workflows/ # Multi-step pipelines
554
+ ```
555
+
556
+ This organization helps you:
557
+ - **Find prompts quickly** by category
558
+ - **Maintain logical separation** of different use cases
559
+ - **Scale your prompt collection** without confusion
560
+ - **Share category-specific prompts** with team members
561
+
562
+ ### Performance
563
+ 1. **Model Selection**: Choose appropriate models
564
+ 2. **Parameter Optimization**: Fine-tune settings
565
+ 3. **Caching**: Cache expensive operations
566
+ 4. **Batch Processing**: Process multiple items efficiently
567
+ 5. **Monitoring**: Track usage and performance
568
+
569
+ ## Related Documentation
570
+
571
+ - [Getting Started](guides/getting-started.md) - Basic prompt usage
572
+ - [Directives Reference](directives-reference.md) - Available directives
573
+ - [Advanced Prompting](advanced-prompting.md) - Expert techniques
574
+ - [Configuration](configuration.md) - Setup and customization
575
+ - [Examples](examples/prompts/index.md) - Real-world prompt examples
576
+
577
+ ---
578
+
579
+ Effective prompt management is key to maximizing AIA's capabilities. Start with a simple organization structure and evolve it as your prompt collection grows!