5.9 KiB
hx
Minimal Rust coding agent. Uses your existing subscriptions, no API keys.
cargo build --release
hx login claude # Claude Pro/Max
hx login codex # ChatGPT Plus/Pro
hx # interactive TUI
hx -p "hello" # one-shot, Claude
hx --provider codex -p "hello" # one-shot, Codex
hx -c # continue last session in this directory
TUI: enter send, alt-enter/ctrl-j newline, esc abort, ctrl-o expand tool output, tab completes @file
(mentioned files are attached), pgup/pgdn scroll. Commands: /model <name>, /provider claude|codex,
/compact, /clear, /quit. Messages typed while the agent works are queued.
Config: ~/.hx/config.toml, overridden per project by .hx/config.toml:
provider = "claude" # or "codex"
claude_model = "claude-sonnet-4-5"
codex_model = "gpt-5-codex"
compact_at = 150000 # auto-compact threshold (estimated tokens)
max_tokens = 16384
# system_prompt = "..." # replaces built-in prompt; AGENTS.md still appended
[lsp]
mode = "turn_end" # turn_end | agent_end | off
disable = ["clangd"]
enable_runners = ["clippy"] # opt-in (slow): clippy
disable_runners = ["rustfmt"] # any of: ruff, biome, eslint, ast-grep, rustfmt, ruff-format, biome-format
tests = "turn_end" # affected tests: turn_end | agent_end | off
# [[lsp.servers]] # add or override (same id replaces built-in)
# id = "zls"
# language = "zig"
# extensions = ["zig"]
# command = ["zls"]
# roots = ["build.zig"]
# install = ["brew", "install", "zls"] # offered by the lsp tool when `zls` is missing
Lens
After every tool round, hx asks the language server about files the agent wrote or edited and appends
errors/warnings to the next request, so the model fixes them without being told. Built in:
rust-analyzer, typescript-language-server, pyright, gopls, clangd (used when on PATH). The lsp tool gives
the model diagnostics, definition, references, hover and symbols on demand. If the language server for a file is
missing, the lsp tool asks you ([y/n] in the footer) whether to install it, once per server per session:
rustup component add rust-analyzer, npm install -g typescript-language-server typescript,
npm install -g pyright, go install golang.org/x/tools/gopls@latest (only offered when the installer is on
PATH; clangd is manual). Custom servers can set install = ["cmd", "args"]. Print mode never installs. /lsp in the TUI shows server status,
missing tools and triage marks.
Besides the language server, changed files go through (when installed and the project uses them):
ruff (Python), biome (with biome.json), eslint (with an eslint config), ast-grep (rules in .hx/rules/*.yml),
and clippy (opt-in). Formatters run only when configured for the project (rustfmt.toml, ruff.toml, biome.json);
their changes don't trip the read-guard. Files edited outside hx are picked up at the next turn.
diag_mark lets the model silence a finding (false_positive = forever, defer = until the file changes),
stored in ~/.hx/projects/<project>/triage.json. Runner timings go to ~/.hx/latency.log.
Affected tests run after each tool round that changed files; only failures are injected (plus one
"all pass now" notice after they're fixed). Supported: cargo, pytest, vitest, jest, go test. Selection is
a heuristic: Rust runs the changed crate and crates depending on it; Go the changed package and importers;
Python/JS the test files that are changed or import a changed file (up to 3 hops). Rust/Go therefore
over-select (whole crates/packages); dynamic imports, fixtures and data files are not tracked.
Existing Claude Code (~/.claude/.credentials.json) and Codex CLI (~/.codex/auth.json) logins are picked up automatically.
Credentials are stored in ~/.hx/auth.json (mode 0600) and refreshed automatically.
On a headless box, open the printed URL elsewhere and paste the final redirect URL back into the terminal.
MCP
Servers come from ~/.hx/mcp.json and .hx/mcp.json (project entries replace global ones with the same
name), in the Claude Code mcpServers shape. ${VAR} and ${VAR:-default} are expanded.
{"mcpServers": {
"fs": {"command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "${HOME}/src"]},
"web": {"type": "http", "url": "https://example.com/mcp", "headers": {"Authorization": "Bearer ${TOKEN}"},
"allow": ["search"], "eager": true, "timeoutSecs": 30}
}}
Transports: stdio and streamable HTTP (static headers; no OAuth). hx extras: allow (tool allowlist),
eager, timeoutSecs (per call, default 60), disabled. Output is capped at 30k chars; a crashed stdio
server is restarted on the next call (at most 3 times).
Lazy by default: the system prompt carries one line per tool (server.tool: description); the model gets the
schema with mcp_describe and calls through mcp_call (arguments are checked against the cached schema).
Servers whose full schemas cost at most ~400 tokens are registered as native tools instead (server__tool);
eager: true|false overrides. Resources are listed in the prompt and read with mcp_read; prompts become
slash commands (/server:prompt args). /mcp in the TUI and hx mcp show tools and token costs.
Measured (hx mcp, bytes/4):
| server | tools | lazy index | eager schemas |
|---|---|---|---|
| context7 | 2 | ~63 tok | ~1147 tok |
| everything | 13 | ~319 tok | ~1235 tok |
| filesystem | 14 | ~453 tok | ~1996 tok |
| playwright | 25 | ~537 tok | ~4397 tok |
Lazy costs one extra round trip (mcp_describe) per tool on first use in a session. Since tool count is a
poor proxy (context7: 2 tools, 1.1k tokens), the eager rule is schema size, not count.
hx mcp-serve runs hx as a stdio MCP server exposing the lsp tool (diagnostics, definition, references,
hover, symbols) to other clients.