tokenusage-cli 0.5.5 → 0.6.0

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
@@ -6,6 +6,38 @@
6
6
  > 0.4.x 之前的条目为压缩摘要;细节与当时的验收记录见 `docs/cli-release.md`
7
7
  > 与 `docs/archive/`。
8
8
 
9
+ ## 0.6.0
10
+
11
+ 2026-11-15。来源覆盖面的补齐 + 采集可诊断性。零契约变更(`docs/cli-contract.md` 未动),
12
+ 服务端无需同步升级;对账基线(`queue.jsonl` last-wins)与队列文件格式不变。
13
+
14
+ - **`doctor` 新增 `sources.coverage`**:按 30 天窗口列出每个来源的最新小时桶、桶数与 token
15
+ 数,并把超过 7 天没有新行的源单列为 `silent`;只有整条队列都超过 7 天才降为 warn——闲置
16
+ 工具正常停写,与解析器坏掉外观一致,必须由人判断。此前回答「这个来源到底采到没有」只能
17
+ 临时扫队列。
18
+ - **WorkBuddy 限额接入 `status --limits`**(`workbuddy` / `workbuddyAi` 两个键):国内版与
19
+ AI 国际版各走自己桌面端的本地计费代理(wbipc),互不借用对方的 socket;订阅窗口取自配额
20
+ 汇总,奖励 credits 不算配额窗口;provider 预算耗尽时 abort 会拆掉 IPC socket。plan 标签
21
+ 原样透传(`Ultimate` / `Advanced` / `STANDARD` / `Free`),共享的 Title-Case 归一化会把
22
+ `Free` 吞掉,因此与 grok / commandCode 同路跳过。
23
+ - **prime-agent 进入源注册表**:解析器早已存在但 id 没注册,`--source prime-agent` 直接报未知
24
+ id,auto / background 同步也整源跳过,只有不带筛选的手动 `sync` 才采得到。同时补
25
+ `astudio → acode` 别名——CLI 里集成叫 AStudio,`acode` 只是采集器 id。
26
+ - **修复 `sync --source <id>` 实际未限制扫描**:手动单源同步此前只校验了 id,随后仍然遍历全部来源
27
+ (`--json` 里恒定 ~32,000 parsed files、固定 ~1.8s 底噪);真正的源筛选只对带 `--auto` 的 hook/
28
+ 重试生效。现在 `--source` 也收窄扫描范围(本机实测 `--source kiro` / `--source zed` 从 31,785 个
29
+ 文件 / 1.8s 降到 0 个 / 0.4s),且单源运行不再跑跨源修复——这些修复会用解析到的文件集重建
30
+ 队列行,只喂一个来源可能把其它来源的桶当成过期数据。全量 `sync` 行为不变。
31
+ - **`sync --timing`**:打印扫描 / 上传 / 会话三段的耗时,长会话机器的慢环节不再靠猜。
32
+ - **旗标解析收敛为声明式 spec**:未知旗标统一走 `UsageError`(退出码 2),`--json` 下错误
33
+ 面与成功面同构;`project-profiles` 的请求补超时,避免桌面端调用挂死。
34
+ - **内部重构(无行为变化)**:八套 limits 的重复原语收敛到 `lib/limits-core`;队列抽排与
35
+ 批次读取、Codex / Grok / Zcode / Mimo / Droid / legacy 修复族各自拆成独立模块;`fs` 调用
36
+ 统一到 promises 版。
37
+
38
+ 升级说明:无需任何动作,随下次计划任务自动生效。想让运行时副本也拿到本版,跑一次
39
+ `tokenusage init --yes --no-integrations --no-open`,随后 `tokenusage doctor` 应全 OK。
40
+
9
41
  ## 0.5.5
10
42
 
11
43
  2026-11-11。新增只读子命令 `tokenusage project-profiles`(契约 §2.13),供桌面端伴生工具
package/README.md CHANGED
@@ -67,7 +67,7 @@ tokenusage sync --drain # 首次/积压补传(更大的批处理预算)
67
67
  | `--dry-run` | 只预览不落盘 |
68
68
  | `--no-open` | 不自动打开浏览器 |
69
69
 
70
- 已移除:`--email` / `--password` / `--device-name` / `--link-code` / `--no-auth`(浏览器登录已下线,配对走 `device-login`)。
70
+ 已移除:`--email` / `--password` / `--device-name` / `--link-code` / `--no-auth`(配对只走 `device-login`)。
71
71
  </details>
72
72
 
73
73
  <details>
@@ -87,6 +87,7 @@ tokenusage sync --drain # 首次/积压补传(更大的批处理预算)
87
87
  | `--wait-for-lock` | 遇并发 sync 等待而不是跳过 |
88
88
  | `--background` / `--lightweight` | 精简扫描档 |
89
89
  | `--repair-grok` | 从会话快照重建 Grok 行 |
90
+ | `--timing` | 在交互式汇总里打印分阶段耗时(扫描 / 上传 / 会话) |
90
91
 
91
92
  可用 `--source` id 见 `tokenusage sync --help` 的来源清单。
92
93
  </details>
@@ -100,9 +101,9 @@ tokenusage sync --drain # 首次/积压补传(更大的批处理预算)
100
101
  | `reconcile` | `--days <n>`(默认 7,上限 366)、`--from` / `--to`(UTC 日历日,裸日期含当天整天)、`--limit <n>`(1–2000)、`--json` |
101
102
  | `status` | `--diagnostics`(含路径 / 光标 / WSL·Kiro 探针)、`--json`、`--light`(无 ANSI 的 ASCII 表)、`--limits`(各家配额面板,会读本机凭据并访问厂商 API)、`--no-spinner`、`--probe-keychain` / `--probe-keychain-details`(macOS) |
102
103
  | `doctor` | `--json`、`--out <file>`、`--base-url <url>` |
103
- | `diagnostics` | `--out <file>` |
104
+ | `diagnostics` | `--out <file>`、`--compact` / `--pretty`(单行 / 缩进 JSON,默认缩进) |
104
105
  | `sessions` | `--from` / `--to`、`--format json\|csv`(或 `--csv`)、`--out <file>`(原子写,0600)、`--refresh`、`--no-git` |
105
- | `device-login` | `--json`、`--base-url <url>` |
106
+ | `device-login` | `--json`、`--base-url <url>`、`--dashboard-url <url>`、`--anon-key <key>` / `--anon-key-file <path>` |
106
107
  </details>
107
108
 
108
109
  ### 只补传积压、不重扫本地日志
@@ -200,7 +201,7 @@ CLI 未配对也能正常用,只是**降级为“只采集、不上报”**:
200
201
 
201
202
  **永不上传**:prompt / 助手正文 / 工具参数 / 命令输出 / diff / 会话标题 / 本地绝对路径 / resume 命令。测试(`test/session-upload.test.js`)用字段白名单锁定该边界。
202
203
 
203
- CLI 不发送匿名安装心跳,也不做任何第三方错误上报:上游的 `tokenusage-telemetry` 端点在自托管后端从未实现(0.2.3 移除);从未接线的 Sentry SDK 也已在 0.2.6 删除。除你自己配对的实例外,CLI 不向任何第三方发送数据。
204
+ CLI 不发送匿名安装心跳,也不做任何第三方错误上报:上游的 `tokenusage-telemetry` 端点与 Sentry SDK 均已移除。除你自己配对的实例外,CLI 不向任何第三方发送数据。
204
205
 
205
206
  ## 数据目录
206
207
 
@@ -217,9 +218,9 @@ CLI 不发送匿名安装心跳,也不做任何第三方错误上报:上游
217
218
  | `tracker/upload.throttle.json` | 上传节流状态 |
218
219
  | `tracker/logs/sync.log` | 自动采集滚动日志(JSONL) |
219
220
 
220
- 暂停标志另存。与旧版 tokentracker CLI 的 `~/.tokentracker/` 互不干扰,迁移期两套 CLI 可在同一台机器共存。
221
+ 暂停标志另存。与旧版 CLI 的 `~/.tokentracker/` 互不干扰,两套 CLI 可在同一台机器共存。
221
222
 
222
- ## 自包含运行时副本(0.2.4+)
223
+ ## 自包含运行时副本
223
224
 
224
225
  init 会把当前 CLI 及其依赖闭包复制到 `~/.tokenusage/tracker/app`,并写入
225
226
  `.runtime-ready`(版本 + 安装时间)。计划任务 / notify / hook 优先启动已安装包;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenusage-cli",
3
- "version": "0.5.5",
3
+ "version": "0.6.0",
4
4
  "description": "Self-hosted AI coding token usage collector for the Token Usage dashboard.",
5
5
  "keywords": [
6
6
  "token-usage",
package/src/cli.js CHANGED
@@ -90,6 +90,7 @@ const COMMANDS = [
90
90
  " --drain Upload the whole backlog (higher batch ceiling)",
91
91
  " --no-sessions Skip the session metadata upload (hourly buckets only)",
92
92
  " --publish-account Publish account-level sources (cursor / trae-cn) locally",
93
+ " --timing Print per-phase durations (scan / upload / sessions)",
93
94
  " --all-local-sources Scan every local source, including background-only ones",
94
95
  " --auto Auto flavor (honors pause + cloud-sync preference)",
95
96
  " --from-notify|--from-openclaw|--from-retry|--from-scheduled",
@@ -144,14 +145,28 @@ const COMMANDS = [
144
145
  {
145
146
  name: "pause",
146
147
  summary: "Stop automatic collection (manual sync still works)",
147
- run: () => cmdPause(),
148
- usage: ["tokenusage pause", "", "Writes the pause flag and stops the registered auto-sync schedule."],
148
+ run: (argv) => cmdPause(argv),
149
+ usage: [
150
+ "tokenusage pause [options]",
151
+ "",
152
+ "Writes the pause flag and stops the registered auto-sync schedule.",
153
+ "",
154
+ "Options:",
155
+ " --json Machine-readable summary",
156
+ ],
149
157
  },
150
158
  {
151
159
  name: "resume",
152
160
  summary: "Restart automatic collection",
153
- run: () => cmdResume(),
154
- usage: ["tokenusage resume", "", "Clears the pause flag and re-enables the registered auto-sync schedule."],
161
+ run: (argv) => cmdResume(argv),
162
+ usage: [
163
+ "tokenusage resume [options]",
164
+ "",
165
+ "Clears the pause flag and re-enables the registered auto-sync schedule.",
166
+ "",
167
+ "Options:",
168
+ " --json Machine-readable summary",
169
+ ],
155
170
  },
156
171
  {
157
172
  name: "status",
@@ -174,7 +189,16 @@ const COMMANDS = [
174
189
  name: "diagnostics",
175
190
  summary: "Dump a redacted environment report",
176
191
  run: (argv) => cmdDiagnostics(argv),
177
- usage: ["tokenusage diagnostics [--out <file>]", "", "Home paths are redacted to `~` before being printed."],
192
+ usage: [
193
+ "tokenusage diagnostics [options]",
194
+ "",
195
+ "Options:",
196
+ " --out <file> Also write the report to a file",
197
+ " --compact Single-line JSON (default is pretty-printed)",
198
+ " --pretty Pretty-printed JSON (the default)",
199
+ "",
200
+ "Home paths are redacted to `~` before being printed.",
201
+ ],
178
202
  },
179
203
  {
180
204
  name: "doctor",
@@ -205,6 +229,9 @@ const COMMANDS = [
205
229
  "Options:",
206
230
  " --json Machine-readable output",
207
231
  " --base-url <url> Backend to pair against",
232
+ " --dashboard-url <url> Browser dashboard the code is approved on",
233
+ " --anon-key <key> Publishable key of your self-hosted instance",
234
+ " --anon-key-file <path> Read the publishable key from a file",
208
235
  ],
209
236
  },
210
237
  {
@@ -8,6 +8,7 @@ const { readJson, updateJsonLocked } = require("../lib/fs");
8
8
  const { resolveTrackerPaths } = require("../lib/tracker-paths");
9
9
  const { resolveRuntimeConfig, assertInsforgeRuntime, normalizeInstanceBaseUrl, clearDeviceIdentity, resetInstanceState } = require("../lib/runtime-config");
10
10
  const { functionUrlFor, fetchFunctionResponse } = require("../lib/function-url");
11
+ const { parseFlags } = require("../lib/cli-flags");
11
12
 
12
13
  const POLL_INTERVAL_MS = 5_000;
13
14
  const ABSOLUTE_TIMEOUT_MS = 16 * 60 * 1000; // matches the 15-min server window with a small buffer
@@ -184,22 +185,20 @@ async function cmdDeviceLogin(argv = [], options = {}) {
184
185
  throw new Error("device-login timed out without approval");
185
186
  }
186
187
 
187
- function parseArgs(argv) {
188
- const out = { json: false, baseUrl: null, anonKey: null, anonKeyFile: null, dashboardUrl: null };
189
- for (let i = 0; i < argv.length; i++) {
190
- const a = argv[i];
191
- if (a === "--json") out.json = true;
192
- else if (a === "--base-url") {
193
- out.baseUrl = argv[++i] || null;
194
- } else if (a === "--anon-key") {
195
- out.anonKey = argv[++i] || null;
196
- } else if (a === "--anon-key-file") {
197
- out.anonKeyFile = argv[++i] || null;
198
- } else if (a === "--dashboard-url") {
199
- out.dashboardUrl = argv[++i] || null;
200
- } else throw new Error(`Unknown option: ${a}`);
201
- }
202
- return out;
188
+ const DEVICE_LOGIN_FLAGS = {
189
+ command: "device-login",
190
+ defaults: { json: false, baseUrl: null, anonKey: null, anonKeyFile: null, dashboardUrl: null },
191
+ flags: [
192
+ { flag: "--json", key: "json" },
193
+ { flag: "--base-url", key: "baseUrl", kind: "value" },
194
+ { flag: "--anon-key", key: "anonKey", kind: "value" },
195
+ { flag: "--anon-key-file", key: "anonKeyFile", kind: "value" },
196
+ { flag: "--dashboard-url", key: "dashboardUrl", kind: "value" },
197
+ ],
198
+ };
199
+
200
+ function parseArgs(argv = []) {
201
+ return parseFlags(argv, DEVICE_LOGIN_FLAGS);
203
202
  }
204
203
 
205
- module.exports = { cmdDeviceLogin, authorize, pollOnce };
204
+ module.exports = { cmdDeviceLogin, authorize, pollOnce, parseArgs, flagSpec: DEVICE_LOGIN_FLAGS };
@@ -2,6 +2,7 @@ const path = require("node:path");
2
2
 
3
3
  const { writeFileAtomic, chmod600IfPossible } = require("../lib/fs");
4
4
  const { collectTrackerDiagnostics } = require("../lib/diagnostics");
5
+ const { parseFlags } = require("../lib/cli-flags");
5
6
 
6
7
  async function cmdDiagnostics(argv = []) {
7
8
  const opts = parseArgs(argv);
@@ -18,21 +19,20 @@ async function cmdDiagnostics(argv = []) {
18
19
  process.stdout.write(json);
19
20
  }
20
21
 
21
- function parseArgs(argv) {
22
- const out = {
23
- out: null,
24
- compact: false,
25
- };
26
-
27
- for (let i = 0; i < argv.length; i++) {
28
- const a = argv[i];
29
- if (a === "--out") out.out = argv[++i] || null;
30
- else if (a === "--compact") out.compact = true;
31
- else if (a === "--pretty") out.compact = false;
32
- else throw new Error(`Unknown option: ${a}`);
33
- }
34
-
35
- return out;
22
+ // `--compact` / `--pretty` were accepted but undocumented; the spec below is
23
+ // the single source `tokenusage diagnostics --help` and the surface test read.
24
+ const DIAGNOSTICS_FLAGS = {
25
+ command: "diagnostics",
26
+ defaults: { out: null, compact: false },
27
+ flags: [
28
+ { flag: "--out", key: "out", kind: "value" },
29
+ { flag: "--compact", key: "compact" },
30
+ { flag: "--pretty", key: "compact", const: false },
31
+ ],
32
+ };
33
+
34
+ function parseArgs(argv = []) {
35
+ return parseFlags(argv, DIAGNOSTICS_FLAGS);
36
36
  }
37
37
 
38
- module.exports = { cmdDiagnostics };
38
+ module.exports = { cmdDiagnostics, parseArgs, flagSpec: DIAGNOSTICS_FLAGS };
@@ -9,6 +9,7 @@ const { resolveDeviceTokenPresence } = require("../lib/cloud-device-token");
9
9
  const { resolveLocalDeviceIdentity } = require("../lib/device-identity");
10
10
  const { buildDoctorReport } = require("../lib/doctor");
11
11
  const { inspectAutoSyncSchedule } = require("../lib/scheduled-task");
12
+ const { parseFlags } = require("../lib/cli-flags");
12
13
 
13
14
  async function cmdDoctor(argv = []) {
14
15
  const opts = parseArgs(argv);
@@ -88,16 +89,18 @@ async function cmdDoctor(argv = []) {
88
89
  }
89
90
  }
90
91
 
91
- function parseArgs(argv) {
92
- const out = { json: false, out: null, baseUrl: null };
93
- for (let i = 0; i < argv.length; i += 1) {
94
- const arg = argv[i];
95
- if (arg === "--json") out.json = true;
96
- else if (arg === "--out") out.out = argv[++i] || null;
97
- else if (arg === "--base-url") out.baseUrl = argv[++i] || null;
98
- else throw new Error(`Unknown option: ${arg}`);
99
- }
100
- return out;
92
+ const DOCTOR_FLAGS = {
93
+ command: "doctor",
94
+ defaults: { json: false, out: null, baseUrl: null },
95
+ flags: [
96
+ { flag: "--json", key: "json" },
97
+ { flag: "--out", key: "out", kind: "value" },
98
+ { flag: "--base-url", key: "baseUrl", kind: "value" },
99
+ ],
100
+ };
101
+
102
+ function parseArgs(argv = []) {
103
+ return parseFlags(argv, DOCTOR_FLAGS);
101
104
  }
102
105
 
103
106
  function renderHumanReport(report) {
@@ -125,4 +128,4 @@ function isPlainObject(value) {
125
128
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
126
129
  }
127
130
 
128
- module.exports = { cmdDoctor };
131
+ module.exports = { cmdDoctor, parseArgs, flagSpec: DOCTOR_FLAGS };
@@ -20,14 +20,37 @@ const {
20
20
  setAutoSyncEnabled,
21
21
  formatScheduleToggle,
22
22
  } = require("../lib/scheduled-task");
23
+ const { parseFlags } = require("../lib/cli-flags");
23
24
 
24
- async function cmdPause() {
25
+ // pause/resume used to receive no argv at all, so `tokenusage pause --json`
26
+ // (or any typo) silently paused collection and exited 0 — the one command
27
+ // where a surprise state change is worst. `--json` is the only accepted flag;
28
+ // every other command already offers it for script consumption.
29
+ const PAUSE_FLAGS = {
30
+ command: "pause",
31
+ defaults: { json: false },
32
+ flags: [{ flag: "--json", key: "json" }],
33
+ };
34
+
35
+ function parseArgs(argv = [], command = "pause") {
36
+ return parseFlags(argv, { ...PAUSE_FLAGS, command });
37
+ }
38
+
39
+ async function cmdPause(argv = []) {
40
+ const opts = parseArgs(argv, "pause");
25
41
  const { trackerDir } = await resolveTrackerPaths({ home: os.homedir() });
26
42
  const alreadyPaused = isCollectionPaused(trackerDir);
27
43
 
28
44
  await setCollectionPaused(trackerDir, true);
29
45
  const schedule = setAutoSyncEnabled(false);
30
46
 
47
+ if (opts.json) {
48
+ process.stdout.write(
49
+ `${JSON.stringify({ ok: true, paused: true, already_paused: alreadyPaused, schedule })}\n`,
50
+ );
51
+ return;
52
+ }
53
+
31
54
  process.stdout.write(
32
55
  [
33
56
  "Collection paused.",
@@ -42,13 +65,21 @@ async function cmdPause() {
42
65
  );
43
66
  }
44
67
 
45
- async function cmdResume() {
68
+ async function cmdResume(argv = []) {
69
+ const opts = parseArgs(argv, "resume");
46
70
  const { trackerDir } = await resolveTrackerPaths({ home: os.homedir() });
47
71
  const wasPaused = isCollectionPaused(trackerDir);
48
72
 
49
73
  await setCollectionPaused(trackerDir, false);
50
74
  const schedule = setAutoSyncEnabled(true);
51
75
 
76
+ if (opts.json) {
77
+ process.stdout.write(
78
+ `${JSON.stringify({ ok: true, paused: false, was_paused: wasPaused, schedule })}\n`,
79
+ );
80
+ return;
81
+ }
82
+
52
83
  process.stdout.write(
53
84
  [
54
85
  "Collection resumed.",
@@ -62,4 +93,4 @@ async function cmdResume() {
62
93
  );
63
94
  }
64
95
 
65
- module.exports = { cmdPause, cmdResume };
96
+ module.exports = { cmdPause, cmdResume, parseArgs, flagSpec: PAUSE_FLAGS };
@@ -59,13 +59,13 @@ async function resolveCredentials({ home }) {
59
59
  }
60
60
  }
61
61
 
62
- return { baseUrl, deviceToken };
62
+ return { baseUrl, deviceToken, httpTimeoutMs: runtime.httpTimeoutMs };
63
63
  }
64
64
 
65
65
  async function cmdProjectProfiles(argv = [], context = {}) {
66
66
  parseArgs(argv);
67
67
  const home = context.home || os.homedir();
68
- const { baseUrl, deviceToken } = await resolveCredentials({ home });
68
+ const { baseUrl, deviceToken, httpTimeoutMs } = await resolveCredentials({ home });
69
69
 
70
70
  if (!baseUrl || !deviceToken) {
71
71
  throw new UsageError("This machine is not paired yet.", {
@@ -75,6 +75,9 @@ async function cmdProjectProfiles(argv = [], context = {}) {
75
75
  }
76
76
 
77
77
  const res = await fetchFunctionResponse(functionUrlFor(baseUrl, SLUG), {
78
+ // The desktop blocks on this call: without a timeout a half-open network
79
+ // would hang the panel until the process is killed.
80
+ ...(httpTimeoutMs > 0 ? { signal: AbortSignal.timeout(httpTimeoutMs) } : {}),
78
81
  headers: {
79
82
  Accept: "application/json",
80
83
  Authorization: `Bearer ${deviceToken}`,
@@ -8,41 +8,29 @@
8
8
  // exporting the wrong shape to the wrong file.
9
9
 
10
10
  const { writeFileAtomic } = require("../lib/fs");
11
- const { UsageError, unknownOptionError } = require("../lib/cli-errors");
11
+ const { UsageError } = require("../lib/cli-errors");
12
+ const { parseFlags } = require("../lib/cli-flags");
12
13
  const { buildSessionAnalytics, summarizeSessions, sessionsToCsv } = require("../lib/session-analytics");
13
14
  const { buildGitOutcomes } = require("../lib/git-outcomes");
14
15
 
15
16
  const FORMATS = new Set(["json", "csv"]);
16
- const VALUE_FLAGS = new Set(["--format", "--out", "--from", "--to"]);
17
- const BOOLEAN_FLAGS = new Set(["--csv", "--refresh", "--no-git"]);
17
+
18
+ const SESSIONS_FLAGS = {
19
+ command: "sessions",
20
+ defaults: { format: null, out: null, from: null, to: null, refresh: false, git: true },
21
+ flags: [
22
+ { flag: "--format", key: "format", kind: "value", parse: (raw) => String(raw).trim().toLowerCase() },
23
+ { flag: "--out", key: "out", kind: "value" },
24
+ { flag: "--from", key: "from", kind: "value" },
25
+ { flag: "--to", key: "to", kind: "value" },
26
+ { flag: "--csv", key: "format", const: "csv" },
27
+ { flag: "--refresh", key: "refresh" },
28
+ { flag: "--no-git", key: "git", const: false },
29
+ ],
30
+ };
18
31
 
19
32
  function parseArgs(args = []) {
20
- const out = { format: null, out: null, from: null, to: null, refresh: false, git: true };
21
- for (let i = 0; i < args.length; i++) {
22
- const a = args[i];
23
- if (VALUE_FLAGS.has(a)) {
24
- const value = args[i + 1];
25
- if (value == null || value === "" || value.startsWith("--")) {
26
- throw new UsageError(`${a} requires a value`, {
27
- code: "MISSING_VALUE",
28
- hint: "Run `tokenusage sessions --help` for supported options.",
29
- });
30
- }
31
- i += 1;
32
- if (a === "--format") out.format = value.trim().toLowerCase();
33
- else if (a === "--out") out.out = value;
34
- else if (a === "--from") out.from = value;
35
- else out.to = value;
36
- continue;
37
- }
38
- if (BOOLEAN_FLAGS.has(a)) {
39
- if (a === "--csv") out.format = "csv";
40
- else if (a === "--refresh") out.refresh = true;
41
- else out.git = false;
42
- continue;
43
- }
44
- throw unknownOptionError(a, "sessions");
45
- }
33
+ const out = parseFlags(args, SESSIONS_FLAGS);
46
34
  if (out.format == null) out.format = "json";
47
35
  if (!FORMATS.has(out.format)) {
48
36
  throw new UsageError(`Unknown --format: ${out.format}`, {
@@ -69,4 +57,4 @@ async function cmdSessions(args = []) {
69
57
  }
70
58
  }
71
59
 
72
- module.exports = { cmdSessions, parseArgs };
60
+ module.exports = { cmdSessions, parseArgs, flagSpec: SESSIONS_FLAGS };
@@ -6,6 +6,7 @@ const pkg = require("../../package.json");
6
6
  const { resolveDumateDbPaths } = require("../lib/dumate");
7
7
 
8
8
  const { readJson } = require("../lib/fs");
9
+ const { parseFlags } = require("../lib/cli-flags");
9
10
  const { readCursorStateSummary } = require("../lib/cursor-store");
10
11
  const {
11
12
  readCodexNotify,
@@ -1640,6 +1641,8 @@ const USAGE_LIMIT_PROVIDERS = [
1640
1641
  ["opencodeGo", "OpenCode Go"],
1641
1642
  ["commandCode", "CommandCode"],
1642
1643
  ["devin", "Devin"],
1644
+ ["workbuddy", "WorkBuddy"],
1645
+ ["workbuddyAi", "WorkBuddy AI"],
1643
1646
  ["qoder", "Qoder"],
1644
1647
  ["qoderCn", "Qoder CN"],
1645
1648
  ["codingPlan", "Ark Coding Plan"],
@@ -1725,8 +1728,9 @@ function formatUsageLimitRows(limits) {
1725
1728
  return rows;
1726
1729
  }
1727
1730
 
1728
- function parseArgs(argv) {
1729
- const out = {
1731
+ const STATUS_FLAGS = {
1732
+ command: "status",
1733
+ defaults: {
1730
1734
  diagnostics: false,
1731
1735
  json: false,
1732
1736
  light: false,
@@ -1734,21 +1738,22 @@ function parseArgs(argv) {
1734
1738
  noSpinner: false,
1735
1739
  probeKeychain: false,
1736
1740
  probeKeychainDetails: false,
1737
- };
1741
+ },
1742
+ flags: [
1743
+ { flag: "--diagnostics", key: "diagnostics" },
1744
+ { flag: "--json", key: "json" },
1745
+ { flag: "--light", key: "light" },
1746
+ { flag: "--limits", key: "limits" },
1747
+ { flag: "--no-spinner", key: "noSpinner" },
1748
+ { flag: "--probe-keychain", key: "probeKeychain" },
1749
+ { flag: "--probe-keychain-details", key: "probeKeychainDetails" },
1750
+ ],
1751
+ };
1738
1752
 
1739
- for (let i = 0; i < argv.length; i++) {
1740
- const a = argv[i];
1741
- if (a === "--diagnostics") out.diagnostics = true;
1742
- else if (a === "--json") out.json = true;
1743
- else if (a === "--light") out.light = true;
1744
- else if (a === "--limits") out.limits = true;
1745
- else if (a === "--no-spinner") out.noSpinner = true;
1746
- else if (a === "--probe-keychain") out.probeKeychain = true;
1747
- else if (a === "--probe-keychain-details") {
1748
- out.probeKeychainDetails = true;
1749
- out.probeKeychain = true;
1750
- } else throw new Error(`Unknown option: ${a}`);
1751
- }
1753
+ function parseArgs(argv = []) {
1754
+ const out = parseFlags(argv, STATUS_FLAGS);
1755
+ // `--probe-keychain-details` implies the base probe (unchanged behavior).
1756
+ if (out.probeKeychainDetails) out.probeKeychain = true;
1752
1757
 
1753
1758
  return out;
1754
1759
  }
@@ -1900,6 +1905,7 @@ function parseEpochMsToIso(v) {
1900
1905
 
1901
1906
  module.exports = {
1902
1907
  cmdStatus,
1908
+ flagSpec: STATUS_FLAGS,
1903
1909
  formatUsageLimitRows,
1904
1910
  parseArgs,
1905
1911
  renderLightTable,