Skip to content

Commit 8c901e9

Browse files
committed
fix: prune gray package skills from host scan roots in hidden mode
Hidden apply previously only pruned active managed ids, leaving gray residues such as consumer-validation-engineering visible in IDE skill lists. Prune all package-registered skill ids (active+gray) from scan roots and cover with a regression test.
1 parent 19b22da commit 8c901e9

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

‎scripts/lib/global-host-config.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const {
2525
const {
2626
createSkillDeployFileFilter,
2727
listManagedSkillIds,
28+
listPrunableSkillIds,
2829
pruneManagedSkillDirs
2930
} = require('./skill-deploy-filter.js')
3031
const { resolveSkillsDeployMode } = require('./skills-deploy-mode.js')
@@ -641,6 +642,8 @@ function buildGlobalHostConfigPlan(options = {}) {
641642
: targets[0]?.host
642643
const hostPlans = []
643644
const managedSkillIds = listManagedSkillIds(packageRoot)
645+
// Hidden mode must also remove gray/historical package skill dirs from L1 scan roots
646+
const prunableSkillIds = listPrunableSkillIds(packageRoot)
644647
const pruneRootsSeen = new Set()
645648

646649
for (const target of targets) {
@@ -669,7 +672,8 @@ function buildGlobalHostConfigPlan(options = {}) {
669672
status: 'planned',
670673
operations: hostOperations,
671674
pruneManagedSkillRoots: pruneRoots,
672-
managedSkillIds
675+
managedSkillIds,
676+
prunableSkillIds
673677
})
674678
} catch (error) {
675679
hostPlans.push({
@@ -852,7 +856,7 @@ function applyGlobalHostConfig(options = {}) {
852856
}
853857
const result = pruneManagedSkillDirs(
854858
scanRoot,
855-
hostPlan.managedSkillIds || [],
859+
hostPlan.prunableSkillIds || hostPlan.managedSkillIds || [],
856860
fsImpl,
857861
{ dryRun: false }
858862
)

‎scripts/lib/skill-deploy-filter.js‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,27 @@ function isSkillsSource(source) {
6666
return normalized === 'skills' || normalized.endsWith('/skills')
6767
}
6868

69-
/** Active/deployable skill ids from plugin registry (managed set for prune). */
69+
/** Active/deployable skill ids from plugin registry (deploy set). */
7070
function listManagedSkillIds (packageRoot) {
7171
return loadPluginSkills(packageRoot)
7272
.filter(skill => isDeployableSkill(skill))
7373
.map(skill => String(skill.id))
7474
}
7575

76+
/**
77+
* Ids that must not remain on host L1 scan roots in hidden mode:
78+
* all package-registered skills (active + gray + other non-orphan registry rows).
79+
* Gray was previously copyable or left as residue when only active ids were pruned.
80+
*/
81+
function listPrunableSkillIds (packageRoot) {
82+
const fromPlugin = loadPluginSkills(packageRoot)
83+
.filter(skill => skill && skill.id)
84+
.map(skill => String(skill.id))
85+
// Always include known gray set even if plugin row missing during partial checkout
86+
const gray = graySkillIds(packageRoot)
87+
return Array.from(new Set([...fromPlugin, ...gray]))
88+
}
89+
7690
/**
7791
* Remove package-managed skill directories under a host scan root.
7892
* Does NOT use file-only removeStaleManagedPaths (that API only unlinks files).
@@ -116,6 +130,7 @@ module.exports = {
116130
isDeployableSkill,
117131
nonActiveSkillIdSet,
118132
listManagedSkillIds,
133+
listPrunableSkillIds,
119134
pruneManagedSkillDirs,
120135
shouldDeploySkillRelative,
121136
createSkillDeployFileFilter,

‎scripts/test-skills-deploy-mode.js‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ assert.strictEqual(resolveSkillsDeployMode({}, { skillsDeployMode: 'legacy' }),
4949
assert.ok(managed.includes('routing'), 'fixture package should manage routing skill')
5050
for (const scan of [
5151
path.join(home, '.agents', 'skills', 'routing'),
52-
path.join(home, '.claude', 'skills', 'routing')
52+
path.join(home, '.claude', 'skills', 'routing'),
53+
// gray residue must also be pruned in hidden mode
54+
path.join(home, '.agents', 'skills', 'consumer-validation-engineering'),
55+
path.join(home, '.claude', 'skills', 'consumer-validation-engineering')
5356
]) {
5457
fs.mkdirSync(scan, { recursive: true })
55-
fs.writeFileSync(path.join(scan, 'SKILL.md'), '---\nname: routing\n---\nlegacy\n', 'utf8')
58+
fs.writeFileSync(path.join(scan, 'SKILL.md'), '---\nname: stub\n---\nlegacy\n', 'utf8')
5659
}
5760

5861
const plan = buildGlobalHostConfigPlan({ packageRoot, env, home })
@@ -69,6 +72,16 @@ assert.strictEqual(resolveSkillsDeployMode({}, { skillsDeployMode: 'legacy' }),
6972
)
7073
assert.strictEqual(fs.existsSync(path.join(home, '.agents', 'skills', 'routing')), false)
7174
assert.strictEqual(fs.existsSync(path.join(home, '.claude', 'skills', 'routing')), false)
75+
assert.strictEqual(
76+
fs.existsSync(path.join(home, '.agents', 'skills', 'consumer-validation-engineering')),
77+
false,
78+
'gray package skill must be pruned from agents scan root'
79+
)
80+
assert.strictEqual(
81+
fs.existsSync(path.join(home, '.claude', 'skills', 'consumer-validation-engineering')),
82+
false,
83+
'gray package skill must be pruned from claude scan root'
84+
)
7285

7386
// legacy re-fills scan roots
7487
const legacy = applyGlobalHostConfig({

0 commit comments

Comments
 (0)