From 735aedb452f145b79b9e1443621c6fa367b08a03 Mon Sep 17 00:00:00 2001 From: Patel230 Date: Tue, 9 Jun 2026 11:54:43 +0530 Subject: [PATCH] fix: pin gofumpt v0.10.0 and align Go version badge - CI: pinned gofumpt to v0.10.0 and reformatted the 10 affected files (excluding external/ submodules). - README: Go badge -> 1.26+ to match go.mod (go 1.26.4). Verified: go build/vet/test pass; gofumpt v0.10.0 clean (excluding submodules). --- .github/workflows/ci.yml | 2 +- cmd/ai_comments.go | 9 +++-- cmd/chat.go | 3 +- cmd/statusbar.go | 3 +- internal/codegraph/algorithms_cgo.go | 9 +++-- internal/codegraph/codegraph_cgo.go | 54 ++++++++++++++++--------- internal/codegraph/embeddings_cgo.go | 3 +- internal/engine/project/release_test.go | 3 +- internal/engine/structured_output.go | 6 ++- internal/sandbox/container.go | 3 +- internal/session/session_gain.go | 3 +- 11 files changed, 65 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 238a26d3..d62c2932 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: cache: true - name: gofumpt run: | - go install mvdan.cc/gofumpt@v0.7.0 + go install mvdan.cc/gofumpt@v0.10.0 out=$(gofumpt -l .) if [ -n "$out" ]; then echo "::error::gofumpt would reformat:" diff --git a/cmd/ai_comments.go b/cmd/ai_comments.go index 045513a5..6a0c87c3 100644 --- a/cmd/ai_comments.go +++ b/cmd/ai_comments.go @@ -104,17 +104,20 @@ func formatDirectivePrompt(d AIDirective) string { if d.Mode == "?" { b.WriteString(fmt.Sprintf( "An AI question comment was found at %s:%d.\n\nQuestion: %s\n\n", - d.Path, d.Line, d.Instruction)) + d.Path, d.Line, d.Instruction, + )) b.WriteString("Answer the question. If a code change is warranted, make it. ") } else { b.WriteString(fmt.Sprintf( "An AI instruction comment was found at %s:%d.\n\nInstruction: %s\n\n", - d.Path, d.Line, d.Instruction)) + d.Path, d.Line, d.Instruction, + )) b.WriteString("Implement this change now, editing the file in place. ") } b.WriteString(fmt.Sprintf( "The directive lives in the file %s; after you finish, the AI comment token will be removed automatically.\n", - d.Path)) + d.Path, + )) return b.String() } diff --git a/cmd/chat.go b/cmd/chat.go index c5f313af..37acfdad 100644 --- a/cmd/chat.go +++ b/cmd/chat.go @@ -1052,7 +1052,8 @@ func (m chatModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case compactMsg: m.compacting = false m.brailleSpinner.SetLabel(m.spinnerVerb) - line := fmt.Sprintf("Context compacted (%s): ~%s → ~%s tokens", + line := fmt.Sprintf( + "Context compacted (%s): ~%s → ~%s tokens", msg.strategy, formatHawkTokenCount(msg.tokensBefore), formatHawkTokenCount(msg.tokensAfter), diff --git a/cmd/statusbar.go b/cmd/statusbar.go index 086f833f..d4aebee9 100644 --- a/cmd/statusbar.go +++ b/cmd/statusbar.go @@ -85,7 +85,8 @@ func renderStatusBarRight(m *chatModel) string { meta = append(meta, dim.Render("⏸")) } - parts := append(meta, + parts := append( + meta, tokenStyle.Render(tokenText), costStyle.Render(costText), timeStyle.Render(timerText), diff --git a/internal/codegraph/algorithms_cgo.go b/internal/codegraph/algorithms_cgo.go index 384ce9c7..1d8f3401 100644 --- a/internal/codegraph/algorithms_cgo.go +++ b/internal/codegraph/algorithms_cgo.go @@ -538,7 +538,8 @@ func (cg *CodeGraph) FindDeadCode() ([]DeadCodeEntry, error) { defer cg.mu.RUnlock() // Get all nodes - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext( + context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE kind IN ('function', 'method', 'class', 'interface', 'struct')`, @@ -769,7 +770,8 @@ func (cg *CodeGraph) ImpactAnalysis(nodeID string, maxDepth int) (*ImpactResult, result.Impacted[s.id] = s.depth // Get all nodes that depend on this one - rows, _ := cg.db.QueryContext(context.Background(), + rows, _ := cg.db.QueryContext( + context.Background(), `SELECT source FROM edges WHERE target = ? AND kind IN ('calls', 'references', 'imports', 'extends', 'implements')`, s.id, ) if rows != nil { @@ -790,7 +792,8 @@ func (cg *CodeGraph) ImpactAnalysis(nodeID string, maxDepth int) (*ImpactResult, // Load node details for id, depth := range result.Impacted { var n Node - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext( + context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, id, diff --git a/internal/codegraph/codegraph_cgo.go b/internal/codegraph/codegraph_cgo.go index 9b1eb00e..d928b40d 100644 --- a/internal/codegraph/codegraph_cgo.go +++ b/internal/codegraph/codegraph_cgo.go @@ -365,7 +365,8 @@ func (cg *CodeGraph) IndexFile(filePath string) error { defer cg.mu.Unlock() for _, n := range nodes { - _, err := cg.db.ExecContext(context.Background(), + _, err := cg.db.ExecContext( + context.Background(), `INSERT OR REPLACE INTO nodes (id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, n.ID, n.Kind, n.Name, n.QualifiedName, n.FilePath, n.Language, @@ -378,7 +379,8 @@ func (cg *CodeGraph) IndexFile(filePath string) error { } for _, e := range edges { - _, err := cg.db.ExecContext(context.Background(), + _, err := cg.db.ExecContext( + context.Background(), `INSERT INTO edges (source, target, kind, line, metadata) VALUES (?, ?, ?, ?, ?)`, e.Source, e.Target, e.Kind, e.Line, e.Metadata, ) @@ -388,7 +390,8 @@ func (cg *CodeGraph) IndexFile(filePath string) error { } for _, ref := range unresolvedRefs { - _, err := cg.db.ExecContext(context.Background(), + _, err := cg.db.ExecContext( + context.Background(), `INSERT INTO unresolved_refs (from_node_id, reference_name, reference_kind, line, file_path, language) VALUES (?, ?, ?, ?, ?, ?)`, ref.FromNodeID, ref.ReferenceName, ref.ReferenceKind, ref.Line, ref.FilePath, ref.Language, @@ -400,7 +403,8 @@ func (cg *CodeGraph) IndexFile(filePath string) error { // Update file record hash := sha256Sum(source) - _, _ = cg.db.ExecContext(context.Background(), + _, _ = cg.db.ExecContext( + context.Background(), `INSERT OR REPLACE INTO files (path, content_hash, language, size, modified_at, indexed_at, node_count) VALUES (?, ?, ?, ?, ?, ?, ?)`, filePath, hash, ext, len(source), time.Now().Unix(), time.Now().Unix(), len(nodes), @@ -439,7 +443,8 @@ func (cg *CodeGraph) Search(query string, limit int) ([]Node, error) { cg.mu.RLock() defer cg.mu.RUnlock() - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext( + context.Background(), `SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language, n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported FROM nodes_fts fts @@ -450,7 +455,8 @@ func (cg *CodeGraph) Search(query string, limit int) ([]Node, error) { ) if err != nil { // Fallback to LIKE search - rows, err = cg.db.QueryContext(context.Background(), + rows, err = cg.db.QueryContext( + context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE name LIKE ? ORDER BY name LIMIT ?`, @@ -491,7 +497,8 @@ func (cg *CodeGraph) GetCallers(nodeID string, maxDepth int) ([]Node, error) { } visited[current.id] = true - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext( + context.Background(), `SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language, n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported FROM edges e JOIN nodes n ON n.id = e.source @@ -542,7 +549,8 @@ func (cg *CodeGraph) GetCallees(nodeID string, maxDepth int) ([]Node, error) { } visited[current.id] = true - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext( + context.Background(), `SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language, n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported FROM edges e JOIN nodes n ON n.id = e.target @@ -578,7 +586,8 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error // Get the focal node var focalNode Node - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext( + context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, nodeID, @@ -615,7 +624,8 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error // Get node var n Node - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext( + context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, s.nodeID, @@ -630,7 +640,8 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error // If container, expand children at same depth if containerKinds[n.Kind] { - childRows, _ := cg.db.QueryContext(context.Background(), + childRows, _ := cg.db.QueryContext( + context.Background(), `SELECT target FROM edges WHERE source = ? AND kind = 'contains'`, s.nodeID, ) if childRows != nil { @@ -646,7 +657,8 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error } // Traverse incoming edges (things that depend on this node) - depRows, _ := cg.db.QueryContext(context.Background(), + depRows, _ := cg.db.QueryContext( + context.Background(), `SELECT source FROM edges WHERE target = ? AND kind IN ('calls', 'references', 'imports', 'extends', 'implements')`, s.nodeID, ) if depRows != nil { @@ -763,7 +775,8 @@ func (cg *CodeGraph) ResolveRefs() error { for _, r := range refs { // Try to find target by name var targetID string - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext( + context.Background(), `SELECT id FROM nodes WHERE name = ? OR qualified_name LIKE ? LIMIT 1`, r.name, "%"+r.name, ).Scan(&targetID) @@ -772,7 +785,8 @@ func (cg *CodeGraph) ResolveRefs() error { } // Create edge - _, err = cg.db.ExecContext(context.Background(), + _, err = cg.db.ExecContext( + context.Background(), `INSERT INTO edges (source, target, kind, line) VALUES (?, ?, ?, ?)`, r.fromID, targetID, r.kind, r.line, ) @@ -1200,7 +1214,8 @@ func (cg *CodeGraph) Trace(fromName, toName string) ([]Node, error) { var path []Node for _, id := range current.path { var n Node - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext( + context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, id, @@ -1216,7 +1231,8 @@ func (cg *CodeGraph) Trace(fromName, toName string) ([]Node, error) { } // Expand via call edges - edgeRows, _ := cg.db.QueryContext(context.Background(), + edgeRows, _ := cg.db.QueryContext( + context.Background(), `SELECT target FROM edges WHERE source = ? AND kind IN ('calls', 'references') LIMIT 20`, current.nodeID, ) if edgeRows != nil { @@ -1438,7 +1454,8 @@ func (cg *CodeGraph) Status() (*StatusResult, error) { // searchByName is an internal search that returns nodes matching a name. func (cg *CodeGraph) searchByName(name string, limit int) ([]Node, error) { - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext( + context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE name = ? OR name LIKE ? LIMIT ?`, @@ -1457,7 +1474,8 @@ func (cg *CodeGraph) GetNode(id string) (Node, error) { defer cg.mu.RUnlock() var n Node - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext( + context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, id, diff --git a/internal/codegraph/embeddings_cgo.go b/internal/codegraph/embeddings_cgo.go index 0f47d80b..96cb351d 100644 --- a/internal/codegraph/embeddings_cgo.go +++ b/internal/codegraph/embeddings_cgo.go @@ -28,7 +28,8 @@ func (cg *CodeGraph) SemanticSearch(query string, limit int) ([]Node, error) { queryVec := GenerateEmbedding(queryNode) // Get all nodes - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext( + context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE kind IN ('function', 'method', 'class', 'interface', 'struct')`, diff --git a/internal/engine/project/release_test.go b/internal/engine/project/release_test.go index 57b9bc41..dc49e22f 100644 --- a/internal/engine/project/release_test.go +++ b/internal/engine/project/release_test.go @@ -917,7 +917,8 @@ func runGit(t *testing.T, dir string, args ...string) { } cmd := exec.CommandContext(context.Background(), "git", args...) cmd.Dir = dir - cmd.Env = append(os.Environ(), + cmd.Env = append( + os.Environ(), "GIT_AUTHOR_DATE=2024-01-01T00:00:00Z", "GIT_COMMITTER_DATE=2024-01-01T00:00:00Z", "GIT_CONFIG_COUNT=2", diff --git a/internal/engine/structured_output.go b/internal/engine/structured_output.go index 6b4f7ddb..81196280 100644 --- a/internal/engine/structured_output.go +++ b/internal/engine/structured_output.go @@ -54,12 +54,14 @@ func (s *Session) ChatStructured(ctx context.Context, msgs []types.EyrieMessage, } else { // Retry once with a corrective instruction. retryMsgs := append([]types.EyrieMessage(nil), msgs...) - retryMsgs = append(retryMsgs, + retryMsgs = append( + retryMsgs, types.EyrieMessage{Role: "assistant", Content: responseText(resp)}, types.EyrieMessage{Role: "user", Content: fmt.Sprintf( "Your previous response did not conform to the required JSON schema (%s). "+ "Respond again with ONLY valid JSON that matches the schema. Schema:\n%s", - vErr.Error(), schema)}, + vErr.Error(), schema, + )}, ) retryResp, retryErr := s.client.Chat(ctx, retryMsgs, opts) if retryErr != nil { diff --git a/internal/sandbox/container.go b/internal/sandbox/container.go index ac9af0c0..170902fd 100644 --- a/internal/sandbox/container.go +++ b/internal/sandbox/container.go @@ -86,7 +86,8 @@ func (c *ContainerSandbox) Start(ctx context.Context) error { } // Inject declarative startup env vars (additive; nil when none configured). args = append(args, c.runtime.StartupEnvArgs()...) - args = append(args, + args = append( + args, c.image, "sleep", "infinity", ) diff --git a/internal/session/session_gain.go b/internal/session/session_gain.go index 5a4e26f5..3a3858c7 100644 --- a/internal/session/session_gain.go +++ b/internal/session/session_gain.go @@ -116,7 +116,8 @@ func (g *GainTracker) Record(ctx context.Context, ev GainEvent) error { if ev.Timestamp.IsZero() { ev.Timestamp = time.Now() } - _, err := g.store.db.ExecContext(ctx, ` + _, err := g.store.db.ExecContext( + ctx, ` INSERT INTO gains (session_id, ts, command, original_bytes, compressed_bytes, original_tokens, compressed_tokens, mode, tier, model)