promptgraph-mcp 2.6.4 → 2.6.5
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 +32 -6
- package/package.json +1 -1
package/github-import.js
CHANGED
|
@@ -429,36 +429,50 @@ function detectSkillsDirLocal(repoRoot) {
|
|
|
429
429
|
return { dir: repoRoot, label: '(root)', sparse: false };
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
//
|
|
432
|
+
// Remove files classified as non-skills by embedding classifier (only if model is trained)
|
|
433
433
|
async function classifierCleanup(dest) {
|
|
434
434
|
const mdFiles = globSync(`${dest}/**/*.md`);
|
|
435
435
|
if (mdFiles.length === 0) return;
|
|
436
436
|
|
|
437
437
|
const parsed = [];
|
|
438
438
|
const fileMap = [];
|
|
439
|
+
let heuristicRemoved = 0;
|
|
440
|
+
|
|
439
441
|
for (const fp of mdFiles) {
|
|
440
442
|
try {
|
|
441
443
|
const raw = fs.readFileSync(fp, 'utf8');
|
|
442
444
|
if (!isSkillFile(fp, raw)) continue;
|
|
445
|
+
if (!seemsLikeSkill(raw)) {
|
|
446
|
+
try { fs.unlinkSync(fp); heuristicRemoved++; } catch {}
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
443
449
|
parsed.push(parseSkillFile(fp, '', { raw }));
|
|
444
450
|
fileMap.push(fp);
|
|
445
451
|
} catch {}
|
|
446
452
|
}
|
|
447
453
|
|
|
448
|
-
if (
|
|
454
|
+
if (heuristicRemoved > 0) {
|
|
455
|
+
console.log(`Removed ${heuristicRemoved} files by content heuristic`);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (parsed.length === 0) {
|
|
459
|
+
if (heuristicRemoved > 0) removeEmptyDirs(dest);
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
449
462
|
|
|
450
463
|
const filtered = await filterWithClassifier(parsed);
|
|
451
464
|
const keptPaths = new Set(filtered.map(s => s.path));
|
|
452
465
|
|
|
453
|
-
let
|
|
466
|
+
let classifierRemoved = 0;
|
|
454
467
|
for (const fp of fileMap) {
|
|
455
468
|
if (!keptPaths.has(fp)) {
|
|
456
|
-
try { fs.unlinkSync(fp);
|
|
469
|
+
try { fs.unlinkSync(fp); classifierRemoved++; } catch {}
|
|
457
470
|
}
|
|
458
471
|
}
|
|
459
472
|
|
|
460
|
-
|
|
461
|
-
|
|
473
|
+
const totalRemoved = heuristicRemoved + classifierRemoved;
|
|
474
|
+
if (totalRemoved > 0) {
|
|
475
|
+
console.log(`Removed ${totalRemoved} non-skill files (heuristic: ${heuristicRemoved}, classifier: ${classifierRemoved})`);
|
|
462
476
|
removeEmptyDirs(dest);
|
|
463
477
|
}
|
|
464
478
|
}
|
|
@@ -566,6 +580,18 @@ export async function importFromGitHub(repoUrl) {
|
|
|
566
580
|
|
|
567
581
|
await classifierCleanup(dest);
|
|
568
582
|
|
|
583
|
+
// Update skill count cache with real survivor count
|
|
584
|
+
const realCount = globSync(`${dest}/**/*.md`).length;
|
|
585
|
+
const cachePath = path.join(PROMPTGRAPH_DIR, 'skill-counts.json');
|
|
586
|
+
try {
|
|
587
|
+
const cache = JSON.parse(fs.readFileSync(cachePath, 'utf8'));
|
|
588
|
+
if (cache[url]) {
|
|
589
|
+
cache[url].count = realCount;
|
|
590
|
+
cache[url].ts = Date.now();
|
|
591
|
+
fs.writeFileSync(cachePath, JSON.stringify(cache, null, 2));
|
|
592
|
+
}
|
|
593
|
+
} catch {}
|
|
594
|
+
|
|
569
595
|
const { dir: localDir, label: localLabel } = detectSkillsDirLocal(dest);
|
|
570
596
|
// Prefer the known skillsSubdir (from API detection or sparse patterns) as the
|
|
571
597
|
// canonical skills directory — it's more accurate than local heuristics for
|