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

Function WriteFileSchema

internal/tools/write.go:39–61  ·  view source on GitHub ↗

WriteFileSchema is the OpenAI tool definition for write_file. The description steers the model away from bash heredocs (shell-quoting failure mode) for small-to-medium writes, and toward heredoc appends for large files (streamed tool-call args truncate server-side), mirroring the system prompt's rul

()

Source from the content-addressed store, hash-verified

37 return fmt.Sprintf("(write error: %v)", err)
38 }
39 return fmt.Sprintf("appended %d bytes to %s", len(content), path)
40 }
41 if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
42 return fmt.Sprintf("(write error: %v)", err)
43 }
44 return fmt.Sprintf("wrote %d bytes to %s", len(content), path)
45}
46
47// WriteFileSchema is the OpenAI tool definition for write_file. The description
48// steers the model away from bash heredocs (shell-quoting failure mode) and
49// names append as the recovery for a body too large for one streamed call,
50// so the truncation dead end is a one-line fix instead of a tool switch.
51func WriteFileSchema() map[string]any {
52 return map[string]any{
53 "type": "function",
54 "function": map[string]any{
55 "name": WriteFileName,
56 "description": "Write content bytes to a file at path. Creates parent directories. Overwrites unless append is true. Use this instead of bash heredocs for multi line content or content with quotes, dollar signs, or backticks - no shell quoting issues. For an existing file prefer edit_file: a full rewrite risks a one-character regression. A very large body can be cut off mid-stream by the server; if that happens, send it in parts of at most ~200 lines - first part plain, each later part with append true.",
57 "parameters": map[string]any{
58 "type": "object",
59 "properties": map[string]any{
60 "path": map[string]any{
61 "type": "string",
62 "description": "Absolute or relative file path. Relative paths resolve against the working directory.",
63 },
64 "content": map[string]any{

Callers 1

buildToolsMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected