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

+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>