@lazyingart/agintiflow 0.16.0 → 0.16.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/package.json +1 -1
- package/scripts/smoke-cli-chat.js +3 -0
- package/src/interactive-cli.js +12 -3
package/package.json
CHANGED
|
@@ -93,6 +93,9 @@ try {
|
|
|
93
93
|
if (!promptText.includes("user>")) {
|
|
94
94
|
throw new Error("terminal prompt layout did not render the user> label");
|
|
95
95
|
}
|
|
96
|
+
if (!promptText.includes("user> ")) {
|
|
97
|
+
throw new Error("terminal prompt layout did not pad user> to the aginti> label width");
|
|
98
|
+
}
|
|
96
99
|
const visibleLengths = promptLayout.renderedRows.map((line) =>
|
|
97
100
|
line.replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, "").length
|
|
98
101
|
);
|
package/src/interactive-cli.js
CHANGED
|
@@ -73,8 +73,17 @@ function sleep(ms) {
|
|
|
73
73
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
const ROLE_LABEL_WIDTH = "aginti".length;
|
|
77
|
+
const PROMPT_LABEL_WIDTH = "aginti>".length;
|
|
78
|
+
|
|
79
|
+
function labelText(name, { prompt = false } = {}) {
|
|
80
|
+
const raw = String(name || "");
|
|
81
|
+
const width = prompt || raw.endsWith(">") ? PROMPT_LABEL_WIDTH : ROLE_LABEL_WIDTH;
|
|
82
|
+
return ` ${raw.padEnd(width, " ")} `;
|
|
83
|
+
}
|
|
84
|
+
|
|
76
85
|
function label(name, bgCode) {
|
|
77
|
-
return color(
|
|
86
|
+
return color(labelText(name), bgCode, ansi.bold);
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
function outputLine(line = "") {
|
|
@@ -542,8 +551,8 @@ export function buildPromptLayout(buffer = "", cursor = 0, width = terminalWidth
|
|
|
542
551
|
const safeBuffer = String(buffer || "");
|
|
543
552
|
const safeCursor = clamp(Number(cursor) || 0, 0, safeBuffer.length);
|
|
544
553
|
const lineWidth = editorWidth(width);
|
|
545
|
-
const firstPrefix = "
|
|
546
|
-
const nextPrefix = "
|
|
554
|
+
const firstPrefix = labelText("user>", { prompt: true });
|
|
555
|
+
const nextPrefix = labelText("...", { prompt: true });
|
|
547
556
|
const firstInnerWidth = Math.max(lineWidth - firstPrefix.length, 8);
|
|
548
557
|
const nextInnerWidth = Math.max(lineWidth - nextPrefix.length, 8);
|
|
549
558
|
const rows = [];
|