MCPcopy Create free account
hub / github.com/FareedKhan-dev/ai-long-task / format_diff_summary

Function format_diff_summary

utils/code_utils.py:139–169  ·  view source on GitHub ↗

Create a human-readable summary of the changes in a list of diffs. Args: diff_blocks: A list of (search_text, replace_text) tuples. Returns: A formatted summary string.

(diff_blocks: List[Tuple[str, str]])

Source from the content-addressed store, hash-verified

137
138
139def format_diff_summary(diff_blocks: List[Tuple[str, str]]) -> str:
140 """
141 Create a human-readable summary of the changes in a list of diffs.
142
143 Args:
144 diff_blocks: A list of (search_text, replace_text) tuples.
145
146 Returns:
147 A formatted summary string.
148 """
149 summary = []
150
151 for i, (search_text, replace_text) in enumerate(diff_blocks):
152 search_lines = search_text.strip().split("\n")
153 replace_lines = replace_text.strip().split("\n")
154
155 # Create a concise summary for each diff
156 if len(search_lines) == 1 and len(replace_lines) == 1:
157 # If it's a single line change, show the before and after
158 summary.append(f"Change {i+1}: '{search_lines[0]}' to '{replace_lines[0]}'")
159 else:
160 # For multi-line changes, just show the number of lines
161 search_summary = (
162 f"{len(search_lines)} lines" if len(search_lines) > 1 else search_lines[0]
163 )
164 replace_summary = (
165 f"{len(replace_lines)} lines" if len(replace_lines) > 1 else replace_lines[0]
166 )
167 summary.append(f"Change {i+1}: Replace {search_summary} with {replace_summary}")
168
169 return "\n".join(summary)
170
171
172def calculate_edit_distance(code1: str, code2: str) -> int:

Callers 2

_run_iteration_workerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected