Skip to content
Merged
10 changes: 0 additions & 10 deletions cmd/gen/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"
"os/signal"
"strings"
"syscall"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -182,15 +181,6 @@ func runHeadlessAgent() error {
return nil
}

// containsIgnoreCase checks if a string slice contains a value (case-insensitive).
func containsIgnoreCase(slice []string, val string) bool {
for _, s := range slice {
if strings.EqualFold(s, val) {
return true
}
}
return false
}

// isGitRepoCheck checks if the given directory is a git repository.
func isGitRepoCheck(dir string) bool {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func init() {
}

func main() {
defer log.Sync()
defer func() { _ = log.Sync() }()

if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/gen/mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ var mcpEditCmd = &cobra.Command{
editorCmd.Stderr = os.Stderr

if err := editorCmd.Run(); err != nil {
os.Remove(info.TempFile)
_ = os.Remove(info.TempFile)
return fmt.Errorf("editor failed: %w", err)
}

Expand Down
4 changes: 1 addition & 3 deletions cmd/gen/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ Examples:
}

installer := plugin.NewInstaller(plugin.DefaultRegistry, cwd)
if err := installer.LoadMarketplaces(); err != nil {
// Non-fatal, continue with empty marketplaces
}
_ = installer.LoadMarketplaces() // Non-fatal, continue with empty marketplaces

scope := parsePluginScope(pluginScope)
if err := installer.Install(ctx, ref, scope); err != nil {
Expand Down
1 change: 0 additions & 1 deletion internal/app/agent/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ type ToggleMsg struct {
Enabled bool
}


// New creates a new agent selector Model.
func New() Model {
return Model{
Expand Down
2 changes: 1 addition & 1 deletion internal/app/approval/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type (
// RequestMsg is sent when a tool needs permission
RequestMsg struct {
Request *permission.PermissionRequest
ToolCall interface{} // The original tool call
ToolCall any // The original tool call
}

// ResponseMsg is sent when the user responds to a permission request
Expand Down
4 changes: 2 additions & 2 deletions internal/app/conversation/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
type Model struct {
Messages []message.ChatMessage
CommittedCount int
Stream StreamState
Compact appcompact.State
Stream StreamState
Compact appcompact.State

// TurnsSinceLastTaskTool counts LLM turns since the last Task* tool was used.
// Reset to 0 when any TaskCreate/TaskGet/TaskUpdate/TaskList tool is called.
Expand Down
4 changes: 2 additions & 2 deletions internal/app/handler_approval.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (m *model) applyPermissionUpdates(updates []hooks.PermissionUpdate) {
}
}
if needReload {
config.Reload()
_, _ = config.Reload()
}
}

Expand Down Expand Up @@ -306,7 +306,7 @@ func (m *model) persistAllowRule(req *permission.PermissionRequest) {
}
}
// Reload settings so the rule takes effect immediately
config.Reload()
_, _ = config.Reload()
}

// applyUpdatedToolInput marshals the hook-provided input and updates the current
Expand Down
6 changes: 3 additions & 3 deletions internal/app/handler_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ func handleClearCommand(ctx context.Context, m *model, args string) (string, tea
cron.DefaultStore.Reset()
m.cronQueue = nil
if tty, err := os.OpenFile("/dev/tty", os.O_WRONLY, 0); err == nil {
tty.WriteString("\033[2J\033[3J\033[H")
tty.Close()
_, _ = tty.WriteString("\033[2J\033[3J\033[H")
_ = tty.Close()
}
if os.Getenv("TMUX") != "" {
exec.Command("tmux", "clear-history").Run()
_ = exec.Command("tmux", "clear-history").Run()
}
return "", tea.ClearScreen, nil
}
Expand Down
15 changes: 5 additions & 10 deletions internal/app/input/input.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package input

import (
"fmt"
"os"
"path/filepath"
"regexp"
Expand All @@ -15,21 +16,15 @@ const (
maxTextareaHeight = 6
)

// ImageRefPattern matches @path/to/image.ext references.
var ImageRefPattern = regexp.MustCompile(`@([^\s]+\.(png|jpg|jpeg|gif|webp))`)
// ImageRefPattern matches @path/to/image.ext references (case-insensitive extension).
var ImageRefPattern = regexp.MustCompile(`(?i)@([^\s]+\.(png|jpg|jpeg|gif|webp))`)

// UpdateHeight adjusts textarea height based on content line count.
func (m *Model) UpdateHeight() {
content := m.Textarea.Value()
lines := strings.Count(content, "\n") + 1

newHeight := lines
if newHeight < minTextareaHeight {
newHeight = minTextareaHeight
}
if newHeight > maxTextareaHeight {
newHeight = maxTextareaHeight
}
newHeight := max(min(lines, maxTextareaHeight), minTextareaHeight)

m.Textarea.SetHeight(newHeight)
}
Expand Down Expand Up @@ -92,7 +87,7 @@ func ProcessImageRefs(cwd, input string) (string, []message.ImageData, error) {

imgInfo, err := image.Load(absPath)
if err != nil {
return "", nil, err
return "", nil, fmt.Errorf("loading image %s: %w", absPath, err)
}
images = append(images, imgInfo.ToProviderData())
loadedRefs = append(loadedRefs, match[0]) // full match including @
Expand Down
8 changes: 4 additions & 4 deletions internal/app/mcp/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,18 @@ func PrepareServerEdit(name string) (*EditInfo, error) {
}

if _, writeErr := tmpFile.Write(append(data, '\n')); writeErr != nil {
tmpFile.Close()
os.Remove(tmpFile.Name())
_ = tmpFile.Close()
_ = os.Remove(tmpFile.Name())
return nil, fmt.Errorf("failed to write temp file: %w", writeErr)
}
tmpFile.Close()
_ = tmpFile.Close()

return &EditInfo{TempFile: tmpFile.Name(), ServerName: name, Scope: scope}, nil
}

// ApplyServerEdit reads the edited temp file and saves the updated config back.
func ApplyServerEdit(info *EditInfo) error {
defer os.Remove(info.TempFile)
defer func() { _ = os.Remove(info.TempFile) }()

data, err := os.ReadFile(info.TempFile)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/app/mcp/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (s *Model) HandleConnectResult(msg ConnectResultMsg) {
// Marks the server as disabled so it won't auto-connect on restart.
func (s *Model) HandleDisconnect(name string) {
if coremcp.DefaultRegistry != nil {
coremcp.DefaultRegistry.Disconnect(name)
_ = coremcp.DefaultRegistry.Disconnect(name)
coremcp.DefaultRegistry.SetDisabled(name, true)
}
s.refreshAndUpdateView()
Expand Down
1 change: 0 additions & 1 deletion internal/app/memory/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type SelectedMsg struct {
Level string
}


// New creates a new memory selector Model.
func New() Model {
return Model{
Expand Down
2 changes: 1 addition & 1 deletion internal/app/mode/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type EnterPlanResponseMsg struct {
// QuestionRequestMsg is sent when AskUserQuestion tool is called
type QuestionRequestMsg struct {
Request *tool.QuestionRequest
ToolCall interface{} // Original tool call
ToolCall any // Original tool call
}

// QuestionResponseMsg is sent when user answers or cancels
Expand Down
8 changes: 0 additions & 8 deletions internal/app/mode/prompt_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,6 @@ func (p *PlanPrompt) submitInlineInput() (tea.Cmd, *PlanResponseMsg) {
}

// Plan prompt styles
func getPlanSeparatorStyle() lipgloss.Style {
return lipgloss.NewStyle().Foreground(theme.CurrentTheme.Separator)
}

func getPlanTitleStyle() lipgloss.Style {
return lipgloss.NewStyle().Foreground(theme.CurrentTheme.Primary).Bold(true)
}

func getPlanSelectedStyle() lipgloss.Style {
return lipgloss.NewStyle().Foreground(theme.CurrentTheme.Success).Bold(true)
}
Expand Down
4 changes: 1 addition & 3 deletions internal/app/plugin/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ func (s *Model) EnterSelect(width, height int) error {
if err := s.marketplaceManager.Load(); err != nil {
s.setError(fmt.Sprintf("Failed to load marketplaces: %v", err))
}
if err := s.installer.LoadMarketplaces(); err != nil {
// Non-fatal.
}
_ = s.installer.LoadMarketplaces() // Non-fatal

s.refreshCurrentTab()
return nil
Expand Down
3 changes: 0 additions & 3 deletions internal/app/plugin/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ type Model struct {
actionIdx int
parentIdx int

installScopes []coreplugin.Scope
installScopeIdx int

addMarketplaceInput string
addDialogCursor int

Expand Down
1 change: 0 additions & 1 deletion internal/app/plugin/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func (s *Model) resetInputState() {
s.filteredItems = nil
s.addMarketplaceInput = ""
s.addDialogCursor = 0
s.installScopeIdx = 0
}

func (s *Model) resetLoadingState() {
Expand Down
16 changes: 8 additions & 8 deletions internal/app/provider/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (

// State holds all provider-related state for the TUI model.
type State struct {
LLM provider.LLMProvider
Store *provider.Store
CurrentModel *provider.CurrentModelInfo
InputTokens int
OutputTokens int
FetchingLimits bool
Selector Model
StatusMessage string // Temporary status shown in status bar
LLM provider.LLMProvider
Store *provider.Store
CurrentModel *provider.CurrentModelInfo
InputTokens int
OutputTokens int
FetchingLimits bool
Selector Model
StatusMessage string // Temporary status shown in status bar
ThinkingLevel provider.ThinkingLevel
ThinkingOverride provider.ThinkingLevel
}
Expand Down
24 changes: 12 additions & 12 deletions internal/app/render/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (

// MDRenderer renders markdown content to styled terminal output using glamour.
type MDRenderer struct {
renderer *glamour.TermRenderer
width int
darkBg bool // tracks last known terminal background to detect theme changes
renderer *glamour.TermRenderer
width int
darkBg bool // tracks last known terminal background to detect theme changes
}

// NewMDRenderer creates a new markdown renderer with the given terminal width.
Expand Down Expand Up @@ -86,7 +86,7 @@ func (r *MDRenderer) Render(content string) (string, error) {
parts = append(parts, seg.content)
} else {
rendered = collapseBlankLines(rendered)
parts = append(parts, strings.TrimRight(rendered, "\n"))
parts = append(parts, strings.TrimRight(rendered, "\n"))
}
}
}
Expand Down Expand Up @@ -334,7 +334,7 @@ func customizeStyle(s *ansi.StyleConfig, width int) {
// Document: set foreground color, no margin (paragraph spacing handled by glamour block prefix/suffix)
margin := uint(0)
s.Document.Margin = &margin
s.Document.StylePrimitive.Color = &text
s.Document.Color = &text
s.Document.BlockPrefix = ""
s.Document.BlockSuffix = ""

Expand All @@ -356,7 +356,7 @@ func customizeStyle(s *ansi.StyleConfig, width int) {
s.H6.Prefix = ""

// BlockQuote: muted color with standard │ indent token
s.BlockQuote.StylePrimitive.Color = &textDim
s.BlockQuote.Color = &textDim
s.BlockQuote.Indent = uintPtr(1)
s.BlockQuote.IndentToken = stringPtr("│ ")

Expand All @@ -367,10 +367,10 @@ func customizeStyle(s *ansi.StyleConfig, width int) {

// Inline code: no background, accent color
accent := adaptiveColorHex(theme.CurrentTheme.Accent)
s.Code.StylePrimitive.BackgroundColor = nil
s.Code.StylePrimitive.Prefix = ""
s.Code.StylePrimitive.Suffix = ""
s.Code.StylePrimitive.Color = &accent
s.Code.BackgroundColor = nil
s.Code.Prefix = ""
s.Code.Suffix = ""
s.Code.Color = &accent

// Code blocks: remove Chroma background color for cleaner look
if s.CodeBlock.Chroma != nil {
Expand All @@ -379,15 +379,15 @@ func customizeStyle(s *ansi.StyleConfig, width int) {
}
}

func boolPtr(b bool) *bool { return &b }
func boolPtr(b bool) *bool { return &b }

func collapseBlankLines(s string) string {
for strings.Contains(s, "\n\n\n") {
s = strings.ReplaceAll(s, "\n\n\n", "\n\n")
}
return s
}
func uintPtr(u uint) *uint { return &u }
func uintPtr(u uint) *uint { return &u }
func stringPtr(s string) *string { return &s }

// normalizeLineBreaks joins single-newline breaks within plain paragraphs so
Expand Down
1 change: 0 additions & 1 deletion internal/app/session/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type SelectedMsg struct {
SessionID string
}


// Model holds the state for the session selector
type Model struct {
active bool
Expand Down
1 change: 0 additions & 1 deletion internal/app/skill/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ type CycleMsg struct {
NewState coreskill.SkillState
}


// InvokeMsg is sent when a skill is invoked from the selector.
type InvokeMsg struct {
SkillName string
Expand Down
2 changes: 1 addition & 1 deletion internal/app/themeselect/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type SelectedMsg struct {
}

var (
selectorTitleStyle = lipgloss.NewStyle().Bold(true).MarginBottom(1)
selectorTitleStyle = lipgloss.NewStyle().Bold(true).MarginBottom(1)
selectorActiveStyle = lipgloss.NewStyle().Bold(true).Foreground(theme.CurrentTheme.Primary)
selectorItemStyle = lipgloss.NewStyle().Foreground(theme.CurrentTheme.Text)
selectorDescStyle = lipgloss.NewStyle().Foreground(theme.CurrentTheme.TextDim)
Expand Down
1 change: 0 additions & 1 deletion internal/app/tool/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ type ToggleMsg struct {
Enabled bool
}


// New creates a new Model
func New() Model {
return Model{
Expand Down
Loading
Loading