MCPcopy Create free account
hub / github.com/codehamr/codehamr / Write

Method Write

internal/tools/bash.go:238–263  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

236 }
237 return Bash(parent, cmd, timeout)
238 case WriteFileName:
239 path, _ := call.Arguments["path"].(string)
240 // A missing/non-string content (valid JSON, so no _parse_error; schema
241 // `required` is not enforced by open-source backends) must not decode
242 // to "" and silently truncate an existing file to 0 bytes behind a
243 // success-shaped result. An explicit `"content": ""` still writes.
244 content, ok := call.Arguments["content"].(string)
245 if !ok {
246 return `(missing content argument: the call carried no string "content", refusing to write - resend with the full content; an intentionally empty file needs an explicit "content": "")`
247 }
248 return WriteFile(path, content, boolArg(call.Arguments, "append"))
249 case EditFileName:
250 path, _ := call.Arguments["path"].(string)
251 oldString, _ := call.Arguments["old_string"].(string)
252 // Same guard as write_file's content: a dropped new_string must not
253 // decode to "" and silently delete the matched text. An explicit
254 // `"new_string": ""` still deletes.
255 newString, ok := call.Arguments["new_string"].(string)
256 if !ok {
257 return `(missing new_string argument: the call carried no string "new_string", refusing to edit - resend it; deleting the match needs an explicit "new_string": "")`
258 }
259 return EditFile(path, oldString, newString)
260 case ReadFileName:
261 path, _ := call.Arguments["path"].(string)
262 return ReadFile(path, intArg(call.Arguments, "offset"), intArg(call.Arguments, "limit"))
263 default:
264 return fmt.Sprintf("(unknown tool: %s)", call.Name)
265 }
266}

Callers 7

newFakeReleaseFunction · 0.80
hashOfFunction · 0.80
writeYAMLFunction · 0.80

Calls

no outgoing calls

Tested by 6

newFakeReleaseFunction · 0.64
hashOfFunction · 0.64