roast-ai 0.2.1 → 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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +5 -1
  3. data/.gitignore +29 -1
  4. data/CHANGELOG.md +27 -0
  5. data/CLAUDE.md +5 -0
  6. data/Gemfile.lock +3 -4
  7. data/README.md +162 -3
  8. data/examples/grading/generate_recommendations/output.txt +6 -6
  9. data/examples/pre_post_processing/README.md +111 -0
  10. data/examples/pre_post_processing/analyze_test_file/prompt.md +23 -0
  11. data/examples/pre_post_processing/improve_test_coverage/prompt.md +17 -0
  12. data/examples/pre_post_processing/optimize_test_performance/prompt.md +25 -0
  13. data/examples/pre_post_processing/post_processing/aggregate_metrics/prompt.md +31 -0
  14. data/examples/pre_post_processing/post_processing/cleanup_environment/prompt.md +28 -0
  15. data/examples/pre_post_processing/post_processing/generate_summary_report/prompt.md +32 -0
  16. data/examples/pre_post_processing/post_processing/output.txt +24 -0
  17. data/examples/pre_post_processing/pre_processing/gather_baseline_metrics/prompt.md +26 -0
  18. data/examples/pre_post_processing/pre_processing/setup_test_environment/prompt.md +11 -0
  19. data/examples/pre_post_processing/validate_changes/prompt.md +24 -0
  20. data/examples/pre_post_processing/workflow.yml +21 -0
  21. data/examples/single_target_prepost/README.md +36 -0
  22. data/examples/single_target_prepost/post_processing/output.txt +27 -0
  23. data/examples/single_target_prepost/pre_processing/gather_dependencies/prompt.md +11 -0
  24. data/examples/single_target_prepost/workflow.yml +20 -0
  25. data/gemfiles/activesupport7.gemfile +4 -0
  26. data/gemfiles/activesupport8.gemfile +4 -0
  27. data/lib/roast/tools/grep.rb +13 -4
  28. data/lib/roast/tools/search_file.rb +2 -2
  29. data/lib/roast/tools.rb +16 -1
  30. data/lib/roast/value_objects/uri_base.rb +49 -0
  31. data/lib/roast/value_objects.rb +1 -0
  32. data/lib/roast/version.rb +1 -1
  33. data/lib/roast/workflow/api_configuration.rb +9 -1
  34. data/lib/roast/workflow/base_workflow.rb +4 -1
  35. data/lib/roast/workflow/command_executor.rb +5 -2
  36. data/lib/roast/workflow/configuration.rb +4 -2
  37. data/lib/roast/workflow/configuration_loader.rb +14 -0
  38. data/lib/roast/workflow/error_handler.rb +18 -0
  39. data/lib/roast/workflow/expression_evaluator.rb +8 -0
  40. data/lib/roast/workflow/step_executor_coordinator.rb +34 -8
  41. data/lib/roast/workflow/step_loader.rb +15 -2
  42. data/lib/roast/workflow/workflow_execution_context.rb +39 -0
  43. data/lib/roast/workflow/workflow_executor.rb +22 -2
  44. data/lib/roast/workflow/workflow_initializer.rb +11 -2
  45. data/lib/roast/workflow/workflow_runner.rb +127 -5
  46. data/lib/roast/workflow.rb +1 -0
  47. data/lib/roast.rb +7 -1
  48. data/roast.gemspec +1 -1
  49. data/schema/workflow.json +14 -0
  50. metadata +25 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db58f659180113d7a2bb1bface8da2898be6717033107247156a464b4d14159d
4
- data.tar.gz: f14c2caae89fab3353b66ae3eb4457c56975e65c464037a2d401cfca30840d81
3
+ metadata.gz: 64b0bfad5bc7ce9abd2d750ff52695ba997a750556a403e3ab4fc449dfb28946
4
+ data.tar.gz: 526beebc0ca0697df5ce2f871468fff246440615634ae516439b4c0740f8ce90
5
5
  SHA512:
6
- metadata.gz: 88c3f83651c535077bdfe29408a19b874f66f19d8b7e743dd4933922f82fd7aee53ee215968e3d10c0207e92d4c53018a0b190475ba7ac4b70d15cda07a634ff
7
- data.tar.gz: 5ebae3dcc5d7d775a3f19ab79ead81d7c11f53fc31b5b20f1db4781a950032e693a2d331fdc4509eb0661c04072f421defcd56d15b9d6ce74f7bfc12357ee1b0
6
+ metadata.gz: 0600537a7242638e683a884a0b22b4d5f7fd58bb02d0c7a04240c8720d197a1f4f5e2d5f44c1a7f0335506f7822b51b6c245fd1c5f25627c8a580319d63b1250
7
+ data.tar.gz: e368630d036c6c3ac6efe00d102ddbf89d438332916ed1adb5aa54fe6cb5f9b34f9adf637c6e36c5baab07015c6f0fb848f675476d4233accd005a98b9630642
@@ -17,10 +17,14 @@ jobs:
17
17
  matrix:
18
18
  os: [ubuntu]
19
19
  ruby: ['3.2', '3.3', '3.4']
20
+ gemfile: ['activesupport7', 'activesupport8']
20
21
  runs-on: ${{ matrix.os }}-latest
21
- continue-on-error: ${{ matrix.ruby == 'ruby-head' }}
22
+ env:
23
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
22
24
  steps:
23
25
  - uses: actions/checkout@v4
26
+ - name: Install ripgrep
27
+ run: sudo apt-get update && sudo apt-get install -y ripgrep
24
28
  - uses: ruby/setup-ruby@v1
25
29
  with:
26
30
  ruby-version: ${{ matrix.ruby }}
data/.gitignore CHANGED
@@ -11,4 +11,32 @@
11
11
  **/.claude/settings.local.json
12
12
 
13
13
  **/CLAUDE.local.md
14
- .roast/
14
+ .roast/
15
+
16
+ bin/_guard-core
17
+ bin/bundle
18
+ bin/coderay
19
+ bin/dotenv
20
+ bin/erb
21
+ bin/guard
22
+ bin/htmldiff
23
+ bin/irb
24
+ bin/ldiff
25
+ bin/listen
26
+ bin/pry
27
+ bin/racc
28
+ bin/rake
29
+ bin/rbs
30
+ bin/rdbg
31
+ bin/rdoc
32
+ bin/ri
33
+ bin/rubocop
34
+ bin/ruby-lsp
35
+ bin/ruby-lsp-check
36
+ bin/ruby-lsp-launcher
37
+ bin/ruby-lsp-test-exec
38
+ bin/ruby-parse
39
+ bin/ruby-rewrite
40
+ bin/thor
41
+
42
+ gemfiles/*.lock
data/CHANGELOG.md CHANGED
@@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.2] - 2025-05-29
9
+
10
+ ### Added
11
+ - Pre/post processing framework for workflows with `pre_processing` and `post_processing` sections (#86)
12
+ - Support for `output.txt` ERB templates in post-processing phase for custom output formatting
13
+ - Pre/post processing support for single-target workflows (not just multi-target)
14
+ - Simplified access to pre-processing data in target workflows (removed `output` intermediary level)
15
+ - Verbose mode improvements for better debugging experience (#98)
16
+ - Command outputs are now displayed when using the `--verbose` flag
17
+ - Commands executed within conditional branches also show output in verbose mode
18
+ - User-friendly error reporting for workflow failures (#98)
19
+ - Clear ❌ indicators when commands or steps fail
20
+ - Command failures show exit status and output (no verbose needed for failures)
21
+ - Step failures provide helpful context about what might be wrong
22
+ - Exit handler displays actionable suggestions for resolving issues
23
+ - Automatic workflow discovery by name (#97)
24
+ - Can now run workflows by name without full path: `roast execute my_workflow`
25
+ - Automatically looks for `roast/my_workflow/workflow.yml` in current directory
26
+ - Configurable base URI for API endpoints (#83)
27
+
28
+ ### Fixed
29
+ - Search file tool now correctly prefixes paths when searching (#92)
30
+ - Support for Ruby projects using ActiveSupport 7.0+ (#95)
31
+
32
+ ### Changed
33
+ - ActiveSupport dependency relaxed to >= 7.0 for broader compatibility
34
+
8
35
  ## [0.2.1]
9
36
 
10
37
  ### Added
data/CLAUDE.md CHANGED
@@ -50,6 +50,11 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
50
50
  - IterationExecutor handles iterations (each, repeat)
51
51
  - ConditionalExecutor handles conditionals (if, unless)
52
52
  - Don't combine different responsibilities in one class
53
+ - **Do not implement prompts "inline" using a prompt: attribute nested under step names, that violates the primary design architecture of Roast**
54
+
55
+ ## Guidance and Expectations
56
+
57
+ - Do not decide unilaterally to leave code for the sake of "backwards compatibility"... always run those decisions by me first.
53
58
 
54
59
  ## Git Workflow Practices
55
60
 
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roast-ai (0.2.1)
5
- activesupport (~> 8.0)
4
+ roast-ai (0.2.2)
5
+ activesupport (>= 7.0)
6
6
  cli-ui
7
7
  diff-lcs (~> 1.5)
8
8
  faraday-retry
@@ -13,7 +13,7 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activesupport (8.0.2)
16
+ activesupport (7.2.2.1)
17
17
  base64
18
18
  benchmark (>= 0.3)
19
19
  bigdecimal
@@ -25,7 +25,6 @@ GEM
25
25
  minitest (>= 5.1)
26
26
  securerandom (>= 0.3)
27
27
  tzinfo (~> 2.0, >= 2.0.5)
28
- uri (>= 0.13.1)
29
28
  addressable (2.8.7)
30
29
  public_suffix (>= 2.0.2, < 7.0)
31
30
  ast (2.4.3)
data/README.md CHANGED
@@ -124,6 +124,9 @@ roast execute workflow.yml target_file.rb
124
124
 
125
125
  # Or for a targetless workflow (API calls, data generation, etc.)
126
126
  roast execute workflow.yml
127
+
128
+ # Roast will automatically search in `project_root/roast/workflow_name` if the path is incomplete.
129
+ roast execute my_cool_workflow # Equivalent to `roast execute roast/my_cool_workflow/workflow.yml
127
130
  ```
128
131
 
129
132
  ### Understanding Workflows
@@ -476,9 +479,9 @@ Benefits of using OpenRouter:
476
479
 
477
480
  When using OpenRouter, specify fully qualified model names including the provider prefix (e.g., `anthropic/claude-3-opus-20240229`).
478
481
 
479
- #### Dynamic API Tokens
482
+ #### Dynamic API Tokens and URIs
480
483
 
481
- Roast allows you to dynamically fetch API tokens using shell commands directly in your workflow configuration:
484
+ Roast allows you to dynamically fetch attributes such as API token and URI base (to use with a proxy) via shell commands directly in your workflow configuration:
482
485
 
483
486
  ```yaml
484
487
  # This will execute the shell command and use the result as the API token
@@ -490,8 +493,13 @@ api_token: $(echo $OPENAI_API_KEY)
490
493
  # For OpenRouter (requires api_provider setting)
491
494
  api_provider: openrouter
492
495
  api_token: $(echo $OPENROUTER_API_KEY)
493
- ```
494
496
 
497
+ # Static Proxy URI
498
+ uri_base: https://proxy.example.com/v1
499
+
500
+ # Dynamic Proxy URI
501
+ uri_base: $(echo $AI_PROXY_URI_BASE)
502
+ ```
495
503
 
496
504
  This makes it easy to use environment-specific tokens without hardcoding credentials, especially useful in development environments or CI/CD pipelines. Alternatively, Roast will fall back to `OPENROUTER_API_KEY` or `OPENAI_API_KEY` environment variables based on the specified provider.
497
505
 
@@ -746,6 +754,157 @@ your-project/
746
754
  └── ...
747
755
  ```
748
756
 
757
+ ### Pre/Post Processing Framework
758
+
759
+ Roast supports pre-processing and post-processing phases for workflows. This enables powerful workflows that need setup/teardown or result aggregation across all processed files.
760
+
761
+ #### Overview
762
+
763
+ - **Pre-processing**: Steps executed once before any targets are processed
764
+ - **Post-processing**: Steps executed once after all targets have been processed
765
+ - **Shared state**: Pre-processing results are available to all subsequent steps
766
+ - **Result aggregation**: Post-processing has access to all workflow execution results
767
+ - **Single-target support**: Pre/post processing works with single-target workflows too
768
+ - **Output templates**: Post-processing supports `output.txt` templates for custom formatting
769
+
770
+ #### Configuration
771
+
772
+ ```yaml
773
+ name: optimize_tests
774
+ model: gpt-4o
775
+ target: "test/**/*_test.rb"
776
+
777
+ # Pre-processing steps run once before any test files
778
+ pre_processing:
779
+ - gather_baseline_metrics
780
+ - setup_test_environment
781
+
782
+ # Main workflow steps run for each test file
783
+ steps:
784
+ - analyze_test
785
+ - improve_coverage
786
+ - optimize_performance
787
+
788
+ # Post-processing steps run once after all test files
789
+ post_processing:
790
+ - aggregate_results
791
+ - generate_report
792
+ - cleanup_environment
793
+ ```
794
+
795
+ #### Directory Structure
796
+
797
+ Pre and post-processing steps follow the same conventions as regular steps but are organized in their own directories:
798
+
799
+ ```
800
+ workflow.yml
801
+ pre_processing/
802
+ ├── gather_baseline_metrics/
803
+ │ └── prompt.md
804
+ └── setup_test_environment/
805
+ └── prompt.md
806
+ analyze_test/
807
+ └── prompt.md
808
+ improve_coverage/
809
+ └── prompt.md
810
+ optimize_performance/
811
+ └── prompt.md
812
+ post_processing/
813
+ ├── output.txt
814
+ ├── aggregate_results/
815
+ │ └── prompt.md
816
+ ├── generate_report/
817
+ │ └── prompt.md
818
+ └── cleanup_environment/
819
+ └── prompt.md
820
+ ```
821
+
822
+ #### Data Access
823
+
824
+ **Pre-processing results in target workflows:**
825
+
826
+ Target workflows have access to pre-processing results through the `pre_processing_data` variable with dot notation:
827
+
828
+ ```erb
829
+ # In a target workflow step prompt
830
+ The baseline metrics from pre-processing:
831
+ <%= pre_processing_data.gather_baseline_metrics %>
832
+
833
+ Environment setup details:
834
+ <%= pre_processing_data.setup_test_environment %>
835
+ ```
836
+
837
+ **Post-processing data access:**
838
+
839
+ Post-processing steps have access to:
840
+
841
+ - `pre_processing`: Direct access to pre-processing results with dot notation
842
+ - `targets`: Hash of all target workflow results, keyed by file paths
843
+
844
+ Example post-processing prompt:
845
+ ```markdown
846
+ # Generate Summary Report
847
+
848
+ Based on the baseline metrics:
849
+ <%= pre_processing.gather_baseline_metrics %>
850
+
851
+ Environment configuration:
852
+ <%= pre_processing.setup_test_environment %>
853
+
854
+ And the results from processing all files:
855
+ <% targets.each do |file, target| %>
856
+ File: <%= file %>
857
+ Analysis results: <%= target.output.analyze_test %>
858
+ Coverage improvements: <%= target.output.improve_coverage %>
859
+ Performance optimizations: <%= target.output.optimize_performance %>
860
+ <% end %>
861
+
862
+ Please generate a comprehensive summary report showing:
863
+ 1. Overall improvements achieved
864
+ 2. Files with the most significant changes
865
+ 3. Recommendations for further optimization
866
+ ```
867
+
868
+ #### Output Templates
869
+
870
+ Post-processing supports custom output formatting using ERB templates. Create an `output.txt` file in your `post_processing` directory to format the final workflow output:
871
+
872
+ ```erb
873
+ # post_processing/output.txt
874
+ === Workflow Summary Report ===
875
+ Generated at: <%= Time.now.strftime("%Y-%m-%d %H:%M:%S") %>
876
+
877
+ Environment: <%= pre_processing.setup_test_environment %>
878
+
879
+ Files Processed: <%= targets.size %>
880
+
881
+ <% targets.each do |file, target| %>
882
+ - <%= file %>: <%= target.output.analyze_test %>
883
+ <% end %>
884
+
885
+ <%= output.generate_report %>
886
+ ===============================
887
+ ```
888
+
889
+ The template has access to:
890
+ - `pre_processing`: All pre-processing step outputs with dot notation
891
+ - `targets`: Hash of all target workflow results with dot notation (each target has `.output` and `.final_output`)
892
+ - `output`: Post-processing step outputs with dot notation
893
+
894
+ #### Use Cases
895
+
896
+ This pattern is ideal for:
897
+
898
+ - **Code migrations**: Setup migration tools, process files, generate migration report
899
+ - **Test optimization**: Baseline metrics, optimize tests, aggregate improvements
900
+ - **Documentation generation**: Analyze codebase, generate docs per module, create index
901
+ - **Dependency updates**: Check versions, update files, verify compatibility
902
+ - **Security audits**: Setup scanners, check each file, generate security report
903
+ - **Performance analysis**: Establish baselines, analyze components, summarize findings
904
+
905
+ See the [pre/post processing example](examples/pre_post_processing) for a complete working demonstration.
906
+
907
+
749
908
  ## Development
750
909
 
751
910
  After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rake` to run the tests and linter. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -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 -%>
@@ -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
+ ```