prior-cli 1.5.5 → 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 +21 -5
- 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);
|
|
@@ -1080,9 +1092,7 @@ Be concise but thorough — this summary replaces the full history to save conte
|
|
|
1080
1092
|
},
|
|
1081
1093
|
];
|
|
1082
1094
|
|
|
1083
|
-
const
|
|
1084
|
-
// infer is not exported — call backend directly
|
|
1085
|
-
const token = require('./lib/config').getToken();
|
|
1095
|
+
const token = require('../lib/config').getToken();
|
|
1086
1096
|
const res = await fetch('https://prior.ngrok.app/cli-backend/api/infer', {
|
|
1087
1097
|
method: 'POST',
|
|
1088
1098
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -1263,9 +1273,15 @@ Be concise but thorough — this summary replaces the full history to save conte
|
|
|
1263
1273
|
break;
|
|
1264
1274
|
}
|
|
1265
1275
|
|
|
1266
|
-
case 'done':
|
|
1276
|
+
case 'done': {
|
|
1267
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
|
+
}
|
|
1268
1283
|
break;
|
|
1284
|
+
}
|
|
1269
1285
|
|
|
1270
1286
|
case 'error':
|
|
1271
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
|
|