(workspaceDir, input)
| 220 | } |
| 221 | |
| 222 | async function writeFile(workspaceDir, input) { |
| 223 | if (typeof input.path !== 'string' || !input.path) { |
| 224 | throw new Error('write_file requires a path') |
| 225 | } |
| 226 | if (typeof input.content !== 'string') { |
| 227 | throw new Error('write_file requires content') |
| 228 | } |
| 229 | |
| 230 | const absolutePath = resolveWorkspacePath(workspaceDir, input.path) |
| 231 | await fs.mkdir(path.dirname(absolutePath), { recursive: true }) |
| 232 | await fs.writeFile(absolutePath, input.content, 'utf8') |
| 233 | |
| 234 | return { |
| 235 | ok: true, |
| 236 | path: toWorkspaceRelative(workspaceDir, absolutePath), |
| 237 | bytesWritten: Buffer.byteLength(input.content, 'utf8'), |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | async function searchText(workspaceDir, input) { |
| 242 | if (typeof input.pattern !== 'string' || !input.pattern) { |
no test coverage detected