@andrewkent/claude-statusline 1.1.7 → 1.1.8

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
@@ -900,6 +901,39 @@ if [ -n "$usage_data" ] && echo "$usage_data" | jq -e . >/dev/null 2>&1; then
900
901
  extra_pct_color=$(color_for_pct "$extra_pct")
901
902
 
902
903
  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}"
904
+
905
+ # Project extra $ spend until current window resets (only when at 100% current)
906
+ if [ "$five_hour_pct" -ge 100 ] 2>/dev/null && [ -f "$prev_poll_file" ] && [ -n "$five_hour_reset_iso" ]; then
907
+ proj_reset_epoch=$(iso_to_epoch "$five_hour_reset_iso")
908
+ if [ -n "$proj_reset_epoch" ]; then
909
+ proj_now=$(date +%s)
910
+ proj_secs_to_reset=$(( proj_reset_epoch - proj_now ))
911
+ [ "$proj_secs_to_reset" -lt 0 ] && proj_secs_to_reset=0
912
+
913
+ proj_poll_ts=$(stat -f %m "$cache_file" 2>/dev/null || stat -c %Y "$cache_file" 2>/dev/null)
914
+ proj_prev_ts=$(jq -r '.ts // 0' "$prev_poll_file" 2>/dev/null)
915
+ proj_prev_extra=$(jq -r '.extra_used // 0' "$prev_poll_file" 2>/dev/null)
916
+ proj_poll_interval=$(( proj_poll_ts - proj_prev_ts ))
917
+
918
+ if [ "$proj_poll_interval" -gt 10 ] 2>/dev/null; then
919
+ # extra_used_raw is in cents, proj_prev_extra is in cents
920
+ proj_extra_spend=$(awk "BEGIN {
921
+ delta = $extra_used_raw - $proj_prev_extra;
922
+ if (delta <= 0) { print \"\"; exit }
923
+ rate_per_sec = delta / $proj_poll_interval;
924
+ secs_since = $proj_now - $proj_poll_ts;
925
+ spent_since = rate_per_sec * secs_since;
926
+ remaining_secs = $proj_secs_to_reset;
927
+ projected = (rate_per_sec * remaining_secs) / 100;
928
+ if (projected < 0.01) { print \"\"; exit }
929
+ printf \"~\$%.0f\", projected
930
+ }")
931
+ if [ -n "$proj_extra_spend" ]; then
932
+ rate_lines+=" ${orange}${proj_extra_spend} until reset${reset}"
933
+ fi
934
+ fi
935
+ fi
936
+ fi
903
937
  fi
904
938
  fi
905
939
 
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.8",
4
4
  "description": "Rich multi-line status bar for Claude Code — model, cost, context, git, rate limits",
5
5
  "keywords": [
6
6
  "claude",