@andrewkent/claude-statusline 1.1.2 → 1.1.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/assets/statusline.sh +89 -3
- package/package.json +1 -1
package/assets/statusline.sh
CHANGED
|
@@ -715,12 +715,13 @@ if [ -n "$usage_data" ] && echo "$usage_data" | jq -e . >/dev/null 2>&1; then
|
|
|
715
715
|
"extra_limit_raw=" + (.extra_usage.monthly_limit // 0 | tostring | @sh)
|
|
716
716
|
' 2>/dev/null)"
|
|
717
717
|
|
|
718
|
+
five_hour_pct_display=$(printf "%.1f" "$five_hour_pct" 2>/dev/null || echo "0.0")
|
|
718
719
|
five_hour_pct=$(printf "%.0f" "$five_hour_pct" 2>/dev/null || echo 0)
|
|
719
720
|
five_hour_reset=$(format_reset_time "$five_hour_reset_iso" "time")
|
|
720
721
|
five_hour_bar=$(build_bar "$five_hour_pct" "$bar_width")
|
|
721
722
|
five_hour_pct_color=$(color_for_pct "$five_hour_pct")
|
|
722
723
|
|
|
723
|
-
rate_lines+="${white}$(printf "%-7s" "current")${reset} ${five_hour_bar} ${five_hour_pct_color}$(printf "%
|
|
724
|
+
rate_lines+="${white}$(printf "%-7s" "current")${reset} ${five_hour_bar} ${five_hour_pct_color}$(printf "%5s" "$five_hour_pct_display")%${reset}"
|
|
724
725
|
[ -n "$five_hour_reset" ] && rate_lines+=" ${white}${five_hour_reset}${reset}"
|
|
725
726
|
|
|
726
727
|
# ── Burn-down projection ──────────────────────────
|
|
@@ -752,29 +753,114 @@ if [ -n "$usage_data" ] && echo "$usage_data" | jq -e . >/dev/null 2>&1; then
|
|
|
752
753
|
[ "$mins_to_full" -le 30 ] && bd_color="$yellow"
|
|
753
754
|
[ "$mins_to_full" -le 15 ] && bd_color="$red"
|
|
754
755
|
rate_lines+=" ${bd_color}→full ~${mins_to_full}m${reset}"
|
|
756
|
+
|
|
757
|
+
# Survive indicator: buffer or downtime until window resets
|
|
758
|
+
mins_to_reset=$(( secs_to_reset / 60 ))
|
|
759
|
+
if [ "$mins_to_reset" -gt 0 ] 2>/dev/null; then
|
|
760
|
+
if [ "$mins_to_full" -gt "$mins_to_reset" ] 2>/dev/null; then
|
|
761
|
+
buffer=$(( mins_to_full - mins_to_reset ))
|
|
762
|
+
rate_lines+=" ${green}✓${buffer}m${reset}"
|
|
763
|
+
else
|
|
764
|
+
downtime=$(( mins_to_reset - mins_to_full ))
|
|
765
|
+
if [ "$downtime" -ge 60 ] 2>/dev/null; then
|
|
766
|
+
dt_display=$(awk "BEGIN { printf \"%.1fh\", $downtime / 60 }")
|
|
767
|
+
else
|
|
768
|
+
dt_display="${downtime}m"
|
|
769
|
+
fi
|
|
770
|
+
rate_lines+=" ${red}✗${dt_display}${reset}"
|
|
771
|
+
fi
|
|
772
|
+
fi
|
|
755
773
|
fi
|
|
756
774
|
fi
|
|
757
775
|
fi
|
|
758
776
|
fi
|
|
759
777
|
fi
|
|
760
778
|
|
|
779
|
+
seven_day_pct_display=$(printf "%.1f" "$seven_day_pct_raw" 2>/dev/null || echo "0.0")
|
|
761
780
|
seven_day_pct=$(printf "%.0f" "$seven_day_pct_raw" 2>/dev/null || echo 0)
|
|
762
781
|
seven_day_reset=$(format_reset_time "$seven_day_reset_iso" "datetime")
|
|
763
782
|
seven_day_bar=$(build_bar "$seven_day_pct" "$bar_width")
|
|
764
783
|
seven_day_pct_color=$(color_for_pct "$seven_day_pct")
|
|
765
784
|
|
|
766
|
-
rate_lines+="\n${white}$(printf "%-7s" "weekly")${reset} ${seven_day_bar} ${seven_day_pct_color}$(printf "%
|
|
785
|
+
rate_lines+="\n${white}$(printf "%-7s" "weekly")${reset} ${seven_day_bar} ${seven_day_pct_color}$(printf "%5s" "$seven_day_pct_display")%${reset}"
|
|
767
786
|
[ -n "$seven_day_reset" ] && rate_lines+=" ${white}${seven_day_reset}${reset}"
|
|
768
787
|
|
|
788
|
+
# ── Weekly burn-down projection ──────────────────
|
|
789
|
+
if [ "$seven_day_pct" -gt 2 ] 2>/dev/null && [ -n "$seven_day_reset_iso" ] && [ "$seven_day_reset_iso" != "" ]; then
|
|
790
|
+
weekly_reset_epoch=$(iso_to_epoch "$seven_day_reset_iso")
|
|
791
|
+
if [ -n "$weekly_reset_epoch" ]; then
|
|
792
|
+
now_wd=$(date +%s)
|
|
793
|
+
# 7-day window: 604800 seconds
|
|
794
|
+
weekly_secs_to_reset=$(( weekly_reset_epoch - now_wd ))
|
|
795
|
+
[ "$weekly_secs_to_reset" -lt 0 ] && weekly_secs_to_reset=0
|
|
796
|
+
weekly_secs_elapsed=$(( 604800 - weekly_secs_to_reset ))
|
|
797
|
+
[ "$weekly_secs_elapsed" -lt 60 ] && weekly_secs_elapsed=60
|
|
798
|
+
|
|
799
|
+
if [ "$weekly_secs_elapsed" -gt 0 ] && [ "$seven_day_pct" -gt 0 ] 2>/dev/null; then
|
|
800
|
+
weekly_remaining_pct=$(( 100 - seven_day_pct ))
|
|
801
|
+
if [ "$weekly_remaining_pct" -gt 0 ]; then
|
|
802
|
+
# Hours to full
|
|
803
|
+
hrs_to_full=$(awk "BEGIN {
|
|
804
|
+
rate = $seven_day_pct / $weekly_secs_elapsed;
|
|
805
|
+
if (rate > 0) printf \"%.1f\", $weekly_remaining_pct / rate / 3600;
|
|
806
|
+
else print 999
|
|
807
|
+
}")
|
|
808
|
+
hrs_to_reset=$(awk "BEGIN { printf \"%.1f\", $weekly_secs_to_reset / 3600 }")
|
|
809
|
+
|
|
810
|
+
# Display as days if > 48h, otherwise hours
|
|
811
|
+
display_to_full=$(awk "BEGIN {
|
|
812
|
+
h = $hrs_to_full;
|
|
813
|
+
if (h >= 48) printf \"%.1fd\", h / 24;
|
|
814
|
+
else printf \"%.0fh\", h
|
|
815
|
+
}")
|
|
816
|
+
|
|
817
|
+
# Only show if projection is within the window (< 7 days)
|
|
818
|
+
if awk "BEGIN { exit ($hrs_to_full < 168) ? 0 : 1 }" 2>/dev/null; then
|
|
819
|
+
wd_color="$green"
|
|
820
|
+
awk "BEGIN { exit ($hrs_to_full <= 72) ? 0 : 1 }" 2>/dev/null && wd_color="$orange"
|
|
821
|
+
awk "BEGIN { exit ($hrs_to_full <= 36) ? 0 : 1 }" 2>/dev/null && wd_color="$yellow"
|
|
822
|
+
awk "BEGIN { exit ($hrs_to_full <= 12) ? 0 : 1 }" 2>/dev/null && wd_color="$red"
|
|
823
|
+
rate_lines+=" ${wd_color}→full ~${display_to_full}${reset}"
|
|
824
|
+
|
|
825
|
+
# Survive indicator: buffer or downtime
|
|
826
|
+
weekly_gap=$(awk "BEGIN { printf \"%.1f\", $hrs_to_full - $hrs_to_reset }")
|
|
827
|
+
if awk "BEGIN { exit ($hrs_to_full > $hrs_to_reset) ? 0 : 1 }" 2>/dev/null; then
|
|
828
|
+
# Buffer — format as days if >= 48h
|
|
829
|
+
weekly_buf_display=$(awk "BEGIN {
|
|
830
|
+
h = $weekly_gap;
|
|
831
|
+
if (h < 0) h = -h;
|
|
832
|
+
if (h >= 48) printf \"%.1fd\", h / 24;
|
|
833
|
+
else if (h >= 1) printf \"%.0fh\", h;
|
|
834
|
+
else printf \"%.0fm\", h * 60
|
|
835
|
+
}")
|
|
836
|
+
rate_lines+=" ${green}✓${weekly_buf_display}${reset}"
|
|
837
|
+
else
|
|
838
|
+
# Downtime
|
|
839
|
+
weekly_dt_display=$(awk "BEGIN {
|
|
840
|
+
h = $weekly_gap;
|
|
841
|
+
if (h < 0) h = -h;
|
|
842
|
+
if (h >= 48) printf \"%.1fd\", h / 24;
|
|
843
|
+
else if (h >= 1) printf \"%.0fh\", h;
|
|
844
|
+
else printf \"%.0fm\", h * 60
|
|
845
|
+
}")
|
|
846
|
+
rate_lines+=" ${red}✗${weekly_dt_display}${reset}"
|
|
847
|
+
fi
|
|
848
|
+
fi
|
|
849
|
+
fi
|
|
850
|
+
fi
|
|
851
|
+
fi
|
|
852
|
+
fi
|
|
853
|
+
|
|
769
854
|
# Extra usage credits
|
|
770
855
|
if [ "$extra_enabled" = "true" ]; then
|
|
856
|
+
extra_pct_display=$(printf "%.1f" "$extra_pct_raw" 2>/dev/null || echo "0.0")
|
|
771
857
|
extra_pct=$(printf "%.0f" "$extra_pct_raw" 2>/dev/null || echo 0)
|
|
772
858
|
extra_used=$(awk "BEGIN {printf \"%.2f\", $extra_used_raw / 100}" 2>/dev/null)
|
|
773
859
|
extra_limit=$(awk "BEGIN {printf \"%.2f\", $extra_limit_raw / 100}" 2>/dev/null)
|
|
774
860
|
extra_bar=$(build_bar "$extra_pct" "$bar_width")
|
|
775
861
|
extra_pct_color=$(color_for_pct "$extra_pct")
|
|
776
862
|
|
|
777
|
-
rate_lines+="\n${white}$(printf "%-7s" "extra")${reset} ${extra_bar} ${extra_pct_color}$(printf "%
|
|
863
|
+
rate_lines+="\n${white}$(printf "%-7s" "extra")${reset} ${extra_bar} ${extra_pct_color}$(printf "%5s" "$extra_pct_display")%${reset} ${white}\$${extra_used}${dim}/${reset}${white}\$${extra_limit}${reset}"
|
|
778
864
|
fi
|
|
779
865
|
fi
|
|
780
866
|
|