@nine-lab/nine-connector 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/init.js +39 -3
package/package.json
CHANGED
package/src/core/init.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import readline from 'readline';
|
|
4
|
-
import { DEFAULT_PROMPTS } from './prompts.js'; // 분리한 프롬프트 가져오기
|
|
4
|
+
//import { DEFAULT_PROMPTS } from './prompts.js'; // 분리한 프롬프트 가져오기
|
|
5
|
+
|
|
6
|
+
// 현재 파일(init.js)의 위치를 기준으로 패키지 루트의 prompts 폴더 경로 계산
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
// init.js가 src/core/ 밑에 있다면, ../../prompts가 원본 위치가 됩니다.
|
|
10
|
+
const SOURCE_PROMPT_DIR = path.resolve(__dirname, '../../prompts');
|
|
5
11
|
|
|
6
12
|
/**
|
|
7
13
|
* 1. .env 파일 생성 담당 함수
|
|
@@ -10,7 +16,7 @@ async function createEnvFile(rl) {
|
|
|
10
16
|
const questions = [
|
|
11
17
|
{ key: 'SERVER_PORT', label: '1. 커넥터 서버 포트', default: '3000' },
|
|
12
18
|
{ key: 'GEMINI_API_KEY', label: '2. Gemini API Key', default: '' },
|
|
13
|
-
{ key: 'GEMINI_MODEL', label: '3. 사용할 모델', default: 'gemini-
|
|
19
|
+
{ key: 'GEMINI_MODEL', label: '3. 사용할 모델', default: 'gemini-2.5-flash' },
|
|
14
20
|
{ key: 'DB_TYPE', label: '4. DB 종류 (mysql, pg, mariadb)', default: 'mysql' },
|
|
15
21
|
{ key: 'DB_HOST', label: '5. DB 호스트', default: '127.0.0.1' },
|
|
16
22
|
{ key: 'DB_PORT', label: '6. DB 포트', default: '3306' },
|
|
@@ -51,7 +57,7 @@ async function createEnvFile(rl) {
|
|
|
51
57
|
/**
|
|
52
58
|
* 2. 프롬프트 파일(.md) 생성 담당 함수
|
|
53
59
|
*/
|
|
54
|
-
function
|
|
60
|
+
function createPromptFiles2() {
|
|
55
61
|
const promptDir = path.join(process.cwd(), 'prompts');
|
|
56
62
|
|
|
57
63
|
if (!fs.existsSync(promptDir)) {
|
|
@@ -68,6 +74,36 @@ function createPromptFiles() {
|
|
|
68
74
|
console.log('프롬프트 파일(prompts/*.md) 생성이 완료되었습니다.');
|
|
69
75
|
}
|
|
70
76
|
|
|
77
|
+
function createPromptFiles() {
|
|
78
|
+
const targetDir = path.join(process.cwd(), 'prompts');
|
|
79
|
+
|
|
80
|
+
// 사용자의 프로젝트 폴더에 prompts 폴더 생성
|
|
81
|
+
if (!fs.existsSync(targetDir)) {
|
|
82
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const templateFiles = ['table-filter.md', 'query-generator.md'];
|
|
86
|
+
|
|
87
|
+
templateFiles.forEach((filename) => {
|
|
88
|
+
const sourcePath = path.join(SOURCE_PROMPT_DIR, filename);
|
|
89
|
+
const targetPath = path.join(targetDir, filename);
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
if (fs.existsSync(sourcePath)) {
|
|
93
|
+
// 원본을 읽어서 사용자 폴더에 생성 (개행 문자 보장)
|
|
94
|
+
const content = fs.readFileSync(sourcePath, 'utf-8');
|
|
95
|
+
fs.writeFileSync(targetPath, content.trim() + '\n', 'utf-8');
|
|
96
|
+
} else {
|
|
97
|
+
console.error(`원본 템플릿을 찾을 수 없습니다: ${sourcePath}`);
|
|
98
|
+
}
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.error(`${filename} 생성 중 오류 발생:`, err.message);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
console.log('프롬프트 파일(prompts/*.md) 생성이 완료되었습니다.');
|
|
105
|
+
}
|
|
106
|
+
|
|
71
107
|
/**
|
|
72
108
|
* 메인 실행 함수
|
|
73
109
|
*/
|