Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Nov 24, 2025

Summary

Adds a new native search_and_replace tool that allows multiple search/replace operations in a single file edit, reducing round-trips for common editing patterns.

Changes

  • packages/types/src/tool.ts: Add search_and_replace to tool names
  • src/core/assistant-message/NativeToolCallParser.ts: Add parser support for the new tool
  • src/core/assistant-message/presentAssistantMessage.ts: Add message presentation handling
  • src/core/prompts/tools/native-tools/index.ts: Export the new tool schema
  • src/core/prompts/tools/native-tools/search_and_replace.ts: Define native tool schema
  • src/core/tools/SearchAndReplaceTool.ts: Main tool implementation with streaming support
  • src/shared/tools.ts: Add tool args type, display name, and group assignment

Features

  • Batch multiple search/replace operations in a single tool call
  • Partial matching support for graceful error handling
  • Individual operation error recovery (continues on partial failures)
  • Streaming support for real-time feedback
  • Integrated with existing diff view infrastructure

Testing

  • Manual testing needed
  • Unit tests to be added

Important

Add search_and_replace tool for batch text replacements with streaming support and error handling.

  • Behavior:
    • Adds search_and_replace tool to tool.ts, NativeToolCallParser.ts, and presentAssistantMessage.ts.
    • Implements main functionality in SearchAndReplaceTool.ts with support for streaming and error handling.
    • Supports batch operations, partial matching, and error recovery.
  • Integration:
    • Exports tool schema in index.ts and defines it in search_and_replace.ts.
    • Validates tool use in validateToolUse.ts and updates modes.spec.ts for testing.
  • Testing:
    • Adds test cases for tool inclusion and mode restrictions in modes.spec.ts.

This description was created by Ellipsis for dc64f16. You can customize this summary. It will automatically update as commits are pushed.

@roomote
Copy link
Contributor

roomote bot commented Nov 24, 2025

Oroocle Clock   Follow along on Roo Cloud

Re-review of the latest changes is complete. One follow-up item remains before this PR is ready to merge.

  • Add unit tests for the search_and_replace tool covering successful replacements, partial failures, write-protected files, and rooignore handling.
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph force-pushed the feature/search-and-replace-tool branch 2 times, most recently from 6343d7a to 520354e Compare November 24, 2025 23:31
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 24, 2025
operations: SearchReplaceOperation[]
}

export class SearchAndReplaceTool extends BaseTool<"search_and_replace"> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This new native search_and_replace tool does not have any automated tests covering successful replacements, partial failures, or error paths. Since it can modify arbitrary user files, missing tests here increases the risk of regressions (for example around multi-operation flows, write-protected files, or rooignore handling); adding unit tests similar to the existing edit tools would make this safer to evolve.

Fix it with Roo Code or mention @roomote and request a fix.

hannesrudolph and others added 3 commits November 27, 2025 14:28
Adds a new native tool that allows multiple search/replace operations
in a single file edit, reducing round-trips for common editing patterns.

- Add search_and_replace to tool types and tool groups
- Implement SearchAndReplaceTool with streaming support
- Add native tool schema and parser support
- Support partial matching and error recovery for individual operations
@daniel-lxs daniel-lxs force-pushed the feature/search-and-replace-tool branch from 514b68c to 993c34b Compare November 27, 2025 19:33
- Add search_and_replace as a customTool in the edit group (opt-in only)
- Fix tool name from 'apply_diff' to 'search_and_replace' in native tools
- Add includedTools parameter to isToolAllowedForMode and validateToolUse
- customTools are only allowed when explicitly included via modelInfo.includedTools
- Pass includedTools from modelInfo in presentAssistantMessage for validation
- Add tests for customTools functionality in modes.spec.ts

This makes search_and_replace a standalone opt-in tool that doesn't replace apply_diff.
Users can enable it via modelInfo.includedTools configuration.
@daniel-lxs daniel-lxs marked this pull request as ready for review November 27, 2025 20:24
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Nov 27, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Enhancement New feature or request labels Nov 27, 2025
@roomote
Copy link
Contributor

roomote bot commented Nov 27, 2025

Oroocle Clock   See task on Roo Cloud

Review updated for the latest PR state. One follow-up item remains for the new search_and_replace tool.

  • Add unit tests for the search_and_replace tool covering successful replacements, partial failures, write-protected files, and rooignore handling.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

operations: SearchReplaceOperation[]
}

export class SearchAndReplaceTool extends BaseTool<"search_and_replace"> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This new search_and_replace tool performs batch edits on arbitrary user files but currently has no automated tests, which makes it easy to regress behavior like multi-operation flows, error aggregation, and protections around rooignore/write-protected files. Adding focused unit tests that cover successful single/multi-operation replacements, partial failures (some operations not matching or matching multiple times), and error paths around missing files or permission constraints would make future changes safer.

Fix it with Roo Code or mention @roomote and request a fix.

Copy link
Member

Choose a reason for hiding this comment

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

This is fine for now

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it correctly handle rooignore and files outside the workspace?

@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Nov 27, 2025
@hannesrudolph hannesrudolph merged commit e682c03 into main Nov 28, 2025
10 checks passed
@hannesrudolph hannesrudolph deleted the feature/search-and-replace-tool branch November 28, 2025 04:19
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Nov 28, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 28, 2025
mini2s added a commit to zgsm-ai/costrict that referenced this pull request Nov 29, 2025