numable-codex-usage 0.1.0 → 0.1.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Codex 用量采集器
2
2
 
3
- 在电脑上统计 Codex 用量,并按需同步到 Numable。首发版本为 `0.1.0`;各平台验证范围见文末兼容矩阵。
3
+ 在电脑上统计 Codex 用量,并按需同步到 Numable。当前版本为 `0.1.1`;各平台验证范围见文末兼容矩阵。
4
4
 
5
5
  需要 Node.js 18.17 或以上;建议使用当前长期支持版本。采集器不假设 Codex 自带可供外部使用的 Node.js。
6
6
 
@@ -54,6 +54,20 @@ node codex/cli.cjs quota-auto-on
54
54
 
55
55
  主动读取通过本机 Codex 协议完成,不创建会话,不要求复制 OpenAI 登录凭证。账号标识在本机匿名化;加入同一空间后使用空间范围的匿名标识,以便服务端合并同账号多台电脑的额度。不能识别账号的日志快照按设备分别展示。
56
56
 
57
+ 0.1.1 的 `init` 在首次配置或旧版未设置时开启每五分钟只读额度检查;明确执行过 `quota-auto-off` 的选择保持不变。初始化本身不启动协议读取或后台进程,也不自动上传历史。
58
+
59
+ 从0.1.0升级后,请运行以下命令;已运行的后台进程必须重启才能使用新版本:
60
+
61
+ ```sh
62
+ npm install -g numable-codex-usage@0.1.1
63
+ numable-codex stop
64
+ numable-codex init
65
+ numable-codex start
66
+ numable-codex status
67
+ ```
68
+
69
+ `status` 会显示 `quotaAuto`、`quotaStatus` 和开启指引;如需主动开启,可运行 `numable-codex quota-auto-on`。额度观测超过15分钟或窗口到期后,页面只保留带过期标识的上次值,不将其当作当前额度。电脑休眠、离线、采集停止或读取失败均可能导致观测过期。
70
+
57
71
  `quota-auto-on` 显式开启每五分钟读取,需后台采集运行;`quota-auto-off` 关闭。多个目录分别连接,单个目录失败会保留其旧观测并标注不完整。macOS 的命令行启动器不可用时,会尝试已安装桌面端的内置可执行文件;也可显式指定路径。
58
72
 
59
73
  ## 手机同步
package/cli.cjs CHANGED
@@ -270,7 +270,12 @@ async function main(argv = process.argv.slice(2)) {
270
270
  process.stdout.write('{}\n');
271
271
  return;
272
272
  }
273
- if (args.command === 'init') { await saveConfig(p, config); output('本机采集已初始化,手机同步尚未开启'); return; }
273
+ if (args.command === 'init') {
274
+ // 首次配置或旧版未设置时启用只读额度检查,保留用户明确关闭的选择。
275
+ if (typeof read(p.config, {}).quotaAuto !== 'boolean') config.quotaAuto = true;
276
+ await saveConfig(p, config);
277
+ output(`本机采集已初始化;手机同步${config.sync ? '已开启' : '尚未开启'}。${config.quotaAuto ? '已启用每五分钟只读额度检查,运行 start 保持后台采集;可用 quota-auto-off 关闭' : '额度自动读取已关闭;可用 quota-auto-on 开启'}`); return;
278
+ }
274
279
  if (args.command === 'collect') {
275
280
  if (args.hookWorker) {
276
281
  let release;
@@ -321,7 +326,7 @@ async function main(argv = process.argv.slice(2)) {
321
326
  if (args.command === 'status') {
322
327
  const snapshot = read(p.snapshot, null);
323
328
  output({ initialized: fs.existsSync(p.config), sync: config.sync, paired: !!config.writeToken, live: config.live,
324
- quotaAuto: config.quotaAuto === true, quotaStatus: config.quotaStatus || null, syncError: config.syncError || null,
329
+ quotaAuto: config.quotaAuto === true, quotaHint: config.quotaAuto ? '请保持后台采集运行;读取失败时检查 Codex 登录状态' : '运行 numable-codex quota-auto-on,再运行 numable-codex start', quotaStatus: config.quotaStatus || null, syncError: config.syncError || null,
325
330
  collectedAt: snapshot?.collectedAt || null, timezone: config.timezone, projects: config.projects,
326
331
  coverage: snapshot?.coverage || [], diagnostics: snapshot?.diagnostics || null, collection: snapshot?.collection || null,
327
332
  hooksInstalled: !!config.installed?.length, hooksTrust: config.installed?.length ? 'check-in-codex' : null });
package/lib/quota.cjs CHANGED
@@ -46,7 +46,7 @@ function readQuota({ binary = process.env.NUMABLE_CODEX_BINARY || 'codex', home,
46
46
  finish(null, { observedAt, scope: hash(salt, 'quota-scope'), supported: quotas.length > 0, quotas });
47
47
  }
48
48
  });
49
- send({ id: 1, method: 'initialize', params: { clientInfo: { name: 'numable_codex_usage', version: '0.1.0' }, capabilities: { experimentalApi: true } } });
49
+ send({ id: 1, method: 'initialize', params: { clientInfo: { name: 'numable_codex_usage', version: '0.1.1' }, capabilities: { experimentalApi: true } } });
50
50
  });
51
51
  }
52
52
  async function readQuotaHomes({ homes, salt, profileSalt = salt, previous, ...options }) {
package/package.json CHANGED
@@ -1,10 +1,20 @@
1
1
  {
2
2
  "name": "numable-codex-usage",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "在本机统计 Codex 用量,并按需同步到 Numable",
5
5
  "license": "MIT",
6
- "engines": { "node": ">=18.17" },
7
- "bin": { "numable-codex": "cli.cjs" },
8
- "files": ["cli.cjs", "lib/", "README.md"],
9
- "scripts": { "test": "node --test ../test/codex-*.test.cjs" }
6
+ "engines": {
7
+ "node": ">=18.17"
8
+ },
9
+ "bin": {
10
+ "numable-codex": "cli.cjs"
11
+ },
12
+ "files": [
13
+ "cli.cjs",
14
+ "lib/",
15
+ "README.md"
16
+ ],
17
+ "scripts": {
18
+ "test": "node --test ../test/codex-*.test.cjs"
19
+ }
10
20
  }