summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/edit.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core/src/tools/edit.ts')
-rw-r--r--packages/core/src/tools/edit.ts23
1 files changed, 19 insertions, 4 deletions
diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts
index ddb521be..2515261d 100644
--- a/packages/core/src/tools/edit.ts
+++ b/packages/core/src/tools/edit.ts
@@ -49,6 +49,11 @@ export interface EditToolParams {
* Use when you want to replace multiple occurrences.
*/
expected_replacements?: number;
+
+ /**
+ * Whether the edit was modified manually by the user.
+ */
+ modified_by_user?: boolean;
}
interface CalculatedEdit {
@@ -81,6 +86,8 @@ export class EditTool
'Edit',
`Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${ReadFileTool.Name} tool to examine the file's current content before attempting a text replacement.
+ The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
+
Expectation for required parameters:
1. \`file_path\` MUST be an absolute path; otherwise an error will be thrown.
2. \`old_string\` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.).
@@ -414,12 +421,19 @@ Expectation for required parameters:
displayResult = { fileDiff, fileName };
}
- const llmSuccessMessage = editData.isNewFile
- ? `Created new file: ${params.file_path} with provided content.`
- : `Successfully modified file: ${params.file_path} (${editData.occurrences} replacements).`;
+ const llmSuccessMessageParts = [
+ editData.isNewFile
+ ? `Created new file: ${params.file_path} with provided content.`
+ : `Successfully modified file: ${params.file_path} (${editData.occurrences} replacements).`,
+ ];
+ if (params.modified_by_user) {
+ llmSuccessMessageParts.push(
+ `User modified the \`new_string\` content to be: ${params.new_string}.`,
+ );
+ }
return {
- llmContent: llmSuccessMessage,
+ llmContent: llmSuccessMessageParts.join(' '),
returnDisplay: displayResult,
};
} catch (error) {
@@ -474,6 +488,7 @@ Expectation for required parameters:
...originalParams,
old_string: oldContent,
new_string: modifiedProposedContent,
+ modified_by_user: true,
}),
};
}