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,417 @@
1
+ # Executable Prompts
2
+
3
+ Transform your prompts into standalone executable scripts that can be run directly from the command line, integrated into shell workflows, and used as command-line tools.
4
+
5
+ ## What Are Executable Prompts?
6
+
7
+ Executable prompts are prompt files with a special shebang line that makes them directly executable from the command line. They combine the power of AIA's prompt processing with the convenience of traditional shell scripts.
8
+
9
+ ## Creating Executable Prompts
10
+
11
+ ### Basic Structure
12
+
13
+ ```bash
14
+ #!/usr/bin/env aia run --no-out_file --exec
15
+ # Your prompt description and comments
16
+
17
+ Your prompt content here...
18
+ ```
19
+
20
+ ### Key Components
21
+
22
+ 1. **Shebang Line**: Must include `--exec` flag to enable prompt processing
23
+ 2. **Output Configuration**: Use `--no-out_file` to send output to STDOUT
24
+ 3. **Executable Permissions**: Make file executable with `chmod +x`
25
+
26
+ ## The `run` Prompt Pattern
27
+
28
+ The `run` prompt is a special configuration-only prompt file that serves as a foundation for executable prompts:
29
+
30
+ ### Creating the `run` Prompt
31
+
32
+ ```bash
33
+ # ~/.prompts/run.txt
34
+ # Desc: A configuration only prompt file for use with executable prompts
35
+ # Put whatever you want here to setup the configuration desired.
36
+ # You could also add a system prompt to preface your intended prompt
37
+
38
+ //config model = gpt-4o-mini
39
+ //config temperature = 0.7
40
+ //config terse = true
41
+ ```
42
+
43
+ ### Usage Pattern
44
+
45
+ ```bash
46
+ # Pipe questions directly to the run prompt
47
+ echo "What is the meaning of life?" | aia run
48
+ ```
49
+
50
+ This pattern allows for quick one-shot questions without creating specific prompt files.
51
+
52
+ ## Practical Examples
53
+
54
+ ### Weather Report Script
55
+
56
+ Create a weather monitoring executable:
57
+
58
+ ```bash
59
+ #!/usr/bin/env aia run --no-out_file --exec
60
+ # Get current storm activity for the east and south coast of the US
61
+
62
+ Summarize the tropical storm outlook for the Atlantic, Caribbean Sea and Gulf of America.
63
+
64
+ //webpage https://www.nhc.noaa.gov/text/refresh/MIATWOAT+shtml/201724_MIATWOAT.shtml
65
+ ```
66
+
67
+ **Setup and Usage:**
68
+ ```bash
69
+ # Save as weather_report
70
+ chmod +x weather_report
71
+
72
+ # Run directly
73
+ ./weather_report
74
+
75
+ # Pipe to markdown viewer
76
+ ./weather_report | glow
77
+ ```
78
+
79
+ ### System Status Monitor
80
+
81
+ ```bash
82
+ #!/usr/bin/env aia run --no-out_file --exec
83
+ # System health check and analysis
84
+
85
+ Analyze the current system status and provide recommendations:
86
+
87
+ System Information:
88
+ //shell uname -a
89
+
90
+ Disk Usage:
91
+ //shell df -h
92
+
93
+ Memory Usage:
94
+ //shell free -h 2>/dev/null || vm_stat
95
+
96
+ Running Processes:
97
+ //shell ps aux | head -20
98
+
99
+ Provide analysis and recommendations for system optimization.
100
+ ```
101
+
102
+ ### Code Quality Checker
103
+
104
+ ```bash
105
+ #!/usr/bin/env aia run --no-out_file --exec
106
+ # Analyze code quality for the current directory
107
+
108
+ //config model = gpt-4
109
+ //config temperature = 0.3
110
+
111
+ Review the code structure and quality in this project:
112
+
113
+ Project Structure:
114
+ //shell find . -type f -name "*.rb" -o -name "*.py" -o -name "*.js" | head -20
115
+
116
+ Git Status:
117
+ //shell git status --short 2>/dev/null || echo "Not a git repository"
118
+
119
+ Recent Commits:
120
+ //shell git log --oneline -10 2>/dev/null || echo "No git history available"
121
+
122
+ Provide code quality assessment and improvement recommendations.
123
+ ```
124
+
125
+ ### Daily Standup Generator
126
+
127
+ ```bash
128
+ #!/usr/bin/env aia run --no-out_file --exec
129
+ # Generate daily standup report from git activity
130
+
131
+ //config model = gpt-4o-mini
132
+ //config temperature = 0.5
133
+
134
+ Generate a daily standup report based on recent git activity:
135
+
136
+ Yesterday's Commits:
137
+ //shell git log --since="1 day ago" --author="$(git config user.name)" --oneline
138
+
139
+ Current Branch Status:
140
+ //shell git status --short
141
+
142
+ Today's Focus:
143
+ Based on the above activity, what should be the key focus areas for today?
144
+ Provide a structured standup report.
145
+ ```
146
+
147
+ ## Advanced Executable Patterns
148
+
149
+ ### Parameterized Executables
150
+
151
+ Create executable prompts that accept command-line parameters:
152
+
153
+ ```bash
154
+ #!/usr/bin/env aia run --no-out_file --exec
155
+ # Code review for specific file
156
+ # Usage: ./code_review <filename>
157
+
158
+ //ruby
159
+ filename = ARGV[0] || "[FILENAME]"
160
+ puts "Reviewing file: #{filename}"
161
+ ```
162
+
163
+ Review this code file for quality, security, and best practices:
164
+
165
+ //include <%= filename %>
166
+
167
+ Provide specific, actionable feedback for improvements.
168
+ ```
169
+
170
+ ### Pipeline Executables
171
+
172
+ Chain multiple prompts in an executable workflow:
173
+
174
+ ```bash
175
+ #!/usr/bin/env aia run --no-out_file --exec
176
+ # Complete project analysis pipeline
177
+
178
+ //pipeline project_scan,security_check,recommendations
179
+
180
+ Starting comprehensive project analysis...
181
+ ```
182
+
183
+ ### Conditional Logic Executables
184
+
185
+ ```bash
186
+ #!/usr/bin/env aia run --no-out_file --exec
187
+ # Environment-aware deployment checker
188
+
189
+ //ruby
190
+ environment = ENV['RAILS_ENV'] || 'development'
191
+ case environment
192
+ when 'production'
193
+ puts "//config model = gpt-4"
194
+ puts "//config temperature = 0.2"
195
+ puts "Production deployment analysis:"
196
+ when 'staging'
197
+ puts "//config model = gpt-4o-mini"
198
+ puts "//config temperature = 0.4"
199
+ puts "Staging deployment analysis:"
200
+ else
201
+ puts "//config model = gpt-3.5-turbo"
202
+ puts "//config temperature = 0.6"
203
+ puts "Development deployment analysis:"
204
+ end
205
+ ```
206
+
207
+ Environment: <%= environment %>
208
+
209
+ //shell env | grep -E "(DATABASE|REDIS|API)" | sort
210
+
211
+ Analyze the deployment configuration and provide environment-specific recommendations.
212
+ ```
213
+
214
+ ## Integration with Shell Workflows
215
+
216
+ ### As Git Hooks
217
+
218
+ ```bash
219
+ #!/usr/bin/env aia run --no-out_file --exec
220
+ # .git/hooks/pre-commit
221
+ # Automated commit message analysis
222
+
223
+ Analyze the staged changes and suggest improvements:
224
+
225
+ Staged Changes:
226
+ //shell git diff --cached --stat
227
+
228
+ //shell git diff --cached
229
+
230
+ Provide commit message suggestions and code quality feedback.
231
+ ```
232
+
233
+ ### In Makefiles
234
+
235
+ ```makefile
236
+ # Makefile integration
237
+ analyze-code:
238
+ @./scripts/code_analyzer
239
+
240
+ deploy-check:
241
+ @./scripts/deployment_check | tee deploy-report.md
242
+
243
+ .PHONY: analyze-code deploy-check
244
+ ```
245
+
246
+ ### In CI/CD Pipelines
247
+
248
+ ```yaml
249
+ # .github/workflows/ai-analysis.yml
250
+ name: AI Code Analysis
251
+ on: [pull_request]
252
+
253
+ jobs:
254
+ analysis:
255
+ runs-on: ubuntu-latest
256
+ steps:
257
+ - uses: actions/checkout@v3
258
+ - name: Setup Ruby
259
+ uses: ruby/setup-ruby@v1
260
+ with:
261
+ ruby-version: 3.2
262
+ - name: Install AIA
263
+ run: gem install aia
264
+ - name: Run Analysis
265
+ run: ./scripts/pr_analyzer
266
+ env:
267
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
268
+ ```
269
+
270
+ ## Best Practices for Executable Prompts
271
+
272
+ ### Security Considerations
273
+
274
+ 1. **Review Before Execution**: Always review executable prompts before running
275
+ 2. **Limit Permissions**: Use appropriate file permissions
276
+ 3. **Validate Inputs**: Check parameters and environment variables
277
+ 4. **Avoid Secrets**: Never hardcode API keys or sensitive data
278
+
279
+ ```bash
280
+ # Set secure permissions
281
+ chmod 750 executable_prompt # Owner can execute, group can read
282
+ chmod 700 sensitive_prompt # Owner only
283
+ ```
284
+
285
+ ### Error Handling
286
+
287
+ ```bash
288
+ #!/usr/bin/env aia run --no-out_file --exec
289
+ # Robust executable with error handling
290
+
291
+ //ruby
292
+ if ARGV.empty?
293
+ puts "Error: Please provide a filename as argument"
294
+ puts "Usage: #{$0} <filename>"
295
+ exit 1
296
+ end
297
+
298
+ filename = ARGV[0]
299
+ unless File.exist?(filename)
300
+ puts "Error: File '#{filename}' not found"
301
+ exit 1
302
+ end
303
+ ```
304
+
305
+ File analysis for: <%= filename %>
306
+
307
+ //include <%= filename %>
308
+
309
+ Analyze the file structure, quality, and provide recommendations.
310
+ ```
311
+
312
+ ### Performance Optimization
313
+
314
+ ```bash
315
+ # Use faster models for simple tasks
316
+ //config model = gpt-4o-mini
317
+
318
+ # Reduce token usage for executables
319
+ //config max_tokens = 1500
320
+
321
+ # Lower temperature for consistent results
322
+ //config temperature = 0.3
323
+ ```
324
+
325
+ ## Debugging Executable Prompts
326
+
327
+ ### Enable Debug Mode
328
+
329
+ ```bash
330
+ #!/usr/bin/env aia run --no-out_file --exec --debug --verbose
331
+ # Debug version of your executable prompt
332
+ ```
333
+
334
+ ### Test Components Separately
335
+
336
+ ```bash
337
+ # Test the underlying prompt
338
+ aia run test_input.txt
339
+
340
+ # Test with debug output
341
+ aia --debug run test_input.txt
342
+
343
+ # Test shell commands separately
344
+ date
345
+ git status
346
+ ```
347
+
348
+ ### Common Issues
349
+
350
+ | Issue | Cause | Solution |
351
+ |-------|-------|----------|
352
+ | "Permission denied" | File not executable | `chmod +x filename` |
353
+ | "Command not found" | Missing shebang or wrong path | Check shebang line |
354
+ | "Prompt not found" | Missing run prompt | Create ~/.prompts/run.txt |
355
+ | "Output not appearing" | Missing --no-out_file | Add flag to shebang |
356
+
357
+ ## Advanced Executable Patterns
358
+
359
+ ### Self-Documenting Executables
360
+
361
+ ```bash
362
+ #!/usr/bin/env aia run --no-out_file --exec
363
+ # Self-documenting code analyzer
364
+ # Usage: ./code_analyzer [--help] <directory>
365
+
366
+ //ruby
367
+ if ARGV.include?('--help')
368
+ puts <<~HELP
369
+ Code Analyzer - AI-powered code quality assessment
370
+
371
+ Usage: #{$0} <directory>
372
+
373
+ Options:
374
+ --help Show this help message
375
+
376
+ Examples:
377
+ #{$0} ./src
378
+ #{$0} /path/to/project
379
+ HELP
380
+ exit 0
381
+ end
382
+ ```
383
+
384
+ ### Multi-Stage Executables
385
+
386
+ ```bash
387
+ #!/usr/bin/env aia run --no-out_file --exec
388
+ # Multi-stage project analysis
389
+
390
+ //ruby
391
+ stages = %w[structure security performance documentation]
392
+ current_stage = ENV['STAGE'] || stages.first
393
+
394
+ puts "=== Stage #{stages.index(current_stage) + 1}: #{current_stage.capitalize} ==="
395
+
396
+ case current_stage
397
+ when 'structure'
398
+ puts "//pipeline structure_analysis,security_check"
399
+ when 'security'
400
+ puts "//pipeline security_scan,vulnerability_check"
401
+ when 'performance'
402
+ puts "//pipeline performance_analysis,optimization_suggestions"
403
+ when 'documentation'
404
+ puts "//pipeline doc_analysis,improvement_suggestions"
405
+ end
406
+ ```
407
+
408
+ ## Related Documentation
409
+
410
+ - [Getting Started](getting-started.md) - Basic AIA usage
411
+ - [Basic Usage](basic-usage.md) - Common usage patterns
412
+ - [CLI Reference](../cli-reference.md) - Command-line options
413
+ - [Advanced Prompting](../advanced-prompting.md) - Complex prompt techniques and shell integration
414
+
415
+ ---
416
+
417
+ Executable prompts transform AIA from a tool into a platform for creating AI-powered command-line utilities. Start with simple executables and gradually build more sophisticated tools as you become comfortable with the patterns!