bug: Fix modify edit (#1078)
This commit is contained in:
parent
4463671284
commit
5c8e49a0e3
|
@ -467,10 +467,12 @@ Expectation for required parameters:
|
|||
}
|
||||
},
|
||||
createUpdatedParams: (
|
||||
oldContent: string,
|
||||
modifiedProposedContent: string,
|
||||
originalParams: EditToolParams,
|
||||
): EditToolParams => ({
|
||||
...originalParams,
|
||||
old_string: oldContent,
|
||||
new_string: modifiedProposedContent,
|
||||
}),
|
||||
};
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
|
|
|
@ -389,6 +389,7 @@ export class WriteFileTool
|
|||
return correctedContentResult.correctedContent;
|
||||
},
|
||||
createUpdatedParams: (
|
||||
_oldContent: string,
|
||||
modifiedProposedContent: string,
|
||||
originalParams: WriteFileToolParams,
|
||||
) => ({
|
||||
|
|
Loading…
Reference in New Issue