MCPcopy Create free account
hub / github.com/Noumena-Network/code / transformSkillFiles

Function transformSkillFiles

src/skills/loadSkillsDir.ts:499–527  ·  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

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

Callers 1

Calls 4

setMethod · 0.80
isSkillFileFunction · 0.70
logForDebuggingFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected