fix: lint noctx issues

ignored slog because in our case it doesn't matter.
This commit is contained in:
Carlos Alexandro Becker
2025-07-31 12:26:57 -03:00
committed by Kujtim Hoxha
parent 3e213e89aa
commit e698239ace
5 changed files with 19 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
package fsext
import (
"context"
"fmt"
"log/slog"
"os"
@@ -29,7 +30,7 @@ func init() {
}
}
func GetRgCmd(globPattern string) *exec.Cmd {
func GetRgCmd(ctx context.Context, globPattern string) *exec.Cmd {
if rgPath == "" {
return nil
}
@@ -44,10 +45,10 @@ func GetRgCmd(globPattern string) *exec.Cmd {
}
rgArgs = append(rgArgs, "--glob", globPattern)
}
return exec.Command(rgPath, rgArgs...)
return exec.CommandContext(ctx, rgPath, rgArgs...)
}
func GetRgSearchCmd(pattern, path, include string) *exec.Cmd {
func GetRgSearchCmd(ctx context.Context, pattern, path, include string) *exec.Cmd {
if rgPath == "" {
return nil
}
@@ -58,7 +59,7 @@ func GetRgSearchCmd(pattern, path, include string) *exec.Cmd {
}
args = append(args, path)
return exec.Command(rgPath, args...)
return exec.CommandContext(ctx, rgPath, args...)
}
type FileInfo struct {

View File

@@ -114,7 +114,7 @@ func (g *globTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
searchPath = g.workingDir
}
files, truncated, err := globFiles(params.Pattern, searchPath, 100)
files, truncated, err := globFiles(ctx, params.Pattern, searchPath, 100)
if err != nil {
return ToolResponse{}, fmt.Errorf("error finding files: %w", err)
}
@@ -138,8 +138,8 @@ func (g *globTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
), nil
}
func globFiles(pattern, searchPath string, limit int) ([]string, bool, error) {
cmdRg := fsext.GetRgCmd(pattern)
func globFiles(ctx context.Context, pattern, searchPath string, limit int) ([]string, bool, error) {
cmdRg := fsext.GetRgCmd(ctx, pattern)
if cmdRg != nil {
cmdRg.Dir = searchPath
matches, err := runRipgrep(cmdRg, searchPath, limit)

View File

@@ -206,7 +206,7 @@ func (g *grepTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
searchPath = g.workingDir
}
matches, truncated, err := searchFiles(searchPattern, searchPath, params.Include, 100)
matches, truncated, err := searchFiles(ctx, searchPattern, searchPath, params.Include, 100)
if err != nil {
return ToolResponse{}, fmt.Errorf("error searching files: %w", err)
}
@@ -247,8 +247,8 @@ func (g *grepTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
), nil
}
func searchFiles(pattern, rootPath, include string, limit int) ([]grepMatch, bool, error) {
matches, err := searchWithRipgrep(pattern, rootPath, include)
func searchFiles(ctx context.Context, pattern, rootPath, include string, limit int) ([]grepMatch, bool, error) {
matches, err := searchWithRipgrep(ctx, pattern, rootPath, include)
if err != nil {
matches, err = searchFilesWithRegex(pattern, rootPath, include)
if err != nil {
@@ -268,8 +268,8 @@ func searchFiles(pattern, rootPath, include string, limit int) ([]grepMatch, boo
return matches, truncated, nil
}
func searchWithRipgrep(pattern, path, include string) ([]grepMatch, error) {
cmd := fsext.GetRgSearchCmd(pattern, path, include)
func searchWithRipgrep(ctx context.Context, pattern, path, include string) ([]grepMatch, error) {
cmd := fsext.GetRgSearchCmd(ctx, pattern, path, include)
if cmd == nil {
return nil, fmt.Errorf("ripgrep not found in $PATH")
}

View File

@@ -1,6 +1,7 @@
package editor
import (
"context"
"fmt"
"math/rand"
"net/http"
@@ -110,7 +111,7 @@ func (m *editorCmp) openEditor(value string) tea.Cmd {
if _, err := tmpfile.WriteString(value); err != nil {
return util.ReportError(err)
}
c := exec.Command(editor, tmpfile.Name())
c := exec.CommandContext(context.TODO(), editor, tmpfile.Name())
c.Stdin = os.Stdin
c.Stdout = os.Stdout
c.Stderr = os.Stderr