-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supports updating multiple locations of a file in one call of the apply_diff tool #1234
base: main
Are you sure you want to change the base?
Supports updating multiple locations of a file in one call of the apply_diff tool #1234
Conversation
|
startLine?: number, | ||
endLine?: number, | ||
_paramStartLine?: number, | ||
_paramEndLIne?: number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter naming: The parameter _paramEndLIne is inconsistently cased (should be _paramEndLine). Please fix for consistency with our coding standards.
_paramEndLIne?: number, | |
_paramEndLine?: number, |
replaceContent: match[3], | ||
endLine: Number(match[4]), | ||
})) | ||
.sort((a, b) => a.startLine - b.startLine) | ||
// Detect line ending from original content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overlap validation: Replacements are sorted by startLine, but there’s no check for overlapping or adjacent diff blocks. Consider validating to prevent unintended behavior.
bestMatchScore = similarity | ||
matchIndex = leftIndex | ||
bestMatchContent = originalChunk | ||
// If no match found yet, try middle-out search within bounds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modularize fuzzy matching logic: The search and error construction code (lines ~204–265) is quite dense. Extracting this into helper functions would improve readability and testability.
cool |
b2d4caa
to
17aa4ae
Compare
17aa4ae
to
7fe0172
Compare
@mrubens I think we can see if the idea is ok first. If this idea works, I will try to add a new strategy class and corresponding experiments, and update the test cases. I did some testing on some files > 1000 lines and DeepSeek models, and the results seem to be ok. |
Description
apply_diff tool (search/replace) seems to only be able to modify a continuous text at a time. Some changes require modifying multiple places in the file at once, which can only be achieved through multiple rounds of interaction.
This pr attempts to implement the function of updating multiple locations of a file in one apply_diff tool call by modifying the format of the apply_diff tool.
Tested with DeepSeek Model.
Type of change
How Has This Been Tested?
Checklist:
Additional context
changes:
result:

(Ignore the prompt word format, I was still testing it at the time)
Related Issues
Reviewers
Important
Enhances
applyDiff
insearch-replace.ts
to support multiple search/replace operations in one call by modifying the diff format.applyDiff
insearch-replace.ts
now supports multiple search/replace operations in one call.This description was created by
for 7941474. It will automatically update as commits are pushed.