summaryrefslogtreecommitdiff
path: root/internal/llm
AgeCommit message (Collapse)Author
2026-05-20test(yousearch): add unit tests; allow base URL override for testsPaul Buetow
Amp-Thread-ID: https://ampcode.com/threads/T-019e45ff-4976-750c-b2e6-121d0e5991ef Co-authored-by: Amp <amp@ampcode.com>
2026-05-20Add YouSearch (You.com Research API) provider integrationPaul Buetow
Amp-Thread-ID: https://ampcode.com/threads/T-019e45ff-4976-750c-b2e6-121d0e5991ef Co-authored-by: Amp <amp@ampcode.com>
2026-05-01Bump version to 0.38.3Paul Buetow
Correct default Ollama Cloud model to gemma4:31b-cloud (bare gemma4 tag returns 404 on Ollama Cloud; the hosted cloud model requires the explicit :31b-cloud tag). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01Bump version to 0.38.2Paul Buetow
Switch default Ollama Cloud model from kimi-k2.6 to gemma4. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26feat: default to Ollama Cloud (kimi-k2.6) when no provider configuredPaul Buetow
Switches the in-code defaults so that hexai talks to Ollama Cloud (https://ollama.com) with model kimi-k2.6 when no provider is configured, instead of OpenAI. The example config, README, and configuration guide all reflect the new recommended setup; previous OpenAI / local-Ollama options are still documented as alternatives. Tests that depended on the implicit "openai" default now pin the provider explicitly so they continue to exercise the OpenAI / gpt-5 code paths they were designed to cover. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26feat: optional API key for Ollama provider (Ollama Cloud)Paul Buetow
Adds an optional HEXAI_OLLAMA_API_KEY (with OLLAMA_API_KEY fallback) so the existing Ollama provider can target Ollama Cloud (ollama.ai) in addition to a local server. When the key is empty the request is unauthenticated, preserving local-server behavior byte-for-byte; when set, an Authorization: Bearer header is attached for both Chat and ChatStream. Documented cloud usage in config.toml.example. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-03-23chore: bump version to v0.25.9v0.25.9Paul Buetow
Code quality fixes from audit: - Log silently discarded errors in status sinks and stats.Update call sites - Fix json.Marshal errors silently ignored in LSP handlers - Replace time.Sleep in tests with channel signaling (mcp) and fake clock (stats) - Make context cancellation work in production time.Sleep sites (handlers_document, cmdentry) - Remove init()-based provider registration from llm package; use explicit RegisterAllProviders() - Add WaitGroup goroutine tracking to MCP server Run() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23refactor: split oversized functions, fix double logging, add %w wrappingPaul Buetow
- lsp/handlers_completion.go: extract buildNativeCompletionCacheKey and postProcessNativeCompletion; track collectFirstCompletion in inflight; remove redundant logLLMStats("") on error path - lsp/handlers.go: extract checkTriggerFromContext and checkTriggerFromCursorChar; isTriggerEvent reduced from 63→10 lines - lsp/transport.go: use %w for error wrapping in Content-Length parse - llm/ollama.go: extract parseOllamaStream; ChatStream reduced to ~35 lines - appconfig/config_load.go: extract decodeModelEntryFromMap; rename 'any' to 'found'; decodeModelEntry reduced to ~18 lines - llm/provider.go: document why providerRegistry is package-level - integrationtests/ask_test.go: add //go:build integration; move repoRoot init from init() to TestMain with diagnostic message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23fix: code quality improvements across lsp, askcli, appconfig, integrationtestsPaul Buetow
- lsp/handlers_completion.go: track collectFirstCompletion goroutine in inflight WaitGroup (goroutine leak fix) - lsp/transport.go: use %w instead of %v for error wrapping - askcli/command_list.go: extract handleListWithFilters shared helper; handleList/handleAll/handleReady are now single-liners - askcli/command_list.go, urgency.go, dep.go: log ParseTaskExport errors to stderr instead of returning 1 silently - appconfig/config_load.go: rename 'any' variable to 'found' to avoid shadowing the built-in identifier - llm/provider.go: add explanatory comment for package-level registry - integrationtests/ask_test.go: add //go:build integration tag; move repoRoot init from init() to TestMain with diagnostic error message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23fix: address all HIGH-severity code quality audit findingsPaul Buetow
- lsp/server.go: track request goroutines in inflight WaitGroup to prevent use-after-close writes on shutdown - lsp/llm_client_registry.go: acquire write lock before calling build() to eliminate TOCTOU race on cache population - lsp/handlers_codeaction.go: resolveSimplifyCodeAction now uses PromptCodeActionSimplify{System,User} (was wrongly using rewrite prompts) - askcli/taskexport.go: remove exported MustParseTaskExport to prevent panic on malformed external input; move to unexported test helper - cmd/ask/main.go: print error to stderr before os.Exit - llm/{openai,ollama,openrouter}.go: add interface satisfaction assertions - integrationtests/ask_test.go: replace type assertions with errors.As for robust exec.ExitError unwrapping Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19Improve actionable error guidancePaul Buetow
2026-03-16Replace Summary: prefixes with standard Go package doc commentsPaul Buetow
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16Add doc comments to exported types and functionsPaul Buetow
Document ~30 exported types in lsp/types.go and exported functions in llm/provider.go, lsp/server.go, and hexailsp/run.go. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02llm: extract shared doJSON and logStart helpers (task 409)Paul Buetow
2026-03-02llm: add provider registry and self-registration factories (task 410)Paul Buetow
2026-02-06Remove GitHub Copilot provider supportpaul@buetow.org
Remove all GitHub Copilot integration from the codebase to streamline the supported provider set to OpenAI, OpenRouter, Anthropic, and Ollama. Changes: - Delete core Copilot implementation (copilot.go) and all related tests - Remove Copilot configuration fields from App struct and Config - Remove Copilot from provider factory and API key handling - Update all test files to replace Copilot references with other providers - Remove Copilot documentation from README, configuration guide, and examples - Remove Copilot section from config.toml.example All tests pass successfully after removal. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-06fix: add missing Anthropic and OpenRouter provider support in config and LSPpaul@buetow.org
- Add Anthropic field merging in config.mergeProviderFields() to properly load AnthropicModel/BaseURL/Temperature from config.toml - Add anthropic and openrouter cases in lsp.resolveDefaultModel() to prevent fallback to OpenAI defaults - Update default Anthropic model to valid claude-3-5-sonnet-20240620 (previous 20241022 doesn't exist) - Update test expectation to match new default model This fixes the issue where Anthropic provider configuration was ignored, causing LSP to return dummy completions instead of real LLM responses. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-01-31feat: add configurable request timeout for LLM callsFlorian
Local LLMs (LM Studio, Ollama, etc.) often need more than the default 30-second timeout. Added request_timeout config option (in seconds) to [general] section and HEXAI_REQUEST_TIMEOUT env var. Original constructor signatures preserved via *WithTimeout variants, so no test changes required.
2026-01-30feat: add completion_wait_all config and fix Anthropic system messagesPaul Buetow
- Add completion_wait_all config option (default true) to wait for all backends before returning results, or return first result immediately - Fix Anthropic API: extract system messages to top-level system field as required by Messages API (was causing 400 errors) - Add anthropic case to server.go clientFor() for model overrides
2026-01-29refactor: apply code style best practices to Anthropic implementationPaul Buetow
- Reorganize anthropic.go: types, interface checks, constructor, public methods, private methods - Extract helper methods from Chat() and ChatStream() to keep functions under 50 lines - Add resolveOptions(), sendRequest(), extractContent() private methods - Add explicit interface satisfaction check for Client and Streamer - Add documentation comments to all public methods (Chat, Name, DefaultModel, ChatStream) - Apply gofmt and gofumpt formatting - Apply goimports for import ordering All 51 tests in llm package pass All code adheres to best practices from go-projects.md: - Value semantics (value receivers only) - Constructors before methods - Public before private - Functions under 50 lines - Explicit interface satisfaction - Documentation on all public identifiers - Proper error handling - Context as first parameter for I/O functions Amp-Thread-ID: https://ampcode.com/threads/T-019c0af1-f215-72cf-9940-b014b1a9576b Co-authored-by: Amp <amp@ampcode.com>
2026-01-29feat: add native Anthropic API provider supportPaul Buetow
- Implement new anthropicClient with full Client interface - Add Streamer interface for token-by-token streaming via SSE - Add Anthropic Messages API v1 integration with proper headers - Support claude-3-5-sonnet-20241022 as default model - Add configuration via [anthropic] TOML section - Add environment variable overrides (HEXAI_ANTHROPIC_*) - Support both HEXAI_ANTHROPIC_API_KEY and ANTHROPIC_API_KEY fallback - Integrate Anthropic key handling in LSP, CLI, and llmutils - Update provider factory to support 'anthropic' provider name - Add 11 comprehensive unit tests for Anthropic client - Update config.toml.example with [anthropic] section - Update NewFromConfig() signature to accept anthropicAPIKey parameter - All 51 internal LLM tests pass (11 new Anthropic tests + 40 existing) Anthropic models can be accessed via: [anthropic] model = "claude-3-5-sonnet-20241022" base_url = "https://api.anthropic.com/v1" temperature = 0.2 or environment: export HEXAI_PROVIDER="anthropic" export HEXAI_ANTHROPIC_API_KEY="your-key" Amp-Thread-ID: https://ampcode.com/threads/T-019c0af1-f215-72cf-9940-b014b1a9576b Co-authored-by: Amp <amp@ampcode.com>
2025-11-03Fix: Address lint warnings and bump patch version to 0.15.3v0.15.3Paul Buetow
2025-11-02some linter fixesPaul Buetow
2025-10-02feat: add OpenRouter providerv0.15.0Paul Buetow
2025-09-24Add runtime config store and reload commandPaul Buetow
2025-09-19fixPaul Buetow
2025-09-17chore(openai): revert default model to gpt-4.1Paul Buetow
2025-09-17feat(openai): set default model to gpt-4oPaul Buetow
2025-09-17chore: commit uncommitted changes before version bumpPaul Buetow
2025-09-17chore(version): bump to v0.11.1 (gpt-5 defaults, timeouts, global stats, ↵v0.11.1Paul Buetow
editor fix)
2025-09-08docs: move tmux documentation to its own filePaul Buetow
2025-09-06more testsPaul Buetow
2025-09-06use gofumptPaul Buetow
2025-09-06feat(lsp): configurable inline/chat triggers; switch inline markers to ↵Paul Buetow
>text>/>>text>; update docs and example config; tests updated to new triggers and raise LSP coverage to >=85%; chore: remove semicolon legacy; chore(mage): auto-refresh coverage daily if docs/coverage.out is older than 24h
2025-09-05tests: add more negative provider cases and table-driven LSP coverage; ↵Paul Buetow
assert headers; add indent postprocess test
2025-09-04tests: add more table-driven cases and negative provider tests; update reportPaul Buetow
2025-09-04tests: expand negative SSE and table-driven coverage; add docs/testing.md; ↵Paul Buetow
use shared fixtures
2025-09-04tests: add negative SSE test, table-driven refactors, and use shared ↵Paul Buetow
fixtures across tests; update REPORT.md progress
2025-09-04tests: add shared test fixtures, expand provider breadth (multi-choice, ↵Paul Buetow
error bodies), add LSP rewrite/diagnostics realism and table-driven tests
2025-09-04tests(llm): raise coverage to >=80%\n- Add OpenAI/Copilot HTTP success + ↵Paul Buetow
stream + token tests\n- Cover With* options and NewFromConfig success paths\n- llm package now ~80.3%
2025-09-04tests(llm): add OpenAI and Copilot HTTP tests (success + token/error paths); ↵Paul Buetow
llm coverage ~61%
2025-09-04tests(lsp,llm): add helper and factory tests to raise coverage modestly; ↵Paul Buetow
continue toward 80% target
2025-09-04llm/ollama: add comprehensive tests (Chat, ChatStream, errors) to reach >80% ↵Paul Buetow
coverage for ollama.go
2025-08-31module: set module path to codeberg.org/snonux/hexai; update imports; docs: ↵v0.3.4Paul Buetow
add go install instructions
2025-08-28copilot: add session token + codex code completion; lsp: prefer native ↵v0.3.0Paul Buetow
CodeCompleter with chat fallback; remove obsolete throttle path; add tests; bump version to 0.3.0
2025-08-22remove busy checkPaul Buetow
2025-08-19chore: commit pending changes in status, LSP, and Ollama modulesPaul Buetow
2025-08-19llm/copilot: add required headers and update default model\n\n- Send ↵Paul Buetow
X-GitHub-Api-Version and User-Agent headers for Copilot requests\n- Default Copilot model to gpt-4o-mini (avoid non-existent 'codex'/'gpt-4.1')\n- README and config.json.example: update Copilot defaults and guidance\n\nNote: Copilot provider expects Copilot-issued auth; for public access use GitHub Models via OpenAI-compatible endpoint.
2025-08-18hexaicli: load config with logger to respect provider\n\nFix CLI requiring ↵Paul Buetow
OPENAI_API_KEY when provider is ollama by actually loading user config.\n\nREADME: update Helix example to use hexai-lsp binary.
2025-08-18refactor(lsp,llm,hexailsp,appconfig): split long funcs; add testsPaul Buetow
- Extract helpers to keep funcs <=50 lines; no behavior changes - Add tests for prompt removal, code actions, and LLM request builders - Table-drive TestInParamList; run gofmt