docuking-mcp 1.2.4 → 1.2.5
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/index.js +75 -60
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1137,30 +1137,6 @@ docuking_init을 먼저 실행하세요.`,
|
|
|
1137
1137
|
};
|
|
1138
1138
|
}
|
|
1139
1139
|
|
|
1140
|
-
// 파일 업로드 (진행률 표시)
|
|
1141
|
-
const results = [];
|
|
1142
|
-
const total = filesToPush.length;
|
|
1143
|
-
let current = 0;
|
|
1144
|
-
let skipped = 0;
|
|
1145
|
-
|
|
1146
|
-
// 시작 안내 메시지 출력 (AI가 사용자에게 전달할 수 있도록)
|
|
1147
|
-
console.error(`[DocuKing] Push 시작: ${total}개 파일`);
|
|
1148
|
-
console.error(`[DocuKing] 💡 실시간 진행상황은 DocuKing 웹(https://docuking.ai)에서 확인하세요`);
|
|
1149
|
-
|
|
1150
|
-
// Sync 시작 알림 (웹에서 프로그레스바 표시용)
|
|
1151
|
-
try {
|
|
1152
|
-
await fetch(`${API_ENDPOINT}/projects/${projectId}/sync/start`, {
|
|
1153
|
-
method: 'POST',
|
|
1154
|
-
headers: {
|
|
1155
|
-
'Content-Type': 'application/json',
|
|
1156
|
-
'Authorization': `Bearer ${API_KEY}`,
|
|
1157
|
-
},
|
|
1158
|
-
body: JSON.stringify({ totalFiles: total }),
|
|
1159
|
-
});
|
|
1160
|
-
} catch (e) {
|
|
1161
|
-
console.error('[DocuKing] Sync 시작 알림 실패:', e.message);
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
1140
|
// 서버에서 파일 해시 조회 (변경 감지용)
|
|
1165
1141
|
let serverFileHashes = {};
|
|
1166
1142
|
try {
|
|
@@ -1181,36 +1157,82 @@ docuking_init을 먼저 실행하세요.`,
|
|
|
1181
1157
|
console.error('[DocuKing] 파일 해시 조회 실패:', e.message);
|
|
1182
1158
|
}
|
|
1183
1159
|
|
|
1160
|
+
// ★ 변경된 파일만 필터링 (업로드 전에 미리 계산)
|
|
1161
|
+
const changedFiles = [];
|
|
1162
|
+
const unchangedFiles = [];
|
|
1163
|
+
|
|
1184
1164
|
for (const file of filesToPush) {
|
|
1165
|
+
let fileHash;
|
|
1166
|
+
let content;
|
|
1167
|
+
let encoding = 'utf-8';
|
|
1168
|
+
|
|
1169
|
+
if (file.fileType === 'binary') {
|
|
1170
|
+
const buffer = fs.readFileSync(file.fullPath);
|
|
1171
|
+
fileHash = crypto.createHash('sha256').update(buffer).digest('hex');
|
|
1172
|
+
content = buffer.toString('base64');
|
|
1173
|
+
encoding = 'base64';
|
|
1174
|
+
} else {
|
|
1175
|
+
content = fs.readFileSync(file.fullPath, 'utf-8');
|
|
1176
|
+
fileHash = crypto.createHash('sha256').update(content, 'utf-8').digest('hex');
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
if (serverFileHashes[file.path] === fileHash) {
|
|
1180
|
+
unchangedFiles.push(file.path);
|
|
1181
|
+
} else {
|
|
1182
|
+
changedFiles.push({ ...file, content, encoding, fileHash });
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
const totalLocal = filesToPush.length;
|
|
1187
|
+
const totalChanged = changedFiles.length;
|
|
1188
|
+
const totalUnchanged = unchangedFiles.length;
|
|
1189
|
+
|
|
1190
|
+
// ★ 변경된 파일이 없으면 즉시 반환
|
|
1191
|
+
if (totalChanged === 0) {
|
|
1192
|
+
return {
|
|
1193
|
+
content: [
|
|
1194
|
+
{
|
|
1195
|
+
type: 'text',
|
|
1196
|
+
text: `변경된 파일이 없습니다.
|
|
1197
|
+
|
|
1198
|
+
📊 로컬 파일: ${totalLocal}개
|
|
1199
|
+
✓ 서버와 동일: ${totalUnchanged}개
|
|
1200
|
+
⊘ 변경 필요: 0개
|
|
1201
|
+
|
|
1202
|
+
이미 모든 파일이 서버와 동기화되어 있습니다.`,
|
|
1203
|
+
},
|
|
1204
|
+
],
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
// ★ 변경된 파일만 업로드 (AI에게 명확히 알림)
|
|
1209
|
+
console.error(`[DocuKing] 변경 감지 완료: 전체 ${totalLocal}개 중 ${totalChanged}개만 업로드`);
|
|
1210
|
+
console.error(`[DocuKing] 💡 실시간 진행상황은 DocuKing 웹(https://docuking.ai)에서 확인하세요`);
|
|
1211
|
+
|
|
1212
|
+
// Sync 시작 알림 (변경된 파일 수만 전달)
|
|
1213
|
+
try {
|
|
1214
|
+
await fetch(`${API_ENDPOINT}/projects/${projectId}/sync/start`, {
|
|
1215
|
+
method: 'POST',
|
|
1216
|
+
headers: {
|
|
1217
|
+
'Content-Type': 'application/json',
|
|
1218
|
+
'Authorization': `Bearer ${API_KEY}`,
|
|
1219
|
+
},
|
|
1220
|
+
body: JSON.stringify({ totalFiles: totalChanged }),
|
|
1221
|
+
});
|
|
1222
|
+
} catch (e) {
|
|
1223
|
+
console.error('[DocuKing] Sync 시작 알림 실패:', e.message);
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
// 파일 업로드 (변경된 파일만)
|
|
1227
|
+
const results = [];
|
|
1228
|
+
let current = 0;
|
|
1229
|
+
|
|
1230
|
+
for (const file of changedFiles) {
|
|
1185
1231
|
current++;
|
|
1186
|
-
const progress = `${current}/${
|
|
1232
|
+
const progress = `${current}/${totalChanged}`;
|
|
1187
1233
|
|
|
1188
1234
|
try {
|
|
1189
|
-
|
|
1190
|
-
let fileHash;
|
|
1191
|
-
let content;
|
|
1192
|
-
let encoding = 'utf-8';
|
|
1193
|
-
|
|
1194
|
-
if (file.fileType === 'binary') {
|
|
1195
|
-
// 바이너리 파일은 Base64로 인코딩
|
|
1196
|
-
const buffer = fs.readFileSync(file.fullPath);
|
|
1197
|
-
fileHash = crypto.createHash('sha256').update(buffer).digest('hex');
|
|
1198
|
-
content = buffer.toString('base64');
|
|
1199
|
-
encoding = 'base64';
|
|
1200
|
-
} else {
|
|
1201
|
-
// 텍스트 파일은 UTF-8
|
|
1202
|
-
content = fs.readFileSync(file.fullPath, 'utf-8');
|
|
1203
|
-
fileHash = crypto.createHash('sha256').update(content, 'utf-8').digest('hex');
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
// 변경 감지: 서버에 같은 해시가 있으면 스킵
|
|
1207
|
-
if (serverFileHashes[file.path] === fileHash) {
|
|
1208
|
-
const resultText = `${progress} ⊘ ${file.path} (변경 없음)`;
|
|
1209
|
-
results.push(resultText);
|
|
1210
|
-
console.log(resultText);
|
|
1211
|
-
skipped++;
|
|
1212
|
-
continue;
|
|
1213
|
-
}
|
|
1235
|
+
const { content, encoding, fileHash } = file;
|
|
1214
1236
|
|
|
1215
1237
|
// 재시도 로직 (최대 3회)
|
|
1216
1238
|
let lastError = null;
|
|
@@ -1325,17 +1347,16 @@ docuking_init을 먼저 실행하세요.`,
|
|
|
1325
1347
|
|
|
1326
1348
|
const successCount = results.filter(r => r.includes('✓')).length;
|
|
1327
1349
|
const failCount = results.filter(r => r.includes('✗')).length;
|
|
1328
|
-
const skippedCount = skipped; // 이미 계산된 스킵 개수 사용
|
|
1329
1350
|
const excludedCount = excludedFiles.length;
|
|
1330
1351
|
|
|
1331
|
-
// 요약 정보
|
|
1332
|
-
let summary = `\n📦 커밋 메시지: "${message}"\n\n📊 처리 결과:\n -
|
|
1352
|
+
// 요약 정보 (★ 변경된 파일만 업로드했음을 명확히 표시)
|
|
1353
|
+
let summary = `\n📦 커밋 메시지: "${message}"\n\n📊 처리 결과:\n - 로컬 파일: ${totalLocal}개\n - 변경 없음 (스킵): ${totalUnchanged}개\n - 변경 감지: ${totalChanged}개\n - 업로드 성공: ${successCount}개\n - 업로드 실패: ${failCount}개`;
|
|
1333
1354
|
if (excludedCount > 0) {
|
|
1334
1355
|
summary += `\n - 제외 (압축/설치파일): ${excludedCount}개`;
|
|
1335
1356
|
}
|
|
1336
1357
|
|
|
1337
1358
|
// 상세 결과를 표시 (Git처럼)
|
|
1338
|
-
let resultText = `✓ Push
|
|
1359
|
+
let resultText = `✓ Push 완료! (변경된 ${totalChanged}개 파일만 업로드)${summary}`;
|
|
1339
1360
|
|
|
1340
1361
|
// 업로드된 파일이 있으면 상세 목록 표시
|
|
1341
1362
|
if (successCount > 0) {
|
|
@@ -1343,12 +1364,6 @@ docuking_init을 먼저 실행하세요.`,
|
|
|
1343
1364
|
resultText += `\n\n📤 업로드된 파일 (${successCount}개):\n${uploadedFiles.map(r => ` ${r.replace(/^\d+\/\d+ /, '')}`).join('\n')}`;
|
|
1344
1365
|
}
|
|
1345
1366
|
|
|
1346
|
-
// 스킵된 파일이 있으면 표시
|
|
1347
|
-
if (skippedCount > 0) {
|
|
1348
|
-
const skippedFiles = results.filter(r => r.includes('⊘'));
|
|
1349
|
-
resultText += `\n\n⏭️ 스킵된 파일 (${skippedCount}개, 변경 없음):\n${skippedFiles.map(r => ` ${r.replace(/^\d+\/\d+ /, '')}`).join('\n')}`;
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
1367
|
// 실패한 파일이 있으면 표시
|
|
1353
1368
|
if (failCount > 0) {
|
|
1354
1369
|
const failedFiles = results.filter(r => r.includes('✗'));
|