@tsa-group/claude-usage 0.3.2 → 0.3.3

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.
package/dist/daemon.js CHANGED
@@ -207,7 +207,11 @@ export function printHealth() {
207
207
  row("last_tick_at", h.last_tick_at);
208
208
  row("last_sample_at", h.last_sample_at);
209
209
  row("last_sample_status", h.last_sample_status);
210
- row("last_ok_at", h.last_ok_at + (h.last_ok_at_backfilled ? " (從既有快照回填,非真的成功紀錄)" : ""));
210
+ // 不能先字串相加再交給 row():h.last_ok_at undefined `undefined + ""` 會變成
211
+ // 字串 "undefined",把 row() 的 `?? "-"` 完全繞過去(Sandy 那台就印出 undefined)。
212
+ row("last_ok_at", h.last_ok_at
213
+ ? h.last_ok_at + (h.last_ok_at_backfilled ? " (從既有快照回填,非真的成功紀錄)" : "")
214
+ : "從未成功採樣過");
211
215
  row("consecutive_failures", h.consecutive_failures ?? 0);
212
216
  row("last_upload_state", h.last_upload_state);
213
217
  if (h.last_error)
package/dist/install.js CHANGED
@@ -129,9 +129,19 @@ function winUninstall() {
129
129
  return 0;
130
130
  }
131
131
  function winStatus() {
132
- const r = spawnSync("schtasks", ["/Query", "/TN", WIN_TASK], { encoding: "utf8" });
133
- console.log(r.status === 0 ? (r.stdout ?? "").trim() : "bg-task: NOT installed (schtasks)");
134
- return r.status ?? 1;
132
+ // winInstall:不設 encoding。Windows 主控台是本地碼頁(繁中 CP950),用 utf8
133
+ // 解碼會把整段表格變成亂碼,而使用者要看的只是「這個工作在不在、下次何時跑」。
134
+ const r = spawnSync("schtasks", ["/Query", "/TN", WIN_TASK]);
135
+ if (r.status !== 0) {
136
+ console.log("bg-task: NOT installed (schtasks)");
137
+ return r.status ?? 1;
138
+ }
139
+ // 只挑出下次執行時間那一段數字/日期,避開會亂碼的本地化欄位標題
140
+ const raw = (r.stdout ?? Buffer.alloc(0)).toString("latin1");
141
+ const when = raw.match(/\d{4}[/-]\d{1,2}[/-]\d{1,2}[^\r\n]*/)?.[0]?.trim();
142
+ console.log(`bg-task: 已註冊 "${WIN_TASK}"${when ? `,下次執行 ${when}` : ""}`);
143
+ console.log(` 完整資訊: schtasks /Query /TN ${WIN_TASK} /V /FO LIST`);
144
+ return 0;
135
145
  }
136
146
  const sessionStartGroups = (s) => s.hooks?.SessionStart ?? [];
137
147
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsa-group/claude-usage",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Per-user Claude usage collector — measures Claude Code token detail and account-level rate-limit utilization locally, reports to your own ingest server.",
5
5
  "type": "module",
6
6
  "bin": {