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

bar

Claude Code 的一个插件,在提示框上方显示状态栏(上下文、计划限额、当前轮次的时间和 token),并为每个最终回答加上边框

AltamimiYasser@AltamimiYasser

AltamimiYasser/claude-code-bar/tree/main/plugins/bar

已翻译

关于这个 mod

Claude Code 的 Bar

一个 Claude Code 插件:在提示框上方添加状态栏、在每轮运行时显示实时计时器,并用边框把每个最终回答与之前的工作区分开。它可以在 Claude 桌面应用的 Code 标签页和终端中运行。

显示内容

提示框上方的状态栏

一个包含两行的面板。第 1 行表示容量:当前用了多少空间。第 2 行表示此刻的状态:当前轮次、工具、提示缓存和 Hand off。每个仪表的绘制方式相同:一条细轨道、一段向末端变亮的填充,以及标记当前位置的圆点(中间为白色)。将鼠标悬停在任意项目上,完整详情会覆盖显示在另一行上方。

第 1 行:容量

  • Context ━━━━●───┊──┊── 216k / 1.0M 22%:当前聊天上下文窗口的占用程度。粗体数字是对话中的 token 数,/ 400k 是上限(设置过时使用自动压缩窗口,否则使用模型窗口,或者使用 /bar-limit 指定的窗口),后面是占比。轨道上的淡色刻度表示下一种颜色从哪里开始,只绘制仍在前方的刻度。点击 Context 可运行 /usage。
  • 5h 和 Week ━━●─┃── 30% 07:20:方案的 5 小时窗口和每周上限。粗体百分比是已使用的比例;变暗的时间或日期表示重置时间。线上的竖直标记是现在:窗口已经过去了多少。圆点在标记左侧,表示使用速度比时钟慢,很安全;圆点在标记右侧,表示进度领先于时间,可能在重置前就用完。悬停可查看准确的重置日期,以及按当前速度最终会落在哪里。

第 2 行:此刻的状态

  • 节拍:橙色圆点每秒由一个扩大的圆环包住一次,表示 Claude 正在工作;节拍与计时器同步。空心灰色圆环表示空闲,此时该行显示上一轮。
  • Working 1m 04s(橙色)或 Last turn 16s:当前轮次已运行或曾运行的时间。
  • 火花线(工作期间):过去 24 秒内每秒输出的 token 数,圆点表示现在。数值高表示 Claude 写得快;变平表示 Claude 正在思考,或正在等待工具。
  • 数字:out 是 Claude 写出的 token 数(+ 表示仍有内容在流入),read 是从提示缓存提供的 token 数,write 是新写入缓存的 token 数。悬停在当前轮次上可查看全部四项,包括缓存之外的输入 in 和工具调用。
  • 3 tools ›:Claude 在本轮调用的工具数量。点击后打开面板,列出每次调用;点开每项即可查看输入和输出。
  • Cache 59:27:对话从 Claude 上一次响应开始在提示缓存中保留的时间,会倒计时(根据会话使用 1 小时或 5 分钟)。过期后,下一条消息必须再次把整个对话写入缓存。悬停可查看准确的过期时间,以及届时需要写入的 token 数。
  • Hand off →(或 /bar-handoff):运行 /mattpocock-skills:handoff 写入交接文档,然后在同一文件夹中打开一个从该文档继续的新 Code 会话。当前聊天保持原样,不会被清除或压缩。这个按钮大多数时候只有轮廓;缓存快耗尽(橙色或红色)时会变成实心,这正是值得按下它的时机。运行过程中依次显示 Writing…、Opening…,然后是 Opened ✓(或 Failed,悬停可看原因)。桌面应用会要求你信任新会话所在的文件夹。该会话运行 Bar 时,会自动发送继续提示;否则提示会留在消息框中。需要 mattpocock-skills 插件。

颜色

| 颜色 | 在仪表或倒计时中的含义 | | --- | --- | | 绿色 | 使用量低于一半 | | 黄色 | 从一半开始(levels.yellow,50%) | | 橙色 | 从四分之三开始(levels.orange,75%) | | 红色 | 达到或超过上限(levels.red,100%);缓存已过期 |

当前轮次中的橙色(节拍、计时器、火花线)是 Claude 自己的颜色,只表示 Claude 正在工作。粗体数字是需要读取的值;变暗的文字是标签或单位。

在终端中,同一个面板会用字符绘制:━ 表示已使用,─ 表示轨道,┃ 表示现在,● 表示工作中,○ 表示空闲,│ 用于分隔项目,Hand off 显示为 [ Hand off → ]。

应用已经在提示框上方显示储存库、分支、未提交变更和正在运行的任务,所以 Bar 不再重复显示。

每一轮

  • 用橙色边框包住最终回答。边框下方显示本轮耗时,以及输入、输出、缓存读取和缓存写入的 token 数。

提示框页脚中的 Remote Control

消息框下方页脚的右侧有一个 ○ Remote 开关。点击它或运行 /remote,即可为项目文件夹启动 Remote Control;再次执行即可停止。它的标记显示当前状态:

  • ○ Remote:已关闭
  • 🟡 Remote…:正在启动
  • 🟢 Remote:已连接
  • 🔴 Remote:进程已停止(原因显示在 Remote sessions 中)

旁边的 Sessions 会打开列表,列出所有使用过 Remote Control 的文件夹;正在运行的排在前面,每项显示文件夹和运行时长(已停止的项目会显示停止时间和运行时长)。运行中时,每行提供 Stop;停止后提供 Start 和 Remove。Stop all 会结束所有正在运行的项目。你自己用 claude remote-control 启动的 Remote Control 进程也会显示,并标记为「started outside Bar」,而且可以停止。

其他外掛添加到页脚的任何内容(例如自己的按钮)都会留在那里,排在 Sessions 之前。

每个文件夹只有一个 Remote Control,由其中的所有会话共享。启动它的会话结束后,它仍会继续运行;之后在该文件夹中打开的任何会话都能看到它并将其关闭。进程 ID 和日志保存在 ~/.claude/bar/remote/。

安装

在 Claude Code 中:

/plugin marketplace add AltamimiYasser/claude-code-bar
/plugin install bar@claude-code-bar

或者从 shell 运行:

claude plugin marketplace add AltamimiYasser/claude-code-bar
claude plugin install bar@claude-code-bar

之后启动新会话。

**要求:**Bar 是一个 mod,也就是由 function hooks 组成的插件,而 function hooks 仍处于早期体验阶段。如果状态栏没有出现,请在环境中设置 CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1,或在 ~/.claude/settings.json 的 env 区块中设置。

命令

| 命令 | 作用 | | --- | --- | | /bar-limit 300k | 设置上下文仪表何时满格并变红。它接受 300k、1.5m 或 250000,上限不会超过模型自身的窗口。/bar-limit model 使用模型的整个窗口;/bar-limit off 恢复默认值,即自动压缩窗口;单独运行 /bar-limit 显示当前值。 | | /remote | 为此文件夹打开或关闭 Remote Control,就像点击页脚开关一样。/remote list 打开 Remote sessions;/remote stop-all 停止所有正在运行的项目。 | | /bar-handoff | 写入交接文档并在新会话中继续,就像 Hand off 按钮一样。 | | /bar-demo | 依次展示示例状态栏(没有方案上限、轻度使用、即将满格、超过上限),然后返回实时状态栏。 |

设置

Bar 显示的所有内容都可以在 ~/.claude/bar/settings.jsonc 中关闭。Bar 第一次运行时会写入该文件,把每个选项设为默认值并附上说明注释。修改会在几秒内生效,不需要重启。错误值会回退到默认值;无法解析的文件会保留上一次有效设置,并显示通知。

| 选项 | 默认值 | 控制内容 | | --- | --- | --- | | bar.enabled | true | 提示框上方的整个状态栏 | | bar.hover | true | 所有悬停效果:详情和下划线 | | bar.pillBorders | true | 状态栏面板周围的淡色轮廓(桌面应用) | | context.enabled | true | Context 仪表 | | context.limit | "autoCompact" | 仪表何时满格:"autoCompact" 使用自动压缩窗口(Claude Code 设置中的 autoCompactWindow;未设置时使用模型窗口),"model" 使用模型自身窗口,或者填写 token 数。旧文件中的 null 会按 "autoCompact" 读取。 | | context.click | "usage" | 点击「Context」时的行为:"usage" 运行 /usage,"none" 什么也不做 | | planLimits.fiveHour / weekly | true | 5h 和 Week 仪表 | | planLimits.resetTime | true | 每个百分比旁的重置时间 | | planLimits.hoverDetails | true | 悬停在 5h 或 Week 上时显示准确的重置日期 | | planLimits.pace | true | 5h 和 Week 仪表上的「现在」标记,以及详情中的进度估算 | | turn.enabled | true | 第 2 行的当前轮次(缓存和 Hand off 仍会显示) | | turn.whileWorking / lastTurn | true | 实时轮次(节拍、时间、火花线)和两轮之间显示的上一轮 | | turn.tokens | true | 第 2 行的 token 数字 | | turn.toolCalls / toolCallsPanel | true | 工具调用数量,以及它打开的面板 | | answer.frame / footer / footerTokens | true | 回答边框、下方那一行及其 token 数字 | | spinnerTimer | true | 应用工作指示器旁的实时耗时 | | cache.enabled | true | Cache 倒计时 | | cache.handoff | true | 旁边的 Hand off 按钮(/bar-handoff 无论如何都可使用) | | remote.enabled | true | Remote Control 开关和 /remote | | remote.autoStart | "newProjects" | 自动启动 Remote Control:"never"、"newProjects"(项目的第一个会话)或 "always" | | remote.notifications | true | 开启/关闭通知 | | remote.sessionsButton | true | 页脚中的 Remote sessions 按钮 | | levels.yellow / orange / red | 0.5 / 0.75 / 1.0 | 颜色发生变化的上限占比 |

开发

插件位于 plugins/bar。使用以下命令检查:

claude plugin validate plugins/bar

进行类型检查时,在 plugins/bar 中打开 Claude Code,运行 /plugin-types(它会把 API 声明写入 .claude/types),然后运行:

npx -p typescript tsc -p plugins/bar

运行测试(插件测试套件需要打开 function hooks):

CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude plugin test plugins/bar

要加载工作副本而不是已安装的版本:

claude --plugin-dir plugins/bar

许可证

MIT

安装

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

claude plugin marketplace add AltamimiYasser/claude-code-bar
claude plugin install bar
原文 / README

Bar for Claude Code

A Claude Code mod that adds a status bar above the prompt, a live timer on every turn, and a frame that sets each final answer apart from the work before it. It works in the Claude desktop app's Code tab and in the terminal.

What it shows

The bar, above the prompt

One panel with two rows. Row 1 is capacity: how full things are. Row 2 is right now: the turn, its tools, the prompt cache and Hand off. Every gauge is the same drawing: a thin track, a fill that brightens toward its end, and a bead (a dot with a white centre) marking where you are. Hover any item and its full detail appears laid over the other row.

Row 1: capacity

  • Context ━━━━●───┊──┊── 216k / 1.0M 22%: how full this chat's context window is. The bold number is the tokens in the conversation, / 400k is the limit (your auto-compact window when you've set one, else the model's window, or your own from /bar-limit), then the share. The faint ticks on the track mark where the next colours start; only the ones still ahead are drawn. Click Context to run /usage.
  • 5h and Week ━━●─┃── 30% 07:20: your plan's 5-hour window and weekly limit. The bold percentage is how much you've used; the dim time or day is when it resets. The upright mark on the line is now: how much of the window has passed. Bead left of the mark: you're using it slower than the clock, fine. Bead right of the mark: you're ahead of pace and may run out before it resets. Hover for the exact reset date and where you'll land at this pace.

Row 2: right now

  • The beat: an orange bead with a ring swelling once a second means Claude is working; the beat keeps time with the timer. A hollow grey ring means idle, and the row shows the last turn.
  • Working 1m 04s (orange) or Last turn 16s: how long the turn has run, or took.
  • The sparkline (while working): output tokens per second over the last 24 seconds, the bead being now. High means Claude is writing fast; flat means it's thinking, or waiting on a tool.
  • The figures: out is the tokens Claude wrote (a + means more are still streaming in), read the tokens served from the prompt cache, write the tokens newly written to it. Hover the turn for all four, with in (input outside the cache) and the tool calls.
  • 3 tools ›: how many tools Claude called this turn. Click it for a panel listing every call, each opening to its input and output.
  • Cache 59:27: how long the conversation stays in the prompt cache, counted down from Claude's last response (1 hour or 5 minutes, whichever the session uses). Once it expires, the next message has to write the whole conversation to the cache again. Hover for the exact expiry time and how many tokens that would be.
  • Hand off → (or /bar-handoff): runs /mattpocock-skills:handoff to write a handoff document, then opens a new Code session in the same folder that continues from it. The current chat stays exactly as it is: it is never cleared or compacted. The button is outlined most of the time and turns solid once the cache is running out (orange or red), the moment it's worth pressing. While it works it reads Writing…, Opening…, then Opened ✓ (or Failed, with the reason on hover). The desktop app asks you to trust the folder for the new session. When that session runs Bar, it sends the continue prompt by itself; otherwise the prompt is waiting in its message box. Requires the mattpocock-skills plugin.

The colours

| Colour | On a meter or a countdown | | --- | --- | | Green | under half used | | Yellow | from half (levels.yellow, 50%) | | Orange | from three quarters (levels.orange, 75%) | | Red | at or past the limit (levels.red, 100%); the cache has expired |

Orange in the turn (the beat, the timer, the sparkline) is Claude's own colour: it only means Claude is working. A bold number is the value to read; dim text is a label or a unit.

In the terminal the same panel is drawn in characters: ━ used, ─ the track, ┃ the now mark, ● working, ○ idle, │ between items, and Hand off as [ Hand off → ].

The app already shows the repo, branch, uncommitted changes and running tasks above the prompt, so Bar leaves those out.

Every turn

  • The final answer in an orange frame. Under the frame: how long the turn took, plus its input, output, cache-read and cache-write tokens.

Remote Control, in the prompt footer

A ○ Remote toggle sits at the right of the footer under the message box. Click it, or run /remote, to start Remote Control for the project folder, and again to stop it. Its mark shows the state:

  • ○ Remote: off
  • 🟡 Remote…: starting
  • 🟢 Remote: connected
  • 🔴 Remote: the process stopped (the reason is in Remote sessions)

Beside it, Sessions opens a list of every folder that has had a Remote Control, running ones first, each with its folder and how long it has run (a stopped one shows when it stopped and how long it ran). Each row offers Stop while running, and Start and Remove once stopped. Stop all ends every running one. Remote Control processes you started yourself with claude remote-control show up too, marked "started outside Bar", and can be stopped.

Anything another mod adds to the footer (a button of its own, say) stays there, before Sessions.

There's one Remote Control per folder, shared by every session in it. It keeps running after the session that started it ends, and any session opened in that folder later shows it and can turn it off. Its process ID and log are kept in ~/.claude/bar/remote/.

Install

In Claude Code:

/plugin marketplace add AltamimiYasser/claude-code-bar
/plugin install bar@claude-code-bar

Or from a shell:

claude plugin marketplace add AltamimiYasser/claude-code-bar
claude plugin install bar@claude-code-bar

Start a new session afterwards.

Requirement: Bar is a mod, a plugin made of function hooks, and function hooks are in early access. If the bar doesn't appear, set CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 in your environment, or in the env block of ~/.claude/settings.json.

Commands

| Command | What it does | | --- | --- | | /bar-limit 300k | Sets where the context meter is full and turns red. It accepts 300k, 1.5m or 250000, and is capped at the model's own window. /bar-limit model uses the model's whole window; /bar-limit off goes back to the default, your auto-compact window; /bar-limit on its own shows the current value. | | /remote | Turns Remote Control on or off for this folder, like the footer toggle. /remote list opens Remote sessions; /remote stop-all stops every running one. | | /bar-handoff | Writes a handoff and continues in a new session, like the Hand off button. | | /bar-demo | Steps through sample bars (no plan limits, light use, getting full, past the limit), then back to your live bar. |

Settings

Everything Bar shows can be turned off, in ~/.claude/bar/settings.jsonc. Bar writes the file the first time it runs, with every option set to its default and a comment explaining it. Changes apply within a few seconds, with no restart. A wrong value falls back to its default, and a file that doesn't parse keeps the last good settings and shows a notice.

| Option | Default | What it controls | | --- | --- | --- | | bar.enabled | true | The whole bar above the prompt | | bar.hover | true | Every hover effect: the details, the underlines | | bar.pillBorders | true | The faint outline around the bar's panel (desktop) | | context.enabled | true | The Context meter | | context.limit | "autoCompact" | Where the meter is full: "autoCompact" for your auto-compact window (autoCompactWindow in Claude Code's settings; the model's window when none is set), "model" for the model's own window, or a token count. An older file's null reads as "autoCompact" | | context.click | "usage" | Clicking "Context": "usage" runs /usage, "none" does nothing | | planLimits.fiveHour / weekly | true | The 5h and Week meters | | planLimits.resetTime | true | The reset time after each percentage | | planLimits.hoverDetails | true | The exact reset date while hovering 5h or Week | | planLimits.pace | true | The "now" mark on the 5h and Week meters, and the pace estimate in their details | | turn.enabled | true | The turn on row 2 (the cache and Hand off stay) | | turn.whileWorking / lastTurn | true | The live turn (beat, time, sparkline), and the last turn between turns | | turn.tokens | true | The token figures on row 2 | | turn.toolCalls / toolCallsPanel | true | The tool-call count, and the panel it opens | | answer.frame / footer / footerTokens | true | The answer frame, the line under it, and its token figures | | spinnerTimer | true | The live time beside the app's working indicator | | cache.enabled | true | The Cache countdown | | cache.handoff | true | The Hand off button beside it (/bar-handoff works either way) | | remote.enabled | true | The Remote Control toggle and /remote | | remote.autoStart | "newProjects" | Start Remote Control by itself: "never", "newProjects" (a project's first session) or "always" | | remote.notifications | true | The on/off notices | | remote.sessionsButton | true | The Remote sessions button in the footer | | levels.yellow / orange / red | 0.5 / 0.75 / 1.0 | The share of a limit where colors change |

Development

The plugin lives in plugins/bar. Check it with:

claude plugin validate plugins/bar

For type checking, open Claude Code in plugins/bar, run /plugin-types (it writes the API declarations to .claude/types), then run:

npx -p typescript tsc -p plugins/bar

Run the tests (the plugin test kit needs function hooks switched on):

CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude plugin test plugins/bar

To load your working copy instead of the installed one:

claude --plugin-dir plugins/bar

License

MIT

更多类似作品