Repository navigation
feat(plugin): live cache clock, sub-agent clocks, model-switch warning (stacked on #478) - #480
OsherElhadad wants to merge 4 commits into
Conversation
Adds GET /api/spend/explain (dollars by token type, full-prefix rewrites classified from token columns, live cache state, Context Guru ledger) and GET /api/tools/last-used, and scripts/cgcost.py with five skills: cost-today, cost-unused, cost-cold, cost-compact, cost-trends. Refs #436. Signed-off-by: Osher-Elhadad <[email protected]>
…commands Status line: saved session/today/lifetime, a cache bar that drains to expiry with a ping marker, a context bar with a rewrite-near warning, one hint, refreshInterval 5. New cg plugin: /cg, savings, cache, waste, session, doctor, built on the cost engine from #441 (moved, not copied). Codex gets the same commands as skills. Signed-off-by: Osher-Elhadad <[email protected]>
Count the cache down in seconds (amber, then red, then up as "cold 1:20") and give each running sub-agent its own clock. /api/cachestate gains the response end time and a per-thread list, and the main clock and context bar now follow the main thread instead of whichever agent spoke last. Drop the /compact suggestion from the cold-cache hint, warn when a model switch will rewrite the cache, explain a tool-set miss, say "proxy offline" in words, and add spend, $/h and session age to the detailed layout plus a remembered --set-layout toggle. Signed-off-by: Osher-Elhadad <[email protected]>
|
Design review, round 1: status line v3 (live clock, sub-agent clocks, model-switch warning). Reviewed all screens and the live 1 Hz recording against the status-line rubric, as a busy first-time user. Rubric
Findings
Pass needs 1 to 3 fixed and an 80-column recording. |
a8b9477 to
11f465d
Compare
|
Review of b34ff93 (stacked on #478). Run: go vet and gofmt clean; Checked
Findings (none blocking)
Approved; labelled ready-to-merge. |
…k, 80-column renders Hints no longer change wording as the clock ticks, say what a pause or model change costs in dollars, and fit an 80-column terminal. Several sub-agents show a count and the soonest expiry instead of an unlabelled list of clocks. Latency over a second is shown in seconds. Signed-off-by: Osher-Elhadad <[email protected]>
|
Design review, round 2: PASS. Re-checked every recording at commit b38f972. Blockers 1 to 3 are fixed: every default-layout render fits 79 columns (including the cold, five-sub-agent, hint worst case and the live 1 Hz run); each state has one hint phrasing, and the live run only changes wording when the state itself changes (expiring to cold); sub-agents show as Remaining POLISH, non-blocking:
|
|
Moved into #478 (one plugin, one status line). |
Stacked on #478 (base
feat/plugin-v2; retarget tomainonce #478 merges).The status line already shows a draining cache bar. This adds a live clock and covers sub-agents, which have their own caches.
What changes for the user
cache ● ████░░ 3:57), amber in the last minute, red with!in the last 15 s, then counts up (cache ○ cold 1:20).refreshIntervalis now 1 (a value someone tuned is kept). The clock runs from the end of the last response, not its start.agent ● 4:21); several show the count and the one expiring soonest (agents 5 · soonest ◐ 0:52). Finished (cold) sub-agents are not shown./api/cachestatedescribed the latest request of any thread, so a busy sub-agent kept resetting the main countdown and shrank the context bar. Both now follow the main thread./compact?suggestion from the cold-cache hint. The hint now states the dollar cost only, in one fixed phrasing per state (your next message costs ≈$0.78 extra) so the line does not change wording as the clock ticks. Every state fits 80 columns.last turn rewrote the cache: tools changed (+2 −0)from Claude Code's own miss report.cg ✕ proxy offlineinstead ofcg!.spent $4.10 · $2.73/h · up 1h30m.statusline.py --set-layout=minimal|balanced|detailed|autoremembers a layout across renders (Claude Code cannot send keys to a status line, so bind it to an alias or command).Server
GET /api/cachestategainsend_tsandthreads[](per-thread last use, TTL tier, prefix size, rewrite price; threads idle for two hours are dropped). Numbers only, same scope as before. Read from the existingrequests.thread_id; no schema change.Findings from the binary
The Claude Code 2.1.296 status line payload has no sub-agent state (
agent.nameonly),refreshIntervalis clamped to at least 1 s, andprompt_cache.expires_atcovers the main thread only. So the proxy is the source for sub-agents.Verification
dashtest for threads and response end; golden tests for critical, cold counting up (1:15 and 1h00m), main clock not reset by a sub-agent, one/several/finished sub-agents, narrow width, model switch (and same model spelled two ways), detailed spend; unit tests for the timer arithmetic (expiry cliff at 289/290/299/300/301 s, colour bands on both TTL tiers, response-end anchor, sample age, a client clock decades off, malformed input) and for--set-layout.docs/statusline-live/, produced against a test proxy with synthetic data.python3 -c passis 24 ms here;main()itself is 17 ms in-process). It never waits on the network beyond the existing 0.6 s deadline.Not in this PR
Context-full ETA, a saved-today sparkline and a "next ping" countdown need data the proxy does not yet expose.
Notes
refreshInterval: 5; a tuned value is kept, so existing users get the 1 s clock only after editing it or reinstalling.refreshInterval: 1costs one status-line process per second per open session (about 74 ms each on a loaded host). The per-thread read on the proxy is capped at 16 threads and a two-hour window.main.