tokenusage-cli 0.4.0 → 0.4.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  本包(`tokenusage-cli`)的用户可见变更记录。发版时在顶部新增一节,
4
4
  `## <版本号>` 行会被 release workflow 取作 GitHub Release 正文。
5
5
 
6
+ ## 0.4.1
7
+
8
+ 2026-11-01。修复 `tokenusage reconcile` 在真实队列上的误报:队列行写的是
9
+ `conversation_count`(`docs/cli-contract.md` §2.4 的线名),小时表列名是
10
+ `conversations`,按字段名直接比较会把每一行都报成 `conversations local 0 → cloud N`
11
+ (本机首跑 41/43 行误报)。现在按别名归一后比较,真实差异仍照常报出。
12
+
13
+ - 会话数比较读 `conversations`,缺失时回退 `conversation_count`(两者都没有按 0)。
14
+ - 单测按真实队列形态(只带 `conversation_count`)覆盖,并断言真差异仍落在 `conversations` 字段。
15
+
6
16
  ## 0.4.0
7
17
 
8
18
  2026-11-01。错误提示更友好(一行 `Error:` + `Hint:` 且不再刷堆栈),帮助信息改为
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenusage-cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Self-hosted AI coding token usage collector for the Token Usage dashboard.",
5
5
  "keywords": [
6
6
  "token-usage",
@@ -296,12 +296,23 @@ function round6(value) {
296
296
 
297
297
  const COMPARED_COLUMNS = [...TOKEN_COLUMNS, "billable_total_tokens", "conversations", "credits"];
298
298
 
299
+ // Queue rows use the `conversation_count` wire alias (§2.4) while the hourly
300
+ // table stores `conversations`; read either name so a row that only carries the
301
+ // legacy one is not compared as 0.
302
+ function columnValue(row, column) {
303
+ if (column === "conversations" && row?.conversations === undefined) {
304
+ return row?.conversation_count;
305
+ }
306
+ return row?.[column];
307
+ }
308
+
299
309
  function describeRow(row) {
300
310
  const out = {};
301
311
  for (const column of COMPARED_COLUMNS) {
302
- if (column === "billable_total_tokens" && row?.[column] == null) out[column] = null;
303
- else if (column === "credits") out[column] = round6(Number(row?.[column] ?? 0));
304
- else out[column] = Number(row?.[column] ?? 0);
312
+ const value = columnValue(row, column);
313
+ if (column === "billable_total_tokens" && value == null) out[column] = null;
314
+ else if (column === "credits") out[column] = round6(Number(value ?? 0));
315
+ else out[column] = Number(value ?? 0);
305
316
  }
306
317
  return out;
307
318
  }
@@ -320,7 +331,7 @@ function compareBuckets({ local, server }) {
320
331
  continue;
321
332
  }
322
333
  const fields = COMPARED_COLUMNS.filter((column) =>
323
- valuesDiffer(localRow?.[column], serverRow?.[column], column),
334
+ valuesDiffer(columnValue(localRow, column), serverRow?.[column], column),
324
335
  );
325
336
  if (fields.length > 0) {
326
337
  mismatches.push({