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:
chengyongru authored and chengyongru committed 2026-09-15 11:25:01 +08:00
1 parent 3a725b35a7
commit 1c3c68262f
13 files changed
+346 -170

No files matched your search

@@ -32,7 +32,7 @@ def test_edit_file_can_select_occurrence(tmp_path):
occurrence=2,
))
assert "Successfully edited" in result
assert "Patch applied:" in result
assert target.read_text() == "one\nsame\ntwo\nchanged\n"
@@ -66,7 +66,7 @@ def test_edit_file_expected_replacements_allows_replace_all_when_count_matches(t
expected_replacements=2,
))
assert "Successfully edited" in result
assert "Patch applied:" in result
assert target.read_text() == "changed\nchanged\n"
@@ -82,7 +82,7 @@ def test_edit_file_line_hint_selects_matching_occurrence(tmp_path):
line_hint=4,
))
assert "Successfully edited" in result
assert "Patch applied:" in result
assert target.read_text() == "one\nsame\ntwo\nchanged\n"
@@ -115,7 +115,7 @@ def test_edit_file_line_hint_can_cover_multiline_match(tmp_path):
line_hint=3,
))
assert "Successfully edited" in result
assert "Patch applied:" in result
assert target.read_text() == "before\nstart\nchanged\nend\nafter\n"
@@ -130,7 +130,7 @@ def test_edit_file_can_edit_ipynb_as_json(tmp_path):
new_text='"cells": [{"cell_type": "markdown", "source": "hi"}]',
))
assert "Successfully edited" in result
assert "Patch applied:" in result
assert '"source": "hi"' in target.read_text()