promptgraph-mcp 2.4.1 → 2.4.2

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.
Files changed (2) hide show
  1. package/marketplace.js +51 -0
  2. package/package.json +1 -1
package/marketplace.js CHANGED
@@ -5,6 +5,7 @@ import { createHash } from 'crypto';
5
5
  import { spawnSync } from 'child_process';
6
6
  import { createRequire } from 'module';
7
7
  import { getDb } from './db.js';
8
+ import { globSync } from 'glob';
8
9
  import { validateSkill, validateBundle } from './validator.js';
9
10
  import { loadConfig, saveConfig, PROMPTGRAPH_DIR, SKILLS_STORE_DIR } from './config.js';
10
11
  import { importFromGitHub, validateRepoSkills } from './github-import.js';
@@ -398,3 +399,53 @@ export function recordFail(skillId) {
398
399
  ON CONFLICT(skill_id) DO UPDATE SET fail = fail + 1
399
400
  `).run(skillId);
400
401
  }
402
+
403
+ // Scan all imported repos, validate their .md files, and remove repos that fail.
404
+ // Returns { removed: string[], kept: string[], errors: string[] }.
405
+ export function pruneInvalidRepos() {
406
+ const config = loadConfig();
407
+ const removed = [];
408
+ const kept = [];
409
+ const errors = [];
410
+
411
+ const repoSources = config.sources.filter(s => s.source?.startsWith('github:'));
412
+ if (repoSources.length === 0) {
413
+ return { removed, kept, errors: [], message: 'No imported repos found.' };
414
+ }
415
+
416
+ for (const src of repoSources) {
417
+ const repoName = src.source.replace('github:', '');
418
+ if (!fs.existsSync(src.dir)) {
419
+ removed.push({ repo: repoName, reason: 'directory not found' });
420
+ config.sources = config.sources.filter(s => s !== src);
421
+ continue;
422
+ }
423
+
424
+ const mdFiles = globSync(`${src.dir}/**/*.md`);
425
+ if (mdFiles.length === 0) {
426
+ removed.push({ repo: repoName, reason: 'no .md files' });
427
+ config.sources = config.sources.filter(s => s !== src);
428
+ try { fs.rmSync(src.dir, { recursive: true, force: true }); } catch {}
429
+ continue;
430
+ }
431
+
432
+ const invalid = [];
433
+ for (const fp of mdFiles) {
434
+ const v = validateSkill(fp);
435
+ if (!v.ok) {
436
+ invalid.push({ file: path.relative(src.dir, fp), errors: v.errors });
437
+ }
438
+ }
439
+
440
+ if (invalid.length > 0) {
441
+ removed.push({ repo: repoName, reason: `${invalid.length}/${mdFiles.length} .md files failed validation`, invalid });
442
+ config.sources = config.sources.filter(s => s !== src);
443
+ try { fs.rmSync(src.dir, { recursive: true, force: true }); } catch (e) { errors.push(`Failed to remove ${src.dir}: ${e.message}`); }
444
+ } else {
445
+ kept.push(repoName);
446
+ }
447
+ }
448
+
449
+ saveConfig(config);
450
+ return { removed, kept, errors };
451
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptgraph-mcp",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "bin": {