@@ -99,6 +99,7 @@ WINDOWS NOTES:
99- File paths should use forward slashes (/) for cross-platform compatibility
99- File paths should use forward slashes (/) for cross-platform compatibility
100- On Windows, absolute paths start with drive letters (C:/) but forward slashes work throughout
100- On Windows, absolute paths start with drive letters (C:/) but forward slashes work throughout
101- File permissions are handled automatically by the Go runtime
101- File permissions are handled automatically by the Go runtime
102+- Always assumes \n for line endings. The tool will handle \r\n conversion automatically if needed.
103Remember: when making multiple file edits in a row to the same file, you should prefer to send all edits in a single message with multiple calls to this tool, rather than multiple messages with a single call each.`
104Remember: when making multiple file edits in a row to the same file, you should prefer to send all edits in a single message with multiple calls to this tool, rather than multiple messages with a single call each.`
@@ -299,7 +300,7 @@ func (e *editTool) deleteContent(ctx context.Context, filePath, oldString string
299 return ToolResponse{}, fmt.Errorf("failed to read file: %w", err)
300 return ToolResponse{}, fmt.Errorf("failed to read file: %w", err)
302− oldContent := string(content)
303+ oldContent, isCrlf := fsext.ToUnixLineEndings(string(content))
304 var newContent string
305 var newContent string
305 var deletionCount int
306 var deletionCount int
@@ -356,6 +357,10 @@ func (e *editTool) deleteContent(ctx context.Context, filePath, oldString string
356 return ToolResponse{}, permission.ErrorPermissionDenied
357 return ToolResponse{}, permission.ErrorPermissionDenied
361+ newContent, _ = fsext.ToWindowsLineEndings(newContent)
359 err = os.WriteFile(filePath, []byte(newContent), 0o644)
364 err = os.WriteFile(filePath, []byte(newContent), 0o644)
360 if err != nil {
365 if err != nil {
361 return ToolResponse{}, fmt.Errorf("failed to write file: %w", err)
366 return ToolResponse{}, fmt.Errorf("failed to write file: %w", err)
@@ -428,7 +433,7 @@ func (e *editTool) replaceContent(ctx context.Context, filePath, oldString, newS
428 return ToolResponse{}, fmt.Errorf("failed to read file: %w", err)
433 return ToolResponse{}, fmt.Errorf("failed to read file: %w", err)
431− oldContent := string(content)
436+ oldContent, isCrlf := fsext.ToUnixLineEndings(string(content))
433 var newContent string
438 var newContent string
434 var replacementCount int
439 var replacementCount int
@@ -487,6 +492,10 @@ func (e *editTool) replaceContent(ctx context.Context, filePath, oldString, newS
487 return ToolResponse{}, permission.ErrorPermissionDenied
492 return ToolResponse{}, permission.ErrorPermissionDenied
496+ newContent, _ = fsext.ToWindowsLineEndings(newContent)
490 err = os.WriteFile(filePath, []byte(newContent), 0o644)
499 err = os.WriteFile(filePath, []byte(newContent), 0o644)
491 if err != nil {
500 if err != nil {
492 return ToolResponse{}, fmt.Errorf("failed to write file: %w", err)
501 return ToolResponse{}, fmt.Errorf("failed to write file: %w", err)