@erichll/pi-statusline 0.6.1 → 0.7.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0 - 2026-10-17
4
+
5
+ ### Added
6
+
7
+ - Add a `toolTotal` segment on the runtime row, enabled by default: the number
8
+ of tool calls recorded in the whole session (`󱁤 128`; `⚒` in Unicode and
9
+ `tool:` in ASCII icon modes), between session age and tokens. Unlike the tool
10
+ row, which counts the current run, it is read from session entries, so it
11
+ survives reloads and resuming and covers every run. It is hidden at zero and
12
+ is the first of these three segments to fold on narrow rows. Existing segment
13
+ lists gain it before `tokens` unless they list it explicitly.
14
+
3
15
  ## 0.6.1 - 2026-10-16
4
16
 
5
17
  ### Changed
package/README.md CHANGED
@@ -6,12 +6,12 @@ activity and live configuration preview. Leaves the editor intact.
6
6
  ```text
7
7
   Example model(high)  󰆼 █░░░░░░░░░ 11.9%  󰉋 pi-packages   main ● *2 ↑2
8
8
  ◐ bash npm test 12s · ✓ read ×5 · ✓ edit ×2
9
- ● 5m 42s · avg 45 tok/s · cache 86% · turns 3 · compactions 1 · 󰥔 2h 6m · 󰊄 49.4k
9
+ ● 5m 42s · avg 45 tok/s · cache 86% · turns 3 · compactions 1 · 󰥔 2h 6m · 󱁤 128 · 󰊄 49.4k
10
10
  ```
11
11
 
12
12
  Rows, top to bottom: the main segments, tool activity for the current run
13
- (only once it has used tools), then run status, run metrics, session age and
14
- tokens, and other extensions' statuses.
13
+ (only once it has used tools), then run status, run metrics, session age,
14
+ tool calls and tokens, and other extensions' statuses.
15
15
 
16
16
  ## Install
17
17
 
@@ -82,6 +82,7 @@ Available segments:
82
82
  | `directory` | Current directory | On |
83
83
  | `git` | Branch, dirty/conflict state, staged/unstaged/untracked counts, ahead/behind | On |
84
84
  | `session` | Time since the session was created, on the bottom row | On |
85
+ | `toolTotal` | Tool calls recorded in the whole session (`󱁤 128`), on the bottom row; hidden at zero | On |
85
86
  | `tokens` | Cumulative session tokens, on the bottom row | On |
86
87
  | `cost` | Pi-recorded cumulative USD cost | Off |
87
88
  | `input`, `output`, `cacheRead`, `cacheWrite` | Individual session token counters | Off |
@@ -89,8 +90,8 @@ Available segments:
89
90
 
90
91
  `segments` is an ordered array of
91
92
  `{ id, enabled, icon?, color?, iconColor?, background? }`. Omitted segments are
92
- disabled, **except `quota` and `session`**: old configurations automatically
93
- gain `quota` after `context` and `session` before `tokens` (or at the end when
93
+ disabled, **except `quota`, `session` and `toolTotal`**: old configurations automatically
94
+ gain `quota` after `context`, and `session` and `toolTotal` before `tokens` (or at the end when
94
95
  the anchor is absent). To keep one off, include it with `"enabled": false`.
95
96
 
96
97
  Colors accept `#RRGGBB` or supported Pi theme tokens such as `accent`, `muted`,
@@ -49,6 +49,10 @@
49
49
  "id": "session",
50
50
  "enabled": true
51
51
  },
52
+ {
53
+ "id": "toolTotal",
54
+ "enabled": true
55
+ },
52
56
  {
53
57
  "id": "tokens",
54
58
  "enabled": true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erichll/pi-statusline",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Configurable Pi statusline with live preview, Git and session usage",
5
5
  "type": "module",
6
6
  "license": "MIT",
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", "tokens", "statuses"]);
13
+ const enabled = new Set<string>(["model", "thinking", "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,7 +80,7 @@ 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", index: number) => {
83
+ const insert = (id: "quota" | "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);
@@ -88,6 +88,7 @@ export function parseConfig(raw: unknown): StatuslineConfig {
88
88
  const contextIndex = config.segments.findIndex((segment) => segment.id === "context");
89
89
  insert("quota", contextIndex < 0 ? -1 : contextIndex + 1);
90
90
  insert("session", config.segments.findIndex((segment) => segment.id === "tokens"));
91
+ insert("toolTotal", config.segments.findIndex((segment) => segment.id === "tokens"));
91
92
  // All other omissions remain editable but disabled.
92
93
  for (const id of SEGMENT_IDS) if (!seen.has(id)) config.segments.push({ id, enabled: false });
93
94
  }
package/src/panel.ts CHANGED
@@ -64,7 +64,7 @@ export class StatuslinePanel implements Component, Focusable {
64
64
  { value: "modelDisplay", label: `Model display: ${this.draft.modelDisplay}`, description: "name: display name · last: final model ID component" },
65
65
  { value: "contextDisplay", label: `Context display: ${this.draft.contextDisplay}`, description: "text: tokens/capacity(percent) · bar: progress and percent" },
66
66
  { value: "spacing", label: `Spacing above statusline: ${this.draft.spacing}`, description: "Blank lines between the input box and the statusline (0–3)" },
67
- ...this.draft.segments.filter((segment) => segment.id !== "thinking").map((segment) => ({ value: `segment:${segment.id}`, label: `[${segment.enabled ? "x" : " "}] ${segment.id}`, description: segment.id === "statuses" || segment.id === "session" || segment.id === "tokens" ? "Runtime row · Space toggles, Enter edits" : segment.id === "quota" ? "Subscription Usage · passive headers/events; hidden without data" : "Space toggles · Alt+Up/Down reorders · Enter edits" })),
67
+ ...this.draft.segments.filter((segment) => segment.id !== "thinking").map((segment) => ({ value: `segment:${segment.id}`, label: `[${segment.enabled ? "x" : " "}] ${segment.id}`, description: segment.id === "statuses" || segment.id === "session" || segment.id === "toolTotal" || segment.id === "tokens" ? "Runtime row · Space toggles, Enter edits" : segment.id === "quota" ? "Subscription Usage · passive headers/events; hidden without data" : "Space toggles · Alt+Up/Down reorders · Enter edits" })),
68
68
  { value: "runtime", label: "Runtime options" },
69
69
  { value: "save", label: "Save and apply globally" },
70
70
  { value: "reset", label: "Restore defaults in preview" },
package/src/render.ts CHANGED
@@ -13,9 +13,9 @@ 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: "◷", tokens: "Σ", cacheRead: "R", cacheWrite: "W" },
17
- nerd: { model: "", directory: "󰉋", git: "", context: "󰆼", quota: "󰦖", cost: "$", input: "↑", output: "↓", session: "󰥔", tokens: "󰊄", cacheRead: "R", cacheWrite: "W" },
18
- ascii: { model: "", directory: "", git: "git:", context: "ctx:", cost: "$", input: "in:", output: "out:", session: "ses:", tokens: "tok:", cacheRead: "R:", cacheWrite: "W:" },
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:" },
19
19
  };
20
20
  const DROP_ORDER: SegmentId[] = ["cost", "cacheWrite", "cacheRead", "output", "input", "thinking", "git", "directory"];
21
21
  export function formatTokens(value: number): string {
@@ -79,6 +79,7 @@ function segmentText(id: SegmentId, data: StatuslineSnapshot, config: Statusline
79
79
  }
80
80
  case "quota": return renderQuota(data.quota, config.icons === "ascii");
81
81
  case "session": return data.sessionMinutes === null ? undefined : formatSessionAge(data.sessionMinutes);
82
+ case "toolTotal": return data.toolCalls > 0 ? String(data.toolCalls) : undefined;
82
83
  case "cost": return usage.cost.toFixed(3);
83
84
  case "input": return formatTokens(usage.input);
84
85
  case "output": return formatTokens(usage.output);
@@ -195,7 +196,7 @@ export function renderFooter(width: number, data: StatuslineSnapshot, config: St
195
196
  if (width === 0) return [];
196
197
  const parts: Part[] = [];
197
198
  let secondary: Part | undefined;
198
- const sessionRow: Partial<Record<"session" | "tokens", string>> = {};
199
+ const sessionRow: Partial<Record<"session" | "toolTotal" | "tokens", string>> = {};
199
200
  // CLIProxyAPI's published `tps` status is display text only.
200
201
  const tps = cleanText(data.statuses.get("tps") ?? "");
201
202
  const elapsedStatus = config.segments.some((s) => s.id === "statuses" && s.enabled) && /^Elapsed \d+[dhms](?: \d+[hms])*$/.test(tps) ? tps : undefined;
@@ -203,7 +204,7 @@ export function renderFooter(width: number, data: StatuslineSnapshot, config: St
203
204
  const thinking = config.segments.find((segment) => segment.id === "thinking");
204
205
  for (const segment of config.segments) {
205
206
  if (!segment.enabled) continue;
206
- if (segment.id === "session" || segment.id === "tokens") { sessionRow[segment.id] = sessionText(segment, data, config, theme); continue; }
207
+ if (segment.id === "session" || segment.id === "toolTotal" || segment.id === "tokens") { sessionRow[segment.id] = sessionText(segment, data, config, theme); continue; }
207
208
  const raw = segmentText(segment.id, segment.id === "statuses" ? { ...data, statuses } : data, config);
208
209
  if (raw === undefined) continue;
209
210
  let text = cleanText(raw);
@@ -278,7 +279,7 @@ export function sampleSnapshot(): StatuslineSnapshot {
278
279
  context: { tokens: 23800, contextWindow: 200000, percent: 11.9 },
279
280
  usage: { ...emptyUsage(), input: 32000, output: 5400, cacheRead: 12000, cost: 0.12 },
280
281
  git: { ...emptyGit("repository"), branch: "main", unstaged: 2, ahead: 2 },
281
- statuses: new Map([["example", "Example extension status"]]), sessionMinutes: 126,
282
+ statuses: new Map([["example", "Example extension status"]]), sessionMinutes: 126, toolCalls: 128,
282
283
  runtime: {
283
284
  runId: "example", status: "Running", elapsedMs: 28000, turns: 3, toolCalls: 8, awaitingInput: false, noContentMs: null, usage: { ...emptyUsage(), output: 1260 }, avg: 45, cache: 0.86,
284
285
  tools: [{ name: "bash", target: "npm test", elapsedMs: 12000 }],
@@ -49,6 +49,8 @@ export interface RuntimeExtras {
49
49
  statuses?: string;
50
50
  /** Session age, already styled. */
51
51
  session?: string;
52
+ /** Completed tool calls in the session, already styled. */
53
+ toolTotal?: string;
52
54
  /** Session token total, already styled. */
53
55
  tokens?: string;
54
56
  /** A `tps` extension status of the form `Elapsed 5m 42s`. */
@@ -56,7 +58,7 @@ export interface RuntimeExtras {
56
58
  }
57
59
 
58
60
  /**
59
- * The bottom row: run status and duration, run metrics, then session age, tokens and extension statuses.
61
+ * The bottom row: run status and duration, run metrics, then session age, tool calls, tokens and extension statuses.
60
62
  * It stays muted so it does not compete with the editor; only problems (failure, waits, low cache) are colored.
61
63
  */
62
64
  export function renderRuntime(width: number, data: StatuslineSnapshot, config: StatuslineConfig, theme: RenderTheme, extras: RuntimeExtras = {}): string | undefined {
@@ -88,9 +90,10 @@ export function renderRuntime(width: number, data: StatuslineSnapshot, config: S
88
90
  }
89
91
  if (enabled && config.runtime.counts && compact && compact.count > 0) count("compactions", compact.count);
90
92
  if (extras.session) parts.push({ id: "session", spans: [], styled: extras.session });
93
+ if (extras.toolTotal) parts.push({ id: "toolTotal", spans: [], styled: extras.toolTotal });
91
94
  if (extras.tokens) parts.push({ id: "tokens", spans: [], styled: extras.tokens });
92
95
  if (extras.statuses && !compacting) parts.push({ id: "statuses", spans: [], styled: extras.statuses });
93
- return fit(parts, ["statuses", "cache", "avg", "compactions", "session", "tokens", "turns", "activity", "failure"], width, ascii ? " | " : " · ", theme, ascii ? "..." : "…");
96
+ return fit(parts, ["statuses", "cache", "avg", "compactions", "toolTotal", "session", "tokens", "turns", "activity", "failure"], width, ascii ? " | " : " · ", theme, ascii ? "..." : "…");
94
97
  }
95
98
 
96
99
  /** `◐ bash npm test 12s · ✓ read ×5 · ✗ bash ×1 · +2`: present while the run has used tools. */
package/src/session.ts CHANGED
@@ -36,6 +36,7 @@ export class FooterSession {
36
36
  private displayKey = "";
37
37
  private context: StatuslineSnapshot["context"] = { tokens: null, contextWindow: 0, percent: null };
38
38
  private sessionStartMs: number | null = null;
39
+ private toolCalls = 0;
39
40
  private readonly gitReader: GitReader | undefined;
40
41
  private signal: AbortSignal | undefined;
41
42
  private readonly onAbort = () => { this.runtime.observeAbort(); this.schedule(true); };
@@ -130,6 +131,7 @@ export class FooterSession {
130
131
  const entries = manager.getEntries();
131
132
  this.usage.update(entries);
132
133
  this.compaction.update(entries);
134
+ this.toolCalls = entries.reduce((total, entry) => total + (entry.type === "message" && entry.message.role === "toolResult" ? 1 : 0), 0);
133
135
  this.sessionStartMs = sessionStart(manager.getHeader()?.timestamp);
134
136
  const context = this.ctx.getContextUsage();
135
137
  this.context = context ?? { tokens: null, contextWindow: this.ctx.model?.contextWindow ?? 0, percent: null };
@@ -152,6 +154,7 @@ export class FooterSession {
152
154
  statuses: this.provider?.getExtensionStatuses() ?? new Map(),
153
155
  // Minute resolution keeps an idle footer from repainting every second.
154
156
  sessionMinutes: this.sessionStartMs === null ? null : Math.floor(Math.max(0, Date.now() - this.sessionStartMs) / 60000),
157
+ toolCalls: this.toolCalls,
155
158
  runtime: this.runtime.snapshot(this.config.runtime.retainSummary), compaction: this.compaction.snapshot(),
156
159
  };
157
160
  }
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", "tokens", "cacheRead", "cacheWrite", "statuses"] as const;
3
+ export const SEGMENT_IDS = ["model", "thinking", "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";
@@ -72,6 +72,8 @@ export interface StatuslineSnapshot {
72
72
  statuses: ReadonlyMap<string, string>;
73
73
  /** Whole minutes since the session file was created; null when unknown. */
74
74
  sessionMinutes: number | null;
75
+ /** Completed tool calls recorded in the session file, across all runs. */
76
+ toolCalls: number;
75
77
  runtime?: import("./runtime.ts").RuntimeSnapshot;
76
78
  compaction?: import("./compaction.ts").CompactionSnapshot;
77
79
  }