@pi-archimedes/footer 2.9.3 → 2.10.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/README.md +1 -0
- package/package.json +2 -2
- package/src/config.ts +8 -0
- package/src/index.ts +3 -3
- package/src/utils/format.test.ts +24 -0
- package/src/utils/format.ts +5 -1
- package/src/utils/icons.ts +2 -2
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ Two honest caveats: the ledger reflects usage and pricing **as reported to the s
|
|
|
43
43
|
| Setting | Type | Default | Description |
|
|
44
44
|
|---------|------|---------|-------------|
|
|
45
45
|
| `splitThreshold` | number | `150` | Minimum terminal columns for the single-line layout. Below it, the footer uses the structured multi-line layout; above it, it stays single-line and wraps only if content overflows. |
|
|
46
|
+
| `branchMaxLength` | number | `0` | Max columns for the branch or jj bookmark name, truncated with `…`. `0` = unlimited. Git status indicators are never truncated. Applies on next session or `/reload`. |
|
|
46
47
|
|
|
47
48
|
In the suite the setting also appears in `/archimedes` (when the panel has a control for it); `/reload` applies it. On/off is managed by the suite: toggle via `/plugins` (`archimedes.footer.enabled`, default on).
|
|
48
49
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-archimedes/footer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/danielcherubini/pi-archimedes.git"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"./config": "./src/config.ts"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@pi-archimedes/core": "2.
|
|
22
|
+
"@pi-archimedes/core": "2.10.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@earendil-works/pi-coding-agent": ">=0.1.0",
|
package/src/config.ts
CHANGED
|
@@ -3,10 +3,12 @@ import type { SettingItem } from "@earendil-works/pi-tui";
|
|
|
3
3
|
|
|
4
4
|
export interface FooterConfig {
|
|
5
5
|
splitThreshold: number;
|
|
6
|
+
branchMaxLength: number;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export const DEFAULT_FOOTER_CONFIG: FooterConfig = {
|
|
9
10
|
splitThreshold: 150,
|
|
11
|
+
branchMaxLength: 0,
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
const NAMESPACE = "archimedes.footer";
|
|
@@ -27,5 +29,11 @@ export function getFooterSettingsItems(): SettingItem[] {
|
|
|
27
29
|
description: "Terminal width threshold for two-line footer split",
|
|
28
30
|
currentValue: String(loadFooterConfig().splitThreshold),
|
|
29
31
|
},
|
|
32
|
+
{
|
|
33
|
+
id: "branchMaxLength",
|
|
34
|
+
label: "Branch Max Length",
|
|
35
|
+
description: "Max columns for the branch/bookmark name (0 = unlimited)",
|
|
36
|
+
currentValue: String(loadFooterConfig().branchMaxLength),
|
|
37
|
+
},
|
|
30
38
|
];
|
|
31
39
|
}
|
package/src/index.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { CostAccumulator } from "./cost-accumulator.js";
|
|
|
18
18
|
import { getGitStatus, isInsideLinkedWorktree } from "./utils/git.js";
|
|
19
19
|
import { getJjBookmark } from "./utils/jj.js";
|
|
20
20
|
import { getContextWindowInfo, getTokenUsageStats, type TokenUsageStats } from "./utils/stats.js";
|
|
21
|
-
import { formatContextBar, formatGitStatusIndicators, formatThinkingIndicator, formatTokenCount, wrapStatusToChunks } from "./utils/format.js";
|
|
21
|
+
import { formatContextBar, formatGitStatusIndicators, formatThinkingIndicator, formatTokenCount, truncateBranch, wrapStatusToChunks } from "./utils/format.js";
|
|
22
22
|
import { footerIcons } from "./utils/icons.js";
|
|
23
23
|
import { packFooterLines, SEP_W, SEPARATOR } from "./utils/layout.js";
|
|
24
24
|
|
|
@@ -36,7 +36,7 @@ export function registerFooter(pi: ExtensionAPI): void {
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
pi.on("session_start", (_event, ctx: ExtensionContext) => {
|
|
39
|
-
const splitThreshold = loadFooterConfig()
|
|
39
|
+
const { splitThreshold, branchMaxLength } = loadFooterConfig();
|
|
40
40
|
|
|
41
41
|
// Create cost accumulator for subagent costs
|
|
42
42
|
footerAccumulator = new CostAccumulator();
|
|
@@ -87,7 +87,7 @@ export function registerFooter(pi: ExtensionAPI): void {
|
|
|
87
87
|
// System info sections: dir | branch [+status] | model | thinking | ext-statuses
|
|
88
88
|
const leftSections = [
|
|
89
89
|
colorize("syntaxFunction", " " + footerIcons.directory + currentDirectory),
|
|
90
|
-
currentBranch ? colorize("success", branchIcon + " " + currentBranch + (gitStatusStr ? " " + gitStatusStr : "")) : "",
|
|
90
|
+
currentBranch ? colorize("success", branchIcon + " " + truncateBranch(currentBranch, branchMaxLength) + (gitStatusStr ? " " + gitStatusStr : "")) : "",
|
|
91
91
|
colorize("syntaxType", footerIcons.model + " " + activeModel),
|
|
92
92
|
thinkingIndicatorStr,
|
|
93
93
|
...extensionStatusChunks,
|
package/src/utils/format.test.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
formatContextBar,
|
|
7
7
|
formatGitStatusIndicators,
|
|
8
8
|
formatThinkingIndicator,
|
|
9
|
+
truncateBranch,
|
|
9
10
|
wrapStatusToChunks,
|
|
10
11
|
} from "./format.js";
|
|
11
12
|
import { thinkingLevelColors, thinkingLevelIcons, type ColorFn } from "./icons.js";
|
|
@@ -14,6 +15,29 @@ import { thinkingLevelColors, thinkingLevelIcons, type ColorFn } from "./icons.j
|
|
|
14
15
|
// Passthrough — we test structure, not actual coloring.
|
|
15
16
|
const mockColor: ColorFn = (_token, text) => text;
|
|
16
17
|
|
|
18
|
+
// ── truncateBranch ──────────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
describe("truncateBranch", () => {
|
|
21
|
+
it("returns the name unchanged when max is 0 (unlimited)", () => {
|
|
22
|
+
const name = "feature/a-very-long-branch-name";
|
|
23
|
+
expect(truncateBranch(name, 0)).toBe(name);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("returns the name unchanged when it is shorter than max", () => {
|
|
27
|
+
expect(truncateBranch("main", 10)).toBe("main");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it.each([
|
|
31
|
+
["feature/a-very-long-branch-name", 10],
|
|
32
|
+
["feature/x", 1], // smallest limit: ellipsis only
|
|
33
|
+
["機能ブランチ名前", 5], // wide chars: odd limit can't split a 2-column char
|
|
34
|
+
])("truncates %s to %i columns ending with an ellipsis", (name, max) => {
|
|
35
|
+
const result = truncateBranch(name, max);
|
|
36
|
+
expect(visibleWidth(result)).toBeLessThanOrEqual(max);
|
|
37
|
+
expect(stripAnsi(result).endsWith("…")).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
17
41
|
// ── formatTokenCount ────────────────────────────────────────────────────────
|
|
18
42
|
|
|
19
43
|
describe("formatTokenCount", () => {
|
package/src/utils/format.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
1
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
2
|
import { footerIcons, gitDisplayIcons, gitStatusColors, thinkingLevelColors, thinkingLevelIcons, type ColorFn } from "./icons.js";
|
|
3
3
|
|
|
4
4
|
// Token counts use binary units (1K = 1024)
|
|
@@ -50,6 +50,10 @@ export function formatGitStatusIndicators(
|
|
|
50
50
|
return statusParts.join("");
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
export function truncateBranch(name: string, max: number): string {
|
|
54
|
+
return max > 0 ? truncateToWidth(name, max, "…") : name;
|
|
55
|
+
}
|
|
56
|
+
|
|
53
57
|
export function formatThinkingIndicator(thinkingLevel: string, colorize: ColorFn): string {
|
|
54
58
|
return colorize(thinkingLevelColors[thinkingLevel] || "dim", `${thinkingLevelIcons[thinkingLevel] || "◑"} ${thinkingLevel}`);
|
|
55
59
|
}
|
package/src/utils/icons.ts
CHANGED
|
@@ -16,11 +16,11 @@ export const gitDisplayIcons = {
|
|
|
16
16
|
behind: "↓",
|
|
17
17
|
} as const;
|
|
18
18
|
|
|
19
|
-
export const gitStatusColors: Record<keyof typeof gitDisplayIcons, "success" | "warning" | "dim" | "
|
|
19
|
+
export const gitStatusColors: Record<keyof typeof gitDisplayIcons, "success" | "warning" | "dim" | "accent"> = {
|
|
20
20
|
staged: "success",
|
|
21
21
|
unstaged: "warning",
|
|
22
22
|
untracked: "dim",
|
|
23
|
-
ahead: "
|
|
23
|
+
ahead: "accent",
|
|
24
24
|
behind: "warning",
|
|
25
25
|
};
|
|
26
26
|
|