From 4fd086f3807f4b5b1fa414b2d1d6ec0f24c3f9b4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 18 Aug 2025 18:54:53 +0300 Subject: hexaicli: load config with logger to respect provider\n\nFix CLI requiring OPENAI_API_KEY when provider is ollama by actually loading user config.\n\nREADME: update Helix example to use hexai-lsp binary. --- internal/hexaicli/run.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'internal/hexaicli') diff --git a/internal/hexaicli/run.go b/internal/hexaicli/run.go index 839daef..cfc70ec 100644 --- a/internal/hexaicli/run.go +++ b/internal/hexaicli/run.go @@ -3,13 +3,14 @@ package hexaicli import ( - "bufio" - "context" - "fmt" - "io" - "os" - "strings" - "time" + "bufio" + "context" + "fmt" + "io" + "log" + "os" + "strings" + "time" "hexai/internal/appconfig" "hexai/internal/llm" @@ -19,12 +20,14 @@ import ( // Run executes the Hexai CLI behavior given arguments and I/O streams. // It assumes flags have already been parsed by the caller. func Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error { - cfg := appconfig.Load(nil) - client, err := newClientFromConfig(cfg) - if err != nil { - fmt.Fprintf(stderr, logging.AnsiBase+"hexai: LLM disabled: %v"+logging.AnsiReset+"\n", err) - return err - } + // Load configuration with a logger so file-based config is respected. + logger := log.New(stderr, "hexai ", log.LstdFlags|log.Lmsgprefix) + cfg := appconfig.Load(logger) + client, err := newClientFromConfig(cfg) + if err != nil { + fmt.Fprintf(stderr, logging.AnsiBase+"hexai: LLM disabled: %v"+logging.AnsiReset+"\n", err) + return err + } return RunWithClient(ctx, args, stdin, stdout, stderr, client) } -- cgit v1.2.3