bug: Fix modify edit (#1078)

This commit is contained in:
Leo 2025-06-16 02:00:41 +01:00 committed by GitHub
parent 4463671284
commit 5c8e49a0e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 1 deletions

View File

@ -467,10 +467,12 @@ Expectation for required parameters:
}
},
createUpdatedParams: (
oldContent: string,
modifiedProposedContent: string,
originalParams: EditToolParams,
): EditToolParams => ({
...originalParams,
old_string: oldContent,
new_string: modifiedProposedContent,
}),
};

View File

@ -74,9 +74,10 @@ describe('modifyWithEditor', () => {
getProposedContent: vi.fn().mockResolvedValue(proposedContent),
createUpdatedParams: vi
.fn()
.mockImplementation((modifiedContent, originalParams) => ({
.mockImplementation((oldContent, modifiedContent, originalParams) => ({
...originalParams,
modifiedContent,
oldContent,
})),
};
@ -153,6 +154,7 @@ describe('modifyWithEditor', () => {
);
expect(mockModifyContext.createUpdatedParams).toHaveBeenCalledWith(
currentContent,
modifiedContent,
mockParams,
);
@ -183,6 +185,7 @@ describe('modifyWithEditor', () => {
updatedParams: {
...mockParams,
modifiedContent,
oldContent: currentContent,
},
updatedDiff: 'mock diff content',
});

View File

@ -29,6 +29,7 @@ export interface ModifyContext<ToolParams> {
getProposedContent: (params: ToolParams) => Promise<string>;
createUpdatedParams: (
oldContent: string,
modifiedProposedContent: string,
originalParams: ToolParams,
) => ToolParams;
@ -98,6 +99,7 @@ function getUpdatedParams<ToolParams>(
}
const updatedParams = modifyContext.createUpdatedParams(
oldContent,
newContent,
originalParams,
);

View File

@ -389,6 +389,7 @@ export class WriteFileTool
return correctedContentResult.correctedContent;
},
createUpdatedParams: (
_oldContent: string,
modifiedProposedContent: string,
originalParams: WriteFileToolParams,
) => ({