5 Commits
Author SHA1 Message Date
lotherk fa16bfd0a9 foreign: adopt a claude, hermes or opencode session as a splinter session
Another harness's conversation is not a session until splinter can resume
it. plugins/foreign reads the three stores that already exist on the
machine - ~/.claude/projects/<slug>/<id>.jsonl, <root>/state.db (and
profiles/*/state.db) and opencode.db's session_v2/session_message - and
offers four tools plus /foreign:

  list, search TEXT, read SOURCE ID, import SOURCE ID

The stores are read with sqlite3 -readonly: an import copies, it never
moves. Reasoning blocks are dropped on the way in, because a provider does
not accept another model's thinking as evidence. Tool calls arrive with
their results in place, which is what makes the imported session worth
resuming instead of retyping.

import writes a real splinter session: the conversation as a replayable
jsonl, and a .meta with the source's title, its start time and *its*
working directory. So /open continues it in the chat,
--session-id <id> --resume in a shell, and -c finds it in the directory the
conversation actually ran in. The marker foreign=<source>:<id> survives
every later reopen, which needed the core's .meta sidecar to carry keys it
does not own.

Building this found nine bugs, each one seen red before it was green:

  - four use-after-frees: mcp_arg_string returns a pointer *into* the parse
    tree, read after mcp_json_free. That garbage in `only`/`src` was why a
    list of three stores answered "no sessions" and named AÃ_Â¥U.
  - sql_json took "no rows" for a failure (NULL), so every empty answer
    looked like a broken database.
  - args_split never terminated its buffers: /foreign list became
    "unknown subcommand 'list('".
  - path_join(dir, id, ".meta") built dir/id/.meta, so the sidecar landed
    in a subdirectory.
  - claude_slug_dir had the sign inverted and returned -1 for every
    non-empty cwd, so the project directory was never found.
  - sp_session_open overwrote cwd with getcwd() on *every* open, though the
    comment beside it promised the opposite: imports claimed the directory
    they were imported from and -c then picked the wrong session.
  - hermes_text ran strncmp(p, "\x00json:", 6) on an empty content, a
    one-byte allocation - heap-buffer-overflow, found by ASAN. The marker is
    stripped in SQL anyway.
  - hermes_calls never freed the root node on the object path (5456 bytes
    over 42 allocations).
  - list_any reported strerror(errno) with errno never set: a real file with
    the wrong schema read as "No such file or directory". The SQL reason is
    passed through now.

Checked end to end against the stores on this machine: claude 64 sessions,
opencode 25, hermes 0 (both hermes databases here are empty, count(*) = 0).
A real opencode session of 150 messages reads back with its tool output; one
of 75 imports with the right cwd and title, --resume sends its history, and
-c from the source directory opens it.

tests/sh/port.sh comes along: the shell tests guessed a port with
20000 + $$ % 30000 and on 2026-11-21 landed on one dtsession held. The fake
died, curl got an answer from dtsession, and twenty checks blamed the
gateway. They ask the kernel for a free port now.
2026-11-21 21:26:43 +00:00
lotherk bff47eede8 ui: palette roles, a working unlimited usage count, /goal as the recap
Three things the screen and the goal were getting wrong.

Colours. The theme had one accent for the user and grey for everything
else. theme.h now carries agent, think, tool and notice colours. A CDE
palette maps them to sets 7 (answer), 3 (reasoning), 6 (tool) and 8
(status); Xresources uses colour10/11/14/13 on dark and 2/3/6/5 on
light. Role colours keep their hue and are pushed from the surface only
when they would disappear; each role has a slightly different minimum,
so even a monochrome palette yields distinguishable steps. The 256-colour
mapping now takes the nearest cube/ramp entry instead of rounding each
channel down, which turned a dark orange into grey 240.

Usage. sp_usage_get() only counted requests inside a declared window. A
provider without limit= therefore always read "0 calls" in the sidebar,
although every call was in its log. Calls are now counted when no window
is declared; test_usage covers it.

Goal. /goal <text> set a variable and answered "goal set" without starting
a turn. The engine now starts the recap prompt: the model writes a short
recap, the focus plugin remembers that answer and injects it every seventh
turn (SPLINTER_FOCUS_EVERY still overrides). /recap is gone as a command;
its old behaviour is what /goal does now. A palette and a wiki page are
not enough to make that visible: the prompt, the confirmation entry and
the sidebar goal all show up in the chat.

Tests: palette role separation and indexed roles in test_theme, four
unlimited calls in test_usage, recap capture/injection and the missing
/recap in test_focus, and a settle delay so the UI tests type after
ui_read_line() owns the keyboard. make check: all tests passed.
2026-11-16 17:48:22 +00:00
lotherk a9f175c25b backend/frontend: an engine every front end can talk to
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").
2026-11-16 09:06:51 +00:00
lotherkandClaude Opus 5.5 a32c591572 tests: drive a tmux server of their own, never the user's
test_agents_ui.sh ran on whatever server $TMUX pointed at, so a run inside
somebody's tmux created and typed into sessions there -- keys went into the
session the person was working in. It now drops $TMUX, points TMUX_TMPDIR at
its temp dir and refuses to signal a server it did not start, the way
test_ui.sh already did. test_a2a_ui.sh gets the same guard for its
kill-server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 21:21:55 +00:00
lotherk 93e955a4c7 a2a: stream the answer, and a --no-stream path
The A2A transport implements send_stream now: SSE events are read as
StreamResponse (task, message, statusUpdate, artifactUpdate), artifact and
message text goes to the screen as it arrives, intermediate status notes
are ignored, and a completed status message is the answer only when no
artifact or direct message text came. Failed/canceled/rejected and
input/auth-required states fail the turn instead of becoming an answer.

One-shot mode already streamed whenever a transport offered it, so the
plain send path was unreachable from the CLI. --no-stream asks for it.
test_a2a.sh covers both SendMessage and SendStreamingMessage; the new
test_a2a_ui.sh drives the UI streaming path through tmux.

README, PLUGINS.md, the man page and the site follow.
2026-11-09 23:32:49 +00:00