@optiqcode/cli 2.1.2 → 2.1.3
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/dist/index.js +17 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,6 +10,8 @@ import { getConfig, saveConfig } from './utils/config.js';
|
|
|
10
10
|
import { isValidDirectory, getGitIgnorePatterns, shouldIgnoreFile } from './utils/files.js';
|
|
11
11
|
const BACKEND_URL = process.env.OPTIQ_BACKEND_URL || 'https://api.optiqcode.com';
|
|
12
12
|
const ENGINE_URL = process.env.OPTIQ_ENGINE_URL || 'https://api.optiqcode.com';
|
|
13
|
+
// Debug mode - set OPTIQ_DEBUG=1 to see request details
|
|
14
|
+
const DEBUG = process.env.OPTIQ_DEBUG === '1';
|
|
13
15
|
// Helper to generate repository ID from path
|
|
14
16
|
function generateRepoId(targetPath) {
|
|
15
17
|
// Use path basename + hash of full path for uniqueness
|
|
@@ -290,14 +292,22 @@ async function indexOnce(targetPath, config) {
|
|
|
290
292
|
// Generate repository ID from path
|
|
291
293
|
const repoId = generateRepoId(targetPath);
|
|
292
294
|
// Upload in small batches to avoid gateway timeouts
|
|
293
|
-
const BATCH_SIZE =
|
|
295
|
+
const BATCH_SIZE = 10;
|
|
294
296
|
let totalChunks = 0;
|
|
297
|
+
if (DEBUG) {
|
|
298
|
+
console.log(chalk.gray(`\n[DEBUG] Sending to: ${ENGINE_URL}/api/v1/index`));
|
|
299
|
+
console.log(chalk.gray(`[DEBUG] Repo ID: ${repoId}`));
|
|
300
|
+
console.log(chalk.gray(`[DEBUG] Total files: ${filesArray.length}`));
|
|
301
|
+
}
|
|
295
302
|
spinner.text = 'Indexing...';
|
|
296
303
|
for (let i = 0; i < filesArray.length; i += BATCH_SIZE) {
|
|
297
304
|
const batch = filesArray.slice(i, i + BATCH_SIZE);
|
|
298
305
|
const batchNum = Math.floor(i / BATCH_SIZE) + 1;
|
|
299
306
|
const totalBatches = Math.ceil(filesArray.length / BATCH_SIZE);
|
|
300
307
|
spinner.text = `Indexing... ${batchNum}/${totalBatches}`;
|
|
308
|
+
if (DEBUG) {
|
|
309
|
+
console.log(chalk.gray(`\n[DEBUG] Batch ${batchNum}: ${batch.map(f => f.path).join(', ')}`));
|
|
310
|
+
}
|
|
301
311
|
// Retry logic for transient failures
|
|
302
312
|
let retries = 3;
|
|
303
313
|
let lastError = null;
|
|
@@ -324,6 +334,12 @@ async function indexOnce(targetPath, config) {
|
|
|
324
334
|
catch (err) {
|
|
325
335
|
lastError = err;
|
|
326
336
|
retries--;
|
|
337
|
+
if (DEBUG) {
|
|
338
|
+
console.log(chalk.red(`\n[DEBUG] Error: ${err.code || err.message}`));
|
|
339
|
+
if (err.response) {
|
|
340
|
+
console.log(chalk.red(`[DEBUG] Status: ${err.response.status}`));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
327
343
|
if (retries > 0) {
|
|
328
344
|
spinner.text = `Retrying batch ${batchNum}... (${retries} attempts left)`;
|
|
329
345
|
await new Promise(r => setTimeout(r, 2000)); // Wait 2s before retry
|