Execute: check comandi shell PRIMA di list_patterns (ls, git, cat, etc.)

This commit is contained in:
opencode committed 2026-03-23 19:12:42 +01:00
1 parent 462f3d1785
commit f9def3e389
1 file changed
+8 -9
+8 -9
View File
@@ -341,6 +341,14 @@ For other questions, just answer normally without tools."""
path_match = re.search(r'([/\w.-]+\.\w+)', text, re.IGNORECASE)
file_path = path_match.group(1) if path_match else None
# Execute command patterns - check FIRST for shell commands with flags
# Shell commands like "ls -lha", "git status" should use execute
if ('ls' in text_lower or 'git' in text_lower or 'cat' in text_lower or
'grep' in text_lower or 'find' in text_lower or 'pwd' in text_lower or
'cd ' in text_lower or 'mkdir' in text_lower or 'rm ' in text_lower or
'cp ' in text_lower or 'mv ' in text_lower or 'chmod' in text_lower) and ' ' in text:
return ToolCall(id='intent', name='execute', arguments={'command': text.strip()})
# System info patterns (more comprehensive)
system_patterns = [
'sistema operativo', 'so sto', 'che os', 'che sistema', 'che so',
@@ -406,15 +414,6 @@ For other questions, just answer normally without tools."""
return ToolCall(id='intent', name='write_file', arguments={'path': file_path, 'content': content})
# Execute command patterns - check FIRST for shell commands
# Shell commands typically have spaces and flags like -, --
if 'ls' in text_lower and ('-' in text or len(text.split()) > 1):
# Looks like a shell command with args
cmd = text_lower.split()[0] if text_lower.split() else text_lower
args = ' '.join(text.split()[1:]) if len(text.split()) > 1 else ''
full_cmd = f"{cmd} {args}".strip() if args else cmd
return ToolCall(id='intent', name='execute', arguments={'command': full_cmd})
exec_patterns = [
'esegui', 'eseguire', 'run', 'run command', 'lanciare',
'avvia', 'comando', 'terminale', 'bash', 'shell'