Headless plan/usage query: expose /usage data (e.g. cmd usage --json)

オープン
#1,093 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
cli
領域
api, cli

調査の方向性

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 status reports authentication only.
  • Automation (status bars, desktop widgets, dashboards) therefore has to approximate window usage from local transcripts (~/.commandcode/projects/**/*.jsonl via costUsd + 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分
マージ済み PR(30日)
7

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CommandCodeAI/command-code のほかの issue

CommandCodeAI/command-code の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。