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

Function buildFileReadContent

desktop/src/features/agents/ui/agentSessionFileRead.ts:65–93  ·  view source on GitHub ↗
(
  item: ToolItem,
  descriptor: AgentActivityDescriptor,
)

Source from the content-addressed store, hash-verified

63}
64
65export function buildFileReadContent(
66 item: ToolItem,
67 descriptor: AgentActivityDescriptor,
68): FileReadContent | null {
69 if (descriptor.renderClass !== "file-read") {
70 return null;
71 }
72
73 const path =
74 getToolString(item.args, ["path", "file", "file_path", "target_file"]) ??
75 descriptor.object ??
76 descriptor.preview;
77 if (!path) {
78 return null;
79 }
80
81 const resultText = getResultText(item.result);
82 if (!resultText.trim()) {
83 return null;
84 }
85
86 const parsed = parseReadFileOutput(resultText, path);
87 return {
88 footerText: parsed.footerText,
89 footerTitle: parsed.footerTitle,
90 lines: parsed.lines,
91 path,
92 };
93}
94
95function parseReadFileOutput(resultText: string, path: string) {
96 const rawLines = trimTrailingEmptyLines(resultText.split(/\r?\n/));

Callers 2

buildCompactToolSummaryFunction · 0.90

Calls 3

getToolStringFunction · 0.90
parseReadFileOutputFunction · 0.85
getResultTextFunction · 0.70

Tested by

no test coverage detected