terminal-smart-cli 0.88.0 → 0.90.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 +12 -1
- package/lib/agent.js +2 -1
- package/package.json +1 -1
package/bin/ts.js
CHANGED
|
@@ -836,6 +836,13 @@ async function agentCmd(words, { askFn, cwd: cwdIn = null, onCwd = null } = {})
|
|
|
836
836
|
if (_v) { const j = words.indexOf(_v); if (j >= 0) words = words.slice(0, j).concat(words.slice(j + 1)); }
|
|
837
837
|
}
|
|
838
838
|
let task = words.join(' ').trim();
|
|
839
|
+
// Flags INLINE no texto (pro REPL, onde não há argv): --passos N / --steps N / --yolo.
|
|
840
|
+
// Assim "faça tudo ... --passos 60 --yolo" digitado no chat vale igual à linha de comando.
|
|
841
|
+
let _inlinePassos, _inlineYolo = false;
|
|
842
|
+
task = task
|
|
843
|
+
.replace(/(?:^|\s)--(?:passos|steps|max-passos)[\s=]+(\d{1,3})\b/gi, (_m, n) => { _inlinePassos = Number(n); return ' '; })
|
|
844
|
+
.replace(/(?:^|\s)--(?:yolo|full-auto|auto-tudo)\b/gi, () => { _inlineYolo = true; return ' '; })
|
|
845
|
+
.replace(/\s{2,}/g, ' ').trim();
|
|
839
846
|
const piped = await readStdin();
|
|
840
847
|
if (piped) task = (task || (cfg.lang === 'en' ? 'Analyze the input below and act on it.' : 'Analise a entrada abaixo e aja sobre ela.'))
|
|
841
848
|
+ `\n\n${T.pipe_ctx}:\n\`\`\`\n${piped.slice(0, 30000)}\n\`\`\``;
|
|
@@ -902,8 +909,12 @@ async function agentCmd(words, { askFn, cwd: cwdIn = null, onCwd = null } = {})
|
|
|
902
909
|
if (streamJson) _emit(core.AgentEvents.systemInit({ model: model || 'auto', cwd: startCwd, mode: plan ? 'plan' : readOnly ? 'ask' : 'agent' }));
|
|
903
910
|
let out;
|
|
904
911
|
try {
|
|
912
|
+
// --passos N (ou --steps): quantas iterações o agente pode fazer numa run (default 15, teto 120).
|
|
913
|
+
// Pra missões grandes ("faça tudo de uma vez") sem o pára-e-continua.
|
|
914
|
+
const _pi = process.argv.findIndex(a => a === '--passos' || a === '--steps' || a === '--max-passos');
|
|
915
|
+
const _maxPassos = _pi >= 0 ? Number(process.argv[_pi + 1]) : _inlinePassos;
|
|
905
916
|
out = await agent.run(task, {
|
|
906
|
-
token, lang: cfg.lang || 'pt', yes: YES, autoAll: YOLO, model, priorMessages, cwd: startCwd, readOnly, plan, browser: useBrowser,
|
|
917
|
+
token, lang: cfg.lang || 'pt', yes: YES, autoAll: (YOLO || _inlineYolo), model, priorMessages, cwd: startCwd, readOnly, plan, browser: useBrowser, maxIter: _maxPassos,
|
|
907
918
|
onThinking: (p) => {
|
|
908
919
|
if (p && typeof p === 'object') {
|
|
909
920
|
_live.steps = p.steps ?? _live.steps; _live.inTok = p.inTok ?? _live.inTok; _live.outTok = p.outTok ?? _live.outTok;
|
package/lib/agent.js
CHANGED
|
@@ -248,6 +248,7 @@ async function _remoteApprove(comando, token, onRemote) {
|
|
|
248
248
|
*/
|
|
249
249
|
async function run(task, opts = {}) {
|
|
250
250
|
const { token, lang = 'pt', yes = false, autoAll = false, model = null, confineDir = null, onStep = () => {}, onStepDone = () => {}, askApprove = async () => false, onThinking = () => {}, onRemote = () => {} } = opts;
|
|
251
|
+
const maxIter = Math.max(1, Math.min(Number(opts.maxIter) || MAX_ITER, 120)); // --passos N (teto 120)
|
|
251
252
|
// FULL-AUTO (autoridade total): aprova destrutivos sem perguntar. Começa por --yolo/--full-auto
|
|
252
253
|
// (opts.autoAll) e pode ser LIGADO no meio da sessão quando o humano responde "a" (aprovar tudo).
|
|
253
254
|
let autoApproveDestructive = !!autoAll;
|
|
@@ -462,7 +463,7 @@ async function run(task, opts = {}) {
|
|
|
462
463
|
// encerra no próximo limite de passo (não interrompe uma chamada em curso, mas para de
|
|
463
464
|
// gastar). Marca `stopped` pra pular o fechamento por LLM lá embaixo.
|
|
464
465
|
let stopped = false;
|
|
465
|
-
for (let iter = 0; iter <
|
|
466
|
+
for (let iter = 0; iter < maxIter; iter++) {
|
|
466
467
|
if (opts.shouldStop && opts.shouldStop()) { stopped = true; break; }
|
|
467
468
|
// passa o snapshot de progresso pra a status line ao vivo (tempo é contado no cliente)
|
|
468
469
|
onThinking({ iter, inTok: acc.inTok, outTok: acc.outTok, cachedTok: acc.cachedTok, steps, model: usedModel });
|