diff options
| author | Leo <[email protected]> | 2025-06-16 02:00:41 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-15 18:00:41 -0700 |
| commit | 5c8e49a0e3e84ea8d04f26201beb2f980e0a3951 (patch) | |
| tree | 5ba6e3934cc02eab940161bb0fac3f2228544b12 /packages/core/src/tools | |
| parent | 4463671284a41822b84ad4a2ecedbf007c078491 (diff) | |
bug: Fix modify edit (#1078)
Diffstat (limited to 'packages/core/src/tools')
| -rw-r--r-- | packages/core/src/tools/edit.ts | 2 | ||||
| -rw-r--r-- | packages/core/src/tools/modifiable-tool.test.ts | 5 | ||||
| -rw-r--r-- | packages/core/src/tools/modifiable-tool.ts | 2 | ||||
| -rw-r--r-- | packages/core/src/tools/write-file.ts | 1 |
4 files changed, 9 insertions, 1 deletions
diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts index 3317d460..ddb521be 100644 --- a/packages/core/src/tools/edit.ts +++ b/packages/core/src/tools/edit.ts @@ -467,10 +467,12 @@ Expectation for required parameters: } }, createUpdatedParams: ( + oldContent: string, modifiedProposedContent: string, originalParams: EditToolParams, ): EditToolParams => ({ ...originalParams, + old_string: oldContent, new_string: modifiedProposedContent, }), }; diff --git a/packages/core/src/tools/modifiable-tool.test.ts b/packages/core/src/tools/modifiable-tool.test.ts index 56c27fe0..850da02b 100644 --- a/packages/core/src/tools/modifiable-tool.test.ts +++ b/packages/core/src/tools/modifiable-tool.test.ts @@ -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', }); diff --git a/packages/core/src/tools/modifiable-tool.ts b/packages/core/src/tools/modifiable-tool.ts index 96fe176c..e935a704 100644 --- a/packages/core/src/tools/modifiable-tool.ts +++ b/packages/core/src/tools/modifiable-tool.ts @@ -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, ); diff --git a/packages/core/src/tools/write-file.ts b/packages/core/src/tools/write-file.ts index b19b00ac..87f6e21e 100644 --- a/packages/core/src/tools/write-file.ts +++ b/packages/core/src/tools/write-file.ts @@ -389,6 +389,7 @@ export class WriteFileTool return correctedContentResult.correctedContent; }, createUpdatedParams: ( + _oldContent: string, modifiedProposedContent: string, originalParams: WriteFileToolParams, ) => ({ |
