Repository navigation
feat(plugin): one prefix, status line, terminal views and user docs - #478
Conversation
|
Design review, round 1: plugin and status line. Reviewed the recordings (light and dark) against the three questions: how much am I saving, is my cache about to cost me, what should I do. Reviewer persona: a busy first-time user who has never heard of caching. Rubric
Findings
Next: the author fixes 1-6; I re-judge the recordings after the new ones are pushed. |
|
Round 1 review addressed (findings 1-7 and polish 8-11) in the latest commit; recordings in docs/plugin-v2/ re-recorded, including the expiring and cold states where the hint fires. |
|
Design review, round 2: PASS. Re-judged the new recordings (status line in warm, expiring and cold states; all remaining commands). Findings 1-6 and 8-11 are resolved: percent only with labelled Rubric: all items pass (three questions, two lines, bottom line first, dollars first, no prose paragraphs, no raw token counts, realised vs estimated separate, jargon, light and dark, namespace explained). Remaining POLISH, non-blocking:
Re-checked after the squash: the status line (warm, expiring, cold) and the six remaining commands are unchanged and still pass; the cache screen is clean without its trailing line. Saved/Estimated badge words are consistent with the dashboard. |
|
Review of 6615248 (on top of #441). Verified: Findings (none blocking)
Approving. Labelled ready-to-merge. |
990a9fe to
a8b9477
Compare
|
Re-review of a8b9477 (squashed, force-pushed): no cache-campaign command, docs, goldens, recordings or CG_DASH_COOKIE remain in the diff, so the public-contract point is resolved. A user-tuned refreshInterval is now kept on reinstall and the status line is still recognised as ours on remove (the check allows only type, command, refreshInterval). vet clean; context-guru-plugin (701 s) and cg-plugin tests pass. The shared-temp cache and lock files remain as a follow-up. Keeping ready-to-merge; merge #441 first. |
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, all /context-guru:*: status is now the home screen (bottom line, today vs yesterday, top three actions); new savings, cache, waste, session, doctor. The insights* and cost-* commands stay for one release as thin redirects. The cost engine from #441 stays in this plugin; Codex gets the same names as skills. 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. Signed-off-by: Osher-Elhadad <[email protected]>
a8b9477 to
11f465d
Compare
|
Rebased on the rebased #441 (main after #445/#477; no conflicts beyond #441's dash/api.go). One plugin, one prefix: the cg plugin is folded into context-guru as /context-guru:status (home), savings, cache, waste, session, doctor. insights* and cost-* stay for one release as thin redirects. Codex has the same names. docs/plugin-v2.md is now in the mkdocs nav; mkdocs build --strict and the plugin tests pass locally. statusline.py changes and terminal views will land here as further commits. |
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]>
…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]>
Signed-off-by: Osher-Elhadad <[email protected]>
|
Re-review of 11f465d (single prefix, on top of #441 98359cd). Both branches are mergeable against current main. The cg plugin is gone and all new commands sit under /context-guru:*; the insights and cost skills are thin redirects (same script, one line telling the user where it moved), the script files are executable and identical in the Codex copy, mkdocs nav has plugin-v2.md. No campaign files or words, no hosts, ids or paths in the diff; attribution clean. go test ./context-guru-plugin (560 s under load): one failure, TestUserScopeThenProjectKeepsTwoPorts (port_changed_since_plan, a port-allocation race on a busy host); it passes alone twice on this branch and on origin/main. User-edited refreshInterval handling is as agreed earlier. Two notes: the redirect skills pass $ARGUMENTS through to the shell command, as the insights skills did before, so keep allowed-tools restricted to the script; and #480 is stacked on the previous #478 head and has to be rebased onto this one. Approved; ready-to-merge stays (merge #441 first). |
…README section One page per command, the status line with every state, configuration and troubleshooting; screenshots are the goldens rendered, and a test keeps the example blocks equal to the goldens. Signed-off-by: Osher-Elhadad <[email protected]>
…ed order and render cost Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
|
Final design pass on the whole PR at head cd5df33: commands, status line, five terminal views, README section and docs/plugin. Persona: busy first-time user. I read the README section, all of docs/plugin, the status line and views docs, and checked that every image referenced exists. Not PASS yet: three BLOCKING wording contradictions, all quick text fixes. Checks
Findings
Pass needs 1 to 3. |
Signed-off-by: Osher-Elhadad <[email protected]>
… kept apart, colour claim fixed Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
|
Final design pass, re-check at head 25cfee3: PASS. The three blockers are fixed. The status line now shows Whole-PR checks: README and docs/plugin read clearly for a first-time user, images exist and match the text, one vocabulary (Saved / Estimated / Measured) across commands, status line, views and dashboard, no contradictions found. Remaining POLISH (non-blocking): the |
Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
…derers can import them without cg Signed-off-by: Osher-Elhadad <[email protected]>
…unctions in tvlib Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
…at, fill, watch) One-line versions of the terminal views, selectable with --layout or --set-layout, drawn with tvlib and fed by the same cached, non-blocking reads as the other layouts. Goldens at 60, 80 and 120 columns. Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
|
Design review: five new status line layouts (spark, strip, heat, fill, watch), commit da62833. Judged from the .cast output (text and escape codes) at 80 columns as a first-time user; the layouts are opt-in via
Findings
Pass needs 1 to 3. |
Signed-off-by: Osher-Elhadad <[email protected]>
…heat readable without colour Signed-off-by: Osher-Elhadad <[email protected]>
|
Status line layouts, re-check at 960a76b: PASS. Strip now has one scope, a key for the miss marker, and "lost today". Heat uses shade glyphs plus colour, shows future hours as "·" so it spans its 0h to 24h axis, and reads without colour. Watch names the clocks ("agent caches (2)") and carries the saved figure on the same line as the cache clock. Spark states its scopes ("today · last 14 days"); fill at 120 columns adds the price of a miss. All lines are 79 characters or shorter. Remaining POLISH: heat's "$5.56 lost" should say "today" like strip does, so its day scope is explicit. |
|
Review of da62833 (and cd5df33, the head main asked about). Not approved yet; the ready-to-merge label is removed until the two blockers below are fixed. Checked at cd5df33 and da62833: full BLOCKING
SHOULD FIX Re-review when 1 and 2 are fixed. |
Signed-off-by: Osher-Elhadad <[email protected]>
…nd heat follow local time The render budget is measured from process start and sizes every read; a read with a cached copy never waits (stale copy plus detached refresh), a slow proxy shows the last numbers with the stale marker. The 14-day sparkline sums the proxy's UTC-aligned hourly buckets into the user's local days. Goldens under three time zones and a slow-proxy test. Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
|
Final re-review at 2f4b916 (code at ec131b8, docs-only commit on top). Both blockers are resolved. Render time: my end-to-end harness (Python start-up included, fresh cache dir, a server that sleeps 3 s) gives minimal, balanced and detailed at 0.38 to 0.41 s with a slow proxy, cold or with a stale cache, including a run with six busy loops competing for CPU (worst 0.413 s); warm 0.05 to 0.06 s, cold 0.09 s, proxy down 0.09 s with 'cg ✕ proxy offline'. Only lean=1 stats and cachestate are read on the render path. The new TestStatuslineFinishesInHalfASecondOnASlowProxy and the #403 tests pass. Sparkline: my earlier diagnosis was wrong, the proxy's series buckets are epoch-aligned, so the hourly-sum-into-local-days approach is correct, and the goldens under Asia/Kolkata, Europe/Berlin and America/Los_Angeles agree with UTC. Full go test ./context-guru-plugin passes (374 s), mkdocs build --strict passes at 2f4b916, CI is green (build-test, build, purego, trivy, DCO), no campaign words, no AI attribution. The docs tables match my measurements. Approved; ready-to-merge. |
Status-line timing test on real data: no regression of #403Result: #478 does not bring back the false "proxy down" that #403 fixed. I tested it against copies of a real local dashboard DB (262 MB, 12.4k requests), with a darwin build of this branch and of
2 notes on this PR's own code (neither blocks it)1. A small race in the refresher lock (
2. The render budget is tighter than
|
…s loading Signed-off-by: Osher-Elhadad <[email protected]>
|
Thanks for testing on real data. Both notes are handled in 738b525. Note 1, the refresher lock. Fixed in Note 2, "loading" with a usable cache. I checked every path. A fetch that times out already shows the cached numbers with ⏳. There was one path that did not: if the fetch thread has not reported by the time the budget ends (a loaded host can starve it), the line said "loading" even with a cache on disk. That path now reads the cached body and shows it with ⏳ ( Numbers, 20 renders each, 2.1 s apart so every render fetches, stats call stalled for 5 s, on this loaded host:
The budget is unchanged (0.36 s; the render stays under 0.5 s). We'll re-check after #492 lands. |
User decision on this PR's review: remove the daily_rollup design entirely for this release. Ship only the bounded session and day scopes; lifetime (since=0) goes back to answering exactly like the full handler, no rollup, no backfill, no watermark. A bounded lifetime is its own project, tracked as #510 rather than shipped half-verified here. - Removed: the daily_rollup table and index (schema.go), its backfill (dailyrollupbackfill.go, deleted), its write-time accumulation and watermark (store.go), and its wiring into backgroundMigrations (capture.go). - OverviewLean: session and day-window scope still run the single bounded aggregate from the previous commit. True lifetime (session=="" && since==0 && until==0) now calls Overview() plus both read-time-priced credits unconditionally — byte-identical to main's own lean handler, confirmed via the regenerated stats_lean golden file (the only remaining differences are fields lean never computed even before #498: self_removed_*, tier_costs, total_reduced_usd). - Review M3: CachesplitSizeSpread (dash/cachehistory.go) ran a deployment-wide, unindexed scan on every session-scoped lean call. Added a TTL cache (5 minutes) behind a *DB-held pointer, so DB.WithContext's shallow copy stays lock-free and every handle shares one cache. TestCachesplitSizeSpreadQueryItselfIsAWholeTableScan documents why the cache exists; TestCachesplitSizeSpreadIsCached proves it intercepts repeat calls (verified it fails with the cache disabled, passes with it restored). - Review M4: cg_latency_ms_avg stays in the lean SELECT — the released v0.4.2 status line (before #478) reads it and renders "proxy: 0ms" if it is ever absent. - DeclFilterSavings now included for day-window scope too, not just session (TestOverviewLeanDeclFilterSavingsIncludedForDayScope). - The EXPLAIN-plan test now rejects "SCAN ... USING INDEX", not just a bare table scan — an index-assisted scan still visits every matching row, unbounded by session or time. Lifetime is deliberately excluded from it, with a comment pointing at the follow-up issue. - Kept: the #501 tenant-scoping fix in cachesplitHistoricalQuery. go test -race -count=1 on ./dash/... and ./proxy/... both pass. Assisted-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
Part of #470, reports to #472. This PR includes #441's commit (its cost engine, moved into this plugin) and supersedes #441.
One plugin, one prefix
Everything is
/context-guru:*. There is no second plugin./context-guru:status/context-guru:savings/context-guru:cache/context-guru:waste/context-guru:session/context-guru:doctorThe four
insights*commands moved onto these and stay for one release as thin redirects that say so and run the new command./context-guru:statuslinestill installs the status line. #441's fivecost-*skills are gone.Each screen: bottom line first, one small visual,
detailsfor tables. Dollars only, plain Unicode (readable on light and dark).✓ Savedand≈ Estimatedare separate blocks.Terminal views
/context-guru:watch(live caches),timeline,chart,heatmapandfilldraw in the terminal with the same rules: dollars first, ✓ Saved and ≈ Estimated apart, colour off when piped,--asciifor plain ASCII.#```
saved ≈$2.15 session · ≈$6.35 today · ★ ≈$212.40 lifetime
cache ◐ █░░░░░ 0:42 │ ctx ███░░░░░ 41% │ ▸ cache gone in 42s: a pause now costs ≈$1.20 to rewrite