From cadf39c9ef6cadfe43e3ec6762858b0998ba40b2 Mon Sep 17 00:00:00 2001 From: lxowalle Date: Fri, 27 Feb 2026 03:31:09 +0800 Subject: [PATCH] * Fix fmt --- pkg/config/config.go | 16 ++++++++-------- pkg/tools/cron/cron.go | 4 +++- pkg/tools/i2c/i2c_linux.go | 4 +++- pkg/tools/spi/spi_linux.go | 4 +++- pkg/tools/types_export.go | 18 ++++++++++-------- pkg/tools/web_fetch/web_fetch_test.go | 3 ++- pkg/tools/write_file/write_file_test.go | 7 ++++--- 7 files changed, 33 insertions(+), 23 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 79a4dcae2..9306e6978 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -452,7 +452,7 @@ type PerplexityConfig struct { } type WebToolsConfig struct { - Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_WEB_ENABLED"` + Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_WEB_ENABLED"` Brave BraveConfig `json:"brave"` Tavily TavilyConfig `json:"tavily"` DuckDuckGo DuckDuckGoConfig `json:"duckduckgo"` @@ -463,7 +463,7 @@ type WebToolsConfig struct { } type CronToolConfig struct { - Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_CRON_ENABLED"` + Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_CRON_ENABLED"` ExecTimeoutMinutes int `json:"exec_timeout_minutes" env:"PICOCLAW_TOOLS_CRON_EXEC_TIMEOUT_MINUTES"` // 0 means no timeout } @@ -472,7 +472,7 @@ type ToolConfig struct { } type ExecConfig struct { - Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_EXEC_ENABLED"` + Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_EXEC_ENABLED"` EnableDenyPatterns bool `json:"enable_deny_patterns" env:"PICOCLAW_TOOLS_EXEC_ENABLE_DENY_PATTERNS"` CustomDenyPatterns []string `json:"custom_deny_patterns" env:"PICOCLAW_TOOLS_EXEC_CUSTOM_DENY_PATTERNS"` } @@ -485,17 +485,17 @@ type ToolsConfig struct { Cron CronToolConfig `json:"cron"` // File tools - ReadFile ToolConfig `json:"read_file" env:"PICOCLAW_TOOLS_READ_FILE_ENABLED"` - WriteFile ToolConfig `json:"write_file" env:"PICOCLAW_TOOLS_WRITE_FILE_ENABLED"` - EditFile ToolConfig `json:"edit_file" env:"PICOCLAW_TOOLS_EDIT_FILE_ENABLED"` + ReadFile ToolConfig `json:"read_file" env:"PICOCLAW_TOOLS_READ_FILE_ENABLED"` + WriteFile ToolConfig `json:"write_file" env:"PICOCLAW_TOOLS_WRITE_FILE_ENABLED"` + EditFile ToolConfig `json:"edit_file" env:"PICOCLAW_TOOLS_EDIT_FILE_ENABLED"` AppendFile ToolConfig `json:"append_file" env:"PICOCLAW_TOOLS_APPEND_FILE_ENABLED"` - ListDir ToolConfig `json:"list_dir" env:"PICOCLAW_TOOLS_LIST_DIR_ENABLED"` + ListDir ToolConfig `json:"list_dir" env:"PICOCLAW_TOOLS_LIST_DIR_ENABLED"` // Exec tool Exec ExecConfig `json:"exec"` // Skills tools - FindSkills ToolConfig `json:"find_skills" env:"PICOCLAW_TOOLS_FIND_SKILLS_ENABLED"` + FindSkills ToolConfig `json:"find_skills" env:"PICOCLAW_TOOLS_FIND_SKILLS_ENABLED"` InstallSkill ToolConfig `json:"install_skill" env:"PICOCLAW_TOOLS_INSTALL_SKILL_ENABLED"` // Subagent tools diff --git a/pkg/tools/cron/cron.go b/pkg/tools/cron/cron.go index 6abf79f85..dd2ea5a97 100644 --- a/pkg/tools/cron/cron.go +++ b/pkg/tools/cron/cron.go @@ -137,7 +137,9 @@ func (t *CronTool) addJob(args map[string]any) *common.ToolResult { t.mu.RUnlock() if channel == "" || chatID == "" { - return common.ErrorResult("no session context (channel/chat_id not set). Use this tool in an active conversation.") + return common.ErrorResult( + "no session context (channel/chat_id not set). Use this tool in an active conversation.", + ) } message, ok := args["message"].(string) diff --git a/pkg/tools/i2c/i2c_linux.go b/pkg/tools/i2c/i2c_linux.go index 2d4f63250..7d2661388 100644 --- a/pkg/tools/i2c/i2c_linux.go +++ b/pkg/tools/i2c/i2c_linux.go @@ -85,7 +85,9 @@ func (t *I2CTool) scan(args map[string]any) *common.ToolResult { devPath := fmt.Sprintf("/dev/i2c-%s", bus) fd, err := syscall.Open(devPath, syscall.O_RDWR, 0) if err != nil { - return common.ErrorResult(fmt.Sprintf("failed to open %s: %v (check permissions and i2c-dev module)", devPath, err)) + return common.ErrorResult( + fmt.Sprintf("failed to open %s: %v (check permissions and i2c-dev module)", devPath, err), + ) } defer syscall.Close(fd) diff --git a/pkg/tools/spi/spi_linux.go b/pkg/tools/spi/spi_linux.go index b1c25c600..91e5ab528 100644 --- a/pkg/tools/spi/spi_linux.go +++ b/pkg/tools/spi/spi_linux.go @@ -40,7 +40,9 @@ type spiTransfer struct { func configureSPI(devPath string, mode uint8, bits uint8, speed uint32) (int, *common.ToolResult) { fd, err := syscall.Open(devPath, syscall.O_RDWR, 0) if err != nil { - return -1, common.ErrorResult(fmt.Sprintf("failed to open %s: %v (check permissions and spidev module)", devPath, err)) + return -1, common.ErrorResult( + fmt.Sprintf("failed to open %s: %v (check permissions and spidev module)", devPath, err), + ) } // Set SPI mode diff --git a/pkg/tools/types_export.go b/pkg/tools/types_export.go index 1ca1a04a5..a3eefca4f 100644 --- a/pkg/tools/types_export.go +++ b/pkg/tools/types_export.go @@ -4,14 +4,16 @@ import ( "github.com/sipeed/picoclaw/pkg/tools/common" ) -type Tool = common.Tool -type ToolResult = common.ToolResult -type ContextualTool = common.ContextualTool -type AsyncTool = common.AsyncTool -type AsyncCallback = common.AsyncCallback -type FileSystem = common.FileSystem -type HostFs = common.HostFs -type SandboxFs = common.SandboxFs +type ( + Tool = common.Tool + ToolResult = common.ToolResult + ContextualTool = common.ContextualTool + AsyncTool = common.AsyncTool + AsyncCallback = common.AsyncCallback + FileSystem = common.FileSystem + HostFs = common.HostFs + SandboxFs = common.SandboxFs +) func NewToolResult(forLLM string) *ToolResult { return common.NewToolResult(forLLM) diff --git a/pkg/tools/web_fetch/web_fetch_test.go b/pkg/tools/web_fetch/web_fetch_test.go index 78c58df27..80a6689b6 100644 --- a/pkg/tools/web_fetch/web_fetch_test.go +++ b/pkg/tools/web_fetch/web_fetch_test.go @@ -3,12 +3,13 @@ package web_fetch import ( "context" "encoding/json" - "github.com/sipeed/picoclaw/pkg/tools/common" "net/http" "net/http/httptest" "strings" "testing" "time" + + "github.com/sipeed/picoclaw/pkg/tools/common" ) // TestWebTool_WebFetch_Success verifies successful URL fetching diff --git a/pkg/tools/write_file/write_file_test.go b/pkg/tools/write_file/write_file_test.go index ae1457faa..8c5b20a70 100644 --- a/pkg/tools/write_file/write_file_test.go +++ b/pkg/tools/write_file/write_file_test.go @@ -3,15 +3,16 @@ package write_file import ( "context" "io" - "github.com/sipeed/picoclaw/pkg/tools/list_dir" - "github.com/sipeed/picoclaw/pkg/tools/read_file" - "github.com/sipeed/picoclaw/pkg/tools/common" "os" "path/filepath" "strings" "testing" "github.com/stretchr/testify/assert" + + "github.com/sipeed/picoclaw/pkg/tools/common" + "github.com/sipeed/picoclaw/pkg/tools/list_dir" + "github.com/sipeed/picoclaw/pkg/tools/read_file" ) // TestFilesystemTool_ReadFile_Success verifies successful file reading