@giladbarnea/pi-custom-footer 0.1.14 → 0.1.16
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/README.md +5 -5
- package/index.ts +25 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
last_updated: 2026-11-
|
|
2
|
+
last_updated: 2026-11-15T13-19
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
@@ -30,12 +30,12 @@ Below the editor, see:
|
|
|
30
30
|
|
|
31
31
|
- **Context remaining at a glance:** a color-graded gauge and used/window tokens.
|
|
32
32
|
- **Cost across the conversation:** cumulative cost and average cost per assistant turn.
|
|
33
|
-
- **Cache behavior:** session hit rate, the last message as `hit 100%` or `miss 45
|
|
33
|
+
- **Cache behavior:** session hit rate, with reused tokens when there is room (`97.6% session (38M reused)`), and the last message as `hit 100%` or `miss 45%`. A hit means more than 90% of the prompt was read from the cache. Like Pi’s own notice, a miss that re-billed cached tokens shows what it cost and why it happened: an idle gap or a model switch.
|
|
34
34
|
- **How long the cache stays warm:** `warm for 26m`, live: the footer redraws once a minute. It counts down to the latest of three times: the last request or cache warm plus the model’s cache lifetime; the end of Pi’s own idle warming, when Pi will refresh this context; and a deadline set with pi-keep-cache-warm in this Pi session. Once that time has passed, the fact hides. Pi’s idle warming counts on Pi 1.5.1 and later; earlier versions show last touch plus lifetime. Models without a declared cache lifetime, such as OpenAI and Codex, show nothing.
|
|
35
35
|
- **Where you are:** Git branch, dirty marker, directory, and other extensions’ status messages.
|
|
36
|
-
- **Subscription pace:** this week’s
|
|
36
|
+
- **Subscription pace:** this week’s pace against the target rate, as `pace ━━━━●┊─── 1.07× ≤ target 1.18× · resets in 12h`. With less room, it reads `pace ≤ target (1.18×)`, then `pace ≤ 1.18×`. The sign turns to `>` when you are over budget, and the dot passes the time marker. A reading more than 30 minutes old adds its age, such as `· 2h old`. The age outlasts the pace bar and goes before the rest of the pace. Optional: shown only when a `quota` cache file exists.
|
|
37
37
|
|
|
38
|
-
The layout follows your Pi theme. The header and the footer each take the fewest lines they can. To fit,
|
|
38
|
+
The layout follows your Pi theme. The header and the footer each take the fewest lines they can. To fit, the footer first drops the optional reused-token suffix, before any other detail or fact. It then drops the pace bar and labels, round readings, remove whitespace, and drop the branch icon. The cache time drops its label (`26m`). A hit or miss drops its percentage. Only then does the footer hide facts: the `sub` mark of a subscription, a stale reading's age, the pace reading with its reset time, the last message's plain `hit` or `miss`, the token counts, the session hit rate, the word `target`, the cache time, and last the cost per turn. The target rate stays down to `pace ≤ 1.18×`. A cache miss drops its re-billed tokens early. It keeps its cause until every one of those facts has hidden, and keeps its cost to the end. Last, the target rate hides only where it alone would add a line.
|
|
39
39
|
|
|
40
40
|
Skills get one row for every eight terminal rows past the first six, with a minimum of one. A 21-row phone screen gets one row, a 27-row screen two, and a 34-row screen three. To fit, the row first drops token ages, then separators, then shortens long names in the middle (`caut…ctor`). Only then does it hide skills from the end, behind a `+N` count at the end of the last row.
|
|
41
41
|
|
|
@@ -43,7 +43,7 @@ Skills get one row for every eight terminal rows past the first six, with a mini
|
|
|
43
43
|
|
|
44
44
|
Skill age measures context-token growth since the first response after a skill load. Cache misses mirror Pi’s own miss accounting: the tokens re-billed since the last request or cache warm, their extra cost over cache reads, and the idle time. Costs use the model’s reported pricing, including when you use a subscription. Numbers show two decimal places below 10, one from 10, and none from 100.
|
|
45
45
|
|
|
46
|
-
The pace comes from `~/.cache/quota/provider-usage.json` (or under `XDG_CACHE_HOME`), which the author’s `quota` tool writes. That tool is not public yet, and without the file the footer shows no pace. The reading is for the pool of the session’s model: Claude, Fable or Codex. The footer only reads that file. It never runs `quota` and never fetches.
|
|
46
|
+
The pace comes from `~/.cache/quota/provider-usage.json` (or under `XDG_CACHE_HOME`), which the author’s `quota` tool writes. That tool is not public yet, and without the file the footer shows no pace. The reading is for the pool of the session’s model: Claude, Fable or Codex. The footer only reads that file. It never runs `quota` and never fetches. Pace and target each take a color from `quota`’s heat map: green near 1.0×, cool where allowance goes unused, amber then red where it runs out early. A Fable session shows Fable’s target capped by the room left in the shared Claude week.
|
|
47
47
|
|
|
48
48
|
## Development
|
|
49
49
|
|
package/index.ts
CHANGED
|
@@ -154,7 +154,7 @@ type Ladder<Key extends string> = {
|
|
|
154
154
|
steps: readonly (readonly [Key | "spacing", Form])[];
|
|
155
155
|
};
|
|
156
156
|
type HeaderFact = "model" | "thinking" | "sessionName" | "sessionId";
|
|
157
|
-
type FooterFact = "branch" | "cwd" | "context" | "tokens" | "cost" | "perTurn" | "cacheSession" | "latest" | "expiry" | "
|
|
157
|
+
type FooterFact = "branch" | "cwd" | "context" | "tokens" | "cost" | "perTurn" | "cacheSession" | "latest" | "expiry" | "pace";
|
|
158
158
|
|
|
159
159
|
const SPACING = {
|
|
160
160
|
full: { separator: WIDE_SEPARATOR, joiner: " " },
|
|
@@ -178,27 +178,29 @@ const FOOTER_LADDER: Ladder<FooterFact> = {
|
|
|
178
178
|
rows: [
|
|
179
179
|
[["branch"], ["cwd"]],
|
|
180
180
|
[["context", "tokens"], ["cost", "perTurn"]],
|
|
181
|
-
[["cacheSession"], ["latest"], ["expiry"]
|
|
181
|
+
[["cacheSession"], ["latest"], ["expiry"]],
|
|
182
182
|
[["pace"]],
|
|
183
183
|
],
|
|
184
184
|
steps: [
|
|
185
|
-
// 1. Drop
|
|
185
|
+
// 1. Drop the optional reused-token suffix before any other detail or fact.
|
|
186
|
+
["cacheSession", "short"],
|
|
187
|
+
// 2. Drop what the values already imply. First the pace bar and the words
|
|
186
188
|
// "resets in": the bar draws what the two rates say. Then the labels.
|
|
187
189
|
["pace", "short"],
|
|
188
190
|
["tokens", "short"], ["context", "bare"], ["cacheSession", "bare"], ["expiry", "short"],
|
|
189
|
-
//
|
|
191
|
+
// 3. Shorten the readings: the last message's cache share (for a
|
|
190
192
|
// detected miss, its re-billed tokens), then the cost, rounded twice.
|
|
191
193
|
["latest", "short"], ["cost", "short"], ["cost", "bare"],
|
|
192
|
-
//
|
|
194
|
+
// 4. Remove whitespace: the padding inside the cwd pill, then the separators.
|
|
193
195
|
["cwd", "short"], ["spacing", "bare"],
|
|
194
|
-
//
|
|
196
|
+
// 5. Drop the branch icon.
|
|
195
197
|
["branch", "bare"],
|
|
196
|
-
//
|
|
198
|
+
// 6. Hide whole facts. First the "sub" mark: that a model runs on your
|
|
197
199
|
// subscription is rarely news, so it is the least important fact, but
|
|
198
200
|
// it is still data and outlasts all the formatting above. Then a stale
|
|
199
201
|
// quota reading's age: it outlasts the bar, the labels and the
|
|
200
202
|
// whitespace, so a laptop still sees that the rates are old, and it
|
|
201
|
-
// goes before every other part of the pace left. Then the
|
|
203
|
+
// goes before every other part of the pace left. Then the pace reading
|
|
202
204
|
// and the reset time: the sign keeps the verdict, and the target is
|
|
203
205
|
// the number to act on. The last message's "hit" or "miss" hides
|
|
204
206
|
// before the session hit rate: the session rate is the cost signal,
|
|
@@ -206,20 +208,20 @@ const FOOTER_LADDER: Ladder<FooterFact> = {
|
|
|
206
208
|
// outlasts the token counts, which the context gauge already sums
|
|
207
209
|
// up, so a phone keeps one cache fact. The word
|
|
208
210
|
// "target" outlasts the cache and token facts, because it names that
|
|
209
|
-
// number once the
|
|
211
|
+
// number once the pace reading is gone. The time left on the cache
|
|
210
212
|
// outlasts it: it says whether to hurry back before a cold restart.
|
|
211
213
|
// The cost per turn goes last of them, because seeing what each turn
|
|
212
214
|
// costs is half of what the footer is for. The target rate hides only
|
|
213
|
-
// at the very end, in step
|
|
215
|
+
// at the very end, in step 8.
|
|
214
216
|
["cost", "least"],
|
|
215
217
|
["pace", "brief"], ["pace", "bare"],
|
|
216
|
-
["
|
|
217
|
-
//
|
|
218
|
+
["latest", "brief"], ["tokens", "hidden"], ["cacheSession", "hidden"], ["pace", "least"], ["expiry", "hidden"], ["perTurn", "hidden"],
|
|
219
|
+
// 7. Drop the cause of a detected cache miss, keeping its cost.
|
|
218
220
|
// Unlike a plain "hit" or "miss", it outranks every hidden fact: it
|
|
219
221
|
// shows only on the turn that missed, and says what to do about the
|
|
220
222
|
// cost (an idle gap or a model switch).
|
|
221
223
|
["latest", "bare"],
|
|
222
|
-
//
|
|
224
|
+
// 8. Last, hide the target rate. Because the footer takes the fullest
|
|
223
225
|
// state with the fewest lines, this fires only where the target alone
|
|
224
226
|
// would add a line, as on a phone with the keyboard up.
|
|
225
227
|
["pace", "hidden"],
|
|
@@ -1057,11 +1059,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
1057
1059
|
// A stale reading keeps showing, with its age until "brief", the form without it.
|
|
1058
1060
|
const age = reading.ageMs > PACE_STALE_AFTER_MS ? dim(` · ${formatRemaining(reading.ageMs)} old`) : "";
|
|
1059
1061
|
return {
|
|
1060
|
-
full: `${label("
|
|
1061
|
-
short: `${label("
|
|
1062
|
-
brief: `${label("
|
|
1063
|
-
bare: `${sign} ${label("target")}${target}`,
|
|
1064
|
-
least: `${sign} ${target}`,
|
|
1062
|
+
full: `${label("pace")}${paceBar(reading.used, reading.elapsed, burnHeat, dim)} ${burn} ${sign} ${label("target")}${target}${dim(` · resets in ${resets}`)}${age}`,
|
|
1063
|
+
short: `${label("pace")}${burn} ${sign} ${label("target")}${target}${dim(` · ${resets}`)}${age}`,
|
|
1064
|
+
brief: `${label("pace")}${burn} ${sign} ${label("target")}${target}${dim(` · ${resets}`)}`,
|
|
1065
|
+
bare: `${label("pace")}${sign} ${label("target")}${dim("(")}${target}${dim(")")}`,
|
|
1066
|
+
least: `${label("pace")}${sign} ${target}`,
|
|
1065
1067
|
};
|
|
1066
1068
|
};
|
|
1067
1069
|
const footerFacts: Partial<Record<FooterFact, FactForms>> = {
|
|
@@ -1076,7 +1078,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
1076
1078
|
},
|
|
1077
1079
|
cost: { full: `${cost(2)}${sub}`, short: `${cost(1)}${sub}`, bare: `${cost(0)}${sub}`, least: cost(0) },
|
|
1078
1080
|
perTurn: { full: paint.quiet(SPEND_TOKEN, `$${formatDecimal(stats.averageCostPerTurn)}/turn`) },
|
|
1079
|
-
cacheSession: {
|
|
1081
|
+
cacheSession: {
|
|
1082
|
+
full: `${label("cache")}${sessionHitText}${sessionHit !== null ? theme.fg("dim", ` (${formatTokens(stats.totalReused)} reused)`) : ""}`,
|
|
1083
|
+
short: `${label("cache")}${sessionHitText}`,
|
|
1084
|
+
bare: sessionHitText,
|
|
1085
|
+
},
|
|
1080
1086
|
// "brief" is the step where a plain hit or miss hides; a detected miss stays to the end.
|
|
1081
1087
|
latest: missForms
|
|
1082
1088
|
? { full: theme.fg("error", missForms.full), short: theme.fg("error", missForms.short), brief: theme.fg("error", missForms.short), bare: theme.fg("error", missForms.bare) }
|
|
@@ -1088,10 +1094,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
1088
1094
|
bare: "",
|
|
1089
1095
|
}
|
|
1090
1096
|
: undefined,
|
|
1091
|
-
reuse: {
|
|
1092
|
-
full: paint.ramp(CACHE_STOPS, sessionHit ?? 0, formatTokens(stats.totalReused)) +
|
|
1093
|
-
theme.fg("dim", ` reused / ${formatTokens(stats.totalFresh)} new`),
|
|
1094
|
-
},
|
|
1095
1097
|
// Once the time has passed the fact hides: there is nothing left to hurry back for,
|
|
1096
1098
|
// and the next request's miss shows what it cost.
|
|
1097
1099
|
expiry: expiresAt !== null && expiresAt > Date.now()
|