Skip to content

New (experimental) edit tool#26

Merged
lyssieth merged 1 commit into
mainfrom
feat-new-edit-tool
Jun 8, 2026
Merged

New (experimental) edit tool#26
lyssieth merged 1 commit into
mainfrom
feat-new-edit-tool

Conversation

@lyssieth

@lyssieth lyssieth commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Adds a new edit tool that improves upon str-replace, and should generally be more reliable and easier to reach for.

@lyssieth lyssieth self-assigned this Jun 8, 2026
@lyssieth lyssieth added the enhancement New feature or request label Jun 8, 2026
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1ab1cd3a-018b-44fe-92ff-98aca3c9c961

📥 Commits

Reviewing files that changed from the base of the PR and between 0036012 and a0f81bd.

📒 Files selected for processing (6)
  • config/agent/tools.toml.example
  • packages/runtime/src/engine/prune.ts
  • packages/runtime/src/engine/tools.ts
  • packages/runtime/src/engine/tools/edit.test.ts
  • packages/runtime/src/engine/tools/edit.ts
  • packages/runtime/src/engine/tools/index.ts

📝 Walkthrough

Walkthrough

This PR adds a new edit tool for fuzzy string replacement in files. The implementation includes whitespace-tolerant matching, optional near-anchor scoping, frontmatter preservation, and detailed error reporting. The tool is integrated into the runtime registry, build system, and token budget management, with comprehensive test coverage.

Changes

Edit Tool Feature

Layer / File(s) Summary
Edit tool schema, matching, and execution
packages/runtime/src/engine/tools/edit.ts
Defines input schema for path, old_text, new_text, optional near anchor, and all-flag. Implements fuzzy-matching utilities for whitespace-insensitive normalization and character-by-character comparison. Adds context formatting for error messages. Implements execute flow: resolves and permission-checks the path, reads file content, preserves frontmatter when required, finds fuzzy matches (optionally scoped by near anchors), validates match counts, applies replacements with offset tracking, writes updated content, invalidates session cache, and returns success with context and replaced count.
Tool registry and import
packages/runtime/src/engine/tools/index.ts
Imports the edit tool module and registers it in builtinToolRegistry to make it available as a built-in tool.
Build system tool enablement and deprecation
packages/runtime/src/engine/tools.ts
Precomputes an enabledTools set from configuration and derives an editEnabled flag. When edit is enabled, marks str-replace with a deprecated label and updates the write tool description to reference edit instead of str-replace.
Token budget eviction
packages/runtime/src/engine/prune.ts
Adds "edit" to the evictable tool-response names so edit tool responses can be superseded when the token budget is exceeded.
Configuration example
config/agent/tools.toml.example
Enables the edit tool by default in the example configuration file.
Edit tool test suite
packages/runtime/src/engine/tools/edit.test.ts
Comprehensive Vitest suite validating exact and fuzzy text matching, whitespace normalization, all flag semantics, near-scoped anchoring with ±15-line windows, frontmatter preservation for block and skill formats, error messages with file excerpts, and empty old_text rejection. Includes filesystem mocking and ToolContext scaffolding.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: introducing a new experimental edit tool, which aligns with the changeset's core objective.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Comment thread packages/runtime/src/engine/tools/edit.ts Dismissed
@lyssieth lyssieth merged commit 7fca5d4 into main Jun 8, 2026
7 checks passed
@lyssieth lyssieth deleted the feat-new-edit-tool branch June 8, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants