coding-usage-bar 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/kimi.js +7 -2
  2. package/package.json +1 -1
package/dist/kimi.js CHANGED
@@ -16,11 +16,16 @@ function asNumber(value) {
16
16
  }
17
17
  // Kimi reports limit/used/remaining per window. Prefer the used/limit ratio;
18
18
  // when limit is 0 or missing, derive the total from used + remaining instead of
19
- // falling back to 0% while a real signal exists.
19
+ // falling back to 0% while a real signal exists. Kimi also omits zero-valued
20
+ // fields entirely (proto3 JSON): a fresh window with no usage reports only
21
+ // limit + remaining, so derive used from limit - remaining instead of failing.
20
22
  function percentFromDetail(detail) {
21
23
  const limit = asNumber(detail.limit);
22
- const used = asNumber(detail.used);
24
+ let used = asNumber(detail.used);
23
25
  const remaining = asNumber(detail.remaining);
26
+ if (used === null && limit !== null && remaining !== null) {
27
+ used = Math.max(0, limit - remaining);
28
+ }
24
29
  if (limit !== null && limit > 0 && used !== null) {
25
30
  return Math.max(0, Math.min(100, (used / limit) * 100));
26
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coding-usage-bar",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "macOS menu bar usage monitor for Claude Code, Codex, GLM, DeepSeek, and MiniMax.",
5
5
  "author": "hanzhangzzz",
6
6
  "license": "MIT",