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

omni-token

Claude Code 插件,在提示框上方显示实时上下文窗口预测、tok/s、提示缓存命中率和 TTL,并提供可选的缓存自动预热与 /omni-token 控制。

mrzzmrzz@mrzzmrzz

mrzzmrzz/claude-code-mods/tree/main/plugins/omni-token

已翻译

关于这个 mod

omni-token 是 claude-code-mods 市场中的 Claude Code 插件,会在每次回合后更新,在提示框上方绘制上下文窗口的实时预测。显示内容包括天气样式的填充指示器(从 Clear 到 Compact soon)、绝对值和百分比上下文用量、12 回合 sparkline、上一回合的输出 token 每秒数、提示缓存命中率,以及提示缓存过期倒计时;低于 5 分钟时倒计时变黄,过期后显示 expired。使用 /plugin marketplace add mrzzmrzz/claude-code-mods 和 /plugin install omni-token@claude-code-mods 安装。选项包括 cacheTtl(5m 或 1h)、autoWarm 和 warmHours。启用 auto-warm 后,闲置的工作阶段会在缓存过期前不久发送一个很小的分叉请求来重启 TTL;该请求永远不会进入记录,并会在 warmHours 到达或缓存已经冷却时停止。/omni-token 命令会报告状态,并可按工作阶段关闭、开启或重置预热。

安装

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

claude plugin marketplace add mrzzmrzz/claude-code-mods
claude plugin install omni-token
原文 / README

claude-code-mods

Mods for Claude Code, packaged as a plugin marketplace.

Install

In Claude Code:

/plugin marketplace add mrzzmrzz/claude-code-mods
/plugin install omni-token@claude-code-mods

Mods

omni-token

A live forecast of your context window, shown in the band above the prompt and updated after every turn:

Cloudy  67% 134.4k / 200k  ▂▃▄▅▆█  ▲ +98.3k last turn  95 tok/s  cache 96% 58:12

| Fill | Forecast (color) | | --- | --- | | < 25% | Clear (yellow) | | 25–49% | Cloudy (cyan) | | 50–74% | Showers (blue) | | 75–89% | Storm (magenta) | | ≥ 90% | Compact soon (red) |

  • The sparkline covers the last 12 turns, scaled to the highest of them.
  • tok/s is the last turn's output tokens (thinking included) over the time from each request's start to its response's end.
  • cache 96% is the last turn's prompt-cache hit rate: cache reads over all input tokens.
  • 58:12 counts down to when the prompt cache expires: the last main-loop request's start plus the cache TTL. It turns yellow under 5 minutes and reads expired after.

Options

| Option | Values | Default | | --- | --- | --- | | cacheTtl | 5m, 1h | 1h | | autoWarm | true, false | false | | warmHours | hours | 24 |

Auto-warm

With autoWarm on, while the session is idle the mod sends one tiny forked request over the main thread's own prefix shortly before the cache expires (3 minutes before on 1h, 1 minute on 5m). The cache read restarts the TTL, so the next real message reads the cache instead of rewriting the whole context. The fork never enters the transcript.

  • Each warm bills a cache read of the whole context (on Claude Opus 5.5, context × $0.20/MTok) plus a few hundred output tokens.
  • It stops warmHours after the last turn started, and never warms an expired cache (that would pay the full write it exists to avoid) or a context under 50k tokens.
  • warmed 3x shows how many warms ran since the last turn; warm missed means a warm found the cache already cold, and warming stops until the next turn.

/omni-token

| Command | Effect | | --- | --- | | /omni-token | Status: auto-warm on or off and why, cache TTL and time left, warms since the last turn, option names | | /omni-token warm off | Stop auto-warming in this session, at once; other sessions and the autoWarm option are unchanged | | /omni-token warm on | Auto-warm this session even with autoWarm off | | /omni-token warm reset | Follow the autoWarm option again |

On a 1-hour TTL, keeping a cache warm costs 0.2/7.8 of a cold restart per hour, so it pays off for gaps under about 39 hours, if you come back.

The API's usage figures don't say which TTL a session runs on, so set it to match yours: 1h on most Claude subscriptions, 5m on the API default or in usage overage.

Developing

Load a mod straight from this checkout, with hot reload on save:

claude --plugin-dir ./plugins/omni-token

Check one before committing:

claude plugin validate ./plugins/omni-token
claude plugin test ./plugins/omni-token

更多类似作品