Skip to content

Autonomous AI sales agent powered by Claude Code or Codex. Finds prospects, writes cold emails, sends campaigns, handles replies, books meetings. No API keys needed — runs on your Claude or Codex subscriptions.

read_user_text returns \n line endings, as text-mode reads do

Ethanc5681506d738
diff --git a/harvey/textio.py b/harvey/textio.py
index 02ce829..33c5f42 100644
--- a/harvey/textio.py
+++ b/harvey/textio.py
@@ -16,10 +16,11 @@ logger = logging.getLogger("harvey.textio")
def read_user_text(path) -> str:
"""A file a person or an older Harvey may have saved (harvey.yaml, .env,
skills, prompts): UTF-8, with or without a BOM, else the locale's code
- page. Raises what reading the file raises (FileNotFoundError...)."""
+ page. Line endings come back as \n, as text-mode reads give them.
+ Raises what reading the file raises (FileNotFoundError...)."""
data = Path(path).read_bytes()
try:
- return data.decode("utf-8-sig")
+ return _newlines(data.decode("utf-8-sig"))
except UnicodeDecodeError:
# The system code page (cp1252 on most Windows), even in Python's
# UTF-8 mode, where getpreferredencoding() would say utf-8.
@@ -27,7 +28,11 @@ def read_user_text(path) -> str:
logger.warning(
f"{path} isn't saved as UTF-8; read it as {encoding}. Re-save it as "
"UTF-8 to keep characters like ★ or — intact.")
- return data.decode(encoding, errors="replace")
+ return _newlines(data.decode(encoding, errors="replace"))
+
+
+def _newlines(text: str) -> str:
+ return text.replace("\r\n", "\n").replace("\r", "\n")
def utf8_stdio(*streams):
diff --git a/tests/test_windows_support.py b/tests/test_windows_support.py
index 3b5a660..8372f4e 100644
--- a/tests/test_windows_support.py
+++ b/tests/test_windows_support.py
@@ -230,3 +230,10 @@ def test_a_shim_pointing_to_another_drive(tmp_path):
'\\claude.exe" %*\r\n', encoding="utf-8")
assert str(claude_runtime._shim_target(shim)).replace("\\", "/") == \
"D:/pnpm/global/5/node_modules/@anthropic-ai/claude-code/bin/claude.exe"
+
+
+def test_windows_line_endings_read_as_newlines(tmp_path):
+ from harvey.textio import read_user_text
+ f = tmp_path / "skill.md"
+ f.write_bytes(b"# Humanizer\r\nCut the tells.\r\n")
+ assert read_user_text(f) == "# Humanizer\nCut the tells.\n"