feat: Auto-trigger git push when AI modifies Second Brain via create_file/edit_file/delete_file

This commit is contained in:
Jay
2026-04-16 14:04:20 +09:00
parent 1f7543ae15
commit f4b4af81d1
3 changed files with 21 additions and 3 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "connect-ai-lab", "name": "connect-ai-lab",
"version": "2.1.29", "version": "2.1.30",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "connect-ai-lab", "name": "connect-ai-lab",
"version": "2.1.29", "version": "2.1.30",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^1.15.0", "axios": "^1.15.0",
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "connect-ai-lab", "name": "connect-ai-lab",
"displayName": "Connect AI", "displayName": "Connect AI",
"description": "100% 로컬 AI 코딩 에이전트 — 파일 생성, 코드 편집, 터미널 실행을 오프라인으로. Ollama + Gemma/Llama/DeepSeek 지원.", "description": "100% 로컬 AI 코딩 에이전트 — 파일 생성, 코드 편집, 터미널 실행을 오프라인으로. Ollama + Gemma/Llama/DeepSeek 지원.",
"version": "2.1.29", "version": "2.1.30",
"publisher": "connectailab", "publisher": "connectailab",
"license": "MIT", "license": "MIT",
"icon": "assets/icon.png", "icon": "assets/icon.png",
+18
View File
@@ -1392,6 +1392,7 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
// -------------------------------------------------------- // --------------------------------------------------------
private async _executeActions(aiMessage: string): Promise<string[]> { private async _executeActions(aiMessage: string): Promise<string[]> {
const report: string[] = []; const report: string[] = [];
let brainModified = false;
let 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 // Fallback to active editor directory if no workspace folder is open
@@ -1431,6 +1432,7 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
fs.mkdirSync(dir, { recursive: true }); fs.mkdirSync(dir, { recursive: true });
} }
fs.writeFileSync(absPath, content, 'utf-8'); fs.writeFileSync(absPath, content, 'utf-8');
if (absPath.includes('.connect-ai-brain')) brainModified = true;
report.push(`✅ 생성: ${relPath}`); report.push(`✅ 생성: ${relPath}`);
if (!firstCreatedFile) { firstCreatedFile = absPath; } if (!firstCreatedFile) { firstCreatedFile = absPath; }
} catch (err: any) { } catch (err: any) {
@@ -1474,6 +1476,7 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
if (editCount > 0) { if (editCount > 0) {
fs.writeFileSync(absPath, fileContent, 'utf-8'); fs.writeFileSync(absPath, fileContent, 'utf-8');
if (absPath.includes('.connect-ai-brain')) brainModified = true;
report.push(`✏️ 편집 완료: ${relPath} (${editCount}건 수정)`); report.push(`✏️ 편집 완료: ${relPath} (${editCount}건 수정)`);
// Open edited file // Open edited file
vscode.window.showTextDocument(vscode.Uri.file(absPath), { preview: false }); vscode.window.showTextDocument(vscode.Uri.file(absPath), { preview: false });
@@ -1496,6 +1499,7 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
} else { } else {
fs.unlinkSync(absPath); fs.unlinkSync(absPath);
} }
if (absPath.includes('.connect-ai-brain')) brainModified = true;
report.push(`🗑️ 삭제: ${relPath}`); report.push(`🗑️ 삭제: ${relPath}`);
} else { } else {
report.push(`⚠️ 삭제 스킵: ${relPath} — 파일이 존재하지 않습니다.`); report.push(`⚠️ 삭제 스킵: ${relPath} — 파일이 존재하지 않습니다.`);
@@ -1628,6 +1632,20 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
vscode.window.showInformationMessage(`Connect AI: ${successCount}개 에이전트 작업 완료!`); vscode.window.showInformationMessage(`Connect AI: ${successCount}개 에이전트 작업 완료!`);
} }
// Auto-Push Second Brain changes to Cloud
if (brainModified) {
try {
const brainDir = path.join(os.homedir(), '.connect-ai-brain');
const { execSync } = require('child_process');
execSync(`git add .`, { cwd: brainDir });
execSync(`git commit -m "[P-Reinforce] Auto-synced structured knowledge"`, { cwd: brainDir });
execSync(`git push`, { cwd: brainDir });
report.push(`☁️ **[GitHub Sync]** 글로벌 뇌(Second Brain)에 지식이 성공적으로 자동 백업되었습니다!`);
} catch (err: any) {
report.push(`⚠️ **[GitHub Sync 보류]** 동기화 중 권한 문제가 발생했습니다 (수동 푸시 권장)`);
}
}
return report; return report;
} }