promptgraph-mcp 2.8.8 → 2.9.0
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/bundle-counts.js +9 -0
- package/commands/marketplace.js +16 -8
- package/github-import.js +8 -8
- package/package.json +1 -1
package/bundle-counts.js
CHANGED
|
@@ -75,6 +75,15 @@ async function countSubdirMdFiles(ownerRepo) {
|
|
|
75
75
|
}).length;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
// Write a known real count (e.g. after install) — skips API, sets TTL to 24h
|
|
79
|
+
export function setCachedCount(repoUrl, count) {
|
|
80
|
+
try {
|
|
81
|
+
const cache = loadCache();
|
|
82
|
+
cache[repoUrl] = { count, ts: Date.now() };
|
|
83
|
+
saveCache(cache);
|
|
84
|
+
} catch {}
|
|
85
|
+
}
|
|
86
|
+
|
|
78
87
|
// Read cached count for a bundle (returns null if stale or missing)
|
|
79
88
|
export function getCachedCount(repoUrl) {
|
|
80
89
|
const cache = loadCache();
|
package/commands/marketplace.js
CHANGED
|
@@ -39,9 +39,22 @@ export default async function handler(args, bin) {
|
|
|
39
39
|
|
|
40
40
|
if (skills?.error) { error(skills.error); process.exit(1); }
|
|
41
41
|
|
|
42
|
-
const { getCachedCount, refreshCountsInBackground } = await import('../bundle-counts.js');
|
|
42
|
+
const { getCachedCount, setCachedCount, refreshCountsInBackground } = await import('../bundle-counts.js');
|
|
43
|
+
const { SKILLS_STORE_DIR } = await import('../config.js');
|
|
44
|
+
const { globSync } = await import('glob');
|
|
45
|
+
const githubDir = path.join(SKILLS_STORE_DIR, 'github');
|
|
46
|
+
|
|
47
|
+
// For each bundle: if installed on disk — use real file count; otherwise use cache
|
|
43
48
|
const bundlesWithCounts = (Array.isArray(bundles) ? bundles : []).map(b => {
|
|
44
49
|
if (!b.repo_url) return b;
|
|
50
|
+
const owner = b.repo_url.split('/')[0];
|
|
51
|
+
const repo = b.repo_url.split('/')[1];
|
|
52
|
+
const clonedDir = path.join(githubDir, `${owner}-${repo}`);
|
|
53
|
+
if (fs.existsSync(clonedDir) && fs.readdirSync(clonedDir).length > 0) {
|
|
54
|
+
const realCount = globSync(`${clonedDir}/**/*.md`).length;
|
|
55
|
+
setCachedCount(b.repo_url, realCount);
|
|
56
|
+
return { ...b, skillCount: realCount };
|
|
57
|
+
}
|
|
45
58
|
const cached = getCachedCount(b.repo_url);
|
|
46
59
|
return cached !== null ? { ...b, skillCount: cached } : b;
|
|
47
60
|
});
|
|
@@ -51,18 +64,13 @@ export default async function handler(args, bin) {
|
|
|
51
64
|
try {
|
|
52
65
|
const cfg = _lcMkt();
|
|
53
66
|
const db = _getDbMkt();
|
|
54
|
-
const { SKILLS_STORE_DIR } = await import('../config.js');
|
|
55
|
-
const githubDir = path.join(SKILLS_STORE_DIR, 'github');
|
|
56
67
|
|
|
57
68
|
for (const b of (Array.isArray(bundles) ? bundles : [])) {
|
|
58
69
|
if (b.repo_url) {
|
|
59
70
|
const owner = b.repo_url.split('/')[0];
|
|
60
71
|
const repo = b.repo_url.split('/')[1];
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const dirExists = fs.existsSync(clonedDir) &&
|
|
64
|
-
fs.readdirSync(clonedDir).length > 0;
|
|
65
|
-
if (dirExists) installedSet.add(b.id);
|
|
72
|
+
const clonedDir = path.join(githubDir, `${owner}-${repo}`);
|
|
73
|
+
if (fs.existsSync(clonedDir) && fs.readdirSync(clonedDir).length > 0) installedSet.add(b.id);
|
|
66
74
|
} else if (Array.isArray(b.skills)) {
|
|
67
75
|
const allOnDisk = b.skills.every(sid => {
|
|
68
76
|
const row = db.prepare('SELECT path FROM skills WHERE id = ?').get(sid);
|
package/github-import.js
CHANGED
|
@@ -735,20 +735,20 @@ export async function importFromGitHubLight(repoUrl) {
|
|
|
735
735
|
process.stderr.write('\n');
|
|
736
736
|
|
|
737
737
|
const realCount = globSync(`${destBase}/**/*.md`).length;
|
|
738
|
-
const cacheKey = url.replace(/\.git$/, '');
|
|
739
|
-
const cachePath = path.join(PROMPTGRAPH_DIR, 'skill-counts.json');
|
|
740
|
-
try {
|
|
741
|
-
fs.mkdirSync(path.dirname(cachePath), { recursive: true });
|
|
742
|
-
const cache = JSON.parse(fs.readFileSync(cachePath, 'utf8') || '{}');
|
|
743
|
-
cache[cacheKey] = { count: realCount, ts: Date.now() };
|
|
744
|
-
fs.writeFileSync(cachePath, JSON.stringify(cache, null, 2));
|
|
745
|
-
} catch {}
|
|
746
738
|
|
|
747
739
|
if (realCount < 1) {
|
|
748
740
|
fs.rmSync(destBase, { recursive: true, force: true });
|
|
749
741
|
throw new Error('No valid skills in repo — all files were filtered out');
|
|
750
742
|
}
|
|
751
743
|
|
|
744
|
+
// Update both caches with the real post-filter count
|
|
745
|
+
try {
|
|
746
|
+
const { setCachedCount } = await import('./bundle-counts.js');
|
|
747
|
+
const cacheKey = url.replace(/\.git$/, '').replace(/^https?:\/\/github\.com\//, '');
|
|
748
|
+
setCachedCount(cacheKey, realCount);
|
|
749
|
+
setCachedCount(url.replace(/\.git$/, ''), realCount);
|
|
750
|
+
} catch {}
|
|
751
|
+
|
|
752
752
|
const { dir: localDir, label: localLabel } = detectSkillsDirLocal(destBase);
|
|
753
753
|
const skillsDir = subdir ? path.join(destBase, subdir) : localDir;
|
|
754
754
|
const label = subdir || localLabel;
|