open points: tables, counted site, and the tests the list asked for

Markdown tables are drawn as columns now (src/md.c, test_md, and a case in
test_ui.sh that checks the screen). The site counts lines, tools, tests,
plugins and palettes from the tree instead of naming them; the binary-size
figure is gone because it aged with every build.

The delegate panel cycle has a test (host + tasks plugin, widget says
delegate:panel exit 0), and the turn loop is driven with lcm at 8 KiB and
32 KiB budgets, so compaction is measured rather than claimed.

swarm, provstate and planner get smoke tests. TODO.md is rewritten against
the tree: the step limit was the old default (8 -> 150), skills and memory
were already built, and the open points are claude exit 2, a real Telegram
approval, A2A, the npm leftovers and the scheduler/job tests.
This commit is contained in:
lotherk committed 2026-11-09 22:46:25 +00:00
1 parent 808039cd58
commit 0576d21924
20 files changed
+1301 -147

No files matched your search

+14 -5
View File
@@ -23,7 +23,7 @@ CURSES_A = $(CURSES_DIR)/libcurses/libcurses.a \
LIB = libsplinter.so
LIBOBJ = src/buf.o src/tool.o src/session.o src/conv.o src/transport.o \
src/json.o src/sse.o src/openai.o src/transport_openai.o src/builtin.o \
src/agent.o src/theme.o src/palettes.o src/decomp.o src/i18n.o src/delegate.o src/telegram.o src/log.o src/cmdscript.o src/folder.o src/interview.o src/ack.o src/mcpserver.o src/skills.o src/memory.o src/prompt.o src/config.o src/plugin.o src/curl.o src/swarm.o src/provstate.o
src/agent.o src/theme.o src/palettes.o src/decomp.o src/i18n.o src/delegate.o src/telegram.o src/log.o src/cmdscript.o src/folder.o src/interview.o src/ack.o src/mcpserver.o src/skills.o src/memory.o src/prompt.o src/config.o src/plugin.o src/curl.o src/swarm.o src/provstate.o src/md.o
BIN = splinter
BINOBJ = src/main.o src/ui.o
PLUGIN = plugins/clock/clock.so plugins/lcm/lcm.so plugins/cps/cps.so \
@@ -36,7 +36,7 @@ PLUGIN = plugins/clock/clock.so plugins/lcm/lcm.so plugins/cps/cps.so \
plugins/tmux/tmux.so
TESTS = tests/test_buf tests/test_tool tests/test_session tests/test_conv \
tests/test_transport tests/test_agent tests/test_openai \
tests/test_theme tests/test_plugin tests/test_memory tests/test_skills tests/test_telegram tests/test_delegate tests/test_builtin tests/test_ascii tests/test_ack tests/test_i18n tests/test_config tests/test_focus tests/test_sse tests/test_cli tests/test_compactor tests/test_secrets tests/test_mcpclient tests/test_kids tests/test_lifecycle
tests/test_theme tests/test_plugin tests/test_memory tests/test_skills tests/test_telegram tests/test_delegate tests/test_builtin tests/test_ascii tests/test_ack tests/test_i18n tests/test_config tests/test_focus tests/test_sse tests/test_cli tests/test_compactor tests/test_secrets tests/test_mcpclient tests/test_kids tests/test_lifecycle tests/test_md tests/test_swarm tests/test_provstate tests/test_planner
RPATH = -Wl,-rpath,'$$ORIGIN'
PLUGIN_RPATH = -Wl,-rpath,'$$ORIGIN/../..'
@@ -106,7 +106,7 @@ plugins/cps/cps.so: plugins/cps/cps.c $(LIB)
# the day somebody adds an #include, every object depends on the headers that
# make up the interface: a change there rebuilds everything that could see it.
HDRS = include/splinter.h include/splinter_plugin.h src/config.h src/ack.h \
src/curl.h src/log.h src/i18n.h
src/curl.h src/log.h src/i18n.h src/md.h
$(LIBOBJ) $(BINOBJ): $(HDRS)
$(PLUGIN): $(HDRS)
@@ -139,7 +139,8 @@ src/prompt.o: src/prompt.h include/splinter.h
src/memory.o: src/memory.h src/config.h include/splinter.h
src/config.o: src/config.h include/splinter.h
src/plugin.o: include/splinter.h include/splinter_plugin.h
src/ui.o: src/ui.h src/theme.h src/decomp.h src/i18n.h include/splinter.h include/splinter_plugin.h
src/ui.o: src/ui.h src/theme.h src/decomp.h src/i18n.h include/splinter.h include/splinter_plugin.h src/md.h
src/md.o: src/md.h include/splinter.h
src/main.o: include/splinter.h src/config.h src/i18n.h include/splinter_plugin.h src/ui.h src/theme.h
tests/test_buf: tests/test_buf.c $(LIB)
@@ -166,7 +167,7 @@ tests/test_skills: tests/test_skills.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_skills.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_telegram: tests/test_telegram.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_telegram.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_delegate: tests/test_delegate.c $(LIB)
tests/test_delegate: tests/test_delegate.c $(LIB) $(PLUGIN)
$(CC) $(CFLAGS) -o $@ tests/test_delegate.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_builtin: tests/test_builtin.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_builtin.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
@@ -177,6 +178,14 @@ tests/test_i18n: tests/test_i18n.c $(LIB)
tests/test_ascii: tests/test_ascii.c $(LIB) $(BINOBJ)
$(CC) $(CFLAGS) -o $@ tests/test_ascii.c src/ui.o -L. -lsplinter \
$(TEST_RPATH) $(CURSES_A) $(LIBS)
tests/test_md: tests/test_md.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_md.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_swarm: tests/test_swarm.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_swarm.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_provstate: tests/test_provstate.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_provstate.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_planner: tests/test_planner.c $(LIB) $(PLUGIN)
$(CC) $(CFLAGS) -o $@ tests/test_planner.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_config: tests/test_config.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_config.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_sse: tests/test_sse.c $(LIB)
+11 -3
View File
@@ -8,7 +8,7 @@ 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 # every test binary (26), no network, no model
make check # every test binary (30), no network, no model
splinter # starts the chat from ~/.config/splinter/config
@@ -51,6 +51,7 @@ transport replays replies.
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/md.c markdown tables as aligned text
src/theme.c CDE palettes -> terminal colours
src/palettes.c generated from CDE's *.dp files
tools/genpalettes.py the generator
@@ -61,8 +62,7 @@ transport replays replies.
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/builtin.c read/write/edit/search/list/run/web tools
src/agent.c the loop
src/main.c CLI
tests/ the test binaries, run by `make check`
@@ -199,6 +199,14 @@ nothing crosses the jump except the task.
Proven: a delegate with host=172.25.206.16 ran on olivia and answered from a
provider reachable only over the wireguard link.
## 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
+70 -79
View File
@@ -1,101 +1,92 @@
# Offene Punkte
Stand: 2026-11-08. Jeder Eintrag nennt, was belegt ist, was fehlt und was der
naechste Schritt waere. Ein Punkt ohne Beweis steht hier als offen, nicht als
fertig.
Stand: 2026-11-09, nach der Arbeit an der Liste. Jeder Punkt nennt den Beleg
und den naechsten Schritt. Erledigtes steht unten, damit die Liste nicht wieder
behauptet, etwas sei offen.
## 1. Turn-Loop laeuft ins Schrittlimit, statt zu antworten
## Offen
Beobachtet beim Delegate-Test:
### 1. `claude`-Delegate endet mit Exit 2 — unerklaert
splinter: agent: step limit (8) reached without an answer
Der Parent hat acht Schritte verbraucht, ohne eine Antwort zu liefern. Entweder
ist `steps = 8` fuer einen Turn mit Werkzeugaufrufen zu klein, oder der Loop
zaehlt falsch (ein Schritt ohne Werkzeugaufruf sollte nicht als Schritt gelten).
Naechster Schritt: einen Turn mit bekanntem Werkzeugpfad mitzaehlen
(`SPLINTER_DUMP_REQUEST` plus Schrittprotokoll) und entscheiden, ob die Zahl oder
der Zaehler falsch ist.
## 2. Delegate-Eintrag im Task-Panel ist unbewiesen
`delegate.c` oeffnet vor dem Aufruf einen Task und schliesst ihn danach
(`sp_task_ops`), aber kein Lauf hat den Zyklus mit einem **erreichbaren** Delegate
gezeigt: `fleet2.conf` zeigte auf einen abgeschalteten Endpoint, `par3.conf` hatte
gar keine Delegates.
Naechster Schritt: ein `delegate` gegen `ocgo` oder `kontron` in einer Sitzung mit
geladenem `tasks`-Plugin, danach `tasks`-Widget und Status-Segment `tasks n/4`
ablesen.
## 3. `claude`-Delegate endet mit Exit 2 — unerklaert
Der aus `CLAUDE_CODE_OAUTH_TOKEN` gebaute Delegate beendet sein Kind mit 2,
waehrend dieselbe CLI von Hand antwortet:
claude -p "sage nur: beta" -> beta, rc 0
delegate tags=claude -> error: delegate: 'claude' exited 2
Abgeschaltet wurde er durch `env_delegates` (Default aus) — das ist eine
Entscheidung, keine Diagnose.
Der Fehler traegt inzwischen die letzten 400 Bytes des Kindes
(`src/delegate.c:511-524`), und ein Limit bencht den Delegate, der naechste
uebernimmt (`tests/test_delegate.c`, claude0 -> claude1). Die Ursache von Exit 2
ist aber nie diagnostiziert worden; der belegte Fall ist Exit 1 ("weekly
limit"). `env=NAME=VALUE` pro Delegate (`75d8bee`) ist ein moeglicher Weg, kein
Beweis.
Naechster Schritt: Kind mit `SPLINTER_DUMP_REQUEST` und ungefiltertem stderr
laufen lassen, Exit-Code der CLI von dem von splinter trennen.
laufen lassen, Exit-Code der CLI von dem von splinter trennen. Braucht die echte
CLI und ein Konto.
Stand 2026-11-09: der Fehler traegt jetzt die letzten 400 Bytes der Ausgabe des
Kindes ("exited 1: ... You've hit your weekly limit"), vorher nur den Code. Ein
Limit benchet den Delegate, der naechste uebernimmt (`test_delegate`, echt
belegt mit claude0 -> claude1).
### 2. Kids-Zustimmung ist gegen einen Stub geprueft, nicht gegen Telegram
## 4. Kids-Zustimmung ist gegen einen Stub geprueft, nicht gegen Telegram
`sp_ack_*` (Datei-Mechanismus, 7 Checks in `tests/test_ack.c`), `tg-ask` (Versand,
gegen Stub-curl geprueft) und der Resolver im Gateway sind gebaut. Die Kette endet
bei einem Menschen: eine echte Anfrage senden und im Chat `ok <id>` schicken.
`sp_ack_*` (19 Checks in `tests/test_ack.c`), `tg-ask` und der Resolver im
Gateway sind gebaut; die Kette endet bei einem Menschen. Die Tests sprechen
gegen `SPLINTER_TELEGRAM_API`/`tests/fake_telegram.py`, nicht gegen einen Bot.
Naechster Schritt: `SPLINTER_ACK_CHANNELS=$HOME/.splinter/bin/tg-ask`,
`SPLINTER_ACK_CHAT=8300935`, eine Aenderung anstossen, Antwort abwarten.
`SPLINTER_ACK_CHAT=8300935`, eine Aenderung anstossen, `ok <id>` im Chat
schicken. Braucht Token und Chat.
## 5. Markdown: keine Tabellen
### 3. A2A nicht gebaut
Der Renderer kann `**fett**`, `*kursiv*`, `` `code` ``, `#`-Zeilen und Fences.
Tabellen werden als Text gezeigt, nicht als Spalten — Spaltenbreiten brauchen eine
Messung ueber alle Zeilen.
splinter ist MCP-Client und -Server, aber kein A2A-Teilnehmer. `src/swarm.c` ist
eine lokale Flotte ueber einen Unix-Socket im Arbeitsverzeichnis
(`.splinter-swarm.sock`), kein Agent-zu-Agent-Protokoll; `tests/test_swarm.c`
deckt nur diesen lokalen Weg ab.
Naechster Schritt: Tabellenerkennung (`|---|`-Zeile nach einer Kopfzeile) und
Spaltenbreiten aus dem Maximum je Spalte.
Naechster Schritt: A2A-Client (anderen Agenten als Backend) entwerfen; danach
Server.
## 6. 8k-Kontext nie gemessen
### 4. `~/.local/lib` enthaelt Fremdlast
LCM und Kompression sind verdrahtet (`sp_host_compact`, `ag.host` wird gesetzt,
Reminder nachgewiesen im Request), aber ein Lauf mit 8k Fenster wurde nie
durchgefahren. „Grob geschaetzt" ist kein Messwert.
`~/.local/lib` ist ein Symlink auf `~/.local/npm`. Dort liegen `node_modules`,
`package.json` und `package-lock.json` aus einem frueheren Projekt (Maerz 2026) —
und seit `make install PREFIX=$HOME/.local` auch `libsplinter.so`. Nur die
npm-Dateien sind Fremdlast; das Verzeichnis ist inzwischen auch das
Installationsziel.
Naechster Schritt: `SPLINTER_CTX_MAX=8192` mit einer langen Sitzung, Anzahl
Kompressionen und Tokenverlauf im `wire.jsonl` auszaehlen.
Naechster Schritt: entscheiden, ob die npm-Reste weg duerfen. Kein Code.
## 7. Skills und Memory fehlen ganz
### 5. Scheduler und die Job-Werkzeuge sind noch ungetestet
`docs/ROADMAP.md` nennt `skill_search`/`skill_load` (lazy, kein Vorladen) und
mem0 pro User. Beides ist nicht gebaut; `~/.splinter/skills/` existiert als
Verzeichnis, ohne Leser.
`plugins/scheduler/` hat keinen Test; es braucht einen faelligen
Delegations-Job und eine Gegenstelle, die den Retry sieht. Von den
Job-Werkzeugen sind `delegate_submit`, `delegate_jobs`, `delegate_result`,
`delegate_due`, `delegate_retry` und `delegate_list` ungetestet;
`test_delegate` deckt Auswahl, Fallback, Panel und `delegate_parallel` ab.
`plugins/tmux/` wird nur indirekt ueber `test_ui.sh` beruehrt.
## 8. A2A nicht gebaut
Naechster Schritt: Job-Persistenz submit -> jobs -> result als Test, danach
einen faelligen Job fuer den Scheduler.
splinter ist MCP-Client und -Server, aber kein A2A-Teilnehmer. Fuer die Flotte
fehlt damit der Weg, auf dem ein Agent einen anderen direkt beauftragt.
## Erledigt (2026-11-09)
## 9. `~/.local/lib` enthaelt Fremdlast
`node_modules` und `package.json` liegen dort aus einem frueheren Projekt, nicht
aus `make install`. Nicht angefasst, weil nicht klar ist, wer sie braucht.
## 10. Website nennt Zahlen, die altern
`src/www/` wird aus `tools/gen_www.py` erzeugt (`make check` prueft, dass die
Seiten zur Quelle passen), aber die Werkzeugzahl und die Pluginliste stehen als
Text darin. Nach jeder neuen Datei muessen sie von Hand nachgezogen werden.
Naechster Schritt: Zahl der Werkzeuge und Plugins beim Generieren aus dem Code
zaehlen statt sie zu schreiben.
- **Markdown-Tabellen**: `src/md.c` erkennt Kopf + Trenner, rechnet die Breite
je Spalte und gibt ausgerichteten Text aus; Text davor/danach bleibt.
`tests/test_md.c` (Kopf, Trenner, ungleich lange Zeilen, UTF-8, zwei Bloecke)
und ein Fall in `tests/test_ui.sh`, der die Spalten auf dem Schirm prueft.
- **Website zaehlt**: `tools/gen_www.py` liest Zeilen, Werkzeuge, Tests, Plugins
und Paletten aus dem Baum. Die meta-Zeile nennt jetzt 30 Test-Programme,
23 Werkzeuge und 15 Plugins; die alte Binärgroesse ist durch die
Werkzeugzahl ersetzt, weil sie mit jedem Build altert.
- **Delegate im Task-Panel**: `tests/test_delegate.c` uebergibt einen Host mit
geladenem `tasks`-Plugin, laesst einen Delegate laufen und prueft
`delegate:panel exit 0` im Widget sowie `tasks_running == 0`.
- **8k-Kontext gemessen**: `tests/test_compactor.c` faehrt den echten Turn-Loop
mit `lcm` bei 8192 und 32768 Bytes Budget und zaehlt die Kompressionen. Der
alte Vorschlag `SPLINTER_CTX_MAX=8192` war falsch: das speist nur die Anzeige
(`src/ui.c:1045`), komprimiert wird nach `max_bytes` (`src/agent.c:327`).
- **Doku-Drift**: `docs/PLUGINS.md` hat Abschnitte fuer planner, provider,
scheduler und tmux; `README.md` nennt `swarm` und die aktuelle Testzahl;
`docs/ROADMAP.md` fuehrt Remote/Jumphost und die 8k-Messung als erledigt.
- **Neue Tests**: `test_swarm` (master/slave, route, busy, standalone),
`test_provstate` (429/503, getrennte Keys, Dateimodus, Fingerprint) und
`test_planner` (add/list/update, `/tasks`, Datei, Widget).
- **Skills und Memory**: `src/skills.c`, `src/memory.c`, registriert in
`src/main.c:908-909`, `test_skills` und `test_memory` laufen gruen.
- **Kompression verdrahtet**: `ag->host` wird gesetzt (`src/main.c:635`).
- **Turn-Loop-Schrittlimit**: `8` war der alte Default, kein Zaehlfehler;
`75d8bee` setzt 150 (`src/main.c:873`, `src/config.c:573`).
- **Delegate-Limit und Fallback**: `tests/test_delegate.c`.
+37
View File
@@ -230,3 +230,40 @@ Regeln, die der Code durchsetzt:
- Grenze: Jeder Prozess unter derselben uid kann antworten. Wer das Kind am
selben Konto vom Zustimmen abhalten will, braucht eine eigene uid fuer splinter
(oder einen Kanal, dessen Antwort der lokale Benutzer nicht schreiben kann).
## planner
A plan for the session, not a background job. The list lives in
`<session>/plan_tasks.json`; the model can add and update tasks, and `/tasks`
shows them, picks the active one and moves it between `todo`, `doing`, `done`,
`blocked` and `waiting_quota`. The focus plugin's `/goal` is the short reminder;
planner is the list behind it. It is a different store from the `tasks` plugin,
which owns shell commands with a process and a clock.
## provider
Per-`(provider, key)` quota and usage, shared by every splinter that uses the
same key: state is written under `~/.splinter/providers/` with `flock` and an
atomic rename. `preflight` can delay or refuse a request before it is sent;
`account` records the status and token counts afterwards. A 429, 402 or 529
becomes a quota wait, 503 and 408 a short backoff. Ollama is treated as local
(backoff only, no quota) unless a quota is configured. `SPLINTER_PROVIDER_PROBE`
and `SPLINTER_QUOTA_PROBE_URL` enable an optional probe.
## scheduler
The other half of a quota wait: once a minute it looks for one durable
delegation job that is due (`waiting_quota`, `waiting_poll` or `queued` with
`run_after`/`next_poll_at` reached) and retries it. With `provider` and the
delegate job tools, "quota is back in three days" becomes a scheduled retry
instead of a lost task.
## tmux
Drives a CLI that wants a terminal in an underlying tmux session. `/tmux start
<cmd>`, `attach`, `send`, `keys`, `capture`, `ask`, `read`, `watch start|stop`
and `status` are the commands; `tmux_start`, `tmux_send`, `tmux_capture`,
`tmux_read`, `tmux_ask`, `tmux_status` and `tmux_watch` are the tools. A watcher
process appends new pane output to `<session>/tmux_watch.log`, so `ask` waits on
the feed instead of sleeping for a fixed time. It refuses to load when `tmux`
is not installed.
+27 -10
View File
@@ -1,20 +1,27 @@
# Offene Punkte
Stand: 2026-11-08. Reihenfolge ist Absicht, nicht Wunschliste.
Stand: 2026-11-09. Die geprüfte, ausführliche Liste mit Belegen steht in
`TODO.md`; hier bleibt die Reihenfolge, was als Nächstes gebaut wird.
1. **A2A-Plugin** — splinter als A2A-Client (anderen Agenten als Backend) und
spaeter als Server, damit die Flotte splinter rufen kann.
2. **Remote/Jumphost** — `opencode`, `claude` und andere CLIs ueber SSH auf einer
anderen Maschine starten (neue IP, anderes Netz). Transport-Plugin mit
`ssh host -- cmd`.
3. **8k-Kontext** — mit LCM/continuous compression messen, was bei 8192 Token
wirklich passiert: wo es bricht, nicht schaetzen.
1. **A2A** — splinter als A2A-Client (anderen Agenten als Backend) und später
als Server, damit die Flotte splinter rufen kann. `swarm` ist nur lokale IPC
im selben Verzeichnis, kein A2A.
2. **Restliche Tests** — `scheduler` und die Job-Werkzeuge
(`delegate_submit`/`jobs`/`result`) haben noch keinen Test; `swarm`,
`provstate` und `planner` sind abgedeckt, `tmux` nur indirekt über
`test_ui.sh`.
3. **Echte Gegenstellen** — die Kids-Zustimmung gegen einen echten Telegram-Bot
(nicht `fake_telegram.py`), und die Ursache von `claude` Exit 2.
## Erledigt
- Werkzeuge: read, write, edit, search, list, run, echo, clock
- Werkzeuge: read, write, edit, search, list, run, websearch, webfetch,
folder_history, delegate (plus parallel/list/submit/jobs/result/due/retry),
skill_search/skill_load, memory_search/memory_add, echo, clock
- Freigabe im TUI (Condition Variable), Diff-Anzeige, Ctrl-C killt curl
- Session-Resume, MCP-Client, Exit-Ring, Delegation mit Modellauswahl
- Session-Resume, MCP-Client und -Server, Exit-Ring, Delegation mit Modellwahl
- Gateway (Telegram) mit Typing-Indicator und Slash-Commands
- Session-Logs: `~/.splinter/logs/<id>/{session.log,wire.jsonl}`
- Slash-Programme: `~/.splinter/commands/<name>`, Ausgabe geht ans Modell
@@ -23,3 +30,13 @@ Stand: 2026-11-08. Reihenfolge ist Absicht, nicht Wunschliste.
- **Memory**: mem0-REST, `user_id` aus dem laufenden Prozess, pro User getrennt
(`test_memory`)
- **Streaming im Gateway**: eigener Callback, damit auch SSE-only-Provider gehen
- **Remote/Jumphost**: `host=` schickt den ganzen Aufruf über ssh; belegt in
`README.md` (olivia, Provider nur über WireGuard erreichbar)
- **Kompression im echten Loop**: `ag->host` ist gesetzt; `test_compactor` fährt
den Turn mit lcm bei 8 KiB und 32 KiB Budget und zählt die Kompressionen
- **Tabellen im Chat**: `src/md.c` erkennt Kopf + Trenner, rechnet Spaltenbreiten
und zeichnet ausgerichteten Text (`test_md`, `test_ui.sh`)
- **Website zählt**: Zeilen, Werkzeuge, Tests, Plugins und Paletten kommen beim
Generieren aus dem Baum (`tools/gen_www.py`)
- **Letzter Delegate-Fehler**: die letzten 400 Bytes des Kindes stehen im Fehler,
ein Limit bencht den Delegate und der nächste übernimmt (`test_delegate`)
+362
View File
@@ -0,0 +1,362 @@
/*
* splinter -- markdown tables as aligned text.
*
* Copyright (c) 2026 Konrad Lother
* SPDX-License-Identifier: BSD-3-Clause
*
* A chat is monospace, so a table can be a table: the pipe rows are rewritten
* with one width per column, taken from the longest cell. The block is the
* markdown shape a model actually emits -- a header line, a separator line
* ("|---|:---:|---|"), then body rows -- and it ends at the first line that is
* not a row. Text before and after the block is copied unchanged.
*
* This is deliberately not a full markdown parser. Escaped pipes are not
* supported (a table cell with a literal '|' is rare; a parser that guesses is
* worse than one that leaves the line alone), and alignment is in bytes, which
* is exact for ASCII. The screen transliterates UTF-8 before drawing, so a cell
* full of umlauts can still be a column short; that is a display detail, not a
* reason to turn the table back into pipes.
*/
#include <stdlib.h>
#include <string.h>
#include "splinter.h"
#include "md.h"
#define MD_MAX_COLS 32
#define MD_MAX_ROWS 512
struct md_row {
size_t n;
char **cell;
};
static const char *
eol(const char *s)
{
const char *p = strchr(s, '\n');
return p != NULL ? p : s + strlen(s);
}
/* A separator line: every cell has at least three dashes, optional colons. */
static int
is_separator(const char *s, size_t n)
{
size_t i = 0, pipes = 0, cells = 0;
while (i < n && (s[i] == ' ' || s[i] == '\t' || s[i] == '\r'))
i++;
if (i < n && s[i] == '|') {
i++;
pipes++;
}
for (;;) {
size_t dashes = 0;
while (i < n && (s[i] == ' ' || s[i] == '\t'))
i++;
if (i < n && s[i] == ':')
i++;
while (i < n && s[i] == '-') {
i++;
dashes++;
}
if (dashes < 3)
return 0;
if (i < n && s[i] == ':')
i++;
while (i < n && (s[i] == ' ' || s[i] == '\t'))
i++;
cells++;
if (i < n && s[i] == '|') {
i++;
pipes++;
while (i < n && (s[i] == ' ' || s[i] == '\t'))
i++;
if (i >= n || s[i] == '\r')
break;
continue;
}
break;
}
while (i < n && (s[i] == ' ' || s[i] == '\t' || s[i] == '\r'))
i++;
return i == n && cells > 0 && pipes > 0;
}
static void
row_free(struct md_row *r)
{
size_t i;
for (i = 0; i < r->n; i++)
free(r->cell[i]);
free(r->cell);
r->cell = NULL;
r->n = 0;
}
/*
* Split one line into cells: trim the line, drop one leading and one trailing
* pipe, then split on '|'. A trailing pipe does not create an empty last cell.
*/
static int
row_parse(const char *s, size_t n, struct md_row *r)
{
size_t i = 0, cap = 0;
r->n = 0;
r->cell = NULL;
while (n > 0 && (s[n - 1] == ' ' || s[n - 1] == '\t' ||
s[n - 1] == '\r'))
n--;
while (i < n && (s[i] == ' ' || s[i] == '\t'))
i++;
if (i < n && s[i] == '|')
i++;
for (;;) {
size_t start = i, end;
while (i < n && s[i] != '|')
i++;
end = i;
while (end > start && (s[end - 1] == ' ' ||
s[end - 1] == '\t'))
end--;
while (start < end && (s[start] == ' ' || s[start] == '\t'))
start++;
if (r->n == MD_MAX_COLS)
goto fail;
if (r->n == cap) {
size_t ncap = cap == 0 ? 4 : cap * 2;
char **nc = realloc(r->cell, ncap * sizeof(*nc));
if (nc == NULL)
goto fail;
r->cell = nc;
cap = ncap;
}
r->cell[r->n] = malloc(end - start + 1);
if (r->cell[r->n] == NULL)
goto fail;
memcpy(r->cell[r->n], s + start, end - start);
r->cell[r->n][end - start] = '\0';
r->n++;
if (i < n && s[i] == '|') {
i++;
if (i >= n)
break;
continue;
}
break;
}
return 0;
fail:
row_free(r);
return -1;
}
static int
row_push(struct md_row **rows, size_t *n, size_t *cap, const char *s,
size_t len)
{
struct md_row *nr;
if (*n == MD_MAX_ROWS)
return -1;
if (*n == *cap) {
size_t ncap = *cap == 0 ? 4 : *cap * 2;
nr = realloc(*rows, ncap * sizeof(**rows));
if (nr == NULL)
return -1;
*rows = nr;
*cap = ncap;
}
memset(&(*rows)[*n], 0, sizeof(**rows));
if (row_parse(s, len, &(*rows)[*n]) != 0)
return -1;
(*n)++;
return 0;
}
static void
rows_free(struct md_row *rows, size_t n)
{
size_t i;
for (i = 0; i < n; i++)
row_free(&rows[i]);
free(rows);
}
/*
* Format the block that starts at 'p' (a header line followed by a separator)
* and return the first line after it. NULL means "leave it alone": too many
* rows or columns, or no memory.
*/
static const char *
format_table(const char *p, struct sp_buf *out)
{
struct md_row *rows = NULL;
size_t nrows = 0, cap = 0, ncols = 0, i, j;
size_t width[MD_MAX_COLS];
const char *e = eol(p);
const char *sep = (*e == '\n') ? e + 1 : e;
const char *se = eol(sep);
const char *cur = (*se == '\n') ? se + 1 : se;
memset(width, 0, sizeof(width));
if (row_push(&rows, &nrows, &cap, p, (size_t)(e - p)) != 0)
goto fail;
while (*cur != '\0') {
const char *ce = eol(cur);
size_t clen = (size_t)(ce - cur);
if (clen == 0 || memchr(cur, '|', clen) == NULL)
break;
if (row_push(&rows, &nrows, &cap, cur, clen) != 0)
goto fail;
if (*ce == '\0') {
cur = ce;
break;
}
cur = ce + 1;
}
if (nrows == 0)
goto fail;
for (i = 0; i < nrows; i++) {
if (rows[i].n > ncols)
ncols = rows[i].n;
for (j = 0; j < rows[i].n; j++) {
size_t l = strlen(rows[i].cell[j]);
if (l > width[j])
width[j] = l;
}
}
if (ncols == 0 || ncols > MD_MAX_COLS)
goto fail;
for (i = 0; i < nrows; i++) {
if (sp_buf_puts(out, "|") != 0)
goto fail;
for (j = 0; j < ncols; j++) {
const char *c = j < rows[i].n ? rows[i].cell[j] : "";
size_t l = strlen(c), k;
if (sp_buf_puts(out, " ") != 0 ||
sp_buf_puts(out, c) != 0)
goto fail;
for (k = l; k < width[j]; k++)
if (sp_buf_puts(out, " ") != 0)
goto fail;
if (sp_buf_puts(out, " |") != 0)
goto fail;
}
if (sp_buf_puts(out, "\n") != 0)
goto fail;
if (i == 0) {
if (sp_buf_puts(out, "|") != 0)
goto fail;
for (j = 0; j < ncols; j++) {
size_t k;
for (k = 0; k < width[j] + 2; k++)
if (sp_buf_puts(out, "-") != 0)
goto fail;
if (sp_buf_puts(out, "|") != 0)
goto fail;
}
if (sp_buf_puts(out, "\n") != 0)
goto fail;
}
}
rows_free(rows, nrows);
return cur;
fail:
rows_free(rows, nrows);
return NULL;
}
static const char *
next_table(const char *in)
{
const char *p = in;
while (*p != '\0') {
const char *e = eol(p);
if (*e == '\n' && memchr(p, '|', (size_t)(e - p)) != NULL) {
const char *q = e + 1;
const char *qe = eol(q);
if (is_separator(q, (size_t)(qe - q)))
return p;
}
if (*e == '\0')
break;
p = e + 1;
}
return NULL;
}
int
sp_md_table_starts(const char *in)
{
const char *e, *q, *qe;
if (in == NULL)
return 0;
e = eol(in);
if (*e != '\n')
return 0;
q = e + 1;
qe = eol(q);
return memchr(in, '|', (size_t)(e - in)) != NULL &&
is_separator(q, (size_t)(qe - q));
}
int
sp_md_table_format(const char *in, struct sp_buf *out)
{
const char *p;
int changed = 0;
if (in == NULL || out == NULL)
return -1;
if (next_table(in) == NULL)
return 0;
p = in;
while (*p != '\0') {
const char *e = eol(p);
if (*e == '\n' && memchr(p, '|', (size_t)(e - p)) != NULL) {
const char *q = e + 1;
const char *qe = eol(q);
if (is_separator(q, (size_t)(qe - q))) {
const char *after = format_table(p, out);
if (after == NULL)
return -1;
changed = 1;
p = after;
continue;
}
}
if (sp_buf_add(out, p, (size_t)(e - p)) != 0)
return -1;
if (*e == '\0') {
p = e;
break;
}
if (sp_buf_add(out, "\n", 1) != 0)
return -1;
p = e + 1;
}
return changed;
}
+27
View File
@@ -0,0 +1,27 @@
/* splinter -- markdown tables as aligned text. */
#ifndef SPLINTER_MD_H
#define SPLINTER_MD_H
#include <stddef.h>
struct sp_buf;
/*
* Rewrite markdown tables in 'in' as aligned plain text and append the result
* to 'out'. A block is a header line containing '|' followed by a separator
* line ("|---|:---:|---|"). Cell widths are the maximum per column, so the
* table reads as columns in a monospace chat, not as a row of pipes.
*
* Returns 1 when a table was rewritten, 0 when the text had none (out stays
* empty), -1 on allocation failure or a table too large to format.
*/
int sp_md_table_format(const char *in, struct sp_buf *out);
/*
* 1 when the first line of 'in' is a table header (the second line is the
* separator). The chat uses this to put the speaker prefix on its own line:
* a table that starts an answer must not begin behind "[12:04] <agent> ".
*/
int sp_md_table_starts(const char *in);
#endif /* SPLINTER_MD_H */
+32 -10
View File
@@ -38,6 +38,7 @@
#include "log.h"
#include "cmdscript.h"
#include "splinter_plugin.h"
#include "md.h"
#include "theme.h"
#include "ui.h"
@@ -675,8 +676,20 @@ md_strip_n(const char *in, char *out, unsigned char *attr)
static int
md_prepare(const char *in, char **plain_out, unsigned char **attr_out)
{
size_t n = in != NULL ? strlen(in) : 0;
struct sp_buf tb;
const char *src;
size_t n;
*plain_out = NULL;
*attr_out = NULL;
if (sp_buf_init(&tb) != 0)
return -1;
if (sp_md_table_format(in, &tb) < 0) {
sp_buf_free(&tb);
return -1;
}
src = tb.len > 0 ? tb.p : (in != NULL ? in : "");
n = strlen(src);
*plain_out = malloc(n + 1);
*attr_out = malloc(n + 1);
if (*plain_out == NULL || *attr_out == NULL) {
@@ -684,9 +697,11 @@ md_prepare(const char *in, char **plain_out, unsigned char **attr_out)
free(*attr_out);
*plain_out = NULL;
*attr_out = NULL;
sp_buf_free(&tb);
return -1;
}
md_strip_n(in, *plain_out, *attr_out);
md_strip_n(src, *plain_out, *attr_out);
sp_buf_free(&tb);
return 0;
}
@@ -793,14 +808,17 @@ entry_lines(int cols, const struct entry *e)
if (cols < 2)
return 1;
{
char prefix[256];
char prefix[256];
const char *brk;
entry_prefix(e, prefix, sizeof(prefix));
len = strlen(prefix) + strlen(e->text) + 1;
/* a table that starts the answer must not start behind the prefix */
brk = sp_md_table_starts(e->text) ? "\n" : "";
len = strlen(prefix) + strlen(brk) + strlen(e->text) + 1;
render = malloc(len);
if (render == NULL)
return 1;
snprintf(render, len, "%s%s", prefix, e->text);
snprintf(render, len, "%s%s%s", prefix, brk, e->text);
}
{
char *plain = NULL;
@@ -878,11 +896,15 @@ draw_history(struct ui_state *s, int reserve)
continue;
}
entry_prefix(e, prefix, sizeof(prefix));
len = strlen(prefix) + strlen(e->text) + 1;
render = malloc(len);
if (render == NULL)
break;
snprintf(render, len, "%s%s", prefix, e->text);
{
const char *brk = sp_md_table_starts(e->text) ? "\n" : "";
len = strlen(prefix) + strlen(brk) + strlen(e->text) + 1;
render = malloc(len);
if (render == NULL)
break;
snprintf(render, len, "%s%s%s", prefix, brk, e->text);
}
wmove(ui_hist, y, 1);
+6 -6
View File
@@ -53,9 +53,9 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
<h1>splinter<span>_</span></h1>
<p class="lead">An agent harness you own: chat in the terminal, tools with authorization classes, plugins, any model that speaks OpenAI — built by us so we can change it, instead of getting used to how somebody else's client behaves.</p>
<p class="meta"><b>9.125</b> lines of C99/POSIX &middot;
<b>248.568</b> bytes binary &middot; <b>21</b> test programs &middot;
<b>8</b> plugins &middot; <b>42</b> palettes &middot; BSD-3-Clause</p>
<p class="meta"><b>21771</b> lines of C99/POSIX &middot;
<b>23</b> tools &middot; <b>30</b> test programs &middot;
<b>15</b> plugins &middot; <b>42</b> palettes &middot; BSD-3-Clause</p>
<h2>What it is</h2>
<p>The same thing Claude Code or opencode is for you: a program you sit in front of, talking to a model, running the tools it asks for. The difference is the source. If something bothers you — the layout, the keys, the confirmation prompts, the transport — you change it here instead of waiting for someone else to.</p>
@@ -149,8 +149,8 @@ plugin = plugins/reminder/reminder.so</pre>
<h2>Building</h2>
<pre><span class="u">$</span> git clone ssh://host/home/git/splinter.git
<span class="u">$</span> cd splinter &amp;&amp; make <span class="d">248 KB, nothing but libc and curses</span>
<span class="u">$</span> make check <span class="d">21 test programs, plus the i18n checker</span>
<span class="u">$</span> cd splinter &amp;&amp; make <span class="d">small, nothing but libc and curses</span>
<span class="u">$</span> make check <span class="d">30 test programs, plus the i18n checker</span>
<span class="u">$</span> ./splinter <span class="d">chat, the config is read</span>
<span class="u">$</span> ./splinter --daemon <span class="d">Telegram gateway</span></pre>
<p>POSIX make, C99, <code>-Wall -Wextra -Werror</code>. NetBSD curses is vendored, so the binary does not depend on a distribution's mood.</p>
@@ -185,7 +185,7 @@ in the header before anybody reads its prose.</p>
<p>As a client splinter fetches an MCP server's tools. As a server it offers its
own:</p>
<pre><span class="u">$</span> splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
splinter: MCP server on 0.0.0.0:8098 (14 tools, read only)</pre>
splinter: MCP server on 0.0.0.0:8098 (23 tools, read only)</pre>
<p>Another agent gets <code>initialize</code>, <code>tools/list</code> and
<code>tools/call</code>. Read tools are served; mutating and destructive ones only
with <code>--autonomous</code> &mdash; a foreign agent does not run shell commands
+6 -6
View File
@@ -53,9 +53,9 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
<h1>splinter<span>_</span></h1>
<p class="lead">Ein Agent-Harness, das dir gehoert: Chat im Terminal, Werkzeuge mit Autorisierungsklassen, Plugins, jedes Modell das OpenAI spricht — von uns gebaut, damit wir es umbauen koennen, statt uns an das Verhalten eines fremden Clients zu gewoehnen.</p>
<p class="meta"><b>9.125</b> Zeilen C99/POSIX &middot;
<b>248.568</b> Bytes Binary &middot; <b>21</b> Test-Programme &middot;
<b>8</b> Plugins &middot; <b>42</b> Farbschemata &middot; BSD-3-Clause</p>
<p class="meta"><b>21771</b> Zeilen C99/POSIX &middot;
<b>23</b> Werkzeuge &middot; <b>30</b> Test-Programme &middot;
<b>15</b> Plugins &middot; <b>42</b> Farbschemata &middot; BSD-3-Clause</p>
<h2>Was es ist</h2>
<p>Dasselbe, was Claude Code oder opencode fuer dich sind: ein Programm, in dem du mit einem Modell redest und das die Werkzeuge ausfuehrt, um die es bittet. Der Unterschied ist der Quelltext. Wenn dich etwas stoert — das Layout, die Tasten, die Frage nach Bestaetigung, der Transport — aenderst du es hier, statt darauf zu warten.</p>
@@ -149,8 +149,8 @@ plugin = plugins/reminder/reminder.so</pre>
<h2>Bauen</h2>
<pre><span class="u">$</span> git clone ssh://host/home/git/splinter.git
<span class="u">$</span> cd splinter &amp;&amp; make <span class="d">248 KB, nichts ausser libc und curses</span>
<span class="u">$</span> make check <span class="d">21 Test-Programme, plus i18n-Pruefer</span>
<span class="u">$</span> cd splinter &amp;&amp; make <span class="d">klein, nichts ausser libc und curses</span>
<span class="u">$</span> make check <span class="d">30 Test-Programme, plus i18n-Pruefer</span>
<span class="u">$</span> ./splinter <span class="d">Chat, Konfiguration wird gelesen</span>
<span class="u">$</span> ./splinter --daemon <span class="d">Telegram-Gateway</span></pre>
<p>POSIX make, C99, <code>-Wall -Wextra -Werror</code>. Die NetBSD-curses liegt im Baum, damit das Binary nicht von der Laune einer Distribution abhaengt.</p>
@@ -186,7 +186,7 @@ ist in der Kopfzeile sichtbar, bevor jemand seinen Text liest.</p>
<p>Als Client holt splinter die Werkzeuge eines MCP-Servers. Als Server stellt es
seine eigenen hin:</p>
<pre><span class="u">$</span> splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
splinter: MCP server on 0.0.0.0:8098 (14 tools, read only)</pre>
splinter: MCP server on 0.0.0.0:8098 (23 tools, read only)</pre>
<p>Ein anderer Agent bekommt <code>initialize</code>, <code>tools/list</code> und
<code>tools/call</code>. Lesende Werkzeuge werden bedient, mutierende und
destruktive nur mit <code>--autonomous</code> &mdash; ein fremder Agent fuehrt hier
+9 -9
View File
@@ -53,9 +53,9 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
<h1>splinter<span>_</span></h1>
<p class="lead">Um harness de agente que e seu: chat no terminal, ferramentas com classes de autorizacao, plugins, qualquer modelo que fale OpenAI - escrito por nos para poder mudar-lo, em vez de nos acostumar com o comportamento de um cliente alheio.</p>
<p class="meta"><b>9.125</b> linhas C99/POSIX &middot;
<b>248.568</b> bytes do binario &middot; <b>21</b> programas de teste &middot;
<b>8</b> plugins &middot; <b>42</b> paletas &middot; BSD-3-Clause</p>
<p class="meta"><b>21771</b> linhas C99/POSIX &middot;
<b>23</b> ferramentas &middot; <b>30</b> programas de teste &middot;
<b>15</b> plugins &middot; <b>42</b> paletas &middot; BSD-3-Clause</p>
<h2>O que e</h2>
<p>splinter e um harness de agente em C99/POSIX: um programa que segura a
@@ -80,10 +80,10 @@ transcript na ordem em que acontecem.</p>
entrar na frente com um gate: permitir, negar com motivo, ou nao opinar.</p>
<h2>Ferramentas</h2>
<p>14 ferramentas: <code>read</code>, <code>write</code>, <code>edit</code>,
<code>search</code>, <code>list</code>, <code>run</code>,
<code>folder_history</code>, <code>delegate</code>,
<code>delegate_parallel</code> e as de leitura do sistema.</p>
<p>23 ferramentas: <code>read</code>, <code>write</code>, <code>edit</code>,
<code>search</code>, <code>list</code>, <code>run</code>, <code>folder_history</code>,
<code>delegate</code>, <code>delegate_parallel</code>, as de leitura do sistema e as de
skills, memoria e pesquisa na web.</p>
<h2>Transportes e plugins</h2>
<p>Transporte e um vtable: openai (HTTP/SSE), cli (claude, opencode), mock para
@@ -114,7 +114,7 @@ mesmos slash commands do terminal.</p>
<h2>Compilar</h2>
<pre>make
make check <span class="d"># 21 binarios de teste, i18n, site</span></pre>
make check <span class="d"># 30 binarios de teste, i18n, site</span></pre>
<p>Sem dependencias alem de libc e pthread; ncurses vem do vendor.</p>
<h2>O que nao e</h2>
@@ -130,7 +130,7 @@ poe suas proprias chaves.</p>
<h2>As duas direcoes: MCP</h2>
<pre><span class="u">$</span> splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
splinter: MCP server on 0.0.0.0:8098 (14 tools, read only)</pre>
splinter: MCP server on 0.0.0.0:8098 (23 tools, read only)</pre>
<p>Como cliente busca ferramentas; como servidor oferece as suas. Mutar so com
<code>--autonomous</code>.</p>
+11 -1
View File
@@ -49,7 +49,17 @@ class H(http.server.BaseHTTPRequestHandler):
return self.reply({"ok": True, "result": True})
req = json.loads(raw)
has_tool = any(m.get("role") == "tool" for m in req.get("messages", []))
if has_tool:
last_user = ""
for m in reversed(req.get("messages", [])):
if m.get("role") == "user":
last_user = m.get("content") or ""
break
if "tabelle" in last_user:
# a markdown table: the chat must draw columns, not pipes
answer = "| a | b |\n|---|---|\n| 1 | 22 |\n"
chunks = [{"choices": [{"delta": {"content": answer}}]},
{"choices": [{"delta": {}, "finish_reason": "stop"}]}]
elif has_tool:
chunks = [{"choices": [{"delta": {"content": "fertig"}}]},
{"choices": [{"delta": {}, "finish_reason": "stop"}]}]
else:
+111
View File
@@ -48,6 +48,98 @@ fill(struct sp_conv *c, int n)
}
}
static int
echo_tool(const char *args, struct sp_buf *out, void *ctx)
{
(void)ctx;
return sp_buf_puts(out, args);
}
/*
* Drive the real turn loop with lcm loaded and a byte budget. The mock echoes a
* fixed payload, so the conversation grows by a known amount per tool round;
* the only way the turn can finish is that the compactor kept every request
* under 'budget'. Returns the agent's rc, fills *stats.
*/
static int
run_budget(size_t budget, size_t calls, size_t payload,
struct sp_agent_stats *stats)
{
struct sp_registry r;
struct sp_tool t;
struct sp_agent ag;
struct sp_agent_config cfg;
struct sp_mock m;
struct sp_host *host = NULL;
struct sp_buf answer, err, reply, chunk;
size_t i;
int have_mock = 0, rc = -1;
memset(&r, 0, sizeof(r));
memset(&t, 0, sizeof(t));
t.name = "echo";
t.description = "echo the argument";
t.auth = SP_AUTH_READ;
t.run = echo_tool;
(void)sp_registry_add(&r, &t);
memset(&ag, 0, sizeof(ag));
memset(&cfg, 0, sizeof(cfg));
cfg.max_steps = calls + 2;
cfg.max_bytes = budget;
cfg.autonomous = 1;
ag.reg = &r;
ag.cfg = &cfg;
memset(&answer, 0, sizeof(answer));
memset(&err, 0, sizeof(err));
memset(&reply, 0, sizeof(reply));
memset(&chunk, 0, sizeof(chunk));
if (sp_buf_init(&answer) != 0 || sp_buf_init(&err) != 0 ||
sp_buf_init(&reply) != 0 || sp_buf_init(&chunk) != 0)
goto out;
host = sp_host_new(&r, &ag, NULL);
if (host == NULL || sp_plugin_load(host, "plugins/lcm/lcm.so", &err) != 0)
goto out;
ag.host = host;
if (sp_mock_init(&m) != 0)
goto out;
have_mock = 1;
for (i = 0; i < payload; i++)
if (sp_buf_puts(&chunk, "x") != 0)
goto out;
for (i = 0; i < calls; i++) {
sp_buf_clear(&reply);
if (sp_buf_printf(&reply, "tool echo %s", chunk.p) != 0 ||
sp_mock_push(&m, 200, reply.p) != 0)
goto out;
}
if (sp_mock_push(&m, 200, "answer done") != 0)
goto out;
ag.tr = sp_mock_transport(&m);
rc = sp_agent_run(&ag, "start", &answer, &err);
if (stats != NULL)
*stats = ag.stats;
if (rc == 0) {
CHECK(answer.p != NULL && strcmp(answer.p, "done") == 0);
} else {
fprintf(stderr, "FAIL budget %zu: rc %d: %s\n", budget, rc,
err.p != NULL ? err.p : "(no error)");
failures++;
}
out:
if (have_mock)
sp_mock_free(&m);
sp_host_free(host);
sp_buf_free(&answer);
sp_buf_free(&err);
sp_buf_free(&reply);
sp_buf_free(&chunk);
sp_registry_free(&r);
return rc;
}
int
main(void)
{
@@ -172,6 +264,25 @@ main(void)
/* ---- a plugin that is not a compactor cannot register one ---- */
CHECK(sp_host_add_compactor(host, NULL) == -1);
/*
* ---- the loop compacts at a budget, not only the plugin in isolation ----
* 8 KiB and 32 KiB (a rough 8k-token window). Each request has to fit
* after compaction or the turn fails; the counter is the measurement.
*/
{
struct sp_agent_stats st;
memset(&st, 0, sizeof(st));
CHECK(run_budget(8192, 40, 400, &st) == 0);
CHECK(st.compactions >= 1);
CHECK(st.steps == 41);
memset(&st, 0, sizeof(st));
CHECK(run_budget(32768, 120, 400, &st) == 0);
CHECK(st.compactions >= 1);
CHECK(st.steps == 121);
}
sp_host_free(host2);
sp_host_free(host);
sp_buf_free(&err);
+69
View File
@@ -13,6 +13,7 @@
#include <unistd.h>
#include "splinter.h"
#include "splinter_plugin.h"
#include "config.h"
static int failures;
@@ -181,6 +182,74 @@ main(void)
(void)system(line);
}
/*
* ---- a delegate is a task on the panel, and the panel says so ----
* The call opens a task before it runs and closes it after; this is the
* cycle that used to be claimed without a test. The widget keeps the
* finished entry, so the assertion is possible after the turn.
*/
{
struct sp_config c;
struct sp_registry r;
struct sp_agent ag;
struct sp_host *host;
struct sp_buf out, err;
char tdir[] = "/tmp/splinter-panel-XXXXXX";
char path[400], line[400], snap[512];
const char *oldpath = getenv("PATH");
const struct sp_tool *t;
FILE *f;
size_t n;
CHECK(mkdtemp(tdir) != NULL);
snprintf(path, sizeof(path), "%s/ssh", tdir);
f = fopen(path, "w");
CHECK(f != NULL);
if (f != NULL) {
fputs("#!/bin/sh\necho 'antwort vom panel'\n", f);
fclose(f);
}
(void)chmod(path, 0755);
snprintf(line, sizeof(line), "%s:%s", tdir,
oldpath != NULL ? oldpath : "/usr/bin:/bin");
(void)setenv("PATH", line, 1);
memset(&c, 0, sizeof(c));
add(&c, "panel", "zeigt sich im panel", "panel");
snprintf(c.delegate[0].host, sizeof(c.delegate[0].host), "panelsrv");
c.delegate[0].max_parallel = 1;
memset(&r, 0, sizeof(r));
memset(&ag, 0, sizeof(ag));
CHECK(sp_buf_init(&out) == 0);
CHECK(sp_buf_init(&err) == 0);
host = sp_host_new(&r, &ag, NULL);
CHECK(host != NULL);
CHECK(sp_plugin_load(host, "plugins/tasks/tasks.so", &err) == 0);
CHECK(sp_delegate_register(&r, &c, host) == 0);
t = sp_registry_find(&r, "delegate");
CHECK(t != NULL);
if (t != NULL)
(void)t->run("{\"task\":\"zeig dich\",\"tags\":\"panel\"}",
&out, t->ctx);
CHECK(out.p != NULL && strstr(out.p, "antwort vom panel") != NULL);
n = sp_host_widget_snapshot(host, snap, sizeof(snap));
if (getenv("TEST_VERBOSE") != NULL)
fprintf(stderr, "panel: %s\n", snap);
CHECK(n > 0);
CHECK(strstr(snap, "delegate:panel") != NULL);
CHECK(strstr(snap, "exit 0") != NULL);
CHECK(sp_host_meter(host)->tasks_running == 0);
sp_host_free(host);
sp_registry_free(&r);
sp_buf_free(&out);
sp_buf_free(&err);
(void)setenv("PATH", oldpath != NULL ? oldpath : "/usr/bin:/bin", 1);
snprintf(line, sizeof(line), "rm -rf '%s'", tdir);
(void)system(line);
}
/*
* ---- a delegate at its limit is benched and the task goes on ----
* Fake ssh: host "spent" answers like claude with an empty account, host
+137
View File
@@ -0,0 +1,137 @@
/*
* splinter -- markdown tables.
*
* The chat is monospace, so a table is only a table when the pipes line up.
* These cases pin the shape a model emits and the cases that must stay text:
* no separator, a pipe in prose, ragged rows, text before and after the block.
*/
#include <stdio.h>
#include <string.h>
#include "splinter.h"
#include "md.h"
static int failures;
#define CHECK(cond) do { \
if (!(cond)) { \
fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \
failures++; \
} \
} while (0)
static void
check_format(const char *in, const char *want)
{
struct sp_buf b;
int rc;
if (sp_buf_init(&b) != 0) {
fprintf(stderr, "FAIL init\n");
failures++;
return;
}
rc = sp_md_table_format(in, &b);
if (rc != 1) {
fprintf(stderr, "FAIL %s:%d: rc %d for:\n%s\n", __FILE__,
__LINE__, rc, in);
failures++;
} else if (b.p == NULL || strcmp(b.p, want) != 0) {
fprintf(stderr, "FAIL %s:%d:\n--- in ---\n%s"
"--- want ---\n%s--- got ---\n%s\n", __FILE__, __LINE__,
in, want, b.p != NULL ? b.p : "(null)");
failures++;
}
sp_buf_free(&b);
}
static void
check_no_table(const char *in)
{
struct sp_buf b;
int rc;
if (sp_buf_init(&b) != 0) {
failures++;
return;
}
rc = sp_md_table_format(in, &b);
if (rc != 0 || b.len != 0) {
fprintf(stderr, "FAIL %s:%d: expected no table, rc %d, %zu B\n",
__FILE__, __LINE__, rc, b.len);
failures++;
}
sp_buf_free(&b);
}
int
main(void)
{
/* header, separator, body: widths come from the longest cell */
check_format("| a | b |\n| --- | --- |\n| 1 | 22 |\n",
"| a | b |\n"
"|---|----|\n"
"| 1 | 22 |\n");
/* alignment markers are syntax, not text */
check_format("| a | b |\n|:---|---:|\n| 1 | 2 |\n",
"| a | b |\n"
"|---|---|\n"
"| 1 | 2 |\n");
/* text before and after the block survives verbatim */
check_format("vor\n| a | b |\n|---|---|\n| 1 | 2 |\nnach\n",
"vor\n"
"| a | b |\n"
"|---|---|\n"
"| 1 | 2 |\n"
"nach\n");
/* ragged rows: missing cells are empty, extra cells get a column */
check_format("| a | b |\n|---|---|\n| 1 |\n| 2 | 3 | 4 |\n",
"| a | b | |\n"
"|---|---|---|\n"
"| 1 | | |\n"
"| 2 | 3 | 4 |\n");
/* UTF-8: the width is the bytes the screen will consume */
check_format("| \xc3\xa4 | b |\n|---|---|\n| 1 | 2 |\n",
"| \xc3\xa4 | b |\n"
"|----|---|\n"
"| 1 | 2 |\n");
/* a table at the very end gets the newline the row needs */
check_format("| a |\n|---|\n| 1 |",
"| a |\n"
"|---|\n"
"| 1 |\n");
/* two blocks in one answer are both formatted */
check_format("| a |\n|---|\n| 1 |\ntext\n| bb |\n|----|\n| 22 |\n",
"| a |\n"
"|---|\n"
"| 1 |\n"
"text\n"
"| bb |\n"
"|----|\n"
"| 22 |\n");
/* a pipe in prose and no separator line is not a table */
check_no_table("a | b\nno separator here\n");
check_no_table("| a | b |\n| 1 | 2 |\n");
check_no_table("plain text\n");
/* the first line alone is not a table */
check_no_table("| a | b |\n");
/* detection: only a header at the very start counts */
CHECK(sp_md_table_starts("| a | b |\n|---|---|\n| 1 | 2 |\n") == 1);
CHECK(sp_md_table_starts("text\n| a |\n|---|\n") == 0);
CHECK(sp_md_table_starts("| a |\n|---|\n") == 1);
CHECK(sp_md_table_starts("| a |\nno separator\n") == 0);
CHECK(sp_md_table_starts(NULL) == 0);
if (failures == 0)
printf("test_md: ok\n");
return failures == 0 ? 0 : 1;
}
+107
View File
@@ -0,0 +1,107 @@
/*
* splinter -- planner plugin smoke test.
*
* The plan belongs to the session: the tools add, list and update tasks, the
* list is on disk, and a second reader sees the same file. This is not the
* background-task store; that one owns processes.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "splinter.h"
#include "splinter_plugin.h"
static int failures;
#define CHECK(cond) do { \
if (!(cond)) { \
fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \
failures++; \
} \
} while (0)
int
main(void)
{
struct sp_session_info sess;
struct sp_registry reg;
struct sp_agent ag;
struct sp_host *host;
struct sp_buf out, err;
const struct sp_tool *t;
char dir[] = "/tmp/splinter-plan-XXXXXX";
char path[600], snap[512], text[2048];
FILE *f;
size_t n;
CHECK(mkdtemp(dir) != NULL);
memset(&sess, 0, sizeof(sess));
snprintf(sess.dir, sizeof(sess.dir), "%s", dir);
memset(&reg, 0, sizeof(reg));
memset(&ag, 0, sizeof(ag));
CHECK(sp_buf_init(&out) == 0);
CHECK(sp_buf_init(&err) == 0);
host = sp_host_new(&reg, &ag, &sess);
CHECK(host != NULL);
CHECK(sp_plugin_load(host, "plugins/planner/planner.so", &err) == 0);
t = sp_registry_find(&reg, "plan_task_add");
CHECK(t != NULL);
if (t != NULL)
(void)t->run("{\"description\":\"write the planner test\"}",
&out, t->ctx);
CHECK(out.p != NULL && strstr(out.p, "added plan task #1") != NULL);
sp_buf_clear(&out);
t = sp_registry_find(&reg, "plan_task_list");
CHECK(t != NULL);
if (t != NULL)
(void)t->run("{}", &out, t->ctx);
CHECK(out.p != NULL &&
strstr(out.p, "write the planner test") != NULL);
CHECK(out.p != NULL && strstr(out.p, "[todo]") != NULL);
sp_buf_clear(&out);
t = sp_registry_find(&reg, "plan_task_update");
CHECK(t != NULL);
if (t != NULL)
(void)t->run("{\"id\":\"1\",\"status\":\"doing\"}", &out,
t->ctx);
CHECK(out.p != NULL && strstr(out.p, "[doing]") != NULL);
/* the command path is the same store */
sp_buf_clear(&out);
CHECK(sp_host_command(host, "tasks", "ls", &out) == 0);
CHECK(out.p != NULL &&
strstr(out.p, "write the planner test") != NULL);
/* the file is the contract: a second reader sees it */
snprintf(path, sizeof(path), "%s/plan_tasks.json", dir);
f = fopen(path, "r");
CHECK(f != NULL);
if (f != NULL) {
n = fread(text, 1, sizeof(text) - 1, f);
text[n] = '\0';
fclose(f);
CHECK(strstr(text, "write the planner test") != NULL);
CHECK(strstr(text, "\"doing\"") != NULL);
}
n = sp_host_widget_snapshot(host, snap, sizeof(snap));
CHECK(n > 0);
CHECK(strstr(snap, "plan:") != NULL);
sp_host_free(host);
sp_registry_free(&reg);
sp_buf_free(&out);
sp_buf_free(&err);
snprintf(path, sizeof(path), "rm -rf '%s'", dir);
(void)system(path);
if (failures == 0)
printf("test_planner: ok\n");
return failures == 0 ? 0 : 1;
}
+91
View File
@@ -0,0 +1,91 @@
/*
* splinter -- shared provider/key state.
*
* The state is what makes two splinter processes agree that a key is out of
* quota: one writes, the other reads, and the answer is the same. HOME points
* at a fresh directory, so the test never touches the real ~/.splinter.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "provstate.h"
static int failures;
#define CHECK(cond) do { \
if (!(cond)) { \
fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \
failures++; \
} \
} while (0)
int
main(void)
{
char dir[] = "/tmp/splinter-prov-XXXXXX";
char path[700], fp1[32], fp2[32];
struct sp_prov_state st;
struct stat sb;
long now, ready = 0;
char reason[128];
CHECK(mkdtemp(dir) != NULL);
CHECK(setenv("HOME", dir, 1) == 0);
now = (long)time(NULL);
/* no state yet: admit */
CHECK(sp_provstate_load("openai", "key-a", &st) != 0);
CHECK(sp_provstate_preflight("openai", "key-a", now, &ready, reason,
sizeof(reason)) == 0);
CHECK(ready == 0);
/* a 429 with Retry-After becomes a quota wait both processes can see */
sp_provstate_account("openai", "key-a", 429, 10, 20, 3600);
CHECK(sp_provstate_load("openai", "key-a", &st) == 0);
CHECK(st.last_status == 429);
CHECK(st.req_count == 1);
CHECK(st.tok_in == 10 && st.tok_out == 20);
CHECK(st.quota_ready_at > now && st.quota_ready_at <= now + 3601);
CHECK(sp_provstate_preflight("openai", "key-a", now, &ready, reason,
sizeof(reason)) == 1);
CHECK(ready == st.quota_ready_at);
CHECK(strstr(reason, "quota") != NULL);
/* the state file is private */
snprintf(path, sizeof(path), "%s/.splinter/providers/openai", dir);
CHECK(stat(path, &sb) == 0);
CHECK((sb.st_mode & 077) == 0);
CHECK(sp_provstate_base("openai", "key-a", path, sizeof(path)) != NULL);
/* a 503 is a short backoff, on its own key */
sp_provstate_account("openai", "key-b", 503, 0, 0, 30);
CHECK(sp_provstate_load("openai", "key-b", &st) == 0);
CHECK(st.backoff_until > now);
CHECK(sp_provstate_preflight("openai", "key-b", now, &ready, reason,
sizeof(reason)) == 2);
CHECK(strstr(reason, "backoff") != NULL);
/* keys are separate: another key is still admitted */
CHECK(sp_provstate_preflight("openai", "key-c", now, &ready, reason,
sizeof(reason)) == 0);
/* the fingerprint is stable and does not contain the secret */
CHECK(sp_key_fingerprint("secret-one", fp1, sizeof(fp1)) != NULL);
CHECK(sp_key_fingerprint("secret-one", fp2, sizeof(fp2)) != NULL);
CHECK(strcmp(fp1, fp2) == 0);
CHECK(strstr(fp1, "secret") == NULL);
CHECK(sp_key_fingerprint("secret-two", fp2, sizeof(fp2)) != NULL);
CHECK(strcmp(fp1, fp2) != 0);
CHECK(sp_key_fingerprint("", fp2, sizeof(fp2)) == NULL);
snprintf(path, sizeof(path), "rm -rf '%s'", dir);
(void)system(path);
if (failures == 0)
printf("test_provstate: ok\n");
return failures == 0 ? 0 : 1;
}
+117
View File
@@ -0,0 +1,117 @@
/*
* splinter -- swarm (local fleet) tests.
*
* Two instances in one directory, in one process: the first binds the socket
* and becomes master, the second connects as a slave. What is asserted is the
* wire cycle -- welcome, id, routed text, busy report -- not the UI.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "swarm.h"
static int failures;
#define CHECK(cond) do { \
if (!(cond)) { \
fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \
failures++; \
} \
} while (0)
static void
nap_ms(long ms)
{
struct timespec ts;
ts.tv_sec = ms / 1000;
ts.tv_nsec = (ms % 1000) * 1000000L;
nanosleep(&ts, NULL);
}
int
main(void)
{
struct swarm master, slave;
char dir[] = "/tmp/splinter-swarm-XXXXXX";
char buf[512], list[512], path[600];
int i, got = 0;
CHECK(mkdtemp(dir) != NULL);
CHECK(swarm_init(&master, dir) == 0);
CHECK(master.role == SWARM_MASTER);
CHECK(master.id == 0);
CHECK(swarm_init(&slave, dir) == 0);
CHECK(slave.role == SWARM_SLAVE);
/* the master has to accept before the welcome reaches the slave */
for (i = 0; i < 50 && slave.id < 0; i++) {
swarm_poll(&master);
swarm_poll(&slave);
if (slave.id < 0)
nap_ms(10);
}
CHECK(slave.id == 1);
/* a routed line arrives in the slave's inbox and says it came from afar */
CHECK(swarm_route(&master, -1, "hallo slave") == 1);
for (i = 0; i < 50 && !got; i++) {
swarm_poll(&slave);
got = swarm_take_inbox(&slave, buf, sizeof(buf));
if (!got)
nap_ms(10);
}
CHECK(got == 1);
CHECK(strcmp(buf, "hallo slave") == 0);
CHECK(swarm_inbox_remote(&slave) == 1);
CHECK(swarm_inbox_remote(&slave) == 0); /* cleared after reading */
/* the master can route to itself without a socket round trip */
CHECK(swarm_route(&master, 0, "an mich") == 0);
CHECK(swarm_take_inbox(&master, buf, sizeof(buf)) == 1);
CHECK(strcmp(buf, "an mich") == 0);
CHECK(swarm_inbox_remote(&master) == 1);
/* a busy report is visible in the master's list */
swarm_report_busy(&slave, 7);
for (i = 0; i < 50; i++) {
swarm_poll(&master);
swarm_list(&master, list, sizeof(list));
if (strstr(list, "busy=7") != NULL)
break;
nap_ms(10);
}
CHECK(strstr(list, "busy=7") != NULL);
CHECK(strstr(list, "slave pid=") != NULL);
swarm_status(&master, buf, sizeof(buf));
CHECK(strstr(buf, "master 0") != NULL);
CHECK(strstr(buf, "1 slaves") != NULL);
swarm_status(&slave, buf, sizeof(buf));
CHECK(strstr(buf, "slave 1") != NULL);
/* close the slave first: the master's socket lives longer */
swarm_close(&slave);
swarm_close(&master);
/* a directory with no fleet is standalone, not an error */
{
struct swarm solo;
CHECK(swarm_init(&solo, dir) == 0);
CHECK(solo.role == SWARM_MASTER);
swarm_close(&solo);
}
snprintf(path, sizeof(path), "rm -rf '%s'", dir);
(void)system(path);
if (failures == 0)
printf("test_swarm: ok\n");
return failures == 0 ? 0 : 1;
}
+4
View File
@@ -86,6 +86,10 @@ typed 'halb'; key C-l; sleep 1
check shows '^>halb'
key BSpace BSpace; key C-l; sleep 1
check shows '^>ha *$'
typed 'zeig eine tabelle'; key Enter
check shows '| a | b |'
check shows '|---|----|'
check shows '| 1 | 22 |'
tmux resize-window -t $S -x 70 -y 20; sleep 1
check shows '^>'
check test "$(quit_code)" = 0
+53 -18
View File
@@ -9,6 +9,7 @@ when a key is missing, so index.html and index.en.html can never drift apart.
python3 tools/gen_www.py --check # compare, exit 1 if they are stale
"""
import pathlib
import re
import sys
ROOT = pathlib.Path(__file__).resolve().parent.parent
@@ -18,6 +19,35 @@ LANGS = ["de", "en", "pt_BR"]
FILES = {"de": "index.html", "en": "index.en.html",
"pt_BR": "index.pt.html"}
# The page states sizes and counts. They are counted here, from the tree, so a
# new test, plugin or tool cannot leave a number behind that was true last week.
def _c_lines(root):
return sum(len(p.read_text(encoding="utf-8").splitlines())
for p in sorted(root.rglob("*"))
if p.is_file() and p.suffix in (".c", ".h"))
def counts():
plugins = [p for p in (ROOT / "plugins").iterdir()
if p.is_dir() and any(p.glob("*.c"))]
tests = list((ROOT / "tests").glob("test_*.c"))
palettes = (ROOT / "src" / "palettes.c").read_text(encoding="utf-8")
tools = set()
for p in (list((ROOT / "src").glob("*.c")) +
list((ROOT / "plugins").glob("*/*.c"))):
tools.update(re.findall(r'\.name = "([a-z_]+)"',
p.read_text(encoding="utf-8")))
return {
"N_LINES": (_c_lines(ROOT / "src") + _c_lines(ROOT / "include") +
_c_lines(ROOT / "plugins")),
"N_TOOLS": len(tools),
"N_TESTS": len(tests),
"N_PLUGINS": len(plugins),
"N_THEMES": len(re.findall(r'^\s*\{ "', palettes, re.M)),
}
HEAD = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="{{lang}}">
@@ -73,9 +103,9 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
<h1>splinter<span>_</span></h1>
<p class="lead">{{lead}}</p>
<p class="meta"><b>9.125</b> {{m_lines}} &middot;
<b>248.568</b> {{m_binary}} &middot; <b>21</b> {{m_tests}} &middot;
<b>8</b> {{m_plugins}} &middot; <b>42</b> {{m_themes}} &middot; BSD-3-Clause</p>
<p class="meta"><b>@@N_LINES@@</b> {{m_lines}} &middot;
<b>@@N_TOOLS@@</b> {{m_tools}} &middot; <b>@@N_TESTS@@</b> {{m_tests}} &middot;
<b>@@N_PLUGINS@@</b> {{m_plugins}} &middot; <b>@@N_THEMES@@</b> {{m_themes}} &middot; BSD-3-Clause</p>
{{body}}
@@ -177,7 +207,7 @@ T = {
"Autorisierungsklassen, Plugins, jedes Modell das OpenAI spricht — von uns "
"gebaut, damit wir es umbauen koennen, statt uns an das Verhalten eines "
"fremden Clients zu gewoehnen.",
"m_lines": "Zeilen C99/POSIX", "m_binary": "Bytes Binary",
"m_lines": "Zeilen C99/POSIX", "m_tools": "Werkzeuge",
"m_tests": "Test-Programme", "m_plugins": "Plugins", "m_themes": "Farbschemata",
"foot": "splinter — C99/POSIX, BSD-3-Clause. Manual: <code>man ./docs/splinter.1</code>"
" &middot; Plugin-ABI: <code>docs/PLUGINS.md</code> &middot; Wir nehmen "
@@ -192,7 +222,7 @@ T = {
"lead": "An agent harness you own: chat in the terminal, tools with authorization "
"classes, plugins, any model that speaks OpenAI — built by us so we can change "
"it, instead of getting used to how somebody else's client behaves.",
"m_lines": "lines of C99/POSIX", "m_binary": "bytes binary",
"m_lines": "lines of C99/POSIX", "m_tools": "tools",
"m_tests": "test programs", "m_plugins": "plugins", "m_themes": "palettes",
"foot": "splinter — C99/POSIX, BSD-3-Clause. Manual: <code>man ./docs/splinter.1</code>"
" &middot; Plugin ABI: <code>docs/PLUGINS.md</code> &middot; We take things "
@@ -208,7 +238,7 @@ T["pt_BR"] = {
"classes de autorizacao, plugins, qualquer modelo que fale OpenAI - "
"escrito por nos para poder mudar-lo, em vez de nos acostumar com o "
"comportamento de um cliente alheio.",
"m_lines": "linhas C99/POSIX", "m_binary": "bytes do binario",
"m_lines": "linhas C99/POSIX", "m_tools": "ferramentas",
"m_tests": "programas de teste", "m_plugins": "plugins", "m_themes": "paletas",
"foot": "splinter - C99/POSIX, BSD-3-Clause. Manual: <code>man ./docs/splinter.1</code>"
" &middot; ABI de plugins: <code>docs/PLUGINS.md</code>",
@@ -285,8 +315,8 @@ SECTIONS = {
"<p>Deine Worte, die Antwort, das Denken, jeder Werkzeugaufruf mit Argumenten, jede "
"Beobachtung, Fehler, Token-Zahlen. Nichts gekuerzt — ein Log, das nur das Gute "
"behaelt, kann einen schlechten Turn nicht erklaeren.</p>"),
(BUILD.format(h="Bauen", c_make="248 KB, nichts ausser libc und curses",
c_check="21 Test-Programme, plus i18n-Pruefer",
(BUILD.format(h="Bauen", c_make="klein, nichts ausser libc und curses",
c_check="@@N_TESTS@@ Test-Programme, plus i18n-Pruefer",
c_chat="Chat, Konfiguration wird gelesen", c_gw="Telegram-Gateway",
p="POSIX make, C99, <code>-Wall -Wextra -Werror</code>. Die NetBSD-curses liegt im "
"Baum, damit das Binary nicht von der Laune einer Distribution abhaengt.")),
@@ -364,8 +394,8 @@ SECTIONS = {
"<p>Your words, the answer, the reasoning, every tool call with its arguments, every "
"observation, failures, token counts. Nothing truncated — a log that keeps only the "
"good parts cannot explain a bad turn.</p>"),
(BUILD.format(h="Building", c_make="248 KB, nothing but libc and curses",
c_check="21 test programs, plus the i18n checker",
(BUILD.format(h="Building", c_make="small, nothing but libc and curses",
c_check="@@N_TESTS@@ test programs, plus the i18n checker",
c_chat="chat, the config is read", c_gw="Telegram gateway",
p="POSIX make, C99, <code>-Wall -Wextra -Werror</code>. NetBSD curses is vendored, so "
"the binary does not depend on a distribution's mood.")),
@@ -403,7 +433,7 @@ ist in der Kopfzeile sichtbar, bevor jemand seinen Text liest.</p>""",
<p>Als Client holt splinter die Werkzeuge eines MCP-Servers. Als Server stellt es
seine eigenen hin:</p>
<pre><span class="u">$</span> splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
splinter: MCP server on 0.0.0.0:8098 (14 tools, read only)</pre>
splinter: MCP server on 0.0.0.0:8098 (@@N_TOOLS@@ tools, read only)</pre>
<p>Ein anderer Agent bekommt <code>initialize</code>, <code>tools/list</code> und
<code>tools/call</code>. Lesende Werkzeuge werden bedient, mutierende und
destruktive nur mit <code>--autonomous</code> &mdash; ein fremder Agent fuehrt hier
@@ -440,7 +470,7 @@ in the header before anybody reads its prose.</p>""",
<p>As a client splinter fetches an MCP server's tools. As a server it offers its
own:</p>
<pre><span class="u">$</span> splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
splinter: MCP server on 0.0.0.0:8098 (14 tools, read only)</pre>
splinter: MCP server on 0.0.0.0:8098 (@@N_TOOLS@@ tools, read only)</pre>
<p>Another agent gets <code>initialize</code>, <code>tools/list</code> and
<code>tools/call</code>. Read tools are served; mutating and destructive ones only
with <code>--autonomous</code> &mdash; a foreign agent does not run shell commands
@@ -477,10 +507,10 @@ transcript na ordem em que acontecem.</p>""",
(read, mutate, destructive) - nunca o modelo, nunca o prompt. Um plugin pode
entrar na frente com um gate: permitir, negar com motivo, ou nao opinar.</p>""",
"""<h2>Ferramentas</h2>
<p>14 ferramentas: <code>read</code>, <code>write</code>, <code>edit</code>,
<code>search</code>, <code>list</code>, <code>run</code>,
<code>folder_history</code>, <code>delegate</code>,
<code>delegate_parallel</code> e as de leitura do sistema.</p>""",
<p>@@N_TOOLS@@ ferramentas: <code>read</code>, <code>write</code>, <code>edit</code>,
<code>search</code>, <code>list</code>, <code>run</code>, <code>folder_history</code>,
<code>delegate</code>, <code>delegate_parallel</code>, as de leitura do sistema e as de
skills, memoria e pesquisa na web.</p>""",
"""<h2>Transportes e plugins</h2>
<p>Transporte e um vtable: openai (HTTP/SSE), cli (claude, opencode), mock para
teste. Plugins sao <code>.so</code> carregados com dlopen: lcm, focus, reminder,
@@ -505,7 +535,7 @@ mesmos slash commands do terminal.</p>""",
<code>wire.jsonl</code> (o que foi de fato enviado ao modelo).</p>""",
"""<h2>Compilar</h2>
<pre>make
make check <span class="d"># 21 binarios de teste, i18n, site</span></pre>
make check <span class="d"># @@N_TESTS@@ binarios de teste, i18n, site</span></pre>
<p>Sem dependencias alem de libc e pthread; ncurses vem do vendor.</p>""",
"""<h2>O que nao e</h2>
<ul><li>nao e um modelo;</li><li>nao e um servico - e um programa;</li>
@@ -518,7 +548,7 @@ make check <span class="d"># 21 binarios de teste, i18n, site</span></pre>
poe suas proprias chaves.</p>""",
"""<h2>As duas direcoes: MCP</h2>
<pre><span class="u">$</span> splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
splinter: MCP server on 0.0.0.0:8098 (14 tools, read only)</pre>
splinter: MCP server on 0.0.0.0:8098 (@@N_TOOLS@@ tools, read only)</pre>
<p>Como cliente busca ferramentas; como servidor oferece as suas. Mutar so com
<code>--autonomous</code>.</p>""",
"""<h2>Pipe, pasta, primeira conversa</h2>
@@ -558,9 +588,14 @@ def render(lang):
for key, value in strings.items():
html = html.replace("{{%s}}" % key, value)
html = html.replace("{{body}}", body)
for key, value in counts().items():
html = html.replace("@@%s@@" % key, str(value))
if "{{" in html:
leftover = html[html.index("{{"):html.index("{{") + 40]
raise SystemExit("gen_www: unfilled placeholder: %s" % leftover)
m = re.search(r"@@N_[A-Z_]+@@", html)
if m is not None:
raise SystemExit("gen_www: unfilled count: %s" % m.group(0))
return html