labs
한국어 hello@taklabs.dev

Work / nerv

nerv

Fig-style autocomplete for zsh on macOS: subcommands, flags, branches and scripts pop up as you type. A Rust daemon and one zsh script, with no login, no AI and no telemetry.

Platform
macOS on Apple Silicon · zsh
Built with
Rust · one zsh script
Specs
715 commands
License
Apache-2.0 · MIT for the specs

What it does.

How it is designed.

The keystroke path of nerv, from the zsh widget to the daemon and back, drawn from its code.

One keystroke, there and backThe zsh widget sends each keystroke to the nerv daemon, which reads gzipped specs from disk when needed, runs live values on a background thread under an 800 ms cap with a 5 s or 60 s cache, and returns the top 500 rows.zshwidgetnervdaemonSpecson diskBackgroundthreadkeystroke, one linereads a spec when neededgzipped JSONruns a live value, 800 ms capcached 5 s or 60 stop 500 rows
Fig. 01 One keystroke, there and back
  1. A socket, not a process, per keystroke

    Each request used to fork the nerv binary: 12 to 14 ms a keystroke. Now the zsh widget opens the daemon’s Unix socket itself and keeps it open for the life of the shell. One line goes out and rows come back, about 0.25 ms a round trip. If the socket fails, that request takes the fork path and the next one reconnects.

  2. Specs are compiled, not interpreted

    The engine is the Fig completion engine that AWS open-sourced. At build time a converter runs the TypeScript specs from withfig/autocomplete and emits plain JSON for 715 commands. At runtime there is no Node and no network: the daemon reads gzipped JSON off disk lazily, with a bound on entries and on bytes. The largest spec, aws, is split into 343 subtrees, and its first keystroke takes 3.9 ms cold (Apple Silicon, release build, v0.1.15, 2026-09).

  3. A slow command cannot freeze the prompt

    A live value such as git branch --list runs in a subprocess on a background thread with a hard 800 ms cap. Its result is cached for 5 seconds, or 60 for a generator measured slower than 50 ms, and it lands on the next keystroke.

  4. At most 500 rows cross the socket

    The popup shows about ten rows, but the widget receives every row and scans them all to size the box. At the 16,914 formulae of brew install that scan alone took about 270 ms a keystroke. The daemon now sends the top 500 after ranking, which keeps the widget’s work near 6 ms.

  5. A budget for every keystroke

    The budget is 25 ms a keystroke. Measured on Apple Silicon (release build, v0.1.15, 2026-09), the engine answers in 0.055 ms at p95 when warm, and a cold start of the CLI bridge takes 4.07 ms at p95. The numbers are measured again before each release.

hello@taklabs.dev