portable-agent-layer 0.62.2 → 0.63.0

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.
@@ -87,14 +87,6 @@ if (Test-Path $projectsDir) {
87
87
  } catch { $OPEN_ISCS = 0 }
88
88
  }
89
89
 
90
- # Rate limits (Pro/Max only - absent for other plans)
91
- $FIVE_H_RAW = $data.rate_limits.five_hour.used_percentage
92
- $SEVEN_D_RAW = $data.rate_limits.seven_day.used_percentage
93
- $RATE_PARTS = @()
94
- if ($FIVE_H_RAW -ne $null) { $RATE_PARTS += "5h: $([int]$FIVE_H_RAW)%" }
95
- if ($SEVEN_D_RAW -ne $null) { $RATE_PARTS += "7d: $([int]$SEVEN_D_RAW)%" }
96
- $RATE_STR = if ($RATE_PARTS.Count -gt 0) { " - " + ($RATE_PARTS -join " | ") } else { "" }
97
-
98
90
  # Create context progress bar - if both are 0, data not yet available (pre-first API call)
99
91
  $NO_DATA = ($USED_RAW -eq $null -and $REM_RAW -eq $null)
100
92
  if ($NO_DATA) { $USED = 0; $REM = 100 }
@@ -115,6 +107,37 @@ $RESET = $ESC + "[0m"
115
107
  # Choose bar color based on context usage
116
108
  $BAR_COLOR = if ($USED -gt 80) { $RED } elseif ($USED -gt 60) { $YELLOW } else { $GREEN }
117
109
 
110
+ # Rate limits (Pro/Max only - absent for other plans)
111
+ $FIVE_H_RAW = $data.rate_limits.five_hour.used_percentage
112
+ $SEVEN_D_RAW = $data.rate_limits.seven_day.used_percentage
113
+
114
+ # Daily soft limit - spending the weekly budget evenly is 100/7 ~ 14% per day.
115
+ # Shows what is still sustainable per day for the rest of the window: remaining
116
+ # budget divided by days left. Dropping under the even-pace ideal means future
117
+ # days have already been eaten into. Both inputs are server-reported for the
118
+ # whole account, so every machine on the account computes the same figure.
119
+ # resets_at is Unix epoch seconds.
120
+ $DAY_STR = ""
121
+ $RESETS_AT = $data.rate_limits.seven_day.resets_at
122
+ if (($SEVEN_D_RAW -ne $null) -and ($RESETS_AT -ne $null)) {
123
+ $now = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds()
124
+ $daysLeft = ([double]$RESETS_AT - $now) / 86400
125
+ if ($daysLeft -gt 0) {
126
+ $dayIdeal = 100 / 7
127
+ $dayRate = (100 - [double]$SEVEN_D_RAW) / $daysLeft
128
+ if ($dayRate -lt 0) { $dayRate = 0 }
129
+ $DAY_COLOR = if ($dayRate -lt $dayIdeal) { $RED } elseif ($dayRate -lt ($dayIdeal * 1.1)) { $YELLOW } else { $GREEN }
130
+ $DAY_FLAG = if ($dayRate -lt $dayIdeal) { " !" } else { "" }
131
+ $DAY_STR = $DAY_COLOR + "day: $([int][math]::Round($dayRate))/$([int][math]::Round($dayIdeal))%$DAY_FLAG" + $RESET + $DIM
132
+ }
133
+ }
134
+
135
+ $RATE_PARTS = @()
136
+ if ($FIVE_H_RAW -ne $null) { $RATE_PARTS += "5h: $([int]$FIVE_H_RAW)%" }
137
+ if ($SEVEN_D_RAW -ne $null) { $RATE_PARTS += "7d: $([int]$SEVEN_D_RAW)%" }
138
+ if ($DAY_STR) { $RATE_PARTS += $DAY_STR }
139
+ $RATE_STR = if ($RATE_PARTS.Count -gt 0) { " - " + ($RATE_PARTS -join " | ") } else { "" }
140
+
118
141
  # PAL: Signal trend (reads 10-min cache written by session intelligence)
119
142
  $SIGNAL_STR = ""
120
143
  $signalCache = Join-Path $env:USERPROFILE ".pal\memory\state\signal-cache.json"
@@ -107,17 +107,6 @@ if [ -d "$PROJECTS_DIR" ]; then
107
107
  done
108
108
  fi
109
109
 
110
- # Rate limits (Pro/Max only — absent for other plans and on Cursor)
111
- FIVE_H=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
112
- SEVEN_D=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
113
- RATE_PARTS=()
114
- [ -n "$FIVE_H" ] && RATE_PARTS+=("5h: ${FIVE_H%.*}%")
115
- [ -n "$SEVEN_D" ] && RATE_PARTS+=("7d: ${SEVEN_D%.*}%")
116
- RATE_STR=""
117
- if [ ${#RATE_PARTS[@]} -gt 0 ]; then
118
- RATE_STR=" │ $(IFS=" | "; echo "${RATE_PARTS[*]}")"
119
- fi
120
-
121
110
  # Create context progress bar (20 chars wide)
122
111
  FILLED=$((USED / 5))
123
112
  EMPTY=$((20 - FILLED))
@@ -147,6 +136,51 @@ else
147
136
  CONTEXT_COLOR=$GREEN
148
137
  fi
149
138
 
139
+ # Rate limits (Pro/Max only — absent for other plans and on Cursor)
140
+ FIVE_H=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
141
+ SEVEN_D=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
142
+
143
+ # Daily soft limit — spending the weekly budget evenly is 100/7 ≈ 14% per day.
144
+ # Shows what is still sustainable per day for the rest of the window: remaining
145
+ # budget divided by days left. Dropping under the even-pace ideal means future
146
+ # days have already been eaten into. Both inputs are server-reported for the
147
+ # whole account, so every machine on the account computes the same figure.
148
+ # resets_at is Unix epoch seconds.
149
+ DAY_STR=""
150
+ RESETS_AT=$(echo "$input" | jq -r '.rate_limits.seven_day.resets_at // empty')
151
+ if [ -n "$SEVEN_D" ] && [ -n "$RESETS_AT" ]; then
152
+ DAYS_LEFT=$(echo "($RESETS_AT - $(date +%s)) / 86400" | bc -l)
153
+ if (( $(echo "$DAYS_LEFT > 0" | bc -l) )); then
154
+ DAY_IDEAL=$(echo "100 / 7" | bc -l)
155
+ DAY_RATE=$(echo "(100 - $SEVEN_D) / $DAYS_LEFT" | bc -l)
156
+ (( $(echo "$DAY_RATE < 0" | bc -l) )) && DAY_RATE=0
157
+ if (( $(echo "$DAY_RATE < $DAY_IDEAL" | bc -l) )); then
158
+ DAY_COLOR=$RED
159
+ DAY_FLAG=" ⚠️"
160
+ elif (( $(echo "$DAY_RATE < $DAY_IDEAL * 1.1" | bc -l) )); then
161
+ DAY_COLOR=$YELLOW
162
+ DAY_FLAG=""
163
+ else
164
+ DAY_COLOR=$GREEN
165
+ DAY_FLAG=""
166
+ fi
167
+ DAY_STR="${DAY_COLOR}day: $(printf '%.0f' "$DAY_RATE")/$(printf '%.0f' "$DAY_IDEAL")%${DAY_FLAG}${RESET}${DIM}"
168
+ fi
169
+ fi
170
+
171
+ RATE_PARTS=()
172
+ [ -n "$FIVE_H" ] && RATE_PARTS+=("5h: ${FIVE_H%.*}%")
173
+ [ -n "$SEVEN_D" ] && RATE_PARTS+=("7d: ${SEVEN_D%.*}%")
174
+ [ -n "$DAY_STR" ] && RATE_PARTS+=("$DAY_STR")
175
+ RATE_STR=""
176
+ if [ ${#RATE_PARTS[@]} -gt 0 ]; then
177
+ RATE_JOINED="${RATE_PARTS[0]}"
178
+ for PART in "${RATE_PARTS[@]:1}"; do
179
+ RATE_JOINED="${RATE_JOINED} | ${PART}"
180
+ done
181
+ RATE_STR=" │ ${RATE_JOINED}"
182
+ fi
183
+
150
184
  # PAL: Signal trend (reads 10-min cache written by session intelligence)
151
185
  SIGNAL_STR=""
152
186
  SIGNAL_CACHE="$HOME/.pal/memory/state/signal-cache.json"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "portable-agent-layer",
3
- "version": "0.62.2",
3
+ "version": "0.63.0",
4
4
  "description": "PAL — Portable Agent Layer: persistent personal context for AI coding assistants",
5
5
  "type": "module",
6
6
  "bin": {