aia 2.0.0.0.pre.beta2 → 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 (225) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/CHANGELOG.md +146 -228
  4. data/README.md +41 -18
  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 +16 -14
  10. data/lib/aia/config/cli_parser.rb +123 -91
  11. data/lib/aia/config/defaults.yml +12 -39
  12. data/lib/aia/config/mcp_parser.rb +30 -36
  13. data/lib/aia/config/model_spec.rb +8 -14
  14. data/lib/aia/config/validator.rb +102 -103
  15. data/lib/aia/config/value_caster.rb +76 -0
  16. data/lib/aia/config.rb +70 -53
  17. data/lib/aia/crew.rb +29 -19
  18. data/lib/aia/debate_handler.rb +27 -10
  19. data/lib/aia/directives/configuration_directives.rb +55 -14
  20. data/lib/aia/directives/context_directives.rb +24 -12
  21. data/lib/aia/directives/execution_directives.rb +18 -23
  22. data/lib/aia/directives/model_directives.rb +41 -104
  23. data/lib/aia/directives/utility_directives.rb +16 -17
  24. data/lib/aia/directives/web_and_file_directives.rb +21 -14
  25. data/lib/aia/fact_asserter.rb +3 -3
  26. data/lib/aia/history_transfer.rb +64 -24
  27. data/lib/aia/logger.rb +10 -45
  28. data/lib/aia/mcp_config_normalizer.rb +27 -14
  29. data/lib/aia/mcp_connection_manager.rb +181 -184
  30. data/lib/aia/mcp_discovery.rb +43 -15
  31. data/lib/aia/mcp_grouper.rb +2 -1
  32. data/lib/aia/mcp_server_config.rb +20 -2
  33. data/lib/aia/mcp_utility.rb +24 -19
  34. data/lib/aia/mention_router.rb +15 -2
  35. data/lib/aia/modality_query.rb +36 -0
  36. data/lib/aia/model_alias_registry.rb +11 -11
  37. data/lib/aia/model_registry.rb +75 -0
  38. data/lib/aia/network_builder.rb +8 -7
  39. data/lib/aia/patches/ruby_llm_streaming_error.rb +21 -4
  40. data/lib/aia/patches/ruby_llm_tool_param_compat.rb +18 -0
  41. data/lib/aia/pipeline_orchestrator.rb +71 -38
  42. data/lib/aia/prompt_decomposer.rb +1 -1
  43. data/lib/aia/prompt_handler.rb +56 -29
  44. data/lib/aia/provider_registry.rb +105 -0
  45. data/lib/aia/robot_builder.rb +1 -1
  46. data/lib/aia/robot_factory.rb +67 -63
  47. data/lib/aia/robot_sync.rb +79 -0
  48. data/lib/aia/role_catalog.rb +89 -0
  49. data/lib/aia/session.rb +25 -11
  50. data/lib/aia/skill_utils.rb +60 -19
  51. data/lib/aia/spawn_handler.rb +16 -4
  52. data/lib/aia/spawn_spec_parser.rb +6 -7
  53. data/lib/aia/special_mode_handler.rb +28 -25
  54. data/lib/aia/speech.rb +70 -34
  55. data/lib/aia/startup_coordinator.rb +17 -92
  56. data/lib/aia/streaming_runner.rb +10 -2
  57. data/lib/aia/system_prompt_assembler.rb +12 -11
  58. data/lib/aia/task_board.rb +60 -0
  59. data/lib/aia/tool_approver.rb +205 -0
  60. data/lib/aia/tool_filter.rb +1 -10
  61. data/lib/aia/tool_filter_strategy.rb +12 -1
  62. data/lib/aia/tool_introspection.rb +9 -1
  63. data/lib/aia/tool_loader.rb +67 -33
  64. data/lib/aia/tool_utility.rb +6 -5
  65. data/lib/aia/tools/delegate_to_foreman_tool.rb +6 -4
  66. data/lib/aia/tools/recruit_robot_tool.rb +12 -12
  67. data/lib/aia/tools/reskill_robot_tool.rb +7 -7
  68. data/lib/aia/tools/task_board_tool.rb +16 -16
  69. data/lib/aia/trakflow_bridge.rb +14 -8
  70. data/lib/aia/turn_state.rb +31 -8
  71. data/lib/aia/ui_presenter.rb +16 -0
  72. data/lib/aia/utility.rb +6 -24
  73. data/lib/aia/variable_input_collector.rb +0 -3
  74. data/lib/aia/verification_network.rb +9 -10
  75. data/lib/aia.rb +33 -8
  76. metadata +19 -160
  77. data/.better-commits.json +0 -150
  78. data/.config/tocer/configuration.yml +0 -6
  79. data/.envrc +0 -19
  80. data/.loki +0 -11
  81. data/.reek.yml +0 -160
  82. data/.rubocop.yml +0 -116
  83. data/.rubocop_strict.yml +0 -15
  84. data/COMMITS.md +0 -196
  85. data/IMPLEMENTATION_PLAN.md +0 -506
  86. data/Rakefile +0 -47
  87. data/_typos.toml +0 -10
  88. data/aia.gemspec +0 -92
  89. data/architecture_review.md +0 -314
  90. data/config/aia.yml +0 -13
  91. data/docs/AGENTS.md +0 -40
  92. data/docs/advanced-prompting.md +0 -814
  93. data/docs/assets/images/aia.png +0 -0
  94. data/docs/cli-reference.md +0 -1241
  95. data/docs/configuration.md +0 -747
  96. data/docs/contributing.md +0 -386
  97. data/docs/directives-reference.md +0 -1145
  98. data/docs/examples/index.md +0 -277
  99. data/docs/examples/mcp/index.md +0 -475
  100. data/docs/examples/prompts/analysis/index.md +0 -78
  101. data/docs/examples/prompts/automation/index.md +0 -109
  102. data/docs/examples/prompts/development/index.md +0 -125
  103. data/docs/examples/prompts/index.md +0 -333
  104. data/docs/examples/prompts/learning/index.md +0 -127
  105. data/docs/examples/prompts/writing/index.md +0 -62
  106. data/docs/examples/tools/index.md +0 -282
  107. data/docs/faq.md +0 -578
  108. data/docs/guides/available-models.md +0 -366
  109. data/docs/guides/basic-usage.md +0 -478
  110. data/docs/guides/chat.md +0 -680
  111. data/docs/guides/crew.md +0 -239
  112. data/docs/guides/executable-prompts.md +0 -331
  113. data/docs/guides/first-prompt.md +0 -454
  114. data/docs/guides/getting-started.md +0 -455
  115. data/docs/guides/image-generation.md +0 -507
  116. data/docs/guides/index.md +0 -48
  117. data/docs/guides/local-models.md +0 -306
  118. data/docs/guides/migrate-prompts.md +0 -335
  119. data/docs/guides/models.md +0 -1017
  120. data/docs/guides/shared-tools.md +0 -254
  121. data/docs/guides/tools.md +0 -831
  122. data/docs/index.md +0 -259
  123. data/docs/installation.md +0 -274
  124. data/docs/mcp-integration.md +0 -603
  125. data/docs/prompt_management.md +0 -665
  126. data/docs/security.md +0 -674
  127. data/docs/special_projects_guide.md +0 -386
  128. data/docs/tools-and-mcp-examples.md +0 -1211
  129. data/docs/workflows-and-pipelines.md +0 -636
  130. data/examples/.gitignore +0 -2
  131. data/examples/00_setup_aia.sh +0 -111
  132. data/examples/01_basic_usage.sh +0 -23
  133. data/examples/02_frontmatter.sh +0 -33
  134. data/examples/03_shell_integration.sh +0 -55
  135. data/examples/04_erb_templating.sh +0 -56
  136. data/examples/05_shell_then_erb.sh +0 -38
  137. data/examples/06_prompt_chaining.sh +0 -59
  138. data/examples/07_pipeline.sh +0 -46
  139. data/examples/08_context_files.sh +0 -43
  140. data/examples/09_roles.sh +0 -67
  141. data/examples/10_stdin_piping.sh +0 -49
  142. data/examples/11_multi_model.sh +0 -65
  143. data/examples/12_token_usage.sh +0 -52
  144. data/examples/13_cost_tracking.sh +0 -68
  145. data/examples/14_output_file.sh +0 -91
  146. data/examples/15_parameters.sh +0 -68
  147. data/examples/16_directives.sh +0 -113
  148. data/examples/17_require_and_conditionals.sh +0 -68
  149. data/examples/18_tools.sh +0 -61
  150. data/examples/19_local_tools.sh +0 -34
  151. data/examples/20_mcp_servers.sh +0 -102
  152. data/examples/21_executable_prompts.sh +0 -78
  153. data/examples/22_chat_mode.sh +0 -217
  154. data/examples/23_verify.sh +0 -139
  155. data/examples/24_decompose.sh +0 -139
  156. data/examples/25_spawn.sh +0 -139
  157. data/examples/26_debate.sh +0 -97
  158. data/examples/27_mention_routing.sh +0 -157
  159. data/examples/28_model_switching.sh +0 -106
  160. data/examples/29_agent_harness.sh +0 -177
  161. data/examples/README.md +0 -321
  162. data/examples/advanced_multi_robot_capabilities_without_examples.md +0 -106
  163. data/examples/aia_config.yml +0 -22
  164. data/examples/aia_config_orchestrator.yml +0 -45
  165. data/examples/aia_config_with_mcp.yml +0 -21
  166. data/examples/common.sh +0 -39
  167. data/examples/context/project_goals.md +0 -6
  168. data/examples/context/tech_stack.md +0 -7
  169. data/examples/directives/timestamp_directive.rb +0 -22
  170. data/examples/mcp/filesystem.json +0 -9
  171. data/examples/prompts_dir/analyze.md +0 -2
  172. data/examples/prompts_dir/brainstorm.md +0 -2
  173. data/examples/prompts_dir/conditional.md +0 -17
  174. data/examples/prompts_dir/creative.md +0 -4
  175. data/examples/prompts_dir/erbinfo.md +0 -5
  176. data/examples/prompts_dir/erbinfo_raw.md +0 -8
  177. data/examples/prompts_dir/evaluate.md +0 -2
  178. data/examples/prompts_dir/explain_joke.md +0 -1
  179. data/examples/prompts_dir/explain_recursion.md +0 -1
  180. data/examples/prompts_dir/fun_fact +0 -3
  181. data/examples/prompts_dir/greeting.md +0 -8
  182. data/examples/prompts_dir/greeting_required.md +0 -7
  183. data/examples/prompts_dir/hello.md +0 -1
  184. data/examples/prompts_dir/includes/ruby_facts.md +0 -4
  185. data/examples/prompts_dir/limerick.md +0 -1
  186. data/examples/prompts_dir/list_with_mcp.md +0 -3
  187. data/examples/prompts_dir/pick_best.md +0 -2
  188. data/examples/prompts_dir/project_summary +0 -12
  189. data/examples/prompts_dir/quiz_with_include.md +0 -6
  190. data/examples/prompts_dir/require_demo.md +0 -5
  191. data/examples/prompts_dir/roles/formal.md +0 -3
  192. data/examples/prompts_dir/roles/orchestrator.md +0 -21
  193. data/examples/prompts_dir/roles/pirate.md +0 -3
  194. data/examples/prompts_dir/shell_then_erb.md +0 -6
  195. data/examples/prompts_dir/sort_compare.md +0 -2
  196. data/examples/prompts_dir/summarize_context.md +0 -2
  197. data/examples/prompts_dir/sysinfo.md +0 -5
  198. data/examples/prompts_dir/sysinfo_raw.md +0 -8
  199. data/examples/prompts_dir/tagline.md +0 -1
  200. data/examples/prompts_dir/tell_joke.md +0 -1
  201. data/examples/prompts_dir/tell_joke_with_next.md +0 -4
  202. data/examples/prompts_dir/use_local_tool.md +0 -8
  203. data/examples/prompts_dir/use_tools.md +0 -8
  204. data/examples/prompts_dir/weather.md +0 -2
  205. data/examples/prompts_dir/whats_new.md +0 -2
  206. data/examples/prompts_dir/with_timestamp.md +0 -5
  207. data/examples/requirements/sinatra_taskflow_app.md +0 -139
  208. data/examples/rules/01_classify_ruby.rb +0 -16
  209. data/examples/rules/02_prefer_claude_for_code.rb +0 -19
  210. data/examples/rules/03_gate_prompt_length.rb +0 -19
  211. data/examples/rules/04_tool_selection.rb +0 -41
  212. data/examples/rules/README.md +0 -30
  213. data/examples/run_all.sh +0 -294
  214. data/examples/tools/word_count_tool.rb +0 -30
  215. data/lib/AGENTS.md +0 -57
  216. data/lib/aia/model_switch_handler.rb +0 -100
  217. data/mcp_servers/README.md +0 -110
  218. data/mcp_servers/apple-mcp.json +0 -8
  219. data/mcp_servers/filesystem.json +0 -9
  220. data/mcp_servers/mcp_server_chart.json +0 -11
  221. data/mcp_servers/playwright_one.json +0 -8
  222. data/mcp_servers/playwright_server_definition.json +0 -9
  223. data/mcp_servers/playwright_two.json +0 -8
  224. data/mcp_servers/tavily_mcp_server.json +0 -8
  225. data/mkdocs.yml +0 -169
@@ -1,636 +0,0 @@
1
- <!-- Tocer[start]: Auto-generated, don't remove. -->
2
-
3
- ## Table of Contents
4
-
5
- - [Workflows and Pipelines](#workflows-and-pipelines)
6
- - [Understanding Workflows](#understanding-workflows)
7
- - [Basic Concepts](#basic-concepts)
8
- - [Simple Workflows](#simple-workflows)
9
- - [Sequential Processing](#sequential-processing)
10
- - [Basic Pipeline](#basic-pipeline)
11
- - [Pipeline Definition](#pipeline-definition)
12
- - [Command Line Pipelines](#command-line-pipelines)
13
- - [Directive-Based Pipelines](#directive-based-pipelines)
14
- - [Dynamic Pipeline Generation](#dynamic-pipeline-generation)
15
- - [Advanced Workflow Patterns](#advanced-workflow-patterns)
16
- - [Conditional Workflows](#conditional-workflows)
17
- - [Parallel Processing Workflows](#parallel-processing-workflows)
18
- - [Error Recovery Workflows](#error-recovery-workflows)
19
- - [State Management in Workflows](#state-management-in-workflows)
20
- - [Context Persistence](#context-persistence)
21
- - [Data Passing Between Stages](#data-passing-between-stages)
22
- - [Current Stage: <%= current_stage.capitalize %>](#current-stage--current_stagecapitalize-)
23
- - [Analysis Task](#analysis-task)
24
- - [Prepare data for next stage (this would be set by the AI response processing)](#prepare-data-for-next-stage-this-would-be-set-by-the-ai-response-processing)
25
- - [This would typically be saved after AI processing](#this-would-typically-be-saved-after-ai-processing)
26
- - [master_controller.md](#master_controllermd)
27
- - [Master Workflow Controller](#master-workflow-controller)
28
- - [workflow_monitor.md](#workflow_monitormd)
29
- - [Setup workflow logging](#setup-workflow-logging)
30
- - [Log workflow start](#log-workflow-start)
31
- - [model_optimized_workflow.md](#model_optimized_workflowmd)
32
- - [cached_workflow.md](#cached_workflowmd)
33
- - [Create cache key from inputs and configuration](#create-cache-key-from-inputs-and-configuration)
34
- - [software_dev_pipeline.md](#software_dev_pipelinemd)
35
- - [Software Development Pipeline](#software-development-pipeline)
36
- - [Pipeline Stages:](#pipeline-stages)
37
- - [content_creation_pipeline.md](#content_creation_pipelinemd)
38
- - [Content Creation Pipeline](#content-creation-pipeline)
39
- - [Research Phase](#research-phase)
40
- - [data_science_workflow.md](#data_science_workflowmd)
41
- - [Checkpoints in Interactive Workflows](#checkpoints-in-interactive-workflows)
42
- - [Workflow Best Practices](#workflow-best-practices)
43
- - [Design Principles](#design-principles)
44
- - [Performance Considerations](#performance-considerations)
45
- - [Maintenance and Debugging](#maintenance-and-debugging)
46
- - [Troubleshooting Workflows](#troubleshooting-workflows)
47
- - [Common Issues](#common-issues)
48
- - [Workflow Interruption](#workflow-interruption)
49
- - [Context Size Issues](#context-size-issues)
50
- - [Model Rate Limiting](#model-rate-limiting)
51
- - [Related Documentation](#related-documentation)
52
-
53
- <!-- Tocer[finish]: Auto-generated, don't remove. -->
54
-
55
- # Workflows and Pipelines
56
-
57
- AIA's workflow system allows you to chain prompts together, creating sophisticated multi-stage processes for complex tasks. This enables automated processing pipelines that can handle everything from simple two-step workflows to complex enterprise-level automation.
58
-
59
- ## Understanding Workflows
60
-
61
- ### Basic Concepts
62
-
63
- **Workflow**: A sequence of prompts executed in order, where each prompt can pass context to the next.
64
-
65
- **Next Prompt**: The immediate next prompt to execute after the current one completes. Specified as a `next` key in the YAML front matter of a `.md` prompt file:
66
-
67
- ```yaml
68
- ---
69
- next: summary
70
- ---
71
- ```
72
-
73
- **Pipeline**: A predefined sequence of prompt IDs specified as a `pipeline` key in YAML front matter, or via `--pipeline` on the command line. These keys are placed at the top of the `.md` prompt file and are processed during prompt loading, not as chat-time directives:
74
-
75
- ```yaml
76
- ---
77
- pipeline: analyze_data,generate_insights,write_report
78
- ---
79
- ```
80
-
81
- **Context Passing**: Information and results flow from one prompt to the next in the sequence.
82
-
83
- ## Simple Workflows
84
-
85
- ### Sequential Processing
86
- ```markdown
87
- # first_prompt.md
88
- ---
89
- next: second_prompt
90
- ---
91
- /config model gpt-4
92
-
93
- Analyze the following data and prepare it for detailed analysis:
94
- /include <%= data_file %>
95
-
96
- Key findings summary:
97
- ```
98
-
99
- ```markdown
100
- # second_prompt.md
101
- /config model claude-3-sonnet
102
-
103
- Based on the initial analysis, provide detailed insights and recommendations:
104
-
105
- Previous analysis results will be available in context.
106
- Generate actionable recommendations.
107
- ```
108
-
109
- ### Basic Pipeline
110
- ```bash
111
- # Execute a simple pipeline
112
- aia --pipeline "data_prep,analysis,report" dataset.csv
113
-
114
- # Or using the directive
115
- aia data_prep --next analysis --next report dataset.csv
116
- ```
117
-
118
- ## Pipeline Definition
119
-
120
- ### Command Line Pipelines
121
- ```bash
122
- # Simple linear pipeline
123
- aia --pipeline "step1,step2,step3" input.txt
124
-
125
- # Pipeline with output files
126
- aia --pipeline "extract,transform,load" --output results.md data.csv
127
-
128
- # Pipeline with model specification
129
- aia --model gpt-4 --pipeline "review,optimize,test" code.py
130
- ```
131
-
132
- ### Directive-Based Pipelines
133
-
134
- The `pipeline` key is placed in YAML front matter at the top of the prompt file and is processed during prompt loading:
135
-
136
- ```markdown
137
- # pipeline_starter.md
138
- ---
139
- pipeline: analyze_data,generate_insights,create_visualization,write_report
140
- ---
141
- /config model claude-3-sonnet
142
-
143
- # Data Analysis Pipeline
144
-
145
- Starting comprehensive data analysis workflow.
146
-
147
- Input data: <%= input_file %>
148
- Processing stages: 4 stages planned
149
-
150
- ## Stage 1: Data Analysis
151
- Initial data examination and basic statistics.
152
- ```
153
-
154
- ### Dynamic Pipeline Generation
155
- ```ruby
156
- # adaptive_pipeline.md
157
- /ruby
158
- data_size = File.size('<%= input_file %>')
159
- complexity = data_size > 100000 ? 'complex' : 'simple'
160
-
161
- if complexity == 'complex'
162
- pipeline = ['data_chunk', 'parallel_analysis', 'merge_results', 'comprehensive_report']
163
- else
164
- pipeline = ['quick_analysis', 'summary_report']
165
- end
166
-
167
- puts "/pipeline #{pipeline.join(',')}"
168
- puts "Selected #{complexity} pipeline (#{pipeline.length} stages)"
169
- ```
170
-
171
- ## Advanced Workflow Patterns
172
-
173
- ### Conditional Workflows
174
- Execute different paths based on intermediate results:
175
-
176
- ```ruby
177
- # conditional_workflow.md
178
- /ruby
179
- # Analyze input to determine workflow path
180
- content = File.read('<%= input_file %>')
181
- file_type = File.extname('<%= input_file %>')
182
-
183
- if file_type == '.py'
184
- workflow = ['python_analysis', 'security_check', 'performance_review', 'documentation']
185
- elsif file_type == '.js'
186
- workflow = ['javascript_analysis', 'eslint_check', 'performance_review', 'documentation']
187
- elsif content.match?(/SELECT|INSERT|UPDATE|DELETE/i)
188
- workflow = ['sql_analysis', 'security_audit', 'optimization_review']
189
- else
190
- workflow = ['generic_analysis', 'quality_check', 'recommendations']
191
- end
192
-
193
- puts "/pipeline #{workflow.join(',')}"
194
- puts "Detected #{file_type} file, using #{workflow.first.split('_').first} workflow"
195
- ```
196
-
197
- ### Parallel Processing Workflows
198
- Handle multiple inputs simultaneously:
199
-
200
- ```ruby
201
- # parallel_processing.md
202
- /ruby
203
- input_files = Dir.glob('<%= pattern %>')
204
- batch_size = 3
205
-
206
- puts "Processing #{input_files.length} files in parallel batches"
207
-
208
- input_files.each_slice(batch_size).with_index do |batch, index|
209
- puts "\n## Batch #{index + 1}"
210
- batch.each_with_index do |file, file_index|
211
- puts "### File #{file_index + 1}: #{File.basename(file)}"
212
- puts "/include #{file}"
213
- end
214
-
215
- puts "\nProcess this batch focusing on:"
216
- puts "- Individual file analysis"
217
- puts "- Cross-file relationships"
218
- puts "- Batch-level patterns"
219
-
220
- if index < (input_files.length / batch_size.to_f).ceil - 1
221
- puts "/next parallel_processing_batch_#{index + 2}"
222
- else
223
- puts "/next merge_parallel_results"
224
- end
225
- end
226
- ```
227
-
228
- ### Error Recovery Workflows
229
- Handle failures gracefully:
230
-
231
- ```markdown
232
- # robust_workflow.md
233
- /config model gpt-4
234
- /config temperature 0.3
235
-
236
- # Robust Analysis Workflow
237
-
238
- /ruby
239
- begin
240
- primary_data = File.read('<%= primary_input %>')
241
- puts "Using primary data source"
242
- puts "/include <%= primary_input %>"
243
-
244
- # Set success path
245
- puts "/next detailed_analysis"
246
-
247
- rescue => e
248
- puts "Primary data unavailable: #{e.message}"
249
- puts "Switching to fallback workflow"
250
-
251
- # Check for fallback options
252
- if File.exist?('<%= fallback_input %>')
253
- puts "/include <%= fallback_input %>"
254
- puts "/next basic_analysis"
255
- else
256
- puts "No data sources available"
257
- puts "/next manual_input_prompt"
258
- end
259
- end
260
- ```
261
-
262
- ## State Management in Workflows
263
-
264
- ### Context Persistence
265
- Maintain state across workflow stages:
266
-
267
- ```ruby
268
- # stateful_workflow.md
269
- /ruby
270
- # Initialize or load workflow state
271
- state_file = '/tmp/workflow_state.json'
272
-
273
- if File.exist?(state_file)
274
- state = JSON.parse(File.read(state_file))
275
- puts "Resuming workflow at stage: #{state['current_stage']}"
276
- else
277
- state = {
278
- 'workflow_id' => SecureRandom.uuid,
279
- 'started_at' => Time.now.iso8601,
280
- 'current_stage' => 1,
281
- 'completed_stages' => [],
282
- 'data' => {}
283
- }
284
- end
285
-
286
- # Update state for current stage
287
- stage_name = '<%= stage_name || "unknown" %>'
288
- state['current_stage'] = stage_name
289
- state['data'][stage_name] = {
290
- 'started_at' => Time.now.iso8601,
291
- 'input_file' => '<%= input_file %>',
292
- 'model' => AIA.config.models.first&.name
293
- }
294
-
295
- # Save state
296
- File.write(state_file, JSON.pretty_generate(state))
297
- puts "Workflow state saved: #{state['workflow_id']}"
298
- ```
299
-
300
- ### Data Passing Between Stages
301
- Pass structured data between workflow stages:
302
-
303
- ```ruby
304
- # data_passing_example.md
305
- /ruby
306
- # Stage data management
307
- stage_data_file = "/tmp/stage_data_#{ENV['WORKFLOW_ID'] || 'default'}.json"
308
-
309
- # Load previous stage data if available
310
- previous_data = {}
311
- if File.exist?(stage_data_file)
312
- previous_data = JSON.parse(File.read(stage_data_file))
313
- puts "Loaded data from previous stages:"
314
- puts JSON.pretty_generate(previous_data)
315
- end
316
-
317
- # Current stage identifier
318
- current_stage = '<%= current_stage || "stage_#{Time.now.to_i}" %>'
319
- ```
320
-
321
- ## Current Stage: <%= current_stage.capitalize %>
322
-
323
- Previous stage results:
324
- <%= previous_data.empty? ? "No previous data" : previous_data.to_json %>
325
-
326
- ## Analysis Task
327
- Perform analysis considering previous stage results.
328
-
329
- /ruby
330
- # Prepare data for next stage (this would be set by the AI response processing)
331
- current_results = {
332
- 'stage' => current_stage,
333
- 'timestamp' => Time.now.iso8601,
334
- 'status' => 'completed',
335
- 'key_findings' => 'placeholder_for_ai_results'
336
- }
337
-
338
- # This would typically be saved after AI processing
339
- puts "Stage data template prepared for: #{current_stage}"
340
- ```
341
-
342
- ## Workflow Orchestration
343
-
344
- ### Master Workflow Controller
345
- Create workflows that manage other workflows:
346
-
347
- ```ruby
348
- # master_controller.md
349
- /config model gpt-4
350
-
351
- # Master Workflow Controller
352
-
353
- /ruby
354
- project_type = '<%= project_type %>'
355
- complexity = '<%= complexity || "standard" %>'
356
-
357
- workflows = {
358
- 'code_project' => {
359
- 'simple' => ['code_review', 'basic_tests', 'documentation'],
360
- 'standard' => ['code_review', 'security_scan', 'performance_test', 'documentation'],
361
- 'complex' => ['architecture_review', 'code_review', 'security_audit', 'performance_analysis', 'test_suite', 'documentation']
362
- },
363
- 'data_analysis' => {
364
- 'simple' => ['data_overview', 'basic_stats', 'summary'],
365
- 'standard' => ['data_validation', 'exploratory_analysis', 'modeling', 'insights'],
366
- 'complex' => ['data_profiling', 'quality_assessment', 'feature_engineering', 'advanced_modeling', 'validation', 'reporting']
367
- },
368
- 'content_creation' => {
369
- 'simple' => ['outline', 'draft', 'review'],
370
- 'standard' => ['research', 'outline', 'draft', 'edit', 'finalize'],
371
- 'complex' => ['research', 'expert_review', 'outline', 'sections_draft', 'peer_review', 'revision', 'final_edit']
372
- }
373
- }
374
-
375
- selected_workflow = workflows[project_type][complexity]
376
- puts "/pipeline #{selected_workflow.join(',')}"
377
-
378
- puts "Initiating #{project_type} workflow (#{complexity} complexity)"
379
- puts "Stages: #{selected_workflow.length}"
380
- puts "Estimated duration: #{selected_workflow.length * 5} minutes"
381
- ```
382
-
383
- ### Workflow Monitoring and Logging
384
- Track workflow execution and performance:
385
-
386
- ```ruby
387
- # workflow_monitor.md
388
- /ruby
389
- require 'logger'
390
-
391
- # Setup workflow logging
392
- log_dir = '/tmp/aia_workflows'
393
- Dir.mkdir(log_dir) unless Dir.exist?(log_dir)
394
-
395
- logger = Logger.new("#{log_dir}/workflow_#{Date.today.strftime('%Y%m%d')}.log")
396
- workflow_id = ENV['WORKFLOW_ID'] || SecureRandom.uuid
397
-
398
- # Log workflow start
399
- logger.info("Workflow #{workflow_id} started")
400
- logger.info("Stage: <%= stage_name %>")
401
- logger.info("Model: #{AIA.config.models.first&.name}")
402
- logger.info("Input: <%= input_description %>")
403
-
404
- start_time = Time.now
405
- puts "Workflow monitoring active (ID: #{workflow_id})"
406
- ```
407
-
408
- ## Workflow Performance Optimization
409
-
410
- ### Intelligent Model Selection
411
- Choose optimal models for each workflow stage:
412
-
413
- ```ruby
414
- # model_optimized_workflow.md
415
- /ruby
416
- stages = {
417
- 'data_extraction' => { model: 'gpt-3.5-turbo', temperature: 0.2 },
418
- 'analysis' => { model: 'claude-3-sonnet', temperature: 0.3 },
419
- 'creative_generation' => { model: 'gpt-4', temperature: 1.0 },
420
- 'review_and_edit' => { model: 'gpt-4', temperature: 0.4 },
421
- 'final_formatting' => { model: 'gpt-3.5-turbo', temperature: 0.1 }
422
- }
423
-
424
- current_stage = '<%= current_stage %>'
425
- stage_config = stages[current_stage]
426
-
427
- if stage_config
428
- puts "/config model #{stage_config[:model]}"
429
- puts "/config temperature #{stage_config[:temperature]}"
430
- puts "Optimized for #{current_stage}: #{stage_config[:model]} at #{stage_config[:temperature]} temperature"
431
- else
432
- puts "/config model gpt-4"
433
- puts "Using default model for unknown stage: #{current_stage}"
434
- end
435
- ```
436
-
437
- ### Caching and Optimization
438
- Implement caching for workflow efficiency:
439
-
440
- ```ruby
441
- # cached_workflow.md
442
- /ruby
443
- require 'digest'
444
-
445
- # Create cache key from inputs and configuration
446
- cache_inputs = {
447
- 'stage' => '<%= stage_name %>',
448
- 'input_file' => '<%= input_file %>',
449
- 'model' => AIA.config.models.first&.name,
450
- 'temperature' => AIA.config.temperature
451
- }
452
-
453
- cache_key = Digest::MD5.hexdigest(cache_inputs.to_json)
454
- cache_file = "/tmp/workflow_cache_#{cache_key}.json"
455
- cache_duration = 3600 # 1 hour
456
-
457
- if File.exist?(cache_file) && (Time.now - File.mtime(cache_file)) < cache_duration
458
- cached_result = JSON.parse(File.read(cache_file))
459
- puts "Using cached result for stage: #{cached_result['stage']}"
460
- puts cached_result['content']
461
-
462
- # Skip to next stage if available
463
- if cached_result['next_stage']
464
- puts "/next #{cached_result['next_stage']}"
465
- end
466
-
467
- exit # Skip AI processing
468
- else
469
- puts "Processing fresh request (cache miss or expired)"
470
- # Continue with normal processing
471
- end
472
- ```
473
-
474
- ## Real-World Workflow Examples
475
-
476
- ### Software Development Pipeline
477
- Complete software development workflow:
478
-
479
- ```markdown
480
- # software_dev_pipeline.md
481
- /pipeline requirements_analysis,architecture_design,implementation_plan,code_review,testing_strategy,documentation,deployment_guide
482
-
483
- # Software Development Pipeline
484
-
485
- Project: <%= project_name %>
486
- Repository: /include README.md
487
-
488
- ## Pipeline Stages:
489
- 1. **Requirements Analysis** - Extract and analyze requirements
490
- 2. **Architecture Design** - Design system architecture
491
- 3. **Implementation Plan** - Create detailed implementation plan
492
- 4. **Code Review** - Review existing code
493
- 5. **Testing Strategy** - Develop testing approach
494
- 6. **Documentation** - Generate comprehensive docs
495
- 7. **Deployment Guide** - Create deployment instructions
496
-
497
- Starting requirements analysis phase...
498
-
499
- /config model gpt-4
500
- /config temperature 0.4
501
- ```
502
-
503
- ### Content Creation Workflow
504
- Multi-stage content creation pipeline:
505
-
506
- ```markdown
507
- # content_creation_pipeline.md
508
- /pipeline research_phase,outline_creation,content_draft,expert_review,content_revision,final_edit,seo_optimization
509
-
510
- # Content Creation Pipeline
511
-
512
- Topic: <%= topic %>
513
- Target Audience: <%= audience %>
514
- Content Type: <%= content_type %>
515
-
516
- ## Research Phase
517
- /include source_materials.md
518
- /shell curl -s "https://api.example.com/research/<%= topic %>" | jq '.'
519
-
520
- Initial research and source gathering...
521
-
522
- /config model claude-3-sonnet
523
- /config temperature 0.6
524
- ```
525
-
526
- ### Data Science Workflow
527
- Comprehensive data analysis pipeline:
528
-
529
- ```ruby
530
- # data_science_workflow.md
531
- /ruby
532
- dataset_size = File.size('<%= dataset %>')
533
- complexity = dataset_size > 10000000 ? 'enterprise' : 'standard'
534
-
535
- pipelines = {
536
- 'standard' => ['data_exploration', 'data_cleaning', 'feature_analysis', 'modeling', 'validation', 'insights'],
537
- 'enterprise' => ['data_profiling', 'quality_assessment', 'preprocessing', 'feature_engineering', 'model_selection', 'hyperparameter_tuning', 'validation', 'deployment_prep', 'monitoring_setup']
538
- }
539
-
540
- selected_pipeline = pipelines[complexity]
541
- puts "/pipeline #{selected_pipeline.join(',')}"
542
-
543
- puts "Selected #{complexity} data science pipeline"
544
- puts "Dataset size: #{dataset_size} bytes"
545
- ```
546
-
547
- # Data Science Analysis Pipeline
548
-
549
- Dataset: /include <%= dataset %>
550
-
551
- Pipeline optimized for <%= complexity %> analysis with <%= selected_pipeline.length %> stages.
552
-
553
- /config model claude-3-sonnet
554
- /config temperature 0.3
555
- ```
556
-
557
- ### Checkpoints in Interactive Workflows
558
-
559
- In interactive chat-based workflows, use `/checkpoint` to save the current conversation state at a meaningful point, and `/restore` to return to that saved state if a later branch produces unsatisfactory results. This is especially useful when running multi-stage workflows that involve experimental or speculative steps.
560
-
561
- ## Workflow Best Practices
562
-
563
- ### Design Principles
564
- 1. **Modularity**: Each stage should have a clear, single purpose
565
- 2. **Reusability**: Design stages that can be used in multiple workflows
566
- 3. **Error Handling**: Plan for failures and provide recovery paths
567
- 4. **State Management**: Maintain proper state between stages
568
- 5. **Monitoring**: Include logging and progress tracking
569
-
570
- ### Performance Considerations
571
- 1. **Model Selection**: Choose appropriate models for each stage
572
- 2. **Caching**: Cache expensive operations and intermediate results
573
- 3. **Parallel Processing**: Run independent stages concurrently
574
- 4. **Resource Management**: Monitor memory and token usage
575
- 5. **Optimization**: Profile and optimize slow stages
576
-
577
- ### Maintenance and Debugging
578
- 1. **Logging**: Comprehensive logging for troubleshooting
579
- 2. **Testing**: Test workflows with various inputs
580
- 3. **Documentation**: Document workflow purpose and usage
581
- 4. **Versioning**: Version control workflow definitions
582
- 5. **Monitoring**: Track workflow performance and success rates
583
-
584
- ## Troubleshooting Workflows
585
-
586
- ### Common Issues
587
-
588
- #### Workflow Interruption
589
- ```bash
590
- # Restart from a specific stage by specifying the remaining pipeline
591
- aia --pipeline "failed_stage,remaining_stages" input_file
592
- ```
593
-
594
- #### Context Size Issues
595
- ```ruby
596
- # Handle large contexts in workflows
597
- /ruby
598
- context_size = File.read('<%= context_file %>').length
599
- max_context = 50000
600
-
601
- if context_size > max_context
602
- puts "Context too large (#{context_size} chars), implementing chunking strategy"
603
- puts "/pipeline chunk_processing,merge_results,final_analysis"
604
- else
605
- puts "/pipeline standard_analysis,final_report"
606
- end
607
- ```
608
-
609
- #### Model Rate Limiting
610
- ```ruby
611
- # Handle rate limiting in workflows
612
- /ruby
613
- stage_delays = {
614
- 'heavy_analysis' => 30, # seconds
615
- 'api_calls' => 10,
616
- 'standard' => 5
617
- }
618
-
619
- current_stage = '<%= stage_name %>'
620
- delay = stage_delays[current_stage] || stage_delays['standard']
621
-
622
- puts "Implementing #{delay}s delay for rate limiting"
623
- sleep delay if ENV['WORKFLOW_MODE'] == 'production'
624
- ```
625
-
626
- ## Related Documentation
627
-
628
- - [Advanced Prompting](advanced-prompting.md) - Complex prompting techniques
629
- - [Prompt Management](prompt_management.md) - Organizing prompts
630
- - [Configuration](configuration.md) - Workflow configuration options
631
- - [Examples](examples/index.md) - Real-world workflow examples
632
- - [CLI Reference](cli-reference.md) - Pipeline command-line options
633
-
634
- ---
635
-
636
- Workflows and pipelines are powerful features that enable sophisticated automation with AIA. Start with simple sequential workflows and gradually build more complex, intelligent automation systems as your needs grow!
data/examples/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- output/
2
- orchestrated_build_*/