ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 AltamimiYasser

bar

Claude Code 的一個外掛,在提示列上方顯示狀態列(上下文、方案額度、目前工作階段的時間與權杖),並為每個最終回答加上邊框

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%:目前聊天上下文視窗的使用量。粗體數字是對話中的權杖數,/ 400k 是上限(設定過時使用自動壓縮視窗,否則使用模型視窗,或使用 /bar-limit 指定的視窗),後面是比例。軌道上的淡色刻度表示下一種顏色從哪裡開始,只繪製仍在前方的刻度。點擊 Context 可執行 /usage。
  • 5h 和 Week ━━●─┃── 30% 07:20:方案的 5 小時視窗和每週上限。粗體百分比是已使用的比例;變暗的時間或日期表示重設時間。線上的直立標記是現在:視窗已經過了多少時間。圓點在標記左側,表示使用速度比時鐘慢,很安全;圓點在標記右側,表示進度領先時間,可能會在重設前用完。停留可查看準確的重設日期,以及照目前速度最後會落在哪裡。

第 2 列:現在的狀態

  • 節拍:橘色圓點每秒由一個膨脹的圓環包住一次,表示 Claude 正在工作;節拍與計時器同步。空心灰色圓環表示閒置,此時該列會顯示上一個工作階段。
  • Working 1m 04s(橘色)或 Last turn 16s:目前工作階段已執行或曾執行的時間。
  • 火花線(工作期間):過去 24 秒內每秒輸出的權杖數,圓點表示現在。數值高表示 Claude 寫得快;變平表示 Claude 正在思考,或等待工具。
  • 數字:out 是 Claude 寫出的權杖數(+ 表示仍有內容正在串流),read 是從提示快取提供的權杖數,write 是新寫入快取的權杖數。停留在目前工作階段上可查看全部四項,包括快取以外的輸入 in 和工具呼叫。
  • 3 tools ›:Claude 在本次工作階段呼叫的工具數量。點擊後開啟面板,列出每次呼叫;點開每項即可查看輸入和輸出。
  • Cache 59:27:對話從 Claude 上一次回應開始在提示快取中保留的時間,會倒數(依工作階段使用 1 小時或 5 分鐘)。過期後,下一則訊息必須再次把整個對話寫入快取。停留可查看準確的過期時間,以及屆時需要寫入的權杖數。
  • 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 不再重複顯示。

每個工作階段

  • 用橘色邊框包住最終回答。邊框下方顯示工作階段耗時,以及輸入、輸出、快取讀取和快取寫入的權杖數。

提示列頁尾中的 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" 使用模型本身的視窗,或填寫權杖數。舊檔案中的 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 列的權杖數字 | | turn.toolCalls / toolCallsPanel | true | 工具呼叫數量,以及它開啟的面板 | | answer.frame / footer / footerTokens | true | 回答邊框、下方那一列及其權杖數字 | | 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

更多類似作品