MCPcopy Create free account
hub / github.com/T-Lab-CUHKSZ/claude-code / listMdFiles

Function listMdFiles

config-ui/server.ts:93–120  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

91}
92
93function listMdFiles(dir: string): Array<{ name: string; path: string; content: string }> {
94 if (!existsSync(dir)) return []
95 const results: Array<{ name: string; path: string; content: string }> = []
96 try {
97 for (const entry of readdirSync(dir, { withFileTypes: true })) {
98 if (entry.isFile() && entry.name.endsWith('.md')) {
99 const p = join(dir, entry.name)
100 results.push({ name: entry.name, path: p, content: readTextSafe(p) })
101 } else if (entry.isDirectory()) {
102 // Check for SKILL.md or agent .md inside subdirectory
103 const skillMd = join(dir, entry.name, 'SKILL.md')
104 const agentMd = join(dir, entry.name + '.md')
105 if (existsSync(skillMd)) {
106 results.push({ name: entry.name, path: skillMd, content: readTextSafe(skillMd) })
107 } else {
108 // List .md files inside subdirectory
109 for (const sub of readdirSync(join(dir, entry.name))) {
110 if (sub.endsWith('.md')) {
111 const p = join(dir, entry.name, sub)
112 results.push({ name: `${entry.name}/${sub}`, path: p, content: readTextSafe(p) })
113 }
114 }
115 }
116 }
117 }
118 } catch {}
119 return results
120}
121
122// --- Feature Flags ---
123

Callers 1

handleAPIFunction · 0.85

Calls 3

existsSyncFunction · 0.90
readdirSyncFunction · 0.90
readTextSafeFunction · 0.85

Tested by

no test coverage detected