(_ context.Context, execCtx ExecutionContext, input any)
| 131 | } |
| 132 | |
| 133 | func (t *WriteFileTool) Execute(_ context.Context, execCtx ExecutionContext, input any) (string, error) { |
| 134 | in := deref[WriteFileInput](input) |
| 135 | path := resolveToolPath(execCtx, in.FilePath) |
| 136 | if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { |
| 137 | return fmt.Sprintf("Error writing file: %s", err), nil |
| 138 | } |
| 139 | if err := os.WriteFile(path, []byte(in.Content), 0o644); err != nil { |
| 140 | return fmt.Sprintf("Error writing file: %s", err), nil |
| 141 | } |
| 142 | return fmt.Sprintf("File written successfully: %s (%d characters)", path, len([]rune(in.Content))), nil |
| 143 | } |
| 144 | |
| 145 | type EditFileInput struct { |
| 146 | FilePath string `json:"file_path" jsonschema_description:"The absolute path to the file to edit"` |
nothing calls this directly
no test coverage detected