pi-path-bar 0.5.0 → 0.5.2

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.2]
4
+
5
+ - In Minimal mode, `billion-context` subagent token usage appears next to session usage on the top border. It no longer repeats below the editor and is hidden when space is tight.
6
+
7
+ ## [0.5.1]
8
+
9
+ - Adapted for Pi 1.6.0.
10
+
3
11
  ## [0.5.0]
4
12
 
5
13
  - **Minimal mode (enabled by default):** Reclaim vertical space by removing the multi-line footer and placing your path, Git status, usage, model, context, and local time cleanly on the editor's top and bottom borders. Built for small screens and narrow splits, with automatic progressive compacting, `+N` overflow folding, and jitter-free running status. Turn it off anytime in `/path-bar` to use the classic multi-line footer or Pi's native footer.
package/README.md CHANGED
@@ -11,7 +11,7 @@ Built for small screens and narrow splits. **pi-path-bar** removes Pi's multi-li
11
11
  Enabled by default. On laptops and split panes, a stacked footer wastes vertical space and breaks awkwardly when the terminal gets narrow. Minimal mode fixes both:
12
12
 
13
13
  - **Zero footer rows:** Everything moves cleanly onto the editor's top and bottom borders, giving your conversation more vertical space.
14
- - **Smooth on narrow splits:** As the window shrinks, parent folders, Git numbers, model names, and context limits step down automatically, and extra right-side items fold into `+N`. Nothing wraps or jumbles.
14
+ - **Smooth on narrow splits:** The bar shortens paths, Git counts, and context limits as space runs out. It truncates model names from the left to keep the model suffix visible. Extra right-side items fold into `+N`.
15
15
  - **Calm, jitter-free status:** Text stays locked in place when Pi starts or finishes running. Rare notices like retries or compaction appear when needed and clear out right after.
16
16
  - **Clean with other extensions:** Popular usage and status extensions stay compact on the top border automatically. Any other extension status appears below only while active and hides when empty.
17
17
  - **Easy to switch back:** Turn **Minimal mode** off anytime in `/path-bar` to use the classic multi-line footer or Pi's native footer.
package/README.zh-CN.md CHANGED
@@ -11,7 +11,7 @@
11
11
  默认开启。在笔记本小屏或分屏终端里,传统多行底栏既占高度,变窄时又容易折行错乱。极简模式直接解决这两个痛点:
12
12
 
13
13
  - **零底栏占行**:隐藏底部状态行,把关键信息干净地嵌进输入框上下横线,留出更多对话阅读空间。
14
- - **窄屏自动瘦身**:分屏变窄时自动精简父目录、Git 计数、模型名与上下文上限,放不下的右侧项自动折叠为 `+N`,绝不折行打乱排版。
14
+ - **窄屏自动瘦身**:空间不足时精简父目录、Git 计数和上下文上限。模型名从左侧截断,优先保留右侧的模型代号。放不下的右侧项折叠为 `+N`。
15
15
  - **运行不跳动**:开始与结束运行时,状态文字位置纹丝不动;遇到重试或压缩等提醒时自动浮现,结束后恢复清净。
16
16
  - **扩展共存清爽**:常见用量与状态扩展会自动以紧凑样式留在上横线;其他扩展仅在有提示时临时出现一行,空闲时彻底隐藏。
17
17
  - **随时切回**:在 `/path-bar` 中关闭 **Minimal mode**,即可随时恢复传统多行底栏或 Pi 原生底栏。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-path-bar",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "A Pi extension for compact paths, folder aliases, and theme-aware Git status",
5
5
  "keywords": [
6
6
  "footer",
@@ -39,8 +39,8 @@
39
39
  "prepublishOnly": "npm run check && npm test"
40
40
  },
41
41
  "devDependencies": {
42
- "@earendil-works/pi-coding-agent": "^1.5.0",
43
- "@earendil-works/pi-tui": "^1.5.0",
42
+ "@earendil-works/pi-coding-agent": "^1.6.0",
43
+ "@earendil-works/pi-tui": "^1.6.0",
44
44
  "@types/node": "^26.6.6",
45
45
  "typescript": "^7.0.2"
46
46
  },
package/src/index.ts CHANGED
@@ -135,10 +135,11 @@ export default function (pi: ExtensionAPI, configFile = join(getAgentDir(), "pi-
135
135
  const { totals, hitRate } = readStats(current);
136
136
  const model = current.model;
137
137
  const subscription = Boolean(model && (model.provider === "kimi-coding" || current.modelRegistry?.isUsingOAuth(model)));
138
- const { slots } = classifyStatuses(footerData?.getExtensionStatuses() ?? new Map());
138
+ const { slots, billionContextUsage } = classifyStatuses(footerData?.getExtensionStatuses() ?? new Map());
139
139
  return {
140
140
  indicator,
141
141
  totals,
142
+ billionContextUsage,
142
143
  hitRate,
143
144
  subscription,
144
145
  sessionName: current.sessionManager.getSessionName(),
package/src/minimal.ts CHANGED
@@ -26,6 +26,7 @@ export interface MinimalBorderTheme {
26
26
  export interface MinimalTopInput {
27
27
  indicator?: WorkingIndicatorLike;
28
28
  totals: UsageTotals;
29
+ billionContextUsage?: string;
29
30
  hitRate?: number;
30
31
  subscription: boolean;
31
32
  sessionName?: string;
@@ -85,47 +86,41 @@ export function formatTimeMinimal(date: Date, timeFormat: "24h" | "12h"): string
85
86
  return `${h12}:${minutes}${suffix}`;
86
87
  }
87
88
 
88
- export function shortModelName(id: string | undefined, compact = false): string {
89
- if (!id) return compact ? "?" : "no-model";
89
+ export function shortModelName(id: string | undefined): string {
90
+ if (!id) return "no-model";
90
91
  const stripped = clean(id)
91
92
  .replace(/-\d{4}-\d{2}-\d{2}$/, "")
92
93
  .replace(/-\d{8}$/, "")
93
- .replace(/-\d{4}$/, "")
94
94
  .replace(/-(?:latest|preview|instruct|chat)$/i, "");
95
95
 
96
96
  let match = /^claude-(sonnet|opus|haiku)-(\d+)[.-](\d+)$/i.exec(stripped);
97
97
  if (match) {
98
98
  const family = match[1].toLowerCase();
99
- return compact ? `${family[0]}${match[2]}.${match[3]}` : `${family}-${match[2]}.${match[3]}`;
99
+ return `${family}-${match[2]}.${match[3]}`;
100
100
  }
101
101
  match = /^claude-(\d+)[.-](\d+)-(sonnet|opus|haiku)$/i.exec(stripped);
102
102
  if (match) {
103
103
  const family = match[3].toLowerCase();
104
- return compact ? `${family[0]}${match[1]}.${match[2]}` : `${family}-${match[1]}.${match[2]}`;
104
+ return `${family}-${match[1]}.${match[2]}`;
105
105
  }
106
106
  match = /^claude-(sonnet|opus|haiku)-(\d+)$/i.exec(stripped);
107
- if (match) {
108
- const family = match[1].toLowerCase();
109
- return compact ? `${family[0]}${match[2]}` : `${family}-${match[2]}`;
110
- }
107
+ if (match) return `${match[1].toLowerCase()}-${match[2]}`;
111
108
  match = /^gemini-([\d.]+)-(flash-lite|pro|flash|ultra)(?:-[a-z0-9.]+)?$/i.exec(stripped);
112
109
  if (match) {
113
110
  const tierMap: Record<string, string> = { "flash-lite": "fl", pro: "p", flash: "f", ultra: "u" };
114
111
  const tier = tierMap[match[2].toLowerCase()] ?? match[2][0].toLowerCase();
115
- return compact ? `g${match[1]}${tier}` : `gem-${match[1]}${tier}`;
112
+ return `gem-${match[1]}${tier}`;
116
113
  }
117
114
  match = /^gpt-([\d.]+)(?:-(codex|mini|nano|turbo))?$/i.exec(stripped);
118
115
  if (match) {
119
116
  const tierMap: Record<string, string> = { codex: "c", mini: "m", nano: "n", turbo: "t" };
120
117
  const tier = match[2] ? tierMap[match[2].toLowerCase()] ?? "" : "";
121
- return compact ? `g${match[1]}${tier}` : `gpt-${match[1]}${tier}`;
118
+ return `gpt-${match[1]}${tier}`;
122
119
  }
123
120
  if (/^deepseek-reasoner$/i.test(stripped)) return "ds-r1";
124
- if (/^deepseek-chat$/i.test(stripped)) return compact ? "ds-c" : "ds-chat";
121
+ if (/^deepseek-chat$/i.test(stripped)) return "ds-chat";
125
122
  match = /^deepseek-(.+)$/i.exec(stripped);
126
- if (match) return compact ? truncateToWidth(`ds-${match[1]}`, 8, "…") : `ds-${match[1]}`;
127
-
128
- return compact ? truncateToWidth(stripped, 8, "…") : stripped;
123
+ return match ? `ds-${match[1]}` : stripped;
129
124
  }
130
125
 
131
126
  export function shortThinking(level: string | undefined): string {
@@ -327,8 +322,12 @@ export function renderMinimalTopBorder(input: MinimalTopInput, width: number, hi
327
322
  const sessionClean = input.showSession && input.sessionName ? clean(input.sessionName).trim() : "";
328
323
  const sessionText = sessionClean ? dim(`·${truncateToWidth(sessionClean, 12, "…")}`) : "";
329
324
 
325
+ const delegateText = input.billionContextUsage
326
+ ? dim(`${tokensText ? "· " : ""}${input.billionContextUsage}`)
327
+ : "";
330
328
  const telemetryTiers = [
331
- [tokensText, cacheText, costText, sessionText],
329
+ [tokensText, delegateText, cacheText, costText, sessionText],
330
+ ...(delegateText ? [[tokensText, delegateText, cacheText, costText]] : []),
332
331
  [tokensText, cacheText, costText],
333
332
  [tokensText, costText],
334
333
  [costText],
@@ -395,11 +394,17 @@ export function renderMinimalBottomBorder(input: MinimalBottomInput, width: numb
395
394
  const thinking = input.reasoning ? shortThinking(input.thinkingLevel) : "";
396
395
  const thinkingStyled = thinking ? borderColor(thinking) : "";
397
396
 
398
- const makeRight = (compactModel: boolean, includeThinking: boolean, includeWindow: boolean): string => {
399
- const model = dim(shortModelName(input.modelId, compactModel));
397
+ const modelName = shortModelName(input.modelId);
398
+ const makeRight = (includeThinking: boolean, includeWindow: boolean, budget = Infinity, minModelWidth = 0): string => {
400
399
  const ctx = formatContextMinimal(input.contextPercent, input.contextWindow, includeWindow, theme);
401
- const modelPart = includeThinking && thinkingStyled ? `${model}${thinkingStyled}` : model;
402
- return `${modelPart}${dim(" ")}${ctx}`;
400
+ const level = includeThinking ? thinkingStyled : "";
401
+ const name = !input.modelId && budget !== Infinity ? "?" : modelName;
402
+ const nameWidth = visibleWidth(name);
403
+ const available = budget - visibleWidth(ctx) - visibleWidth(level) - 1;
404
+ if (minModelWidth && available < Math.min(minModelWidth, nameWidth)) return "";
405
+ const tail = nameWidth <= available ? name : sliceByColumn(name, nameWidth - available + 1, available - 1, true);
406
+ if (!tail) return minModelWidth ? "" : ctx;
407
+ return `${dim(nameWidth <= available ? tail : `…${tail}`)}${level}${dim(" ")}${ctx}`;
403
408
  };
404
409
 
405
410
  const pathStyle: PathOptions["style"] = {
@@ -410,6 +415,7 @@ export function renderMinimalBottomBorder(input: MinimalBottomInput, width: numb
410
415
  const leafName = clean(input.displayPath).split("/").filter(Boolean).pop() ?? clean(input.displayPath);
411
416
  const minPathWidth = Math.min(Math.max(4, visibleWidth(leafName)), 12);
412
417
  const minGap = 2;
418
+ const maxRightContent = width - minGap - minPathWidth - 8; // four frame columns around each block
413
419
 
414
420
  const tiers: Array<{
415
421
  pathMode: Exclude<Config["mode"], "native">;
@@ -430,19 +436,23 @@ export function renderMinimalBottomBorder(input: MinimalBottomInput, width: numb
430
436
  let rightBlock = "";
431
437
 
432
438
  for (const tier of tiers) {
433
- const rightContent = makeRight(tier.compactModel, tier.includeThinking, tier.includeWindow);
434
- const rightCandidate = `${borderColor(" ")}${rightContent}${borderColor(" ──")}`;
435
- const rightW = visibleWidth(rightCandidate);
436
- const leftBudget = width - rightW - minGap - 4; // 4 cols = "── " (3) + trailing " " (1)
437
-
438
439
  const gitRaw = input.showBranch && tier.gitDetail !== "none"
439
440
  ? formatGitMinimal(input.gitState, input.fallbackBranch, tier.gitDetail)
440
441
  : "";
441
442
  const gitStyled = gitRaw ? theme.fg(gitColor(input.gitState), gitRaw) : "";
442
443
  const gitW = visibleWidth(gitStyled);
444
+ const gitSpace = gitW ? gitW + 1 : 0;
445
+ const rightBudget = tier.compactModel ? maxRightContent - gitSpace : Infinity;
446
+ let rightContent = makeRight(tier.includeThinking, tier.includeWindow, rightBudget, 6);
447
+ if (!rightContent && tier.gitDetail === "branch" && gitW > 5) {
448
+ rightContent = makeRight(tier.includeThinking, tier.includeWindow, maxRightContent - 6, 6);
449
+ }
450
+ if (!rightContent) continue;
451
+ const rightCandidate = `${borderColor(" ")}${rightContent}${borderColor(" ──")}`;
452
+ const leftBudget = width - visibleWidth(rightCandidate) - minGap - 4;
443
453
 
444
- if (leftBudget >= minPathWidth + (gitW ? gitW + 1 : 0)) {
445
- const pathBudget = leftBudget - (gitW ? gitW + 1 : 0);
454
+ if (leftBudget >= minPathWidth + gitSpace) {
455
+ const pathBudget = leftBudget - gitSpace;
446
456
  const pathStyled = formatPath(input.displayPath, pathBudget, {
447
457
  mode: tier.pathMode,
448
458
  icon: input.showIcon,
@@ -477,13 +487,10 @@ export function renderMinimalBottomBorder(input: MinimalBottomInput, width: numb
477
487
 
478
488
  // Ultra-narrow fallback: guarantee context% survives first, then model, then leaf directory.
479
489
  if (!rightBlock) {
480
- const compactRight = makeRight(true, false, false);
481
- const ctxOnly = formatContextMinimal(input.contextPercent, input.contextWindow, false, theme);
490
+ const compactRight = makeRight(false, false, width - 6);
482
491
  const chosenRightContent = visibleWidth(compactRight) + 6 <= width
483
492
  ? compactRight
484
- : visibleWidth(ctxOnly) + 6 <= width
485
- ? ctxOnly
486
- : truncateToWidth(ctxOnly, Math.max(0, width - 4), "");
493
+ : truncateToWidth(compactRight, width - 4, "");
487
494
  rightBlock = chosenRightContent ? `${borderColor(" ")}${chosenRightContent}${borderColor(" ──")}` : "";
488
495
  const rightW = visibleWidth(rightBlock);
489
496
  const leftBudget = width - rightW - minGap - 4;
package/src/segments.ts CHANGED
@@ -18,6 +18,8 @@ export interface ExtensionAdapter {
18
18
  export interface ClassifiedStatuses {
19
19
  /** Type 1 (adapted) and Type 2 (path-bar:*) slots before hidden filtering. */
20
20
  slots: Map<string, SlotEntry>;
21
+ /** Compact billion-context usage for the left telemetry block. */
22
+ billionContextUsage?: string;
21
23
  /** Type 3 (unknown extensions), sorted alphabetically by status key. */
22
24
  unknown: Array<[string, string]>;
23
25
  }
@@ -659,7 +661,7 @@ export function segmentEntries(statuses: ReadonlyMap<string, string>): Map<strin
659
661
  }
660
662
 
661
663
  /**
662
- * Split extension statuses into three tiers for Minimal mode:
664
+ * Extract billion-context telemetry and split the remaining statuses into three tiers:
663
665
  * - Type 2: explicit `path-bar:<id>` segments (highest priority; suppresses matching Type 1 key)
664
666
  * - Type 1: known third-party statuses compressed by built-in adapters
665
667
  * - Type 3: unknown extensions rendered on the auto-hiding line below the bottom border
@@ -681,7 +683,16 @@ export function classifyStatuses(
681
683
  }
682
684
  const byKey = new Map(adapters.map((adapter) => [adapter.key, adapter]));
683
685
  const unknown: Array<[string, string]> = [];
686
+ let billionContextUsage: string | undefined;
684
687
  for (const [key, text] of remaining) {
688
+ if (key === "billion-context") {
689
+ // shortcut: matches v0.1.216's display text; use structured usage if upstream exposes it.
690
+ const usage = /^sub-agents (↑\d+(?:\.\d+)?[kM]?) (↓\d+(?:\.\d+)?[kM]?)(?: \(\$\d+(?:\.\d+)?\))?$/.exec(stripTerminalSequences(text).trim());
691
+ if (usage) {
692
+ billionContextUsage = `bc${usage[1]}${usage[2]}`;
693
+ continue;
694
+ }
695
+ }
685
696
  const adapter = byKey.get(key);
686
697
  if (adapter) {
687
698
  // Explicit Type 2 registration wins and suppresses the legacy key so it does not duplicate below.
@@ -695,7 +706,7 @@ export function classifyStatuses(
695
706
  unknown.push([key, text]);
696
707
  }
697
708
  unknown.sort(([a], [b]) => a.localeCompare(b));
698
- return { slots, unknown };
709
+ return { slots, unknown, billionContextUsage };
699
710
  }
700
711
 
701
712
  /**