From 724a143f904bdbe4a02eb375a57d182d6937cbd0 Mon Sep 17 00:00:00 2001 From: Victor Vargas Date: Sun, 12 Jul 2026 16:14:15 -0700 Subject: [PATCH] style: gofmt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Formatting only (struct field alignment, import ordering) across the files that didn't comply — no semantic changes. Co-Authored-By: Claude Fable 5 --- pkg/agent/integration_test.go | 14 ++++----- pkg/agent/loop_test.go | 22 ++++++------- pkg/config/config.go | 30 +++++++++--------- pkg/llm/mock/mock.go | 6 ++-- pkg/llm/mock/mock_test.go | 2 +- pkg/llm/providers/llamacpp/client_test.go | 8 ++--- pkg/llm/providers/openai/client_test.go | 16 +++++----- pkg/llm/types.go | 38 +++++++++++------------ pkg/llm/types_test.go | 6 ++-- pkg/persona/persona.go | 2 +- pkg/rag/backends/chroma/chroma.go | 8 ++--- pkg/rag/backends/chroma/chroma_test.go | 2 +- pkg/rag/memory_test.go | 6 ++-- pkg/tools/registry.go | 6 ++-- pkg/tools/types.go | 12 +++---- 15 files changed, 88 insertions(+), 90 deletions(-) diff --git a/pkg/agent/integration_test.go b/pkg/agent/integration_test.go index 6de55ad..2a2f052 100644 --- a/pkg/agent/integration_test.go +++ b/pkg/agent/integration_test.go @@ -96,10 +96,10 @@ func TestIntegration_AgentLoop_Generate(t *testing.T) { }) loop := agent.New(agent.Config{ - LLM: client, - Persona: persona.DefaultPersona(), - Tools: registry, - Sandbox: &mockSandbox{}, + LLM: client, + Persona: persona.DefaultPersona(), + Tools: registry, + Sandbox: &mockSandbox{}, MaxIters: 3, }) @@ -124,9 +124,9 @@ func TestIntegration_AgentLoop_Stream(t *testing.T) { } loop := agent.New(agent.Config{ - LLM: client, - Persona: persona.DefaultPersona(), - Tools: tools.NewRegistry(), + LLM: client, + Persona: persona.DefaultPersona(), + Tools: tools.NewRegistry(), MaxIters: 3, }) diff --git a/pkg/agent/loop_test.go b/pkg/agent/loop_test.go index ccf5931..2135b93 100644 --- a/pkg/agent/loop_test.go +++ b/pkg/agent/loop_test.go @@ -28,8 +28,8 @@ func (m *mockLLM) Stream(ctx context.Context, req llm.CompletionRequest) iter.Se return m.streamFunc(ctx, req) } -func (m *mockLLM) Name() string { return "mock" } -func (m *mockLLM) Capabilities() llm.ProviderCapabilities { return llm.ProviderCapabilities{} } +func (m *mockLLM) Name() string { return "mock" } +func (m *mockLLM) Capabilities() llm.ProviderCapabilities { return llm.ProviderCapabilities{} } type mockSandbox struct { validateFunc func(tool tools.Tool, call llm.ToolCall) error @@ -71,9 +71,9 @@ func TestNew_CustomMaxIters(t *testing.T) { } loop := New(Config{ - LLM: mockClient, - Persona: persona.DefaultPersona(), - Tools: tools.NewRegistry(), + LLM: mockClient, + Persona: persona.DefaultPersona(), + Tools: tools.NewRegistry(), MaxIters: 10, }) @@ -373,9 +373,9 @@ func TestRun_MaxIterations(t *testing.T) { }) loop := New(Config{ - LLM: mockClient, - Persona: persona.DefaultPersona(), - Tools: registry, + LLM: mockClient, + Persona: persona.DefaultPersona(), + Tools: registry, MaxIters: 3, }) @@ -706,9 +706,9 @@ func TestRun_Stream_MaxIterations(t *testing.T) { }) loop := New(Config{ - LLM: mockClient, - Persona: persona.DefaultPersona(), - Tools: registry, + LLM: mockClient, + Persona: persona.DefaultPersona(), + Tools: registry, MaxIters: 1, }) diff --git a/pkg/config/config.go b/pkg/config/config.go index a663a54..8793a31 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -7,34 +7,34 @@ import ( // ProviderConfig holds provider-specific settings. type ProviderConfig struct { - Type string `yaml:"type"` - Model string `yaml:"model"` - APIKey string `yaml:"api_key"` - BaseURL string `yaml:"base_url,omitempty"` - MaxTokens int `yaml:"max_tokens,omitempty"` + Type string `yaml:"type"` + Model string `yaml:"model"` + APIKey string `yaml:"api_key"` + BaseURL string `yaml:"base_url,omitempty"` + MaxTokens int `yaml:"max_tokens,omitempty"` Temperature float32 `yaml:"temperature,omitempty"` } // ToolPolicy controls which tools are available and their permissions. type ToolPolicy struct { - DefaultPermission string `yaml:"default_permission"` - AllowList []string `yaml:"allow_list,omitempty"` - DenyList []string `yaml:"deny_list,omitempty"` + DefaultPermission string `yaml:"default_permission"` + AllowList []string `yaml:"allow_list,omitempty"` + DenyList []string `yaml:"deny_list,omitempty"` } // LoggingConfig controls logging output. type LoggingConfig struct { - Level string `yaml:"level"` - Format string `yaml:"format"` - Output string `yaml:"output"` + Level string `yaml:"level"` + Format string `yaml:"format"` + Output string `yaml:"output"` } // Config is the top-level configuration for the agent. type Config struct { - Model string `yaml:"model"` - Provider ProviderConfig `yaml:"provider"` - Tools ToolPolicy `yaml:"tools"` - Logging LoggingConfig `yaml:"logging"` + Model string `yaml:"model"` + Provider ProviderConfig `yaml:"provider"` + Tools ToolPolicy `yaml:"tools"` + Logging LoggingConfig `yaml:"logging"` } // Loader is responsible for loading configuration from various sources. diff --git a/pkg/llm/mock/mock.go b/pkg/llm/mock/mock.go index f34f625..4c56987 100644 --- a/pkg/llm/mock/mock.go +++ b/pkg/llm/mock/mock.go @@ -10,9 +10,9 @@ import ( // MockLLMClient is a deterministic implementation of llm.LLMClient for testing. type MockLLMClient struct { - GenerateFunc func(ctx context.Context, req llm.CompletionRequest) (llm.CompletionResponse, error) - StreamFunc func(ctx context.Context, req llm.CompletionRequest) iter.Seq2[llm.StreamChunk, error] - NameFunc func() string + GenerateFunc func(ctx context.Context, req llm.CompletionRequest) (llm.CompletionResponse, error) + StreamFunc func(ctx context.Context, req llm.CompletionRequest) iter.Seq2[llm.StreamChunk, error] + NameFunc func() string CapabilitiesFunc func() llm.ProviderCapabilities } diff --git a/pkg/llm/mock/mock_test.go b/pkg/llm/mock/mock_test.go index c049aeb..7a86371 100644 --- a/pkg/llm/mock/mock_test.go +++ b/pkg/llm/mock/mock_test.go @@ -167,7 +167,7 @@ func TestMockLLMClient_MatchResponse(t *testing.T) { client := NewWithMatch([]MatchResponse{ {Match: "hello", Response: "hi there!"}, {Match: "world", Response: "earth"}, - {Match: "*", Response: "default"}, + {Match: "*", Response: "default"}, }) resp, _ := client.Generate(context.Background(), llm.CompletionRequest{ diff --git a/pkg/llm/providers/llamacpp/client_test.go b/pkg/llm/providers/llamacpp/client_test.go index 7e66c3b..4de3eed 100644 --- a/pkg/llm/providers/llamacpp/client_test.go +++ b/pkg/llm/providers/llamacpp/client_test.go @@ -34,8 +34,8 @@ func TestClient_Generate(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(llamaChatResponse{ - ID: "llama-123", - Model: "llama3", + ID: "llama-123", + Model: "llama3", Choices: []llamaChoice{ { Index: 0, @@ -189,8 +189,8 @@ func TestClient_Generate_ToolCall(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(llamaChatResponse{ - ID: "llama-tool-1", - Model: "llama3", + ID: "llama-tool-1", + Model: "llama3", Choices: []llamaChoice{ { Index: 0, diff --git a/pkg/llm/providers/openai/client_test.go b/pkg/llm/providers/openai/client_test.go index dd838f6..04c7040 100644 --- a/pkg/llm/providers/openai/client_test.go +++ b/pkg/llm/providers/openai/client_test.go @@ -33,8 +33,8 @@ func TestClient_Generate(t *testing.T) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(openaiChatResponse{ - ID: "test-123", - Model: "gpt-4", + ID: "test-123", + Model: "gpt-4", Choices: []openaiChoice{ { Index: 0, @@ -55,8 +55,8 @@ func TestClient_Generate(t *testing.T) { defer server.Close() client, err := New(Config{ - APIKey: "test-key", - BaseURL: server.URL, + APIKey: "test-key", + BaseURL: server.URL, }) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -90,8 +90,8 @@ func TestClient_Generate_Error(t *testing.T) { defer server.Close() client, err := New(Config{ - APIKey: "bad-key", - BaseURL: server.URL, + APIKey: "bad-key", + BaseURL: server.URL, }) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -113,8 +113,8 @@ func TestClient_Stream(t *testing.T) { defer server.Close() client, err := New(Config{ - APIKey: "test-key", - BaseURL: server.URL + "/v1", + APIKey: "test-key", + BaseURL: server.URL + "/v1", }) if err != nil { t.Fatalf("unexpected error: %v", err) diff --git a/pkg/llm/types.go b/pkg/llm/types.go index 3e571de..7c8df57 100644 --- a/pkg/llm/types.go +++ b/pkg/llm/types.go @@ -10,18 +10,18 @@ import ( type Role string const ( - RoleSystem Role = "system" - RoleUser Role = "user" + RoleSystem Role = "system" + RoleUser Role = "user" RoleAssistant Role = "assistant" - RoleTool Role = "tool" + RoleTool Role = "tool" ) // Message is a single message in a conversation. type Message struct { - Role Role `json:"role"` - Content string `json:"content"` - ToolCallID string `json:"tool_call_id,omitempty"` - Name string `json:"name,omitempty"` + Role Role `json:"role"` + Content string `json:"content"` + ToolCallID string `json:"tool_call_id,omitempty"` + Name string `json:"name,omitempty"` // ToolCalls records the calls an assistant message requested, so the // agent loop can replay them on the next request: without this, the // conversation sent back to the model has tool-result messages with no @@ -50,8 +50,8 @@ type TokenUsage struct { type ToolChoice string const ( - ToolChoiceAuto ToolChoice = "auto" - ToolChoiceNone ToolChoice = "none" + ToolChoiceAuto ToolChoice = "auto" + ToolChoiceNone ToolChoice = "none" ToolChoiceRequired ToolChoice = "required" ) @@ -73,14 +73,14 @@ func (t *ToolRef) MarshalJSON() ([]byte, error) { // CompletionRequest is sent to an LLM provider. type CompletionRequest struct { - Model string `json:"model"` - Messages []Message `json:"messages"` - Tools []json.RawMessage `json:"tools,omitempty"` - ToolChoice interface{} `json:"tool_choice,omitempty"` // ToolChoice, ToolRef, or null - Temperature *float32 `json:"temperature,omitempty"` - MaxTokens *int `json:"max_tokens,omitempty"` - Stop []string `json:"stop,omitempty"` - Metadata map[string]string `json:"metadata,omitempty"` + Model string `json:"model"` + Messages []Message `json:"messages"` + Tools []json.RawMessage `json:"tools,omitempty"` + ToolChoice interface{} `json:"tool_choice,omitempty"` // ToolChoice, ToolRef, or null + Temperature *float32 `json:"temperature,omitempty"` + MaxTokens *int `json:"max_tokens,omitempty"` + Stop []string `json:"stop,omitempty"` + Metadata map[string]string `json:"metadata,omitempty"` ChatTemplateKwargs map[string]any `json:"chat_template_kwargs,omitempty"` // model-specific chat template params, e.g. Qwen enable_thinking } @@ -98,9 +98,9 @@ type CompletionResponse struct { // StopReason values. const ( StopReasonEndTurn = "end_turn" - StopReasonToolUse = "tool_use" + StopReasonToolUse = "tool_use" StopReasonMaxTokens = "max_tokens" - StopReasonStopSeq = "stop_sequence" + StopReasonStopSeq = "stop_sequence" ) // ToolCall represents a function invocation requested by the model. diff --git a/pkg/llm/types_test.go b/pkg/llm/types_test.go index 6747890..0359137 100644 --- a/pkg/llm/types_test.go +++ b/pkg/llm/types_test.go @@ -121,7 +121,7 @@ func TestToolCall_JSON(t *testing.T) { func TestStreamChunk_JSON(t *testing.T) { chunk := StreamChunk{ - Delta: "hello", + Delta: "hello", ToolCalls: []ToolCall{}, } @@ -139,7 +139,5 @@ func TestStreamChunk_JSON(t *testing.T) { } } - - -func float32Ptr(f float32) *float32 { return &f } +func float32Ptr(f float32) *float32 { return &f } func intPtr(i int) *int { return &i } diff --git a/pkg/persona/persona.go b/pkg/persona/persona.go index c092b23..b8a72a1 100644 --- a/pkg/persona/persona.go +++ b/pkg/persona/persona.go @@ -18,7 +18,7 @@ type Persona struct { Style string Language string Constraints []string - FewShot []llm.Message + FewShot []llm.Message } // Loader loads personas from files. diff --git a/pkg/rag/backends/chroma/chroma.go b/pkg/rag/backends/chroma/chroma.go index 3900cb2..586b313 100644 --- a/pkg/rag/backends/chroma/chroma.go +++ b/pkg/rag/backends/chroma/chroma.go @@ -224,13 +224,13 @@ func stringifyMap(m map[string]interface{}) map[string]string { // chromaQueryResponse represents the structure of a ChromaDB query response. type chromaQueryResponse struct { - Names []string `json:"names"` + Names []string `json:"names"` Results []chromaQueryResults `json:"results"` } type chromaQueryResults struct { - IDs [][]string `json:"ids"` - Documents [][]string `json:"documents"` - Distances [][]float64 `json:"distances"` + IDs [][]string `json:"ids"` + Documents [][]string `json:"documents"` + Distances [][]float64 `json:"distances"` Metadatas [][]map[string]interface{} `json:"metadatas"` } diff --git a/pkg/rag/backends/chroma/chroma_test.go b/pkg/rag/backends/chroma/chroma_test.go index dfe6324..03101a4 100644 --- a/pkg/rag/backends/chroma/chroma_test.go +++ b/pkg/rag/backends/chroma/chroma_test.go @@ -54,7 +54,7 @@ func TestBackend_Search(t *testing.T) { meta := []map[string]interface{}{{"key": "value"}} metaNested := [][]map[string]interface{}{meta} mockResponse := map[string]interface{}{ - "names": []string{"rony-memory"}, + "names": []string{"rony-memory"}, "results": []map[string]interface{}{ { "ids": [][]string{{"test-id"}}, diff --git a/pkg/rag/memory_test.go b/pkg/rag/memory_test.go index dbe77f8..7bda2d4 100644 --- a/pkg/rag/memory_test.go +++ b/pkg/rag/memory_test.go @@ -193,9 +193,9 @@ func TestMemory_Search_EmbeddingErrorFallsBackToLexicalSearch(t *testing.T) { // mockBackend implements chroma.Backend for testing. type mockBackend struct { - upsertFunc func(ctx context.Context, id string, vector []float32, content string, metadata map[string]string) error - searchFunc func(ctx context.Context, query string, queryVector []float32, topK int) ([]rag.SearchResult, error) - forgetAllFunc func(ctx context.Context) error + upsertFunc func(ctx context.Context, id string, vector []float32, content string, metadata map[string]string) error + searchFunc func(ctx context.Context, query string, queryVector []float32, topK int) ([]rag.SearchResult, error) + forgetAllFunc func(ctx context.Context) error } func (m *mockBackend) Upsert(ctx context.Context, id string, vector []float32, content string, metadata map[string]string) error { diff --git a/pkg/tools/registry.go b/pkg/tools/registry.go index dc64673..955c66f 100644 --- a/pkg/tools/registry.go +++ b/pkg/tools/registry.go @@ -6,9 +6,9 @@ import ( // registry is the default implementation of Registry. type registry struct { - mu sync.RWMutex - tools map[string]Tool - order []string + mu sync.RWMutex + tools map[string]Tool + order []string } // NewRegistry returns a new empty registry. diff --git a/pkg/tools/types.go b/pkg/tools/types.go index 1db51cd..dae7c05 100644 --- a/pkg/tools/types.go +++ b/pkg/tools/types.go @@ -45,10 +45,10 @@ type ToolHandler func(ctx context.Context, args json.RawMessage) (ToolResult, er // ToolResult is returned by a ToolHandler. type ToolResult struct { - Content string - IsError bool - Metadata map[string]string - Artifacts []Artifact + Content string + IsError bool + Metadata map[string]string + Artifacts []Artifact } // Artifact represents a file or data artifact produced by a tool. @@ -60,8 +60,8 @@ type Artifact struct { // ToolExample provides few-shot examples for the LLM to improve tool usage. type ToolExample struct { - Input map[string]interface{} - Output string + Input map[string]interface{} + Output string } // Registry manages tool registration and lookup.