ccstatusline 2.2.16 → 2.2.17

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.
@@ -56039,16 +56039,26 @@ function getTTYForProcess(pid) {
56039
56039
  }
56040
56040
  }
56041
56041
  function getWidthForTTY(tty2) {
56042
- try {
56043
- const width = execSync(`stty size < /dev/${tty2} | awk '{print $2}'`, {
56044
- encoding: "utf8",
56045
- stdio: ["pipe", "pipe", "ignore"],
56046
- shell: "/bin/sh"
56047
- }).trim();
56048
- return parsePositiveInteger(width);
56049
- } catch {
56050
- return null;
56042
+ const devicePath = `/dev/${tty2}`;
56043
+ const attempts = [
56044
+ `stty -F ${devicePath} size`,
56045
+ `stty -f ${devicePath} size`,
56046
+ `stty size < ${devicePath}`
56047
+ ];
56048
+ for (const cmd of attempts) {
56049
+ try {
56050
+ const width = execSync(`${cmd} 2>/dev/null | awk '{print $2}'`, {
56051
+ encoding: "utf8",
56052
+ stdio: ["pipe", "pipe", "ignore"],
56053
+ shell: "/bin/sh"
56054
+ }).trim();
56055
+ const parsed = parsePositiveInteger(width);
56056
+ if (parsed !== null) {
56057
+ return parsed;
56058
+ }
56059
+ } catch {}
56051
56060
  }
56061
+ return null;
56052
56062
  }
56053
56063
  function getTerminalWidth() {
56054
56064
  return probeTerminalWidth();
@@ -56056,7 +56066,7 @@ function getTerminalWidth() {
56056
56066
  function canDetectTerminalWidth() {
56057
56067
  return probeTerminalWidth() !== null;
56058
56068
  }
56059
- var __dirname = "/home/runner/work/ccstatusline/ccstatusline/src/utils", PACKAGE_VERSION = "2.2.16";
56069
+ var __dirname = "/home/runner/work/ccstatusline/ccstatusline/src/utils", PACKAGE_VERSION = "2.2.17";
56060
56070
  var init_terminal = () => {};
56061
56071
 
56062
56072
  // src/utils/renderer.ts
@@ -59430,6 +59440,9 @@ import * as fs3 from "fs";
59430
59440
  import * as https from "https";
59431
59441
  import * as os4 from "os";
59432
59442
  import * as path3 from "path";
59443
+ function getUsageApiBucketUtilization(bucket) {
59444
+ return bucket === null ? 0 : bucket?.utilization ?? undefined;
59445
+ }
59433
59446
  function parseJsonWithSchema(rawJson, schema) {
59434
59447
  try {
59435
59448
  const parsed = schema.safeParse(JSON.parse(rawJson));
@@ -59470,13 +59483,13 @@ function parseUsageApiResponse(rawJson) {
59470
59483
  return null;
59471
59484
  }
59472
59485
  return {
59473
- sessionUsage: parsed.five_hour?.utilization ?? undefined,
59486
+ sessionUsage: getUsageApiBucketUtilization(parsed.five_hour),
59474
59487
  sessionResetAt: parsed.five_hour?.resets_at ?? undefined,
59475
- weeklyUsage: parsed.seven_day?.utilization ?? undefined,
59488
+ weeklyUsage: getUsageApiBucketUtilization(parsed.seven_day),
59476
59489
  weeklyResetAt: parsed.seven_day?.resets_at ?? undefined,
59477
- weeklySonnetUsage: parsed.seven_day_sonnet === null ? 0 : parsed.seven_day_sonnet?.utilization ?? undefined,
59490
+ weeklySonnetUsage: getUsageApiBucketUtilization(parsed.seven_day_sonnet),
59478
59491
  weeklySonnetResetAt: parsed.seven_day_sonnet?.resets_at ?? undefined,
59479
- weeklyOpusUsage: parsed.seven_day_opus === null ? 0 : parsed.seven_day_opus?.utilization ?? undefined,
59492
+ weeklyOpusUsage: getUsageApiBucketUtilization(parsed.seven_day_opus),
59480
59493
  weeklyOpusResetAt: parsed.seven_day_opus?.resets_at ?? undefined,
59481
59494
  extraUsageEnabled: parsed.extra_usage?.is_enabled ?? undefined,
59482
59495
  extraUsageLimit: parsed.extra_usage?.monthly_limit ?? undefined,
@@ -59801,9 +59814,11 @@ async function fetchUsageData(options = {}) {
59801
59814
  }
59802
59815
  const usageData = parseUsageApiResponse(response.body);
59803
59816
  if (!usageData) {
59817
+ writeUsageLock(now2 + LOCK_MAX_AGE, "parse-error");
59804
59818
  return getStaleUsageOrError("parse-error", now2, LOCK_MAX_AGE, requiredFields);
59805
59819
  }
59806
59820
  if (usageData.sessionUsage === undefined && usageData.weeklyUsage === undefined) {
59821
+ writeUsageLock(now2 + LOCK_MAX_AGE, "parse-error");
59807
59822
  return getStaleUsageOrError("parse-error", now2, LOCK_MAX_AGE, requiredFields);
59808
59823
  }
59809
59824
  try {
@@ -59812,10 +59827,11 @@ async function fetchUsageData(options = {}) {
59812
59827
  } catch {}
59813
59828
  return cacheUsageData(usageData, now2);
59814
59829
  } catch {
59830
+ writeUsageLock(now2 + LOCK_MAX_AGE, "parse-error");
59815
59831
  return getStaleUsageOrError("parse-error", now2, LOCK_MAX_AGE, requiredFields);
59816
59832
  }
59817
59833
  }
59818
- var CACHE_DIR, CACHE_FILE, LOCK_FILE, CACHE_MAX_AGE = 180, LOCK_MAX_AGE = 30, DEFAULT_RATE_LIMIT_BACKOFF = 300, MACOS_USAGE_CREDENTIALS_SERVICE = "Claude Code-credentials", MACOS_SECURITY_DUMP_MAX_BUFFER, UsageCredentialsSchema, UsageLockErrorSchema, UsageLockSchema, CachedUsageDataSchema, PerModelWeeklyBucketSchema, UsageApiResponseSchema, cachedUsageData = null, usageCacheTime = 0, usageErrorCacheMaxAge, USAGE_API_HOST = "api.anthropic.com", USAGE_API_PATH = "/api/oauth/usage", USAGE_API_TIMEOUT_MS = 5000;
59834
+ var CACHE_DIR, CACHE_FILE, LOCK_FILE, CACHE_MAX_AGE = 180, LOCK_MAX_AGE = 30, DEFAULT_RATE_LIMIT_BACKOFF = 300, MACOS_USAGE_CREDENTIALS_SERVICE = "Claude Code-credentials", MACOS_SECURITY_DUMP_MAX_BUFFER, UsageCredentialsSchema, UsageLockErrorSchema, UsageLockSchema, CachedUsageDataSchema, UsageApiBucketSchema, UsageApiResponseSchema, cachedUsageData = null, usageCacheTime = 0, usageErrorCacheMaxAge, USAGE_API_HOST = "api.anthropic.com", USAGE_API_PATH = "/api/oauth/usage", USAGE_API_TIMEOUT_MS = 5000;
59819
59835
  var init_usage_fetch = __esm(async () => {
59820
59836
  init_dist5();
59821
59837
  init_zod();
@@ -59826,7 +59842,7 @@ var init_usage_fetch = __esm(async () => {
59826
59842
  LOCK_FILE = path3.join(CACHE_DIR, "usage.lock");
59827
59843
  MACOS_SECURITY_DUMP_MAX_BUFFER = 8 * 1024 * 1024;
59828
59844
  UsageCredentialsSchema = exports_external.object({ claudeAiOauth: exports_external.object({ accessToken: exports_external.string().nullable().optional() }).optional() });
59829
- UsageLockErrorSchema = exports_external.enum(["timeout", "rate-limited"]);
59845
+ UsageLockErrorSchema = exports_external.enum(["timeout", "rate-limited", "parse-error"]);
59830
59846
  UsageLockSchema = exports_external.object({
59831
59847
  blockedUntil: exports_external.number(),
59832
59848
  error: UsageLockErrorSchema.optional()
@@ -59846,27 +59862,21 @@ var init_usage_fetch = __esm(async () => {
59846
59862
  extraUsageUtilization: exports_external.number().nullable().optional(),
59847
59863
  error: exports_external.string().nullable().optional()
59848
59864
  });
59849
- PerModelWeeklyBucketSchema = exports_external.object({
59865
+ UsageApiBucketSchema = exports_external.looseObject({
59850
59866
  utilization: exports_external.number().nullable().optional(),
59851
59867
  resets_at: exports_external.string().nullable().optional()
59852
59868
  }).nullable().optional();
59853
- UsageApiResponseSchema = exports_external.object({
59854
- five_hour: exports_external.object({
59855
- utilization: exports_external.number().nullable().optional(),
59856
- resets_at: exports_external.string().nullable().optional()
59857
- }).optional(),
59858
- seven_day: exports_external.object({
59859
- utilization: exports_external.number().nullable().optional(),
59860
- resets_at: exports_external.string().nullable().optional()
59861
- }).optional(),
59862
- seven_day_sonnet: PerModelWeeklyBucketSchema,
59863
- seven_day_opus: PerModelWeeklyBucketSchema,
59864
- extra_usage: exports_external.object({
59869
+ UsageApiResponseSchema = exports_external.looseObject({
59870
+ five_hour: UsageApiBucketSchema,
59871
+ seven_day: UsageApiBucketSchema,
59872
+ seven_day_sonnet: UsageApiBucketSchema,
59873
+ seven_day_opus: UsageApiBucketSchema,
59874
+ extra_usage: exports_external.looseObject({
59865
59875
  is_enabled: exports_external.boolean().nullable().optional(),
59866
59876
  monthly_limit: exports_external.number().nullable().optional(),
59867
59877
  used_credits: exports_external.number().nullable().optional(),
59868
59878
  utilization: exports_external.number().nullable().optional()
59869
- }).optional()
59879
+ }).nullable().optional()
59870
59880
  });
59871
59881
  usageErrorCacheMaxAge = LOCK_MAX_AGE;
59872
59882
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccstatusline",
3
- "version": "2.2.16",
3
+ "version": "2.2.17",
4
4
  "description": "A customizable status line formatter for Claude Code CLI",
5
5
  "module": "src/ccstatusline.ts",
6
6
  "type": "module",