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

Function transformPluginSkillFiles

src/utils/plugins/loadPluginCommands.ts:135–167  ·  view source on GitHub ↗

* Transforms plugin markdown files to handle skill directories

(
  files: PluginMarkdownFile[],
)

Source from the content-addressed store, hash-verified

133 * Transforms plugin markdown files to handle skill directories
134 */
135function transformPluginSkillFiles(
136 files: PluginMarkdownFile[],
137): PluginMarkdownFile[] {
138 const filesByDir = new Map<string, PluginMarkdownFile[]>()
139
140 for (const file of files) {
141 const dir = dirname(file.filePath)
142 const dirFiles = filesByDir.get(dir) ?? []
143 dirFiles.push(file)
144 filesByDir.set(dir, dirFiles)
145 }
146
147 const result: PluginMarkdownFile[] = []
148
149 for (const [dir, dirFiles] of filesByDir) {
150 const skillFiles = dirFiles.filter(f => isSkillFile(f.filePath))
151 if (skillFiles.length > 0) {
152 // Use the first skill file if multiple exist
153 const skillFile = skillFiles[0]!
154 if (skillFiles.length > 1) {
155 logForDebugging(
156 `Multiple skill files found in ${dir}, using ${basename(skillFile.filePath)}`,
157 )
158 }
159 // Directory has a skill - only include the skill file
160 result.push(skillFile)
161 } else {
162 result.push(...dirFiles)
163 }
164 }
165
166 return result
167}
168
169async function loadCommandsFromDirectory(
170 commandsPath: string,

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