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.
TypeScript agent-teamagentic-aiai-agentsai-assistantclaude-codecodexcursorelectrongrokgrok-bot-alternativelinuxlocal-firstmacosmcpmulti-agentopenclaw-alternativeopencodewindows
Discover plugin skills declared in the manifest (#1)
Gian Moraes2c18036d8066
diff --git a/src/core/local-skills.ts b/src/core/local-skills.tsindex 71ecb32..7f5149d 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 { readdirSync, readFileSync, realpathSync, statSync } from 'node:fs'+import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs'import { homedir } from 'node:os'import { basename, dirname, extname, join, relative, sep } from 'node:path'import { L } from '../shared/lang'@@ -98,7 +98,31 @@ function pluginSkills(claude: string): LocalSkill[] {const [plugin, market] = key.split('@')if (!plugin || !market) return []const versions = dirs(join(claude, 'plugins', 'cache', market, plugin)).sort((a, b) => statSync(b).mtimeMs - statSync(a).mtimeMs)- return versions[0] ? inDirs(join(versions[0], 'skills'), `Plugin ${plugin}`) : []+ if (!versions[0]) return []+ const root = realpathSync(versions[0])+ // The manifest's "skills" (a path or a list) adds folders to the skills/ scan: each one holds+ // <name>/SKILL.md folders or a SKILL.md itself ("./" is the root). Like Claude Code, a path+ // that leaves the plugin is ignored. With no skills/ and no "skills", a root SKILL.md is the skill.+ let declared: unknown+ try {+ declared = (JSON.parse(readFileSync(join(root, '.claude-plugin', 'plugin.json'), 'utf8')) as { skills?: unknown }).skills+ } catch {+ // no manifest: the default layout+ }+ const extra = (Array.isArray(declared) ? declared : [declared]).filter((p): p is string => typeof p === 'string')+ const folders = ['skills', ...extra, ...(extra.length === 0 && !existsSync(join(root, 'skills')) ? ['.'] : [])]+ const seen = new Set<string>()+ return folders.flatMap((p) => {+ let dir: string+ try {+ dir = realpathSync(join(root, p))+ } catch {+ return []+ }+ if (dir !== root && !dir.startsWith(root + sep)) return []+ const found = existsSync(join(dir, 'SKILL.md')) ? [skill(join(dir, 'SKILL.md'), `Plugin ${plugin}`)].filter((s): s is LocalSkill => !!s) : inDirs(dir, `Plugin ${plugin}`)+ return found.filter((s) => !seen.has(s.source) && !!seen.add(s.source))+ })})}diff --git a/test/local-skills.test.ts b/test/local-skills.test.tsindex a77290c..20085fc 100644--- a/test/local-skills.test.ts+++ b/test/local-skills.test.ts@@ -21,9 +21,12 @@ beforeEach(() => {put(join(home, '.claude/skills/video/SKILL.md'), '---\nname: video\ndescription: |\n Cria os vídeos do canal.\n Use pra "novo vídeo".\n---\n# Vídeos\nLeia estilo.md antes.')put(join(home, '.claude/skills/video/estilo.md'), 'Quadro de marcador.')put(join(home, '.claude/skills/video/motor/build.py'), 'print(1)')- put(join(home, '.claude/settings.json'), JSON.stringify({ enabledPlugins: { 'sdd@mkt': true, 'off@mkt': false }, hooks: { Stop: [] } }))+ put(join(home, '.claude/settings.json'), JSON.stringify({ enabledPlugins: { 'sdd@mkt': true, 'root@mkt': true, 'off@mkt': false }, hooks: { Stop: [] } }))put(join(home, '.claude/plugins/cache/mkt/sdd/1.0.0/skills/verify/SKILL.md'), '---\nname: verify\ndescription: "Confere a entrega"\n---\nPassos.')put(join(home, '.claude/plugins/cache/mkt/off/1.0.0/skills/hidden/SKILL.md'), '---\nname: hidden\n---\n')+ // A plugin whose skill is the root itself, as "skills": ["./"] declares in the manifest.+ put(join(home, '.claude/plugins/cache/mkt/root/1.0.0/SKILL.md'), '---\nname: humanize\ndescription: "Remove AI tells"\n---\nReceita.')+ put(join(home, '.claude/plugins/cache/mkt/root/1.0.0/.claude-plugin/plugin.json'), JSON.stringify({ name: 'root', version: '1.0.0', skills: ['./'] }))put(join(home, '.codex/skills/imediato/SKILL.md'), '---\nname: imediato\ndescription: Responde já\n---\nCorpo.')put(join(home, 'secret.md'), 'segredo')symlinkSync(join(home, 'secret.md'), join(home, '.claude/skills/video/fuga.md'))@@ -36,7 +39,7 @@ describe('local skills', () => {it("finds the user's Claude Code skills, the turned-on plugins' and Codex's, with their files and scripts", () => {const found = findLocalSkills(home)- expect(found.map((k) => [k.name, k.origin])).toEqual([['video', 'Claude Code'], ['verify', 'Plugin sdd'], ['imediato', 'Codex']])+ expect(found.map((k) => [k.name, k.origin])).toEqual([['video', 'Claude Code'], ['verify', 'Plugin sdd'], ['humanize', 'Plugin root'], ['imediato', 'Codex']])const video = found[0]!expect(video.description).toBe('Cria os vídeos do canal. Use pra "novo vídeo".')expect(video.files).toEqual(['estilo.md', 'fuga.md'])@@ -69,3 +72,36 @@ describe('local skills', () => {expect(skills.save({ id: k.id, name: 'outro', description: '', body: '', agents: ['a1'] })).toMatchObject({ name: 'video', agents: ['a1'], source })})})++// One turned-on plugin, laid out as each case needs, following Claude Code's manifest rules.+describe('plugin skills declared in the manifest', () => {+ const plugin = (manifest: object | null, files: Record<string, string>): string => {+ const root = join(home, '.claude/plugins/cache/mkt/p/1.0.0')+ put(join(home, '.claude/settings.json'), JSON.stringify({ enabledPlugins: { 'p@mkt': true } }))+ if (manifest) put(join(root, '.claude-plugin/plugin.json'), JSON.stringify(manifest))+ for (const [file, text] of Object.entries(files)) put(join(root, file), text)+ return root+ }+ const names = (): string[] => findLocalSkills(home).filter((k) => k.origin === 'Plugin p').map((k) => k.name).sort()++ it('adds the declared folders to the skills/ scan', () => {+ plugin({ name: 'p', skills: ['./extra/'] }, { 'skills/a/SKILL.md': '---\nname: a\n---\n', 'extra/b/SKILL.md': '---\nname: b\n---\n' })+ expect(names()).toEqual(['a', 'b'])+ })++ it('takes a single path as well as a list', () => {+ plugin({ name: 'p', skills: './' }, { 'SKILL.md': '---\nname: root\n---\n' })+ expect(names()).toEqual(['root'])+ })++ it('reads a root SKILL.md as the skill when there is no skills/ and no manifest', () => {+ plugin(null, { 'SKILL.md': '---\nname: root\n---\n' })+ expect(names()).toEqual(['root'])+ })++ it('ignores a declared path that leaves the plugin', () => {+ plugin({ name: 'p', skills: ['../../../../../../'] }, {})+ put(join(home, 'SKILL.md'), '---\nname: fora\n---\n')+ expect(names()).toEqual([])+ })+})