roast-ai 0.1.5 → 0.1.7
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 +1 -1
- data/CHANGELOG.md +31 -0
- data/CLAUDE.md +118 -8
- data/Gemfile +1 -2
- data/Gemfile.lock +8 -21
- data/README.md +169 -2
- data/Rakefile +5 -1
- data/docs/INSTRUMENTATION.md +42 -1
- data/examples/interpolation/analyze_file/prompt.md +1 -13
- data/examples/interpolation/generate_report_for_js/prompt.md +2 -27
- data/examples/interpolation/generate_report_for_rb/prompt.md +1 -1
- data/examples/interpolation/workflow.yml +1 -3
- data/examples/openrouter_example/README.md +48 -0
- data/examples/openrouter_example/analyze_input/prompt.md +16 -0
- data/examples/openrouter_example/generate_response/prompt.md +9 -0
- data/examples/openrouter_example/workflow.yml +12 -0
- data/lib/roast/initializers.rb +39 -0
- data/lib/roast/tools/search_file.rb +22 -15
- data/lib/roast/tools/update_files.rb +413 -0
- data/lib/roast/tools.rb +1 -0
- data/lib/roast/version.rb +1 -1
- data/lib/roast/workflow/configuration.rb +28 -1
- data/lib/roast/workflow/configuration_parser.rb +10 -21
- data/lib/roast.rb +6 -0
- data/roast.gemspec +1 -0
- metadata +21 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40bb03c596dcaa3dd49685c9b5f804ca6c6db00cf239d5e52748e6fa485f9c3b
|
4
|
+
data.tar.gz: c56399cca493aa9d925bb4d0550dc7ad0c0ed03b74b4f7894a3205ba72e66d1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2560cd52f21eb2aa0c954d1759ac762c12f2840a1533cc41017003a022f002212e9fb8d6e6b3d11fc1245ff413a86bd68d3aad7a142de9a30d4c534277a80f51
|
7
|
+
data.tar.gz: 371d573330873f1e76aec168e72ed8e2c53d0a127af83683205fae7d060dfa758aeb2352133b4f8b263803b5384b77be76b91a564d945cfd8966a682959a0d13
|
data/.github/workflows/ci.yaml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,37 @@ 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.1.7] - 2024-05-16
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- `UpdateFiles` tool for applying diffs/patches to multiple files at once
|
12
|
+
- Support for atomic file updates with rollback capability
|
13
|
+
- Comprehensive documentation for all built-in tools
|
14
|
+
- Enhanced README with detailed tool usage examples
|
15
|
+
|
16
|
+
## [0.1.6] - 2024-05-15
|
17
|
+
|
18
|
+
### Added
|
19
|
+
- Support for OpenRouter as an API provider
|
20
|
+
- `api_provider` configuration option allowing choice between OpenAI and OpenRouter
|
21
|
+
- Added separate CI rake task for improved build pipeline
|
22
|
+
- Version command to check current Roast version
|
23
|
+
- Walking up to home folder for config root
|
24
|
+
- Improved initializer support for better project configuration
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
- Enhanced search tool to work with globs for more flexible searches
|
28
|
+
- Improved error handling in configuration and initializers
|
29
|
+
- Fixed and simplified interpolation examples
|
30
|
+
|
31
|
+
### Fixed
|
32
|
+
- Better error messages for search file tool
|
33
|
+
- Improved initializer loading and error handling
|
34
|
+
- Fixed tests for nested .roast folders
|
35
|
+
|
36
|
+
[0.1.7]: https://github.com/Shopify/roast/compare/v0.1.6...v0.1.7
|
37
|
+
[0.1.6]: https://github.com/Shopify/roast/compare/v0.1.5...v0.1.6
|
38
|
+
|
8
39
|
## [0.1.5] - 2024-05-13
|
9
40
|
|
10
41
|
### Added
|
data/CLAUDE.md
CHANGED
@@ -7,16 +7,15 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
7
7
|
|
8
8
|
## Commands
|
9
9
|
|
10
|
-
- Build: `bundle exec rake build`
|
11
|
-
- Test all: `bundle exec rspec`
|
12
|
-
- Run single test: `bundle exec rspec spec/path/to/test_file.rb`
|
13
|
-
- Lint: `bundle exec rubocop -A`
|
14
10
|
- Default (tests + lint): `bundle exec rake`
|
15
|
-
-
|
11
|
+
- Test all: `bundle exec test`
|
12
|
+
- Run single test: `bundle exec ruby -Itest test/path/to/test_file.rb`
|
13
|
+
- Lint: `bundle exec rubocop`
|
14
|
+
- Lint (with autocorrect, preferred): `bundle exec rubocop -A`
|
16
15
|
|
17
16
|
## Tech stack
|
18
|
-
- `
|
19
|
-
- Testing: Use
|
17
|
+
- `thor` and `cli-ui` for the CLI tool
|
18
|
+
- Testing: Use Minitest, VCR for HTTP mocking, test files named with `_test.rb` suffix
|
20
19
|
|
21
20
|
## Code Style Guidelines
|
22
21
|
|
@@ -30,4 +29,115 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
30
29
|
- Define class methods inside `class << self; end` declarations.
|
31
30
|
- Add runtime dependencies to `roast.gemspec`.
|
32
31
|
- Add development dependencies to `Gemfile`.
|
33
|
-
- Don't ever test private methods directly. Specs should test behavior, not implementation.
|
32
|
+
- Don't ever test private methods directly. Specs should test behavior, not implementation.
|
33
|
+
|
34
|
+
## Git Workflow Practices
|
35
|
+
|
36
|
+
1. **Amending Commits**:
|
37
|
+
- Use `git commit --amend --no-edit` to add staged changes to the last commit without changing the commit message
|
38
|
+
- This is useful for incorporating small fixes or changes that belong with the previous commit
|
39
|
+
- Be careful when amending commits that have already been pushed, as it will require a force push
|
40
|
+
|
41
|
+
2. **Force Pushing Safety**:
|
42
|
+
- Always use `git push --force-with-lease` rather than `git push --force` when pushing amended commits
|
43
|
+
- This prevents accidentally overwriting remote changes made by others that you haven't pulled yet
|
44
|
+
- It's a safer alternative that respects collaborative work environments
|
45
|
+
|
46
|
+
4. **PR Management**:
|
47
|
+
- Pay attention to linting results before pushing to avoid CI failures
|
48
|
+
|
49
|
+
## GitHub API Commands
|
50
|
+
To get comments from a Pull Request using the GitHub CLI:
|
51
|
+
|
52
|
+
```bash
|
53
|
+
# Get review comments from a PR
|
54
|
+
gh api repos/Shopify/roast/pulls/{pr_number}/comments
|
55
|
+
|
56
|
+
# Get issue-style comments
|
57
|
+
gh api repos/Shopify/roast/issues/{pr_number}/comments
|
58
|
+
|
59
|
+
# Filter comments from a specific user using jq
|
60
|
+
gh api repos/Shopify/roast/pulls/{pr_number}/comments | jq '.[] | select(.user.login == "username")'
|
61
|
+
|
62
|
+
# Get only the comment content
|
63
|
+
gh api repos/Shopify/roast/pulls/{pr_number}/comments | jq '.[].body'
|
64
|
+
```
|
65
|
+
|
66
|
+
### Creating and Managing Issues via API
|
67
|
+
|
68
|
+
```bash
|
69
|
+
# Create a new issue
|
70
|
+
gh api repos/Shopify/roast/issues -X POST -F title="Issue Title" -F body="Issue description"
|
71
|
+
|
72
|
+
# Update an existing issue
|
73
|
+
gh api repos/Shopify/roast/issues/{issue_number} -X PATCH -F body="Updated description"
|
74
|
+
|
75
|
+
# Add a comment to an issue
|
76
|
+
gh api repos/Shopify/roast/issues/{issue_number}/comments -X POST -F body="Comment text"
|
77
|
+
```
|
78
|
+
|
79
|
+
### Creating and Managing Pull Requests
|
80
|
+
|
81
|
+
```bash
|
82
|
+
# Create a new PR with a detailed description using heredoc
|
83
|
+
gh pr create --title "PR Title" --body "$(cat <<'EOF'
|
84
|
+
## Summary
|
85
|
+
|
86
|
+
Detailed description here...
|
87
|
+
|
88
|
+
## Testing
|
89
|
+
|
90
|
+
Testing instructions here...
|
91
|
+
EOF
|
92
|
+
)"
|
93
|
+
|
94
|
+
# Update an existing PR description
|
95
|
+
gh pr edit {pr_number} --body "$(cat <<'EOF'
|
96
|
+
Updated PR description...
|
97
|
+
EOF
|
98
|
+
)"
|
99
|
+
|
100
|
+
# Check PR details
|
101
|
+
gh pr view {pr_number}
|
102
|
+
|
103
|
+
# View PR diff
|
104
|
+
gh pr diff {pr_number}
|
105
|
+
```
|
106
|
+
|
107
|
+
#### Formatting Tips for GitHub API
|
108
|
+
1. Use literal newlines in the body text instead of `\n` escape sequences
|
109
|
+
2. When formatting is stripped (like backticks), use alternatives:
|
110
|
+
- **Bold text** instead of `code formatting`
|
111
|
+
- Add a follow-up comment with proper formatting
|
112
|
+
3. For complex issues, create the basic issue first, then enhance with formatted comments
|
113
|
+
4. Always verify the formatting in the created content
|
114
|
+
5. Use raw JSON for complex formatting requirements:
|
115
|
+
```bash
|
116
|
+
gh api repos/Shopify/roast/issues -X POST --raw-field '{"title":"Issue Title","body":"Complex **formatting** with `code` and lists:\n\n1. Item one\n2. Item two"}'
|
117
|
+
```
|
118
|
+
|
119
|
+
## PR Review Best Practices
|
120
|
+
1. **Always provide your honest opinion about the PR** - be candid about both strengths and concerns
|
121
|
+
2. Give a clear assessment of risks, architectural implications, and potential future issues
|
122
|
+
3. Don't be afraid to point out potential problems even in otherwise good PRs
|
123
|
+
4. When reviewing feature flag removal PRs, carefully inspect control flow changes, not just code branch removals
|
124
|
+
5. Pay special attention to control flow modifiers like `next`, `return`, and `break` which affect iteration behavior
|
125
|
+
6. Look for variable scope issues, especially for variables that persist across loop iterations
|
126
|
+
7. Analyze how code behavior changes in all cases, not just how code structure changes
|
127
|
+
8. Be skeptical of seemingly simple changes that simply remove conditional branches
|
128
|
+
9. When CI checks fail, look for subtle logic inversions or control flow changes
|
129
|
+
10. Examine every file changed in a PR with local code for context, focusing on both what's removed and what remains
|
130
|
+
11. Verify variable initialization, modification, and usage patterns remain consistent after refactoring
|
131
|
+
12. **Never try to directly check out PR branches** - instead, compare PR changes against the existing local codebase
|
132
|
+
13. Understand the broader system architecture to identify potential impacts beyond the changed files
|
133
|
+
14. Look at both the "before" and "after" state of the code when evaluating changes, not just the diff itself
|
134
|
+
15. Consider how the changes will interact with other components that depend on the modified code
|
135
|
+
16. Run searches or examine related files even if they're not directly modified by the PR
|
136
|
+
17. Look for optimization opportunities, especially in frequently-called methods:
|
137
|
+
- Unnecessary object creation in loops
|
138
|
+
- Redundant collection transformations
|
139
|
+
- Inefficient filtering methods that create temporary collections
|
140
|
+
18. Prioritize code readability while encouraging performance optimizations:
|
141
|
+
- Avoid premature optimization outside of hot paths
|
142
|
+
- Consider the tradeoff between readability and performance
|
143
|
+
- Suggest optimizations that improve both clarity and performance
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
roast-ai (0.1.
|
4
|
+
roast-ai (0.1.7)
|
5
5
|
activesupport (~> 8.0)
|
6
|
+
diff-lcs (~> 1.5)
|
6
7
|
faraday-retry
|
7
8
|
json-schema
|
8
9
|
raix (~> 0.8.4)
|
@@ -53,6 +54,7 @@ GEM
|
|
53
54
|
faraday (~> 2.0)
|
54
55
|
ffi (1.17.2)
|
55
56
|
ffi (1.17.2-arm64-darwin)
|
57
|
+
ffi (1.17.2-x86_64-linux-gnu)
|
56
58
|
formatador (1.1.0)
|
57
59
|
guard (2.19.1)
|
58
60
|
formatador (>= 0.2.4)
|
@@ -66,10 +68,9 @@ GEM
|
|
66
68
|
shellany (~> 0.0)
|
67
69
|
thor (>= 0.18.1)
|
68
70
|
guard-compat (1.2.1)
|
69
|
-
guard-
|
70
|
-
guard (~> 2
|
71
|
-
|
72
|
-
rspec (>= 2.99.0, < 4.0)
|
71
|
+
guard-minitest (2.4.6)
|
72
|
+
guard-compat (~> 1.2)
|
73
|
+
minitest (>= 3.0)
|
73
74
|
hashdiff (1.1.2)
|
74
75
|
i18n (1.14.7)
|
75
76
|
concurrent-ruby (~> 1.0)
|
@@ -123,19 +124,6 @@ GEM
|
|
123
124
|
ffi (~> 1.0)
|
124
125
|
regexp_parser (2.10.0)
|
125
126
|
rexml (3.4.1)
|
126
|
-
rspec (3.13.0)
|
127
|
-
rspec-core (~> 3.13.0)
|
128
|
-
rspec-expectations (~> 3.13.0)
|
129
|
-
rspec-mocks (~> 3.13.0)
|
130
|
-
rspec-core (3.13.3)
|
131
|
-
rspec-support (~> 3.13.0)
|
132
|
-
rspec-expectations (3.13.3)
|
133
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
134
|
-
rspec-support (~> 3.13.0)
|
135
|
-
rspec-mocks (3.13.2)
|
136
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
137
|
-
rspec-support (~> 3.13.0)
|
138
|
-
rspec-support (3.13.2)
|
139
127
|
rubocop (1.75.3)
|
140
128
|
json (~> 2.3)
|
141
129
|
language_server-protocol (~> 3.17.0.2)
|
@@ -176,15 +164,14 @@ GEM
|
|
176
164
|
|
177
165
|
PLATFORMS
|
178
166
|
arm64-darwin-23
|
179
|
-
|
167
|
+
x86_64-linux
|
180
168
|
|
181
169
|
DEPENDENCIES
|
182
170
|
cgi
|
183
171
|
dotenv
|
184
172
|
guard
|
185
|
-
guard-
|
173
|
+
guard-minitest
|
186
174
|
mocha
|
187
|
-
pry
|
188
175
|
rake
|
189
176
|
roast-ai!
|
190
177
|
rubocop-shopify
|
data/README.md
CHANGED
@@ -312,9 +312,27 @@ Individual steps can override this setting with their own model parameter:
|
|
312
312
|
|
313
313
|
```yaml
|
314
314
|
analyze_data:
|
315
|
-
model: anthropic
|
315
|
+
model: anthropic/claude-3-haiku # Takes precedence over the global model
|
316
316
|
```
|
317
317
|
|
318
|
+
#### API Provider Configuration
|
319
|
+
|
320
|
+
Roast supports both OpenAI and OpenRouter as API providers. By default, Roast uses OpenAI, but you can specify OpenRouter:
|
321
|
+
|
322
|
+
```yaml
|
323
|
+
name: My Workflow
|
324
|
+
api_provider: openrouter
|
325
|
+
api_token: $(echo $OPENROUTER_API_KEY)
|
326
|
+
model: anthropic/claude-3-opus-20240229
|
327
|
+
```
|
328
|
+
|
329
|
+
Benefits of using OpenRouter:
|
330
|
+
- Access to multiple model providers through a single API
|
331
|
+
- Support for models from Anthropic, Meta, Mistral, and more
|
332
|
+
- Consistent API interface across different model providers
|
333
|
+
|
334
|
+
When using OpenRouter, specify fully qualified model names including the provider prefix (e.g., `anthropic/claude-3-opus-20240229`).
|
335
|
+
|
318
336
|
#### Dynamic API Tokens
|
319
337
|
|
320
338
|
Roast allows you to dynamically fetch API tokens using shell commands directly in your workflow configuration:
|
@@ -323,8 +341,12 @@ Roast allows you to dynamically fetch API tokens using shell commands directly i
|
|
323
341
|
# This will execute the shell command and use the result as the API token
|
324
342
|
api_token: $(print-token --key)
|
325
343
|
|
326
|
-
#
|
344
|
+
# For OpenAI (default)
|
327
345
|
api_token: $(echo $OPENAI_API_KEY)
|
346
|
+
|
347
|
+
# For OpenRouter (requires api_provider setting)
|
348
|
+
api_provider: openrouter
|
349
|
+
api_token: $(echo $OPENROUTER_API_KEY)
|
328
350
|
```
|
329
351
|
|
330
352
|
This makes it easy to use environment-specific tokens without hardcoding credentials, especially useful in development environments or CI/CD pipelines.
|
@@ -363,6 +385,151 @@ For most workflows, you'll mainly use `response` to access the current step's re
|
|
363
385
|
|
364
386
|
Roast provides extensive instrumentation capabilities using ActiveSupport::Notifications. You can monitor workflow execution, track AI model usage, measure performance, and integrate with external monitoring systems. [Read the full instrumentation documentation](docs/INSTRUMENTATION.md).
|
365
387
|
|
388
|
+
### Built-in Tools
|
389
|
+
|
390
|
+
Roast provides several built-in tools that you can use in your workflows:
|
391
|
+
|
392
|
+
#### ReadFile
|
393
|
+
|
394
|
+
Reads the contents of a file from the filesystem.
|
395
|
+
|
396
|
+
```ruby
|
397
|
+
# Basic usage
|
398
|
+
read_file(path: "path/to/file.txt")
|
399
|
+
|
400
|
+
# Reading a specific portion of a file
|
401
|
+
read_file(path: "path/to/large_file.txt", offset: 100, limit: 50)
|
402
|
+
```
|
403
|
+
|
404
|
+
- The `path` can be absolute or relative to the current working directory
|
405
|
+
- Use `offset` and `limit` for large files to read specific sections (line numbers)
|
406
|
+
- Returns the file content as a string
|
407
|
+
|
408
|
+
#### WriteFile
|
409
|
+
|
410
|
+
Writes content to a file, creating the file if it doesn't exist or overwriting it if it does.
|
411
|
+
|
412
|
+
```ruby
|
413
|
+
# Basic usage
|
414
|
+
write_file(path: "output.txt", content: "This is the file content")
|
415
|
+
|
416
|
+
# With path restriction for security
|
417
|
+
write_file(
|
418
|
+
path: "output.txt",
|
419
|
+
content: "Restricted content",
|
420
|
+
restrict: "/safe/directory" # Only allows writing to files under this path
|
421
|
+
)
|
422
|
+
```
|
423
|
+
|
424
|
+
- Creates missing directories automatically
|
425
|
+
- Can restrict file operations to specific directories for security
|
426
|
+
- Returns a success message with the number of lines written
|
427
|
+
|
428
|
+
#### UpdateFiles
|
429
|
+
|
430
|
+
Applies a unified diff/patch to one or more files. Changes are applied atomically when possible.
|
431
|
+
|
432
|
+
```ruby
|
433
|
+
update_files(
|
434
|
+
diff: <<~DIFF,
|
435
|
+
--- a/file1.txt
|
436
|
+
+++ b/file1.txt
|
437
|
+
@@ -1,3 +1,4 @@
|
438
|
+
line1
|
439
|
+
+new line
|
440
|
+
line2
|
441
|
+
line3
|
442
|
+
|
443
|
+
--- a/file2.txt
|
444
|
+
+++ b/file2.txt
|
445
|
+
@@ -5,7 +5,7 @@
|
446
|
+
line5
|
447
|
+
line6
|
448
|
+
-old line7
|
449
|
+
+updated line7
|
450
|
+
line8
|
451
|
+
DIFF
|
452
|
+
base_path: "/path/to/project", # Optional, defaults to current working directory
|
453
|
+
restrict_path: "/path/to/allowed", # Optional, restricts where files can be modified
|
454
|
+
create_files: true, # Optional, defaults to true
|
455
|
+
)
|
456
|
+
```
|
457
|
+
|
458
|
+
- Accepts standard unified diff format from tools like `git diff`
|
459
|
+
- Supports multiple file changes in a single operation
|
460
|
+
- Handles file creation, deletion, and modification
|
461
|
+
- Performs atomic operations with rollback on failure
|
462
|
+
- Includes fuzzy matching to handle minor context differences
|
463
|
+
- This tool is especially useful for making targeted changes to multiple files at once
|
464
|
+
|
465
|
+
#### Grep
|
466
|
+
|
467
|
+
Searches file contents for a specific pattern using regular expressions.
|
468
|
+
|
469
|
+
```ruby
|
470
|
+
# Basic usage
|
471
|
+
grep(pattern: "function\\s+myFunction")
|
472
|
+
|
473
|
+
# With file filtering
|
474
|
+
grep(pattern: "class\\s+User", include: "*.rb")
|
475
|
+
|
476
|
+
# With directory scope
|
477
|
+
grep(pattern: "TODO:", path: "src/components")
|
478
|
+
```
|
479
|
+
|
480
|
+
- Uses regular expressions for powerful pattern matching
|
481
|
+
- Can filter by file types using the `include` parameter
|
482
|
+
- Can scope searches to specific directories with the `path` parameter
|
483
|
+
- Returns a list of files containing matches
|
484
|
+
|
485
|
+
#### SearchFile
|
486
|
+
|
487
|
+
Provides advanced file search capabilities beyond basic pattern matching.
|
488
|
+
|
489
|
+
```ruby
|
490
|
+
search_file(query: "class User", file_path: "app/models")
|
491
|
+
```
|
492
|
+
|
493
|
+
- Combines pattern matching with contextual search
|
494
|
+
- Useful for finding specific code structures or patterns
|
495
|
+
- Returns matched lines with context
|
496
|
+
|
497
|
+
#### Cmd
|
498
|
+
|
499
|
+
Executes shell commands and returns their output.
|
500
|
+
|
501
|
+
```ruby
|
502
|
+
# Execute a simple command
|
503
|
+
cmd(command: "ls -la")
|
504
|
+
|
505
|
+
# With working directory specified
|
506
|
+
cmd(command: "npm list", cwd: "/path/to/project")
|
507
|
+
|
508
|
+
# With environment variables
|
509
|
+
cmd(command: "deploy", env: { "NODE_ENV" => "production" })
|
510
|
+
```
|
511
|
+
|
512
|
+
- Provides access to shell commands for more complex operations
|
513
|
+
- Can specify working directory and environment variables
|
514
|
+
- Captures and returns command output
|
515
|
+
- Useful for integrating with existing tools and scripts
|
516
|
+
|
517
|
+
#### CodingAgent
|
518
|
+
|
519
|
+
Creates a specialized agent for complex coding tasks or long-running operations.
|
520
|
+
|
521
|
+
```ruby
|
522
|
+
coding_agent(
|
523
|
+
task: "Refactor the authentication module to use JWT tokens",
|
524
|
+
language: "ruby",
|
525
|
+
files: ["app/models/user.rb", "app/controllers/auth_controller.rb"]
|
526
|
+
)
|
527
|
+
```
|
528
|
+
|
529
|
+
- Delegates complex tasks to a specialized coding agent
|
530
|
+
- Useful for tasks that require deep code understanding or multi-step changes
|
531
|
+
- Can work across multiple files and languages
|
532
|
+
|
366
533
|
### Custom Tools
|
367
534
|
|
368
535
|
You can create your own tools using the [Raix function dispatch pattern](https://github.com/OlympiaAI/raix-rails?tab=readme-ov-file#use-of-toolsfunctions). Custom tools should be placed in `.roast/initializers/` (subdirectories are supported):
|
data/Rakefile
CHANGED
data/docs/INSTRUMENTATION.md
CHANGED
@@ -199,4 +199,45 @@ Then run:
|
|
199
199
|
roast execute test_instrumentation.yml some_file.rb
|
200
200
|
```
|
201
201
|
|
202
|
-
Your instrumentation should capture the workflow start, step execution, and workflow completion events.
|
202
|
+
Your instrumentation should capture the workflow start, step execution, and workflow completion events.
|
203
|
+
|
204
|
+
## Available Tools
|
205
|
+
|
206
|
+
Roast provides several built-in tools that you can use in your workflows:
|
207
|
+
|
208
|
+
### WriteFile Tool
|
209
|
+
|
210
|
+
Writes content to a file, creating the file if it doesn't exist or overwriting it if it does.
|
211
|
+
|
212
|
+
```ruby
|
213
|
+
# Example usage in a prompt
|
214
|
+
write_file(path: "output.txt", content: "This is the file content")
|
215
|
+
```
|
216
|
+
|
217
|
+
### UpdateFiles Tool
|
218
|
+
|
219
|
+
Applies a unified diff/patch to one or more files. Changes are applied atomically when possible.
|
220
|
+
|
221
|
+
```ruby
|
222
|
+
# Example usage in a prompt
|
223
|
+
update_files(diff: <<~DIFF, base_path: "/path/to/project", create_files: true)
|
224
|
+
--- a/file1.txt
|
225
|
+
+++ b/file1.txt
|
226
|
+
@@ -1,3 +1,4 @@
|
227
|
+
line1
|
228
|
+
+new line
|
229
|
+
line2
|
230
|
+
line3
|
231
|
+
|
232
|
+
--- a/file2.txt
|
233
|
+
+++ b/file2.txt
|
234
|
+
@@ -5,7 +5,7 @@
|
235
|
+
line5
|
236
|
+
line6
|
237
|
+
-old line7
|
238
|
+
+updated line7
|
239
|
+
line8
|
240
|
+
DIFF
|
241
|
+
```
|
242
|
+
|
243
|
+
This tool is especially useful for making targeted changes to multiple files at once, without having to replace entire file contents.
|
@@ -1,13 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
I'm going to analyze the file at: <%= workflow.file %>
|
4
|
-
|
5
|
-
First, let me gather some basic information about the file:
|
6
|
-
|
7
|
-
1. File name: `<%= File.basename(workflow.file) %>`
|
8
|
-
2. File extension: `<%= File.extname(workflow.file).sub('.', '') %>`
|
9
|
-
3. File size: `<%= File.size(workflow.file) %> bytes`
|
10
|
-
|
11
|
-
---
|
12
|
-
|
13
|
-
Can you read the file for me so I can analyze it?
|
1
|
+
Analyze the file at: <%= workflow.file %>
|
@@ -1,28 +1,3 @@
|
|
1
|
-
|
1
|
+
Generate a nicely formatted report based on the following metadata:
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
- File name: `<%= workflow.output['file_basename'] %>`
|
6
|
-
- Lines: `<%= workflow.output['patterns_found']['lines'] %>`
|
7
|
-
|
8
|
-
## JavaScript-Specific Report
|
9
|
-
|
10
|
-
JavaScript files typically contain functions, classes, and import/export statements. I'll generate a report focused on JavaScript code analysis.
|
11
|
-
|
12
|
-
### Recommendations for JavaScript Code
|
13
|
-
|
14
|
-
1. Follow a consistent style guide (ESLint)
|
15
|
-
2. Use modern JavaScript features (ES6+)
|
16
|
-
3. Prefer const and let over var
|
17
|
-
4. Use async/await for asynchronous code
|
18
|
-
5. Write unit tests with Jest or Mocha
|
19
|
-
|
20
|
-
### Summary
|
21
|
-
|
22
|
-
This JavaScript file has been analyzed and basic metrics have been collected. A more detailed analysis would involve parsing the JavaScript code to extract functions, classes, and import/export statements.
|
23
|
-
|
24
|
-
I'll create a report file with this information.
|
25
|
-
|
26
|
-
I'll use my WriteFile tool to generate the report.
|
27
|
-
|
28
|
-
Can you please write the report to `report_<%= workflow.output['file_basename'] %>.md` in the current directory?
|
3
|
+
<%= workflow.output[:analyze_patterns] %>
|
@@ -3,12 +3,10 @@ model: anthropic:claude-3-7-sonnet
|
|
3
3
|
|
4
4
|
tools:
|
5
5
|
- Roast::Tools::ReadFile
|
6
|
-
- Roast::Tools::WriteFile
|
7
|
-
- Roast::Tools::Grep
|
8
6
|
|
9
7
|
steps:
|
10
8
|
- analyze_file
|
11
|
-
-
|
9
|
+
- analyze_patterns
|
12
10
|
- generate_report_for_{{File.extname(workflow.file).sub('.', '')}}
|
13
11
|
- '$(echo "Processing completed for file: {{File.basename(workflow.file)}}")'
|
14
12
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# OpenRouter Example
|
2
|
+
|
3
|
+
This example demonstrates how to use OpenRouter with Roast to access models from different providers through a single API.
|
4
|
+
|
5
|
+
## Setup
|
6
|
+
|
7
|
+
1. Sign up for an account at [OpenRouter](https://openrouter.ai/)
|
8
|
+
2. Get your API key from the OpenRouter dashboard
|
9
|
+
3. Set the API key as an environment variable:
|
10
|
+
```bash
|
11
|
+
export OPENROUTER_API_KEY=your_api_key_here
|
12
|
+
```
|
13
|
+
|
14
|
+
## Running the Example
|
15
|
+
|
16
|
+
```bash
|
17
|
+
# Run without a specific target (general analysis)
|
18
|
+
roast execute workflow.yml
|
19
|
+
|
20
|
+
# Run with a specific file to analyze
|
21
|
+
roast execute workflow.yml path/to/your/file.txt
|
22
|
+
```
|
23
|
+
|
24
|
+
## How it Works
|
25
|
+
|
26
|
+
This example configures Roast to use OpenRouter as the API provider:
|
27
|
+
|
28
|
+
```yaml
|
29
|
+
api_provider: openrouter
|
30
|
+
api_token: $(echo $OPENROUTER_API_KEY)
|
31
|
+
model: anthropic/claude-3-haiku-20240307
|
32
|
+
```
|
33
|
+
|
34
|
+
The workflow consists of two steps:
|
35
|
+
1. `analyze_input`: Analyzes the provided content (or generates general insights if no target is provided)
|
36
|
+
2. `generate_response`: Creates a structured response based on the analysis
|
37
|
+
|
38
|
+
## Available Models
|
39
|
+
|
40
|
+
When using OpenRouter, you can access models from multiple providers by specifying the fully qualified model name, including the provider prefix. Some examples:
|
41
|
+
|
42
|
+
- `anthropic/claude-3-opus-20240229`
|
43
|
+
- `anthropic/claude-3-sonnet-20240229`
|
44
|
+
- `meta/llama-3-70b-instruct`
|
45
|
+
- `google/gemini-1.5-pro-latest`
|
46
|
+
- `mistral/mistral-large-latest`
|
47
|
+
|
48
|
+
Check the [OpenRouter documentation](https://openrouter.ai/docs) for the complete list of supported models.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
I'd like you to analyze the following input and provide your insights.
|
2
|
+
|
3
|
+
<% if workflow.file && workflow.resource.content %>
|
4
|
+
Here is the content to analyze:
|
5
|
+
|
6
|
+
```
|
7
|
+
<%= workflow.resource.content %>
|
8
|
+
```
|
9
|
+
<% else %>
|
10
|
+
The workflow is running without a specific file target. Please provide general insights based on the context.
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
Please provide:
|
14
|
+
1. A summary of the key points
|
15
|
+
2. Any notable patterns or issues
|
16
|
+
3. Recommendations based on your analysis
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Based on the analysis from the previous step, please generate a response that addresses the findings.
|
2
|
+
|
3
|
+
Your response should be well-structured and include:
|
4
|
+
1. An introduction summarizing the analysis
|
5
|
+
2. Detailed discussion of key points
|
6
|
+
3. Clear recommendations for improvements
|
7
|
+
4. A conclusion
|
8
|
+
|
9
|
+
Format the response in markdown for better readability.
|