@oxecli/oxe 1.0.79 → 1.0.81
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/dist/cli.js +8 -2
- package/dist/ui.js +16 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { loadOrPrompt, default_reasoning_effort, max_action_chars, max_resume_history_items, runtimeOsSummary, } from "./config.js";
|
|
4
|
+
import { loadOrPrompt, default_reasoning_effort, max_action_chars, max_resume_history_items, runtimeOsSummary, max_context_tokens, context_overhead_margin, } from "./config.js";
|
|
5
5
|
import { InferenceEngine, estimateTokens } from "./engine.js";
|
|
6
6
|
import { saveSession, loadSession, listSessions, nextSessionId, conversationLabel, COMMAND_HELP, stripOrphanCalls, toolOutputFailed, } from "./sessions.js";
|
|
7
7
|
import { clearScreen, enableAnsi, askBottomPrompt, userDisplayText, aiMarkdown, mutedMarkdown, messageText, toolCallLabel, formatToolResult, truncateEllipsis, stripAnsi, renderPanel, renderTableString, enableRawStdin, disableRawStdin, waitRawKey, } from "./ui.js";
|
|
@@ -372,7 +372,13 @@ export class CLI {
|
|
|
372
372
|
engine.inQuery = false;
|
|
373
373
|
let queryStarted = false;
|
|
374
374
|
try {
|
|
375
|
-
const
|
|
375
|
+
const used = estimateTokens(this.inputItems);
|
|
376
|
+
const budget = max_context_tokens - context_overhead_margin;
|
|
377
|
+
const pct = Math.max(0, Math.min(100, Math.round(((budget - used) / budget) * 100)));
|
|
378
|
+
const [input, spans] = await askBottomPrompt("You", "❯", this.promptHistory, {
|
|
379
|
+
left: "\x1b[90mPress \x1b[1;36mesc\x1b[0m\x1b[90m to interrupt\x1b[0m",
|
|
380
|
+
right: `\x1b[1;36m${pct}%\x1b[0m \x1b[90muntil auto-compact\x1b[0m`,
|
|
381
|
+
});
|
|
376
382
|
if (!input.trim())
|
|
377
383
|
continue;
|
|
378
384
|
this.interruptPending = false;
|
package/dist/ui.js
CHANGED
|
@@ -866,7 +866,7 @@ function wrapRuns(runs, width) {
|
|
|
866
866
|
flush();
|
|
867
867
|
return { rows, caretRow, caretCol };
|
|
868
868
|
}
|
|
869
|
-
export function renderBufferWithCursor(buffer, pasteSpans, prefix, label, cursor) {
|
|
869
|
+
export function renderBufferWithCursor(buffer, pasteSpans, prefix, label, cursor, hints) {
|
|
870
870
|
const termW = terminalWidth();
|
|
871
871
|
const boxW = Math.max(termW - 4, 16);
|
|
872
872
|
const innerW = boxW - 4;
|
|
@@ -964,10 +964,21 @@ export function renderBufferWithCursor(buffer, pasteSpans, prefix, label, cursor
|
|
|
964
964
|
body.push(`\x1b[90m│\x1b[0m ${l}${" ".repeat(pad)} \x1b[90m│\x1b[0m`);
|
|
965
965
|
}
|
|
966
966
|
const bottom = `\x1b[90m╰${"─".repeat(Math.max(0, boxW - 2))}╯\x1b[0m`;
|
|
967
|
-
const
|
|
967
|
+
const lines = [top, ...body, bottom];
|
|
968
|
+
let totalRows = body.length + 2;
|
|
969
|
+
if (hints && (hints.left || hints.right)) {
|
|
970
|
+
const left = hints.left ?? "";
|
|
971
|
+
const right = hints.right ?? "";
|
|
972
|
+
// Inset the hint row inside the box (box spans columns 0..boxW-1): a
|
|
973
|
+
// leading space gives left-edge padding, and the right hint ends one
|
|
974
|
+
// column before the box's right border for the same padding.
|
|
975
|
+
const gap = Math.max(1, boxW - 2 - plainLen(left) - plainLen(right));
|
|
976
|
+
lines.push(" " + left + " ".repeat(gap) + right);
|
|
977
|
+
totalRows += 1;
|
|
978
|
+
}
|
|
979
|
+
const frame = lines.join("\n");
|
|
968
980
|
const cursorRow = (caretRow === -1 ? 0 : caretRow) + 1;
|
|
969
981
|
const cursorCol = (caretCol === -1 ? 0 : caretCol) + 2;
|
|
970
|
-
const totalRows = body.length + 2;
|
|
971
982
|
return { frame, cursorRow, cursorCol, totalRows };
|
|
972
983
|
}
|
|
973
984
|
/**
|
|
@@ -989,7 +1000,7 @@ function isEnterKey(str, key) {
|
|
|
989
1000
|
seq === "\x1bOM" // application keypad
|
|
990
1001
|
);
|
|
991
1002
|
}
|
|
992
|
-
export function askBottomPrompt(label = "You", prefix = "❯", history = []) {
|
|
1003
|
+
export function askBottomPrompt(label = "You", prefix = "❯", history = [], hints) {
|
|
993
1004
|
return new Promise((resolve, reject) => {
|
|
994
1005
|
const isTTY = process.stdin.isTTY;
|
|
995
1006
|
if (!isTTY) {
|
|
@@ -1056,7 +1067,7 @@ export function askBottomPrompt(label = "You", prefix = "❯", history = []) {
|
|
|
1056
1067
|
resolve(value);
|
|
1057
1068
|
};
|
|
1058
1069
|
const repaint = (isFirst = false) => {
|
|
1059
|
-
const { frame, cursorRow, cursorCol, totalRows } = renderBufferWithCursor(buffer, pasteSpans, prefix, label, cursor);
|
|
1070
|
+
const { frame, cursorRow, cursorCol, totalRows } = renderBufferWithCursor(buffer, pasteSpans, prefix, label, cursor, hints);
|
|
1060
1071
|
const newLines = frame.split("\n");
|
|
1061
1072
|
if (isFirst) {
|
|
1062
1073
|
process.stdout.write("\n");
|