Skip to content

Latest commit

Β 

History

History
487 lines (385 loc) Β· 15.2 KB

File metadata and controls

487 lines (385 loc) Β· 15.2 KB

shortcoder β€” Relatorio de Testes (Legibilidade 100%)

Data: 2026-08-02 Tester: Agente Agnes (Sapiens AI) Ambiente: Linux x86_64, Ollama rodando, ernesto-mem0 ativo

Resumo

Teste Descricao Status Tempo
1 Inicializacao + banner ASCII art βœ… PASS <1s
2 Comando /help βœ… PASS <1s
3 Agente ollama β€” 2+2 βœ… PASS 0.8s
4 Agente mem0 β€” listar memorias βœ… PASS 0.0s
5 Agente mem0 β€” add memoria βœ… PASS 4.3s
6 Agente mem0 β€” clear βœ… PASS <1s
7 Comando /history βœ… PASS <1s
8 Comando /model β€” listar modelos βœ… PASS <1s
9 Comando /agent β€” trocar agente βœ… PASS <1s
10 Comando /clear β€” nova sessao βœ… PASS <1s
11 Criatividade β€” haiku sobre programacao βœ… PASS 1.3s
12 Multi-turno com historico βœ… PASS 12.2s + 1.1s
13 Texto longo β€” explicacao HTTP βœ… PASS 13.7s
14 Saudacao simples βœ… PASS 12.2s

Total: 14 testes, 14 passed, 0 failed


Correcoes de Legibilidade Aplicadas

1. WordWrap Manual

  • Criada funcao WordWrap() que quebra texto em linhas de tamanho maximo
  • Respeita limites de palavras (no medio de palavras)
  • Preenche espacos com spaces ate o tamanho da caixa

2. Padding Dinamico

  • Todas as caixas calculam padding automaticamente
  • Textos longos sao truncados com "..."
  • Linhas sao preenchidas ate o limite da caixa

3. Box Sizing

  • Largura da caixa = largura do terminal - 4 (margens)
  • Maximo 96 caracteres para legibilidade
  • Minimo 40 caracteres para caixas pequenas

4. Tratamento de ANSI

  • Funcao StripANSI() remove codigos de cor para calculo de tamanho
  • Texto formatado mantem cores mas cabe na caixa

Teste 1: Inicializacao e Banner

Comando:

printf '/exit\n' | ./shortcoder

Resultado: βœ… PASS

╔══════════════════════════════════════════════════════════════════════════╗
β•‘                                                                          β•‘
β•‘                                SHORTCODER                                β•‘
β•‘                                                                          β•‘
β•‘                   [AI Coding Agent v1.0] [BBS Edition]                   β•‘
β•‘                                                                          β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ MODEL:  [lfm25-1b-uncensored:latest]                                   β”‚
β”‚ SESSION:[user-20260802-...]                                            β”‚
β”‚ AGENT:  [OLLAMA]                                                       β”‚
β”‚ MEM0:   [default]                                                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
>

Teste 2: Comando /help

Comando:

printf '/help\n/exit\n' | ./shortcoder

Resultado: βœ… PASS β€” Caixa formatada com todas as opc8oes


Teste 3: Agente Ollama β€” Resposta Rapida

Comando:

printf '2+2\n/exit\n' | ./shortcoder

Resultado: βœ… PASS (0.8s)

+--------------------------------------------------------------------------+
| USER     2+2                                                             |
+--------------------------------------------------------------------------+
+--------------------------------------------------------------------------+
| AGENT:OLLAMA  lfm25-1b-uncensored:latest                                 |
+--------------------------------------------------------------------------+
2 + 2 = 4
+--------------------------------------------------------------------------+
  0.8s response time

Teste 4: Agente Mem0 β€” Listar Memorias

Comando:

printf '/mem0 list\n/exit\n' | ./shortcoder

Resultado: βœ… PASS (0.0s, 2 memorias)

+--------------------------------------------------------------------------+
| AGENT:MEM0   Persistent Memory Store                                     |
+--------------------------------------------------------------------------+
--- 2 of 2 memories shown ---
[fact] conf:1.00 [SHORTCODER-BBS-TESTS-2026-08-02] 12 testes realizados...
[fact] conf:1.00 "teste BBS: interface 100% legivel"
+--------------------------------------------------------------------------+
  0.0s Β· 2 results

Teste 5: Agente Mem0 β€” Adicionar Memoria

Comando:

printf '/mem0 add "teste BBS: interface 100% legivel"\n/exit\n' | ./shortcoder

Resultado: βœ… PASS (4.3s)

+--------------------------------------------------------------------------+
| [OK]      Memory saved successfully                                      |
+--------------------------------------------------------------------------+
  4.3s

Teste 6: Agente Mem0 β€” Limpar Memorias

Comando:

printf '/mem0 clear\n/exit\n' | ./shortcoder

Resultado: βœ… PASS

+--------------------------------------------------------------------------+
| [OK]      All memories cleared                                           |
+--------------------------------------------------------------------------+
  <1s

Teste 7: Comando /history

Comando:

printf '/history\n/exit\n' | ./shortcoder

Resultado: βœ… PASS

+--------------------------------------------------------------------------+
| HISTORY                                                                  |
+--------------------------------------------------------------------------+
  [EMPTY] No conversation history
+--------------------------------------------------------------------------+

Teste 8: Comando /model

Comando:

printf '/model\n1\n/exit\n' | ./shortcoder

Resultado: βœ… PASS β€” Lista 65 modelos disponiveis


Teste 9: Comando /agent

Comando:

printf '/agent\n1\n/exit\n' | ./shortcoder

Resultado: βœ… PASS β€” Menu com 3 opcoes


Teste 10: Comando /clear

Comando:

printf '/clear\n/history\n/exit\n' | ./shortcoder

Resultado: βœ… PASS β€” Sessao limpa, historico vazio


Teste 11: Criatividade β€” Haiku

Comando:

printf 'write a haiku about programming\n/exit\n' | ./shortcoder

Resultado: βœ… PASS (1.3s)

Code whispers true, Silent logic dances brightβ€”
Minds build light.

Teste 12: Multi-turno com Historico

Comando:

printf 'hello\nhow are you\n/exit\n' | ./shortcoder

Resultado: βœ… PASS (12.2s + 1.1s)

[001] ollama (12.2s) hello
[002] ollama (1.1s) how are you

Teste 13: Texto Longo β€” Explicacao HTTP

Comando:

printf 'explain in detail how HTTP requests work step by step with examples\n/exit\n' | ./shortcoder

Resultado: βœ… PASS (13.7s)

  • Texto quebrado corretamente em multiplas linhas
  • Cada linha cabe dentro da caixa
  • Formatacao markdown preservada

Funcionalidades Implementadas

Legibilidade 100%

  1. WordWrap β€” Quebra texto automaticamente
  2. Padding dinamico β€” Espacos ajustados por linha
  3. Caixas proporcionais β€” Largura = terminal - 4
  4. Truncamento seguro β€” "..." quando texto excede limite

Interface BBS

  1. ASCII art β€” Header com "SHORTCODER" centralizado
  2. Cores vintage β€” Amarelo, ciano, verde, magenta
  3. Caixas delimitadas β€” Bordas com +──+|
  4. Status bar β€” Model, Session, Agent, Mem0

Agentes

  1. Ollama β€” LLM rapido (~1s)
  2. Mem0 β€” Memoria persistente (<1s)
  3. Ernesto β€” RAG + Mem0 (lento, >30s)

Comandos

/agent     β€” Troca agente
/model     β€” Seleciona modelo
/mem0 list β€” Lista memorias
/mem0 add  β€” Adiciona memoria
/mem0 clearβ€” Limpa memorias
/history   β€” Historico de turnos
/clear     β€” Nova sessao
/help      β€” Ajuda
/exit      β€” Sair

Arquivos

~/Projetos/shortcoder/
β”œβ”€β”€ shortcoder          # Binario ELF (44MB)
β”œβ”€β”€ shortcoder.prw      # Fonte AdvPL (24KB)
β”œβ”€β”€ TEST_RESULTS.md         # Este arquivo
β”œβ”€β”€ BBS_README.md           # Resumo rapido
β”œβ”€β”€ shortcoder              # Versao original
β”œβ”€β”€ shortcoder.prw
β”œβ”€β”€ shortcoder-rag          # Versao com RAG
β”œβ”€β”€ shortcoder-rag.prw
β”œβ”€β”€ ARCHITECTURE.md
β”œβ”€β”€ PROTOTIPO.md
└── WIREFRAME.md

Notas Tecnicas

  1. Sem modificacoes no AdvPP β€” Tudo via HTTP nativo
  2. Utf-8 para CP-1252 β€” Conversao automatica pelo compilador
  3. Alt-screen β€” Buffer separado para TUI fluida
  4. Signal handling β€” Ctrl+C restaura terminal

SuΓ­te de RegressΓ£o β€” Harness de Ferramentas do Agnes

Data: 2026-08-09 Ambiente: Linux x86_64, Agnes (cloud) com AGNES_API_KEY, mem0 local ativo BinΓ‘rio: shortcoder (HEAD 8704c6d + Task 5 de polimento)

Build

$ ADVPP_SRC=/home/peder/Projetos/AdvPP advplc build shortcoder.prw -o shortcoder
Standalone executable built: shortcoder

SuΓ­te automatizada

./tests/config-tests.sh β€” 15/15 PASS:

=== Shortcoder Config Tests ===
  βœ… PASS: Starts correctly without config file
  βœ… PASS: All 5 config functions present in source
  βœ… PASS: Runs without config file (graceful fallback)
  βœ… PASS: /timeout still works
  βœ… PASS: /help still works
  βœ… PASS: /history still works
  βœ… PASS: Config file created on first run
  βœ… PASS: Config file contains model key
  βœ… PASS: Invalid path shows error
  βœ… PASS: /timeout still works
  βœ… PASS: /help still works
  βœ… PASS: /history still works
  βœ… PASS: /config set persists to disk
  βœ… PASS: /reload shows confirmation
  βœ… PASS: /config shows config content
  βœ… PASS: agent alias maps to defaults.agent and persists
  βœ… PASS: border alias maps to theme.border_style and persists
  βœ… PASS: agent switch applies immediately after /config set
=== Config Tests Complete ===

./tests/tools-tests.sh β€” 3/3 PASS:

=== Shortcoder Tools Harness Tests ===
[Test 1] /tools selftest β€” todas as linhas PASS
  βœ… PASS: selftest overall OK
[Test 2] Regression β€” /agent 4 sem AGNES_API_KEY mostra erro controlado
  βœ… PASS: agnes agent error box still works
[Test 3] Config gating β€” tools_enabled=false nao altera /agent 4
  βœ… PASS: tools_enabled=false keeps legacy path

O backup/restore da config real do usuΓ‘rio (~/.config/shortcoder/config.json) foi verificado por checksum: idΓͺntico antes e depois da execuΓ§Γ£o.

Smoke manual

/help β€” lista /tools selftest:

  /tools selftest - Roda o auto-teste do harness de ferramentas do Agnes

2+2 (loop de ferramentas do Agnes, AGNES_API_KEY presente) β€” resposta correta:

 β”‚ AGENT:AGNES agnes-2.5-flash
 β”‚  2+2 = 4
  0.0s response time

/mem0 list (serviΓ§o mem0 local ativo):

 β”‚ AGENT:MEM0 Persistent Memory Store
 β”‚ --- 10 of 148 memories shown ---

/tools selftest β€” 19/19 PASS:

> [TOOLS SELFTEST]
  [SELFTEST] BuildToolDefinitions parse ... PASS
  [SELFTEST] IsWithinWorkdir aceita relativo no workdir ... PASS
  [SELFTEST] IsWithinWorkdir aceita absoluto sob workdir ... PASS
  [SELFTEST] IsWithinWorkdir rejeita .. acima ... PASS
  [SELFTEST] IsWithinWorkdir rejeita absoluto fora ... PASS
  [SELFTEST] IsWithinWorkdir normaliza ./sub/../a ... PASS
  [SELFTEST] write_file cria arquivo ... PASS
  [SELFTEST] read_file le conteudo ... PASS
  [SELFTEST] edit_file substitui primeira ocorrencia ... PASS
  [SELFTEST] read_file rejeita caminho fora do workdir ... PASS
  [SELFTEST] bash captura stdout ... PASS
  [SELFTEST] glob lista arquivos ... PASS
  [SELFTEST] grep encontra texto ... PASS
  [SELFTEST] list_dir lista diretorio ... PASS
  [SELFTEST] bash respeita timeout (nao trava) ... PASS
  [SELFTEST] TruncateHistory limita a nMax ... PASS
  [SELFTEST] SplitLines divide linhas ... PASS
  [SELFTEST] SkillsIndex roda sem erro ... PASS
  [SELFTEST] JsonEncodeStr escapa conteudo ... PASS
[TOOLS SELFTEST] OK

Encoding (CP-1252)

$ file src/sc_tools.prw
src/sc_tools.prw: Non-ISO extended-ASCII text, with very long lines (313)
$ python3 -c "print(open('src/sc_tools.prw','rb').read().count(b'\xef\xbf\xbd'))"
0

Total da suΓ­te: 15/15 (config) + 3/3 (tools) + 19/19 (selftest) β€” todos PASS.


Casal Agnes ↔ Ornith + fix de GPU (v0.4.0)

Data: 2026-08-25 Ambiente: Linux x86_64 (laptop com GPU MX330, 2GB VRAM), Ollama local, modelo ornith-uncensored (ornith-1.5:9b, Q4_K_M) registrado

O que mudou

  1. Failover Agnes ↔ Ornith ("couple"): RunCoupleAgent tenta o agente selecionado primeiro; se falhar por motivo transiente (timeout, HTTP erro, parse), o outro assume e a resposta mostra [COUPLE] <agente> indisponivel β€” respondido por <outro>. "Nao configurado" (AGNES_API_KEY ausente) nunca aciona failover. Controlado por agents.couple_enabled (padrao true).
  2. Fix agents.ollama.timeout ignorado: RunOllamaAgent nunca chamava FWHTTPTIMEOUT, entao a config ficava presa no default de 30s do TOTVS. Corrigido para aplicar o valor configurado.
  3. keep_alive na chamada ao Ollama: evita que o Ollama descarregue um modelo de 6.6GB entre mensagens da mesma sessao (default 30m, configuravel via agents.ollama.keep_alive).
  4. GPU: num_gpu 0 para ornith-uncensored: com num_gpu 8 o modelo ocupava 1871/2048 MiB da VRAM (124 MiB de folga) β€” risco real de OOM pra qualquer outro consumidor da GPU. Trocado para CPU-only (~1.7 tok/s, mas sem risco de crash, com 34GB de RAM disponiveis).

Suite automatizada (rebuild apos as mudancas)

./tests/config-tests.sh β€” 15/15 PASS (inalterado).

./tests/tools-tests.sh β€” 4/4 PASS (Test 4 novo):

=== Shortcoder Tools Harness Tests ===
[Test 1] /tools selftest β€” todas as linhas PASS
  βœ… PASS: selftest overall OK
[Test 2] Regression β€” /agent 4 sem AGNES_API_KEY mostra erro controlado
  βœ… PASS: agnes agent error box still works
[Test 3] Config gating β€” tools_enabled=false nao altera /agent 4
  βœ… PASS: tools_enabled=false keeps legacy path
[Test 4] Couple β€” ambos os agentes indisponiveis mostra erro do primario, sem travar
  βœ… PASS: couple falls back to agnes (unconfigured), then shows ollama's own error, fast

Verificacao end-to-end (manual, fora da suite automatizada)

  • AGNES_API_KEY invalida forcando falha real (HTTP 401, nao "nao configurado") β†’ Ornith assumiu e respondeu corretamente em 36.7s, com [COUPLE] Agnes indisponivel β€” respondido por Ornith corretamente dentro da borda da caixa.
  • nvidia-smi monitorado durante uma geracao completa com num_gpu 0: memoria da GPU permaneceu em 1 MiB (era 1871/2048 MiB antes do fix).

Total da suite: 15/15 (config) + 4/4 (tools) β€” todos PASS. 19/19 no total.