@erichll/pi-statusline 0.10.0 → 0.11.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/CHANGELOG.md +10 -0
- package/README.md +3 -2
- package/examples/statusline.json +4 -0
- package/package.json +1 -1
- package/src/config.ts +3 -2
- package/src/index.ts +2 -2
- package/src/render.ts +10 -4
- package/src/session.ts +21 -1
- package/src/types.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.0 - 2026-11-20
|
|
4
|
+
|
|
5
|
+
- Add a `speed` segment, enabled by default, that shows the `service_tier` of
|
|
6
|
+
the latest provider request (`fast` for `priority`, `Ultra Fast` for
|
|
7
|
+
`ultrafast`, `flex`). It is read from the outgoing payload, so it shows what
|
|
8
|
+
was actually requested; it works with CLIProxyAPI's `/fast` and `/ultrafast`
|
|
9
|
+
modes, which the replaced built-in footer could no longer label. It is hidden
|
|
10
|
+
until a request carries a tier, and cleared on a model switch. Existing
|
|
11
|
+
segment lists gain it before `context` unless they list it explicitly.
|
|
12
|
+
|
|
3
13
|
## 0.10.0 - 2026-11-03
|
|
4
14
|
|
|
5
15
|
- Mark the cost segment when the summed USD total is a catalog estimate or
|
package/README.md
CHANGED
|
@@ -81,6 +81,7 @@ Available segments:
|
|
|
81
81
|
| ID | Data | Default |
|
|
82
82
|
| --- | --- | --- |
|
|
83
83
|
| `model`, `thinking` | Model and colored `(level)` suffix | On |
|
|
84
|
+
| `speed` | Service tier of the latest provider request: `fast` (`priority`), `Ultra Fast` (`ultrafast`) or `flex`; hidden when the request carried none or before the first request after a model switch | On |
|
|
84
85
|
| `context` | Current context usage | On |
|
|
85
86
|
| `quota` | Subscription Usage and reset countdowns; hidden without data | On |
|
|
86
87
|
| `directory` | Current directory | On |
|
|
@@ -94,8 +95,8 @@ Available segments:
|
|
|
94
95
|
|
|
95
96
|
`segments` is an ordered array of
|
|
96
97
|
`{ id, enabled, icon?, color?, iconColor?, background? }`. Omitted segments are
|
|
97
|
-
disabled, **except `quota`, `session` and `toolTotal`**: old configurations automatically
|
|
98
|
-
gain `quota` after `context`, and `session` and `toolTotal` before `tokens` (or at the end when
|
|
98
|
+
disabled, **except `quota`, `speed`, `session` and `toolTotal`**: old configurations automatically
|
|
99
|
+
gain `quota` after `context`, `speed` before `context`, and `session` and `toolTotal` before `tokens` (or at the end when
|
|
99
100
|
the anchor is absent). To keep one off, include it with `"enabled": false`.
|
|
100
101
|
|
|
101
102
|
Colors accept `#RRGGBB` or supported Pi theme tokens such as `accent`, `muted`,
|
package/examples/statusline.json
CHANGED
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -10,7 +10,7 @@ export function validColor(value: unknown): value is ColorValue {
|
|
|
10
10
|
return typeof value === "string" && (/^#[\da-f]{6}$/i.test(value) || (COLORS as readonly string[]).includes(value));
|
|
11
11
|
}
|
|
12
12
|
export function presetConfig(): StatuslineConfig {
|
|
13
|
-
const enabled = new Set<string>(["model", "thinking", "directory", "git", "context", "quota", "session", "toolTotal", "tokens", "statuses"]);
|
|
13
|
+
const enabled = new Set<string>(["model", "thinking", "speed", "directory", "git", "context", "quota", "session", "toolTotal", "tokens", "statuses"]);
|
|
14
14
|
return {
|
|
15
15
|
version: 1, enabled: true, preset: "powerline", icons: "nerd",
|
|
16
16
|
separator: "powerline", pathMode: "basename", modelDisplay: "name", contextDisplay: "bar", spacing: 1,
|
|
@@ -80,13 +80,14 @@ export function parseConfig(raw: unknown): StatuslineConfig {
|
|
|
80
80
|
return result;
|
|
81
81
|
});
|
|
82
82
|
// Upgrade older lists once with segments added later; an explicit entry (including disabled) wins.
|
|
83
|
-
const insert = (id: "quota" | "session" | "toolTotal", index: number) => {
|
|
83
|
+
const insert = (id: "quota" | "speed" | "session" | "toolTotal", index: number) => {
|
|
84
84
|
if (seen.has(id)) return;
|
|
85
85
|
config.segments.splice(index < 0 ? config.segments.length : index, 0, { id, enabled: true });
|
|
86
86
|
seen.add(id);
|
|
87
87
|
};
|
|
88
88
|
const contextIndex = config.segments.findIndex((segment) => segment.id === "context");
|
|
89
89
|
insert("quota", contextIndex < 0 ? -1 : contextIndex + 1);
|
|
90
|
+
insert("speed", config.segments.findIndex((segment) => segment.id === "context"));
|
|
90
91
|
insert("session", config.segments.findIndex((segment) => segment.id === "tokens"));
|
|
91
92
|
insert("toolTotal", config.segments.findIndex((segment) => segment.id === "tokens"));
|
|
92
93
|
// All other omissions remain editable but disabled.
|
package/src/index.ts
CHANGED
|
@@ -25,7 +25,7 @@ export default function statusline(pi: ExtensionAPI): void {
|
|
|
25
25
|
session.install();
|
|
26
26
|
});
|
|
27
27
|
pi.on("session_shutdown", () => { generation++; session?.dispose(); session = undefined; });
|
|
28
|
-
pi.on("before_provider_request", (
|
|
28
|
+
pi.on("before_provider_request", (event, ctx) => { session?.setContext(ctx); session?.beginProviderRequest(event.payload); });
|
|
29
29
|
pi.on("after_provider_response", (event, ctx) => { session?.setContext(ctx); session?.observeProviderResponse(event.headers); });
|
|
30
30
|
pi.on("provider_stream_event", (event, ctx) => {
|
|
31
31
|
if (!session?.active) return;
|
|
@@ -61,7 +61,7 @@ export default function statusline(pi: ExtensionAPI): void {
|
|
|
61
61
|
const resetLive = (event: unknown, ctx: ExtensionContext) => { session?.setLive(undefined); refresh(event, ctx); };
|
|
62
62
|
pi.on("agent_end", resetLive);
|
|
63
63
|
pi.on("turn_end", (event, ctx) => { if (event.message.role === "assistant") session?.runtime.message(event.message, true); session?.runtime.turnEnd(); refresh(event, ctx); });
|
|
64
|
-
pi.on("model_select", (event, ctx) => { session?.quota.clear(); refresh(event, ctx); });
|
|
64
|
+
pi.on("model_select", (event, ctx) => { session?.quota.clear(); session?.clearServiceTier(); refresh(event, ctx); });
|
|
65
65
|
pi.on("thinking_level_select", refresh);
|
|
66
66
|
pi.on("session_compact", (event, ctx) => {
|
|
67
67
|
session?.compaction.finish("success", event.compactionEntry.id); session?.runtime.compaction(false); resetLive(event, ctx);
|
package/src/render.ts
CHANGED
|
@@ -13,11 +13,11 @@ export type RenderTheme = Pick<Theme, "style" | "colors" | "appearance">;
|
|
|
13
13
|
// Keep rainbow hues independent of semantic theme colors, which can repeat.
|
|
14
14
|
const THINKING_RAINBOW = ["#c084fc", "#f472b6", "#fb923c", "#facc15", "#4ade80", "#22d3ee", "#60a5fa"].map((value) => parseColor(value));
|
|
15
15
|
const ICONS: Record<StatuslineConfig["icons"], Partial<Record<SegmentId, string>>> = {
|
|
16
|
-
unicode: { model: "", directory: "▸", git: "⑂", context: "◉", cost: "$", input: "↑", output: "↓", session: "◷", toolTotal: "⚒", tokens: "Σ", cacheRead: "R", cacheWrite: "W" },
|
|
17
|
-
nerd: { model: "", directory: "", git: "", context: "", quota: "", cost: "$", input: "↑", output: "↓", session: "", toolTotal: "", tokens: "", cacheRead: "R", cacheWrite: "W" },
|
|
18
|
-
ascii: { model: "", directory: "", git: "git:", context: "ctx:", cost: "$", input: "in:", output: "out:", session: "ses:", toolTotal: "tool:", tokens: "tok:", cacheRead: "R:", cacheWrite: "W:" },
|
|
16
|
+
unicode: { speed: "⚡", model: "", directory: "▸", git: "⑂", context: "◉", cost: "$", input: "↑", output: "↓", session: "◷", toolTotal: "⚒", tokens: "Σ", cacheRead: "R", cacheWrite: "W" },
|
|
17
|
+
nerd: { speed: "\uf0e7", model: "", directory: "", git: "", context: "", quota: "", cost: "$", input: "↑", output: "↓", session: "", toolTotal: "", tokens: "", cacheRead: "R", cacheWrite: "W" },
|
|
18
|
+
ascii: { speed: "", model: "", directory: "", git: "git:", context: "ctx:", cost: "$", input: "in:", output: "out:", session: "ses:", toolTotal: "tool:", tokens: "tok:", cacheRead: "R:", cacheWrite: "W:" },
|
|
19
19
|
};
|
|
20
|
-
const DROP_ORDER: SegmentId[] = ["cost", "cacheWrite", "cacheRead", "output", "input", "thinking", "git", "directory"];
|
|
20
|
+
const DROP_ORDER: SegmentId[] = ["cost", "speed", "cacheWrite", "cacheRead", "output", "input", "thinking", "git", "directory"];
|
|
21
21
|
export function formatTokens(value: number): string {
|
|
22
22
|
if (value < 1000) return String(Math.round(value));
|
|
23
23
|
const divisor = value >= 1e6 ? 1e6 : 1000;
|
|
@@ -64,11 +64,16 @@ function gitText(data: StatuslineSnapshot, ascii: boolean): string | undefined {
|
|
|
64
64
|
if (git.behind) bits.push(`${ascii ? "v" : "↓"}${git.behind}`);
|
|
65
65
|
return bits.join(" ");
|
|
66
66
|
}
|
|
67
|
+
/** Service tiers worth showing; `default`, `auto` and unknown values stay hidden. */
|
|
68
|
+
function speedLabel(tier: string | undefined): string | undefined {
|
|
69
|
+
return tier === "priority" ? "fast" : tier === "ultrafast" ? "Ultra Fast" : tier === "flex" ? "flex" : undefined;
|
|
70
|
+
}
|
|
67
71
|
function segmentText(id: SegmentId, data: StatuslineSnapshot, config: StatuslineConfig): string | undefined {
|
|
68
72
|
const usage = data.usage;
|
|
69
73
|
switch (id) {
|
|
70
74
|
case "model": return (config.modelDisplay === "last" ? data.modelId.split("/").filter(Boolean).at(-1) : undefined) || data.model || "No model";
|
|
71
75
|
case "thinking": return undefined; // Its settings now control the model's suffix.
|
|
76
|
+
case "speed": return speedLabel(data.serviceTier);
|
|
72
77
|
case "directory": return displayPath(data, config.pathMode);
|
|
73
78
|
case "git": return gitText(data, config.icons === "ascii");
|
|
74
79
|
case "context": {
|
|
@@ -110,6 +115,7 @@ function defaultColor(id: SegmentId, data: StatuslineSnapshot): ColorValue {
|
|
|
110
115
|
const colors: Record<string, ColorValue> = { off: "thinkingOff", minimal: "thinkingMinimal", low: "thinkingLow", medium: "thinkingMedium", high: "thinkingHigh", xhigh: "thinkingXhigh", max: "thinkingMax" };
|
|
111
116
|
return colors[data.thinking] ?? "muted";
|
|
112
117
|
}
|
|
118
|
+
if (id === "speed") return "warning";
|
|
113
119
|
if (id === "model") return "accent";
|
|
114
120
|
if (id === "directory") return "success";
|
|
115
121
|
if (id === "context") return "#c678dd";
|
package/src/session.ts
CHANGED
|
@@ -17,6 +17,13 @@ export function sessionStart(timestamp: string | undefined, now = Date.now()): n
|
|
|
17
17
|
return Number.isFinite(ms) && ms <= now + 60000 ? ms : null;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/** The request's `service_tier`, when it is a short plain token. */
|
|
21
|
+
export function serviceTierOf(payload: unknown): string | undefined {
|
|
22
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return undefined;
|
|
23
|
+
const tier = (payload as { service_tier?: unknown }).service_tier;
|
|
24
|
+
return typeof tier === "string" && /^[\w.-]{1,32}$/.test(tier) ? tier.toLowerCase() : undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
export class FooterSession {
|
|
21
28
|
readonly runtime = new RuntimeState();
|
|
22
29
|
readonly compaction = new CompactionState();
|
|
@@ -39,6 +46,7 @@ export class FooterSession {
|
|
|
39
46
|
private sessionStartMs: number | null = null;
|
|
40
47
|
private toolCalls = 0;
|
|
41
48
|
private skills: string[] = [];
|
|
49
|
+
private serviceTier: string | undefined;
|
|
42
50
|
private readonly gitReader: GitReader | undefined;
|
|
43
51
|
private readonly commands: () => readonly SlashCommandInfo[];
|
|
44
52
|
private signal: AbortSignal | undefined;
|
|
@@ -49,7 +57,18 @@ export class FooterSession {
|
|
|
49
57
|
}
|
|
50
58
|
get active(): boolean { return this.ownsFooter && !this.closed; }
|
|
51
59
|
setContext(ctx: ExtensionContext): void { this.ctx = ctx; this.quota.select(ctx.model); this.watchSignal(); }
|
|
52
|
-
beginProviderRequest(): void {
|
|
60
|
+
beginProviderRequest(payload?: unknown): void {
|
|
61
|
+
if (!this.active) return;
|
|
62
|
+
this.quota.beginRequest(this.ctx.model);
|
|
63
|
+
// The tier is read from the outgoing payload, so it reflects what was actually requested.
|
|
64
|
+
this.setServiceTier(serviceTierOf(payload));
|
|
65
|
+
}
|
|
66
|
+
/** Forget the observed tier, e.g. after a model switch, until the next request reports it. */
|
|
67
|
+
clearServiceTier(): void { this.setServiceTier(undefined); }
|
|
68
|
+
private setServiceTier(tier: string | undefined): void {
|
|
69
|
+
if (tier === this.serviceTier) return;
|
|
70
|
+
this.serviceTier = tier; this.schedule(true);
|
|
71
|
+
}
|
|
53
72
|
observeProviderResponse(headers: Record<string, string>): void {
|
|
54
73
|
if (!this.active) return;
|
|
55
74
|
this.quota.response(headers, this.ctx.model); this.schedule(true);
|
|
@@ -156,6 +175,7 @@ export class FooterSession {
|
|
|
156
175
|
thinking: this.ctx.thinkingLevel ?? "off", cwd: this.ctx.cwd, home: homedir(),
|
|
157
176
|
context: this.context, usage: this.usage.snapshot(), quota: this.quota.snapshot(this.ctx.model), git: this.git,
|
|
158
177
|
statuses: this.provider?.getExtensionStatuses() ?? new Map(),
|
|
178
|
+
...(this.serviceTier ? { serviceTier: this.serviceTier } : {}),
|
|
159
179
|
// Minute resolution keeps an idle footer from repainting every second.
|
|
160
180
|
sessionMinutes: this.sessionStartMs === null ? null : Math.floor(Math.max(0, Date.now() - this.sessionStartMs) / 60000),
|
|
161
181
|
toolCalls: this.toolCalls, skills: this.skills,
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ThemeColor } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
|
-
export const SEGMENT_IDS = ["model", "thinking", "context", "quota", "directory", "git", "cost", "input", "output", "session", "toolTotal", "tokens", "cacheRead", "cacheWrite", "statuses"] as const;
|
|
3
|
+
export const SEGMENT_IDS = ["model", "thinking", "speed", "context", "quota", "directory", "git", "cost", "input", "output", "session", "toolTotal", "tokens", "cacheRead", "cacheWrite", "statuses"] as const;
|
|
4
4
|
export type SegmentId = typeof SEGMENT_IDS[number];
|
|
5
5
|
export type ColorValue = ThemeColor | `#${string}`;
|
|
6
6
|
export type Preset = "powerline";
|
|
@@ -82,6 +82,8 @@ export interface StatuslineSnapshot {
|
|
|
82
82
|
quota?: import("./quota.ts").QuotaSnapshot;
|
|
83
83
|
git: GitState;
|
|
84
84
|
statuses: ReadonlyMap<string, string>;
|
|
85
|
+
/** `service_tier` of the latest provider request (`priority`, `ultrafast`, ...); undefined when it carried none. */
|
|
86
|
+
serviceTier?: string;
|
|
85
87
|
/** Whole minutes since the session file was created; null when unknown. */
|
|
86
88
|
sessionMinutes: number | null;
|
|
87
89
|
/** Completed tool calls recorded in the session file, across all runs. */
|