diff --git a/ollama_agent.py b/ollama_agent.py index 160c499..c91f6e4 100644 --- a/ollama_agent.py +++ b/ollama_agent.py @@ -406,7 +406,15 @@ For other questions, just answer normally without tools.""" return ToolCall(id='intent', name='write_file', arguments={'path': file_path, 'content': content}) - # Execute command patterns + # 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'