usage

usage 0.28.20

工具與目錄
在這頁

新功能 2 項

01

5 小時工作階段會重新自動開啟

你靠自動功能守著 5 小時工作階段時,第一個提醒過後不會再整天沒動靜。先前它改用「跨過時段交界才提醒」的判斷,卻因為背景執行的 claude -p 不會觸發 statusLine(顯示在終端機最底下的狀態列)掛鉤,usage-status.json 一直留著已處理過的交界時間,於是自動功能永遠不再啟動。現在除了保留交界判斷來即時抓住真正換時段,也加上 5 小時 5 分鐘的冷卻計時;資料太舊時便重新準備下一次提醒。像鬧鐘既會在整點響,也有備用計時器;其中一個卡住,另一個仍會叫你起床。原本避免已開啟工作階段又亂提醒的關卡都還在。

官方原文

**Auto-start 5-hour Session stopped firing at all after its first ping.** 0.28.17 swapped the keeper's elapsed-time throttle for reset-boundary deduplication, which only holds up while the boundary keeps moving — and it doesn't. The ping runs claude -p headless, which never triggers Claude Code's statusLine hook, so usage-status.json goes on reporting the boundary that was already handled and the keeper wedges permanently. One machine went 23 hours with no auto-opened window while the cooldown-based Antigravity keeper kept working normally. The boundary check stays, since it is what catches a real rollover the moment it happens; a 5h5m cooldown is added alongside it as a second, independent way to re-arm once the payload has gone stale. Every existing gate is untouched, so a live window still never draws a spurious ping.

02

異常中斷留下的暫存檔會自動清理

程式在寫入資料時若突然當掉或被強制關閉,~/.usage/ 裡留下的暫存檔現在會被收走,不會越堆越多。正常情況下,原子寫入(先寫好新檔再一次換上去,避免寫到一半壞掉)結束時會刪除 mkstemp 產生的檔案;但遇到 SIGKILL(作業系統立刻強制終止程式的訊號)或崩潰,清理步驟來不及跑。一台電腦曾在 12 天累積 40 MB,主要是寫得較慢的 JSONL 快取(把算過/查過的結果暫存起來直接用)。現在啟動時會掃描 ~/.usage/ 和它直接底下的 *.d 資料夾,只刪符合名稱、超過 24 小時未碰過的一般檔案;符號連結和資料夾一律不碰。像倉庫每天開門先清昨夜遺下的包材,仍在裝箱的貨不會被誤丟。

官方原文

**Orphaned temp files piled up in ~/.usage/.** Every atomic write unlinks its mkstemp file in a finally block, and that block never runs when the app is SIGKILLed or crashes mid-write. One install had collected 40 MB of them over twelve days, dominated by the large JSONL caches whose slow writes are the likeliest to be interrupted. Startup now sweeps ~/.usage and its direct *.d children, deleting only regular files that match the mkstemp name shape and have gone untouched for 24 hours — long enough that a second usage process cannot lose a temp file it is still writing. Symlinks and directories are skipped no matter how well their name matches.