( clientFlag: string | undefined, destFlag: string | undefined, operation: 'install' | 'uninstall', )
| 196 | } |
| 197 | |
| 198 | function resolveTargets( |
| 199 | clientFlag: string | undefined, |
| 200 | destFlag: string | undefined, |
| 201 | operation: 'install' | 'uninstall', |
| 202 | ): ClientInfo[] { |
| 203 | if (destFlag) { |
| 204 | const resolvedDest = resolvePathFromCwd(destFlag); |
| 205 | if (resolvedDest === path.parse(resolvedDest).root) { |
| 206 | throw new Error( |
| 207 | 'Refusing to use filesystem root as skills destination. Use a dedicated directory.', |
| 208 | ); |
| 209 | } |
| 210 | return [{ name: 'Custom', id: 'custom', skillsDir: resolvedDest }]; |
| 211 | } |
| 212 | |
| 213 | if (clientFlag && clientFlag !== 'auto') { |
| 214 | const def = CLIENT_DEFINITIONS.find((d) => d.id === clientFlag); |
| 215 | if (!def) { |
| 216 | throw new Error(`Unknown client: ${clientFlag}. Valid clients: claude, agents`); |
| 217 | } |
| 218 | const home = os.homedir(); |
| 219 | return [{ name: def.name, id: def.id, skillsDir: path.join(home, def.skillsSubdir) }]; |
| 220 | } |
| 221 | |
| 222 | const detected = detectClients(); |
| 223 | if (detected.length === 0) { |
| 224 | if (operation === 'uninstall') { |
| 225 | return []; |
| 226 | } |
| 227 | |
| 228 | throw new Error( |
| 229 | 'No supported AI clients detected.\n' + |
| 230 | 'Use --client to specify a client, --dest to specify a custom path, or --print to output the skill content.', |
| 231 | ); |
| 232 | } |
| 233 | return detected; |
| 234 | } |
| 235 | |
| 236 | function renderAgentsAppendDiff(fileName: string): string { |
| 237 | return `--- ${fileName}\n+++ ${fileName}\n@@\n+${AGENTS_GUIDANCE_LINE}`; |
no test coverage detected