tokenusage-cli 0.4.1 → 0.4.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  本包(`tokenusage-cli`)的用户可见变更记录。发版时在顶部新增一节,
4
4
  `## <版本号>` 行会被 release workflow 取作 GitHub Release 正文。
5
5
 
6
+ ## 0.4.2
7
+
8
+ 2026-11-01。`init` 的调度摘要不再只写 `degraded: xml_rejected`:现在把被拒的第一行原因
9
+ (如 `ERROR: Access is denied.`,超过 100 字符截断)一并打印,用户能据此判断是「需要
10
+ 管理员权限」还是「任务定义本身有问题」。
11
+
12
+ - Windows:非提升 shell 下 `schtasks /Create /XML` 必然 `Access is denied`,降级路径照旧
13
+ 每小时采集(隐藏窗口);要启用 catch-up / retry / 无执行时限,需以管理员身份重跑
14
+ `tokenusage init`。
15
+ - 单测覆盖:原因可见、超长命令输出截断(`test/scheduled-task.test.js`)。
16
+
6
17
  ## 0.4.1
7
18
 
8
19
  2026-11-01。修复 `tokenusage reconcile` 在真实队列上的误报:队列行写的是
package/README.md CHANGED
@@ -8,7 +8,8 @@
8
8
 
9
9
  ```bash
10
10
  # 1) 初始化:扫描根配置、各工具用量 hook、并注册每小时自动采集的计划任务
11
- # (Windows 经 VBS 隐藏窗口运行,不弹黑框;--no-task 可跳过任务注册)
11
+ # (Windows 经 VBS 隐藏窗口运行,不弹黑框;--no-task 可跳过任务注册。增强任务定义
12
+ # 需要管理员权限,非提升 shell 下会自动降级为普通每小时触发并提示 degraded)
12
13
  tokenusage init
13
14
 
14
15
  # 2) 配对:输出一个 user_code,浏览器打开提示的链接批准
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenusage-cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Self-hosted AI coding token usage collector for the Token Usage dashboard.",
5
5
  "keywords": [
6
6
  "token-usage",
@@ -637,12 +637,28 @@ function deleteAutoSyncSchedule({ home = os.homedir(), binDir, platform = proces
637
637
  }
638
638
 
639
639
  // One place for the init summary copy so Windows/macOS/Linux cannot drift.
640
+ //
641
+ // Degraded registrations carry the raw rejection in `detail`. On a normal
642
+ // (non-elevated) Windows install `schtasks /Create /XML` always fails with
643
+ // "Access is denied", so showing that first line lets the user tell "re-run as
644
+ // administrator" apart from a genuinely malformed definition. Clip it to one
645
+ // short line so the summary table stays readable.
646
+ function scheduleDetailLine(value, max = 100) {
647
+ const line =
648
+ String(value ?? "")
649
+ .split(/\r?\n/)
650
+ .map((part) => part.trim())
651
+ .find(Boolean) ?? "";
652
+ return line.length > max ? `${line.slice(0, max - 1)}…` : line;
653
+ }
654
+
640
655
  function formatScheduleRegistration(outcome) {
641
656
  if (!outcome) return "not registered";
642
657
  if (outcome.registered) {
643
658
  const when = "hourly, hidden window";
644
659
  if (outcome.degraded) {
645
- return `${outcome.label}: ${when} (degraded: ${outcome.reason}; no catch-up/retry settings)`;
660
+ const why = scheduleDetailLine(outcome.detail);
661
+ return `${outcome.label}: ${when} (degraded: ${outcome.reason}${why ? ` — ${why}` : ""}; no catch-up/retry settings)`;
646
662
  }
647
663
  return `${outcome.label}: ${when} (pause/resume toggles it)`;
648
664
  }