roast-ai 0.1.6 → 0.2.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/.github/workflows/ci.yaml +1 -1
- data/CHANGELOG.md +48 -0
- data/CLAUDE.md +20 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +11 -6
- data/README.md +225 -13
- data/bin/roast +27 -0
- data/docs/INSTRUMENTATION.md +42 -1
- data/docs/ITERATION_SYNTAX.md +119 -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/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 +5 -1
- 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/openrouter_example/workflow.yml +2 -2
- 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/update_files.rb +413 -0
- data/lib/roast/tools.rb +12 -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 +165 -0
- data/lib/roast/workflow/base_step.rb +4 -24
- data/lib/roast/workflow/base_workflow.rb +76 -73
- 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 +96 -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_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 +85 -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/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 +205 -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 +154 -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 +117 -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 +3 -1
- data/schema/workflow.json +85 -0
- metadata +112 -4
@@ -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
|
@@ -0,0 +1,58 @@
|
|
1
|
+
name: Ruby Method Counter
|
2
|
+
tools:
|
3
|
+
- Roast::Tools::ReadFile
|
4
|
+
- Roast::Tools::Grep
|
5
|
+
- Roast::Tools::WriteFile
|
6
|
+
- Roast::Tools::CodingAgent
|
7
|
+
|
8
|
+
steps:
|
9
|
+
# Find all Ruby files in the specified directory
|
10
|
+
- find_ruby_files:
|
11
|
+
$(find lib/roast/workflow -type f -name "*.rb")
|
12
|
+
|
13
|
+
# Initialize a report object to store our results
|
14
|
+
- initialize_report:
|
15
|
+
$(echo '{"files_analyzed": 0, "total_methods": 0, "results": []}')
|
16
|
+
|
17
|
+
# Process each file found
|
18
|
+
- each: "{{output['find_ruby_files'].split('\n')}}"
|
19
|
+
as: "current_file"
|
20
|
+
steps:
|
21
|
+
# Read the file content
|
22
|
+
- read_file:
|
23
|
+
prompt: examples/iteration/prompts/analyze_file
|
24
|
+
model: claude-3-haiku-20240307
|
25
|
+
vars:
|
26
|
+
file_path: "{{ current_file }}"
|
27
|
+
|
28
|
+
# Update the report with the analysis result
|
29
|
+
- update_report:
|
30
|
+
prompt: examples/iteration/prompts/update_report
|
31
|
+
model: claude-3-haiku-20240307
|
32
|
+
vars:
|
33
|
+
file_path: "{{ current_file }}"
|
34
|
+
method_count: "{{ output['read_file']['method_count'] }}"
|
35
|
+
current_report: "{{ output['initialize_report'] }}"
|
36
|
+
|
37
|
+
# Generate the summary report after processing all files
|
38
|
+
- report_count:
|
39
|
+
$(echo "{{ output.initialize_report.files_analyzed }}")
|
40
|
+
|
41
|
+
# Repeat to generate the final summary - demonstrates the repeat construct
|
42
|
+
- repeat:
|
43
|
+
steps:
|
44
|
+
- generate_summary:
|
45
|
+
prompt: examples/iteration/prompts/generate_summary
|
46
|
+
model: claude-3-haiku-20240307
|
47
|
+
vars:
|
48
|
+
report_data: "{{ output['initialize_report'] }}"
|
49
|
+
until: "{{true}}"
|
50
|
+
max_iterations: 1
|
51
|
+
|
52
|
+
# Write the report to a file
|
53
|
+
- write_report:
|
54
|
+
prompt: examples/iteration/prompts/write_report
|
55
|
+
model: claude-3-haiku-20240307
|
56
|
+
vars:
|
57
|
+
report_data: "{{ output['initialize_report'] }}"
|
58
|
+
summary: "{{ output['generate_summary']['summary'] }}"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
I'll update the count of fixes that have been successfully applied.
|
2
|
+
|
3
|
+
Current fix count:
|
4
|
+
```
|
5
|
+
{{output.update_fix_count || 0}}
|
6
|
+
```
|
7
|
+
|
8
|
+
Verification result from the previous step:
|
9
|
+
```json
|
10
|
+
{{output.verify_fix}}
|
11
|
+
```
|
12
|
+
|
13
|
+
I'll increment the fix count if the verification was successful or partial, but not if it failed.
|
14
|
+
|
15
|
+
```javascript
|
16
|
+
let currentCount = parseInt({{output.update_fix_count || 0}});
|
17
|
+
let verificationStatus = "{{output.verify_fix.status}}";
|
18
|
+
|
19
|
+
if (verificationStatus === "success" || verificationStatus === "partial") {
|
20
|
+
currentCount += 1;
|
21
|
+
}
|
22
|
+
|
23
|
+
return { fixes_applied: currentCount };
|
24
|
+
```
|
25
|
+
|
26
|
+
This updated count will be used to determine whether we've met our target for the number of fixes to implement.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
I'll verify that the fix implemented in the previous step correctly addresses the identified issue.
|
2
|
+
|
3
|
+
Here are the details of the issue that was fixed:
|
4
|
+
```json
|
5
|
+
{{output.select_next_issue}}
|
6
|
+
```
|
7
|
+
|
8
|
+
And here is the implementation of the fix:
|
9
|
+
```json
|
10
|
+
{{output.implement_fix}}
|
11
|
+
```
|
12
|
+
|
13
|
+
Now I'll read the updated file to verify the changes:
|
14
|
+
```ruby
|
15
|
+
{{read_file(output.select_next_issue.file_path)}}
|
16
|
+
```
|
17
|
+
|
18
|
+
I'll evaluate the fix based on these criteria:
|
19
|
+
1. Does it fully address the identified issue?
|
20
|
+
2. Did it introduce any new issues or regressions?
|
21
|
+
3. Does it maintain the original functionality?
|
22
|
+
4. Does it follow Ruby best practices and style conventions?
|
23
|
+
5. Is it minimal and focused (changing only what was necessary)?
|
24
|
+
|
25
|
+
Based on this evaluation, I'll provide:
|
26
|
+
1. A verification status (success, partial, failure)
|
27
|
+
2. Detailed reasoning for the status
|
28
|
+
3. Any recommendations for further improvements or adjustments
|
29
|
+
4. An overall assessment of the code quality improvement
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Code Quality Analyzer
|
2
|
+
tools:
|
3
|
+
- Roast::Tools::ReadFile
|
4
|
+
- Roast::Tools::Grep
|
5
|
+
- Roast::Tools::WriteFile
|
6
|
+
- Roast::Tools::UpdateFiles
|
7
|
+
- Roast::Tools::CodingAgent
|
8
|
+
- Roast::Tools::Cmd
|
9
|
+
|
10
|
+
steps:
|
11
|
+
# Get all Ruby files from the target directory
|
12
|
+
- get_files_to_analyze:
|
13
|
+
$(find {{resource.target}} -name "*.rb" -not -path "*/vendor/*" | grep -v "test")
|
14
|
+
|
15
|
+
# Analyze each file and generate improvement recommendations
|
16
|
+
- each: "{{output['get_files_to_analyze'].split('\n')}}"
|
17
|
+
as: "current_file"
|
18
|
+
steps:
|
19
|
+
- read_file:
|
20
|
+
$(cat {{current_file}})
|
21
|
+
- analyze_complexity
|
22
|
+
- generate_recommendations
|
23
|
+
|
24
|
+
# After analyzing all files, sort issues by priority
|
25
|
+
- prioritize_issues
|
26
|
+
|
27
|
+
# Process the highest priority issues first, until we've addressed a sufficient number
|
28
|
+
# or reached our iteration limit
|
29
|
+
- initialize_fixes:
|
30
|
+
$(echo "0")
|
31
|
+
|
32
|
+
- repeat:
|
33
|
+
steps:
|
34
|
+
- select_next_issue
|
35
|
+
- implement_fix
|
36
|
+
- verify_fix
|
37
|
+
- update_fix_count
|
38
|
+
until: "{{output['update_fix_count']['fixes_applied'] >= 5 || output['select_next_issue']['no_issues_left'] == true}}"
|
39
|
+
max_iterations: 10
|
40
|
+
|
41
|
+
# Generate a summary report of all changes made
|
42
|
+
- generate_report
|
@@ -1,7 +1,7 @@
|
|
1
1
|
name: OpenRouter Example
|
2
2
|
api_provider: openrouter
|
3
3
|
api_token: $(echo $OPENROUTER_API_KEY)
|
4
|
-
model:
|
4
|
+
model: google/gemini-2.0-flash-001
|
5
5
|
|
6
6
|
tools:
|
7
7
|
- Roast::Tools::ReadFile
|
@@ -9,4 +9,4 @@ tools:
|
|
9
9
|
|
10
10
|
steps:
|
11
11
|
- analyze_input
|
12
|
-
- generate_response
|
12
|
+
- generate_response
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Workflow Generator
|
2
|
+
|
3
|
+
This workflow generates new Roast workflows based on user descriptions. It's the engine behind the "New from prompt" option in `roast init`.
|
4
|
+
|
5
|
+
## How It Works
|
6
|
+
|
7
|
+
The workflow generator takes a user description and workflow name, then:
|
8
|
+
|
9
|
+
1. **Analyzes the request** - Understands what type of workflow is needed, what steps are required, and what tools should be used
|
10
|
+
2. **Generates structure** - Creates a complete workflow configuration including YAML and step prompts
|
11
|
+
3. **Creates files** - Writes all the necessary files and directories to disk
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
This workflow is typically invoked automatically by the `roast init` command, but can also be run directly:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
# Run the generator workflow
|
19
|
+
roast execute examples/workflow_generator/workflow.yml
|
20
|
+
```
|
21
|
+
|
22
|
+
## Generated Output
|
23
|
+
|
24
|
+
The workflow creates a new directory with:
|
25
|
+
- `workflow.yml` - Main workflow configuration
|
26
|
+
- `step_name/prompt.md` - Individual step prompts
|
27
|
+
- `README.md` - Documentation for the generated workflow
|
@@ -0,0 +1,34 @@
|
|
1
|
+
You are an assistant that analyzes user requests to understand what kind of workflow they want to create.
|
2
|
+
|
3
|
+
Based on the user input from the previous step:
|
4
|
+
<%= workflow.output["get_user_input"] %>
|
5
|
+
|
6
|
+
Roast information from previous step:
|
7
|
+
<%= workflow.output["info_from_roast"] %>
|
8
|
+
|
9
|
+
First, explore existing workflow examples in the examples directory to understand common patterns and structures. Look for ones that may be related to the user's intention.
|
10
|
+
|
11
|
+
Then analyze the user's request and determine:
|
12
|
+
|
13
|
+
1. **Required Steps**: Break down the workflow into logical steps. Each step should be a discrete task that can be accomplished with an AI prompt.
|
14
|
+
|
15
|
+
2. **Tools Needed**: What Roast tools will be needed? Base this on the actual tools you read from info provided above.
|
16
|
+
|
17
|
+
3. **Target Strategy**: Will this workflow:
|
18
|
+
- Process specific files (needs target configuration)
|
19
|
+
- Be targetless (works without specific input files)
|
20
|
+
- Use shell commands to find targets dynamically
|
21
|
+
|
22
|
+
4. **Model Requirements**: Should this use a specific model, or is the default (gpt-4o-mini) sufficient?
|
23
|
+
|
24
|
+
Respond with a structured analysis in this format:
|
25
|
+
|
26
|
+
```
|
27
|
+
STEPS: [list of 3-5 logical steps]
|
28
|
+
TOOLS: [list of required tools]
|
29
|
+
TARGET_STRATEGY: [targetless/files/dynamic]
|
30
|
+
MODEL: [model recommendation]
|
31
|
+
COMPLEXITY: [simple/moderate/complex]
|
32
|
+
```
|
33
|
+
|
34
|
+
Be specific and actionable in your analysis.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
You are an assistant that creates the actual workflow files in the filesystem.
|
2
|
+
|
3
|
+
Based on the user input:
|
4
|
+
<%= workflow.output["get_user_input"] %>
|
5
|
+
|
6
|
+
And the generated workflow structure from the previous step:
|
7
|
+
<%= workflow.output["analyze_user_request"] %>
|
8
|
+
|
9
|
+
And info from roast:
|
10
|
+
<%= workflow.output["info_from_roast"] %>
|
11
|
+
|
12
|
+
Your task is to create all the necessary files and directories for the workflow.
|
13
|
+
|
14
|
+
Extract the workflow name from the user input JSON and create the workflow in the current directory under that folder name.
|
15
|
+
|
16
|
+
Steps to complete:
|
17
|
+
|
18
|
+
1. **Create the main directory**: Use Cmd to create the "{{ workflow_name }}" directory
|
19
|
+
2. **Create step directories**: Create subdirectories for each workflow step
|
20
|
+
3. **Create workflow.yml**: Write the main workflow configuration file
|
21
|
+
4. **Create step prompt files**: Write each step's prompt.md file
|
22
|
+
5. **Create README.md**: Generate a helpful README explaining the workflow
|
23
|
+
|
24
|
+
When writing files, extract the content from the structured response and write each file separately.
|
25
|
+
|
26
|
+
Important notes:
|
27
|
+
- Make sure all directories exist before writing files to them
|
28
|
+
- Follow the exact structure specified in the previous step
|
29
|
+
- Include helpful comments in the workflow.yml file
|
30
|
+
- Make the README.md informative and include usage instructions
|
31
|
+
|
32
|
+
At the end, confirm that all files have been created by listing the directory structure.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
You need to collect user input for generating a new workflow.
|
2
|
+
|
3
|
+
Step 1: Ask for the workflow description using ask_user tool with prompt: "What should your workflow do?"
|
4
|
+
|
5
|
+
Step 2: Ask for the workflow name using ask_user tool with prompt: "Enter workflow directory name:"
|
6
|
+
|
7
|
+
Step 3: Return the result in JSON format:
|
8
|
+
|
9
|
+
<json>
|
10
|
+
{
|
11
|
+
"user_description": "what the user wants the workflow to do",
|
12
|
+
"workflow_name": "directory_name_provided_by_user"
|
13
|
+
}
|
14
|
+
</json>
|