promptgraph-mcp 2.3.4 → 2.3.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 +49 -7
- package/package.json +1 -1
package/github-import.js
CHANGED
|
@@ -81,9 +81,9 @@ function sparseClone(url, dest, subdir) {
|
|
|
81
81
|
if (git(['init'], dest, 'pipe').status !== 0) return false;
|
|
82
82
|
if (git(['remote', 'add', 'origin', url], dest, 'pipe').status !== 0) return false;
|
|
83
83
|
|
|
84
|
-
// 2. sparse-checkout
|
|
85
|
-
git(['sparse-checkout', 'init'
|
|
86
|
-
git(['sparse-checkout', 'set', subdir], dest, 'pipe');
|
|
84
|
+
// 2. sparse-checkout — non-cone mode with *.md glob
|
|
85
|
+
git(['sparse-checkout', 'init'], dest, 'pipe');
|
|
86
|
+
git(['sparse-checkout', 'set', '--no-cone', `${subdir}/*.md`, `${subdir}/**/*.md`], dest, 'pipe');
|
|
87
87
|
|
|
88
88
|
// 3. fetch + checkout (depth=1, skip large blobs)
|
|
89
89
|
const fetch = git(['fetch', '--depth=1', '--filter=blob:none', 'origin'], dest);
|
|
@@ -97,13 +97,44 @@ function sparseClone(url, dest, subdir) {
|
|
|
97
97
|
return false;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
// After full-clone root: remove files that are not skills and dirs we don't need
|
|
101
|
+
function cleanupRepoRoot(repoRoot) {
|
|
102
|
+
const SKIP_RE = /^(readme|changelog|license|contributing|code.of.conduct|security|authors|credits|install|installation|usage|promotion|faq|glossary|index|overview|summary|roadmap|todo|notes|template|example|sample|demo|guide|tutorial|walkthrough|architecture|design|spec|requirements|privacy|terms|disclaimer|notice|copying|warranty|funding)/i;
|
|
103
|
+
const SKIP_DIRS_LOCAL = new Set(['.github', 'docs', 'doc', 'assets', 'images', 'img', 'screenshots', 'media', 'static', 'scripts', 'ci_scripts', 'node_modules', 'vendor', 'dist', 'build', 'tests', 'test']);
|
|
104
|
+
|
|
105
|
+
let removed = 0;
|
|
106
|
+
const entries = fs.readdirSync(repoRoot, { withFileTypes: true });
|
|
107
|
+
for (const entry of entries) {
|
|
108
|
+
if (entry.name === '.git') continue;
|
|
109
|
+
const fullPath = path.join(repoRoot, entry.name);
|
|
110
|
+
if (entry.isDirectory()) {
|
|
111
|
+
if (SKIP_DIRS_LOCAL.has(entry.name.toLowerCase())) {
|
|
112
|
+
fs.rmSync(fullPath, { recursive: true, force: true });
|
|
113
|
+
removed++;
|
|
114
|
+
}
|
|
115
|
+
} else if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
116
|
+
const base = entry.name.replace(/\.md$/i, '').toLowerCase();
|
|
117
|
+
if (SKIP_RE.test(base)) {
|
|
118
|
+
fs.unlinkSync(fullPath);
|
|
119
|
+
removed++;
|
|
120
|
+
}
|
|
121
|
+
} else if (entry.isFile() && !entry.name.endsWith('.md')) {
|
|
122
|
+
// Remove non-md files (gitignore, LICENSE, Makefile, etc.) — keep only .md
|
|
123
|
+
if (entry.name !== '.gitignore') {
|
|
124
|
+
try { fs.unlinkSync(fullPath); removed++; } catch {}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (removed > 0) console.log(`Cleaned up ${removed} non-skill files/dirs from root`);
|
|
129
|
+
}
|
|
130
|
+
|
|
100
131
|
// Update sparse repo — fetch + reset
|
|
101
132
|
function sparseUpdate(dest, subdir) {
|
|
102
133
|
const fetch = git(['fetch', '--depth=1', 'origin'], dest);
|
|
103
134
|
if (fetch.status !== 0) return false;
|
|
104
135
|
|
|
105
136
|
// Ensure sparse-checkout still set correctly
|
|
106
|
-
git(['sparse-checkout', 'set', subdir], dest, 'pipe');
|
|
137
|
+
git(['sparse-checkout', 'set', '--no-cone', `${subdir}/*.md`, `${subdir}/**/*.md`], dest, 'pipe');
|
|
107
138
|
|
|
108
139
|
for (const ref of ['origin/HEAD', 'origin/main', 'origin/master']) {
|
|
109
140
|
const r = git(['reset', '--hard', ref], dest, 'pipe');
|
|
@@ -112,8 +143,7 @@ function sparseUpdate(dest, subdir) {
|
|
|
112
143
|
return false;
|
|
113
144
|
}
|
|
114
145
|
|
|
115
|
-
// Fallback:
|
|
116
|
-
// --filter=blob:none skips large binaries (images, zips) — only fetches text files
|
|
146
|
+
// Fallback: clone root but only checkout .md files
|
|
117
147
|
function fullClone(url, dest) {
|
|
118
148
|
if (fs.existsSync(dest)) {
|
|
119
149
|
const fetch = git(['fetch', '--depth=1', '--filter=blob:none', 'origin'], dest);
|
|
@@ -123,7 +153,19 @@ function fullClone(url, dest) {
|
|
|
123
153
|
}
|
|
124
154
|
return false;
|
|
125
155
|
}
|
|
126
|
-
|
|
156
|
+
// init + sparse *.md + fetch + checkout
|
|
157
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
158
|
+
if (git(['init'], dest, 'pipe').status !== 0) return false;
|
|
159
|
+
if (git(['remote', 'add', 'origin', url], dest, 'pipe').status !== 0) return false;
|
|
160
|
+
git(['sparse-checkout', 'init'], dest, 'pipe');
|
|
161
|
+
git(['sparse-checkout', 'set', '--no-cone', '*.md', '**/*.md'], dest, 'pipe');
|
|
162
|
+
const fetch = git(['fetch', '--depth=1', '--filter=blob:none', 'origin'], dest);
|
|
163
|
+
if (fetch.status !== 0) return false;
|
|
164
|
+
for (const branch of ['FETCH_HEAD', 'main', 'master']) {
|
|
165
|
+
const r = git(['checkout', branch], dest, 'pipe');
|
|
166
|
+
if (r.status === 0) return true;
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
127
169
|
}
|
|
128
170
|
|
|
129
171
|
// After clone: detect actual skills dir on disk
|