Skip to content

Your lightweight open-source personal agent.

fix(dream): ignore line-ending-only memory diffs

bingqilinweimaotaied47cf1562f7
diff --git a/nanobot/utils/gitstore.py b/nanobot/utils/gitstore.py
index bb61bb6c3..58daeeac9 100644
--- a/nanobot/utils/gitstore.py
+++ b/nanobot/utils/gitstore.py
@@ -377,12 +377,16 @@ class GitStore:
changed += 1
summary_lines.append(f"{path}: binary or non-UTF-8 file changed")
continue
- if head_text == wt_text:
+ # Git blobs preserve line endings while read_text() normalizes
+ # them. Compare the same logical lines used by the diff.
+ head_lines = head_text.splitlines()
+ wt_lines = wt_text.splitlines()
+ if head_lines == wt_lines:
continue
changed += 1
hunks = list(difflib.unified_diff(
- head_text.splitlines(),
- wt_text.splitlines(),
+ head_lines,
+ wt_lines,
fromfile=path,
tofile=path,
lineterm="",
diff --git a/tests/agent/test_dream.py b/tests/agent/test_dream.py
index 7b3f41e53..b2791502b 100644
--- a/tests/agent/test_dream.py
+++ b/tests/agent/test_dream.py
@@ -666,6 +666,37 @@ class TestDreamContentDiff:
store.git.auto_commit("initial")
assert store.dream_content_diff() == ""
+ def test_ignores_platform_line_ending_normalization(self, store, monkeypatch):
+ import subprocess
+
+ system_config = store.workspace / "system.gitconfig"
+ global_config = store.workspace / "global.gitconfig"
+ system_config.touch()
+ global_config.touch()
+ subprocess.run(
+ [
+ "git", "config", "--file", str(system_config),
+ "core.autocrlf", "false",
+ ],
+ check=True,
+ capture_output=True,
+ )
+ monkeypatch.delenv("GIT_CONFIG_NOSYSTEM", raising=False)
+ monkeypatch.setenv("GIT_CONFIG_SYSTEM", str(system_config))
+ monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(global_config))
+
+ store.soul_file.write_bytes(b"# Soul\r\n- Helpful")
+ store.memory_file.write_bytes(b"# Memory\r\n- Project X active")
+ store.git.init()
+
+ status = subprocess.check_output(
+ ["git", "status", "--porcelain", "--", "SOUL.md", "memory/MEMORY.md"],
+ cwd=store.workspace,
+ text=True,
+ )
+ assert status == ""
+ assert store.dream_content_diff() == ""
+
def test_reflects_real_content_edits(self, store):
store.git.init()
store.git.auto_commit("initial")