archicore 0.2.5 → 0.2.7

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.
@@ -11,8 +11,11 @@ import { loadConfig } from './config.js';
11
11
  const MAX_PAYLOAD_SIZE = 10 * 1024 * 1024; // 10MB per chunk
12
12
  const MAX_SYMBOLS_PER_CHUNK = 5000;
13
13
  const MAX_FILES_PER_CHUNK = 100;
14
- const UPLOAD_TIMEOUT = 60000; // 60 секунд на chunk
14
+ const UPLOAD_TIMEOUT = 120000; // 120 секунд на chunk (увеличено для больших проектов)
15
15
  const MAX_RETRIES = 3;
16
+ // Лимиты для минимальной загрузки
17
+ const MINIMAL_MAX_SYMBOLS = 10000;
18
+ const MINIMAL_MAX_FILES = 500;
16
19
  /**
17
20
  * Определение размера JSON в байтах
18
21
  */
@@ -298,20 +301,31 @@ async function uploadChunked(baseUrl, projectId, data, accessToken, onProgress)
298
301
  });
299
302
  try {
300
303
  // 1. Инициализируем chunked upload
301
- const initResponse = await fetchWithRetry(`${config.serverUrl}/api/projects/${projectId}/upload-index/init`, {
302
- method: 'POST',
303
- headers: {
304
- 'Content-Type': 'application/json',
305
- 'Authorization': `Bearer ${accessToken}`,
306
- },
307
- body: JSON.stringify({
308
- statistics: data.statistics,
309
- totalChunks,
310
- }),
311
- });
304
+ let initResponse;
305
+ try {
306
+ initResponse = await fetchWithRetry(`${config.serverUrl}/api/projects/${projectId}/upload-index/init`, {
307
+ method: 'POST',
308
+ headers: {
309
+ 'Content-Type': 'application/json',
310
+ 'Authorization': `Bearer ${accessToken}`,
311
+ },
312
+ body: JSON.stringify({
313
+ statistics: data.statistics,
314
+ totalChunks,
315
+ }),
316
+ }, 15000, // 15 секунд - короткий таймаут для проверки поддержки
317
+ 1 // Только 1 попытка
318
+ );
319
+ }
320
+ catch (initError) {
321
+ // Сервер не поддерживает chunked upload или недоступен
322
+ console.log(`[DEBUG] Chunked upload not supported, falling back to minimal data`);
323
+ return uploadMinimalData(baseUrl, projectId, data, accessToken, onProgress);
324
+ }
312
325
  if (!initResponse.ok) {
313
326
  // Fallback: если сервер не поддерживает chunked upload,
314
327
  // отправляем только минимальные данные
328
+ console.log(`[DEBUG] Init returned ${initResponse.status}, falling back to minimal data`);
315
329
  return uploadMinimalData(baseUrl, projectId, data, accessToken, onProgress);
316
330
  }
317
331
  const initResult = await initResponse.json();
@@ -408,21 +422,27 @@ async function uploadChunked(baseUrl, projectId, data, accessToken, onProgress)
408
422
  * Загрузка минимальных данных (fallback для серверов без chunked upload)
409
423
  */
410
424
  async function uploadMinimalData(url, _projectId, data, accessToken, onProgress) {
425
+ const symbolCount = data.symbols.length;
426
+ const fileCount = data.asts.length;
427
+ console.log(`[DEBUG] uploadMinimalData: ${symbolCount} symbols, ${fileCount} files`);
411
428
  onProgress?.({
412
429
  phase: 'uploading',
413
430
  current: 50,
414
431
  total: 100,
415
- message: 'Uploading minimal index (large project mode)...',
432
+ message: `Uploading minimal index (${Math.min(symbolCount, MINIMAL_MAX_SYMBOLS)} of ${symbolCount} symbols)...`,
416
433
  });
417
- // Отправляем только граф и статистику (без содержимого файлов и AST)
434
+ // Отправляем урезанные данные для очень больших проектов
435
+ // Граф отправляем полностью, но AST и символы урезаем
418
436
  const minimalData = {
419
- asts: data.asts.slice(0, MAX_FILES_PER_CHUNK), // Только первые N файлов
420
- symbols: data.symbols.slice(0, MAX_SYMBOLS_PER_CHUNK), // Только первые N символов
437
+ asts: data.asts.slice(0, MINIMAL_MAX_FILES),
438
+ symbols: data.symbols.slice(0, MINIMAL_MAX_SYMBOLS),
421
439
  graph: data.graph,
422
440
  statistics: data.statistics,
423
441
  // Без fileContents - это самая большая часть
424
442
  };
443
+ console.log(`[DEBUG] Minimal payload: ${minimalData.asts.length} ASTs, ${minimalData.symbols.length} symbols`);
425
444
  try {
445
+ console.log(`[DEBUG] Sending minimal data to ${url}`);
426
446
  const response = await fetchWithRetry(url, {
427
447
  method: 'POST',
428
448
  headers: {
@@ -430,9 +450,11 @@ async function uploadMinimalData(url, _projectId, data, accessToken, onProgress)
430
450
  'Authorization': `Bearer ${accessToken}`,
431
451
  },
432
452
  body: JSON.stringify(minimalData),
433
- }, 120000); // 2 минуты
453
+ }, 180000, 2); // 3 минуты, 2 попытки
454
+ console.log(`[DEBUG] Response status: ${response.status}`);
434
455
  if (!response.ok) {
435
456
  const errorBody = await response.json().catch(() => ({}));
457
+ console.log(`[DEBUG] Error body: ${JSON.stringify(errorBody)}`);
436
458
  const errorDetails = analyzeHttpError(response.status, errorBody);
437
459
  return {
438
460
  success: false,
@@ -449,10 +471,14 @@ async function uploadMinimalData(url, _projectId, data, accessToken, onProgress)
449
471
  });
450
472
  return {
451
473
  success: true,
452
- statistics: result.statistics,
474
+ statistics: result.statistics || {
475
+ filesCount: minimalData.asts.length,
476
+ symbolsCount: minimalData.symbols.length,
477
+ },
453
478
  };
454
479
  }
455
480
  catch (error) {
481
+ console.log(`[DEBUG] uploadMinimalData error: ${error}`);
456
482
  const errorDetails = analyzeNetworkError(error);
457
483
  return {
458
484
  success: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archicore",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "AI Software Architect - code analysis, impact prediction, semantic search",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -57,6 +57,7 @@
57
57
  "bcrypt": "^5.1.1",
58
58
  "boxen": "^8.0.1",
59
59
  "chalk": "^5.4.1",
60
+ "claude": "^0.1.1",
60
61
  "cli-progress": "^3.12.0",
61
62
  "cli-table3": "^0.6.5",
62
63
  "commander": "^12.1.0",
@@ -73,8 +74,8 @@
73
74
  "morgan": "^1.10.1",
74
75
  "multer": "^2.0.2",
75
76
  "openai": "^4.73.0",
76
- "pg": "^8.13.0",
77
77
  "ora": "^8.1.1",
78
+ "pg": "^8.13.0",
78
79
  "tree-sitter": "^0.21.1",
79
80
  "tree-sitter-javascript": "^0.21.4",
80
81
  "tree-sitter-python": "^0.21.0",