@ninebone/mcp 0.1.29 → 0.1.30

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/core/init.js +31 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninebone/mcp",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "description": "NineQuery AI Connector for Database",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/core/init.js CHANGED
@@ -57,42 +57,47 @@ async function createEnvFile(rl) {
57
57
  * 2. 프롬프트 파일(.md) 자동 복사 함수 (개선됨)
58
58
  */
59
59
  function createPromptFiles() {
60
- // 사용자가 명령어를 실행한 현재 터미널 위치(작업 디렉토리) 아래에 prompts 폴더를 만듭니다.
61
60
  const targetDir = path.join(process.cwd(), 'prompts');
62
61
 
63
- if (!fs.existsSync(targetDir)) {
64
- fs.mkdirSync(targetDir, { recursive: true });
65
- }
62
+ // 하위 폴더 구조까지 통째로 복사하기 위한 재귀 함수
63
+ function copyFolderRecursive(source, target) {
64
+ if (!fs.existsSync(target)) {
65
+ fs.mkdirSync(target, { recursive: true });
66
+ }
66
67
 
67
- // 디버깅을 위해 로그를 살짝 추가해두면 어디서 고장 났는지 알기 쉽습니다.
68
- console.log(`\n🔍 원본 프롬프트 탐색 경로: ${SOURCE_PROMPT_DIR}`);
69
- console.log(`📂 복사될 대상 경로: ${targetDir}`);
68
+ if (!fs.existsSync(source)) return;
70
69
 
71
- try {
72
- if (fs.existsSync(SOURCE_PROMPT_DIR)) {
73
- const files = fs.readdirSync(SOURCE_PROMPT_DIR);
70
+ const items = fs.readdirSync(source);
74
71
 
75
- // .md 파일 필터링 및 복사
76
- const mdFiles = files.filter(f => f.endsWith('.md'));
72
+ items.forEach((item) => {
73
+ const sourcePath = path.join(source, item);
74
+ const targetPath = path.join(target, item);
75
+ const stat = fs.statSync(sourcePath);
76
+
77
+ if (stat.isDirectory()) {
78
+ // 하위 폴더인 경우 재귀 호출 (예: prompts/system)
79
+ copyFolderRecursive(sourcePath, targetPath);
80
+ } else if (stat.isFile() && item.endsWith('.md')) {
81
+ // 마크다운 파일인 경우 복사 실행
82
+ const content = fs.readFileSync(sourcePath, 'utf-8');
83
+ fs.writeFileSync(targetPath, content.trim() + '\n', 'utf-8');
77
84
 
78
- if (mdFiles.length === 0) {
79
- console.log('⚠️ 원본 폴더에 마크다운(.md) 파일이 존재하지 않습니다.');
80
- return;
85
+ // 복사되는 상대 경로 이쁘게 출력하기
86
+ const relativePath = path.relative(SOURCE_PROMPT_DIR, sourcePath);
87
+ console.log(` └📄 ${relativePath} 생성 완료`);
81
88
  }
89
+ });
90
+ }
82
91
 
83
- mdFiles.forEach((filename) => {
84
- const sourcePath = path.join(SOURCE_PROMPT_DIR, filename);
85
- const targetPath = path.join(targetDir, filename);
92
+ try {
93
+ console.log(`\n🔍 원본 프롬프트 탐색 경로: ${SOURCE_PROMPT_DIR}`);
94
+ console.log(`📂 복사될 대상 경로: ${targetDir}`);
86
95
 
87
- const content = fs.readFileSync(sourcePath, 'utf-8');
88
- fs.writeFileSync(targetPath, content.trim() + '\n', 'utf-8');
89
- console.log(` └📄 ${filename} 복사 완료`);
90
- });
91
- console.log('✨ 프롬프트 파일(prompts/*.md) 배포가 성공적으로 완료되었습니다.');
96
+ if (fs.existsSync(SOURCE_PROMPT_DIR)) {
97
+ copyFolderRecursive(SOURCE_PROMPT_DIR, targetDir);
98
+ console.log('✨ 프롬프트 파일 및 폴더 구조 배포가 모두 완료되었습니다.');
92
99
  } else {
93
- // 여기가 실행된다면 package.json의 files 항목에 prompts 폴더가 담겼거나 경로 depth가 틀린 것입니다.
94
- console.error(`❌ [오류] 원본 템플릿 경로를 찾을 수 없습니다.`);
95
- console.error(` 현재 배포된 패키지 내부 구조를 확인하세요.`);
100
+ console.error(`❌ [경로 오류] 원본 템플릿 위치를 찾을 없습니다: ${SOURCE_PROMPT_DIR}`);
96
101
  }
97
102
  } catch (err) {
98
103
  console.error(`❌ 프롬프트 생성 중 오류 발생:`, err.message);