diff --git a/.golangci.yaml b/.golangci.yaml index d45d69e67..dd176c51f 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -66,7 +66,7 @@ linters: - testifylint - thelper - unparam - - unused + # - unused # Enabled to detect dead code - usestdlibvars - usetesting - wastedassign diff --git a/pkg/agent/context.go b/pkg/agent/context.go index a9db5afdd..ba07e33d3 100644 --- a/pkg/agent/context.go +++ b/pkg/agent/context.go @@ -288,25 +288,6 @@ func (cb *ContextBuilder) AddAssistantMessage( return messages } -func (cb *ContextBuilder) loadSkills() string { - allSkills := cb.skillsLoader.ListSkills() - if len(allSkills) == 0 { - return "" - } - - var skillNames []string - for _, s := range allSkills { - skillNames = append(skillNames, s.Name) - } - - content := cb.skillsLoader.LoadSkillsForContext(skillNames) - if content == "" { - return "" - } - - return "# Skill Definitions\n\n" + content -} - // GetSkillsInfo returns information about loaded skills. func (cb *ContextBuilder) GetSkillsInfo() map[string]any { allSkills := cb.skillsLoader.ListSkills() diff --git a/pkg/providers/antigravity_provider.go b/pkg/providers/antigravity_provider.go index cff67c88c..d4ee528b7 100644 --- a/pkg/providers/antigravity_provider.go +++ b/pkg/providers/antigravity_provider.go @@ -404,64 +404,6 @@ type antigravityJSONResponse struct { } `json:"usageMetadata"` } -func (p *AntigravityProvider) parseJSONResponse(body []byte) (*LLMResponse, error) { - var resp antigravityJSONResponse - if err := json.Unmarshal(body, &resp); err != nil { - return nil, fmt.Errorf("parsing antigravity response: %w", err) - } - - if len(resp.Candidates) == 0 { - return nil, fmt.Errorf("antigravity: no candidates in response") - } - - candidate := resp.Candidates[0] - var contentParts []string - var toolCalls []ToolCall - - for _, part := range candidate.Content.Parts { - if part.Text != "" { - contentParts = append(contentParts, part.Text) - } - if part.FunctionCall != nil { - argumentsJSON, _ := json.Marshal(part.FunctionCall.Args) - toolCalls = append(toolCalls, ToolCall{ - ID: fmt.Sprintf("call_%s_%d", part.FunctionCall.Name, time.Now().UnixNano()), - Name: part.FunctionCall.Name, - Arguments: part.FunctionCall.Args, - Function: &FunctionCall{ - Name: part.FunctionCall.Name, - Arguments: string(argumentsJSON), - ThoughtSignature: extractPartThoughtSignature(part.ThoughtSignature, part.ThoughtSignatureSnake), - }, - }) - } - } - - finishReason := "stop" - if len(toolCalls) > 0 { - finishReason = "tool_calls" - } - if candidate.FinishReason == "MAX_TOKENS" { - finishReason = "length" - } - - var usage *UsageInfo - if resp.UsageMetadata.TotalTokenCount > 0 { - usage = &UsageInfo{ - PromptTokens: resp.UsageMetadata.PromptTokenCount, - CompletionTokens: resp.UsageMetadata.CandidatesTokenCount, - TotalTokens: resp.UsageMetadata.TotalTokenCount, - } - } - - return &LLMResponse{ - Content: strings.Join(contentParts, ""), - ToolCalls: toolCalls, - FinishReason: finishReason, - Usage: usage, - }, nil -} - func (p *AntigravityProvider) parseSSEResponse(body string) (*LLMResponse, error) { var contentParts []string var toolCalls []ToolCall diff --git a/pkg/providers/fallback_test.go b/pkg/providers/fallback_test.go index e872c672e..ebba054ef 100644 --- a/pkg/providers/fallback_test.go +++ b/pkg/providers/fallback_test.go @@ -17,12 +17,6 @@ func successRun(content string) func(ctx context.Context, provider, model string } } -func failRun(err error) func(ctx context.Context, provider, model string) (*LLMResponse, error) { - return func(ctx context.Context, provider, model string) (*LLMResponse, error) { - return nil, err - } -} - func TestFallback_SingleCandidate_Success(t *testing.T) { ct := NewCooldownTracker() fc := NewFallbackChain(ct) diff --git a/pkg/tools/i2c.go b/pkg/tools/i2c.go index 0387a26d3..cf3439ad6 100644 --- a/pkg/tools/i2c.go +++ b/pkg/tools/i2c.go @@ -95,9 +95,7 @@ func (t *I2CTool) detect() *ToolResult { } if len(matches) == 0 { - return SilentResult( - "No I2C buses found. You may need to:\n1. Load the i2c-dev module: modprobe i2c-dev\n2. Check that I2C is enabled in device tree\n3. Configure pinmux for your board (see hardware skill)", - ) + return SilentResult("No I2C buses found. You may need to:\n1. Load the i2c-dev module: modprobe i2c-dev\n2. Check that I2C is enabled in device tree\n3. Configure pinmux for your board (see hardware skill)") } type busInfo struct { @@ -116,34 +114,3 @@ func (t *I2CTool) detect() *ToolResult { result, _ := json.MarshalIndent(buses, "", " ") return SilentResult(fmt.Sprintf("Found %d I2C bus(es):\n%s", len(buses), string(result))) } - -// isValidBusID checks that a bus identifier is a simple number (prevents path injection) -func isValidBusID(id string) bool { - matched, _ := regexp.MatchString(`^\d+$`, id) - return matched -} - -// parseI2CAddress extracts and validates an I2C address from args -func parseI2CAddress(args map[string]any) (int, *ToolResult) { - addrFloat, ok := args["address"].(float64) - if !ok { - return 0, ErrorResult("address is required (e.g. 0x38 for AHT20)") - } - addr := int(addrFloat) - if addr < 0x03 || addr > 0x77 { - return 0, ErrorResult("address must be in valid 7-bit range (0x03-0x77)") - } - return addr, nil -} - -// parseI2CBus extracts and validates an I2C bus from args -func parseI2CBus(args map[string]any) (string, *ToolResult) { - bus, ok := args["bus"].(string) - if !ok || bus == "" { - return "", ErrorResult("bus is required (e.g. \"1\" for /dev/i2c-1)") - } - if !isValidBusID(bus) { - return "", ErrorResult("invalid bus identifier: must be a number (e.g. \"1\")") - } - return bus, nil -} diff --git a/pkg/tools/spi.go b/pkg/tools/spi.go index d6a88a5b0..91ed2d2d2 100644 --- a/pkg/tools/spi.go +++ b/pkg/tools/spi.go @@ -97,9 +97,7 @@ func (t *SPITool) list() *ToolResult { } if len(matches) == 0 { - return SilentResult( - "No SPI devices found. You may need to:\n1. Enable SPI in device tree\n2. Configure pinmux for your board (see hardware skill)\n3. Check that spidev module is loaded", - ) + return SilentResult("No SPI devices found. You may need to:\n1. Enable SPI in device tree\n2. Configure pinmux for your board (see hardware skill)\n3. Check that spidev module is loaded") } type devInfo struct { @@ -118,41 +116,3 @@ func (t *SPITool) list() *ToolResult { result, _ := json.MarshalIndent(devices, "", " ") return SilentResult(fmt.Sprintf("Found %d SPI device(s):\n%s", len(devices), string(result))) } - -// parseSPIArgs extracts and validates common SPI parameters -func parseSPIArgs(args map[string]any) (device string, speed uint32, mode uint8, bits uint8, errMsg string) { - dev, ok := args["device"].(string) - if !ok || dev == "" { - return "", 0, 0, 0, "device is required (e.g. \"2.0\" for /dev/spidev2.0)" - } - matched, _ := regexp.MatchString(`^\d+\.\d+$`, dev) - if !matched { - return "", 0, 0, 0, "invalid device identifier: must be in format \"X.Y\" (e.g. \"2.0\")" - } - - speed = 1000000 // default 1 MHz - if s, ok := args["speed"].(float64); ok { - if s < 1 || s > 125000000 { - return "", 0, 0, 0, "speed must be between 1 Hz and 125 MHz" - } - speed = uint32(s) - } - - mode = 0 - if m, ok := args["mode"].(float64); ok { - if int(m) < 0 || int(m) > 3 { - return "", 0, 0, 0, "mode must be 0-3" - } - mode = uint8(m) - } - - bits = 8 - if b, ok := args["bits"].(float64); ok { - if int(b) < 1 || int(b) > 32 { - return "", 0, 0, 0, "bits must be between 1 and 32" - } - bits = uint8(b) - } - - return dev, speed, mode, bits, "" -}