diff --git a/package.json b/package.json index 4aac7c0..249b11d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "connect-ai-lab", "displayName": "Connect AI", "description": "100% 로컬 AI 코딩 에이전트 — 파일 생성, 코드 편집, 터미널 실행을 오프라인으로. Ollama + Gemma/Llama/DeepSeek 지원.", - "version": "1.0.31", + "version": "1.0.32", "publisher": "connectailab", "license": "MIT", "icon": "assets/icon.png", diff --git a/src/extension.ts b/src/extension.ts index 43ad226..3b3d09f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -819,18 +819,23 @@ class SidebarChatProvider implements vscode.WebviewViewProvider { // -------------------------------------------------------- private _executeActions(aiMessage: string): string[] { const report: string[] = []; - const rootPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath; + let rootPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath; + + // Fallback to active editor directory if no workspace folder is open + if (!rootPath && vscode.window.activeTextEditor && vscode.window.activeTextEditor.document.uri.scheme === 'file') { + rootPath = path.dirname(vscode.window.activeTextEditor.document.uri.fsPath); + } if (!rootPath) { - const hasActions = /]+)['"]?[^>]*>([\s\S]*?)<\/create_file>/gi; + const createRegex = /<(?:create_file|file)\s+(?:path|file|name)=['"]?([^'">]+)['"]?[^>]*>([\s\S]*?)<\/(?:create_file|file)>/gi; let match: RegExpExecArray | null; let firstCreatedFile = ''; @@ -866,7 +871,7 @@ class SidebarChatProvider implements vscode.WebviewViewProvider { } // ACTION 2: Edit files - const editRegex = /]+)['"]?[^>]*>([\s\S]*?)<\/edit_file>/gi; + const editRegex = /<(?:edit_file|edit)\s+(?:path|file|name)=['"]?([^'">]+)['"]?[^>]*>([\s\S]*?)<\/(?:edit_file|edit)>/gi; while ((match = editRegex.exec(aiMessage)) !== null) { const relPath = match[1].trim(); const body = match[2]; @@ -906,7 +911,7 @@ class SidebarChatProvider implements vscode.WebviewViewProvider { } // ACTION 3: Run commands - const cmdRegex = /([\s\S]*?)<\/run_command>/gi; + const cmdRegex = /<(?:run_command|command|bash|terminal)>([\s\S]*?)<\/(?:run_command|command|bash|terminal)>/gi; while ((match = cmdRegex.exec(aiMessage)) !== null) { let cmd = match[1].trim(); // Clean up if AI outputs markdown inside