Every feature is a plugin
On this page
Open Lokyr and look at the tab bar. It's a plugin. So are the find bar, the command palette, the split panes and the quick terminal that slides in over every app. Add two lines to your config:
[plugins.tabs]
enabled = false
Save the file, and the tab bar is gone, along with every key that opens a tab. Set it back to true, and it returns. No restart.
That's the idea Lokyr is built around: a small core that keeps the terminal itself, the screen, the input and the rendering, and plugins for everything you see. This post is about what that takes, and what it costs.
From the core to the window
Start at the bottom. Your shell and its programs talk to Lokyr through a PTY. For each pane, one thread reads their output, another parses it into a grid of cells, and a third writes your keys back. That's the terminal core, vt-core, and it has no UI at all.
Above it sits the kernel: the windows, the tabs, the split layouts and the panes, the commands, the keymap, the config, and a bus of events. It holds the mechanisms, and decides nothing about what you see. A key goes from AppKit to the kernel's keymap, which runs the command bound to it, or hands the key to the terminal core, encoded for the program.
The plugins decide. Through the plugin API they ask the kernel to open a tab or split a pane, hear its events, and hand it views as data. The UI engine lays those views out beside the terminal's rows, shapes the text and draws a frame with Metal, only when something changed.
Sleip stays outside the app. It's a separate tool that fetches plugins from the registry and installs them on disk, where Lokyr finds them.
One API, two languages
Lokyr comes with 16 plugins of its own: the tabs, the splits, search, the palette, the macOS shortcuts, copy mode, the quick tips, even the settings window's pages. They're written in Rust and built into the app. Plugins from other authors are written in Luau, a typed dialect of Lua made for sandboxes, and installed from the registry.
Both kinds run on the same API. It's defined once, in Rust, as messages: a plugin sends requests, Lokyr answers them, and events come back in batches. Today that's 172 kinds of requests and 32 kinds of events. The Rust plugins reach them through a crate, plugin-sdk; the Luau plugins through the same messages, from their own VM.
The bundled plugins get no back door. Each one depends on plugin-sdk alone, forbids unsafe code, and passes the API's conformance suite. The tab bar holds no capability that another plugin can't ask for: it opens and moves tabs, sets their titles, and reads the panes' programs. The tab bar is about 5,500 lines of Rust, and everything it does, drawing the tabs, dragging them, pinning and grouping them, goes through requests that a Luau plugin can make too. When the tab bar needed something the API didn't have, the API grew, for everyone.
That's the real reason for the design. A core that its own features can't go around keeps the API honest: if the tab bar can be a plugin, so can yours.
Plugins don't draw pixels
A plugin never touches the GPU. It hands Lokyr a tree of views, containers, text, buttons, fields and lists, and Lokyr lays them out and draws them in the theme's colors, keeps their state, and makes them readable to VoiceOver. A view goes into a slot: the tab bar, the buttons beside the window's, the status bar, a strip across the window's top, a pane's header. Or into a panel that floats over the window, anchored to a cell, the cursor or a corner.
Here is the core of sephiroth74/hello, the registry's test plugin, shortened. Its command shows a notice at the top of the window and closes it after three seconds:
function Plugin.activate(cx: Cx)
assert(cx.register_command({ name = "hello.say", title = "Say Hello", category = "view" }))
end
function Plugin.on_command(cx: Cx, name: string, args: Args)
local window = cx.focused_window()
if window == nil then
return
end
assert(cx.open_panel(NOTICE, {
anchor = { window_corner = { window = window, corner = "top" } },
role = "overlay",
close_outside = true,
close_escape = true,
}))
closing = assert(cx.start_timer(3000, false))
end
The whole plugin, its view and its timer included, is 67 lines.
Capabilities: what a plugin may reach
A plugin from someone else runs in a Luau VM of its own. The VM has no io, no os and no debug library, and its require stays inside its package. Files, processes and the network exist only as functions of the host. A plugin reaches the screen's text, the clipboard, the shell's input or your command history only through the capabilities that its manifest declares. There are about two dozen, each with its risk, from notifications (low) to input-read (very high: it's a keylogger's power).
You see them three times. Sleip shows them before it installs anything:
$ sleip info sephiroth74/awake
sephiroth74/awake 0.1.0
Keeps the Mac awake from a button beside the window's buttons: always, or while a tab runs a program
Capabilities: keep-awake, process-read
Lokyr asks for them the first time the plugin starts, and the default button refuses. Your answers stay in permissions.toml, beside your config. Take one back there, and the plugin stops at once.
Commands are no way around them. Each command carries the capabilities of what it does: pane.paste needs clipboard-read and pty-write. Beyond its own, a plugin runs only the commands that its manifest lists, and only if it holds their capabilities.
Limits that hold
Every Luau plugin has a memory limit of 64 MB and a deadline for each call: 16 ms to render a view, 250 ms for a command or an event, a second to start. A watchdog ends a call that runs past its deadline, and that watchdog sleeps unless a plugin is running, so plugins at rest wake nothing. A plugin that faults starts again; after three faults within a minute, it stays off until Lokyr's next start. The terminal never goes down with it.
These limits are tested against plugins written to break them. On every build, CI runs hostile plugins: an endless loop, an allocation that never stops, a string that doubles, a table that holds itself, a flood of writes, a flood of images, a capability that was never granted, a require outside the package, a runaway recursion. Each one must be stopped by its limit, while a well-behaved plugin beside it keeps running its commands and hearing its events.
And without third-party plugins, there's no Luau VM at all. A plugin can wait until it's needed: the first run of one of its commands, the first time its view shows, or the event it waits for. Until then, it makes no VM.
The registry
Sleip installs plugins from pkg.lokyr.dev. The registry builds each package from a tagged commit of its sources, and packages carry Luau sources, never bytecode: Lokyr compiles every script itself. Sleip checks each package against the registry's signed index, and refuses an index that the registry's keys didn't sign, or one older than the index it already holds.
Sleip's connections carry only the registry's public files, each checked against the signed index, and no credentials. Its HTTPS still runs on ring, through rustls. On 3 December, rustls deprecated its ring provider, because ring has no post-quantum key exchange: the kind that keeps what a connection carries secret even from someone who records it today and decrypts it years from now. Nothing Sleip downloads is secret, so nothing is lost today, but ring will be replaced soon anyway.
There are five plugins so far: snap makes an image of the terminal's text, awake keeps the Mac awake, font-picker previews the system's monospaced fonts, git-folder shows the folder and its branch in the status bar, and open-in-editor opens a pane's scrollback, or a command's output, in your text editor.
The video tour shows sleip search and sleip info, then one of these plugins at work.
Where the line is
"Every feature is a plugin" isn't the whole truth, and the exceptions are where the idea was tested.
The first plan had a themes plugin. But a theme colors everything, the cells and the interface, from the first frame: it's part of how Lokyr draws, and a plugin would have handed it back whole at every change. So themes belong to the core, in [theme] beside [font] and [window]. A third party adds themes as files, not as code.
The dividers between panes are the core's too: it draws them and takes their drags. Broadcast input lives in the core, and plugins turn it on and off through requests. And the triggers in your config run in the core, not in a plugin.
What it cost
The app grew. When Luau and Sleip arrived, in 0.8.0, the download went from 9.0 MB to 14.7 MB, and the app from 16.5 MB to 35.3 MB.
Everything crosses a boundary. A plugin gets copies of the data, never references into the terminal's state, and its changes apply in order once its call returns. A Luau plugin's calls copy their data in and out of its VM.
And the API is big: 172 kinds of requests, each documented and tested. That's why it has its own version, 0.1.9 today, apart from the app's: a plugin says which versions of the API it takes, and Lokyr refuses one that it can't serve.
Write your own
sleip new owner/name makes a plugin that runs, with its test. sleip check checks its manifest, its translations and its types, sleip test runs its tests, and sleip dev loads it into Lokyr, which reloads it as you save.
Publish it
When it's ready, publishing takes three steps. Push the plugin to a public GitHub repository, the one its plugin.toml names. Tag the version, v and the manifest's version, and push the tag:
git tag v0.1.0
git push origin main v0.1.0
Then run sleip publish. Sleip checks and tests the plugin as the registry will, finds the tag on GitHub, and opens the registry's pull request through gh; without gh, it gives you a link that proposes the change on GitHub. It's the only step that needs your GitHub login, and it goes through gh and git, never through Sleip's own connections.
The registry's CI checks the pull request: the plugin's owner, which must be your account or one of your organizations, its tag and its commit, its manifest and its tests. It builds the package itself, from the tag's commit, and keeps it in a release of its own, which stays as it was whatever happens later to your repository. I review every new plugin. A new version that asks for nothing new, no new capability, host or command, merges by itself; one that asks for more waits for a review. Once merged, the version is signed into the index and shows on pkg.lokyr.dev, and anyone can install it:
sleip add owner/name
A new version is a new version in the manifest, a new tag, and sleip publish again. Writing a plugin walks through all of it, and the plugin reference has every capability, slot, event and limit.
Lokyr is free and open source, under the MIT License, for macOS 26 or later on Apple Silicon: install it.
This post was drafted with Claude from Lokyr's sources and documents, and reviewed by me.