roast-ai 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yaml +2 -2
- data/.gitignore +1 -0
- data/CHANGELOG.md +85 -0
- data/CLAUDE.md +106 -9
- data/Gemfile +4 -1
- data/Gemfile.lock +70 -16
- data/README.md +159 -8
- data/bin/console +1 -0
- data/bin/roast +1 -1
- data/claude-swarm.yml +210 -0
- data/docs/AGENT_STEPS.md +288 -0
- data/docs/VALIDATION.md +178 -0
- data/examples/agent_continue/add_documentation/prompt.md +5 -0
- data/examples/agent_continue/add_error_handling/prompt.md +5 -0
- data/examples/agent_continue/analyze_codebase/prompt.md +7 -0
- data/examples/agent_continue/combined_workflow.yml +24 -0
- data/examples/agent_continue/continue_adding_features/prompt.md +4 -0
- data/examples/agent_continue/create_integration_tests/prompt.md +3 -0
- data/examples/agent_continue/document_with_context/prompt.md +5 -0
- data/examples/agent_continue/explore_api/prompt.md +6 -0
- data/examples/agent_continue/implement_client/prompt.md +6 -0
- data/examples/agent_continue/inline_workflow.yml +20 -0
- data/examples/agent_continue/refactor_code/prompt.md +2 -0
- data/examples/agent_continue/verify_changes/prompt.md +6 -0
- data/examples/agent_continue/workflow.yml +27 -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.png +0 -0
- data/examples/agent_workflow/workflow.yml +16 -0
- data/examples/api_workflow/workflow.png +0 -0
- data/examples/apply_diff_demo/README.md +58 -0
- data/examples/apply_diff_demo/apply_simple_change/prompt.md +13 -0
- data/examples/apply_diff_demo/create_sample_file/prompt.md +11 -0
- data/examples/apply_diff_demo/workflow.yml +24 -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.png +0 -0
- data/examples/available_tools_demo/workflow.yml +32 -0
- data/examples/available_tools_demo/write_summary/prompt.md +6 -0
- data/examples/bash_prototyping/api_testing.png +0 -0
- data/examples/bash_prototyping/system_analysis.png +0 -0
- data/examples/case_when/detect_language/prompt.md +2 -2
- data/examples/case_when/workflow.png +0 -0
- data/examples/cmd/basic_workflow.png +0 -0
- data/examples/cmd/dev_workflow.png +0 -0
- data/examples/cmd/explorer_workflow.png +0 -0
- data/examples/conditional/simple_workflow.png +0 -0
- data/examples/conditional/workflow.png +0 -0
- data/examples/context_management_demo/README.md +43 -0
- data/examples/context_management_demo/workflow.yml +42 -0
- data/examples/direct_coerce_syntax/workflow.png +0 -0
- data/examples/dot_notation/workflow.png +0 -0
- data/examples/exit_on_error/workflow.png +0 -0
- data/examples/grading/run_coverage.rb +0 -2
- data/examples/grading/workflow.png +0 -0
- data/examples/interpolation/workflow.png +0 -0
- data/examples/interpolation/workflow.yml +1 -1
- 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/iteration/workflow.png +0 -0
- data/examples/json_handling/workflow.png +0 -0
- data/examples/mcp/README.md +3 -3
- data/examples/mcp/analyze_changes/prompt.md +1 -1
- data/examples/mcp/database_workflow.png +0 -0
- data/examples/mcp/database_workflow.yml +1 -1
- data/examples/mcp/env_demo/workflow.png +0 -0
- data/examples/mcp/fetch_pr_context/prompt.md +1 -1
- data/examples/mcp/filesystem_demo/workflow.png +0 -0
- data/examples/mcp/github_workflow.png +0 -0
- data/examples/mcp/github_workflow.yml +1 -1
- data/examples/mcp/multi_mcp_workflow.png +0 -0
- data/examples/mcp/post_review/prompt.md +1 -1
- data/examples/mcp/workflow.png +0 -0
- data/examples/no_model_fallback/README.md +17 -0
- data/examples/no_model_fallback/analyze_file/prompt.md +1 -0
- data/examples/no_model_fallback/analyze_patterns/prompt.md +27 -0
- data/examples/no_model_fallback/generate_report_for_md/prompt.md +10 -0
- data/examples/no_model_fallback/generate_report_for_rb/prompt.md +3 -0
- data/examples/no_model_fallback/sample.rb +42 -0
- data/examples/no_model_fallback/workflow.yml +19 -0
- data/examples/openrouter_example/workflow.png +0 -0
- 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/pre_post_processing/workflow.png +0 -0
- data/examples/rspec_to_minitest/workflow.png +0 -0
- data/examples/shared_config/example_with_shared_config/workflow.png +0 -0
- data/examples/shared_config/shared.png +0 -0
- data/examples/single_target_prepost/workflow.png +0 -0
- data/examples/smart_coercion_defaults/workflow.png +0 -0
- data/examples/step_configuration/workflow.png +0 -0
- data/examples/swarm_example.yml +25 -0
- data/examples/tool_config_example/workflow.png +0 -0
- 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.png +0 -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.png +0 -0
- data/examples/user_input/simple_input_demo/workflow.yml +35 -0
- data/examples/user_input/survey_workflow.png +0 -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.png +0 -0
- data/examples/user_input/workflow.yml +73 -0
- data/examples/workflow_generator/create_workflow_files/prompt.md +1 -1
- data/examples/workflow_generator/workflow.png +0 -0
- 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/helpers/timeout_handler.rb +91 -0
- 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/services/context_threshold_checker.rb +42 -0
- data/lib/roast/services/token_counting_service.rb +44 -0
- data/lib/roast/tools/apply_diff.rb +128 -0
- data/lib/roast/tools/ask_user.rb +0 -2
- data/lib/roast/tools/bash.rb +12 -9
- data/lib/roast/tools/cmd.rb +29 -12
- data/lib/roast/tools/coding_agent.rb +65 -17
- data/lib/roast/tools/context_summarizer.rb +108 -0
- 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/swarm.rb +124 -0
- 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 +33 -0
- data/lib/roast/workflow/api_configuration.rb +0 -4
- data/lib/roast/workflow/base_iteration_step.rb +3 -6
- data/lib/roast/workflow/base_step.rb +54 -28
- data/lib/roast/workflow/base_workflow.rb +43 -23
- 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 +5 -67
- data/lib/roast/workflow/configuration_loader.rb +63 -3
- data/lib/roast/workflow/configuration_parser.rb +1 -7
- data/lib/roast/workflow/context_manager.rb +89 -0
- data/lib/roast/workflow/dot_access_hash.rb +16 -1
- data/lib/roast/workflow/each_step.rb +1 -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 +1 -3
- data/lib/roast/workflow/output_manager.rb +0 -2
- data/lib/roast/workflow/repeat_step.rb +1 -1
- data/lib/roast/workflow/replay_handler.rb +1 -4
- data/lib/roast/workflow/resource_resolver.rb +0 -3
- data/lib/roast/workflow/session_manager.rb +0 -3
- data/lib/roast/workflow/sqlite_state_repository.rb +342 -0
- data/lib/roast/workflow/state_manager.rb +2 -4
- data/lib/roast/workflow/state_repository_factory.rb +36 -0
- data/lib/roast/workflow/step_completion_reporter.rb +27 -0
- data/lib/roast/workflow/step_executor_coordinator.rb +48 -24
- 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_executor_with_reporting.rb +68 -0
- 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 +31 -17
- data/lib/roast/workflow/step_name_extractor.rb +84 -0
- data/lib/roast/workflow/step_orchestrator.rb +3 -2
- data/lib/roast/workflow/step_type_resolver.rb +28 -1
- data/lib/roast/workflow/validation_command.rb +197 -0
- data/lib/roast/workflow/validator.rb +0 -4
- data/lib/roast/workflow/validators/base_validator.rb +44 -0
- data/lib/roast/workflow/validators/dependency_validator.rb +223 -0
- data/lib/roast/workflow/validators/linting_validator.rb +113 -0
- data/lib/roast/workflow/validators/schema_validator.rb +90 -0
- data/lib/roast/workflow/validators/step_collector.rb +57 -0
- data/lib/roast/workflow/validators/validation_orchestrator.rb +52 -0
- data/lib/roast/workflow/workflow_executor.rb +11 -20
- data/lib/roast/workflow/workflow_initializer.rb +1 -8
- data/lib/roast/workflow/workflow_runner.rb +6 -7
- data/lib/roast/workflow.rb +0 -15
- data/lib/roast/workflow_diagram_generator.rb +298 -0
- data/lib/roast.rb +212 -10
- data/roast.gemspec +4 -2
- data/schema/workflow.json +123 -1
- metadata +143 -6
- data/lib/roast/helpers.rb +0 -12
@@ -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.
|
Binary file
|
@@ -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
|
Binary file
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Apply Diff Demo
|
2
|
+
|
3
|
+
This example demonstrates the `apply_diff` tool, which shows users a colored diff of proposed changes and applies them only after user confirmation.
|
4
|
+
|
5
|
+
## What this workflow does
|
6
|
+
|
7
|
+
1. **Creates a sample file** - Generates `hello.txt` with simple text content
|
8
|
+
2. **Applies a simple change** - Uses `apply_diff` to modify the greeting and ask for user confirmation
|
9
|
+
|
10
|
+
## Key features demonstrated
|
11
|
+
|
12
|
+
- **Interactive approval** - The `apply_diff` tool shows a clear, colored diff and waits for user confirmation
|
13
|
+
- **Safe modifications** - Changes are only applied when the user explicitly approves them
|
14
|
+
- **Colored visualization** - Diff format shows exactly what will be changed with:
|
15
|
+
- **Red** lines starting with `-` for removed content
|
16
|
+
- **Green** lines starting with `+` for added content
|
17
|
+
- **Cyan** line numbers and context (`@@` lines)
|
18
|
+
- **Bold** diff headers
|
19
|
+
- **Optional descriptions** - You can provide context about why a change is being made
|
20
|
+
|
21
|
+
## Running the workflow
|
22
|
+
|
23
|
+
```bash
|
24
|
+
bin/roast examples/apply_diff_demo/workflow.yml
|
25
|
+
```
|
26
|
+
|
27
|
+
## Expected interaction
|
28
|
+
|
29
|
+
When you run this workflow, you'll see:
|
30
|
+
|
31
|
+
1. The workflow creates a simple `hello.txt` file
|
32
|
+
2. It proposes changing "Hello World!" to "Hello, Apply Diff Demo!"
|
33
|
+
3. It shows you a colored diff of the proposed change:
|
34
|
+
```
|
35
|
+
📝 Proposed change for hello.txt:
|
36
|
+
Description: Update greeting to be more specific to the demo
|
37
|
+
|
38
|
+
diff --git a/hello.txt b/hello.txt
|
39
|
+
index 1234567..abcdefg 100644
|
40
|
+
--- a/hello.txt
|
41
|
+
+++ b/hello.txt
|
42
|
+
@@ -1,3 +1,3 @@
|
43
|
+
-Hello World!
|
44
|
+
+Hello, Apply Diff Demo!
|
45
|
+
This is a demo file.
|
46
|
+
We will modify this file in the next step.
|
47
|
+
```
|
48
|
+
4. It asks for your confirmation: `Apply this change? (y/n)`
|
49
|
+
5. If you say "y", it applies the change; if "n", it cancels
|
50
|
+
6. Finally, it reads the file again to show the result
|
51
|
+
|
52
|
+
## Tools used
|
53
|
+
|
54
|
+
- `Roast::Tools::WriteFile` - Creates the initial sample file
|
55
|
+
- `Roast::Tools::ReadFile` - Reads files to show results
|
56
|
+
- `Roast::Tools::ApplyDiff` - Shows colored diffs and applies changes with user confirmation
|
57
|
+
|
58
|
+
This pattern is useful for any workflow where you want to make targeted changes to files but give users control over what actually gets applied.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Apply Simple Change
|
2
|
+
|
3
|
+
Now use the apply_diff function to modify the `hello.txt` file. Let's change the greeting from "Hello World!" to "Hello, Apply Diff Demo!".
|
4
|
+
|
5
|
+
Use the apply_diff function with:
|
6
|
+
- `file_path`: "hello.txt"
|
7
|
+
- `old_content`: "Hello World!"
|
8
|
+
- `new_content`: "Hello, Apply Diff Demo!"
|
9
|
+
- `description`: "Update greeting to be more specific to the demo"
|
10
|
+
|
11
|
+
This will show the user a colored diff of the proposed change and ask for their confirmation before applying it.
|
12
|
+
|
13
|
+
After the change is applied (or declined), read the file again to show the final result.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Apply Diff Demo
|
2
|
+
#
|
3
|
+
# This workflow demonstrates the apply_diff tool which shows users a diff
|
4
|
+
# and applies changes based on their confirmation. It's useful for making
|
5
|
+
# targeted changes to files with user approval.
|
6
|
+
|
7
|
+
name: Apply Diff Demo
|
8
|
+
model: gpt-4o-mini
|
9
|
+
|
10
|
+
tools:
|
11
|
+
- Roast::Tools::WriteFile
|
12
|
+
- Roast::Tools::ReadFile
|
13
|
+
- Roast::Tools::ApplyDiff
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- create_sample_file
|
17
|
+
- apply_simple_change
|
18
|
+
|
19
|
+
# Step configurations
|
20
|
+
create_sample_file:
|
21
|
+
print_response: false
|
22
|
+
|
23
|
+
apply_simple_change:
|
24
|
+
print_response: true
|
@@ -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`.
|
Binary file
|
@@ -0,0 +1,32 @@
|
|
1
|
+
model: anthropic:claude-opus-4
|
2
|
+
|
3
|
+
tools:
|
4
|
+
- Roast::Tools::Grep
|
5
|
+
- Roast::Tools::ReadFile
|
6
|
+
- Roast::Tools::WriteFile
|
7
|
+
- Roast::Tools::Cmd:
|
8
|
+
allowed_commands:
|
9
|
+
- pwd
|
10
|
+
- ls
|
11
|
+
- echo
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- explore_directory
|
15
|
+
- analyze_files
|
16
|
+
- write_summary
|
17
|
+
|
18
|
+
# Step-level tool configuration
|
19
|
+
explore_directory:
|
20
|
+
available_tools:
|
21
|
+
- pwd
|
22
|
+
- ls
|
23
|
+
|
24
|
+
analyze_files:
|
25
|
+
available_tools:
|
26
|
+
- grep
|
27
|
+
- read_file
|
28
|
+
|
29
|
+
write_summary:
|
30
|
+
available_tools:
|
31
|
+
- write_file
|
32
|
+
- echo
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Based on your exploration and analysis, create a summary:
|
2
|
+
|
3
|
+
1. Write a brief summary of what you found to a file called `summary.txt`
|
4
|
+
2. Echo a completion message
|
5
|
+
|
6
|
+
Note: You only have access to the `write_file` and `echo` tools for this step. You cannot read files or use other commands.
|
Binary file
|
Binary file
|
@@ -9,8 +9,8 @@ Based on the file extension and content, determine the primary programming langu
|
|
9
9
|
|
10
10
|
Return ONLY the language name in lowercase, nothing else.
|
11
11
|
|
12
|
-
File:
|
12
|
+
File: <%= context.resource_uri %>
|
13
13
|
Content:
|
14
14
|
```
|
15
|
-
|
15
|
+
<%= context.resource %>
|
16
16
|
```
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Context Management Demo
|
2
|
+
|
3
|
+
This example demonstrates Roast's automatic context management feature, which helps prevent workflow failures when conversation history exceeds the LLM's context window.
|
4
|
+
|
5
|
+
## Features Demonstrated
|
6
|
+
|
7
|
+
1. **Automatic Token Tracking**: Monitors token usage throughout workflow execution
|
8
|
+
2. **Configurable Thresholds**: Set when to trigger warnings or compaction
|
9
|
+
3. **Context Preservation**: Specify critical steps to retain during compaction
|
10
|
+
|
11
|
+
## Configuration
|
12
|
+
|
13
|
+
```yaml
|
14
|
+
context_management:
|
15
|
+
enabled: true # Enable context management
|
16
|
+
strategy: auto # Compaction strategy (auto, summarize, prune, none)
|
17
|
+
threshold: 0.8 # Trigger at 80% of context window
|
18
|
+
max_tokens: 10000 # Override default limit (for demo purposes)
|
19
|
+
retain_steps: # Steps to always keep in full
|
20
|
+
- analyze_requirements
|
21
|
+
- generate_summary
|
22
|
+
```
|
23
|
+
|
24
|
+
## Running the Demo
|
25
|
+
|
26
|
+
```bash
|
27
|
+
roast execute context_management_demo
|
28
|
+
```
|
29
|
+
|
30
|
+
The workflow intentionally generates verbose responses to demonstrate how context management handles large amounts of text without failing.
|
31
|
+
|
32
|
+
## What to Observe
|
33
|
+
|
34
|
+
1. **Token Usage Warnings**: Watch for warnings as the context approaches limits
|
35
|
+
2. **Automatic Handling**: The workflow continues even with large outputs
|
36
|
+
3. **Preserved Context**: Critical steps remain accessible throughout execution
|
37
|
+
|
38
|
+
## Customization
|
39
|
+
|
40
|
+
Try modifying the configuration:
|
41
|
+
- Lower `max_tokens` to trigger compaction sooner
|
42
|
+
- Change `strategy` to test different compaction approaches
|
43
|
+
- Add more steps to `retain_steps` to preserve additional context
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Context Management Demo
|
2
|
+
tools:
|
3
|
+
- Roast::Tools::ReadFile
|
4
|
+
- Roast::Tools::WriteFile
|
5
|
+
|
6
|
+
# Context management configuration
|
7
|
+
context_management:
|
8
|
+
enabled: true
|
9
|
+
strategy: auto
|
10
|
+
threshold: 0.8 # Trigger compaction at 80% of context window
|
11
|
+
max_tokens: 10000 # Demo with smaller limit for testing
|
12
|
+
retain_steps:
|
13
|
+
- analyze_requirements
|
14
|
+
- generate_summary
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- analyze_requirements: |
|
18
|
+
Analyze this text and list the key requirements:
|
19
|
+
|
20
|
+
We need a system that can:
|
21
|
+
1. Process customer orders
|
22
|
+
2. Track inventory levels
|
23
|
+
3. Generate reports
|
24
|
+
4. Handle refunds
|
25
|
+
5. Integrate with payment systems
|
26
|
+
|
27
|
+
- expand_details: |
|
28
|
+
For each requirement from the previous step, provide detailed implementation notes,
|
29
|
+
technical considerations, and potential challenges. Be very thorough and verbose
|
30
|
+
to help test the context management system.
|
31
|
+
|
32
|
+
- generate_more_context: |
|
33
|
+
Now describe the database schema needed for this system. Include all tables,
|
34
|
+
relationships, indexes, and data types. Be extremely detailed.
|
35
|
+
|
36
|
+
- add_api_design: |
|
37
|
+
Design a complete REST API for this system. Include all endpoints, request/response
|
38
|
+
formats, authentication, and error handling. Provide examples for each endpoint.
|
39
|
+
|
40
|
+
- generate_summary: |
|
41
|
+
Create a concise executive summary of the system design. Focus on the key decisions
|
42
|
+
and trade-offs made during the design process.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,4 +1,4 @@
|
|
1
|
-
I'll analyze the code complexity of the file
|
1
|
+
I'll analyze the code complexity of the file <%= current_file %>, which I've read in the previous step.
|
2
2
|
|
3
3
|
I'll examine the following aspects:
|
4
4
|
1. Cyclomatic complexity (number of decision paths)
|
@@ -9,7 +9,7 @@ I'll examine the following aspects:
|
|
9
9
|
6. Opportunities for refactoring
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
|
12
|
+
<%= output.read_file %>
|
13
13
|
```
|
14
14
|
|
15
15
|
Based on this analysis, I'll provide a structured assessment of the code quality issues found.
|
@@ -1,8 +1,8 @@
|
|
1
|
-
Based on the analysis of complexity for file
|
1
|
+
Based on the analysis of complexity for file <%= current_file %>, I'll generate specific recommendations for improving code quality.
|
2
2
|
|
3
3
|
I'll use the complexity analysis from the previous step:
|
4
4
|
```json
|
5
|
-
|
5
|
+
<%= output.analyze_complexity %>
|
6
6
|
```
|
7
7
|
|
8
8
|
For each identified issue, I'll provide detailed, actionable recommendations including:
|
@@ -2,13 +2,13 @@ I'll implement the fix for the issue selected in the previous step.
|
|
2
2
|
|
3
3
|
Here is the issue to fix:
|
4
4
|
```json
|
5
|
-
|
5
|
+
<%= output.select_next_issue %>
|
6
6
|
```
|
7
7
|
|
8
8
|
First, I'll read the current file content to understand the context:
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
|
11
|
+
<%= read_file(output.select_next_issue.file_path) %>
|
12
12
|
```
|
13
13
|
|
14
14
|
Based on the issue description and the recommended changes, I'll implement a fix that:
|
@@ -8,7 +8,7 @@ I'll analyze all the recommendations I've generated across multiple files and pr
|
|
8
8
|
Let me review all the recommendations collected so far:
|
9
9
|
|
10
10
|
```json
|
11
|
-
|
11
|
+
<%= outputs_of.generate_recommendations %>
|
12
12
|
```
|
13
13
|
|
14
14
|
I'll create a comprehensive prioritized list of all issues across files, combining similar issues where appropriate. The prioritized list will include:
|
@@ -3,10 +3,10 @@
|
|
3
3
|
You are a code analyzer focusing on analyzing Ruby files to count the number of methods defined.
|
4
4
|
|
5
5
|
## Input
|
6
|
-
- File path:
|
6
|
+
- File path: <%= file_path %>
|
7
7
|
- File content:
|
8
8
|
```ruby
|
9
|
-
|
9
|
+
<%= read_file(file_path) %>
|
10
10
|
```
|
11
11
|
|
12
12
|
## Task
|
@@ -3,9 +3,9 @@
|
|
3
3
|
You are a data updater responsible for adding analysis results to a report.
|
4
4
|
|
5
5
|
## Input
|
6
|
-
- File path:
|
7
|
-
- Method count:
|
8
|
-
- Current report data:
|
6
|
+
- File path: <%= file_path %>
|
7
|
+
- Method count: <%= method_count %>
|
8
|
+
- Current report data: <%= current_report %>
|
9
9
|
|
10
10
|
## Task
|
11
11
|
1. Parse the current report data as JSON
|
@@ -3,8 +3,8 @@
|
|
3
3
|
You are responsible for creating a formatted report file based on the analysis results.
|
4
4
|
|
5
5
|
## Input
|
6
|
-
- Report data:
|
7
|
-
- Summary:
|
6
|
+
- Report data: <%= report_data %>
|
7
|
+
- Summary: <%= summary %>
|
8
8
|
|
9
9
|
## Task
|
10
10
|
1. Generate a Markdown report that includes:
|
@@ -16,7 +16,7 @@ You are responsible for creating a formatted report file based on the analysis r
|
|
16
16
|
Return a JSON object with the following structure:
|
17
17
|
```json
|
18
18
|
{
|
19
|
-
"report_content": "# Ruby Method Analysis Report\n\n
|
19
|
+
"report_content": "# Ruby Method Analysis Report\n\n<%= summary %>\n\n## Detailed Results\n\n| File | Method Count | Methods |\n|------|--------------|--------|\n| file1.rb | 5 | method1, method2, ... |\n| file2.rb | 3 | methodA, methodB, ... |\n...",
|
20
20
|
"report_file_path": "method_analysis_report.md"
|
21
21
|
}
|
22
22
|
```
|
@@ -1,9 +1,9 @@
|
|
1
|
-
I'll analyze the Ruby file at:
|
1
|
+
I'll analyze the Ruby file at: <%= current_file %>
|
2
2
|
|
3
3
|
First, let me read the content of this file.
|
4
4
|
|
5
5
|
```ruby
|
6
|
-
|
6
|
+
<%= read_file(current_file) %>
|
7
7
|
```
|
8
8
|
|
9
9
|
I'll store this content for further analysis in the next steps.
|
@@ -2,12 +2,12 @@ I'll select the next highest priority issue to fix from our prioritized list.
|
|
2
2
|
|
3
3
|
Here is the current prioritized list of issues:
|
4
4
|
```json
|
5
|
-
|
5
|
+
<%= output.prioritize_issues %>
|
6
6
|
```
|
7
7
|
|
8
8
|
And here is the count of fixes we've already applied:
|
9
9
|
```
|
10
|
-
|
10
|
+
<%= output.update_fix_count || '0' %>
|
11
11
|
```
|
12
12
|
|
13
13
|
I'll select the highest priority issue that hasn't yet been addressed. I'll consider:
|
@@ -2,19 +2,19 @@ I'll update the count of fixes that have been successfully applied.
|
|
2
2
|
|
3
3
|
Current fix count:
|
4
4
|
```
|
5
|
-
|
5
|
+
<%= output.update_fix_count || 0 %>
|
6
6
|
```
|
7
7
|
|
8
8
|
Verification result from the previous step:
|
9
9
|
```json
|
10
|
-
|
10
|
+
<%= output.verify_fix %>
|
11
11
|
```
|
12
12
|
|
13
13
|
I'll increment the fix count if the verification was successful or partial, but not if it failed.
|
14
14
|
|
15
15
|
```javascript
|
16
|
-
let currentCount = parseInt(
|
17
|
-
let verificationStatus = "
|
16
|
+
let currentCount = parseInt(<%= output.update_fix_count || 0 %>);
|
17
|
+
let verificationStatus = "<%= output.verify_fix.status %>";
|
18
18
|
|
19
19
|
if (verificationStatus === "success" || verificationStatus === "partial") {
|
20
20
|
currentCount += 1;
|
@@ -2,17 +2,17 @@ I'll verify that the fix implemented in the previous step correctly addresses th
|
|
2
2
|
|
3
3
|
Here are the details of the issue that was fixed:
|
4
4
|
```json
|
5
|
-
|
5
|
+
<%= output.select_next_issue %>
|
6
6
|
```
|
7
7
|
|
8
8
|
And here is the implementation of the fix:
|
9
9
|
```json
|
10
|
-
|
10
|
+
<%= output.implement_fix %>
|
11
11
|
```
|
12
12
|
|
13
13
|
Now I'll read the updated file to verify the changes:
|
14
14
|
```ruby
|
15
|
-
|
15
|
+
<%= read_file(output.select_next_issue.file_path) %>
|
16
16
|
```
|
17
17
|
|
18
18
|
I'll evaluate the fix based on these criteria:
|
Binary file
|
Binary file
|