From 6c8eb6876fe87553770de114ebd34649a0c6ec10 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 16 Aug 2025 15:35:02 +0300 Subject: lsp: split monolithic server.go into modules; add configurable max tokens and context strategies (minimal|window|file-on-new-func|always-full); provide flags/env fallbacks; add unit tests for helpers and context; update README; remove obsolete files --- README.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 8fd42bd..aad155f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Hexai, the AI LSP for the Helix editor. -At the moment this project is only in the brainstorming phase. +At the moment this project is only in the proof of concept phase. ## LLM provider @@ -17,3 +17,32 @@ code completion when `OPENAI_API_KEY` is present in the environment. If no key is configured, Hexai will fall back to a basic, local completion. +## CLI usage and configuration + +- Run LSP server over stdio: + - `hexai -stdio` + +- Completion settings: + - `-max-tokens`: maximum tokens for LLM completions (default `500`). If the flag isn’t provided, `HEXAI_MAX_TOKENS` is used when set. + - `-context-mode`: how much additional context to include with completion prompts. One of: + - `minimal`: no extra context + - `window`: include a sliding window around the cursor + - `file-on-new-func` (default): include the full file only when defining a new function (cursor before the opening `{`) + - `always-full`: always include the full file (may be slower/costly) + - `-context-window-lines`: line count for the sliding window when `context-mode=window` (default `120`). + - `-max-context-tokens`: budget for additional context tokens (default `2000`). If the flag isn’t provided, `HEXAI_MAX_CONTEXT_TOKENS` is used when set. + +Notes: +- Token estimation for truncation uses a simple 4 chars/token heuristic. +- Full-file context is only included by default when defining a new function to balance quality, latency, and cost. + +### Flags quick reference + +| Flag | Default | Env override | Description | +|-------------------------|--------------------|----------------------------|----------------------------------------------------| +| `-stdio` | `true` | — | Run as LSP over stdio (only supported mode). | +| `-log` | `/tmp/hexai.log` | — | Path to log file (optional). | +| `-max-tokens` | `500` | `HEXAI_MAX_TOKENS` | Max tokens for LLM completions. | +| `-context-mode` | `file-on-new-func` | — | `minimal` `window` `file-on-new-func` `always-full` | +| `-context-window-lines` | `120` | — | Lines around cursor when using `window` mode. | +| `-max-context-tokens` | `2000` | `HEXAI_MAX_CONTEXT_TOKENS` | Token budget for additional context. | -- cgit v1.2.3