feat: force folder selection before brain pack injection or github sync
This commit is contained in:
+1
-1
@@ -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.2.14",
|
"version": "2.2.15",
|
||||||
"publisher": "connectailab",
|
"publisher": "connectailab",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"icon": "assets/icon.png",
|
"icon": "assets/icon.png",
|
||||||
|
|||||||
+50
-1
@@ -37,6 +37,35 @@ function _getBrainDir(): string {
|
|||||||
return path.join(os.homedir(), '.connect-ai-brain');
|
return path.join(os.homedir(), '.connect-ai-brain');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _isBrainDirExplicitlySet(): boolean {
|
||||||
|
const { localBrainPath } = getConfig();
|
||||||
|
return !!(localBrainPath && localBrainPath.trim() !== '');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function _ensureBrainDir(): Promise<string | null> {
|
||||||
|
if (_isBrainDirExplicitlySet()) {
|
||||||
|
return _getBrainDir();
|
||||||
|
}
|
||||||
|
// 폴더 미설정 → 사용자에게 강제 선택 요청
|
||||||
|
const result = await vscode.window.showInformationMessage(
|
||||||
|
'📁 지식을 저장할 폴더를 먼저 선택해주세요! (내 지식이 저장될 곳입니다)',
|
||||||
|
'폴더 선택하기'
|
||||||
|
);
|
||||||
|
if (result !== '폴더 선택하기') return null;
|
||||||
|
|
||||||
|
const folders = await vscode.window.showOpenDialog({
|
||||||
|
canSelectFolders: true, canSelectFiles: false, canSelectMany: false,
|
||||||
|
openLabel: '이 폴더를 내 지식 폴더로 사용',
|
||||||
|
title: '🧠 내 지식 폴더 선택'
|
||||||
|
});
|
||||||
|
if (!folders || folders.length === 0) return null;
|
||||||
|
|
||||||
|
const selectedPath = folders[0].fsPath;
|
||||||
|
await vscode.workspace.getConfiguration('connectAiLab').update('localBrainPath', selectedPath, vscode.ConfigurationTarget.Global);
|
||||||
|
vscode.window.showInformationMessage(`✅ 지식 폴더가 설정되었습니다: ${selectedPath}`);
|
||||||
|
return selectedPath;
|
||||||
|
}
|
||||||
|
|
||||||
const EXCLUDED_DIRS = new Set([
|
const EXCLUDED_DIRS = new Set([
|
||||||
'node_modules', '.git', '.vscode', 'out', 'dist', 'build',
|
'node_modules', '.git', '.vscode', 'out', 'dist', 'build',
|
||||||
'.next', '.cache', '__pycache__', '.DS_Store', 'coverage',
|
'.next', '.cache', '__pycache__', '.DS_Store', 'coverage',
|
||||||
@@ -350,7 +379,21 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
req.on('end', async () => {
|
req.on('end', async () => {
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(body);
|
const parsed = JSON.parse(body);
|
||||||
const brainDir = _getBrainDir();
|
|
||||||
|
// 폴더 미설정 시 강제 선택 요청
|
||||||
|
let brainDir: string;
|
||||||
|
if (!_isBrainDirExplicitlySet()) {
|
||||||
|
const ensured = await _ensureBrainDir();
|
||||||
|
if (!ensured) {
|
||||||
|
res.writeHead(400, { 'Content-Type': 'application/json' });
|
||||||
|
res.end(JSON.stringify({ error: '지식 폴더를 먼저 선택해주세요.' }));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
brainDir = ensured;
|
||||||
|
} else {
|
||||||
|
brainDir = _getBrainDir();
|
||||||
|
}
|
||||||
|
|
||||||
if (!fs.existsSync(brainDir)) {
|
if (!fs.existsSync(brainDir)) {
|
||||||
fs.mkdirSync(brainDir, { recursive: true });
|
fs.mkdirSync(brainDir, { recursive: true });
|
||||||
}
|
}
|
||||||
@@ -1111,6 +1154,12 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 폴더 미설정 시 먼저 폴더 선택 강제
|
||||||
|
if (!_isBrainDirExplicitlySet()) {
|
||||||
|
const ensured = await _ensureBrainDir();
|
||||||
|
if (!ensured) { return; }
|
||||||
|
}
|
||||||
|
|
||||||
let secondBrainRepo = vscode.workspace.getConfiguration('connectAiLab').get<string>('secondBrainRepo', '');
|
let secondBrainRepo = vscode.workspace.getConfiguration('connectAiLab').get<string>('secondBrainRepo', '');
|
||||||
|
|
||||||
// UX 극대화: 안 채워져 있으면 에러 내뱉지 말고 입력창 띄우기!
|
// UX 극대화: 안 채워져 있으면 에러 내뱉지 말고 입력창 띄우기!
|
||||||
|
|||||||
Reference in New Issue
Block a user