Skip to content

feat: edit tool added - #9

Merged
bobrykov merged 3 commits into
masterfrom
feat/edit-tool
Jul 17, 2026
Merged

feat: edit tool added#9
bobrykov merged 3 commits into
masterfrom
feat/edit-tool

Conversation

@bobrykov

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 17, 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: 6 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: 518f38f0-436c-465a-b5e3-bbad4c4596a5

📥 Commits

Reviewing files that changed from the base of the PR and between 1f29899 and 639a74a.

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

Walkthrough

This change adds a registered EditTool for unique text replacement, shared atomic file writing, enhanced line-diff summaries, and tests covering validation, linting, path handling, persistence, and output behavior.

Changes

Edit tool workflow

Layer / File(s) Summary
Diff change summaries
crates/dch-tools/src/diff.rs
Modified-file diffs now include removed and added line counts when changes exist, with pluralization and no-op handling.
Shared atomic file writes
crates/dch-tools/src/fs.rs, crates/dch-tools/src/write.rs
File replacement uses a shared atomic-write helper that preserves existing permissions; WriteTool delegates to it and updates shared lint-failure wording.
Edit tool pipeline and registration
crates/dch-tools/src/edit.rs, crates/dch-tools/src/lib.rs, crates/dch-tools/src/registry.rs
EditTool validates requests, resolves and reads files, performs one unique replacement, optionally lints, writes atomically, returns a diff preview, and is exported and registered.
Edit behavior validation
crates/dch-tools/src/edit.rs
Tests cover successful and rejected edits, occurrence counts, path and input validation, linting, registry properties, atomic-write cleanup, and helper functions.

Sequence Diagram(s)

sequenceDiagram
  participant ToolCaller
  participant EditTool
  participant FileSystem
  participant Linter
  ToolCaller->>EditTool: JSON edit request
  EditTool->>FileSystem: read existing content
  EditTool->>EditTool: locate and replace unique occurrence
  EditTool->>Linter: lint updated content
  Linter-->>EditTool: validation result
  EditTool->>FileSystem: atomic write
  EditTool-->>ToolCaller: diff preview or error
Loading

Possibly related PRs

  • dch-labs/dch#3: Introduces the working-directory context used by EditTool path resolution.
  • dch-labs/dch#6: Modifies the same builtin tool registry extended here for EditTool.
  • dch-labs/dch#8: Introduces related diff rendering and write-tool behavior extended by this change.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding the new edit 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/edit-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: 4

🤖 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/diff.rs`:
- Around line 117-127: The diff summary currently misses changes to the file’s
trailing newline because the line-count inputs lose terminal empty segments.
Update the diff construction and summary logic around the removed/added counts
to preserve EOF segments or explicitly report newline-at-EOF changes, ensuring
transitions such as "a\n" to "a" produce a visible preview and summary. Add a
regression test covering this case.

In `@crates/dch-tools/src/edit.rs`:
- Around line 93-97: Update Edit’s system_prompt method to remove the
unavailable MultiEdit instruction, while preserving the guidance that old_text
must be unique and callers should run the linter after applying changes.
- Around line 132-146: Serialize the read-modify-write flow around read_existing
and atomic_write per target path, using the existing path-based synchronization
mechanism if available. Immediately before atomic_write, re-read the target and
compare it with old_content; if it differs, return a retryable conflict output
instead of writing, while preserving the existing edit and linter behavior.

In `@crates/dch-tools/src/fs.rs`:
- Around line 19-36: Update atomic_write to explicitly handle symbolic-link
targets before creating the temporary file: resolve the link and write to the
resolved target, or reject symlink targets with a clear ToolError, ensuring
symlinks are never replaced by regular files. Add a Unix-only regression test
for atomic_write that verifies the chosen 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: 4a7a4da5-d795-48d9-8452-1e03f365d85e

📥 Commits

Reviewing files that changed from the base of the PR and between 5f583d0 and 1f29899.

📒 Files selected for processing (6)
  • crates/dch-tools/src/diff.rs
  • crates/dch-tools/src/edit.rs
  • crates/dch-tools/src/fs.rs
  • crates/dch-tools/src/lib.rs
  • crates/dch-tools/src/registry.rs
  • crates/dch-tools/src/write.rs

Comment thread crates/dch-tools/src/diff.rs
Comment thread crates/dch-tools/src/edit.rs
Comment thread crates/dch-tools/src/edit.rs
Comment thread crates/dch-tools/src/fs.rs
@bobrykov
bobrykov merged commit 0073bc5 into master Jul 17, 2026
8 checks passed
This was referenced Jul 18, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Aug 8, 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