pi-subagent-manager 1.10.0 → 1.12.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/README.md +9 -9
- package/dist/index.d.ts +2 -0
- package/dist/index.js +790 -0
- package/dist/orch/checklist-integration.js +176 -0
- package/dist/orch/context-entries.js +6 -0
- package/dist/orch/cost-ledger.js +38 -0
- package/dist/orch/diagnostics.js +86 -0
- package/dist/orch/extensions.js +66 -0
- package/dist/orch/housekeeping-usage.js +22 -0
- package/dist/orch/housekeeping.js +248 -0
- package/dist/orch/inherited-tools.js +57 -0
- package/dist/orch/mailbox.js +195 -0
- package/dist/orch/manager.js +970 -0
- package/dist/orch/paths.js +69 -0
- package/dist/orch/prompt.js +30 -0
- package/dist/orch/registry.js +115 -0
- package/dist/orch/runtime.js +835 -0
- package/dist/orch/tools.js +112 -0
- package/dist/orch/transcript.js +165 -0
- package/dist/prefs/agent-import.js +188 -0
- package/dist/prefs/config.js +878 -0
- package/dist/prefs/import-discovery.js +547 -0
- package/{src/prefs/import-instructions.ts → dist/prefs/import-instructions.js} +0 -1
- package/dist/prefs/models.js +56 -0
- package/dist/prefs/settings.js +491 -0
- package/dist/types.js +1 -0
- package/dist/ui/agent-loader.js +63 -0
- package/dist/ui/agent-navigation-editor.js +168 -0
- package/dist/ui/cost-footer.js +209 -0
- package/dist/ui/dialog.js +505 -0
- package/dist/ui/import-picker.js +191 -0
- package/dist/ui/live-agent-view.js +527 -0
- package/dist/ui/model-picker.js +529 -0
- package/dist/ui/settings-ui.js +671 -0
- package/dist/ui/status-ui.js +470 -0
- package/dist/ui/thread-tree.js +142 -0
- package/dist/ui/tool-picker.js +331 -0
- package/dist/ui/transcript-tool.js +91 -0
- package/dist/ui/ui.js +1019 -0
- package/package.json +17 -5
- package/docs/assets/subagent-manager-demo.gif +0 -0
- package/docs/async-lifecycle.md +0 -153
- package/docs/custom-agents.md +0 -154
- package/docs/default-agents.md +0 -95
- package/docs/demo.md +0 -63
- package/docs/development.md +0 -74
- package/docs/importing-agents.md +0 -41
- package/docs/pi-footer.md +0 -128
- package/docs/research-claude.md +0 -258
- package/docs/research-codex.md +0 -143
- package/docs/research-default-agent-models.md +0 -121
- package/docs/research-model-audit-2026-10.md +0 -154
- package/docs/research-model-roles-coding.md +0 -99
- package/docs/research-model-roles-writing.md +0 -78
- package/docs/research-researcher-workflow.md +0 -97
- package/docs/settings.md +0 -293
- package/docs/subagent-extension-limitations.md +0 -98
- package/docs/threads.md +0 -73
- package/docs/tools-and-ui.md +0 -129
- package/src/index.ts +0 -920
- package/src/orch/checklist-integration.ts +0 -230
- package/src/orch/context-entries.ts +0 -15
- package/src/orch/cost-ledger.ts +0 -56
- package/src/orch/diagnostics.ts +0 -95
- package/src/orch/extensions.ts +0 -83
- package/src/orch/housekeeping-usage.ts +0 -47
- package/src/orch/housekeeping.ts +0 -348
- package/src/orch/inherited-tools.ts +0 -84
- package/src/orch/mailbox.ts +0 -261
- package/src/orch/manager.ts +0 -1084
- package/src/orch/paths.ts +0 -73
- package/src/orch/prompt.ts +0 -39
- package/src/orch/registry.ts +0 -168
- package/src/orch/runtime.ts +0 -1041
- package/src/orch/tools.ts +0 -190
- package/src/orch/transcript.ts +0 -186
- package/src/prefs/agent-import.ts +0 -245
- package/src/prefs/config.ts +0 -1017
- package/src/prefs/import-discovery.ts +0 -643
- package/src/prefs/models.ts +0 -74
- package/src/prefs/settings.ts +0 -614
- package/src/types.ts +0 -271
- package/src/ui/agent-loader.ts +0 -98
- package/src/ui/agent-navigation-editor.ts +0 -233
- package/src/ui/cost-footer.ts +0 -230
- package/src/ui/dialog.ts +0 -678
- package/src/ui/import-picker.ts +0 -231
- package/src/ui/live-agent-view.ts +0 -600
- package/src/ui/model-picker.ts +0 -701
- package/src/ui/settings-ui.ts +0 -830
- package/src/ui/status-ui.ts +0 -628
- package/src/ui/thread-tree.ts +0 -173
- package/src/ui/tool-picker.ts +0 -398
- package/src/ui/transcript-tool.ts +0 -142
- package/src/ui/ui.ts +0 -1407
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { CustomEditor, } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { getKeybindings, Key, matchesKey, } from "@earendil-works/pi-tui";
|
|
3
|
+
export class AgentNavigationEditor extends CustomEditor {
|
|
4
|
+
navigationKeys;
|
|
5
|
+
navigation;
|
|
6
|
+
pending;
|
|
7
|
+
disposed = false;
|
|
8
|
+
dispatchDepth = 0;
|
|
9
|
+
inputEpoch = 0;
|
|
10
|
+
pastePending = false;
|
|
11
|
+
jumpPending = false;
|
|
12
|
+
constructor(tui, theme, navigationKeys, navigation, options) {
|
|
13
|
+
super(tui, theme, navigationKeys, options);
|
|
14
|
+
this.navigationKeys = navigationKeys;
|
|
15
|
+
this.navigation = navigation;
|
|
16
|
+
for (const text of navigation.initialHistory ?? [])
|
|
17
|
+
this.addToHistory(text);
|
|
18
|
+
}
|
|
19
|
+
dispose() {
|
|
20
|
+
this.disposed = true;
|
|
21
|
+
this.inputEpoch++;
|
|
22
|
+
}
|
|
23
|
+
ordinaryArrow(data, direction) {
|
|
24
|
+
if (!matchesKey(data, direction === "left" ? Key.left : Key.right))
|
|
25
|
+
return false;
|
|
26
|
+
const action = direction === "left" ? "tui.editor.cursorLeft" : "tui.editor.cursorRight";
|
|
27
|
+
for (const keys of [this.navigationKeys, getKeybindings()]) {
|
|
28
|
+
if (!keys.matches(data, action))
|
|
29
|
+
return false;
|
|
30
|
+
for (const other of Object.keys(keys.getResolvedBindings())) {
|
|
31
|
+
if (other !== action &&
|
|
32
|
+
(other.startsWith("tui.editor.") ||
|
|
33
|
+
other.startsWith("tui.input.") ||
|
|
34
|
+
other.startsWith("tui.altScreen.") ||
|
|
35
|
+
other.startsWith("app.")) &&
|
|
36
|
+
keys.matches(data, other))
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
handleInput(data) {
|
|
43
|
+
const outer = this.dispatchDepth === 0;
|
|
44
|
+
const direction = this.ordinaryArrow(data, "left")
|
|
45
|
+
? "left"
|
|
46
|
+
: this.ordinaryArrow(data, "right")
|
|
47
|
+
? "right"
|
|
48
|
+
: undefined;
|
|
49
|
+
if (outer && (!direction || (this.pending && this.pending !== direction)))
|
|
50
|
+
this.inputEpoch++;
|
|
51
|
+
const previousPaste = this.pastePending;
|
|
52
|
+
const wasPaste = previousPaste || data.includes("\x1b[200~");
|
|
53
|
+
if (data.includes("\x1b[200~"))
|
|
54
|
+
this.pastePending = true;
|
|
55
|
+
if (wasPaste && data.includes("\x1b[201~"))
|
|
56
|
+
this.pastePending = false;
|
|
57
|
+
const wasJump = this.jumpPending;
|
|
58
|
+
const cursor = this.getCursor();
|
|
59
|
+
const text = this.getText();
|
|
60
|
+
const lines = text.split("\n");
|
|
61
|
+
const atBoundary = direction === "left"
|
|
62
|
+
? cursor.line === 0 && cursor.col === 0
|
|
63
|
+
: direction === "right" &&
|
|
64
|
+
cursor.line === lines.length - 1 &&
|
|
65
|
+
cursor.col === lines.at(-1).length;
|
|
66
|
+
const eligible = outer &&
|
|
67
|
+
direction !== undefined &&
|
|
68
|
+
this.focused &&
|
|
69
|
+
!this.disposed &&
|
|
70
|
+
!wasPaste &&
|
|
71
|
+
!wasJump &&
|
|
72
|
+
!this.isShowingAutocomplete() &&
|
|
73
|
+
atBoundary;
|
|
74
|
+
const generation = eligible ? this.navigation.generation() : undefined;
|
|
75
|
+
let changed = false;
|
|
76
|
+
let consumed = false;
|
|
77
|
+
const originalChange = this.onChange;
|
|
78
|
+
const originalShortcut = this.onExtensionShortcut;
|
|
79
|
+
const observeChange = (value) => {
|
|
80
|
+
changed = true;
|
|
81
|
+
originalChange?.call(this, value);
|
|
82
|
+
};
|
|
83
|
+
const observeShortcut = (value) => {
|
|
84
|
+
const handled = originalShortcut?.call(this, value) ?? false;
|
|
85
|
+
consumed ||= handled && value === data;
|
|
86
|
+
return handled;
|
|
87
|
+
};
|
|
88
|
+
this.onChange = observeChange;
|
|
89
|
+
this.onExtensionShortcut = observeShortcut;
|
|
90
|
+
this.dispatchDepth++;
|
|
91
|
+
try {
|
|
92
|
+
super.handleInput(data);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
this.dispatchDepth--;
|
|
96
|
+
if (this.onChange === observeChange)
|
|
97
|
+
this.onChange = originalChange;
|
|
98
|
+
if (this.onExtensionShortcut === observeShortcut)
|
|
99
|
+
this.onExtensionShortcut = originalShortcut;
|
|
100
|
+
if (consumed)
|
|
101
|
+
this.pastePending = previousPaste;
|
|
102
|
+
if (!consumed) {
|
|
103
|
+
if (!wasPaste) {
|
|
104
|
+
const keys = getKeybindings();
|
|
105
|
+
const jump = keys.matches(data, "tui.editor.jumpForward") ||
|
|
106
|
+
keys.matches(data, "tui.editor.jumpBackward");
|
|
107
|
+
this.jumpPending = !wasJump && jump;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const after = this.getCursor();
|
|
112
|
+
if (eligible &&
|
|
113
|
+
!consumed &&
|
|
114
|
+
!changed &&
|
|
115
|
+
!this.isShowingAutocomplete() &&
|
|
116
|
+
this.getText() === text &&
|
|
117
|
+
after.line === cursor.line &&
|
|
118
|
+
after.col === cursor.col) {
|
|
119
|
+
this.queueNavigation(text, cursor, generation, direction);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
queueNavigation(text, cursor, generation, direction) {
|
|
123
|
+
const action = () => {
|
|
124
|
+
if (direction === "right")
|
|
125
|
+
return this.navigation.collapseWidget && (this.navigation.canCollapse?.() ?? false)
|
|
126
|
+
? "collapse"
|
|
127
|
+
: undefined;
|
|
128
|
+
if (this.navigation.expandWidget && (this.navigation.canExpand?.() ?? false))
|
|
129
|
+
return "expand";
|
|
130
|
+
return this.navigation.canOpen() ? "tree" : undefined;
|
|
131
|
+
};
|
|
132
|
+
const chosen = action();
|
|
133
|
+
if (this.pending || !chosen)
|
|
134
|
+
return;
|
|
135
|
+
this.pending = direction;
|
|
136
|
+
const epoch = this.inputEpoch;
|
|
137
|
+
queueMicrotask(() => {
|
|
138
|
+
const after = this.getCursor();
|
|
139
|
+
if (this.disposed ||
|
|
140
|
+
!this.focused ||
|
|
141
|
+
this.inputEpoch !== epoch ||
|
|
142
|
+
this.navigation.generation() !== generation ||
|
|
143
|
+
action() !== chosen ||
|
|
144
|
+
this.isShowingAutocomplete() ||
|
|
145
|
+
this.getText() !== text ||
|
|
146
|
+
after.line !== cursor.line ||
|
|
147
|
+
after.col !== cursor.col) {
|
|
148
|
+
this.pending = undefined;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
void Promise.resolve(chosen === "tree"
|
|
153
|
+
? this.navigation.openTree()
|
|
154
|
+
: chosen === "expand"
|
|
155
|
+
? this.navigation.expandWidget()
|
|
156
|
+
: this.navigation.collapseWidget())
|
|
157
|
+
.catch((error) => this.navigation.onError?.(error))
|
|
158
|
+
.finally(() => {
|
|
159
|
+
this.pending = undefined;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
this.pending = undefined;
|
|
164
|
+
this.navigation.onError?.(error);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
export function footerUsage(entries) {
|
|
4
|
+
const totals = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0 };
|
|
5
|
+
let cacheHit;
|
|
6
|
+
const add = (usage) => {
|
|
7
|
+
if (!usage)
|
|
8
|
+
return;
|
|
9
|
+
totals.input += usage.input;
|
|
10
|
+
totals.output += usage.output;
|
|
11
|
+
totals.cacheRead += usage.cacheRead;
|
|
12
|
+
totals.cacheWrite += usage.cacheWrite;
|
|
13
|
+
totals.cost += usage.cost.total;
|
|
14
|
+
};
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
if (entry.type === "usage")
|
|
17
|
+
add(entry.usage);
|
|
18
|
+
else if (entry.type === "message") {
|
|
19
|
+
if (entry.message.role === "assistant") {
|
|
20
|
+
add(entry.message.usage);
|
|
21
|
+
const usage = entry.message.usage;
|
|
22
|
+
const prompt = usage.input + usage.cacheRead + usage.cacheWrite;
|
|
23
|
+
cacheHit = prompt ? (usage.cacheRead / prompt) * 100 : undefined;
|
|
24
|
+
}
|
|
25
|
+
else if (entry.message.role === "toolResult")
|
|
26
|
+
add(entry.message.usage);
|
|
27
|
+
}
|
|
28
|
+
else if (entry.type === "branch_summary" || entry.type === "compaction")
|
|
29
|
+
add(entry.usage);
|
|
30
|
+
}
|
|
31
|
+
return { ...totals, cacheHit };
|
|
32
|
+
}
|
|
33
|
+
export const COST_WIDGET_ID = "subagent_cost";
|
|
34
|
+
export const COST_WIDGET_EVENT = "pi-footer:update-widget";
|
|
35
|
+
export const COST_ICON = "\uf0d6";
|
|
36
|
+
export function costIconGlyph(icon, nerdFontIcons) {
|
|
37
|
+
const glyphs = {
|
|
38
|
+
money: { emoji: "💵", nerd: COST_ICON },
|
|
39
|
+
coins: { emoji: "🪙", nerd: "\uede8" },
|
|
40
|
+
wallet: { emoji: "👛", nerd: "\uee1e" },
|
|
41
|
+
};
|
|
42
|
+
return glyphs[icon][nerdFontIcons ? "nerd" : "emoji"];
|
|
43
|
+
}
|
|
44
|
+
export function formatSubagentCost(cost, nerdFontIcons) {
|
|
45
|
+
return `${nerdFontIcons ? COST_ICON + " " : ""}$${cost.toFixed(4)}`;
|
|
46
|
+
}
|
|
47
|
+
export function hasExternalFooter(pi) {
|
|
48
|
+
return pi
|
|
49
|
+
.getCommands()
|
|
50
|
+
.some((command) => command.name === "footer" && command.source === "extension");
|
|
51
|
+
}
|
|
52
|
+
export class CostFooterController {
|
|
53
|
+
pi;
|
|
54
|
+
subagentCost;
|
|
55
|
+
nerdFontIcons;
|
|
56
|
+
displayMode;
|
|
57
|
+
costValue;
|
|
58
|
+
costIcon;
|
|
59
|
+
installed = false;
|
|
60
|
+
requestRender;
|
|
61
|
+
publishedMode;
|
|
62
|
+
statusContext;
|
|
63
|
+
constructor(pi, subagentCost, nerdFontIcons, displayMode = () => "pi-footer-status", costValue = () => "subagents", costIcon = () => "money") {
|
|
64
|
+
this.pi = pi;
|
|
65
|
+
this.subagentCost = subagentCost;
|
|
66
|
+
this.nerdFontIcons = nerdFontIcons;
|
|
67
|
+
this.displayMode = displayMode;
|
|
68
|
+
this.costValue = costValue;
|
|
69
|
+
this.costIcon = costIcon;
|
|
70
|
+
}
|
|
71
|
+
formatCost(mainCost) {
|
|
72
|
+
const cost = this.subagentCost() + (this.costValue() === "total" ? mainCost : 0);
|
|
73
|
+
return `${costIconGlyph(this.costIcon(), this.nerdFontIcons())} $${cost.toFixed(4)}`;
|
|
74
|
+
}
|
|
75
|
+
refresh(ctx) {
|
|
76
|
+
const mode = this.displayMode();
|
|
77
|
+
const value = this.formatCost(this.costValue() === "total" ? footerUsage(ctx.sessionManager.getEntries()).cost : 0);
|
|
78
|
+
if (this.publishedMode !== undefined && this.publishedMode !== mode) {
|
|
79
|
+
this.clear();
|
|
80
|
+
this.reset(ctx);
|
|
81
|
+
}
|
|
82
|
+
this.publishedMode = mode;
|
|
83
|
+
if (mode !== "pi-footer-event") {
|
|
84
|
+
if (ctx.hasUI) {
|
|
85
|
+
this.statusContext = ctx;
|
|
86
|
+
const label = this.costValue() === "total" ? "Total" : "Subagents";
|
|
87
|
+
ctx.ui.setStatus(COST_WIDGET_ID, mode === "pi-status" ? `${label}: ${value}` : value);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.pi.events.emit(COST_WIDGET_EVENT, { widgetId: COST_WIDGET_ID, value });
|
|
92
|
+
if (hasExternalFooter(this.pi)) {
|
|
93
|
+
this.installed = false;
|
|
94
|
+
this.requestRender = undefined;
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (this.installed) {
|
|
98
|
+
this.requestRender?.();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (this.subagentCost() <= 0 || !ctx.hasUI || ctx.mode !== "tui")
|
|
102
|
+
return;
|
|
103
|
+
this.requestRender = installCostFooter(ctx, this.subagentCost, (mainCost) => this.formatCost(mainCost));
|
|
104
|
+
this.installed = true;
|
|
105
|
+
}
|
|
106
|
+
reset(ctx) {
|
|
107
|
+
if (this.installed && !hasExternalFooter(this.pi))
|
|
108
|
+
ctx.ui.setFooter(undefined);
|
|
109
|
+
this.installed = false;
|
|
110
|
+
this.requestRender = undefined;
|
|
111
|
+
}
|
|
112
|
+
clear() {
|
|
113
|
+
if (this.publishedMode === "pi-footer-event")
|
|
114
|
+
this.pi.events.emit(COST_WIDGET_EVENT, { widgetId: COST_WIDGET_ID, value: null });
|
|
115
|
+
this.statusContext?.ui.setStatus(COST_WIDGET_ID, undefined);
|
|
116
|
+
this.statusContext = undefined;
|
|
117
|
+
this.publishedMode = undefined;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const tokens = (n) => n < 1000
|
|
121
|
+
? String(n)
|
|
122
|
+
: n < 10000
|
|
123
|
+
? `${(n / 1000).toFixed(1)}k`
|
|
124
|
+
: n < 1000000
|
|
125
|
+
? `${Math.round(n / 1000)}k`
|
|
126
|
+
: `${(n / 1000000).toFixed(1)}M`;
|
|
127
|
+
export function installCostFooter(ctx, subagentCost, displayCost) {
|
|
128
|
+
if (!ctx.hasUI || ctx.mode !== "tui" || !ctx.ui.setFooter)
|
|
129
|
+
return;
|
|
130
|
+
let requestRender;
|
|
131
|
+
ctx.ui.setFooter((tui, theme, footerData) => {
|
|
132
|
+
requestRender = () => tui.requestRender();
|
|
133
|
+
const unsubscribe = footerData.onBranchChange(() => tui.requestRender());
|
|
134
|
+
let entryCount = -1;
|
|
135
|
+
let totals = footerUsage([]);
|
|
136
|
+
return {
|
|
137
|
+
dispose: unsubscribe,
|
|
138
|
+
invalidate() {
|
|
139
|
+
entryCount = -1;
|
|
140
|
+
},
|
|
141
|
+
render(width) {
|
|
142
|
+
const entries = ctx.sessionManager.getEntries();
|
|
143
|
+
const count = entries.length;
|
|
144
|
+
if (count !== entryCount) {
|
|
145
|
+
totals = footerUsage(entries);
|
|
146
|
+
entryCount = count;
|
|
147
|
+
}
|
|
148
|
+
const branch = footerData.getGitBranch();
|
|
149
|
+
const name = ctx.sessionManager.getSessionName();
|
|
150
|
+
const cwd = ctx.cwd === homedir()
|
|
151
|
+
? "~"
|
|
152
|
+
: ctx.cwd.startsWith(homedir() + "/")
|
|
153
|
+
? "~" + ctx.cwd.slice(homedir().length)
|
|
154
|
+
: ctx.cwd;
|
|
155
|
+
const location = cwd + (branch ? ` (${branch})` : "") + (name ? ` • ${name}` : "");
|
|
156
|
+
const parts = [];
|
|
157
|
+
if (totals.input)
|
|
158
|
+
parts.push(`↑${tokens(totals.input)}`);
|
|
159
|
+
if (totals.output)
|
|
160
|
+
parts.push(`↓${tokens(totals.output)}`);
|
|
161
|
+
if (totals.cacheRead)
|
|
162
|
+
parts.push(`R${tokens(totals.cacheRead)}`);
|
|
163
|
+
if (totals.cacheWrite)
|
|
164
|
+
parts.push(`W${tokens(totals.cacheWrite)}`);
|
|
165
|
+
if ((totals.cacheRead || totals.cacheWrite) && totals.cacheHit !== undefined)
|
|
166
|
+
parts.push(`CH${totals.cacheHit.toFixed(1)}%`);
|
|
167
|
+
const subscription = ctx.model &&
|
|
168
|
+
(ctx.model.provider === "kimi-coding" || ctx.modelRegistry?.isUsingOAuth(ctx.model));
|
|
169
|
+
const costText = displayCost?.(totals.cost) ?? `$${(totals.cost + subagentCost()).toFixed(3)}`;
|
|
170
|
+
parts.push(`${costText}${subscription ? " (sub)" : ""}`);
|
|
171
|
+
const context = ctx.getContextUsage();
|
|
172
|
+
if (context) {
|
|
173
|
+
const text = `${context.percent === null ? "?" : context.percent.toFixed(1) + "%"}/${tokens(context.contextWindow)}`;
|
|
174
|
+
parts.push(theme.fg((context.percent ?? 0) > 90
|
|
175
|
+
? "error"
|
|
176
|
+
: (context.percent ?? 0) > 70
|
|
177
|
+
? "warning"
|
|
178
|
+
: "dim", text));
|
|
179
|
+
}
|
|
180
|
+
const left = truncateToWidth(parts.join(" "), width, "");
|
|
181
|
+
let right = ctx.model?.id ?? "no-model";
|
|
182
|
+
if (ctx.model?.reasoning)
|
|
183
|
+
right += ` • ${ctx.thinkingLevel ?? "off"}`;
|
|
184
|
+
if (footerData.getAvailableProviderCount() > 1 && ctx.model) {
|
|
185
|
+
const withProvider = `(${ctx.model.provider}) ${right}`;
|
|
186
|
+
if (visibleWidth(left) + 2 + visibleWidth(withProvider) <= width)
|
|
187
|
+
right = withProvider;
|
|
188
|
+
}
|
|
189
|
+
const available = width - visibleWidth(left) - 2;
|
|
190
|
+
const stats = available > 0
|
|
191
|
+
? left +
|
|
192
|
+
" ".repeat(Math.max(2, width - visibleWidth(left) - Math.min(available, visibleWidth(right)))) +
|
|
193
|
+
truncateToWidth(right, available, "")
|
|
194
|
+
: left;
|
|
195
|
+
const lines = [truncateToWidth(theme.fg("dim", location), width), theme.fg("dim", stats)];
|
|
196
|
+
const statuses = [...footerData.getExtensionStatuses()]
|
|
197
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
198
|
+
.map(([, text]) => text
|
|
199
|
+
.replace(/[\r\n\t]/g, " ")
|
|
200
|
+
.replace(/ +/g, " ")
|
|
201
|
+
.trim());
|
|
202
|
+
if (statuses.length)
|
|
203
|
+
lines.push(truncateToWidth(theme.fg("dim", statuses.join(" ")), width));
|
|
204
|
+
return lines;
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
return () => requestRender?.();
|
|
209
|
+
}
|