@erichll/pi-statusline 0.7.0 → 0.8.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,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0 - 2026-10-18
4
+
5
+ ### Added
6
+
7
+ - Add a skills row, enabled by default, between the tool row and the runtime
8
+ row: the loaded skills used in the session, in first-use order
9
+ (`󰗚 pdf-tools · docx +1`; `❖` in Unicode and `skills` in ASCII icon modes).
10
+ It counts `/skill:name` invocations and model reads of a loaded skill's file,
11
+ is read from session entries so it survives reloads and resuming, and is
12
+ hidden until a skill is used. `runtime.skills` toggles it and
13
+ `runtime.skillsMaxVisible` (1–8, default 4) sets how many names show before
14
+ `+N`; narrow rows fold names, then show only the count.
15
+ - Show the skill directory for reads of a skill file on the tool row
16
+ (`read pdf-tools/SKILL.md` instead of `read SKILL.md`).
17
+
18
+ ### Changed
19
+
20
+ - Give the lower rows dim row icons aligned with the main row: each starts with
21
+ a space, so its icon sits under the model icon, and two spaces set the icon
22
+ off from the row contents (one in ASCII mode). The tool row leads with the
23
+ tool total's icon (`󱁤`; `⚒` in Unicode and `tools` in ASCII icon modes) and
24
+ the runtime row with a pulse (`󰐰 ● 5m 42s`; `∿` and `run`).
25
+ - Quiet the tool row like the runtime row: running tools (`◐ bash`) use the
26
+ text color instead of warning and accent, and completed calls (`✓`) are dim
27
+ instead of success. Only a tool running 30s or longer (its `◐` and timer turn
28
+ warning) and failures (`✗`, error) stay colored.
29
+
3
30
  ## 0.7.0 - 2026-10-17
4
31
 
5
32
  ### Added
package/README.md CHANGED
@@ -5,13 +5,17 @@ activity and live configuration preview. Leaves the editor intact.
5
5
 
6
6
  ```text
7
7
   Example model(high)  󰆼 █░░░░░░░░░ 11.9%  󰉋 pi-packages   main ● *2 ↑2
8
- ◐ bash npm test 12s · ✓ read ×5 · ✓ edit ×2
9
- ● 5m 42s · avg 45 tok/s · cache 86% · turns 3 · compactions 1 · 󰥔 2h 6m · 󱁤 128 · 󰊄 49.4k
8
+ 󱁤 ◐ bash npm test 12s · ✓ read ×5 · ✓ edit ×2
9
+ 󰗚 pdf-tools · docx
10
+ 󰐰 ● 5m 42s · avg 45 tok/s · cache 86% · turns 3 · compactions 1 · 󰥔 2h 6m · 󱁤 128 · 󰊄 49.4k
10
11
  ```
11
12
 
12
13
  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,
14
- tool calls and tokens, and other extensions' statuses.
14
+ (only once it has used tools), the skills used in the session (only once one
15
+ is used), then run status, run metrics, session age, tool calls and tokens,
16
+ and other extensions' statuses. The last three rows start with a space, so their
17
+ labels (`󱁤`, `󰗚`, `󰐰`) sit under the main row's model icon, and two
18
+ spaces set each label off from the row contents (one in ASCII mode).
15
19
 
16
20
  ## Install
17
21
 
@@ -114,8 +118,8 @@ Bars show **used** percentages for the primary and secondary windows, with live
114
118
  reset countdowns. Labels come from the reported window length (`5h`, `1d`,
115
119
  `7d`, `30d` within 5%, otherwise exact such as `1h30m`); without one, the
116
120
  window is unlabeled rather than guessed. Each window is colored on its own:
117
- Pi's accent, warning above 70% and error above 90%; a segment `color` overrides
118
- both. Narrow terminals omit countdowns, then bars, then the segment rather than
121
+ Pi's accent, warning above 70% and error above 90%; the segment icon follows
122
+ the higher of the two. A segment `color` overrides both. Narrow terminals omit countdowns, then bars, then the segment rather than
119
123
  truncate a window; an unlabeled window keeps its countdown instead of its bar.
120
124
 
121
125
  Data is observed passively through Pi's provider events:
@@ -142,9 +146,9 @@ or RPM/TPM rate limit.
142
146
  - Context is Pi's current estimate, not cumulative consumption; unknown values
143
147
  show `?`. Session totals include recorded usage across the whole session file,
144
148
  including compaction and abandoned branches. Cost is Pi-reported, not an invoice.
145
- - The bottom row starts with the run status (`●` running, `✓` done, `✗` failed,
146
- `⊘` cancelled) and its duration, which spans retries, tools, UI waits and
147
- compaction. `avg` is assistant output tokens / total run seconds, **not
149
+ - The bottom row (`󰐰`, `∿` in Unicode and `run` in ASCII icon modes) starts
150
+ with the run status (`●` running, `✓` done, `✗` failed, `⊘` cancelled) and its
151
+ duration, which spans retries, tools, UI waits and compaction. `avg` is assistant output tokens / total run seconds, **not
148
152
  inference speed**; `cache` is cache-read / (input + cache-read + cache-write).
149
153
  `turns` counts Pi turns, not upstream requests; `compactions` counts
150
154
  successful session entries. The row stays muted; only a failed run, waits,
@@ -157,16 +161,28 @@ or RPM/TPM rate limit.
157
161
  - `awaiting input` and `no content 10s` follow the duration while active. No
158
162
  content means no non-empty text, reasoning or tool-call delta was observed; it
159
163
  is not a server timeout and is suppressed during tools, UI waits and compaction.
160
- - The tool row shows up to two running tools with what they work on (a shell
161
- command without `cd`/env prefixes, a file name or a search pattern), merging
164
+ - The tool row (`󱁤`, `⚒` in Unicode and `tools` in ASCII icon modes, like the
165
+ session tool total) shows up to two running tools with what they work on (a
166
+ shell command without `cd`/env prefixes, a file name or a search pattern), merging
162
167
  same-name calls as `×N`, then this run's completed (`✓`) and failed (`✗`)
163
168
  counts. `toolsMaxVisible` (1–8, default 4) completed kinds show before `+N`.
164
169
  Nested calls count but are represented by their parent while running; calls
165
170
  ended by a cancellation are not failures. Narrow rows fold kinds, then drop
166
- targets, then timers.
171
+ targets, then timers. The row stays quiet: running tools (`◐ bash`) use the
172
+ text color, completed ones (`✓`) are dim, and only a tool running 30s or
173
+ longer (its `◐` and timer turn warning) and failures (error) are colored. A read of a skill file shows its directory
174
+ (`read pdf-tools/SKILL.md`).
175
+ - The skills row (`󰗚`, `❖` in Unicode and `skills` in ASCII icon modes) lists
176
+ the loaded skills used in the session, in first-use order: `/skill:name`
177
+ invocations and model reads of a loaded skill's file.
178
+ Reads of skill files Pi did not load are ignored; a skill read only for
179
+ reference, such as while writing another skill, still counts. Like tool calls,
180
+ it is read from session entries, so it survives reloads and resuming.
181
+ `skillsMaxVisible` (1–8, default 4) names show before `+N`; narrow rows fold
182
+ names, then show only the count.
167
183
 
168
184
  All runtime options default to enabled; `noContentSeconds` accepts 1–3600
169
- (default 10). `tools: false` hides the tool row. `retainSummary` keeps the last run until the next one;
185
+ (default 10). `tools: false` hides the tool row and `skills: false` the skills row. `retainSummary` keeps the last run until the next one;
170
186
  `runtime.enabled: false` hides local runtime metrics. Reload/new session resets
171
187
  in-memory runtime summaries, not persisted session totals.
172
188
 
@@ -80,6 +80,8 @@
80
80
  "cache": true,
81
81
  "counts": true,
82
82
  "retainSummary": true,
83
- "toolsMaxVisible": 4
83
+ "toolsMaxVisible": 4,
84
+ "skills": true,
85
+ "skillsMaxVisible": 4
84
86
  }
85
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erichll/pi-statusline",
3
- "version": "0.7.0",
3
+ "version": "0.8.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
@@ -15,7 +15,7 @@ export function presetConfig(): StatuslineConfig {
15
15
  version: 1, enabled: true, preset: "powerline", icons: "nerd",
16
16
  separator: "powerline", pathMode: "basename", modelDisplay: "name", contextDisplay: "bar", spacing: 1,
17
17
  segments: SEGMENT_IDS.map((id) => ({ id, enabled: enabled.has(id) })),
18
- runtime: { enabled: true, status: true, tools: true, noContent: true, noContentSeconds: 10, avg: true, cache: true, counts: true, retainSummary: true, toolsMaxVisible: 4 },
18
+ runtime: { enabled: true, status: true, tools: true, noContent: true, noContentSeconds: 10, avg: true, cache: true, counts: true, retainSummary: true, toolsMaxVisible: 4, skills: true, skillsMaxVisible: 4 },
19
19
  };
20
20
  }
21
21
  function record(value: unknown): value is Record<string, unknown> {
@@ -54,7 +54,7 @@ export function parseConfig(raw: unknown): StatuslineConfig {
54
54
  if (key === "noContentSeconds") {
55
55
  if (typeof value !== "number" || !Number.isInteger(value) || value < 1 || value > 3600) throw new Error("Invalid runtime.noContentSeconds (1–3600)");
56
56
  config.runtime.noContentSeconds = value;
57
- } else if (key === "toolsMaxVisible") config.runtime.toolsMaxVisible = integer(value, 1, 8, "runtime.toolsMaxVisible");
57
+ } else if (key === "toolsMaxVisible" || key === "skillsMaxVisible") config.runtime[key] = integer(value, 1, 8, `runtime.${key}`);
58
58
  else (config[group] as unknown as Record<string, unknown>)[key] = boolean(value, `${group}.${key}`);
59
59
  }
60
60
  }
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export default function statusline(pi: ExtensionAPI): void {
10
10
  let config = presetConfig();
11
11
  let session: FooterSession | undefined;
12
12
  let generation = 0;
13
+ const commands = () => pi.getCommands();
13
14
 
14
15
  pi.on("session_start", async (_event, ctx) => {
15
16
  const token = ++generation;
@@ -19,7 +20,7 @@ export default function statusline(pi: ExtensionAPI): void {
19
20
  if (token !== generation) return;
20
21
  config = loaded.config;
21
22
  if (loaded.warning) ctx.ui.notify(loaded.warning, "warning");
22
- session = new FooterSession(ctx, config);
23
+ session = new FooterSession(ctx, config, undefined, commands);
23
24
  session.refresh(true);
24
25
  session.install();
25
26
  });
@@ -89,7 +90,7 @@ export default function statusline(pi: ExtensionAPI): void {
89
90
  config = loaded.config;
90
91
  if (loaded.warning) ctx.ui.notify(loaded.warning, "warning");
91
92
  current.dispose();
92
- session = new FooterSession(ctx, config);
93
+ session = new FooterSession(ctx, config, undefined, commands);
93
94
  session.refresh(true); session.install();
94
95
  return;
95
96
  }
package/src/panel.ts CHANGED
@@ -41,7 +41,7 @@ export class StatuslinePanel implements Component, Focusable {
41
41
  }
42
42
  private items(): SelectItem[] {
43
43
  if (this.section) {
44
- const labels: Record<string, string> = { enabled: "Runtime metrics", status: "Run status, elapsed and compaction status", tools: "Tool activity row", noContent: "No content warning", noContentSeconds: "No content threshold (seconds)", avg: "Average output speed", cache: "Cache read ratio", counts: "Turns and compactions", retainSummary: "Retain last run summary", toolsMaxVisible: "Completed tool kinds shown" };
44
+ const labels: Record<string, string> = { enabled: "Runtime metrics", status: "Run status, elapsed and compaction status", tools: "Tool activity row", noContent: "No content warning", noContentSeconds: "No content threshold (seconds)", avg: "Average output speed", cache: "Cache read ratio", counts: "Turns and compactions", retainSummary: "Retain last run summary", toolsMaxVisible: "Completed tool kinds shown", skills: "Skills row", skillsMaxVisible: "Skill names shown" };
45
45
  return [...Object.entries(this.draft[this.section]).map(([key, value]) => ({ value: `option:${key}`, label: `${labels[key] ?? key}: ${value}` })), { value: "back", label: "Back to settings" }];
46
46
  }
47
47
  if (this.editing) {
@@ -93,9 +93,9 @@ export class StatuslinePanel implements Component, Focusable {
93
93
  if (this.section) {
94
94
  if (value === "back") { this.cancel(); return; }
95
95
  const key = value.slice("option:".length);
96
- if (key === "noContentSeconds" || key === "toolsMaxVisible") {
96
+ if (key === "noContentSeconds" || key === "toolsMaxVisible" || key === "skillsMaxVisible") {
97
97
  this.input = new Input(); this.input.focused = this.hasFocus; this.input.setValue(String(this.draft.runtime[key]));
98
- this.inputLabel = key === "noContentSeconds" ? "No content threshold (1–3600 seconds)" : "Completed tool kinds shown before +N (1–8)";
98
+ this.inputLabel = key === "noContentSeconds" ? "No content threshold (1–3600 seconds)" : key === "toolsMaxVisible" ? "Completed tool kinds shown before +N (1–8)" : "Skill names shown before +N (1–8)";
99
99
  this.input.onEscape = () => this.cancel();
100
100
  this.input.onSubmit = (text) => {
101
101
  try { this.draft = parseConfig({ ...this.draft, runtime: { ...this.draft.runtime, [key]: Number(text) } }); this.input = undefined; this.error = ""; this.rebuild(value); }
package/src/render.ts CHANGED
@@ -6,7 +6,7 @@ export { cleanText } from "./text.ts";
6
6
  import type { ColorValue, SegmentConfig, SegmentId, StatuslineConfig, StatuslineSnapshot } from "./types.ts";
7
7
  import { emptyGit } from "./git.ts";
8
8
  import { emptyUsage } from "./usage.ts";
9
- import { renderRuntime, renderTools } from "./runtime-render.ts";
9
+ import { renderRuntime, renderSkills, renderTools } from "./runtime-render.ts";
10
10
  import { quotaPieces, quotaSeparator, renderQuota, type QuotaDetail } from "./quota.ts";
11
11
 
12
12
  export type RenderTheme = Pick<Theme, "style" | "colors" | "appearance">;
@@ -258,6 +258,8 @@ export function renderFooter(width: number, data: StatuslineSnapshot, config: St
258
258
  if (parts.length) lines.push(truncateToWidth(line, width, ellipsis));
259
259
  const tools = renderTools(width, data, config, theme);
260
260
  if (tools) lines.push(tools);
261
+ const skills = renderSkills(width, data, config, theme);
262
+ if (skills) lines.push(skills);
261
263
  const runtime = renderRuntime(width, data, config, theme, { statuses: secondary ? renderPart(secondary, theme) : undefined, ...sessionRow, elapsedStatus });
262
264
  if (runtime) lines.push(runtime);
263
265
  return lines;
@@ -279,7 +281,7 @@ export function sampleSnapshot(): StatuslineSnapshot {
279
281
  context: { tokens: 23800, contextWindow: 200000, percent: 11.9 },
280
282
  usage: { ...emptyUsage(), input: 32000, output: 5400, cacheRead: 12000, cost: 0.12 },
281
283
  git: { ...emptyGit("repository"), branch: "main", unstaged: 2, ahead: 2 },
282
- statuses: new Map([["example", "Example extension status"]]), sessionMinutes: 126, toolCalls: 128,
284
+ statuses: new Map([["example", "Example extension status"]]), sessionMinutes: 126, toolCalls: 128, skills: ["pdf-tools", "docx"],
283
285
  runtime: {
284
286
  runId: "example", status: "Running", elapsedMs: 28000, turns: 3, toolCalls: 8, awaitingInput: false, noContentMs: null, usage: { ...emptyUsage(), output: 1260 }, avg: 45, cache: 0.86,
285
287
  tools: [{ name: "bash", target: "npm test", elapsedMs: 12000 }],
@@ -36,6 +36,15 @@ function fit(parts: Part[], dropOrder: string[], width: number, separator: strin
36
36
  }
37
37
  return parts.length ? truncateToWidth(line, width, ellipsis) : undefined;
38
38
  }
39
+ /**
40
+ * Lower rows start with a space so their labels (`󱁤`, `󰗚`, `󰐰`) sit under the main row's
41
+ * model icon. Two spaces then set the label off from the contents; ASCII labels are words and take one.
42
+ */
43
+ function labeled(label: Span, ascii: boolean, width: number, theme: RenderTheme, render: (width: number) => string | undefined): string | undefined {
44
+ const prefix = ` ${theme.style(label[0], { fg: theme.colors[label[1]] })}${ascii ? " " : " "}`;
45
+ const line = render(Math.max(1, width - visibleWidth(prefix)));
46
+ return line ? truncateToWidth(prefix + line, width, ascii ? "..." : "…") : undefined;
47
+ }
39
48
 
40
49
  const STATUS: Partial<Record<RuntimeSnapshot["status"], { icon: string; ascii: string; color: Color }>> = {
41
50
  Running: { icon: "●", ascii: "*", color: "muted" },
@@ -58,7 +67,8 @@ export interface RuntimeExtras {
58
67
  }
59
68
 
60
69
  /**
61
- * The bottom row: run status and duration, run metrics, then session age, tool calls, tokens and extension statuses.
70
+ * The bottom row (` 󰐰 ● 5m 42s · …`): run status and duration, run metrics, then session age, tool calls, tokens
71
+ * and extension statuses.
62
72
  * It stays muted so it does not compete with the editor; only problems (failure, waits, low cache) are colored.
63
73
  */
64
74
  export function renderRuntime(width: number, data: StatuslineSnapshot, config: StatuslineConfig, theme: RenderTheme, extras: RuntimeExtras = {}): string | undefined {
@@ -93,10 +103,42 @@ export function renderRuntime(width: number, data: StatuslineSnapshot, config: S
93
103
  if (extras.toolTotal) parts.push({ id: "toolTotal", spans: [], styled: extras.toolTotal });
94
104
  if (extras.tokens) parts.push({ id: "tokens", spans: [], styled: extras.tokens });
95
105
  if (extras.statuses && !compacting) parts.push({ id: "statuses", spans: [], styled: extras.statuses });
96
- return fit(parts, ["statuses", "cache", "avg", "compactions", "toolTotal", "session", "tokens", "turns", "activity", "failure"], width, ascii ? " | " : " · ", theme, ascii ? "..." : "…");
106
+ // A pulse: the run's status and vitals, then the session's.
107
+ const label: Span = [{ nerd: "\u{F0430}", unicode: "∿", ascii: "run" }[config.icons], "dim"];
108
+ return labeled(label, ascii, width, theme, (available) =>
109
+ fit(parts, ["statuses", "cache", "avg", "compactions", "toolTotal", "session", "tokens", "turns", "activity", "failure"], available, ascii ? " | " : " · ", theme, ascii ? "..." : "…"));
97
110
  }
98
111
 
99
- /** `◐ bash npm test 12s · ✓ read ×5 · ✗ bash ×1 · +2`: present while the run has used tools. */
112
+ /** ` 󰗚 pdf-tools · docx +1`: the session's skills in first-use order, present once one is used. */
113
+ export function renderSkills(width: number, data: StatuslineSnapshot, config: StatuslineConfig, theme: RenderTheme): string | undefined {
114
+ if (!config.runtime.enabled || !config.runtime.skills || !data.skills.length) return undefined;
115
+ const ascii = config.icons === "ascii", ellipsis = ascii ? "..." : "…", separator = ascii ? " | " : " · ";
116
+ const names = data.skills.map((name) => truncateToWidth(name, 24, ellipsis));
117
+ // An open book: a skill is a set of instructions. ASCII keeps the word.
118
+ const label: Span = [{ nerd: "\u{F05DA}", unicode: "❖", ascii: "skills" }[config.icons], "dim"];
119
+ const build = (visible: number): Part[] => {
120
+ if (!visible) return [{ id: "skills", spans: [[String(names.length), "muted"]] }];
121
+ const spans: Span[] = [];
122
+ names.slice(0, visible).forEach((name, index) => { if (index) spans.push([separator, "dim"]); spans.push([name, "muted"]); });
123
+ if (names.length > visible) spans.push([` +${names.length - visible}`, "dim"]);
124
+ return [{ id: "skills", spans }];
125
+ };
126
+ // Narrowing order: fold names into `+N`, then show only the count.
127
+ return labeled(label, ascii, width, theme, (available) => {
128
+ let parts: Part[] = [];
129
+ for (let visible = Math.min(config.runtime.skillsMaxVisible, names.length); visible >= 0; visible--) {
130
+ parts = build(visible);
131
+ if (visibleWidth(draw(parts, separator, theme)) <= available) break;
132
+ }
133
+ return fit(parts, [], available, separator, theme, ellipsis);
134
+ });
135
+ }
136
+
137
+ /**
138
+ * ` 󱁤 ◐ bash npm test 12s · ✓ read ×5 · ✗ bash ×1 · +2`: present while the run has used tools.
139
+ * Like the runtime row it stays quiet: running tools (`◐ bash`) are the brightest text, completed
140
+ * ones recede, and only problems (a tool running 30s or longer, a failure) are colored.
141
+ */
100
142
  export function renderTools(width: number, data: StatuslineSnapshot, config: StatuslineConfig, theme: RenderTheme): string | undefined {
101
143
  const runtime = data.runtime;
102
144
  if (!config.runtime.enabled || !config.runtime.tools || !runtime || (!runtime.tools.length && !runtime.completed.length)) return undefined;
@@ -112,15 +154,17 @@ export function renderTools(width: number, data: StatuslineSnapshot, config: Sta
112
154
  const failed = runtime.completed.filter((tool) => tool.failed).sort((a, b) => b.failed - a.failed);
113
155
  const build = (visible: number, targets: boolean, timers: boolean): Part[] => {
114
156
  const parts: Part[] = running.slice(0, 2).map((group) => {
115
- const spans: Span[] = [[sym.run, "warning"], [` ${group.name}`, "accent"]];
157
+ // A tool running 30s or longer is the one problem a running call can show.
158
+ const slow = group.elapsedMs >= 30000;
159
+ const spans: Span[] = [[sym.run, slow ? "warning" : "text"], [` ${group.name}`, "text"]];
116
160
  if (group.count > 1) spans.push([` ${sym.times}${group.count}`, "dim"]);
117
161
  else if (targets && group.target) spans.push([` ${group.target}`, "muted"]);
118
- if (timers && group.elapsedMs >= 1000) spans.push([` ${short(group.elapsedMs)}`, group.elapsedMs >= 30000 ? "warning" : "muted"]);
162
+ if (timers && group.elapsedMs >= 1000) spans.push([` ${short(group.elapsedMs)}`, slow ? "warning" : "muted"]);
119
163
  return { id: "running", spans };
120
164
  });
121
165
  const moreRunning = running.slice(2).reduce((total, group) => total + group.count, 0);
122
- if (moreRunning) parts.push({ id: "running", spans: [[sym.run, "warning"], [` +${moreRunning}`, "dim"]] });
123
- for (const tool of ok.slice(0, visible)) parts.push({ id: "ok", spans: [[sym.ok, "success"], [` ${tool.name}`, "muted"], [` ${sym.times}${tool.ok}`, "dim"]] });
166
+ if (moreRunning) parts.push({ id: "running", spans: [[sym.run, "text"], [` +${moreRunning}`, "dim"]] });
167
+ for (const tool of ok.slice(0, visible)) parts.push({ id: "ok", spans: [[sym.ok, "dim"], [` ${tool.name}`, "muted"], [` ${sym.times}${tool.ok}`, "dim"]] });
124
168
  for (const tool of failed) parts.push({ id: "failed", spans: [[sym.fail, "error"], [` ${tool.name}`, "muted"], [` ${sym.times}${tool.failed}`, "error"]] });
125
169
  const hidden = ok.length - Math.min(visible, ok.length);
126
170
  if (hidden) parts.push({ id: "more", spans: [[`+${hidden}`, "dim"]] });
@@ -132,10 +176,14 @@ export function renderTools(width: number, data: StatuslineSnapshot, config: Sta
132
176
  for (let visible = max; visible >= 1; visible--) attempts.push([visible, true, true]);
133
177
  attempts.push([1, false, true], [0, false, true], [0, false, false]);
134
178
  const separator = ascii ? " | " : " · ";
135
- let parts: Part[] = [];
136
- for (const [visible, targets, timers] of attempts) {
137
- parts = build(visible, targets, timers);
138
- if (visibleWidth(draw(parts, separator, theme)) <= width) break;
139
- }
140
- return fit(parts, [], width, separator, theme, ascii ? "..." : "…");
179
+ // The same icon as the session's tool total: this row is the current run's share.
180
+ const label: Span = [{ nerd: "\u{F1064}", unicode: "⚒", ascii: "tools" }[config.icons], "dim"];
181
+ return labeled(label, ascii, width, theme, (available) => {
182
+ let parts: Part[] = [];
183
+ for (const [visible, targets, timers] of attempts) {
184
+ parts = build(visible, targets, timers);
185
+ if (visibleWidth(draw(parts, separator, theme)) <= available) break;
186
+ }
187
+ return fit(parts, [], available, separator, theme, ascii ? "..." : "…");
188
+ });
141
189
  }
package/src/session.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { homedir } from "node:os";
2
2
  import type { AssistantMessage } from "@earendil-works/pi-ai";
3
- import type { ExtensionContext, ReadonlyFooterDataProvider } from "@earendil-works/pi-coding-agent";
3
+ import type { ExtensionContext, ReadonlyFooterDataProvider, SlashCommandInfo } from "@earendil-works/pi-coding-agent";
4
4
  import type { TUI } from "@earendil-works/pi-tui";
5
5
  import { emptyGit, GitPoller, type GitReader } from "./git.ts";
6
6
  import { renderFooter, withSpacing } from "./render.ts";
@@ -9,6 +9,7 @@ import { UsageCache } from "./usage.ts";
9
9
  import { RuntimeState } from "./runtime.ts";
10
10
  import { CompactionState } from "./compaction.ts";
11
11
  import { QuotaState } from "./quota.ts";
12
+ import { sessionSkills } from "./skills.ts";
12
13
 
13
14
  /** The header's creation time; hidden rather than guessed when missing, malformed or in the future. */
14
15
  export function sessionStart(timestamp: string | undefined, now = Date.now()): number | null {
@@ -37,12 +38,14 @@ export class FooterSession {
37
38
  private context: StatuslineSnapshot["context"] = { tokens: null, contextWindow: 0, percent: null };
38
39
  private sessionStartMs: number | null = null;
39
40
  private toolCalls = 0;
41
+ private skills: string[] = [];
40
42
  private readonly gitReader: GitReader | undefined;
43
+ private readonly commands: () => readonly SlashCommandInfo[];
41
44
  private signal: AbortSignal | undefined;
42
45
  private readonly onAbort = () => { this.runtime.observeAbort(); this.schedule(true); };
43
46
 
44
- constructor(ctx: ExtensionContext, config: StatuslineConfig, gitReader?: GitReader) {
45
- this.ctx = ctx; this.config = config; this.gitReader = gitReader;
47
+ constructor(ctx: ExtensionContext, config: StatuslineConfig, gitReader?: GitReader, commands: () => readonly SlashCommandInfo[] = () => []) {
48
+ this.ctx = ctx; this.config = config; this.gitReader = gitReader; this.commands = commands;
46
49
  }
47
50
  get active(): boolean { return this.ownsFooter && !this.closed; }
48
51
  setContext(ctx: ExtensionContext): void { this.ctx = ctx; this.quota.select(ctx.model); this.watchSignal(); }
@@ -132,6 +135,7 @@ export class FooterSession {
132
135
  this.usage.update(entries);
133
136
  this.compaction.update(entries);
134
137
  this.toolCalls = entries.reduce((total, entry) => total + (entry.type === "message" && entry.message.role === "toolResult" ? 1 : 0), 0);
138
+ this.skills = sessionSkills(entries, this.ctx.cwd, this.commands);
135
139
  this.sessionStartMs = sessionStart(manager.getHeader()?.timestamp);
136
140
  const context = this.ctx.getContextUsage();
137
141
  this.context = context ?? { tokens: null, contextWindow: this.ctx.model?.contextWindow ?? 0, percent: null };
@@ -154,7 +158,7 @@ export class FooterSession {
154
158
  statuses: this.provider?.getExtensionStatuses() ?? new Map(),
155
159
  // Minute resolution keeps an idle footer from repainting every second.
156
160
  sessionMinutes: this.sessionStartMs === null ? null : Math.floor(Math.max(0, Date.now() - this.sessionStartMs) / 60000),
157
- toolCalls: this.toolCalls,
161
+ toolCalls: this.toolCalls, skills: this.skills,
158
162
  runtime: this.runtime.snapshot(this.config.runtime.retainSummary), compaction: this.compaction.snapshot(),
159
163
  };
160
164
  }
package/src/skills.ts ADDED
@@ -0,0 +1,40 @@
1
+ import { homedir } from "node:os";
2
+ import { resolve } from "node:path";
3
+ import { parseSkillBlock, type SessionEntry, type SlashCommandInfo } from "@earendil-works/pi-coding-agent";
4
+ import { cleanText } from "./text.ts";
5
+
6
+ /** Pi's read path handling: an `@` prefix is stripped, `~` is the home directory, the rest is relative to cwd. */
7
+ function readPath(path: string, cwd: string): string {
8
+ const text = path.startsWith("@") ? path.slice(1) : path;
9
+ if (text === "~") return homedir();
10
+ return resolve(cwd, text.startsWith("~/") ? `${homedir()}${text.slice(1)}` : text);
11
+ }
12
+ function userText(content: unknown): string {
13
+ if (typeof content === "string") return content;
14
+ if (!Array.isArray(content)) return "";
15
+ return content.map((block) => block?.type === "text" && typeof block.text === "string" ? block.text : "").join("");
16
+ }
17
+
18
+ /**
19
+ * Loaded skills used in the session, in first-use order: `/skill:name` invocations and model
20
+ * reads of a loaded skill's file. Reads of skill files Pi did not load are not skills in use.
21
+ */
22
+ export function sessionSkills(entries: readonly SessionEntry[], cwd: string, commands: () => readonly SlashCommandInfo[]): string[] {
23
+ const used = new Set<string>();
24
+ let paths: Map<string, string> | undefined;
25
+ const add = (name: string | undefined) => { const text = name && cleanText(name).trim(); if (text) used.add(text); };
26
+ for (const entry of entries) {
27
+ if (entry.type !== "message") continue;
28
+ const message = entry.message;
29
+ if (message.role === "user") add(parseSkillBlock(userText(message.content))?.name);
30
+ if (message.role !== "assistant" || !Array.isArray(message.content)) continue;
31
+ for (const block of message.content) {
32
+ if (block.type !== "toolCall" || block.name !== "read" || typeof block.arguments?.path !== "string") continue;
33
+ // Looked up once per scan, only when the session has reads.
34
+ paths ??= new Map(commands().filter((command) => command.source === "skill" && command.sourceInfo?.path)
35
+ .map((command) => [resolve(command.sourceInfo.path), command.name.replace(/^skill:/, "")]));
36
+ add(paths.get(readPath(block.arguments.path, cwd)));
37
+ }
38
+ }
39
+ return [...used];
40
+ }
package/src/tools.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { basename } from "node:path";
1
+ import { basename, dirname } from "node:path";
2
2
  import { visibleWidth } from "@earendil-works/pi-tui";
3
3
  import { cleanText } from "./text.ts";
4
4
 
@@ -21,6 +21,13 @@ function fileName(path: string | undefined): string | undefined {
21
21
  const name = path ? basename(cleanText(path).replace(/[\\/]+$/, "")) : "";
22
22
  return name && name !== "." ? name : undefined;
23
23
  }
24
+ /** `skills/pdf-tools/SKILL.md` → `pdf-tools/SKILL.md`: every skill file has the same name. */
25
+ function readTarget(path: string | undefined): string | undefined {
26
+ const name = fileName(path);
27
+ if (name !== "SKILL.md") return fit(name, 24);
28
+ const skill = fileName(dirname(cleanText(path!).replace(/[\\/]+$/, "")));
29
+ return skill ? `${fit(skill, 24 - "/SKILL.md".length)}/SKILL.md` : name;
30
+ }
24
31
  /** `cd dir && FOO=1 npm test` → `npm test`: the part that says what is running. */
25
32
  function commandSummary(command: string): string | undefined {
26
33
  let text = cleanText(command.split(/\r?\n/).find((line) => line.trim()) ?? "");
@@ -35,7 +42,8 @@ function commandSummary(command: string): string | undefined {
35
42
  export function toolTarget(name: string, args: unknown): string | undefined {
36
43
  switch (name) {
37
44
  case "bash": case "powershell": { const command = arg(args, "command"); return fit(command && commandSummary(command), 24); }
38
- case "read": case "edit": case "write": return fit(fileName(arg(args, "path")), 24);
45
+ case "read": return readTarget(arg(args, "path"));
46
+ case "edit": case "write": return fit(fileName(arg(args, "path")), 24);
39
47
  case "grep": case "find": { const pattern = arg(args, "pattern"); const text = pattern && cleanText(pattern); return text ? `"${fit(text, 16)}"` : undefined; }
40
48
  case "ls": { const dir = fileName(arg(args, "path")); return dir ? `${fit(dir, 23)}/` : undefined; }
41
49
  default: return undefined;
package/src/types.ts CHANGED
@@ -17,6 +17,10 @@ export interface RuntimeConfig {
17
17
  retainSummary: boolean;
18
18
  /** Completed tool kinds shown before folding into `+N` (1–8). */
19
19
  toolsMaxVisible: number;
20
+ /** The session's skills row. */
21
+ skills: boolean;
22
+ /** Skill names shown before folding into `+N` (1–8). */
23
+ skillsMaxVisible: number;
20
24
  }
21
25
  export interface SegmentConfig {
22
26
  id: SegmentId;
@@ -74,6 +78,8 @@ export interface StatuslineSnapshot {
74
78
  sessionMinutes: number | null;
75
79
  /** Completed tool calls recorded in the session file, across all runs. */
76
80
  toolCalls: number;
81
+ /** Loaded skills used in the session, in first-use order. */
82
+ skills: string[];
77
83
  runtime?: import("./runtime.ts").RuntimeSnapshot;
78
84
  compaction?: import("./compaction.ts").CompactionSnapshot;
79
85
  }