usage

usage 0.29.36

工具與目錄
在這頁

新功能 4 項

01

Antigravity 額度會提醒,也能提早預警

⟦把 Antigravity 額度想成油表:油用完才亮燈已經太晚,舊讀值更不能冒充油箱已空。⟧ 現在 agy_session 和 agy_weekly 兩列會發通知,不再因為漏列在通知允許清單而一路耗盡卻沒消息。它們也接上各自的用量追蹤器,會在額度歸零前顯示警告,而不是等到底才沉默。Antigravity 的資料來自經過快取(把查過的結果暫存起來直接用)的網路端點;快取過期時,快照會標成不可用,因而不會誤報額度已用完。預測採用快照自己的 fetched_at 時間,而非輪詢當下的時鐘,避免同一份每五分鐘才變動的資料被重複讀取後憑空算出趨勢。兩列使用 3600 秒視窗;原本十分鐘的預設視窗湊不齊 MIN_FORECAST_SAMPLES,等同根本無法預測。過期快照也會完全停用預測,與 agy_window_keeper 一致。

官方原文

**Antigravity quota now raises notifications, the way Claude Code and Codex already did.** The agy_session and agy_weekly channels were missing from the notification allow-list, so the two Antigravity rows could run to the floor without ever saying so. Antigravity quota is the one source that comes from a network endpoint behind a local cache rather than a file on disk, so QuotaRowState.available is hard-coded to True; a stale snapshot now passes available=False instead, so an expired cache can no longer announce that the quota has run out.

**The Antigravity rows now warn before the quota is gone, not after.** They had never been wired to the burn-rate forecast, so their warning flag was permanently False — Claude and Codex warned ahead of a reset and Antigravity stayed silent until it hit the floor. Both rows now register their own tracker. Samples are timestamped with the snapshot's own fetched_at rather than the wall clock, because the Antigravity snapshot only changes every five minutes and polling would otherwise read the same payload again and invent a slope out of it. Both rows use a 3600-second window: at one sample per five minutes the default ten-minute window never collects MIN_FORECAST_SAMPLES, which is the same as not forecasting at all. A stale snapshot suppresses the forecast entirely, matching what agy_window_keeper already does.

02

usage doctor 能抓出 Codex 歷史搬遷後的歸零

⟦這像記帳員同時翻閱收據盒與總帳;收據盒空了、總帳卻有交易,便知道資料沒有真的消失。⟧ usage doctor(用來檢查使用資料異常的指令)現在會檢查 Codex 的歷史搬遷。Codex 開始寫入 rollout_migration_state 這類資料表後,若搬遷完成、工作階段的 .jsonl 檔不再寫入,loaders/codex_loader.py 會毫無錯誤地回傳零 token(AI 計費與計量的文字單位)數。現在只要 .jsonl 在最近七天沒有任何項目,但 thread_history_1.sqlite 裡的 thread_turns 卻有同一時段資料,檢查便會警告你。這能指出原本悄悄把計數歸零的落差。

官方原文

**usage doctor now catches a Codex history migration that would silently zero the token counts.** Codex has begun writing tables such as rollout_migration_state, and if that migration lands and the .jsonl files stop being written, loaders/codex_loader.py returns zero without an error anywhere. The check warns when the session .jsonl files hold no entry from the last seven days while thread_history_1.sqlite does hold thread_turns from that window.

03

usage doctor 會核對 Claude 費用是否偏離官方數字

帳單對不上時,問題可能不在你,而在離線價目表已經過時。⟦這次的 usage doctor 像把兩把尺靠在同一塊木板上,讀數差距超過門檻就亮起警示燈。⟧ 它會把 usage-status.json 的 cost.total_cost_usd 與 usage 自行算出的金額相比。差距同時超過 20% 與 $1 時便會警告。撰寫這項功能的那台機器上,兩者相差 46.4%,原因是價目表把 claude-opus-5 標成真實費率的一半。這正是離線備援價目表可能掩蓋的價格漂移。

官方原文

**usage doctor now reconciles its own Claude cost against the official one.** It compares cost.total_cost_usd from usage-status.json with the figure usage calculates itself and warns when they differ by more than 20% and more than $1. On the machine this was written on they differed by 46.4%, because the price table listed claude-opus-5 at half its real rate — exactly the kind of drift the offline fallback table is known to hide.

04

八個模組搬進新套件,專案根目錄少了雜物

八個模組搬離根目錄,行為不變。burn_rate、usage_rate、window_keeper、agy_window_keeper 搬進 quota/;time_utils、usage_logging、usage_lang、usage_dir_sweeper 搬進 usage_common/。⟦這像把工作桌上八樣零件分別收進兩個標籤清楚的抽屜,零件不變,不再散在桌面。⟧ 共用工具套件叫 usage_common,不用 common,uvx usage-cli 的進入點會把頂層套件裝進共用的 site-packages,common 易撞名。未留相容墊片:所有 import 一次更新,pyproject.toml 移除八個 py-modules 項目並加入兩個套件,setup_app.py 也更新。

官方原文

**Eight more modules moved out of the repository root.** quota/ took burn_rate, usage_rate, window_keeper, and agy_window_keeper; usage_common/ took time_utils, usage_logging, usage_lang, and usage_dir_sweeper. The shared-utility package is named usage_common rather than common because the uvx usage-cli entry point installs top-level packages into a shared site-packages, where common is about the most collision-prone name available. No compatibility shims were left behind — every import in the repository was updated in one pass, pyproject.toml dropped the eight py-modules entries and added the two packages, and setup_app.py followed. Behavior is unchanged.

修正 1 項

05

WIN95 與 Newspaper 的專案用量卡不再截掉資料列

WIN95 與 Newspaper 面板上的專案用量卡,現在不會只露出標題列,把底下資料列截掉。面板量自然高度時會暫時把整條 height: 100% 改成 auto。但兩個面板都把專案卡寫成 flex: 1,其彈性基準是零;卡片自己的 overflow: hidden 是復古視窗外框所需,卻壓掉可撐開內容的自動最小尺寸。量測時,卡片因此縮成標題列,WIN95 報出 877 像素、Newspaper 報出 876 像素,而結構相同的 Classic 是 923 像素。⟦像量布料時先把被拉緊的橡皮筋鬆開,才不會把整件衣服量短。⟧ 現在量測會暫時把這類可拉伸子項固定為 flex: 0 0 auto,量完再還原,因此面板的視覺設計不會改變。

官方原文

**The project usage card no longer clips its rows on the WIN95 and Newspaper panels.** A panel measures its own natural height by releasing the whole height: 100% chain to auto. Both panels write their project card as flex: 1, which means a flex basis of zero, and the card's own overflow: hidden — the retro window chrome depends on it — suppresses the automatic content-based minimum size that would otherwise hold the card open. The card therefore collapsed to its title bar during the measurement, and the reported height was short by exactly the project rows: 877 pixels for WIN95 and 876 for Newspaper against 923 for the structurally identical Classic. The measurement now pins such stretching children to flex: 0 0 auto while it measures and restores them afterwards, so no panel's visual design changes.