@kattebak/sterk
v2.0.2
Published
Touch-friendly terminal emulator for the web — Ace renderer + clean-room VT core. OSC 133 first-class.
Maintainers
Readme
@kattebak/sterk
Sterk is a terminal emulator for the web, built with ❤️ on top of Ace. It pairs Ace's mature text-rendering engine with a clean-room VT core, and treats shell-integration (OSC 133) as a first-class primitive rather than an extension.
Touch-friendly. Mobile-first. MIT.
Status
- ✅ M0 — Public API contract (
src/types.ts) - ✅ M1 — Foundation utilities (256-color palette, scrollback buffer, EventEmitter shim)
- ✅ M2 — Clean-room VT core (Paul Williams parser, SGR, OSC 133,
Terminalfactory) - 🚧 M3 — Ace renderer glue (input, mouse, links, theme, DOM)
- ✅ M4 — Polish, alt-screen buffer, demo page, 1.0 release
See docs/ROADMAP.md.
Installation
npm install @kattebak/sterkSize
Sterk is lightweight — under 53 kB packed (including Ace as a peer dependency).
Run npm run size to verify the current bundle size against the 75 kB budget.
Demo
A standalone demo is available in demo/index.html. To run it:
npm run build
npm run demoThen open http://localhost:3000 in your browser.
Usage
Headless mode (parser + buffer only)
import { createTerminal } from '@kattebak/sterk';
const term = createTerminal({ cols: 80, rows: 24 });
term.write('Hello, world!\r\n');
term.write('\x1b[1;31mBold red text\x1b[0m\r\n');
term.onData((data) => {
console.log('User input:', data);
// Forward to backend (WebSocket, pty, etc.)
});
// Access buffer for rendering
const line = term.buffer.active.getLine(0);
console.log(line?.translateToString());DOM mode (with Ace renderer)
import { createTerminal } from '@kattebak/sterk';
const term = createTerminal({
cols: 80,
rows: 24,
theme: {
foreground: '#f0f0f0',
background: '#1e1e1e',
},
});
// Attach to DOM
const container = document.getElementById('terminal');
term.open(container);
term.write('Welcome to sterk!\r\n');
// Register OSC 133 handler for shell integration
term.parser.registerOscHandler(133, (data) => {
const kind = data.charAt(0); // 'A', 'B', 'C', 'D'
if (kind === 'A') {
console.log('Prompt start');
}
return false; // Allow other handlers
});See demo/ for a complete standalone example.
Public API
createTerminal(options?: TerminalOptions): Terminal— Create a terminal instanceTerminal— Main terminal interface (write, resize, open, dispose)Parser.registerOscHandler(id, handler)— Register OSC sequence handlersBuffer/BufferLine/BufferCell— Read-only buffer access with full SGR attributesTheme— Color theme definition (foreground, background, ANSI palette)
See src/types.ts for full API documentation with JSDoc comments and examples.
Design principles
- Clean-room core. The VT parser is written from public specs (Paul Williams' state machine, XTerm Control Sequences, ECMA-48). No code lifted from other emulators.
- Ace does what Ace does well. Text layout, scrolling, theming — we don't reinvent it.
- OSC 133 first-class. Shell integration (prompt markers, command boundaries) is a built-in concept, not a bolt-on.
- Pragmatic feature scope. Feature parity with xterm.js is aspirational. We build what real consumers need and skip the rest.
License
MIT © 2026 Matthijs van Henten / kattebak
