Support CRLF detection in WSL
Files on Windows use \r\n as the line ending whereas POSIX systems use \n.
This poses a problem when editing Windows files from WSL - in the fs_read tool, we only send the content joined by \n. This causes context-mismatch issues with the model whenever it attempts to make changes, since it is not expecting line endings to contain a \r prefix.
Instead, we should detect what line endings to use (\r\n vs \n) when editing a file since it is possible to edit Windows based files that use \r\n while in WSL.
This is a great opportunity to enhance cross-platform compatibility. I'd be happy to investigate implementing a line ending detection mechanism. The approach could involve:
- Detecting the existing line ending style in the file (\r\n vs \n)
- Preserving that style when writing back changes via fs_write
- Adding tests for both Windows and POSIX line ending scenarios
Would this align with the expected solution? I can start working on a PR if this direction makes sense.
I’m investigating a focused fix that preserves each file’s existing LF/CRLF style at the shared read/write boundary, with regression coverage for both endings. I found no linked implementation PR; I’ll keep the change scoped to this issue.