MCPcopy Create free account
hub / github.com/block/buzz / buildFileEditDiff

Function buildFileEditDiff

desktop/src/features/agents/ui/agentSessionFileEditDiff.ts:34–66  ·  view source on GitHub ↗
(
  item: ToolItem,
  descriptor: AgentActivityDescriptor,
)

Source from the content-addressed store, hash-verified

32const SHIKI_REMOVE_RE = /\s*\/\/\s*\[!code\s*--\]\s*$/;
33
34export function buildFileEditDiff(
35 item: ToolItem,
36 descriptor: AgentActivityDescriptor,
37): FileEditDiff | null {
38 if (descriptor.renderClass !== "file-edit") {
39 return null;
40 }
41
42 const resultText = getResultText(item.result);
43 const path =
44 getToolString(item.args, ["path", "file", "file_path", "target_file"]) ??
45 descriptor.object ??
46 descriptor.preview ??
47 getDiffPath(resultText);
48
49 if (!path) {
50 return null;
51 }
52
53 const lines = getDiffLines(resultText);
54 const stats = getDiffStats(resultText, lines);
55 if (!stats) {
56 return null;
57 }
58
59 return {
60 path,
61 filename: basename(path),
62 additions: stats.additions,
63 deletions: stats.deletions,
64 lines,
65 };
66}
67
68function getResultText(result: string): string {
69 const parsed = parseToolResultValue(result);

Callers 1

buildCompactToolSummaryFunction · 0.90

Calls 6

getToolStringFunction · 0.90
getDiffPathFunction · 0.85
getDiffLinesFunction · 0.85
getDiffStatsFunction · 0.85
getResultTextFunction · 0.70
basenameFunction · 0.70

Tested by

no test coverage detected