@giladbarnea/pi-custom-footer 0.1.6 → 0.1.7

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/index.ts +34 -34
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- last_updated: 2026-10-26T15-03
2
+ last_updated: 2026-10-29T12-05
3
3
  ---
4
4
 
5
5
  <div align="center">
@@ -31,7 +31,7 @@ Below the editor, see:
31
31
 
32
32
  The layout follows your Pi theme. The header and the footer each take the fewest lines they can. To fit, they first drop labels, round readings, remove whitespace, and drop the branch icon. Only then does the footer hide facts: the reused/new split, the session hit rate, the token counts, and last the cost per turn.
33
33
 
34
- Skills get up to 10% of the terminal's rows, rounded to the nearest row with a minimum of two. To fit, the row first drops token ages, then separators, then shortens long names in the middle (`caut…ctor`). Only then does it reserve the final row for a hidden-skill count.
34
+ Skills get one row for every eight terminal rows past the first six, with a minimum of one. A 21-row phone screen gets one row, a 27-row screen two, and a 34-row screen three. To fit, the row first drops token ages, then separators, then shortens long names in the middle (`caut…ctor`). Only then does it hide skills from the end, behind a `+N` count at the end of the last row.
35
35
 
36
36
  **Resize without rescanning the conversation.** The header and footer share cached values. Session changes refresh them, including forks and compaction.
37
37
 
package/index.ts CHANGED
@@ -3,15 +3,16 @@
3
3
  *
4
4
  * Skill row. Each loaded skill shows its name and its token age: how far the
5
5
  * context has grown since the first response that saw the skill. The age tells
6
- * how deep in the context the skill now sits. Skills get one tenth of the
7
- * terminal's rows, rounded to the nearest row with a minimum of two. When
8
- * they do not fit, the row gives up the least important thing left:
6
+ * how deep in the context the skill now sits. Skills get one row for every
7
+ * eight terminal rows past the first six, rounded down, with a minimum of one.
8
+ * When they do not fit, the row gives up the least important thing left:
9
9
  * 1. The token ages.
10
10
  * 2. The separators between skills.
11
11
  * 3. The middle of the longest names, one character per step, down to four
12
12
  * characters on each side of the ellipsis. Names shorter than ten
13
13
  * characters never change.
14
- * 4. Last, reserve the final row for a "+N skills" count.
14
+ * 4. Last, hide skills from the end behind a "+N" count that ends the
15
+ * last row.
15
16
  * Knowing which skills are loaded matters more than any detail about them, so
16
17
  * hiding a skill is the last resort. The Claude Code status line in
17
18
  * ~/.claude/statusline.sh uses the same order.
@@ -31,8 +32,13 @@ import { getLoadedSkills, type SkillLocation } from "./skill-tracker.ts";
31
32
 
32
33
  // ── Layout constants ────────────────────────────────────────────────────────
33
34
 
34
- const MINIMUM_SKILL_ROWS = 2;
35
- const TERMINAL_ROWS_PER_SKILL_ROW = 10;
35
+ // The skill-row limit reads only the terminal height, never the todo list, editor or other widgets: predictable, and no measuring loop with taller-editor.
36
+ // Accepted cost: when a short screen and a long todo list overflow Pi's stack, Pi cuts the skill rows first, rather than us measuring Pi's internal layout.
37
+ // Calibrated on a phone over SSH: 21 terminal rows give one skill row, 22 to
38
+ // 29 give two, and 30 to 37 give three.
39
+ const MINIMUM_SKILL_ROWS = 1;
40
+ const TERMINAL_ROWS_BEFORE_SKILL_ROWS = 6;
41
+ const TERMINAL_ROWS_PER_SKILL_ROW = 8;
36
42
  // A truncated name keeps four characters on each side of the ellipsis.
37
43
  const MIN_TRUNCATED_NAME_LENGTH = 9;
38
44
  const NARROW_SEPARATOR = " ";
@@ -174,17 +180,12 @@ function wrapParts(parts: string[], width: number, separator: string): string[][
174
180
  return lines;
175
181
  }
176
182
 
177
- type WrappedLine = { text: string; partCount: number };
178
-
179
- /** Wrap whole parts and retain the number of parts in each row.
183
+ /** Wrap whole parts into joined lines that fit the width.
180
184
  * @example
181
- * wrapJoinedLines(["one", "two"], 6, " · ") // [{ text: " one", partCount: 1 }, { text: " two", partCount: 1 }]
185
+ * wrapJoinedLines(["one", "two"], 6, " · ") // [" one", " two"]
182
186
  */
183
- function wrapJoinedLines(parts: string[], width: number, separator: string): WrappedLine[] {
184
- return wrapParts(parts, width, separator).map((lineParts) => ({
185
- text: truncateToWidth(joinedLine(lineParts, separator), width),
186
- partCount: lineParts.length,
187
- }));
187
+ function wrapJoinedLines(parts: string[], width: number, separator: string): string[] {
188
+ return wrapParts(parts, width, separator).map((lineParts) => truncateToWidth(joinedLine(lineParts, separator), width));
188
189
  }
189
190
 
190
191
  /** Pack rows onto lines. Rows share a line when they fit, and a row breaks only
@@ -194,7 +195,7 @@ function wrapJoinedLines(parts: string[], width: number, separator: string): Wra
194
195
  */
195
196
  function packRows(rows: string[][], width: number, separator: string): string[] {
196
197
  const rowLines = rows.flatMap((row) => wrapParts(row, width, separator).map((lineParts) => lineParts.join(separator)));
197
- return wrapJoinedLines(rowLines, width, separator).map((line) => line.text);
198
+ return wrapJoinedLines(rowLines, width, separator);
198
199
  }
199
200
 
200
201
  /** The ladder's fullest state among those that pack the facts onto the fewest lines.
@@ -638,28 +639,27 @@ export default function (pi: ExtensionAPI) {
638
639
  };
639
640
  // No background here: the cwd pill is the one filled element in the whole
640
641
  // footer, and a second pill style would leave neither of them the anchor.
641
- const renderSkillLines = (layout: SkillLayout) => wrapJoinedLines(
642
- loadedSkills.map(({ name, tokenAge }) => {
643
- const nameText = paint.token(SKILL_TOKEN, middleTruncate(name, layout.maxNameLength));
644
- const ageText = layout.ages && tokenAge !== null ? theme.fg("dim", ` -${formatTokens(tokenAge)}`) : "";
645
- return `${nameText}${ageText}`;
646
- }),
647
- width,
648
- theme.fg("dim", layout.separator),
649
- );
642
+ const skillParts = (layout: SkillLayout) => loadedSkills.map(({ name, tokenAge }) => {
643
+ const nameText = paint.token(SKILL_TOKEN, middleTruncate(name, layout.maxNameLength));
644
+ const ageText = layout.ages && tokenAge !== null ? theme.fg("dim", ` -${formatTokens(tokenAge)}`) : "";
645
+ return `${nameText}${ageText}`;
646
+ });
647
+ const renderSkillLines = (parts: string[], layout: SkillLayout) => wrapJoinedLines(parts, width, theme.fg("dim", layout.separator));
650
648
  // Take the fullest layout that fits the row limit. Hiding skills behind a
651
- // count is the last resort, after the most compact layout.
652
- const maximumSkillRows = Math.max(MINIMUM_SKILL_ROWS, Math.round(terminalHeight / TERMINAL_ROWS_PER_SKILL_ROW));
649
+ // count is the last resort, after the most compact layout. The count ends
650
+ // the last row, so even a one-row limit still names some skills.
651
+ const maximumSkillRows = Math.max(MINIMUM_SKILL_ROWS, Math.floor((terminalHeight - TERMINAL_ROWS_BEFORE_SKILL_ROWS) / TERMINAL_ROWS_PER_SKILL_ROW));
653
652
  const layouts = skillLayouts(Math.max(0, ...loadedSkills.map(({ name }) => name.length)));
654
- const layout = layouts.find((candidate) => renderSkillLines(candidate).length <= maximumSkillRows) ?? layouts.at(-1)!;
655
- const skillLines = renderSkillLines(layout);
656
- const visibleSkillLines = skillLines.length > maximumSkillRows ? skillLines.slice(0, maximumSkillRows - 1) : skillLines;
657
- const hiddenSkillCount = skillLines.slice(visibleSkillLines.length).reduce((count, line) => count + line.partCount, 0);
658
- const overflowLines = hiddenSkillCount === 0 ? [] : [truncateToWidth(theme.fg("dim", ` +${hiddenSkillCount} skills`), width)];
653
+ const layout = layouts.find((candidate) => renderSkillLines(skillParts(candidate), candidate).length <= maximumSkillRows) ?? layouts.at(-1)!;
654
+ const parts = skillParts(layout);
655
+ const partsHiding = (hiddenCount: number) => hiddenCount === 0
656
+ ? parts
657
+ : [...parts.slice(0, parts.length - hiddenCount), theme.fg("dim", `+${hiddenCount}`)];
658
+ const hiddenSkillCount = Array.from({ length: parts.length + 1 }, (_, count) => count)
659
+ .find((count) => renderSkillLines(partsHiding(count), layout).length <= maximumSkillRows)!;
659
660
  return [
660
661
  ...fitFacts(headerFacts, HEADER_LADDER, width, theme),
661
- ...visibleSkillLines.map((line) => line.text),
662
- ...overflowLines,
662
+ ...renderSkillLines(partsHiding(hiddenSkillCount), layout),
663
663
  ];
664
664
  }
665
665
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-custom-footer",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Context, cache, cost, and loaded skills at a glance in Pi.",
5
5
  "type": "module",
6
6
  "license": "MIT",