@@ -27,7 +27,9 @@ import {
2727 getPkgKeyFiles ,
2828 getRepoCacheDir ,
2929 getShippedSkills ,
30+ inferDocsTypeFromCache ,
3031 isCached ,
32+ isReadmeOnlyCache ,
3133 linkPkgNamed ,
3234 linkShippedSkill ,
3335 listReferenceFiles ,
@@ -38,7 +40,7 @@ import {
3840import { promptForAgent , resolveAgent , sharedArgs } from '../cli-helpers.ts'
3941import { defaultFeatures , readConfig } from '../core/config.ts'
4042import { timedSpinner } from '../core/formatting.ts'
41- import { mergeLocks , parsePackages , readLock , syncLockfilesToDirs , writeLock } from '../core/lockfile.ts'
43+ import { mergeLocks , parsePackageNames , parsePackages , readLock , syncLockfilesToDirs , writeLock } from '../core/lockfile.ts'
4244import { readPackageJsonSafe } from '../core/package-json.ts'
4345import { toStoragePackageName } from '../core/prefix.ts'
4446import { sanitizeMarkdown } from '../core/sanitize.ts'
@@ -199,7 +201,7 @@ export async function installCommand(opts: InstallOptions): Promise<void> {
199201 for ( const pkg of parsePackages ( info . packages ) )
200202 linkPkgNamed ( skillDir , pkg . name , cwd , pkg . version )
201203 // Only link external docs if package doesn't ship its own and has more than just README
202- if ( ! pkgHasShippedDocs ( pkgName , cwd , version ) && ! isReadmeOnly ( globalCachePath ) ) {
204+ if ( ! pkgHasShippedDocs ( pkgName , cwd , version ) && ! isReadmeOnlyCache ( globalCachePath ) ) {
203205 const docsLink = join ( referencesPath , 'docs' )
204206 const cachedDocs = join ( globalCachePath , 'docs' )
205207 if ( existsSync ( docsLink ) )
@@ -368,7 +370,7 @@ export async function installCommand(opts: InstallOptions): Promise<void> {
368370 for ( const pkg of parsePackages ( info . packages ) )
369371 linkPkgNamed ( skillDir , pkg . name , cwd , pkg . version )
370372 // Link fetched docs unless it's just a README (already in pkg/)
371- if ( ! isReadmeOnly ( globalCachePath ) ) {
373+ if ( ! isReadmeOnlyCache ( globalCachePath ) ) {
372374 const docsLink = join ( referencesPath , 'docs' )
373375 const cachedDocsDir = join ( globalCachePath , 'docs' )
374376 if ( existsSync ( docsLink ) )
@@ -514,15 +516,6 @@ function linkPkgSymlink(referencesDir: string, name: string, cwd: string, versio
514516 symlinkSync ( pkgPath , pkgLink , 'junction' )
515517}
516518
517- /** Check if cache only has docs/README.md (pkg/ already has this) */
518- function isReadmeOnly ( cacheDir : string ) : boolean {
519- const docsDir = join ( cacheDir , 'docs' )
520- if ( ! existsSync ( docsDir ) )
521- return false
522- const files = readdirSync ( docsDir )
523- return files . length === 1 && files [ 0 ] === 'README.md'
524- }
525-
526519/** Check if package ships its own docs folder */
527520function pkgHasShippedDocs ( name : string , cwd : string , version ?: string ) : boolean {
528521 const pkgPath = resolvePkgDir ( name , cwd , version )
@@ -587,16 +580,12 @@ async function enhanceRegenerated(
587580 }
588581 }
589582
590- let docsType : 'llms.txt' | 'readme' | 'docs' = 'docs'
591- if ( existsSync ( join ( globalCachePath , 'docs' , 'llms.txt' ) ) )
592- docsType = 'llms.txt'
593- else if ( isReadmeOnly ( globalCachePath ) )
594- docsType = 'readme'
583+ const docsType = inferDocsTypeFromCache ( globalCachePath )
595584
596585 // Derive dirName from the skill directory name
597586 const dirName = skillDir . split ( '/' ) . pop ( )
598587
599- const allPackages = parsePackages ( packages ) . map ( p => ( { name : p . name } ) )
588+ const allPackages = parsePackageNames ( packages )
600589 writeGeneratedSkillMd ( skillDir , {
601590 name : pkgName ,
602591 version,
@@ -667,11 +656,7 @@ function regenerateBaseSkillMd(
667656
668657 // Infer docsType from source or cache
669658 const globalCachePath = getCacheDir ( pkgName , version )
670- let docsType : 'llms.txt' | 'readme' | 'docs' = 'docs'
671- if ( source ?. includes ( 'llms.txt' ) || existsSync ( join ( globalCachePath , 'docs' , 'llms.txt' ) ) )
672- docsType = 'llms.txt'
673- else if ( isReadmeOnly ( globalCachePath ) )
674- docsType = 'readme'
659+ const docsType = inferDocsTypeFromCache ( globalCachePath , source )
675660
676661 // Check cache dirs for issues/discussions/releases (only if feature enabled)
677662 const feat = readConfig ( ) . features ?? defaultFeatures
@@ -686,7 +671,7 @@ function regenerateBaseSkillMd(
686671 const dirName = skillDir . split ( '/' ) . pop ( )
687672
688673 // Build multi-package list from lockfile packages field
689- const allPackages = parsePackages ( packages ) . map ( p => ( { name : p . name } ) )
674+ const allPackages = parsePackageNames ( packages )
690675
691676 mkdirSync ( skillDir , { recursive : true } )
692677 writeGeneratedSkillMd ( skillDir , {
0 commit comments