@giladbarnea/pi-custom-footer 0.1.2 → 0.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.
- package/README.md +1 -1
- package/index.ts +166 -119
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ Below the editor, see:
|
|
|
25
25
|
- **Cache behavior:** session hit rate, latest hit or estimated miss, and reused/new token totals.
|
|
26
26
|
- **Where you are:** Git branch, dirty marker, directory, and other extensions’ status messages.
|
|
27
27
|
|
|
28
|
-
The layout follows your Pi theme
|
|
28
|
+
The layout follows your Pi theme. The header and the footer each take the fewest lines they can. To fit, they first drop labels, round readings, remove whitespace, and drop the branch icon. Only then does the footer hide facts: the reused/new split, the session hit rate, the token counts, and last the cost per turn.
|
|
29
29
|
|
|
30
30
|
On terminals with 40 rows or fewer, skills get at most four rows. To fit, the row first drops token ages, then separators, then shortens long names in the middle (`caut…ctor`). Only then does it show three rows plus a hidden-skill count.
|
|
31
31
|
|
package/index.ts
CHANGED
|
@@ -31,7 +31,6 @@ import { getLoadedSkills, type SkillLocation } from "./skill-tracker.ts";
|
|
|
31
31
|
|
|
32
32
|
// ── Layout constants ────────────────────────────────────────────────────────
|
|
33
33
|
|
|
34
|
-
const NARROW_WIDTH = 56;
|
|
35
34
|
const SHORT_TERMINAL_HEIGHT = 40;
|
|
36
35
|
const SKILL_COLLAPSE_ROW_THRESHOLD = 4;
|
|
37
36
|
const COLLAPSED_SKILL_ROWS = 3;
|
|
@@ -39,6 +38,7 @@ const COLLAPSED_SKILL_ROWS = 3;
|
|
|
39
38
|
const MIN_TRUNCATED_NAME_LENGTH = 9;
|
|
40
39
|
const NARROW_SEPARATOR = " ";
|
|
41
40
|
const WIDE_SEPARATOR = " · ";
|
|
41
|
+
const BRANCH_GLYPH = "";
|
|
42
42
|
const CONTEXT_GAUGE_SYMBOLS = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"];
|
|
43
43
|
const CONTEXT_GAUGE_STEP_COUNT = CONTEXT_GAUGE_SYMBOLS.length;
|
|
44
44
|
const CACHE_MISS_NOISE_FLOOR_TOKENS = 1_024;
|
|
@@ -91,25 +91,76 @@ const THINKING_LEVELS: Record<string, { full: string; short: string; token: stri
|
|
|
91
91
|
max: { full: "max", short: "mx", token: "thinkingMax" },
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
// ──
|
|
94
|
+
// ── Shrink ladders ──────────────────────────────────────────────────────────
|
|
95
|
+
// The same approach as the Claude Code status line in ~/.claude/statusline.sh.
|
|
96
|
+
// Each region packs its rows onto the fewest lines it can, at the fullest state
|
|
97
|
+
// that reaches that count. State N applies the first N steps. Each phase gives
|
|
98
|
+
// up a kind of detail that matters more than the phase before it, and within a
|
|
99
|
+
// phase the least needed fact goes first.
|
|
100
|
+
|
|
101
|
+
type Form = "full" | "short" | "bare" | "hidden";
|
|
102
|
+
/** A fact's text in each form it has. A step names only forms its fact has. */
|
|
103
|
+
type FactForms = { full: string } & Partial<Record<"short" | "bare", string>>;
|
|
104
|
+
/** One row of facts. Each inner list is one group, joined by the narrow joiner. */
|
|
105
|
+
type Row<Key extends string> = readonly (readonly Key[])[];
|
|
106
|
+
type Ladder<Key extends string> = {
|
|
107
|
+
rows: readonly Row<Key>[];
|
|
108
|
+
steps: readonly (readonly [Key | "spacing", Form])[];
|
|
109
|
+
};
|
|
110
|
+
type HeaderFact = "model" | "thinking" | "sessionName" | "sessionId";
|
|
111
|
+
type FooterFact = "branch" | "cwd" | "context" | "tokens" | "cost" | "perTurn" | "cacheSession" | "latest" | "reuse";
|
|
95
112
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
113
|
+
const SPACING = {
|
|
114
|
+
full: { separator: WIDE_SEPARATOR, joiner: " " },
|
|
115
|
+
bare: { separator: NARROW_SEPARATOR, joiner: " " },
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const HEADER_LADDER: Ladder<HeaderFact> = {
|
|
119
|
+
rows: [[["model"], ["thinking"], ["sessionName"], ["sessionId"]]],
|
|
120
|
+
steps: [
|
|
121
|
+
// 1. Narrow the separators to one space.
|
|
122
|
+
["spacing", "bare"],
|
|
123
|
+
// 2. Shorten the thinking level.
|
|
124
|
+
["thinking", "short"],
|
|
125
|
+
// 3. Trim the session id to its first two segments. Last, because the
|
|
126
|
+
// full id is what finds the session again.
|
|
127
|
+
["sessionId", "short"],
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const FOOTER_LADDER: Ladder<FooterFact> = {
|
|
132
|
+
rows: [
|
|
133
|
+
[["branch"], ["cwd"]],
|
|
134
|
+
[["context", "tokens"], ["cost", "perTurn"]],
|
|
135
|
+
[["cacheSession"], ["latest"], ["reuse"]],
|
|
136
|
+
],
|
|
137
|
+
steps: [
|
|
138
|
+
// 1. Drop the labels the values already imply.
|
|
139
|
+
["tokens", "short"], ["context", "bare"], ["cacheSession", "bare"],
|
|
140
|
+
// 2. Shorten the readings: the latest cache figure, then the cost, rounded twice.
|
|
141
|
+
["latest", "short"], ["cost", "short"], ["cost", "bare"],
|
|
142
|
+
// 3. Remove whitespace: the padding inside the cwd pill, then the separators.
|
|
143
|
+
["cwd", "short"], ["spacing", "bare"],
|
|
144
|
+
// 4. Drop the branch icon.
|
|
145
|
+
["branch", "bare"],
|
|
146
|
+
// 5. Hide whole facts. The cost per turn goes last, because seeing what
|
|
147
|
+
// each turn costs is half of what the footer is for.
|
|
148
|
+
["reuse", "hidden"], ["cacheSession", "hidden"], ["tokens", "hidden"], ["perTurn", "hidden"],
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// ── Generic helpers ─────────────────────────────────────────────────────────
|
|
99
153
|
|
|
100
154
|
function joinedLine(parts: string[], separator: string): string {
|
|
101
155
|
return ` ${parts.join(separator)}`;
|
|
102
156
|
}
|
|
103
157
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/** Wrap whole parts and retain the number of parts in each row.
|
|
158
|
+
/** Wrap whole parts into lines narrower than width. A part wider than width takes a line alone.
|
|
107
159
|
* @example
|
|
108
|
-
*
|
|
160
|
+
* wrapParts(["one", "two"], 6, " · ") // [["one"], ["two"]]
|
|
109
161
|
*/
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
const lines: WrappedLine[] = [];
|
|
162
|
+
function wrapParts(parts: string[], width: number, separator: string): string[][] {
|
|
163
|
+
const lines: string[][] = [];
|
|
113
164
|
const remainingParts = [...parts];
|
|
114
165
|
while (remainingParts.length > 0) {
|
|
115
166
|
const lineParts: string[] = [];
|
|
@@ -119,11 +170,58 @@ function wrapJoinedLines(parts: string[], width: number, separator: string): Wra
|
|
|
119
170
|
lineParts.push(remainingParts.shift()!);
|
|
120
171
|
if (visibleWidth(joinedLine(lineParts, separator)) >= width) break;
|
|
121
172
|
}
|
|
122
|
-
lines.push(
|
|
173
|
+
lines.push(lineParts);
|
|
123
174
|
}
|
|
124
175
|
return lines;
|
|
125
176
|
}
|
|
126
177
|
|
|
178
|
+
type WrappedLine = { text: string; partCount: number };
|
|
179
|
+
|
|
180
|
+
/** Wrap whole parts and retain the number of parts in each row.
|
|
181
|
+
* @example
|
|
182
|
+
* wrapJoinedLines(["one", "two"], 6, " · ") // [{ text: " one", partCount: 1 }, { text: " two", partCount: 1 }]
|
|
183
|
+
*/
|
|
184
|
+
function wrapJoinedLines(parts: string[], width: number, separator: string): WrappedLine[] {
|
|
185
|
+
return wrapParts(parts, width, separator).map((lineParts) => ({
|
|
186
|
+
text: truncateToWidth(joinedLine(lineParts, separator), width),
|
|
187
|
+
partCount: lineParts.length,
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Pack rows onto lines. Rows share a line when they fit, and a row breaks only
|
|
192
|
+
* when it is wider than the width, so a fact moves between lines only with its whole row.
|
|
193
|
+
* @example
|
|
194
|
+
* packRows([["a", "b"], ["c"]], 20, " · ") // [" a · b · c"]
|
|
195
|
+
*/
|
|
196
|
+
function packRows(rows: string[][], width: number, separator: string): string[] {
|
|
197
|
+
const rowLines = rows.flatMap((row) => wrapParts(row, width, separator).map((lineParts) => lineParts.join(separator)));
|
|
198
|
+
return wrapJoinedLines(rowLines, width, separator).map((line) => line.text);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** The ladder's fullest state among those that pack the facts onto the fewest lines.
|
|
202
|
+
* A fact missing from `facts` is left out.
|
|
203
|
+
*/
|
|
204
|
+
function fitFacts<Key extends string>(
|
|
205
|
+
facts: Partial<Record<Key, FactForms>>,
|
|
206
|
+
ladder: Ladder<Key>,
|
|
207
|
+
width: number,
|
|
208
|
+
theme: Theme,
|
|
209
|
+
): string[] {
|
|
210
|
+
const linesAt = (state: number): string[] => {
|
|
211
|
+
const forms = new Map<Key | "spacing", Form>(ladder.steps.slice(0, state));
|
|
212
|
+
const spacing = forms.get("spacing") === "bare" ? SPACING.bare : SPACING.full;
|
|
213
|
+
const text = (key: Key): string => {
|
|
214
|
+
const form = forms.get(key) ?? "full";
|
|
215
|
+
const fact = facts[key];
|
|
216
|
+
return form === "hidden" || !fact ? "" : fact[form]!;
|
|
217
|
+
};
|
|
218
|
+
const rows = ladder.rows.map((row) => row.map((group) => group.map(text).filter(Boolean).join(spacing.joiner)).filter(Boolean));
|
|
219
|
+
return packRows(rows, width, theme.fg("dim", spacing.separator));
|
|
220
|
+
};
|
|
221
|
+
const states = Array.from({ length: ladder.steps.length + 1 }, (_, state) => linesAt(state));
|
|
222
|
+
return states.find((lines) => lines.length === states.at(-1)!.length)!;
|
|
223
|
+
}
|
|
224
|
+
|
|
127
225
|
/** Cut the middle of a name down to maxLength, marking the cut with an ellipsis.
|
|
128
226
|
* @example
|
|
129
227
|
* middleTruncate("cautious-refactor", 9) // "caut…ctor"
|
|
@@ -199,16 +297,14 @@ function trimSessionPrefix(session: string, cwd: string): string {
|
|
|
199
297
|
: session;
|
|
200
298
|
}
|
|
201
299
|
|
|
202
|
-
type
|
|
300
|
+
type DisplaySession = { name: string | null; id: string | null };
|
|
203
301
|
|
|
204
|
-
function
|
|
205
|
-
const customName = pi.getSessionName?.() || null;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const idPart = sessionId ? [{ text: sessionId, token: "dim" } as const] : [];
|
|
211
|
-
return [namePart, ...idPart];
|
|
302
|
+
function getDisplaySession(ctx: any, cwd: string, pi: ExtensionAPI): DisplaySession {
|
|
303
|
+
const customName: string | null = pi.getSessionName?.() || null;
|
|
304
|
+
return {
|
|
305
|
+
name: customName && trimSessionPrefix(customName, cwd),
|
|
306
|
+
id: ctx.sessionManager?.getSessionId?.() || null,
|
|
307
|
+
};
|
|
212
308
|
}
|
|
213
309
|
|
|
214
310
|
function getSkillLocations(pi: ExtensionAPI): SkillLocation[] {
|
|
@@ -372,8 +468,7 @@ function ctxGauge(pct: number): string {
|
|
|
372
468
|
return CONTEXT_GAUGE_SYMBOLS[stepIndex]!;
|
|
373
469
|
}
|
|
374
470
|
|
|
375
|
-
function renderThinkingLabel(theme: any, level: string, full: boolean): string
|
|
376
|
-
if (!level) return null;
|
|
471
|
+
function renderThinkingLabel(theme: any, level: string, full: boolean): string {
|
|
377
472
|
const info = THINKING_LEVELS[level];
|
|
378
473
|
if (!info) return level;
|
|
379
474
|
const label = full ? info.full : info.short;
|
|
@@ -479,7 +574,7 @@ interface FooterSnapshot {
|
|
|
479
574
|
model: ExtensionContext["model"];
|
|
480
575
|
stats: SessionStats;
|
|
481
576
|
context: ReturnType<typeof getContextPercent>;
|
|
482
|
-
|
|
577
|
+
session: DisplaySession;
|
|
483
578
|
}
|
|
484
579
|
|
|
485
580
|
// ── Extension entry point ───────────────────────────────────────────────────
|
|
@@ -523,7 +618,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
523
618
|
snapshot = {
|
|
524
619
|
manager, sessionId, leafId, model, stats,
|
|
525
620
|
context: getContextPercent(currentCtx, stats.lastContextTokens, usage),
|
|
526
|
-
|
|
621
|
+
session: getDisplaySession(currentCtx, currentCtx.cwd || ".", pi),
|
|
527
622
|
};
|
|
528
623
|
return snapshot;
|
|
529
624
|
}
|
|
@@ -531,9 +626,17 @@ export default function (pi: ExtensionAPI) {
|
|
|
531
626
|
function renderAbove(width: number, terminalHeight: number, theme: Theme): string[] {
|
|
532
627
|
if (!currentCtx) return [];
|
|
533
628
|
const paint = makePainter(theme);
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
629
|
+
const { session } = getSnapshot();
|
|
630
|
+
// Weight is reserved for the pill and for thinking at high and above, so
|
|
631
|
+
// the model carries its family hue and nothing more.
|
|
632
|
+
const headerFacts: Partial<Record<HeaderFact, FactForms>> = {
|
|
633
|
+
model: { full: paint.token(MACHINE_TOKEN, formatModel(currentCtx.model)) },
|
|
634
|
+
thinking: { full: renderThinkingLabel(theme, thinkingLevel, true), short: renderThinkingLabel(theme, thinkingLevel, false) },
|
|
635
|
+
sessionName: session.name ? { full: theme.fg("text", session.name) } : undefined,
|
|
636
|
+
sessionId: session.id
|
|
637
|
+
? { full: theme.fg("dim", session.id), short: theme.fg("dim", session.id.split("-").slice(0, 2).join("-")) }
|
|
638
|
+
: undefined,
|
|
639
|
+
};
|
|
537
640
|
// No background here: the cwd pill is the one filled element in the whole
|
|
538
641
|
// footer, and a second pill style would leave neither of them the anchor.
|
|
539
642
|
const renderSkillLines = (layout: SkillLayout) => wrapJoinedLines(
|
|
@@ -545,12 +648,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
545
648
|
width,
|
|
546
649
|
theme.fg("dim", layout.separator),
|
|
547
650
|
);
|
|
548
|
-
// Weight is reserved for the pill and for thinking at high and above, so
|
|
549
|
-
// the model carries its family hue and nothing more.
|
|
550
|
-
const parts = [paint.token(MACHINE_TOKEN, model)];
|
|
551
|
-
if (thinking) parts.push(thinking);
|
|
552
|
-
parts.push(...sessionParts);
|
|
553
|
-
const separator = theme.fg("dim", WIDE_SEPARATOR);
|
|
554
651
|
// A short terminal takes the fullest layout that fits the row limit. Hiding
|
|
555
652
|
// skills behind a count is the last resort, after the most compact layout.
|
|
556
653
|
const shortTerminal = terminalHeight <= SHORT_TERMINAL_HEIGHT;
|
|
@@ -563,7 +660,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
563
660
|
const hiddenSkillCount = skillLines.slice(visibleSkillLines.length).reduce((count, line) => count + line.partCount, 0);
|
|
564
661
|
const overflowLines = hiddenSkillCount === 0 ? [] : [truncateToWidth(theme.fg("dim", ` +${hiddenSkillCount} skills`), width)];
|
|
565
662
|
return [
|
|
566
|
-
...
|
|
663
|
+
...fitFacts(headerFacts, HEADER_LADDER, width, theme),
|
|
567
664
|
...visibleSkillLines.map((line) => line.text),
|
|
568
665
|
...overflowLines,
|
|
569
666
|
];
|
|
@@ -573,51 +670,20 @@ export default function (pi: ExtensionAPI) {
|
|
|
573
670
|
if (!currentCtx) return [];
|
|
574
671
|
const { stats, context: { pct, window, tokens } } = getSnapshot();
|
|
575
672
|
const paint = makePainter(theme);
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
width: number,
|
|
583
|
-
theme: any,
|
|
584
|
-
paint: Painter,
|
|
585
|
-
stats: SessionStats,
|
|
586
|
-
pct: number,
|
|
587
|
-
window: number,
|
|
588
|
-
tokens: number,
|
|
589
|
-
): string[] {
|
|
590
|
-
const separator = theme.fg("dim", WIDE_SEPARATOR);
|
|
591
|
-
const label = (text: string) => theme.fg("dim", text.padEnd(8));
|
|
592
|
-
const cwd = currentCtx.cwd || ".";
|
|
593
|
-
|
|
594
|
-
const locationParts: string[] = [];
|
|
595
|
-
if (gitBranch) {
|
|
596
|
-
// A dirty worktree is a property of the place, not a cost, so it stays
|
|
597
|
-
// in the place family and leaves `warning` meaning spend alone.
|
|
598
|
-
const dirty = gitDirty ? paint.token(PLACE_TOKEN, "*") : "";
|
|
599
|
-
locationParts.push(`${paint.token(PLACE_TOKEN, ` ${gitBranch}`)}${dirty}`);
|
|
600
|
-
}
|
|
601
|
-
locationParts.push(theme.bg("selectedBg", paint.token(PLACE_TOKEN, theme.bold(` ${currentDirectoryName(cwd)}/ `))));
|
|
602
|
-
const locationLine = truncateToWidth(` ${locationParts.join(separator)}`, width);
|
|
603
|
-
|
|
673
|
+
const label = (text: string) => theme.fg("dim", `${text} `);
|
|
674
|
+
const pill = (text: string) => theme.bg("selectedBg", paint.token(PLACE_TOKEN, theme.bold(text)));
|
|
675
|
+
const directory = currentDirectoryName(currentCtx.cwd || ".");
|
|
676
|
+
// A dirty worktree is a property of the place, not a cost, so it stays in
|
|
677
|
+
// the place family and leaves `warning` meaning spend alone.
|
|
678
|
+
const dirty = gitDirty ? paint.token(PLACE_TOKEN, "*") : "";
|
|
604
679
|
const gauge = paint.ramp(CONTEXT_STOPS, pct, `${ctxGauge(pct)} ${Math.round(pct)}%`);
|
|
605
680
|
// Colour the figure that moves and leave its reference quiet, so the eye
|
|
606
681
|
// lands on the reading rather than on the window size beside it.
|
|
607
|
-
const
|
|
608
|
-
paint.ramp(CONTEXT_STOPS, pct, formatTokens(tokens)) +
|
|
609
|
-
theme.fg("dim", ` / ${formatTokens(window)} tokens`);
|
|
682
|
+
const usedTokens = paint.ramp(CONTEXT_STOPS, pct, formatTokens(tokens));
|
|
610
683
|
const usingSubscription = currentCtx.model
|
|
611
684
|
? currentCtx.modelRegistry?.isUsingOAuth?.(currentCtx.model)
|
|
612
685
|
: false;
|
|
613
|
-
const
|
|
614
|
-
const subLabel = usingSubscription ? theme.fg("muted", " sub") : "";
|
|
615
|
-
const perTurn = paint.quiet(SPEND_TOKEN, `$${formatCost(stats.averageCostPerTurn)}/turn`);
|
|
616
|
-
const contextLine = truncateToWidth(
|
|
617
|
-
` ${label("context")}${gauge} ${contextValue}${separator}${costText}${subLabel} ${perTurn}`,
|
|
618
|
-
width,
|
|
619
|
-
);
|
|
620
|
-
|
|
686
|
+
const cost = (amount: string) => paint.token(SPEND_TOKEN, `$${amount}`) + (usingSubscription ? theme.fg("muted", " sub") : "");
|
|
621
687
|
// A hit rate is a measurement, so it rides the ramp. The old cliff at 80%
|
|
622
688
|
// made 79% and 20% look identical and threw the reading away.
|
|
623
689
|
const sessionHit = stats.sessionCacheHitRate;
|
|
@@ -625,50 +691,31 @@ export default function (pi: ExtensionAPI) {
|
|
|
625
691
|
? paint.ramp(CACHE_STOPS, sessionHit, `${sessionHit.toFixed(1)}% session`)
|
|
626
692
|
: theme.fg("dim", "no cache yet");
|
|
627
693
|
const latestHit = stats.latestCacheHitRate;
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
:
|
|
631
|
-
? paint.
|
|
632
|
-
:
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
const dirty = gitDirty ? paint.token(PLACE_TOKEN, "*") : "";
|
|
654
|
-
locationParts.push(`${paint.token(PLACE_TOKEN, gitBranch)}${dirty}`);
|
|
655
|
-
}
|
|
656
|
-
// The pill earns its two columns most here: a split pane is where you are
|
|
657
|
-
// least sure which session you are looking at.
|
|
658
|
-
locationParts.push(theme.bg("selectedBg", paint.token(PLACE_TOKEN, theme.bold(` ${currentDirectoryName(cwd)}/ `))));
|
|
659
|
-
const locationLine = truncateToWidth(` ${locationParts.join(NARROW_SEPARATOR)}`, width);
|
|
660
|
-
|
|
661
|
-
const gauge = paint.ramp(CONTEXT_STOPS, pct, `${Math.round(pct)}%/${formatTokens(window)}`);
|
|
662
|
-
const latestHit = stats.latestCacheHitRate;
|
|
663
|
-
const cache = stats.latestCacheMissTokens != null
|
|
664
|
-
? theme.fg("error", `miss ${formatTokens(stats.latestCacheMissTokens)}`)
|
|
665
|
-
: latestHit != null
|
|
666
|
-
? paint.ramp(CACHE_STOPS, latestHit, `latest ${Math.round(latestHit)}%`)
|
|
667
|
-
: "";
|
|
668
|
-
const cost = paint.token(SPEND_TOKEN, `$${formatCost(stats.totalCost)}`);
|
|
669
|
-
const dataLine = truncateToWidth(` ${[gauge, cache, cost].filter(Boolean).join(NARROW_SEPARATOR)}`, width);
|
|
670
|
-
|
|
671
|
-
return [locationLine, dataLine];
|
|
694
|
+
const missedTokens = stats.latestCacheMissTokens;
|
|
695
|
+
const footerFacts: Partial<Record<FooterFact, FactForms>> = {
|
|
696
|
+
branch: gitBranch
|
|
697
|
+
? { full: `${paint.token(PLACE_TOKEN, `${BRANCH_GLYPH} ${gitBranch}`)}${dirty}`, bare: `${paint.token(PLACE_TOKEN, gitBranch)}${dirty}` }
|
|
698
|
+
: undefined,
|
|
699
|
+
cwd: { full: pill(` ${directory}/ `), short: pill(`${directory}/`) },
|
|
700
|
+
context: { full: `${label("context")}${gauge}`, bare: gauge },
|
|
701
|
+
tokens: {
|
|
702
|
+
full: `${usedTokens}${theme.fg("dim", ` / ${formatTokens(window)} tokens`)}`,
|
|
703
|
+
short: `${usedTokens}${theme.fg("dim", ` / ${formatTokens(window)}`)}`,
|
|
704
|
+
},
|
|
705
|
+
cost: { full: cost(formatCost(stats.totalCost)), short: cost(stats.totalCost.toFixed(1)), bare: cost(stats.totalCost.toFixed(0)) },
|
|
706
|
+
perTurn: { full: paint.quiet(SPEND_TOKEN, `$${formatCost(stats.averageCostPerTurn)}/turn`) },
|
|
707
|
+
cacheSession: { full: `${label("cache")}${sessionHitText}`, bare: sessionHitText },
|
|
708
|
+
latest: missedTokens != null
|
|
709
|
+
? { full: theme.fg("error", `latest miss ${formatTokens(missedTokens)} re-billed`), short: theme.fg("error", `miss ${formatTokens(missedTokens)}`) }
|
|
710
|
+
: latestHit != null
|
|
711
|
+
? { full: paint.ramp(CACHE_STOPS, latestHit, `latest ${latestHit.toFixed(1)}%`), short: paint.ramp(CACHE_STOPS, latestHit, `latest ${Math.round(latestHit)}%`) }
|
|
712
|
+
: undefined,
|
|
713
|
+
reuse: {
|
|
714
|
+
full: paint.ramp(CACHE_STOPS, sessionHit ?? 0, formatTokens(stats.totalReused)) +
|
|
715
|
+
theme.fg("dim", ` reused / ${formatTokens(stats.totalFresh)} new`),
|
|
716
|
+
},
|
|
717
|
+
};
|
|
718
|
+
return fitFacts(footerFacts, FOOTER_LADDER, width, theme);
|
|
672
719
|
}
|
|
673
720
|
|
|
674
721
|
// ── Git ───────────────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@giladbarnea/pi-custom-footer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Context, cache, cost, and loaded skills at a glance in Pi.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"LICENSE"
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
|
-
"test": "node tests/skills.mjs && node tests/cache.mjs && node tests/load.mjs",
|
|
31
|
+
"test": "node tests/skills.mjs && node tests/cache.mjs && node tests/layout.mjs && node tests/load.mjs",
|
|
32
32
|
"check": "tsc --noEmit"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|