roast-ai 0.2.0 → 0.2.2

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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +5 -1
  3. data/.gitignore +29 -1
  4. data/CHANGELOG.md +36 -0
  5. data/CLAUDE.md +5 -0
  6. data/CLAUDE_NOTES.md +68 -0
  7. data/Gemfile.lock +3 -4
  8. data/README.md +235 -10
  9. data/docs/ITERATION_SYNTAX.md +31 -3
  10. data/examples/case_when/README.md +58 -0
  11. data/examples/case_when/detect_language/prompt.md +16 -0
  12. data/examples/case_when/workflow.yml +58 -0
  13. data/examples/direct_coerce_syntax/README.md +32 -0
  14. data/examples/direct_coerce_syntax/workflow.yml +36 -0
  15. data/examples/grading/generate_recommendations/output.txt +6 -6
  16. data/examples/grading/workflow.yml +6 -4
  17. data/examples/json_handling/README.md +32 -0
  18. data/examples/json_handling/workflow.yml +52 -0
  19. data/examples/pre_post_processing/README.md +111 -0
  20. data/examples/pre_post_processing/analyze_test_file/prompt.md +23 -0
  21. data/examples/pre_post_processing/improve_test_coverage/prompt.md +17 -0
  22. data/examples/pre_post_processing/optimize_test_performance/prompt.md +25 -0
  23. data/examples/pre_post_processing/post_processing/aggregate_metrics/prompt.md +31 -0
  24. data/examples/pre_post_processing/post_processing/cleanup_environment/prompt.md +28 -0
  25. data/examples/pre_post_processing/post_processing/generate_summary_report/prompt.md +32 -0
  26. data/examples/pre_post_processing/post_processing/output.txt +24 -0
  27. data/examples/pre_post_processing/pre_processing/gather_baseline_metrics/prompt.md +26 -0
  28. data/examples/pre_post_processing/pre_processing/setup_test_environment/prompt.md +11 -0
  29. data/examples/pre_post_processing/validate_changes/prompt.md +24 -0
  30. data/examples/pre_post_processing/workflow.yml +21 -0
  31. data/examples/single_target_prepost/README.md +36 -0
  32. data/examples/single_target_prepost/post_processing/output.txt +27 -0
  33. data/examples/single_target_prepost/pre_processing/gather_dependencies/prompt.md +11 -0
  34. data/examples/single_target_prepost/workflow.yml +20 -0
  35. data/examples/smart_coercion_defaults/README.md +65 -0
  36. data/examples/smart_coercion_defaults/workflow.yml +44 -0
  37. data/examples/step_configuration/README.md +87 -0
  38. data/examples/step_configuration/workflow.yml +60 -0
  39. data/gemfiles/activesupport7.gemfile +4 -0
  40. data/gemfiles/activesupport8.gemfile +4 -0
  41. data/lib/roast/tools/grep.rb +13 -4
  42. data/lib/roast/tools/search_file.rb +2 -2
  43. data/lib/roast/tools.rb +16 -1
  44. data/lib/roast/value_objects/uri_base.rb +49 -0
  45. data/lib/roast/value_objects.rb +1 -0
  46. data/lib/roast/version.rb +1 -1
  47. data/lib/roast/workflow/api_configuration.rb +9 -1
  48. data/lib/roast/workflow/base_iteration_step.rb +22 -3
  49. data/lib/roast/workflow/base_step.rb +40 -3
  50. data/lib/roast/workflow/base_workflow.rb +4 -1
  51. data/lib/roast/workflow/case_executor.rb +49 -0
  52. data/lib/roast/workflow/case_step.rb +82 -0
  53. data/lib/roast/workflow/command_executor.rb +5 -2
  54. data/lib/roast/workflow/conditional_step.rb +6 -43
  55. data/lib/roast/workflow/configuration.rb +4 -2
  56. data/lib/roast/workflow/configuration_loader.rb +14 -0
  57. data/lib/roast/workflow/error_handler.rb +18 -0
  58. data/lib/roast/workflow/expression_evaluator.rb +86 -0
  59. data/lib/roast/workflow/iteration_executor.rb +18 -0
  60. data/lib/roast/workflow/prompt_step.rb +4 -1
  61. data/lib/roast/workflow/repeat_step.rb +2 -2
  62. data/lib/roast/workflow/step_executor_coordinator.rb +50 -8
  63. data/lib/roast/workflow/step_loader.rb +21 -7
  64. data/lib/roast/workflow/step_type_resolver.rb +16 -0
  65. data/lib/roast/workflow/workflow_execution_context.rb +39 -0
  66. data/lib/roast/workflow/workflow_executor.rb +22 -2
  67. data/lib/roast/workflow/workflow_initializer.rb +11 -2
  68. data/lib/roast/workflow/workflow_runner.rb +127 -5
  69. data/lib/roast/workflow.rb +1 -0
  70. data/lib/roast.rb +7 -1
  71. data/roast.gemspec +1 -1
  72. data/schema/workflow.json +41 -0
  73. metadata +40 -5
@@ -0,0 +1,32 @@
1
+ # Direct Coerce Syntax
2
+
3
+ This example demonstrates the simplified syntax for specifying `coerce_to` and other configuration options directly on iteration steps.
4
+
5
+ ## Direct Syntax
6
+
7
+ Configuration options are specified directly on the step:
8
+
9
+ ```yaml
10
+ - repeat:
11
+ until: "condition"
12
+ coerce_to: boolean
13
+ print_response: true
14
+ model: "claude-3-haiku"
15
+ steps: [...]
16
+ ```
17
+
18
+ ## Benefits
19
+
20
+ 1. **Cleaner YAML** - No unnecessary nesting
21
+ 2. **More intuitive** - Configuration options are at the same level as other step properties
22
+ 3. **Consistent** - Matches how other step properties are specified
23
+
24
+ ## Supported Options
25
+
26
+ All step configuration options can be specified directly:
27
+ - `coerce_to` - Type coercion (boolean, llm_boolean, iterable)
28
+ - `print_response` - Whether to print LLM responses
29
+ - `loop` - Auto-loop behavior
30
+ - `json` - JSON response mode
31
+ - `params` - Additional parameters
32
+ - `model` - Model override
@@ -0,0 +1,36 @@
1
+ name: Direct Coerce Syntax Demo
2
+ description: Demonstrates the simplified coerce_to syntax without config blocks
3
+
4
+ steps:
5
+ # Example 1: Direct coerce_to on repeat
6
+ - repeat:
7
+ until: "check_api_ready"
8
+ coerce_to: boolean # Direct syntax - no config block needed
9
+ max_iterations: 5
10
+ steps:
11
+ - check_api_ready:
12
+ prompt: "Check if the API endpoint returns a 200 status"
13
+ - wait: 2
14
+
15
+ # Example 2: Direct coerce_to on each
16
+ - get_data_sources:
17
+ prompt: "List available data sources, one per line"
18
+
19
+ - each: "get_data_sources"
20
+ as: "source"
21
+ coerce_to: iterable # Direct syntax
22
+ steps:
23
+ - validate_source: "Validating {{source}}..."
24
+ - process_source:
25
+ prompt: "Process data from {{source}}"
26
+
27
+ # Example 3: Multiple configuration options
28
+ - repeat:
29
+ until: "all_tests_pass"
30
+ coerce_to: llm_boolean # Override default
31
+ print_response: true # Other options work too
32
+ max_iterations: 10
33
+ steps:
34
+ - run_tests: "$(rake test)"
35
+ - all_tests_pass:
36
+ prompt: "Did all tests pass successfully?"
@@ -1,16 +1,16 @@
1
1
  ========== TEST RECOMMENDATIONS ==========
2
- <%- if response["recommendations"].empty? -%>
2
+ <%- if response.recommendations.empty? -%>
3
3
  No recommendations found.
4
4
  <%- else -%>
5
- <%- response["recommendations"].each_with_index do |rec, index| -%>
5
+ <%- response.recommendations.each_with_index do |rec, index| -%>
6
6
  Recommendation #<%= index + 1 %>:
7
- Description: <%= rec["description"] %>
8
- Impact: <%= rec["impact"] %>
9
- Priority: <%= rec["priority"] %>
7
+ Description: <%= rec.description %>
8
+ Impact: <%= rec.impact %>
9
+ Priority: <%= rec.priority %>
10
10
 
11
11
  Code Suggestion:
12
12
 
13
- <%= rec["code_suggestion"] %>
13
+ <%= rec.code_suggestion %>
14
14
 
15
15
  <%- end -%>
16
16
  <%- end -%>
@@ -1,5 +1,7 @@
1
1
  name: Test Grading
2
- model: anthropic:claude-opus-4
2
+ api_token: $(echo $OPENAI_API_KEY)
3
+ # model: anthropic:claude-opus-4
4
+ model: gpt-4.1-mini
3
5
 
4
6
  tools:
5
7
  - Roast::Tools::Grep
@@ -23,16 +25,16 @@ steps:
23
25
 
24
26
  # set non-default attributes for steps below
25
27
  analyze_coverage:
26
- model: gpt-4.1-mini
28
+ # model: gpt-4.1-mini
27
29
  auto_loop: false
28
30
  json: true
29
31
 
30
32
  generate_grades:
31
- model: o3
33
+ # model: o3
32
34
  json: true
33
35
 
34
36
  generate_recommendations:
35
- model: o3
37
+ # model: o3
36
38
  auto_loop: false
37
39
  json: true
38
40
  params:
@@ -0,0 +1,32 @@
1
+ # JSON Handling Example
2
+
3
+ This example demonstrates how Roast handles JSON responses from LLM steps.
4
+
5
+ ## Key Features
6
+
7
+ 1. **JSON Arrays**: When a step has `json: true` and returns an array, the result is `flatten.first` - the first element after flattening the array. This is useful when the LLM returns an array with a single object.
8
+
9
+ 2. **JSON Objects**: Hash/object responses are maintained as proper Ruby hashes in the workflow output.
10
+
11
+ 3. **Replay Support**: JSON data structures are properly serialized and deserialized when saving/loading workflow state for replay functionality.
12
+
13
+ ## Running the Example
14
+
15
+ ```bash
16
+ bin/roast examples/json_handling/workflow.yml
17
+ ```
18
+
19
+ ## How It Works
20
+
21
+ 1. The `fetch_users` step generates a JSON array of user objects
22
+ 2. The `fetch_metadata` step generates a JSON object with metadata
23
+ 3. The `process_data` step can access the structured data using `{{output.fetch_users}}` and `{{output.fetch_metadata}}`
24
+ 4. The structured data is preserved through the workflow, including during replay scenarios
25
+
26
+ ## Implementation Details
27
+
28
+ When `json: true` is set on a step:
29
+ - Array responses return `flatten.first` - the first element after flattening
30
+ - Object responses are preserved as hashes
31
+ - Non-JSON array responses (when `json: false`) are joined with newlines
32
+ - The data maintains its structure when saved to and loaded from workflow state files
@@ -0,0 +1,52 @@
1
+ name: JSON Data Handling Example
2
+ api_provider: openai
3
+ model: gpt-4
4
+
5
+ tools:
6
+ - type: write_file
7
+ allowed_paths:
8
+ - examples/json_handling/
9
+
10
+ steps:
11
+ - name: fetch_users
12
+ prompt: |
13
+ Generate a JSON array of 3 user objects. Each user should have:
14
+ - id (number)
15
+ - name (string)
16
+ - email (string)
17
+ - active (boolean)
18
+ json: true
19
+
20
+ - name: fetch_metadata
21
+ prompt: |
22
+ Generate a JSON object with metadata about a dataset:
23
+ - total_records (number)
24
+ - last_updated (ISO date string)
25
+ - categories (array of strings)
26
+ - filters (object with status and sort fields)
27
+ json: true
28
+
29
+ - name: process_data
30
+ prompt: |
31
+ Based on the users data: {{output.fetch_users}}
32
+ And metadata: {{output.fetch_metadata}}
33
+
34
+ Create a summary report describing:
35
+ 1. How many active users there are
36
+ 2. The categories available
37
+ 3. When the data was last updated
38
+
39
+ - name: save_report
40
+ tool: write_file
41
+ path: examples/json_handling/report.txt
42
+ content: |
43
+ # JSON Data Processing Report
44
+
45
+ ## Users Data
46
+ {{output.fetch_users}}
47
+
48
+ ## Metadata
49
+ {{output.fetch_metadata}}
50
+
51
+ ## Summary
52
+ {{output.process_data}}
@@ -0,0 +1,111 @@
1
+ # Pre/Post Processing Example: Test Suite Optimization
2
+
3
+ This example demonstrates how to use Roast's pre/post processing framework to optimize an entire test suite across multiple files.
4
+
5
+ ## Overview
6
+
7
+ The workflow processes multiple test files, but performs setup and aggregation tasks only once:
8
+
9
+ - **Pre-processing**: Runs once before any test files are processed
10
+ - Gathers baseline metrics for comparison
11
+ - Sets up the test environment
12
+
13
+ - **Main workflow**: Runs for each test file matching the target pattern
14
+ - Analyzes test quality and coverage
15
+ - Improves test coverage
16
+ - Optimizes test performance
17
+ - Validates changes
18
+
19
+ - **Post-processing**: Runs once after all test files have been processed
20
+ - Aggregates metrics from all files
21
+ - Generates a comprehensive report
22
+ - Cleans up the environment
23
+
24
+ ## Workflow Structure
25
+
26
+ ```yaml
27
+ name: test_optimization
28
+ model: gpt-4o
29
+ target: "test/**/*_test.rb"
30
+
31
+ pre_processing:
32
+ - gather_baseline_metrics
33
+ - setup_test_environment
34
+
35
+ steps:
36
+ - analyze_test_file
37
+ - improve_test_coverage
38
+ - optimize_test_performance
39
+ - validate_changes
40
+
41
+ post_processing:
42
+ - aggregate_metrics
43
+ - generate_summary_report
44
+ - cleanup_environment
45
+ ```
46
+
47
+ ## Directory Structure
48
+
49
+ ```
50
+ pre_post_processing/
51
+ ├── workflow.yml
52
+ ├── pre_processing/
53
+ │ ├── gather_baseline_metrics/
54
+ │ │ └── prompt.md
55
+ │ └── setup_test_environment/
56
+ │ └── prompt.md
57
+ ├── analyze_test_file/
58
+ │ └── prompt.md
59
+ ├── improve_test_coverage/
60
+ │ └── prompt.md
61
+ ├── optimize_test_performance/
62
+ │ └── prompt.md
63
+ ├── validate_changes/
64
+ │ └── prompt.md
65
+ └── post_processing/
66
+ ├── aggregate_metrics/
67
+ │ └── prompt.md
68
+ ├── generate_summary_report/
69
+ │ └── prompt.md
70
+ └── cleanup_environment/
71
+ └── prompt.md
72
+ ```
73
+
74
+ ## Key Features Demonstrated
75
+
76
+ 1. **Shared State**: Pre-processing results are available to all subsequent steps
77
+ 2. **Result Aggregation**: Post-processing has access to results from all workflow executions
78
+ 3. **One-time Operations**: Setup and cleanup happen only once, regardless of target count
79
+ 4. **Metrics Collection**: Each file's results are stored and aggregated for reporting
80
+
81
+ ## Running the Example
82
+
83
+ ```bash
84
+ cd examples/pre_post_processing
85
+ roast workflow.yml
86
+ ```
87
+
88
+ This will:
89
+ 1. Run pre-processing steps once
90
+ 2. Process each test file matching `test/**/*_test.rb`
91
+ 3. Run post-processing steps once with access to all results
92
+ 4. Generate a comprehensive optimization report
93
+
94
+ ## Use Cases
95
+
96
+ This pattern is ideal for:
97
+ - **Code migrations**: Setup migration tools, process files, generate migration report
98
+ - **Performance audits**: Baseline metrics, analyze files, aggregate improvements
99
+ - **Documentation generation**: Analyze codebase, generate docs per file, create index
100
+ - **Dependency updates**: Check current versions, update files, verify compatibility
101
+ - **Security scanning**: Setup scanners, check each file, generate security report
102
+
103
+ ## Customization
104
+
105
+ To adapt this example for your use case:
106
+
107
+ 1. Update the `target` pattern to match your files
108
+ 2. Modify pre-processing steps for your setup needs
109
+ 3. Adjust main workflow steps for your processing logic
110
+ 4. Customize post-processing for your reporting requirements
111
+ 5. Use appropriate AI models for each step type
@@ -0,0 +1,23 @@
1
+ # Analyze Test File
2
+
3
+ Current test file: {{file}}
4
+
5
+ Please analyze this test file and identify:
6
+
7
+ 1. **Test Structure**: Number of test cases, test suites, and overall organization
8
+ 2. **Coverage Gaps**: Areas of the code that aren't adequately tested
9
+ 3. **Test Quality Issues**:
10
+ - Tests that are too brittle or implementation-dependent
11
+ - Missing edge cases
12
+ - Unclear test descriptions
13
+ - Excessive mocking that reduces test value
14
+ 4. **Performance Issues**:
15
+ - Slow setup/teardown methods
16
+ - Inefficient test data generation
17
+ - Unnecessary database operations
18
+ 5. **Opportunities for Improvement**:
19
+ - Tests that could be parameterized
20
+ - Common patterns that could be extracted to helpers
21
+ - Better use of test fixtures or factories
22
+
23
+ Provide specific, actionable recommendations for each issue found.
@@ -0,0 +1,17 @@
1
+ # Improve Test Coverage
2
+
3
+ Based on the analysis of {{file}}, implement the following improvements:
4
+
5
+ 1. **Add Missing Test Cases**: Write tests for uncovered code paths, edge cases, and error conditions
6
+ 2. **Improve Test Descriptions**: Make test names more descriptive and follow consistent naming conventions
7
+ 3. **Enhance Assertions**: Add more specific assertions to catch regressions
8
+ 4. **Test Data**: Use more realistic test data that better represents production scenarios
9
+ 5. **Remove Redundancy**: Eliminate duplicate tests or merge similar ones
10
+
11
+ Generate the improved test code and explain the rationale for each change.
12
+
13
+ Remember to:
14
+ - Maintain backward compatibility with existing test interfaces
15
+ - Follow the project's testing conventions and style guide
16
+ - Ensure new tests are fast and deterministic
17
+ - Add appropriate comments for complex test scenarios
@@ -0,0 +1,25 @@
1
+ # Optimize Test Performance
2
+
3
+ Optimize the performance of {{file}} by:
4
+
5
+ 1. **Reduce Setup Overhead**:
6
+ - Move expensive operations out of individual test setup
7
+ - Use shared fixtures where appropriate
8
+ - Lazy-load test data only when needed
9
+
10
+ 2. **Optimize Database Operations**:
11
+ - Use transactions for test isolation instead of truncation
12
+ - Minimize database queries in tests
13
+ - Use in-memory databases where possible
14
+
15
+ 3. **Improve Test Isolation**:
16
+ - Remove unnecessary dependencies between tests
17
+ - Clean up resources properly to avoid test pollution
18
+ - Use proper test doubles instead of hitting external services
19
+
20
+ 4. **Parallelize When Possible**:
21
+ - Identify tests that can run in parallel
22
+ - Remove shared state that prevents parallelization
23
+ - Group related tests for better cache utilization
24
+
25
+ Generate the optimized test code and provide before/after performance metrics estimates.
@@ -0,0 +1,31 @@
1
+ # Aggregate Metrics
2
+
3
+ Aggregate all the metrics collected during the workflow execution:
4
+
5
+ Available data:
6
+ - Pre-processing baseline metrics: {{pre_processing.gather_baseline_metrics}}
7
+ - Results from all processed test files: {{output.targets}}
8
+
9
+ Please calculate and provide:
10
+
11
+ 1. **Overall Coverage Improvement**:
12
+ - Total coverage before and after
13
+ - Percentage improvement
14
+ - Files with biggest improvements
15
+
16
+ 2. **Performance Gains**:
17
+ - Total execution time saved
18
+ - Average performance improvement per file
19
+ - Files with best optimization results
20
+
21
+ 3. **Test Quality Metrics**:
22
+ - Number of new tests added
23
+ - Number of tests optimized
24
+ - Reduction in flaky/brittle tests
25
+
26
+ 4. **Summary Statistics**:
27
+ - Total files processed
28
+ - Success rate
29
+ - Any files that had issues
30
+
31
+ Output a comprehensive metrics summary that can be used in the final report.
@@ -0,0 +1,28 @@
1
+ # Cleanup Environment
2
+
3
+ Perform post-optimization cleanup tasks:
4
+
5
+ 1. **Commit Changes**: Create a commit with all the test improvements
6
+ - Use a descriptive commit message summarizing the optimization results
7
+ - Include key metrics in the commit description
8
+
9
+ 2. **Update Documentation**:
10
+ - Update test documentation if structure changed significantly
11
+ - Add notes about any new test helpers or patterns introduced
12
+
13
+ 3. **Clean Temporary Files**:
14
+ - Remove any temporary files created during optimization
15
+ - Clear test caches that were used for benchmarking
16
+
17
+ 4. **Final Verification**:
18
+ - Run the full test suite one more time to ensure everything works
19
+ - Verify CI/CD pipelines will work with the changes
20
+
21
+ 5. **Create PR Description**:
22
+ - Generate a pull request description template with:
23
+ - Summary of changes
24
+ - Key metrics improvements
25
+ - Any breaking changes or considerations
26
+ - Review checklist
27
+
28
+ Output a summary of cleanup actions performed and any final notes for the team.
@@ -0,0 +1,32 @@
1
+ # Generate Summary Report
2
+
3
+ Generate a comprehensive test optimization report based on all the collected data:
4
+
5
+ ## Test Suite Optimization Report
6
+
7
+ ### Executive Summary
8
+ Provide a high-level overview of the optimization results, key achievements, and any issues encountered.
9
+
10
+ ### Metrics Summary
11
+ Include the aggregated metrics from the previous step:
12
+ {{aggregate_metrics}}
13
+
14
+ ### Detailed Results by File
15
+ For each processed test file, include:
16
+ - File name and path
17
+ - Coverage improvement
18
+ - Performance improvement
19
+ - Number of tests added/modified
20
+ - Key changes made
21
+
22
+ ### Recommendations
23
+ Based on the optimization results, provide:
24
+ 1. Further optimization opportunities
25
+ 2. Best practices observed that should be adopted project-wide
26
+ 3. Common patterns that could be extracted into shared utilities
27
+ 4. Testing strategy improvements
28
+
29
+ ### Next Steps
30
+ Suggest follow-up actions to maintain and build upon these improvements.
31
+
32
+ Format the report in Markdown for easy sharing and include visual indicators (✅ ❌ ⚠️) for quick scanning.
@@ -0,0 +1,24 @@
1
+ === Test Optimization Summary Report ===
2
+ Generated at: <%= Time.now.strftime("%Y-%m-%d %H:%M:%S") %>
3
+
4
+ ## Baseline Metrics
5
+ <%= pre_processing.gather_baseline_metrics %>
6
+
7
+ ## Files Processed
8
+ Total files: <%= targets.size %>
9
+
10
+ <% targets.each do |file, target| %>
11
+ ### <%= file %>
12
+ Analysis: <%= target.output.analyze_test_file %>
13
+ Coverage improvements: <%= target.output.improve_test_coverage %>
14
+ Performance optimizations: <%= target.output.optimize_test_performance %>
15
+ <% end %>
16
+
17
+ ## Post-Processing Results
18
+ ### Aggregated Metrics
19
+ <%= output.aggregate_metrics %>
20
+
21
+ ### Summary Report
22
+ <%= output.generate_summary_report %>
23
+
24
+ === End of Report ===
@@ -0,0 +1,26 @@
1
+ # Gather Baseline Metrics
2
+
3
+ Analyze the current test suite and gather baseline metrics for comparison. Please provide:
4
+
5
+ 1. Total number of test files to be processed
6
+ 2. Current overall test coverage percentage
7
+ 3. Average test execution time across all files
8
+ 4. Number of tests by type (unit, integration, system)
9
+ 5. Any test files that are particularly slow (> 5 seconds)
10
+
11
+ Store these metrics in the workflow state for later comparison in post-processing.
12
+
13
+ Output format:
14
+ ```json
15
+ {
16
+ "total_test_files": 0,
17
+ "overall_coverage": 0.0,
18
+ "average_execution_time": 0.0,
19
+ "test_counts": {
20
+ "unit": 0,
21
+ "integration": 0,
22
+ "system": 0
23
+ },
24
+ "slow_tests": []
25
+ }
26
+ ```
@@ -0,0 +1,11 @@
1
+ # Setup Test Environment
2
+
3
+ Prepare the test environment for optimization. Please:
4
+
5
+ 1. Ensure all test dependencies are installed
6
+ 2. Create a backup branch for safety: `test-optimization-backup-{{timestamp}}`
7
+ 3. Set up any necessary test databases or fixtures
8
+ 4. Configure test parallelization settings if available
9
+ 5. Clear any test caches that might affect benchmarking
10
+
11
+ Return a summary of the setup steps completed and any warnings or issues encountered.
@@ -0,0 +1,24 @@
1
+ # Validate Changes
2
+
3
+ Validate the changes made to {{file}}:
4
+
5
+ 1. **Run the updated tests** and ensure they all pass
6
+ 2. **Check coverage metrics** to verify improvements
7
+ 3. **Measure execution time** to confirm performance gains
8
+ 4. **Verify no regressions** were introduced
9
+ 5. **Ensure code style** follows project conventions
10
+
11
+ Store the validation results in the workflow state:
12
+ ```json
13
+ {
14
+ "file": "{{file}}",
15
+ "tests_passed": true,
16
+ "coverage_before": 0.0,
17
+ "coverage_after": 0.0,
18
+ "execution_time_before": 0.0,
19
+ "execution_time_after": 0.0,
20
+ "issues_found": []
21
+ }
22
+ ```
23
+
24
+ If any issues are found, provide recommendations for fixing them.
@@ -0,0 +1,21 @@
1
+ name: test_optimization
2
+ model: gpt-4o
3
+ target: "test/**/*_test.rb"
4
+
5
+ # Pre-processing steps run once before any test files are processed
6
+ pre_processing:
7
+ - gather_baseline_metrics
8
+ - setup_test_environment
9
+
10
+ # Main workflow steps run for each test file
11
+ steps:
12
+ - analyze_test_file
13
+ - improve_test_coverage
14
+ - optimize_test_performance
15
+ - validate_changes
16
+
17
+ # Post-processing steps run once after all test files have been processed
18
+ post_processing:
19
+ - aggregate_metrics
20
+ - generate_summary_report
21
+ - cleanup_environment
@@ -0,0 +1,36 @@
1
+ # Single Target with Pre/Post Processing Example
2
+
3
+ This example demonstrates how pre/post processing works with single-target workflows. Even when analyzing just one file, you can use pre-processing to gather context and post-processing to format results.
4
+
5
+ ## Features Demonstrated
6
+
7
+ 1. **Pre-processing for context gathering** - Analyze dependencies before the main workflow
8
+ 2. **Single-target analysis** - Focus on one specific file
9
+ 3. **Post-processing with output template** - Custom formatting of the final report
10
+
11
+ ## Running the Example
12
+
13
+ ```bash
14
+ roast workflow.yml
15
+ ```
16
+
17
+ This will:
18
+ 1. Run pre-processing to gather dependencies and context
19
+ 2. Analyze the single target file (src/main.rb)
20
+ 3. Apply the post-processing template to format the output
21
+
22
+ ## Output Template
23
+
24
+ The `post_processing/output.txt` template demonstrates how to:
25
+ - Access pre-processing results with `<%= pre_processing[:step_name] %>`
26
+ - Iterate over target results (even for single targets)
27
+ - Include post-processing step outputs
28
+ - Format everything into a professional report
29
+
30
+ ## Use Cases
31
+
32
+ This pattern is ideal for:
33
+ - Deep analysis of critical files
34
+ - Security audits of specific components
35
+ - Performance profiling of key modules
36
+ - Generating documentation for important classes
@@ -0,0 +1,27 @@
1
+ === Code Analysis Report ===
2
+ Generated: <%= Time.now.strftime("%Y-%m-%d %H:%M:%S") %>
3
+
4
+ ## Dependencies & Context
5
+ <%= pre_processing.gather_dependencies %>
6
+
7
+ ## Target File Analysis
8
+ <% targets.each do |file, target| %>
9
+ File: <%= file %>
10
+
11
+ ### Code Quality
12
+ <%= target.output.analyze_code_quality %>
13
+
14
+ ### Identified Improvements
15
+ <%= target.output.identify_improvements %>
16
+
17
+ ### Recommendations
18
+ <%= target.output.generate_recommendations %>
19
+ <% end %>
20
+
21
+ ## Summary
22
+ <%= output.summarize_findings %>
23
+
24
+ ## Action Items
25
+ <%= output.create_action_items %>
26
+
27
+ === End of Report ===
@@ -0,0 +1,11 @@
1
+ # Gather Dependencies
2
+
3
+ Analyze the project structure to understand the dependencies and context for <%= file %>.
4
+
5
+ Tasks:
6
+ 1. List all files that import or depend on the target file
7
+ 2. Identify the key modules and classes used
8
+ 3. Note any external dependencies or libraries
9
+ 4. Summarize the architectural context
10
+
11
+ Provide a structured summary that will help with the main analysis.