Repository navigation
feat(plugin): five cost commands (today, unused, cold, compact, trends) - #441
Conversation
|
Reviewer: approved, with non-blocking notes. CI all pass; go test ./dash ./context-guru-plugin green; gofmt clean. Checked:
Non-blocking:
Ordering vs #440: no conflict. #441 adds cgcost.py and does not modify context-guru-plugin/scripts/insights.py, which #440 vendors as insights_core.py, so no rebase is needed in either order. Only a later PR that edits insights.py needs to refresh the Codex copy. |
…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]>
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]>
842ffc7 to
98359cd
Compare
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]>
|
Rebased on main after #445/#477; the conflict was in dash/api.go (both cache fields and both heavy-route timeout entries kept). Plugin tests pass locally; the dash suite hit a database-locked flake under load in a broad run, the spend and last-used tests pass alone. #478 builds on this commit and turns the five cost-* skills into thin redirects to the new /context-guru:* commands for one release. |
|
Re-review after the rebase (98359cd): mergeable, the dash/api.go conflict resolution keeps both sides, and the diff is the same five cost commands with the spend and last-used endpoints. ready-to-merge stays. |
Refs #436 (Workstream C). Design note: #436 (comment)
What
Five cost commands for the Claude Code plugin, each a skill, replacing the question "what is my setup costing me" with answers that are ranked, priced at the gateway's rates, labelled observed / modelled / estimate, and netted against Context Guru's own overhead.
Two read-only Go endpoints (tests included):
GET /api/spend/explain(one pass over the window; rewrites are cache_write >= 0.8 x context, read from token columns, not cache_miss_reason; the cause is inferred from idle gap and message count and says so) andGET /api/tools/last-used(names and times). Logic lives inscripts/cgcost.py, stdlib-only with the fetcher passed in, so the Codex plugin can vendor it unchanged. Old insights skills and the status line are untouched.Rules enforced by tests: Context Guru's own server and skills are never offered for removal; built-ins are never offered; a tool called in the last 30 days is flagged; a cold cache is never described as avoidable by compacting; no ANSI escapes without a tty or with NO_COLOR.
Before / after
Before:
/context-guru:insightslists findings from a 30-day window and has no answer to "what cost me most today", no per-session or per-project view, no rewrite classification, and no "compact now?" answer. The status line's unused-tool nudge ranks by use share and once named our own skill.After (synthetic fixture, 14 days, not production data):
Verified
Limits
/api/toolsis slow on a large database (about 7 s for 7 days on the snapshot copy); cost-unused and cost-trends wait for it.