@sheepbun/yips 0.1.1 → 0.1.47
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/LICENSE +21 -0
- package/README.md +52 -0
- package/bin/yips.js +15 -0
- package/package.json +21 -128
- package/postinstall.js +52 -0
- package/dist/agent/commands/command-catalog.js +0 -243
- package/dist/agent/commands/commands.js +0 -418
- package/dist/agent/conductor.js +0 -118
- package/dist/agent/context/code-context.js +0 -68
- package/dist/agent/context/memory-store.js +0 -159
- package/dist/agent/context/session-store.js +0 -211
- package/dist/agent/protocol/tool-protocol.js +0 -160
- package/dist/agent/skills/skills.js +0 -327
- package/dist/agent/tools/tool-executor.js +0 -415
- package/dist/agent/tools/tool-safety.js +0 -52
- package/dist/app/index.js +0 -35
- package/dist/app/repl.js +0 -105
- package/dist/app/update-check.js +0 -132
- package/dist/app/version.js +0 -51
- package/dist/code-context.js +0 -68
- package/dist/colors.js +0 -204
- package/dist/command-catalog.js +0 -242
- package/dist/commands.js +0 -350
- package/dist/conductor.js +0 -94
- package/dist/config/config.js +0 -335
- package/dist/config/hooks.js +0 -187
- package/dist/config.js +0 -335
- package/dist/downloader-state.js +0 -302
- package/dist/downloader-ui.js +0 -289
- package/dist/gateway/adapters/discord.js +0 -108
- package/dist/gateway/adapters/formatting.js +0 -96
- package/dist/gateway/adapters/telegram.js +0 -106
- package/dist/gateway/adapters/types.js +0 -2
- package/dist/gateway/adapters/whatsapp.js +0 -124
- package/dist/gateway/auth-policy.js +0 -66
- package/dist/gateway/core.js +0 -87
- package/dist/gateway/headless-conductor.js +0 -328
- package/dist/gateway/message-router.js +0 -23
- package/dist/gateway/rate-limiter.js +0 -48
- package/dist/gateway/runtime/backend-policy.js +0 -18
- package/dist/gateway/runtime/discord-bot.js +0 -104
- package/dist/gateway/runtime/discord-main.js +0 -69
- package/dist/gateway/session-manager.js +0 -77
- package/dist/gateway/types.js +0 -2
- package/dist/hardware.js +0 -92
- package/dist/hooks.js +0 -187
- package/dist/index.js +0 -34
- package/dist/input-engine.js +0 -250
- package/dist/llama-client.js +0 -227
- package/dist/llama-server.js +0 -620
- package/dist/llm/llama-client.js +0 -227
- package/dist/llm/llama-server.js +0 -620
- package/dist/llm/token-counter.js +0 -47
- package/dist/memory-store.js +0 -159
- package/dist/messages.js +0 -59
- package/dist/model-downloader.js +0 -382
- package/dist/model-manager-state.js +0 -118
- package/dist/model-manager-ui.js +0 -194
- package/dist/model-manager.js +0 -190
- package/dist/models/hardware.js +0 -92
- package/dist/models/model-downloader.js +0 -382
- package/dist/models/model-manager.js +0 -190
- package/dist/prompt-box.js +0 -78
- package/dist/prompt-composer.js +0 -498
- package/dist/repl.js +0 -105
- package/dist/session-store.js +0 -211
- package/dist/spinner.js +0 -76
- package/dist/title-box.js +0 -388
- package/dist/token-counter.js +0 -47
- package/dist/tool-executor.js +0 -415
- package/dist/tool-protocol.js +0 -121
- package/dist/tool-safety.js +0 -52
- package/dist/tui/app.js +0 -2553
- package/dist/tui/startup.js +0 -56
- package/dist/tui-input-routing.js +0 -53
- package/dist/tui.js +0 -51
- package/dist/types/app-types.js +0 -2
- package/dist/types.js +0 -2
- package/dist/ui/colors.js +0 -204
- package/dist/ui/downloader/downloader-state.js +0 -302
- package/dist/ui/downloader/downloader-ui.js +0 -289
- package/dist/ui/input/input-engine.js +0 -250
- package/dist/ui/input/tui-input-routing.js +0 -53
- package/dist/ui/input/vt-session.js +0 -168
- package/dist/ui/messages.js +0 -59
- package/dist/ui/model-manager/model-manager-state.js +0 -118
- package/dist/ui/model-manager/model-manager-ui.js +0 -194
- package/dist/ui/prompt/prompt-box.js +0 -78
- package/dist/ui/prompt/prompt-composer.js +0 -498
- package/dist/ui/spinner.js +0 -76
- package/dist/ui/title-box.js +0 -388
- package/dist/ui/tui/app.js +0 -6
- package/dist/ui/tui/autocomplete.js +0 -85
- package/dist/ui/tui/constants.js +0 -18
- package/dist/ui/tui/history.js +0 -29
- package/dist/ui/tui/layout.js +0 -341
- package/dist/ui/tui/runtime-core.js +0 -2584
- package/dist/ui/tui/runtime-utils.js +0 -53
- package/dist/ui/tui/start-tui.js +0 -54
- package/dist/ui/tui/startup.js +0 -56
- package/dist/version.js +0 -51
- package/dist/vt-session.js +0 -168
- package/install.sh +0 -457
package/dist/ui/tui/layout.js
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildPromptStatusText = buildPromptStatusText;
|
|
4
|
-
exports.composeOutputLines = composeOutputLines;
|
|
5
|
-
exports.computeVisibleLayoutSlices = computeVisibleLayoutSlices;
|
|
6
|
-
exports.computeTitleVisibleScrollCap = computeTitleVisibleScrollCap;
|
|
7
|
-
exports.buildPromptRenderLines = buildPromptRenderLines;
|
|
8
|
-
const prompt_box_1 = require("#ui/prompt/prompt-box");
|
|
9
|
-
const colors_1 = require("#ui/colors");
|
|
10
|
-
const constants_1 = require("#ui/tui/constants");
|
|
11
|
-
const runtime_utils_1 = require("#ui/tui/runtime-utils");
|
|
12
|
-
const model_manager_1 = require("#models/model-manager");
|
|
13
|
-
function formatBackendName(backend) {
|
|
14
|
-
return backend === "llamacpp" ? "llama.cpp" : backend;
|
|
15
|
-
}
|
|
16
|
-
function resolveLoadedModel(model) {
|
|
17
|
-
const trimmed = model.trim();
|
|
18
|
-
if (trimmed.length === 0) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
if (trimmed.toLowerCase() === "default") {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
return trimmed;
|
|
25
|
-
}
|
|
26
|
-
function charLength(text) {
|
|
27
|
-
return Array.from(text).length;
|
|
28
|
-
}
|
|
29
|
-
function clipPromptStatusText(statusText, maxWidth) {
|
|
30
|
-
if (maxWidth <= 0)
|
|
31
|
-
return "";
|
|
32
|
-
const trimmed = statusText.trim();
|
|
33
|
-
const normalized = trimmed.length > 0 ? ` ${trimmed} ` : " ";
|
|
34
|
-
const chars = Array.from(normalized);
|
|
35
|
-
if (chars.length <= maxWidth)
|
|
36
|
-
return normalized;
|
|
37
|
-
return chars.slice(chars.length - maxWidth).join("");
|
|
38
|
-
}
|
|
39
|
-
function withCursorAt(content, index) {
|
|
40
|
-
const chars = Array.from(content);
|
|
41
|
-
if (chars.length === 0) {
|
|
42
|
-
return content;
|
|
43
|
-
}
|
|
44
|
-
const safeIndex = Math.max(0, Math.min(index, chars.length - 1));
|
|
45
|
-
chars[safeIndex] = constants_1.CURSOR_MARKER;
|
|
46
|
-
return chars.join("");
|
|
47
|
-
}
|
|
48
|
-
function stripAnsi(text) {
|
|
49
|
-
return text.replace(constants_1.ANSI_SGR_PATTERN, "");
|
|
50
|
-
}
|
|
51
|
-
function isVisuallyEmptyLine(line) {
|
|
52
|
-
return stripAnsi(line).trim().length === 0;
|
|
53
|
-
}
|
|
54
|
-
function visibleCharLength(line) {
|
|
55
|
-
return Array.from(stripAnsi(line)).length;
|
|
56
|
-
}
|
|
57
|
-
function inferRenderWidth(titleLines, promptLines) {
|
|
58
|
-
const candidates = [...titleLines, ...promptLines]
|
|
59
|
-
.map((line) => visibleCharLength(line))
|
|
60
|
-
.filter((length) => length > 0);
|
|
61
|
-
if (candidates.length === 0) {
|
|
62
|
-
return 80;
|
|
63
|
-
}
|
|
64
|
-
return Math.max(1, ...candidates);
|
|
65
|
-
}
|
|
66
|
-
function lineDisplayRows(line, width) {
|
|
67
|
-
const safeWidth = Math.max(1, width);
|
|
68
|
-
const length = visibleCharLength(line);
|
|
69
|
-
if (length <= 0) {
|
|
70
|
-
return 1;
|
|
71
|
-
}
|
|
72
|
-
return Math.max(1, Math.ceil(length / safeWidth));
|
|
73
|
-
}
|
|
74
|
-
function countDisplayRows(lines, width) {
|
|
75
|
-
return lines.reduce((total, line) => total + lineDisplayRows(line, width), 0);
|
|
76
|
-
}
|
|
77
|
-
function trimEndByDisplayRows(line, rowsToTrim, width) {
|
|
78
|
-
if (rowsToTrim <= 0) {
|
|
79
|
-
return line;
|
|
80
|
-
}
|
|
81
|
-
const safeWidth = Math.max(1, width);
|
|
82
|
-
const plainChars = Array.from(stripAnsi(line));
|
|
83
|
-
if (plainChars.length === 0) {
|
|
84
|
-
return "";
|
|
85
|
-
}
|
|
86
|
-
const nextLength = Math.max(0, plainChars.length - rowsToTrim * safeWidth);
|
|
87
|
-
return plainChars.slice(0, nextLength).join("");
|
|
88
|
-
}
|
|
89
|
-
function dropLeadingByDisplayRows(lines, rowsToDrop, width) {
|
|
90
|
-
if (rowsToDrop <= 0 || lines.length === 0) {
|
|
91
|
-
return [...lines];
|
|
92
|
-
}
|
|
93
|
-
let index = 0;
|
|
94
|
-
let remaining = rowsToDrop;
|
|
95
|
-
while (index < lines.length && remaining > 0) {
|
|
96
|
-
remaining -= lineDisplayRows(lines[index] ?? "", width);
|
|
97
|
-
index += 1;
|
|
98
|
-
}
|
|
99
|
-
return lines.slice(index);
|
|
100
|
-
}
|
|
101
|
-
function dropTrailingByDisplayRows(lines, rowsToDrop, width) {
|
|
102
|
-
if (rowsToDrop <= 0 || lines.length === 0) {
|
|
103
|
-
return [...lines];
|
|
104
|
-
}
|
|
105
|
-
const next = [...lines];
|
|
106
|
-
let remaining = rowsToDrop;
|
|
107
|
-
while (next.length > 0 && remaining > 0) {
|
|
108
|
-
const lastIndex = next.length - 1;
|
|
109
|
-
const lastLine = next[lastIndex] ?? "";
|
|
110
|
-
const lastRows = lineDisplayRows(lastLine, width);
|
|
111
|
-
if (remaining >= lastRows) {
|
|
112
|
-
remaining -= lastRows;
|
|
113
|
-
next.pop();
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
next[lastIndex] = trimEndByDisplayRows(lastLine, remaining, width);
|
|
117
|
-
remaining = 0;
|
|
118
|
-
}
|
|
119
|
-
return next;
|
|
120
|
-
}
|
|
121
|
-
function computeMinVisibleContentRows(outputLines, width) {
|
|
122
|
-
const firstContentIndex = outputLines.findIndex((line) => !isVisuallyEmptyLine(line));
|
|
123
|
-
if (firstContentIndex === -1) {
|
|
124
|
-
return 0;
|
|
125
|
-
}
|
|
126
|
-
const rowsBeforeFirstContent = countDisplayRows(outputLines.slice(0, firstContentIndex), width);
|
|
127
|
-
return rowsBeforeFirstContent + 1;
|
|
128
|
-
}
|
|
129
|
-
function computeMaxOutputScrollOffsetRows(outputLines, width) {
|
|
130
|
-
const totalRows = countDisplayRows(outputLines, width);
|
|
131
|
-
const minVisibleRows = computeMinVisibleContentRows(outputLines, width);
|
|
132
|
-
return Math.max(0, totalRows - minVisibleRows);
|
|
133
|
-
}
|
|
134
|
-
function computeUsefulOutputScrollCapRows(options) {
|
|
135
|
-
const structuralMax = computeMaxOutputScrollOffsetRows(options.outputLines, options.width);
|
|
136
|
-
const safeRows = Math.max(1, options.rows);
|
|
137
|
-
const promptCount = Math.min(options.promptLines.length, safeRows);
|
|
138
|
-
const upperRowCount = Math.max(0, safeRows - promptCount);
|
|
139
|
-
const topVisibleTitleCount = Math.min(options.titleLines.length, upperRowCount);
|
|
140
|
-
const topGapRows = topVisibleTitleCount > 0 ? constants_1.TITLE_OUTPUT_GAP_ROWS : 0;
|
|
141
|
-
const topContentRows = Math.max(0, upperRowCount - topVisibleTitleCount - topGapRows);
|
|
142
|
-
const extraRowsBeyondAnchor = Math.max(0, topContentRows - 1);
|
|
143
|
-
return Math.max(0, structuralMax - extraRowsBeyondAnchor);
|
|
144
|
-
}
|
|
145
|
-
function buildPromptStatusText(state) {
|
|
146
|
-
if (state.uiMode === "confirm") {
|
|
147
|
-
return "confirmation · required";
|
|
148
|
-
}
|
|
149
|
-
if (state.uiMode === "vt") {
|
|
150
|
-
return "virtual-terminal · active";
|
|
151
|
-
}
|
|
152
|
-
if (state.uiMode === "sessions") {
|
|
153
|
-
return "sessions · browse";
|
|
154
|
-
}
|
|
155
|
-
if (state.uiMode === "model-manager") {
|
|
156
|
-
return "model-manager · search";
|
|
157
|
-
}
|
|
158
|
-
if (state.uiMode === "downloader") {
|
|
159
|
-
return "model-downloader · search";
|
|
160
|
-
}
|
|
161
|
-
const provider = formatBackendName(state.config.backend);
|
|
162
|
-
const loadedModel = resolveLoadedModel(state.config.model);
|
|
163
|
-
const parts = [provider];
|
|
164
|
-
if (loadedModel) {
|
|
165
|
-
parts.push((0, model_manager_1.getFriendlyModelName)(loadedModel, state.config.nicknames));
|
|
166
|
-
if (typeof state.latestOutputTokensPerSecond === "number" &&
|
|
167
|
-
state.latestOutputTokensPerSecond > 0) {
|
|
168
|
-
parts.push((0, runtime_utils_1.formatTokensPerSecond)(state.latestOutputTokensPerSecond));
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const status = parts.join(" · ");
|
|
172
|
-
if (state.outputScrollOffset > 0) {
|
|
173
|
-
return `${status} · scroll +${state.outputScrollOffset}`;
|
|
174
|
-
}
|
|
175
|
-
return status;
|
|
176
|
-
}
|
|
177
|
-
function composeOutputLines(options) {
|
|
178
|
-
const lines = [...options.outputLines, ...options.autocompleteOverlay];
|
|
179
|
-
if (options.busyLine && options.busyLine.length > 0) {
|
|
180
|
-
lines.push(options.busyLine);
|
|
181
|
-
}
|
|
182
|
-
return lines;
|
|
183
|
-
}
|
|
184
|
-
function computeVisibleLayoutSlices(rows, titleLines, outputLines, promptLines, outputScrollOffset = 0) {
|
|
185
|
-
const safeRows = Math.max(1, rows);
|
|
186
|
-
const promptCount = Math.min(promptLines.length, safeRows);
|
|
187
|
-
const visiblePrompt = promptLines.slice(-promptCount);
|
|
188
|
-
const upperRowCount = Math.max(0, safeRows - visiblePrompt.length);
|
|
189
|
-
const renderWidth = inferRenderWidth(titleLines, visiblePrompt);
|
|
190
|
-
if (upperRowCount === 0) {
|
|
191
|
-
return {
|
|
192
|
-
titleLines: [],
|
|
193
|
-
outputLines: [],
|
|
194
|
-
promptLines: visiblePrompt
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
const baseHiddenTitle = Math.max(0, titleLines.length - upperRowCount);
|
|
198
|
-
const initiallyVisibleTitleCount = titleLines.length - baseHiddenTitle;
|
|
199
|
-
const maxOffset = computeUsefulOutputScrollCapRows({
|
|
200
|
-
rows: safeRows,
|
|
201
|
-
titleLines,
|
|
202
|
-
outputLines,
|
|
203
|
-
promptLines: visiblePrompt,
|
|
204
|
-
width: renderWidth
|
|
205
|
-
});
|
|
206
|
-
const clampedOffset = Math.max(0, Math.min(outputScrollOffset, maxOffset));
|
|
207
|
-
const isAtTopOfScrollback = maxOffset > 0 && clampedOffset === maxOffset;
|
|
208
|
-
const reservedTitleGap = isAtTopOfScrollback || initiallyVisibleTitleCount <= 0 ? 0 : constants_1.TITLE_OUTPUT_GAP_ROWS;
|
|
209
|
-
const initialGap = Math.max(0, upperRowCount - initiallyVisibleTitleCount - reservedTitleGap);
|
|
210
|
-
const scrollWindow = dropTrailingByDisplayRows(outputLines, clampedOffset, renderWidth);
|
|
211
|
-
const firstContentIndex = scrollWindow.findIndex((line) => !isVisuallyEmptyLine(line));
|
|
212
|
-
const contentWindow = firstContentIndex === -1 ? [] : scrollWindow.slice(firstContentIndex);
|
|
213
|
-
let lastContentIndex = -1;
|
|
214
|
-
for (let index = contentWindow.length - 1; index >= 0; index -= 1) {
|
|
215
|
-
if (!isVisuallyEmptyLine(contentWindow[index] ?? "")) {
|
|
216
|
-
lastContentIndex = index;
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
const pressureWindow = lastContentIndex === -1 ? [] : contentWindow.slice(0, lastContentIndex + 1);
|
|
221
|
-
const trailingSpacerRows = lastContentIndex === -1 ? [] : contentWindow.slice(lastContentIndex + 1);
|
|
222
|
-
const outputCount = countDisplayRows(pressureWindow, renderWidth);
|
|
223
|
-
const outputConsumedByGap = isAtTopOfScrollback ? 0 : Math.min(outputCount, initialGap);
|
|
224
|
-
const outputAfterGap = outputCount - outputConsumedByGap;
|
|
225
|
-
const outputConsumedByTitle = isAtTopOfScrollback
|
|
226
|
-
? 0
|
|
227
|
-
: Math.min(outputAfterGap, initiallyVisibleTitleCount);
|
|
228
|
-
const totalHiddenTitle = baseHiddenTitle + outputConsumedByTitle;
|
|
229
|
-
const visibleTitle = titleLines.slice(totalHiddenTitle);
|
|
230
|
-
const hiddenOutputRows = isAtTopOfScrollback
|
|
231
|
-
? 0
|
|
232
|
-
: Math.max(0, outputAfterGap - initiallyVisibleTitleCount);
|
|
233
|
-
const visibleCoreOutput = dropLeadingByDisplayRows(pressureWindow, hiddenOutputRows, renderWidth);
|
|
234
|
-
const topModeGapRows = isAtTopOfScrollback && visibleTitle.length > 0 ? constants_1.TITLE_OUTPUT_GAP_ROWS : 0;
|
|
235
|
-
const outputRowsAvailable = Math.max(0, upperRowCount - visibleTitle.length - topModeGapRows);
|
|
236
|
-
const visibleOutput = [...visibleCoreOutput];
|
|
237
|
-
let usedOutputRows = countDisplayRows(visibleOutput, renderWidth);
|
|
238
|
-
for (const spacerRow of trailingSpacerRows) {
|
|
239
|
-
const nextRows = usedOutputRows + lineDisplayRows(spacerRow, renderWidth);
|
|
240
|
-
if (nextRows > outputRowsAvailable) {
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
visibleOutput.push(spacerRow);
|
|
244
|
-
usedOutputRows = nextRows;
|
|
245
|
-
}
|
|
246
|
-
if (usedOutputRows < outputRowsAvailable) {
|
|
247
|
-
const outputPadding = new Array(outputRowsAvailable - usedOutputRows).fill("");
|
|
248
|
-
if (isAtTopOfScrollback) {
|
|
249
|
-
const titleGapPadding = new Array(topModeGapRows).fill("");
|
|
250
|
-
return {
|
|
251
|
-
titleLines: visibleTitle,
|
|
252
|
-
outputLines: [...titleGapPadding, ...visibleOutput, ...outputPadding],
|
|
253
|
-
promptLines: visiblePrompt
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
return {
|
|
257
|
-
titleLines: visibleTitle,
|
|
258
|
-
outputLines: [...outputPadding, ...visibleOutput],
|
|
259
|
-
promptLines: visiblePrompt
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
if (usedOutputRows > outputRowsAvailable) {
|
|
263
|
-
const trimmedOutput = dropLeadingByDisplayRows(visibleOutput, usedOutputRows - outputRowsAvailable, renderWidth);
|
|
264
|
-
if (isAtTopOfScrollback) {
|
|
265
|
-
const titleGapPadding = new Array(topModeGapRows).fill("");
|
|
266
|
-
return {
|
|
267
|
-
titleLines: visibleTitle,
|
|
268
|
-
outputLines: [...titleGapPadding, ...trimmedOutput],
|
|
269
|
-
promptLines: visiblePrompt
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
return {
|
|
273
|
-
titleLines: visibleTitle,
|
|
274
|
-
outputLines: trimmedOutput,
|
|
275
|
-
promptLines: visiblePrompt
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
if (isAtTopOfScrollback) {
|
|
279
|
-
const titleGapPadding = new Array(topModeGapRows).fill("");
|
|
280
|
-
return {
|
|
281
|
-
titleLines: visibleTitle,
|
|
282
|
-
outputLines: [...titleGapPadding, ...visibleOutput],
|
|
283
|
-
promptLines: visiblePrompt
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
titleLines: visibleTitle,
|
|
288
|
-
outputLines: visibleOutput,
|
|
289
|
-
promptLines: visiblePrompt
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
function computeTitleVisibleScrollCap(rows, titleLines, outputLines, promptLines) {
|
|
293
|
-
const safeRows = Math.max(1, rows);
|
|
294
|
-
const promptCount = Math.min(promptLines.length, safeRows);
|
|
295
|
-
const visiblePrompt = promptLines.slice(-promptCount);
|
|
296
|
-
const renderWidth = inferRenderWidth(titleLines, visiblePrompt);
|
|
297
|
-
return computeUsefulOutputScrollCapRows({
|
|
298
|
-
rows: safeRows,
|
|
299
|
-
titleLines,
|
|
300
|
-
outputLines,
|
|
301
|
-
promptLines: visiblePrompt,
|
|
302
|
-
width: renderWidth
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
function buildPromptRenderLines(width, statusText, promptLayout, showCursor = true) {
|
|
306
|
-
const frame = (0, prompt_box_1.buildPromptBoxFrame)(width, statusText, promptLayout.rowCount);
|
|
307
|
-
const lines = [(0, colors_1.horizontalGradient)(frame.top, colors_1.GRADIENT_PINK, colors_1.GRADIENT_YELLOW)];
|
|
308
|
-
for (let rowIndex = 0; rowIndex < frame.middleRows.length; rowIndex++) {
|
|
309
|
-
if (width <= 1) {
|
|
310
|
-
lines.push((0, colors_1.horizontalGradient)(frame.middleRows[rowIndex] ?? "", colors_1.GRADIENT_PINK, colors_1.GRADIENT_YELLOW));
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
const prefix = rowIndex === 0 ? promptLayout.prefix : "";
|
|
314
|
-
const contentChars = Array.from(`${prefix}${promptLayout.rows[rowIndex] ?? ""}`).slice(0, frame.innerWidth);
|
|
315
|
-
while (contentChars.length < frame.innerWidth) {
|
|
316
|
-
contentChars.push(" ");
|
|
317
|
-
}
|
|
318
|
-
let plainInner = contentChars.join("");
|
|
319
|
-
if (showCursor && rowIndex === promptLayout.cursorRow && frame.innerWidth > 0) {
|
|
320
|
-
const cursorOffset = rowIndex === 0 ? charLength(prefix) : 0;
|
|
321
|
-
const cursorIndex = Math.max(0, Math.min(frame.innerWidth - 1, cursorOffset + promptLayout.cursorCol));
|
|
322
|
-
plainInner = withCursorAt(plainInner, cursorIndex);
|
|
323
|
-
}
|
|
324
|
-
const leftBorder = (0, colors_1.colorText)("│", colors_1.GRADIENT_PINK);
|
|
325
|
-
const rightBorder = (0, colors_1.colorText)("│", colors_1.GRADIENT_YELLOW);
|
|
326
|
-
const coloredInner = (0, colors_1.colorText)(plainInner, colors_1.INPUT_PINK);
|
|
327
|
-
lines.push(`${leftBorder}${coloredInner}${rightBorder}`);
|
|
328
|
-
}
|
|
329
|
-
if (width <= 1) {
|
|
330
|
-
lines.push((0, colors_1.horizontalGradient)(frame.bottom, colors_1.GRADIENT_PINK, colors_1.GRADIENT_YELLOW));
|
|
331
|
-
return lines;
|
|
332
|
-
}
|
|
333
|
-
const clippedStatus = clipPromptStatusText(statusText, frame.innerWidth);
|
|
334
|
-
const fill = "─".repeat(Math.max(0, frame.innerWidth - charLength(clippedStatus)));
|
|
335
|
-
const leftBottom = (0, colors_1.horizontalGradientAtOffset)("╰", colors_1.GRADIENT_PINK, colors_1.GRADIENT_YELLOW, 0, width);
|
|
336
|
-
const fillBottom = (0, colors_1.horizontalGradientAtOffset)(fill, colors_1.GRADIENT_PINK, colors_1.GRADIENT_YELLOW, 1, width);
|
|
337
|
-
const statusBottom = (0, colors_1.colorText)(clippedStatus, colors_1.GRADIENT_BLUE);
|
|
338
|
-
const rightBottom = (0, colors_1.horizontalGradientAtOffset)("╯", colors_1.GRADIENT_PINK, colors_1.GRADIENT_YELLOW, width - 1, width);
|
|
339
|
-
lines.push(`${leftBottom}${fillBottom}${statusBottom}${rightBottom}`);
|
|
340
|
-
return lines;
|
|
341
|
-
}
|