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

context-statusline

一个 Claude Code 插件,在提示框上方渲染单行卡片,显示模型、以渐细色带表示的上下文窗口用量、提示缓存热度和命中率,以及 Git 仓库和分支;终端窄小时会优雅收起。

nthplusio@nthplusio

nthplusio/skills/tree/main/plugins/context-statusline

已翻译

关于这个 mod

该插件会在提示框上方绘制卡片,显示会话模型、已使用 token 相对于上下文窗口的比例(带分段进度条)、提示缓存热度和命中率倒计时,以及工作目录的 Git 仓库和分支。卡片始终保持一行,并会随着终端变窄逐步移除区段。可通过 /config 使用一个设置(Prompt cache TTL)。使用 /plugin marketplace add nthplusio/skills 和 /plugin install context-statusline@nthplusio 安装。仓库和分支图标需要 Nerd Font。

安装

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

claude plugin marketplace add nthplusio/skills
claude plugin install context-statusline
原文 / README

context-statusline

A Claude Code plugin that draws a card above the prompt with the model, the context window, prompt cache warmth, and the git repo and branch.

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ◆ Opus 5.5   ctx 450k ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌▓▓▓▓▓▓▓▌▓░░░▏░░▏░▏░ 1M (550k left)   cache warm 57m · hit 97%    platform   ui-676 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Install

/plugin marketplace add nthplusio/skills
/plugin install context-statusline@nthplusio

The repo and branch icons are Nerd Font glyphs. Without a Nerd Font they draw as blank cells.

What the card shows

  • Model: the session's model, for example Opus 5.5.
  • Context: tokens used on the left, the window size on the right, and a bar of the whole window between them. The bar is split into bands by how comfortable that much context is:
    • The target band, green, takes half the bar. It runs to 200k on a larger window, or over the first half of a window of 200k or less.
    • Five bands from yellow to red split the rest of the window into equal token ranges, but each takes less of the bar than the one before (20, 12, 8, 6 and 4%), since that context is a worse place to be.
    • Used cells are bright, the window ahead is dimmed in its band's colour, and ▌/▏ marks where a band starts. A band too narrow for a divider is marked by its colour alone.
    • Past 200k, or at the cap, the room left follows: (550k left).
  • Cache: how long the prompt cache stays warm after the last response, and the share of the last request the cache served: cache warm 57m · hit 97%. Once the time runs out it reads cold 12m ago; after a model switch, cold (model switch). The countdown updates every 15 seconds and ignores subagents, which cache their own prefixes.
  • Git: the repository and branch of the working directory, outside a repository nothing.

Narrow terminals

The card always fits on one line. As the terminal narrows, the bar first shrinks from 40 cells to 20, then parts give way in this order:

  1. The repository name, trimmed to 12 cells and then dropped.
  2. The cache hit rate.
  3. The branch, trimmed from the front (…ui-676) and then dropped.
  4. The room note.
  5. The cache segment.
  6. The bar shrinks to 10 cells, then the ctx label and the bar go.
  7. The model name is trimmed last.

A narrower terminal never shows more than a wider one, and never a longer bar.

Settings

/config lists one setting, Prompt cache TTL (cacheTtl): 1h, the default, or 5m. Claude Code reports the cache lifetime only when the model changes, so until then the card counts down from this setting. Subscription sessions use a 1-hour cache; API-key sessions default to 5 minutes.

Develop

Load a checkout in place of the installed plugin:

claude --plugin-dir plugins/context-statusline

Run the tests, which include a sweep over every terminal width from 20 to 200 columns:

claude plugin test plugins/context-statusline
claude plugin validate plugins/context-statusline

tsconfig.json extends .claude-plugin/types/tsconfig.json, which Claude Code writes the first time it loads the plugin. Once it has loaded the plugin, npx tsc -p plugins/context-statusline type-checks it. The generated types are gitignored.

All layout and formatting is pure and lives in hooks/format.ts; hooks/register.tsx gathers the figures and draws the strings the layout returns.

更多类似作品