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: ( createUpdatedParams: (
oldContent: string,
modifiedProposedContent: string, modifiedProposedContent: string,
originalParams: EditToolParams, originalParams: EditToolParams,
): EditToolParams => ({ ): EditToolParams => ({
...originalParams, ...originalParams,
old_string: oldContent,
new_string: modifiedProposedContent, new_string: modifiedProposedContent,
}), }),
}; };

View File

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

View File

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

View File

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