MCPcopy Create free account
hub / github.com/anomalyco/opencode / diffContentForPatch

Function diffContentForPatch

packages/opencode/src/acp/permission.ts:207–217  ·  view source on GitHub ↗
(filepath: string, diff: string, displayPath = filepath)

Source from the content-addressed store, hash-verified

205}
206
207async function diffContentForPatch(filepath: string, diff: string, displayPath = filepath) {
208 const content = (await exists(filepath)) ? await readText(filepath) : ""
209 const next = applyPatch(content, diff)
210 if (next === false) return undefined
211 return {
212 type: "diff" as const,
213 path: displayPath,
214 oldText: content,
215 newText: next,
216 }
217}
218
219function selectedReply(result: RequestPermissionResponse): Reply {
220 if (result.outcome.outcome !== "selected") return "reject"

Callers 2

permissionContentFunction · 0.85
diffContentForFilesFunction · 0.85

Calls 2

existsFunction · 0.90
readTextFunction · 0.90

Tested by

no test coverage detected