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

Function formatApplyChangeResult

sdk/src/tools/change-file.ts:44–73  ·  view source on GitHub ↗
(
  result: ApplyChangeResult,
  fileChange: FileChange,
)

Source from the content-addressed store, hash-verified

42}
43
44function formatApplyChangeResult(
45 result: ApplyChangeResult,
46 fileChange: FileChange,
47): CodebuffToolOutput<'str_replace'>[0]['value'] {
48 if (result.status === 'created' || result.status === 'modified') {
49 return {
50 file: result.file,
51 message:
52 fileChange.type === 'patch'
53 ? 'String replace applied successfully.'
54 : result.status === 'created'
55 ? 'Created file successfully.'
56 : 'Overwrote file successfully.',
57 }
58 }
59
60 if (result.status === 'patchFailed') {
61 return {
62 file: result.file,
63 errorMessage: `Failed to apply patch.`,
64 patch: result.patch,
65 }
66 }
67
68 return {
69 file: result.file,
70 errorMessage:
71 'Failed to write to file: file path caused an error or file could not be written',
72 }
73}
74
75async function applyChange(params: {
76 change: FileChange

Callers 1

changeFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected