feat: add bash tool - #7
Conversation
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughChangesThe PR adds a Bash tool for foreground and background shell execution, with bounded output, timeouts, process-group cleanup, job operations, public exports, builtin registration, and comprehensive tests. Bash Tool
Sequence Diagram(s)sequenceDiagram
participant Caller
participant BashTool
participant BashProcess
participant JobTable
Caller->>BashTool: Submit command
alt Foreground execution
BashTool->>BashProcess: Run bash -c command
BashProcess-->>BashTool: Output and exit status
BashTool-->>Caller: Bounded result and metadata
else Background execution
BashTool->>JobTable: Create and track job
JobTable-->>BashTool: Job ID
BashTool-->>Caller: Running job ID
Caller->>BashTool: Request job status
BashTool->>JobTable: Read job state
JobTable-->>BashTool: Job status
BashTool-->>Caller: Status result
end
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
crates/dch-tools/src/bash.rs (1)
30-31: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDoc comment promises a combined cap; implementation caps each stream independently.
The constant doc says "Truncate captured stdout + stderr beyond this many bytes." but
truncate_stringis applied separately tostdoutandstderr, each allowed up toMAX_OUTPUT_BYTES(Lines 426-427), so combined output can reach ~2× the documented cap when both streams are large. Either track a shared byte budget across both streams, or update the doc/constant name to reflect the per-stream semantics.Also applies to: 426-433
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/dch-tools/src/bash.rs` around lines 30 - 31, The output limit documentation does not match the per-stream truncation performed around truncate_string. Either implement a shared MAX_OUTPUT_BYTES budget across stdout and stderr, or rename and update the constant documentation to explicitly describe the per-stream limit, preserving the existing truncation behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/dch-tools/src/bash.rs`:
- Around line 417-420: Replace the unbounded child.wait_with_output() usage in
the command execution flow with bounded streaming reads for stdout and stderr,
limiting retained data to MAX_OUTPUT_BYTES per stream while continuing to drain
both pipes until the child exits. Preserve the existing timeout and ToolError
handling, and apply truncate_string only to the bounded captured output.
- Around line 98-140: Thread the requested timeout through the background-job
path: update call_inner to read the timeout before its background branch and
pass it to spawn_background_job, then update spawn_background_job to enforce it
with tokio::time::timeout around execute_foreground and mark timed-out jobs as
failed with a clear timeout message. Replace the unused _timeout_secs parameter
in execute_foreground only as needed to preserve the existing timeout behavior.
- Around line 33-61: Harden is_read_only_command, used by
is_safe_for_concurrent_execution, against destructive command false negatives:
detect shell redirections such as >, >>, and < as unsafe, reject mutating find
actions including -delete and -exec, and remove git branch/git remote from
READ_ONLY_PREFIXES or add denylist checks for mutating subcommands and flags
before prefix matching. Preserve read-only classification only for commands that
pass these safety checks.
---
Nitpick comments:
In `@crates/dch-tools/src/bash.rs`:
- Around line 30-31: The output limit documentation does not match the
per-stream truncation performed around truncate_string. Either implement a
shared MAX_OUTPUT_BYTES budget across stdout and stderr, or rename and update
the constant documentation to explicitly describe the per-stream limit,
preserving the existing truncation behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5ef0ed71-d146-4ef6-9958-fced88bc12c9
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
crates/dch-tools/Cargo.tomlcrates/dch-tools/src/bash.rscrates/dch-tools/src/lib.rscrates/dch-tools/src/registry.rs
No description provided.