From bff47eede8ab1ed32575fe4152a488746053d95a Mon Sep 17 00:00:00 2001 From: lotherk Date: Mon, 16 Nov 2026 17:48:22 +0000 Subject: [PATCH] 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 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. --- README.md | 37 +++++++----- docs/CONFIG.md | 6 +- docs/PLUGINS.md | 22 +++++--- docs/WORKFLOW.md | 5 +- plugins/focus/focus.c | 125 ++++++++++++++++++++++++++--------------- share/locale/de.msg | 11 ++-- share/locale/en.msg | 11 ++-- share/locale/pt_BR.msg | 11 ++-- src/backend/engine.c | 27 +++++++++ src/backend/telegram.c | 6 +- src/backend/theme.c | 116 ++++++++++++++++++++++++++++---------- src/backend/theme.h | 9 ++- src/backend/usage.c | 16 +++++- src/frontend/curses.c | 35 +++++++++--- src/www/index.en.html | 2 +- src/www/index.html | 2 +- src/www/index.pt.html | 2 +- tests/test_a2a_ui.sh | 3 + tests/test_focus.c | 38 +++++++++---- tests/test_theme.c | 8 +++ tests/test_ui.sh | 7 ++- tests/test_usage.c | 8 +++ 22 files changed, 357 insertions(+), 150 deletions(-) diff --git a/README.md b/README.md index 6dcd61b..5e20de3 100644 --- a/README.md +++ b/README.md @@ -173,10 +173,13 @@ Without any of those resources it keeps the terminal's own colour indices. Every CDE palette from the desktop's `.dp` files is a theme as well, 43 of them including `Default` and `MakroSlate`. A palette is used the way the desktop -uses it: set 5 is the chat background, set 4 the input area, set 6 hints, set 1 -the user's lines and set 2 secondary text, with black or white text by CDE's -own rule. `--list-themes` prints the names, `--theme NAME` picks one, and -`theme = NAME` in the config makes it the default. +uses it: set 5 is the chat background, set 4 the input area, set 1 the user's +lines, set 7 the model's answer, set 3 its reasoning, set 6 tool calls, set 8 +status and session notes, and set 2 observations, with black or white text by +CDE's own rule. Role colours keep their hue and are moved away from the +background only when they would disappear into it. `--list-themes` prints the +names, `--theme NAME` picks one, and `theme = NAME` in the config makes it the +default. ## Talking to a model @@ -304,11 +307,15 @@ data line, and the keepalive lines that carry nothing. ## Colour, measured -A CDE palette is eight mid-tones; painted literally, the accent can sit 8% away -from the background, and nothing is readable. Two safeguards live in -`theme.c`: text on a surface follows CDE's rule (black on light, white on +A CDE palette is eight mid-tones; painted literally, a role can sit a few +percent away from the background, and nothing is readable. Two safeguards live +in `theme.c`: text on a surface follows CDE's rule (black on light, white on dark), and a role that is too close to the background is pushed away from it -until it is legible. `Xresources` themes are used as they are. +until it is legible. The push keeps the hue, and each role gets a slightly +different minimum, so even a monochrome palette yields distinguishable steps. +The 256-colour path picks the nearest cube or grey-ramp entry instead of +rounding channels down, which used to turn a dark orange into grey 240. +`Xresources` themes follow the same rules with colour0..15. The other half was a real bug: `COLORS` was read before `start_color()`, so it was 0, the code took the eight-basic-colour path, and the whole palette @@ -374,10 +381,12 @@ comes from the parser (`sp_sse_kind`). ## Compaction -`focus` keeps the session's goal in front of the model every five turns, the -way Claude Code's recap does — one inserted system message, never twice in a -turn, nothing until a goal is set. `/goal ` sets it, `/recap` forces a -reminder, both in the TUI and with `-p`. +`focus` keeps a short recap of the session's goal in front of the model every +seven turns — one inserted system message, never twice in a turn, nothing until +a goal is set. `/goal ` sets the goal and starts that recap turn; the +model's answer is remembered and injected later. `/goal` alone shows it. There +is no separate `/recap`: recapping is what a goal does. Both work in the TUI and +with `-p`. ## Languages @@ -471,7 +480,7 @@ API answers `chat not found`. That is Telegram, not the harness. The bot registers the commands that actually exist with `setMyCommands`: `/start`, `/help`, `/interview`, `/new`, `/model`, `/connect`, every command a loaded plugin registers -(`/goal`, `/recap`, `/tasks`, `/quota`, `/tmux`, ...) and every program in +(`/goal`, `/tasks`, `/quota`, `/tmux`, ...) and every program in `~/.splinter/commands/` whose name is a valid Telegram command (lower-case, digits, underscore, at most 32). `/start` and `/help` answer with the short text plus that live list. An approval arrives as a message with **Yes/No @@ -703,7 +712,7 @@ budget in one keystroke. ## Slash commands A leading `/` never reaches the model: the UI asks the host, the host asks the -plugins. A plugin registers what it handles (`/goal`, `/recap` today); an +plugins. A plugin registers what it handles (`/goal` today); an unknown command lists what exists instead of being sent as a prompt. Compaction is a plugin, not a switch in the loop. Two ship here: `lcm` diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 054861e..ecc9b3d 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -216,8 +216,10 @@ repeats the request: `on_limit = wait`, the default. `max_wait` bounds it ## Not in the file: the goal The session goal is set at runtime with `/goal ` — in the TUI, or in a -one-shot run (`splinter -p "/goal ship the config"`). It belongs to the -conversation in front of you, not to a file that outlives it. +one-shot run (`splinter -p "/goal ship the config"`). It sets the goal and +starts a turn that writes a short recap; the recap is injected every seventh +turn. It belongs to the conversation in front of you, not to a file that +outlives it. ## Precedence diff --git a/docs/PLUGINS.md b/docs/PLUGINS.md index 57cd340..6c63c12 100644 --- a/docs/PLUGINS.md +++ b/docs/PLUGINS.md @@ -215,16 +215,20 @@ the table. /goal splinter zu einem agent-harness machen, das hermes ersetzt ``` -`/goal ` sets it, `/goal` shows it, `/recap` forces a reminder into the -next turn. That works in the TUI and in a one-shot run -(`splinter -p "/goal ..."`); it is deliberately not a config key, because a goal -belongs to the conversation in front of you and not to a file that outlives it. -`SPLINTER_FOCUS_EVERY` sets the interval (default 5 turns). +`/goal ` sets it and starts a turn: the prompt asks the model for a short +recap (3-5 bullets, what must be true at the end, the first steps, open +questions). The plugin remembers that answer and injects it every seventh turn +— never twice in one turn, nothing at all when no goal is set. `/goal` alone +shows the goal. There is no `/recap`: recapping is what a goal does. That works +in the TUI and in a one-shot run (`splinter -p "/goal ..."`); it is deliberately +not a config key, because a goal belongs to the conversation in front of you and +not to a file that outlives it. `SPLINTER_FOCUS_EVERY` sets the interval +(default 7 turns). -It registers as a compactor and, on every fifth turn, inserts one system -message — *before* the newest user message, so the model reads goal then request -and answers the request. Never twice in one turn, and nothing at all when no -goal is set. Its widget line shows the goal and how many reminders went out. +It registers as a compactor and inserts one system message — *before* the newest +user message, so the model reads recap then request and answers the request. If +the model has not answered the recap prompt yet, the goal text stands in. Its +widget line shows the goal and how many recaps went out. It is a reminder, not an instruction: the user can change direction at any time, and the message says so on its face. diff --git a/docs/WORKFLOW.md b/docs/WORKFLOW.md index 472efd9..ef310dc 100644 --- a/docs/WORKFLOW.md +++ b/docs/WORKFLOW.md @@ -39,8 +39,9 @@ cd ~/src/projekt splinter # Chat auf "work" ``` -1. **Ziel setzen**: `/goal `. Das Plugin `focus` - hält splinter dabei, auch nach Kontext-Verdichtung. +1. **Ziel setzen**: `/goal `. Das setzt das Ziel und + startet einen Turn, der einen kurzen Recap schreibt; `focus` injiziert ihn + alle sieben Turns, auch nach Kontext-Verdichtung. 2. **Projektregeln mitgeben**: splinter liest `AGENTS.md`/`GOAL.md` nicht von allein. Erste Nachricht: "Lies GOAL.md und AGENTS.md, halte dich daran." 3. **Arbeiten**: normal beschreiben, was getan werden soll. Umsetzung macht diff --git a/plugins/focus/focus.c b/plugins/focus/focus.c index b60cd59..a6daa3b 100644 --- a/plugins/focus/focus.c +++ b/plugins/focus/focus.c @@ -5,15 +5,18 @@ * SPDX-License-Identifier: BSD-3-Clause * * Long conversations drift. Ten turns in, the model is deep in a detail and the - * thing the session was started for is somewhere behind it. This plugin puts - * the goal back on the table every five turns - not as a new instruction that - * overrides the user, but as one system message right before the turn, so it - * can be read as a reminder and dismissed if the user has changed direction. + * thing the session was started for is somewhere behind it. This plugin puts a + * short recap back on the table every seven turns - not as a new instruction + * that overrides the user, but as one system message right before the turn, so + * it can be read as a reminder and dismissed if the user has changed direction. * - * The goal comes from the operator, never from the model: + * `/goal ` sets the goal. The engine starts a turn with it, asking the + * model for a short recap; the plugin remembers the answer and injects that + * recap every seventh turn. There is no separate /recap command: recapping is + * what a goal does. * * SPLINTER_FOCUS_GOAL text, exported from the config key `goal` - * SPLINTER_FOCUS_EVERY turns between reminders, default 5 + * SPLINTER_FOCUS_EVERY turns between recaps, default 7 * * A goal longer than 1000 characters is truncated with a marker: a reminder * that eats the budget it is meant to protect would be self-defeating. @@ -32,21 +35,72 @@ #include "i18n.h" #define GOAL_MAX 1000 +#define RECAP_MAX 800 /* - * goal, force and reminders are shared by three threads: /goal and /recap run - * on the UI thread, the compactor on the turn thread, the tick on its own. - * One lock for all of them; the tick used to read the goal while /goal was - * rewriting it. + * goal, recap and reminders are shared by three threads: /goal runs on the UI + * thread, the compactor on the turn thread, the tick on its own. One lock for + * all of them; the tick used to read the goal while /goal was rewriting it. */ static pthread_mutex_t focus_lock = PTHREAD_MUTEX_INITIALIZER; static char goal[GOAL_MAX + 1]; -static unsigned every = 5; +static char recap[RECAP_MAX + 1]; /* the model's short recap of the goal */ +static int recap_pending; /* goal set, waiting for that answer */ +static unsigned every = 7; static unsigned last_reminder; -static int force; /* /recap: remind on the next turn */ static unsigned reminders; static char widget_text[128]; +/* One line, bounded: the recap travels in a system message, not a transcript. */ +static void +recap_fit(char *s, size_t cap) +{ + size_t i = 0, n = 0; + + while (s[i] != '\0' && n + 1 < cap) { + unsigned char c = (unsigned char)s[i++]; + + if (c == '\n' || c == '\r' || c == '\t') { + if (n > 0 && s[n - 1] != ' ') + s[n++] = ' '; + } else if (c == ' ') { + if (n > 0 && s[n - 1] != ' ') + s[n++] = ' '; + } else + s[n++] = (char)c; + } + while (n > 0 && s[n - 1] == ' ') + n--; + s[n] = '\0'; +} + +/* + * The first answer after /goal is the recap. A tool round may put empty + * assistant messages before it; only text without calls counts. + */ +static void +recap_capture(struct sp_conv *conv) +{ + size_t i; + + if (!recap_pending || conv == NULL) + return; + for (i = conv->n; i > 0; i--) { + const struct sp_msg *m = &conv->v[i - 1]; + + if (m->role == NULL || strcmp(m->role, "assistant") != 0) + continue; + if (m->content == NULL || m->content[0] == '\0') + continue; + if (m->calls != NULL && m->calls[0] != '\0') + continue; + snprintf(recap, sizeof(recap), "%s", m->content); + recap_fit(recap, sizeof(recap)); + recap_pending = 0; + return; + } +} + static int focus_compact(struct sp_host *h, struct sp_conv *conv, size_t budget, unsigned turn) @@ -55,27 +109,29 @@ focus_compact(struct sp_host *h, struct sp_conv *conv, size_t budget, struct sp_msg m; size_t at; - char g[GOAL_MAX + 1]; + char r[GOAL_MAX + 1]; (void)budget; (void)h; if (conv == NULL || conv->n == 0) return 0; pthread_mutex_lock(&focus_lock); - if (goal[0] == '\0' || (!force && (turn == 0 || (turn % every) != 0)) || - turn == last_reminder) { /* one reminder per turn, always */ + recap_capture(conv); + if (goal[0] == '\0' || turn == 0 || (turn % every) != 0 || + turn == last_reminder) { /* one recap per turn, always */ pthread_mutex_unlock(&focus_lock); return 0; } - snprintf(g, sizeof(g), "%s", goal); + snprintf(r, sizeof(r), "%s", recap[0] != '\0' ? recap : goal); pthread_mutex_unlock(&focus_lock); { - char rem[1024]; + char rem[GOAL_MAX + 256]; snprintf(rem, sizeof(rem), sp_td("focus.reminder", - "Before answering, check whether the last step moved closer " - "to the goal. If not, say so and name the next step. Goal: %s"), g); + "Recap to remember: %s. Before answering, check whether the " + "last step moved closer to the goal; if not, say so and name " + "the next step."), r); snprintf(text, sizeof(text), "[focus] %s", rem); } @@ -93,7 +149,6 @@ focus_compact(struct sp_host *h, struct sp_conv *conv, size_t budget, pthread_mutex_lock(&focus_lock); last_reminder = turn; - force = 0; reminders++; snprintf(widget_text, sizeof(widget_text), "%u reminders, every %u turns", reminders, every); @@ -102,9 +157,8 @@ focus_compact(struct sp_host *h, struct sp_conv *conv, size_t budget, } /* - * /goal set the goal at runtime, effective from the next request + * /goal set the goal; the engine starts the recap turn * /goal show what it is now - * /recap force the reminder into the next turn */ static int focus_command(struct sp_host *h, const char *args, struct sp_buf *out, @@ -122,14 +176,15 @@ focus_command(struct sp_host *h, const char *args, struct sp_buf *out, if (g[0] == '\0') return sp_buf_puts(out, sp_td("focus.none", "no goal set (/goal )")); return sp_buf_printf(out, sp_td("focus.status", - "goal: %s (%u reminders, every %u turns)"), g, n, every); + "goal: %s (%u recaps, every %u turns)"), g, n, every); } snprintf(goal, sizeof(goal), "%.*s", GOAL_MAX, args); if (strlen(args) > GOAL_MAX) snprintf(goal + GOAL_MAX - 24, 25, "...[gekuerzt]"); + recap[0] = '\0'; + recap_pending = 1; reminders = 0; last_reminder = 0; - force = 0; snprintf(g, sizeof(g), "%s", goal); pthread_mutex_unlock(&focus_lock); /* publish now, so the sidebar does not wait for the next tick */ @@ -143,24 +198,6 @@ focus_command(struct sp_host *h, const char *args, struct sp_buf *out, return sp_buf_printf(out, sp_td("focus.set", "goal set: %s"), g); } -static int -recap_command(struct sp_host *h, const char *args, struct sp_buf *out, - void *ctx) -{ - (void)h; - (void)args; - (void)ctx; - pthread_mutex_lock(&focus_lock); - if (goal[0] == '\0') { - pthread_mutex_unlock(&focus_lock); - return sp_buf_puts(out, sp_td("focus.none", "no goal set (/goal )")); - } - force = 1; /* the next turn gets a reminder */ - pthread_mutex_unlock(&focus_lock); - return sp_buf_puts(out, sp_td("focus.recap", - "reminder scheduled for the next turn")); -} - static int focus_tick(struct sp_host *h, const char *name, void *ctx) { @@ -187,6 +224,8 @@ focus_init(struct sp_host *h) const char *e = getenv("SPLINTER_FOCUS_EVERY"); memset(goal, 0, sizeof(goal)); + memset(recap, 0, sizeof(recap)); + recap_pending = 0; if (g != NULL) { snprintf(goal, sizeof(goal), "%.*s", GOAL_MAX, g); if (strlen(g) > GOAL_MAX) @@ -199,8 +238,6 @@ focus_init(struct sp_host *h) return -1; if (sp_host_add_command(h, "goal", focus_command, NULL) != 0) return -1; - if (sp_host_add_command(h, "recap", recap_command, NULL) != 0) - return -1; if (sp_host_add_widget(h, &w) != 0) return -1; return 0; diff --git a/share/locale/de.msg b/share/locale/de.msg index f29b242..b9a9c5c 100644 --- a/share/locale/de.msg +++ b/share/locale/de.msg @@ -42,10 +42,11 @@ role.tool = werkzeug role.observation = ausgabe err.thread = Turn-Thread laesst sich nicht starten err.turn_failed = Turn fehlgeschlagen -focus.reminder = Pruefe vor der Antwort, ob der letzte Schritt naeher am Ziel war; wenn nicht, sage das und nenne den naechsten Schritt. Ziel: %s +focus.reminder = Recap zum Merken: %s. Pruefe vor der Antwort, ob der letzte Schritt naeher am Ziel war; wenn nicht, sage das und nenne den naechsten Schritt. +focus.recap_prompt = Ziel: %s. Schreibe einen kurzen Recap zum Merken: 3-5 Punkte, was am Ende stimmen muss, die ersten konkreten Schritte und offene Fragen. focus.set = Ziel gesetzt: %s focus.none = kein Ziel gesetzt (/goal ) -focus.status = Ziel: %s (%u Erinnerungen, alle %u Turns) +focus.status = Ziel: %s (%u Recaps, alle %u Turns) cps.idle = Leerlauf (angewandt %lu, vorbereitet %lu) cps.plan = Plan bereit: schnitt %zu/%zu, %zu -> %zu B cli.no_output = cli: '%s' lieferte keine Ausgabe @@ -76,7 +77,6 @@ ack.granted = Zustimmung erteilt. ack.refused = Abgelehnt. ack.gone = Diese Anfrage gibt es nicht (mehr). ack.waiting = Ich warte noch auf eine Zustimmung: ok %d / no %d -focus.recap = Erinnerung fuer den naechsten Turn eingeplant # openai transport openai.oom = openai: kein Speicher @@ -98,11 +98,10 @@ delegate.parallel_timeout = [parallel: Zeitueberschreitung, Rest wird beendet] # telegram menu and approval buttons tg.cmd.start = Begruessung und Befehle tg.cmd.help = Hilfe und Befehle -tg.cmd.goal = Ziel setzen oder zeigen -tg.cmd.recap = Ziel in die naechste Runde legen +tg.cmd.goal = Ziel setzen oder zeigen, dann zusammenfassen tg.cmd.run = fuehrt /%s aus tg.cmd.tasks = Plandateien zeigen -tg.help = Ich bin splinter. Schreib eine Nachricht fuer einen Turn. /goal setzt das Ziel, /recap legt es in die naechste Runde, /tasks zeigt den Plan. Aenderungen fragen hier mit Ja/Nein oder ok / no . +tg.help = Ich bin splinter. Schreib eine Nachricht fuer einen Turn. /goal setzt das Ziel und startet einen Recap-Turn, /tasks zeigt den Plan. Aenderungen fragen hier mit Ja/Nein oder ok / no . ack.yes = Ja ack.no = Nein ack.how = Antwort: Knopf unten oder ok %d / no %d diff --git a/share/locale/en.msg b/share/locale/en.msg index 9e89deb..ec9ac23 100644 --- a/share/locale/en.msg +++ b/share/locale/en.msg @@ -41,10 +41,11 @@ role.tool = tool role.observation = output err.thread = cannot start the turn thread err.turn_failed = turn failed -focus.reminder = Before answering, check whether the last step moved closer to the goal. If not, say so and name the next step. Goal: %s +focus.reminder = Recap to remember: %s. Before answering, check whether the last step moved closer to the goal; if not, say so and name the next step. +focus.recap_prompt = Goal: %s. Write a short recap to remember: 3-5 bullets, what must be true at the end, the first concrete steps, and open questions. focus.set = goal set: %s focus.none = no goal set (/goal ) -focus.status = goal: %s (%u reminders, every %u turns) +focus.status = goal: %s (%u recaps, every %u turns) cps.idle = idle (applied %lu, prepared %lu) cps.plan = plan ready: cut %zu/%zu, %zu -> %zu B cli.no_output = cli: '%s' produced no output @@ -75,7 +76,6 @@ ack.granted = Approved. ack.refused = Refused. ack.gone = There is no such request (any more). ack.waiting = Still waiting for an approval: ok %d / no %d -focus.recap = reminder scheduled for the next turn # openai transport openai.oom = openai: out of memory @@ -97,11 +97,10 @@ delegate.parallel_timeout = [parallel: timeout, killing the rest] # telegram menu and approval buttons tg.cmd.start = Greeting and commands tg.cmd.help = Help and commands -tg.cmd.goal = Set or show the goal -tg.cmd.recap = Put the goal into the next turn +tg.cmd.goal = Set or show the goal, then recap it tg.cmd.run = run /%s tg.cmd.tasks = Show the plan -tg.help = I am splinter. Send a message for a turn. /goal sets the goal, /recap puts it into the next turn, /tasks shows the plan. Changes ask here with Yes/No or ok / no . +tg.help = I am splinter. Send a message for a turn. /goal sets the goal and starts a recap turn, /tasks shows the plan. Changes ask here with Yes/No or ok / no . ack.yes = Yes ack.no = No ack.how = Answer: button below or ok %d / no %d diff --git a/share/locale/pt_BR.msg b/share/locale/pt_BR.msg index 2e20cc0..e004627 100644 --- a/share/locale/pt_BR.msg +++ b/share/locale/pt_BR.msg @@ -56,10 +56,11 @@ err.turn_failed = turno falhou auth.mutate = altera arquivos auth.destructive = destrutivo -focus.reminder = Antes de responder, verifique se o ultimo passo aproximou do objetivo; se nao, diga isso e proponha o proximo passo. Objetivo: %s +focus.reminder = Recap para lembrar: %s. Antes de responder, verifique se o ultimo passo aproximou do objetivo; se nao, diga isso e proponha o proximo passo. +focus.recap_prompt = Objetivo: %s. Escreva um recap curto para lembrar: 3-5 pontos, o que precisa estar certo no final, os primeiros passos concretos e as perguntas abertas. focus.set = objetivo definido: %s focus.none = nenhum objetivo definido (/goal ) -focus.status = objetivo: %s (%u lembretes, a cada %u turnos) +focus.status = objetivo: %s (%u recaps, a cada %u turnos) cps.idle = ocioso (aplicado %lu, preparado %lu) cps.plan = plano pronto: corte %zu/%zu, %zu -> %zu B @@ -79,7 +80,6 @@ ack.granted = Aprovado. ack.refused = Recusado. ack.gone = Esse pedido nao existe (mais). ack.waiting = Ainda aguardando uma aprovacao: ok %d / no %d -focus.recap = lembrete agendado para o proximo turno # openai transport openai.oom = openai: sem memoria @@ -101,11 +101,10 @@ delegate.parallel_timeout = [paralelo: tempo esgotado, encerrando o resto] # telegram menu and approval buttons tg.cmd.start = Saudacao e comandos tg.cmd.help = Ajuda e comandos -tg.cmd.goal = Definir ou mostrar a meta -tg.cmd.recap = Levar a meta para o proximo turno +tg.cmd.goal = Definir ou mostrar a meta, depois resumir tg.cmd.run = executa /%s tg.cmd.tasks = Mostrar o plano -tg.help = Eu sou o splinter. Envie uma mensagem para um turno. /goal define a meta, /recap leva a meta para o proximo turno, /tasks mostra o plano. Mudancas perguntam aqui com Sim/Nao ou ok / no . +tg.help = Eu sou o splinter. Envie uma mensagem para um turno. /goal define a meta e inicia um turno de recap, /tasks mostra o plano. Mudancas perguntam aqui com Sim/Nao ou ok / no . ack.yes = Sim ack.no = Nao ack.how = Resposta: botao abaixo ou ok %d / no %d diff --git a/src/backend/engine.c b/src/backend/engine.c index f0b79a2..bafc4f9 100644 --- a/src/backend/engine.c +++ b/src/backend/engine.c @@ -2005,6 +2005,33 @@ sp_engine_input(struct sp_engine *e, const char *line, struct sp_buf *out) connect_ask(&e->cc, out); return SP_INPUT_HANDLED; } + /* + * /goal is a command and a prompt: the plugin stores the goal, + * then a turn asks the model for the short recap that the plugin will + * inject every few turns. /goal without text stays a status command. + */ + if (strcmp(name, "goal") == 0 && args[0] != '\0' && e->host != NULL) { + struct sp_buf confirm; + + if (sp_buf_init(&confirm) == 0) { + int set = sp_host_command(e->host, name, args, &confirm); + + if (set == 0) { + if (confirm.p != NULL && confirm.len > 0) + ev_push(e, SP_EV_ENTRY, 0, "splinter", + confirm.p); + sp_buf_clear(out); + sp_buf_printf(out, sp_td("focus.recap_prompt", + "Goal: %s. Write a short recap to remember: " + "3-5 bullets, what must be true at the end, " + "the first concrete steps, and open " + "questions."), args); + sp_buf_free(&confirm); + return SP_INPUT_PROMPT; + } + sp_buf_free(&confirm); + } + } if (e->host != NULL && sp_host_command(e->host, name, args, out) == 0) return SP_INPUT_HANDLED; /* diff --git a/src/backend/telegram.c b/src/backend/telegram.c index cf4c16e..5b43412 100644 --- a/src/backend/telegram.c +++ b/src/backend/telegram.c @@ -826,8 +826,6 @@ tg_known_desc(const char *name) return sp_t("tg.cmd.help"); if (strcmp(name, "goal") == 0) return sp_t("tg.cmd.goal"); - if (strcmp(name, "recap") == 0) - return sp_t("tg.cmd.recap"); if (strcmp(name, "tasks") == 0) return sp_t("tg.cmd.tasks"); return NULL; @@ -2089,8 +2087,8 @@ sp_telegram_run(struct sp_agent *ag, struct sp_host *host, const char *token, sp_buf_clear(&aerr); /* * A slash command is the harness talking, not the - * model: /goal and /recap come from plugins and - * answer without a request. + * model: /goal comes from a plugin and may + * start a prompt, not only answer. */ /* * An answer to a pending approval. The gateway is the one diff --git a/src/backend/theme.c b/src/backend/theme.c index 2ff0001..4d5344e 100644 --- a/src/backend/theme.c +++ b/src/backend/theme.c @@ -50,20 +50,46 @@ load_cde(const struct sp_palette *p, struct sp_theme *out) out->name = p->name; memcpy(out->bg, p->c[4], 3); /* set 5: main windows */ cde_fg(out->bg, out->fg); - memcpy(out->accent, p->c[0], 3); /* set 1: active frame */ + memcpy(out->accent, p->c[0], 3); /* set 1: active frame, user */ memcpy(out->border, p->c[1], 3); /* set 2: inactive frame */ + out->think[0] = p->c[2][0]; /* set 3: reasoning */ + out->think[1] = p->c[2][1]; + out->think[2] = p->c[2][2]; memcpy(out->input_bg, p->c[3], 3); /* set 4: text areas */ cde_fg(out->input_bg, out->input_fg); memcpy(out->status, p->c[5], 3); /* set 6: dialogs, menus */ cde_fg(out->status, out->status_fg); + out->tool[0] = p->c[5][0]; /* set 6: tool calls */ + out->tool[1] = p->c[5][1]; + out->tool[2] = p->c[5][2]; + out->agent[0] = p->c[6][0]; /* set 7: the model's answer */ + out->agent[1] = p->c[6][1]; + out->agent[2] = p->c[6][2]; + out->notice[0] = p->c[7][0]; /* set 8: status and notes */ + out->notice[1] = p->c[7][1]; + out->notice[2] = p->c[7][2]; if (luma(out->bg) > LIGHT) { out->error[0] = 0xa0; out->error[1] = 0x10; out->error[2] = 0x10; } else { out->error[0] = 0xff; out->error[1] = 0x70; out->error[2] = 0x70; } - /* a frame colour as text on the window colour: legible, or pushed */ - sp_color_separate(out->accent, out->bg, 70000); + /* + * A frame colour as text on the window colour: legible, or pushed. The + * role colours keep their hue; only their distance from the surface is + * adjusted, so a palette's character survives. + */ + /* + * The role colours only move when the palette puts them too close to + * the surface. A high minimum turned a whole light palette into greys; + * these thresholds keep the hue and differ slightly so a monochrome + * palette still gets distinguishable steps. + */ + sp_color_separate(out->accent, out->bg, 30000); sp_color_separate(out->border, out->bg, 50000); + sp_color_separate(out->agent, out->bg, 32000); + sp_color_separate(out->think, out->bg, 28000); + sp_color_separate(out->tool, out->bg, 34000); + sp_color_separate(out->notice, out->bg, 36000); sp_color_separate(out->error, out->bg, 60000); } @@ -196,6 +222,10 @@ sp_theme_from_xrdb(const char *text, struct sp_theme *out) out->idx_bg = 0; out->idx_border = 8; out->idx_accent = 12; + out->idx_agent = 10; + out->idx_think = 11; + out->idx_tool = 14; + out->idx_notice = 13; out->idx_error = 9; return 0; } @@ -233,6 +263,27 @@ sp_theme_from_xrdb(const char *text, struct sp_theme *out) else { out->error[0] = 0xff; out->error[1] = 0x50; out->error[2] = 0x50; } + /* the role colours: bright on dark, plain on light, always the same role */ + i = dark ? (have[10] ? 10 : 2) : (have[2] ? 2 : 10); + if (have[i]) + memcpy(out->agent, col[i], 3); + else + memcpy(out->agent, out->accent, 3); + i = dark ? (have[11] ? 11 : 3) : (have[3] ? 3 : 11); + if (have[i]) + memcpy(out->think, col[i], 3); + else + memcpy(out->think, out->accent, 3); + i = dark ? (have[14] ? 14 : 6) : (have[6] ? 6 : 14); + if (have[i]) + memcpy(out->tool, col[i], 3); + else + memcpy(out->tool, out->accent, 3); + i = dark ? (have[13] ? 13 : 5) : (have[5] ? 5 : 13); + if (have[i]) + memcpy(out->notice, col[i], 3); + else + memcpy(out->notice, out->accent, 3); i = dark ? (have[8] ? 8 : 0) : (have[7] ? 7 : 15); if (have[i]) memcpy(out->status, col[i], 3); @@ -240,8 +291,12 @@ sp_theme_from_xrdb(const char *text, struct sp_theme *out) memcpy(out->status, fg, 3); memcpy(out->status_fg, fg, 3); sp_color_separate(out->status_fg, out->status, 90000); - sp_color_separate(out->accent, out->bg, 50000); + sp_color_separate(out->accent, out->bg, 30000); sp_color_separate(out->border, out->bg, 40000); + sp_color_separate(out->agent, out->bg, 32000); + sp_color_separate(out->think, out->bg, 28000); + sp_color_separate(out->tool, out->bg, 34000); + sp_color_separate(out->notice, out->bg, 36000); sp_color_separate(out->error, out->bg, 50000); return 0; } @@ -366,35 +421,36 @@ sp_color_rgb(unsigned char r, unsigned char g, unsigned char b, short colors) int i, best = 0, bestd = 1 << 30; if (colors >= 256) { - int ri = 0, gi = 0, bi = 0, dr, dg, db; + /* + * Nearest of the 240 cube/ramp colours, not the cube corner the + * channels happen to share. Rounding each channel down made a + * dark orange a grey (240 instead of a brown cube entry) and the + * palette colours lost their hue on the screen. + */ + best = 16; + bestd = 1 << 30; + for (i = 16; i < 256; i++) { + int cr, cg, cb, dr, dg, db, d; - for (i = 1; i < 6; i++) { - if (r >= level[i]) - ri = i; - } - for (i = 1; i < 6; i++) { - if (g >= level[i]) - gi = i; - } - for (i = 1; i < 6; i++) { - if (b >= level[i]) - bi = i; - } - dr = r - level[ri]; - dg = g - level[gi]; - db = b - level[bi]; - if (dr * dr + dg * dg + db * db > 3 * 32 * 32) { - /* closer to a grey than to a cube corner: use the ramp */ - int grey = (r + g + b) / 3; - int gi2 = (grey - 8) / 10; + if (i < 232) { + int k = i - 16; - if (gi2 < 0) - gi2 = 0; - if (gi2 > 23) - gi2 = 23; - return (short)(232 + gi2); + cr = level[k / 36]; + cg = level[(k / 6) % 6]; + cb = level[k % 6]; + } else { + cr = cg = cb = 8 + (i - 232) * 10; + } + dr = r - cr; + dg = g - cg; + db = b - cb; + d = dr * dr + dg * dg + db * db; + if (d < bestd) { + bestd = d; + best = i; + } } - return (short)(16 + 36 * ri + 6 * gi + bi); + return (short)best; } for (i = 0; i < (colors >= 16 ? 16 : 8); i++) { diff --git a/src/backend/theme.h b/src/backend/theme.h index 5ec8b63..ac77f84 100644 --- a/src/backend/theme.h +++ b/src/backend/theme.h @@ -35,8 +35,12 @@ struct sp_theme { const char *name; unsigned char bg[3]; /* the chat background */ unsigned char fg[3]; /* text on it */ - unsigned char border[3]; /* secondary text: labels, tool lines */ + unsigned char border[3]; /* secondary text: labels, observations */ unsigned char accent[3]; /* the user's lines */ + unsigned char agent[3]; /* the model's answer */ + unsigned char think[3]; /* the model's reasoning */ + unsigned char tool[3]; /* a tool call */ + unsigned char notice[3]; /* status and session notes */ unsigned char error[3]; /* errors */ unsigned char input_bg[3]; /* the input line */ unsigned char input_fg[3]; @@ -47,7 +51,8 @@ struct sp_theme { * index in idx[], so the terminal's own palette shows. */ int indexed; - short idx_fg, idx_bg, idx_border, idx_accent, idx_error; + short idx_fg, idx_bg, idx_border, idx_accent, idx_agent; + short idx_think, idx_tool, idx_notice, idx_error; }; #define SP_THEME_DEFAULT "Xresources" diff --git a/src/backend/usage.c b/src/backend/usage.c index 850f4c6..1afd5dd 100644 --- a/src/backend/usage.c +++ b/src/backend/usage.c @@ -190,10 +190,20 @@ sp_usage_get(const char *id, unsigned long req_limit, long req_window, to = strtol(e, &e, 10); if (ts <= 0) continue; - if (req_window > 0 && ts > now - req_window) { + if (req_window > 0) { + if (ts > now - req_window) { + u->req_used++; + if (oldest_r == 0 || ts < oldest_r) + oldest_r = ts; + } + } else { + /* + * No declared request limit: 'calls' is what the + * sidebar shows, so count the calls the log still + * holds. Leaving it at zero made every unlimited + * provider read "0 calls" after every turn. + */ u->req_used++; - if (oldest_r == 0 || ts < oldest_r) - oldest_r = ts; } if (tok_window > 0 && ts > now - tok_window) { u->tok_used += (unsigned long)(ti + to); diff --git a/src/frontend/curses.c b/src/frontend/curses.c index 8cdaeb9..1dc7fad 100644 --- a/src/frontend/curses.c +++ b/src/frontend/curses.c @@ -140,11 +140,15 @@ static char ui_agent[32]; enum { PAIR_MAIN = 1, /* fg on bg */ - PAIR_ACCENT, /* accent */ - PAIR_DIM, /* border */ - PAIR_STATUS, /* hints and questions */ + PAIR_ACCENT, /* the user's lines */ + PAIR_DIM, /* border: observations, secondary text */ + PAIR_STATUS, /* the status bar */ PAIR_INPUT, /* the input line */ - PAIR_ERROR /* errors */ + PAIR_ERROR, /* errors */ + PAIR_AGENT, /* the model's answer */ + PAIR_THINK, /* the model's reasoning */ + PAIR_TOOL, /* a tool call */ + PAIR_NOTICE /* status and session notes */ }; /* the session id and directory the sidebar shows */ @@ -248,6 +252,10 @@ init_colors(const struct sp_theme *t) short accent = n >= 16 ? t->idx_accent : COLOR_BLUE; short dim = n >= 16 ? t->idx_border : COLOR_WHITE; short errc = n >= 16 ? t->idx_error : COLOR_RED; + short agent = n >= 16 ? t->idx_agent : COLOR_GREEN; + short think = n >= 16 ? t->idx_think : COLOR_YELLOW; + short tool = n >= 16 ? t->idx_tool : COLOR_CYAN; + short notice = n >= 16 ? t->idx_notice : COLOR_MAGENTA; init_pair(PAIR_MAIN, t->idx_fg, t->idx_bg); init_pair(PAIR_ACCENT, accent, t->idx_bg); @@ -255,6 +263,10 @@ init_colors(const struct sp_theme *t) init_pair(PAIR_STATUS, t->idx_bg, t->idx_fg); init_pair(PAIR_INPUT, t->idx_fg, t->idx_bg); init_pair(PAIR_ERROR, errc, t->idx_bg); + init_pair(PAIR_AGENT, agent, t->idx_bg); + init_pair(PAIR_THINK, think, t->idx_bg); + init_pair(PAIR_TOOL, tool, t->idx_bg); + init_pair(PAIR_NOTICE, notice, t->idx_bg); return; } init_pair(PAIR_MAIN, rgb(t->fg, n), rgb(t->bg, n)); @@ -263,6 +275,10 @@ init_colors(const struct sp_theme *t) init_pair(PAIR_STATUS, rgb(t->status_fg, n), rgb(t->status, n)); init_pair(PAIR_INPUT, rgb(t->input_fg, n), rgb(t->input_bg, n)); init_pair(PAIR_ERROR, rgb(t->error, n), rgb(t->bg, n)); + init_pair(PAIR_AGENT, rgb(t->agent, n), rgb(t->bg, n)); + init_pair(PAIR_THINK, rgb(t->think, n), rgb(t->bg, n)); + init_pair(PAIR_TOOL, rgb(t->tool, n), rgb(t->bg, n)); + init_pair(PAIR_NOTICE, rgb(t->notice, n), rgb(t->bg, n)); } /* @@ -955,7 +971,9 @@ draw_history(struct ui_state *s) if (strcmp(e->role, "you") == 0) wattrset(ui_hist, COLOR_PAIR(PAIR_ACCENT) | A_BOLD); else if (strcmp(e->role, "agent") == 0) - wattrset(ui_hist, COLOR_PAIR(PAIR_MAIN)); + wattrset(ui_hist, COLOR_PAIR(PAIR_AGENT)); + else if (strcmp(e->role, "thinking") == 0) + wattrset(ui_hist, COLOR_PAIR(PAIR_THINK)); else if (strcmp(e->role, "error") == 0) wattrset(ui_hist, COLOR_PAIR(PAIR_ERROR) | A_BOLD); /* @@ -963,8 +981,11 @@ draw_history(struct ui_state *s) * returned is reference material under it. Painted with it, the * transcript read as one grey wall of "Run". */ - else if (strcmp(e->role, "tool") == 0) - wattrset(ui_hist, COLOR_PAIR(PAIR_ACCENT)); + else if (strcmp(e->role, "tool") == 0 || + strcmp(e->role, "shell") == 0) + wattrset(ui_hist, COLOR_PAIR(PAIR_TOOL) | A_BOLD); + else if (strcmp(e->role, "splinter") == 0) + wattrset(ui_hist, COLOR_PAIR(PAIR_NOTICE)); else wattrset(ui_hist, COLOR_PAIR(PAIR_DIM)); if (blank[idx]) { diff --git a/src/www/index.en.html b/src/www/index.en.html index cf9052c..fe010e6 100644 --- a/src/www/index.en.html +++ b/src/www/index.en.html @@ -140,7 +140,7 @@ coder 7 task mentions 'code'

A plugin is a .so loaded with dlopen. It can register tools, slash commands, sidebar widgets, transports and gates. A widget's tick runs on its own thread; only the UI thread draws. The ABI is in docs/PLUGINS.md. Plugins run in the process with your rights.

  • lcm, cps: compact the conversation
  • -
  • focus: reminds the model of /goal every N turns
  • +
  • focus: keeps a /goal recap in front every 7 turns
  • reminder: puts the ground rules back every 10 turns
  • ring: next exit on 429 or limit
  • mcp, a2a, cli: reach other tools and agents
  • diff --git a/src/www/index.html b/src/www/index.html index f9961de..b42a4a2 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -140,7 +140,7 @@ coder 7 task mentions 'code'

    Ein Plugin ist eine .so, die per dlopen geladen wird. Es kann Werkzeuge, Slash-Befehle, Seitenleisten-Widgets, Transporte und Gates registrieren. Der Tick eines Widgets läuft auf einem eigenen Thread; gezeichnet wird nur im UI-Thread. Die ABI steht in docs/PLUGINS.md. Plugins laufen im Prozess mit deinen Rechten.

    • lcm, cps: Konversation komprimieren
    • -
    • focus: erinnert alle N Turns an /goal
    • +
    • focus: legt /goal als Recap alle 7 Turns vor
    • reminder: legt alle 10 Turns die Grundregeln zurück
    • ring: nächster Ausgang bei 429 oder Limit
    • mcp, a2a, cli: andere Werkzeuge und Agenten erreichen
    • diff --git a/src/www/index.pt.html b/src/www/index.pt.html index b453195..effcc83 100644 --- a/src/www/index.pt.html +++ b/src/www/index.pt.html @@ -140,7 +140,7 @@ coder 7 task mentions 'code'

      Um plugin é um .so carregado com dlopen. Ele pode registrar ferramentas, comandos com barra, widgets da barra lateral, transportes e gates. O tick de um widget roda em thread própria; só a thread da UI desenha. A ABI está em docs/PLUGINS.md. Plugins rodam no processo com os seus direitos.

      • lcm, cps: comprimem a conversa
      • -
      • focus: lembra o /goal a cada N turnos
      • +
      • focus: mantem o recap do /goal a cada 7 turnos
      • reminder: repõe as regras básicas a cada 10 turnos
      • ring: próxima saída em 429 ou limite
      • mcp, a2a, cli: alcançam outras ferramentas e agentes
      • diff --git a/tests/test_a2a_ui.sh b/tests/test_a2a_ui.sh index 0d806f8..8417092 100755 --- a/tests/test_a2a_ui.sh +++ b/tests/test_a2a_ui.sh @@ -64,6 +64,9 @@ tmux new-session -d -s $S -x 110 -y 30 \ ./splinter --no-config --plugin plugins/a2a/a2a.so \ --transport a2a --chat 2>/dev/null; echo \$? > $D/rc" shows 'Enter sends' +# the ready entry is drawn before ui_read_line() owns the keyboard; give the +# first wgetch a moment, or the first byte of the first prompt can be lost +sleep 1 # artifact chunks stream; the completed status note is not appended typed 'stream bitte'; key Enter diff --git a/tests/test_focus.c b/tests/test_focus.c index 88c0b21..127e61f 100644 --- a/tests/test_focus.c +++ b/tests/test_focus.c @@ -119,15 +119,17 @@ main(void) CHECK(sp_host_compact(host, &conv, 1) == 1); CHECK(count_focus(&conv) == 2); - /* ---- /goal sets it at runtime, /recap forces the next reminder ---- */ + /* ---- /goal is the recap feature; /recap is not a command ---- */ { struct sp_buf out; + size_t i; + int found = 0; CHECK(sp_buf_init(&out) == 0); sp_conv_free(&conv); sp_conv_init(&conv); - CHECK(sp_conv_push(&conv, "user", NULL, "turn fuenf") == 0); + CHECK(sp_conv_push(&conv, "user", NULL, "start") == 0); sp_buf_clear(&out); CHECK(sp_host_command(host, "goal", "", &out) == 0); @@ -137,17 +139,31 @@ main(void) CHECK(sp_host_command(host, "goal", "neues ziel", &out) == 0); CHECK(strstr(out.p, "neues ziel") != NULL); - /* a forced recap lands on the next turn regardless of the counter */ - sp_buf_clear(&out); - CHECK(sp_host_command(host, "recap", "", &out) == 0); + /* the goal prompt starts a turn; no recap exists yet */ + CHECK(sp_conv_push(&conv, "user", NULL, + "Goal: neues ziel. Write a short recap.") == 0); sp_host_turn(host); - { - int before = count_focus(&conv); + CHECK(sp_host_compact(host, &conv, 1) == 0); - CHECK(sp_host_compact(host, &conv, 1) == 1); - CHECK(count_focus(&conv) == before + 1); - CHECK(strstr(conv.v[conv.n - 1].content, "turn fuenf") != NULL); - } + /* the answer is the recap; the next turn injects it */ + CHECK(sp_conv_push(&conv, "assistant", NULL, + "KURZ: neues ziel, erster Schritt") == 0); + CHECK(sp_conv_push(&conv, "user", NULL, "weiter") == 0); + sp_host_turn(host); + CHECK(sp_host_compact(host, &conv, 1) == 1); + CHECK(count_focus(&conv) == 1); + for (i = 0; i < conv.n; i++) + if (conv.v[i].content != NULL && + strstr(conv.v[i].content, "[focus]") != NULL) { + CHECK(strstr(conv.v[i].content, "KURZ") != NULL); + found = 1; + } + CHECK(found); + + /* /recap is gone; /goal carries the recap now */ + sp_buf_clear(&out); + CHECK(sp_host_command(host, "recap", "", &out) == -1); + CHECK(strstr(out.p, "unknown command") != NULL); /* an unknown command is refused and says so */ sp_buf_clear(&out); diff --git a/tests/test_theme.c b/tests/test_theme.c index cb4a6c9..6807208 100644 --- a/tests/test_theme.c +++ b/tests/test_theme.c @@ -63,6 +63,12 @@ main(void) luma(t.bg) == luma(t.fg)); CHECK(abs(luma(t.input_fg) - luma(t.input_bg)) >= 100000 || luma(t.input_bg) == luma(t.input_fg)); + /* every role colour stands off the chat surface */ + CHECK(abs(luma(t.accent) - luma(t.bg)) >= 30000); + CHECK(abs(luma(t.agent) - luma(t.bg)) >= 32000); + CHECK(abs(luma(t.think) - luma(t.bg)) >= 28000); + CHECK(abs(luma(t.tool) - luma(t.bg)) >= 34000); + CHECK(abs(luma(t.notice) - luma(t.bg)) >= 36000); } /* X resources: the tight binding wins, 48-bit colours are read */ CHECK(sp_theme_from_xrdb("*.background:\t#6e1e7d\n" @@ -79,6 +85,8 @@ main(void) /* no resources: the terminal's own colours, by index */ CHECK(sp_theme_from_xrdb(NULL, &t) == 0); CHECK(t.indexed == 1); + CHECK(t.idx_agent == 10 && t.idx_think == 11); + CHECK(t.idx_tool == 14 && t.idx_notice == 13); CHECK(sp_theme_from_xrdb("URxvt.background: #000000\n", &t) == 0); CHECK(t.indexed == 1); diff --git a/tests/test_ui.sh b/tests/test_ui.sh index 0e04442..2f958d9 100755 --- a/tests/test_ui.sh +++ b/tests/test_ui.sh @@ -85,8 +85,11 @@ start() { # a fresh fake model and a fresh UI ./splinter --no-config --endpoint http://127.0.0.1:$P/v1/chat/completions \ --model m --chat 2>/dev/null; echo \$? > $D/rc" shows 'Enter sends' + # the ready entry is drawn before ui_read_line() owns the keyboard; a + # byte typed in that window can be lost + sleep 1 } -typed() { tmux send-keys -t $S -l "$1"; } +typed() { sleep 0.3; tmux send-keys -t $S -l "$1"; } key() { tmux send-keys -t $S "$@"; } quit_code() { key C-u C-d @@ -159,6 +162,7 @@ tmux new-session -d -s $S -x 110 -y 30 "HOME=$D/home SPLINTER_LOCALE=en \ SPLINTER_CLI_CMD='sleep 60' ./splinter --no-config --transport cli \ --plugin plugins/cli/cli.so --chat 2>/dev/null; echo \$? > $D/rc" check shows 'Enter sends' +sleep 1 typed 'tu was'; key Enter check shows 'working' sleep 0.5 @@ -194,6 +198,7 @@ check test -n "$new" typed "/open $old"; key Enter check shows 'session opened' check shows ' ok' +sleep 1 typed "/rm $new"; key Enter check shows 'removed' check test ! -e "$D/home/.splinter/$new.jsonl" diff --git a/tests/test_usage.c b/tests/test_usage.c index 3e811ae..95fd3a7 100644 --- a/tests/test_usage.c +++ b/tests/test_usage.c @@ -63,6 +63,14 @@ main(void) * between the two, and a one-second upper bound failed the suite. */ CHECK(u.reset_at >= now + 3590 && u.reset_at <= now + 3660); + /* + * Without a declared limit the sidebar still says how many calls the + * log holds; a fresh provider no longer reads "0 calls" forever. + */ + sp_usage_get("a", 0, 0, 0, 0, &u); + CHECK(u.req_used == 4); + CHECK(u.frac < 0); + sp_usage_get("a", 0, 0, 1000, 3600, &u); CHECK(u.tok_used == 600); CHECK(u.frac > 0.59 && u.frac < 0.61);