MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / constructDiffFromReplacements

Function constructDiffFromReplacements

cli/src/utils/implementor-helpers.ts:383–409  ·  view source on GitHub ↗
(
  replacements: ReplacementInput[],
)

Source from the content-addressed store, hash-verified

381}
382
383function constructDiffFromReplacements(
384 replacements: ReplacementInput[],
385): string {
386 const lines: string[] = []
387
388 for (const replacement of replacements) {
389 const oldString = replacement.oldString ?? replacement.old ?? ''
390 const newString = replacement.newString ?? replacement.new ?? ''
391
392 // Add old lines as removals
393 const oldLines = oldString.split('\n')
394 for (const line of oldLines) {
395 lines.push(`- ${line}`)
396 }
397 // Add new lines as additions
398 const newLines = newString.split('\n')
399 for (const line of newLines) {
400 lines.push(`+ ${line}`)
401 }
402 // Add separator between replacements if there are multiple
403 if (replacements.length > 1) {
404 lines.push('')
405 }
406 }
407
408 return lines.join('\n')
409}
410
411/**
412 * Construct a diff view from write_file content.

Callers 1

extractDiffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected