-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: rename search_and_replace tool to edit and unify edit-family UI #11296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hannesrudolph
wants to merge
11
commits into
main
Choose a base branch
from
feat/rename-search-and-replace-to-edit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2db8972
feat: rename search_and_replace tool to edit with new parameter struc…
hannesrudolph 8f25a3b
chore: delete orphaned search_and_replace.ts prompt schema
hannesrudolph dfa2c8f
fix: avoid XML false positives for <editor>/<editable> tags
hannesrudolph 6d5dd35
test: stabilize HistoryPreview ordering in windows CI
hannesrudolph 8fbebbf
test: increase custom tool cache clear timeout for CI
hannesrudolph 6997963
fix(ui): unify edit-family tool rows with appliedDiff
hannesrudolph 793be28
fix(chatrow): restore newFileCreated jump-to-file action in unified d…
hannesrudolph d172b5e
fix(apply-patch): stabilize partial fallback path across platforms
hannesrudolph e1a149c
fix(apply-patch): fallback to cwd basename for partial preview path
hannesrudolph 876ae99
fix(apply-patch): guarantee non-empty partial preview path
hannesrudolph 6b7b715
fix(edit-tool): preserve literal dollar sequences and stabilize path …
hannesrudolph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import type OpenAI from "openai" | ||
|
|
||
| const EDIT_DESCRIPTION = `Performs exact string replacements in files. | ||
|
|
||
| Usage: | ||
| - You must use your \`Read\` tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file. | ||
| - When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + tab. Everything after that tab is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string. | ||
| - ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required. | ||
| - Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked. | ||
| - The edit will FAIL if \`old_string\` is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use \`replace_all\` to change every instance of \`old_string\`. | ||
| - Use \`replace_all\` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.` | ||
|
|
||
| const edit = { | ||
| type: "function", | ||
| function: { | ||
| name: "edit", | ||
| description: EDIT_DESCRIPTION, | ||
| parameters: { | ||
| type: "object", | ||
| properties: { | ||
| file_path: { | ||
| type: "string", | ||
| description: "The path of the file to edit (relative to the working directory)", | ||
| }, | ||
| old_string: { | ||
| type: "string", | ||
| description: | ||
| "The exact text to find in the file. Must match exactly, including all whitespace, indentation, and line endings.", | ||
| }, | ||
| new_string: { | ||
| type: "string", | ||
| description: | ||
| "The replacement text that will replace old_string. Must include all necessary whitespace and indentation.", | ||
| }, | ||
| replace_all: { | ||
| type: "boolean", | ||
| description: | ||
| "When true, replaces ALL occurrences of old_string in the file. When false (default), only replaces the first occurrence and errors if multiple matches exist.", | ||
| default: false, | ||
| }, | ||
| }, | ||
| required: ["file_path", "old_string", "new_string"], | ||
| additionalProperties: false, | ||
| }, | ||
| }, | ||
| } satisfies OpenAI.Chat.ChatCompletionTool | ||
|
|
||
| export default edit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.