promptgraph-mcp 2.6.8 → 2.6.9
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/marketplace.js +28 -2
- package/package.json +1 -1
package/marketplace.js
CHANGED
|
@@ -13,6 +13,7 @@ import { isSkillFile } from './parser.js';
|
|
|
13
13
|
|
|
14
14
|
const REGISTRY_URL = 'https://raw.githubusercontent.com/NeiP4n/promptgraph-registry/main/registry.json';
|
|
15
15
|
const SKILL_COUNT_CACHE = path.join(PROMPTGRAPH_DIR, 'skill-counts.json');
|
|
16
|
+
const DEAD_REPOS_FILE = path.join(PROMPTGRAPH_DIR, 'dead-repos.json');
|
|
16
17
|
const SKILLS_DIR = path.join(SKILLS_STORE_DIR, 'marketplace');
|
|
17
18
|
|
|
18
19
|
// Atomically write content to dest via tmp — cleans up on failure
|
|
@@ -143,6 +144,21 @@ function writeSkillCountCache(data) {
|
|
|
143
144
|
} catch {}
|
|
144
145
|
}
|
|
145
146
|
|
|
147
|
+
function readDeadRepos() {
|
|
148
|
+
try { return JSON.parse(fs.readFileSync(DEAD_REPOS_FILE, 'utf8')); } catch { return []; }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function markDeadRepo(repoUrl) {
|
|
152
|
+
try {
|
|
153
|
+
const dead = readDeadRepos();
|
|
154
|
+
if (!dead.includes(repoUrl)) {
|
|
155
|
+
dead.push(repoUrl);
|
|
156
|
+
fs.mkdirSync(path.dirname(DEAD_REPOS_FILE), { recursive: true });
|
|
157
|
+
fs.writeFileSync(DEAD_REPOS_FILE, JSON.stringify(dead, null, 2));
|
|
158
|
+
}
|
|
159
|
+
} catch {}
|
|
160
|
+
}
|
|
161
|
+
|
|
146
162
|
async function fetchText(url) {
|
|
147
163
|
const cacheFile = path.join(PROMPTGRAPH_DIR, 'registry-cache.json');
|
|
148
164
|
const isRegistry = url === REGISTRY_URL;
|
|
@@ -275,7 +291,10 @@ export async function browseBundles(topK = 20) {
|
|
|
275
291
|
try {
|
|
276
292
|
const text = await fetchText(REGISTRY_URL);
|
|
277
293
|
const registry = JSON.parse(text);
|
|
278
|
-
const
|
|
294
|
+
const deadRepos = new Set(readDeadRepos());
|
|
295
|
+
const bundles = (registry.bundles || []).filter(b =>
|
|
296
|
+
validateRegistryEntry(b).ok && !deadRepos.has(b.repo_url)
|
|
297
|
+
);
|
|
279
298
|
const cache = readSkillCountCache();
|
|
280
299
|
const now = Date.now();
|
|
281
300
|
let changed = false;
|
|
@@ -346,7 +365,14 @@ export async function installBundle(bundleId) {
|
|
|
346
365
|
if (!bundle) return { error: `No bundle matching "${bundleId}"` };
|
|
347
366
|
|
|
348
367
|
if (bundle.repo_url) {
|
|
349
|
-
|
|
368
|
+
try {
|
|
369
|
+
await importFromGitHub(bundle.repo_url);
|
|
370
|
+
} catch (e) {
|
|
371
|
+
if (e.message && e.message.includes('No valid skills')) {
|
|
372
|
+
markDeadRepo(bundle.repo_url);
|
|
373
|
+
}
|
|
374
|
+
throw e;
|
|
375
|
+
}
|
|
350
376
|
return { success: true, bundle: bundle.name, type: 'repo_import', repo_url: bundle.repo_url };
|
|
351
377
|
}
|
|
352
378
|
|