|
1 | | -import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'; |
| 1 | +import { existsSync, readdirSync, readFileSync } from 'node:fs'; |
2 | 2 | import { homedir } from 'node:os'; |
3 | 3 | import { join } from 'node:path'; |
4 | 4 |
|
@@ -84,35 +84,33 @@ function scanSkillsDir(dir: string, source: ClaudeSkill['source']): ClaudeSkill[ |
84 | 84 | for (const entry of entries) { |
85 | 85 | const fullPath = join(dir, entry); |
86 | 86 |
|
87 | | - try { |
88 | | - const stats = statSync(fullPath); |
89 | | - |
90 | | - if (stats.isFile() && entry.endsWith('.md')) { |
91 | | - // Flat .md skill file |
| 87 | + if (entry.endsWith('.md')) { |
| 88 | + // Try reading as a flat .md skill file |
| 89 | + try { |
92 | 90 | const content = readFileSync(fullPath, 'utf-8'); |
93 | 91 | skills.push({ |
94 | 92 | name: extractName(content, entry.replace('.md', '')), |
95 | 93 | path: fullPath, |
96 | 94 | description: extractDescription(content), |
97 | 95 | source, |
98 | 96 | }); |
99 | | - } else if (stats.isDirectory()) { |
100 | | - // Try reading SKILL.md inside subdirectory |
101 | | - const skillMdPath = join(fullPath, 'SKILL.md'); |
102 | | - try { |
103 | | - const content = readFileSync(skillMdPath, 'utf-8'); |
104 | | - skills.push({ |
105 | | - name: extractName(content, entry), |
106 | | - path: skillMdPath, |
107 | | - description: extractDescription(content), |
108 | | - source, |
109 | | - }); |
110 | | - } catch { |
111 | | - // SKILL.md not found or unreadable, skip |
112 | | - } |
| 97 | + } catch { |
| 98 | + // File unreadable, skip |
| 99 | + } |
| 100 | + } else { |
| 101 | + // Try reading SKILL.md inside subdirectory |
| 102 | + const skillMdPath = join(fullPath, 'SKILL.md'); |
| 103 | + try { |
| 104 | + const content = readFileSync(skillMdPath, 'utf-8'); |
| 105 | + skills.push({ |
| 106 | + name: extractName(content, entry), |
| 107 | + path: skillMdPath, |
| 108 | + description: extractDescription(content), |
| 109 | + source, |
| 110 | + }); |
| 111 | + } catch { |
| 112 | + // Not a skill directory or unreadable, skip |
113 | 113 | } |
114 | | - } catch { |
115 | | - // Skip unreadable entries |
116 | 114 | } |
117 | 115 | } |
118 | 116 | } catch { |
|
0 commit comments