Skip to content

Commit fac44f5

Browse files
authored
fix: check shipped skills before doc resolution fallback (#48)
1 parent 4cc9c99 commit fac44f5

4 files changed

Lines changed: 32 additions & 3 deletions

File tree

src/commands/sync-parallel.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ async function syncBaseSkill(
401401
const localDeps = await readLocalDependencies(cwd).catch(() => [])
402402
const localVersion = localDeps.find(d => d.name === packageName)?.version
403403

404-
const { package: resolvedPkg, attempts } = await resolvePackageDocsWithAttempts(requestedTag ? packageSpec : packageName, {
404+
const { package: resolvedPkg, attempts, registryVersion } = await resolvePackageDocsWithAttempts(requestedTag ? packageSpec : packageName, {
405405
version: localVersion,
406406
cwd,
407407
onProgress: step => update(packageName, 'resolving', RESOLVE_STEP_LABELS[step]),
@@ -414,6 +414,19 @@ async function syncBaseSkill(
414414
}
415415

416416
if (!resolved) {
417+
// Even without docs, the package may ship its own skills (skills-npm convention)
418+
const shippedVersion = localVersion || registryVersion || 'latest'
419+
const earlyShipped = handleShippedSkills(packageName, shippedVersion, cwd, config.agent, config.global)
420+
if (earlyShipped) {
421+
const shared = !config.global && getSharedSkillsDir(cwd)
422+
if (shared) {
423+
for (const shipped of earlyShipped.shipped)
424+
linkSkillToAgents(shipped.skillName, shared, cwd, config.agent)
425+
}
426+
update(packageName, 'done', 'Published SKILL.md', getVersionKey(shippedVersion))
427+
return 'shipped'
428+
}
429+
417430
const npmAttempt = attempts.find(a => a.source === 'npm')
418431
let reason: string
419432
if (npmAttempt?.status === 'not-found') {

src/commands/sync.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,20 @@ async function syncSinglePackage(packageSpec: string, config: SyncConfig): Promi
290290
}
291291

292292
if (!resolved) {
293+
// Even without docs, the package may ship its own skills (skills-npm convention)
294+
const shippedVersion = localVersion || resolveResult.registryVersion || 'latest'
295+
const earlyShipped = handleShippedSkills(packageName, shippedVersion, cwd, config.agent, config.global)
296+
if (earlyShipped) {
297+
const shared = !config.global && getSharedSkillsDir(cwd)
298+
for (const shipped of earlyShipped.shipped) {
299+
if (shared)
300+
linkSkillToAgents(shipped.skillName, shared, cwd, config.agent)
301+
p.log.success(`Using published SKILL.md: ${shipped.skillName}${relative(cwd, shipped.skillDir)}`)
302+
}
303+
spin.stop(`Using published SKILL.md(s) from ${packageName}`)
304+
return
305+
}
306+
293307
// Search npm for alternatives before giving up
294308
spin.message(`Searching npm for "${packageName}"...`)
295309
const suggestions = await searchNpmPackages(packageName)

src/sources/npm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,10 @@ export async function resolvePackageDocsWithAttempts(packageName: string, option
375375

376376
// Must have at least one source
377377
if (!result.docsUrl && !result.llmsUrl && !result.readmeUrl && !result.gitDocsUrl) {
378-
return { package: null, attempts }
378+
return { package: null, attempts, registryVersion: pkg.version }
379379
}
380380

381-
return { package: result, attempts }
381+
return { package: result, attempts, registryVersion: pkg.version }
382382
}
383383

384384
/**

src/sources/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,6 @@ export interface ResolveAttempt {
7474
export interface ResolveResult {
7575
package: ResolvedPackage | null
7676
attempts: ResolveAttempt[]
77+
/** npm registry version, available even when doc resolution fails */
78+
registryVersion?: string
7779
}

0 commit comments

Comments
 (0)