prior-cli 1.5.6 → 1.5.8
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 +38 -2
- package/lib/agent.js +1 -1
- package/package.json +1 -1
package/bin/prior.js
CHANGED
|
@@ -42,19 +42,49 @@ const DIVIDER = c.muted(' ' + '─'.repeat(50));
|
|
|
42
42
|
const SPIN_FRAMES = ['◐', '◓', '◑', '◒'];
|
|
43
43
|
let _spinTimer = null;
|
|
44
44
|
let _spinIdx = 0;
|
|
45
|
+
let _spinStart = null;
|
|
46
|
+
let _spinLabel = '';
|
|
47
|
+
|
|
48
|
+
function fmtElapsed(ms) {
|
|
49
|
+
const s = Math.floor(ms / 1000);
|
|
50
|
+
if (s < 60) return `${s}s`;
|
|
51
|
+
return `${Math.floor(s / 60)}m ${s % 60}s`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const THINK_LABELS = [
|
|
55
|
+
'thinking…',
|
|
56
|
+
'prioring…',
|
|
57
|
+
'processing…',
|
|
58
|
+
'reasoning…',
|
|
59
|
+
'cooking…',
|
|
60
|
+
'figuring it out…',
|
|
61
|
+
'on it…',
|
|
62
|
+
'analyzing…',
|
|
63
|
+
];
|
|
45
64
|
|
|
46
65
|
function spinStart(label = '') {
|
|
47
66
|
spinStop();
|
|
48
67
|
if (!process.stdout.isTTY) return;
|
|
68
|
+
_spinLabel = label;
|
|
69
|
+
_spinStart = Date.now();
|
|
70
|
+
let labelIdx = 0;
|
|
49
71
|
_spinTimer = setInterval(() => {
|
|
50
72
|
process.stdout.clearLine(0);
|
|
51
73
|
process.stdout.cursorTo(0);
|
|
52
|
-
|
|
74
|
+
const ms = Date.now() - _spinStart;
|
|
75
|
+
// Cycle through think labels every 4s only when in thinking mode
|
|
76
|
+
if (_spinLabel === 'thinking…') {
|
|
77
|
+
labelIdx = Math.floor(ms / 4000) % THINK_LABELS.length;
|
|
78
|
+
}
|
|
79
|
+
const displayLabel = _spinLabel === 'thinking…' ? THINK_LABELS[labelIdx] : _spinLabel;
|
|
80
|
+
const elapsedStr = ` ${c.dim('(' + fmtElapsed(ms) + ')')}`;
|
|
81
|
+
process.stdout.write(` ${c.brand(SPIN_FRAMES[_spinIdx++ % 4])} ${c.dim(displayLabel)}${elapsedStr}`);
|
|
53
82
|
}, 100);
|
|
54
83
|
}
|
|
55
84
|
|
|
56
85
|
function spinStop() {
|
|
57
86
|
if (_spinTimer) { clearInterval(_spinTimer); _spinTimer = null; }
|
|
87
|
+
_spinStart = null;
|
|
58
88
|
if (process.stdout.isTTY) {
|
|
59
89
|
process.stdout.clearLine(0);
|
|
60
90
|
process.stdout.cursorTo(0);
|
|
@@ -1261,9 +1291,15 @@ Be concise but thorough — this summary replaces the full history to save conte
|
|
|
1261
1291
|
break;
|
|
1262
1292
|
}
|
|
1263
1293
|
|
|
1264
|
-
case 'done':
|
|
1294
|
+
case 'done': {
|
|
1265
1295
|
spinStop();
|
|
1296
|
+
const pt = ev.promptTokens || 0;
|
|
1297
|
+
const ct = ev.completionTokens || 0;
|
|
1298
|
+
if (pt || ct) {
|
|
1299
|
+
process.stdout.write(c.dim(` ◦ ${pt.toLocaleString()} in · ${ct.toLocaleString()} out · ${(pt + ct).toLocaleString()} total\n`));
|
|
1300
|
+
}
|
|
1266
1301
|
break;
|
|
1302
|
+
}
|
|
1267
1303
|
|
|
1268
1304
|
case 'error':
|
|
1269
1305
|
spinStop();
|
package/lib/agent.js
CHANGED
|
@@ -262,7 +262,7 @@ async function runAgent({ messages, model, uncensored, cwd, projectContext, imag
|
|
|
262
262
|
}
|
|
263
263
|
await trackTokenUsage(token, totalPromptTokens, totalCompletionTokens);
|
|
264
264
|
send({ type: 'text', content: finalText });
|
|
265
|
-
send({ type: 'done' });
|
|
265
|
+
send({ type: 'done', promptTokens: totalPromptTokens, completionTokens: totalCompletionTokens });
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
268
|
|