MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / writeFile

Function writeFile

compatible-shell/src/tools.mjs:222–239  ·  view source on GitHub ↗
(workspaceDir, input)

Source from the content-addressed store, hash-verified

220}
221
222async 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
241async function searchText(workspaceDir, input) {
242 if (typeof input.pattern !== 'string' || !input.pattern) {

Callers 15

initMemoryFunction · 0.85
saveMemoryFileFunction · 0.85
runDreamFunction · 0.85
updateMemoryIndexFunction · 0.85
updateMagicDocFunction · 0.85
writeAppSessionsStoreFunction · 0.85
persistRuntimeQueueStateFunction · 0.85
saveConfigFunction · 0.85
initBootstrapFunction · 0.85
saveBootstrapFileFunction · 0.85
regenerateIdentityFunction · 0.85
writeSecretStoreFunction · 0.85

Calls 2

resolveWorkspacePathFunction · 0.85
toWorkspaceRelativeFunction · 0.85

Tested by

no test coverage detected