MCPcopy Create free account
hub / github.com/betta-tech/byo-coding-agent / synthesizeNewFileDiff

Function synthesizeNewFileDiff

internal/agent/diff.go:56–71  ·  view source on GitHub ↗
(path, content string)

Source from the content-addressed store, hash-verified

54}
55
56func synthesizeNewFileDiff(path, content string) string {
57 lines := difflib.SplitLines(content)
58 var out string
59 out += "--- /dev/null\n"
60 out += "+++ " + path + " (new file)\n"
61 out += fmt.Sprintf("@@ -0,0 +1,%d @@\n", len(lines))
62 for _, l := range lines {
63 out += "+" + l
64 // SplitLines preserves trailing newlines; if the last line lacked
65 // one, the next iteration would concatenate without a break.
66 }
67 if len(lines) > 0 && lines[len(lines)-1] != "" && lines[len(lines)-1][len(lines[len(lines)-1])-1] != '\n' {
68 out += "\n"
69 }
70 return out
71}

Callers 1

buildWriteDiffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected