promptgraph-mcp 2.0.2 → 2.0.4
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 +35 -12
- package/index.js +2 -2
- package/package.json +1 -1
package/github-import.js
CHANGED
|
@@ -4,9 +4,24 @@ import os from 'os';
|
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import { globSync } from 'glob';
|
|
6
6
|
import { indexAll } from './indexer.js';
|
|
7
|
-
import { loadConfig, saveConfig } from './config.js';
|
|
7
|
+
import { loadConfig, saveConfig, SKILLS_STORE_DIR } from './config.js';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// Directories likely to contain skills — checked in priority order
|
|
10
|
+
const SKILL_DIRS = ['skills', 'commands', 'prompts', 'agents', 'skills-store', 'slash-commands', 'custom-commands', 'templates'];
|
|
11
|
+
|
|
12
|
+
// Find the best subdirectory to index in the cloned repo.
|
|
13
|
+
// Returns the subdir path if a known skills dir exists with 2+ .md files,
|
|
14
|
+
// otherwise returns the repo root (full scan with isSkillFile filtering).
|
|
15
|
+
function detectSkillsDir(repoRoot) {
|
|
16
|
+
for (const dir of SKILL_DIRS) {
|
|
17
|
+
const candidate = path.join(repoRoot, dir);
|
|
18
|
+
if (fs.existsSync(candidate)) {
|
|
19
|
+
const files = globSync(`${candidate}/**/*.md`);
|
|
20
|
+
if (files.length >= 2) return { dir: candidate, auto: true, label: dir };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { dir: repoRoot, auto: false, label: '(root)' };
|
|
24
|
+
}
|
|
10
25
|
|
|
11
26
|
export async function importFromGitHub(repoUrl) {
|
|
12
27
|
if (!repoUrl) {
|
|
@@ -16,7 +31,7 @@ export async function importFromGitHub(repoUrl) {
|
|
|
16
31
|
|
|
17
32
|
const url = repoUrl.startsWith('http') ? repoUrl : `https://github.com/${repoUrl}`;
|
|
18
33
|
const repoName = url.split('/').slice(-2).join('-').replace('.git', '');
|
|
19
|
-
const dest = path.join(
|
|
34
|
+
const dest = path.join(SKILLS_STORE_DIR, 'github', repoName);
|
|
20
35
|
|
|
21
36
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
22
37
|
|
|
@@ -30,23 +45,31 @@ export async function importFromGitHub(repoUrl) {
|
|
|
30
45
|
if (cloneResult.status !== 0) throw new Error(`git clone failed for ${url}`);
|
|
31
46
|
}
|
|
32
47
|
|
|
33
|
-
const
|
|
34
|
-
|
|
48
|
+
const { dir: skillsDir, auto, label } = detectSkillsDir(dest);
|
|
49
|
+
const mdFiles = globSync(`${skillsDir}/**/*.md`);
|
|
50
|
+
|
|
51
|
+
if (auto) {
|
|
52
|
+
console.log(`Auto-detected skills directory: ${label}/ (${mdFiles.length} .md files)`);
|
|
53
|
+
} else {
|
|
54
|
+
console.log(`No skills/ dir found — scanning root (${mdFiles.length} .md files, non-skill files will be filtered)`);
|
|
55
|
+
}
|
|
35
56
|
|
|
36
|
-
if (mdFiles.length <
|
|
37
|
-
console.warn('Warning:
|
|
57
|
+
if (mdFiles.length < 1) {
|
|
58
|
+
console.warn('Warning: no .md files found');
|
|
38
59
|
}
|
|
39
60
|
|
|
40
61
|
const config = loadConfig();
|
|
41
|
-
// Per-repo source so two repos with the same skill name don't overwrite each other
|
|
42
62
|
const repoSource = `github:${repoName}`;
|
|
43
|
-
if (!config.sources.find(s => s.dir ===
|
|
44
|
-
|
|
63
|
+
if (!config.sources.find(s => s.dir === skillsDir)) {
|
|
64
|
+
// Remove any old entry pointing at the full repo root if we now have a subdir
|
|
65
|
+
const oldIdx = config.sources.findIndex(s => s.source === repoSource);
|
|
66
|
+
if (oldIdx !== -1) config.sources.splice(oldIdx, 1);
|
|
67
|
+
config.sources.push({ dir: skillsDir, source: repoSource });
|
|
45
68
|
saveConfig(config);
|
|
46
|
-
console.log(`
|
|
69
|
+
console.log(`Indexing from: ${skillsDir}`);
|
|
47
70
|
}
|
|
48
71
|
|
|
49
72
|
console.log('\nReindexing...');
|
|
50
73
|
await indexAll();
|
|
51
|
-
console.log(`Done! Imported
|
|
74
|
+
console.log(`Done! Imported from ${repoName}/${label}`);
|
|
52
75
|
}
|
package/index.js
CHANGED
|
@@ -417,9 +417,9 @@ if (args[0] === 'update') {
|
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
info(`Current: ${chalk.gray('v' + currentVersion)} → Latest: ${chalk.white.bold('v' + latest)}`);
|
|
420
|
-
const updateSpin = (await import('./cli.js')).spinner(`Installing promptgraph-mcp
|
|
420
|
+
const updateSpin = (await import('./cli.js')).spinner(`Installing promptgraph-mcp@latest (v${latest})...`);
|
|
421
421
|
updateSpin.start();
|
|
422
|
-
const result = spawnSync('npm', ['install', '-g',
|
|
422
|
+
const result = spawnSync('npm', ['install', '-g', 'promptgraph-mcp@latest'], { encoding: 'utf8', stdio: 'pipe', shell: true });
|
|
423
423
|
updateSpin.stop();
|
|
424
424
|
|
|
425
425
|
if (result.status !== 0) {
|