From 35e1de6f975088ade5dbf0af533fe6fdac8fcc94 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 2 Nov 2025 23:42:15 +0200 Subject: some linter fixes --- SCRATCHPAD.md | 2 - cmd/hexai/main.go | 2 +- cmd/hexai/main_test.go | 4 +- config.toml.example | 7 +- docs/coverage.html | 3593 +- docs/coverage.out | 52027 +++++++++++++++++------------ internal/hexaiaction/cmdentry.go | 4 +- internal/hexaiaction/cmdentry_test.go | 6 +- internal/hexaiaction/run.go | 12 +- internal/hexaiaction/tui_delegate.go | 2 +- internal/hexaicli/run.go | 35 +- internal/hexaicli/run_test.go | 2 +- internal/hexaicli/testhelpers_test.go | 10 +- internal/hexailsp/run.go | 6 +- internal/llm/copilot.go | 20 +- internal/llm/copilot_http_test.go | 16 +- internal/llm/ollama.go | 14 +- internal/llm/openai.go | 14 +- internal/llm/openai_http_test.go | 14 +- internal/llm/openai_sse_negative_test.go | 4 +- internal/llm/openrouter.go | 12 +- internal/llm/openrouter_test.go | 4 +- internal/lsp/codeaction_prompts_test.go | 2 +- internal/lsp/completion_messages_test.go | 2 +- internal/stats/stats.go | 14 +- internal/tmux/status_more_test.go | 10 +- internal/version.go | 2 +- 27 files changed, 34119 insertions(+), 21721 deletions(-) diff --git a/SCRATCHPAD.md b/SCRATCHPAD.md index 803b1a3..c046e79 100644 --- a/SCRATCHPAD.md +++ b/SCRATCHPAD.md @@ -2,8 +2,6 @@ This document shows future items and items in progress. Already completed ones are deleted from this document as updates occur. * [ ] hexai cli to keep context for the follow-up question/prompt? -* [/] configure multiple models for cli and code completion * [ ] Exclude the test coverage files from git and wipe them from the history * [/] Review documentation -* [/] Manual review the code * [ ] ASCIInema: Record and share terminal sessions for demos and bug reports diff --git a/cmd/hexai/main.go b/cmd/hexai/main.go index 7caedc6..d0508e7 100644 --- a/cmd/hexai/main.go +++ b/cmd/hexai/main.go @@ -44,7 +44,7 @@ func main() { } _ = fs.Parse(remaining) if *showVersion { - fmt.Fprintln(os.Stdout, internal.Version) + _, _ = fmt.Fprintln(os.Stdout, internal.Version) return } var selection []int diff --git a/cmd/hexai/main_test.go b/cmd/hexai/main_test.go index 70c844f..797584f 100644 --- a/cmd/hexai/main_test.go +++ b/cmd/hexai/main_test.go @@ -15,7 +15,9 @@ func TestMain_Version(t *testing.T) { os.Stdout = w defer func() { os.Stdout = old }() main() - w.Close() + if err := w.Close(); err != nil { + t.Fatalf("failed to close pipe: %v", err) + } b, _ := io.ReadAll(r) if len(b) == 0 { t.Fatalf("expected version output") diff --git a/config.toml.example b/config.toml.example index cd10e73..84f716e 100644 --- a/config.toml.example +++ b/config.toml.example @@ -3,7 +3,12 @@ [general] max_tokens = 4000 max_context_tokens = 4000 -context_mode = "always-full" # minimal | window | file-on-new-func | always-full +# context_mode controls how much of the current document is sent as extra context: +# - minimal: no additional context beyond the request payload. +# - window: include a sliding window of ~context_window_lines around the cursor. +# - file-on-new-func: include the full file only when starting a new function. +# - always-full: always include the entire open file. +context_mode = "always-full" context_window_lines = 120 coding_temperature = 0.2 # single knob for LSP calls (optional) diff --git a/docs/coverage.html b/docs/coverage.html index 36775ce..4526ad1 100644 --- a/docs/coverage.html +++ b/docs/coverage.html @@ -55,13 +55,13 @@ @@ -165,15 +167,20 @@ package main import ( "flag" + "fmt" "log" "os" + "strings" "codeberg.org/snonux/hexai/internal" + "codeberg.org/snonux/hexai/internal/appconfig" "codeberg.org/snonux/hexai/internal/hexailsp" ) func main() { logPath := flag.String("log", "/tmp/hexai-lsp.log", "path to log file (optional)") + defaultCfg := defaultConfigPath() + configPath := flag.String("config", "", fmt.Sprintf("path to config file (default: %s)", defaultCfg)) showVersion := flag.Bool("version", false, "print version and exit") flag.Parse() if *showVersion { @@ -181,10 +188,19 @@ func main() { return } - if err := hexailsp.Run(*logPath, os.Stdin, os.Stdout, os.Stderr); err != nil { + path := strings.TrimSpace(*configPath) + if err := hexailsp.RunWithConfig(*logPath, path, os.Stdin, os.Stdout, os.Stderr); err != nil { log.Fatalf("server error: %v", err) } } + +func defaultConfigPath() string { + path, err := appconfig.ConfigPath() + if err != nil { + return "$XDG_CONFIG_HOME/hexai/config.toml" + } + return path +}