From f8ebfb65ab79da6a568358808175d3a7503e0075 Mon Sep 17 00:00:00 2001 From: opencode Date: Mon, 23 Mar 2026 19:00:09 +0100 Subject: [PATCH] feat: aggiunge pattern per comando 'cerca file' --- ollama_agent.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ollama_agent.py b/ollama_agent.py index 9e8ba26..2832c4d 100644 --- a/ollama_agent.py +++ b/ollama_agent.py @@ -367,6 +367,20 @@ For other questions, just answer normally without tools.""" if any(p in text_lower for p in list_patterns): return ToolCall(id='intent', name='ls', arguments={'path': '.'}) + # Search patterns + search_patterns = [ + 'cerca', 'cercare', 'trova', 'trovare', 'dove si trova', + 'search', 'find', 'file', '*.py', '*.md', '*.txt' + ] + # If the message mentions file patterns, use search tool + if 'cerca' in text_lower or 'search' in text_lower or 'find' in text_lower: + # Extract directory and pattern + dir_match = re.search(r'(?:in|alla|nella)\s+([/\w.-]+)', text) + pattern_match = re.search(r'\*\.(\w+)', text) + directory = dir_match.group(1) if dir_match else '.' + pattern = f"*.{pattern_match.group(1)}" if pattern_match else "*" + return ToolCall(id='intent', name='search', arguments={'directory': directory, 'pattern': pattern}) + # Read/show file patterns - check for ANY read keyword AND a file path read_keywords = ['leggi', 'leggere', 'mostrami', 'apri', 'aprimi', 'visualizza', 'vediamo', 'vedi', 'show me', 'show the', 'read', 'open',