prior-cli 1.7.0 → 1.7.2
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/prior.js +105 -8
- package/package.json +1 -1
package/bin/prior.js
CHANGED
|
@@ -844,7 +844,7 @@ async function startChat(opts = {}) {
|
|
|
844
844
|
console.log(c.ok(' ◉') + c.muted(' Agent mode ') + c.dim('· file web shell image prior-network'));
|
|
845
845
|
|
|
846
846
|
console.log(DIVIDER);
|
|
847
|
-
console.log(c.muted(' /help /clear /compact /timer /save /load /saves /exit'));
|
|
847
|
+
console.log(c.muted(' /help /clear /compact /timer /save /load /saves /delete /exit'));
|
|
848
848
|
console.log(DIVIDER);
|
|
849
849
|
console.log('');
|
|
850
850
|
|
|
@@ -866,6 +866,7 @@ async function startChat(opts = {}) {
|
|
|
866
866
|
{ cmd: '/saves', desc: 'List all saved conversations' },
|
|
867
867
|
{ cmd: '/save', desc: 'Save current conversation e.g. /save my session' },
|
|
868
868
|
{ cmd: '/load', desc: 'Load a saved conversation' },
|
|
869
|
+
{ cmd: '/delete', desc: 'Delete a saved conversation' },
|
|
869
870
|
{ cmd: '/help', desc: 'Show help' },
|
|
870
871
|
{ cmd: '/clear', desc: 'Clear screen' },
|
|
871
872
|
{ cmd: '/censored', desc: 'Load standard model (qwen)' },
|
|
@@ -1062,7 +1063,79 @@ async function startChat(opts = {}) {
|
|
|
1062
1063
|
console.log(num + name + meta);
|
|
1063
1064
|
});
|
|
1064
1065
|
console.log(DIVIDER);
|
|
1065
|
-
console.log(c.muted('
|
|
1066
|
+
console.log(c.muted(' /load <name|#> · /delete <name|#>\n'));
|
|
1067
|
+
}
|
|
1068
|
+
return loop();
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
case '/delete': {
|
|
1072
|
+
const saves = listSaves(user);
|
|
1073
|
+
if (saves.length === 0) {
|
|
1074
|
+
console.log(c.muted('\n No saved conversations to delete.\n'));
|
|
1075
|
+
return loop();
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
let target = null;
|
|
1079
|
+
const query = args.join(' ').trim();
|
|
1080
|
+
|
|
1081
|
+
if (query) {
|
|
1082
|
+
const num = parseInt(query, 10);
|
|
1083
|
+
if (!isNaN(num) && num >= 1 && num <= saves.length) {
|
|
1084
|
+
target = saves[num - 1];
|
|
1085
|
+
} else {
|
|
1086
|
+
const q = query.toLowerCase();
|
|
1087
|
+
target = saves.find(s => sanitizeName(s.name) === sanitizeName(query))
|
|
1088
|
+
|| saves.find(s => s.name.toLowerCase().includes(q));
|
|
1089
|
+
}
|
|
1090
|
+
if (!target) {
|
|
1091
|
+
console.log(c.err(` No save found matching "${query}"\n`));
|
|
1092
|
+
return loop();
|
|
1093
|
+
}
|
|
1094
|
+
} else {
|
|
1095
|
+
// Show list and ask
|
|
1096
|
+
console.log('');
|
|
1097
|
+
console.log(c.bold(' Delete a conversation:'));
|
|
1098
|
+
console.log(DIVIDER);
|
|
1099
|
+
saves.forEach((s, i) => {
|
|
1100
|
+
const num = c.brand(` ${String(i + 1).padStart(2)}. `);
|
|
1101
|
+
const name = c.white(s.name.padEnd(28));
|
|
1102
|
+
const meta = c.muted(`${s.msgCount} msgs · ${new Date(s.savedAt).toLocaleDateString('en-PH', { month: 'short', day: 'numeric', year: 'numeric' })}`);
|
|
1103
|
+
console.log(num + name + meta);
|
|
1104
|
+
});
|
|
1105
|
+
console.log(DIVIDER);
|
|
1106
|
+
const answer = await new Promise(res => rl.question(c.muted(' Enter number or name (Enter to cancel): '), res));
|
|
1107
|
+
const trimmed = (answer || '').trim();
|
|
1108
|
+
if (!trimmed) {
|
|
1109
|
+
console.log(c.muted(' Cancelled.\n'));
|
|
1110
|
+
return loop();
|
|
1111
|
+
}
|
|
1112
|
+
const n = parseInt(trimmed, 10);
|
|
1113
|
+
if (!isNaN(n) && n >= 1 && n <= saves.length) {
|
|
1114
|
+
target = saves[n - 1];
|
|
1115
|
+
} else {
|
|
1116
|
+
const q = trimmed.toLowerCase();
|
|
1117
|
+
target = saves.find(s => sanitizeName(s.name) === sanitizeName(trimmed))
|
|
1118
|
+
|| saves.find(s => s.name.toLowerCase().includes(q));
|
|
1119
|
+
}
|
|
1120
|
+
if (!target) {
|
|
1121
|
+
console.log(c.err(` No save found matching "${trimmed}"\n`));
|
|
1122
|
+
return loop();
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
// Confirm
|
|
1127
|
+
const confirm = await new Promise(res => rl.question(c.warn(` Delete "${target.name}"? [y/N] `), res));
|
|
1128
|
+
if ((confirm || '').trim().toLowerCase() !== 'y') {
|
|
1129
|
+
console.log(c.muted(' Cancelled.\n'));
|
|
1130
|
+
return loop();
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
try {
|
|
1134
|
+
const filePath = path.join(savesDir(user), sanitizeName(target.name) + '.json');
|
|
1135
|
+
fs.unlinkSync(filePath);
|
|
1136
|
+
console.log(c.ok(` ✓ Deleted "${target.name}"\n`));
|
|
1137
|
+
} catch (err) {
|
|
1138
|
+
console.log(c.err(` Failed to delete: ${err.message}\n`));
|
|
1066
1139
|
}
|
|
1067
1140
|
return loop();
|
|
1068
1141
|
}
|
|
@@ -1079,7 +1152,9 @@ async function startChat(opts = {}) {
|
|
|
1079
1152
|
}
|
|
1080
1153
|
try {
|
|
1081
1154
|
writeSession(user, saveName, chatHistory, currentModel);
|
|
1082
|
-
|
|
1155
|
+
const savedPath = path.join(savesDir(user), sanitizeName(saveName) + '.json');
|
|
1156
|
+
console.log(c.ok(` ✓ Saved "${saveName}"`) + c.muted(` · ${chatHistory.length} messages`));
|
|
1157
|
+
console.log(c.muted(` ${savedPath}\n`));
|
|
1083
1158
|
} catch (err) {
|
|
1084
1159
|
console.log(c.err(` Failed to save: ${err.message}\n`));
|
|
1085
1160
|
}
|
|
@@ -1089,7 +1164,7 @@ async function startChat(opts = {}) {
|
|
|
1089
1164
|
case '/load': {
|
|
1090
1165
|
const saves = listSaves(user);
|
|
1091
1166
|
if (saves.length === 0) {
|
|
1092
|
-
console.log(c.muted('\n No saved conversations yet.\n'));
|
|
1167
|
+
console.log(c.muted('\n No saved conversations yet. Use /save <name> to create one.\n'));
|
|
1093
1168
|
return loop();
|
|
1094
1169
|
}
|
|
1095
1170
|
|
|
@@ -1102,7 +1177,6 @@ async function startChat(opts = {}) {
|
|
|
1102
1177
|
if (!isNaN(num) && num >= 1 && num <= saves.length) {
|
|
1103
1178
|
chosen = saves[num - 1];
|
|
1104
1179
|
} else {
|
|
1105
|
-
// fuzzy name match
|
|
1106
1180
|
const q = query.toLowerCase();
|
|
1107
1181
|
chosen = saves.find(s => sanitizeName(s.name) === sanitizeName(query))
|
|
1108
1182
|
|| saves.find(s => s.name.toLowerCase().includes(q));
|
|
@@ -1112,14 +1186,36 @@ async function startChat(opts = {}) {
|
|
|
1112
1186
|
return loop();
|
|
1113
1187
|
}
|
|
1114
1188
|
} else {
|
|
1115
|
-
//
|
|
1189
|
+
// Numbered list prompt — reliable across all terminals
|
|
1116
1190
|
console.log('');
|
|
1117
1191
|
console.log(c.bold(' Load a conversation:'));
|
|
1118
|
-
|
|
1119
|
-
|
|
1192
|
+
console.log(DIVIDER);
|
|
1193
|
+
saves.forEach((s, i) => {
|
|
1194
|
+
const num = c.brand(` ${String(i + 1).padStart(2)}. `);
|
|
1195
|
+
const name = c.white(s.name.padEnd(28));
|
|
1196
|
+
const meta = c.muted(`${s.msgCount} msgs · ${new Date(s.savedAt).toLocaleDateString('en-PH', { month: 'short', day: 'numeric', year: 'numeric' })}`);
|
|
1197
|
+
console.log(num + name + meta);
|
|
1198
|
+
});
|
|
1199
|
+
console.log(DIVIDER);
|
|
1200
|
+
|
|
1201
|
+
const answer = await new Promise(res => rl.question(c.muted(' Enter number or name (Esc to cancel): '), res));
|
|
1202
|
+
const trimmed = (answer || '').trim();
|
|
1203
|
+
if (!trimmed) {
|
|
1120
1204
|
console.log(c.muted(' Cancelled.\n'));
|
|
1121
1205
|
return loop();
|
|
1122
1206
|
}
|
|
1207
|
+
const n = parseInt(trimmed, 10);
|
|
1208
|
+
if (!isNaN(n) && n >= 1 && n <= saves.length) {
|
|
1209
|
+
chosen = saves[n - 1];
|
|
1210
|
+
} else {
|
|
1211
|
+
const q = trimmed.toLowerCase();
|
|
1212
|
+
chosen = saves.find(s => sanitizeName(s.name) === sanitizeName(trimmed))
|
|
1213
|
+
|| saves.find(s => s.name.toLowerCase().includes(q));
|
|
1214
|
+
}
|
|
1215
|
+
if (!chosen) {
|
|
1216
|
+
console.log(c.err(` No save found matching "${trimmed}"\n`));
|
|
1217
|
+
return loop();
|
|
1218
|
+
}
|
|
1123
1219
|
}
|
|
1124
1220
|
|
|
1125
1221
|
// Load it
|
|
@@ -1457,6 +1553,7 @@ Be concise but thorough — this summary replaces the full history to save conte
|
|
|
1457
1553
|
console.log(c.muted(' /saves ') + 'List all saved conversations');
|
|
1458
1554
|
console.log(c.muted(' /save <name> ') + 'Save current conversation');
|
|
1459
1555
|
console.log(c.muted(' /load [name|number] ') + 'Load a saved conversation (picker if no arg)');
|
|
1556
|
+
console.log(c.muted(' /delete [name|number]') + 'Delete a saved conversation');
|
|
1460
1557
|
console.log(c.muted(' /clear ') + 'Clear screen');
|
|
1461
1558
|
console.log(c.muted(' /censored ') + 'Load standard model (qwen)');
|
|
1462
1559
|
console.log(c.muted(' /uncensored ') + 'Load uncensored model (dolphin)');
|