Skip to content

Your team of AI agents, on your Mac, Windows or Linux. Agents that talk in channels, write code, review each other and use your tools, on the Claude Code, Codex, OpenCode or Pi you already have. Anything that touches the real world waits for your yes.

Find skills whose folder is a symlink (#14)

Gian Moraesb5925696aede
diff --git a/src/core/local-skills.ts b/src/core/local-skills.ts
index bd14f5a..35cb96a 100644
--- a/src/core/local-skills.ts
+++ b/src/core/local-skills.ts
@@ -3,7 +3,7 @@
// (~/.codex/skills). The app reads them, never runs them: the user links one to
// agents, and an agent reads it with ler_skill, straight from the file, so an
// edit in Claude Code counts from the next read.
-import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs'
+import { existsSync, readdirSync, readFileSync, realpathSync, statSync, type Dirent } from 'node:fs'
import { homedir } from 'node:os'
import { basename, dirname, extname, join, relative, sep } from 'node:path'
import { L } from '../shared/lang'
@@ -13,10 +13,22 @@ const TEXT = new Set(['.md', '.txt', '.json', '.yaml', '.yml', '.csv', '.toml',
const SCRIPT = new Set(['.py', '.sh', '.js', '.mjs', '.cjs', '.ts', '.rb', '.go', '.swift'])
const MAX_FILE = 60_000
+// A skill folder can be a symlink: the skills CLI keeps the recipe in ~/.agents/skills
+// and links it into ~/.claude/skills. isDirectory() is false for a link, so the stat decides.
+const isDir = (path: string, e: Dirent): boolean => {
+ if (e.isDirectory()) return true
+ if (!e.isSymbolicLink()) return false
+ try {
+ return statSync(path).isDirectory()
+ } catch {
+ return false
+ }
+}
+
const dirs = (d: string): string[] => {
try {
return readdirSync(d, { withFileTypes: true })
- .filter((e) => e.isDirectory())
+ .filter((e) => isDir(join(d, e.name), e))
.map((e) => join(d, e.name))
} catch {
return []
diff --git a/test/local-skills.test.ts b/test/local-skills.test.ts
index 20085fc..89fe8bc 100644
--- a/test/local-skills.test.ts
+++ b/test/local-skills.test.ts
@@ -46,6 +46,15 @@ describe('local skills', () => {
expect(video.scripts).toBe(true)
})
+ it('finds a skill whose folder is a symlink, as the skills CLI leaves it, and skips a broken one', () => {
+ put(join(home, '.agents/skills/grill-me/SKILL.md'), '---\nname: grill-me\ndescription: Entrevista sem piedade\n---\nChame grilling.')
+ symlinkSync(join(home, '.agents/skills/grill-me'), join(home, '.claude/skills/grill-me'))
+ symlinkSync(join(home, '.agents/skills/gone'), join(home, '.claude/skills/gone'), 'dir')
+ const found = findLocalSkills(home)
+ expect(found.filter((k) => k.origin === 'Claude Code').map((k) => k.name).sort()).toEqual(['grill-me', 'video'])
+ expect(found.find((k) => k.name === 'grill-me')?.source).toBe(join(home, '.claude/skills/grill-me/SKILL.md'))
+ })
+
it('reads a linked file only inside the skill folder, following links', () => {
const source = join(home, '.claude/skills/video/SKILL.md')
expect(readLinked(source)).toBe('# Vídeos\nLeia estilo.md antes.')