prior-cli 1.5.6 → 1.5.7
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 +20 -2
- package/lib/agent.js +1 -1
- package/package.json +1 -1
package/bin/prior.js
CHANGED
|
@@ -42,19 +42,31 @@ 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
|
+
}
|
|
45
53
|
|
|
46
54
|
function spinStart(label = '') {
|
|
47
55
|
spinStop();
|
|
48
56
|
if (!process.stdout.isTTY) return;
|
|
57
|
+
_spinLabel = label;
|
|
58
|
+
_spinStart = Date.now();
|
|
49
59
|
_spinTimer = setInterval(() => {
|
|
50
60
|
process.stdout.clearLine(0);
|
|
51
61
|
process.stdout.cursorTo(0);
|
|
52
|
-
|
|
62
|
+
const elapsed = _spinStart ? ` ${c.dim('(' + fmtElapsed(Date.now() - _spinStart) + ')')}` : '';
|
|
63
|
+
process.stdout.write(` ${c.brand(SPIN_FRAMES[_spinIdx++ % 4])} ${c.dim(_spinLabel)}${elapsed}`);
|
|
53
64
|
}, 100);
|
|
54
65
|
}
|
|
55
66
|
|
|
56
67
|
function spinStop() {
|
|
57
68
|
if (_spinTimer) { clearInterval(_spinTimer); _spinTimer = null; }
|
|
69
|
+
_spinStart = null;
|
|
58
70
|
if (process.stdout.isTTY) {
|
|
59
71
|
process.stdout.clearLine(0);
|
|
60
72
|
process.stdout.cursorTo(0);
|
|
@@ -1261,9 +1273,15 @@ Be concise but thorough — this summary replaces the full history to save conte
|
|
|
1261
1273
|
break;
|
|
1262
1274
|
}
|
|
1263
1275
|
|
|
1264
|
-
case 'done':
|
|
1276
|
+
case 'done': {
|
|
1265
1277
|
spinStop();
|
|
1278
|
+
const pt = ev.promptTokens || 0;
|
|
1279
|
+
const ct = ev.completionTokens || 0;
|
|
1280
|
+
if (pt || ct) {
|
|
1281
|
+
process.stdout.write(c.dim(` ◦ ${pt.toLocaleString()} in · ${ct.toLocaleString()} out · ${(pt + ct).toLocaleString()} total\n`));
|
|
1282
|
+
}
|
|
1266
1283
|
break;
|
|
1284
|
+
}
|
|
1267
1285
|
|
|
1268
1286
|
case 'error':
|
|
1269
1287
|
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
|
|