fix: rimuovi codici ANSI e aggiungi info scroll per CLI semplice

- strip_ansi() rimuove escape sequences per terminali base
- Info scroll per output > 1000 caratteri
This commit is contained in:
opencode committed 2026-03-24 14:13:50 +01:00
1 parent 918b1f3a5b
commit 3197dedd4c
1 file changed
+14 -1
+14 -1
View File
@@ -29,6 +29,13 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
VERSION = "1.0.0"
def strip_ansi(text: str) -> str:
"""Rimuove codici ANSI escape sequences per terminali semplici"""
import re
ansi_pattern = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
return ansi_pattern.sub('', text)
def cmd_chat(args):
"""Avvia l'agent in modalità chat interattiva"""
import signal
@@ -160,7 +167,13 @@ Comandi disponibili:
thinking_active.clear()
thinker.join(timeout=1)
print(f"🤖 {response}\n")
# Strip ANSI codes per terminali semplici
clean_response = strip_ansi(response)
print(f"🤖 {clean_response}\n")
# Info scroll per output lunghi
if len(clean_response) > 1000:
print("💡 Suggerimento: scorri con Shift+PgUp / Shift+PgDn o mouse\n")
except KeyboardInterrupt:
print("\n👋 Arrivederci!")