The default prompt says what the code cannot: read the documentation before you
build - README, AGENTS, man pages, the source itself - because a hack that works
against the documented way is a bug with good timing. Also: check what exists,
change the approach instead of repeating a failure, evidence over claims, never
invent output, answer briefly.
Placeholders {{os}}, {{home}}, {{cwd}}, {{model}} are filled at startup, so the
model is told which machine it is on instead of asking.
plugins/reminder puts five short rules back into the conversation every tenth
turn (SPLINTER_REMINDER_EVERY), in front of the newest user message. A rule read
once and buried under forty thousand tokens has stopped existing; one that comes
back is still a rule.
The bug that made both pointless: ag.host was never set, so sp_host_compact was
never called by the real binary. Every compactor - lcm, focus, reminder - was
registered, tested in isolation, and dead in production. 'Compaction happens
before the budget is judged' was true only in the tests.
Verified: with SPLINTER_REMINDER_EVERY=1 the request body contains [reminder]
(checked in wire.jsonl), and the system prompt arrives with the OS and no
leftover {{...}}.
Skills: ~/.splinter/skills plus any skills_dir from the config. Nothing is
preloaded and the system prompt does not grow - the model asks:
skill_search {query} returns names, one-line descriptions and paths;
skill_load {name} returns the file. Both read-only. A miss says what exists
instead of answering with silence.
Memory: memory_search and memory_add against mem0's REST API. Every request
carries user_id, taken from the account the process runs as ($USER, else the
passwd entry) - deliberately not a config key, because a setting is a thing to
forget and the process already knows who it is. A memory written by root is
invisible to lotherk.
Gateway: it ran without a stream callback, so a provider that only speaks SSE
answered with a stream the non-streaming reader could not parse. It now passes a
no-op callback - nobody to stream to, but the transport takes the streaming path.
tests: test_skills (search, directory form, miss, load, unknown name) and
test_memory (user id from environment and fallback).
Sending 'typing' every four seconds while a turn runs was in the code and never
on the screen: the API base became overridable and the URL format lost the token
on the way, so the gateway could not poll at all. Fixed, and proven against a
fake Telegram API with a slow provider behind it:
get /bot.../getUpdates
typing 00s, 04s, 08s, 12s (one per four seconds, whole turn)
message <answer> (typing stops with the turn)
SPLINTER_TELEGRAM_API now overrides the API base, because a gateway you can only
test in production is a gateway you test in production.
Logs: every session keeps ~/.splinter/logs/<id>/session.log (readable, in order,
nothing truncated) and wire.jsonl (request bodies and replies). The agent records
the user's words, the answer, the reasoning, every tool call with arguments,
every observation, failures, and the transport records the wire.
Slash programs: anything executable in ~/.splinter/commands/ becomes /name. It
gets the rest of the line as one argument and its output goes to the *model* as
context, not to the operator as a reply. Two bugs found by trying it: the
directory was derived from --session (so a session elsewhere found nothing), and
the whole slash branch only ran when a plugin host existed, so without plugins
/uptime was never even looked at.
Telegram: a typing thread sends sendChatAction every four seconds while a turn
runs - and only while a turn runs, not while a plugin answers a slash command.
The gateway no longer appends to the session twice (the agent already does).
docs/ROADMAP.md lists what is still open, in the order it should be done.
--daemon long-polls getUpdates, runs one turn per message and replies. The token
comes from ~/.splinter/telegram.token (0600) or SPLINTER_TELEGRAM_TOKEN, never
from an argument: arguments end up in ps and in shell history.
telegram_allow lists who is answered, comma separated, nobody by default - an
empty list is a refusal, not an open door. Unknown senders are logged without
their text.
The loop survives a failed request instead of dying on it, and keeps no state
beyond the session: a restart re-delivers the last update, which costs one
duplicated answer and never a lost message.
test_telegram covers the token paths (file wins, environment as fallback, empty
file is not a token). Verified against api.telegram.org: the token works and
getMe answers hbx_splinter_bot. Sending needs the user to write first - a bot
cannot start a chat, the API says 'chat not found'.
The config moved to ~/.splinter/splinter.conf - next to the sessions, where the
state of this thing already lives - and every *.conf in the directory named after
it is read after it, in name order. A later file overrides an earlier one, an
unknown key is still fatal, and the error now names the file it came from.
plugins/ring is the exit ring: several ways to reach a model, walked 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 | kontron, lokal | endpoint=... | model=...
Only pressure moves the ring - 429, 5xx, 'rate limit', 'quota'. A dead host or a
bad key stops the turn, because a ring that treats every failure as 'try the
next one' hides real breakage behind a random provider.
Two things had to be fixed underneath: sp_openai_transport kept its context in a
static variable, so building several transports pointed them all at the last one
(now one heap context per transport), and plugins had no way to read the config
or the registry (sp_host_config, sp_host_registry).
Measured against two fake providers: the first answers 429, the ring moves on and
the second answers 'Antwort vom zweiten Ausgang.'; a dead port does not move it
and the error stands.
A delegate is a line in the config - id, what it is good at, tags, endpoint,
model. No profiles: a profile is a directory of files, and this needs a line you
can read at 2 a.m.
The delegate tool takes a task and optional tags. The pick is code, not a guess:
requested tag 5, tag in the task 3, description word 1, ties to the earlier
entry. The observation opens with the choice and the reason, and --choose prints
the same decision without running anything:
coder 7 task mentions 'code'
quick 5 task mentions 'chat'
coder 3 task mentions 'refactor'
The child is splinter itself in one-shot mode - same tools, own context, own
endpoint and model. Classed destructive, because it runs a whole agent; the
operator approves the delegation once.
test_delegate pins the decisions, including the two cases that must not pick
anything: no matching tag and no delegates at all.
A mutate tool that says 'wrote 23 bytes' tells the operator nothing. write and
edit now put a one-hunk diff into the observation - common prefix and suffix as
context - so the model sees what it did and the transcript shows it as its own
'anderung:' entry.
One hunk, not a general diff algorithm: a tool changes one place, and the point
is to see which. Verified against kontron: asking for an edit produced
@@ -1,2 +1,2 @@
zeile eins
-zeile zwei
+zeile zwei geaendert
and the file on disk really was changed.
--resume loads the newest session in the directory into the conversation and
shows it. The first version opened a fresh id beside the old one and resumed
nothing while claiming to; it now picks the newest sess-*.jsonl before the id is
generated. Verified: a session that was told 'die Zahl ist 4711' and restarted
with --resume answered '4711' when asked.
plugins/mcp speaks MCP over stdio: handshake, tools/list, and each server tool
registered under its published inputSchema - not an empty object, because a tool
whose parameters the model cannot see gets called with nothing.
Two bugs the tests would not have caught without a real server:
* the reply id was matched with strstr(), and servers that write "id": 1 lost
the match - the client waited for a reply it already had;
* tool descriptions pointed into the parsed reply and dangled once it was
freed, so the request carried garbage bytes and the endpoint answered 500.
Also SPLINTER_DUMP_REQUEST=<path> now keeps the request body; finding that
garbage meant seeing what was actually sent.
The harness had echo, run and clock - a chat with a shell. A coding agent needs
to look at a file, change one, find something, list a directory:
read (read) numbered lines, offset/limit, refuses binary, says where it
stopped
search (read) literal search over a tree, capped at 100 hits
list (read) a directory
write (mutate) up to 4 MiB
edit (mutate) exactly one occurrence; a non-unique 'old' is an error
run (destructive, already there)
Approval was dead code in the chat: ask_operator() read stdin, which a curses
program cannot do without eating its own keystrokes, so with --autonomous off
every mutate tool was silently denied ('fail closed'). The agent now asks through
a callback; the UI puts the question in the prompt line and parks the turn
thread on a condition variable until y or n arrives.
Measured against kontron: prompt appeared 6 s into the turn, 'y' ran the tool and
the answer carried its output; 'n' left the target file absent and the model saw
'error: denied by operator'.
test_builtin covers the refusals, not just the happy path: ambiguous edit writes
nothing, binary read reports instead of spraying, missing arguments say what is
required. README no longer claims there is no tool-call parser and no compaction.
Pressing Ctrl-C killed the harness. cbreak() leaves ISIG on, so the terminal
driver turned the key into SIGINT and the process died before wgetch() could
return 3 - the 'Ctrl-C cancels' line was a claim, and one keystroke disproved it.
raw() hands every byte to the program.
Cancelling a turn also only took effect between steps, so a request in flight
kept running to completion. The transport used popen(), which returns a stream
and not a process id, so there was nothing to kill. It now forks and execs,
keeps the pid, and both the read loop and the streaming loop poll with a 200 ms
timeout and SIGKILL the child when the turn is cancelled. Measured: Ctrl-C during
a streaming request returns to the prompt in 510 ms and the UI survives.
Temp files no longer use a fixed /tmp path: $TMPDIR, then /var/tmp. Three sites,
including the cli plugin, and they carry the conversation, so the path is now a
512-byte buffer built at runtime instead of a literal.
Four things, three of them reported by the operator.
1. Rows are counted from the real line structure. The old arithmetic
(strlen/cols) assumed one long line; a model's reasoning is full of '\n', so
the true height was far larger than the estimate and the text painted over
the answer below it - 'it just goes anywhere on the screen'. text_rows() and
row_offset() split on newlines first, then wrap. entry_lines() now measures
the string that is actually drawn ('role: text'), which also fixes the last
character of an entry being cut off (a truncated code fence).
2. Tool calls are visible: the agent's tool_begin hook fires before each call,
the UI drains the list under its lock and writes 'werkzeug: run
{"command":"echo a"}' into the transcript; the one at the top of the live
area shows the call while it runs. The reasoning entry is inserted before
those lines, so the transcript reads du, denkt, werkzeug, modell.
3. The chat pane has a black background, and the status line sits between the
pane and the prompt, the way Hermes shows it.
4. i18n is complete: every remaining literal in ui.c, main.c and the plugins
goes through the catalogue, including widget texts and format strings.
sp_td() carries a compiled-in English default, so a missing catalogue can
never drop a printf placeholder. tools/check_i18n.py runs in make check and
fails when a key used in the code is missing from any catalogue, or when a
catalogue key is used nowhere.
Seventeen test binaries green.
Not gettext: this harness is meant to start in ten years, and gettext needs
msgfmt at build time and .mo files at runtime. So catalogues are 'key = text'
files in share/locale, read once at startup.
- language from the config key LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=, else SPLINTER_LOCALE, LC_ALL,
LC_MESSAGES, LANG; regional variants are stripped (de_DE.UTF-8 -> de);
- catalogue search: $SPLINTER_LOCALE_DIR, the executable's own directory (so
works from any cwd), the source tree, /usr/local/share;
- a missing key falls back to English, and a key that exists nowhere is shown as
itself - an empty label hides a bug, a visible key does not;
- UI labels, roles, sidebar headings, status line, command errors and the shell
escape all go through sp_t(); plugins can translate theirs the same way.
test_i18n loads both catalogues from share/locale, checks lookups, the
fallback chain, printf placeholders, and that de.msg covers every key en.msg
has - a translation that silently misses half the UI is worse than none.
Seventeen test binaries green.
Three things the operator asked for, and one bug he found:
1. The reasoning moved out of the sidebar into the left pane, above the answer,
dimmed - the same place every other harness puts it. While a turn runs it
scrolls with PgUp/PgDn; afterwards it is appended to the transcript as a
'thinking' entry (capped at 1500 characters) so it can be read later.
2. ????? - glibc transliterates ß but turns ü into '?', so German answers came
back as question-mark soup. Letters now come from a table generated out of
Unicode's decompositions (tools/gen_decomp.py, 266 entries, U+00A0..U+024F,
German umlauts written out as ae/oe/ue), punctuation goes through iconv
(— -> --, … -> ...). Verified: 'ein — Gedankenstrich, „Zitat“, Auslassung…'
becomes 'ein -- Gedankenstrich, ,,Zitat", Auslassung...'.
3. Slices for the viewport now start and end on UTF-8 sequence boundaries: a
column offset could cut a character in half and draw a replacement glyph.
4. The shell tool ran the JSON as a command. 'run' received
{"command":"uname -sr"} and handed that string to popen. It now parses the
arguments (echo too) and falls back to the raw string for the mock transport.
Proven against kontron: the model called run, the observation was
'Linux 7.1.3+deb14-amd64 [exit status 0]', and it read that back correctly.
Sixteen test binaries green, test_ascii added for the transliteration.
Two real defects, both measurable:
1. COLORS was read before start_color(), so it was 0 and the colour mapper took
the eight-basic-colour branch. Every palette collapsed to white on black -
the theme was effectively ignored.
2. A CDE palette is eight mid-tones. Painted literally, Delphinium's accent sat
8% away from the background in luma and its secondary text 14%: readable on a
1995 desktop with a light backdrop, unreadable in a terminal.
Fix: the background is darkened (same hue) until its luma is a terminal
background, then each role is pushed away from it - foreground 120k, accent
100k, labels 60k in luma units. Delphinium now gives 14:1 for text, 7.7:1 for
accent and 4.7:1 for labels on a slate background, with the palette's blues
intact. Verified in the escape stream: 38;5;230 text, 38;5;68 and 38;5;74
accents, 48;5;235 surface.
sp_color_darken and sp_color_separate live in theme.c so any future consumer
gets the same rule, and the deltas are named in one place instead of spread over
four init_pair calls.
The goal is not configuration: it belongs to the conversation in front of you.
So it moved out of the config file and became a command.
- commands are an ABI now: sp_host_add_command / sp_host_command, so the UI
never needs to know a plugin by name. A leading '/' is never sent to the
model; an unknown command lists what exists.
- works in both modes: '/goal <text>' in the TUI and
'splinter -p "/goal ..."' (exit 0 on success, 2 on an unknown command).
- focus registers /goal (set, show when empty of arguments) and /recap (force
a reminder into the next turn, regardless of the five-turn cadence).
Fixed while testing it: the UI only repainted on a keypress, so a plugin widget
that ticks was frozen on screen - the clock showed the time from when the window
opened. The input read now times out after 500 ms and that timeout repaints the
sidebar and status line: clock, focus and cps are alive while you do nothing.
Fifteen test binaries green; test_focus covers the command path too: set, show,
force a recap outside the cadence, refuse an unknown command.
Long conversations drift, and a model ten turns in is deep in a detail while the
reason the session exists has scrolled away. focus puts it back: on every fifth
turn it inserts one system message with the goal and asks whether the last step
was closer to it.
Details that matter and are tested:
- one reminder per turn at most, even if compaction runs twice;
- inserted BEFORE the newest user message, so the model reads goal then request
and answers the request instead of treating the goal as a reply;
- nothing at all without a goal: no goal, no noise;
- the goal comes from the operator (config key goal -> SPLINTER_FOCUS_GOAL),
never from the model, and is truncated with a marker rather than eating the
budget it is meant to protect.
The host now counts turns (sp_host_turn) so a plugin can schedule against them;
that is what makes 'every five' mean five user turns and not five requests.
Sidebar shows the goal and the reminder count. Fourteen test binaries green,
test_focus drives the counter directly: turn 1 silent, turn 2 one reminder
in the right position, a second compaction in the same turn adds none, turn 3
silent, turn 4 the second reminder.
One file, key = value, comments with '#'. /splinter/config (or
~/.config/splinter/config), overridable with SPLINTER_CONFIG or --config,
ignorable with --no-config, generatable with --init-config.
Precedence is command line, then file, then built-in default, and an unknown
key is an error with its line number - a typo that is silently ignored is a
config that lies about what it does. The example file is written and read back
by the test suite, so it cannot rot into something the parser rejects.
What it covers: endpoint, model, api_key_env, transport, cli_cmd, plugin
(repeatable), theme, autonomous, steps, max_bytes, session_dir, system_prompt.
Verified from /tmp with nothing but the word 'splinter': the chat started, the
sidebar showed the configured endpoint, theme, cps and clock widgets, and a
turn against kontron answered 'Ich bin ein grosses Sprachmodell...' with the
session written to /home/lotherk/.splinter.
Thirteen test binaries green (test_config: full file, trimming, unknown key
with line number, missing '=', missing file, example round-trip, env path).
The sidebar counted characters and guessed tokens. The provider reports the
real numbers in the final chunk (prompt_tokens/completion_tokens, or
input_tokens/output_tokens), so both the streaming accumulator and the
one-shot reply parser now keep them, the agent sums them per turn, and the
sidebar shows '79 tok (in 344)' instead of an estimate. The estimate stays as
the fallback for endpoints that report nothing, and it is still labelled as
one.
Streaming: the OpenAI transport reads SSE over curl -N and reports deltas as
they arrive. Text goes to the chat pane, a tool-call start to the sidebar, and
a reasoning model's reasoning_content is shown dimmed above the answer instead
of being hidden - which is what made a 143 s turn look like a dead terminal.
Measured against kontron (Qwen3.6-35B, strata-poly): first byte at 11.6 s on a
short question, text growing visibly in the TUI at 7 s and 17 s on a longer one.
test_sse drives the accumulator with recorded lines: plain text, a tool call
split over three chunks, two calls in one turn, a broken data line, keepalives.
Twelve test binaries green.
Defects found while proving it, each fixed or stated:
- typed umlauts were dropped: the input loop accepted ASCII only. Every byte
above 0x1f is kept now and the line is redrawn from the buffer.
- setlocale() was never called, so curses had no encoding at all.
- the vendored NetBSD curses emits Latin-1 bytes for wide characters (ü ->
0xFC) while ncurses passes UTF-8 through; proven with a raw pty dump of both.
The UI therefore transliterates for display (gruen) and the conversation and
session log keep the exact UTF-8. The library defect is written down, not
papered over.
- an answer longer than the screen was skipped by the viewport and the chat
looked empty; draw_history now shows the bottom of the content, including
entries taller than the window.
First run against a real model (Qwen3.6-35B-A3B on kontron, strata-poly)
exposed two things a stub never would:
- our tool schema sent "properties":{}, which tells the model that no
arguments exist. Tools now carry a real JSON schema (echo/command/clock), and
the loop completes a tool round against the 35B: request 1 -> tool_call,
request 2 -> "Das Ergebnis ist: ping".
- an answer longer than the screen was not drawn at all: the entry did not
'fit', so the viewport skipped it and the chat looked empty. draw_history is
now a real viewport (total height, bottom-anchored, entries taller than the
screen start at the offset that puts their end on screen).
Steering: a turn runs on its own thread while the UI keeps reading keys. Enter
queues text the loop picks up at the next step boundary; Ctrl-C cancels; in a
single-step turn the text becomes the next message instead of disappearing.
Curses remains UI-thread-only. A dangling ag->cfg after the turn made a steer
run twice - the caller's config is now restored, and the session log confirms
one user line per steer.
Transports are plugins now (sp_host_add_transport / --transport). plugins/cli
makes any program the model: SPLINTER_CLI_CMD, run through /bin/sh, prompt on
stdin, stdout as the answer, 4 MiB cap, non-zero exit with the program's stderr,
empty output is an error. Verified with sed, with claude -p (2.9 s, answer OK)
and with cat.
Eleven test binaries green, test_cli included.
Compaction is not a flag in the loop; it is a compactor registered by a
plugin and run on the main thread before every request, with the whole
conversation in hand. Returning 1 means changed, 0 nothing to do, -1 failed -
and a failure is counted, not fatal.
lcm: deterministic lossy compression. Over budget, it keeps the leading
system prompt and the last six messages and inserts one system message that
says how many messages went, of which roles, and quotes the head of the
oldest dropped turn. No second model, so a run stays reproducible and costs
nothing extra.
cps: continuous parallel compression. The worker thread decides what would go
from an index it got under a mutex (role, size, 64 bytes of head per message)
and never touches the conversation; the main thread splices the prepared plan
in one pass when the budget is hit. The sidebar line shows applied/prepared
counts or a ready plan, so the claim is visible.
The limit is in both files: they can decide which messages go, not summarise
their text, because the text is not the worker's to read.
Ten test binaries green; test_compactor drives both against their real .so
files, including that lcm leaves the system prompt first, inserts the [lcm]
record at index 1, keeps the tail verbatim, and that cps needs two calls
(prepare, then apply) to change anything.
Splinter can now talk to a real endpoint: --endpoint plus --model shapes the
whole conversation into one chat/completions request and parses the reply back.
The seam changed from a raw string to the conversation, because a provider
adapter cannot invent history and the loop must not depend on vendor JSON:
- sp_conv: owned messages (role, name, call_id, content, raw tool_calls),
geometric growth, trim from the front. Copy on push, so a compaction step
must produce a new array - which is what makes it reviewable.
- sp_openai_request(): conversation + tool table -> JSON body.
- sp_openai_reply(): choices[0].message -> content + calls, and it keeps the
provider's raw tool_calls array to hand back verbatim next round.
- provider error objects, empty choice lists, non-JSON bodies and empty bodies
each produce a distinct, quoted error instead of a silent empty answer.
- transport_openai: curl, body through a temp file, status from curl's -w, key
from the environment only.
- libmcp's JSON parser is vendored and instantiated exactly once (src/json.c);
two instantiations would be a link error rather than a silent duplicate.
Proven end to end against a local stub speaking the real wire format:
request 1 (1 message, 2 tools, 448 bytes) -> tool_call for echo; splinter ran
the tool, request 2 (3 messages, 682 bytes) -> final text; the session log
holds user, observation, assistant.
Nine test binaries green, including test_openai (request shape, tool_call
parsing, raw array kept, four failing reply shapes) and test_conv.
A plugin is a .so against libsplinter.so, exporting sp_plugin_describe().
The layout changes so there is exactly one copy of each symbol in the
process: all logic lives in libsplinter.so and both the binary and every
plugin link against it. Two copies would have meant two registries.
What the ABI offers:
- tools with the authorization classes the loop already enforces, so the
decision stays in the harness and not in the plugin;
- widgets rendered in the sidebar, one line per widget (name: text);
- a worker thread per widget with tick(), which may block, read files, wait
on sockets - and which cannot touch curses at all;
- sp_host_widget_text() as the only thread-safe write path: the host copies
the string under a mutex, so a stack buffer is safe and the UI never holds
a pointer a worker could free.
Error paths are part of the design: a wrong ABI number is refused with both
numbers in the message, a failed init is reported and skipped, a duplicate
widget name is refused, a tool without a run function is not registered, and
nothing is dlclose()d while a thread might be inside it.
Layout: chat on three quarters, sidebar on one (session, transport, theme,
last-turn numbers, widgets), status bar underneath. The clock example plugin
proves the path end to end - its widget publishes 11:45:23 into the sidebar
from its own thread.
Seven test binaries green; test_plugin loads the real clock.so with dlopen
and checks the worker actually published, plus every refusal above.