-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add unified diff support to text editor #4522
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
Conversation
|
seems nice - not sure if we have this AND replace_all (maybe....). curious how performance is |
* main: docs: social channels (#4552) feat: simplify navigation, make reload work (#4498) docs: new recipe warning (#4545) Add AGENTS.md for AI coding assistant support (#4539) docs: non-interactive compact now (#4543) fixed css classes and added some accessibility fixes (#4492) feat(acp): Read files (#4531) Add YouTube Short to Auto Visualiser Tutorial (#4536) Fix/settings page (#4520) update to RMCP 0.6.2 (#4523)
michaelneale
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ok, I wasn't able to trigger it to use a diff, it would happily use str_replace when it made sense, but that is probably ok. I did try to tell it to make a diff, it did, but it didn't work (probably as it was contrived). Any tips on how to see this out? just has to be day to day?
Seems a nicely focussed change and improvement. Main concern is how it works with lower end models, but the prompt doesn't really change much so should be ok.
|
@michaelneale yeah, it is reluctant to use it. The old/new str is more intuitive for it, I think. But, in my testing, sonnet handled the diff format for multiple files (going up to 10) really well. I'm not sure if I should use stronger language here to encourage using diff editing more, because it is pretty aggressive already. |
|
@tlongwell-block I would leave it as is, and consider (while cracked open) adding in replace_all in this one omnibus PR and then we can get it in? covers all bases then. |
…data * 'main' of github.com:block/goose: refactor: add new recipe dependency updater (#4596) chore: fix nightly builds to have tags (#4595) feat: Import file contents from recipe 'file' input type parameter (#4558) also adding this change to the api key send for recipes (#4587) Fix local (working directory) recipes storage (#4588) fix: don't redact tool calls (#4589) Prompt injection detection (simplified - only pattern matching) (#4237) feat: add streaming support to Tetrate Agent Router Service provider (#4477) docs: goosehints updates (#4581) Iand/recipe scanner updates (#4584) patching recipe scanning workflows for permissions changes (#4579) fix: onboarding endpoints send token secret (#4575) Fix : Google AI schema validation by adding missing array items fields (#4569) Add unified diff support to text editor (#4522)
* main: (29 commits) docs: update built-in extensions list and fix link (#4601) Add Message Metadata for Visibility Control (#4538) Remove deprecated Claude 3.5 models (#4590) Remove unused loadRecipe function (#4599) Send the secret with decodeRecipe (#4597) fix markdown links overflowing content and hide agent link previews (#4585) refactor: add new recipe dependency updater (#4596) chore: fix nightly builds to have tags (#4595) feat: Import file contents from recipe 'file' input type parameter (#4558) also adding this change to the api key send for recipes (#4587) Fix local (working directory) recipes storage (#4588) fix: don't redact tool calls (#4589) Prompt injection detection (simplified - only pattern matching) (#4237) feat: add streaming support to Tetrate Agent Router Service provider (#4477) docs: goosehints updates (#4581) Iand/recipe scanner updates (#4584) patching recipe scanning workflows for permissions changes (#4579) fix: onboarding endpoints send token secret (#4575) Fix : Google AI schema validation by adding missing array items fields (#4569) Add unified diff support to text editor (#4522) ...
* main: (30 commits) docs: update built-in extensions list and fix link (#4601) Add Message Metadata for Visibility Control (#4538) Remove deprecated Claude 3.5 models (#4590) Remove unused loadRecipe function (#4599) Send the secret with decodeRecipe (#4597) fix markdown links overflowing content and hide agent link previews (#4585) refactor: add new recipe dependency updater (#4596) chore: fix nightly builds to have tags (#4595) feat: Import file contents from recipe 'file' input type parameter (#4558) also adding this change to the api key send for recipes (#4587) Fix local (working directory) recipes storage (#4588) fix: don't redact tool calls (#4589) Prompt injection detection (simplified - only pattern matching) (#4237) feat: add streaming support to Tetrate Agent Router Service provider (#4477) docs: goosehints updates (#4581) Iand/recipe scanner updates (#4584) patching recipe scanning workflows for permissions changes (#4579) fix: onboarding endpoints send token secret (#4575) Fix : Google AI schema validation by adding missing array items fields (#4569) Add unified diff support to text editor (#4522) ...
Co-authored-by: Michael Neale <[email protected]> Signed-off-by: Matt Donovan <[email protected]>
|
Claude 3.7 Sonnet seems to be having a lot of trouble with this new tool for me. It tries to: i.e. it puts the full path in the IMHO Goose should stop trying to invent clever new variations of tools that are completely different from what the common models out there are trained on. We should try to mimic the prompts and tools that Claude Code, Gemini CLI, and OpenAI Codex are providing to their respective models. |
Co-authored-by: Michael Neale <[email protected]> Signed-off-by: HikaruEgashira <[email protected]>
Adds support for applying unified diffs (both single-file and multi-file) through the text editor's
str_replacecommand. This enhancement reduces token usage when making multi-line edits by up to 90%.Why This Matters
Previously, multi-line edits required sending the entire old and new content as parameters, consuming substantial tokens. With diff support, only the changes are transmitted, dramatically reducing token usage for large edits.
What's New
Core Features
Implementation
Text Editor Enhancement
diffparameter: Optional parameter added toTextEditorParamsfor thestr_replacecommandmpatchcrate (v0.2.0) for robust diff parsing and applicationSafety & Validation
Architecture
The feature is built with a modular, functional approach:
Key Components
apply_diff(): Main entry point that coordinates the diff application processvalidate_path_safety(): Ensures all file operations are secureapply_single_patch(): Handles individual file patches with fuzzy matchingDiffResults: Tracks statistics about the applied changesProcessing Flow
Benefits
Usage Example
Instead of:
{ "command": "str_replace", "old_str": "// 50 lines of old code...", "new_str": "// 50 lines of new code..." }Now you can use:
{ "command": "str_replace", "diff": "--- a/file.rs\n+++ b/file.rs\n@@ -10,3 +10,3 @@\n-old line\n+new line" }Testing
Comprehensive test suite includes:
All tests pass successfully.