更新 verify-skill-admin.mjs

This commit is contained in:
QQ 2026-11-11 11:34:27 +08:00
parent 3677e90c4f
commit 07ce910e08
1 changed files with 9 additions and 15 deletions

View File

@ -45,12 +45,11 @@ writeFileSync(join(process.env.DSH_HOME, 'cloud-memory-skills.json'), JSON.strin
delivered: {}, removed: {},
}, null, 2))
const { SkillAdmin, SkillAdminError, skillsHoldingDir, skillsTrashDir } = await import('./lib/skill-admin.js')
const { SkillAdmin, SkillAdminError, skillsHoldingDir } = await import('./lib/skill-admin.js')
const holding = skillsHoldingDir()
const admin = new SkillAdmin({
skillsRoot: () => root,
holdingDir: () => holding,
trashDir: () => skillsTrashDir(),
syncStatePath: () => join(process.env.DSH_HOME, 'cloud-memory-skills.json'),
syncRunning: () => false,
log: () => {},
@ -75,21 +74,16 @@ check('parked skill lists as disabled', inventory.skills.find((s) => s.folder ==
await admin.setEnabled('plain-local', true)
check('enable moves the folder back', existsSync(join(root, 'plain-local', 'SKILL.md')))
// 3. Remove goes to trash; restore returns it.
const trashed = await admin.remove('handmade')
check('remove lands in trash with an index entry',
!existsSync(join(root, 'handmade')) && existsSync(join(skillsTrashDir(), trashed.id, 'SKILL.md')) && trashed.from === 'root')
await admin.restore(trashed.id)
check('restore returns the skill to the root', existsSync(join(root, 'handmade', 'SKILL.md')))
// 3. Remove is a real delete: the folder is gone, for good.
await admin.remove('handmade')
check('remove deletes the folder outright',
!existsSync(join(root, 'handmade')) && !(await admin.list()).skills.some((s) => s.folder === 'handmade'))
// 4. A parked skill restores into the parking area, staying disabled.
// 4. A parked skill deletes from the parking area too.
await admin.setEnabled('plain-local', false)
const trashedParked = await admin.remove('plain-local')
check('parked removal remembers its area', trashedParked.from === 'holding')
await admin.restore(trashedParked.id)
check('restore of a parked skill keeps it parked',
existsSync(join(holding, 'plain-local', 'SKILL.md')) && !existsSync(join(root, 'plain-local')))
await admin.setEnabled('plain-local', true)
await admin.remove('plain-local')
check('remove deletes a parked skill as well',
!existsSync(join(holding, 'plain-local')) && !existsSync(join(root, 'plain-local')))
// 5. Install from a git repository (file:// fixture), then collide.
const repo = mkdtempSync(join(tmpdir(), 'skill-repo-'))