@openxiaobu/codexl 0.1.3 → 0.1.5

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
@@ -10,7 +10,7 @@
10
10
  - Manage multiple accounts or workspaces as separate slots
11
11
  - Fetch the latest usage from the official usage endpoint
12
12
  - Expose a local provider endpoint for Codex
13
- - Apply local cooldown rules for temporary, 5-hour, and weekly limits
13
+ - Apply local block rules for temporary, 5-hour, and weekly limits
14
14
  - Automatically switch `~/.codex/config.toml` to the `codexl` provider while the local proxy is running
15
15
 
16
16
  ## Installation
package/dist/cli.js CHANGED
@@ -13,6 +13,27 @@ const config_1 = require("./config");
13
13
  const login_1 = require("./login");
14
14
  const status_1 = require("./status");
15
15
  const usage_sync_1 = require("./usage-sync");
16
+ /**
17
+ * 读取当前 CLI 的发布版本号,优先与 npm 包元数据保持一致。
18
+ *
19
+ * @returns string,当前包版本号;当 package.json 不可读或字段缺失时返回 `0.0.0`。
20
+ * @throws 无显式抛出;内部异常会被吞掉并回退到默认版本号。
21
+ */
22
+ function getCliVersion() {
23
+ try {
24
+ const packageJsonPath = node_path_1.default.resolve(__dirname, "../package.json");
25
+ // 直接读取发布包内的 package.json,避免 CLI 版本号与 npm 发布版本脱节。
26
+ const packageJsonContent = node_fs_1.default.readFileSync(packageJsonPath, "utf8");
27
+ const packageJson = JSON.parse(packageJsonContent);
28
+ if (typeof packageJson.version === "string" && packageJson.version.trim().length > 0) {
29
+ return packageJson.version;
30
+ }
31
+ }
32
+ catch {
33
+ // 读取失败时使用保底版本,避免 `-V` 命令直接异常退出。
34
+ }
35
+ return "0.0.0";
36
+ }
16
37
  /**
17
38
  * 刷新所有已录入账号的远端额度,并输出最新状态表格。
18
39
  *
@@ -23,10 +44,10 @@ async function handleStatus() {
23
44
  const statuses = (0, status_1.collectAccountStatuses)();
24
45
  console.log((0, status_1.renderStatusTable)(statuses));
25
46
  const available = statuses.filter((item) => item.isAvailable).length;
26
- const cooldown = statuses.filter((item) => item.isFiveHourLimited && !item.isWeeklyLimited).length;
47
+ const fiveHourLimited = statuses.filter((item) => item.isFiveHourLimited && !item.isWeeklyLimited).length;
27
48
  const weeklyLimited = statuses.filter((item) => item.isWeeklyLimited).length;
28
49
  console.log("");
29
- console.log(`available=${available} cooldown=${cooldown} weekly_limited=${weeklyLimited}`);
50
+ console.log(`available=${available} 5h_limited=${fiveHourLimited} weekly_limited=${weeklyLimited}`);
30
51
  }
31
52
  /**
32
53
  * 将已有的 Codex HOME 目录中的登录态复制到 codexl 自己的隔离目录并纳入管理。
@@ -296,7 +317,7 @@ async function main() {
296
317
  program
297
318
  .name("codexl")
298
319
  .description("本地 Codex 多账号切换与状态管理工具")
299
- .version("0.1.2");
320
+ .version(getCliVersion());
300
321
  program
301
322
  .command("add")
302
323
  .description("登录并新增一个账号或工作空间")
package/dist/status.js CHANGED
@@ -100,7 +100,7 @@ function renderStatusTable(statuses) {
100
100
  status = "weekly_limited";
101
101
  }
102
102
  else if (item.isFiveHourLimited) {
103
- status = "cooldown";
103
+ status = "5h_limited";
104
104
  }
105
105
  else if (item.isAvailable) {
106
106
  status = "available";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openxiaobu/codexl",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "本地 Codex 多账号切换与状态管理工具",
5
5
  "type": "commonjs",
6
6
  "main": "dist/cli.js",