promptgraph-mcp 2.8.4 → 2.8.5
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 +15 -3
- package/package.json +1 -1
package/github-import.js
CHANGED
|
@@ -678,18 +678,23 @@ export async function importFromGitHubLight(repoUrl) {
|
|
|
678
678
|
fs.mkdirSync(destBase, { recursive: true });
|
|
679
679
|
|
|
680
680
|
const gitEnv = { ...process.env, GIT_TERMINAL_PROMPT: '0' };
|
|
681
|
+
const prog = (msg) => process.stderr.write(`\r\x1b[K ${msg}`);
|
|
681
682
|
|
|
682
683
|
// Step 1: treeless clone — gets file tree instantly, no blob download, no API
|
|
683
|
-
|
|
684
|
+
prog(`Cloning ${ownerRepo}...`);
|
|
685
|
+
const init = spawnSync('git', ['clone', '--depth=1', '--filter=blob:none', '--no-checkout', '--progress', cloneUrl, destBase], { stdio: 'pipe', env: gitEnv, timeout: 120000 });
|
|
684
686
|
if (init.status !== 0) {
|
|
687
|
+
process.stderr.write('\n');
|
|
685
688
|
fs.rmSync(destBase, { recursive: true, force: true });
|
|
686
689
|
throw new Error(`Failed to clone ${ownerRepo}: ${(init.stderr?.toString() || '').trim().slice(0, 120)}`);
|
|
687
690
|
}
|
|
688
691
|
|
|
689
692
|
// Step 2: detect skills subdir from local tree — zero API calls
|
|
693
|
+
prog(`Detecting skill directory...`);
|
|
690
694
|
const subdir = detectSubdirFromTree(destBase);
|
|
691
695
|
|
|
692
696
|
// Step 3: sparse-checkout only the skills subdir .md files
|
|
697
|
+
prog(`Setting up sparse checkout${subdir ? ` (${subdir}/)` : ''}...`);
|
|
693
698
|
spawnSync('git', ['-C', destBase, 'sparse-checkout', 'init'], { stdio: 'pipe', env: gitEnv });
|
|
694
699
|
if (subdir) {
|
|
695
700
|
spawnSync('git', ['-C', destBase, 'sparse-checkout', 'set', '--no-cone', `${subdir}/*.md`, `${subdir}/**/*.md`], { stdio: 'pipe', env: gitEnv });
|
|
@@ -698,16 +703,20 @@ export async function importFromGitHubLight(repoUrl) {
|
|
|
698
703
|
}
|
|
699
704
|
|
|
700
705
|
// Step 4: checkout to materialize only the selected files
|
|
701
|
-
|
|
706
|
+
prog(`Downloading .md files...`);
|
|
707
|
+
const co = spawnSync('git', ['-C', destBase, 'checkout'], { stdio: 'pipe', env: gitEnv, timeout: 120000 });
|
|
702
708
|
if (co.status !== 0) {
|
|
709
|
+
process.stderr.write('\n');
|
|
703
710
|
fs.rmSync(destBase, { recursive: true, force: true });
|
|
704
711
|
throw new Error(`Checkout failed for ${ownerRepo}`);
|
|
705
712
|
}
|
|
706
713
|
// Force blob materialization (needed for partial clones on Windows)
|
|
707
|
-
spawnSync('git', ['-C', destBase, 'checkout', 'HEAD', '--', '.'], { stdio: 'pipe', env: gitEnv, timeout:
|
|
714
|
+
spawnSync('git', ['-C', destBase, 'checkout', 'HEAD', '--', '.'], { stdio: 'pipe', env: gitEnv, timeout: 120000 });
|
|
715
|
+
process.stderr.write('\n');
|
|
708
716
|
|
|
709
717
|
// Step 5: filter out non-skill files locally
|
|
710
718
|
const allMd = globSync(`${destBase}/**/*.md`);
|
|
719
|
+
prog(`Filtering ${allMd.length} files...`);
|
|
711
720
|
let removed = 0;
|
|
712
721
|
for (const fp of allMd) {
|
|
713
722
|
if (!isSkillFile(fp)) { try { fs.unlinkSync(fp); removed++; } catch {} }
|
|
@@ -715,6 +724,7 @@ export async function importFromGitHubLight(repoUrl) {
|
|
|
715
724
|
if (removed > 0) removeEmptyDirs(destBase);
|
|
716
725
|
|
|
717
726
|
const remaining = globSync(`${destBase}/**/*.md`);
|
|
727
|
+
prog(`Validating ${remaining.length} skill files...`);
|
|
718
728
|
let removedV = 0;
|
|
719
729
|
for (const fp of remaining) {
|
|
720
730
|
const v = validateSkill(fp);
|
|
@@ -722,7 +732,9 @@ export async function importFromGitHubLight(repoUrl) {
|
|
|
722
732
|
}
|
|
723
733
|
if (removedV > 0) removeEmptyDirs(destBase);
|
|
724
734
|
|
|
735
|
+
prog(`Running classifier...`);
|
|
725
736
|
await classifierCleanup(destBase);
|
|
737
|
+
process.stderr.write('\n');
|
|
726
738
|
|
|
727
739
|
const realCount = globSync(`${destBase}/**/*.md`).length;
|
|
728
740
|
const cacheKey = url.replace(/\.git$/, '');
|