promptgraph-mcp 2.8.5 → 2.8.6
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/github-import.js +0 -2
- package/indexer.js +31 -8
- package/package.json +1 -1
package/github-import.js
CHANGED
|
@@ -732,8 +732,6 @@ export async function importFromGitHubLight(repoUrl) {
|
|
|
732
732
|
}
|
|
733
733
|
if (removedV > 0) removeEmptyDirs(destBase);
|
|
734
734
|
|
|
735
|
-
prog(`Running classifier...`);
|
|
736
|
-
await classifierCleanup(destBase);
|
|
737
735
|
process.stderr.write('\n');
|
|
738
736
|
|
|
739
737
|
const realCount = globSync(`${destBase}/**/*.md`).length;
|
package/indexer.js
CHANGED
|
@@ -255,7 +255,7 @@ export async function indexFile(filePath, source) {
|
|
|
255
255
|
await indexBatch(db, [{ ...skill, hash }]);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
// Index only one source directory —
|
|
258
|
+
// Index only one source directory — fast mode first (no embeddings), then embed in background
|
|
259
259
|
export async function indexSource(dir, sourceName) {
|
|
260
260
|
const db = getDb();
|
|
261
261
|
const files = globSync(`${dir}/**/*.md`);
|
|
@@ -280,6 +280,7 @@ export async function indexSource(dir, sourceName) {
|
|
|
280
280
|
let count = 0, skipped = 0, errors = 0, batch = [];
|
|
281
281
|
const start = Date.now();
|
|
282
282
|
|
|
283
|
+
// Pass 1: fast — upsert skills into DB with keyword search only (instant)
|
|
283
284
|
for (const file of files) {
|
|
284
285
|
try {
|
|
285
286
|
const norm = sanitizePath(file);
|
|
@@ -293,18 +294,40 @@ export async function indexSource(dir, sourceName) {
|
|
|
293
294
|
const parsed = parseSkillFile(file, sourceName, { raw });
|
|
294
295
|
batch.push({ ...parsed, hash });
|
|
295
296
|
if (batch.length >= BATCH_SIZE) {
|
|
296
|
-
await indexBatch(db, batch);
|
|
297
|
+
await indexBatch(db, batch, { fast: true });
|
|
297
298
|
count += batch.length; batch = [];
|
|
298
299
|
progress(count, total, { skipped, errors });
|
|
299
|
-
await new Promise(r => setImmediate ? setImmediate(r) : setTimeout(r, 0));
|
|
300
300
|
}
|
|
301
301
|
} catch (e) { errors++; count++; }
|
|
302
302
|
}
|
|
303
|
-
|
|
304
|
-
if (batch.length > 0) { await indexBatch(db, batch); count += batch.length; }
|
|
303
|
+
if (batch.length > 0) { await indexBatch(db, batch, { fast: true }); count += batch.length; }
|
|
305
304
|
progress(total, total, { skipped, errors });
|
|
306
305
|
progressDone();
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
306
|
+
const elapsed1 = ((Date.now() - start) / 1000).toFixed(1);
|
|
307
|
+
success(`Indexed ${chalk.white.bold(count)} skills from ${sourceName} ${chalk.gray(`(${skipped} skipped, ${elapsed1}s)`)}`);
|
|
308
|
+
info(chalk.gray(' Semantic embeddings generating in background — keyword search available now.'));
|
|
309
|
+
|
|
310
|
+
// Pass 2: embed in background (non-blocking)
|
|
311
|
+
setImmediate(async () => {
|
|
312
|
+
try {
|
|
313
|
+
const toEmbed = [];
|
|
314
|
+
for (const file of files) {
|
|
315
|
+
try {
|
|
316
|
+
const norm = sanitizePath(file);
|
|
317
|
+
const stat = fs.statSync(norm);
|
|
318
|
+
if (stat.size > MAX_FILE_SIZE) continue;
|
|
319
|
+
const raw = fs.readFileSync(norm, 'utf8');
|
|
320
|
+
if (!isSkillFile(file, raw)) continue;
|
|
321
|
+
const hash = createHash('md5').update(raw).digest('hex');
|
|
322
|
+
const parsed = parseSkillFile(file, sourceName, { raw });
|
|
323
|
+
toEmbed.push({ ...parsed, hash });
|
|
324
|
+
} catch {}
|
|
325
|
+
}
|
|
326
|
+
if (toEmbed.length === 0) return;
|
|
327
|
+
for (let i = 0; i < toEmbed.length; i += BATCH_SIZE) {
|
|
328
|
+
await indexBatch(db, toEmbed.slice(i, i + BATCH_SIZE), { fast: false });
|
|
329
|
+
}
|
|
330
|
+
await buildAnnIndex();
|
|
331
|
+
} catch {}
|
|
332
|
+
});
|
|
310
333
|
}
|