prior-cli 1.7.1 → 1.7.3

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.
Files changed (2) hide show
  1. package/bin/prior.js +113 -2
  2. 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 /update /compact /timer /save /load /saves /delete /exit'));
848
848
  console.log(DIVIDER);
849
849
  console.log('');
850
850
 
@@ -861,11 +861,13 @@ async function startChat(opts = {}) {
861
861
  readline.emitKeypressEvents(process.stdin, rl);
862
862
 
863
863
  const SLASH_CMDS = [
864
+ { cmd: '/update', desc: 'Check for updates and install if available' },
864
865
  { cmd: '/compact', desc: 'Compact conversation to save context' },
865
866
  { cmd: '/timer', desc: 'Set a countdown timer e.g. /timer 30s' },
866
867
  { cmd: '/saves', desc: 'List all saved conversations' },
867
868
  { cmd: '/save', desc: 'Save current conversation e.g. /save my session' },
868
869
  { cmd: '/load', desc: 'Load a saved conversation' },
870
+ { cmd: '/delete', desc: 'Delete a saved conversation' },
869
871
  { cmd: '/help', desc: 'Show help' },
870
872
  { cmd: '/clear', desc: 'Clear screen' },
871
873
  { cmd: '/censored', desc: 'Load standard model (qwen)' },
@@ -1062,7 +1064,79 @@ async function startChat(opts = {}) {
1062
1064
  console.log(num + name + meta);
1063
1065
  });
1064
1066
  console.log(DIVIDER);
1065
- console.log(c.muted(' Use /load <name> or /load <number> to restore\n'));
1067
+ console.log(c.muted(' /load <name|#> · /delete <name|#>\n'));
1068
+ }
1069
+ return loop();
1070
+ }
1071
+
1072
+ case '/delete': {
1073
+ const saves = listSaves(user);
1074
+ if (saves.length === 0) {
1075
+ console.log(c.muted('\n No saved conversations to delete.\n'));
1076
+ return loop();
1077
+ }
1078
+
1079
+ let target = null;
1080
+ const query = args.join(' ').trim();
1081
+
1082
+ if (query) {
1083
+ const num = parseInt(query, 10);
1084
+ if (!isNaN(num) && num >= 1 && num <= saves.length) {
1085
+ target = saves[num - 1];
1086
+ } else {
1087
+ const q = query.toLowerCase();
1088
+ target = saves.find(s => sanitizeName(s.name) === sanitizeName(query))
1089
+ || saves.find(s => s.name.toLowerCase().includes(q));
1090
+ }
1091
+ if (!target) {
1092
+ console.log(c.err(` No save found matching "${query}"\n`));
1093
+ return loop();
1094
+ }
1095
+ } else {
1096
+ // Show list and ask
1097
+ console.log('');
1098
+ console.log(c.bold(' Delete a conversation:'));
1099
+ console.log(DIVIDER);
1100
+ saves.forEach((s, i) => {
1101
+ const num = c.brand(` ${String(i + 1).padStart(2)}. `);
1102
+ const name = c.white(s.name.padEnd(28));
1103
+ const meta = c.muted(`${s.msgCount} msgs · ${new Date(s.savedAt).toLocaleDateString('en-PH', { month: 'short', day: 'numeric', year: 'numeric' })}`);
1104
+ console.log(num + name + meta);
1105
+ });
1106
+ console.log(DIVIDER);
1107
+ const answer = await new Promise(res => rl.question(c.muted(' Enter number or name (Enter to cancel): '), res));
1108
+ const trimmed = (answer || '').trim();
1109
+ if (!trimmed) {
1110
+ console.log(c.muted(' Cancelled.\n'));
1111
+ return loop();
1112
+ }
1113
+ const n = parseInt(trimmed, 10);
1114
+ if (!isNaN(n) && n >= 1 && n <= saves.length) {
1115
+ target = saves[n - 1];
1116
+ } else {
1117
+ const q = trimmed.toLowerCase();
1118
+ target = saves.find(s => sanitizeName(s.name) === sanitizeName(trimmed))
1119
+ || saves.find(s => s.name.toLowerCase().includes(q));
1120
+ }
1121
+ if (!target) {
1122
+ console.log(c.err(` No save found matching "${trimmed}"\n`));
1123
+ return loop();
1124
+ }
1125
+ }
1126
+
1127
+ // Confirm
1128
+ const confirm = await new Promise(res => rl.question(c.warn(` Delete "${target.name}"? [y/N] `), res));
1129
+ if ((confirm || '').trim().toLowerCase() !== 'y') {
1130
+ console.log(c.muted(' Cancelled.\n'));
1131
+ return loop();
1132
+ }
1133
+
1134
+ try {
1135
+ const filePath = path.join(savesDir(user), sanitizeName(target.name) + '.json');
1136
+ fs.unlinkSync(filePath);
1137
+ console.log(c.ok(` ✓ Deleted "${target.name}"\n`));
1138
+ } catch (err) {
1139
+ console.log(c.err(` Failed to delete: ${err.message}\n`));
1066
1140
  }
1067
1141
  return loop();
1068
1142
  }
@@ -1330,6 +1404,41 @@ Keep it under 350 words. Write prior.md now.`;
1330
1404
  return loop();
1331
1405
  }
1332
1406
 
1407
+ case '/update': {
1408
+ console.log('');
1409
+ process.stdout.write(c.dim(' Checking for updates…'));
1410
+ const _fetch = require('node-fetch');
1411
+ let _latest;
1412
+ try {
1413
+ const _res = await _fetch('https://registry.npmjs.org/prior-cli/latest', { timeout: 8000 });
1414
+ if (!_res.ok) throw new Error(`HTTP ${_res.status}`);
1415
+ _latest = (await _res.json()).version;
1416
+ } catch (err) {
1417
+ process.stdout.clearLine(0); process.stdout.cursorTo(0);
1418
+ console.log(c.err(` ✗ Could not reach npm registry: ${err.message}\n`));
1419
+ return loop();
1420
+ }
1421
+ process.stdout.clearLine(0); process.stdout.cursorTo(0);
1422
+ if (_latest === version) {
1423
+ console.log(c.ok(' ✓ Already up to date ') + c.muted(`v${version}\n`));
1424
+ return loop();
1425
+ }
1426
+ console.log(` ${c.muted('Current :')} ${c.white(`v${version}`)}`);
1427
+ console.log(` ${c.muted('Latest :')} ${c.bold(`v${_latest}`)}`);
1428
+ console.log('');
1429
+ process.stdout.write(c.dim(' Installing update…'));
1430
+ try {
1431
+ require('child_process').execSync('npm install -g prior-cli@latest', { stdio: 'ignore' });
1432
+ process.stdout.clearLine(0); process.stdout.cursorTo(0);
1433
+ console.log(c.ok(` ✓ Updated to v${_latest} `) + c.muted('restart prior to apply\n'));
1434
+ } catch (err) {
1435
+ process.stdout.clearLine(0); process.stdout.cursorTo(0);
1436
+ console.log(c.err(` ✗ Install failed: ${err.message}`));
1437
+ console.log(c.muted(' Try manually: npm install -g prior-cli@latest\n'));
1438
+ }
1439
+ return loop();
1440
+ }
1441
+
1333
1442
  case '/compact': {
1334
1443
  if (chatHistory.length === 0) {
1335
1444
  console.log(c.muted(' Nothing to compact yet.\n'));
@@ -1475,11 +1584,13 @@ Be concise but thorough — this summary replaces the full history to save conte
1475
1584
  case '/help':
1476
1585
  console.log('');
1477
1586
  console.log(c.bold(' Commands'));
1587
+ console.log(c.muted(' /update ') + 'Check for updates and install if available');
1478
1588
  console.log(c.muted(' /compact ') + 'Compact conversation to save context');
1479
1589
  console.log(c.muted(' /timer <duration> ') + 'Countdown timer e.g. /timer 30s, /timer 5m');
1480
1590
  console.log(c.muted(' /saves ') + 'List all saved conversations');
1481
1591
  console.log(c.muted(' /save <name> ') + 'Save current conversation');
1482
1592
  console.log(c.muted(' /load [name|number] ') + 'Load a saved conversation (picker if no arg)');
1593
+ console.log(c.muted(' /delete [name|number]') + 'Delete a saved conversation');
1483
1594
  console.log(c.muted(' /clear ') + 'Clear screen');
1484
1595
  console.log(c.muted(' /censored ') + 'Load standard model (qwen)');
1485
1596
  console.log(c.muted(' /uncensored ') + 'Load uncensored model (dolphin)');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prior-cli",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "Prior Network AI — command-line interface",
5
5
  "bin": {
6
6
  "prior": "bin/prior.js"