Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Effect, FileSystem, Option, Path } from 'effect'; |
| 2 | |
| 3 | const SKILL_NAME = 'composio-cli'; |
| 4 | |
| 5 | /** |
| 6 | * Find every directory where the composio-cli skill is currently installed. |
| 7 | * Known locations: |
| 8 | * ~/.agents/skills/composio-cli (canonical install target) |
| 9 | * ~/.claude/skills/composio-cli (Claude Code — may be a symlink or a real dir) |
| 10 | * |
| 11 | * We resolve symlinks so we don't rebuild the same physical directory twice, |
| 12 | * but we also rebuild any real (non-symlink) copies so everything stays in sync. |
| 13 | */ |
| 14 | export const discoverSkillRoots = (home: string) => |
| 15 | Effect.gen(function* () { |
| 16 | const fs = yield* FileSystem.FileSystem; |
| 17 | const path = yield* Path.Path; |
| 18 | const candidates = [path.join(home, '.agents', 'skills'), path.join(home, '.claude', 'skills')]; |
| 19 | const seen = new Set<string>(); |
| 20 | const roots: string[] = []; |
| 21 | |
| 22 | for (const parent of candidates) { |
| 23 | const skillDir = path.join(parent, SKILL_NAME); |
| 24 | const link = yield* fs.readLink(skillDir).pipe(Effect.option); |
| 25 | if (Option.isSome(link)) { |
| 26 | const realDir = yield* fs.realPath(skillDir).pipe(Effect.option); |
| 27 | if (Option.isNone(realDir)) continue; |
| 28 | |
| 29 | const realParent = path.dirname(realDir.value); |
| 30 | if (!seen.has(realParent)) { |
| 31 | seen.add(realParent); |
| 32 | roots.push(realParent); |
| 33 | } |
| 34 | continue; |
| 35 | } |
| 36 | |
| 37 | const stat = yield* fs.stat(skillDir).pipe(Effect.option); |
| 38 | if (Option.isSome(stat) && stat.value.type === 'Directory' && !seen.has(parent)) { |
| 39 | seen.add(parent); |
| 40 | roots.push(parent); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | // Always include ~/.agents/skills as a fallback so there's at least one target |
| 45 | const agentSkillsRoot = path.join(home, '.agents', 'skills'); |
| 46 | if (!seen.has(agentSkillsRoot)) { |
| 47 | roots.push(agentSkillsRoot); |
| 48 | } |
| 49 | |
| 50 | return roots; |
| 51 | }); |