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

usage-ring

在提示列上方顯示限制、上下文、待辦事項、權杖、費用與提示快取的環形指標

Oualid0@Oualid0

Oualid0/claude-mods/tree/main/plugins/usage-ring

已翻譯

關於這個 mod

claude-mods

給 Claude Code 終端機使用的外掛:提示列上方會顯示一排環形指標,呈現你的限制、本次對話的用量與提示快取,另外還有執行中 Claude 工作階段的看板。

快速安裝

把這段提示複製到 Claude Code:

Install the Claude Code plugins from https://github.com/Oualid0/claude-mods:
add the repo as a plugin marketplace, then install every plugin listed in its
.claude-plugin/marketplace.json, and tell me to run /reload-plugins when done.

手動安裝

claude plugin marketplace add Oualid0/claude-mods
claude plugin install usage-ring@claude-mods
claude plugin install session-board@claude-mods

接著在 Claude Code 執行 /reload-plugins,或啟動新的工作階段。從本機複製的儲存庫執行 ./install.sh 也會做同樣的事(需要 python3),而且可以安全地重複執行。

更新

自動更新預設關閉。在工作階段中用 /plugin marketplace update claude-mods 手動更新,或在 shell 中執行 claude plugin update usage-ring@claude-mods 與 claude plugin update session-board@claude-mods。也可以在 /plugin 的 Marketplaces 下為這個 marketplace 開啟 Enable auto-update。

外掛

| 外掛 | 功能 | |---|---| | usage-ring | 提示列正上方的兩個晶片:limits 與 chat。旁邊有一個像素 Claude,執行一輪時會敲打,其他時候會睡覺;模型則以灰色顯示在旁邊,例如 Opus 5.5 (mid)(effort 為 low、mid、high、xhigh 或 max,從第一次請求起就知道)。 | | session-board | 這台機器上有其他 Claude 工作階段執行時,在上方顯示 sessions 晶片:每個工作階段一列(● 執行中,完成後 60 s 內為 ✓ 已完成),再加上標記 ← 的本工作階段一列(○ 就緒或 ● 執行中)。沒有其他工作階段執行時,看板會隱藏。 |

標籤代表什麼

| 標籤 | 晶片 | 意義 | |---|---|---| | Wk | limits | 已使用的每週限制,以百分比表示。 | | Se | limits | 已使用的工作階段限制(5 小時視窗),以及距離重設的時間:4:50h,或不到 1 小時時顯示 33m。視窗結束後,在下一次讀取前會顯示 0% 5:00h。 | | Cx | chat | 已使用的上下文視窗,以百分比表示。 | | Td | chat | 已完成的待辦事項數/總數,例如 3/5。只有對話有待辦清單時才顯示。 | | Tk | chat | 從工作階段開始後這個對話使用的權杖(包括輸入、輸出、快取讀取與寫入,以及子代理)。每次模型請求後都會增加。 | | Co | chat | 目前工作階段的累計費用,單位為美元。 | | Ca | chat | 提示快取剩餘時間(33m);過期後顯示 expired。 |

終端機較窄時,會先移除不重要的內容:模型標籤、limits 與 chat 文字、Ca、Co、Tk、Td、Wk、像素 Claude,最後才是 Cx。Se 會盡量保留;連它也放不下時,整排就隱藏。內容不會被擠壓或換行。

限制

  • 需要支援 mods(function-hook 外掛)的 Claude Code 版本;已在 Claude Code 2.1.288 測試。mod API 仍屬早期功能,版本之間可能變動。
  • kitty 與 Ghostty 會以像素圖片顯示環形指標;其他終端機則顯示字元。
  • 每週、工作階段與上下文指標從 95% 起變紅,快取時間 Ca 在最後 3 分鐘變紅。
  • Ca 是估計值。Claude Code 不會告訴外掛快取能存活多久(5 分鐘或 1 小時),所以看板假設為 1 小時,再根據每次請求從快取讀到的內容學習:暫停超過 5 分鐘後命中表示為 1 小時,未命中表示為 5 分鐘。系統提示變更也可能造成未命中,但看板看不到這個原因。
  • 工作階段開始或恢復時,Tk 從 0 開始;恢復的工作階段先前使用的權杖無法取得。Co 從工作階段費用開始計算。
  • Td 統計 TaskCreate/TaskUpdate/TaskList 與 TodoWrite。較新的模型只有在 CLAUDE_CODE_ENABLE_TODO_TOOLS=1 時才有這些工具(文件)。
  • 看板只能知道其他工作階段忙碌或閒置;無法知道它們是否「需要輸入」。沒有名稱的工作階段會隱藏。
  • 看板每 5 s 從 ListAgents 工具讀取工作階段清單。它的輸出是給模型看的文字,不是固定格式:如果 Claude Code 更新輸出,看板會保持空白,不會顯示錯誤。

選項

usage-ring 有一個預設關閉的選項:

| 選項 | 意義 | |---|---| | limitsFile | 將工作階段與每週限制寫入 $CLAUDE_CONFIG_DIR/usage-limits.json(預設 ~/.claude),供其他工具讀取。 |

在 Claude Code 執行 /plugin configure usage-ring@claude-mods 設定,或執行:

echo '{"limitsFile":"true"}' | claude plugin configure usage-ring@claude-mods --values-stdin

開發

  • 每個外掛位於 plugins/<name>/:.claude-plugin/plugin.json、hooks/hooks.json、含有 hooks 的 hooks/register.tsx、旁邊的純邏輯檔案、types/index.d.ts(狀態契約)以及 tests/。
  • 檢查:先執行 claude plugin validate .,再執行 claude plugin validate plugins/<name> 與 claude plugin test plugins/<name>。
  • 從本機儲存庫安裝時,Claude Code 會直接讀取原位置的檔案:變更會在 /reload-plugins 或下一個工作階段套用。
  • 兩個 mod 都繪製在提示列上方的同一列;每個 render hook 都會呼叫 next(e),並保留下方的內容(session-board 在上方,usage-ring 緊鄰提示列)。

授權條款

MIT,請參閱 LICENSE。

安裝

請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。

claude plugin marketplace add Oualid0/claude-mods
claude plugin install usage-ring
原文 / README

claude-mods

Mods for the Claude Code terminal: a band of rings above the prompt that shows your limits, this chat's usage and the prompt cache, plus a board of your running Claude sessions.

Quick install

Copy this prompt into Claude Code:

Install the Claude Code plugins from https://github.com/Oualid0/claude-mods:
add the repo as a plugin marketplace, then install every plugin listed in its
.claude-plugin/marketplace.json, and tell me to run /reload-plugins when done.

Manual install

claude plugin marketplace add Oualid0/claude-mods
claude plugin install usage-ring@claude-mods
claude plugin install session-board@claude-mods

Then run /reload-plugins in Claude Code, or start a new session. From a local clone, ./install.sh does the same (it needs python3) and is safe to run again.

Update

Auto-update is off by default. Update by hand with /plugin marketplace update claude-mods in a session, or claude plugin update usage-ring@claude-mods and claude plugin update session-board@claude-mods in the shell. You can also turn on Enable auto-update for the marketplace under Marketplaces in /plugin.

Mods

| Plugin | What it does | |---|---| | usage-ring | Two chips right above the prompt: limits and chat, with a pixel Claude beside them that hammers while a turn runs and sleeps otherwise, and the model in grey next to it, e.g. Opus 5.5 (mid) (effort low, mid, high, xhigh or max, known from the first request on). | | session-board | A sessions chip above that while other Claude sessions on this machine are running: one row each (● running, ✓ done for 60 s after it finished), plus your own row (○ ready or ● running) marked ←. With no other session running, the board is hidden. |

What the labels mean

| Label | Chip | Meaning | |---|---|---| | Wk | limits | Weekly limit used, in percent. | | Se | limits | Session limit (the 5-hour window) used, and the time until it resets: 4:50h, or 33m under an hour. Once the window is over it shows 0% 5:00h until the next reading. | | Cx | chat | Context window used, in percent. | | Td | chat | Todos done out of all, e.g. 3/5. Only while the chat has a todo list. | | Tk | chat | Tokens this chat used since the session started (input, output, cache reads and writes, subagents included). Grows after every model request. | | Co | chat | What the session cost so far, in US dollars. | | Ca | chat | Time left on the prompt cache (33m), expired once it lapsed. |

When the terminal is narrow, the least important goes first: the model label, the words limits and chat, Ca, Co, Tk, Td, Wk, the pixel Claude, then Cx. Se stays longest; if not even it fits, the band is hidden. Nothing is squeezed or wrapped.

Limits

  • Needs a Claude Code version with mods (function-hook plugins); tested with Claude Code 2.1.288. The mod API is early access and may change between versions.
  • Rings are pixel images in kitty and Ghostty; other terminals show a glyph instead.
  • Rings for the week, session and context turn red from 95%, and the cache time Ca turns red in its last 3 minutes.
  • Ca is an estimate. Claude Code does not tell plugins how long the cache lives (5 minutes or 1 hour), so the band assumes 1 hour and learns from what each request read from the cache: a hit after a pause of more than 5 minutes means 1 hour, a miss means 5 minutes. A miss can also come from a changed system prompt, which the band cannot see.
  • Tk starts at 0 when a session starts or resumes; earlier tokens of a resumed session are not available. Co starts with the session's cost.
  • Td counts TaskCreate/TaskUpdate/TaskList and TodoWrite. Newer models only have these tools with CLAUDE_CODE_ENABLE_TODO_TOOLS=1 (docs).
  • The board knows other sessions only as busy or idle; "needs input" is not available. Sessions without a name are hidden.
  • The board reads the session list from the ListAgents tool every 5 s. Its output is text for the model, not a fixed format: if a Claude Code update changes it, the board stays empty instead of showing an error.

Options

usage-ring has one option, off by default:

| Option | Meaning | |---|---| | limitsFile | Write the session and weekly limits to $CLAUDE_CONFIG_DIR/usage-limits.json (default ~/.claude) for other tools to read. |

Set it with /plugin configure usage-ring@claude-mods in Claude Code, or:

echo '{"limitsFile":"true"}' | claude plugin configure usage-ring@claude-mods --values-stdin

Development

  • Each plugin lives in plugins/<name>/: .claude-plugin/plugin.json, hooks/hooks.json, hooks/register.tsx with the hooks, pure logic in files beside it, types/index.d.ts (the state contract) and tests/.
  • Check: claude plugin validate ., then claude plugin validate plugins/<name> and claude plugin test plugins/<name>.
  • Installed from a local clone, Claude Code reads the files in place: changes apply with /reload-plugins or the next session.
  • Both mods draw into the same band above the prompt; each render hook calls next(e) and keeps what is beneath (session-board on top, usage-ring next to the prompt).

License

MIT, see LICENSE.

更多類似作品