@andrewkent/claude-statusline 1.1.2 → 1.1.3

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.
@@ -752,6 +752,23 @@ if [ -n "$usage_data" ] && echo "$usage_data" | jq -e . >/dev/null 2>&1; then
752
752
  [ "$mins_to_full" -le 30 ] && bd_color="$yellow"
753
753
  [ "$mins_to_full" -le 15 ] && bd_color="$red"
754
754
  rate_lines+=" ${bd_color}→full ~${mins_to_full}m${reset}"
755
+
756
+ # Survive indicator: buffer or downtime until window resets
757
+ mins_to_reset=$(( secs_to_reset / 60 ))
758
+ if [ "$mins_to_reset" -gt 0 ] 2>/dev/null; then
759
+ if [ "$mins_to_full" -gt "$mins_to_reset" ] 2>/dev/null; then
760
+ buffer=$(( mins_to_full - mins_to_reset ))
761
+ rate_lines+=" ${green}✓${buffer}m${reset}"
762
+ else
763
+ downtime=$(( mins_to_reset - mins_to_full ))
764
+ if [ "$downtime" -ge 60 ] 2>/dev/null; then
765
+ dt_display=$(awk "BEGIN { printf \"%.1fh\", $downtime / 60 }")
766
+ else
767
+ dt_display="${downtime}m"
768
+ fi
769
+ rate_lines+=" ${red}✗${dt_display}${reset}"
770
+ fi
771
+ fi
755
772
  fi
756
773
  fi
757
774
  fi
@@ -766,6 +783,72 @@ if [ -n "$usage_data" ] && echo "$usage_data" | jq -e . >/dev/null 2>&1; then
766
783
  rate_lines+="\n${white}$(printf "%-7s" "weekly")${reset} ${seven_day_bar} ${seven_day_pct_color}$(printf "%3d" "$seven_day_pct")%${reset}"
767
784
  [ -n "$seven_day_reset" ] && rate_lines+=" ${white}${seven_day_reset}${reset}"
768
785
 
786
+ # ── Weekly burn-down projection ──────────────────
787
+ if [ "$seven_day_pct" -gt 2 ] 2>/dev/null && [ -n "$seven_day_reset_iso" ] && [ "$seven_day_reset_iso" != "" ]; then
788
+ weekly_reset_epoch=$(iso_to_epoch "$seven_day_reset_iso")
789
+ if [ -n "$weekly_reset_epoch" ]; then
790
+ now_wd=$(date +%s)
791
+ # 7-day window: 604800 seconds
792
+ weekly_secs_to_reset=$(( weekly_reset_epoch - now_wd ))
793
+ [ "$weekly_secs_to_reset" -lt 0 ] && weekly_secs_to_reset=0
794
+ weekly_secs_elapsed=$(( 604800 - weekly_secs_to_reset ))
795
+ [ "$weekly_secs_elapsed" -lt 60 ] && weekly_secs_elapsed=60
796
+
797
+ if [ "$weekly_secs_elapsed" -gt 0 ] && [ "$seven_day_pct" -gt 0 ] 2>/dev/null; then
798
+ weekly_remaining_pct=$(( 100 - seven_day_pct ))
799
+ if [ "$weekly_remaining_pct" -gt 0 ]; then
800
+ # Hours to full
801
+ hrs_to_full=$(awk "BEGIN {
802
+ rate = $seven_day_pct / $weekly_secs_elapsed;
803
+ if (rate > 0) printf \"%.1f\", $weekly_remaining_pct / rate / 3600;
804
+ else print 999
805
+ }")
806
+ hrs_to_reset=$(awk "BEGIN { printf \"%.1f\", $weekly_secs_to_reset / 3600 }")
807
+
808
+ # Display as days if > 48h, otherwise hours
809
+ display_to_full=$(awk "BEGIN {
810
+ h = $hrs_to_full;
811
+ if (h >= 48) printf \"%.1fd\", h / 24;
812
+ else printf \"%.0fh\", h
813
+ }")
814
+
815
+ # Only show if projection is within the window (< 7 days)
816
+ if awk "BEGIN { exit ($hrs_to_full < 168) ? 0 : 1 }" 2>/dev/null; then
817
+ wd_color="$green"
818
+ awk "BEGIN { exit ($hrs_to_full <= 72) ? 0 : 1 }" 2>/dev/null && wd_color="$orange"
819
+ awk "BEGIN { exit ($hrs_to_full <= 36) ? 0 : 1 }" 2>/dev/null && wd_color="$yellow"
820
+ awk "BEGIN { exit ($hrs_to_full <= 12) ? 0 : 1 }" 2>/dev/null && wd_color="$red"
821
+ rate_lines+=" ${wd_color}→full ~${display_to_full}${reset}"
822
+
823
+ # Survive indicator: buffer or downtime
824
+ weekly_gap=$(awk "BEGIN { printf \"%.1f\", $hrs_to_full - $hrs_to_reset }")
825
+ if awk "BEGIN { exit ($hrs_to_full > $hrs_to_reset) ? 0 : 1 }" 2>/dev/null; then
826
+ # Buffer — format as days if >= 48h
827
+ weekly_buf_display=$(awk "BEGIN {
828
+ h = $weekly_gap;
829
+ if (h < 0) h = -h;
830
+ if (h >= 48) printf \"%.1fd\", h / 24;
831
+ else if (h >= 1) printf \"%.0fh\", h;
832
+ else printf \"%.0fm\", h * 60
833
+ }")
834
+ rate_lines+=" ${green}✓${weekly_buf_display}${reset}"
835
+ else
836
+ # Downtime
837
+ weekly_dt_display=$(awk "BEGIN {
838
+ h = $weekly_gap;
839
+ if (h < 0) h = -h;
840
+ if (h >= 48) printf \"%.1fd\", h / 24;
841
+ else if (h >= 1) printf \"%.0fh\", h;
842
+ else printf \"%.0fm\", h * 60
843
+ }")
844
+ rate_lines+=" ${red}✗${weekly_dt_display}${reset}"
845
+ fi
846
+ fi
847
+ fi
848
+ fi
849
+ fi
850
+ fi
851
+
769
852
  # Extra usage credits
770
853
  if [ "$extra_enabled" = "true" ]; then
771
854
  extra_pct=$(printf "%.0f" "$extra_pct_raw" 2>/dev/null || echo 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrewkent/claude-statusline",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Rich multi-line status bar for Claude Code — model, cost, context, git, rate limits",
5
5
  "keywords": [
6
6
  "claude",