On this page

Script plugins

ADR-0280. A script plugin is a Tenon package that an app loads at run time to add key bindings, commands, themes, tools, prompt hooks or status widgets without being rebuilt. It runs in the reference interpreter in a child process and talks to the host only through typed messages.

Status: implemented across M22.7–M22.9 (ADR-0280, ADR-0297). Manifest validation (tenon plugin check), the framed stdio server (tenon script-serve <plugin-path> [--fuel N] [--deadline-ms N] [--max-frame N] [--heap-bytes N]), and the bundled plugins/script_host host library (frame, api, policy, discover, lock, protocol, reload, session) are live in the repository and edition 2026.

Manifest

[package]
name = "keys"
version = "0.1.0"
edition = "2026"
capabilities = ["fs"]          # optional ceiling; the host may grant less

[plugin]
kind = "script"
index = "keys: vim-style bindings for the harness"
api = "harness.plugin/1"

api is <host>.plugin/<major>: the host package's name and the major version of its plugin interface. A host accepts plugins with the same major. Script plugins cannot declare the ffi capability, an [ffi] table or a platform (E0955), so they never contain extern functions or natives. Generators and platforms stay in compiled packages; process access goes through PluginMsg.Request. tenon plugin check <dir> reports kind conformance: ok (script: api …).

Interface

The host package declares one interface and two closed enums with derived codecs. The step has the same shape as Agent.step -> Transition<Self>:

interface HarnessPlugin { fn handle(self, msg: HostMsg) -> Reply<Self> }
struct Reply<S> { state: S, out: vec<PluginMsg> }

HostMsg holds variants such as Init, Key, Command, Prompt, Render and ToolCall. PluginMsg holds variants such as Bind, AddCommand, Theme, Status, PromptEdit, ToolResult and Request. Adding a HostMsg variant is a minor change: the generated dispatcher replies Unsupported to variants it does not know.

Session protocol

The host starts tenon script-serve <plugin-dir> (or resolves the serve binary via TENON_SCRIPT_BIN / script_host.session.resolve_script_bin). The host uses plugins/proc inside process.sandbox(fs, net), with fs limited to the plugin directory (read-only) plus its data directory, and net.none() unless granted. The child checks the plugin and then serves framed requests on stdio until stdin closes.

Discovery and determinism

Hosts load $XDG_CONFIG_HOME/<app>/plugins/* (default ~/.config/<app>/plugins/) in name order. An optional plugins.lock pins a SHA-256 per plugin tree, and --strict-plugins refuses plugins that are unpinned or changed. In agent runs every call is journaled like a tool result, with the plugin hash in the journal header. Replay feeds the recorded replies back without running the plugin, and warns when a hash does not match.