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

Function snapPatch

packages/opencode/src/cli/cmd/run/tool.ts:534–569  ·  view source on GitHub ↗
(p: ToolProps<typeof ApplyPatchTool>)

Source from the content-addressed store, hash-verified

532}
533
534function snapPatch(p: ToolProps<typeof ApplyPatchTool>): ToolSnapshot | undefined {
535 const files = list<PatchFile>(p.frame.meta.files)
536 if (files.length === 0) {
537 return undefined
538 }
539
540 const items = files.flatMap((file) => {
541 if (!file || typeof file !== "object") {
542 return []
543 }
544
545 const diff = typeof file.patch === "string" ? file.patch : ""
546 if (!diff.trim()) {
547 return []
548 }
549
550 const name = file.movePath || file.filePath || file.relativePath
551 return [
552 {
553 title: patchTitle(file),
554 diff,
555 file: name,
556 deletions: typeof file.deletions === "number" ? file.deletions : 0,
557 },
558 ]
559 })
560
561 if (items.length === 0) {
562 return undefined
563 }
564
565 return {
566 kind: "diff",
567 items,
568 }
569}
570
571function snapTask(p: ToolProps<typeof TaskTool>): ToolSnapshot {
572 const kind = Locale.titlecase(p.input.subagent_type || "general")

Callers

nothing calls this directly

Calls 2

patchTitleFunction · 0.85
listFunction · 0.70

Tested by

no test coverage detected