MCPcopy Create free account
hub / github.com/freecodexyz/free-code / getBaseFileNames

Function getBaseFileNames

src/commands/plugin/ManagePlugins.tsx:129–148  ·  view source on GitHub ↗

* Get list of base file names (without .md extension) from a directory * @param dirPath The directory path to list files from * @returns Array of base file names without .md extension * @example * // Given directory contains: agent-sdk-verifier-py.md, agent-sdk-verifier-ts.md, README.txt * awai

(dirPath: string)

Source from the content-addressed store, hash-verified

127 * // Returns: ['agent-sdk-verifier-py', 'agent-sdk-verifier-ts']
128 */
129async function getBaseFileNames(dirPath: string): Promise<string[]> {
130 try {
131 const entries = await fs.readdir(dirPath, {
132 withFileTypes: true
133 });
134 return entries.filter((entry: Dirent) => entry.isFile() && entry.name.endsWith('.md')).map((entry: Dirent) => {
135 // Remove .md extension specifically
136 const baseName = path.basename(entry.name, '.md');
137 return baseName;
138 });
139 } catch (error) {
140 const errorMsg = errorMessage(error);
141 logForDebugging(`Failed to read plugin components from ${dirPath}: ${errorMsg}`, {
142 level: 'error'
143 });
144 logError(toError(error));
145 // Return empty array to allow graceful degradation - plugin details can still be shown
146 return [];
147 }
148}
149
150/**
151 * Get list of skill directory names from a skills directory

Callers 1

loadComponentsFunction · 0.85

Calls 4

logForDebuggingFunction · 0.85
toErrorFunction · 0.85
errorMessageFunction · 0.50
logErrorFunction · 0.50

Tested by

no test coverage detected