ClaudeMods
☰
ZH-CN
● 0 人在线 · 浏览 0 次
赞助提交作品
GitHub 仓库 · 发布者 ildunari

cache-timer

一个 Claude Code mod(function-hook 插件),用于跟踪主对话的提示缓存窗口。

ildunari@ildunari

ildunari/kosta-plugins/tree/main/plugins/cache-timer

已翻译

关于这个 mod

cache-timer

一个 Claude Code mod(function-hook 插件),用于跟踪主对话的提示缓存窗口。

  • 状态行:🟢 ▰▰▰▰▰▰▰▰▱▱ 47:12,显示在模型名称旁边。窗口使用量超过一半时显示 🟢,降到 15% 时变为 🟡,低于该值时变为 🔴,过期后显示 ⚪ cold。窗口会从主线程请求发送的时间开始重新计时,并在模型完成响应后结束(被中断的响应也算);子代理和压缩请求使用各自的缓存前缀,会被忽略。
  • **警告:**剩余 12 分钟时,提示消息会说如果不发送内容,2 分钟后将进行自动压缩。如果上下文太小而无法压缩,或时钟在休眠后已经跳过 10 分钟位置,则不会显示警告。
  • **自动压缩,仅一次:**剩余 10 分钟时,只要缓存仍然处于热状态,就会执行与 /compact 相同的压缩。每一代缓存(以请求时间命名)只有一次机会:调用前就会消耗机会,跳过调用或在工作阶段中途拒绝也会消耗机会;只有到达模型的新请求才会以新的机会启动新一代。上下文少于 40k token 时会跳过;如果请求在准备期间重新预热了缓存,也会关闭这次压缩调用。📦 表示某一代确实执行过压缩。

这里假定窗口使用 1 小时 TTL(TTL_MS)。使用 5 分钟 TTL 的会话(超额用量、某些 API key 设置)会看到错误的倒计时。阈值是 hooks/register.tsx 顶部的常量。

安装:claude plugin install cache-timer@kosta-plugins。检查:claude plugin validate plugins/cache-timer。

安装

请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。

claude plugin marketplace add ildunari/kosta-plugins
claude plugin install cache-timer
原文 / README

cache-timer

A Claude Code mod (function-hook plugin) that tracks the prompt-cache window of the main conversation.

  • Status line: 🟢 ▰▰▰▰▰▰▰▰▱▱ 47:12 beside the model name. The dot goes 🟢 above half the window, 🟡 down to 15%, 🔴 below, ⚪ cold once it has expired. The window restarts from when a main-thread request is sent, once the model has answered it (an interrupted answer counts); subagent and compaction requests run on their own cache prefix and are ignored.
  • Warning: at 12 minutes left, a toast says an auto-compact is coming in 2 minutes unless you send something. It's skipped when the context is too small to compact, or when the clock has already jumped past the 10-minute mark (after a sleep).
  • Auto-compact, once: at 10 minutes left, while the cache is still warm, it runs the same compaction as /compact. Each cache generation (named by its request time) gets one shot: it's spent before the call, a skip or a mid-turn refusal leaves it spent, and only a new request that reaches the model starts a generation with a fresh shot. It skips contexts under 40k tokens and calls the compaction off if a request re-warmed the cache while it was getting ready. 📦 marks a generation where a compaction actually stood.

The window is assumed to be the 1-hour TTL (TTL_MS). Sessions on the 5-minute TTL (usage overage, some API-key setups) will see the wrong countdown. The thresholds are constants at the top of hooks/register.tsx.

Install: claude plugin install cache-timer@kosta-plugins. Check: claude plugin validate plugins/cache-timer.

其他同名作品

更多类似作品