refactor(tools): unify edit summaries with shared fast diffs
Return compact, workspace-relative summaries from edit_file and apply_patch. Compute one RapidFuzz line alignment per file and reuse it for summary counts and WebUI unified diffs, checking snapshots before reuse. Summarize batched edits by their final file state. Warn only when a recorded file version changed, without asking for a read after an edit has already succeeded. Preserve existing edit errors. Validate summary and activity reuse, repetitive files, diff formatting, snapshot changes, file creation, and read-state behavior.
This commit is contained in:
1 parent
3a725b35a7
commit
1c3c68262f
13 files changed
+346
-170
No files matched your search
@@ -130,7 +130,7 @@ class TestEditFileTool:
|
||||
f = tmp_path / "a.py"
|
||||
f.write_text("hello world", encoding="utf-8")
|
||||
result = await tool.execute(path=str(f), old_text="world", new_text="earth")
|
||||
assert "Successfully" in result
|
||||
assert "Patch applied:" in result
|
||||
assert f.read_text() == "hello earth"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -150,7 +150,7 @@ class TestEditFileTool:
|
||||
result = await tool.execute(
|
||||
path=str(f), old_text="line1\nline2", new_text="LINE1\nLINE2",
|
||||
)
|
||||
assert "Successfully" in result
|
||||
assert "Patch applied:" in result
|
||||
raw = f.read_bytes()
|
||||
assert b"LINE1" in raw
|
||||
# CRLF line endings should be preserved throughout the file
|
||||
@@ -163,7 +163,7 @@ class TestEditFileTool:
|
||||
result = await tool.execute(
|
||||
path=str(f), old_text="def foo():\n pass", new_text="def bar():\n return 1",
|
||||
)
|
||||
assert "Successfully" in result
|
||||
assert "Patch applied:" in result
|
||||
assert "bar" in f.read_text()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -180,7 +180,7 @@ class TestEditFileTool:
|
||||
result = await tool.execute(
|
||||
path=str(f), old_text="foo", new_text="baz", replace_all=True,
|
||||
)
|
||||
assert "Successfully" in result
|
||||
assert "Patch applied:" in result
|
||||
assert f.read_text() == "baz bar baz bar baz"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -476,5 +476,5 @@ class TestWorkspaceRestriction:
|
||||
old_text="before",
|
||||
new_text="after",
|
||||
)
|
||||
assert "Successfully edited" in result
|
||||
assert "Patch applied:" in result
|
||||
assert target.read_text(encoding="utf-8") == "after\n"
|
||||
Reference in new issue
Block a user