roast-ai 0.3.0 → 0.4.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/.gitignore +1 -0
- data/CHANGELOG.md +32 -0
- data/CLAUDE.md +52 -1
- data/Gemfile +3 -1
- data/Gemfile.lock +63 -16
- data/README.md +115 -5
- data/bin/roast +1 -1
- data/claude-swarm.yml +210 -0
- data/docs/AGENT_STEPS.md +264 -0
- data/examples/agent_workflow/README.md +75 -0
- data/examples/agent_workflow/apply_refactorings/prompt.md +22 -0
- data/examples/agent_workflow/identify_code_smells/prompt.md +15 -0
- data/examples/agent_workflow/summarize_improvements/prompt.md +18 -0
- data/examples/agent_workflow/workflow.yml +16 -0
- data/examples/available_tools_demo/README.md +42 -0
- data/examples/available_tools_demo/analyze_files/prompt.md +6 -0
- data/examples/available_tools_demo/explore_directory/prompt.md +6 -0
- data/examples/available_tools_demo/workflow.yml +32 -0
- data/examples/available_tools_demo/write_summary/prompt.md +6 -0
- data/examples/case_when/detect_language/prompt.md +2 -2
- data/examples/grading/README.md +71 -0
- data/examples/grading/run_coverage.rb +0 -2
- data/examples/iteration/analyze_complexity/prompt.md +2 -2
- data/examples/iteration/generate_recommendations/prompt.md +2 -2
- data/examples/iteration/implement_fix/prompt.md +2 -2
- data/examples/iteration/prioritize_issues/prompt.md +1 -1
- data/examples/iteration/prompts/analyze_file.md +2 -2
- data/examples/iteration/prompts/generate_summary.md +1 -1
- data/examples/iteration/prompts/update_report.md +3 -3
- data/examples/iteration/prompts/write_report.md +3 -3
- data/examples/iteration/read_file/prompt.md +2 -2
- data/examples/iteration/select_next_issue/prompt.md +2 -2
- data/examples/iteration/update_fix_count/prompt.md +4 -4
- data/examples/iteration/verify_fix/prompt.md +3 -3
- data/examples/mcp/README.md +3 -3
- data/examples/mcp/analyze_changes/prompt.md +1 -1
- data/examples/mcp/database_workflow.yml +1 -1
- data/examples/mcp/fetch_pr_context/prompt.md +1 -1
- data/examples/mcp/github_workflow.yml +1 -1
- data/examples/mcp/post_review/prompt.md +1 -1
- data/examples/pre_post_processing/analyze_test_file/prompt.md +1 -1
- data/examples/pre_post_processing/improve_test_coverage/prompt.md +1 -1
- data/examples/pre_post_processing/optimize_test_performance/prompt.md +1 -1
- data/examples/pre_post_processing/post_processing/aggregate_metrics/prompt.md +2 -2
- data/examples/pre_post_processing/post_processing/generate_summary_report/prompt.md +1 -1
- data/examples/pre_post_processing/pre_processing/setup_test_environment/prompt.md +1 -1
- data/examples/pre_post_processing/validate_changes/prompt.md +2 -2
- data/examples/user_input/README.md +90 -0
- data/examples/user_input/funny_name/create_backstory/prompt.md +10 -0
- data/examples/user_input/funny_name/workflow.yml +26 -0
- data/examples/user_input/generate_summary/prompt.md +11 -0
- data/examples/user_input/simple_input_demo/workflow.yml +35 -0
- data/examples/user_input/survey_workflow.yml +71 -0
- data/examples/user_input/welcome_message/prompt.md +3 -0
- data/examples/user_input/workflow.yml +73 -0
- data/examples/workflow_generator/create_workflow_files/prompt.md +1 -1
- data/lib/roast/errors.rb +6 -4
- data/lib/roast/helpers/function_caching_interceptor.rb +0 -2
- data/lib/roast/helpers/logger.rb +12 -35
- data/lib/roast/helpers/minitest_coverage_runner.rb +0 -1
- data/lib/roast/helpers/prompt_loader.rb +0 -2
- data/lib/roast/resources/api_resource.rb +0 -4
- data/lib/roast/resources/url_resource.rb +0 -3
- data/lib/roast/resources.rb +0 -8
- data/lib/roast/tools/ask_user.rb +0 -2
- data/lib/roast/tools/bash.rb +0 -3
- data/lib/roast/tools/cmd.rb +0 -3
- data/lib/roast/tools/coding_agent.rb +1 -8
- data/lib/roast/tools/grep.rb +0 -3
- data/lib/roast/tools/helpers/coding_agent_message_formatter.rb +1 -4
- data/lib/roast/tools/read_file.rb +0 -2
- data/lib/roast/tools/search_file.rb +0 -2
- data/lib/roast/tools/update_files.rb +0 -4
- data/lib/roast/tools/write_file.rb +0 -3
- data/lib/roast/tools.rb +0 -13
- data/lib/roast/value_objects/step_name.rb +14 -3
- data/lib/roast/value_objects/workflow_path.rb +0 -2
- data/lib/roast/value_objects.rb +4 -4
- data/lib/roast/version.rb +1 -1
- data/lib/roast/workflow/agent_step.rb +26 -0
- data/lib/roast/workflow/api_configuration.rb +0 -4
- data/lib/roast/workflow/base_iteration_step.rb +0 -4
- data/lib/roast/workflow/base_step.rb +54 -28
- data/lib/roast/workflow/base_workflow.rb +2 -21
- data/lib/roast/workflow/case_executor.rb +0 -1
- data/lib/roast/workflow/case_step.rb +0 -4
- data/lib/roast/workflow/command_executor.rb +0 -2
- data/lib/roast/workflow/conditional_executor.rb +0 -1
- data/lib/roast/workflow/conditional_step.rb +0 -4
- data/lib/roast/workflow/configuration.rb +3 -10
- data/lib/roast/workflow/configuration_loader.rb +0 -2
- data/lib/roast/workflow/configuration_parser.rb +1 -7
- data/lib/roast/workflow/dot_access_hash.rb +16 -1
- data/lib/roast/workflow/error_handler.rb +0 -3
- data/lib/roast/workflow/expression_evaluator.rb +0 -3
- data/lib/roast/workflow/file_state_repository.rb +0 -5
- data/lib/roast/workflow/input_executor.rb +41 -0
- data/lib/roast/workflow/input_step.rb +163 -0
- data/lib/roast/workflow/iteration_executor.rb +0 -2
- data/lib/roast/workflow/output_handler.rb +0 -2
- data/lib/roast/workflow/output_manager.rb +0 -2
- data/lib/roast/workflow/prompt_step.rb +1 -1
- data/lib/roast/workflow/replay_handler.rb +0 -3
- data/lib/roast/workflow/resource_resolver.rb +0 -3
- data/lib/roast/workflow/session_manager.rb +0 -3
- data/lib/roast/workflow/state_manager.rb +0 -2
- data/lib/roast/workflow/step_executor_coordinator.rb +34 -11
- data/lib/roast/workflow/step_executor_factory.rb +0 -5
- data/lib/roast/workflow/step_executor_registry.rb +1 -4
- data/lib/roast/workflow/step_executors/hash_step_executor.rb +0 -3
- data/lib/roast/workflow/step_executors/parallel_step_executor.rb +0 -3
- data/lib/roast/workflow/step_executors/string_step_executor.rb +0 -2
- data/lib/roast/workflow/step_factory.rb +56 -0
- data/lib/roast/workflow/step_loader.rb +30 -16
- data/lib/roast/workflow/step_orchestrator.rb +3 -2
- data/lib/roast/workflow/step_type_resolver.rb +28 -1
- data/lib/roast/workflow/validator.rb +0 -4
- data/lib/roast/workflow/workflow_executor.rb +0 -16
- data/lib/roast/workflow/workflow_initializer.rb +1 -8
- data/lib/roast/workflow/workflow_runner.rb +0 -7
- data/lib/roast/workflow.rb +0 -15
- data/lib/roast.rb +55 -10
- data/roast.gemspec +2 -1
- data/schema/workflow.json +46 -0
- metadata +44 -6
- data/lib/roast/helpers.rb +0 -12
data/claude-swarm.yml
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
version: 1
|
2
|
+
swarm:
|
3
|
+
name: "Roast Development Team"
|
4
|
+
main: lead_developer
|
5
|
+
instances:
|
6
|
+
lead_developer:
|
7
|
+
description: "Lead developer coordinating Roast gem development"
|
8
|
+
directory: .
|
9
|
+
model: opus
|
10
|
+
vibe: true
|
11
|
+
connections: [test_runner, code_quality, raix_expert, solid_critic, github_expert]
|
12
|
+
prompt: |
|
13
|
+
You are the lead developer for Roast, a convention-oriented framework for creating structured AI workflows. You coordinate the development team and make architectural decisions.
|
14
|
+
|
15
|
+
Your responsibilities:
|
16
|
+
- Coordinate feature development and bug fixes
|
17
|
+
- Review and integrate contributions from team members
|
18
|
+
- Ensure code consistency and project direction
|
19
|
+
- Make architectural decisions
|
20
|
+
- Manage the development workflow
|
21
|
+
|
22
|
+
You have access to a specialized team:
|
23
|
+
- test_runner: Runs and analyzes test results
|
24
|
+
- code_quality: Ensures code quality standards
|
25
|
+
- raix_expert: Provides expertise on the Raix gem for AI chat completions
|
26
|
+
- solid_critic: Reviews code for SOLID principles compliance
|
27
|
+
- github_expert: Handles all GitHub-related operations
|
28
|
+
|
29
|
+
When working on tasks:
|
30
|
+
1. Break down complex features into manageable pieces
|
31
|
+
2. Delegate specific aspects to appropriate team members
|
32
|
+
3. Integrate feedback and ensure all changes align with Roast's conventions
|
33
|
+
4. Always ensure tests pass before finalizing changes
|
34
|
+
|
35
|
+
For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.
|
36
|
+
|
37
|
+
test_runner:
|
38
|
+
description: "Test execution specialist for running and analyzing test results"
|
39
|
+
directory: .
|
40
|
+
model: sonnet
|
41
|
+
vibe: true
|
42
|
+
prompt: |
|
43
|
+
You are the test execution specialist for the Roast gem. Your role is to run tests, analyze results, and ensure comprehensive test coverage.
|
44
|
+
|
45
|
+
Your responsibilities:
|
46
|
+
- Run the full test suite using `bundle exec rake test`
|
47
|
+
- Run specific tests when requested
|
48
|
+
- Analyze test failures and provide detailed diagnostics
|
49
|
+
- Identify missing test coverage
|
50
|
+
- Suggest new test cases for edge scenarios
|
51
|
+
- Verify that new features have appropriate tests
|
52
|
+
|
53
|
+
When analyzing test results:
|
54
|
+
1. Clearly identify which tests are failing and why
|
55
|
+
2. Provide stack traces and relevant error messages
|
56
|
+
3. Suggest fixes for failing tests
|
57
|
+
4. Ensure tests follow RSpec best practices
|
58
|
+
5. Check for test isolation and avoid test interdependencies
|
59
|
+
|
60
|
+
For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.
|
61
|
+
|
62
|
+
code_quality:
|
63
|
+
description: "Code quality enforcer ensuring standards and best practices"
|
64
|
+
directory: .
|
65
|
+
model: sonnet
|
66
|
+
vibe: true
|
67
|
+
prompt: |
|
68
|
+
You are the code quality specialist for the Roast gem. Your role is to ensure all code meets high quality standards and follows Ruby best practices.
|
69
|
+
|
70
|
+
Your responsibilities:
|
71
|
+
- Run RuboCop for style checking: `bundle exec rubocop`
|
72
|
+
- Apply automatic fixes when safe: `bundle exec rubocop -A`
|
73
|
+
- Check for code smells and anti-patterns
|
74
|
+
- Ensure proper documentation with YARD comments
|
75
|
+
- Verify consistent naming conventions
|
76
|
+
- Check for performance issues
|
77
|
+
- Ensure proper error handling
|
78
|
+
|
79
|
+
Quality standards to enforce:
|
80
|
+
1. Ruby community style guide compliance
|
81
|
+
2. Clear and meaningful variable/method names
|
82
|
+
3. DRY (Don't Repeat Yourself) principle
|
83
|
+
4. Appropriate use of Ruby idioms
|
84
|
+
5. Proper exception handling with meaningful messages
|
85
|
+
6. Comprehensive inline documentation
|
86
|
+
|
87
|
+
When reviewing code:
|
88
|
+
- Provide specific line numbers for issues
|
89
|
+
- Suggest concrete improvements
|
90
|
+
- Explain why changes improve quality
|
91
|
+
|
92
|
+
For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.
|
93
|
+
|
94
|
+
raix_expert:
|
95
|
+
description: "Expert on the Raix gem for AI chat completions integration"
|
96
|
+
directory: ~/src/github.com/OlympiaAI/raix
|
97
|
+
model: opus
|
98
|
+
vibe: true
|
99
|
+
prompt: |
|
100
|
+
You are the Raix gem expert, specializing in AI chat completion integrations. Raix is a Ruby gem that provides a clean interface for AI chat completions, and you have deep knowledge of its architecture and usage patterns.
|
101
|
+
|
102
|
+
Your expertise includes:
|
103
|
+
- Raix's function dispatch pattern for tools
|
104
|
+
- Chat completion API abstractions
|
105
|
+
- Integration patterns with various AI providers
|
106
|
+
- Best practices for tool definitions
|
107
|
+
- Performance optimization for AI interactions
|
108
|
+
- Error handling in AI contexts
|
109
|
+
|
110
|
+
When consulted about Roast's AI integration:
|
111
|
+
1. Provide guidance on proper Raix usage patterns
|
112
|
+
2. Suggest optimal ways to structure tool definitions
|
113
|
+
3. Help integrate new AI capabilities using Raix
|
114
|
+
4. Ensure Roast's tools follow Raix conventions
|
115
|
+
5. Optimize AI interaction performance
|
116
|
+
6. Review function definitions for clarity and effectiveness
|
117
|
+
|
118
|
+
You have access to the Raix source code and can:
|
119
|
+
- Reference specific Raix implementation details
|
120
|
+
- Suggest patterns from Raix that could benefit Roast
|
121
|
+
- Ensure compatibility between Roast and Raix
|
122
|
+
- Provide examples of advanced Raix features
|
123
|
+
|
124
|
+
For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.
|
125
|
+
|
126
|
+
solid_critic:
|
127
|
+
description: "SOLID principles expert providing aggressive code critique"
|
128
|
+
directory: .
|
129
|
+
model: opus
|
130
|
+
vibe: true
|
131
|
+
prompt: |
|
132
|
+
You are a SOLID principles expert, channeling the expertise and style of Sandi Metz. You provide aggressive but constructive critique of code to ensure it follows SOLID principles and object-oriented design best practices.
|
133
|
+
|
134
|
+
Your approach:
|
135
|
+
- Be direct and uncompromising about violations
|
136
|
+
- Provide specific examples of how to improve
|
137
|
+
- Reference Sandi Metz's rules for developers
|
138
|
+
- Focus on practical, maintainable solutions
|
139
|
+
|
140
|
+
SOLID principles to enforce:
|
141
|
+
1. **Single Responsibility**: Each class should have only one reason to change
|
142
|
+
2. **Open/Closed**: Open for extension, closed for modification
|
143
|
+
3. **Liskov Substitution**: Subtypes must be substitutable for base types
|
144
|
+
4. **Interface Segregation**: Depend on abstractions, not concretions
|
145
|
+
5. **Dependency Inversion**: High-level modules shouldn't depend on low-level modules
|
146
|
+
|
147
|
+
Sandi Metz's rules to apply:
|
148
|
+
- Classes can be no longer than 100 lines of code
|
149
|
+
- Methods can be no longer than 5 lines of code
|
150
|
+
- Pass no more than 4 parameters into a method
|
151
|
+
- Controllers can instantiate only one object
|
152
|
+
|
153
|
+
When reviewing code:
|
154
|
+
1. Identify specific SOLID violations with line numbers
|
155
|
+
2. Explain why it's a problem (not just that it violates a rule)
|
156
|
+
3. Provide a refactored version that fixes the issue
|
157
|
+
4. Show how the refactoring improves maintainability
|
158
|
+
5. Be aggressive but educational - every critique should teach
|
159
|
+
|
160
|
+
Common code smells to attack:
|
161
|
+
- Large classes doing too much
|
162
|
+
- Methods with multiple responsibilities
|
163
|
+
- Tight coupling between classes
|
164
|
+
- Inheritance used inappropriately
|
165
|
+
- Primitive obsession
|
166
|
+
- Feature envy
|
167
|
+
|
168
|
+
Remember: "The road to programming hell is paved with global variables and side effects."
|
169
|
+
|
170
|
+
For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.
|
171
|
+
|
172
|
+
github_expert:
|
173
|
+
description: "GitHub operations specialist using gh CLI"
|
174
|
+
directory: .
|
175
|
+
model: sonnet
|
176
|
+
vibe: true
|
177
|
+
prompt: |
|
178
|
+
You are the GitHub operations specialist for the Roast gem project. You handle all GitHub-related tasks using the `gh` command-line tool.
|
179
|
+
|
180
|
+
Your responsibilities:
|
181
|
+
- Create and manage issues: `gh issue create`, `gh issue list`
|
182
|
+
- Handle pull requests: `gh pr create`, `gh pr review`, `gh pr merge`
|
183
|
+
- Manage releases: `gh release create`
|
184
|
+
- Check workflow runs: `gh run list`, `gh run view`
|
185
|
+
- Manage repository settings and configurations
|
186
|
+
- Handle branch operations and protection rules
|
187
|
+
|
188
|
+
Common operations you perform:
|
189
|
+
1. Creating feature branches and PRs
|
190
|
+
2. Running and monitoring CI/CD workflows
|
191
|
+
3. Managing issue labels and milestones
|
192
|
+
4. Creating releases with proper changelogs
|
193
|
+
5. Reviewing and merging pull requests
|
194
|
+
6. Setting up GitHub Actions workflows
|
195
|
+
|
196
|
+
Best practices to follow:
|
197
|
+
- Always create feature branches for new work
|
198
|
+
- Write clear PR descriptions with context
|
199
|
+
- Ensure CI passes before merging
|
200
|
+
- Use conventional commit messages
|
201
|
+
- Tag releases following semantic versioning
|
202
|
+
- Keep issues organized with appropriate labels
|
203
|
+
|
204
|
+
When working with the team:
|
205
|
+
- Create issues for bugs found by test_runner
|
206
|
+
- Open PRs for code reviewed by solid_critic
|
207
|
+
- Set up CI to run code_quality checks
|
208
|
+
- Document Raix integration in wiki/docs
|
209
|
+
|
210
|
+
For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.
|
data/docs/AGENT_STEPS.md
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
# Agent Steps in Roast
|
2
|
+
|
3
|
+
Agent steps provide a way to send prompts directly to a coding agent (like Claude Code) without going through the standard LLM translation layer. This document explains when and how to use agent steps effectively.
|
4
|
+
|
5
|
+
## What are Agent Steps?
|
6
|
+
|
7
|
+
Agent steps are denoted by prefixing a step name with `^`. They bypass the normal LLM processing and send your prompt content directly to the CodingAgent tool.
|
8
|
+
|
9
|
+
```yaml
|
10
|
+
steps:
|
11
|
+
# File-based prompts
|
12
|
+
- analyze_code # Regular step - processed by LLM first
|
13
|
+
- ^implement_fix # Agent step - direct to CodingAgent
|
14
|
+
|
15
|
+
# Inline prompts
|
16
|
+
- Analyze the code quality and suggest improvements # Regular inline
|
17
|
+
- ^Fix all ESLint errors and apply Prettier formatting # Agent inline
|
18
|
+
```
|
19
|
+
|
20
|
+
Both file-based prompts (with directories like `implement_fix/prompt.md`) and inline prompts (text with spaces) are supported.
|
21
|
+
|
22
|
+
## When to Use Agent Steps
|
23
|
+
|
24
|
+
### Use Agent Steps When:
|
25
|
+
|
26
|
+
1. **You need precise control over tool usage**
|
27
|
+
- When you want to ensure specific tools are used in a particular way
|
28
|
+
- When the task requires exact file manipulations or code transformations
|
29
|
+
|
30
|
+
2. **Complex multi-file operations**
|
31
|
+
- When coordinating changes across multiple files
|
32
|
+
- When the operation requires specific sequencing of edits
|
33
|
+
|
34
|
+
3. **Performance optimization**
|
35
|
+
- When you want to skip the LLM interpretation layer
|
36
|
+
- For well-defined tasks that don't need additional context
|
37
|
+
|
38
|
+
### Use Regular Steps When:
|
39
|
+
|
40
|
+
1. **You need natural language processing**
|
41
|
+
- When the prompt benefits from LLM interpretation
|
42
|
+
- When you want the LLM to add context or reasoning
|
43
|
+
|
44
|
+
2. **Flexible, adaptive responses**
|
45
|
+
- When the exact approach might vary based on context
|
46
|
+
- When you want the LLM to make judgment calls
|
47
|
+
|
48
|
+
## Practical Examples
|
49
|
+
|
50
|
+
### Example 1: Database Migration
|
51
|
+
|
52
|
+
**Regular Step (analyze_migration/prompt.md):**
|
53
|
+
```markdown
|
54
|
+
Look at the user's database schema and determine what migrations might be needed to support the new features they've described. Consider best practices for database design.
|
55
|
+
```
|
56
|
+
|
57
|
+
This benefits from LLM interpretation because:
|
58
|
+
- It needs to understand "best practices" in context
|
59
|
+
- It should make judgments about schema design
|
60
|
+
- The approach varies based on the specific features
|
61
|
+
|
62
|
+
**Agent Step (^apply_migration/prompt.md):**
|
63
|
+
```markdown
|
64
|
+
Create a new migration file with the following specifications:
|
65
|
+
|
66
|
+
1. Use MultiEdit to create file: db/migrate/{{timestamp}}_add_user_preferences.rb
|
67
|
+
2. The migration must include:
|
68
|
+
- Add column :users, :preferences, :jsonb, default: {}
|
69
|
+
- Add index :users, :preferences, using: :gin
|
70
|
+
- Add column :users, :notification_settings, :jsonb, default: {}
|
71
|
+
3. Ensure proper up/down methods
|
72
|
+
4. Follow Rails migration conventions exactly
|
73
|
+
|
74
|
+
Required tools: MultiEdit
|
75
|
+
Do not use Write tool for migrations.
|
76
|
+
```
|
77
|
+
|
78
|
+
This is better as an agent step because:
|
79
|
+
- It requires specific tool usage (MultiEdit, not Write)
|
80
|
+
- The instructions are precise and technical
|
81
|
+
- No interpretation needed - just execution
|
82
|
+
|
83
|
+
### Example 2: Code Refactoring
|
84
|
+
|
85
|
+
**Regular Step (identify_code_smells/prompt.md):**
|
86
|
+
```markdown
|
87
|
+
Review the provided code and identify any code smells or anti-patterns. Consider things like:
|
88
|
+
- Long methods that do too much
|
89
|
+
- Duplicated code
|
90
|
+
- Poor naming
|
91
|
+
- Tight coupling
|
92
|
+
- Missing abstractions
|
93
|
+
|
94
|
+
Explain why each identified issue is problematic.
|
95
|
+
```
|
96
|
+
|
97
|
+
This works well as a regular step because it requires judgment and explanation.
|
98
|
+
|
99
|
+
**Agent Step (^extract_method/prompt.md):**
|
100
|
+
```markdown
|
101
|
+
Extract the authentication logic from UserController#create into a separate method:
|
102
|
+
|
103
|
+
1. Read file: app/controllers/user_controller.rb
|
104
|
+
2. Find the code block from line 15-28 (the authentication logic)
|
105
|
+
3. Create a new private method called `authenticate_user_params`
|
106
|
+
4. Move the authentication logic to this new method
|
107
|
+
5. Replace the original code with a call to the new method
|
108
|
+
6. Ensure all variables are properly passed
|
109
|
+
|
110
|
+
Use MultiEdit to make all changes in a single operation.
|
111
|
+
Preserve exact indentation and formatting.
|
112
|
+
```
|
113
|
+
|
114
|
+
This is ideal as an agent step because:
|
115
|
+
- Specific line numbers and method names
|
116
|
+
- Exact refactoring instructions
|
117
|
+
- No room for interpretation
|
118
|
+
|
119
|
+
### Example 3: Test Generation
|
120
|
+
|
121
|
+
**Regular Step (plan_test_coverage/prompt.md):**
|
122
|
+
```markdown
|
123
|
+
Analyze the {{file}} and determine what test cases would provide comprehensive coverage. Consider:
|
124
|
+
- Happy path scenarios
|
125
|
+
- Edge cases
|
126
|
+
- Error conditions
|
127
|
+
- Boundary values
|
128
|
+
|
129
|
+
Focus on behavior, not implementation details.
|
130
|
+
```
|
131
|
+
|
132
|
+
**Agent Step (^implement_tests/prompt.md):**
|
133
|
+
```markdown
|
134
|
+
Create test file: test/models/user_validator_test.rb
|
135
|
+
|
136
|
+
Implement exactly these test cases:
|
137
|
+
1. test "validates email format"
|
138
|
+
- Use valid emails: ["user@example.com", "test.user+tag@domain.co.uk"]
|
139
|
+
- Use invalid emails: ["invalid", "@example.com", "user@", "user space@example.com"]
|
140
|
+
|
141
|
+
2. test "validates age is positive integer"
|
142
|
+
- Valid: [18, 25, 100]
|
143
|
+
- Invalid: [-1, 0, 17, 101, "twenty", nil]
|
144
|
+
|
145
|
+
3. test "validates username uniqueness"
|
146
|
+
- Create user with username "testuser"
|
147
|
+
- Attempt to create second user with same username
|
148
|
+
- Assert validation error on :username
|
149
|
+
|
150
|
+
Use minitest assertion style.
|
151
|
+
Each test must be independent.
|
152
|
+
Use setup method for common test data.
|
153
|
+
```
|
154
|
+
|
155
|
+
### Example 4: API Integration
|
156
|
+
|
157
|
+
**Regular Step (design_api_client/prompt.md):**
|
158
|
+
```markdown
|
159
|
+
Design a client for the {{api_name}} API that follows Ruby best practices. Consider:
|
160
|
+
- Error handling strategies
|
161
|
+
- Rate limiting
|
162
|
+
- Authentication patterns
|
163
|
+
- Response parsing
|
164
|
+
- Testing approach
|
165
|
+
|
166
|
+
Suggest an architecture that will be maintainable and extensible.
|
167
|
+
```
|
168
|
+
|
169
|
+
**Agent Step (^implement_api_client/prompt.md):**
|
170
|
+
```markdown
|
171
|
+
Implement the API client with this exact structure:
|
172
|
+
|
173
|
+
1. Create file: lib/external_apis/weather_api/client.rb
|
174
|
+
```ruby
|
175
|
+
module ExternalApis
|
176
|
+
module WeatherApi
|
177
|
+
class Client
|
178
|
+
include HTTParty
|
179
|
+
base_uri 'https://api.weather.com/v1'
|
180
|
+
|
181
|
+
def initialize(api_key)
|
182
|
+
@api_key = api_key
|
183
|
+
@options = { headers: { 'Authorization' => "Bearer #{api_key}" } }
|
184
|
+
end
|
185
|
+
|
186
|
+
def current_weather(location)
|
187
|
+
response = self.class.get("/current", @options.merge(query: { location: location }))
|
188
|
+
handle_response(response)
|
189
|
+
end
|
190
|
+
|
191
|
+
private
|
192
|
+
|
193
|
+
def handle_response(response)
|
194
|
+
raise ApiError, response.message unless response.success?
|
195
|
+
response.parsed_response
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
```
|
201
|
+
|
202
|
+
2. Create file: lib/external_apis/weather_api/api_error.rb
|
203
|
+
Define custom exception class
|
204
|
+
|
205
|
+
3. Update file: config/initializers/weather_api.rb
|
206
|
+
Add configuration for API endpoint and timeout
|
207
|
+
|
208
|
+
Use exact module structure and method signatures shown.
|
209
|
+
```
|
210
|
+
|
211
|
+
## Best Practices
|
212
|
+
|
213
|
+
1. **Be explicit about tool usage in agent steps**
|
214
|
+
```markdown
|
215
|
+
# Good agent step
|
216
|
+
Use MultiEdit tool to update the following files:
|
217
|
+
- app/models/user.rb: Add validation
|
218
|
+
- test/models/user_test.rb: Add test case
|
219
|
+
|
220
|
+
# Avoid in agent steps
|
221
|
+
Update the user model with better validation
|
222
|
+
```
|
223
|
+
|
224
|
+
2. **Include specific line numbers or code markers when possible**
|
225
|
+
```markdown
|
226
|
+
# Good agent step
|
227
|
+
In app/controllers/application_controller.rb:
|
228
|
+
- Find method `authenticate_user!` (around line 45)
|
229
|
+
- Add the following before the redirect_to call:
|
230
|
+
session[:return_to] = request.fullpath
|
231
|
+
```
|
232
|
+
|
233
|
+
3. **Specify exact formatting requirements**
|
234
|
+
```markdown
|
235
|
+
# Good agent step
|
236
|
+
Create method with exactly this signature:
|
237
|
+
def calculate_tax(amount, rate = 0.08)
|
238
|
+
|
239
|
+
Ensure:
|
240
|
+
- Two-space indentation
|
241
|
+
- No trailing whitespace
|
242
|
+
- Blank line before method definition
|
243
|
+
```
|
244
|
+
|
245
|
+
4. **Chain agent steps for complex operations**
|
246
|
+
```yaml
|
247
|
+
steps:
|
248
|
+
# First understand the system
|
249
|
+
- analyze_current_architecture
|
250
|
+
|
251
|
+
# Then execute precise changes
|
252
|
+
- ^create_service_objects
|
253
|
+
- ^update_controllers
|
254
|
+
- ^add_test_coverage
|
255
|
+
|
256
|
+
# Finally verify
|
257
|
+
- verify_all_tests_pass
|
258
|
+
```
|
259
|
+
|
260
|
+
## Summary
|
261
|
+
|
262
|
+
Agent steps are powerful when you need direct control over tool usage and precise execution of technical tasks. They complement regular steps by handling the implementation details while regular steps handle the analysis and planning.
|
263
|
+
|
264
|
+
Choose agent steps when precision matters more than interpretation. Choose regular steps when context and judgment are important.
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Agent Workflow Example
|
2
|
+
|
3
|
+
This example demonstrates the practical differences between regular steps and agent steps in Roast workflows.
|
4
|
+
|
5
|
+
## What are Agent Steps?
|
6
|
+
|
7
|
+
Agent steps are a special type of step that sends prompts directly to the CodingAgent tool (e.g., Claude Code) without going through the normal LLM translation layer. They're denoted by prefixing the step name with `^`.
|
8
|
+
|
9
|
+
## When to Use Each Type
|
10
|
+
|
11
|
+
### Regular Steps
|
12
|
+
Best for tasks that benefit from LLM interpretation:
|
13
|
+
- Analysis and judgment tasks
|
14
|
+
- Natural language understanding
|
15
|
+
- Flexible responses based on context
|
16
|
+
- Summary and explanation generation
|
17
|
+
|
18
|
+
### Agent Steps
|
19
|
+
Best for tasks requiring precise tool control:
|
20
|
+
- Exact code refactoring operations
|
21
|
+
- Multi-file coordinated changes
|
22
|
+
- Specific tool usage requirements
|
23
|
+
- Performance-critical operations
|
24
|
+
|
25
|
+
## Workflow Structure
|
26
|
+
|
27
|
+
This example demonstrates a code refactoring workflow:
|
28
|
+
|
29
|
+
1. **identify_code_smells** (Regular Step)
|
30
|
+
- Analyzes code to identify issues
|
31
|
+
- Uses LLM judgment to prioritize problems
|
32
|
+
- Provides contextual explanations
|
33
|
+
|
34
|
+
2. **^apply_refactorings** (Agent Step)
|
35
|
+
- Executes precise refactoring operations
|
36
|
+
- Uses specific tools (Read, MultiEdit) directly
|
37
|
+
- Follows exact formatting requirements
|
38
|
+
- No interpretation needed - just execution
|
39
|
+
|
40
|
+
3. **summarize_improvements** (Regular Step)
|
41
|
+
- Reviews all changes made
|
42
|
+
- Generates human-friendly summary
|
43
|
+
- Provides recommendations
|
44
|
+
|
45
|
+
## Running the Workflow
|
46
|
+
|
47
|
+
```bash
|
48
|
+
# Run on all Ruby files in current directory
|
49
|
+
roast execute examples/agent_workflow/workflow.yml
|
50
|
+
|
51
|
+
# Run on specific files
|
52
|
+
roast execute examples/agent_workflow/workflow.yml app/models/*.rb
|
53
|
+
```
|
54
|
+
|
55
|
+
## Key Differences in Practice
|
56
|
+
|
57
|
+
### Regular Step Example
|
58
|
+
The `identify_code_smells` step benefits from LLM interpretation because:
|
59
|
+
- It needs to understand "code smells" in context
|
60
|
+
- It makes subjective judgments about code quality
|
61
|
+
- It prioritizes issues based on impact
|
62
|
+
|
63
|
+
### Agent Step Example
|
64
|
+
The `^apply_refactorings` step works better as an agent step because:
|
65
|
+
- It requires specific tool usage (MultiEdit, not Write)
|
66
|
+
- It needs exact preservation of formatting
|
67
|
+
- It follows precise refactoring patterns
|
68
|
+
- No interpretation is needed - just execution
|
69
|
+
|
70
|
+
## Benefits Demonstrated
|
71
|
+
|
72
|
+
1. **Complementary Strengths**: Regular steps handle analysis and planning, agent steps handle precise execution
|
73
|
+
2. **Better Performance**: Agent steps skip the LLM layer for well-defined tasks
|
74
|
+
3. **Predictable Results**: Agent steps execute exactly as specified
|
75
|
+
4. **Tool Control**: Agent steps can enforce specific tool usage patterns
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Based on the code smells identified in the previous step, apply the following refactorings:
|
2
|
+
|
3
|
+
For each file that needs changes:
|
4
|
+
|
5
|
+
1. Use the Read tool to examine the current implementation
|
6
|
+
2. Use MultiEdit to apply all refactorings in a single operation per file
|
7
|
+
3. Ensure all changes maintain exact formatting and indentation
|
8
|
+
4. Focus on these specific refactorings:
|
9
|
+
- Extract long methods (>15 lines) into smaller, focused methods
|
10
|
+
- Replace magic numbers with named constants
|
11
|
+
- Rename variables/methods that don't clearly express intent
|
12
|
+
- Extract duplicate code into shared methods
|
13
|
+
- Add proper error handling where missing
|
14
|
+
|
15
|
+
Important constraints:
|
16
|
+
- DO NOT change the public API of any class
|
17
|
+
- DO NOT modify test files
|
18
|
+
- DO NOT add comments unless replacing unclear code
|
19
|
+
- Preserve all existing functionality
|
20
|
+
- Use Ruby idioms and conventions
|
21
|
+
|
22
|
+
After each file modification, verify the changes maintain the original behavior.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Analyze the provided Ruby code and identify potential code smells or areas for improvement. Consider:
|
2
|
+
|
3
|
+
1. Method complexity and length
|
4
|
+
2. Duplicated code patterns
|
5
|
+
3. Poor naming conventions
|
6
|
+
4. Tight coupling between classes
|
7
|
+
5. Missing abstractions or violated SOLID principles
|
8
|
+
6. Performance anti-patterns
|
9
|
+
|
10
|
+
For each issue found, explain:
|
11
|
+
- What the problem is
|
12
|
+
- Why it's problematic
|
13
|
+
- A general approach to fix it
|
14
|
+
|
15
|
+
Focus on the most impactful improvements that would enhance code maintainability and readability.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Review the refactorings that were applied and provide a comprehensive summary that includes:
|
2
|
+
|
3
|
+
1. **Overview of Changes**
|
4
|
+
- Number of files modified
|
5
|
+
- Types of refactorings applied
|
6
|
+
- Overall impact on code quality
|
7
|
+
|
8
|
+
2. **Key Improvements**
|
9
|
+
- Most significant refactorings and their benefits
|
10
|
+
- Complexity reductions achieved
|
11
|
+
- Readability enhancements
|
12
|
+
|
13
|
+
3. **Recommendations for Future**
|
14
|
+
- Any remaining code smells that require larger architectural changes
|
15
|
+
- Suggested next steps for continued improvement
|
16
|
+
- Areas that would benefit from additional test coverage
|
17
|
+
|
18
|
+
Format the summary in a way that would be useful for a code review or team discussion.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
description: Example workflow demonstrating agent steps
|
2
|
+
|
3
|
+
# Agent steps send prompts directly to CodingAgent (e.g., Claude Code)
|
4
|
+
# without the intermediate LLM translation layer
|
5
|
+
|
6
|
+
target: "**/*.rb"
|
7
|
+
|
8
|
+
steps:
|
9
|
+
# Regular step - goes through LLM first for analysis and judgment
|
10
|
+
- identify_code_smells
|
11
|
+
|
12
|
+
# Agent step - direct to CodingAgent for precise refactoring
|
13
|
+
- ^apply_refactorings
|
14
|
+
|
15
|
+
# Regular step - verify changes and provide summary
|
16
|
+
- summarize_improvements
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Available Tools Demo
|
2
|
+
|
3
|
+
This example demonstrates the `available_tools` feature in Roast, which allows you to restrict which tools are available to specific steps in your workflow.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
The workflow consists of three steps, each with different tool access:
|
8
|
+
|
9
|
+
1. **explore_directory**: Can only use `pwd` and `ls` commands
|
10
|
+
2. **analyze_files**: Can only use `grep` and `read_file` tools
|
11
|
+
3. **write_summary**: Can only use `write_file` and `echo` tools
|
12
|
+
|
13
|
+
## Key Features Demonstrated
|
14
|
+
|
15
|
+
### Security Through Least Privilege
|
16
|
+
Each step only has access to the tools it needs. For example, the exploration step cannot write files, and the summary step cannot read files or explore directories.
|
17
|
+
|
18
|
+
### Tool Name Convention
|
19
|
+
- For built-in tools: Use snake_case names (e.g., `read_file` for `Roast::Tools::ReadFile`)
|
20
|
+
- For Cmd tool: Use the specific command names (e.g., `pwd`, `ls`)
|
21
|
+
|
22
|
+
### Configuration Structure
|
23
|
+
```yaml
|
24
|
+
step_name:
|
25
|
+
available_tools:
|
26
|
+
- tool1
|
27
|
+
- tool2
|
28
|
+
```
|
29
|
+
|
30
|
+
## Running the Example
|
31
|
+
|
32
|
+
```bash
|
33
|
+
roast examples/available_tools_demo/workflow.yml
|
34
|
+
```
|
35
|
+
|
36
|
+
## What Happens
|
37
|
+
|
38
|
+
1. The first step explores the current directory using only `pwd` and `ls`
|
39
|
+
2. The second step searches for Ruby files and reads one using only `grep` and `read_file`
|
40
|
+
3. The final step creates a summary file using only `write_file` and `echo`
|
41
|
+
|
42
|
+
Each step is restricted to its specified tools, demonstrating how you can create secure, focused workflows where each step has exactly the capabilities it needs.
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Based on the directory listing from the previous step, your task is to:
|
2
|
+
|
3
|
+
1. Search for any Ruby files using grep
|
4
|
+
2. Read the contents of the first Ruby file you find
|
5
|
+
|
6
|
+
Note: You only have access to the `grep` and `read_file` tools for this step. You cannot use commands like `ls` or `pwd`.
|