fix(filesystem): improve edit_file error with nearest-match diagnostics - #3738
Conversation
…iagnostics When edit_file fails to find a match, the error now shows the closest near-match location with line numbers, matching percentage, and a line-by-line diff highlighting which lines diverge. This helps agents and users quickly identify whitespace or content mismatches. Fixes modelcontextprotocol#2034
|
Friendly bump -- would love a review when someone has a chance. Happy to address any feedback. |
|
Closing due to inactivity. Happy to reopen if there's interest. |
|
@claude review |
|
Claude finished @cliffhall's task in 1m 45s —— View job PR Review: fix(filesystem): improve edit_file error with nearest-match diagnostics
Overall: This is a well-targeted quality-of-life improvement for agent/human debugging. The feature is correctly scoped (error paths only), and the diagnostic output format is sensible. There are a few issues worth addressing before merging.
|
Summary
When
edit_filefails to find a match (neither exact nor whitespace-flexible), the error message currently just dumps theoldTextwith no context about what the file actually contains. This makes it hard for both agents and humans to diagnose why the match failed.This PR improves the error to include:
Example error after this change:
No changes to the actual matching/replacement logic -- this is purely diagnostic improvement.
Fixes #2034
Test plan