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

Function loadCommandsFromDirectory

src/utils/plugins/loadPluginCommands.ts:169–213  ·  view source on GitHub ↗
(
  commandsPath: string,
  pluginName: string,
  sourceName: string,
  pluginManifest: PluginManifest,
  pluginPath: string,
  config: LoadConfig = { isSkillMode: false },
  loadedPaths: Set<string> = new Set(),
)

Source from the content-addressed store, hash-verified

167}
168
169async function loadCommandsFromDirectory(
170 commandsPath: string,
171 pluginName: string,
172 sourceName: string,
173 pluginManifest: PluginManifest,
174 pluginPath: string,
175 config: LoadConfig = { isSkillMode: false },
176 loadedPaths: Set<string> = new Set(),
177): Promise<Command[]> {
178 // Collect all markdown files
179 const markdownFiles = await collectMarkdownFiles(
180 commandsPath,
181 commandsPath,
182 loadedPaths,
183 )
184
185 // Apply skill transformation
186 const processedFiles = transformPluginSkillFiles(markdownFiles)
187
188 // Convert to commands
189 const commands: Command[] = []
190 for (const file of processedFiles) {
191 const commandName = getCommandNameFromFile(
192 file.filePath,
193 file.baseDir,
194 pluginName,
195 )
196
197 const command = createPluginCommand(
198 commandName,
199 file,
200 sourceName,
201 pluginManifest,
202 pluginPath,
203 isSkillFile(file.filePath),
204 config,
205 )
206
207 if (command) {
208 commands.push(command)
209 }
210 }
211
212 return commands
213}
214
215/**
216 * Create a Command from a plugin markdown file

Callers 1

Calls 6

collectMarkdownFilesFunction · 0.85
getCommandNameFromFileFunction · 0.85
createPluginCommandFunction · 0.85
isSkillFileFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected