ccclub 0.2.80 → 0.2.81

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.
Files changed (2) hide show
  1. package/dist/index.js +29 -32
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -452,45 +452,42 @@ async function fetchUsageLimits() {
452
452
  debug("returning null: token expired at", expiresAt);
453
453
  return null;
454
454
  }
455
- const curlCmd = `curl -sf --max-time 8 "https://api.anthropic.com/api/oauth/usage" -H "Authorization: Bearer ${accessToken}" -H "anthropic-beta: oauth-2025-04-20" -H "User-Agent: claude-code/2.1.5"`;
455
+ const curlCmd = `curl -s --max-time 8 "https://api.anthropic.com/api/oauth/usage" -H "Authorization: Bearer ${accessToken}" -H "anthropic-beta: oauth-2025-04-20" -H "User-Agent: claude-code/2.1.5"`;
456
456
  debug("running curl...");
457
457
  const { stdout: stdout5 } = await execAsync(curlCmd, { timeout: 9e3 });
458
458
  debug("curl stdout length:", stdout5.length, "first 100:", stdout5.slice(0, 100));
459
- if (!stdout5) {
460
- debug("returning null: empty stdout");
461
- return null;
462
- }
463
- const data = JSON.parse(stdout5);
464
- if (data.error) {
465
- debug("returning null: data.error =", data.error);
466
- return null;
467
- }
468
- const fiveHourRaw = data.five_hour?.utilization;
469
- const sevenDayRaw = data.seven_day?.utilization;
470
- const result = {
471
- fiveHour: parseUtilization(fiveHourRaw),
472
- sevenDay: parseUtilization(sevenDayRaw),
473
- snapshotAt: (/* @__PURE__ */ new Date()).toISOString()
474
- };
475
- debug("returning snapshot:", result.fiveHour, result.sevenDay);
476
- writeCache(result);
477
- return result;
478
- } catch (err) {
479
- debug("caught error:", err instanceof Error ? err.message : String(err));
480
- try {
481
- const tmp = JSON.parse(readFileSync2("/tmp/sl-claude-usage", "utf-8"));
482
- if (typeof tmp.fiveHour === "number" && typeof tmp.sevenDay === "number") {
483
- const result = { fiveHour: tmp.fiveHour, sevenDay: tmp.sevenDay, snapshotAt: (/* @__PURE__ */ new Date()).toISOString() };
484
- debug("returning cc-costline cache fallback:", result.fiveHour, result.sevenDay);
459
+ if (stdout5) {
460
+ const data = JSON.parse(stdout5);
461
+ if (!data.error) {
462
+ const fiveHourRaw = data.five_hour?.utilization;
463
+ const sevenDayRaw = data.seven_day?.utilization;
464
+ const result = {
465
+ fiveHour: parseUtilization(fiveHourRaw),
466
+ sevenDay: parseUtilization(sevenDayRaw),
467
+ snapshotAt: (/* @__PURE__ */ new Date()).toISOString()
468
+ };
469
+ debug("returning snapshot:", result.fiveHour, result.sevenDay);
485
470
  writeCache(result);
486
471
  return result;
487
472
  }
488
- } catch {
473
+ debug("API error response:", data.error);
489
474
  }
490
- const stale = readCache(true);
491
- if (stale) debug("returning stale cache as fallback:", stale.fiveHour, stale.sevenDay);
492
- return stale;
475
+ } catch (err) {
476
+ debug("caught error:", err instanceof Error ? err.message : String(err));
477
+ }
478
+ try {
479
+ const tmp = JSON.parse(readFileSync2("/tmp/sl-claude-usage", "utf-8"));
480
+ if (typeof tmp.fiveHour === "number" && typeof tmp.sevenDay === "number") {
481
+ const result = { fiveHour: tmp.fiveHour, sevenDay: tmp.sevenDay, snapshotAt: (/* @__PURE__ */ new Date()).toISOString() };
482
+ debug("returning cc-costline cache fallback:", result.fiveHour, result.sevenDay);
483
+ writeCache(result);
484
+ return result;
485
+ }
486
+ } catch {
493
487
  }
488
+ const stale = readCache(true);
489
+ if (stale) debug("returning stale cache as fallback:", stale.fiveHour, stale.sevenDay);
490
+ return stale;
494
491
  }
495
492
 
496
493
  // src/commands/sync.ts
@@ -1397,7 +1394,7 @@ async function hookCommand() {
1397
1394
  }
1398
1395
 
1399
1396
  // src/index.ts
1400
- var VERSION = "0.2.80";
1397
+ var VERSION = "0.2.81";
1401
1398
  startUpdateCheck(VERSION);
1402
1399
  var program = new Command();
1403
1400
  program.name("ccclub").description("Claude Code leaderboard among friends").version(VERSION, "-v, -V, --version");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccclub",
3
- "version": "0.2.80",
3
+ "version": "0.2.81",
4
4
  "type": "module",
5
5
  "description": "Claude Code leaderboard among friends",
6
6
  "bin": {