Navigation
Copy page

Extend kli

On this page

kli is a live image. A small boot kernel installs the extension protocol. Everything above it (the model providers, the tools, the slash commands, the terminal UI) is an extension installed into that protocol with a retractor. You extend kli by installing more of the same: there is no privileged built-in path, only contributions and the two operations that add and remove them.

One mechanism, three altitudes

The mechanism is constant. A contribution installs against the protocol and carries a retractor that undoes exactly what it installed. What changes between altitudes is how much of the contribution you write yourself.

  1. Feed a builtin extension a resource. The prompt-templates and skills extensions ship in the image. Drop a Markdown file in an extensions directory and the builtin's effect registers a slash command for it, with a retractor that unregisters it on unload. You write no Lisp; you hand data to the builtin prompt-templates and skills extensions, which someone already wrote.
  2. Write a contribution. A defextension form adds tools, commands, themes, event handlers, or methods. Requirements for the common kinds are derived from the clauses you write, and each kind retracts. See Lisp extension anatomy and Contribution kinds.
  3. Define a new contribution kind. The kernel's own vocabulary (:tool, :method, :effect, :theme) is built with defcontribution-kind. When no existing kind fits a domain, you add one and defextension learns to compile its clause. See Defining a contribution kind.

Extensions all the way down

The altitudes are not tiers of a ladder; they are the same install/retract shape seen at three depths. prompt-templates and skills are not a no-code layer bolted under the Lisp one. Each is a defextension whose (:provides ...) is a single effect that registers commands against the commands/v1 capability and pairs an unregister retractor:

lisp
(defextension prompt-templates
  (:requires
   (capability commands :contract commands/v1)
   (capability config :contract config/v1))
  (:provides
   (effect prompt-templates
     #'register-prompt-template-commands
     #'unregister-prompt-template-commands)))

cairn, a separate tool, contributes its slash commands with the same shape: a cairn-commands effect that registers them against commands/v1 with a retractor. The Markdown-prompt path and the kernel's command machinery run the same mechanism; one writes the effect for you, the other hands you the macros to write your own. The protocol does not distinguish them.

For the same idea stated as the design's spine and the three pillars it buys you, see Extensions all the way down.

Where to go