promptgraph-mcp 2.4.5 → 2.4.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 +28 -0
- package/package.json +1 -1
package/github-import.js
CHANGED
|
@@ -238,6 +238,19 @@ function cleanupRepoDir(dirPath, SKIP_RE) {
|
|
|
238
238
|
return removed;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
+
// Recursively remove empty directories
|
|
242
|
+
function removeEmptyDirs(dirPath) {
|
|
243
|
+
let entries;
|
|
244
|
+
try { entries = fs.readdirSync(dirPath, { withFileTypes: true }); } catch { return; }
|
|
245
|
+
for (const entry of entries) {
|
|
246
|
+
if (entry.name === '.git') continue;
|
|
247
|
+
if (!entry.isDirectory()) continue;
|
|
248
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
249
|
+
removeEmptyDirs(fullPath);
|
|
250
|
+
try { if (fs.readdirSync(fullPath).length === 0) fs.rmdirSync(fullPath); } catch {}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
241
254
|
// Update sparse repo — fetch + reset
|
|
242
255
|
function sparseUpdate(dest, subdir) {
|
|
243
256
|
const fetch = git(['fetch', '--depth=1', 'origin'], dest);
|
|
@@ -353,6 +366,21 @@ export async function importFromGitHub(repoUrl) {
|
|
|
353
366
|
// Remove doc files anywhere in the cloned tree
|
|
354
367
|
cleanupRepoRoot(dest);
|
|
355
368
|
|
|
369
|
+
// Validate every .md file — delete those that fail
|
|
370
|
+
const allMd = globSync(`${dest}/**/*.md`);
|
|
371
|
+
let removedInvalid = 0;
|
|
372
|
+
for (const fp of allMd) {
|
|
373
|
+
const v = validateSkill(fp);
|
|
374
|
+
if (!v.ok) {
|
|
375
|
+
try { fs.unlinkSync(fp); removedInvalid++; } catch {}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (removedInvalid > 0) {
|
|
379
|
+
console.log(`Removed ${removedInvalid} invalid .md files (failed validation)`);
|
|
380
|
+
// Clean up empty dirs left behind
|
|
381
|
+
removeEmptyDirs(dest);
|
|
382
|
+
}
|
|
383
|
+
|
|
356
384
|
const { dir: skillsDir, label } = detectSkillsDirLocal(dest);
|
|
357
385
|
const mdFiles = globSync(`${skillsDir}/**/*.md`);
|
|
358
386
|
|