Skip to content

feat: add read tool - #6

Merged
bobrykov merged 2 commits into
masterfrom
feat/read-tool
Jul 12, 2026
Merged

feat: add read tool#6
bobrykov merged 2 commits into
masterfrom
feat/read-tool

Conversation

@bobrykov

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@bobrykov, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e75812d5-0569-447b-a3ea-aca91a60df5e

📥 Commits

Reviewing files that changed from the base of the PR and between f7f586e and d87dc0a.

📒 Files selected for processing (2)
  • crates/dch-tools/src/read.rs
  • crates/dch-tools/src/registry.rs
📝 Walkthrough

Walkthrough

Changes

Read tool integration

Layer / File(s) Summary
Dependencies and path utilities
Cargo.toml, crates/dch-tools/Cargo.toml, crates/dch-tools/src/util.rs
Adds shared base64 and tempfile dependencies plus MIME and HTTP(S) path helpers.
ReadTool contract and execution
crates/dch-tools/src/read.rs
Adds bounded text reads, image responses, binary detection, range parsing, truncation, URL rejection, and session-history recording.
ReadTool behavioral validation
crates/dch-tools/src/read.rs
Adds tests covering read behavior, parsing, content handling, history, schema, and registry properties.
Builtin registry and public wiring
crates/dch-tools/src/lib.rs, crates/dch-tools/src/registry.rs
Exposes the new modules and registers ReadTool in builtin_registry.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant ReadTool
  participant RunnerContext
  participant FileSystem
  participant SessionState
  Caller->>ReadTool: call with file path and range options
  ReadTool->>RunnerContext: resolve path relative to cwd
  ReadTool->>FileSystem: read metadata and contents
  ReadTool->>SessionState: append FileReadEntry
  ReadTool-->>Caller: return formatted text or multipart image output
Loading

Possibly related PRs

  • dch-labs/dch#3: Introduces the RunnerContext and SessionState types used by ReadTool for path resolution and read-history recording.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a new read tool.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 50.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/read-tool

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
crates/dch-tools/src/registry.rs (1)

9-10: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Doc comment phrasing is slightly misleading.

"Each concrete tool registers itself here" implies tools self-register, but builtin_registry actively registers them. Consider rewording to "Each builtin tool is registered here" for clarity.

🤖 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/registry.rs` around lines 9 - 10, Update the doc comment
above builtin_registry to state that each builtin tool is registered here,
avoiding language that implies tools self-register. Preserve the existing
description of runner startup invocation and later task registrations.
🤖 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/read.rs`:
- Around line 285-291: Update the truncation logic in the read flow to check
character boundaries against shown_content, the same string later sliced by
shown_content.get(..cut), rather than the full content. Preserve the
MAX_FILE_READ_BYTES cap for partial views, and add a test covering multibyte
characters with a nonzero offset that verifies the returned content remains
truncated.
- Around line 141-156: After retrieving metadata in the read flow, validate
`metadata.is_file()` before the size check and file read. For directory paths,
return a clear `ToolOutput::error_text` message explaining that the path is a
directory and should reference a file, while preserving the existing handling
for regular files.
- Around line 396-402: Update parse_line_range so a non-empty left side with a
non-empty right side parses and validates the right endpoint, returning the
equivalent inclusive range (for example, 50:100 yields (50, 51)); retain
MAX_FILE_READ_LINES only for open-ended ranges such as 50:, and reject invalid
or non-positive endpoints consistently with the existing dash-range handling.

---

Nitpick comments:
In `@crates/dch-tools/src/registry.rs`:
- Around line 9-10: Update the doc comment above builtin_registry to state that
each builtin tool is registered here, avoiding language that implies tools
self-register. Preserve the existing description of runner startup invocation
and later task registrations.
🪄 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: ec32cc07-8c7d-4824-81cb-60897d109f6d

📥 Commits

Reviewing files that changed from the base of the PR and between 265164f and f7f586e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • Cargo.toml
  • crates/dch-tools/Cargo.toml
  • crates/dch-tools/src/lib.rs
  • crates/dch-tools/src/read.rs
  • crates/dch-tools/src/registry.rs
  • crates/dch-tools/src/util.rs

Comment thread crates/dch-tools/src/read.rs
Comment thread crates/dch-tools/src/read.rs
Comment thread crates/dch-tools/src/read.rs Outdated
@bobrykov
bobrykov merged commit d308045 into master Jul 12, 2026
9 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant