`slurp` and `read` treated ferror() as EOF: `edit` then took the truncated
prefix for the whole file and wrote it back, and `read` silently showed
fewer lines. Both now report the error and name the path.
`search` still skips a file it cannot read - it only reports hits, and a
file it cannot open is not a hit - but it no longer claims a clean scan.
Evidence:
edit /proc/self/mem -> "error: /proc/self/mem: Input/output error"
(before: "is empty")
read /proc/self/mem -> "[...: read error after line 0: Input/output error]"
edit <dir> -> "Is a directory"
With the three ferror() guards removed, tests/test_builtin.c fails at
lines 221, 227 and the directory cases; with them the test is green.
make check: all tests passed, 21 suites. check_asan: 45 binaries clean.
1076 lines
55 KiB
Markdown
1076 lines
55 KiB
Markdown
# splinter
|
|
|
|
Named after Master Splinter: the one who knows which tools exist, who may use
|
|
them, and what happened — and trains the ones that do the fighting.
|
|
|
|
A C99/POSIX agent harness with a curses interface: the conversation on three
|
|
quarters, a sidebar on the last one that says which agent, provider, model and
|
|
allowance you are on and where the tools will act, a status line above the
|
|
prompt with the context gauge (`ctx used/max`, cache share, tok/s), and the
|
|
prompt below it. The conversation starts clear at the top and only ever grows.
|
|
|
|
Code: https://git.kropa.tech/hiddenbox/splinter
|
|
|
|
make # libsplinter.so, the binaries, the plugins
|
|
make check # the tests, no network, no model
|
|
make install PREFIX=$HOME/.local # binaries, library, plugins
|
|
|
|
splinter --init-config # writes ~/.splinter/splinter.conf
|
|
splinter --doctor # does every provider answer?
|
|
splinter # the chat; Tab switches build / plan
|
|
splinter -m claude # a provider, a pool, provider/model
|
|
splinter --model-list # everything -m takes
|
|
splinter --serve # the engine on a socket, for a GUI
|
|
splinter --attach # the same curses UI, as a client of it
|
|
splinterctl --say "hallo" # the reference client for that socket
|
|
splinter --openai-listen 127.0.0.1 # /v1 for another harness, gw_ tools
|
|
|
|
The working day with several subscriptions (who analyses, who implements, what
|
|
happens at a limit) is in `docs/WORKFLOW.md`.
|
|
|
|
## Command line
|
|
|
|
`splinter --help` prints this list; `docs/splinter.1` is the manual page. Exactly
|
|
one transport is required (`--endpoint`, `--script` or `--transport`); with none,
|
|
splinter refuses to start rather than pretend it can talk to a model.
|
|
|
|
| option | what it does |
|
|
|---|---|
|
|
| `-p, --prompt TEXT` | run one turn with TEXT and exit |
|
|
| `--endpoint URL` | transport: an OpenAI-compatible chat endpoint (`--model` is then required) |
|
|
| `--model NAME` | model name for `--endpoint` |
|
|
| `-m, --select SEL` | a provider or pool of the config: `ID`, `ID/MODEL`, `POOL`, or a model name it serves |
|
|
| `--agent NAME` | start as that agent profile (`build`, `plan`, or a file in `~/.splinter/agents`, `.agents/`); Tab switches in the chat |
|
|
| `--agent-list` | list the agent profiles and exit |
|
|
| `--doctor` | check every provider — key and reachability through its model list, never spending tokens |
|
|
| `--model-list` | list what `-m` accepts (`--no-probe` skips asking each endpoint) |
|
|
| `--api-key-env VAR` | read the API key from VAR (default `SPLINTER_API_KEY`; missing means no auth) |
|
|
| `--script FILE` | transport: replay replies from FILE, one per line (no network) |
|
|
| `--transport NAME` | use a transport a plugin provides (`cli`) |
|
|
| `--kind NAME` | vendor shape of `--endpoint`: `openai` (default) or `anthropic` |
|
|
| `--config PATH`, `--no-config` | this config file, or ignore the config entirely |
|
|
| `--init-config` | write a commented example config and exit |
|
|
| `--plugin PATH` | load a plugin (`.so`) before the first turn |
|
|
| `--chat` | the interactive curses UI instead of one turn |
|
|
| `--serve`, `--attach`, `--socket PATH` | serve the line protocol on a Unix socket, or be a client of it (default `~/.splinter/splinter.sock`) |
|
|
| `--theme NAME`, `--list-themes` | UI theme (`Xresources` or a CDE palette such as `Default`, `Delphinium`, `MakroSlate`), and the names |
|
|
| `--resume`, `-c, --continue` | load the session's history; continue the last session started in this directory |
|
|
| `--claude`, `--opencode`, `--hermes`, `--from=NAME` | continue the newest session that tool ran in this directory (imports it on the first start) |
|
|
| `--session DIR`, `--session-id ID` | session directory (default `~/.splinter`) and id (default `sess-<time>-<pid>`) |
|
|
| `--steps N` | tool rounds per turn (default 150) |
|
|
| `--max-bytes N` | request budget in bytes, 0 = no limit |
|
|
| `--autonomous` | run mutating tools without asking |
|
|
| `--no-stream` | wait for the whole reply instead of printing it as it arrives |
|
|
| `--no-stdin` | ignore data on standard input |
|
|
| `--choose TEXT`, `--delegate ID` | print which delegate fits TEXT; run that delegate with `-p TEXT` and print its observation |
|
|
| `--daemon` | answer on Telegram until SIGINT |
|
|
| `--interview` | let the model interview you; writes `USER.txt` |
|
|
| `--mcp-server-listen IP`, `--mcp-listen-port N` | serve MCP with this registry's tools (port 8098; beyond loopback it needs `SPLINTER_MCP_TOKEN`) |
|
|
| `--a2a-server-listen IP`, `--a2a-listen-port N` | serve A2A (JSON-RPC, agent card; port 8099; beyond loopback it needs `SPLINTER_A2A_SERVER_TOKEN`) |
|
|
| `--openai-listen IP`, `--openai-listen-port N` | serve `/v1/chat/completions` with the local `gw_` tools (port 8097) |
|
|
| `--ack ID yes|no`, `--ack-list` | answer a pending approval request, or list them (the files under `~/.splinter/ack`; see `docs/GATEWAY.md`) |
|
|
| `-V, --version`, `-h, --help` | version and this text |
|
|
|
|
`--ack`, `--ack-list` and `--live` are read by the parser but missing from the
|
|
`--help` text (src/main.c:283, :338-352); `--live` is also never used after it is
|
|
set — the command line of this table, `--help` and the manual page are the
|
|
reference.
|
|
|
|
## What it does
|
|
|
|
`splinter -p "list the C files" --endpoint http://127.0.0.1:8080/turn` sends a
|
|
prompt, runs the tools the transport asks for, and prints the answer. Every turn
|
|
is appended to `~/.splinter/<id>.jsonl` as one JSON object per line.
|
|
|
|
## What it refuses to do
|
|
|
|
- Send a request that exceeds the configured byte budget (nothing is sent; the
|
|
turn fails instead of letting an endpoint truncate silently).
|
|
- Run a tool that is not in the registry (the model is told, not guessed at).
|
|
- Run a mutating or destructive tool without operator consent, unless
|
|
`--autonomous` was given.
|
|
- Skip a denial silently: the denial becomes the observation the model sees.
|
|
|
|
## Transport protocol
|
|
|
|
The harness speaks a line protocol with its transport, not a vendor API:
|
|
|
|
request user <text>
|
|
request observe <tool> <output>
|
|
reply answer <text>
|
|
reply tool <name> <arguments>
|
|
|
|
A provider adapter translates an OpenAI-compatible endpoint into this shape and
|
|
back. That is why `make check` needs no network, no key and no model: the mock
|
|
transport replays replies.
|
|
|
|
## Layout
|
|
|
|
The harness is a backend and a set of front ends; `docs/FRONTENDS.md` says
|
|
where the line runs and how to add another one.
|
|
|
|
libsplinter.so every symbol, once; binaries and plugins link to it
|
|
include/splinter.h the core interface
|
|
include/splinter_engine.h the engine a front end talks to (events, turns)
|
|
include/splinter_plugin.h plugin ABI and host API
|
|
|
|
src/backend/engine.c session + agent + turn thread + event queue
|
|
src/backend/agent.c the loop
|
|
src/backend/conv.c the conversation (owned messages, no sharing)
|
|
src/backend/openai.c request shaping + reply parsing, pure functions
|
|
src/backend/transport*.c HTTP, the mock, the vendor shapes
|
|
src/backend/session.c append-only JSONL session
|
|
src/backend/builtin.c read/write/edit/search/list/run/web tools
|
|
src/backend/tool.c the registry
|
|
src/backend/config.c the config file
|
|
src/backend/providers.c -m, /model, pools, failover
|
|
src/backend/plugin.c dlopen loader, widget registry, worker threads
|
|
src/backend/md.c markdown tables as aligned text
|
|
src/backend/telegram.c gateway mode
|
|
src/backend/a2aserver.c the A2A server
|
|
src/backend/openai_server.c /v1/chat/completions with gw_ tools
|
|
src/backend/http.c the HTTP helpers the JSON servers share
|
|
|
|
src/frontend/curses.c transcript, sidebar, prompt
|
|
src/frontend/ui_backend.h what the screen needs from a backend
|
|
src/frontend/ui_local.c that backend as the engine in this process
|
|
src/frontend/ui_remote.c that backend as a socket client (--attach)
|
|
src/frontend/protocol.c splinter --serve: JSON lines on a Unix socket
|
|
src/frontend/client.c splinterctl, the reference protocol client
|
|
src/frontend/ui.h the curses entry point
|
|
src/main.c launcher: parse, config, engine, front end
|
|
|
|
plugins/clock/ example plugin: a sidebar clock + a tool
|
|
vendor/netbsd-curses/ NetBSD curses and terminfo, vendored
|
|
docs/PLUGINS.md the ABI, the threading rules
|
|
docs/PROTOCOL.md the line protocol a GUI client speaks
|
|
docs/GATEWAY.md the OpenAI endpoint and its two tool sets
|
|
tests/ the test binaries, run by `make check`
|
|
docs/splinter.1 manual page
|
|
src/www/index*.html the site, written by hand (de, en, pt_BR)
|
|
|
|
## Front ends
|
|
|
|
The engine is front-end neutral: `sp_engine_submit()` starts a turn on its own
|
|
thread and everything that happens — streamed text, a step's reasoning, a tool
|
|
call, its observation, an approval question, the answer — becomes an event the
|
|
front end drains. The curses interface is one front end; `splinter --serve`
|
|
is another, and it is what a GUI would use.
|
|
|
|
```sh
|
|
splinter --serve # ~/.splinter/splinter.sock
|
|
splinter --serve --socket /tmp/s.sock
|
|
splinter --attach --socket /tmp/s.sock # the curses UI, as a client
|
|
splinterctl --socket /tmp/s.sock --say "list the C files"
|
|
python3 docs/proto-example.py /tmp/s.sock "list the C files"
|
|
```
|
|
|
|
The screen itself is a client in `--attach` mode: it speaks the same lines a
|
|
GUI would, shows the server's session and its transcript so far, runs every
|
|
turn there and switches the server's profiles. That is the proof that the
|
|
protocol carries everything the front end needs; if `--attach` works, a GUI
|
|
has no hidden C dependency.
|
|
|
|
The protocol is one JSON object per line (`ready`, `state`, `stream`, `step`,
|
|
`tool`, `tool_result`, `approval`, `turn`, ...; `input`, `say`, `approve`,
|
|
`cancel`, `steer`, `state`, `quit`, `sessions`, `open`). `docs/PROTOCOL.md`
|
|
has the field list and a sequence diagram; `docs/FRONTENDS.md` has the code
|
|
layout and how to start a GUI on top of it. The socket is `0600` and the server
|
|
checks the peer's uid.
|
|
|
|
The engine keeps more than one session: `sessions` lists the directory, `open`
|
|
switches to an id (or `new`/`last`) and sends the state and history of that
|
|
session. The screen offers the same as `/sessions` and `/open ID`, locally and
|
|
over the socket; a local switch closes the engine and reopens it from the same
|
|
options, because plugins keep process globals. `/sessions` without an argument
|
|
is a picker in two steps: the sources first (`splinter` and every foreign store
|
|
that has sessions), then the sessions of the chosen one. A foreign row carries
|
|
its source in the id (`claude:<id>`), and choosing it imports that session and
|
|
continues it here. A session shows a title - the first user line until
|
|
`/rename [ID] TITLE` says otherwise - and `/rm ID` removes a session that is not
|
|
open. One session is active at a time; over the socket, one client at a time.
|
|
|
|
`--attach` reconnects: if the server dies, the screen says so, keeps running,
|
|
and attaches again when a server is back on the socket - asking for the session
|
|
it was on by id, so the conversation continues where it stopped. If that
|
|
session is gone, it says which one and stays on the server's current session.
|
|
|
|
## Gateway: another harness, splinter's tools
|
|
|
|
`splinter --openai-listen 127.0.0.1` serves `/v1/chat/completions` for another
|
|
harness. The model sees splinter's local tools as `gw_read`, `gw_write`,
|
|
`gw_run`, ... and the caller's own tools under their own names:
|
|
|
|
* a `gw_*` call is executed by splinter, on the host where splinter runs, and
|
|
the caller only sees the final answer;
|
|
* any other tool call is returned to the calling harness, which runs it where
|
|
it runs and sends the results back in the next request.
|
|
|
|
That is how one conversation can act in both places, without a name collision
|
|
between a local `read` and a caller's `read`. Beyond loopback a
|
|
`SPLINTER_GATEWAY_TOKEN` is required, and local mutating tools need
|
|
`--autonomous`. `docs/GATEWAY.md` has the details and examples.
|
|
|
|
The gateway answers one request at a time, so a client that connects and sends
|
|
half a request used to hold it for everyone; an unanswered read now ends after
|
|
60 seconds (`SPLINTER_GATEWAY_READ_TIMEOUT`).
|
|
|
|
## Plugins and themes
|
|
|
|
A plugin is a `.so` against `libsplinter.so`, exporting
|
|
`sp_plugin_describe()`. It can register tools (with authorization classes the
|
|
loop enforces) and widgets. A widget's `tick()` runs on its own thread and
|
|
publishes a line of text, which the sidebar shows; `/widgets` prints the same
|
|
lines into the transcript. See `docs/PLUGINS.md`.
|
|
|
|
The default theme is `Xresources`: it takes `*foreground`, `*background` and
|
|
`*color0`..`*color15` from `xrdb -query` (or `~/.Xresources` without X) and
|
|
paints the UI with them, so the harness looks like the terminal it runs in.
|
|
Without any of those resources it keeps the terminal's own colour indices.
|
|
|
|
Two flat themes are the readable ones: `light` is a white page with black text,
|
|
`dark` the same inverted. The chat, the sidebar and the input line share the
|
|
page colour; only the status line above the prompt is a separate surface (light
|
|
grey on `light`, dark grey on `dark`). That is the shape to reach for when a
|
|
palette leaves the conversation unreadable: `theme = light` in the config or
|
|
`--theme light`.
|
|
|
|
Every CDE palette from the desktop's `.dp` files is a theme as well, 42 of them
|
|
including `Default` and `MakroSlate`. A palette is used the way the desktop
|
|
uses it: set 5 is the chat background, set 4 the input area, set 1 the user's
|
|
lines, set 7 the model's answer, set 3 its reasoning, set 6 tool calls, set 8
|
|
status and session notes, and set 2 observations, with black or white text by
|
|
CDE's own rule. Role colours keep their hue and are moved away from the
|
|
background only when they would disappear into it. `--list-themes` prints the
|
|
names, `--theme NAME` picks one, and `theme = NAME` in the config makes it the
|
|
default.
|
|
|
|
## Talking to a model
|
|
|
|
```sh
|
|
./splinter -p "say hi" --endpoint http://127.0.0.1:8080/v1 \
|
|
--model qwen2.5-coder-7b --api-key-env SPLINTER_API_KEY
|
|
```
|
|
|
|
The adapter shapes the whole conversation into one `chat/completions` request,
|
|
including the tool table, and parses `content` and `tool_calls` back. The
|
|
provider's raw `tool_calls` array is stored verbatim in the conversation and
|
|
sent back unchanged on the next round: re-encoding it would be a silently
|
|
different JSON. `content: null` is an empty answer, not an error; a reply
|
|
without choices, or a provider `error` object, is an error that quotes the
|
|
provider's own message.
|
|
|
|
## Any program as the model
|
|
|
|
```sh
|
|
SPLINTER_CLI_CMD="claude -p" ./splinter -p "hi" --plugin plugins/cli/cli.so --transport cli
|
|
```
|
|
|
|
The `cli` transport runs a program and takes its stdout as the answer, so
|
|
`claude -p`, `opencode run`, `ollama run` or a script can be the brains. The
|
|
OpenAI adapter stays the default for local endpoints.
|
|
|
|
## Claude without the CLI
|
|
|
|
Anthropic speaks its own shape, not `chat/completions`, so it is a transport of
|
|
its own (`kind = anthropic`). It is called over the API with the operator's own
|
|
token -- no `claude` process, no child, nothing to freeze:
|
|
|
|
```
|
|
provider claude-a {
|
|
kind = anthropic
|
|
endpoint = https://api.anthropic.com/v1
|
|
model = claude-sonnet-5-5
|
|
key = "sk-ant-oat01-..." # or key_env = CLAUDE_CODE_OAUTH_TOKEN
|
|
limit = 40/5h
|
|
}
|
|
```
|
|
|
|
A `sk-ant-oat` token (Claude Code) is sent as a Bearer token with the oauth
|
|
beta and Claude Code's first system block, which the API insists on; an
|
|
`sk-ant-api` key goes as `x-api-key`. Tools become `tool_use` blocks and their
|
|
observations `tool_result` blocks; the system prompt is the top-level `system`
|
|
field. Three accounts are three providers and one pool:
|
|
|
|
```sh
|
|
splinter -m claude # the pool: the account with the most room first
|
|
splinter -m claude-a # one account
|
|
splinter -m claude/claude-opus-5-5 # the pool, another of its models
|
|
```
|
|
|
|
`--doctor` checks each one by asking for its model list and reading the local usage record; it never sends a completion request, so it spends no tokens.
|
|
|
|
## Another agent: A2A
|
|
|
|
```sh
|
|
SPLINTER_A2A_URL=https://agent.example/rpc \
|
|
SPLINTER_A2A_TOKEN=... \
|
|
./splinter -p "hi" --plugin plugins/a2a/a2a.so --transport a2a
|
|
```
|
|
|
|
The client half of Agent2Agent: one `SendMessage` over JSON-RPC 2.0 with a text
|
|
part, blocking, and a direct `Message` or a completed `Task` as the answer. In
|
|
the UI the turn streams: `SendStreamingMessage`, artifact text appearing as it
|
|
arrives. The task and context ids are kept for the session, so the next turn
|
|
continues the same A2A context. `SPLINTER_A2A_CARD` discovers the JSON-RPC
|
|
endpoint from an agent card; `SPLINTER_A2A_URL` sets it directly. One-shot mode
|
|
streams by default; `--no-stream` asks for the blocking send.
|
|
|
|
The transport sends text. A file goes with `a2a_send` — a message plus a `file`
|
|
part (base64, 8 MiB cap, media type guessed from the name) — and a file the
|
|
other side sends back is saved (`SPLINTER_A2A_INBOX`, default
|
|
`$TMPDIR/splinter-a2a-inbox`) and named by path in the answer. `a2a_get_task`,
|
|
`a2a_cancel_task` and `a2a_subscribe` (the SSE events of a task, as one text)
|
|
use the same endpoint. Push notifications are not sent by the client.
|
|
|
|
## The other direction: splinter as an A2A server
|
|
|
|
```sh
|
|
SPLINTER_A2A_SERVER_TOKEN=... \
|
|
./splinter --a2a-server-listen 127.0.0.1 --a2a-listen-port 8099
|
|
```
|
|
|
|
Another agent can send `SendMessage` to `POST /a2a` and read `GetTask` or
|
|
`ListTasks`; the
|
|
agent card is served at `/.well-known/agent-card.json`. `SendStreamingMessage`
|
|
streams the answer as SSE artifact updates, then a completed status. A
|
|
`contextId` is a conversation: the next message with it continues. Without one
|
|
the server creates a context and returns it in the task. A
|
|
`taskPushNotificationConfig` in the request posts the completed task to a
|
|
webhook: loopback is always allowed, other hosts need
|
|
`SPLINTER_A2A_PUSH_ALLOW`; the config's token travels as
|
|
`X-A2A-Notification-Token`, its authentication as `Authorization`. Binary
|
|
`file`/`raw` parts are written into the session's `inbox/` and described to the
|
|
model by path (a text model cannot read a PNG, the agent around it can); URL
|
|
parts are fetched from loopback or a host in `SPLINTER_A2A_URL_ALLOW`.
|
|
`SubscribeToTask` replays the stored task state once and ends the stream — the
|
|
server answers one request at a time, so there is no progress to watch. Beyond loopback the bearer token is required;
|
|
there is no TLS, so put it behind ssh or a tunnel.
|
|
|
|
One request at a time means a client that opens a socket and sends nothing
|
|
holds everyone else: the server gives up on an unanswered read after 120
|
|
seconds (`SPLINTER_A2A_READ_TIMEOUT`).
|
|
|
|
## Configuration
|
|
|
|
`splinter` alone starts the chat: endpoint, model, plugins, theme and session
|
|
directory come from `~/.splinter/splinter.conf` (or `$SPLINTER_CONFIG`), written
|
|
in blocks: `core { }`, `provider NAME { }`, `pool NAME { }`. Command line wins
|
|
over the file, the file wins over the built-in default, and an unknown key is
|
|
an error with the line you wrote. Providers (several accounts, usage limits per
|
|
window, pools that balance or fail over) and agent profiles are in
|
|
`docs/CONFIG.md`; `splinter --init-config` writes a commented starter.
|
|
|
|
## Streaming
|
|
|
|
Answers arrive as they are produced, not as one block: the adapter reads SSE,
|
|
appends text deltas to the transcript as they arrive and a tool call as its own
|
|
line, and a reasoning model's own `reasoning_content` is shown dimmed, in
|
|
sequence, instead of being hidden. In one-shot mode the text goes straight to
|
|
stdout as it comes.
|
|
|
|
A data object split across SSE events, a blank line between its lines and a
|
|
truncated trailing fragment are all tolerated: the parser buffers until the
|
|
object is complete and drops a fragment that never is, instead of failing a
|
|
turn that already has its answer. An error object in the stream
|
|
(`data: {"error":{"message":...,"code":...}}`) is not ignored: the message is
|
|
reported and the code becomes the reply's status, so a judge's 400 does not
|
|
turn into "stream ended with no answer" and is not retried as if it were a
|
|
broken connection. `test_sse` feeds recorded lines: plain text, a tool call
|
|
split across three chunks, two calls in one turn, a pretty-printed object
|
|
across events, a truncated tail, an in-stream 400, and the keepalive lines that
|
|
carry nothing.
|
|
|
|
A request that fails before anything was streamed is tried again three times,
|
|
five seconds apart; a broken connection, a missing status, a 5xx and a stream
|
|
that carried no answer qualify, a 401 or 404 does not. After the first streamed
|
|
chunk the retry stops, because printing the same answer twice is worse than
|
|
reporting the provider's error. The wait is visible where the failure happened:
|
|
a status row `retrying in 5 s: ...` joins the transcript below the call, so a
|
|
pause does not look like a hang and nothing is printed into the input line.
|
|
Ctrl-C during a wait ends it at once.
|
|
|
|
A tool call whose arguments are not JSON is a different failure with a
|
|
different answer. Sending the identical prompt asks for the identical broken
|
|
call, so the request is not repeated: the turn appends a user message that
|
|
quotes what came back and says what was wrong with it - a call cut off by the
|
|
output limit is told to be smaller, everything else to be one complete JSON
|
|
object. Five such corrections are allowed, five seconds apart, and each one is
|
|
announced (`broken tool call, trying again in 5 s (2/5)`), so a gateway that
|
|
shows no screen still tells the operator why it is quiet. When the fifth
|
|
correction is spent the turn stops asking for a call at all and asks for words:
|
|
the operator gets what the model wanted to do, step by step, instead of a turn
|
|
that died on "model sent malformed tool arguments".
|
|
|
|
A stream is never cut for being slow: a router may wait minutes for an upstream
|
|
without sending anything but keepalive lines, and a byte-per-second guard cut
|
|
exactly those with "Less than 1 bytes/sec". The overall HTTP timeout is the
|
|
only limit.
|
|
|
|
## Inside tmux
|
|
|
|
When the chat starts under tmux, it names the window and the pane after the
|
|
directory it was started in, with `S: ` in front - `S: kidstube` in one window,
|
|
`S: splinter` in the next. tmux is asked directly (not through a shell, and the
|
|
directory is one argument), and `automatic-rename` is turned off for that
|
|
window so the foreground process does not replace the name. On exit the names
|
|
tmux had before are put back: normal quit, a signal (SIGTERM/SIGHUP/SIGQUIT) and
|
|
the double-Ctrl-C exit all restore them, so the shell prompt does not inherit
|
|
`S:`. Outside tmux nothing is emitted into the terminal.
|
|
|
|
## Colour, measured
|
|
|
|
A CDE palette is eight mid-tones; painted literally, a role can sit a few
|
|
percent away from the background, and nothing is readable. Two safeguards live
|
|
in `theme.c`: text on a surface follows CDE's rule (black on light, white on
|
|
dark), and a role that is too close to the background is pushed away from it
|
|
until it is legible. The push keeps the hue, and each role gets a slightly
|
|
different minimum, so even a monochrome palette yields distinguishable steps.
|
|
The 256-colour path picks the nearest cube or grey-ramp entry instead of
|
|
rounding channels down, which used to turn a dark orange into grey 240.
|
|
`Xresources` themes follow the same rules with colour0..15.
|
|
|
|
The other half was a real bug: `COLORS` was read before `start_color()`, so it
|
|
was 0, the code took the eight-basic-colour path, and the whole palette
|
|
collapsed to white on black.
|
|
|
|
## Screen encoding, measured
|
|
|
|
The vendored NetBSD curses emits Latin-1 bytes for wide characters (`ü` becomes
|
|
`0xFC`); ncurses passes UTF-8 through. So the UI transliterates for display
|
|
(`gruen`), while the conversation and the session log keep the exact UTF-8.
|
|
That is a defect in the ported library, recorded here instead of being papered
|
|
over with a claim that it works.
|
|
|
|
## What you see, and what is on disk
|
|
|
|
The chat draws a transcript: `[time] <you>`, `[time] ~ denkt:` for the model's
|
|
reasoning, `[time] >> Run du -sh ../xsrc` for a tool call, `[time] | output`
|
|
for what the tool returned, `[time] <model>` for the answer. A turn that calls
|
|
tools therefore reads in order: reasoning, text before the call, the call, the
|
|
output, text after it.
|
|
|
|
A call is one row and it says what happened in the words a person would use:
|
|
the tool as a capitalized verb, then its one interesting argument - the command
|
|
of a `run`, the path of a `read`, the pattern of a `search`. No JSON, no
|
|
`command:` in front of the value, and no second copy of the arguments in the
|
|
prompt: the model's encoding is not the reader's business. Call rows are painted
|
|
in the accent colour, their output dim underneath, so a run of shell calls is a
|
|
list of calls and not a grey column of the same word.
|
|
|
|
The same records go to `<session_dir>/logs/<session-id>/session.log`, in the
|
|
order they happened: the user's words, the model's answer, its reasoning, every
|
|
call with its arguments, every observation, failures and token counts.
|
|
`wire.jsonl` next to it keeps the request bodies and replies, raw. The log is
|
|
the complete record - the screen keeps sixteen rows and 4 KiB of a long
|
|
observation, whichever comes first, and says how many lines are left out, so an
|
|
`ls -la` or a 300 KB JSON dump does not bury the conversation; the log has all
|
|
of it.
|
|
|
|
## The input line
|
|
|
|
Up and Down walk through what was typed before, like a shell. The list is kept
|
|
in `<session_dir>/history`, so the next session starts with it.
|
|
|
|
The prompt is a line editor, not an append buffer: Ctrl-A and Home go to the
|
|
start, Ctrl-E and End to the end, Left/Right and Ctrl-B/Ctrl-F move by a
|
|
character (a whole UTF-8 sequence, never a byte), Backspace and Delete remove
|
|
before and at the caret, Ctrl-K cuts to the end, Ctrl-U clears the line and
|
|
Ctrl-W removes the word before the caret. Ctrl-L repaints, Ctrl-C clears the
|
|
line, Ctrl-D quits, Tab completes a `/command` or switches the agent, and
|
|
Shift+Enter inserts a line break. The `steer>` line of a running turn takes the
|
|
same keys and scrolls with its caret, so a long sentence stays readable while
|
|
you type into it. Both prompts used to append every key, which made fixing the
|
|
first word of a sentence mean retyping it.
|
|
|
|
## Steering while a turn runs
|
|
|
|
The turn runs on its own thread, so the keyboard stays live. Every tool call is
|
|
one row in the transcript, in the words of the call itself - `>> Run echo a` -
|
|
because "it did something" is not information. The reasoning is inserted before
|
|
those rows: it came first, and the log should read in the order things
|
|
happened. While it runs, the input line is only `steer> ` and what is typed,
|
|
and the status line above it carries the elapsed seconds as its first meter:
|
|
the call belongs in the transcript, and in the prompt it was a second copy that
|
|
pushed the steer hint off the right edge. Nothing else is written into the
|
|
input line or the status bar; an error is a transcript row below the row that
|
|
caused it, and a backend request that failed before any answer is retried (the
|
|
status row says so). A steer is picked up at the
|
|
next step boundary; in a single-step turn it becomes the next message instead of
|
|
being dropped. A line that starts with `/` or `!` is a command, not a steer:
|
|
`/model` opens the picker at once (the switch is applied between requests, so
|
|
the transport under the running request is never freed), `/status`, `/cost`,
|
|
`/usage`, `/sessions` and `!` answer immediately. `/compact` typed mid-turn is
|
|
remembered and applied when the turn ends - the moment you want it is the moment
|
|
a big conversation has a turn running - and `/new`, `/agent` and `/connect`
|
|
say "not while a turn runs" instead of being sent to the model. Curses is only
|
|
ever touched by the UI thread.
|
|
|
|
A name is not text: `SP_STREAM_TOOL` carries the name of a call that has begun,
|
|
and the answer text is built from `SP_STREAM_TEXT` alone. The stream used to be
|
|
classified by looking for `tool_calls` in the raw line, which broke as soon as
|
|
the provider sent `"content":null` beside the call - the name landed in the
|
|
answer and two `read` calls were printed as `<model> readread`. The kind now
|
|
comes from the parser (`sp_sse_kind`).
|
|
|
|
## Compaction
|
|
|
|
When the conversation outgrows the window, the core compactor replaces the older
|
|
part with a digest: each operator message keeps its opening, each assistant turn
|
|
what it claimed to be doing, each tool result enough to recognise it — in order,
|
|
because the thread is the point. The newest messages stay verbatim, and the last
|
|
real user message is pinned so a long tool loop cannot push the task out. A
|
|
plugin that compacts too runs first; the core one is the backstop.
|
|
|
|
What it drops is not gone. The digest opens with a line saying where it went,
|
|
and the model has `history_search`, which searches the whole session by meaning
|
|
— not just what is quoted in the digest. The index is built by a background
|
|
thread, never inside the turn, so the turn does not pay for it (28 ms on a
|
|
937 KB session). `core { embed = local }` is the default: a built-in CPU
|
|
encoder, no model, no key. `embed = openai` points it at a real embedding model
|
|
instead, `off` takes the tool away. See `docs/CONFIG.md`.
|
|
|
|
`focus` keeps a short recap of the session's goal in front of the model every
|
|
seven turns — one inserted system message, never twice in a turn, nothing until
|
|
a goal is set. `/goal <text>` sets the goal and starts that recap turn; the
|
|
model's answer is remembered and injected later. The goal is stored in the
|
|
session's `.meta`, so a resumed session finds it; `/continue` starts the next
|
|
turn from it. `/goal` alone shows it. There is no separate `/recap`: recapping
|
|
is what a goal does. Both work in the TUI and with `-p`.
|
|
|
|
`/self-check` is the one to type when a turn went nowhere: it hands the model
|
|
the last three turns it ran, every failed tool result in them and the last
|
|
turn's error, with the instruction to find its own mistake and continue. It
|
|
takes no arguments and runs as an ordinary turn, so it works in the TUI, with
|
|
`-p` and over the socket.
|
|
|
|
`/learn` is the one to type when the work is done and nothing was written down.
|
|
It sends a turn that reads the sessions of this folder — splinter's own with
|
|
`session_list` and `session_search`, the other harnesses' with `foreign_list`,
|
|
`foreign_search` and `foreign_read` — and asks for what stays true after today
|
|
to be kept where it can be found again: a skill for a procedure that worked, a
|
|
memory for a decision or a measurement, a wiki page for an explanation, a task
|
|
for work still open. Without an argument it covers every session of the folder
|
|
and the prompt lists them, newest first; with one (`/learn the gateway retry`)
|
|
it covers that topic and nothing else. It runs as an ordinary turn, so the same
|
|
command works in the TUI, with `-p` and over the socket. Which session tools
|
|
the prompt names depends on what the engine actually loaded; for storing, the
|
|
prompt names the write tools the registry has (`mcp_junction_skilld__skill_create`
|
|
and its siblings), and when there are none yet — an MCP server connects in the
|
|
background — it names their shape and says to read the tool list first. Both
|
|
came out of live runs: without the names the model greps the filesystem for a
|
|
server binary, and a prompt that says "you have no write tool" while skilld is
|
|
still dialling is a lie the model then acts on.
|
|
|
|
## Languages
|
|
|
|
UI strings live in `share/locale/<lang>.msg`, plain `key = text` files read at
|
|
startup — no gettext, no `.mo`, nothing to build. The language comes from
|
|
`locale` in the config, else `SPLINTER_LOCALE`, `LC_ALL`, `LC_MESSAGES`, `LANG`.
|
|
A missing translation falls back to English; a key that exists nowhere is shown
|
|
as itself, so nothing is silently empty. `test_i18n` fails if `de.msg` misses a
|
|
key that `en.msg` has.
|
|
|
|
Ships with `en` and `de`. Plugins translate their own strings with `sp_t()`.
|
|
|
|
## Hosts: one fleet
|
|
|
|
A delegate may name a host. The whole invocation then goes through ssh, so
|
|
claude, opencode or another splinter run where the model or the network is:
|
|
|
|
provider remote {
|
|
about = "on a remote host"
|
|
tags = [remote]
|
|
host = build.example.org
|
|
endpoint = http://10.0.0.2:8080/v1
|
|
model = ...
|
|
}
|
|
|
|
delegate and delegate_parallel both honour it, and the report names the host like
|
|
any other model. The remote needs splinter at the same path and its own keys -
|
|
nothing crosses the jump except the task.
|
|
|
|
Proven: a delegate with host=build.example.org ran on the remote host and answered from a
|
|
provider reachable only over the wireguard link.
|
|
|
|
A failing delegate can be run without a model, which is how the child's own
|
|
error text and exit status are inspected:
|
|
|
|
./splinter --delegate claude0 -p "sage nur: beta"
|
|
|
|
The observation carries the delegate line, the child's exit status and the task
|
|
or job state; no model turn, no transport.
|
|
|
|
## A fleet in one directory
|
|
|
|
`src/swarm.c` is the local variant. The first splinter started in a directory
|
|
binds `.splinter-swarm.sock` and becomes the master; later ones join as slaves.
|
|
`/swarm <text>` sends a line to the least busy peer, `/swarm <id> <text>` picks
|
|
one, `/swarm ls` lists them, and a routed command runs there. It is IPC between
|
|
processes that share a working directory — not A2A, and not a network protocol.
|
|
|
|
## First run: the interview
|
|
|
|
splinter --interview
|
|
|
|
No questionnaire: the model talks to you. Its system prompt says to get to know
|
|
you - what you work on, the tools you reach for, how you want to be spoken to,
|
|
what you never want - one question at a time, and to end with a compact summary
|
|
followed by the single line `INTERVIEW_COMPLETE`.
|
|
|
|
That summary is written to `~/.splinter/USER.txt` (0600) and put into the system
|
|
prompt of every later session, so the harness starts out knowing who it is
|
|
working with. The marker itself never reaches the file or the transcript. The
|
|
interview needs a provider like any chat; Telegram has the same `/interview`,
|
|
with the conversation in the chat.
|
|
|
|
An installation from before `USER.txt` still has `~/.splinter/profile/<user>.md`;
|
|
it is read as the fallback until the first new interview. Starting the chat
|
|
without either prints a hint, once.
|
|
|
|
## Piped input
|
|
|
|
cat /etc/passwd | splinter "explain the file"
|
|
|
|
Anything on standard input becomes context, framed and labelled with its size:
|
|
|
|
[stdin: 12 bytes]
|
|
...
|
|
[/stdin]
|
|
|
|
The question and the bytes are kept apart, so the model knows which is which. A
|
|
binary input is reported as binary instead of being sprayed into the request, the
|
|
size is capped at 192 KiB (with `[truncated]`), and `--no-stdin` ignores the pipe
|
|
entirely. With no prompt at all, the input becomes the prompt.
|
|
|
|
## Gateway mode
|
|
|
|
`--daemon` turns splinter into a Telegram bot: long-poll `getUpdates`, one turn
|
|
per message, reply. No curses, no terminal.
|
|
|
|
~/.splinter/telegram.token the token, mode 0600 (or SPLINTER_TELEGRAM_TOKEN)
|
|
telegram_allow = 8300935 who is answered, comma separated; nobody by default
|
|
|
|
The token is read from a file or the environment and never from an argument, and
|
|
the message loop keeps no state on disk beyond the session: a restart re-delivers
|
|
the last update, which costs one duplicated answer and never a lost message.
|
|
Signature handling is the session's business, not the gateway's.
|
|
|
|
A bot cannot start a conversation - the user has to write first, otherwise the
|
|
API answers `chat not found`. That is Telegram, not the harness.
|
|
|
|
The bot registers the commands that actually exist with `setMyCommands`:
|
|
`/start`, `/help`, `/interview`, `/new`, `/model`, `/connect`, every command a
|
|
loaded plugin registers
|
|
(`/goal`, `/quota`, ...) and every program in
|
|
`~/.splinter/commands/` whose name is a valid Telegram command (lower-case,
|
|
digits, underscore, at most 32). `/start` and `/help` answer with the short
|
|
text plus that live list. An approval arrives as a message with **Yes/No
|
|
buttons**; the callback answers the button, removes the buttons and writes the
|
|
ack file. The text form `ok <id>` / `no <id>` still works.
|
|
|
|
The model's markdown is rendered as Telegram HTML: bold, italic, strike,
|
|
inline code, fenced blocks, links (also `<https://…>`) and quotes become tags,
|
|
everything else is escaped. An image is sent as a photo with the alt text as
|
|
caption: `` is fetched by Telegram, `` (or
|
|
`file:///…`) is uploaded from this machine. A local file that is not an image
|
|
goes out as a document (`sendDocument`, at most 50 MiB). The photo guard still
|
|
checks the bytes — PNG/JPEG/GIF/WebP up to 10 MiB — so a text file cannot ride
|
|
in as a photo; a missing or unreadable file stays a reference in the chat.
|
|
Images inside code or a table stay text. Tables are laid out as columns inside a `<pre>` block. A long answer
|
|
is split at tag boundaries, with the open tags closed and reopened per
|
|
message, and a piece Telegram refuses to parse is sent as plain text instead.
|
|
`SPLINTER_TG_MARKDOWN=0` turns the rendering off.
|
|
|
|
`/compact [tokens]` runs the compactors now (default target: `compact_target`,
|
|
else 8000 tokens) and reports messages/bytes before and after. Typing it while
|
|
a turn runs does not lose it: the request is queued and applied when that turn
|
|
ends, which is exactly the moment a large context makes you reach for it. The
|
|
`lcm` widget in the sidebar keeps the running numbers (context, compactions,
|
|
messages cut, last cut in messages and bytes, trimmed tool outputs), and the
|
|
status line carries a `compact N` segment. With
|
|
`compact_threshold` set, the harness compacts automatically once the last
|
|
request was larger than that: the conversation is cut to `compact_target`
|
|
before the next turn, so the context never grows without bound. The size it
|
|
judges is the `prompt_tokens` the provider reports, so every streamed turn
|
|
sends `stream_options.include_usage` - a provider that follows the OpenAI
|
|
contract returns no `usage` otherwise and the threshold would never fire.
|
|
Compaction rewrites the prompt prefix, which invalidates the provider's prompt
|
|
cache - the threshold is the knob that trades cache hits for a smaller context.
|
|
What was dropped stays in the session log, and the `recall` tool searches it:
|
|
the model can look an earlier turn up instead of guessing.
|
|
|
|
The `session` plugin reaches further back: `session_search` finds text in the
|
|
logs of earlier sessions that ran in this working directory (with date, session
|
|
id, title and a snippet) and `session_list` shows them. Sessions from other
|
|
folders are left out. When the working directory has history,
|
|
the system prompt says so and tells the model to look there before asking the
|
|
user something that was already answered.
|
|
|
|
`/cost` reports what the session has cost: provider-reported dollars (if the
|
|
provider puts `cost` in its usage object), tokens, and the cache share of the
|
|
last request. It splits turns into `judged` and `plain`, because a judged model
|
|
is an upstream alias that runs a judge first: the provider's usage object
|
|
carries only the final answer, so the judge's own tokens and dollars are not in
|
|
these numbers. What is measurable is the difference in latency and reported
|
|
tokens per turn. The sidebar's cost segment prefers the reported dollars over
|
|
list-price arithmetic.
|
|
|
|
`/new` (or `/reset`) starts a fresh conversation and a fresh session file; the
|
|
old one stays on disk, and the system prompt is put back.
|
|
|
|
`/model` lists the models the config names (the core endpoint, every delegate
|
|
with a model, every exit) as buttons and points the running transport at the
|
|
one you press. The choice is written to the session's sidecar
|
|
(`<session>.model`) and comes back when that session is opened again, so one
|
|
conversation can sit on a different model without changing what a new one
|
|
starts on. `/model <name>` keeps the endpoint and takes another model from it.
|
|
`/model probe` asks the configured endpoints `/v1/models` and lists what they
|
|
really serve.
|
|
|
|
In the curses chat, `/model` alone opens a picker: Up/Down move, typing filters
|
|
by provider or model, Enter takes the highlighted selector, Esc cancels. The
|
|
rows are the full selector (`junction/qwen3.6-35b-judged`);
|
|
`-m provider/model` does not invent a second row for the same endpoint. After
|
|
the configured list appears, the picker asks the endpoint this session is on
|
|
what it serves and adds those models, so a router's whole menu is selectable
|
|
and not only the one alias in the config. It is the same list the clients get
|
|
from the `models` protocol command (with `probe`), so `--attach`
|
|
has it too, and the actual switch is still the ordinary `/model <selector>`
|
|
command.
|
|
|
|
`/connect` works the same in the TUI, one answer per line. It adds a provider
|
|
in four answers — name, endpoint, model, key
|
|
variable (or `-` for none); `ollama` and `opencode` stand for their usual
|
|
endpoint. It writes the line to `<config>.d/20-connect.conf`, so the next start
|
|
has the provider too, runs one tiny turn against it to prove endpoint, model
|
|
and key work, and offers to use it right away.
|
|
|
|
`/interview` starts the same model-driven interview as `splinter --interview`
|
|
in the chat; `/new` leaves it. A program in
|
|
`commands/` answers in the chat: its output is the reply. In the
|
|
TUI the same program's output becomes context for the model instead. A typo
|
|
such as `/nosuch` is answered with the command list, not sent to the model.
|
|
|
|
`docs/splinter-gateway.service` is a systemd user unit if it should survive a
|
|
logout.
|
|
|
|
## The exit ring
|
|
|
|
`plugins/ring/ring.so` holds several ways to reach a model and walks them in
|
|
order when one is rate limited:
|
|
|
|
exit = go | OpenCode Go | endpoint=... | model=...
|
|
exit = groq | Groq free tier | endpoint=... | model=... | key_env=GROQ_KEY
|
|
exit = local | local | endpoint=... | model=...
|
|
|
|
Run it with `--transport ring`. Only pressure moves the ring: 429, 5xx, "rate
|
|
limit", "quota". A dead host or a bad key stops the turn where it is - a ring
|
|
that treats every failure as "try the next" hides real breakage behind a random
|
|
provider. Proven against two fake providers: the first answered 429, the ring
|
|
moved on and the second answered; a dead port did not move it.
|
|
|
|
## Providers from the environment
|
|
|
|
Nothing to configure if the keys are already there:
|
|
|
|
OLLAMA_KEY OLLAMA_KEY_0 .. OLLAMA_KEY_N
|
|
CLAUDE_CODE_OAUTH_TOKEN CLAUDE_CODE_OAUTH_TOKEN_0 .. _N
|
|
|
|
Each Ollama key becomes a delegate *and* an exit in the ring, with the endpoint
|
|
from `OLLAMA_ENDPOINT` (default `https://ollama.com/v1`) and the
|
|
model from `OLLAMA_MODEL`. Each Claude token becomes a `cli` delegate that runs
|
|
`claude -p`. Several keys mean several accounts, and the ring uses them in order.
|
|
|
|
The keys are copied into memory and passed to children through the environment -
|
|
never on a command line, never into a log.
|
|
|
|
$ OLLAMA_KEY=... CLAUDE_CODE_OAUTH_TOKEN=... splinter --choose "plane die arbeit"
|
|
claude-3 score=4 prio=10 task mentions 'plan'
|
|
$ OLLAMA_KEY=... splinter --choose "implementier das"
|
|
ollama-2 score=3 prio=0 task mentions 'implement'
|
|
|
|
Parallel handover uses `delegate_parallel` with a list of tasks - each picks its
|
|
own model, up to eight run at once, and the answers come back labelled:
|
|
|
|
[parallel: 2 task(s), 12018 ms wall]
|
|
|
|
## task 1 | model slow | score 5 | 12018 ms | exit 0 | 75 B | requested tag 'slow'
|
|
> sag A
|
|
...
|
|
|
|
## task 2 | model fast | score 5 | 16 ms | exit 0 | 74 B | requested tag 'fast'
|
|
...
|
|
|
|
## summary
|
|
- slow: 1 task(s), 12018 ms total
|
|
- fast: 1 task(s), 16 ms total
|
|
|
|
The summary gets who did what, how long it took and whether it worked - not a wall
|
|
of answers. A delegate that is slow or failing is visible in the header before
|
|
anybody reads its prose.
|
|
|
|
`max_parallel` still applies: a delegate that is full skips the task with a note
|
|
instead of queueing it.
|
|
|
|
That is the workflow the tool is built for: a strong model plans and defines the
|
|
work, the local models implement it, and `delegate` is the handover.
|
|
|
|
## Delegation
|
|
|
|
Work can be handed to another model. A delegate is a `provider` block in the
|
|
config - no profiles, no directories, nothing to keep in sync:
|
|
|
|
provider coder {
|
|
about = "C99, POSIX, knows the source tree"
|
|
tags = [code, c99, review]
|
|
prio = 5
|
|
max_parallel = 2
|
|
endpoint = http://127.0.0.1:8080/v1
|
|
model = Qwen3.6-35B
|
|
}
|
|
provider quick { about = "short answers" tags = [chat, cheap] endpoint = ... model = ... }
|
|
|
|
Which provider takes a task is decided by words, with synonyms (docs/CONFIG.md,
|
|
"How a task finds its provider"); a private task only goes to a provider tagged
|
|
`private`.
|
|
|
|
`prio` breaks ties (higher wins), `max_parallel` caps how many calls may run on
|
|
one delegate at once - a busy delegate answers "busy", it does not queue
|
|
silently. `kind=cli` and `cmd=claude -p` turn a delegate into a program instead
|
|
of an endpoint.
|
|
|
|
The `delegate` tool takes a task and, optionally, tags. splinter picks the model
|
|
itself: a requested tag counts 5, a tag found in the task 3, a word of the
|
|
description 1. The observation starts with the choice and the reason, so a wrong
|
|
pick is visible instead of mysterious:
|
|
|
|
[delegate coder, score 7: task mentions 'code']
|
|
|
|
`--choose "text"` prints that decision without running anything:
|
|
`coder 7 task mentions 'code'`. The child is splinter in one-shot mode with its
|
|
own context; the tool is classed destructive, so the operator approves the
|
|
delegation once.
|
|
|
|
## Resuming
|
|
|
|
`--resume` loads the newest session in the session directory back into the
|
|
conversation and puts it on screen. It continues that session id rather than
|
|
opening a fresh one beside it - the first version did the latter, which looked
|
|
like a resume and was none. The agent profile comes back too: the engine keeps
|
|
the session's profile in `<session>.agent`, so a session left in plan resumes
|
|
in plan; the model it was left on is in `<session>.model` and comes back too.
|
|
|
|
## Foreign sessions: claude, hermes, opencode
|
|
|
|
`splinter --plugin plugins/foreign/foreign.so` reads the three session stores
|
|
that already exist on the machine and can adopt one of their conversations:
|
|
|
|
| source | what it reads |
|
|
|------------|--------------------------------------------------------|
|
|
| `claude` | `~/.claude/projects/<slug>/<id>.jsonl` (Claude Code) |
|
|
| `hermes` | `<root>/state.db` and `<root>/profiles/*/state.db` |
|
|
| `opencode` | `~/.local/share/opencode/opencode.db` (`session_v2`) |
|
|
|
|
The roots are `SPLINTER_FOREIGN_CLAUDE`, `SPLINTER_FOREIGN_HERMES` (a comma
|
|
list, one root per store) and `SPLINTER_FOREIGN_OPENCODE` (the database file
|
|
itself), or the plugin's own block in the config, which also loads it:
|
|
|
|
plugin foreign {
|
|
claude = ~/.claude/projects
|
|
hermes = ~/.hermes, ~/.hermes-work
|
|
opencode = ~/.local/share/opencode/opencode.db
|
|
}
|
|
|
|
Four tools — `foreign_list`, `foreign_search`, `foreign_read`, `foreign_import`
|
|
— and the `/foreign` command:
|
|
|
|
/foreign list what is there, per store
|
|
/foreign search TEXT full text, with role and session id
|
|
/foreign read SOURCE ID one transcript, tool calls in place
|
|
/foreign import SOURCE ID adopt it as a splinter session
|
|
|
|
### Continuing another tool's session from the shell
|
|
|
|
The case this was built for: a Claude session hit its limit mid-thought and the
|
|
conversation has to go on *here*.
|
|
|
|
splinter -c --claude
|
|
|
|
`--claude` (likewise `--opencode`, `--hermes`, `--from=NAME`) finds the newest
|
|
session that tool ran in **this** directory, imports it and continues it —
|
|
the import happens before the history is loaded, so the first turn already
|
|
carries it. `-c` is not needed for that: `--claude` resumes by itself. What
|
|
`-c` adds is the fallback — with it, a directory that has neither a foreign
|
|
nor a splinter session is still an error that says so, instead of an empty
|
|
start.
|
|
|
|
A second start does not import again: the imported session carries
|
|
`foreign=<source>:<id>` in its sidecar, and that is what the next `-c --claude`
|
|
finds and continues. Importing again would replace the file and throw away
|
|
everything the conversation did in splinter since. The empty placeholder a run
|
|
opens before it knows what it continues is removed; a session that already had
|
|
content never is.
|
|
|
|
The plugin has to be loaded — either `plugin foreign` in the config, or
|
|
`--plugin plugins/foreign/foreign.so`. Without it the option says so by name
|
|
instead of silently starting a fresh session.
|
|
|
|
`import` writes a real splinter session and says so: the conversation as a
|
|
replayable `.jsonl`, and a `.meta` with the source's title, its start time and
|
|
**its** working directory, not the one you imported from. So `/open <new id>`
|
|
continues it in the chat and `--session-id <new id> --resume` in a shell; `-c`
|
|
finds it in the directory the conversation actually ran in. The new id carries the origin (`fcl-`, `fhm-`,
|
|
`foc-`), and the sidecar keeps `foreign=<source>:<id>` — a key the core does not
|
|
own, so it is carried through every later reopen.
|
|
|
|
Three limits worth knowing. The stores are read with `sqlite3 -readonly`, so
|
|
splinter never writes into them — an import copies, it does not move. Reasoning
|
|
blocks are dropped on the way in: a provider does not accept another model's
|
|
thinking as evidence. And the tool calls arrive with their results in place,
|
|
which is what makes the imported session worth resuming instead of retyping:
|
|
every `tool_calls` the source recorded is kept with the call id, and every
|
|
result is kept with the same id, so the pairing a provider insists on survives
|
|
the import (an imported claude session of 3436 messages reaches the model with
|
|
its 1630 calls and 1630 results).
|
|
|
|
## MCP
|
|
|
|
`plugins/mcp/mcp.so` speaks MCP to a server and registers its tools. The config
|
|
names the servers; two transports, one block each:
|
|
|
|
mcp junction {
|
|
url = http://172.25.206.16:8090/mcp
|
|
header = "Authorization: Bearer ${JUNCTION_TOKEN}"
|
|
}
|
|
mcp files {
|
|
cmd = "npx -y @modelcontextprotocol/server-filesystem /home"
|
|
}
|
|
|
|
`url` is the streamable-HTTP transport: one POST per JSON-RPC message, answered
|
|
with one JSON object or with an SSE stream of `data:` lines - both are read, and
|
|
the `Mcp-Session-Id` a server hands out is echoed back. `cmd` starts a program
|
|
whose stdin/stdout carry the same messages. A header travels to curl through its
|
|
stdin config, so the token is never in `ps`.
|
|
|
|
Each tool keeps the schema the server published, so the model sees its
|
|
parameters; the class is `mutate`, because a server can do anything and the
|
|
harness does not pretend to know better. With one server the tools are
|
|
`mcp_<tool>`; with several, `mcp_<server>_<tool>`. Proven against both: a stdio
|
|
test server (the model called `mcp_add(17, 25)` and answered 42) and a socket
|
|
server that speaks HTTP and SSE.
|
|
|
|
The sidebar names every server and says whether it is connected
|
|
(`junction connected`, `files disconnected`), rather than only counting the
|
|
tools they offered.
|
|
|
|
The one-server form from before still works:
|
|
|
|
SPLINTER_MCP_CMD="npx -y @modelcontextprotocol/server-filesystem /home" \
|
|
splinter --plugin plugins/mcp/mcp.so
|
|
|
|
The other direction, splinter as the server, is `--mcp-server-listen IP`:
|
|
newline-delimited JSON-RPC over TCP, read tools only unless `--autonomous`.
|
|
On 127.x it needs nothing; on any other address it refuses to start without
|
|
`SPLINTER_MCP_TOKEN`, and every connection must begin with the line
|
|
`AUTH <token>`. There is no TLS: across a network you do not own, tunnel it.
|
|
|
|
SPLINTER_MCP_TOKEN=$(cat ~/.splinter/mcp.token) \
|
|
splinter --mcp-server-listen 0.0.0.0
|
|
(echo "AUTH $(cat ~/.splinter/mcp.token)"; cat requests.jsonl) | nc host 8098
|
|
|
|
Beside the file tools the server offers the session tools, so another agent can
|
|
work with splinter itself:
|
|
|
|
splinter_sessions list the sessions (current marked)
|
|
splinter_state model, endpoint, profile, session, busy, tokens
|
|
splinter_models the selectors /model takes
|
|
splinter_agents the profiles
|
|
splinter_history the open session's user and assistant messages
|
|
splinter_say send a prompt, wait, return the answer
|
|
splinter_open switch to a session (id, new, last)
|
|
splinter_model switch the model (any /model selector)
|
|
splinter_agent switch the profile by name
|
|
splinter_steer type into the running turn
|
|
splinter_cancel cancel the running turn
|
|
splinter_approve answer a pending approval (allow true|false)
|
|
|
|
`say` starts a real turn, so the server needs a provider: give it `-m` (or run
|
|
`--daemon --mcp-server-listen`, where the Telegram daemon and the MCP server
|
|
share one engine). A turn that parks on an approval is returned as the
|
|
question, not as a failure; `splinter_approve` answers it. The first line of
|
|
`splinter_say` is the answer, then the step and tool-call counts.
|
|
|
|
## Tools
|
|
|
|
Every tool declares its class, and the loop enforces it - never the model, never
|
|
the prompt.
|
|
|
|
- `read` (read): numbered lines, offset and limit, refuses binary files, says
|
|
where it stopped.
|
|
- `search` (read): literal string over a directory tree, capped at 100 hits.
|
|
- `list` (read): a directory.
|
|
- `write` (mutate): writes a file, up to 4 MiB. The new text goes to a sibling
|
|
`.tmp`, is flushed and renamed over the target, so a full disk or a crash can
|
|
never leave the old file truncated. A symlink is followed and stays a link;
|
|
the mode of an existing file is kept, and a file the operator made read-only
|
|
is still refused (`Permission denied`) instead of being replaced.
|
|
- `edit` (mutate): replaces exactly one occurrence; a non-unique `old` is an
|
|
error, because an ambiguous edit is a wrong edit waiting to happen. Written
|
|
the same way as `write`, atomically. A read error is reported instead of
|
|
being taken for the end of the file.
|
|
- `run` (destructive): a shell command; the exit status is an observation.
|
|
Its own process group, stdin `/dev/null`, an environment without splinter's
|
|
API keys and tokens, so `run env` cannot hand them to the model. It is killed
|
|
after `SPLINTER_RUN_TIMEOUT` seconds (default 600, or `run_timeout` in the
|
|
config) **without output**: every line on stdout or stderr resets the window,
|
|
and the process itself is checked before it is extended, so a long build that
|
|
reports progress is not killed for being long.
|
|
- `webfetch` (mutate): http(s) only, curl started without a shell. Not read:
|
|
a URL the model picks is a message out of the machine.
|
|
- `echo` (read), `clock` (read).
|
|
|
|
Mutate and destructive tools ask first, unless `--autonomous` is set. In the
|
|
chat the question sits where the prompt is, worded like the transcript row -
|
|
`Run touch x (destructive)? y/N` - and the turn waits on it; `n` or Esc
|
|
denies, and the model is told
|
|
`error: denied by operator`. This used to be dead code in the TUI: the prompt
|
|
read stdin behind curses' back, so with `--autonomous` off every such tool was
|
|
silently denied.
|
|
|
|
## Shell escape
|
|
|
|
`!command` runs it here and puts the output into the conversation, so the model
|
|
sees what the operator saw. Capped at 4 KiB: a runaway command must not eat the
|
|
budget in one keystroke.
|
|
|
|
## Slash commands
|
|
|
|
A leading `/` never reaches the model: the UI asks the host, the host asks the
|
|
plugins. A plugin registers what it handles (`/goal` today); an
|
|
unknown command lists what exists instead of being sent as a prompt.
|
|
|
|
Compaction is a plugin, not a switch in the loop. Two ship here: `lcm`
|
|
(deterministic front-trim with an in-band system message saying what went) and
|
|
`cps` (continuous parallel compression: plans are prepared on a worker thread
|
|
from an index of the conversation, then spliced in instantly). Details and the
|
|
ABI in `docs/PLUGINS.md`.
|
|
|
|
## Limits, stated
|
|
|
|
- Tool arguments reach the tool as one string; each tool validates its own.
|
|
- MCP tools are all `mutate`, so they ask before they run.
|
|
- The ring only retries on rate limits; a 500 from a broken endpoint also counts
|
|
as pressure, so a provider that fails hard gets skipped rather than fixed.
|
|
- No retrieval tiers over old sessions. Compaction is a plugin (lcm); it cuts the
|
|
conversation, it does not remember what it cut.
|
|
- A `tick()` that never returns hangs the exit: the host can stop a thread only
|
|
between ticks, not inside one.
|
|
- Plugins are not sandboxed. They run in the process with full rights; the
|
|
authorization classes protect the harness from the *model*, not from code you
|
|
chose to load.
|
|
|
|
## License
|
|
|
|
BSD-3-Clause.
|