Konrad 8fa3e9d7bb splinter: /goal as a command, and widgets that are actually alive
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.
2026-11-07 20:50:58 +00:00

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: chat on three quarters of the screen, a sidebar on one quarter, plugins that can put tools and widgets into both.

make            # libsplinter.so, the binary, the plugins
make check      # thirteen test binaries

splinter        # starts the chat from ~/.config/splinter/config

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.

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

libsplinter.so          every symbol, once; binary and plugins link to it
include/splinter.h      the core interface
include/splinter_plugin.h  plugin ABI and host API
src/plugin.c            dlopen loader, widget registry, worker threads
src/conv.c              the conversation (owned messages, no sharing)
src/openai.c            request shaping + reply parsing, pure functions
src/transport_openai.c  HTTP to /v1/chat/completions via curl(1)
src/json.c              libmcp's JSON, instantiated once
src/ui.c                curses UI: chat 3/4, sidebar 1/4, status bar
src/theme.c             CDE palettes -> terminal colours
src/palettes.c          generated from CDE's *.dp files
tools/genpalettes.py    the generator
plugins/clock/          example plugin: sidebar clock + a tool
vendor/netbsd-curses/   NetBSD curses and terminfo, vendored
docs/PLUGINS.md         the ABI, the threading rules
src/buf.c               growable buffer, JSON escaping
src/tool.c              registry
src/session.c           append-only JSONL session
src/transport.c         deterministic mock transport
src/transport_curl.c    HTTP via curl(1), request body through a temp file
src/builtin.c           echo (read) and run (destructive)
src/agent.c             the loop
src/main.c              CLI
tests/                  five test binaries, run by `make check`
docs/splinter.1         manual page
src/www/index.html      HTML 4.01 static page

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 (rendered in the sidebar). A widget's tick() runs on its own thread and publishes text; only the UI thread draws. See docs/PLUGINS.md.

Themes are CDE palettes: 42 of them, generated from the desktop's own .dp files. Roles are derived from the eight colour sets — darkest is the background, lightest the foreground, the most saturated the accent. Default is Delphinium. --list-themes prints the names, --theme NAME picks one.

Talking to a model

./splinter -p "say hi" --endpoint http://127.0.0.1:8080/v1/chat/completions \
           --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

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.

Configuration

splinter alone starts the chat: endpoint, model, plugins, theme and session directory come from ~/.config/splinter/config (or $SPLINTER_CONFIG). Command line wins over the file, the file wins over the built-in default, and an unknown key is an error with its line number. Keys and examples 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, turns text deltas into the chat pane and tool-call starts into the sidebar, and a reasoning model's own reasoning_content is shown dimmed one line above the answer instead of being hidden. In one-shot mode the text goes straight to stdout as it comes.

Both directions are covered by test_sse, which feeds recorded lines: plain text, a tool call split across three chunks, two calls in one turn, a broken data line, and the keepalive lines that carry nothing.

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.

Steering while a turn runs

The turn runs on its own thread, so the keyboard stays live. While it runs, the input line shows running Ns | Enter steers, Ctrl-C cancels. A steer is picked up at the next step boundary; in a single-step turn it becomes the next message instead of being dropped. Curses is only ever touched by the UI thread.

Compaction

focus keeps the session's goal in front of the model every five turns, the way Claude Code's recap does — one inserted system message, never twice in a turn, nothing until a goal is set. /goal <text> sets it, /recap forces a reminder, both in the TUI and with -p.

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, /recap 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.
  • The loop has no JSON tool-call parser yet. Wire formats live in adapters, so the loop stays testable; an OpenAI adapter is the next piece.
  • No compaction, no retrieval tiers. When a turn does not fit the budget it fails loudly, which is the honest behaviour until compaction exists.
  • 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.

S
Description
splinter (from the Thinkpad, ~/src/splinter)
Readme
9.3 MiB
0 Stars 3 Watchers 0 Forks
Languages
C 87.6%
Shell 6.1%
Python 2.7%
HTML 2.4%
Makefile 1.2%