0agent 1.0.47 → 1.0.48
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/bin/chat.js +30 -24
- package/package.json +1 -1
package/bin/chat.js
CHANGED
|
@@ -1002,51 +1002,55 @@ async function openPalette(initialFilter = '') {
|
|
|
1002
1002
|
|
|
1003
1003
|
let filter = initialFilter.toLowerCase();
|
|
1004
1004
|
let idx = 0;
|
|
1005
|
-
let
|
|
1005
|
+
let scroll = 0; // top of the visible window
|
|
1006
|
+
let drawn = 0;
|
|
1007
|
+
const PAGE = 10; // visible rows at once
|
|
1006
1008
|
|
|
1007
1009
|
const getItems = () => SLASH_COMMANDS.filter(c =>
|
|
1008
1010
|
!filter || c.cmd.slice(1).startsWith(filter)
|
|
1009
1011
|
);
|
|
1010
1012
|
|
|
1011
1013
|
const paint = () => {
|
|
1012
|
-
// Erase previous draw: move up `drawn` lines, clear everything below
|
|
1013
1014
|
if (drawn > 0) process.stdout.write(`\x1b[${drawn}A\x1b[0J`);
|
|
1014
1015
|
|
|
1015
|
-
const items
|
|
1016
|
-
|
|
1017
|
-
|
|
1016
|
+
const items = getItems();
|
|
1017
|
+
if (items.length === 0) { idx = 0; scroll = 0; }
|
|
1018
|
+
else {
|
|
1019
|
+
idx = Math.max(0, Math.min(idx, items.length - 1));
|
|
1020
|
+
// Keep selected item inside the visible window
|
|
1021
|
+
if (idx < scroll) scroll = idx;
|
|
1022
|
+
if (idx >= scroll + PAGE) scroll = idx - PAGE + 1;
|
|
1023
|
+
}
|
|
1018
1024
|
|
|
1025
|
+
const show = items.slice(scroll, scroll + PAGE);
|
|
1019
1026
|
const lines = [];
|
|
1020
1027
|
|
|
1021
|
-
// Top border
|
|
1022
1028
|
lines.push(` \x1b[2m${'─'.repeat(58)}\x1b[0m`);
|
|
1023
1029
|
|
|
1024
|
-
if (
|
|
1030
|
+
if (items.length === 0) {
|
|
1025
1031
|
lines.push(` \x1b[2m no commands match "/${filter}"\x1b[0m`);
|
|
1026
1032
|
} else {
|
|
1027
1033
|
for (let i = 0; i < show.length; i++) {
|
|
1028
1034
|
const m = show[i];
|
|
1029
|
-
const sel = i === idx;
|
|
1035
|
+
const sel = (scroll + i) === idx;
|
|
1030
1036
|
if (sel) {
|
|
1031
|
-
lines.push(
|
|
1032
|
-
` \x1b[36;1m›\x1b[0m \x1b[36;1m${m.cmd.padEnd(22)}\x1b[0m \x1b[0m${m.desc}\x1b[0m`
|
|
1033
|
-
);
|
|
1037
|
+
lines.push(` \x1b[36;1m›\x1b[0m \x1b[36;1m${m.cmd.padEnd(22)}\x1b[0m ${m.desc}`);
|
|
1034
1038
|
} else {
|
|
1035
|
-
lines.push(
|
|
1036
|
-
` \x1b[36m${m.cmd.padEnd(22)}\x1b[0m \x1b[2m${m.desc}\x1b[0m`
|
|
1037
|
-
);
|
|
1039
|
+
lines.push(` \x1b[36m${m.cmd.padEnd(22)}\x1b[0m \x1b[2m${m.desc}\x1b[0m`);
|
|
1038
1040
|
}
|
|
1039
1041
|
}
|
|
1040
1042
|
}
|
|
1041
1043
|
|
|
1042
|
-
|
|
1044
|
+
// Scroll indicator
|
|
1045
|
+
if (items.length > PAGE) {
|
|
1046
|
+
const pct = Math.round(((scroll + PAGE / 2) / items.length) * 100);
|
|
1047
|
+
lines.push(` \x1b[2m ${idx + 1} / ${items.length} (${pct}%)\x1b[0m`);
|
|
1048
|
+
}
|
|
1043
1049
|
|
|
1044
|
-
// Bottom: search input line
|
|
1045
1050
|
lines.push(` \x1b[2m${'─'.repeat(58)}\x1b[0m`);
|
|
1046
|
-
lines.push(` ${fmt(C.cyan, '/')}${filter}\x1b[K \x1b[2m↑↓
|
|
1051
|
+
lines.push(` ${fmt(C.cyan, '/')}${filter}\x1b[K \x1b[2m↑↓ scroll · Enter select · Esc cancel\x1b[0m`);
|
|
1047
1052
|
|
|
1048
|
-
|
|
1049
|
-
process.stdout.write(out);
|
|
1053
|
+
process.stdout.write(lines.join('\n') + '\n');
|
|
1050
1054
|
drawn = lines.length;
|
|
1051
1055
|
};
|
|
1052
1056
|
|
|
@@ -1069,11 +1073,11 @@ async function openPalette(initialFilter = '') {
|
|
|
1069
1073
|
paint();
|
|
1070
1074
|
} else if (s === '\x7f' || s === '\x08') { // Backspace
|
|
1071
1075
|
filter = filter.slice(0, -1);
|
|
1072
|
-
idx = 0;
|
|
1076
|
+
idx = 0; scroll = 0;
|
|
1073
1077
|
paint();
|
|
1074
1078
|
} else if (/^[a-z0-9\-_]$/i.test(s)) { // Printable letter/digit/hyphen
|
|
1075
1079
|
filter += s.toLowerCase();
|
|
1076
|
-
idx = 0;
|
|
1080
|
+
idx = 0; scroll = 0;
|
|
1077
1081
|
paint();
|
|
1078
1082
|
}
|
|
1079
1083
|
};
|
|
@@ -1410,17 +1414,19 @@ function isNewerVersion(a, b) {
|
|
|
1410
1414
|
|
|
1411
1415
|
// ─── Message queue + serial executor ─────────────────────────────────────────
|
|
1412
1416
|
|
|
1413
|
-
|
|
1417
|
+
// Only these exact prefixes are built-in commands handled by handleCommand().
|
|
1418
|
+
// Everything else starting with '/' is a skill → routed to runTask().
|
|
1419
|
+
const COMMAND_PREFIXES = ['/model','/key','/status','/skills','/graph','/clear',
|
|
1420
|
+
'/help','/schedule','/update','/telegram'];
|
|
1414
1421
|
|
|
1415
1422
|
async function executeInput(line) {
|
|
1416
|
-
const isCmd =
|
|
1423
|
+
const isCmd = COMMAND_PREFIXES.some(c => line === c || line.startsWith(c + ' '));
|
|
1417
1424
|
if (isCmd) {
|
|
1418
1425
|
await handleCommand(line);
|
|
1419
1426
|
} else {
|
|
1420
1427
|
lastFailedTask = null;
|
|
1421
1428
|
await runTask(line);
|
|
1422
1429
|
}
|
|
1423
|
-
// After this input completes, drain the queue
|
|
1424
1430
|
await drainQueue();
|
|
1425
1431
|
}
|
|
1426
1432
|
|