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

Function scan

src/utils/plugins/walkPluginMarkdown.ts:29–66  ·  view source on GitHub ↗
(dirPath: string, namespace: string[])

Source from the content-addressed store, hash-verified

27 const label = opts.logLabel ?? 'plugin'
28
29 async function scan(dirPath: string, namespace: string[]): Promise<void> {
30 try {
31 const entries = await fs.readdir(dirPath)
32
33 if (
34 opts.stopAtSkillDir &&
35 entries.some(e => e.isFile() && SKILL_MD_RE.test(e.name))
36 ) {
37 // Skill directory: collect .md files here, don't recurse.
38 await Promise.all(
39 entries.map(entry =>
40 entry.isFile() && entry.name.toLowerCase().endsWith('.md')
41 ? onFile(join(dirPath, entry.name), namespace)
42 : undefined,
43 ),
44 )
45 return
46 }
47
48 await Promise.all(
49 entries.map(entry => {
50 const fullPath = join(dirPath, entry.name)
51 if (entry.isDirectory()) {
52 return scan(fullPath, [...namespace, entry.name])
53 }
54 if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) {
55 return onFile(fullPath, namespace)
56 }
57 return undefined
58 }),
59 )
60 } catch (error) {
61 logForDebugging(
62 `Failed to scan ${label} directory ${dirPath}: ${error}`,
63 { level: 'error' },
64 )
65 }
66 }
67
68 await scan(rootDir, [])
69}

Callers 1

walkPluginMarkdownFunction · 0.70

Calls 1

logForDebuggingFunction · 0.85

Tested by

no test coverage detected