Commit Graph
107 Commits
Author SHA1 Message Date
lotherk 181b2c0638 ask: the model can put a question to the operator, in every front end
The `ask` tool asks and the answer -- or "nobody answered" -- becomes the
observation. Read class: it changes nothing on the machine, and the authority
is the operator, not a gate.

Front ends: the chat draws a dialog (options to pick, typed words still count),
the protocol carries it as an `ask` event and an `answer` command, MCP returns
it from splinter_say and resumes with splinter_answer, the Telegram gateway
sends it as a message and takes the next message from an allowed user.

What the review of the WIP found, and what this fixes:

- -p hung for the full 900 s ask wait: sp_engine_prompt installed engine_ask,
  but nobody polls events on the synchronous path. cfg.ask now stays NULL
  there, so the tool answers at once with "nobody can be asked here".
  Measured: 3 s instead of 900 s (was rc=124 after 20 s).
- splinter_say over MCP hung the same way, because tool_say only looked at
  st.waiting. It now looks at st.asking and returns the question; the client
  timed out at 15 s before, and the turn was lost.
- protocol.c read the question buffer uninitialized when sp_engine_ask
  returned 0.
- turn_ask answered nothing when the window could not be opened, which parked
  the turn for the full wait.
- pick_run computed the list height without the question's rows, so the
  highlighted row scrolled out of the window (reproduced: after nine Downs no
  ">" row was on the screen). pick_draw and pick_run now share pick_listtop().
- the Telegram gateway was dead for this tool: it runs its turns on a copy of
  e->base, where ask was never set, so the model was told "nobody can be
  asked" while the operator sat in the chat. New tg_ask, verified against a
  running daemon and covered in test_gateway.sh.
- tests/test_ask_ui.sh was untracked and not in make check, so it never ran.

A2A keeps no ask channel on purpose: there an approval pauses the task into
INPUT_REQUIRED, and the ask signature cannot express a pause -- saying
"nobody can be asked" is the honest answer there.

Tests: make check green (327 s), including the new test_ask_mcp.sh and
test_ask_ui.sh, both wired into make check. test_ask_mcp.sh was verified to
fail against the unfixed code (client times out, no result written).
make check-asan: 46 binaries clean. make check-tsan: 46 binaries, no races.
2026-11-24 07:57:35 +00:00
lotherk 4fc7614cc5 builtin: tools_root - the file tools stay inside one directory
The five file tools act with the rights of the process. The authorization
classes say *whether* a tool may run, never *where*: a model with mutate rights
- or a prompt-injected one - could write ~/.ssh/authorized_keys or the config
that names the plugins this harness loads.

core { tools_root = ~/src } closes that. Empty (the default) means no boundary,
so an existing setup is unchanged.

What makes it hold, rather than look like it:
- every path is resolved before it is used, and the resolved path is what the
  tool then opens (realpath for existing paths, resolve_target for one that
  does not exist yet, so a dangling symlink cannot be followed out);
- search resolves every entry it recurses into: stat() follows a directory
  symlink, so guarding only the argument left a door open (found and fixed in
  this change, the test went red without it);
- the root is resolved once at startup, and a root that does not exist is
  refused with the path in the message instead of matching nothing;
- run cannot be fenced (a shell opens any path); it starts in the root, and a
  failed chdir is written into the tool's observation, not the operator's
  terminal.

Verified: an escape by absolute path, by ../.., by a symlink inside, by a
dangling symlink, and through search's recursion are all refused in the live
engine path (scripted model, tool call in the session log); the same tree
inside the root still reads; without tools_root everything behaves as before.
Each guard was removed once to watch the test go red. tests: test_builtin,
test_config, test_secrets ok; make check: all tests passed; check_asan: all 46
binaries clean.
2026-11-23 16:55:49 +00:00
lotherk 6166acfdea config: a leading ~ is the home directory
The shipped --init-config template suggests "session_dir = ~/.splinter" and
"tools_root = ~/src". Nothing expanded "~": no shell is involved in reading
the file, so the first created a directory literally named "~" in the cwd and
the second made the tool fence match nothing.

set_path() now expands a leading "~/" (or a bare "~") for the settings that
name a place on disk: session_dir, state_dir, skills_dir, tools_root. A
"~user" form is left alone rather than half-guessed.

Verified: the template with both lines uncommented starts, writes its sessions
under $HOME and leaves no "~" directory behind; tests/test_config covers the
expansion (3 checks red without it, green with it); make check: all tests
passed.
2026-11-23 16:55:49 +00:00
lotherk 3b0de63e06 protocol: the model list carries its tag too
The listings got a request tag so a late answer could not be read as the
next request's; `models` was left out. A probe that outlived the client's
15 s timeout stayed in the socket and the following plain `models` read it
as its own answer - /model then drew the endpoint's models where the
configuration was asked for, and the picker's second request drew a stale
list.

Test: tests/test_remote_list.c, fake server answers the first models
request twice and never the second. Before the fix the second call
returned 2 rows (FAIL nm == 0), after it 0. Full suite green, ASan clean
on the 46 test binaries.
2026-11-23 12:55:04 +00:00
lotherk 4ff2844955 main: a port that is not a port is refused, not guessed
atoi() took anything on --mcp-listen-port, --a2a-listen-port and
--openai-listen-port: "abc" bound port 0 (a random port the operator was
never told) and "-5" bound 65531. Both started a server on a port nobody
chose and said nothing.

port_arg() parses with strtol, requires the whole string, and refuses
anything outside 1..65535, naming the option and the value.

Test: tests/test_args.sh, new, in make check. Six bad values are refused
with the reason; a valid port still starts the gateway and says which one
it took. With the check reverted the test reports 6 failures, with it
"test_args: ok". make check: all tests passed.

docs/splinter.1: the two documented port options say so.
2026-11-23 12:37:42 +00:00
lotherk 0fc81398dc protocol: a late answer cannot answer the next request
The listings were matched to their request by kind alone. A server slower
than the client's 5 s timeout left its answer in the socket, and the next
request of the same kind read it as its own: the /sessions picker drew one
source's sessions under another source's name. Seen live on 2026-11-22
against a --serve instance.

A request may now carry "tag":N, the server echoes it in the event that
answers it, and the client drops an event whose tag is not the one it waits
for. Without a tag both sides behave as before.

Test: tests/test_remote_list.c has the server echo the tag and send the
first sessions answer twice. With the tag check removed it reports
"the unanswered request still drew 2 row(s): erste zweite" and three FAILs,
with it green. make check: all tests passed.

Also in here: pick_match stops at SP_PICK_ROWS like pick_add does (the two
caps are the same constant, the write was only safe because of that).
2026-11-23 12:37:42 +00:00
lotherk 0b643ca6d9 servers: a silent client no longer holds the gateway or A2A server
Both HTTP servers answer one connection at a time. A client that sent half a
header and then went quiet held the whole gateway: a second client's complete
request was never answered (measured: recv timed out after 10s, with the lazy
socket open). The A2A server had the same shape with a five minute read
timeout, so one idle socket blocked every other request for five minutes.

Both now bound the read (gateway 60s, A2A 120s) and take the value from
SPLINTER_GATEWAY_READ_TIMEOUT / SPLINTER_A2A_READ_TIMEOUT so a test does not
wait a minute.

Tests: tests/slow_client.py and tests/slow_a2a_client.py open a socket, send
half a request, wait past the timeout, then send a complete one and require a
200. Without the fix both print "the server is still held" and the suite is
red; with it, test_gateway_openai: ok and test_a2a_server: ok. Full suite:
all tests passed. check_asan: all 45 test binaries clean.
2026-11-23 01:11:56 +00:00
lotherk d7ce939966 docs: a remote index is searched by the model that built it 2026-11-23 00:48:06 +00:00
lotherk f6211362cb sessions: /sessions is a picker over sources, foreign sessions included
`/sessions` printed a list of ids; the operator then typed the id into
/open. The list was the wrong shape for a thing you pick from, and the
foreign stores (claude, hermes, opencode) were not in it at all - their
sessions were only reachable through the model's import tool.

Now it is a picker in two steps: the sources first (`splinter` and every
foreign store that has something), then the rows of the chosen one. A
foreign row's id is "claude:<id>", which sp_engine_switch() already reads
as an import - so picking it loads and continues that session, exactly
like `/open claude:<id>` typed by hand.

The picker got one shared implementation while it was open: pick_run()
with a value/label list, a configurable title and two hint lines. /model
and /sessions draw the same way now instead of two copies that could
diverge on Esc, resize and the filter. One window is held across both
steps, so a quick double Esc leaves; with a window per step the second Esc
landed in a window that was already gone and the picker stayed open.

Over the socket the same two steps exist: `{"cmd":"sources"}` and
`{"cmd":"sessions","source":"NAME"}`.

Tested: make check, all suites green (test_engine, test_protocol,
test_ui against a real tmux pane, 229 i18n keys in three catalogues).
2026-11-22 21:32:31 +00:00
lotherk f19fbf6ac1 cli: splinter -c --claude continues the newest claude session of this folder
The operator's claude ran into its limit mid-work; the session was too full to
continue there. The foreign plugin could already read and import it, but only
through a tool call inside a turn - there was no way in from the command line.

--claude, --opencode, --hermes and --from=NAME make the newest session that
tool ran in this directory the session of the run: it is imported before the
history is loaded, so the first turn already carries it. -c no longer fails in
a folder that has no splinter session yet; it falls back to "no session" and
lets the import decide. An empty placeholder session is removed again, whether
the import worked or not.

Repeating the call continues the same session instead of importing a second
time: sp_session_foreign() reads the foreign= marker back, so the work done in
splinter is kept. A second foreign_import into the same session replaces the
history rather than appending it twice (path_join built "id/.jsonl", so the
replace branch never fired).

Test: tests/test_foreignopen.c builds a claude fixture under its own HOME and
covers import, idempotency, replace-not-append, the empty placeholder and a
folder with no foreign session. make check exit 0, check_asan.sh clean.
2026-11-22 13:20:45 +00:00
lotherk a00534cf6c serve: a second client is told why, not left hanging
`--serve` holds one engine, so one client talks to it at a time - that part is
deliberate. What was not: the second client connected into the listen backlog
and then waited for a greeting that could not come until the first one left.
splinterctl printed nothing and hung; --attach gave up 10 s later with "no
greeting from the backend", which names the wrong cause.

The accept is non-blocking now and a client that arrives while the engine is
taken is answered at once: an error event with the reason, then a shutdown of
the write side. That reads on the other end as "another client is attached:
one conversation runs one turn at a time". Descriptors are drained before the
close, or the RST would eat the message the client has not read yet.

Two smaller ones on the same path:
- --attach reconnects on a broken connection; it now carries the server's error
  text through instead of replacing it with "no greeting".
- a client that reads nothing is not waited for forever: a greeting timeout
  turns a silent server into a message instead of a hang.
2026-11-22 10:26:06 +00:00
lotherk 6358fcf42a openai: every streamed turn asks for usage, so compaction can fire
openai_stream passed the request options only when c->have_gen was set,
and only openai_server.c (splinter as a server, relaying a client's
request) ever set it. A normal turn therefore sent no
stream_options.include_usage, a provider that follows the OpenAI
contract returned no usage, reply.tokens_in stayed 0, last_in stayed 0,
and compact_threshold could never fire - a session grew monotonically to
250k tokens with the threshold at 128000.

The transport now always asks, with a local option block; the gateway
path keeps its caller's settings. Verified against a strict endpoint
that sends usage only when asked: before the fix two turns went 82->86
messages with no compaction, after it the second turn is 8 messages and
21 KB.

tests/test_usage_request.sh starts that strict endpoint (its usage is
emitted only when the request opts in) and asserts the request carries
the option and that the second turn is compacted. It fails without the
transport change.
2026-11-22 08:25:42 +00:00
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 47d45bfd15 session: search only sessions that ran in this working directory
"What did we do last?" in a folder searched every session ever and wandered
off in another direction: the plugin walked the whole session directory while
only the prompt note was folder-scoped. Both tools now read the cwd from the
session's meta sidecar (sp_session_cwd, the same record the folder note uses)
and skip sessions from other folders -- and sessions that have no cwd record.

test_sessiontools creates a session in a second folder with the same needle:
with the filter disabled it shows up (red), with it the search and the list
stay in the folder, and even session=<id from elsewhere> answers "no message".

make check: all tests passed. make check-asan: all 41 test binaries clean.
2026-11-19 07:57:03 +00:00
lotherk 11d119be04 session: a plugin that reads earlier sessions, and a prompt that points at them
session_search walks the logs of earlier sessions in this folder newest first
(query, limit, days, session) and answers with date, session id, title and a
snippet around the match; session_list shows the sessions themselves. The
running session is left out -- that is context, and lcm's recall covers what
compaction dropped -- unless a call names it with session=.

The system prompt now carries two things. When the working directory has
earlier sessions, a paragraph says how many, the newest, and that
session_search/session_list read them, so the model looks before asking the
user something that was already answered. And the default prompt tells it to
use the mcp_* tools for tasks, memory, skills and knowledge bases actively, not
only when asked.

test_sessiontools drives both tools (hit, no hit, limit, days, explicit id,
list with the current session marked); test_engine checks the prompt paragraph
and the default text. make check: all tests passed.
make check-asan: all 41 test binaries clean.

The user's ~/.splinter/splinter.conf gained "plugin session { }" (backup:
splinter.conf.bak-session).
2026-11-19 07:40:49 +00:00
lotherk 0841fabe87 protocol: record why the line-JSON framing stays
It was up for replacement after a session woke with no task and a turn died
with "stream ended with no answer". Both were elsewhere: a model put two
tool-argument objects in one string and mcp_parse() took the first, and a
gateway sent HTTP chunk framing inside an SSE body. A second, non-JSON protocol
would have hidden neither, and the line format is what keeps splinterctl and
proto-example.py small.

Docs only; no code path changed.
2026-11-19 06:25:37 +00:00
lotherk 86e0233c16 model: the session remembers /model; the config does not
A session owns the model chosen inside it, so reopening that conversation
comes back on the same model. The config is never touched: a new session
starts on core default (or -m), and the old global 90-model drop-in stays
removed. Telegram's /model remains process-only and writes no config.

- <session>.model is written by /model (provider/model, e.g.
  junction/qwen3.6-35b) and read when the session is opened again.
- /new copies the model the session is on into the new session.
- test_engine checks the sidecar and that reopening restores test-model-2;
  a new session still starts on config test-model.
- docs say exactly that: session choice persists, config does not.

Verified with the real config: /model junction/qwen3.6-35b writes the sidecar,
-c comes back on qwen3.6-35b, a new session starts on qwen3.6-35b-judged.
2026-11-18 12:47:30 +00:00
lotherk d63da16c65 model: /model never saves; config (or -m) is the default
The user's rule: what the config says is the default, -m overrides it for one
run, /model overrides it for the running process - and nothing is written to
the config or to the session. The session sidecar from the previous change made
/model persistent, which is exactly the harness behaviour this rejects.

- removed <session>.model writing and restoring; a reopened session starts on
  the config default or -m, not on the last /model choice.
- /new no longer copies the current model into the new session.
- Telegram's /model and probe buttons no longer write 90-model.conf; the
  switch lasts for the gateway process.
- existing .model sidecars were moved out of ~/.splinter; the stale 90-model
  drop-in was moved aside earlier.
- test_engine asserts that /model leaves no sidecar and that reopening uses
  test-model, not test-model-2; test_gateway asserts that no 90-model.conf is
  written.
- docs: "choice lasts for this run and is not saved".

Verified with the real config: default is junction/qwen3.6-35b-judged, -m
junction/qwen3.6-35b uses qwen3.6-35b for that run, /model switches to
claude-haiku for that run and the next start is judged again.

make check: all tests passed.
2026-11-18 12:38:29 +00:00
lotherk 6813fff1b5 model: every choice is provider/model; no main row
The picker and the text list now say what goes on the command line:
junction/qwen3.6-35b-judged, local/qwen3.6-35b. Labels and selectors are the
same string, so there is no second format to explain.

- the core endpoint (the endpoint/model without a provider block) is called
  "local" in every choice; its old name "main" is still accepted as a selector
  so existing drop-ins and session files keep working.
- sp_provider_choose("local/model") resolves to the core endpoint; a configured
  provider with that name wins if one exists.
- /model, /model probe and the served-model list all emit provider/model.
- the session sidecar stores provider/model (junction/qwen3.6-35b).
- the sidebar and /usage print "local" for the core endpoint.
- -m provider/model no longer produces an extra main row, and 90-model.conf
  (the old global /model file) was moved aside; the config's provider wins.
- tests and docs use local/test-model and local/m.

make check: all tests passed.
2026-11-18 12:22:52 +00:00
lotherk 4be6e26f78 tests: keep their sessions out of ~/.splinter
`make check` created a session for every splinter invocation that did not set
HOME - the A2A and gateway scripts pass --no-config, which does not change the
session directory. The user's ~/.splinter collected hundreds of "hallo",
"fehler" and "auth ohne token" sessions; the last three in /sessions were test
noise that looked like aborted chats.

- SPLINTER_SESSION_DIR overrides the session directory (o->session_dir still
  wins when a caller names one, so test_engine keeps its temp dir).
- make check exports a mktemp session dir and removes it on exit; the scripts
  that inspect $D/home/.splinter point the variable there.
- docs/CONFIG documents the variable.
- the existing test sessions were moved to
  ~/.splinter/test-sessions-2026-11-18 (not deleted) so /sessions shows the
  real conversations again.

make check: all tests passed; ~/.splinter kept 211 sessions before and after.
2026-11-18 06:48:01 +00:00
lotherk ddf0ec5462 tools: valid schemas; sse: surface in-stream errors
A judged request sends the whole tool list to the judge. Claude validates the
schemas and rejected the request with 400
"tools.22.function.parameters.type: Field required": delegate_due and
delegate_jobs declared "parameters": {} instead of an object schema. junction
wrapped that 400 in the stream as data: {"error":{...,"code":400}}, but the SSE
parser ignored anything that was not a choice - so the turn ended with
"stream ended with no answer" and the one line explaining it was lost. Three
sessions stopped that way at the same minute.

- delegate_due/delegate_jobs now carry {"type":"object","properties":{}}.
- test_engine walks every registered tool and fails when parameters.type is
  not "object"; this catches the next schema before a judge does.
- sp_sse_line recognises a top-level error object, reports its message and
  remembers its code; the transport puts the code in the reply status.
- a 4xx from the stream ends the turn with the real message and is not
  retried; an empty 2xx stream and a 5xx still are. 402/429/529 stay with the
  usage-limit path, which already handles them.
- test_sse feeds the junction 400 event and checks message and code.
- README and docs/PLUGINS say why a tool schema needs type:object.

make check: all tests passed.
2026-11-18 06:28:23 +00:00
lotherk af2001bfee ui, model, cost and idle timeouts
- lcm: the sidebar widget and /status segment show the context, the number of
  compactions, messages and bytes of the last cut, and how many old tool
  outputs were trimmed. The counters are the compactor's own, not an estimate.
- cost: a provider-reported USD cost (usage.cost/cost_usd) is carried through
  sse/openai, the agent and the engine. /cost reports it with the cache share
  and splits judged from plain turns; the notes say that an upstream judge is
  not visible in the provider's usage. The status plugin and junction prefer
  the reported number over list-price arithmetic.
- curses: the running turn's seconds moved from the input line to the status
  bar. Notes and errors are transcript rows below the cause, never text in the
  input line or the status bar; a failed backend request is a status row and is
  retried by the agent. The steer prompt is only "steer> " and what was typed.
- model: /model probe works in the chat. The picker lists the configuration at
  once, then asks the endpoint the session is on what it serves and adds those
  models, so a router's whole menu is selectable. provider/model selectors now
  apply the right provider instead of becoming a model name. The choice is
  written to <session>.model and restored when that session is reopened; /new
  carries the current model into the new session.
- sidebar: plugin titles are bold and underlined (this curses has no italic
  attribute), with a rule between the plugin blocks.
- run/cli: a command timeout is an idle window. Every chunk on stdout or
  stderr resets it, and the process is asked with waitpid(WNOHANG) whether it
  is still there before the window is extended. A long build that keeps
  reporting progress is no longer killed for being long; a silent hang is.
- config: ';' separates settings on one line, so
  plugin lcm { keep = 6; tool_trim = 8192 } parses as two keys.
- tests: lcm widget/status counters, one-line config blocks, session model
  restore and /model probe, cli idle timeout with a talkative and a silent
  command, run output reset, and the UI status/retry rows.

make check: all tests passed.
2026-11-17 23:21:56 +00:00
lotherk 82bda09ed1 lcm: cut old tool outputs before dropping messages
Tool observations are the bulk of a long conversation. Before lcm drops any
message it now cuts every old tool output to a head and a tail with a marker
quoting its first line; the middle stays in the session log, where the recall
tool finds it. Only when that is still over budget are messages dropped, so a
conversation often keeps all its turns and only loses the middle of old
outputs.

- plugin lcm { keep = 6; tool_trim = 8192 } sets the verbatim tail and the cap
  per old observation (0 turns the trim off).
- the compacted summary says when tool output was cut too.
- test_compactor: a 20 KB old observation is trimmed, nothing is dropped, and
  the marker points at recall.
- docs/CONFIG and docs/PLUGINS updated; the user config uses 6/8192.

make check: all tests passed.
2026-11-17 21:44:45 +00:00
lotherk 63b6742447 retry reasoning-only streams, /compact, token threshold and target
- a stream that carried only reasoning and then ended without an answer used to
  abort with no retry: guarded_stream counted every chunk as "already
  produced". Only answer text and tool calls block a retry now; the thinking
  may repeat, a lost turn may not. test_agent has a stream that thinks, fails
  once and answers on the second attempt.
- /compact [tokens]: runs the compactors now (default: compact_target, else
  8000 tokens) and reports messages and bytes before/after.
- compact_threshold / compact_target in core (tokens): once the last request
  was larger than the threshold, the next request is compacted to the target
  before it is sent. 0 disables either.
- lcm gains a read tool `recall`: case-blind search in the session log for
  what compaction dropped from the prompt.
- user config: compact_threshold = 32000, compact_target = 12000.
- README/CONFIG document the command, the two keys and the cache trade-off.

make check: all tests passed.
2026-11-17 21:34:57 +00:00
lotherk 8aee12e9d4 drop tmux/planner/sysinfo, tasks becomes processes, no capitalised calls
- plugins/tmux, plugins/planner and plugins/sysinfo are gone (plugin list,
  Makefile rules, tests, docs). The config no longer loads them; the stale
  .so files were removed from the install tree.
- plugins/tasks is plugins/processes: plugin name "processes", widget
  "processes", tools process_start/process_list/process_result/process_kill.
  The sidebar now lists only running work: a finished task keeps its output
  in process_result but stops taking a row forever.
- the dead planner link in the delegate (link_plan_quota -> command "tasks")
  is removed with the planner.
- tool call rows are no longer capitalised: "run  ls -l", "read  src/x.c" as
  the model sent them, not "Run "/"Read ".
- tests updated (delegate panel expects no finished row, engine/UI expect the
  lowercase call row, secrets/delegate use the processes plugin and tools).
- the user's config gets a Delegate/Scheduler section: the three providers
  carry review/plan/docs tags and keep max_parallel=2; plugin scheduler stays
  loaded so waiting jobs are retried.

make check: all tests passed.
2026-11-17 21:06:55 +00:00
lotherk 1e15c91e4e interview: the model talks to the user, USER.txt rides in the prompt
The six-question form is gone. `splinter --interview` now opens the chat with an
interview system prompt: get to know the person, one question at a time, then
write a compact summary and end with INTERVIEW_COMPLETE.

- the marker is captured in the engine's turn thread and in the synchronous -p
  path: the summary before it is written to ~/.splinter/USER.txt (0600), the
  marker is stripped from the answer and the conversation, and a "interview
  saved to USER.txt" note goes into the transcript. An installation from before
  USER.txt keeps working: profile/<user>.md is the fallback until the first new
  interview.
- the USER.txt text is appended to the system prompt of every later session
  (plain "What you know about the user" block), including after /new and an
  agent switch (it rides in base_prompt).
- --interview is a chat mode with the interview prompt and no agent profiles;
  it needs a provider like any chat.
- Telegram: /interview swaps the system prompt, starts the conversation and
  restores the normal prompt once the summary is captured. The initial turn and
  every later reply are checked, so a model that summarizes immediately also
  works.
- test_interview.sh now proves capture, marker-free USER.txt and the summary in
  the next request; test_gateway drives /interview and the fake model answers
  with the marker when the interview prompt is in the request.
- docs (README, PLUGINS) describe the new flow.

make check: all tests passed.
2026-11-17 20:50:03 +00:00
lotherk 8aad48b928 remove the mem0 memory system
The memory tools talked to a mem0 server (memory_url/memory_key_env), one
bucket per unix user. It is gone: no memory_add, no memory_search, no mem0
client, no config keys, no test_memory.

- delete src/backend/memory.c and memory.h; the engine no longer registers the
  tools; config loses memory_url/memory_key_env; SPLINTER_MEM_KEY leaves the
  secret list; docs/CONFIG, ROADMAP and GATEWAY stop mentioning it.
- the unix identity helper stays, under its real name: sp_user_name() in
  src/backend/user.c (profiles, interview and the Telegram gateway used it).
- tool list is now read/search/list/write/edit/run/skill_*/... plus the MCP
  session tools; nothing about memory remains.
- test_mcpsession.sh: the client socket gets a 120 s read timeout, not the
  5 s connect timeout (a turn under load answered too late and looked hung).

make check: all tests passed.
2026-11-17 20:00:38 +00:00
lotherk 36a66ab4f0 self monitor, MCP session tools, junction serving endpoint
- plugins/self: what the session costs the machine - RSS, CPU, threads, fds
  and io of the process itself from /proc/self/*, and the same (count, RSS,
  CPU) for every process whose parent chain reaches it: run calls, MCP
  children, delegates. Widget, /self and the session_usage tool; interval in
  the plugin block (default 2 s).
- MCP server: the session tools. splinter_sessions, splinter_state,
  splinter_models, splinter_agents, splinter_history, splinter_say,
  splinter_open, splinter_model, splinter_agent, splinter_steer,
  splinter_cancel, splinter_approve. Say starts a real turn and returns the
  answer; a turn parked on an approval returns the question instead of
  failing. Mutating tools obey --autonomous. `--daemon --mcp-server-listen`
  runs the MCP server on a thread beside the Telegram daemon.
- the MCP server asks the engine for its registry on every call (a session
  switch replaces it) and copies the tool name out of the parsed JSON before
  freeing it (the first version compared a dangling pointer and answered
  every session call with empty text).
- junction: "serving <endpoint>" - streaming answers carry no
  X-Junction-Endpoint, so the plugin compares the route targets' ok counters
  from /status between samples and names the one that grew, with its
  last_ms. The header is still used when present (non-streaming). The
  X-Junction-Endpoint of the plugin's own /v1/models probe remains a probe
  fact in /junction only.
- transport: X-Junction-Endpoint is parsed from the response headers in both
  the streaming and the non-streaming path and published through
  sp_host_served_by(); sp_reply carries served_by.
- the curl rate guard (--speed-limit/--speed-time) is gone: it cut slow
  router streams with "Less than 1 bytes/sec" even while keepalives arrived.
  The overall -m timeout stays.
- focus: the sidebar shows "recap N, every M turns", and an applied recap
  writes "recap applied (turn N, every M turns)" into the transcript (host
  status messages are now drained during a turn; protocol clients get them
  as entry events too). The initial goal announcement says so as well.
- tests: test_self, test_mcpsession.sh (real socket), test_focus status
  messages, test_junction serving placeholder.

make check: all tests passed.
2026-11-17 19:13:59 +00:00
lotherk 55ca5c71f8 junction widget: the model's route, nothing else
Two reasons the sidebar was useless: it named the route of the *configured*
provider model, not of the model the run was switched to (/model
deepseek-v4.1-flash kept showing qwen3.6-35b's kontron/kompute route), and it
repeated server counters (MCP servers, queue, requests, probe headers) that
have nothing to do with the conversation.

- sp_host_model()/sp_host_set_model(): the engine publishes the model it is
  actually on; the engine sets it at plugin load, after /model and on every
  state read. The junction plugin prefers it over the config.
- the widget is now only the model, the route from the matching rule (one
  target per row, "!" when that target's probe fails) and "N/M up":
  deepseek-v4.1-flash / route opencode-go0 / opencode-go1 / ... / 4/4 up.
  Uptime, MCP servers, queue, requests, endpoint p95 and every response
  header stay in /junction.
- widget text may use up to 8 rows (a four-target route plus model and
  health is seven).
- test_junction: the widget must be exactly "m\nroute a\nb!\n1/2 up" and
  must not repeat mcp/models/probe stats.

make check: all tests passed.
2026-11-17 18:28:00 +00:00
lotherk b0c1da65a2 junction: the session's route, not the probe's endpoint
The widget printed "endpoint=opencode-go" because that is the
X-Junction-Endpoint header of the plugin's own /v1/models probe, which
junction routes there by a path rule. It says nothing about where the
conversation goes, and the operator's qwen3.6-35b is routed to kontron and
kompute0..2 - so the line was wrong, not just imprecise.

- read the active model from the config (sp_usage_active -> provider model)
  and match /status' rules against it: exact model > glob > catch-all, rules
  with a path are another route. The result is the route line:
  "route kontron! kompute0 kompute1 kompute2" ("!" = that target's own health
  probe is not ok).
- /junction shows model, route and "route health: N/M up, down: ..."; the
  /v1/models header block is marked as the probe's route, not the session's.
- the header stats label the probe values (probe-ms=, probe-cache=) and no
  longer print the endpoint header as if it were the route.
- side_text(): wrap one line at a time and let a continuation use up to three
  rows; passing a multi-line string to one mvwaddnstr() double-counted rows
  and cut "route ... kompute1 kompute2" in half.
- test_junction: fake /status gains rules and per-endpoint probe_ok; the test
  sets the run's model ("m") and expects "route a b!", "probe-ms=12",
  "route health: 1/2 up, down: b" and no "endpoint=" in the stats.

make check: all tests passed.
2026-11-17 12:31:58 +00:00
lotherk 0f46c22a58 model picker, steer feedback, tolerant SSE with retries, junction headers
- /model in the curses chat opens a picker: Up/Down, typing filters by
  provider/model, Enter takes the selector, Esc cancels. The list comes from
  the backend (sp_engine_models -> sp_provider_choices), not from a text
  scrape; the socket has a `models` command, so --attach gets the same picker,
  and the switch is still the ordinary "/model <selector>" input.
- steering: Enter during a turn now says so twice - a "steering queued: ..."
  row in the transcript and "Ns steering queued (n) steer>" in the input line
  until the step boundary picks it up; a rejected steer is an error entry.
- input lag: typing during a turn is echoed immediately (the input line is
  redrawn per key, not at the next 100 ms frame), and the history is only
  repainted when its generation changed, so a streaming turn no longer
  repaints the whole transcript on every clock tick.
- sidebar: the first line of every widget is bold, like its heading, so a
  plugin block has a title instead of a wall of small print.
- junction plugin: keeps every response header from /mcp, the status route and
  /v1/models; the widget shows the X-Junction-* routing stats, /junction lists
  all headers per source. It reads the status aliases (/status, /v1/status,
  /queue, /v1/queue) and remembers the one that answered, parses queue,
  endpoint p95/exhausted counts, and counts the models (/v1/models, probed on
  its own slower interval because it goes upstream).
- SSE: blank lines no longer abort a pretty-printed object, a truncated tail
  is dropped instead of failing the turn ("incomplete data line" is gone), and
  a [DONE] with a fragment clears it.
- retries: a request that fails before anything streamed (connection, missing
  status, 5xx) is tried three more times, 5 s apart; 4xx is not retried, and
  after the first chunk the error is reported instead of printing the answer
  twice. Ctrl-C ends a wait at once; SPLINTER_RETRY_WAIT_MS overrides the wait.
- tests: test_sse (split object across events, truncated tail), test_agent
  (four 500s = four requests; two 500s then an answer), test_engine and
  test_protocol (models list), test_junction (headers, aliases, models),
  test_ui (/model picker), test_focus (status keys).

make check: all tests passed.
2026-11-17 11:46:11 +00:00
lotherk 614988aa68 junction plugin, light/dark themes, goal completion
- plugins/junction: evaluates the X-Junction-Mcp header and /status; the
  sidebar widget, the "junction" status segment, junction_status and
  /junction show uptime, MCP-server health, queue and request counts.
  The url/header come from the plugin block, the mcp junction server or
  SPLINTER_JUNCTION_URL/TOKEN; the key is never printed.
- theme: two flat themes. light is a white page with black text, dark the
  same inverted; chat, sidebar and input share the page, the status line is
  the one separate surface. Each CDE palette keeps its own rules.
- curses: the sidebar uses the theme's own text on its own background
  (white/black) instead of white on a darkened surface; the one column
  between chat and sidebar is painted, so a white theme has no black seam.
- focus: the goal goes into the first prompt (config, resume, planner), and
  every goal-carrying text asks the model to end with GOAL_COMPLETE. The
  marker is read from the conversation and the session log and recorded as
  goal_state=succeeded in the session meta; /goal and the sidebar say
  [done], reminders stop, a new goal opens a new one.
- tests: test_junction (fake server, header identity, no colon in widget
  continuation lines, no key in the output), test_focus (announcement,
  completion in the compactor and from the tick, persisted state),
  test_theme (flat themes, list order).

make check: all tests passed.
2026-11-17 10:10:47 +00:00
lotherk 67b4d5d070 goal in the session, /continue, a white sidebar, sysinfo
The goal lived only in the focus plugin's memory: a resume lost it and
there was no way to start the next turn from it. It is now stored in the
session's .meta (one line, 1000 bytes) and read back when the plugin sees a
new session id, so /open and a resumed process find their own goal again.
/continue reads the same sidecar and starts a turn with "Continue working
toward this goal: ...". /goal still sets it and starts the recap turn.

The sidebar was a patchwork of pairs and widgets could inherit the wrong
background. It now uses one PAIR_SIDE (white on a darkened theme
background) for every heading, label, usage row and widget; the window
gets that pair as its background, so no line paints its own surface.

New plugins/sysinfo: a widget thread samples /proc/meminfo, /proc/stat and
statvfs("/"), and publishes RAM, CPU, swap and disk with five-cell
[|||| ] gauges every two seconds. It is added to the shipped plugin list
and to the user's config.

agent.c keeps the last prompt/cache counters when a tool-call step reports
no usage. A zero there used to reset the ctx gauge in the status bar after
every tool call.

Tests: session goal survives reopen, /continue returns the prompt,
make check: all tests passed.
2026-11-16 18:30:42 +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 1726bc1967 ui: a status bar above the prompt, a scroll fix, a steer space
The screen had no room for the numbers that say how a turn is doing, and
two older behaviours still hurt: scrolling to the top made PgDn jump back
to the top, and a catalogue's steer mark without its trailing space glued
the typed text to ">".

- draw_statusbar() in curses.c: one row above the prompt with
  ctx used/max + [||||    ] gauge, cache share and tok/s. The history and
  sidebar lose one row; the prompt stays the bottom row. The bar is drawn
  on every idle tick, during a turn and in --attach.
- ctx: optional field on a provider (and in core) in tokens; the engine
  reports it in struct sp_engine_state. SPLINTER_CTX_MAX still overrides it.
- cache: sp_reply gained tokens_cached. OpenAI reads
  prompt_tokens_details.cached_tokens / prompt_cache_hit_tokens, Anthropic
  reads cache_read_input_tokens and counts cache reads+writes in the prompt
  total. sp_agent_stats keeps the last request's prompt and cache share;
  the engine keeps the turn's output tokens for a real tok/s.
- scroll: grow scroll by the growth of maxscroll, not by the distance from
  the first visible line. At the top that distance was 0, so every frame
  re-added the whole scrollback and PgDn could not leave the top.
- steer mark: append the missing space if a catalogue omits it.
- protocol state carries ctx_used/ctx_max/cached/turn_tokens_out, so the
  attached UI shows the same bar.
- tests: cache parsing in test_sse/test_openai/test_anthropic, ctx parsing
  in test_confblock, and test_ui checks the bar, the cache share and the
  PgUp-to-top/PgDn-down path.

make check: all tests passed.
2026-11-16 16:59:49 +00:00
lotherk 76c9007c02 config: a core default is a choice, not something a main endpoint overrides
load_config() copied the config's main endpoint into the command-line
options, so apply_selection() saw o->endpoint != NULL and skipped
core { default = ... }. Every config with a main endpoint (and every
/model drop-in, which wrote exactly that) silently ran the main endpoint
instead of the default; a drop-in with model = provider/model even put a
slash-name into the model field.

- The main endpoint is applied only when no -m and no default exist.
  -m and a command-line --endpoint still win.
- /model saves a delegate choice as "default = ID[/MODEL]" instead of a
  second main endpoint; the provider block supplies kind, endpoint and
  key. A model of the main endpoint has no provider block, so that one
  keeps the full endpoint/model/api_key_env form.
- docs/CONFIG.md, README and test_providers describe the order and the
  new drop-in line.

Verified with a fake endpoint: core default -> mb, -m a -> ma, main-only
config -> mmain, a stale endpoint/model drop-in no longer shadows the
default, a "default = a" drop-in does.
make check: all tests passed.
2026-11-16 16:27:03 +00:00
lotherk 573ef61afc version: print the build time and revision, not just 0.1.0
The release number does not move, so two builds - the tree and the
installed binary - looked identical in --version.

make now generates src/backend/buildinfo.c from the objects it stamps and
links it into libsplinter. The stamp is only rewritten when one of those
objects is newer, so a no-op make keeps the old time instead of pretending
the binary was rebuilt. The git revision is included, with -dirty when the
working tree differs from HEAD.

    splinter 0.1.0 (built 2026-11-16 15:39:00 WET, 42c11f9)

buildinfo.c is a build artefact: gitignored and removed by make clean.
make check: all tests passed.
2026-11-16 15:39:10 +00:00
lotherk 9af7695064 gateway streams: the answer grows while the provider talks
- stream:true uses the provider's send_stream and writes each text delta as a
  chat.completion.chunk as it arrives, instead of one chunk at the end. The
  SSE headers and the role chunk go out before the upstream call, so a slow
  provider still gives the caller a live connection.
- caller tool calls are sent as one tool_calls delta at the end of the step,
  when their names and arguments are complete; filtered gw_ calls are
  renumbered 0,1,... so strict accumulators see no gap. Local gw_ calls stay
  invisible.
- stream_options.include_usage asks the provider for usage and adds the summed
  token counts in a final chunk before [DONE]. Usage is now summed over every
  upstream round, for the non-stream reply too.
- an error after the first byte becomes an SSE error object plus [DONE]; a
  bad request is still an ordinary HTTP 400. SIGPIPE is ignored and
  TCP_NODELAY set, so a caller that closes early cannot kill the gateway.
- tests: fake_gateway.py has a slow stream, tests/stream_probe.py measures
  that chunks arrive while the upstream streams, usage is checked, and the
  mixed reply keeps index 0 after filtering. make check green.
2026-11-16 14:06:54 +00:00
lotherk dd135f3b33 sessions get titles, /rename and /rm
- .meta carries a title: the first user line is stored once, /rename
  [ID] TITLE replaces it. Reopening preserves the title and the original
  creation time.
- /sessions shows the title, locally and over the link; the protocol's
  sessions event carries it. Old sessions without a stored title fall back
  to their first user line when listed.
- /rm ID removes a session that is not open: JSONL, meta, saved agent
  profile and logs/<id>; the open session is refused, /rm last resolves
  the newest.
- tests: test_session (auto title, explicit title survives reopen, old-log
  fallback, recursive removal), test_protocol (title, rename, rm, errors),
  test_ui (title, rename, rm). make check green.
2026-11-16 12:10:06 +00:00
lotherk a01bfe9df1 sessions switch locally, gateway keeps caller settings and mixed calls
- sp_engine_switch(): close the old engine and open the chosen session from
  the same options; if the new one fails, reopen the session the engine was
  on. The protocol's open and the in-process /open both use it. The curses
  screen clears the pane and replays the new history, so /open no longer says
  it needs --attach.
- gateway: temperature, top_p and max_tokens (max_completion_tokens) are
  forwarded to the provider instead of dropped; request bodies may be
  Transfer-Encoding: chunked; a mixed reply runs the gw_ calls, returns the
  caller's calls in tool_calls and puts the local observations in content
  (also in the SSE delta), so the caller can echo them back.
- reconnect: when the remembered session is gone, the screen says which one
  and stays on the session the server has instead of silently swapping the
  transcript.
- ring: the exits' transports are disposed on plugin shutdown.
- /status goes through the catalogues like the rest of the UI (the English
  labels and their alignment are unchanged, so existing parsers still work).
- the man page passes mandoc -Tlint and covers the gateway and /open.

Tests: test_ui.sh covers local /sessions and /open (new, back, history),
test_protocol.sh the shared switch, test_reconnect.sh a vanished session,
test_gateway_openai.sh forwarded parameters, a chunked body and the mixed
reply in JSON and SSE. make check green.
2026-11-16 10:18:41 +00:00
lotherk 5143fcd054 gateway, sessions, reconnect: splinter serves other harnesses and keeps tabs
- --openai-listen: an OpenAI-compatible /v1/chat/completions and /v1/models.
  The model gets splinter's local tools as gw_* (executed here) and the
  caller's tools under their own names (returned as tool_calls to run there).
  Local calls loop inside one request; a mixed reply runs the local calls and
  asks again. --autonomous gates mutation; beyond loopback a bearer token is
  required; stream:true answers with SSE.
- --serve keeps several sessions: sessions/open over the protocol and
  /sessions, /open in the attach screen. The server owns the engines, closes
  the old one before opening the next (plugins keep globals) and sends
  state/history after every switch. Session ids are unique per process, so two
  engines in the same second no longer share a file.
- --attach reconnects: when the server goes away the screen keeps running,
  retries every second, asks for its session by id and restores the
  transcript; a missing session falls back to the server's current one.
- transports own their context now: provider switches and close dispose it
  (a switch used to leak one per change). The idle screen repaints entries it
  drains, so a reconnect note is not invisible.
- docs/GATEWAY.md; PROTOCOL, FRONTENDS, README and the manual page describe
  the three; tests cover the gateway tools, sessions/open and a server
  restart under --attach.
2026-11-16 09:33:37 +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 32a214aee3 ui: the sidebar is back, and it says where splinter runs
Removing it went too far: the conversation area should be plain appended
text, but the sidebar carries what no line of the transcript should repeat -
agent, provider and model, what is left of the allowance, the plugin widget
lines, the session and now the directory the tools act in ("~" for $HOME,
wrapped at the slashes). A narrow terminal drops it and gives the width to
the conversation.

No status bar: the running time and the tool lead the prompt, and /usage,
/status and /widgets print the same numbers on demand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 22:00:49 +00:00
lotherkandClaude Opus 5.5 c215fd8101 docs: the plugin docs say where a widget line shows now
No sidebar to draw into: /widgets prints the published text, and draw() is
not called at all any more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 21:31:04 +00:00
lotherk 23bc0d13d4 merge: plugins get their own config block 2026-11-13 20:59:51 +00:00
lotherkandClaude Opus 5.5 a77641b699 ui: one text field that only grows; themes are Xresources or a CDE palette
The chat is now the whole screen and the input line the row below it: no
sidebar, no status bar. Entries are append only -- a growing answer stays in
its entry while it is the last one and continues in a new entry once a tool
line follows, so nothing that was on screen ever moves. The prompt carries
the agent name ("build> "), /widgets shows what plugins published, and
/status still prints the status segments.

The default theme is Xresources: *foreground, *background and *color0..15
from xrdb -query (or ~/.Xresources), falling back to the terminal's own
colour indices. Every CDE palette is a theme by its own name, painted the
way the desktop paints it (set 5 windows, set 4 text areas, set 6 dialogs,
set 1 active frame, set 2 inactive frame) with CDE's black-or-white rule.
"Default" is therefore the CDE Default palette again, which is what the
config asked for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:59:13 +00:00
lotherkandClaude Opus 5 f3b832ae64 plugins come from their own config block, with their own settings
plugin NAME { path = ...  enabled = false  key = value } loads the plugin
(shipped one for NAME unless path says otherwise) and hands everything else
to that plugin as its configuration, read with sp_host_plugin_config() or
walked with sp_host_plugin_config_at(). Nested blocks give dotted keys,
lists arrive comma-separated.

The mcp plugin's servers are now server ID { url | cmd | header } blocks
inside plugin mcp { }; the old top-level mcp NAME { } and the flat
plugin = path / plugins = [ ... ] forms keep loading.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-11-13 20:52:46 +00:00
lotherkandClaude Opus 5.5 2c58dcfd2a cli providers take a model: provider prefix, {model}, -m occli/MODEL
A kind = cli provider now has a default model and a prefix
(provider = opencode), so -m occli/deepseek-v4.1-flash-free runs
"opencode run --model opencode/deepseek-v4.1-flash-free". {model} in cmd
marks where the model goes, otherwise --model is appended; a model that
already has a '/' is used as it is. sp_cli_command() builds the command for
-m, delegates and the cli plugin's pool fallback. Model names are limited to
letters, digits and ._:/@+- since the command goes through /bin/sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:08:16 +00:00
lotherkandClaude Opus 5.5 05c8d936e7 anthropic transport, provider usage APIs, endpoints as /v1 base
- kind = anthropic: the Messages API over curl, OAuth tokens (sk-ant-oat)
  as Bearer with the oauth beta, tool_use/tool_result blocks.
- --doctor spends no tokens: it asks /models and the provider's own usage
  route (ollama /api/balance, opencode go /v1/usage) instead of a tiny turn;
  cli providers are only checked for the program. /usage shows the same
  provider figures, cached for a minute.
- endpoint names the API base (https://host/v1); sp_endpoint_url() builds
  chat/completions (default), messages, models and usage from it. A full
  route is still accepted and cut back to the base.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:35:41 +00:00
lotherk 62a041a61b mcp: servers from the config, HTTP transport
The MCP client could only start one program and talk to it on a pipe; a server
behind an endpoint (junction at http://host:8090/mcp) had no way in. Now the
config names the servers and the plugin speaks whichever transport each one
offers:

- new `mcp NAME { url | cmd | header | enabled }` block (and the flat
  `mcp = NAME | url=...` form), parsed into struct sp_mcpserver; an entry
  without a url and without a cmd is refused with its line number
- streamable HTTP in plugins/mcp/mcp.c: one POST per JSON-RPC message, answered
  with one JSON object or an SSE stream of `data:` lines - both are read,
  Mcp-Session-Id is kept and echoed back, and the Authorization header travels
  through curl's stdin config so the token never appears in ps
- several servers register side by side; tools are mcp_<tool> for one server
  and mcp_<server>_<tool> for more, so two servers that both offer `search` do
  not overwrite each other. A server that fails its handshake is reported and
  skipped, the rest still load. SPLINTER_MCP_CMD stays as the one stdio server
- tests: the config and block parsers, and a socket server in test_mcpclient
  that refuses the tool list without the configured header and answers the call
  as an event stream
- README and docs/CONFIG.md describe both transports and where the token lives
2026-11-12 12:05:35 +00:00