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

Function changeFile

sdk/src/tools/change-file.ts:26–42  ·  view source on GitHub ↗
(params: {
  parameters: unknown
  cwd: string
  fs: CodebuffFileSystem
})

Source from the content-addressed store, hash-verified

24 | { status: 'invalid'; file: string }
25
26export async function changeFile(params: {
27 parameters: unknown
28 cwd: string
29 fs: CodebuffFileSystem
30}): Promise<CodebuffToolOutput<'str_replace'>> {
31 const { parameters, cwd, fs } = params
32
33 const fileChange = FileChangeSchema.parse(parameters)
34 const resolvedPath = resolveFilePathWithinProject(cwd, fileChange.path)
35 if (!resolvedPath) {
36 throw new Error('file path is outside the project directory')
37 }
38
39 const result = await applyChange({ change: fileChange, resolvedPath, fs })
40
41 return [{ type: 'json', value: formatApplyChangeResult(result, fileChange) }]
42}
43
44function formatApplyChangeResult(
45 result: ApplyChangeResult,

Callers 2

handleToolCallFunction · 0.90

Calls 4

applyChangeFunction · 0.85
formatApplyChangeResultFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected