Correzione pattern write_file: usa file_path già estratto

This commit is contained in:
opencode committed 2026-03-23 19:09:28 +01:00
1 parent f678a6f20d
commit 57c43d4738
1 file changed
+10 -11
+10 -11
View File
@@ -391,21 +391,20 @@ For other questions, just answer normally without tools."""
'write', 'create', 'save', 'make file']
has_write_keyword = any(k in text_lower for k in write_keywords)
if has_write_keyword:
# Try to extract path and content
path_match = re.search(r'(?:file|file\s+)(\S+\.\w+)', text_lower)
if has_write_keyword and file_path:
# Extract content from quoted text
content_match = re.search(r'["\']([^"\']+)["\']', text)
if path_match:
file_path = path_match.group(1)
# Try to get content from quoted text or description
if content_match:
content = content_match.group(1)
else:
# Try to extract content between "con dentro" and quotes
content_match = re.search(r'con dentro ["\']([^"\']+)["\']', text)
if content_match:
content = content_match.group(1)
else:
# Try to extract content from the text
content = text.replace('"', "'").split("'")[1] if "'" in text else "Content not specified"
return ToolCall(id='intent', name='write_file', arguments={'path': file_path, 'content': content})
content = "Content not specified"
return ToolCall(id='intent', name='write_file', arguments={'path': file_path, 'content': content})
# Execute command patterns
exec_patterns = [