Feature: non-interactive way to read plan quota (5-hour / weekly / monthly)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start by tracing the CLI's existing projectUsageView and the documented-in-the-issue endpoints: /alpha/whoami?limits=1, /alpha/billing/credits, /alpha/billing/subscriptions, and /alpha/usage/summary?since=. Define the supported command output around the five-hour, weekly, and monthly fields, then verify that the text and --json forms exit non-interactively and expose the requested values.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Feature Description
Make the plan's quota readable from the CLI in a non-interactive way — one command that prints the 5-hour, weekly and monthly windows and exits, with a --json form for scripts.
Concretely, something like:
$ command-code usage
GOAT / alex
5h ▌░░░░░░░░░ 5% $13.32 left of $14.00 resets 04:16 (in 3h35m)
week ███▊░░░░░░ 37% $22.00 left of $35.00 resets 09-27 23:29 (in 5d22h)
month █▉░░░░░░░░ 19% $57.00 left of $70.00 resets 10-20 23:25 (in 28d22h)
and command-code usage --json printing the same fields (used, cap, percent, remaining, resetAt, resetsInMs) for tooling.
Right now the numbers exist — the dashboard shows them, and the web app reads them from /alpha/billing/credits (credits + windowLimits.fiveHour/weekly) and /alpha/billing/subscriptions — but as far as I can tell there is no supported way to ask for them without a browser. If a non-interactive path already exists, a pointer to it in the docs would be just as good as a new subcommand.
Optional, if it fits your roadmap: the same numbers in the terminal title or prompt, so they are ambient rather than something you remember to ask for. That is what most people build on top of this themselves.
Use Case
The quota is what decides whether work can continue, and it is checked at exactly the moments the user is inside a terminal:
- Sizing a task before starting it. "Can I finish this refactor on the current 5-hour window, or do I spread it over two?" needs the window's remaining amount and its reset countdown, not a percentage on a page in another tab.
- Explaining a failure. When a request is refused mid-run, the first question is whether the window is spent and when it comes back. Today that answer means leaving the editor for a dashboard.
- Scripts and status lines. CI jobs, hooks and status-line integrations can only consume the quota if there is a documented, non-interactive output contract. Today they have to depend on
/alpha/*— the web app's own endpoints — which are undocumented and can change without notice. A supported--jsonoutput would turn that from a hack into an interface. - Team plans. The same read with an
orgIdanswers "how much does the team have left", which is currently only visible per-account in the app.
Reading the quota should also cost nothing: it is four GETs, no model call.
Additional Context
I hit this while building a usage line for the agents I work in (Claude Code, Codex, ZCode, opencode, pi, DeepSeek Harness, and Grok) and ended up implementing it as an external plugin because there was no first-party surface to read:
- https://github.com/Jovan1666/commandcode-usage — MIT, ~300 lines of Node with no dependencies, and it is exactly the read described above: resolve the credential (
COMMAND_CODE_API_KEYor~/.commandcode/auth.json), call/alpha/whoami?limits=1,/alpha/billing/credits,/alpha/billing/subscriptions,/alpha/usage/summary?since=, normalize, print. - The normalization is written to match the CLI's own
projectUsageView: the plan's face value is the denominator while the subscription isactive, otherwise it falls back to spent + remaining;windowLimits.limited: falsemeans the account has no rolling windows and the plain monthly pool is the whole story. - A few details I had to guess at, which a first-party implementation could settle: whether
windowLimits.*.capis ever absent for a plan (I keep a plan table as a fallback), whatexceededimplies for subsequent requests, and whetheraverageCostis the right basis for a request count estimate (it moves with the model mix, so any count is an estimate).
Happy to hand over the code, or to open a PR against this repo if you want it there rather than in a plugin.
How important is this to you?
Important for my workflow
- Ngôn ngữ chính
- Không có dữ liệu ngôn ngữ
- Star
- 4k
- Fork
- 350
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CommandCodeAI/command-code
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CommandCodeAI/command-code#903 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CommandCodeAI/command-code#855 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CommandCodeAI/command-code#841 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CommandCodeAI/command-code#655 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CommandCodeAI/command-code#608 ·
Tất cả issue của CommandCodeAI/command-code
Issue tương tự
-
货币战争手改优先级配置缺少列表元素类型校验(P3) Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
syfoud/Simulated_Scepter#172 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
crossplane/crossplane#7859 ·
-
bot:ai-assisted component:compact-js status:untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
midnightntwrk/midnight-sdk#403 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nightscout/nocturne#1379 ·