Headless plan/usage query: expose /usage data (e.g. cmd usage --json)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
The payload names no source files. Start by finding where the /usage slash command gets its window and credit data in the interactive TUI, and where the existing status subcommand is defined. Confirm whether a server endpoint for this data is already in use, since the issue rules out probing undocumented ones. Done means cmd usage and cmd usage --json print the proposed shape, with exit code 0 on success and the existing auth and network error codes preserved.
由索引模型根據 Issue 內容生成。
描述
Summary
/usage shows the 5-hour and weekly usage windows (percent used, reset time) plus the credit balance, but it is only available in the interactive TUI. There is no headless/scriptable way to read the same data.
Problem
cmd -p "/usage"does not run the slash command (it is treated as a prompt).cmd statusreports authentication only.- Automation (status bars, desktop widgets, dashboards) therefore has to approximate window usage from local transcripts (
~/.commandcode/projects/**/*.jsonlviacostUsd+ timestamps, simulating the anchored windows). That cannot match server-side credit accounting, especially on plans where credits are not exactly $1 of usage.
Proposal
Add a headless command with the same content as /usage:
cmd usage # human-readable
cmd usage --json # machine-readable
Suggested JSON shape:
{
"plan": "GOAT",
"credits": { "monthly_cap": 100.0, "remaining": 74.5 },
"windows": {
"5h": { "used": 4.2, "cap": 20.0, "percent": 21, "resets_at": "2026-10-31T17:20:00Z" },
"7d": { "used": 8.8, "cap": 50.0, "percent": 18, "resets_at": "2026-11-04T21:00:00Z" }
}
}
Exit code 0 on success; keep the existing exit-code conventions for auth/network errors.
Alternatives considered
- Parsing an internal endpoint: undocumented and brittle; the docs advise against probing endpoints/auth.
- Local transcript approximation: cannot reproduce server-side credit accounting or window anchoring reliably.
Additional context
Use case: a Wayland bar / desktop widget polling usage every minute so the user sees the same meters as /usage without opening the TUI.
- 主要語言
- 沒有語言資料
- 星號
- 4.2k
- 分支
- 377
- 平均合併
- 1 天 17 分鐘
- 30 天內合併 PR
- 7
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
CommandCodeAI/command-code 的其他 Issue
-
Provider /v1/messages rejects role:"system" inside messages[] — Claude Code ≥ 2.1.154 incompatible未關閉
難度 2/5 1-3 小時 新手友好度 75/100
CommandCodeAI/command-code#1085 ·
維護者通常 1 天內回覆
-
Feature request: auto-reconnect remote control (/rc) after restart可能已有人在做 @aliarain 於 20 天前認領。 未關閉p2
難度 2/5 1-3 小時 新手友好度 85/100
CommandCodeAI/command-code#992 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
CommandCodeAI/command-code#933 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
CommandCodeAI/command-code#855 ·
維護者通常 1 天內回覆
-
grep tool passes empty file type to ripgrep可能已有人在做 @ahmadbilaldev 於 19 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
CommandCodeAI/command-code#655 · 1 則留言 ·
維護者通常 1 天內回覆
查看 CommandCodeAI/command-code 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 85/100
-
難度 2/5 1-3 小時 新手友好度 78/100
UKGovernmentBEIS/inspect_ai#6512 ·
維護者通常 1 天內回覆
-
area/c++ area/core kind/bug-report
難度 2/5 1-3 小時 新手友好度 78/100
tensorflow/quantum#1140 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 68/100
Kav-K/GPTDiscord#501 ·
維護者通常 1 天內回覆