roast-ai 0.1.7 → 0.2.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 +1 -1
- data/CHANGELOG.md +49 -1
- data/CLAUDE.md +20 -0
- data/CLAUDE_NOTES.md +68 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +9 -6
- data/README.md +159 -26
- data/bin/roast +27 -0
- data/docs/ITERATION_SYNTAX.md +147 -0
- data/examples/case_when/README.md +58 -0
- data/examples/case_when/detect_language/prompt.md +16 -0
- data/examples/case_when/workflow.yml +58 -0
- data/examples/conditional/README.md +161 -0
- data/examples/conditional/check_condition/prompt.md +1 -0
- data/examples/conditional/simple_workflow.yml +15 -0
- data/examples/conditional/workflow.yml +23 -0
- data/examples/direct_coerce_syntax/README.md +32 -0
- data/examples/direct_coerce_syntax/workflow.yml +36 -0
- data/examples/dot_notation/README.md +37 -0
- data/examples/dot_notation/workflow.yml +44 -0
- data/examples/exit_on_error/README.md +50 -0
- data/examples/exit_on_error/analyze_lint_output/prompt.md +9 -0
- data/examples/exit_on_error/apply_fixes/prompt.md +2 -0
- data/examples/exit_on_error/workflow.yml +19 -0
- data/examples/grading/workflow.yml +10 -4
- data/examples/iteration/IMPLEMENTATION.md +88 -0
- data/examples/iteration/README.md +68 -0
- data/examples/iteration/analyze_complexity/prompt.md +22 -0
- data/examples/iteration/generate_recommendations/prompt.md +21 -0
- data/examples/iteration/generate_report/prompt.md +129 -0
- data/examples/iteration/implement_fix/prompt.md +25 -0
- data/examples/iteration/prioritize_issues/prompt.md +24 -0
- data/examples/iteration/prompts/analyze_file.md +28 -0
- data/examples/iteration/prompts/generate_summary.md +24 -0
- data/examples/iteration/prompts/update_report.md +29 -0
- data/examples/iteration/prompts/write_report.md +22 -0
- data/examples/iteration/read_file/prompt.md +9 -0
- data/examples/iteration/select_next_issue/prompt.md +25 -0
- data/examples/iteration/simple_workflow.md +39 -0
- data/examples/iteration/simple_workflow.yml +58 -0
- data/examples/iteration/update_fix_count/prompt.md +26 -0
- data/examples/iteration/verify_fix/prompt.md +29 -0
- data/examples/iteration/workflow.yml +42 -0
- data/examples/json_handling/README.md +32 -0
- data/examples/json_handling/workflow.yml +52 -0
- data/examples/openrouter_example/workflow.yml +2 -2
- data/examples/smart_coercion_defaults/README.md +65 -0
- data/examples/smart_coercion_defaults/workflow.yml +44 -0
- data/examples/step_configuration/README.md +87 -0
- data/examples/step_configuration/workflow.yml +60 -0
- data/examples/workflow_generator/README.md +27 -0
- data/examples/workflow_generator/analyze_user_request/prompt.md +34 -0
- data/examples/workflow_generator/create_workflow_files/prompt.md +32 -0
- data/examples/workflow_generator/get_user_input/prompt.md +14 -0
- data/examples/workflow_generator/info_from_roast.rb +22 -0
- data/examples/workflow_generator/workflow.yml +35 -0
- data/lib/roast/errors.rb +9 -0
- data/lib/roast/factories/api_provider_factory.rb +61 -0
- data/lib/roast/helpers/function_caching_interceptor.rb +1 -1
- data/lib/roast/helpers/minitest_coverage_runner.rb +1 -1
- data/lib/roast/helpers/prompt_loader.rb +50 -1
- data/lib/roast/resources/base_resource.rb +7 -0
- data/lib/roast/resources.rb +6 -6
- data/lib/roast/tools/ask_user.rb +40 -0
- data/lib/roast/tools/cmd.rb +1 -1
- data/lib/roast/tools/search_file.rb +1 -1
- data/lib/roast/tools.rb +11 -1
- data/lib/roast/value_objects/api_token.rb +49 -0
- data/lib/roast/value_objects/step_name.rb +39 -0
- data/lib/roast/value_objects/workflow_path.rb +77 -0
- data/lib/roast/value_objects.rb +5 -0
- data/lib/roast/version.rb +1 -1
- data/lib/roast/workflow/api_configuration.rb +61 -0
- data/lib/roast/workflow/base_iteration_step.rb +184 -0
- data/lib/roast/workflow/base_step.rb +44 -27
- data/lib/roast/workflow/base_workflow.rb +76 -73
- data/lib/roast/workflow/case_executor.rb +49 -0
- data/lib/roast/workflow/case_step.rb +82 -0
- data/lib/roast/workflow/command_executor.rb +88 -0
- data/lib/roast/workflow/conditional_executor.rb +50 -0
- data/lib/roast/workflow/conditional_step.rb +59 -0
- data/lib/roast/workflow/configuration.rb +35 -158
- data/lib/roast/workflow/configuration_loader.rb +78 -0
- data/lib/roast/workflow/configuration_parser.rb +13 -248
- data/lib/roast/workflow/context_path_resolver.rb +43 -0
- data/lib/roast/workflow/dot_access_hash.rb +198 -0
- data/lib/roast/workflow/each_step.rb +86 -0
- data/lib/roast/workflow/error_handler.rb +97 -0
- data/lib/roast/workflow/expression_evaluator.rb +78 -0
- data/lib/roast/workflow/expression_utils.rb +36 -0
- data/lib/roast/workflow/file_state_repository.rb +3 -2
- data/lib/roast/workflow/interpolator.rb +34 -0
- data/lib/roast/workflow/iteration_executor.rb +103 -0
- data/lib/roast/workflow/llm_boolean_coercer.rb +55 -0
- data/lib/roast/workflow/output_handler.rb +35 -0
- data/lib/roast/workflow/output_manager.rb +77 -0
- data/lib/roast/workflow/parallel_executor.rb +49 -0
- data/lib/roast/workflow/prompt_step.rb +4 -1
- data/lib/roast/workflow/repeat_step.rb +75 -0
- data/lib/roast/workflow/replay_handler.rb +123 -0
- data/lib/roast/workflow/resource_resolver.rb +77 -0
- data/lib/roast/workflow/session_manager.rb +6 -2
- data/lib/roast/workflow/state_manager.rb +97 -0
- data/lib/roast/workflow/step_executor_coordinator.rb +221 -0
- data/lib/roast/workflow/step_executor_factory.rb +47 -0
- data/lib/roast/workflow/step_executor_registry.rb +79 -0
- data/lib/roast/workflow/step_executors/base_step_executor.rb +23 -0
- data/lib/roast/workflow/step_executors/hash_step_executor.rb +43 -0
- data/lib/roast/workflow/step_executors/parallel_step_executor.rb +54 -0
- data/lib/roast/workflow/step_executors/string_step_executor.rb +29 -0
- data/lib/roast/workflow/step_finder.rb +97 -0
- data/lib/roast/workflow/step_loader.rb +155 -0
- data/lib/roast/workflow/step_orchestrator.rb +45 -0
- data/lib/roast/workflow/step_runner.rb +23 -0
- data/lib/roast/workflow/step_type_resolver.rb +133 -0
- data/lib/roast/workflow/workflow_context.rb +60 -0
- data/lib/roast/workflow/workflow_executor.rb +90 -209
- data/lib/roast/workflow/workflow_initializer.rb +112 -0
- data/lib/roast/workflow/workflow_runner.rb +87 -0
- data/lib/roast/workflow.rb +3 -0
- data/lib/roast.rb +96 -3
- data/roast.gemspec +2 -1
- data/schema/workflow.json +112 -0
- metadata +112 -4
@@ -0,0 +1,19 @@
|
|
1
|
+
name: Linting with Error Recovery
|
2
|
+
tools:
|
3
|
+
- Roast::Tools::ReadFile
|
4
|
+
- Roast::Tools::WriteFile
|
5
|
+
- Roast::Tools::CodingAgent
|
6
|
+
|
7
|
+
steps:
|
8
|
+
# Run linter on the file - may fail if there are syntax errors
|
9
|
+
- lint_check: $(rubocop {{file}})
|
10
|
+
|
11
|
+
# Analyze linter output and fix issues even if linter failed
|
12
|
+
- analyze_lint_output
|
13
|
+
|
14
|
+
# Apply fixes based on the analysis
|
15
|
+
- apply_fixes
|
16
|
+
|
17
|
+
# Step configuration
|
18
|
+
lint_check:
|
19
|
+
exit_on_error: false # Continue even if rubocop exits with non-zero status
|
@@ -1,10 +1,14 @@
|
|
1
|
-
name: Grading
|
1
|
+
name: Test Grading
|
2
|
+
api_token: $(echo $OPENAI_API_KEY)
|
3
|
+
# model: anthropic:claude-opus-4
|
4
|
+
model: gpt-4.1-mini
|
2
5
|
|
3
6
|
tools:
|
4
7
|
- Roast::Tools::Grep
|
5
8
|
- Roast::Tools::ReadFile
|
6
9
|
- Roast::Tools::SearchFile
|
7
10
|
|
11
|
+
# Uncomment this to run the workflow on modified tests automatically
|
8
12
|
# each: '% cd $(git rev-parse --show-toplevel) && git status --porcelain | grep "_test\.rb" | cut -c4- | xargs realpath'
|
9
13
|
|
10
14
|
steps:
|
@@ -21,17 +25,19 @@ steps:
|
|
21
25
|
|
22
26
|
# set non-default attributes for steps below
|
23
27
|
analyze_coverage:
|
24
|
-
model: gpt-4.1-mini
|
28
|
+
# model: gpt-4.1-mini
|
25
29
|
auto_loop: false
|
26
30
|
json: true
|
27
31
|
|
28
32
|
generate_grades:
|
29
|
-
model: o3
|
33
|
+
# model: o3
|
30
34
|
json: true
|
31
35
|
|
32
36
|
generate_recommendations:
|
33
|
-
model: o3
|
37
|
+
# model: o3
|
34
38
|
auto_loop: false
|
35
39
|
json: true
|
36
40
|
params:
|
37
41
|
max_completion_tokens: 5_000
|
42
|
+
|
43
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# Iteration Mechanisms Implementation
|
2
|
+
|
3
|
+
This document provides an overview of how the iteration mechanisms are implemented in Roast.
|
4
|
+
|
5
|
+
## Core Components
|
6
|
+
|
7
|
+
### 1. Schema Extensions
|
8
|
+
|
9
|
+
The workflow schema has been extended to support two new iteration constructs:
|
10
|
+
|
11
|
+
- **Repeat** - For conditional repetition until a condition is met
|
12
|
+
- **Each** - For iterating over collections with a variable binding
|
13
|
+
|
14
|
+
These schema extensions define the structure and validation rules for the iteration YAML syntax.
|
15
|
+
|
16
|
+
### 2. Step Classes
|
17
|
+
|
18
|
+
Two new step classes handle the actual iteration logic:
|
19
|
+
|
20
|
+
- **RepeatStep** - Executes steps repeatedly until a condition is met or a maximum iteration count is reached
|
21
|
+
- **EachStep** - Iterates over a collection, binding each item to a variable, and executes steps for each item
|
22
|
+
|
23
|
+
Both inherit from a common `BaseIterationStep` class that provides shared functionality.
|
24
|
+
|
25
|
+
### 3. Pattern Matching
|
26
|
+
|
27
|
+
The `WorkflowExecutor` has been enhanced with pattern matching to recognize the `repeat` and `each` keywords and dispatch to the appropriate step classes:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
case name
|
31
|
+
when "repeat"
|
32
|
+
execute_repeat_step(command)
|
33
|
+
when "each"
|
34
|
+
# Handle 'each' step with its special format
|
35
|
+
execute_each_step(step)
|
36
|
+
else
|
37
|
+
# Handle regular steps
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
### 4. State Management
|
42
|
+
|
43
|
+
Both iteration types include state management to:
|
44
|
+
|
45
|
+
- Track current iteration number
|
46
|
+
- Save state after each iteration
|
47
|
+
- Support resumption after failures
|
48
|
+
- Provide safety limits against infinite loops
|
49
|
+
|
50
|
+
## Iteration Flow
|
51
|
+
|
52
|
+
### RepeatStep Flow
|
53
|
+
|
54
|
+
1. Start with iteration count = 0
|
55
|
+
2. Execute the nested steps in sequence
|
56
|
+
3. Evaluate the until condition
|
57
|
+
4. If condition is true or max_iterations is reached, stop
|
58
|
+
5. Otherwise, increment iteration count and go back to step 2
|
59
|
+
6. Return the results of all iterations
|
60
|
+
|
61
|
+
### EachStep Flow
|
62
|
+
|
63
|
+
1. Resolve the collection expression
|
64
|
+
2. For each item in the collection:
|
65
|
+
a. Set the named variable (accessible in steps through a getter method)
|
66
|
+
b. Execute the nested steps
|
67
|
+
c. Save state
|
68
|
+
3. Return the results from all iterations
|
69
|
+
|
70
|
+
## Safety Mechanisms
|
71
|
+
|
72
|
+
- **max_iterations** parameter prevents infinite loops
|
73
|
+
- State is saved after each iteration for resumption capability
|
74
|
+
- Robust error handling during condition evaluation and step execution
|
75
|
+
- Collection type checking ensures iterable objects
|
76
|
+
|
77
|
+
## Usage Examples
|
78
|
+
|
79
|
+
The workflow.yml and step files in this directory demonstrate practical applications of these iteration mechanisms for code quality analysis.
|
80
|
+
|
81
|
+
## Integration with Existing Workflow Engine
|
82
|
+
|
83
|
+
The iteration mechanism integrates seamlessly with the existing workflow engine:
|
84
|
+
|
85
|
+
- Uses the same state persistence mechanisms
|
86
|
+
- Follows the same execution models
|
87
|
+
- Maintains compatibility with all existing steps
|
88
|
+
- Supports interpolation within iteration constructs
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Code Quality Analysis Workflow
|
2
|
+
|
3
|
+
This example demonstrates the use of Roast's iteration features to analyze and improve code quality across a codebase.
|
4
|
+
|
5
|
+
## What it does
|
6
|
+
|
7
|
+
1. Collects Ruby files from the codebase for analysis
|
8
|
+
2. Analyzes each file for complexity, code smells, and potential improvements
|
9
|
+
3. Generates recommendations for each file
|
10
|
+
4. Prioritizes the identified issues by impact and difficulty
|
11
|
+
5. Automatically implements fixes for the highest-priority issues
|
12
|
+
6. Verifies each fix before moving to the next one
|
13
|
+
7. Continues until either 5 fixes have been applied or all issues are addressed
|
14
|
+
8. Generates a summary report of changes made
|
15
|
+
|
16
|
+
## Iteration Features Demonstrated
|
17
|
+
|
18
|
+
### Collection Iteration with `each`
|
19
|
+
|
20
|
+
The workflow uses the `each` construct to iterate through Ruby files:
|
21
|
+
|
22
|
+
```yaml
|
23
|
+
- each: "output['get_files_to_analyze'].split('\n')"
|
24
|
+
as: "current_file"
|
25
|
+
steps:
|
26
|
+
- read_file
|
27
|
+
- analyze_complexity
|
28
|
+
- generate_recommendations
|
29
|
+
```
|
30
|
+
|
31
|
+
This makes the current file available as `current_file` in each step, allowing the analysis steps to process each file individually.
|
32
|
+
|
33
|
+
### Conditional Repetition with `repeat`
|
34
|
+
|
35
|
+
The workflow uses the `repeat` construct to iteratively fix issues until a condition is met:
|
36
|
+
|
37
|
+
```yaml
|
38
|
+
- repeat:
|
39
|
+
steps:
|
40
|
+
- select_next_issue
|
41
|
+
- implement_fix
|
42
|
+
- verify_fix
|
43
|
+
- update_fix_count
|
44
|
+
until: "output['update_fix_count']['fixes_applied'] >= 5 || output['select_next_issue']['no_issues_left'] == true"
|
45
|
+
max_iterations: 10
|
46
|
+
```
|
47
|
+
|
48
|
+
This continues applying fixes until either:
|
49
|
+
- 5 fixes have been successfully applied
|
50
|
+
- No more issues remain to be fixed
|
51
|
+
- The maximum of 10 iterations is reached (safety limit)
|
52
|
+
|
53
|
+
## Running the Example
|
54
|
+
|
55
|
+
To run this workflow:
|
56
|
+
|
57
|
+
```bash
|
58
|
+
roast run examples/iteration/workflow.yml --target=/path/to/your/project
|
59
|
+
```
|
60
|
+
|
61
|
+
The workflow will analyze the Ruby files in your project, suggest improvements, and apply the highest-priority fixes.
|
62
|
+
|
63
|
+
## Customizing
|
64
|
+
|
65
|
+
- Adjust the file selection criteria in `get_files_to_analyze`
|
66
|
+
- Modify the analysis criteria in `analyze_complexity`
|
67
|
+
- Change the fix limit in the `until` condition
|
68
|
+
- Set a different `max_iterations` value to control the maximum number of fixes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
I'll analyze the code complexity of the file {{current_file}}, which I've read in the previous step.
|
2
|
+
|
3
|
+
I'll examine the following aspects:
|
4
|
+
1. Cyclomatic complexity (number of decision paths)
|
5
|
+
2. Method length and complexity
|
6
|
+
3. Class size and responsibilities
|
7
|
+
4. Code smells (long parameter lists, deeply nested blocks, etc.)
|
8
|
+
5. Potential performance bottlenecks
|
9
|
+
6. Opportunities for refactoring
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
{{output.read_file}}
|
13
|
+
```
|
14
|
+
|
15
|
+
Based on this analysis, I'll provide a structured assessment of the code quality issues found.
|
16
|
+
|
17
|
+
For each issue identified, I'll assign:
|
18
|
+
- Severity (high, medium, low)
|
19
|
+
- Type (complexity, maintainability, performance, style)
|
20
|
+
- Location (line numbers, method/class names)
|
21
|
+
- Brief description of the issue
|
22
|
+
- Suggested improvement
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Based on the analysis of complexity for file {{current_file}}, I'll generate specific recommendations for improving code quality.
|
2
|
+
|
3
|
+
I'll use the complexity analysis from the previous step:
|
4
|
+
```json
|
5
|
+
{{output.analyze_complexity}}
|
6
|
+
```
|
7
|
+
|
8
|
+
For each identified issue, I'll provide detailed, actionable recommendations including:
|
9
|
+
|
10
|
+
1. What specific changes should be made
|
11
|
+
2. How the change improves the code
|
12
|
+
3. Sample code snippets demonstrating the improvement
|
13
|
+
4. An estimate of effort required (low, medium, high)
|
14
|
+
5. Priority level for implementation
|
15
|
+
|
16
|
+
I'll organize these recommendations to address:
|
17
|
+
- Most critical issues first
|
18
|
+
- Quick wins that provide significant value for minimal effort
|
19
|
+
- Long-term architectural improvements
|
20
|
+
|
21
|
+
My recommendations will follow Ruby best practices, adhere to common style guides, and consider maintainability, readability, and performance.
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# Code Quality Improvement Report
|
2
|
+
|
3
|
+
## Summary of Analysis and Improvements
|
4
|
+
|
5
|
+
I've analyzed {{output.get_files_to_analyze.split('\n').length}} Ruby files for code quality issues and made targeted improvements.
|
6
|
+
|
7
|
+
### Files Analyzed
|
8
|
+
|
9
|
+
```
|
10
|
+
{{output.get_files_to_analyze}}
|
11
|
+
```
|
12
|
+
|
13
|
+
### Issues Identified
|
14
|
+
|
15
|
+
Total issues identified: {{output.prioritize_issues.total_issues}}
|
16
|
+
|
17
|
+
Issues by severity:
|
18
|
+
- High: {{output.prioritize_issues.high_severity || 0}}
|
19
|
+
- Medium: {{output.prioritize_issues.medium_severity || 0}}
|
20
|
+
- Low: {{output.prioritize_issues.low_severity || 0}}
|
21
|
+
|
22
|
+
Issues by type:
|
23
|
+
- Complexity: {{output.prioritize_issues.complexity_issues || 0}}
|
24
|
+
- Maintainability: {{output.prioritize_issues.maintainability_issues || 0}}
|
25
|
+
- Performance: {{output.prioritize_issues.performance_issues || 0}}
|
26
|
+
- Style: {{output.prioritize_issues.style_issues || 0}}
|
27
|
+
|
28
|
+
### Improvements Made
|
29
|
+
|
30
|
+
Number of fixes applied: {{output.update_fix_count.fixes_applied || 0}}
|
31
|
+
|
32
|
+
{{#if output.update_fix_count.fixes_applied > 0}}
|
33
|
+
Fixes by type:
|
34
|
+
{{#each output.fix_summary}}
|
35
|
+
- {{this.type}}: {{this.count}} ({{this.percentage}}% of total)
|
36
|
+
{{/each}}
|
37
|
+
|
38
|
+
Top files improved:
|
39
|
+
{{#each output.file_improvements}}
|
40
|
+
- {{this.file}}: {{this.issues_fixed}} issues fixed
|
41
|
+
{{/each}}
|
42
|
+
{{else}}
|
43
|
+
No fixes were applied during this run.
|
44
|
+
{{/if}}
|
45
|
+
|
46
|
+
## Detailed Fix List
|
47
|
+
|
48
|
+
{{#if output.update_fix_count.fixes_applied > 0}}
|
49
|
+
{{#each output.fixes_applied}}
|
50
|
+
### Fix #{{@index + 1}}: {{this.issue.type}} in {{this.issue.file_path}}
|
51
|
+
|
52
|
+
**Issue**: {{this.issue.description}}
|
53
|
+
**Location**: {{this.issue.location}}
|
54
|
+
**Severity**: {{this.issue.severity}}
|
55
|
+
|
56
|
+
**Solution Applied**: {{this.fix_description}}
|
57
|
+
|
58
|
+
```diff
|
59
|
+
{{this.diff}}
|
60
|
+
```
|
61
|
+
|
62
|
+
**Verification**: {{#if this.verification.success}}✅ Successful{{else}}❌ Failed: {{this.verification.reason}}{{/if}}
|
63
|
+
|
64
|
+
{{/each}}
|
65
|
+
{{else}}
|
66
|
+
No fixes were applied during this run.
|
67
|
+
{{/if}}
|
68
|
+
|
69
|
+
## Recommendations for Future Improvements
|
70
|
+
|
71
|
+
Based on the remaining issues, here are the top recommendations for improving code quality:
|
72
|
+
|
73
|
+
{{#each output.top_recommendations}}
|
74
|
+
{{@index + 1}}. **{{this.title}}**
|
75
|
+
{{this.description}}
|
76
|
+
Affected files: {{this.affected_files}}
|
77
|
+
{{/each}}
|
78
|
+
|
79
|
+
## Conclusion
|
80
|
+
|
81
|
+
This automated code quality improvement run has {{#if output.update_fix_count.fixes_applied > 0}}successfully addressed {{output.update_fix_count.fixes_applied}} issues{{else}}identified issues but did not apply any fixes{{/if}}. The remaining issues should be reviewed and addressed as part of ongoing code maintenance.
|
82
|
+
|
83
|
+
I'll generate a comprehensive summary report of all the code quality improvements made during this workflow.
|
84
|
+
|
85
|
+
Total number of fixes applied:
|
86
|
+
```
|
87
|
+
{{output.update_fix_count.fixes_applied || 0}}
|
88
|
+
```
|
89
|
+
|
90
|
+
I'll analyze the following data to create the report:
|
91
|
+
1. Original list of issues identified:
|
92
|
+
```json
|
93
|
+
{{output.prioritize_issues}}
|
94
|
+
```
|
95
|
+
|
96
|
+
2. Issues that were addressed:
|
97
|
+
```json
|
98
|
+
{{outputs_of.select_next_issue}}
|
99
|
+
```
|
100
|
+
|
101
|
+
3. Implementation and verification details:
|
102
|
+
```json
|
103
|
+
{{outputs_of.implement_fix}}
|
104
|
+
{{outputs_of.verify_fix}}
|
105
|
+
```
|
106
|
+
|
107
|
+
The report will include:
|
108
|
+
|
109
|
+
1. **Executive Summary**
|
110
|
+
- Total files analyzed
|
111
|
+
- Total issues identified
|
112
|
+
- Issues fixed vs. remaining
|
113
|
+
- Most common issue types
|
114
|
+
|
115
|
+
2. **Detailed Analysis by File**
|
116
|
+
- Issues fixed per file
|
117
|
+
- Before/after code quality assessment
|
118
|
+
|
119
|
+
3. **Implementation Details**
|
120
|
+
- Description of each fix
|
121
|
+
- Impact on code quality
|
122
|
+
- Verification results
|
123
|
+
|
124
|
+
4. **Recommendations**
|
125
|
+
- Remaining high-priority issues
|
126
|
+
- Suggested next steps
|
127
|
+
- Long-term code quality improvement suggestions
|
128
|
+
|
129
|
+
This report provides a comprehensive overview of the code quality improvements made and serves as documentation for the changes implemented.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
I'll implement the fix for the issue selected in the previous step.
|
2
|
+
|
3
|
+
Here is the issue to fix:
|
4
|
+
```json
|
5
|
+
{{output.select_next_issue}}
|
6
|
+
```
|
7
|
+
|
8
|
+
First, I'll read the current file content to understand the context:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
{{read_file(output.select_next_issue.file_path)}}
|
12
|
+
```
|
13
|
+
|
14
|
+
Based on the issue description and the recommended changes, I'll implement a fix that:
|
15
|
+
1. Addresses the specific issue identified
|
16
|
+
2. Follows Ruby best practices and style conventions
|
17
|
+
3. Is minimal and focused (changes only what's necessary)
|
18
|
+
4. Maintains or improves the existing functionality
|
19
|
+
|
20
|
+
I'll use the update_files tool to apply the changes. For each change, I'll provide:
|
21
|
+
1. The file path
|
22
|
+
2. The changes to make
|
23
|
+
3. A detailed explanation of what was changed and why
|
24
|
+
|
25
|
+
After implementing the fix, I'll return a summary of the changes made.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
I'll analyze all the recommendations I've generated across multiple files and prioritize them according to:
|
2
|
+
|
3
|
+
1. Severity of the issues
|
4
|
+
2. Complexity of implementation
|
5
|
+
3. Impact on code quality and maintainability
|
6
|
+
4. Dependencies between issues
|
7
|
+
|
8
|
+
Let me review all the recommendations collected so far:
|
9
|
+
|
10
|
+
```json
|
11
|
+
{{outputs_of.generate_recommendations}}
|
12
|
+
```
|
13
|
+
|
14
|
+
I'll create a comprehensive prioritized list of all issues across files, combining similar issues where appropriate. The prioritized list will include:
|
15
|
+
|
16
|
+
1. Issue ID
|
17
|
+
2. File path
|
18
|
+
3. Issue description
|
19
|
+
4. Severity (High, Medium, Low)
|
20
|
+
5. Implementation difficulty (Easy, Medium, Hard)
|
21
|
+
6. Priority score (calculated from severity and difficulty)
|
22
|
+
7. Dependencies (if any)
|
23
|
+
|
24
|
+
This prioritized list will guide our approach to addressing the most important issues first, while being mindful of dependencies between issues.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Ruby File Method Analysis
|
2
|
+
|
3
|
+
You are a code analyzer focusing on analyzing Ruby files to count the number of methods defined.
|
4
|
+
|
5
|
+
## Input
|
6
|
+
- File path: {{ file_path }}
|
7
|
+
- File content:
|
8
|
+
```ruby
|
9
|
+
{{ tools.read_file.content(file_path) }}
|
10
|
+
```
|
11
|
+
|
12
|
+
## Task
|
13
|
+
1. Analyze the Ruby file content
|
14
|
+
2. Count the number of methods defined in the file (including class methods, instance methods, and module methods)
|
15
|
+
3. Return a JSON object with:
|
16
|
+
- file_name: The basename of the file
|
17
|
+
- method_count: The number of methods found
|
18
|
+
- method_names: An array of method names found in the file
|
19
|
+
|
20
|
+
## Response Format
|
21
|
+
Return a JSON object with the following structure:
|
22
|
+
```json
|
23
|
+
{
|
24
|
+
"file_name": "base_step.rb",
|
25
|
+
"method_count": 5,
|
26
|
+
"method_names": ["initialize", "call", "validate", "execute", "helper_method"]
|
27
|
+
}
|
28
|
+
```
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Generate Method Analysis Summary
|
2
|
+
|
3
|
+
You are a report generator responsible for summarizing the method analysis results.
|
4
|
+
|
5
|
+
## Input
|
6
|
+
- Report data: {{ report_data }}
|
7
|
+
|
8
|
+
## Task
|
9
|
+
1. Parse the report data as JSON
|
10
|
+
2. Create a summary of the analysis results including:
|
11
|
+
- Total number of files analyzed
|
12
|
+
- Total number of methods found
|
13
|
+
- Average number of methods per file
|
14
|
+
- File with the most methods
|
15
|
+
- File with the fewest methods
|
16
|
+
3. Generate a formatted summary text
|
17
|
+
|
18
|
+
## Response Format
|
19
|
+
Return a JSON object with the following structure:
|
20
|
+
```json
|
21
|
+
{
|
22
|
+
"summary": "## Ruby Method Analysis Summary\n\nAnalyzed 10 Ruby files in the workflow directory.\n- Total methods found: 45\n- Average methods per file: 4.5\n- Most methods: base_workflow.rb (12 methods)\n- Fewest methods: state_repository.rb (1 method)\n\n### Top 3 Files by Method Count\n1. base_workflow.rb: 12 methods\n2. configuration.rb: 8 methods\n3. workflow_executor.rb: 7 methods\n"
|
23
|
+
}
|
24
|
+
```
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Update Method Count Report
|
2
|
+
|
3
|
+
You are a data updater responsible for adding analysis results to a report.
|
4
|
+
|
5
|
+
## Input
|
6
|
+
- File path: {{ file_path }}
|
7
|
+
- Method count: {{ method_count }}
|
8
|
+
- Current report data: {{ current_report }}
|
9
|
+
|
10
|
+
## Task
|
11
|
+
1. Parse the current report data as JSON
|
12
|
+
2. Add the new file analysis results to the report's "results" array
|
13
|
+
3. Increment the "files_analyzed" counter by 1
|
14
|
+
4. Add the method count to the "total_methods" counter
|
15
|
+
5. Return the updated JSON report
|
16
|
+
|
17
|
+
## Response Format
|
18
|
+
Return a JSON object with the updated report structure:
|
19
|
+
```json
|
20
|
+
{
|
21
|
+
"files_analyzed": 10,
|
22
|
+
"total_methods": 45,
|
23
|
+
"results": [
|
24
|
+
{"file_path": "file1.rb", "method_count": 5, "method_names": ["method1", "method2", ...]},
|
25
|
+
{"file_path": "file2.rb", "method_count": 3, "method_names": ["methodA", "methodB", ...]},
|
26
|
+
...
|
27
|
+
]
|
28
|
+
}
|
29
|
+
```
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Write Method Analysis Report
|
2
|
+
|
3
|
+
You are responsible for creating a formatted report file based on the analysis results.
|
4
|
+
|
5
|
+
## Input
|
6
|
+
- Report data: {{ report_data }}
|
7
|
+
- Summary: {{ summary }}
|
8
|
+
|
9
|
+
## Task
|
10
|
+
1. Generate a Markdown report that includes:
|
11
|
+
- The summary information
|
12
|
+
- A detailed table of all files analyzed, with their method counts and method names
|
13
|
+
2. Format the report in a clean, readable manner
|
14
|
+
|
15
|
+
## Response Format
|
16
|
+
Return a JSON object with the following structure:
|
17
|
+
```json
|
18
|
+
{
|
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
|
+
"report_file_path": "method_analysis_report.md"
|
21
|
+
}
|
22
|
+
```
|
@@ -0,0 +1,25 @@
|
|
1
|
+
I'll select the next highest priority issue to fix from our prioritized list.
|
2
|
+
|
3
|
+
Here is the current prioritized list of issues:
|
4
|
+
```json
|
5
|
+
{{output.prioritize_issues}}
|
6
|
+
```
|
7
|
+
|
8
|
+
And here is the count of fixes we've already applied:
|
9
|
+
```
|
10
|
+
{{output.update_fix_count || '0'}}
|
11
|
+
```
|
12
|
+
|
13
|
+
I'll select the highest priority issue that hasn't yet been addressed. I'll consider:
|
14
|
+
|
15
|
+
1. The priority score from our previous analysis
|
16
|
+
2. Dependencies between issues (ensuring prerequisites are addressed first)
|
17
|
+
3. Logical grouping (addressing related issues in the same file together)
|
18
|
+
|
19
|
+
If there are no issues left to fix, I'll indicate this with `{"no_issues_left": true}`.
|
20
|
+
|
21
|
+
For the selected issue, I'll return:
|
22
|
+
1. The issue details
|
23
|
+
2. The file path to modify
|
24
|
+
3. A clear description of the changes needed
|
25
|
+
4. Any context needed for implementation
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Simple Iteration Workflow Example
|
2
|
+
|
3
|
+
This example demonstrates how to use both the `each` and `repeat` iteration constructs in Roast workflows.
|
4
|
+
|
5
|
+
## Workflow Description
|
6
|
+
|
7
|
+
The workflow analyzes Ruby files in the `lib/roast/workflow` directory and counts the number of methods defined in each file. The process follows these steps:
|
8
|
+
|
9
|
+
1. Find all Ruby files in the specified directory
|
10
|
+
2. Initialize a report object to store our results
|
11
|
+
3. Process each file found:
|
12
|
+
- Read the file content
|
13
|
+
- Count the methods defined
|
14
|
+
- Update the report with the analysis result
|
15
|
+
4. Generate a summary report
|
16
|
+
5. Write the report to a file
|
17
|
+
|
18
|
+
## Key Components
|
19
|
+
|
20
|
+
- `each` construct: Processes every Ruby file found in the directory
|
21
|
+
- `repeat` construct: Used to generate the final summary (demonstrates a simple case of the repeat construct)
|
22
|
+
- Both block-level and prompt-based steps
|
23
|
+
|
24
|
+
## Running the Workflow
|
25
|
+
|
26
|
+
To run this workflow, use the following command:
|
27
|
+
|
28
|
+
```bash
|
29
|
+
shadowenv exec -- bundle exec roast examples/iteration/simple_workflow.yml
|
30
|
+
```
|
31
|
+
|
32
|
+
The final report will be saved to a markdown file as specified in the output of the `write_report` step.
|
33
|
+
|
34
|
+
## Learning Objectives
|
35
|
+
|
36
|
+
- Understand how to use the `each` construct to iterate over a collection
|
37
|
+
- Understand how to use the `repeat` construct for conditional repetition
|
38
|
+
- Learn how to build and update data structures across workflow steps
|
39
|
+
- See how to pass data between steps in an iteration workflow
|