* Removes skill directories for workflows that are no longer selected in the active profile. * Returns the number of directories removed.
(
skillsDir: string,
desiredWorkflows: readonly (typeof ALL_WORKFLOWS)[number][]
)
| 424 | * Returns the number of directories removed. |
| 425 | */ |
| 426 | private async removeUnselectedSkillDirs( |
| 427 | skillsDir: string, |
| 428 | desiredWorkflows: readonly (typeof ALL_WORKFLOWS)[number][] |
| 429 | ): Promise<number> { |
| 430 | const desiredSet = new Set(desiredWorkflows); |
| 431 | let removed = 0; |
| 432 | |
| 433 | for (const workflow of ALL_WORKFLOWS) { |
| 434 | if (desiredSet.has(workflow)) continue; |
| 435 | const dirName = WORKFLOW_TO_SKILL_DIR[workflow]; |
| 436 | if (!dirName) continue; |
| 437 | |
| 438 | const skillDir = path.join(skillsDir, dirName); |
| 439 | try { |
| 440 | if (fs.existsSync(skillDir)) { |
| 441 | await fs.promises.rm(skillDir, { recursive: true, force: true }); |
| 442 | removed++; |
| 443 | } |
| 444 | } catch { |
| 445 | // Ignore errors |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | return removed; |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * Removes command files for workflows when delivery changed to skills-only. |