roast-ai 0.3.1 → 0.4.1
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yaml +2 -2
- data/.gitignore +1 -0
- data/CHANGELOG.md +85 -0
- data/CLAUDE.md +106 -9
- data/Gemfile +4 -1
- data/Gemfile.lock +70 -16
- data/README.md +159 -8
- data/bin/console +1 -0
- data/bin/roast +1 -1
- data/claude-swarm.yml +210 -0
- data/docs/AGENT_STEPS.md +288 -0
- data/docs/VALIDATION.md +178 -0
- data/examples/agent_continue/add_documentation/prompt.md +5 -0
- data/examples/agent_continue/add_error_handling/prompt.md +5 -0
- data/examples/agent_continue/analyze_codebase/prompt.md +7 -0
- data/examples/agent_continue/combined_workflow.yml +24 -0
- data/examples/agent_continue/continue_adding_features/prompt.md +4 -0
- data/examples/agent_continue/create_integration_tests/prompt.md +3 -0
- data/examples/agent_continue/document_with_context/prompt.md +5 -0
- data/examples/agent_continue/explore_api/prompt.md +6 -0
- data/examples/agent_continue/implement_client/prompt.md +6 -0
- data/examples/agent_continue/inline_workflow.yml +20 -0
- data/examples/agent_continue/refactor_code/prompt.md +2 -0
- data/examples/agent_continue/verify_changes/prompt.md +6 -0
- data/examples/agent_continue/workflow.yml +27 -0
- data/examples/agent_workflow/README.md +75 -0
- data/examples/agent_workflow/apply_refactorings/prompt.md +22 -0
- data/examples/agent_workflow/identify_code_smells/prompt.md +15 -0
- data/examples/agent_workflow/summarize_improvements/prompt.md +18 -0
- data/examples/agent_workflow/workflow.png +0 -0
- data/examples/agent_workflow/workflow.yml +16 -0
- data/examples/api_workflow/workflow.png +0 -0
- data/examples/apply_diff_demo/README.md +58 -0
- data/examples/apply_diff_demo/apply_simple_change/prompt.md +13 -0
- data/examples/apply_diff_demo/create_sample_file/prompt.md +11 -0
- data/examples/apply_diff_demo/workflow.yml +24 -0
- data/examples/available_tools_demo/README.md +42 -0
- data/examples/available_tools_demo/analyze_files/prompt.md +6 -0
- data/examples/available_tools_demo/explore_directory/prompt.md +6 -0
- data/examples/available_tools_demo/workflow.png +0 -0
- data/examples/available_tools_demo/workflow.yml +32 -0
- data/examples/available_tools_demo/write_summary/prompt.md +6 -0
- data/examples/bash_prototyping/api_testing.png +0 -0
- data/examples/bash_prototyping/system_analysis.png +0 -0
- data/examples/case_when/detect_language/prompt.md +2 -2
- data/examples/case_when/workflow.png +0 -0
- data/examples/cmd/basic_workflow.png +0 -0
- data/examples/cmd/dev_workflow.png +0 -0
- data/examples/cmd/explorer_workflow.png +0 -0
- data/examples/conditional/simple_workflow.png +0 -0
- data/examples/conditional/workflow.png +0 -0
- data/examples/context_management_demo/README.md +43 -0
- data/examples/context_management_demo/workflow.yml +42 -0
- data/examples/direct_coerce_syntax/workflow.png +0 -0
- data/examples/dot_notation/workflow.png +0 -0
- data/examples/exit_on_error/workflow.png +0 -0
- data/examples/grading/run_coverage.rb +0 -2
- data/examples/grading/workflow.png +0 -0
- data/examples/interpolation/workflow.png +0 -0
- data/examples/interpolation/workflow.yml +1 -1
- data/examples/iteration/analyze_complexity/prompt.md +2 -2
- data/examples/iteration/generate_recommendations/prompt.md +2 -2
- data/examples/iteration/implement_fix/prompt.md +2 -2
- data/examples/iteration/prioritize_issues/prompt.md +1 -1
- data/examples/iteration/prompts/analyze_file.md +2 -2
- data/examples/iteration/prompts/generate_summary.md +1 -1
- data/examples/iteration/prompts/update_report.md +3 -3
- data/examples/iteration/prompts/write_report.md +3 -3
- data/examples/iteration/read_file/prompt.md +2 -2
- data/examples/iteration/select_next_issue/prompt.md +2 -2
- data/examples/iteration/update_fix_count/prompt.md +4 -4
- data/examples/iteration/verify_fix/prompt.md +3 -3
- data/examples/iteration/workflow.png +0 -0
- data/examples/json_handling/workflow.png +0 -0
- data/examples/mcp/README.md +3 -3
- data/examples/mcp/analyze_changes/prompt.md +1 -1
- data/examples/mcp/database_workflow.png +0 -0
- data/examples/mcp/database_workflow.yml +1 -1
- data/examples/mcp/env_demo/workflow.png +0 -0
- data/examples/mcp/fetch_pr_context/prompt.md +1 -1
- data/examples/mcp/filesystem_demo/workflow.png +0 -0
- data/examples/mcp/github_workflow.png +0 -0
- data/examples/mcp/github_workflow.yml +1 -1
- data/examples/mcp/multi_mcp_workflow.png +0 -0
- data/examples/mcp/post_review/prompt.md +1 -1
- data/examples/mcp/workflow.png +0 -0
- data/examples/no_model_fallback/README.md +17 -0
- data/examples/no_model_fallback/analyze_file/prompt.md +1 -0
- data/examples/no_model_fallback/analyze_patterns/prompt.md +27 -0
- data/examples/no_model_fallback/generate_report_for_md/prompt.md +10 -0
- data/examples/no_model_fallback/generate_report_for_rb/prompt.md +3 -0
- data/examples/no_model_fallback/sample.rb +42 -0
- data/examples/no_model_fallback/workflow.yml +19 -0
- data/examples/openrouter_example/workflow.png +0 -0
- data/examples/pre_post_processing/analyze_test_file/prompt.md +1 -1
- data/examples/pre_post_processing/improve_test_coverage/prompt.md +1 -1
- data/examples/pre_post_processing/optimize_test_performance/prompt.md +1 -1
- data/examples/pre_post_processing/post_processing/aggregate_metrics/prompt.md +2 -2
- data/examples/pre_post_processing/post_processing/generate_summary_report/prompt.md +1 -1
- data/examples/pre_post_processing/pre_processing/setup_test_environment/prompt.md +1 -1
- data/examples/pre_post_processing/validate_changes/prompt.md +2 -2
- data/examples/pre_post_processing/workflow.png +0 -0
- data/examples/rspec_to_minitest/workflow.png +0 -0
- data/examples/shared_config/example_with_shared_config/workflow.png +0 -0
- data/examples/shared_config/shared.png +0 -0
- data/examples/single_target_prepost/workflow.png +0 -0
- data/examples/smart_coercion_defaults/workflow.png +0 -0
- data/examples/step_configuration/workflow.png +0 -0
- data/examples/swarm_example.yml +25 -0
- data/examples/tool_config_example/workflow.png +0 -0
- data/examples/user_input/README.md +90 -0
- data/examples/user_input/funny_name/create_backstory/prompt.md +10 -0
- data/examples/user_input/funny_name/workflow.png +0 -0
- data/examples/user_input/funny_name/workflow.yml +26 -0
- data/examples/user_input/generate_summary/prompt.md +11 -0
- data/examples/user_input/simple_input_demo/workflow.png +0 -0
- data/examples/user_input/simple_input_demo/workflow.yml +35 -0
- data/examples/user_input/survey_workflow.png +0 -0
- data/examples/user_input/survey_workflow.yml +71 -0
- data/examples/user_input/welcome_message/prompt.md +3 -0
- data/examples/user_input/workflow.png +0 -0
- data/examples/user_input/workflow.yml +73 -0
- data/examples/workflow_generator/create_workflow_files/prompt.md +1 -1
- data/examples/workflow_generator/workflow.png +0 -0
- data/lib/roast/errors.rb +6 -4
- data/lib/roast/helpers/function_caching_interceptor.rb +0 -2
- data/lib/roast/helpers/logger.rb +12 -35
- data/lib/roast/helpers/minitest_coverage_runner.rb +0 -1
- data/lib/roast/helpers/prompt_loader.rb +0 -2
- data/lib/roast/helpers/timeout_handler.rb +91 -0
- data/lib/roast/resources/api_resource.rb +0 -4
- data/lib/roast/resources/url_resource.rb +0 -3
- data/lib/roast/resources.rb +0 -8
- data/lib/roast/services/context_threshold_checker.rb +42 -0
- data/lib/roast/services/token_counting_service.rb +44 -0
- data/lib/roast/tools/apply_diff.rb +128 -0
- data/lib/roast/tools/ask_user.rb +0 -2
- data/lib/roast/tools/bash.rb +12 -9
- data/lib/roast/tools/cmd.rb +29 -12
- data/lib/roast/tools/coding_agent.rb +65 -17
- data/lib/roast/tools/context_summarizer.rb +108 -0
- data/lib/roast/tools/grep.rb +0 -3
- data/lib/roast/tools/helpers/coding_agent_message_formatter.rb +1 -4
- data/lib/roast/tools/read_file.rb +0 -2
- data/lib/roast/tools/search_file.rb +0 -2
- data/lib/roast/tools/swarm.rb +124 -0
- data/lib/roast/tools/update_files.rb +0 -4
- data/lib/roast/tools/write_file.rb +0 -3
- data/lib/roast/tools.rb +0 -13
- data/lib/roast/value_objects/step_name.rb +14 -3
- data/lib/roast/value_objects/workflow_path.rb +0 -2
- data/lib/roast/value_objects.rb +4 -4
- data/lib/roast/version.rb +1 -1
- data/lib/roast/workflow/agent_step.rb +33 -0
- data/lib/roast/workflow/api_configuration.rb +0 -4
- data/lib/roast/workflow/base_iteration_step.rb +3 -6
- data/lib/roast/workflow/base_step.rb +54 -28
- data/lib/roast/workflow/base_workflow.rb +43 -23
- data/lib/roast/workflow/case_executor.rb +0 -1
- data/lib/roast/workflow/case_step.rb +0 -4
- data/lib/roast/workflow/command_executor.rb +0 -2
- data/lib/roast/workflow/conditional_executor.rb +0 -1
- data/lib/roast/workflow/conditional_step.rb +0 -4
- data/lib/roast/workflow/configuration.rb +5 -67
- data/lib/roast/workflow/configuration_loader.rb +63 -3
- data/lib/roast/workflow/configuration_parser.rb +1 -7
- data/lib/roast/workflow/context_manager.rb +89 -0
- data/lib/roast/workflow/dot_access_hash.rb +16 -1
- data/lib/roast/workflow/each_step.rb +1 -1
- data/lib/roast/workflow/error_handler.rb +0 -3
- data/lib/roast/workflow/expression_evaluator.rb +0 -3
- data/lib/roast/workflow/file_state_repository.rb +0 -5
- data/lib/roast/workflow/input_executor.rb +41 -0
- data/lib/roast/workflow/input_step.rb +163 -0
- data/lib/roast/workflow/iteration_executor.rb +0 -2
- data/lib/roast/workflow/output_handler.rb +1 -3
- data/lib/roast/workflow/output_manager.rb +0 -2
- data/lib/roast/workflow/repeat_step.rb +1 -1
- data/lib/roast/workflow/replay_handler.rb +1 -4
- data/lib/roast/workflow/resource_resolver.rb +0 -3
- data/lib/roast/workflow/session_manager.rb +0 -3
- data/lib/roast/workflow/sqlite_state_repository.rb +342 -0
- data/lib/roast/workflow/state_manager.rb +2 -4
- data/lib/roast/workflow/state_repository_factory.rb +36 -0
- data/lib/roast/workflow/step_completion_reporter.rb +27 -0
- data/lib/roast/workflow/step_executor_coordinator.rb +48 -24
- data/lib/roast/workflow/step_executor_factory.rb +0 -5
- data/lib/roast/workflow/step_executor_registry.rb +1 -4
- data/lib/roast/workflow/step_executor_with_reporting.rb +68 -0
- data/lib/roast/workflow/step_executors/hash_step_executor.rb +0 -3
- data/lib/roast/workflow/step_executors/parallel_step_executor.rb +0 -3
- data/lib/roast/workflow/step_executors/string_step_executor.rb +0 -2
- data/lib/roast/workflow/step_factory.rb +56 -0
- data/lib/roast/workflow/step_loader.rb +31 -17
- data/lib/roast/workflow/step_name_extractor.rb +84 -0
- data/lib/roast/workflow/step_orchestrator.rb +3 -2
- data/lib/roast/workflow/step_type_resolver.rb +28 -1
- data/lib/roast/workflow/validation_command.rb +197 -0
- data/lib/roast/workflow/validator.rb +0 -4
- data/lib/roast/workflow/validators/base_validator.rb +44 -0
- data/lib/roast/workflow/validators/dependency_validator.rb +223 -0
- data/lib/roast/workflow/validators/linting_validator.rb +113 -0
- data/lib/roast/workflow/validators/schema_validator.rb +90 -0
- data/lib/roast/workflow/validators/step_collector.rb +57 -0
- data/lib/roast/workflow/validators/validation_orchestrator.rb +52 -0
- data/lib/roast/workflow/workflow_executor.rb +11 -20
- data/lib/roast/workflow/workflow_initializer.rb +1 -8
- data/lib/roast/workflow/workflow_runner.rb +6 -7
- data/lib/roast/workflow.rb +0 -15
- data/lib/roast/workflow_diagram_generator.rb +298 -0
- data/lib/roast.rb +212 -10
- data/roast.gemspec +4 -2
- data/schema/workflow.json +123 -1
- metadata +143 -6
- data/lib/roast/helpers.rb +0 -12
data/docs/AGENT_STEPS.md
ADDED
@@ -0,0 +1,288 @@
|
|
1
|
+
# Agent Steps in Roast
|
2
|
+
|
3
|
+
Agent steps provide a way to send prompts directly to a coding agent (like Claude Code) without going through the standard LLM translation layer. This document explains when and how to use agent steps effectively.
|
4
|
+
|
5
|
+
## What are Agent Steps?
|
6
|
+
|
7
|
+
Agent steps are denoted by prefixing a step name with `^`. They bypass the normal LLM processing and send your prompt content directly to the CodingAgent tool.
|
8
|
+
|
9
|
+
```yaml
|
10
|
+
steps:
|
11
|
+
# File-based prompts
|
12
|
+
- analyze_code # Regular step - processed by LLM first
|
13
|
+
- ^implement_fix # Agent step - direct to CodingAgent
|
14
|
+
|
15
|
+
# Inline prompts
|
16
|
+
- Analyze the code quality and suggest improvements # Regular inline
|
17
|
+
- ^Fix all ESLint errors and apply Prettier formatting # Agent inline
|
18
|
+
```
|
19
|
+
|
20
|
+
Both file-based prompts (with directories like `implement_fix/prompt.md`) and inline prompts (text with spaces) are supported.
|
21
|
+
|
22
|
+
## Agent Step Configuration Options
|
23
|
+
|
24
|
+
Agent steps support two special configuration options:
|
25
|
+
|
26
|
+
### `continue` (boolean, default: false)
|
27
|
+
When set to `true`, the agent continues from its previous session instead of starting fresh. This is useful for iterative development where you want the agent to maintain context across multiple steps.
|
28
|
+
|
29
|
+
### `include_context_summary` (boolean, default: false)
|
30
|
+
When set to `true`, the agent receives an AI-generated summary of the workflow context as a system directive. This summary is intelligently tailored to the agent's upcoming task, including only relevant information from previous steps. The summary is generated by analyzing:
|
31
|
+
- The agent's prompt to understand what context would be helpful
|
32
|
+
- Previous step outputs and their relevance to the current task
|
33
|
+
- Workflow description and configuration
|
34
|
+
- Current working directory
|
35
|
+
|
36
|
+
This helps the agent understand what has been done so far without overwhelming it with irrelevant details. NOTE: Without this option, the agent relies solely on what it is instructed to do either by the prompt or your specific step instructions.
|
37
|
+
|
38
|
+
```yaml
|
39
|
+
steps:
|
40
|
+
- analyze_code
|
41
|
+
- implement_fix: ^Fix the issues identified in the analysis
|
42
|
+
- add_tests: ^Prepare and publish PR
|
43
|
+
|
44
|
+
implement_fix:
|
45
|
+
include_context_summary: true # Include a summary of the workflow context so far
|
46
|
+
|
47
|
+
add_tests:
|
48
|
+
continue: true # does not need context since is continuing from the previous step
|
49
|
+
```
|
50
|
+
|
51
|
+
## When to Use Agent Steps
|
52
|
+
|
53
|
+
### Use Agent Steps When:
|
54
|
+
|
55
|
+
1. **You need precise control over tool usage**
|
56
|
+
- When you want to ensure specific tools are used in a particular way
|
57
|
+
- When the task requires exact file manipulations or code transformations
|
58
|
+
|
59
|
+
2. **Complex multi-file operations**
|
60
|
+
- When coordinating changes across multiple files
|
61
|
+
- When the operation requires specific sequencing of edits
|
62
|
+
|
63
|
+
3. **Performance optimization**
|
64
|
+
- When you want to skip the LLM interpretation layer
|
65
|
+
- For well-defined tasks that don't need additional context
|
66
|
+
|
67
|
+
### Use Regular Steps When:
|
68
|
+
|
69
|
+
1. **You need natural language processing**
|
70
|
+
- When the prompt benefits from LLM interpretation
|
71
|
+
- When you want the LLM to add context or reasoning
|
72
|
+
|
73
|
+
2. **Flexible, adaptive responses**
|
74
|
+
- When the exact approach might vary based on context
|
75
|
+
- When you want the LLM to make judgment calls
|
76
|
+
|
77
|
+
## Practical Examples
|
78
|
+
|
79
|
+
### Example 1: Database Migration
|
80
|
+
|
81
|
+
**Regular Step (analyze_migration/prompt.md):**
|
82
|
+
```markdown
|
83
|
+
Look at the user's database schema and determine what migrations might be needed to support the new features they've described. Consider best practices for database design.
|
84
|
+
```
|
85
|
+
|
86
|
+
This benefits from LLM interpretation because:
|
87
|
+
- It needs to understand "best practices" in context
|
88
|
+
- It should make judgments about schema design
|
89
|
+
- The approach varies based on the specific features
|
90
|
+
|
91
|
+
**Agent Step (^apply_migration/prompt.md):**
|
92
|
+
```markdown
|
93
|
+
Create a new migration file with the following specifications:
|
94
|
+
|
95
|
+
1. Create a new migration file: db/migrate/{{timestamp}}_add_user_preferences.rb
|
96
|
+
2. The migration must include:
|
97
|
+
- Add column :users, :preferences, :jsonb, default: {}
|
98
|
+
- Add index :users, :preferences, using: :gin
|
99
|
+
- Add column :users, :notification_settings, :jsonb, default: {}
|
100
|
+
3. Ensure proper up/down methods
|
101
|
+
4. Follow Rails migration conventions exactly
|
102
|
+
```
|
103
|
+
|
104
|
+
This is better as an agent step because:
|
105
|
+
- The instructions are precise and technical
|
106
|
+
- No interpretation needed - just execution of steps known beforehand
|
107
|
+
|
108
|
+
### Example 2: Code Refactoring
|
109
|
+
|
110
|
+
**Regular Step (identify_code_smells/prompt.md):**
|
111
|
+
```markdown
|
112
|
+
Review the provided code and identify any code smells or anti-patterns. Consider things like:
|
113
|
+
- Long methods that do too much
|
114
|
+
- Duplicated code
|
115
|
+
- Poor naming
|
116
|
+
- Tight coupling
|
117
|
+
- Missing abstractions
|
118
|
+
|
119
|
+
Explain why each identified issue is problematic.
|
120
|
+
```
|
121
|
+
|
122
|
+
This works well as a regular step because it requires judgment and explanation.
|
123
|
+
|
124
|
+
**Agent Step (^extract_method/prompt.md):**
|
125
|
+
```markdown
|
126
|
+
Extract the authentication logic from UserController#create into a separate method:
|
127
|
+
|
128
|
+
1. Read file: app/controllers/user_controller.rb
|
129
|
+
2. Find the code block from line 15-28 (the authentication logic)
|
130
|
+
3. Create a new private method called `authenticate_user_params`
|
131
|
+
4. Move the authentication logic to this new method
|
132
|
+
5. Replace the original code with a call to the new method
|
133
|
+
6. Ensure all variables are properly passed
|
134
|
+
|
135
|
+
Use MultiEdit to make all changes in a single operation.
|
136
|
+
Preserve exact indentation and formatting.
|
137
|
+
```
|
138
|
+
|
139
|
+
This is ideal as an agent step because:
|
140
|
+
- Specific line numbers and method names
|
141
|
+
- Exact refactoring instructions
|
142
|
+
- No room for interpretation
|
143
|
+
|
144
|
+
### Example 3: Test Generation
|
145
|
+
|
146
|
+
**Regular Step (plan_test_coverage/prompt.md):**
|
147
|
+
```markdown
|
148
|
+
Analyze the {{file}} and determine what test cases would provide comprehensive coverage. Consider:
|
149
|
+
- Happy path scenarios
|
150
|
+
- Edge cases
|
151
|
+
- Error conditions
|
152
|
+
- Boundary values
|
153
|
+
|
154
|
+
Focus on behavior, not implementation details.
|
155
|
+
```
|
156
|
+
|
157
|
+
**Agent Step (^implement_tests/prompt.md):**
|
158
|
+
```markdown
|
159
|
+
Create test file: test/models/user_validator_test.rb
|
160
|
+
|
161
|
+
Implement exactly these test cases:
|
162
|
+
1. test "validates email format"
|
163
|
+
- Use valid emails: ["user@example.com", "test.user+tag@domain.co.uk"]
|
164
|
+
- Use invalid emails: ["invalid", "@example.com", "user@", "user space@example.com"]
|
165
|
+
|
166
|
+
2. test "validates age is positive integer"
|
167
|
+
- Valid: [18, 25, 100]
|
168
|
+
- Invalid: [-1, 0, 17, 101, "twenty", nil]
|
169
|
+
|
170
|
+
3. test "validates username uniqueness"
|
171
|
+
- Create user with username "testuser"
|
172
|
+
- Attempt to create second user with same username
|
173
|
+
- Assert validation error on :username
|
174
|
+
|
175
|
+
Use minitest assertion style.
|
176
|
+
Each test must be independent.
|
177
|
+
Use setup method for common test data.
|
178
|
+
```
|
179
|
+
|
180
|
+
### Example 4: API Integration
|
181
|
+
|
182
|
+
**Regular Step (design_api_client/prompt.md):**
|
183
|
+
```markdown
|
184
|
+
Design a client for the {{api_name}} API that follows Ruby best practices. Consider:
|
185
|
+
- Error handling strategies
|
186
|
+
- Rate limiting
|
187
|
+
- Authentication patterns
|
188
|
+
- Response parsing
|
189
|
+
- Testing approach
|
190
|
+
|
191
|
+
Suggest an architecture that will be maintainable and extensible.
|
192
|
+
```
|
193
|
+
|
194
|
+
**Agent Step (^implement_api_client/prompt.md):**
|
195
|
+
```markdown
|
196
|
+
Implement the API client with this exact structure:
|
197
|
+
|
198
|
+
1. Create file: lib/external_apis/weather_api/client.rb
|
199
|
+
```ruby
|
200
|
+
module ExternalApis
|
201
|
+
module WeatherApi
|
202
|
+
class Client
|
203
|
+
include HTTParty
|
204
|
+
base_uri 'https://api.weather.com/v1'
|
205
|
+
|
206
|
+
def initialize(api_key)
|
207
|
+
@api_key = api_key
|
208
|
+
@options = { headers: { 'Authorization' => "Bearer #{api_key}" } }
|
209
|
+
end
|
210
|
+
|
211
|
+
def current_weather(location)
|
212
|
+
response = self.class.get("/current", @options.merge(query: { location: location }))
|
213
|
+
handle_response(response)
|
214
|
+
end
|
215
|
+
|
216
|
+
private
|
217
|
+
|
218
|
+
def handle_response(response)
|
219
|
+
raise ApiError, response.message unless response.success?
|
220
|
+
response.parsed_response
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
```
|
226
|
+
|
227
|
+
2. Create file: lib/external_apis/weather_api/api_error.rb
|
228
|
+
Define custom exception class
|
229
|
+
|
230
|
+
3. Update file: config/initializers/weather_api.rb
|
231
|
+
Add configuration for API endpoint and timeout
|
232
|
+
|
233
|
+
Use exact module structure and method signatures shown.
|
234
|
+
```
|
235
|
+
|
236
|
+
## Best Practices
|
237
|
+
|
238
|
+
1. **Be explicit about tool usage in agent steps**
|
239
|
+
```markdown
|
240
|
+
# Good agent step
|
241
|
+
Use MultiEdit tool to update the following files:
|
242
|
+
- app/models/user.rb: Add validation
|
243
|
+
- test/models/user_test.rb: Add test case
|
244
|
+
```
|
245
|
+
|
246
|
+
2. **Include specific line numbers or code markers when possible**
|
247
|
+
```markdown
|
248
|
+
# Good agent step
|
249
|
+
In app/controllers/application_controller.rb:
|
250
|
+
- Find method `authenticate_user!` (around line 45)
|
251
|
+
- Add the following before the redirect_to call:
|
252
|
+
session[:return_to] = request.fullpath
|
253
|
+
```
|
254
|
+
|
255
|
+
3. **Specify exact formatting requirements**
|
256
|
+
```markdown
|
257
|
+
# Good agent step
|
258
|
+
Create method with exactly this signature:
|
259
|
+
def calculate_tax(amount, rate = 0.08)
|
260
|
+
|
261
|
+
Ensure:
|
262
|
+
- Two-space indentation
|
263
|
+
- No trailing whitespace
|
264
|
+
- Blank line before method definition
|
265
|
+
```
|
266
|
+
|
267
|
+
4. **Chain agent steps for complex operations**
|
268
|
+
```yaml
|
269
|
+
steps:
|
270
|
+
# First understand the system
|
271
|
+
- analyze_current_architecture
|
272
|
+
|
273
|
+
# Then execute precise changes
|
274
|
+
- ^create_service_objects
|
275
|
+
- ^update_controllers
|
276
|
+
- ^add_test_coverage
|
277
|
+
|
278
|
+
# Finally verify
|
279
|
+
- verify_all_tests_pass
|
280
|
+
```
|
281
|
+
|
282
|
+
## Summary
|
283
|
+
|
284
|
+
Agent steps are powerful when you need direct control over tool usage and precise execution of technical tasks. They complement regular steps by handling the implementation details while regular steps handle the analysis and planning.
|
285
|
+
|
286
|
+
The `continue` and `include_context_summary` options make agent steps even more powerful for iterative development workflows where maintaining context is important.
|
287
|
+
|
288
|
+
Choose agent steps when precision matters more than interpretation. Choose regular steps when context and judgment are important.
|
data/docs/VALIDATION.md
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
# Workflow Validation
|
2
|
+
|
3
|
+
Roast provides comprehensive validation for workflow configurations to catch errors early and improve the development experience.
|
4
|
+
|
5
|
+
## Using the Validation Command
|
6
|
+
|
7
|
+
### Validate a Single Workflow
|
8
|
+
|
9
|
+
```bash
|
10
|
+
# Validate a specific workflow by path
|
11
|
+
roast validate path/to/workflow.yml
|
12
|
+
|
13
|
+
# Or by workflow name (assumes roast/ directory structure)
|
14
|
+
roast validate my_workflow
|
15
|
+
```
|
16
|
+
|
17
|
+
### Validate All Workflows
|
18
|
+
|
19
|
+
```bash
|
20
|
+
# Validate all workflows in the roast/ directory
|
21
|
+
roast validate
|
22
|
+
```
|
23
|
+
|
24
|
+
### Strict Mode
|
25
|
+
|
26
|
+
Use the `--strict` or `-s` flag to treat warnings as errors:
|
27
|
+
|
28
|
+
```bash
|
29
|
+
roast validate --strict
|
30
|
+
```
|
31
|
+
|
32
|
+
## Validation Levels
|
33
|
+
|
34
|
+
### 1. Schema Validation
|
35
|
+
|
36
|
+
Ensures your workflow conforms to the JSON schema:
|
37
|
+
- Required fields (name, tools, steps)
|
38
|
+
- Correct data types
|
39
|
+
- Valid structure for complex steps (if/then, case/when, each, repeat)
|
40
|
+
|
41
|
+
### 2. Dependency Checking
|
42
|
+
|
43
|
+
#### Tool Dependencies
|
44
|
+
Validates that all declared tools are available:
|
45
|
+
- Checks for tool module existence
|
46
|
+
- Supports MCP tool configurations
|
47
|
+
- Provides helpful suggestions for typos
|
48
|
+
|
49
|
+
#### Step References
|
50
|
+
Validates that steps referenced in conditions exist:
|
51
|
+
- Checks `if`, `unless`, and `case` conditions
|
52
|
+
- Distinguishes between step references and expressions
|
53
|
+
|
54
|
+
#### Resource Dependencies
|
55
|
+
Validates file resources:
|
56
|
+
- Warns if target files don't exist (unless using glob patterns)
|
57
|
+
- Checks for missing prompt files
|
58
|
+
|
59
|
+
### 3. Configuration Linting
|
60
|
+
|
61
|
+
#### Naming Conventions
|
62
|
+
- Workflows should have descriptive names
|
63
|
+
- Step names should use snake_case
|
64
|
+
|
65
|
+
#### Complexity Checks
|
66
|
+
- Warns about workflows with too many steps (>20)
|
67
|
+
- Detects excessive nesting depth (>5 levels)
|
68
|
+
|
69
|
+
|
70
|
+
#### Best Practices
|
71
|
+
- Warns about missing error handling
|
72
|
+
- Detects unused tool declarations
|
73
|
+
|
74
|
+
## Error Messages
|
75
|
+
|
76
|
+
The validator provides clear, actionable error messages:
|
77
|
+
|
78
|
+
```
|
79
|
+
Workflow validation failed with 2 error(s):
|
80
|
+
|
81
|
+
• Missing required field: 'steps' (Add 'steps' to your workflow configuration)
|
82
|
+
• Tool 'Roast::Tools::BashCommand' is not available (Did you mean: Roast::Tools::Bash?)
|
83
|
+
```
|
84
|
+
|
85
|
+
## Example Workflow
|
86
|
+
|
87
|
+
Here's an example of a well-validated workflow:
|
88
|
+
|
89
|
+
```yaml
|
90
|
+
name: Data Processing Workflow
|
91
|
+
tools:
|
92
|
+
- Roast::Tools::Bash
|
93
|
+
- Roast::Tools::ReadFile
|
94
|
+
- Roast::Tools::WriteFile
|
95
|
+
|
96
|
+
# Use inputs for sensitive data
|
97
|
+
inputs:
|
98
|
+
- api_token: "Enter your API token"
|
99
|
+
|
100
|
+
# Enable error handling
|
101
|
+
exit_on_error: true
|
102
|
+
|
103
|
+
steps:
|
104
|
+
- validate_input
|
105
|
+
- fetch_data
|
106
|
+
- process_data
|
107
|
+
- save_results
|
108
|
+
```
|
109
|
+
|
110
|
+
## Integration with CI/CD
|
111
|
+
|
112
|
+
You can integrate workflow validation into your CI/CD pipeline:
|
113
|
+
|
114
|
+
```yaml
|
115
|
+
# .github/workflows/validate.yml
|
116
|
+
name: Validate Workflows
|
117
|
+
on: [push, pull_request]
|
118
|
+
|
119
|
+
jobs:
|
120
|
+
validate:
|
121
|
+
runs-on: ubuntu-latest
|
122
|
+
steps:
|
123
|
+
- uses: actions/checkout@v2
|
124
|
+
- uses: ruby/setup-ruby@v1
|
125
|
+
with:
|
126
|
+
ruby-version: '3.0'
|
127
|
+
bundler-cache: true
|
128
|
+
- name: Validate all workflows
|
129
|
+
run: bundle exec roast validate --strict
|
130
|
+
```
|
131
|
+
|
132
|
+
## Programmatic Usage
|
133
|
+
|
134
|
+
You can also use the validator programmatically:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
require 'roast'
|
138
|
+
|
139
|
+
yaml_content = File.read('workflow.yml')
|
140
|
+
validator = Roast::Workflow::Validators::ValidationOrchestrator.new(yaml_content, 'workflow.yml')
|
141
|
+
|
142
|
+
if validator.valid?
|
143
|
+
puts "Workflow is valid!"
|
144
|
+
|
145
|
+
# Check for warnings
|
146
|
+
validator.warnings.each do |warning|
|
147
|
+
puts "Warning: #{warning[:message]}"
|
148
|
+
puts " → #{warning[:suggestion]}"
|
149
|
+
end
|
150
|
+
else
|
151
|
+
# Handle errors
|
152
|
+
validator.errors.each do |error|
|
153
|
+
puts "Error: #{error[:message]}"
|
154
|
+
puts " → #{error[:suggestion]}"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
```
|
158
|
+
|
159
|
+
## Architecture
|
160
|
+
|
161
|
+
The validation system follows SOLID principles with a modular design:
|
162
|
+
|
163
|
+
- **ValidationOrchestrator**: Coordinates all validators and aggregates results
|
164
|
+
- **SchemaValidator**: Handles YAML parsing and JSON schema validation
|
165
|
+
- **DependencyValidator**: Validates tools, step references, and resources
|
166
|
+
- **LintingValidator**: Enforces best practices and code quality standards
|
167
|
+
- **StepCollector**: Provides efficient caching for step traversal
|
168
|
+
|
169
|
+
This architecture makes it easy to extend validation with new rules or customize existing behavior.
|
170
|
+
|
171
|
+
## Future Enhancements
|
172
|
+
|
173
|
+
The validation system is designed to be extensible. Future enhancements may include:
|
174
|
+
|
175
|
+
- Detection of circular dependencies
|
176
|
+
- Performance analysis and optimization suggestions
|
177
|
+
- Custom validation rules via plugins
|
178
|
+
- Integration with language servers for real-time validation
|
@@ -0,0 +1,24 @@
|
|
1
|
+
description: Example combining both continue and context summary features
|
2
|
+
|
3
|
+
# This example shows how both parameters can work together for complex workflows
|
4
|
+
|
5
|
+
steps:
|
6
|
+
# Initial exploration
|
7
|
+
- explore_api
|
8
|
+
|
9
|
+
# First coding agent task
|
10
|
+
- ^implement_client
|
11
|
+
|
12
|
+
# Continue with context awareness
|
13
|
+
- ^add_error_handling
|
14
|
+
|
15
|
+
# Final implementation with full context
|
16
|
+
- ^create_integration_tests
|
17
|
+
|
18
|
+
add_error_handling:
|
19
|
+
continue: true # Continue working on the same client
|
20
|
+
include_context_summary: true # Include context about what was explored and built
|
21
|
+
|
22
|
+
create_integration_tests:
|
23
|
+
continue: true # Continue in the same session
|
24
|
+
include_context_summary: true # Full context of implementation
|
@@ -0,0 +1,20 @@
|
|
1
|
+
description: Example workflow using inline agent prompts with continuation
|
2
|
+
|
3
|
+
# This example demonstrates using inline agent prompts (direct text after ^)
|
4
|
+
# combined with the new parameters
|
5
|
+
|
6
|
+
steps:
|
7
|
+
# Start with a fresh context
|
8
|
+
- ^Create a simple Ruby class for managing a todo list with add, remove, and list methods
|
9
|
+
|
10
|
+
# Continue from previous session to add more features
|
11
|
+
- ^continue_adding_features
|
12
|
+
|
13
|
+
# Use context summary to understand what was built
|
14
|
+
- ^document_with_context
|
15
|
+
|
16
|
+
continue_adding_features:
|
17
|
+
continue: true # This continues from the previous agent session
|
18
|
+
|
19
|
+
document_with_context:
|
20
|
+
include_context_summary: true # This will include context about previous steps
|
@@ -0,0 +1,27 @@
|
|
1
|
+
description: Example workflow demonstrating agent continuation and context summary features
|
2
|
+
|
3
|
+
# This example shows how to use the new coding agent parameters:
|
4
|
+
# - continue: true - continues from previous agent session
|
5
|
+
# - include_context_summary: true - includes workflow context in the prompt
|
6
|
+
|
7
|
+
target: "**/*.rb"
|
8
|
+
|
9
|
+
steps:
|
10
|
+
# First agent step - starts fresh
|
11
|
+
- ^analyze_codebase
|
12
|
+
|
13
|
+
# Second agent step - continues from previous session
|
14
|
+
- ^refactor_code
|
15
|
+
|
16
|
+
# Third agent step - includes context summary from previous steps
|
17
|
+
- ^add_documentation
|
18
|
+
|
19
|
+
# Final verification step
|
20
|
+
- verify_changes
|
21
|
+
|
22
|
+
# Step configurations
|
23
|
+
refactor_code:
|
24
|
+
continue: true # Continue from the previous agent session
|
25
|
+
|
26
|
+
add_documentation:
|
27
|
+
include_context_summary: true # Include workflow context in the prompt
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Agent Workflow Example
|
2
|
+
|
3
|
+
This example demonstrates the practical differences between regular steps and agent steps in Roast workflows.
|
4
|
+
|
5
|
+
## What are Agent Steps?
|
6
|
+
|
7
|
+
Agent steps are a special type of step that sends prompts directly to the CodingAgent tool (e.g., Claude Code) without going through the normal LLM translation layer. They're denoted by prefixing the step name with `^`.
|
8
|
+
|
9
|
+
## When to Use Each Type
|
10
|
+
|
11
|
+
### Regular Steps
|
12
|
+
Best for tasks that benefit from LLM interpretation:
|
13
|
+
- Analysis and judgment tasks
|
14
|
+
- Natural language understanding
|
15
|
+
- Flexible responses based on context
|
16
|
+
- Summary and explanation generation
|
17
|
+
|
18
|
+
### Agent Steps
|
19
|
+
Best for tasks requiring precise tool control:
|
20
|
+
- Exact code refactoring operations
|
21
|
+
- Multi-file coordinated changes
|
22
|
+
- Specific tool usage requirements
|
23
|
+
- Performance-critical operations
|
24
|
+
|
25
|
+
## Workflow Structure
|
26
|
+
|
27
|
+
This example demonstrates a code refactoring workflow:
|
28
|
+
|
29
|
+
1. **identify_code_smells** (Regular Step)
|
30
|
+
- Analyzes code to identify issues
|
31
|
+
- Uses LLM judgment to prioritize problems
|
32
|
+
- Provides contextual explanations
|
33
|
+
|
34
|
+
2. **^apply_refactorings** (Agent Step)
|
35
|
+
- Executes precise refactoring operations
|
36
|
+
- Uses specific tools (Read, MultiEdit) directly
|
37
|
+
- Follows exact formatting requirements
|
38
|
+
- No interpretation needed - just execution
|
39
|
+
|
40
|
+
3. **summarize_improvements** (Regular Step)
|
41
|
+
- Reviews all changes made
|
42
|
+
- Generates human-friendly summary
|
43
|
+
- Provides recommendations
|
44
|
+
|
45
|
+
## Running the Workflow
|
46
|
+
|
47
|
+
```bash
|
48
|
+
# Run on all Ruby files in current directory
|
49
|
+
roast execute examples/agent_workflow/workflow.yml
|
50
|
+
|
51
|
+
# Run on specific files
|
52
|
+
roast execute examples/agent_workflow/workflow.yml app/models/*.rb
|
53
|
+
```
|
54
|
+
|
55
|
+
## Key Differences in Practice
|
56
|
+
|
57
|
+
### Regular Step Example
|
58
|
+
The `identify_code_smells` step benefits from LLM interpretation because:
|
59
|
+
- It needs to understand "code smells" in context
|
60
|
+
- It makes subjective judgments about code quality
|
61
|
+
- It prioritizes issues based on impact
|
62
|
+
|
63
|
+
### Agent Step Example
|
64
|
+
The `^apply_refactorings` step works better as an agent step because:
|
65
|
+
- It requires specific tool usage (MultiEdit, not Write)
|
66
|
+
- It needs exact preservation of formatting
|
67
|
+
- It follows precise refactoring patterns
|
68
|
+
- No interpretation is needed - just execution
|
69
|
+
|
70
|
+
## Benefits Demonstrated
|
71
|
+
|
72
|
+
1. **Complementary Strengths**: Regular steps handle analysis and planning, agent steps handle precise execution
|
73
|
+
2. **Better Performance**: Agent steps skip the LLM layer for well-defined tasks
|
74
|
+
3. **Predictable Results**: Agent steps execute exactly as specified
|
75
|
+
4. **Tool Control**: Agent steps can enforce specific tool usage patterns
|