usage

usage 0.30.15

工具與目錄
在這頁

新功能 4 項

01

HTML 報表內建互動日期切換,外寄檔案免裝 app 隨開即查

將匯出的 HTML 報表寄給同事或主管時,對方現在打開網頁就能自由挑選想看的日期範圍。⟦這好比寄給客戶一張附帶迷你算盤的互動報價單,對方輕撥頂端滑軌,整張單據的各項統計數字便立刻重算。⟧過去報表在產生的那一刻就把區間寫死,收到檔案的人完全無法切換視角;若要改看上週數據,只能請你重跑一次指令。新版直接將約 80 KB 的「日 × 工具 × 模型 × 專案」彙總表嵌入網頁中,所有牽涉日期的區塊都在瀏覽器內即時計算。頁面上方設有吸頂日期列,提供五個快捷範圍與自訂起訖日;不需安裝 app 也不必重新產檔,分享出去的檔案依然能完整操作。至於那些固定觀察特定天數的區塊,介面也會清楚標明涵蓋範圍,避免切換日期時讓人誤以為畫面故障。

官方原文

**The report's date range can be changed inside the page** ([#137](https://github.com/aqua5230/usage/pull/137)). The HTML report used to freeze its period at generation time, so a copy sent to someone else could not be explored. A day × tool × model × project table (about 80 KB) is now embedded, and every date-dependent section recalculates in the browser from five shortcuts or a custom from/to range in a sticky bar. No app and no regeneration are needed, so a shared file stays fully usable. Sections that always cover a fixed span say so, so they don't look broken when the dates change.

02

清理對話紀錄不再遺失用量歷史,快照持久化小計與花費

刪除舊的對話紀錄釋放硬碟空間,歷史報表不再跟著消失。過往報表每次都從 ~/.claude/projects 與 ~/.codex/sessions 重算,這些紀錄每月約增長 1.9 GB,清掉舊檔等於抹平歷史。新版將小計以工作階段、日期、工具、模型與專案五個維度存入 ~/.usage/usage_snapshot.json 快照檔,並記錄各工作階段(session)的開始時間與時長,排行榜也能救回。若某天讀取的 token(AI 處理與計費的文字單位)少於快照,當天改由快照還原;已存花費原樣沿用,不依今日價格重新計價。實測今天、本週、最近 7 天、本月與全部五個範圍,模擬紀錄全刪與完整留存產出的報表,除產生時間外逐字相同。⟦這宛如會計部將厚重簽單彙總成分類帳,日後銷毀過期單據,收支與排行依然分毫不差。⟧

官方原文

**Report history survives transcript cleanup.** The report recomputed everything from ~/.claude/projects and ~/.codex/sessions, which grow by roughly 1.9 GB a month, so deleting old transcripts erased report history with them. Totals are now kept in ~/.usage/usage_snapshot.json at (session, date, tool, model, project) grain, plus each session's start time and duration so the session ranking survives too. When a day's live transcripts hold fewer tokens than the snapshot, that day is replayed from the snapshot; stored costs are used as-is rather than repriced against today's price list. On real data, reports for today / week / last 7 days / month / all were byte-identical except for the generation time with transcripts present and with all of them simulated as deleted.

03

報表依閱讀動線重新排版,視覺降噪並最佳化手機瀏覽

用量報表打開後,版面按閱讀順序重排。⟦像把年報改成目錄,先放總覽,撤掉重複圖表,細節收進可展開頁籤,手機也不迷路。⟧順序是摘要卡、用量趨勢、工具、專案、高花費工作階段、固定週期群組、計算方式、年度回顧。主力模型區塊因重複工具數字而移除;工具列可展開模型,切換日期後保持展開;專案甜甜圈圖因重複排行而刪除。每週燃燒趨勢改名為「用量趨勢」。token(AI 處理與計費的文字單位)組成、快取命中率與花費可信度收進折疊的計算卡,五個 fixed range 標籤變成群組上方說明。色條改成底緣 2px 細線,只有 token 數字維持黃色;摘要卡獨立成圓角框,先顯示縮寫數字,下方列精確數字。區塊間距、標題大小與左右邊界也統一,可展開列滑過會高亮。手機上專案一行、工具兩行,工作階段表格橫滑,熱圖保留可讀格子並自動捲到最新週數。開頭摘要移除專案數,因非 git 資料夾與重播歷史會墊高數字。

官方原文

**The report is reorganised around what people read first.** Order is now summary cards → usage trend → your tools → projects → costliest sessions → the fixed-span group (heatmap, habits, recent work, insights) → how these numbers are calculated → Year in Review. The main-model section repeated the tools section's numbers exactly, so it is gone; each tool row now expands to show its models, and expanded rows stay open when the date range changes. The project donut repeated the ranking below it and was removed. "Weekly burn trend" is now "Usage trend". Token mix, cache hit rate and cost confidence live in a collapsed "How these numbers are calculated" card. The five "fixed range" tags became one note above the group they apply to.

**Visual pass across the report.** Filled bars behind ranking, tool, composition and weekly rows became 2px tracks along the bottom edge; only token figures stay yellow. Summary cards are separate rounded boxes that lead with the abbreviated number and show the exact count underneath. Section spacing and title sizes are consistent, every section shares one left and right edge, and expandable rows highlight on hover. On phones, a project is one line instead of four, a tool is two lines instead of four, the session table scrolls sideways instead of wrapping, and the heatmap keeps readable cells and opens scrolled to the latest weeks.

**The summary sentence no longer states a project count.** Projects are attributed by working folder, so non-git folders and replayed history still inflate the number enough to mislead.

04

新增每日用量堆疊圖與花費可信度,工具分色不再混淆

想看清各家 AI 每天的花費與用量節奏,報表新增了直觀的每日用量圖表。圖表每天顯示一根堆疊長條並依工具分色,右上角提供 Tokens 與花費切換開關,滑鼠懸停即可檢視當日用量細項,切換日期時也會跟著重新繪製。為了讓各家工具一目了然,Grok 的代表色改為粉紅色,徹底解決過往綠色與相鄰 Claude 綠色混在一起難以分辨的困擾。此外,報表增設「花費可信度」標記,明確列出有多少比例的用量具備公開價格、多少沒有,並直接點名缺乏公開報價的模型。介面也明白告知讀者,統計顯示的金額是依公開價目表折算的 API 等值花費,並非你的訂閱制月租帳單。⟦這種透明度恰如商務飯店出具的明細單,每天的消費以不同顏色長條清楚區分,附上幣別切換與項目透視,並誠實註記未定價項目的等值折算依據。⟧

官方原文

**Daily usage chart.** A stacked bar per day, coloured by tool, with a Tokens/Cost toggle, a hover breakdown, and redraws when the date range changes.

**Cost confidence.** Shows how much usage has a public price and how much does not, names the unpriced models, and states plainly that cost is the API-equivalent value from public price lists, not a subscription bill.

**Grok is pink in the report.** Its previous green sat next to Claude's green in the stacked daily chart and the two could not be told apart.

修正 2 項

05

Claude 子目錄工作階段依 Git 歸屬專案,快取擴大防止重複查詢

在專案子資料夾啟動 Claude,用量現在會正確歸入同一個母專案。過去 adapters/claude.py 處理工作階段(session)只取路徑最後一層名稱,導致 tests/、docs/ 或 panels/ 都被誤算成獨立專案。新版改用與 Codex、Grok 及 Antigravity 相同的 resolve_project_name() 判斷 git 根目錄。為了避免多個工具的資料夾加總後反覆呼叫 git,共用快取(cache,把查過的結果暫存起來直接用)上限從 256 筆調升至 2048 筆。只能從小計快照還原的舊日期,則沿用當時記下的資料夾名稱。⟦這彷彿收發室先前只看包裹的辦公室門牌,把同一部門信件拆給不同客戶;改查大樓總地址後,信件才正確歸入同案。⟧

官方原文

**Claude sessions opened in a repo subfolder no longer count as separate projects.** adapters/claude.py used only the last folder name, so tests/, docs/ and panels/ each became a project. It now uses the same resolve_project_name() git lookup as Codex, Grok and Antigravity, and the shared cache grew from 256 to 2048 entries so several tools' folders together don't push it into repeated git calls. Days that can only be replayed from the snapshot keep the folder names recorded at the time.

06

報表修復排版與圖表比例,校準前期統計與混合計價

瀏覽 HTML 報表時,多項版面與統計問題已修正。前期比較不再算到資料起始日之前,排除了如 ↑2799% 的假成長;工具分組混到未定價模型也不再把整組花費隱藏成 —,Antigravity 曾被藏起的 $166 現已正常顯示。因 .rank-line 的 display:grid 權重高於瀏覽器 [hidden] 導致收合失效的問題已排除,收合列會確實收起;.tokens-cell 補上 position:relative,工作階段(session)排行的長條不再全疊在頁面左上角;展開的模型子列修正尺規,不再把專案佔比套用總量尺度,避免佔專案 68.7% 的模型看起來比專案本身大三倍。⟦這好比校對帳冊排版,校正前後期基準日,把摺疊欄位確實藏起並歸位重疊圖條,不再讓細項畫得比總額還長。⟧

官方原文

**Previous-period comparisons no longer reach before the first day of data** ([#137](https://github.com/aqua5230/usage/pull/137)), which produced growth like ↑2799%.

**A tool group with one unpriced model no longer hides its whole cost** ([#137](https://github.com/aqua5230/usage/pull/137)); Antigravity's $166 had been shown as —.

**Collapsed rows actually collapse** ([#137](https://github.com/aqua5230/usage/pull/137)). .rank-line's display:grid outranked the browser's [hidden], so collapsing changed the DOM but not the screen.

**Session ranking bars no longer pile up in the top-left corner** ([#137](https://github.com/aqua5230/usage/pull/137)); .tokens-cell was missing position:relative.

**Expanded model rows are no longer wider than their parent.** Child bars were drawn as share-of-project on the same scale as the parent's share-of-total, so a model at 68.7% of a project looked three times bigger than the project itself.