terminal-smart-cli 0.83.0 → 0.84.0
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/ts.js +25 -3
- package/lib/agent.js +2 -1
- package/package.json +1 -1
package/bin/ts.js
CHANGED
|
@@ -883,12 +883,30 @@ async function agentCmd(words, { askFn, cwd: cwdIn = null, onCwd = null } = {})
|
|
|
883
883
|
const sp = (streamJson || _noTTY) ? { text() {}, start() {}, stop() {} } : ui.spinner(T.agent_thinking).start();
|
|
884
884
|
if (_noTTY && !streamJson) console.log(' ' + C.dim(T.agent_thinking));
|
|
885
885
|
const t0 = Date.now();
|
|
886
|
+
// STATUS LINE ao vivo (estilo Claude/Verboo): tempo · modelo · tokens · passo — atualiza a cada 1s.
|
|
887
|
+
const _live = { steps: 0, inTok: 0, outTok: 0, model: model || 'auto' };
|
|
888
|
+
const _fmtTime = (ms) => { const s = Math.floor(ms / 1000), m = Math.floor(s / 60); return m > 0 ? `${m}m${String(s % 60).padStart(2, '0')}s` : `${s}s`; };
|
|
889
|
+
const _fmtTok = (n) => n >= 1000 ? (n / 1000).toFixed(1).replace('.0', '') + 'k' : String(n);
|
|
890
|
+
const _statusLine = () => {
|
|
891
|
+
const tok = _live.inTok + _live.outTok;
|
|
892
|
+
const parts = [_fmtTime(Date.now() - t0), String(_live.model).slice(0, 22)];
|
|
893
|
+
if (tok > 0) parts.push('↓ ' + _fmtTok(tok) + ' tok');
|
|
894
|
+
if (_live.steps > 0) parts.push('passo ' + _live.steps);
|
|
895
|
+
return T.agent_thinking + ' · ' + parts.join(' · '); // texto puro; o spinner aplica a cor
|
|
896
|
+
};
|
|
897
|
+
const _liveTimer = (!_noTTY && !streamJson) ? setInterval(() => sp.text(_statusLine()), 1000) : null;
|
|
886
898
|
if (streamJson) _emit(core.AgentEvents.systemInit({ model: model || 'auto', cwd: startCwd, mode: plan ? 'plan' : readOnly ? 'ask' : 'agent' }));
|
|
887
899
|
let out;
|
|
888
900
|
try {
|
|
889
901
|
out = await agent.run(task, {
|
|
890
902
|
token, lang: cfg.lang || 'pt', yes: YES, autoAll: YOLO, model, priorMessages, cwd: startCwd, readOnly, plan, browser: useBrowser,
|
|
891
|
-
onThinking: () =>
|
|
903
|
+
onThinking: (p) => {
|
|
904
|
+
if (p && typeof p === 'object') {
|
|
905
|
+
_live.steps = p.steps ?? _live.steps; _live.inTok = p.inTok ?? _live.inTok; _live.outTok = p.outTok ?? _live.outTok;
|
|
906
|
+
if (p.model && p.model !== 'smart') _live.model = p.model;
|
|
907
|
+
}
|
|
908
|
+
sp.text(_statusLine());
|
|
909
|
+
},
|
|
892
910
|
onStep: ({ name, detail, blocked, loop, retry, auto }) => {
|
|
893
911
|
if (streamJson) { _emit(core.AgentEvents.tool({ subtype: retry ? 'retry' : loop ? 'loop' : blocked ? 'blocked' : auto ? 'auto_approved' : 'started', tool: name, detail: detail || '' })); return; }
|
|
894
912
|
sp.stop();
|
|
@@ -919,7 +937,8 @@ async function agentCmd(words, { askFn, cwd: cwdIn = null, onCwd = null } = {})
|
|
|
919
937
|
sp.start();
|
|
920
938
|
},
|
|
921
939
|
});
|
|
922
|
-
} catch (e) { sp.stop(); throw e; }
|
|
940
|
+
} catch (e) { if (_liveTimer) clearInterval(_liveTimer); sp.stop(); throw e; }
|
|
941
|
+
if (_liveTimer) clearInterval(_liveTimer);
|
|
923
942
|
sp.stop();
|
|
924
943
|
// cwd EFETIVO (o agente pode ter feito cd/mudar_diretorio) → devolve ao REPL e persiste.
|
|
925
944
|
const effCwd = out.cwd || startCwd;
|
|
@@ -967,7 +986,10 @@ async function agentCmd(words, { askFn, cwd: cwdIn = null, onCwd = null } = {})
|
|
|
967
986
|
? ' · ' + (cfg.lang === 'en' ? 'context ' : 'contexto ') + Math.round(out.context.used / 1000) + 'k/' + Math.round(out.context.window / 1000) + 'k (' + Math.round(100 * out.context.used / out.context.window) + '%)'
|
|
968
987
|
: '')
|
|
969
988
|
: '';
|
|
970
|
-
|
|
989
|
+
// rodapé enriquecido: passos · créditos · tempo · MODELO · tokens (· contexto)
|
|
990
|
+
const _tokTot = (out.tokens && ((out.tokens.inTok || 0) + (out.tokens.outTok || 0))) || 0;
|
|
991
|
+
const _extra = (out.model ? ' · ' + String(out.model).slice(0, 22) : '') + (_tokTot ? ' · ↓ ' + _fmtTok(_tokTot) + ' tok' : '');
|
|
992
|
+
console.log(' ' + C.dim(T.agent_footer(out.steps, out.credits, secs)) + C.dim(_extra) + C.dim(_cx) + C.dim(' · ts agente --continuar "..." pra seguir') + '\n');
|
|
971
993
|
_printWt();
|
|
972
994
|
}
|
|
973
995
|
|
package/lib/agent.js
CHANGED
|
@@ -462,7 +462,8 @@ async function run(task, opts = {}) {
|
|
|
462
462
|
let stopped = false;
|
|
463
463
|
for (let iter = 0; iter < MAX_ITER; iter++) {
|
|
464
464
|
if (opts.shouldStop && opts.shouldStop()) { stopped = true; break; }
|
|
465
|
-
|
|
465
|
+
// passa o snapshot de progresso pra a status line ao vivo (tempo é contado no cliente)
|
|
466
|
+
onThinking({ iter, inTok: acc.inTok, outTok: acc.outTok, cachedTok: acc.cachedTok, steps, model: usedModel });
|
|
466
467
|
await _compactIfNeeded(false); // proativo: compacta ao cruzar ~65% da janela
|
|
467
468
|
let r;
|
|
468
469
|
// gateway oscilou → mostra "reconectando" em vez de morrer calado (confiabilidade visível)
|