archicore 0.4.3 → 0.4.4

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.
@@ -225,25 +225,43 @@ export async function uploadIndexData(projectId, data, onProgress) {
225
225
  const url = `${config.serverUrl}/api/projects/${projectId}/upload-index`;
226
226
  // Оценка размера данных
227
227
  const estimatedSize = estimateJsonSize(data);
228
- // Используем single request для большинства проектов (до 50K символов / 50MB)
229
- // Chunked upload используется только для очень больших проектов
230
- // ВАЖНО: chunked upload требует одного инстанса сервера (PM2 -i 1)
231
- const needsChunkedUpload = estimatedSize > MAX_PAYLOAD_SIZE ||
232
- data.symbols.length > SINGLE_REQUEST_MAX_SYMBOLS;
233
228
  onProgress?.({
234
229
  phase: 'preparing',
235
230
  current: 0,
236
231
  total: 100,
237
232
  message: `Preparing upload (${(estimatedSize / 1024 / 1024).toFixed(1)} MB, ${data.symbols.length} symbols)...`,
238
233
  });
239
- // Для большинства проектов - single request (работает с PM2 cluster mode)
240
- if (!needsChunkedUpload) {
234
+ // ВАЖНО: Chunked upload НЕ работает с PM2 cluster mode (разные процессы = разная память)
235
+ // Поэтому для проектов до 50K символов ВСЕГДА используем single request
236
+ // Если payload слишком большой - урезаем данные вместо chunked upload
237
+ if (data.symbols.length <= SINGLE_REQUEST_MAX_SYMBOLS) {
238
+ // Проект средний - используем single request
239
+ // Если payload > 50MB, урезаем fileContents
240
+ let uploadData = data;
241
+ if (estimatedSize > MAX_PAYLOAD_SIZE) {
242
+ debugLog(` Payload ${(estimatedSize / 1024 / 1024).toFixed(1)}MB exceeds limit, trimming fileContents`);
243
+ onProgress?.({
244
+ phase: 'preparing',
245
+ current: 0,
246
+ total: 100,
247
+ message: `Optimizing payload (trimming file contents)...`,
248
+ });
249
+ // Урезаем fileContents чтобы уместиться в лимит
250
+ const maxFileContents = Math.floor(data.fileContents.length * (MAX_PAYLOAD_SIZE / estimatedSize));
251
+ uploadData = {
252
+ ...data,
253
+ fileContents: data.fileContents.slice(0, Math.max(maxFileContents, 100)),
254
+ };
255
+ const newSize = estimateJsonSize(uploadData);
256
+ debugLog(` Trimmed payload to ${(newSize / 1024 / 1024).toFixed(1)}MB (${uploadData.fileContents.length} files)`);
257
+ }
241
258
  debugLog(` Using single request upload for ${data.symbols.length} symbols`);
242
- return uploadSingleRequest(url, projectId, data, config.accessToken || '', onProgress);
259
+ return uploadSingleRequest(url, projectId, uploadData, config.accessToken || '', onProgress);
243
260
  }
244
- // Для очень больших проектов - chunked upload (требует PM2 -i 1)
261
+ // Проект очень большой (>50K символов) - chunked upload
262
+ // ВНИМАНИЕ: требует PM2 -i 1 (один инстанс)
245
263
  debugLog(` Using chunked upload for very large project (${data.symbols.length} symbols)`);
246
- console.log(' ⚠ Large project detected. Chunked upload requires single server instance.');
264
+ console.log(' ⚠ Very large project (>50K symbols). Chunked upload requires single server instance (PM2 -i 1).');
247
265
  return uploadChunked(url, projectId, data, config.accessToken || '', onProgress);
248
266
  }
249
267
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archicore",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "AI Software Architect - code analysis, impact prediction, semantic search",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",