@andrewkent/claude-statusline 1.1.7 → 1.1.9

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.
@@ -665,7 +665,8 @@ if $needs_refresh || $needs_profile_refresh; then
665
665
  prev_ts=$(stat -f %m "$cache_file" 2>/dev/null || stat -c %Y "$cache_file" 2>/dev/null)
666
666
  prev_5h=$(jq -r '.five_hour.utilization // 0' "$cache_file" 2>/dev/null)
667
667
  prev_7d=$(jq -r '.seven_day.utilization // 0' "$cache_file" 2>/dev/null)
668
- printf '{"ts":%s,"five_hour":%s,"seven_day":%s}' "$prev_ts" "$prev_5h" "$prev_7d" > "/tmp/claude/statusline-usage-prev.json"
668
+ prev_extra=$(jq -r '.extra_usage.used_credits // 0' "$cache_file" 2>/dev/null)
669
+ printf '{"ts":%s,"five_hour":%s,"seven_day":%s,"extra_used":%s}' "$prev_ts" "$prev_5h" "$prev_7d" "$prev_extra" > "/tmp/claude/statusline-usage-prev.json"
669
670
  fi
670
671
  echo "$response" > "$cache_file"
671
672
  fi
@@ -764,6 +765,23 @@ if [ -n "$usage_data" ] && echo "$usage_data" | jq -e . >/dev/null 2>&1; then
764
765
  rate_lines+="${white}$(printf "%-7s" "current")${reset} ${five_hour_bar} ${five_hour_pct_color}$(printf "%5.1f" "$five_hour_pct_display")%${reset}"
765
766
  [ -n "$five_hour_reset" ] && rate_lines+=" ${white}${five_hour_reset}${reset}"
766
767
 
768
+ # When at 100%, show countdown to reset
769
+ if [ "$five_hour_pct" -ge 100 ] 2>/dev/null && [ -n "$five_hour_reset_iso" ]; then
770
+ countdown_epoch=$(iso_to_epoch "$five_hour_reset_iso")
771
+ if [ -n "$countdown_epoch" ]; then
772
+ countdown_now=$(date +%s)
773
+ countdown_secs=$(( countdown_epoch - countdown_now ))
774
+ [ "$countdown_secs" -lt 0 ] && countdown_secs=0
775
+ countdown_mins=$(( countdown_secs / 60 ))
776
+ if [ "$countdown_mins" -ge 60 ] 2>/dev/null; then
777
+ countdown_display=$(awk "BEGIN { printf \"%.1fh\", $countdown_mins / 60 }")
778
+ else
779
+ countdown_display="${countdown_mins}m"
780
+ fi
781
+ rate_lines+=" ${red}resets ${countdown_display}${reset}"
782
+ fi
783
+ fi
784
+
767
785
  # ── Burn-down projection ──────────────────────────
768
786
  # Estimate minutes until 100% based on utilization velocity
769
787
  if [ "$five_hour_pct" -gt 5 ] 2>/dev/null && [ -n "$five_hour_reset_iso" ] && [ "$five_hour_reset_iso" != "" ]; then
@@ -900,6 +918,39 @@ if [ -n "$usage_data" ] && echo "$usage_data" | jq -e . >/dev/null 2>&1; then
900
918
  extra_pct_color=$(color_for_pct "$extra_pct")
901
919
 
902
920
  rate_lines+="\n${white}$(printf "%-7s" "extra")${reset} ${extra_bar} ${extra_pct_color}$(printf "%5.1f" "$extra_pct_display")%${reset} ${white}\$${extra_used}${dim}/${reset}${white}\$${extra_limit}${reset}"
921
+
922
+ # Project extra $ spend until current window resets (only when at 100% current)
923
+ if [ "$five_hour_pct" -ge 100 ] 2>/dev/null && [ -f "$prev_poll_file" ] && [ -n "$five_hour_reset_iso" ]; then
924
+ proj_reset_epoch=$(iso_to_epoch "$five_hour_reset_iso")
925
+ if [ -n "$proj_reset_epoch" ]; then
926
+ proj_now=$(date +%s)
927
+ proj_secs_to_reset=$(( proj_reset_epoch - proj_now ))
928
+ [ "$proj_secs_to_reset" -lt 0 ] && proj_secs_to_reset=0
929
+
930
+ proj_poll_ts=$(stat -f %m "$cache_file" 2>/dev/null || stat -c %Y "$cache_file" 2>/dev/null)
931
+ proj_prev_ts=$(jq -r '.ts // 0' "$prev_poll_file" 2>/dev/null)
932
+ proj_prev_extra=$(jq -r '.extra_used // 0' "$prev_poll_file" 2>/dev/null)
933
+ proj_poll_interval=$(( proj_poll_ts - proj_prev_ts ))
934
+
935
+ if [ "$proj_poll_interval" -gt 10 ] 2>/dev/null; then
936
+ # extra_used_raw is in cents, proj_prev_extra is in cents
937
+ proj_extra_spend=$(awk "BEGIN {
938
+ delta = $extra_used_raw - $proj_prev_extra;
939
+ if (delta <= 0) { print \"\"; exit }
940
+ rate_per_sec = delta / $proj_poll_interval;
941
+ secs_since = $proj_now - $proj_poll_ts;
942
+ spent_since = rate_per_sec * secs_since;
943
+ remaining_secs = $proj_secs_to_reset;
944
+ projected = (rate_per_sec * remaining_secs) / 100;
945
+ if (projected < 0.01) { print \"\"; exit }
946
+ printf \"~\$%.0f\", projected
947
+ }")
948
+ if [ -n "$proj_extra_spend" ]; then
949
+ rate_lines+=" ${orange}${proj_extra_spend} until reset${reset}"
950
+ fi
951
+ fi
952
+ fi
953
+ fi
903
954
  fi
904
955
  fi
905
956
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrewkent/claude-statusline",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "Rich multi-line status bar for Claude Code — model, cost, context, git, rate limits",
5
5
  "keywords": [
6
6
  "claude",