1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# Hexai

Hexai, the AI LSP for the Helix editor.
At the moment this project is only in the proof of PoC phase.
## LLM provider
Hexai exposes a simple LLM provider interface. It supports OpenAI and a local
Ollama server. Provider selection and models are configured via a JSON
configuration file.
### Selecting a provider
- Set `provider` in the config file to `openai` or `ollama`.
- If omitted, Hexai defaults to `openai`.
### OpenAI configuration
- Required: `OPENAI_API_KEY` — provided via environment variable only.
- In config file:
- `openai_model` — model name (default: `gpt-4o-mini`).
- `openai_base_url` — API base (default: `https://api.openai.com/v1`).
### Ollama configuration (local)
- In config file:
- `ollama_model` — model name/tag (default: `qwen2.5-coder:latest`).
- `ollama_base_url` — base URL to Ollama (default: `http://localhost:11434`).
Notes:
- For Ollama, ensure the model is available locally (e.g., `ollama pull qwen2.5-coder:latest`).
- If you run Ollama in OpenAI‑compatible mode, you may alternatively use the
OpenAI provider with `openai_base_url` in the config pointing to your local endpoint.
## CLI usage and configuration
- Run LSP server over stdio:
- `hexai`
- Flags (minimal):
- `-version`: print the Hexai version and exit.
- `-log`: path to log file (optional; default `/tmp/hexai.log`).
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 | Description |
|------------|--------------------------------------|
| `-log` | Path to log file (optional). |
| `-version` | Print version and exit. |
Configuration is via a JSON file only. Environment variables are not used
except for `OPENAI_API_KEY`.
### JSON config file
- Location: `~/.config/hexai/config.json`
- Example:
```
{
"max_tokens": 4000,
"context_mode": "always-full", // minimal | window | file-on-new-func | always-full
"context_window_lines": 120,
"max_context_tokens": 4000,
"log_preview_limit": 100,
"no_disk_io": true,
"provider": "ollama", // or "openai"
// OpenAI-only options
"openai_model": "gpt-4.1",
"openai_base_url": "https://api.openai.com/v1",
// Ollama-only options
"ollama_model": "qwen2.5-coder:latest",
"ollama_base_url": "http://localhost:11434"
}
```
Minimal config (defaults to OpenAI):
```
{}
```
Ensure `OPENAI_API_KEY` is set in your environment.
### Environment
- Only `OPENAI_API_KEY` is read from the environment when `provider` is `openai`.
## Inline triggers
Hexai supports inline trigger tags you can type in your code to request an
action from the LLM and then clean up the tag automatically.
- `;text;`: Do what is written in `text`, then remove just the `;text;` marker.
- Strict form: no space after the first `;` and no space before the last `;`.
- An optional single space immediately after the closing `;` is also removed.
- Multiple markers per line are supported.
- Example: `// TODO ;rename this function to add;` removes only the marker.
- `;;text;`: Do what is written in `text`, then remove the entire line.
- Strict form: no space after `;;` and no space before the closing `;`.
- Any line containing such a marker is deleted after processing.
- Example:
```
some() ;;extract helper; // this entire line is removed
```
- Spaced variants such as `; text ;` or `;; spaced ;` are ignored.
## Code actions
Hexai provides code actions that operate only on the current selection in Helix:
- Rewrite selection: Hexai looks for the first instruction inside the selection
and rewrites the selection accordingly.
- Resolve diagnostics: With a selection active, Hexai gathers only diagnostics
that overlap your selection and fixes them by editing only the selected code.
Diagnostics outside the selection are not modified.
Instruction sources (first one found wins):
- Strict marker: `;text;` (no space after first `;`, none before last `;`).
- Line comments: `// text`, `# text`, `-- text`.
- Single-line block comments: `/* text */`, `<!-- text -->`.
Notes:
- Only the earliest instruction in the selection is used; Hexai removes that
marker/comment from the selection before sending it to the LLM.
- The action returns only the transformed code and replaces exactly the
selected range.
|