aia 2.0.0.0.pre.alpha → 2.0.0

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 (236) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/CHANGELOG.md +151 -228
  4. data/README.md +42 -19
  5. data/bin/aia +8 -3
  6. data/lib/aia/aia_completion.bash +2 -3
  7. data/lib/aia/aia_completion.fish +6 -5
  8. data/lib/aia/aia_completion.zsh +2 -3
  9. data/lib/aia/chat_loop.rb +24 -66
  10. data/lib/aia/config/cli_parser.rb +164 -123
  11. data/lib/aia/config/defaults.yml +12 -39
  12. data/lib/aia/config/mcp_parser.rb +42 -40
  13. data/lib/aia/config/model_spec.rb +8 -14
  14. data/lib/aia/config/validator.rb +144 -156
  15. data/lib/aia/config/value_caster.rb +76 -0
  16. data/lib/aia/config.rb +72 -54
  17. data/lib/aia/content_extractor.rb +2 -0
  18. data/lib/aia/cost_calculator.rb +1 -0
  19. data/lib/aia/crew.rb +29 -19
  20. data/lib/aia/debate_handler.rb +45 -20
  21. data/lib/aia/delegate_handler.rb +7 -3
  22. data/lib/aia/directive.rb +10 -8
  23. data/lib/aia/directives/configuration_directives.rb +164 -109
  24. data/lib/aia/directives/context_directives.rb +55 -40
  25. data/lib/aia/directives/execution_directives.rb +25 -25
  26. data/lib/aia/directives/model_directives.rb +112 -195
  27. data/lib/aia/directives/trakflow_directives.rb +27 -9
  28. data/lib/aia/directives/utility_directives.rb +86 -87
  29. data/lib/aia/directives/web_and_file_directives.rb +83 -63
  30. data/lib/aia/fact_asserter.rb +3 -3
  31. data/lib/aia/history_transfer.rb +64 -24
  32. data/lib/aia/layered_orchestrator.rb +66 -43
  33. data/lib/aia/logger.rb +27 -62
  34. data/lib/aia/mcp_config_normalizer.rb +27 -14
  35. data/lib/aia/mcp_connection_manager.rb +193 -186
  36. data/lib/aia/mcp_discovery.rb +43 -15
  37. data/lib/aia/mcp_grouper.rb +2 -1
  38. data/lib/aia/mcp_server_config.rb +48 -0
  39. data/lib/aia/mcp_utility.rb +28 -20
  40. data/lib/aia/mention_router.rb +22 -52
  41. data/lib/aia/modality_query.rb +36 -0
  42. data/lib/aia/model_alias_registry.rb +11 -11
  43. data/lib/aia/model_registry.rb +75 -0
  44. data/lib/aia/network_builder.rb +17 -11
  45. data/lib/aia/network_memory_manager.rb +6 -6
  46. data/lib/aia/patches/ruby_llm_streaming_error.rb +21 -4
  47. data/lib/aia/patches/ruby_llm_tool_param_compat.rb +18 -0
  48. data/lib/aia/pipeline_orchestrator.rb +88 -45
  49. data/lib/aia/plugin_monitor.rb +9 -6
  50. data/lib/aia/prompt_decomposer.rb +6 -4
  51. data/lib/aia/prompt_handler.rb +90 -69
  52. data/lib/aia/provider_registry.rb +105 -0
  53. data/lib/aia/robot_builder.rb +1 -1
  54. data/lib/aia/robot_factory.rb +77 -69
  55. data/lib/aia/robot_namer.rb +2 -8
  56. data/lib/aia/robot_sync.rb +79 -0
  57. data/lib/aia/role_catalog.rb +89 -0
  58. data/lib/aia/session.rb +32 -14
  59. data/lib/aia/session_tracker.rb +39 -41
  60. data/lib/aia/similarity_scorer.rb +5 -3
  61. data/lib/aia/skill_utils.rb +60 -19
  62. data/lib/aia/spawn_handler.rb +16 -4
  63. data/lib/aia/spawn_spec_parser.rb +6 -7
  64. data/lib/aia/special_mode_handler.rb +80 -57
  65. data/lib/aia/speech.rb +103 -0
  66. data/lib/aia/startup_coordinator.rb +17 -91
  67. data/lib/aia/streaming_runner.rb +16 -5
  68. data/lib/aia/system_prompt_assembler.rb +20 -15
  69. data/lib/aia/task_board.rb +60 -0
  70. data/lib/aia/task_coordinator.rb +10 -5
  71. data/lib/aia/timing.rb +15 -0
  72. data/lib/aia/tool_approver.rb +205 -0
  73. data/lib/aia/tool_filter.rb +1 -9
  74. data/lib/aia/tool_filter_strategy.rb +39 -25
  75. data/lib/aia/tool_introspection.rb +25 -0
  76. data/lib/aia/tool_loader.rb +71 -31
  77. data/lib/aia/tool_utility.rb +6 -5
  78. data/lib/aia/tools/delegate_to_foreman_tool.rb +6 -4
  79. data/lib/aia/tools/recruit_robot_tool.rb +12 -12
  80. data/lib/aia/tools/reskill_robot_tool.rb +7 -7
  81. data/lib/aia/tools/task_board_tool.rb +17 -16
  82. data/lib/aia/trakflow_bridge.rb +19 -11
  83. data/lib/aia/turn_state.rb +32 -8
  84. data/lib/aia/ui_presenter.rb +83 -59
  85. data/lib/aia/utility.rb +8 -24
  86. data/lib/aia/variable_input_collector.rb +1 -3
  87. data/lib/aia/verification_network.rb +10 -12
  88. data/lib/aia.rb +49 -8
  89. metadata +27 -162
  90. data/.better-commits.json +0 -150
  91. data/.config/tocer/configuration.yml +0 -6
  92. data/.envrc +0 -15
  93. data/.loki +0 -231
  94. data/.quality/flay_baseline.txt +0 -1
  95. data/.quality/flog_baseline.txt +0 -29
  96. data/.quality/reek_baseline.txt +0 -80
  97. data/.rubocop.yml +0 -116
  98. data/COMMITS.md +0 -196
  99. data/IMPLEMENTATION_PLAN.md +0 -506
  100. data/Rakefile +0 -160
  101. data/architecture_review.md +0 -314
  102. data/docs/AGENTS.md +0 -40
  103. data/docs/advanced-prompting.md +0 -814
  104. data/docs/assets/images/aia.png +0 -0
  105. data/docs/cli-reference.md +0 -1241
  106. data/docs/configuration.md +0 -747
  107. data/docs/contributing.md +0 -386
  108. data/docs/directives-reference.md +0 -1145
  109. data/docs/examples/index.md +0 -277
  110. data/docs/examples/mcp/index.md +0 -475
  111. data/docs/examples/prompts/analysis/index.md +0 -78
  112. data/docs/examples/prompts/automation/index.md +0 -109
  113. data/docs/examples/prompts/development/index.md +0 -125
  114. data/docs/examples/prompts/index.md +0 -333
  115. data/docs/examples/prompts/learning/index.md +0 -127
  116. data/docs/examples/prompts/writing/index.md +0 -62
  117. data/docs/examples/tools/index.md +0 -282
  118. data/docs/faq.md +0 -578
  119. data/docs/guides/available-models.md +0 -366
  120. data/docs/guides/basic-usage.md +0 -478
  121. data/docs/guides/chat.md +0 -680
  122. data/docs/guides/crew.md +0 -239
  123. data/docs/guides/executable-prompts.md +0 -331
  124. data/docs/guides/first-prompt.md +0 -454
  125. data/docs/guides/getting-started.md +0 -455
  126. data/docs/guides/image-generation.md +0 -507
  127. data/docs/guides/index.md +0 -48
  128. data/docs/guides/local-models.md +0 -306
  129. data/docs/guides/migrate-prompts.md +0 -335
  130. data/docs/guides/models.md +0 -1017
  131. data/docs/guides/shared-tools.md +0 -254
  132. data/docs/guides/tools.md +0 -831
  133. data/docs/index.md +0 -259
  134. data/docs/installation.md +0 -274
  135. data/docs/mcp-integration.md +0 -603
  136. data/docs/prompt_management.md +0 -665
  137. data/docs/security.md +0 -674
  138. data/docs/special_projects_guide.md +0 -386
  139. data/docs/tools-and-mcp-examples.md +0 -1211
  140. data/docs/workflows-and-pipelines.md +0 -636
  141. data/examples/.gitignore +0 -2
  142. data/examples/00_setup_aia.sh +0 -111
  143. data/examples/01_basic_usage.sh +0 -23
  144. data/examples/02_frontmatter.sh +0 -33
  145. data/examples/03_shell_integration.sh +0 -55
  146. data/examples/04_erb_templating.sh +0 -56
  147. data/examples/05_shell_then_erb.sh +0 -38
  148. data/examples/06_prompt_chaining.sh +0 -59
  149. data/examples/07_pipeline.sh +0 -46
  150. data/examples/08_context_files.sh +0 -43
  151. data/examples/09_roles.sh +0 -67
  152. data/examples/10_stdin_piping.sh +0 -49
  153. data/examples/11_multi_model.sh +0 -65
  154. data/examples/12_token_usage.sh +0 -52
  155. data/examples/13_cost_tracking.sh +0 -68
  156. data/examples/14_output_file.sh +0 -91
  157. data/examples/15_parameters.sh +0 -68
  158. data/examples/16_directives.sh +0 -113
  159. data/examples/17_require_and_conditionals.sh +0 -68
  160. data/examples/18_tools.sh +0 -61
  161. data/examples/19_local_tools.sh +0 -34
  162. data/examples/20_mcp_servers.sh +0 -102
  163. data/examples/21_executable_prompts.sh +0 -78
  164. data/examples/22_chat_mode.sh +0 -217
  165. data/examples/23_verify.sh +0 -139
  166. data/examples/24_decompose.sh +0 -139
  167. data/examples/25_spawn.sh +0 -139
  168. data/examples/26_debate.sh +0 -97
  169. data/examples/27_mention_routing.sh +0 -157
  170. data/examples/28_model_switching.sh +0 -106
  171. data/examples/29_agent_harness.sh +0 -177
  172. data/examples/README.md +0 -321
  173. data/examples/advanced_multi_robot_capabilities_without_examples.md +0 -106
  174. data/examples/aia_config.yml +0 -22
  175. data/examples/aia_config_orchestrator.yml +0 -45
  176. data/examples/aia_config_with_mcp.yml +0 -21
  177. data/examples/common.sh +0 -39
  178. data/examples/context/project_goals.md +0 -6
  179. data/examples/context/tech_stack.md +0 -7
  180. data/examples/directives/timestamp_directive.rb +0 -22
  181. data/examples/mcp/filesystem.json +0 -9
  182. data/examples/prompts_dir/analyze.md +0 -2
  183. data/examples/prompts_dir/brainstorm.md +0 -2
  184. data/examples/prompts_dir/conditional.md +0 -17
  185. data/examples/prompts_dir/creative.md +0 -4
  186. data/examples/prompts_dir/erbinfo.md +0 -5
  187. data/examples/prompts_dir/erbinfo_raw.md +0 -8
  188. data/examples/prompts_dir/evaluate.md +0 -2
  189. data/examples/prompts_dir/explain_joke.md +0 -1
  190. data/examples/prompts_dir/explain_recursion.md +0 -1
  191. data/examples/prompts_dir/fun_fact +0 -3
  192. data/examples/prompts_dir/greeting.md +0 -8
  193. data/examples/prompts_dir/greeting_required.md +0 -7
  194. data/examples/prompts_dir/hello.md +0 -1
  195. data/examples/prompts_dir/includes/ruby_facts.md +0 -4
  196. data/examples/prompts_dir/limerick.md +0 -1
  197. data/examples/prompts_dir/list_with_mcp.md +0 -3
  198. data/examples/prompts_dir/pick_best.md +0 -2
  199. data/examples/prompts_dir/project_summary +0 -12
  200. data/examples/prompts_dir/quiz_with_include.md +0 -6
  201. data/examples/prompts_dir/require_demo.md +0 -5
  202. data/examples/prompts_dir/roles/formal.md +0 -3
  203. data/examples/prompts_dir/roles/orchestrator.md +0 -21
  204. data/examples/prompts_dir/roles/pirate.md +0 -3
  205. data/examples/prompts_dir/shell_then_erb.md +0 -6
  206. data/examples/prompts_dir/sort_compare.md +0 -2
  207. data/examples/prompts_dir/summarize_context.md +0 -2
  208. data/examples/prompts_dir/sysinfo.md +0 -5
  209. data/examples/prompts_dir/sysinfo_raw.md +0 -8
  210. data/examples/prompts_dir/tagline.md +0 -1
  211. data/examples/prompts_dir/tell_joke.md +0 -1
  212. data/examples/prompts_dir/tell_joke_with_next.md +0 -4
  213. data/examples/prompts_dir/use_local_tool.md +0 -8
  214. data/examples/prompts_dir/use_tools.md +0 -8
  215. data/examples/prompts_dir/weather.md +0 -2
  216. data/examples/prompts_dir/whats_new.md +0 -2
  217. data/examples/prompts_dir/with_timestamp.md +0 -5
  218. data/examples/requirements/sinatra_taskflow_app.md +0 -139
  219. data/examples/rules/01_classify_ruby.rb +0 -16
  220. data/examples/rules/02_prefer_claude_for_code.rb +0 -19
  221. data/examples/rules/03_gate_prompt_length.rb +0 -19
  222. data/examples/rules/04_tool_selection.rb +0 -41
  223. data/examples/rules/README.md +0 -30
  224. data/examples/run_all.sh +0 -294
  225. data/examples/tools/word_count_tool.rb +0 -30
  226. data/lib/AGENTS.md +0 -57
  227. data/lib/aia/model_switch_handler.rb +0 -100
  228. data/mcp_servers/README.md +0 -110
  229. data/mcp_servers/apple-mcp.json +0 -8
  230. data/mcp_servers/filesystem.json +0 -9
  231. data/mcp_servers/mcp_server_chart.json +0 -11
  232. data/mcp_servers/playwright_one.json +0 -8
  233. data/mcp_servers/playwright_server_definition.json +0 -9
  234. data/mcp_servers/playwright_two.json +0 -8
  235. data/mcp_servers/tavily_mcp_server.json +0 -8
  236. data/mkdocs.yml +0 -169
@@ -1,814 +0,0 @@
1
- <!-- Tocer[start]: Auto-generated, don't remove. -->
2
-
3
- ## Table of Contents
4
-
5
- - [Stage 1: Data Preparation](#stage-1-data-preparation)
6
- - [Data Analysis Pipeline - Stage 1: Preparation](#data-analysis-pipeline---stage-1-preparation)
7
- - [Input Data Overview](#input-data-overview)
8
- - [Data Quality Assessment](#data-quality-assessment)
9
- - [Determine analysis approach](#determine-analysis-approach)
10
- - [Layer 1: Project Context](#layer-1-project-context)
11
- - [Layer 2: Domain Context](#layer-2-domain-context)
12
- - [Code Review with Clipboard Content](#code-review-with-clipboard-content)
13
- - [Code to Review](#code-to-review)
14
- - [Review Guidelines](#review-guidelines)
15
- - [Multi-format document generator](#multi-format-document-generator)
16
- - [<%= document_type.capitalize %> Document](#-document_typecapitalize--document)
17
- - [Source Material](#source-material)
18
- - [Additional Context](#additional-context)
19
- - [Clipboard Content (if applicable)](#clipboard-content-if-applicable)
20
- - [Multi-model analysis system](#multi-model-analysis-system)
21
- - [Phase 1: Creative Ideation (High Temperature)](#phase-1-creative-ideation-high-temperature)
22
- - [Phase 3: Synthesis and Recommendation](#phase-3-synthesis-and-recommendation)
23
- - [Advanced Tool Integration](#advanced-tool-integration)
24
- - [Custom Tool Workflows](#custom-tool-workflows)
25
- - [Analyze content to determine best tools](#analyze-content-to-determine-best-tools)
26
- - [Multi-Format Report Generator](#multi-format-report-generator)
27
- - [1. Executive Summary (Business Format)](#1-executive-summary-business-format)
28
- - [2. Technical Detail (Developer Format)](#2-technical-detail-developer-format)
29
- - [3. Academic Format (Research Paper Style)](#3-academic-format-research-paper-style)
30
- - [4. Action Items (Project Management Format)](#4-action-items-project-management-format)
31
- - [Structured data extraction](#structured-data-extraction)
32
- - [Post-process extracted JSON](#post-process-extracted-json)
33
- - [Robust prompt with fallbacks](#robust-prompt-with-fallbacks)
34
- - [Output validation system](#output-validation-system)
35
- - [This will be used to validate the AI response](#this-will-be-used-to-validate-the-ai-response)
36
- - [Smart caching system](#smart-caching-system)
37
- - [Intelligent batch processing](#intelligent-batch-processing)
38
- - [Switch to faster model for large batches](#switch-to-faster-model-for-large-batches)
39
- - [enterprise_code_review.md](#enterprise_code_reviewmd)
40
- - [Enterprise Code Review System](#enterprise-code-review-system)
41
- - [Multi-phase review process](#multi-phase-review-process)
42
- - [Intelligent Research Assistant](#intelligent-research-assistant)
43
- - [Adaptive Research Analysis](#adaptive-research-analysis)
44
- - [Query: <%= research_query %>](#query--research_query-)
45
- - [Dynamic source inclusion based on domain](#dynamic-source-inclusion-based-on-domain)
46
- - [Advanced Execution Modes](#advanced-execution-modes)
47
- - [Related Documentation](#related-documentation)
48
-
49
- <!-- Tocer[finish]: Auto-generated, don't remove. -->
50
-
51
- # Advanced Prompting Techniques
52
-
53
- Master sophisticated prompting strategies to get the most out of AIA's capabilities with complex workflows, dynamic content generation, and expert-level AI interactions.
54
-
55
- ## Advanced Directive Usage
56
-
57
- ### Conditional Execution
58
- Execute directives based on runtime conditions:
59
-
60
- ```markdown
61
- <%
62
- environment = ENV['RAILS_ENV'] || 'development'
63
- config_file = "config/#{environment}.yml"
64
- if File.exist?(config_file)
65
- %>
66
- /include <%= config_file %><%
67
- <% else %>
68
- /include config/default.yml
69
- <% end %>
70
- ```
71
-
72
- ```markdown
73
- <%
74
- model = AIA.config.models.first&.name
75
- case model
76
- when /gpt-4/
77
- %>
78
- Provide detailed, step-by-step analysis with code examples.
79
- <% when /gpt-3.5/ %>
80
- Provide concise, practical guidance with brief examples.
81
- <% when /claude/ %>
82
- Provide thorough analysis with emphasis on reasoning process.
83
- <% end %>
84
- ```
85
-
86
- ### Dynamic Configuration
87
- Adjust settings based on content or context:
88
-
89
- ```markdown
90
- /ruby
91
- <%
92
- task_type = '<%= task_type %>'
93
- temperature = case task_type
94
- when 'creative' then 1.2
95
- when 'analytical' then 0.3
96
- when 'balanced' then 0.7
97
- else 0.7
98
- end
99
- %>
100
- /config temperature <%= temperature %>
101
- ```
102
-
103
- ```markdown
104
- <%
105
- content_size = File.read('<%= input_file %>').length
106
- model = content_size > 50000 ? 'claude-3-sonnet' : 'gpt-4'
107
- max_tokens = content_size > 50000 ? 8000 : 4000
108
- %>
109
- /config model <%= model %>
110
- /config max_tokens <%= max_tokens %>
111
- ```
112
-
113
- ## Complex Workflow Patterns
114
-
115
- ### Multi-Stage Analysis Pipeline
116
- Create sophisticated analysis workflows with intermediate processing:
117
-
118
- ```markdown
119
- # Stage 1: Data Preparation
120
- /config model gpt-3.5-turbo
121
- /config temperature 0.2
122
-
123
- # Data Analysis Pipeline - Stage 1: Preparation
124
-
125
- ## Input Data Overview
126
- /shell file <%= input_file %>
127
- /shell wc -l <%= input_file %>
128
- <%= "File size: #{File.size('<%= input_file %>')} bytes" %>
129
-
130
- ## Data Quality Assessment
131
- /include <%= input_file %>
132
-
133
- Analyze the data structure and identify:
134
- 1. Data format and schema
135
- 2. Missing or inconsistent values
136
- 3. Potential data quality issues
137
- 4. Preprocessing requirements
138
-
139
- Save findings to: preprocessing_notes.md
140
-
141
- /next data_cleaning
142
- /pipeline analysis_deep_dive,pattern_recognition,insight_generation,final_report
143
- ```
144
-
145
- ### Adaptive Decision Trees
146
- Create prompts that adapt their approach based on intermediate results:
147
-
148
- ```markdown
149
- <%
150
- file_ext = File.extname('<%= code_file %>')
151
- file_size = File.size('<%= code_file %>')
152
-
153
- # Determine analysis approach
154
- if file_size > 10000
155
- analysis_type = 'comprehensive'
156
- %>
157
- /config model gpt-4
158
- /config max_tokens 6000
159
- <%
160
- elsif file_ext == '.py'
161
- analysis_type = 'python_specific'
162
- %>
163
- /config model gpt-4
164
- Including Python-specific analysis patterns
165
- <%
166
- else
167
- analysis_type = 'standard'
168
- %>
169
- /config model gpt-3.5-turbo
170
- <%
171
- end
172
- %>
173
- Selected <%= analysis_type %> analysis for <%= file_ext %> file (<%= file_size %> bytes)
174
- ```
175
-
176
- ## Advanced Context Management
177
-
178
- ### Hierarchical Context Building
179
- Build context progressively through multiple layers:
180
-
181
- ```markdown
182
- # Layer 1: Project Context
183
- /include README.md
184
- /include ARCHITECTURE.md
185
-
186
- # Layer 2: Domain Context
187
- <%
188
- domain = '<%= domain || "general" %>'
189
- domain_file = "docs/#{domain}_context.md"
190
- if File.exist?(domain_file)
191
- %>
192
- /include <%= domain_file %>
193
- <% end %>
194
- ```
195
-
196
- # Layer 3: Task-Specific Context
197
- <% if task_context_file %>
198
- /include <%= task_context_file %>
199
- <% end %>
200
-
201
- # Layer 4: Historical Context
202
- <%
203
- history_file = ".aia/history/#{Date.today.strftime('%Y%m')}_context.md"
204
- if File.exist?(history_file)
205
- %>
206
- /include <%= history_file %>
207
- <% end %>
208
- ```
209
-
210
- Now analyze <%= task %> using all available context layers.
211
- ```
212
-
213
- ### Clipboard Integration
214
- Quick data insertion from clipboard:
215
-
216
- ```markdown
217
- # Code Review with Clipboard Content
218
-
219
- ## Code to Review
220
- /paste
221
-
222
- ## Review Guidelines
223
- - Check for best practices
224
- - Identify security vulnerabilities
225
- - Suggest performance improvements
226
- - Validate error handling
227
-
228
- Please provide detailed feedback on the code above.
229
- ```
230
-
231
- This is particularly useful for:
232
- - Quick code reviews when you've copied code from an IDE
233
- - Analyzing error messages or logs copied from terminals
234
- - Including data from spreadsheets or other applications
235
- - Rapid prototyping with copied examples
236
-
237
- ### Context Filtering and Summarization
238
- Manage large contexts intelligently:
239
-
240
- ```markdown
241
- <%
242
- max_context_size = 20000 # characters
243
- context_files = ['docs/spec.md', 'docs/api.md', 'docs/examples.md']
244
- total_size = 0
245
-
246
- context_files.each do |file|
247
- if File.exist?(file)
248
- file_size = File.read(file).length
249
- if total_size + file_size <= max_context_size
250
- %>
251
- /include <%= file %>
252
- <%
253
- total_size += file_size
254
- else
255
- %>
256
- Summarizing <%= file %> (too large for full inclusion):
257
-
258
- <%= AIA.summarize_file(file, max_length: 500) %>
259
- <%
260
- end
261
- end
262
- end
263
- %>
264
- ```
265
-
266
- ## Dynamic Content Generation
267
-
268
- ### Template-Based Generation
269
- Create flexible templates that adapt to different scenarios:
270
-
271
- ```erb
272
- # Multi-format document generator
273
- /config model <%= model || "gpt-4" %>
274
- /config temperature <%= creativity || "0.7" %>
275
-
276
- # <%= document_type.capitalize %> Document
277
-
278
- <% case format %>
279
- <% when 'technical' %>
280
- Generate a technical document with:
281
- - Executive summary
282
- - Detailed technical specifications
283
- - Implementation guidelines
284
- - Code examples and APIs
285
- - Testing and validation procedures
286
-
287
- <% when 'business' %>
288
- Generate a business document with:
289
- - Executive summary
290
- - Market analysis
291
- - Financial projections
292
- - Risk assessment
293
- - Implementation timeline
294
-
295
- <% when 'academic' %>
296
- Generate an academic document with:
297
- - Abstract and keywords
298
- - Literature review
299
- - Methodology
300
- - Results and analysis
301
- - Conclusions and future work
302
- <% end %>
303
-
304
- ## Source Material
305
- /include <%= source_file %>
306
-
307
- ## Additional Context
308
- <% if context_files %>
309
- <% context_files.each do |file| %>
310
- /include <%= file %>
311
- <% end %>
312
- <% end %>
313
-
314
- ## Clipboard Content (if applicable)
315
- <% if include_clipboard %>
316
- /paste
317
- <% end %>
318
-
319
- Target audience: <%= audience || "general professional" %>
320
- Document length: <%= length || "2000-3000 words" %>
321
- ```
322
-
323
- ### Recursive Prompt Generation
324
- Generate prompts that create other prompts:
325
-
326
- ```markdown
327
- <%
328
- domain = '<%= domain %>'
329
- tasks = ['analyze', 'design', 'implement', 'test', 'document']
330
-
331
- tasks.each do |task|
332
- prompt_content = <<~PROMPT
333
- # #{domain.capitalize} #{task.capitalize} Prompt
334
-
335
- /config model gpt-4
336
- /config temperature 0.5
337
-
338
- You are a #{domain} expert performing #{task} tasks.
339
-
340
- Task: <%= specific_task %>
341
- Context: /include <%= context_file %>
342
-
343
- Provide expert-level guidance specific to #{domain} #{task}.
344
- PROMPT
345
-
346
- filename = "generated_#{domain}_#{task}.md"
347
- File.write(filename, prompt_content)
348
- %>
349
- Generated: <%= filename %>
350
- <% end %>
351
- ```
352
-
353
- ## Expert-Level Model Interaction
354
-
355
- ### Multi-Model Orchestration
356
- Coordinate multiple models for complex tasks:
357
-
358
- ```markdown
359
- # Multi-model analysis system
360
- /config consensus false
361
-
362
- ## Phase 1: Creative Ideation (High Temperature)
363
- <%= "Using GPT-4 for creative brainstorming..." %>
364
- <%
365
- gpt4_creative = RubyLLM.chat(model: 'gpt-4', temperature: 1.3)
366
- ideas = gpt4_creative.ask("Generate 10 innovative approaches to: <%= problem %>")
367
- %>
368
- <%= ideas.content %>
369
- ```
370
-
371
- ## Phase 2: Technical Analysis (Low Temperature)
372
-
373
- <%= "Using Claude for technical analysis..." %>
374
- <%
375
- claude_technical = RubyLLM.chat(model: 'claude-3-sonnet', temperature: 0.2)
376
- analysis = claude_technical.ask("Analyze technical feasibility of these approaches: #{ideas.content}")
377
- %>
378
- <%= analysis.content %>
379
- ```
380
-
381
- ## Phase 3: Synthesis and Recommendation
382
-
383
- <%= "Using GPT-4 for final synthesis..." %>
384
- <%
385
- gpt4_synthesis = RubyLLM.chat(model: 'gpt-4', temperature: 0.7)
386
- final_rec = gpt4_synthesis.ask("Synthesize and recommend best approach: Ideas: #{ideas.content} Analysis: #{analysis.content}")
387
- %>
388
- <%= final_rec.content %>
389
- ```
390
-
391
- ### Model-Specific Optimization
392
- Tailor prompts for specific model strengths:
393
-
394
- ```markdown
395
- <%
396
- model = AIA.config.models.first&.name
397
- case model
398
- when /gpt-4/
399
- # GPT-4 excels at complex reasoning and code
400
- instruction_style = "detailed step-by-step analysis with code examples"
401
- context_depth = "comprehensive background and multiple perspectives"
402
- when /claude/
403
- # Claude excels at long-form analysis and following instructions precisely
404
- instruction_style = "thorough systematic analysis with clear reasoning"
405
- context_depth = "complete context with relevant documentation"
406
- when /gemini/
407
- # Gemini excels at structured data and mathematical reasoning
408
- instruction_style = "structured analysis with quantitative metrics"
409
- context_depth = "organized data with clear relationships"
410
- end
411
- %>
412
- Optimizing for <%= model %>: <%= instruction_style %>
413
- ```
414
-
415
- Apply <%= instruction_style %> to analyze <%= task %>.
416
-
417
- Include <%= context_depth %> for comprehensive understanding.
418
- ```
419
-
420
- ## Advanced Tool Integration
421
-
422
- ### Custom Tool Workflows
423
- Create sophisticated tool integration patterns:
424
-
425
- ```markdown
426
- /tools advanced_analysis_tools.rb
427
-
428
- <%
429
- # Initialize analysis workflow
430
- workflow = AnalysisWorkflow.new
431
- workflow.add_tool('data_preprocessor', weight: 0.3)
432
- workflow.add_tool('statistical_analyzer', weight: 0.4)
433
- workflow.add_tool('pattern_detector', weight: 0.2)
434
- workflow.add_tool('insight_generator', weight: 0.1)
435
-
436
- results = workflow.execute('<%= input_data %>')
437
- %>
438
- Analysis complete. Confidence: <%= results[:confidence] %>
439
- <%= results[:summary] %>
440
- ```
441
-
442
- Based on multi-tool analysis, provide expert interpretation of:
443
- <%= results[:detailed_findings] %>
444
- ```
445
-
446
- ### Dynamic Tool Selection
447
- Select tools based on content analysis:
448
-
449
- ```markdown
450
- <%
451
- content = File.read('<%= input_file %>')
452
-
453
- # Analyze content to determine best tools
454
- tools = []
455
- tools << 'text_analyzer' if content.match?(/[a-zA-Z]{100,}/)
456
- tools << 'code_analyzer' if content.match?(/def\s+\w+|function\s+\w+|class\s+\w+/)
457
- tools << 'data_analyzer' if content.match?(/\d+[,.]?\d*\s*[%$]?/)
458
- tools << 'web_scraper' if content.match?(/https?:\/\//)
459
- %>
460
- Selected tools: <%= tools.join(', ') %>
461
- <% tools.each do |tool| %>
462
- /tools <%= tool %>.rb
463
- <% end %>
464
- ```
465
-
466
- ## Sophisticated Output Formatting
467
-
468
- ### Multi-Format Output Generation
469
- Generate output in multiple formats simultaneously:
470
-
471
- ```markdown
472
- /config model gpt-4
473
-
474
- # Multi-Format Report Generator
475
-
476
- Generate analysis in multiple formats:
477
-
478
- ## 1. Executive Summary (Business Format)
479
- Provide a 200-word executive summary suitable for C-level presentation.
480
-
481
- ## 2. Technical Detail (Developer Format)
482
- Provide detailed technical analysis with:
483
- - Architecture diagrams (textual description)
484
- - Code examples
485
- - Implementation steps
486
- - Testing strategies
487
-
488
- ## 3. Academic Format (Research Paper Style)
489
- Provide structured analysis with:
490
- - Abstract and keywords
491
- - Methodology description
492
- - Results and discussion
493
- - References and citations
494
-
495
- ## 4. Action Items (Project Management Format)
496
- Extract concrete action items with:
497
- - Priority levels (High/Medium/Low)
498
- - Estimated effort
499
- - Dependencies
500
- - Assigned roles
501
- - Success criteria
502
-
503
- Source: /include <%= source_file %>
504
- ```
505
-
506
- ### Structured Data Extraction
507
- Extract structured data from unstructured content:
508
-
509
- ```ruby
510
- # Structured data extraction
511
- /config model gpt-4
512
- /config temperature 0.1
513
-
514
- Extract structured information from the following content and format as JSON:
515
-
516
- Required fields:
517
- - entities: List of people, organizations, locations
518
- - dates: Important dates and deadlines
519
- - metrics: Numerical data and KPIs
520
- - actions: Required actions and decisions
521
- - risks: Identified risks and concerns
522
- - opportunities: Growth and improvement opportunities
523
-
524
- Content:
525
- /include <%= unstructured_content %>
526
-
527
- Output valid JSON only, no explanatory text.
528
-
529
- # Post-process extracted JSON
530
- json_output = response.content
531
- begin
532
- data = JSON.parse(json_output)
533
- puts "Successfully extracted #{data.keys.length} data categories"
534
-
535
- # Save to structured file
536
- File.write('extracted_data.json', JSON.pretty_generate(data))
537
- puts "Data saved to extracted_data.json"
538
- rescue JSON::ParserError => e
539
- puts "JSON parsing failed: #{e.message}"
540
- end
541
- ```
542
-
543
- ## Advanced Error Handling and Recovery
544
-
545
- ### Graceful Degradation
546
- Handle errors and provide fallback options:
547
-
548
- ```ruby
549
- # Robust prompt with fallbacks
550
- <%=
551
- begin
552
- primary_content = File.read('<%= primary_source %>')
553
- puts "/include <%= primary_source %>"
554
- rescue => e
555
- puts "Primary source unavailable (#{e.message})"
556
-
557
- # Try fallback sources
558
- fallback_sources = ['backup.txt', 'default_context.md', 'minimal_info.txt']
559
- fallback_found = false
560
-
561
- fallback_sources.each do |source|
562
- if File.exist?(source)
563
- puts "Using fallback source: #{source}"
564
- puts "/include #{source}"
565
- fallback_found = true
566
- break
567
- end
568
- end
569
-
570
- unless fallback_found
571
- puts "No sources available. Proceeding with minimal context."
572
- puts "Please provide basic information about: <%= topic %>"
573
- end
574
- end
575
- %>
576
- ```
577
-
578
- ### Validation and Quality Assurance
579
- Implement quality checks for AI outputs:
580
-
581
- ```ruby
582
- # Output validation system
583
- <%=
584
- class OutputValidator
585
- def self.validate_code_review(output)
586
- required_sections = ['Summary', 'Issues Found', 'Recommendations']
587
- severity_levels = ['Critical', 'Major', 'Minor']
588
-
589
- issues = []
590
- required_sections.each do |section|
591
- issues << "Missing section: #{section}" unless output.include?(section)
592
- end
593
-
594
- has_severity = severity_levels.any? { |level| output.include?(level) }
595
- issues << "No severity levels found" unless has_severity
596
-
597
- issues.empty? ? "✓ Validation passed" : "⚠ Issues: #{issues.join(', ')}"
598
- end
599
- end
600
-
601
- # This will be used to validate the AI response
602
- puts "Response will be validated for: <%= validation_criteria %>"
603
- %>
604
- ```
605
-
606
- ## Performance Optimization Techniques
607
-
608
- ### Intelligent Caching
609
- Implement smart caching for expensive operations:
610
-
611
- ```ruby
612
- # Smart caching system
613
- <%=
614
- require 'digest'
615
-
616
- cache_key = Digest::MD5.hexdigest('<%= input_data %>' + AIA.config.models.first&.name)
617
- cache_file = "/tmp/aia_cache_#{cache_key}.json"
618
- cache_duration = 3600 # 1 hour
619
-
620
- if File.exist?(cache_file) && (Time.now - File.mtime(cache_file)) < cache_duration
621
- puts "Using cached result for similar query..."
622
- cached_result = JSON.parse(File.read(cache_file))
623
- puts cached_result['content']
624
- exit # Skip AI processing
625
- else
626
- puts "Processing fresh query (no valid cache found)..."
627
- # Continue with normal processing
628
- # Result will be cached by post-processing script
629
- end
630
- %>
631
- ```
632
-
633
- ### Batch Processing Strategies
634
- Optimize for processing multiple items:
635
-
636
- ```ruby
637
- # Intelligent batch processing
638
- <%=
639
- files = Dir.glob('<%= pattern %>')
640
- batch_size = 5
641
- model_switching_threshold = 10
642
-
643
- puts "Processing #{files.length} files in batches of #{batch_size}"
644
-
645
- # Switch to faster model for large batches
646
- if files.length > model_switching_threshold
647
- puts "/config model gpt-3.5-turbo # Using faster model for large batch"
648
- else
649
- puts "/config model gpt-4 # Using quality model for small batch"
650
- end
651
-
652
- files.each_slice(batch_size).with_index do |batch, index|
653
- puts "\n## Batch #{index + 1}: #{batch.map(&:basename).join(', ')}"
654
- batch.each { |file| puts "/include #{file}" }
655
- puts "\nAnalyze this batch focusing on common patterns and unique aspects."
656
- end
657
- %>
658
- ```
659
-
660
- ## Best Practices for Advanced Prompting
661
-
662
- ### Modular Design Principles
663
- 1. **Separation of Concerns**: Keep configuration, data, and instructions separate
664
- 2. **Reusable Components**: Create modular prompt components
665
- 3. **Clear Dependencies**: Document and manage prompt dependencies
666
- 4. **Version Control**: Track changes and maintain prompt versioning
667
-
668
- ### Performance Considerations
669
- 1. **Model Selection**: Choose appropriate models for task complexity
670
- 2. **Context Management**: Balance completeness with efficiency
671
- 3. **Caching Strategies**: Cache expensive computations and API calls
672
- 4. **Batch Processing**: Optimize for multiple similar tasks
673
-
674
- ### Error Prevention
675
- 1. **Validation**: Validate inputs and outputs
676
- 2. **Fallbacks**: Provide graceful degradation options
677
- 3. **Testing**: Test prompts with various inputs
678
- 4. **Monitoring**: Track performance and error rates
679
-
680
- ### Security and Privacy
681
- 1. **Input Sanitization**: Clean and validate user inputs
682
- 2. **Access Control**: Limit file and system access
683
- 3. **Data Privacy**: Avoid exposing sensitive information
684
- 4. **Audit Trails**: Log usage and maintain accountability
685
-
686
- ## Real-World Advanced Examples
687
-
688
- ### Automated Code Review System
689
- A comprehensive code review system using multiple models and tools:
690
-
691
- ```markdown
692
- # enterprise_code_review.md
693
- /config model gpt-4
694
- /tools security_scanner.rb,performance_analyzer.rb,style_checker.rb
695
-
696
- # Enterprise Code Review System
697
-
698
- <%=
699
- # Multi-phase review process
700
- phases = {
701
- security: { model: 'gpt-4', temperature: 0.1, tools: ['security_scanner'] },
702
- performance: { model: 'claude-3-sonnet', temperature: 0.2, tools: ['performance_analyzer'] },
703
- style: { model: 'gpt-3.5-turbo', temperature: 0.3, tools: ['style_checker'] },
704
- architecture: { model: 'gpt-4', temperature: 0.5, tools: [] }
705
- }
706
-
707
- current_phase = '<%= phase || "security" %>'
708
- config = phases[current_phase.to_sym]
709
-
710
- puts "/config model #{config[:model]}"
711
- puts "/config temperature #{config[:temperature]}"
712
- config[:tools].each { |tool| puts "/tools #{tool}.rb" }
713
-
714
- puts "\n## Phase: #{current_phase.capitalize} Review"
715
- %>
716
- ```
717
-
718
- ### Code to Analyze:
719
- /include <%= code_file %>
720
-
721
- Perform comprehensive <%= current_phase %> analysis following enterprise standards.
722
-
723
- <%=
724
- next_phase = phases.keys[phases.keys.index(current_phase.to_sym) + 1]
725
- puts next_phase ? "/next enterprise_code_review --phase #{next_phase}" : "# Review complete"
726
- %>
727
- ```
728
-
729
- ### Intelligent Research Assistant
730
- A research system that adapts its approach based on query complexity:
731
-
732
- ```markdown
733
- <%=
734
- # adaptive_research_assistant.md
735
- query = research_query
736
- complexity = query.split.length > 10 ? 'complex' : 'simple'
737
- domain = domain || "general"
738
-
739
- if complexity == 'complex'
740
- puts "/config model claude-3-sonnet"
741
- puts "/config max_tokens 6000"
742
- research_depth = 'comprehensive'
743
- else
744
- puts "/config model gpt-4"
745
- puts "/config max_tokens 3000"
746
- research_depth = 'focused'
747
- end
748
-
749
- puts "Research mode: #{research_depth} analysis for #{domain} domain"
750
- %>
751
- ```
752
-
753
- # Adaptive Research Analysis
754
-
755
- ## Query: <%= research_query %>
756
-
757
- # Dynamic source inclusion based on domain
758
- <%=
759
- source_map = {
760
- 'technology' => ['tech_sources.md', 'industry_reports/', 'patent_db.txt'],
761
- 'business' => ['market_data.csv', 'financial_reports/', 'competitor_analysis.md'],
762
- 'academic' => ['literature_db.txt', 'citation_index.md', 'peer_reviews/'],
763
- 'general' => ['general_sources.md', 'news_feeds.txt', 'reference_materials/']
764
- }
765
-
766
- sources = source_map[domain] || source_map['general']
767
- sources.each do |source|
768
- if File.exist?(source) || Dir.exist?(source)
769
- puts "/include #{source}"
770
- end
771
- end
772
- %>
773
- ```
774
-
775
- Provide <%= research_depth %> research analysis addressing:
776
- 1. Current state of knowledge
777
- 2. Key findings and insights
778
- 3. Research gaps and limitations
779
- 4. Future research directions
780
- 5. Practical implications
781
-
782
- <%=
783
- if research_depth == 'comprehensive'
784
- puts "/next citation_generator"
785
- puts "/pipeline fact_checker,source_validator,bibliography_creator"
786
- end
787
- %>
788
- ```
789
-
790
- ## Advanced Execution Modes
791
-
792
- In interactive chat sessions, the following directives invoke specialized multi-robot execution modes:
793
-
794
- - `/verify` — Generates two independent answers to the same question, then has a third robot reconcile them into a final response.
795
- - `/decompose` — Breaks a complex prompt into parallel sub-tasks, executes them concurrently, and merges the results.
796
- - `/debate` — Initiates a multi-round debate between robots with convergence detection; rounds end when agreement is reached or the round limit is hit.
797
- - `/spawn` — Dynamically spawns a one-shot specialist robot to handle a specific subtask without disrupting the current session. For a persistent, `@mention`-able crew member, use `/add_recruit` instead (see the [Crews guide](guides/crew.md)).
798
- - `/add_recruit` (`/add`) / `/drop_recruit` (`/drop`) — Add or remove a persistent robot in the session's crew; recruits answer to `@name` and inherit the chief's tools and MCP servers.
799
- - `/delegate` — Delegates a subtask to a specialist via TrakFlow for asynchronous handling.
800
- - `/concurrent` — Enables concurrent MCP server access for the immediately following prompt turn.
801
-
802
- These modes are available at the chat prompt and require no additional configuration beyond having the relevant robots or MCP servers set up.
803
-
804
- ## Related Documentation
805
-
806
- - [Prompt Management](prompt_management.md) - Organizing and managing prompts
807
- - [Directives Reference](directives-reference.md) - All available directives
808
- - [Working with Models](guides/models.md) - Model selection and optimization
809
- - [Tools Integration](guides/tools.md) - Advanced tool usage
810
- - [Examples](examples/index.md) - Real-world advanced examples
811
-
812
- ---
813
-
814
- Advanced prompting is where AIA truly shines. These techniques enable you to create sophisticated, intelligent workflows that adapt to complex requirements and deliver expert-level results. Experiment with these patterns and develop your own advanced techniques!