From 9b4efddd9b444d177acf7019500aacb6c10e3c4b Mon Sep 17 00:00:00 2001 From: lc6464 <64722907+lc6464@users.noreply.github.com> Date: Fri, 17 Apr 2026 14:16:18 +0800 Subject: [PATCH] fix(providers,tools): address linter issues after reorg --- pkg/providers/facade_compat_test.go | 12 ++--------- pkg/tools/fs_facade.go | 31 ++++++++++++++++++++++++----- pkg/tools/hardware/i2c.go | 12 +++++------ pkg/tools/hardware/spi.go | 4 ++-- pkg/tools/integration_facade.go | 4 ---- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/pkg/providers/facade_compat_test.go b/pkg/providers/facade_compat_test.go index b0aa48bf8..024c36abf 100644 --- a/pkg/providers/facade_compat_test.go +++ b/pkg/providers/facade_compat_test.go @@ -38,15 +38,7 @@ func TestNormalizeToolCallFacadeMatchesCLIProvider(t *testing.T) { } func TestAntigravityFacadeSignaturesRemainAvailable(t *testing.T) { - var projectFetcher func(string) (string, error) = FetchAntigravityProjectID - var modelsFetcher func(string, string) ([]AntigravityModelInfo, error) = FetchAntigravityModels - - if projectFetcher == nil { - t.Fatal("FetchAntigravityProjectID facade should be available") - } - if modelsFetcher == nil { - t.Fatal("FetchAntigravityModels facade should be available") - } - + var _ func(string) (string, error) = FetchAntigravityProjectID + var _ func(string, string) ([]AntigravityModelInfo, error) = FetchAntigravityModels var _ AntigravityModelInfo = oauthprovider.AntigravityModelInfo{} } diff --git a/pkg/tools/fs_facade.go b/pkg/tools/fs_facade.go index 13bb827c3..5ed68f04c 100644 --- a/pkg/tools/fs_facade.go +++ b/pkg/tools/fs_facade.go @@ -20,7 +20,12 @@ type ( const MaxReadFileSize = fstools.MaxReadFileSize -func NewReadFileTool(workspace string, restrict bool, maxReadFileSize int, allowPaths ...[]*regexp.Regexp) *ReadFileTool { +func NewReadFileTool( + workspace string, + restrict bool, + maxReadFileSize int, + allowPaths ...[]*regexp.Regexp, +) *ReadFileTool { return fstools.NewReadFileTool(workspace, restrict, maxReadFileSize, allowPaths...) } @@ -42,19 +47,35 @@ func NewReadFileLinesTool( return fstools.NewReadFileLinesTool(workspace, restrict, maxReadFileSize, allowPaths...) } -func NewWriteFileTool(workspace string, restrict bool, allowPaths ...[]*regexp.Regexp) *WriteFileTool { +func NewWriteFileTool( + workspace string, + restrict bool, + allowPaths ...[]*regexp.Regexp, +) *WriteFileTool { return fstools.NewWriteFileTool(workspace, restrict, allowPaths...) } -func NewListDirTool(workspace string, restrict bool, allowPaths ...[]*regexp.Regexp) *ListDirTool { +func NewListDirTool( + workspace string, + restrict bool, + allowPaths ...[]*regexp.Regexp, +) *ListDirTool { return fstools.NewListDirTool(workspace, restrict, allowPaths...) } -func NewEditFileTool(workspace string, restrict bool, allowPaths ...[]*regexp.Regexp) *EditFileTool { +func NewEditFileTool( + workspace string, + restrict bool, + allowPaths ...[]*regexp.Regexp, +) *EditFileTool { return fstools.NewEditFileTool(workspace, restrict, allowPaths...) } -func NewAppendFileTool(workspace string, restrict bool, allowPaths ...[]*regexp.Regexp) *AppendFileTool { +func NewAppendFileTool( + workspace string, + restrict bool, + allowPaths ...[]*regexp.Regexp, +) *AppendFileTool { return fstools.NewAppendFileTool(workspace, restrict, allowPaths...) } diff --git a/pkg/tools/hardware/i2c.go b/pkg/tools/hardware/i2c.go index caa0017ea..62e9557ee 100644 --- a/pkg/tools/hardware/i2c.go +++ b/pkg/tools/hardware/i2c.go @@ -120,16 +120,12 @@ func (t *I2CTool) detect() *ToolResult { // Helper functions for I2C operations (used by platform-specific implementations) // isValidBusID checks that a bus identifier is a simple number (prevents path injection) -// -//nolint:unused // Used by i2c_linux.go func isValidBusID(id string) bool { matched, _ := regexp.MatchString(`^\d+$`, id) return matched } // parseI2CAddress extracts and validates an I2C address from args -// -//nolint:unused // Used by i2c_linux.go func parseI2CAddress(args map[string]any) (int, *ToolResult) { addrFloat, ok := args["address"].(float64) if !ok { @@ -143,8 +139,6 @@ func parseI2CAddress(args map[string]any) (int, *ToolResult) { } // parseI2CBus extracts and validates an I2C bus from args -// -//nolint:unused // Used by i2c_linux.go func parseI2CBus(args map[string]any) (string, *ToolResult) { bus, ok := args["bus"].(string) if !ok || bus == "" { @@ -155,3 +149,9 @@ func parseI2CBus(args map[string]any) (string, *ToolResult) { } return bus, nil } + +var ( + _ = isValidBusID + _ = parseI2CAddress + _ = parseI2CBus +) diff --git a/pkg/tools/hardware/spi.go b/pkg/tools/hardware/spi.go index 298d36f08..0bc0d8f72 100644 --- a/pkg/tools/hardware/spi.go +++ b/pkg/tools/hardware/spi.go @@ -122,8 +122,6 @@ func (t *SPITool) list() *ToolResult { // Helper function for SPI operations (used by platform-specific implementations) // parseSPIArgs extracts and validates common SPI parameters -// -//nolint:unused // Used by spi_linux.go func parseSPIArgs(args map[string]any) (device string, speed uint32, mode uint8, bits uint8, errMsg string) { dev, ok := args["device"].(string) if !ok || dev == "" { @@ -160,3 +158,5 @@ func parseSPIArgs(args map[string]any) (device string, speed uint32, mode uint8, return dev, speed, mode, bits, "" } + +var _ = parseSPIArgs diff --git a/pkg/tools/integration_facade.go b/pkg/tools/integration_facade.go index 11e604bca..00c00b810 100644 --- a/pkg/tools/integration_facade.go +++ b/pkg/tools/integration_facade.go @@ -1,8 +1,6 @@ package tools import ( - "context" - "github.com/modelcontextprotocol/go-sdk/mcp" "github.com/sipeed/picoclaw/pkg/audio/tts" @@ -101,5 +99,3 @@ func NewWebFetchToolWithConfig( ) (*WebFetchTool, error) { return integrationtools.NewWebFetchToolWithConfig(maxChars, proxy, format, fetchLimitBytes, privateHostWhitelist) } - -func _keepContext(context.Context) {}