roast-ai 0.1.7 → 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.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +1 -1
  3. data/CHANGELOG.md +40 -1
  4. data/CLAUDE.md +20 -0
  5. data/Gemfile +1 -0
  6. data/Gemfile.lock +9 -6
  7. data/README.md +81 -14
  8. data/bin/roast +27 -0
  9. data/docs/ITERATION_SYNTAX.md +119 -0
  10. data/examples/conditional/README.md +161 -0
  11. data/examples/conditional/check_condition/prompt.md +1 -0
  12. data/examples/conditional/simple_workflow.yml +15 -0
  13. data/examples/conditional/workflow.yml +23 -0
  14. data/examples/dot_notation/README.md +37 -0
  15. data/examples/dot_notation/workflow.yml +44 -0
  16. data/examples/exit_on_error/README.md +50 -0
  17. data/examples/exit_on_error/analyze_lint_output/prompt.md +9 -0
  18. data/examples/exit_on_error/apply_fixes/prompt.md +2 -0
  19. data/examples/exit_on_error/workflow.yml +19 -0
  20. data/examples/grading/workflow.yml +5 -1
  21. data/examples/iteration/IMPLEMENTATION.md +88 -0
  22. data/examples/iteration/README.md +68 -0
  23. data/examples/iteration/analyze_complexity/prompt.md +22 -0
  24. data/examples/iteration/generate_recommendations/prompt.md +21 -0
  25. data/examples/iteration/generate_report/prompt.md +129 -0
  26. data/examples/iteration/implement_fix/prompt.md +25 -0
  27. data/examples/iteration/prioritize_issues/prompt.md +24 -0
  28. data/examples/iteration/prompts/analyze_file.md +28 -0
  29. data/examples/iteration/prompts/generate_summary.md +24 -0
  30. data/examples/iteration/prompts/update_report.md +29 -0
  31. data/examples/iteration/prompts/write_report.md +22 -0
  32. data/examples/iteration/read_file/prompt.md +9 -0
  33. data/examples/iteration/select_next_issue/prompt.md +25 -0
  34. data/examples/iteration/simple_workflow.md +39 -0
  35. data/examples/iteration/simple_workflow.yml +58 -0
  36. data/examples/iteration/update_fix_count/prompt.md +26 -0
  37. data/examples/iteration/verify_fix/prompt.md +29 -0
  38. data/examples/iteration/workflow.yml +42 -0
  39. data/examples/openrouter_example/workflow.yml +2 -2
  40. data/examples/workflow_generator/README.md +27 -0
  41. data/examples/workflow_generator/analyze_user_request/prompt.md +34 -0
  42. data/examples/workflow_generator/create_workflow_files/prompt.md +32 -0
  43. data/examples/workflow_generator/get_user_input/prompt.md +14 -0
  44. data/examples/workflow_generator/info_from_roast.rb +22 -0
  45. data/examples/workflow_generator/workflow.yml +35 -0
  46. data/lib/roast/errors.rb +9 -0
  47. data/lib/roast/factories/api_provider_factory.rb +61 -0
  48. data/lib/roast/helpers/function_caching_interceptor.rb +1 -1
  49. data/lib/roast/helpers/minitest_coverage_runner.rb +1 -1
  50. data/lib/roast/helpers/prompt_loader.rb +50 -1
  51. data/lib/roast/resources/base_resource.rb +7 -0
  52. data/lib/roast/resources.rb +6 -6
  53. data/lib/roast/tools/ask_user.rb +40 -0
  54. data/lib/roast/tools/cmd.rb +1 -1
  55. data/lib/roast/tools/search_file.rb +1 -1
  56. data/lib/roast/tools.rb +11 -1
  57. data/lib/roast/value_objects/api_token.rb +49 -0
  58. data/lib/roast/value_objects/step_name.rb +39 -0
  59. data/lib/roast/value_objects/workflow_path.rb +77 -0
  60. data/lib/roast/value_objects.rb +5 -0
  61. data/lib/roast/version.rb +1 -1
  62. data/lib/roast/workflow/api_configuration.rb +61 -0
  63. data/lib/roast/workflow/base_iteration_step.rb +165 -0
  64. data/lib/roast/workflow/base_step.rb +4 -24
  65. data/lib/roast/workflow/base_workflow.rb +76 -73
  66. data/lib/roast/workflow/command_executor.rb +88 -0
  67. data/lib/roast/workflow/conditional_executor.rb +50 -0
  68. data/lib/roast/workflow/conditional_step.rb +96 -0
  69. data/lib/roast/workflow/configuration.rb +35 -158
  70. data/lib/roast/workflow/configuration_loader.rb +78 -0
  71. data/lib/roast/workflow/configuration_parser.rb +13 -248
  72. data/lib/roast/workflow/context_path_resolver.rb +43 -0
  73. data/lib/roast/workflow/dot_access_hash.rb +198 -0
  74. data/lib/roast/workflow/each_step.rb +86 -0
  75. data/lib/roast/workflow/error_handler.rb +97 -0
  76. data/lib/roast/workflow/expression_utils.rb +36 -0
  77. data/lib/roast/workflow/file_state_repository.rb +3 -2
  78. data/lib/roast/workflow/interpolator.rb +34 -0
  79. data/lib/roast/workflow/iteration_executor.rb +85 -0
  80. data/lib/roast/workflow/llm_boolean_coercer.rb +55 -0
  81. data/lib/roast/workflow/output_handler.rb +35 -0
  82. data/lib/roast/workflow/output_manager.rb +77 -0
  83. data/lib/roast/workflow/parallel_executor.rb +49 -0
  84. data/lib/roast/workflow/repeat_step.rb +75 -0
  85. data/lib/roast/workflow/replay_handler.rb +123 -0
  86. data/lib/roast/workflow/resource_resolver.rb +77 -0
  87. data/lib/roast/workflow/session_manager.rb +6 -2
  88. data/lib/roast/workflow/state_manager.rb +97 -0
  89. data/lib/roast/workflow/step_executor_coordinator.rb +205 -0
  90. data/lib/roast/workflow/step_executor_factory.rb +47 -0
  91. data/lib/roast/workflow/step_executor_registry.rb +79 -0
  92. data/lib/roast/workflow/step_executors/base_step_executor.rb +23 -0
  93. data/lib/roast/workflow/step_executors/hash_step_executor.rb +43 -0
  94. data/lib/roast/workflow/step_executors/parallel_step_executor.rb +54 -0
  95. data/lib/roast/workflow/step_executors/string_step_executor.rb +29 -0
  96. data/lib/roast/workflow/step_finder.rb +97 -0
  97. data/lib/roast/workflow/step_loader.rb +154 -0
  98. data/lib/roast/workflow/step_orchestrator.rb +45 -0
  99. data/lib/roast/workflow/step_runner.rb +23 -0
  100. data/lib/roast/workflow/step_type_resolver.rb +117 -0
  101. data/lib/roast/workflow/workflow_context.rb +60 -0
  102. data/lib/roast/workflow/workflow_executor.rb +90 -209
  103. data/lib/roast/workflow/workflow_initializer.rb +112 -0
  104. data/lib/roast/workflow/workflow_runner.rb +87 -0
  105. data/lib/roast/workflow.rb +3 -0
  106. data/lib/roast.rb +96 -3
  107. data/roast.gemspec +2 -1
  108. data/schema/workflow.json +85 -0
  109. metadata +97 -4
@@ -0,0 +1,15 @@
1
+ name: Simple Conditional Test
2
+ tools: []
3
+
4
+ steps:
5
+ - set_value: "$(echo 'true')"
6
+
7
+ - if: "{{output.set_value.strip == 'true'}}"
8
+ then:
9
+ - success: "$(echo 'If condition worked!')"
10
+ else:
11
+ - failure: "$(echo 'If condition failed!')"
12
+
13
+ - unless: "{{output.set_value.strip == 'false'}}"
14
+ then:
15
+ - unless_success: "$(echo 'Unless condition worked!')"
@@ -0,0 +1,23 @@
1
+ name: Conditional Execution Example
2
+ tools:
3
+ - Roast::Tools::Cmd
4
+
5
+ steps:
6
+ - check_os: "$(uname -s)"
7
+
8
+ - if: "{{output.check_os.strip == 'Darwin'}}"
9
+ then:
10
+ - mac_message: "$(echo 'Running on macOS!')"
11
+ - mac_info: "$(sw_vers)"
12
+ else:
13
+ - linux_message: "$(echo 'Running on Linux!')"
14
+ - linux_info: "$(lsb_release -a)"
15
+
16
+ - check_file: "$(test -f /tmp/roast_test.txt && echo exists || echo missing)"
17
+
18
+ - unless: "{{output.check_file.strip == 'exists'}}"
19
+ then:
20
+ - create_file: "$(touch /tmp/roast_test.txt && echo 'File created')"
21
+
22
+ - verify_file: "$(ls -la /tmp/roast_test.txt)"
23
+ - cleanup: "$(rm -f /tmp/roast_test.txt)"
@@ -0,0 +1,37 @@
1
+ # Dot Notation Access Example
2
+
3
+ This example demonstrates the new dot notation access feature for workflow outputs.
4
+
5
+ ## Usage
6
+
7
+ With the new dot notation feature, you can access output values using Ruby's method syntax instead of hash syntax:
8
+
9
+ ### Before (hash syntax):
10
+ ```yaml
11
+ until: "output[:update_fix_count][:fixes_applied] >= 5 || output[:select_next_issue][:no_issues_left] == true"
12
+ ```
13
+
14
+ ### After (dot notation):
15
+ ```yaml
16
+ until: "output.update_fix_count.fixes_applied >= 5 || output.select_next_issue.no_issues_left?"
17
+ ```
18
+
19
+ ### Even cleaner (omitting output prefix):
20
+ ```yaml
21
+ until: "update_fix_count.fixes_applied >= 5 || select_next_issue.no_issues_left?"
22
+ ```
23
+
24
+ ## Features
25
+
26
+ 1. **Nested access**: `output.step_name.nested.value`
27
+ 2. **Boolean predicates**: `output.step_name.is_complete?` returns false for nil/false values
28
+ 3. **Direct access**: Omit the `output.` prefix for cleaner syntax
29
+ 4. **Backward compatible**: Hash syntax still works (`output[:step_name][:value]`)
30
+
31
+ ## Example Workflow
32
+
33
+ See `workflow.yml` for a complete example that demonstrates:
34
+ - Setting values in output
35
+ - Using dot notation in conditions
36
+ - Boolean predicate methods
37
+ - Nested value access
@@ -0,0 +1,44 @@
1
+ name: dot_notation_example
2
+ description: Example demonstrating dot notation access for workflow outputs
3
+
4
+ steps:
5
+ initialize:
6
+ prompt: |
7
+ Initialize the workflow with some sample data.
8
+
9
+ Set output.counter to 0
10
+ Set output.config.max_iterations to 5
11
+ Set output.config.enabled to true
12
+
13
+ process_items:
14
+ repeat:
15
+ # Using dot notation in conditions
16
+ until: "counter >= config.max_iterations || !config.enabled?"
17
+ steps:
18
+ - increment_counter
19
+ - check_status
20
+
21
+ increment_counter:
22
+ prompt: |
23
+ Increment the counter by 1.
24
+ Current counter value: {{counter}}
25
+
26
+ Set output.counter to {{counter}} + 1
27
+
28
+ check_status:
29
+ prompt: |
30
+ Check if we should continue processing.
31
+
32
+ Current counter: {{counter}}
33
+ Max iterations: {{config.max_iterations}}
34
+
35
+ If counter is 3, set output.config.enabled to false
36
+ Set output.status.last_checked to current counter value
37
+
38
+ summarize:
39
+ prompt: |
40
+ Summarize the results:
41
+ - Total iterations: {{counter}}
42
+ - Last checked at: {{status.last_checked}}
43
+ - Was enabled: {{config.enabled}}
44
+ - Hit max iterations: {{counter >= config.max_iterations ? "Yes" : "No"}}
@@ -0,0 +1,50 @@
1
+ # Exit on Error Example
2
+
3
+ This example demonstrates how to use the `exit_on_error` configuration option to continue workflow execution even when a command fails.
4
+
5
+ ## Use Case
6
+
7
+ When running a linter like RuboCop on a file with syntax errors or style violations, the command will exit with a non-zero status. By default, this would halt the workflow. However, we often want to:
8
+
9
+ 1. Capture the linter output (including errors)
10
+ 2. Analyze what went wrong
11
+ 3. Apply fixes based on the analysis
12
+
13
+ ## Configuration
14
+
15
+ The key configuration is in the step configuration section:
16
+
17
+ ```yaml
18
+ lint_check:
19
+ exit_on_error: false
20
+ ```
21
+
22
+ This tells Roast to:
23
+ - Continue workflow execution even if the command fails
24
+ - Capture the full output (stdout and stderr)
25
+ - Append the exit status to the output
26
+
27
+ ## Output Format
28
+
29
+ When a command fails with `exit_on_error: false`, the output will look like:
30
+
31
+ ```
32
+ lib/example.rb:5:3: C: Style/StringLiterals: Prefer double-quoted strings
33
+ 'hello'
34
+ ^^^^^^^
35
+ [Exit status: 1]
36
+ ```
37
+
38
+ This allows subsequent steps to process both the error output and the exit status.
39
+
40
+ ## Running the Example
41
+
42
+ ```bash
43
+ roast execute workflow.yml path/to/file.rb
44
+ ```
45
+
46
+ The workflow will:
47
+ 1. Run RuboCop on the file
48
+ 2. Continue even if RuboCop finds issues
49
+ 3. Analyze the linter output
50
+ 4. Apply fixes based on the analysis
@@ -0,0 +1,9 @@
1
+ The linter output from the previous step shows issues with the code.
2
+ Please analyze the output and identify the specific problems that need to be fixed.
3
+
4
+ Focus on:
5
+ - Syntax errors
6
+ - Style violations
7
+ - Best practice violations
8
+
9
+ Provide a structured list of issues found.
@@ -0,0 +1,2 @@
1
+ Based on the analysis, please generate the fixes for the identified issues.
2
+ Use the CodingAgent tool to apply the necessary changes to the file.
@@ -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,12 @@
1
- name: Grading current test changes
1
+ name: Test Grading
2
+ model: anthropic:claude-opus-4
2
3
 
3
4
  tools:
4
5
  - Roast::Tools::Grep
5
6
  - Roast::Tools::ReadFile
6
7
  - Roast::Tools::SearchFile
7
8
 
9
+ # Uncomment this to run the workflow on modified tests automatically
8
10
  # each: '% cd $(git rev-parse --show-toplevel) && git status --porcelain | grep "_test\.rb" | cut -c4- | xargs realpath'
9
11
 
10
12
  steps:
@@ -35,3 +37,5 @@ generate_recommendations:
35
37
  json: true
36
38
  params:
37
39
  max_completion_tokens: 5_000
40
+
41
+
@@ -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
+ ```