kovence-cli 1.2.0 → 1.3.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/tui.js CHANGED
@@ -253,6 +253,7 @@ class KovenceTUI {
253
253
  provider: "default",
254
254
  providerType: "openai",
255
255
  model: "",
256
+ reasoning: "off",
256
257
  ctxText: "",
257
258
  agentMode: "default",
258
259
  colorScheme: "amber",
@@ -701,14 +702,31 @@ class KovenceTUI {
701
702
  return true;
702
703
  }
703
704
 
704
- openPicker(title, items, { initialIdx = 0, hint = "↑/↓ select · Enter open · d delete · Esc close" } = {}) {
705
+ openPicker(
706
+ title,
707
+ items,
708
+ {
709
+ initialIdx = 0,
710
+ hint = "↑/↓ select · Enter open · d delete · Esc close",
711
+ multiSelect = false,
712
+ selectedIds = null,
713
+ } = {}
714
+ ) {
705
715
  return new Promise((resolve) => {
706
716
  let safeIdx = Math.max(0, Math.min(Number(initialIdx) || 0, Math.max(0, items.length - 1)));
707
717
  if (items[safeIdx]?.type === "header") {
708
718
  const nextSelectable = items.findIndex((x) => x.type !== "header");
709
719
  if (nextSelectable >= 0) safeIdx = nextSelectable;
710
720
  }
711
- this.picker = { title, items, selIdx: safeIdx, hint, resolve };
721
+ this.picker = {
722
+ title,
723
+ items,
724
+ selIdx: safeIdx,
725
+ hint,
726
+ multiSelect: Boolean(multiSelect),
727
+ selectedIds: selectedIds instanceof Set ? new Set(selectedIds) : new Set(),
728
+ resolve,
729
+ };
712
730
  this.scheduleRender();
713
731
  });
714
732
  }
@@ -806,13 +824,33 @@ class KovenceTUI {
806
824
  const detailW = Math.max(12, innerW - 6);
807
825
 
808
826
  if (hasWriteStats) {
809
- // --- Stats line: spinner (if active) or ✓ (if done) + lines + tokens + speed ---
810
- const elapsedSec = Math.max(0.1, (Date.now() - ws.startTime) / 1000);
811
- // Rough token estimate: ~4 chars per token.
812
- const tokEst = Math.round(ws.totalChars / 4);
813
- const tokSec = Math.round(tokEst / elapsedSec);
827
+ // --- Stats line: animated real-time counter during write, ✓ summary when done ---
828
+ // Use firstChunkAt for accurate tok/s (excludes LLM think time before streaming)
829
+ const t0 = ws.firstChunkAt || ws.startTime;
830
+ const elapsedSec = Math.max(0.05, (Date.now() - t0) / 1000);
831
+ // Rough token estimate: ~4 chars per token (show at least 1 token as soon as chars stream)
832
+ const tokEst = ws.totalChars > 0 ? Math.max(1, Math.round(ws.totalChars / 4)) : 0;
833
+ const rawTokSec = tokEst / elapsedSec;
834
+ // Smooth: only show speed once we have at least a little data
835
+ const tokSec = tokEst > 8 ? Math.round(rawTokSec) : 0;
836
+ // Count current partial line (lineBuf) as a line in progress
837
+ const displayLines = ws.totalLines + (ws.lineBuf ? 1 : 0);
814
838
  const statusIcon = isActiveWrite ? dot : "✓";
815
- const statsLine = `${statusIcon} ${ws.totalLines} lines · ~${tokEst} tokens · ${tokSec} tok/s`;
839
+ // During active write: show incrementing counters live
840
+ // When done: show final summary
841
+ let statsLine;
842
+ if (isActiveWrite) {
843
+ const speedStr = tokSec > 0 ? ` · ${tokSec} tok/s` : "";
844
+ statsLine = `${statusIcon} ${displayLines} lines · ~${tokEst} tokens${speedStr}`;
845
+ } else {
846
+ // Final state — use precise elapsed from first chunk to done
847
+ const finalElapsed = ws.doneAt
848
+ ? Math.max(0.05, (ws.doneAt - t0) / 1000)
849
+ : elapsedSec;
850
+ const finalSpeed = tokEst > 8 ? Math.round(tokEst / finalElapsed) : 0;
851
+ const speedStr = finalSpeed > 0 ? ` · ${finalSpeed} tok/s` : "";
852
+ statsLine = `${statusIcon} ${ws.totalLines} lines · ~${tokEst} tokens${speedStr}`;
853
+ }
816
854
  blockLines.push(
817
855
  ` ${ansi.gray}│ ${ansi.amber}${clipToWidth(statsLine, detailW)}${ansi.reset}`
818
856
  );
@@ -963,7 +1001,7 @@ class KovenceTUI {
963
1001
 
964
1002
  const pickerRows = this.picker ? Math.min(10, this.picker.items.length) + 2 : 0;
965
1003
  const sugRows = suggestions.length;
966
- const composerRows = 3 + modalLines.length + visCompLines.length;
1004
+ const composerRows = 5 + modalLines.length + visCompLines.length; // +1 blank sep, +2 boxPad, +2 footer lines
967
1005
  const headerRows = 2;
968
1006
  const viewHeight = Math.max(4, rows - headerRows - sugRows - pickerRows - composerRows);
969
1007
 
@@ -1039,6 +1077,19 @@ class KovenceTUI {
1039
1077
  out.push(
1040
1078
  `${ansi.topBg}${ansi.orange}${ansi.bold}${padRight(titleText, displayWidth(titleText), cols)}${ansi.reset}\x1b[K\n`
1041
1079
  );
1080
+ const visPickerItems = this.picker.items.slice(pStart, pStart + maxVisible);
1081
+ const maxDescW = Math.min(30, Math.max(0, ...visPickerItems.map((x) => displayWidth(x?.desc || ""))));
1082
+ const availLeftW = Math.max(24, cols - (maxDescW > 0 ? maxDescW + 3 : 2));
1083
+ const formatPickerLabel = (it) => {
1084
+ if (this.picker.multiSelect && it.type !== "header" && it.type !== "skip" && it.type !== "action") {
1085
+ const mark = this.picker.selectedIds?.has(it.id) ? "[✓] " : "[ ] ";
1086
+ return ` ${mark}${it.label}`;
1087
+ }
1088
+ return ` ${it.label}`;
1089
+ };
1090
+ const naturalLeftW = Math.max(22, ...visPickerItems.map((x) => displayWidth(formatPickerLabel(x))));
1091
+ const leftColW = Math.min(availLeftW, naturalLeftW);
1092
+
1042
1093
  for (let i = 0; i < maxVisible; i++) {
1043
1094
  const idx = pStart + i;
1044
1095
  const it = this.picker.items[idx];
@@ -1050,7 +1101,9 @@ class KovenceTUI {
1050
1101
  continue;
1051
1102
  }
1052
1103
  const active = idx === this.picker.selIdx;
1053
- const left = clipToWidth(` ${it.label.padEnd(22)}`, Math.min(24, cols));
1104
+ const rawLeftLabel = formatPickerLabel(it);
1105
+ const clippedLeft = clipToWidth(rawLeftLabel, leftColW);
1106
+ const left = padRight(clippedLeft, displayWidth(clippedLeft), leftColW);
1054
1107
  const right = clipToWidth(it.desc || "", Math.max(0, cols - displayWidth(left) - 1));
1055
1108
  const plainLen = displayWidth(left) + 1 + displayWidth(right);
1056
1109
  const line = active
@@ -1074,6 +1127,8 @@ class KovenceTUI {
1074
1127
  }
1075
1128
 
1076
1129
  // 4) Multi-Line Bottom Composer Box
1130
+ // Blank separator line between viewport content and the composer box for breathing room.
1131
+ out.push(`\x1b[K\n`);
1077
1132
  const boxPad = `${ansi.barBg}${ansi.orange}┃${" ".repeat(Math.max(0, cols - 1))}${ansi.reset}\x1b[K\n`;
1078
1133
  out.push(boxPad);
1079
1134
 
@@ -1090,8 +1145,10 @@ class KovenceTUI {
1090
1145
  const pfx = i === 0 && compStart === 0 ? promptPrefix : prefixSpace;
1091
1146
  const txt = visCompLines[i];
1092
1147
  const isBusy = Boolean(this.status.isBusy || this.status.busyLabel);
1148
+ // When busy: show NO placeholder text — just an empty input with cursor.
1149
+ // The busy label is already visible in the top-right header corner.
1093
1150
  const defaultPh = "Type message · Shift+Enter newline · / commands...";
1094
- const phText = isBusy && this.status.busyLabel ? `⏳ ${this.status.busyLabel}` : defaultPh;
1151
+ const phText = isBusy ? "" : defaultPh;
1095
1152
  const showPh =
1096
1153
  i === 0 &&
1097
1154
  compStart === 0 &&
@@ -1099,7 +1156,8 @@ class KovenceTUI {
1099
1156
  !this.input &&
1100
1157
  this.status.showTips !== false &&
1101
1158
  cols >= 2 + displayWidth(pfx) + displayWidth(phText);
1102
- const placeholder = showPh ? `${isBusy ? ansi.amber : ansi.gray}${phText}${ansi.reset}` : "";
1159
+ // Keep ansi.barBg continuous across the entire input line (never emit inner ansi.reset before padding)
1160
+ const placeholder = showPh ? `${isBusy ? ansi.amber : ansi.gray}${phText}` : "";
1103
1161
  const phLen = showPh ? displayWidth(phText) : 0;
1104
1162
  const linePlainLen = 2 + displayWidth(pfx) + displayWidth(txt);
1105
1163
  const padComposer = Math.max(0, cols - linePlainLen - phLen);
@@ -1109,8 +1167,10 @@ class KovenceTUI {
1109
1167
  }
1110
1168
  out.push(boxPad);
1111
1169
 
1112
- // 5) Bottom Footer Status & Keybinds
1113
- const shortModel = this.status.model.length > 20 ? `...${this.status.model.slice(-17)}` : this.status.model;
1170
+ // 5) Bottom Footer Status & Dedicated Keyboard Shortcuts Line
1171
+ const fullModel = this.status.model || "";
1172
+ const reasoningTag =
1173
+ this.status.reasoning && this.status.reasoning !== "off" ? ` (${this.status.reasoning})` : "";
1114
1174
  const apiTag = `${this.status.provider}(${this.status.providerType})`;
1115
1175
  const ctxSeg = this.status.ctxText ? ` · ${this.status.ctxText}` : "";
1116
1176
  const modeTag = this.status.agentMode || (this.status.auto ? "auto" : "default");
@@ -1120,26 +1180,46 @@ class KovenceTUI {
1120
1180
  if (this.status.activeTodos > 0) taskParts.push(`Todos:${this.status.activeTodos}`);
1121
1181
  }
1122
1182
  const taskSeg = taskParts.length ? ` · ${taskParts.join(" ")}` : "";
1123
- const rawLeft = `Kovence CLI · Mode: ${modeTag} · ${apiTag} · ${shortModel}${ctxSeg}${taskSeg} · Tools ${this.status.tools ? "ON" : "OFF"}`;
1124
- const maxLeftW = Math.max(20, cols - 2);
1125
- const clampedLeft = clipToWidth(rawLeft, maxLeftW);
1126
- const fullHints =
1127
- this.scrollOffset > 0
1128
- ? `[Scrolled +${this.scrollOffset}] Shift+Tab mode · Ctrl+Y copy · F2 select`
1129
- : `Shift+Tab mode · Ctrl+S sessions · Ctrl+, settings · Ctrl+Y copy · F2 select`;
1130
- const maxHintW = Math.max(0, cols - displayWidth(clampedLeft) - 3);
1131
- const hintsRight = maxHintW >= 12 ? clipToWidth(fullHints, maxHintW) : "";
1132
- const footerGap = hintsRight ? Math.max(1, cols - displayWidth(clampedLeft) - displayWidth(hintsRight) - 2) : 0;
1133
- const footerBrand = clampedLeft.startsWith("Kovence CLI")
1134
- ? `${ansi.orange}${ansi.bold}Kovence CLI${ansi.reset}${ansi.gray}${clampedLeft.slice(11)}`
1135
- : `${ansi.gray}${clampedLeft}`;
1136
- out.push(` ${footerBrand}${hintsRight ? `${" ".repeat(footerGap)}${hintsRight}` : ""}${ansi.reset}\x1b[K`);
1183
+ const rawStatusLine = `Kovence CLI · Mode: ${modeTag} · ${apiTag} · ${fullModel}${reasoningTag}${ctxSeg}${taskSeg} · Tools ${this.status.tools ? "ON" : "OFF"}`;
1184
+ const maxFooterW = Math.max(20, cols - 2);
1185
+ const clampedStatus = clipToWidth(rawStatusLine, maxFooterW);
1186
+ const footerBrand = clampedStatus.startsWith("Kovence CLI")
1187
+ ? `${ansi.orange}${ansi.bold}Kovence CLI${ansi.reset}${ansi.gray}${clampedStatus.slice(11)}`
1188
+ : `${ansi.gray}${clampedStatus}`;
1189
+ out.push(` ${footerBrand}${ansi.reset}\x1b[K\n`);
1190
+
1191
+ // Line 2 of footer: dedicated keyboard shortcuts bar (never hidden by long model/context status)
1192
+ const priorityShortcuts = [
1193
+ "Shift+Tab mode",
1194
+ "Ctrl+S sessions",
1195
+ "Ctrl+, settings",
1196
+ "Ctrl+Y copy",
1197
+ "F2 select",
1198
+ "Ctrl+N new",
1199
+ "Ctrl+O details",
1200
+ ];
1201
+ const scrollPrefix = this.scrollOffset > 0 ? `[Scrolled +${this.scrollOffset}] · ` : "";
1202
+ let hintText = scrollPrefix;
1203
+ for (const sc of priorityShortcuts) {
1204
+ const candidate = hintText ? `${hintText}${hintText === scrollPrefix ? "" : " · "}${sc}` : sc;
1205
+ if (displayWidth(candidate) <= maxFooterW) {
1206
+ hintText = candidate;
1207
+ }
1208
+ }
1209
+ if (!hintText || hintText === scrollPrefix) {
1210
+ hintText = clipToWidth(`${scrollPrefix}${priorityShortcuts[0]}`, maxFooterW);
1211
+ }
1212
+ const renderedHints =
1213
+ this.scrollOffset > 0 && hintText.startsWith(scrollPrefix)
1214
+ ? `${ansi.amber}${scrollPrefix.slice(0, -3)}${ansi.gray} · ${hintText.slice(scrollPrefix.length)}`
1215
+ : `${ansi.gray}${hintText}`;
1216
+ out.push(` ${renderedHints}${ansi.reset}\x1b[K`);
1137
1217
 
1138
1218
  // Exact cursor placement (accounts cleanly for wrapped modal header lines)
1139
1219
  const curLineText = compLayout.lines[compLayout.curRow] || "";
1140
1220
  const curColVis = displayWidth(curLineText.slice(0, compLayout.curCol));
1141
1221
  const inputRow =
1142
- headerRows + viewHeight + pickerRows + sugRows + 2 + modalLines.length + (compLayout.curRow - compStart);
1222
+ headerRows + viewHeight + pickerRows + sugRows + 3 + modalLines.length + (compLayout.curRow - compStart);
1143
1223
  const inputCol = Math.min(cols, 2 + displayWidth(promptPrefix) + curColVis + 1);
1144
1224
  out.push(`\x1b[${inputRow};${inputCol}H`, ansi.showCur);
1145
1225
 
@@ -1232,12 +1312,44 @@ class KovenceTUI {
1232
1312
  this.scheduleRender();
1233
1313
  return;
1234
1314
  }
1315
+ if (this.picker.multiSelect && (key.name === "space" || str === " ")) {
1316
+ const chosen = items[this.picker.selIdx];
1317
+ if (chosen && chosen.type !== "header" && chosen.type !== "skip" && chosen.type !== "action") {
1318
+ if (this.picker.selectedIds.has(chosen.id)) this.picker.selectedIds.delete(chosen.id);
1319
+ else this.picker.selectedIds.add(chosen.id);
1320
+ this.scheduleRender();
1321
+ }
1322
+ return;
1323
+ }
1324
+ if (this.picker.multiSelect && str === "a") {
1325
+ const toggleable = items.filter((x) => x.type !== "header" && x.type !== "skip" && x.type !== "action");
1326
+ const allSelected = toggleable.length > 0 && toggleable.every((x) => this.picker.selectedIds.has(x.id));
1327
+ if (allSelected) {
1328
+ this.picker.selectedIds.clear();
1329
+ } else {
1330
+ for (const it of toggleable) this.picker.selectedIds.add(it.id);
1331
+ }
1332
+ this.scheduleRender();
1333
+ return;
1334
+ }
1235
1335
  if (key.name === "return" || key.name === "enter") {
1236
1336
  const chosen = items[this.picker.selIdx];
1237
1337
  if (!chosen || chosen.type === "header") return;
1338
+ const pickedIds = this.picker.multiSelect ? [...this.picker.selectedIds] : null;
1339
+ const isMulti = this.picker.multiSelect;
1238
1340
  this.picker = null;
1239
1341
  this.scheduleRender();
1240
- resolve({ action: "select", item: chosen });
1342
+ if (isMulti) {
1343
+ if (chosen.type === "skip") {
1344
+ resolve({ action: "multi", ids: [] });
1345
+ } else if (pickedIds && pickedIds.length > 0) {
1346
+ resolve({ action: "multi", ids: pickedIds });
1347
+ } else {
1348
+ resolve({ action: "select", item: chosen });
1349
+ }
1350
+ } else {
1351
+ resolve({ action: "select", item: chosen });
1352
+ }
1241
1353
  return;
1242
1354
  }
1243
1355
  if (key.name === "delete" || str === "d") {
package/ui.js CHANGED
@@ -24,7 +24,10 @@ const SLASH_COMMANDS = [
24
24
  { cmd: "/settings", desc: "Open interactive Settings panel (Ctrl+,)" },
25
25
  { cmd: "/set", desc: "Update persisted setting (/set <key> <val>)", hasArg: true },
26
26
  { cmd: "/api", desc: "Switch/add OpenAI or Anthropic custom APIs" },
27
- { cmd: "/model", desc: "Pick or switch active model (/model [name])" },
27
+ { cmd: "/model", desc: "Pick or switch active model & reasoning (/model [name])" },
28
+ { cmd: "/reasoning", desc: "Select reasoning effort (off|low|medium|high)" },
29
+ { cmd: "/skills", desc: "Manage stored markdown skills (list|add|show|rm)", hasArg: true },
30
+ { cmd: "/browser", desc: "Check/install/close headless Playwright browser runtime", hasArg: true },
28
31
  { cmd: "/sessions", desc: "Session picker / manage (list|new|switch|delete) (Ctrl+S)" },
29
32
  { cmd: "/new", desc: "Open a new isolated session (Ctrl+N)" },
30
33
  { cmd: "/retry", desc: "Retry the last failed/aborted user turn" },
@@ -76,6 +79,24 @@ const SUBCOMMAND_HINTS = {
76
79
  { fill: "/memory global rm ", desc: "Remove global memory item" },
77
80
  { fill: "/memory global clear", desc: "Clear all global memory" },
78
81
  ],
82
+ "/reasoning": [
83
+ { fill: "/reasoning off", desc: "Disable extended reasoning/thinking budget" },
84
+ { fill: "/reasoning low", desc: "Light reasoning effort" },
85
+ { fill: "/reasoning medium", desc: "Balanced reasoning effort" },
86
+ { fill: "/reasoning high", desc: "Deep reasoning effort" },
87
+ ],
88
+ "/skills": [
89
+ { fill: "/skills list", desc: "List all saved markdown skills" },
90
+ { fill: "/skills add ", desc: "<file.md> [--project] Save a markdown skill" },
91
+ { fill: "/skills new ", desc: "[title] Create a new skill interactively" },
92
+ { fill: "/skills show ", desc: "<name> View stored skill details" },
93
+ { fill: "/skills rm ", desc: "<name> Remove a stored skill" },
94
+ ],
95
+ "/browser": [
96
+ { fill: "/browser status", desc: "Show Playwright runtime & browser executable status" },
97
+ { fill: "/browser install", desc: "Pre-install isolated playwright-core (+ Chromium if needed)" },
98
+ { fill: "/browser close", desc: "Close active headless browser session" },
99
+ ],
79
100
  "/set": [
80
101
  { fill: "/set agentMode ", desc: "default | accept-edits | plan | auto" },
81
102
  { fill: "/set toolPermission ", desc: "ask | allow-reads | allow-edits | always-proceed" },