cache-stats — плагин для GitHub Copilot: что делает и как установить
Плагин cache-stats для GitHub Copilot показывает в сессии повторное использование промпт-кэша, его истечение, состав токенов и стоимость в AI Credits. Обновляется локально каждые две секунды.
MIT обновлён 2026-10-11
copilot plugin install cache-stats@awesome-copilotЧто делает cache-stats
Плагин рисует canvas с тремя экранами: Live Cache (состояние кэша, повторное использование, цена перестройки префикса), Composition (разложение токенов на свежий ввод, чтение и запись кэша, вывод и reasoning) и Turn History (холодные старты и стоимость перестройки по ходам). Данные берутся из локального хранилища сессий ~/.copilot/session-store.db, открытого только на чтение.
Расход считается в AI Credits по тарифам из token_details_json каждой записи, то есть привязан к модели, которая реально обслуживала вызов, а не к зашитым ценам. Ход помечается REBUILT, если входной вызов не прочитал кэшированный префикс, но записал заметный новый.
Нужен Copilot-клиент с поддержкой canvas-расширений, Node.js с модулем node:sqlite и локальное хранилище сессий с таблицей assistant_usage_events. Модель не вызывается и телеметрия не отправляется: холст отдаётся с временного порта 127.0.0.1. Без этих трёх условий статистика просто не появится.
Какие задачи решает
- увидеть, сколько промпта переиспользуется из кэша в текущей сессии
- посчитать стоимость сессии в AI Credits без вызовов модели
- разложить токены по категориям: ввод, чтение и запись кэша, вывод, reasoning
- найти ходы, где кэш перестраивался заново
- отследить истечение срока кэш-записи по событию
session.usage_checkpoint
Примеры запросов агенту
- Открой канву статистики кэша
- Покажи историю ходов и где был REBUILT
- Сколько сейчас стоит эта сессия в AI Credits и что будет, если кэш протухнет
Как установить cache-stats
Команда из источника
copilot plugin install cache-stats@awesome-copilotПо шагам, с командами для каждой платформы: Плагины Claude Code: маркетплейсы, установка и как собрать свой
Вопросы о cache-stats
Как установить cache-stats в GitHub Copilot?
Выполните команду copilot plugin install cache-stats@awesome-copilot. После установки попросите Copilot открыть cache stats canvas.
Что делает cache-stats?
Показывает на локальной канве, как повторно используется промпт-кэш, когда он истекает, из чего состоят токены и сколько сессия стоит в AI Credits. Обновляется каждые две секунды и не тратит токены модели.
Тратит ли cache-stats токены и отправляет ли данные наружу?
Нет. Плагин читает ~/.copilot/session-store.db только на чтение, отдаёт холст с временного порта 127.0.0.1 и не вызывает модель, не грузит внешние ресурсы и не шлёт телеметрию.
Исходный текст
SKILL.md · MIT
# Cache Stats A local-first GitHub Copilot canvas for understanding prompt-cache reuse, expiry, token composition, and AI Credit cost while a session is still active.  > Preview data is illustrative and does not contain session information. The one-bit HyperCard stack has three focused views: - **Live Cache** shows expiry state, reuse, and the cost exposed if the reusable prompt prefix must be rebuilt. - **Composition** separates fresh input, cache reads, cache writes, output, and reasoning tokens. - **Turn History** makes cold starts and rebuild costs visible turn by turn. The canvas refreshes locally every two seconds. Opening and using it consumes no model tokens. ## Install In a GitHub Copilot session, ask: > Install this extension: https://github.com/arafattehsin/cache-stats-extension Then ask: > Open the cache stats canvas Before marketplace approval, install the public repository directly: ```shell copilot plugin install arafattehsin/cache-stats-extension ``` After marketplace approval, install it from Awesome Copilot: ```shell copilot plugin install cache-stats@awesome-copilot ``` ## Requirements - A GitHub Copilot client with canvas-extension support - A Node.js runtime with the built-in `node:sqlite` module - A local Copilot session store containing `assistant_usage_events` ## Privacy Cache Stats reads `~/.copilot/session-store.db` in read-only mode and serves the canvas from an ephemeral `127.0.0.1` port. It does not modify the session store, call a model, load remote assets, or send telemetry. The local canvas API includes the active session ID and database path in its response for diagnostics. That endpoint is available only through the loopback server created for the open canvas instance. ## How the numbers work `input_tokens` is the complete prompt for one model call: ```text fresh input = input_tokens - cache_read_tokens - cache_write_tokens ``` Per-token billing rates come from each row's `token_details_json`, so baseline cost, actual cost, savings, and rebuild exposure follow the model that served the call instead of relying on hard-coded prices. Costs are shown in AI Credits (AIC), converted from the store's nano-AIU values at 1 AI Credit = 1e9 nano-AIU. A turn starts with one user-initiated call and includes its agent, sub-agent, and compaction follow-ups. A turn is marked `REBUILT` when its entry call reads no cached prefix but writes a substantial one. Live expiry comes from Copilot's `session.usage_checkpoint` event, using the cache entry for the model the main conversation called last. ## Development ```shell npm install npm run check copilot plugin install . ``` Reinstall the local plugin after changing source files because Copilot caches installed plugin content. ## Package layout | Path | Role | | --- | --- | | `plugin.json` | Agent Plugins v1 manifest and Copilot catalog metadata | | `copilot-extension.json` | Direct canvas-extension install metadata | | `extension.mjs` | Direct-install bridge to the packaged extension | | `com.github.copilot/extensions/cache-stats/` | Spec-namespaced canvas extension package | | `assets/preview.png` | Anonymized catalog preview | | `scripts/` | Package and embedded-UI checks | | `docs/PUBLISHING.md` | Public release and Awesome Copilot submission guide | ## Environment overrides - `COPILOT_CACHE_STATS_DB` - explicit path to the session store - `COPILOT_HOME` - alternate Copilot home directory ## License [MIT](LICENSE)
© Arafat Tehsin · MIT · arafattehsin/cache-stats-extension