Terminal UI Target
Compile KERN to ANSI terminal interfaces with zero dependencies. Pure Node.js output using escape codes written directly to stdout.
What it generates
KERN input:
screen name=dashboard
text value="Deploy Status" {color:blue,fw:bold}
separator {width:48}
box {color:green,width:50}
text value="All systems operational"
progress value=95 max=100 {color:green}
spinner message="Checking services..." {color:cyan}Compiled output (TypeScript, zero dependencies):
// ── ANSI helpers ──────────────────────────
const ESC = '\x1b[';
const RESET = ESC + '0m';
// ... (style, box, gradient, spinner, etc.)
// ── Output ─────────────────────────────────
console.log(style("Deploy Status", { color: "blue", bold: true }));
console.log(separator(48));
console.log(box("All systems operational\n[progress: 95/100]", "green", 50));
const _spinner = spinner("Checking services...", "cyan");
_spinner.start();Supported nodes
The terminal transpiler handles these node types:
| Node | Props | Description |
|---|---|---|
| text | value, color, bg, bold, dim, italic | Styled text output via console.log |
| separator | width (default 48) | Horizontal line using dim characters |
| table | headers, row children with data | Auto-width table with bold headers |
| scoreboard | title, winner, metric children | Results display with metrics and optional winner |
| spinner | message, color | Animated braille spinner (80ms interval) |
| progress | value, max (default 100), color | Block-character progress bar with percentage |
| box | color, width (default 50), children | Unicode box-drawing frame around content |
| gradient | text, colors (array of ANSI 256 codes) | Per-character color gradient |
| state | name, initial | Mutable variable (let declaration) |
| handler | code | Raw code injection |
REPL support
The terminal target has built-in REPL support using Node.js readline. Define interactive prompts with event handlers:
screen name=chatRepl
state name=busy initial=false
text value="Chat REPL" {fw:bold}
repl prompt=">"
guard busy
text value="Waiting for response..." {color:yellow}
on input
handler <<<
busy = true;
const response = await getResponse(trimmed);
console.log(response);
busy = false;
>>>
on interrupt
text value="Goodbye!" {color:dim}This generates a complete readline-based REPL with a busy guard, input handler, and SIGINT cleanup.
Parallel dispatch
The terminal target supports parallel async dispatch with timeout and abort control. Use the parallel node to fan out work and collect results:
parallel timeout=30
each engine in state.engines
dispatch prompt=userPrompt result=response
on start
handler <<<
console.log(style('Starting ' + engine, { dim: true }));
>>>
on done
handler <<<
console.log(style('Done: ' + engine, { color: 'green' }));
>>>
then
handler <<<
// results array contains all completed responses
console.log('Finished: ' + results.length + ' responses');
>>>Color support
Colors can be specified as named colors (red, green, blue, cyan, magenta, yellow, white), hex codes (#ff6600), or ANSI 256 palette numbers. Bold, dim, and italic styles are supported on all text nodes.
Configuration
kern dev dashboard.kern --target=terminalThe generated .ts file runs directly with ts-node or tsx. No external dependencies required.