(params: {
parameters: unknown
cwd: string
fs: CodebuffFileSystem
})
| 24 | | { status: 'invalid'; file: string } |
| 25 | |
| 26 | export 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 | |
| 44 | function formatApplyChangeResult( |
| 45 | result: ApplyChangeResult, |
no test coverage detected