ccstatusline-usage 2.3.3 → 2.3.4

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
@@ -66,6 +66,11 @@ Session: [████░░░░░░░░░░░] 27.0% | Weekly: [██
66
66
 
67
67
  ## 🆕 Recent Updates
68
68
 
69
+ ### [v2.3.4](https://github.com/pcvelz/ccstatusline-usage/releases/tag/v2.3.4) - Upstream sync + extra usage fix
70
+
71
+ - [sirmalloc/ccstatusline](https://github.com/sirmalloc/ccstatusline): **Native rate_limits support** — Upstream now uses Claude Code 2.1.80's native `rate_limits` field for usage data
72
+ - [pcvelz/ccstatusline-usage](https://github.com/pcvelz/ccstatusline-usage): **Extra usage regression fix** — Reset timer widget now supplements native `rate_limits` data with API fetch for extra usage fields that upstream's pipeline omits
73
+
69
74
  ### [v2.3.3](https://github.com/pcvelz/ccstatusline-usage/releases/tag/v2.3.3) - CI pipeline fix
70
75
 
71
76
  - [pcvelz/ccstatusline-usage](https://github.com/pcvelz/ccstatusline-usage): **CI pipeline fix** — Fixed TypeScript errors (model union type narrowing, missing `extraUsageBalance` setting), disabled broken `import/order` ESLint rule (incompatible with ESLint 10), resolved all remaining lint errors in fork-specific files
@@ -54072,7 +54072,7 @@ function getTerminalWidth() {
54072
54072
  function canDetectTerminalWidth() {
54073
54073
  return probeTerminalWidth() !== null;
54074
54074
  }
54075
- var __dirname = "/Users/peter/Documents/Code/ccstatusline-usage/src/utils", PACKAGE_VERSION = "2.3.3";
54075
+ var __dirname = "/Users/peter/Documents/Code/ccstatusline-usage/src/utils", PACKAGE_VERSION = "2.3.4";
54076
54076
  var init_terminal = () => {};
54077
54077
 
54078
54078
  // src/utils/renderer.ts
@@ -68997,6 +68997,10 @@ var CoercedNumberSchema = exports_external.preprocess((value) => {
68997
68997
  const parsed = Number(trimmed);
68998
68998
  return Number.isFinite(parsed) ? parsed : value;
68999
68999
  }, exports_external.number());
69000
+ var RateLimitPeriodSchema = exports_external.object({
69001
+ used_percentage: CoercedNumberSchema.nullable().optional(),
69002
+ resets_at: CoercedNumberSchema.nullable().optional()
69003
+ });
69000
69004
  var StatusJSONSchema = exports_external.looseObject({
69001
69005
  hook_event_name: exports_external.string().optional(),
69002
69006
  session_id: exports_external.string().optional(),
@@ -69039,7 +69043,11 @@ var StatusJSONSchema = exports_external.looseObject({
69039
69043
  used_percentage: CoercedNumberSchema.nullable().optional(),
69040
69044
  remaining_percentage: CoercedNumberSchema.nullable().optional()
69041
69045
  }).nullable().optional(),
69042
- vim: exports_external.object({ mode: exports_external.string().optional() }).nullable().optional()
69046
+ vim: exports_external.object({ mode: exports_external.string().optional() }).nullable().optional(),
69047
+ rate_limits: exports_external.object({
69048
+ five_hour: RateLimitPeriodSchema.optional(),
69049
+ seven_day: RateLimitPeriodSchema.optional()
69050
+ }).nullable().optional()
69043
69051
  });
69044
69052
 
69045
69053
  // src/ccstatusline.ts
@@ -69172,11 +69180,46 @@ var USAGE_WIDGET_TYPES = new Set([
69172
69180
  function hasUsageDependentWidgets(lines) {
69173
69181
  return lines.some((line) => line.some((item) => USAGE_WIDGET_TYPES.has(item.type)));
69174
69182
  }
69175
- async function prefetchUsageDataIfNeeded(lines) {
69183
+ function epochSecondsToIsoString(epochSeconds) {
69184
+ if (epochSeconds === null || epochSeconds === undefined || !Number.isFinite(epochSeconds)) {
69185
+ return;
69186
+ }
69187
+ return new Date(epochSeconds * 1000).toISOString();
69188
+ }
69189
+ function extractUsageDataFromRateLimits(rateLimits) {
69190
+ if (!rateLimits) {
69191
+ return null;
69192
+ }
69193
+ const sessionUsage = rateLimits.five_hour?.used_percentage ?? undefined;
69194
+ const sessionResetAt = epochSecondsToIsoString(rateLimits.five_hour?.resets_at);
69195
+ const weeklyUsage = rateLimits.seven_day?.used_percentage ?? undefined;
69196
+ const weeklyResetAt = epochSecondsToIsoString(rateLimits.seven_day?.resets_at);
69197
+ if (sessionUsage === undefined && weeklyUsage === undefined) {
69198
+ return null;
69199
+ }
69200
+ return { sessionUsage, sessionResetAt, weeklyUsage, weeklyResetAt };
69201
+ }
69202
+ function hasCompleteRateLimitsUsageData(usageData) {
69203
+ return usageData?.sessionUsage !== undefined && usageData.sessionResetAt !== undefined && usageData.weeklyUsage !== undefined && usageData.weeklyResetAt !== undefined;
69204
+ }
69205
+ function hasExtraUsageDependentWidgets(lines) {
69206
+ return lines.some((line) => line.some((item) => item.type === "reset-timer"));
69207
+ }
69208
+ async function prefetchUsageDataIfNeeded(lines, data) {
69176
69209
  if (!hasUsageDependentWidgets(lines)) {
69177
69210
  return null;
69178
69211
  }
69179
- return await fetchUsageData();
69212
+ const rateLimitsData = extractUsageDataFromRateLimits(data?.rate_limits);
69213
+ if (hasCompleteRateLimitsUsageData(rateLimitsData)) {
69214
+ if (hasExtraUsageDependentWidgets(lines)) {
69215
+ const apiData = await fetchUsageData();
69216
+ if (apiData.error === undefined) {
69217
+ return { ...rateLimitsData, extraUsageEnabled: apiData.extraUsageEnabled, extraUsageLimit: apiData.extraUsageLimit, extraUsageUsed: apiData.extraUsageUsed, extraUsageUtilization: apiData.extraUsageUtilization };
69218
+ }
69219
+ }
69220
+ return rateLimitsData;
69221
+ }
69222
+ return fetchUsageData();
69180
69223
  }
69181
69224
 
69182
69225
  // src/ccstatusline.ts
@@ -69248,7 +69291,7 @@ async function renderMultipleLines(data) {
69248
69291
  if (hasSessionClock && !hasSessionDurationInStatusJson(data) && data.transcript_path) {
69249
69292
  sessionDuration = await getSessionDuration(data.transcript_path);
69250
69293
  }
69251
- const usageData = await prefetchUsageDataIfNeeded(lines);
69294
+ const usageData = await prefetchUsageDataIfNeeded(lines, data);
69252
69295
  let speedMetrics = null;
69253
69296
  let windowedSpeedMetrics = null;
69254
69297
  if (hasSpeedItems && data.transcript_path) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccstatusline-usage",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "A customizable status line formatter for Claude Code CLI",
5
5
  "module": "src/ccstatusline.ts",
6
6
  "type": "module",