From 454451105ad3522d2ac3d22136eedee4a4d034af Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 17 Aug 2025 18:52:51 +0300 Subject: cli+lsp: refactor main packages into internal runners; add tests - Move CLI logic to internal/hexaicli with Run/RunWithClient - Move LSP logic to internal/hexailsp with Run/RunWithFactory - Extract helpers; keep behavior identical for both binaries - Add unit tests for hexaicli (input parsing, messages, streaming) and hexailsp (factory wiring, client creation, logging settings) - Add top-of-file summaries and 'Not yet reviewed by a human' comments to all Go files - Update README with internal package docs --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index b17983d..dc79489 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Hexai, the AI LSP for the Helix editor and also a simple command line tool to interact with LLMs in general. -At the moment this project is only in the proof of PoC phase. +At the moment this project is in the alpha state. ## LLM provider @@ -74,6 +74,22 @@ Notes for `hexai` (CLI): - Add the word `explain` in your prompt to request a verbose explanation. - Exit codes: `0` success, `1` provider/config error, `2` no input. +### Internal CLI package + +- Package `internal/hexaicli` contains the CLI logic extracted from `cmd/hexai`. +- Entry points: +- `Run(ctx, args, stdin, stdout, stderr)`: Full CLI flow; parses input and builds the LLM client from config/env. +- `RunWithClient(ctx, args, stdin, stdout, stderr, client)`: Same flow using a provided `llm.Client` (useful for tests and embedding). +- Behavior is identical to the `hexai` binary: provider/model banner on stderr, streamed output when available, and a final summary line. + +### Internal LSP package + +- Package `internal/hexailsp` contains the LSP binary logic extracted from `cmd/hexai-lsp`. +- Entry points: +- `Run(logPath, stdin, stdout, stderr)`: Configures logging, loads config, builds the LLM client, and runs the LSP server over stdio. +- `RunWithFactory(logPath, stdin, stdout, logger, cfg, client, factory)`: Testable entry that accepts a prebuilt `llm.Client` and a factory for `lsp.Server` creation. +- Mirrors the behavior of the `hexai-lsp` binary while enabling unit tests without invoking the full server loop. + Examples: ``` -- cgit v1.2.3