Merged
Conversation
…andling - Add fuzzy matching algorithm for inexact text matches - Sort edits by position and apply in reverse order to avoid offset issues - Enhance error messages with surrounding context for failed matches - Extract helper functions for better code organization - Improve similarity scoring with whitespace normalization
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
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.
Summary
This PR refactors the LLM provider selection logic, enhances file editing
capabilities with fuzzy matching and improved diff generation, and
introduces provider-specific system prompt extensions.
Changes
constant from src/utils/constants.ts instead of directly
accessing config.provider.
The applyFileEdits function has been significantly refactored to
improve robustness and accuracy of file modifications:
Edits are now sorted by their position in the file (in reverse
order) before application to prevent offset issues.
Introduced fuzzy matching logic (findBestMatch,
calculateSimilarity, applyFuzzyEdit) to locate and apply
edits when exact matches for old_text are not found. This
includes normalizing line endings and whitespace for matching.
Improved diff output formatting with dynamic backtick counting.
Added helper functions: normalizeLineEndings,
normalizeForMatching, formatDiffOutput,
sortEditsByPosition, findBestMatch, calculateSimilarity,
applyFuzzyEdit, and getSurroundingContext for better error
reporting.
The read_multiple_files tool description was slightly
re-formatted (whitespace).
Added a new PROVIDER constant, which defaults to config.provider
or "openai".
Introduced SYSTEM_PROVIDER_EXTENSION, a record to store
provider-specific additions to the system prompt (e.g., for
"gemini").
The main SYSTEM prompt now appends the relevant
SYSTEM_PROVIDER_EXTENSION based on the active PROVIDER.