<div align="center">

# 🐳 Whale Meter · dsh-whale-meter

**An electricity meter for your whale — usage & cost dashboard for DeepSeek Harness**

One-line install · Zero config · Old-vs-new price comparison · Shareable "AI Bill" cards

[中文](README.md)

</div>

---

> **DeepSeek raised prices on 2026-08-17**: v4-flash cache-miss input went ¥1 → ¥3, output ¥2 → ¥9 (peak tier).
> Which raises the only question anyone actually has: **how much more is my agent costing me now?**
>
> Whale Meter prices the same usage under both the old and new tables side by side, shows what the cache is saving you, which model is burning money — and renders a bill card pretty enough to post.

## Install in 30 seconds

```bash
dsh plugin --profile <your-profile> add dsh-whale-meter
```

Restart `dsh web` — a 🐳 spend chip appears in the session header. Click it for the full bill.

> From source: `dsh plugin --profile <your-profile> add github:Shiye-10Pages/dsh-whale-meter` (pnpm will ask you to allow the build once; pin a commit for safety).

## What it shows

- **Today / yesterday / month / all-time spend**, estimated from official DeepSeek rates (¥ or $)
- **📈 Price-change comparison**: the same usage under both tables, and the delta, right on the panel. Before 08-17 it previews ("today would cost X at the new rates"), after it looks back ("X at the old rates")
- **⚡ Peak/off-peak tiers**: from 08-17, off-peak is half of peak. Each request is priced by its own timestamp; the chip shows `⚡½` off-peak — **note this is not cheaper than before the hike; off-peak still costs more than the old flat rate**
- **Correct across the price change**: rates are organized by effective era, so 08-16 usage bills at old rates and 08-17 at new ones — history is never repriced with one blunt table
- **Cache ledger**: hit rate + "saved by cache ¥X" — the cache is worth more after the hike, since the hit/miss gap widened too
- **Per-model / per-session bills** — failed retries are billed too, so they are counted too
- **14-day trend**, account balance (with API key), and a **daily budget line**
- **🐳 Bill share card**: one click renders a deep-sea style PNG — monthly spend, a fun equivalent ("≈ 2.3 bottles of iced tea"), cache savings — save or copy and post it

## Configuration (optional)

Works with zero config. To tweak, override in your profile's `cordis.patch.yml`:

```yaml
- update:
    - id: whale-meter
      config:
        currency: USD        # or CNY (default)
        budgetDaily: 1
        apiKey: sk-...       # balance lookup only; falls back to DEEPSEEK_API_KEY
        prices:
          my-model: { hit: 0.5, miss: 4, out: 12 }   # per million tokens
```

## How it works & privacy

- Consumes usage records from dsh session logs (`assistant/chunk usage` authoritative, `assistant/message.usage` fallback, deduplicated per the official accounting rules), appended to `~/.dsh/whale-meter/usage-YYYY-MM.jsonl`
- **Raw tokens only, never baked-in prices** — pricing table updates retroactively reprice your history
- **Everything stays on your machine.** No telemetry. The only outbound request is the optional balance lookup against DeepSeek's official endpoint
- A meter must never sink the ship: the collector is fully defensive and degrades silently instead of disturbing your agent

## FAQ

**Will the numbers match my platform bill exactly?** They're estimates from official rates per-request; usually very close. The [platform bill](https://platform.deepseek.com) is authoritative. Pricing lives in one file (`src/pricing.data.ts`, versioned `2026-08-14`) — PRs welcome when rates change.

**Third-party models?** Tokens are always counted; unknown models are marked *unpriced* instead of guessing — add your own rates via `prices`.

**TUI / headless?** Collection is host-side; `curl http://127.0.0.1:3080/whale-meter/api/summary` works anywhere. A standalone TUI view is on the roadmap.

## Roadmap

Backfill of pre-install sessions · monthly report export · off-peak scheduling hints · built-in rates for more providers · TUI view

## Disclaimer

Community plugin, not affiliated with DeepSeek. dsh is a developer preview; when upstream breaks things, this plugin follows up fast (file an issue to nudge).

**If it helps, a ⭐ means a lot to an indie dev shipping at 2am.**

## License

[MIT](LICENSE) © 2026 shiye (十页)
