@oxecli/oxe 1.0.79 → 1.0.80

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 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 [input, spans] = await askBottomPrompt("You", "❯", this.promptHistory);
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[90mesc 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,18 @@ 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 frame = [top, ...body, bottom].join("\n");
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
+ const gap = Math.max(1, termW - plainLen(left) - plainLen(right));
973
+ lines.push(left + " ".repeat(gap) + right);
974
+ totalRows += 1;
975
+ }
976
+ const frame = lines.join("\n");
968
977
  const cursorRow = (caretRow === -1 ? 0 : caretRow) + 1;
969
978
  const cursorCol = (caretCol === -1 ? 0 : caretCol) + 2;
970
- const totalRows = body.length + 2;
971
979
  return { frame, cursorRow, cursorCol, totalRows };
972
980
  }
973
981
  /**
@@ -989,7 +997,7 @@ function isEnterKey(str, key) {
989
997
  seq === "\x1bOM" // application keypad
990
998
  );
991
999
  }
992
- export function askBottomPrompt(label = "You", prefix = "❯", history = []) {
1000
+ export function askBottomPrompt(label = "You", prefix = "❯", history = [], hints) {
993
1001
  return new Promise((resolve, reject) => {
994
1002
  const isTTY = process.stdin.isTTY;
995
1003
  if (!isTTY) {
@@ -1056,7 +1064,7 @@ export function askBottomPrompt(label = "You", prefix = "❯", history = []) {
1056
1064
  resolve(value);
1057
1065
  };
1058
1066
  const repaint = (isFirst = false) => {
1059
- const { frame, cursorRow, cursorCol, totalRows } = renderBufferWithCursor(buffer, pasteSpans, prefix, label, cursor);
1067
+ const { frame, cursorRow, cursorCol, totalRows } = renderBufferWithCursor(buffer, pasteSpans, prefix, label, cursor, hints);
1060
1068
  const newLines = frame.split("\n");
1061
1069
  if (isFirst) {
1062
1070
  process.stdout.write("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxecli/oxe",
3
- "version": "1.0.79",
3
+ "version": "1.0.80",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },