@henryqw/pi-footer 0.2.2 → 0.3.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.
- package/README.md +2 -2
- package/extensions/footer.ts +15 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,13 +23,13 @@ pi install npm:@henryqw/pi-footer
|
|
|
23
23
|
|
|
24
24
|
```text
|
|
25
25
|
pi-packages · clear-field-f8d2 · PR #123 · approved
|
|
26
|
-
↑ 12.4k · ↓ 2.1k · ↺ 84.3% · $ 0.127 · ◔ 36.8% gpt-5.6-luna • high
|
|
26
|
+
↑ 12.4k · ↓ 2.1k · ↺ 84.3% · ⚡ 87.4 t/s · $ 0.127 · ◔ 36.8% gpt-5.6-luna • high
|
|
27
27
|
Codex #1 · 50% · 7d 1d 1h 22m
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
First line shows repository, branch, and pull request status (`pi-pr`) after clickable checkout link. Linked-worktree branches drop generated `worktree/` prefix.
|
|
31
31
|
|
|
32
|
-
Second line shows cumulative input tokens, output tokens, latest cache-hit rate, estimated cost, and context usage. Unavailable values render as `—` without a misleading percent sign. Active model and thinking level are right-aligned.
|
|
32
|
+
Second line shows cumulative input tokens, output tokens, latest cache-hit rate, tokens per second of the most recent assistant response, estimated cost, and context usage. Unavailable values render as `—` without a misleading percent sign. Active model and thinking level are right-aligned.
|
|
33
33
|
|
|
34
34
|
`off` uses the same dim grey as the model name. Active levels use an ANSI-256 gradient: green `minimal`, yellow-green `low`, lime `medium`, yellow `high`, orange `xhigh`, and red `max`. `ultra` renders as a rainbow when the runtime supplies it. Pi 0.84.2 does not yet accept `ultra`, so that footer path remains unreachable until Pi adds it.
|
|
35
35
|
|
package/extensions/footer.ts
CHANGED
|
@@ -53,6 +53,19 @@ export default function footerExtension(pi: ExtensionAPI): void {
|
|
|
53
53
|
const commonName = commonDir && basename(commonDir) === ".git" ? basename(dirname(commonDir)) : undefined;
|
|
54
54
|
const repo = git.code === 0 ? commonName && commonName !== rootName ? commonName : rootName : basename(ctx.cwd);
|
|
55
55
|
|
|
56
|
+
let tps: number | undefined;
|
|
57
|
+
let assistantStartedAt: number | undefined;
|
|
58
|
+
pi.on("message_start", async (event) => {
|
|
59
|
+
if (event.message.role === "assistant") assistantStartedAt = performance.now();
|
|
60
|
+
});
|
|
61
|
+
pi.on("message_end", async (event) => {
|
|
62
|
+
if (event.message.role !== "assistant") return;
|
|
63
|
+
const output = event.message.usage?.output ?? 0;
|
|
64
|
+
const seconds = assistantStartedAt === undefined ? 0 : (performance.now() - assistantStartedAt) / 1000;
|
|
65
|
+
assistantStartedAt = undefined;
|
|
66
|
+
tps = seconds > 0 ? output / seconds : undefined;
|
|
67
|
+
});
|
|
68
|
+
|
|
56
69
|
// ponytail: keyed on length + last entry (sessions are append-only); revisit if entries ever mutate in place.
|
|
57
70
|
let usageKey: string | undefined;
|
|
58
71
|
let input = 0;
|
|
@@ -115,7 +128,8 @@ export default function footerExtension(pi: ExtensionAPI): void {
|
|
|
115
128
|
`↑ ${formatTokens(input)}`,
|
|
116
129
|
`↓ ${formatTokens(output)}`,
|
|
117
130
|
`↺ ${cacheRate === undefined ? "—" : `${cacheRate.toFixed(1)}%`}`,
|
|
118
|
-
|
|
131
|
+
`⚡ ${tps === undefined ? "—" : `${tps.toFixed(1)} t/s`}`,
|
|
132
|
+
`$ ${cost.toFixed(3)}`,
|
|
119
133
|
`◔ ${context == null ? "—" : `${context.toFixed(1)}%`}`,
|
|
120
134
|
].join(" · "));
|
|
121
135
|
const thinkingText = thinking === "ultra"
|