-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add apply_diff tool for efficient file editing #9
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
sandipwane
wants to merge
12
commits into
main
Choose a base branch
from
claude/writr-tool-apply-diffs-011CUtF5dDVVMeBUhu7fTHhj
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
feat: Add apply_diff tool for efficient file editing #9
sandipwane
wants to merge
12
commits into
main
from
claude/writr-tool-apply-diffs-011CUtF5dDVVMeBUhu7fTHhj
Conversation
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
Instead of sending entire file contents on every edit, the LLM can now use apply_diff to make targeted changes by specifying old_string and new_string. This significantly reduces token usage and improves performance when editing large files. Changes: - Add new apply_diff tool with old_string/new_string replacement - Support replace_all option for multiple occurrences - Add validation for file existence and string matching - Display byte count differences in output - Update write tool description to guide LLM to prefer apply_diff
Added a comprehensive system prompt that instructs the agent on: - When to use apply_diff vs write (prefer apply_diff for edits) - Best practices for file operations (read before edit) - Proper usage of bash tool with descriptions and timeouts - Emphasis on being precise with whitespace in apply_diff This will help the agent make better decisions about which tools to use and significantly reduce unnecessary token usage by preferring targeted edits over full file rewrites.
- Added biome.json configuration for linting and formatting rules. - Updated package.json to include @biomejs/biome as a dev dependency. - Enhanced index.ts with improved tool descriptions and consistent formatting. - Refactored code for better readability and maintainability. - Updated local settings for streamlined permissions management.
- Replaced the existing system prompt with a new version that provides clearer instructions for tool usage. - Emphasized best practices for file operations, including reading before editing and using apply_diff for modifications. - Improved clarity on the usage of the bash tool and error handling. - Aims to optimize agent performance and reduce token usage by promoting targeted edits.
- Changed CLI version from v0.2 to v0.3 in the main function for clarity. - Removed outdated comment regarding the system prompt and refined the prompt for better user guidance.
- Updated TOOL_DESCRIPTIONS to use string literals instead of arrays for better clarity and consistency. - This change enhances the maintainability of the code and aligns with previous formatting improvements.
- Introduced a new `bundle.ts` script to build the coding-agent binary for the current platform. - Enhanced `index.ts` with ANSI color-coded logging for added and removed lines in diffs. - Updated `package.json` to include a new script for bundling. - Modified local settings to expand permissions for Bash commands.
- Modified the build script in `bundle.ts` to reflect the new binary name `chai-cli` and include the version from `package.json`. - Enhanced logging to display the version during the build process, improving clarity on the output binary.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Instead of sending entire file contents on every edit, the LLM can now
use apply_diff to make targeted changes by specifying old_string and
new_string. This significantly reduces token usage and improves
performance when editing large files.
Changes: