pi-status-footer 1.0.4 β 1.0.5
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 +15 -14
- package/package.json +2 -2
- package/stats-footer.ts +111 -40
package/README.md
CHANGED
|
@@ -7,15 +7,15 @@ A compact, zero-config two-line status footer for [pi](https://github.com/earend
|
|
|
7
7
|

|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
|
|
11
|
-
π my-project βΈ ξ₯ main
|
|
10
|
+
π¦ 38%/128k πΎ 63% β5.2k β8.1k β‘42 t/s β³ 4:32 π¬ 1:18
|
|
11
|
+
π my-project βΈ ξ₯ main +3 -1 π€ openai/ry-very-long-modelid-4o π medium
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
**Line 1 β
|
|
14
|
+
**Line 1 β Stats & timers:** context window usage with color-coded fullness (green < 60%, yellow < 80%, red β₯ 80%), cache hit rate, input/output tokens, tokens per second (live while streaming), agent run timer (β³), current turn timer (π¬).
|
|
15
15
|
|
|
16
|
-
**Line 2 β Project &
|
|
16
|
+
**Line 2 β Project & model:** repo folder name, git branch, live working-tree diff from HEAD (+N added lines, -M deleted), provider/model, thinking level with themed color.
|
|
17
17
|
|
|
18
|
-
Everything auto-fits to your terminal width
|
|
18
|
+
Everything auto-fits to your terminal width. Line 1 always keeps every segment (it clips only on very narrow terminals). On line 2 the model is mandatory: the model id is shortened from the left, keeping the provider and thinking level intact β only if even that can't fit does the folder/git group drop off.
|
|
19
19
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
@@ -25,7 +25,8 @@ Everything auto-fits to your terminal width β lower-priority segments drop off
|
|
|
25
25
|
- **Cache hit rate** β percentage of prompt tokens served from cache
|
|
26
26
|
- **Context gauge** β percentage and raw max; shifts from green β yellow β red as you approach the limit
|
|
27
27
|
- **Thinking level** β color-coded to match pi's thinking theme
|
|
28
|
-
- **
|
|
28
|
+
- **Responsive model id** β shortened from the left (with an `β¦` marker) when space is tight, so the provider and thinking level stay fully readable; the folder/git group drops only when the model still can't share the line
|
|
29
|
+
- **Line 1 never drops stats** β every stat segment always renders; on very narrow terminals the line clips instead
|
|
29
30
|
- **East Asian safe** β explicit ambiguous-width handling for CJK-friendly terminals
|
|
30
31
|
- **Safe at all times** β footer rendering never crashes the TUI, even on edge cases
|
|
31
32
|
|
|
@@ -46,26 +47,26 @@ After installation, the footer appears automatically on the next pi TUI session.
|
|
|
46
47
|
|
|
47
48
|
## Display reference
|
|
48
49
|
|
|
49
|
-
### Line 1 β
|
|
50
|
+
### Line 1 β Stats & timers
|
|
50
51
|
|
|
51
52
|
| Segment | Example | Source |
|
|
52
53
|
|---|---|---|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
54
|
+
| π¦context | `π¦ 38%/128k` | `ctx.getContextUsage()`, color-coded by percent |
|
|
55
|
+
| πΎcache | `πΎ 63%` | `cacheRead / (input + cacheRead + cacheWrite)` |
|
|
55
56
|
| βinput βoutput | `β5.2k β8.1k` | Session `usage.input / usage.output` (accumulated across all entries) |
|
|
56
57
|
| β‘tps | `β‘42 t/s` | Live during generation; last completed rate shown between turns |
|
|
57
|
-
|
|
|
58
|
-
|
|
|
58
|
+
| β³ working | `β³ 4:32` | Elapsed time since `agent_start`, HH:MM:SS above 1h |
|
|
59
|
+
| π¬ turn | `π¬ 1:18` | Elapsed time since last `turn_start` |
|
|
59
60
|
|
|
60
|
-
### Line 2 β Project &
|
|
61
|
+
### Line 2 β Project & model
|
|
61
62
|
|
|
62
63
|
| Segment | Example | Source |
|
|
63
64
|
|---|---|---|
|
|
64
65
|
| π repo | `π my-project` | Git repo root basename (from `ctx.cwd` walk-up) |
|
|
65
66
|
| βΈ ξ₯ branch | `βΈ ξ₯ main` | `footerData.getGitBranch()`, auto-updates |
|
|
66
67
|
| +N -M diff | `+3 -1` | Async `git diff --shortstat HEAD` (1s debounced) |
|
|
67
|
-
|
|
|
68
|
-
|
|
|
68
|
+
| π€ model | `π€ openai/gpt-4o` | `ctx.model.provider / ctx.model.id`, id shortened from the left when narrow |
|
|
69
|
+
| π thinking | `π high` | `ctx.thinkingLevel`, themed via `theme.fg()` |
|
|
69
70
|
|
|
70
71
|
## How it works
|
|
71
72
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-status-footer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Compact two-line status footer for pi: model, thinking level, tokens, TPS, cache hit rate, context usage, live git diff, and working/turn timers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"streaming"
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
|
-
"test": "node --experimental-strip-types test-live-tps.ts"
|
|
32
|
+
"test": "node --experimental-strip-types test-live-tps.ts && node --experimental-strip-types test-layout.ts"
|
|
33
33
|
},
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"repository": {
|
package/stats-footer.ts
CHANGED
|
@@ -202,24 +202,94 @@ function joinSegments(segments: string[], separator: string): string {
|
|
|
202
202
|
return segments.filter(Boolean).join(separator);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
/** Below this terminal width the footer gives up fitting and lets the line
|
|
206
|
+
* overflow (the TUI clips it); shortening arithmetic degenerates here. */
|
|
207
|
+
const MIN_FIT_WIDTH = 50;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Shorten a model id by dropping leading characters, keeping the trailing
|
|
211
|
+
* part (model ids usually end in the distinguishing version, e.g. `...-4o`).
|
|
212
|
+
* A leading ellipsis marks the cut. Returns "" when nothing fits.
|
|
213
|
+
*/
|
|
214
|
+
export function shortenModelId(
|
|
215
|
+
id: string,
|
|
216
|
+
budget: number,
|
|
217
|
+
ellipsis = "β¦",
|
|
209
218
|
): string {
|
|
210
|
-
if (
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
219
|
+
if (budget <= 0) return "";
|
|
220
|
+
if (measureWidth(id) <= budget) return id;
|
|
221
|
+
const ellipsisWidth = measureWidth(ellipsis);
|
|
222
|
+
if (budget < ellipsisWidth) return "";
|
|
223
|
+
const chars = Array.from(id);
|
|
224
|
+
for (let start = 0; start < chars.length; start++) {
|
|
225
|
+
const candidate = ellipsis + chars.slice(start).join("");
|
|
226
|
+
if (measureWidth(candidate) <= budget) return candidate;
|
|
216
227
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
228
|
+
return ellipsis;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface SecondLineParts {
|
|
232
|
+
/** Folder/branch/diff group; "" when there is no folder to show. */
|
|
233
|
+
gitGroup: string;
|
|
234
|
+
/** Prefix before the provider, e.g. "π€ ". */
|
|
235
|
+
modelPrefix: string;
|
|
236
|
+
/** Provider name; may be "" when no model is selected. */
|
|
237
|
+
provider: string;
|
|
238
|
+
/** Model id, shortened from the left when space is tight. */
|
|
239
|
+
modelId: string;
|
|
240
|
+
/** Everything after the model id, e.g. " π medium". */
|
|
241
|
+
modelSuffix: string;
|
|
242
|
+
/** Between-segment separator. */
|
|
243
|
+
separator: string;
|
|
244
|
+
/** Color wrapper applied to the `provider/id` text. */
|
|
245
|
+
styleModelId?: (text: string) => string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Line 2 = folder/git group + model segment. The model (provider + thinking
|
|
250
|
+
* level) is mandatory: when space is tight the model id loses leading
|
|
251
|
+
* characters first, and if even a bare `provider/` cannot share the line the
|
|
252
|
+
* whole git group is dropped.
|
|
253
|
+
*/
|
|
254
|
+
export function fitSecondLine(parts: SecondLineParts, width: number): string {
|
|
255
|
+
const {
|
|
256
|
+
gitGroup,
|
|
257
|
+
modelPrefix,
|
|
258
|
+
provider,
|
|
259
|
+
modelId,
|
|
260
|
+
modelSuffix,
|
|
261
|
+
separator,
|
|
262
|
+
styleModelId = (text: string) => text,
|
|
263
|
+
} = parts;
|
|
264
|
+
const providerPrefix = provider ? `${provider}/` : "";
|
|
265
|
+
const fixedWidth =
|
|
266
|
+
measureWidth(modelPrefix) +
|
|
267
|
+
measureWidth(providerPrefix) +
|
|
268
|
+
measureWidth(modelSuffix);
|
|
269
|
+
const buildModel = (budget: number): string | null => {
|
|
270
|
+
if (fixedWidth > budget) return null;
|
|
271
|
+
const idText = shortenModelId(modelId, budget - fixedWidth);
|
|
272
|
+
return `${modelPrefix}${styleModelId(`${providerPrefix}${idText}`)}${modelSuffix}`;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const fullModel = buildModel(Number.POSITIVE_INFINITY)!;
|
|
276
|
+
if (width < MIN_FIT_WIDTH) {
|
|
277
|
+
// Too narrow to fit meaningfully β render everything and let the TUI clip.
|
|
278
|
+
return joinSegments([gitGroup, fullModel], separator);
|
|
221
279
|
}
|
|
222
|
-
|
|
280
|
+
const maxWidth = Math.max(0, width - SAFETY_MARGIN);
|
|
281
|
+
if (!gitGroup) return buildModel(maxWidth) ?? fullModel;
|
|
282
|
+
|
|
283
|
+
const full = joinSegments([gitGroup, fullModel], separator);
|
|
284
|
+
if (measureWidth(full) <= maxWidth) return full;
|
|
285
|
+
|
|
286
|
+
const withGit = buildModel(
|
|
287
|
+
maxWidth - measureWidth(gitGroup) - measureWidth(separator),
|
|
288
|
+
);
|
|
289
|
+
if (withGit !== null) return joinSegments([gitGroup, withGit], separator);
|
|
290
|
+
|
|
291
|
+
// The model alone can't share the line: drop the whole folder/git group.
|
|
292
|
+
return buildModel(maxWidth) ?? fullModel;
|
|
223
293
|
}
|
|
224
294
|
|
|
225
295
|
/** Walk up from cwd to find the git repo root directory (or null). */
|
|
@@ -358,9 +428,6 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
358
428
|
else contextColor = "success";
|
|
359
429
|
}
|
|
360
430
|
|
|
361
|
-
const modelId = ctx.model
|
|
362
|
-
? `${ctx.model.provider}/${ctx.model.id}`
|
|
363
|
-
: "no-model";
|
|
364
431
|
const thinkingLevel = ctx.thinkingLevel || "off";
|
|
365
432
|
const contextText =
|
|
366
433
|
contextPercent === null
|
|
@@ -385,34 +452,35 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
385
452
|
// TPS: live rate while the current assistant message streams,
|
|
386
453
|
// falling back to the last completed message's rate so the value
|
|
387
454
|
// keeps a fixed position instead of flashing only at message_end.
|
|
388
|
-
let tpsSuffix = "";
|
|
389
455
|
const liveTps =
|
|
390
456
|
genStart !== null && liveOutput > 0
|
|
391
457
|
? computeTps(liveOutput, genStart, Date.now())
|
|
392
458
|
: null;
|
|
393
459
|
const tpsValue = liveTps ?? lastTps;
|
|
394
|
-
|
|
395
|
-
//
|
|
396
|
-
|
|
460
|
+
// Line 1 β stats only (context, cache, tokens, TPS, timers). Every
|
|
461
|
+
// segment always renders; on very narrow terminals the line overflows
|
|
462
|
+
// and the TUI clips it rather than dropping stats.
|
|
463
|
+
const statsLine = joinSegments(
|
|
397
464
|
[
|
|
398
|
-
|
|
465
|
+
`π¦ ${theme.fg(contextColor, contextText)}`,
|
|
399
466
|
theme.fg(
|
|
400
467
|
"dim",
|
|
401
|
-
|
|
468
|
+
`πΎ ${cacheRate === null ? "-" : `${cacheRate.toFixed(0)}%`}`,
|
|
402
469
|
),
|
|
403
470
|
theme.fg(
|
|
404
471
|
"dim",
|
|
405
|
-
|
|
472
|
+
`β${formatTokens(usage.input)} β${formatTokens(usage.output)}`,
|
|
406
473
|
),
|
|
407
|
-
|
|
474
|
+
theme.fg("dim", `β‘${Math.round(tpsValue ?? 0)} t/s`),
|
|
475
|
+
`β³ ${theme.fg("accent", formatDuration(elapsed))}`,
|
|
476
|
+
`π¬ ${theme.fg("accent", formatDuration(turnElapsed))}`,
|
|
408
477
|
],
|
|
409
478
|
separator,
|
|
410
|
-
Math.max(0, width - SAFETY_MARGIN),
|
|
411
479
|
);
|
|
412
|
-
// Line 2 β folder/git status +
|
|
413
|
-
//
|
|
414
|
-
//
|
|
415
|
-
//
|
|
480
|
+
// Line 2 β folder/git status + model/thinking. The folder name
|
|
481
|
+
// always shows (repo root basename, or plain cwd basename when
|
|
482
|
+
// not inside a git repo); branch + diff only when git is present.
|
|
483
|
+
// The model id is shortened from the left before git is dropped.
|
|
416
484
|
const branch = footerData.getGitBranch();
|
|
417
485
|
const gitSegments: string[] = [];
|
|
418
486
|
if (folderName !== null) {
|
|
@@ -430,15 +498,18 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
430
498
|
gitSegments.push(folderText);
|
|
431
499
|
}
|
|
432
500
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
501
|
+
const gitGroup = joinSegments(gitSegments, separator);
|
|
502
|
+
const gitLine = fitSecondLine(
|
|
503
|
+
{
|
|
504
|
+
gitGroup,
|
|
505
|
+
modelPrefix: "π€ ",
|
|
506
|
+
provider: ctx.model?.provider ?? "",
|
|
507
|
+
modelId: ctx.model?.id ?? "no-model",
|
|
508
|
+
modelSuffix: ` ${thinkingText}`,
|
|
509
|
+
separator,
|
|
510
|
+
styleModelId: (text) => theme.fg("accent", text),
|
|
511
|
+
},
|
|
512
|
+
width,
|
|
442
513
|
);
|
|
443
514
|
|
|
444
515
|
return [
|