edit_file fails on CRLF files when old_string contains LF-only line endings
Summary
mcp__gortex__edit_file does exact byte matching for old_string. On Windows repositories where files use CRLF (\r\n) line endings, any old_string value that arrives with LF-only (\n) endings silently fails to match, even when the content is otherwise identical.
Steps to reproduce
- Have a file tracked by gortex that uses CRLF line endings throughout (e.g. a .cpp / .h file on a Windows repo where .gitattributes or editor config enforces CRLF).
- Call edit_file with a multi-line old_string. The JSON transport normalizes newlines to \n, so the string arrives at the server as LF-only.
- The tool reports no match and makes no edit, even though the target text is visually correct.
Workaround used
Read the file in binary mode with Python (open(path, 'rb')), construct old_bytes / new_bytes as b"...\r\n" byte literals, call content.replace(old_bytes, new_bytes), and write back with open(path, 'wb'). This bypasses edit_file entirely but costs extra tokens (script authoring, Write + Bash round trips, duplicated byte-string content).
Expected behavior
edit_file should normalize line endings when matching old_string against file content (CRLF ↔ LF equivalent), while writing new_string with whatever line ending the file uses — or at minimum expose a line_ending: "crlf" | "lf" | "auto" parameter so the caller can opt in to normalization.
Impact
Every edit to a CRLF file requires the Python binary-write workaround. On multi-edit tasks this duplicates large byte-string blocks (once per call site), adds multiple Write + Bash round trips, and inflates token usage significantly — especially when the same replacement block appears at several locations in the same file.
Environment
- OS: Windows 11
- Gortex daemon: vv0.41.0+29a0849