From 09c25b99757d2b0141fb0004849acfb102ac5e01 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Feb 2026 15:38:00 +0000 Subject: [PATCH] chore: replace interface{} with any (Go 1.18+ alias) Co-Authored-By: Claude Opus 4.6 --- pkg/cache/cache.go | 4 ++-- pkg/framework/core/interfaces.go | 6 +++--- pkg/session/parser.go | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 60aefb9..bc5dc5a 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -67,7 +67,7 @@ func (c *Cache) Path(key string) string { } // Get retrieves a cached item if it exists and hasn't expired. -func (c *Cache) Get(key string, dest interface{}) (bool, error) { +func (c *Cache) Get(key string, dest any) (bool, error) { path := c.Path(key) dataStr, err := c.medium.Read(path) @@ -98,7 +98,7 @@ func (c *Cache) Get(key string, dest interface{}) (bool, error) { } // Set stores an item in the cache. -func (c *Cache) Set(key string, data interface{}) error { +func (c *Cache) Set(key string, data any) error { path := c.Path(key) // Ensure parent directory exists diff --git a/pkg/framework/core/interfaces.go b/pkg/framework/core/interfaces.go index 8d587d2..a347ebb 100644 --- a/pkg/framework/core/interfaces.go +++ b/pkg/framework/core/interfaces.go @@ -44,15 +44,15 @@ type Option func(*Core) error // Message is the interface for all messages that can be sent through the Core's IPC system. // Any struct can be a message, allowing for structured data to be passed between services. // Used with ACTION for fire-and-forget broadcasts. -type Message interface{} +type Message any // Query is the interface for read-only requests that return data. // Used with QUERY (first responder) or QUERYALL (all responders). -type Query interface{} +type Query any // Task is the interface for requests that perform side effects. // Used with PERFORM (first responder executes). -type Task interface{} +type Task any // TaskWithID is an optional interface for tasks that need to know their assigned ID. // This is useful for tasks that want to report progress back to the frontend. diff --git a/pkg/session/parser.go b/pkg/session/parser.go index 6304189..4c3dd87 100644 --- a/pkg/session/parser.go +++ b/pkg/session/parser.go @@ -54,7 +54,7 @@ type contentBlock struct { Text string `json:"text,omitempty"` Input json.RawMessage `json:"input,omitempty"` ToolUseID string `json:"tool_use_id,omitempty"` - Content interface{} `json:"content,omitempty"` + Content any `json:"content,omitempty"` IsError *bool `json:"is_error,omitempty"` } @@ -340,7 +340,7 @@ func extractToolInput(toolName string, raw json.RawMessage) string { } // Fallback: show raw JSON keys - var m map[string]interface{} + var m map[string]any if json.Unmarshal(raw, &m) == nil { var parts []string for k := range m { @@ -353,21 +353,21 @@ func extractToolInput(toolName string, raw json.RawMessage) string { return "" } -func extractResultContent(content interface{}) string { +func extractResultContent(content any) string { switch v := content.(type) { case string: return v - case []interface{}: + case []any: var parts []string for _, item := range v { - if m, ok := item.(map[string]interface{}); ok { + if m, ok := item.(map[string]any); ok { if text, ok := m["text"].(string); ok { parts = append(parts, text) } } } return strings.Join(parts, "\n") - case map[string]interface{}: + case map[string]any: if text, ok := v["text"].(string); ok { return text }