The harness was two halves that could not see each other: main.c built the
agent, ui.c ran it -- with the curses thread model, the approval condition
variable, the slash commands and the provider switching inside the drawing
code. A second front end had to copy all of it.
Now:
src/backend/ engine.c owns the session, the turn thread, the event queue
and every command; agent, transports, tools, session, config,
providers, plugins and the protocol servers move here.
src/frontend/ curses.c draws and reads keys through ui_backend.h;
ui_local.c is the engine in this process, ui_remote.c is a
served engine behind a socket. protocol.c serves the engine
as JSON lines (protocol 2: history, approvals, steering);
client.c is splinterctl, the reference client.
splinter --serve / --attach: the same screen runs as a client of a served
engine, so the socket carries everything the front end needs. docs/PROTOCOL.md
and docs/FRONTENDS.md describe the contract; docs/proto-example.py is a
60-line client. tests/test_engine, test_protocol and test_attach cover the
event order, the socket and the attach mode.
Review fixes in the same tree: dynamic line buffers (9 KB prompts and 8 KB
events were truncated), a turn event no longer ends the busy window (steer
leftovers), the screen finalises every turn, /new keeps the profile, reopens
the log and gets unique ids, the profile is remembered in <session>.agent so
--resume comes back in it, agent statistics are a locked snapshot (no data
race), !shell keeps 64 KiB with a marker, the socket probes for a live server,
compares its inode and sets CLOEXEC/SNDTIMEO, exit 2 means configuration,
BSD peer checks use getpeereid, and the i18n checker scans the new
subdirectories again.
Includes the parallel session's SSE fix: the parser reports what a line
produced, so a tool name no longer lands in the answer ("readread").
23 lines
768 B
Bash
Executable File
23 lines
768 B
Bash
Executable File
#!/bin/sh
|
|
# Writes a C file holding the message catalogues, so a splinter that was copied
|
|
# somewhere (make install, a tarball) never shows raw keys like "ui.ready".
|
|
# usage: embed_catalogs.sh share/locale/*.msg > src/backend/catalogs.c
|
|
echo '/* generated by tools/embed_catalogs.sh from share/locale -- do not edit */'
|
|
echo '#include "splinter.h"'; echo '#include "i18n.h"'
|
|
echo
|
|
for f in "$@"; do
|
|
n=$(basename "$f" .msg | tr -c 'A-Za-z0-9\n' '_')
|
|
echo "static const char cat_$n[] ="
|
|
sed 's/\\/\\\\/g; s/"/\\"/g; s/^/\t"/; s/$/\\n"/' "$f"
|
|
echo " ;"
|
|
done
|
|
echo
|
|
echo 'const struct sp_embedded sp_embedded_catalogs[] = {'
|
|
for f in "$@"; do
|
|
l=$(basename "$f" .msg)
|
|
n=$(echo "$l" | tr -c 'A-Za-z0-9\n' '_')
|
|
echo " { \"$l\", cat_$n },"
|
|
done
|
|
echo ' { 0, 0 }'
|
|
echo '};'
|