roadmap BUILT

169. kilo: the smallest real text editor, as the forcing function for raw terminal input

Built, 2026-08-27: the raw-keystroke primitive (OP_RAWMODE/OP_READRAW, line_editor) is built and proven by the raw-mode tests. No editor program ships in this tree. DECISIONS §31's foreign-language seam as built is a one-shot call. It cannot support kilo's own blocking event loop without new seam infrastructure (that infrastructure is milestone 181, raised separately).

A dependency review of Emacs, nano and vim, for a lightweight first text editor, found the same wall under all three. DECISIONS §31 (the foreign-language seam) forbids C code from making a system call or holding a capability directly. So any C program's port is really "rewrite its system call layer against nife's Rust-mediated shim," and no editor sidesteps that by being smaller. What does scale with size is how much of that rewrite there is to do. antirez's kilo (https://github.com/antirez/kilo) is a public-domain, single-file, roughly 1,000-line terminal text editor written explicitly to have almost no dependencies: raw termios mode and hand-written ANSI escape sequences, no ncurses, no subprocess calls, no dynamic linking, no threads. It is the cheapest real program that exercises nife's one missing terminal capability without also carrying nano's or vim's much larger optional-feature surface.

The one real gap this milestone exists to close

nife's terminal contract, DECISIONS §21, is a line discipline, not a curses substrate: OP_READLINE hands a program a finished line, and the program "never sees a keystroke, an escape sequence, or an echo" (per that decision's own text). OP_WRITE passes a program's own ANSI output straight through to the screen untouched, so the output half of what kilo needs already exists. What does not exist is the input half: raw, unbuffered, per-keystroke delivery with echo suppressed, which is what lets kilo see arrow keys, Ctrl-key chords and Escape sequences as they happen rather than after a line is finished.

This milestone's real deliverable is not "get kilo's C source to compile." It is: design and build the raw-keystroke input primitive nife's terminal layer does not have today. Prove it with the smallest program that needs it. Leave that primitive in place for nano (see below) and anything else that wants a screen editor's shape of input.

What else kilo needs, and why each one is already answered

Checked directly against kilo.c's own structure, not assumed from its reputation:

What this unblocks

Directly, DECISIONS §31's foreign-language seam gets its first real, load-bearing C program beyond the confined c_seam.c spike, and the raw-keystroke primitive this milestone has to build is reusable infrastructure, not a kilo-specific hack.

Milestone 170 is the direct follow-on, sequenced to start only once this milestone's raw-input primitive exists. Nano needs the exact same terminal capability at roughly 25x the code size. It also needs an optional (skippable) subprocess dependency for spell-check and external filtering that kilo never has to answer. Building kilo first is what turns "design a raw-terminal-input primitive and prove it under a full-size editor at the same time" into two separable pieces of work.

What this does not decide

Whether SIGWINCH-equivalent resize notification is worth building now or left as a recorded gap. Whether the raw-input primitive should be a new system call, a new line_editor opcode, or a capability narrowing of the existing terminal object. And whether kilo's optional syntax-highlighting feature (a few hundred lines, off by default without a language database) is in scope for a first cut. Left for whoever picks this up, informed by how the raw-input primitive actually gets designed.

Follow-on

Index row

A dependency review of Emacs, nano and vim for a possible nife port found the same wall under all three (DECISIONS §31's C-system-call seam), and one real, reusable gap behind it. Nife's terminal contract is a line discipline with no raw-keystroke input. The raw-keystroke primitive (OP_RAWMODE/OP_READRAW) is the milestone's own real deliverable; the seam as built cannot support an interactive event loop (milestone 181 (the foreign-language seam, extended)).