fix: sparse checkout includes subpath so skill discovery works

cloneRepo now accepts a subpath option. When set, sparse-checkout
includes both the subpath itself and SKILL_DISCOVERY_PATHS under it.
All four providers pass their parsed subpath through to cloneRepo.

Without this, sparse checkout would skip the subpath directory and
discoverSkills would find nothing.
This commit is contained in:
Rohit Ghumare
2026-04-10 21:27:44 +01:00
parent dd30ee0af0
commit 3457fbc011
5 changed files with 13 additions and 7 deletions
+9 -3
View File
@@ -19,6 +19,7 @@ export interface CloneOptions {
depth?: number;
branch?: string;
ssh?: boolean;
subpath?: string;
onProgress?: (message: string) => void;
}
@@ -100,11 +101,16 @@ export async function cloneRepo(
stdio: ['pipe', 'pipe', 'pipe'],
});
const sparsePaths = SKILL_DISCOVERY_PATHS.filter((p) => !p.includes('/'));
const deepPaths = SKILL_DISCOVERY_PATHS.filter((p) => p.includes('/'));
const sparsePaths = [...SKILL_DISCOVERY_PATHS];
if (options.subpath) {
sparsePaths.push(options.subpath);
for (const dp of SKILL_DISCOVERY_PATHS) {
sparsePaths.push(`${options.subpath}/${dp}`);
}
}
execFileSync(
'git',
['-C', tempDir, 'sparse-checkout', 'set', ...sparsePaths, ...deepPaths],
['-C', tempDir, 'sparse-checkout', 'set', ...sparsePaths],
{ stdio: ['pipe', 'pipe', 'pipe'] },
);
+1 -1
View File
@@ -75,7 +75,7 @@ export class BitbucketProvider implements GitProviderAdapter {
const tempDir = join(tmpdir(), `skillkit-${randomUUID()}`);
try {
await cloneRepo(cloneUrl, tempDir, options);
await cloneRepo(cloneUrl, tempDir, { ...options, subpath });
const searchDir = subpath ? join(tempDir, subpath) : tempDir;
const skills = discoverSkills(searchDir);
+1 -1
View File
@@ -68,7 +68,7 @@ export class GitHubProvider implements GitProviderAdapter {
const tempDir = join(tmpdir(), `skillkit-${randomUUID()}`);
try {
await cloneRepo(cloneUrl, tempDir, options);
await cloneRepo(cloneUrl, tempDir, { ...options, subpath });
const searchDir = subpath ? join(tempDir, subpath) : tempDir;
const skills = discoverSkills(searchDir);
+1 -1
View File
@@ -73,7 +73,7 @@ export class GitLabProvider implements GitProviderAdapter {
const tempDir = join(tmpdir(), `skillkit-${randomUUID()}`);
try {
await cloneRepo(cloneUrl, tempDir, options);
await cloneRepo(cloneUrl, tempDir, { ...options, subpath });
const searchDir = subpath ? join(tempDir, subpath) : tempDir;
const skills = discoverSkills(searchDir);
+1 -1
View File
@@ -65,7 +65,7 @@ export class SkillsShProvider implements GitProviderAdapter {
const tempDir = join(tmpdir(), `skillkit-skillssh-${randomUUID()}`);
try {
await cloneRepo(cloneUrl, tempDir, options);
await cloneRepo(cloneUrl, tempDir, { ...options, subpath });
const searchDir = subpath ? join(tempDir, subpath) : tempDir;