fix: robust regex parser for XML actions resolving file creation and terminal failures (v1.0.31)

This commit is contained in:
Jay
2026-04-14 03:47:30 +09:00
parent 383d803d2d
commit b2ac61b848
2 changed files with 22 additions and 6 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "connect-ai-lab",
"displayName": "Connect AI",
"description": "100% 로컬 AI 코딩 에이전트 — 파일 생성, 코드 편집, 터미널 실행을 오프라인으로. Ollama + Gemma/Llama/DeepSeek 지원.",
"version": "1.0.30",
"version": "1.0.31",
"publisher": "connectailab",
"license": "MIT",
"icon": "assets/icon.png",
+21 -5
View File
@@ -830,13 +830,22 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
}
// ACTION 1: Create files
const createRegex = /<create_file\s+path="([^"]+)">([\s\S]*?)<\/create_file>/g;
const createRegex = /<create_file\s+path=['"]?([^'">]+)['"]?[^>]*>([\s\S]*?)<\/create_file>/gi;
let match: RegExpExecArray | null;
let firstCreatedFile = '';
while ((match = createRegex.exec(aiMessage)) !== null) {
const relPath = match[1].trim();
const content = match[2].replace(/^\n/, ''); // remove leading newline only
let content = match[2].trim();
// Strip markdown code fences if AI accidentally wrapped the content inside the xml
if (content.startsWith('```')) {
const lines = content.split('\n');
if (lines[0].startsWith('```')) lines.shift();
if (lines.length > 0 && lines[lines.length - 1].startsWith('```')) lines.pop();
content = lines.join('\n').trim();
}
try {
const absPath = path.join(rootPath, relPath);
const dir = path.dirname(absPath);
@@ -857,7 +866,7 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
}
// ACTION 2: Edit files
const editRegex = /<edit_file\s+path="([^"]+)">([\s\S]*?)<\/edit_file>/g;
const editRegex = /<edit_file\s+path=['"]?([^'">]+)['"]?[^>]*>([\s\S]*?)<\/edit_file>/gi;
while ((match = editRegex.exec(aiMessage)) !== null) {
const relPath = match[1].trim();
const body = match[2];
@@ -897,9 +906,16 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
}
// ACTION 3: Run commands
const cmdRegex = /<run_command>([\s\S]*?)<\/run_command>/g;
const cmdRegex = /<run_command>([\s\S]*?)<\/run_command>/gi;
while ((match = cmdRegex.exec(aiMessage)) !== null) {
const cmd = match[1].trim();
let cmd = match[1].trim();
// Clean up if AI outputs markdown inside
if (cmd.startsWith('```')) {
const lines = cmd.split('\n');
if (lines[0].startsWith('```')) lines.shift();
if (lines.length > 0 && lines[lines.length - 1].startsWith('```')) lines.pop();
cmd = lines.join('\n').trim();
}
try {
if (!this._terminal || this._terminal.exitStatus !== undefined) {
this._terminal = vscode.window.createTerminal({