(workDir: string, skills: SkillEntry[])
| 68 | } |
| 69 | |
| 70 | export function installSkills(workDir: string, skills: SkillEntry[]): void { |
| 71 | if (skills.length === 0) { |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | for (const group of groupSkillsBySource(skills)) { |
| 76 | const args = buildInstallArgs(group); |
| 77 | const displayArgs = args |
| 78 | .map((arg) => (/\s/.test(arg) ? JSON.stringify(arg) : arg)) |
| 79 | .join(" "); |
| 80 | |
| 81 | console.log(chalk.dim(`> npx ${displayArgs}`)); |
| 82 | |
| 83 | const result = spawnSync("npx", args, { |
| 84 | cwd: workDir, |
| 85 | stdio: "inherit", |
| 86 | encoding: "utf-8", |
| 87 | }); |
| 88 | |
| 89 | if (result.error) { |
| 90 | throw result.error; |
| 91 | } |
| 92 | |
| 93 | if (result.status !== 0) { |
| 94 | throw new Error( |
| 95 | `Failed to install skills from ${group.source} (exit code ${result.status ?? "unknown"})`, |
| 96 | ); |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | export function scanInstalledSkills(workDir: string): InstalledSkill[] { |
| 102 | const installed: InstalledSkill[] = []; |
no test coverage detected