Session Watcher
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
**LLM context economics, in your terminal.**
Session Watcher treats your prompt cache as *inventory* — it uses EOQ theory to measure whether the current context is still *worth carrying*, tracking restart pressure so you can decide when to hand off.
Documentation ·
npm ·
Paper ·
llms.txt
Quick Start ·
Install ·
DSH ·
How It Works ·
Context Buckets ·
Handoff ·
MCP Tools ·
Agents ·
Cite
---
What it does
Session Watcher reads your Claude Code transcript in real time and answers one question: **is this session still worth carrying?**
Most context tools optimize *how* you consume tokens — Headroom compresses, /compact shrinks, RTK filters. Session Watcher tracks *when* the cost curve is drifting, giving you the data to decide. They compose: run any pruning strategy you like, SW measures the cost curve so you can decide when to hand off.
SW reads from the transcript, never writes to it. The dashboard and statusline are pure observers; MCP tools return data for you to act on.
How it works
The harness layer is the only part that knows Claude Code: it reads transcript rows, decides the active branch, and emits normalized observations. Everything below it — measurement, dialogue history, handoff — consumes those observations and carries no transcript format, no row shape, and no tool name of any particular agent.
**Core model:** L = cache_read_input_tokens — the context stock you are renting. B is the rebuild baseline: the session's overhead floor plus the tokens of every file, skill and tool it has pulled in, which is what a restart would have to re-read. g is the growth no path accounts for, a smoothed ΔtotalStock − ΔB. x = L / B is the raw position ratio; the authoritative position is u, which every call advances by its own fraction of the restart interval that held while it ran, so the position records the path travelled rather than a ratio of today's numbers, and each landmark on the x axis is read off the reference skeleton fitted across that path. br = mf × pp is the bill premium — how much you are overpaying relative to ideal restart timing. The restart reminder is separate: it reads the rent the ledger has accumulated, so no revision of the position can withdraw one.
Lamp thresholds are the named constants BR_AMBER and BR_RED in lib/bill-regret.js: below the amber one the lamp is green, between them amber, at or above the red one red. See the paper for the full derivation — EOQ inventory theory mapped to LLM prompt caching.
Quick Start
Requires Node.js ≥ 22.16.
Opens a browser dashboard. The demo uses a pre-built anonymized session; replay uses your real transcript. Both are read-only — nothing is modified or uploaded.
Install
Plugin (recommended)
Or from within a Claude Code session:
This registers:
- **MCP tools** — available in every session
- **SessionStart hook** — points the running watcher at a new session and announces pending handoffs
If you installed or updated in an already-running session, run /reload-plugins to activate.
DSH plugin
@nomadop/session-watcher-dsh runs Session Watcher inside DeepSeek Harness (DSH). It watches every running session of the host it loads into and shares ~/.session-watcher with the Claude Code plugin.
- **The Session Watcher tab** — a view in the conversation view strip that mounts the dashboard's elements for that session.
- **The composer dock** — a pill below the composer showing the lamp, the bill premium and the alert clock, with the position and the context stock in its popover.