pi-path-bar 0.5.0 → 0.5.1
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 +4 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/package.json +3 -3
- package/src/minimal.ts +33 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.1]
|
|
4
|
+
|
|
5
|
+
- Adapted for Pi 1.6.0.
|
|
6
|
+
|
|
3
7
|
## [0.5.0]
|
|
4
8
|
|
|
5
9
|
- **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:**
|
|
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
|
-
-
|
|
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.
|
|
3
|
+
"version": "0.5.1",
|
|
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.
|
|
43
|
-
"@earendil-works/pi-tui": "^1.
|
|
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/minimal.ts
CHANGED
|
@@ -85,47 +85,41 @@ export function formatTimeMinimal(date: Date, timeFormat: "24h" | "12h"): string
|
|
|
85
85
|
return `${h12}:${minutes}${suffix}`;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
export function shortModelName(id: string | undefined
|
|
89
|
-
if (!id) return
|
|
88
|
+
export function shortModelName(id: string | undefined): string {
|
|
89
|
+
if (!id) return "no-model";
|
|
90
90
|
const stripped = clean(id)
|
|
91
91
|
.replace(/-\d{4}-\d{2}-\d{2}$/, "")
|
|
92
92
|
.replace(/-\d{8}$/, "")
|
|
93
|
-
.replace(/-\d{4}$/, "")
|
|
94
93
|
.replace(/-(?:latest|preview|instruct|chat)$/i, "");
|
|
95
94
|
|
|
96
95
|
let match = /^claude-(sonnet|opus|haiku)-(\d+)[.-](\d+)$/i.exec(stripped);
|
|
97
96
|
if (match) {
|
|
98
97
|
const family = match[1].toLowerCase();
|
|
99
|
-
return
|
|
98
|
+
return `${family}-${match[2]}.${match[3]}`;
|
|
100
99
|
}
|
|
101
100
|
match = /^claude-(\d+)[.-](\d+)-(sonnet|opus|haiku)$/i.exec(stripped);
|
|
102
101
|
if (match) {
|
|
103
102
|
const family = match[3].toLowerCase();
|
|
104
|
-
return
|
|
103
|
+
return `${family}-${match[1]}.${match[2]}`;
|
|
105
104
|
}
|
|
106
105
|
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
|
-
}
|
|
106
|
+
if (match) return `${match[1].toLowerCase()}-${match[2]}`;
|
|
111
107
|
match = /^gemini-([\d.]+)-(flash-lite|pro|flash|ultra)(?:-[a-z0-9.]+)?$/i.exec(stripped);
|
|
112
108
|
if (match) {
|
|
113
109
|
const tierMap: Record<string, string> = { "flash-lite": "fl", pro: "p", flash: "f", ultra: "u" };
|
|
114
110
|
const tier = tierMap[match[2].toLowerCase()] ?? match[2][0].toLowerCase();
|
|
115
|
-
return
|
|
111
|
+
return `gem-${match[1]}${tier}`;
|
|
116
112
|
}
|
|
117
113
|
match = /^gpt-([\d.]+)(?:-(codex|mini|nano|turbo))?$/i.exec(stripped);
|
|
118
114
|
if (match) {
|
|
119
115
|
const tierMap: Record<string, string> = { codex: "c", mini: "m", nano: "n", turbo: "t" };
|
|
120
116
|
const tier = match[2] ? tierMap[match[2].toLowerCase()] ?? "" : "";
|
|
121
|
-
return
|
|
117
|
+
return `gpt-${match[1]}${tier}`;
|
|
122
118
|
}
|
|
123
119
|
if (/^deepseek-reasoner$/i.test(stripped)) return "ds-r1";
|
|
124
|
-
if (/^deepseek-chat$/i.test(stripped)) return
|
|
120
|
+
if (/^deepseek-chat$/i.test(stripped)) return "ds-chat";
|
|
125
121
|
match = /^deepseek-(.+)$/i.exec(stripped);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return compact ? truncateToWidth(stripped, 8, "…") : stripped;
|
|
122
|
+
return match ? `ds-${match[1]}` : stripped;
|
|
129
123
|
}
|
|
130
124
|
|
|
131
125
|
export function shortThinking(level: string | undefined): string {
|
|
@@ -395,11 +389,17 @@ export function renderMinimalBottomBorder(input: MinimalBottomInput, width: numb
|
|
|
395
389
|
const thinking = input.reasoning ? shortThinking(input.thinkingLevel) : "";
|
|
396
390
|
const thinkingStyled = thinking ? borderColor(thinking) : "";
|
|
397
391
|
|
|
398
|
-
const
|
|
399
|
-
|
|
392
|
+
const modelName = shortModelName(input.modelId);
|
|
393
|
+
const makeRight = (includeThinking: boolean, includeWindow: boolean, budget = Infinity, minModelWidth = 0): string => {
|
|
400
394
|
const ctx = formatContextMinimal(input.contextPercent, input.contextWindow, includeWindow, theme);
|
|
401
|
-
const
|
|
402
|
-
|
|
395
|
+
const level = includeThinking ? thinkingStyled : "";
|
|
396
|
+
const name = !input.modelId && budget !== Infinity ? "?" : modelName;
|
|
397
|
+
const nameWidth = visibleWidth(name);
|
|
398
|
+
const available = budget - visibleWidth(ctx) - visibleWidth(level) - 1;
|
|
399
|
+
if (minModelWidth && available < Math.min(minModelWidth, nameWidth)) return "";
|
|
400
|
+
const tail = nameWidth <= available ? name : sliceByColumn(name, nameWidth - available + 1, available - 1, true);
|
|
401
|
+
if (!tail) return minModelWidth ? "" : ctx;
|
|
402
|
+
return `${dim(nameWidth <= available ? tail : `…${tail}`)}${level}${dim(" ")}${ctx}`;
|
|
403
403
|
};
|
|
404
404
|
|
|
405
405
|
const pathStyle: PathOptions["style"] = {
|
|
@@ -410,6 +410,7 @@ export function renderMinimalBottomBorder(input: MinimalBottomInput, width: numb
|
|
|
410
410
|
const leafName = clean(input.displayPath).split("/").filter(Boolean).pop() ?? clean(input.displayPath);
|
|
411
411
|
const minPathWidth = Math.min(Math.max(4, visibleWidth(leafName)), 12);
|
|
412
412
|
const minGap = 2;
|
|
413
|
+
const maxRightContent = width - minGap - minPathWidth - 8; // four frame columns around each block
|
|
413
414
|
|
|
414
415
|
const tiers: Array<{
|
|
415
416
|
pathMode: Exclude<Config["mode"], "native">;
|
|
@@ -430,19 +431,23 @@ export function renderMinimalBottomBorder(input: MinimalBottomInput, width: numb
|
|
|
430
431
|
let rightBlock = "";
|
|
431
432
|
|
|
432
433
|
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
434
|
const gitRaw = input.showBranch && tier.gitDetail !== "none"
|
|
439
435
|
? formatGitMinimal(input.gitState, input.fallbackBranch, tier.gitDetail)
|
|
440
436
|
: "";
|
|
441
437
|
const gitStyled = gitRaw ? theme.fg(gitColor(input.gitState), gitRaw) : "";
|
|
442
438
|
const gitW = visibleWidth(gitStyled);
|
|
439
|
+
const gitSpace = gitW ? gitW + 1 : 0;
|
|
440
|
+
const rightBudget = tier.compactModel ? maxRightContent - gitSpace : Infinity;
|
|
441
|
+
let rightContent = makeRight(tier.includeThinking, tier.includeWindow, rightBudget, 6);
|
|
442
|
+
if (!rightContent && tier.gitDetail === "branch" && gitW > 5) {
|
|
443
|
+
rightContent = makeRight(tier.includeThinking, tier.includeWindow, maxRightContent - 6, 6);
|
|
444
|
+
}
|
|
445
|
+
if (!rightContent) continue;
|
|
446
|
+
const rightCandidate = `${borderColor(" ")}${rightContent}${borderColor(" ──")}`;
|
|
447
|
+
const leftBudget = width - visibleWidth(rightCandidate) - minGap - 4;
|
|
443
448
|
|
|
444
|
-
if (leftBudget >= minPathWidth +
|
|
445
|
-
const pathBudget = leftBudget -
|
|
449
|
+
if (leftBudget >= minPathWidth + gitSpace) {
|
|
450
|
+
const pathBudget = leftBudget - gitSpace;
|
|
446
451
|
const pathStyled = formatPath(input.displayPath, pathBudget, {
|
|
447
452
|
mode: tier.pathMode,
|
|
448
453
|
icon: input.showIcon,
|
|
@@ -477,13 +482,10 @@ export function renderMinimalBottomBorder(input: MinimalBottomInput, width: numb
|
|
|
477
482
|
|
|
478
483
|
// Ultra-narrow fallback: guarantee context% survives first, then model, then leaf directory.
|
|
479
484
|
if (!rightBlock) {
|
|
480
|
-
const compactRight = makeRight(
|
|
481
|
-
const ctxOnly = formatContextMinimal(input.contextPercent, input.contextWindow, false, theme);
|
|
485
|
+
const compactRight = makeRight(false, false, width - 6);
|
|
482
486
|
const chosenRightContent = visibleWidth(compactRight) + 6 <= width
|
|
483
487
|
? compactRight
|
|
484
|
-
:
|
|
485
|
-
? ctxOnly
|
|
486
|
-
: truncateToWidth(ctxOnly, Math.max(0, width - 4), "");
|
|
488
|
+
: truncateToWidth(compactRight, width - 4, "");
|
|
487
489
|
rightBlock = chosenRightContent ? `${borderColor(" ")}${chosenRightContent}${borderColor(" ──")}` : "";
|
|
488
490
|
const rightW = visibleWidth(rightBlock);
|
|
489
491
|
const leftBudget = width - rightW - minGap - 4;
|