From e3cb8d95a3e50d9e446e048ff4c5181c1018baf3 Mon Sep 17 00:00:00 2001 From: 0x5487 Date: Sun, 22 Feb 2026 15:03:52 +0800 Subject: [PATCH] refactor: rename `appendFileWithRW` function to `appendFile` --- pkg/tools/edit.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/tools/edit.go b/pkg/tools/edit.go index 7df909216..0b0c24742 100644 --- a/pkg/tools/edit.go +++ b/pkg/tools/edit.go @@ -133,7 +133,7 @@ func (t *AppendFileTool) Execute(ctx context.Context, args map[string]any) *Tool var rw fileReadWriter if t.restrict { return executeInWorkspace(t.workspace, path, func(root *os.Root, relPath string) (*ToolResult, error) { - if err := appendFileWithRW(&sandboxFs{root: root}, relPath, content); err != nil { + if err := appendFile(&sandboxFs{root: root}, relPath, content); err != nil { return nil, err } return SilentResult(fmt.Sprintf("Appended to %s", path)), nil @@ -141,7 +141,7 @@ func (t *AppendFileTool) Execute(ctx context.Context, args map[string]any) *Tool } rw = &hostFs{} - if err := appendFileWithRW(rw, path, content); err != nil { + if err := appendFile(rw, path, content); err != nil { return ErrorResult(err.Error()) } return SilentResult(fmt.Sprintf("Appended to %s", path)) @@ -163,8 +163,8 @@ func editFile(rw fileReadWriter, path, oldText, newText string) error { return rw.Write(path, newContent) } -// appendFileWithRW reads the existing content (if any) via rw, appends new content, and writes back. -func appendFileWithRW(rw fileReadWriter, path, appendContent string) error { +// appendFile reads the existing content (if any) via rw, appends new content, and writes back. +func appendFile(rw fileReadWriter, path, appendContent string) error { content, err := rw.Read(path) if err != nil && !errors.Is(err, fs.ErrNotExist) { return err