on main help sign in
chore: lint
272d931Kujtim Hoxha
cmd/root.go+4−4
@@ -93,7 +93,7 @@ to assist developers in writing, debugging, and understanding code directly from
93
93
94 app, err := app.New(ctx, conn)
94 app, err := app.New(ctx, conn)
95 if err != nil {
95 if err != nil {
96− slog.Error("Failed to create app: %v", err)
96+ slog.Error(fmt.Sprintf("Failed to create app instance: %v", err))
97 return err
97 return err
98 }
98 }
99 // Defer shutdown here so it runs for both interactive and non-interactive modes
99 // Defer shutdown here so it runs for both interactive and non-interactive modes
@@ -104,7 +104,7 @@ to assist developers in writing, debugging, and understanding code directly from
104
104
105 prompt, err = maybePrependStdin(prompt)
105 prompt, err = maybePrependStdin(prompt)
106 if err != nil {
106 if err != nil {
107− slog.Error("Failed to read stdin: %v", err)
107+ slog.Error(fmt.Sprintf("Failed to read from stdin: %v", err))
108 return err
108 return err
109 }
109 }
110
110
@@ -174,11 +174,11 @@ to assist developers in writing, debugging, and understanding code directly from
174 cleanup()
174 cleanup()
175
175
176 if err != nil {
176 if err != nil {
177− slog.Error("TUI error: %v", err)
177+ slog.Error(fmt.Sprintf("TUI run error: %v", err))
178 return fmt.Errorf("TUI error: %v", err)
178 return fmt.Errorf("TUI error: %v", err)
179 }
179 }
180
180
181− slog.Info("TUI exited with result: %v", result)
181+ slog.Info(fmt.Sprintf("TUI exited with result: %v", result))
182 return nil
182 return nil
183 },
183 },
184}
184}
internal/app/app.go+3−2
@@ -5,6 +5,7 @@ import (
5 "database/sql"
5 "database/sql"
6 "errors"
6 "errors"
7 "fmt"
7 "fmt"
8+ "log/slog"
8 "maps"
9 "maps"
9 "sync"
10 "sync"
10 "time"
11 "time"
@@ -14,7 +15,7 @@ import (
14 "github.com/charmbracelet/crush/internal/format"
15 "github.com/charmbracelet/crush/internal/format"
15 "github.com/charmbracelet/crush/internal/history"
16 "github.com/charmbracelet/crush/internal/history"
16 "github.com/charmbracelet/crush/internal/llm/agent"
17 "github.com/charmbracelet/crush/internal/llm/agent"
17− "log/slog"
18+
18 "github.com/charmbracelet/crush/internal/lsp"
19 "github.com/charmbracelet/crush/internal/lsp"
19 "github.com/charmbracelet/crush/internal/message"
20 "github.com/charmbracelet/crush/internal/message"
20 "github.com/charmbracelet/crush/internal/permission"
21 "github.com/charmbracelet/crush/internal/permission"
@@ -73,7 +74,7 @@ func New(ctx context.Context, conn *sql.DB) (*App, error) {
73 app.LSPClients,
74 app.LSPClients,
74 )
75 )
75 if err != nil {
76 if err != nil {
76− slog.Error("Failed to create coder agent", err)
77+ slog.Error("Failed to create coder agent", "err", err)
77 return nil, err
78 return nil, err
78 }
79 }
79
80
internal/config/init.go+1−2
@@ -2,13 +2,12 @@ package config
2
2
3import (
3import (
4 "fmt"
4 "fmt"
5+ "log/slog"
5 "os"
6 "os"
6 "path/filepath"
7 "path/filepath"
7 "strings"
8 "strings"
8 "sync"
9 "sync"
9 "sync/atomic"
10 "sync/atomic"
10−
11− "log/slog"
12)
11)
13
12
14const (
13const (
internal/config/load_test.go+1−1
@@ -7,8 +7,8 @@ import (
7 "strings"
7 "strings"
8 "testing"
8 "testing"
9
9
10− "github.com/charmbracelet/crush/internal/fur/provider"
11 "github.com/charmbracelet/crush/internal/env"
10 "github.com/charmbracelet/crush/internal/env"
11+ "github.com/charmbracelet/crush/internal/fur/provider"
12 "github.com/stretchr/testify/assert"
12 "github.com/stretchr/testify/assert"
13)
13)
14
14
internal/config/resolve.go+1−1
@@ -6,8 +6,8 @@ import (
6 "strings"
6 "strings"
7 "time"
7 "time"
8
8
9− "github.com/charmbracelet/crush/internal/shell"
10 "github.com/charmbracelet/crush/internal/env"
9 "github.com/charmbracelet/crush/internal/env"
10+ "github.com/charmbracelet/crush/internal/shell"
11)
11)
12
12
13type VariableResolver interface {
13type VariableResolver interface {
internal/db/connect.go+1−1
@@ -4,6 +4,7 @@ import (
4 "context"
4 "context"
5 "database/sql"
5 "database/sql"
6 "fmt"
6 "fmt"
7+ "log/slog"
7 "os"
8 "os"
8 "path/filepath"
9 "path/filepath"
9
10
@@ -11,7 +12,6 @@ import (
11 _ "github.com/ncruces/go-sqlite3/embed"
12 _ "github.com/ncruces/go-sqlite3/embed"
12
13
13 "github.com/charmbracelet/crush/internal/config"
14 "github.com/charmbracelet/crush/internal/config"
14− "log/slog"
15
15
16 "github.com/pressly/goose/v3"
16 "github.com/pressly/goose/v3"
17)
17)
internal/fsext/fileutil.go+2−1
@@ -2,6 +2,7 @@ package fsext
2
2
3import (
3import (
4 "fmt"
4 "fmt"
5+ "log/slog"
5 "os"
6 "os"
6 "os/exec"
7 "os/exec"
7 "path/filepath"
8 "path/filepath"
@@ -11,7 +12,7 @@ import (
11
12
12 "github.com/bmatcuk/doublestar/v4"
13 "github.com/bmatcuk/doublestar/v4"
13 "github.com/charlievieth/fastwalk"
14 "github.com/charlievieth/fastwalk"
14− "log/slog"
15+
15 ignore "github.com/sabhiram/go-gitignore"
16 ignore "github.com/sabhiram/go-gitignore"
16)
17)
17
18
internal/llm/agent/mcp-tools.go+2−1
@@ -4,10 +4,11 @@ import (
4 "context"
4 "context"
5 "encoding/json"
5 "encoding/json"
6 "fmt"
6 "fmt"
7+ "log/slog"
7
8
8 "github.com/charmbracelet/crush/internal/config"
9 "github.com/charmbracelet/crush/internal/config"
9 "github.com/charmbracelet/crush/internal/llm/tools"
10 "github.com/charmbracelet/crush/internal/llm/tools"
10− "log/slog"
11+
11 "github.com/charmbracelet/crush/internal/permission"
12 "github.com/charmbracelet/crush/internal/permission"
12 "github.com/charmbracelet/crush/internal/version"
13 "github.com/charmbracelet/crush/internal/version"
13
14
internal/llm/prompt/coder.go+1−1
@@ -3,6 +3,7 @@ package prompt
3import (
3import (
4 "context"
4 "context"
5 "fmt"
5 "fmt"
6+ "log/slog"
6 "os"
7 "os"
7 "path/filepath"
8 "path/filepath"
8 "runtime"
9 "runtime"
@@ -11,7 +12,6 @@ import (
11 "github.com/charmbracelet/crush/internal/config"
12 "github.com/charmbracelet/crush/internal/config"
12 "github.com/charmbracelet/crush/internal/fur/provider"
13 "github.com/charmbracelet/crush/internal/fur/provider"
13 "github.com/charmbracelet/crush/internal/llm/tools"
14 "github.com/charmbracelet/crush/internal/llm/tools"
14− "log/slog"
15)
15)
16
16
17func CoderPrompt(p string, contextFiles ...string) string {
17func CoderPrompt(p string, contextFiles ...string) string {
internal/llm/provider/vertexai.go+1−1
@@ -2,8 +2,8 @@ package provider
2
2
3import (
3import (
4 "context"
4 "context"
5−
6 "log/slog"
5 "log/slog"
6+
7 "google.golang.org/genai"
7 "google.golang.org/genai"
8)
8)
9
9
internal/llm/tools/edit.go+2−1
@@ -4,6 +4,7 @@ import (
4 "context"
4 "context"
5 "encoding/json"
5 "encoding/json"
6 "fmt"
6 "fmt"
7+ "log/slog"
7 "os"
8 "os"
8 "path/filepath"
9 "path/filepath"
9 "strings"
10 "strings"
@@ -12,7 +13,7 @@ import (
12 "github.com/charmbracelet/crush/internal/config"
13 "github.com/charmbracelet/crush/internal/config"
13 "github.com/charmbracelet/crush/internal/diff"
14 "github.com/charmbracelet/crush/internal/diff"
14 "github.com/charmbracelet/crush/internal/history"
15 "github.com/charmbracelet/crush/internal/history"
15− "log/slog"
16+
16 "github.com/charmbracelet/crush/internal/lsp"
17 "github.com/charmbracelet/crush/internal/lsp"
17 "github.com/charmbracelet/crush/internal/permission"
18 "github.com/charmbracelet/crush/internal/permission"
18)
19)
internal/llm/tools/glob.go+1−1
@@ -5,6 +5,7 @@ import (
5 "context"
5 "context"
6 "encoding/json"
6 "encoding/json"
7 "fmt"
7 "fmt"
8+ "log/slog"
8 "os/exec"
9 "os/exec"
9 "path/filepath"
10 "path/filepath"
10 "sort"
11 "sort"
@@ -12,7 +13,6 @@ import (
12
13
13 "github.com/charmbracelet/crush/internal/config"
14 "github.com/charmbracelet/crush/internal/config"
14 "github.com/charmbracelet/crush/internal/fsext"
15 "github.com/charmbracelet/crush/internal/fsext"
15− "log/slog"
16)
16)
17
17
18const (
18const (
internal/llm/tools/write.go+2−1
@@ -4,6 +4,7 @@ import (
4 "context"
4 "context"
5 "encoding/json"
5 "encoding/json"
6 "fmt"
6 "fmt"
7+ "log/slog"
7 "os"
8 "os"
8 "path/filepath"
9 "path/filepath"
9 "strings"
10 "strings"
@@ -12,7 +13,7 @@ import (
12 "github.com/charmbracelet/crush/internal/config"
13 "github.com/charmbracelet/crush/internal/config"
13 "github.com/charmbracelet/crush/internal/diff"
14 "github.com/charmbracelet/crush/internal/diff"
14 "github.com/charmbracelet/crush/internal/history"
15 "github.com/charmbracelet/crush/internal/history"
15− "log/slog"
16+
16 "github.com/charmbracelet/crush/internal/lsp"
17 "github.com/charmbracelet/crush/internal/lsp"
17 "github.com/charmbracelet/crush/internal/permission"
18 "github.com/charmbracelet/crush/internal/permission"
18)
19)
internal/lsp/handlers.go+2−1
@@ -2,9 +2,10 @@ package lsp
2
2
3import (
3import (
4 "encoding/json"
4 "encoding/json"
5+ "log/slog"
5
6
6 "github.com/charmbracelet/crush/internal/config"
7 "github.com/charmbracelet/crush/internal/config"
7− "log/slog"
8+
8 "github.com/charmbracelet/crush/internal/lsp/protocol"
9 "github.com/charmbracelet/crush/internal/lsp/protocol"
9 "github.com/charmbracelet/crush/internal/lsp/util"
10 "github.com/charmbracelet/crush/internal/lsp/util"
10)
11)
internal/lsp/transport.go+1−1
@@ -6,10 +6,10 @@ import (
6 "encoding/json"
6 "encoding/json"
7 "fmt"
7 "fmt"
8 "io"
8 "io"
9+ "log/slog"
9 "strings"
10 "strings"
10
11
11 "github.com/charmbracelet/crush/internal/config"
12 "github.com/charmbracelet/crush/internal/config"
12− "log/slog"
13)
13)
14
14
15// Write writes an LSP message to the given writer
15// Write writes an LSP message to the given writer
internal/lsp/watcher/watcher.go+2−1
@@ -3,6 +3,7 @@ package watcher
3import (
3import (
4 "context"
4 "context"
5 "fmt"
5 "fmt"
6+ "log/slog"
6 "os"
7 "os"
7 "path/filepath"
8 "path/filepath"
8 "strings"
9 "strings"
@@ -11,7 +12,7 @@ import (
11
12
12 "github.com/bmatcuk/doublestar/v4"
13 "github.com/bmatcuk/doublestar/v4"
13 "github.com/charmbracelet/crush/internal/config"
14 "github.com/charmbracelet/crush/internal/config"
14− "log/slog"
15+
15 "github.com/charmbracelet/crush/internal/lsp"
16 "github.com/charmbracelet/crush/internal/lsp"
16 "github.com/charmbracelet/crush/internal/lsp/protocol"
17 "github.com/charmbracelet/crush/internal/lsp/protocol"
17 "github.com/fsnotify/fsnotify"
18 "github.com/fsnotify/fsnotify"
internal/tui/components/chat/sidebar/sidebar.go+1−2
@@ -13,7 +13,7 @@ import (
13 "github.com/charmbracelet/crush/internal/diff"
13 "github.com/charmbracelet/crush/internal/diff"
14 "github.com/charmbracelet/crush/internal/fsext"
14 "github.com/charmbracelet/crush/internal/fsext"
15 "github.com/charmbracelet/crush/internal/history"
15 "github.com/charmbracelet/crush/internal/history"
16− "log/slog"
16+
17 "github.com/charmbracelet/crush/internal/lsp"
17 "github.com/charmbracelet/crush/internal/lsp"
18 "github.com/charmbracelet/crush/internal/lsp/protocol"
18 "github.com/charmbracelet/crush/internal/lsp/protocol"
19 "github.com/charmbracelet/crush/internal/pubsub"
19 "github.com/charmbracelet/crush/internal/pubsub"
@@ -94,7 +94,6 @@ func (m *sidebarCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
94 case chat.SessionClearedMsg:
94 case chat.SessionClearedMsg:
95 m.session = session.Session{}
95 m.session = session.Session{}
96 case pubsub.Event[history.File]:
96 case pubsub.Event[history.File]:
97− slog.Info("sidebar", "Received file history event", "file", msg.Payload.Path, "session", msg.Payload.SessionID)
98 return m, m.handleFileHistoryEvent(msg)
97 return m, m.handleFileHistoryEvent(msg)
99 case pubsub.Event[session.Session]:
98 case pubsub.Event[session.Session]:
100 if msg.Type == pubsub.UpdatedEvent {
99 if msg.Type == pubsub.UpdatedEvent {
internal/tui/components/core/layout/split.go+3−1
@@ -1,9 +1,11 @@
1package layout
1package layout
2
2
3import (
3import (
4+ "log/slog"
5+
4 "github.com/charmbracelet/bubbles/v2/key"
6 "github.com/charmbracelet/bubbles/v2/key"
5 tea "github.com/charmbracelet/bubbletea/v2"
7 tea "github.com/charmbracelet/bubbletea/v2"
6− "log/slog"
8+
7 "github.com/charmbracelet/crush/internal/tui/styles"
9 "github.com/charmbracelet/crush/internal/tui/styles"
8 "github.com/charmbracelet/crush/internal/tui/util"
10 "github.com/charmbracelet/crush/internal/tui/util"
9 "github.com/charmbracelet/lipgloss/v2"
11 "github.com/charmbracelet/lipgloss/v2"
internal/tui/components/core/status/status.go−1
@@ -56,7 +56,6 @@ func (m *statusCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
56 return m, m.clearMessageCmd(ttl)
56 return m, m.clearMessageCmd(ttl)
57 case util.ClearStatusMsg:
57 case util.ClearStatusMsg:
58 m.info = util.InfoMsg{}
58 m.info = util.InfoMsg{}
59−
60 }
59 }
61 return m, nil
60 return m, nil
62}
61}
main.go+2−1
@@ -1,6 +1,7 @@
1package main
1package main
2
2
3import (
3import (
4+ "fmt"
4 "log/slog"
5 "log/slog"
5 "net/http"
6 "net/http"
6 "os"
7 "os"
@@ -22,7 +23,7 @@ func main() {
22 go func() {
23 go func() {
23 slog.Info("Serving pprof at localhost:6060")
24 slog.Info("Serving pprof at localhost:6060")
24 if httpErr := http.ListenAndServe("localhost:6060", nil); httpErr != nil {
25 if httpErr := http.ListenAndServe("localhost:6060", nil); httpErr != nil {
25− slog.Error("Failed to pprof listen: %v", httpErr)
26+ slog.Error(fmt.Sprintf("Failed to pprof listen: %v", httpErr))
26 }
27 }
27 }()
28 }()
28 }
29 }