@optiqcode/cli 2.7.0 → 2.9.0

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/dist/index.js +34 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -308,13 +308,17 @@ async function indexOnce(targetPath, config) {
308
308
  }
309
309
  spinner.text = `Indexing ${filesArray.length} files...`;
310
310
  const totalBatches = Math.ceil(filesArray.length / BATCH_SIZE);
311
+ if (DEBUG) {
312
+ console.log(chalk.gray(`\n[DEBUG] Total files: ${filesArray.length}, Batch size: ${BATCH_SIZE}, Total batches: ${totalBatches}`));
313
+ }
311
314
  for (let i = 0; i < filesArray.length; i += BATCH_SIZE) {
312
315
  const batch = filesArray.slice(i, i + BATCH_SIZE);
313
316
  const batchNum = Math.floor(i / BATCH_SIZE) + 1;
314
317
  const filesProcessed = Math.min(i + BATCH_SIZE, filesArray.length);
315
318
  spinner.text = `Indexing... ${filesProcessed}/${filesArray.length} files (batch ${batchNum}/${totalBatches})`;
316
319
  if (DEBUG) {
317
- console.log(chalk.gray(`\n[DEBUG] Batch ${batchNum}: ${batch.map(f => f.path).join(', ')}`));
320
+ console.log(chalk.gray(`\n[DEBUG] Starting batch ${batchNum}/${totalBatches} (files ${i + 1}-${Math.min(i + BATCH_SIZE, filesArray.length)})`));
321
+ console.log(chalk.gray(`[DEBUG] Batch files: ${batch.map(f => f.path).join(', ')}`));
318
322
  }
319
323
  // Retry logic for transient failures
320
324
  let retries = 3;
@@ -331,12 +335,18 @@ async function indexOnce(targetPath, config) {
331
335
  },
332
336
  timeout: 300000, // 5 minutes per batch
333
337
  });
338
+ if (DEBUG) {
339
+ console.log(chalk.gray(`[DEBUG] Batch ${batchNum} response: success=${response.data.success}, chunks=${response.data.result?.chunks_created}, errors=${JSON.stringify(response.data.result?.errors || [])}`));
340
+ }
334
341
  if (!response.data.success) {
335
342
  spinner.fail(chalk.red('Indexing failed'));
336
343
  console.log(chalk.gray(response.data.result?.errors?.join('\n') || 'Unknown error'));
337
344
  return;
338
345
  }
339
346
  totalChunks += response.data.result?.chunks_created || 0;
347
+ if (DEBUG) {
348
+ console.log(chalk.gray(`[DEBUG] Batch ${batchNum} complete. Total chunks so far: ${totalChunks}`));
349
+ }
340
350
  break;
341
351
  }
342
352
  catch (err) {
@@ -347,6 +357,10 @@ async function indexOnce(targetPath, config) {
347
357
  console.log(chalk.red(`\n✗ Batch ${batchNum} failed: ${err.code || err.message}`));
348
358
  console.log(chalk.yellow(` Files: ${batch.map(f => f.path).join(', ')}`));
349
359
  console.log(chalk.gray(` Sizes: ${batch.map(f => `${f.path}(${Math.round(f.content.length / 1024)}KB)`).join(', ')}`));
360
+ if (DEBUG && err.response) {
361
+ console.log(chalk.gray(`[DEBUG] Response status: ${err.response.status}`));
362
+ console.log(chalk.gray(`[DEBUG] Response data: ${JSON.stringify(err.response.data)}`));
363
+ }
350
364
  if (retries > 0) {
351
365
  console.log(chalk.gray(` Retrying... (${retries} left)\n`));
352
366
  await new Promise(r => setTimeout(r, 2000));
@@ -358,6 +372,9 @@ async function indexOnce(targetPath, config) {
358
372
  throw lastError;
359
373
  }
360
374
  }
375
+ if (DEBUG) {
376
+ console.log(chalk.gray(`\n[DEBUG] All ${totalBatches} batches complete. Total chunks: ${totalChunks}`));
377
+ }
361
378
  spinner.succeed(chalk.cyan('Indexed'));
362
379
  console.log(chalk.gray(` ${filesArray.length} files • ${totalChunks} chunks`));
363
380
  console.log(chalk.cyan('\n📊 Repository ID:'));
@@ -404,11 +421,17 @@ async function watchDirectory(targetPath, config) {
404
421
  }
405
422
  // Upload in small batches to avoid gateway timeouts
406
423
  const BATCH_SIZE = 50;
424
+ const totalBatches = Math.ceil(filesArray.length / BATCH_SIZE);
425
+ if (DEBUG) {
426
+ console.log(chalk.gray(`\n[DEBUG] Watch initial index: ${filesArray.length} files, ${totalBatches} batches`));
427
+ }
407
428
  for (let i = 0; i < filesArray.length; i += BATCH_SIZE) {
408
429
  const batch = filesArray.slice(i, i + BATCH_SIZE);
409
430
  const batchNum = Math.floor(i / BATCH_SIZE) + 1;
410
- const totalBatches = Math.ceil(filesArray.length / BATCH_SIZE);
411
431
  spinner.text = `Indexing... ${batchNum}/${totalBatches}`;
432
+ if (DEBUG) {
433
+ console.log(chalk.gray(`[DEBUG] Watch batch ${batchNum}/${totalBatches} starting...`));
434
+ }
412
435
  // Retry logic for transient failures
413
436
  let retries = 3;
414
437
  let lastError = null;
@@ -424,6 +447,9 @@ async function watchDirectory(targetPath, config) {
424
447
  },
425
448
  timeout: 300000, // 5 minutes per batch
426
449
  });
450
+ if (DEBUG) {
451
+ console.log(chalk.gray(`[DEBUG] Watch batch ${batchNum} response: success=${response.data.success}, chunks=${response.data.result?.chunks_created}`));
452
+ }
427
453
  if (!response.data.success) {
428
454
  spinner.fail(chalk.red('Failed'));
429
455
  console.log(chalk.gray(response.data.result?.errors?.join('\n') || 'Unknown error'));
@@ -434,6 +460,9 @@ async function watchDirectory(targetPath, config) {
434
460
  catch (err) {
435
461
  lastError = err;
436
462
  retries--;
463
+ if (DEBUG) {
464
+ console.log(chalk.gray(`[DEBUG] Watch batch ${batchNum} error: ${err.message}`));
465
+ }
437
466
  if (retries > 0) {
438
467
  spinner.text = `Retrying batch ${batchNum}... (${retries} left)`;
439
468
  await new Promise(r => setTimeout(r, 2000));
@@ -444,6 +473,9 @@ async function watchDirectory(targetPath, config) {
444
473
  throw lastError;
445
474
  }
446
475
  }
476
+ if (DEBUG) {
477
+ console.log(chalk.gray(`[DEBUG] Watch initial index complete: all ${totalBatches} batches done`));
478
+ }
447
479
  spinner.succeed(chalk.cyan(`Indexed ${files.length} files`));
448
480
  console.log(chalk.gray(` Repo ID: ${repoId}\n`));
449
481
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optiqcode/cli",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "description": "CLI tool for Optiq - automatic code indexing and context engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",