terminal-smart-cli 0.97.14 → 0.97.16

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/lib/agent.js CHANGED
@@ -1587,7 +1587,7 @@ async function run(task, opts = {}) {
1587
1587
  try { require('./memoria').logErro(confineDir || cwd, name, String(result.erro || result.stderr || ('exit ' + result.codigo))); } catch (_) {}
1588
1588
  // RECOVERY ENGINE: erro de classe CONHECIDA → injeta a estratégia de conserto no
1589
1589
  // resultado (o modelo aplica o padrão DevOps em vez de chutar/entrar em loop).
1590
- try { const _rh = require('./recovery').recoveryHint(_tr.errorClass); if (_rh && result && typeof result === 'object' && !result._recovery) result = Object.assign({}, result, { _recovery: _rh }); } catch (_) {}
1590
+ try { const _rh = require('./recovery').recoveryHint(_tr.errorClass, { availableTools:_allowedToolNames }); if (_rh && result && typeof result === 'object' && !result._recovery) result = Object.assign({}, result, { _recovery: _rh }); } catch (_) {}
1591
1591
  }
1592
1592
  // HOOK PostToolUse (determinístico): feedback (ex: lint/format) vai pro modelo ver.
1593
1593
  if (_hooks._any) {
package/lib/i18n.js CHANGED
@@ -163,7 +163,7 @@ const STR = {
163
163
  chat_bye: 'Até logo! A conversa continua salva na web (/ia).',
164
164
  agent_need: 'Descreva a tarefa. Ex.: ts agente "libere espaço em disco analisando as pastas maiores"',
165
165
  agent_thinking: 'agente pensando',
166
- agent_blocked: 'bloqueado (destrutivo)',
166
+ agent_blocked: 'bloqueado pelo harness',
167
167
  agent_approve: (cmd) => `O agente quer rodar um comando DESTRUTIVO:\n\n ${cmd}\n\n Permitir? (s/N) `,
168
168
  agent_footer: (st, cr, s) => `${st} passo(s) · ${cr} créditos · ${s}`,
169
169
  agent_footer_byok: (st, prov, s) => `${st} passo(s) · sua chave (${prov}) · ${s}`,
@@ -332,7 +332,7 @@ const STR = {
332
332
  chat_bye: 'See you! The conversation stays saved on the web (/ia).',
333
333
  agent_need: 'Describe the task. E.g.: ts agente "free disk space by analyzing the largest folders"',
334
334
  agent_thinking: 'agent thinking',
335
- agent_blocked: 'blocked (destructive)',
335
+ agent_blocked: 'blocked by harness',
336
336
  agent_approve: (cmd) => `The agent wants to run a DESTRUCTIVE command:\n\n ${cmd}\n\n Allow? (y/N) `,
337
337
  agent_footer: (st, cr, s) => `${st} step(s) · ${cr} credits · ${s}`,
338
338
  agent_footer_byok: (st, prov, s) => `${st} step(s) · your key (${prov}) · ${s}`,
package/lib/meta.js CHANGED
@@ -49,7 +49,7 @@ function artifactForMetaItem(item, st) {
49
49
  const list = Array.isArray(st && st.checklist) ? st.checklist : [];
50
50
  const index = Math.max(0, list.indexOf(item));
51
51
  const criterion = Array.isArray(st && st.criteria) ? st.criteria[index] : null;
52
- if (criterion && criterion.type === 'file_exists' && criterion.path) return String(criterion.path);
52
+ if (criterion && ['file_exists', 'file_contains'].includes(criterion.type) && criterion.path) return String(criterion.path);
53
53
  const d = String(item && item.desc || '').toLowerCase();
54
54
  if (/controller.*8 dire|8 dire.*controller/.test(d)) return 'src/player_controller.gd';
55
55
  if (/combate b[aá]sico|sistema de combate/.test(d)) return 'src/combat_system.gd';
@@ -1630,13 +1630,17 @@ async function run(goal, opts = {}) {
1630
1630
  if (expectedNow && !wroteExpectedNow) {
1631
1631
  item.attempts = Math.max(0, (item.attempts || 1) - 1);
1632
1632
  item.avoidModels = [...new Set([...(item.avoidModels || []), String(out.model || roundModel || 'automatico')])];
1633
- item.directArtifact = true;
1633
+ const expectedTarget = path.isAbsolute(expectedArtifact) ? expectedArtifact : path.resolve(dir, expectedArtifact);
1634
+ // Conteúdo direto é seguro para um artefato NOVO. Para código existente ele poderia
1635
+ // substituir o projeto inteiro por uma resposta parcial do item; nesse caso troque o
1636
+ // executor e obrigue uma edição real, preservando o arquivo atual.
1637
+ item.directArtifact = !fs.existsSync(expectedTarget);
1634
1638
  const failedModel = String(out.model || roundModel || 'glm-5.2');
1635
- item.directModel = /glm/i.test(failedModel) ? 'glm-5.2' : failedModel;
1639
+ if (item.directArtifact) item.directModel = /glm/i.test(failedModel) ? 'glm-5.2' : failedModel;
1636
1640
  st.status = 'paused'; st.pause_reason = 'model_no_action';
1637
1641
  st.budget = st.creditsSpent;
1638
1642
  save(st, dir);
1639
- onAlert({ type: 'retry', text: `O modelo ${out.model || roundModel || 'automatico'} respondeu, mas executou zero ferramentas. Nao marquei falha do item; a retomada usara outro executor.` });
1643
+ onAlert({ type: 'retry', text: `O modelo ${out.model || roundModel || 'automatico'} não persistiu o artefato esperado. Não marquei o item como concluído; a retomada usará outro executor sem substituir código existente.` });
1640
1644
  return st;
1641
1645
  }
1642
1646
 
package/lib/recovery.js CHANGED
@@ -63,9 +63,17 @@ const RECOVERABLE = Object.keys(STRATEGIES); // classes com estratégia conhecid
63
63
  function strategiesFor(errorClass) { return STRATEGIES[errorClass] || null; }
64
64
 
65
65
  // Texto acionável pra INJETAR no resultado da ferramenta que o modelo lê. '' se classe sem estratégia.
66
- function recoveryHint(errorClass) {
66
+ function recoveryHint(errorClass, options = {}) {
67
67
  const s = STRATEGIES[errorClass];
68
68
  if (!s) return '';
69
+ if (errorClass === 'not_found' && Array.isArray(options.availableTools)) {
70
+ const available = new Set(options.availableTools);
71
+ const probes = ['listar_diretorio', 'buscar_arquivos'].filter(name => available.has(name));
72
+ if (!probes.length) {
73
+ return 'ESCOPO ESTRITO: o alvo não foi encontrado e as ferramentas de procura não foram autorizadas. Não contorne a restrição, não invente outro caminho e não repita a mesma leitura. Encerre com a falha objetiva e informe que listar_diretorio ou buscar_arquivos permitiria investigar.';
74
+ }
75
+ return `ESTRATÉGIA CONHECIDA (not_found) — use somente ferramentas disponíveis:\n1) DIAGNOSTIQUE com ${probes.join(' ou ')} para confirmar o caminho exato.\n2) Se encontrar um candidato inequívoco, tente ler uma única vez; caso contrário, encerre com a evidência sem inventar caminho.`;
76
+ }
69
77
  return `ESTRATÉGIA CONHECIDA (${errorClass}) — não chute:\n1) DIAGNOSTIQUE: ${s.diag}\n2) CONSERTO: ${s.fix}`;
70
78
  }
71
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminal-smart-cli",
3
- "version": "0.97.14",
3
+ "version": "0.97.16",
4
4
  "description": "Terminal Smart no seu terminal — pergunte, analise logs por pipe e orquestre agentes de IA. Comando: ts",
5
5
  "bin": {
6
6
  "ts": "bin/ts.js"