pi-deepseek-cache
DeepSeek prefix-cache extension for pi — hit-rate telemetry, prefix guard, and cache-friendly compaction.
Package details
Install pi-deepseek-cache from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-deepseek-cache- Package
pi-deepseek-cache- Version
0.1.0- Published
- May 31, 2026
- Downloads
- 126/mo · 126/wk
- Author
- ruanbw
- License
- MIT
- Types
- extension
- Size
- 30.6 KB
- Dependencies
- 3 dependencies · 0 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-deepseek-cache
DeepSeek prefix cache extension for pi — hit rate telemetry, prefix guard, cache-friendly compaction.
Features
- P1 Hit Rate Telemetry — real-time cache hit rate with persistent storage
- P2 Prefix Guard — strips
volatile-scratchmessages to protect cache prefix stability - P3 Cache-Friendly Compaction — deterministic summarization via
deepseek-v4-flash(temperature: 0) - Overlay Commands —
/cache-statsand/cache-graphdisplay in overlay popups (ESC to dismiss)
Install
npm (recommended)
pi install npm:pi-deepseek-cache
Git
pi install git:github.com/ruanbw/pi-deepseek-cache
Manual
mkdir -p ~/.pi/agent/extensions/deepseek-cache
cp index.ts ~/.pi/agent/extensions/deepseek-cache/
Usage
export DEEPSEEK_API_KEY=sk-...
pi --model deepseek/deepseek-chat
In the session:
/cache-stats → overlay popup with hit rate, read/miss/write, turns
/cache-graph → overlay popup with ASCII trend chart
How It Works
| Layer | What it does |
|---|---|
| P1 | Accumulates cacheRead / input / cacheWrite / turns from message_end events, persists to ~/.pi/agent/extensions/deepseek-cache/stats.json |
| P2 | Filters out messages with customType="volatile-scratch" in the context hook, preventing volatile content from breaking the byte prefix |
| P3 | On session_before_compact, summarizes history with deepseek-v4-flash at temperature 0, caches summaries by SHA-256 hash to ensure byte stability |
Test
npm test # 28 tests (18 unit + 10 integration)