roast-ai 0.3.1 → 0.4.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +20 -0
- data/CLAUDE.md +52 -1
- data/Gemfile +3 -1
- data/Gemfile.lock +63 -16
- data/README.md +90 -5
- data/bin/roast +1 -1
- data/claude-swarm.yml +210 -0
- data/docs/AGENT_STEPS.md +264 -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.yml +16 -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.yml +32 -0
- data/examples/available_tools_demo/write_summary/prompt.md +6 -0
- data/examples/case_when/detect_language/prompt.md +2 -2
- data/examples/grading/run_coverage.rb +0 -2
- 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/mcp/README.md +3 -3
- data/examples/mcp/analyze_changes/prompt.md +1 -1
- data/examples/mcp/database_workflow.yml +1 -1
- data/examples/mcp/fetch_pr_context/prompt.md +1 -1
- data/examples/mcp/github_workflow.yml +1 -1
- data/examples/mcp/post_review/prompt.md +1 -1
- 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/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.yml +26 -0
- data/examples/user_input/generate_summary/prompt.md +11 -0
- data/examples/user_input/simple_input_demo/workflow.yml +35 -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.yml +73 -0
- data/examples/workflow_generator/create_workflow_files/prompt.md +1 -1
- 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/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/tools/ask_user.rb +0 -2
- data/lib/roast/tools/bash.rb +0 -3
- data/lib/roast/tools/cmd.rb +0 -3
- data/lib/roast/tools/coding_agent.rb +1 -8
- 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/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 +26 -0
- data/lib/roast/workflow/api_configuration.rb +0 -4
- data/lib/roast/workflow/base_iteration_step.rb +0 -4
- data/lib/roast/workflow/base_step.rb +54 -28
- data/lib/roast/workflow/base_workflow.rb +2 -21
- 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 +3 -66
- data/lib/roast/workflow/configuration_loader.rb +0 -2
- data/lib/roast/workflow/configuration_parser.rb +1 -7
- data/lib/roast/workflow/dot_access_hash.rb +16 -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 +0 -2
- data/lib/roast/workflow/output_manager.rb +0 -2
- data/lib/roast/workflow/replay_handler.rb +0 -3
- data/lib/roast/workflow/resource_resolver.rb +0 -3
- data/lib/roast/workflow/session_manager.rb +0 -3
- data/lib/roast/workflow/state_manager.rb +0 -2
- data/lib/roast/workflow/step_executor_coordinator.rb +34 -11
- 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_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 +30 -16
- data/lib/roast/workflow/step_orchestrator.rb +3 -2
- data/lib/roast/workflow/step_type_resolver.rb +28 -1
- data/lib/roast/workflow/validator.rb +0 -4
- data/lib/roast/workflow/workflow_executor.rb +0 -16
- data/lib/roast/workflow/workflow_initializer.rb +1 -8
- data/lib/roast/workflow/workflow_runner.rb +0 -7
- data/lib/roast/workflow.rb +0 -15
- data/lib/roast.rb +55 -10
- data/roast.gemspec +2 -1
- data/schema/workflow.json +46 -0
- metadata +43 -6
- data/lib/roast/helpers.rb +0 -12
data/docs/AGENT_STEPS.md
ADDED
@@ -0,0 +1,264 @@
|
|
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
|
+
## When to Use Agent Steps
|
23
|
+
|
24
|
+
### Use Agent Steps When:
|
25
|
+
|
26
|
+
1. **You need precise control over tool usage**
|
27
|
+
- When you want to ensure specific tools are used in a particular way
|
28
|
+
- When the task requires exact file manipulations or code transformations
|
29
|
+
|
30
|
+
2. **Complex multi-file operations**
|
31
|
+
- When coordinating changes across multiple files
|
32
|
+
- When the operation requires specific sequencing of edits
|
33
|
+
|
34
|
+
3. **Performance optimization**
|
35
|
+
- When you want to skip the LLM interpretation layer
|
36
|
+
- For well-defined tasks that don't need additional context
|
37
|
+
|
38
|
+
### Use Regular Steps When:
|
39
|
+
|
40
|
+
1. **You need natural language processing**
|
41
|
+
- When the prompt benefits from LLM interpretation
|
42
|
+
- When you want the LLM to add context or reasoning
|
43
|
+
|
44
|
+
2. **Flexible, adaptive responses**
|
45
|
+
- When the exact approach might vary based on context
|
46
|
+
- When you want the LLM to make judgment calls
|
47
|
+
|
48
|
+
## Practical Examples
|
49
|
+
|
50
|
+
### Example 1: Database Migration
|
51
|
+
|
52
|
+
**Regular Step (analyze_migration/prompt.md):**
|
53
|
+
```markdown
|
54
|
+
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.
|
55
|
+
```
|
56
|
+
|
57
|
+
This benefits from LLM interpretation because:
|
58
|
+
- It needs to understand "best practices" in context
|
59
|
+
- It should make judgments about schema design
|
60
|
+
- The approach varies based on the specific features
|
61
|
+
|
62
|
+
**Agent Step (^apply_migration/prompt.md):**
|
63
|
+
```markdown
|
64
|
+
Create a new migration file with the following specifications:
|
65
|
+
|
66
|
+
1. Use MultiEdit to create file: db/migrate/{{timestamp}}_add_user_preferences.rb
|
67
|
+
2. The migration must include:
|
68
|
+
- Add column :users, :preferences, :jsonb, default: {}
|
69
|
+
- Add index :users, :preferences, using: :gin
|
70
|
+
- Add column :users, :notification_settings, :jsonb, default: {}
|
71
|
+
3. Ensure proper up/down methods
|
72
|
+
4. Follow Rails migration conventions exactly
|
73
|
+
|
74
|
+
Required tools: MultiEdit
|
75
|
+
Do not use Write tool for migrations.
|
76
|
+
```
|
77
|
+
|
78
|
+
This is better as an agent step because:
|
79
|
+
- It requires specific tool usage (MultiEdit, not Write)
|
80
|
+
- The instructions are precise and technical
|
81
|
+
- No interpretation needed - just execution
|
82
|
+
|
83
|
+
### Example 2: Code Refactoring
|
84
|
+
|
85
|
+
**Regular Step (identify_code_smells/prompt.md):**
|
86
|
+
```markdown
|
87
|
+
Review the provided code and identify any code smells or anti-patterns. Consider things like:
|
88
|
+
- Long methods that do too much
|
89
|
+
- Duplicated code
|
90
|
+
- Poor naming
|
91
|
+
- Tight coupling
|
92
|
+
- Missing abstractions
|
93
|
+
|
94
|
+
Explain why each identified issue is problematic.
|
95
|
+
```
|
96
|
+
|
97
|
+
This works well as a regular step because it requires judgment and explanation.
|
98
|
+
|
99
|
+
**Agent Step (^extract_method/prompt.md):**
|
100
|
+
```markdown
|
101
|
+
Extract the authentication logic from UserController#create into a separate method:
|
102
|
+
|
103
|
+
1. Read file: app/controllers/user_controller.rb
|
104
|
+
2. Find the code block from line 15-28 (the authentication logic)
|
105
|
+
3. Create a new private method called `authenticate_user_params`
|
106
|
+
4. Move the authentication logic to this new method
|
107
|
+
5. Replace the original code with a call to the new method
|
108
|
+
6. Ensure all variables are properly passed
|
109
|
+
|
110
|
+
Use MultiEdit to make all changes in a single operation.
|
111
|
+
Preserve exact indentation and formatting.
|
112
|
+
```
|
113
|
+
|
114
|
+
This is ideal as an agent step because:
|
115
|
+
- Specific line numbers and method names
|
116
|
+
- Exact refactoring instructions
|
117
|
+
- No room for interpretation
|
118
|
+
|
119
|
+
### Example 3: Test Generation
|
120
|
+
|
121
|
+
**Regular Step (plan_test_coverage/prompt.md):**
|
122
|
+
```markdown
|
123
|
+
Analyze the {{file}} and determine what test cases would provide comprehensive coverage. Consider:
|
124
|
+
- Happy path scenarios
|
125
|
+
- Edge cases
|
126
|
+
- Error conditions
|
127
|
+
- Boundary values
|
128
|
+
|
129
|
+
Focus on behavior, not implementation details.
|
130
|
+
```
|
131
|
+
|
132
|
+
**Agent Step (^implement_tests/prompt.md):**
|
133
|
+
```markdown
|
134
|
+
Create test file: test/models/user_validator_test.rb
|
135
|
+
|
136
|
+
Implement exactly these test cases:
|
137
|
+
1. test "validates email format"
|
138
|
+
- Use valid emails: ["user@example.com", "test.user+tag@domain.co.uk"]
|
139
|
+
- Use invalid emails: ["invalid", "@example.com", "user@", "user space@example.com"]
|
140
|
+
|
141
|
+
2. test "validates age is positive integer"
|
142
|
+
- Valid: [18, 25, 100]
|
143
|
+
- Invalid: [-1, 0, 17, 101, "twenty", nil]
|
144
|
+
|
145
|
+
3. test "validates username uniqueness"
|
146
|
+
- Create user with username "testuser"
|
147
|
+
- Attempt to create second user with same username
|
148
|
+
- Assert validation error on :username
|
149
|
+
|
150
|
+
Use minitest assertion style.
|
151
|
+
Each test must be independent.
|
152
|
+
Use setup method for common test data.
|
153
|
+
```
|
154
|
+
|
155
|
+
### Example 4: API Integration
|
156
|
+
|
157
|
+
**Regular Step (design_api_client/prompt.md):**
|
158
|
+
```markdown
|
159
|
+
Design a client for the {{api_name}} API that follows Ruby best practices. Consider:
|
160
|
+
- Error handling strategies
|
161
|
+
- Rate limiting
|
162
|
+
- Authentication patterns
|
163
|
+
- Response parsing
|
164
|
+
- Testing approach
|
165
|
+
|
166
|
+
Suggest an architecture that will be maintainable and extensible.
|
167
|
+
```
|
168
|
+
|
169
|
+
**Agent Step (^implement_api_client/prompt.md):**
|
170
|
+
```markdown
|
171
|
+
Implement the API client with this exact structure:
|
172
|
+
|
173
|
+
1. Create file: lib/external_apis/weather_api/client.rb
|
174
|
+
```ruby
|
175
|
+
module ExternalApis
|
176
|
+
module WeatherApi
|
177
|
+
class Client
|
178
|
+
include HTTParty
|
179
|
+
base_uri 'https://api.weather.com/v1'
|
180
|
+
|
181
|
+
def initialize(api_key)
|
182
|
+
@api_key = api_key
|
183
|
+
@options = { headers: { 'Authorization' => "Bearer #{api_key}" } }
|
184
|
+
end
|
185
|
+
|
186
|
+
def current_weather(location)
|
187
|
+
response = self.class.get("/current", @options.merge(query: { location: location }))
|
188
|
+
handle_response(response)
|
189
|
+
end
|
190
|
+
|
191
|
+
private
|
192
|
+
|
193
|
+
def handle_response(response)
|
194
|
+
raise ApiError, response.message unless response.success?
|
195
|
+
response.parsed_response
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
```
|
201
|
+
|
202
|
+
2. Create file: lib/external_apis/weather_api/api_error.rb
|
203
|
+
Define custom exception class
|
204
|
+
|
205
|
+
3. Update file: config/initializers/weather_api.rb
|
206
|
+
Add configuration for API endpoint and timeout
|
207
|
+
|
208
|
+
Use exact module structure and method signatures shown.
|
209
|
+
```
|
210
|
+
|
211
|
+
## Best Practices
|
212
|
+
|
213
|
+
1. **Be explicit about tool usage in agent steps**
|
214
|
+
```markdown
|
215
|
+
# Good agent step
|
216
|
+
Use MultiEdit tool to update the following files:
|
217
|
+
- app/models/user.rb: Add validation
|
218
|
+
- test/models/user_test.rb: Add test case
|
219
|
+
|
220
|
+
# Avoid in agent steps
|
221
|
+
Update the user model with better validation
|
222
|
+
```
|
223
|
+
|
224
|
+
2. **Include specific line numbers or code markers when possible**
|
225
|
+
```markdown
|
226
|
+
# Good agent step
|
227
|
+
In app/controllers/application_controller.rb:
|
228
|
+
- Find method `authenticate_user!` (around line 45)
|
229
|
+
- Add the following before the redirect_to call:
|
230
|
+
session[:return_to] = request.fullpath
|
231
|
+
```
|
232
|
+
|
233
|
+
3. **Specify exact formatting requirements**
|
234
|
+
```markdown
|
235
|
+
# Good agent step
|
236
|
+
Create method with exactly this signature:
|
237
|
+
def calculate_tax(amount, rate = 0.08)
|
238
|
+
|
239
|
+
Ensure:
|
240
|
+
- Two-space indentation
|
241
|
+
- No trailing whitespace
|
242
|
+
- Blank line before method definition
|
243
|
+
```
|
244
|
+
|
245
|
+
4. **Chain agent steps for complex operations**
|
246
|
+
```yaml
|
247
|
+
steps:
|
248
|
+
# First understand the system
|
249
|
+
- analyze_current_architecture
|
250
|
+
|
251
|
+
# Then execute precise changes
|
252
|
+
- ^create_service_objects
|
253
|
+
- ^update_controllers
|
254
|
+
- ^add_test_coverage
|
255
|
+
|
256
|
+
# Finally verify
|
257
|
+
- verify_all_tests_pass
|
258
|
+
```
|
259
|
+
|
260
|
+
## Summary
|
261
|
+
|
262
|
+
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.
|
263
|
+
|
264
|
+
Choose agent steps when precision matters more than interpretation. Choose regular steps when context and judgment are important.
|
@@ -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
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Based on the code smells identified in the previous step, apply the following refactorings:
|
2
|
+
|
3
|
+
For each file that needs changes:
|
4
|
+
|
5
|
+
1. Use the Read tool to examine the current implementation
|
6
|
+
2. Use MultiEdit to apply all refactorings in a single operation per file
|
7
|
+
3. Ensure all changes maintain exact formatting and indentation
|
8
|
+
4. Focus on these specific refactorings:
|
9
|
+
- Extract long methods (>15 lines) into smaller, focused methods
|
10
|
+
- Replace magic numbers with named constants
|
11
|
+
- Rename variables/methods that don't clearly express intent
|
12
|
+
- Extract duplicate code into shared methods
|
13
|
+
- Add proper error handling where missing
|
14
|
+
|
15
|
+
Important constraints:
|
16
|
+
- DO NOT change the public API of any class
|
17
|
+
- DO NOT modify test files
|
18
|
+
- DO NOT add comments unless replacing unclear code
|
19
|
+
- Preserve all existing functionality
|
20
|
+
- Use Ruby idioms and conventions
|
21
|
+
|
22
|
+
After each file modification, verify the changes maintain the original behavior.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Analyze the provided Ruby code and identify potential code smells or areas for improvement. Consider:
|
2
|
+
|
3
|
+
1. Method complexity and length
|
4
|
+
2. Duplicated code patterns
|
5
|
+
3. Poor naming conventions
|
6
|
+
4. Tight coupling between classes
|
7
|
+
5. Missing abstractions or violated SOLID principles
|
8
|
+
6. Performance anti-patterns
|
9
|
+
|
10
|
+
For each issue found, explain:
|
11
|
+
- What the problem is
|
12
|
+
- Why it's problematic
|
13
|
+
- A general approach to fix it
|
14
|
+
|
15
|
+
Focus on the most impactful improvements that would enhance code maintainability and readability.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Review the refactorings that were applied and provide a comprehensive summary that includes:
|
2
|
+
|
3
|
+
1. **Overview of Changes**
|
4
|
+
- Number of files modified
|
5
|
+
- Types of refactorings applied
|
6
|
+
- Overall impact on code quality
|
7
|
+
|
8
|
+
2. **Key Improvements**
|
9
|
+
- Most significant refactorings and their benefits
|
10
|
+
- Complexity reductions achieved
|
11
|
+
- Readability enhancements
|
12
|
+
|
13
|
+
3. **Recommendations for Future**
|
14
|
+
- Any remaining code smells that require larger architectural changes
|
15
|
+
- Suggested next steps for continued improvement
|
16
|
+
- Areas that would benefit from additional test coverage
|
17
|
+
|
18
|
+
Format the summary in a way that would be useful for a code review or team discussion.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
description: Example workflow demonstrating agent steps
|
2
|
+
|
3
|
+
# Agent steps send prompts directly to CodingAgent (e.g., Claude Code)
|
4
|
+
# without the intermediate LLM translation layer
|
5
|
+
|
6
|
+
target: "**/*.rb"
|
7
|
+
|
8
|
+
steps:
|
9
|
+
# Regular step - goes through LLM first for analysis and judgment
|
10
|
+
- identify_code_smells
|
11
|
+
|
12
|
+
# Agent step - direct to CodingAgent for precise refactoring
|
13
|
+
- ^apply_refactorings
|
14
|
+
|
15
|
+
# Regular step - verify changes and provide summary
|
16
|
+
- summarize_improvements
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Available Tools Demo
|
2
|
+
|
3
|
+
This example demonstrates the `available_tools` feature in Roast, which allows you to restrict which tools are available to specific steps in your workflow.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
The workflow consists of three steps, each with different tool access:
|
8
|
+
|
9
|
+
1. **explore_directory**: Can only use `pwd` and `ls` commands
|
10
|
+
2. **analyze_files**: Can only use `grep` and `read_file` tools
|
11
|
+
3. **write_summary**: Can only use `write_file` and `echo` tools
|
12
|
+
|
13
|
+
## Key Features Demonstrated
|
14
|
+
|
15
|
+
### Security Through Least Privilege
|
16
|
+
Each step only has access to the tools it needs. For example, the exploration step cannot write files, and the summary step cannot read files or explore directories.
|
17
|
+
|
18
|
+
### Tool Name Convention
|
19
|
+
- For built-in tools: Use snake_case names (e.g., `read_file` for `Roast::Tools::ReadFile`)
|
20
|
+
- For Cmd tool: Use the specific command names (e.g., `pwd`, `ls`)
|
21
|
+
|
22
|
+
### Configuration Structure
|
23
|
+
```yaml
|
24
|
+
step_name:
|
25
|
+
available_tools:
|
26
|
+
- tool1
|
27
|
+
- tool2
|
28
|
+
```
|
29
|
+
|
30
|
+
## Running the Example
|
31
|
+
|
32
|
+
```bash
|
33
|
+
roast examples/available_tools_demo/workflow.yml
|
34
|
+
```
|
35
|
+
|
36
|
+
## What Happens
|
37
|
+
|
38
|
+
1. The first step explores the current directory using only `pwd` and `ls`
|
39
|
+
2. The second step searches for Ruby files and reads one using only `grep` and `read_file`
|
40
|
+
3. The final step creates a summary file using only `write_file` and `echo`
|
41
|
+
|
42
|
+
Each step is restricted to its specified tools, demonstrating how you can create secure, focused workflows where each step has exactly the capabilities it needs.
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Based on the directory listing from the previous step, your task is to:
|
2
|
+
|
3
|
+
1. Search for any Ruby files using grep
|
4
|
+
2. Read the contents of the first Ruby file you find
|
5
|
+
|
6
|
+
Note: You only have access to the `grep` and `read_file` tools for this step. You cannot use commands like `ls` or `pwd`.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
model: anthropic:claude-opus-4
|
2
|
+
|
3
|
+
tools:
|
4
|
+
- Roast::Tools::Grep
|
5
|
+
- Roast::Tools::ReadFile
|
6
|
+
- Roast::Tools::WriteFile
|
7
|
+
- Roast::Tools::Cmd:
|
8
|
+
allowed_commands:
|
9
|
+
- pwd
|
10
|
+
- ls
|
11
|
+
- echo
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- explore_directory
|
15
|
+
- analyze_files
|
16
|
+
- write_summary
|
17
|
+
|
18
|
+
# Step-level tool configuration
|
19
|
+
explore_directory:
|
20
|
+
available_tools:
|
21
|
+
- pwd
|
22
|
+
- ls
|
23
|
+
|
24
|
+
analyze_files:
|
25
|
+
available_tools:
|
26
|
+
- grep
|
27
|
+
- read_file
|
28
|
+
|
29
|
+
write_summary:
|
30
|
+
available_tools:
|
31
|
+
- write_file
|
32
|
+
- echo
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Based on your exploration and analysis, create a summary:
|
2
|
+
|
3
|
+
1. Write a brief summary of what you found to a file called `summary.txt`
|
4
|
+
2. Echo a completion message
|
5
|
+
|
6
|
+
Note: You only have access to the `write_file` and `echo` tools for this step. You cannot read files or use other commands.
|
@@ -9,8 +9,8 @@ Based on the file extension and content, determine the primary programming langu
|
|
9
9
|
|
10
10
|
Return ONLY the language name in lowercase, nothing else.
|
11
11
|
|
12
|
-
File:
|
12
|
+
File: <%= context.resource_uri %>
|
13
13
|
Content:
|
14
14
|
```
|
15
|
-
|
15
|
+
<%= context.resource %>
|
16
16
|
```
|
@@ -1,4 +1,4 @@
|
|
1
|
-
I'll analyze the code complexity of the file
|
1
|
+
I'll analyze the code complexity of the file <%= current_file %>, which I've read in the previous step.
|
2
2
|
|
3
3
|
I'll examine the following aspects:
|
4
4
|
1. Cyclomatic complexity (number of decision paths)
|
@@ -9,7 +9,7 @@ I'll examine the following aspects:
|
|
9
9
|
6. Opportunities for refactoring
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
|
12
|
+
<%= output.read_file %>
|
13
13
|
```
|
14
14
|
|
15
15
|
Based on this analysis, I'll provide a structured assessment of the code quality issues found.
|
@@ -1,8 +1,8 @@
|
|
1
|
-
Based on the analysis of complexity for file
|
1
|
+
Based on the analysis of complexity for file <%= current_file %>, I'll generate specific recommendations for improving code quality.
|
2
2
|
|
3
3
|
I'll use the complexity analysis from the previous step:
|
4
4
|
```json
|
5
|
-
|
5
|
+
<%= output.analyze_complexity %>
|
6
6
|
```
|
7
7
|
|
8
8
|
For each identified issue, I'll provide detailed, actionable recommendations including:
|
@@ -2,13 +2,13 @@ I'll implement the fix for the issue selected in the previous step.
|
|
2
2
|
|
3
3
|
Here is the issue to fix:
|
4
4
|
```json
|
5
|
-
|
5
|
+
<%= output.select_next_issue %>
|
6
6
|
```
|
7
7
|
|
8
8
|
First, I'll read the current file content to understand the context:
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
|
11
|
+
<%= read_file(output.select_next_issue.file_path) %>
|
12
12
|
```
|
13
13
|
|
14
14
|
Based on the issue description and the recommended changes, I'll implement a fix that:
|
@@ -8,7 +8,7 @@ I'll analyze all the recommendations I've generated across multiple files and pr
|
|
8
8
|
Let me review all the recommendations collected so far:
|
9
9
|
|
10
10
|
```json
|
11
|
-
|
11
|
+
<%= outputs_of.generate_recommendations %>
|
12
12
|
```
|
13
13
|
|
14
14
|
I'll create a comprehensive prioritized list of all issues across files, combining similar issues where appropriate. The prioritized list will include:
|
@@ -3,10 +3,10 @@
|
|
3
3
|
You are a code analyzer focusing on analyzing Ruby files to count the number of methods defined.
|
4
4
|
|
5
5
|
## Input
|
6
|
-
- File path:
|
6
|
+
- File path: <%= file_path %>
|
7
7
|
- File content:
|
8
8
|
```ruby
|
9
|
-
|
9
|
+
<%= read_file(file_path) %>
|
10
10
|
```
|
11
11
|
|
12
12
|
## Task
|
@@ -3,9 +3,9 @@
|
|
3
3
|
You are a data updater responsible for adding analysis results to a report.
|
4
4
|
|
5
5
|
## Input
|
6
|
-
- File path:
|
7
|
-
- Method count:
|
8
|
-
- Current report data:
|
6
|
+
- File path: <%= file_path %>
|
7
|
+
- Method count: <%= method_count %>
|
8
|
+
- Current report data: <%= current_report %>
|
9
9
|
|
10
10
|
## Task
|
11
11
|
1. Parse the current report data as JSON
|
@@ -3,8 +3,8 @@
|
|
3
3
|
You are responsible for creating a formatted report file based on the analysis results.
|
4
4
|
|
5
5
|
## Input
|
6
|
-
- Report data:
|
7
|
-
- Summary:
|
6
|
+
- Report data: <%= report_data %>
|
7
|
+
- Summary: <%= summary %>
|
8
8
|
|
9
9
|
## Task
|
10
10
|
1. Generate a Markdown report that includes:
|
@@ -16,7 +16,7 @@ You are responsible for creating a formatted report file based on the analysis r
|
|
16
16
|
Return a JSON object with the following structure:
|
17
17
|
```json
|
18
18
|
{
|
19
|
-
"report_content": "# Ruby Method Analysis Report\n\n
|
19
|
+
"report_content": "# Ruby Method Analysis Report\n\n<%= summary %>\n\n## Detailed Results\n\n| File | Method Count | Methods |\n|------|--------------|--------|\n| file1.rb | 5 | method1, method2, ... |\n| file2.rb | 3 | methodA, methodB, ... |\n...",
|
20
20
|
"report_file_path": "method_analysis_report.md"
|
21
21
|
}
|
22
22
|
```
|
@@ -1,9 +1,9 @@
|
|
1
|
-
I'll analyze the Ruby file at:
|
1
|
+
I'll analyze the Ruby file at: <%= current_file %>
|
2
2
|
|
3
3
|
First, let me read the content of this file.
|
4
4
|
|
5
5
|
```ruby
|
6
|
-
|
6
|
+
<%= read_file(current_file) %>
|
7
7
|
```
|
8
8
|
|
9
9
|
I'll store this content for further analysis in the next steps.
|
@@ -2,12 +2,12 @@ I'll select the next highest priority issue to fix from our prioritized list.
|
|
2
2
|
|
3
3
|
Here is the current prioritized list of issues:
|
4
4
|
```json
|
5
|
-
|
5
|
+
<%= output.prioritize_issues %>
|
6
6
|
```
|
7
7
|
|
8
8
|
And here is the count of fixes we've already applied:
|
9
9
|
```
|
10
|
-
|
10
|
+
<%= output.update_fix_count || '0' %>
|
11
11
|
```
|
12
12
|
|
13
13
|
I'll select the highest priority issue that hasn't yet been addressed. I'll consider:
|