MCPcopy Index your code
hub / github.com/codeaashu/claude-code / transformSkillFiles

Function transformSkillFiles

src/skills/loadSkillsDir.ts:493–521  ·  view source on GitHub ↗

* Transforms markdown files to handle "skill" commands in legacy /commands/ folder. * When a SKILL.md file exists in a directory, only that file is loaded * and it takes the name of its parent directory.

(files: MarkdownFile[])

Source from the content-addressed store, hash-verified

491 * and it takes the name of its parent directory.
492 */
493function transformSkillFiles(files: MarkdownFile[]): MarkdownFile[] {
494 const filesByDir = new Map<string, MarkdownFile[]>()
495
496 for (const file of files) {
497 const dir = dirname(file.filePath)
498 const dirFiles = filesByDir.get(dir) ?? []
499 dirFiles.push(file)
500 filesByDir.set(dir, dirFiles)
501 }
502
503 const result: MarkdownFile[] = []
504
505 for (const [dir, dirFiles] of filesByDir) {
506 const skillFiles = dirFiles.filter(f => isSkillFile(f.filePath))
507 if (skillFiles.length > 0) {
508 const skillFile = skillFiles[0]!
509 if (skillFiles.length > 1) {
510 logForDebugging(
511 `Multiple skill files found in ${dir}, using ${basename(skillFile.filePath)}`,
512 )
513 }
514 result.push(skillFile)
515 } else {
516 result.push(...dirFiles)
517 }
518 }
519
520 return result
521}
522
523function buildNamespace(targetDir: string, baseDir: string): string {
524 const normalizedBaseDir = baseDir.endsWith(pathSep)

Callers 1

Calls 5

logForDebuggingFunction · 0.85
isSkillFileFunction · 0.70
getMethod · 0.65
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected