MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / collectMarkdown

Function collectMarkdown

source code/utils/plugins/validatePlugin.ts:720–754  ·  view source on GitHub ↗

* Recursively collect .md files under a directory. Uses withFileTypes to * avoid a stat per entry. Returns absolute paths so error messages stay * readable.

(
  dir: string,
  isSkillsDir: boolean,
)

Source from the content-addressed store, hash-verified

718 * readable.
719 */
720async function collectMarkdown(
721 dir: string,
722 isSkillsDir: boolean,
723): Promise<string[]> {
724 let entries: Dirent[]
725 try {
726 entries = await readdir(dir, { withFileTypes: true })
727 } catch (e: unknown) {
728 const code = getErrnoCode(e)
729 if (code === 'ENOENT' || code === 'ENOTDIR') return []
730 throw e
731 }
732
733 // Skills use <name>/SKILL.md — only descend one level, only collect SKILL.md.
734 // Matches the runtime loader: single .md files in skills/ are NOT loaded,
735 // and subdirectories of a skill dir aren't scanned. Paths are speculative
736 // (the subdir may lack SKILL.md); the caller handles ENOENT.
737 if (isSkillsDir) {
738 return entries
739 .filter(e => e.isDirectory())
740 .map(e => path.join(dir, e.name, 'SKILL.md'))
741 }
742
743 // Commands/agents: recurse and collect all .md files.
744 const out: string[] = []
745 for (const entry of entries) {
746 const full = path.join(dir, entry.name)
747 if (entry.isDirectory()) {
748 out.push(...(await collectMarkdown(full, false)))
749 } else if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) {
750 out.push(full)
751 }
752 }
753 return out
754}
755
756/**
757 * Validate the content files inside a plugin directory — skills, agents,

Callers 1

validatePluginContentsFunction · 0.85

Calls 2

readdirFunction · 0.85
getErrnoCodeFunction · 0.85

Tested by

no test coverage detected