@optiqcode/cli 2.1.3 → 2.1.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.
- package/dist/index.js +15 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -273,17 +273,24 @@ async function indexOnce(targetPath, config) {
|
|
|
273
273
|
spinner.text = `Reading ${files.length} files...`;
|
|
274
274
|
// Read files in parallel (100 at a time)
|
|
275
275
|
const PARALLEL_READS = 100;
|
|
276
|
+
const MAX_FILE_SIZE = 100_000; // 100KB max per file
|
|
276
277
|
const filesArray = [];
|
|
277
278
|
for (let i = 0; i < files.length; i += PARALLEL_READS) {
|
|
278
279
|
const chunk = files.slice(i, i + PARALLEL_READS);
|
|
279
280
|
const results = await Promise.allSettled(chunk.map(async (file) => {
|
|
280
281
|
const content = await fs.readFile(file, 'utf-8');
|
|
281
282
|
const relativePath = path.relative(targetPath, file).replace(/\\/g, '/');
|
|
283
|
+
// Skip files that are too large
|
|
284
|
+
if (content.length > MAX_FILE_SIZE) {
|
|
285
|
+
if (DEBUG)
|
|
286
|
+
console.log(chalk.yellow(`[DEBUG] Skipping large file: ${relativePath} (${Math.round(content.length / 1024)}KB)`));
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
282
289
|
return { path: relativePath, content };
|
|
283
290
|
}));
|
|
284
|
-
// Filter successful reads
|
|
291
|
+
// Filter successful reads (and non-null)
|
|
285
292
|
for (const result of results) {
|
|
286
|
-
if (result.status === 'fulfilled') {
|
|
293
|
+
if (result.status === 'fulfilled' && result.value) {
|
|
287
294
|
filesArray.push(result.value);
|
|
288
295
|
}
|
|
289
296
|
}
|
|
@@ -292,7 +299,7 @@ async function indexOnce(targetPath, config) {
|
|
|
292
299
|
// Generate repository ID from path
|
|
293
300
|
const repoId = generateRepoId(targetPath);
|
|
294
301
|
// Upload in small batches to avoid gateway timeouts
|
|
295
|
-
const BATCH_SIZE =
|
|
302
|
+
const BATCH_SIZE = 5;
|
|
296
303
|
let totalChunks = 0;
|
|
297
304
|
if (DEBUG) {
|
|
298
305
|
console.log(chalk.gray(`\n[DEBUG] Sending to: ${ENGINE_URL}/api/v1/index`));
|
|
@@ -376,23 +383,26 @@ async function watchDirectory(targetPath, config) {
|
|
|
376
383
|
spinner.text = `Reading ${files.length} files...`;
|
|
377
384
|
// Read files in parallel (100 at a time)
|
|
378
385
|
const PARALLEL_READS = 100;
|
|
386
|
+
const MAX_FILE_SIZE = 100_000; // 100KB max per file
|
|
379
387
|
const filesArray = [];
|
|
380
388
|
for (let i = 0; i < files.length; i += PARALLEL_READS) {
|
|
381
389
|
const chunk = files.slice(i, i + PARALLEL_READS);
|
|
382
390
|
const results = await Promise.allSettled(chunk.map(async (file) => {
|
|
383
391
|
const content = await fs.readFile(file, 'utf-8');
|
|
384
392
|
const relativePath = path.relative(targetPath, file).replace(/\\/g, '/');
|
|
393
|
+
if (content.length > MAX_FILE_SIZE)
|
|
394
|
+
return null;
|
|
385
395
|
return { path: relativePath, content };
|
|
386
396
|
}));
|
|
387
397
|
for (const result of results) {
|
|
388
|
-
if (result.status === 'fulfilled') {
|
|
398
|
+
if (result.status === 'fulfilled' && result.value) {
|
|
389
399
|
filesArray.push(result.value);
|
|
390
400
|
}
|
|
391
401
|
}
|
|
392
402
|
spinner.text = `Reading... ${Math.min(i + PARALLEL_READS, files.length)}/${files.length}`;
|
|
393
403
|
}
|
|
394
404
|
// Upload in small batches to avoid gateway timeouts
|
|
395
|
-
const BATCH_SIZE =
|
|
405
|
+
const BATCH_SIZE = 5;
|
|
396
406
|
for (let i = 0; i < filesArray.length; i += BATCH_SIZE) {
|
|
397
407
|
const batch = filesArray.slice(i, i + BATCH_SIZE);
|
|
398
408
|
const batchNum = Math.floor(i / BATCH_SIZE) + 1;
|