An AI harness you can shape.
An AI coding harness for any LLM provider.
With advanced Clojure scripting, permission gating via rules and broad configurability via extensions and MCP support.
bun install -g xi-agentScripting
The agent scripts in Clojure, not shell pipelines.
Instead of a bash tool, Xi gives the agent a persistent Clojure REPL with file helpers. Scripts filter and aggregate in the runtime; only the result enters the conversation.
- Small context. Load a large file once, query it across calls. The file never enters the conversation.
- Reviewable. Every real command runs argv-style through one call you can read. No quoting tricks, no hidden pipes.
- Gated. Read-only tools run freely. Anything else asks once, or is allowed by a rule.
;; count TODOs per file, return only the summary
(->> (glob "src/**/*.cljs")
(map (fn [f] [f (count (re-seq #"TODO" (cat f)))]))
(filter (fn [[_ n]] (pos? n)))
(into {}))
;; => {"src/xi/agent.cljs" 3, "src/xi/fx.cljs" 1}
;; a real CLI, argv-style — reviewed before it runs
(sh "ffmpeg" "-i" "talk.mp4" "-vn" "talk.mp3")Permissions
Permission rules.
What the agent may do on its own is a list of rules in a file, evaluated top to bottom. Allow, deny, ask, or nudge it in another direction.
- Scoped. Match on the tool, the path, the command, the git repo, or the extension making the call.
- Layered. Repo rules beat global rules; both beat anything granted in the moment. A hardened tier stays out of reach.
- Agents can't touch them. The rules files are off-limits to every tool. Only you edit them.
;; ~/.config/xi/rules.edn — first match wins
{:type :xi/rules
:version 1
:rules
[{:match {:tool #{:write :edit} :path #"\.sh$"}
:action {:type :nudge :message "write babashka scripts, not shell scripts"}}
{:match {:tool :sh :cli "git" :command #"\bgit push\b"}
:action {:type :ask :message "Push to the remote?"}}
{:match {:tool #{:read :grep :find :ls} :path #"^~/Code(?:/|$)"}
:action {:type :allow}}]}Extensions
Extension.
Drop a ClojureScript file into ~/.config/xi/extensions/, list it in your config, and it loads. No build step. /ext reload swaps a changed file in while the server runs.
- Tools, commands, keys, pages. An extension is a plain map. Give the agent a tool, add a slash command, bind a key, or ship a page for the web client.
- Sandboxed. Extensions have no host access of their own. Files, shell commands and network requests go through the same rules as the agent's tool calls.
- Your data stays yours. Each extension gets a data directory it may use freely. Everything else asks, or is pre-allowed by a rule you wrote.
;; ~/.config/xi/extensions/notes.cljs
(ns notes
(:require [xi.api.fs :as fs]
[xi.api.promise :as p]))
(defn- notes-file [ctx] (str (fs/data-dir ctx) "/notes.md"))
(def extension
{:id :notes
;; a tool the agent can call
:tool-definitions
[{:name "notes_add"
:description "Append a line to my notes."
:input_schema {:type "object"
:properties {:text {:type "string"}}
:required ["text"]}}]
:tool-registry
{"notes_add"
(fn [{:keys [text]} ctx]
(-> (fs/read ctx (notes-file ctx))
(p/catch (fn [_] ""))
(p/then #(fs/write ctx (notes-file ctx) (str % text "\n")))
(p/then (fn [_] {:content [{:type "text" :text "added"}]}))))}
;; and a slash command for you
:commands
[{:name "notes" :description "Show my notes"
:handler (fn [_st {:keys [room-id]}]
{:effects [[:ext.notes/show {:room-id room-id}]]})}]})MCP
Plug in any MCP server.
Xi speaks the Model Context Protocol on both sides: it offers its own tools to the model, and it pulls in tools from servers you add. One command registers a server; its tools show up on the next turn.
- Trust once. A server runs nothing until you approve it. Trust it and its calls stop asking, until its code changes.
- Stdio or HTTP. Spawn a local process, or point at a hosted server with an API key kept outside your config.
- Private servers for extensions. An extension can bring its own server, like a headless browser, that only it can call.
/mcp add browser npx -y chrome-devtools-mcp@1.10.1 --headless
# connects, caches the tool list, done — tools are there on the next turn
/mcp trust browser
# run its tools without asking, until the server's code changesWeb client
Start at your desk. Continue on your phone.
The web client joins the same session as your terminal. Begin a refactor in the TUI, stand up, and the conversation is already on your phone, still streaming. Reply from there and the terminal follows.
- Pair once. A new device shows a four-digit code; approve it from the terminal or the browser.
- Installable. Add it to your home screen. Recent chats are cached, so the list opens before the connection does.
- Review in place. Diffs, tool calls and permission requests render where they happen. Allow or deny with one tap.
Durability
Durable by default.
Chats live on the server, not in a tab or a terminal. A crash, a deploy or a reboot does not end a turn: when the server is back, every chat it cut off continues where it stopped. Nothing to turn on.
- Runs unattended. Close the laptop and the task finishes. The result waits in the chat list.
- Survives restarts. A chat cut off mid-turn continues on its own, whether or not anyone has it open.
- Queued prompts follow. Messages queued behind the interrupted turn are sent after it, in order.
xi server
# mid-turn: the server dies, a deploy restarts it, the machine reboots
xi server
[ws] continuing the chat cut off by the restart: Fix the flaky login testThemes
Make it yours.
Pick a background and an accent in the Appearance dialog. Xi derives the rest in OKLCH: surfaces, borders, text, status colors, diff bands and code all follow your color. Try a few: this page and every live session on it follow.
Multi-user Beta
First-class multi-user.
Use Xi with your team. Share one server and every connection acts as a user, so each person keeps their own identity and settings across terminal, browser and phone.
- User settings. Theme, collapsed groups, preferred model, and which chats are read or hidden are kept per user on the server, so they follow each person from device to device.
- Profiles are optional. Declare a name and avatar in the config, or don't: an undeclared user is a circle with initials. Extensions can read profiles and keep data per user.
;; ~/.config/xi/config.edn
:users {"alice" {:name "Alice"
:avatar "https://example.com/a.png"
:meta {:team "ops"}}
"bob" {:name "Bob"}}xi join --user alice # this terminal acts as alice
xi clients user iPhone bob # pin a paired phone to bobProviders
Providers
Every model provider is a program Xi starts for each message: Claude through the Agent SDK, GPT on a ChatGPT plan, OpenCode, Ollama, or one you write. Xi keeps the tools, the rules and the chat; a provider only turns a prompt into text and tool calls.
- Pick in your config. List the providers you want, in the order the model picker shows them, with options for each. Only those load.
- Write your own. A manifest and a program that speaks JSON lines over stdio. With the TypeScript kit it is a dozen lines; babashka or Go work just as well.
- Same rules for every model. A provider asks Xi to run each tool, so your rules and approvals apply whichever model is talking.
;; ~/.config/xi/config.edn
:providers [:anthropic
{:id :ollama
:base-url "http://gpu:11434"}
{:dir "~/code/my-provider"}]// main.ts — its manifest is in package.json
import { serve } from "@xi-agent/provider-kit";
import { chatCompletionsTurn }
from "@xi-agent/provider-kit/openai-compat";
serve({
turn: (req, io) =>
chatCompletionsTurn(req, io, {
baseUrl: "http://localhost:8080",
}),
});Architecture
One server, every surface.
A server holds each session as one state and runs every action through a single event queue. Terminal, browser and scripts are clients of the same session. Model providers are programs it starts per message; their tool calls, the clj tool and MCP servers sit behind rules you wrote.
Under the hood
One state, every surface.
Terminal, server and browser run the same pure handlers over one state interface.
Everything is an event.
Prompts, output, commands, dialogs and renders all pass through one queue. The wire protocol is the event maps themselves.
ClojureScript on Bun.
A light runtime with no dependencies that starts fast. Server, terminal and browser share the same code, and you can change it from a REPL while it runs.
Install Xi
Bring a Claude login, a ChatGPT plan, an OpenCode key or a local Ollama.