diff --git a/scripts/install-global.mjs b/scripts/install-global.mjs index 62bc38c..de81919 100644 --- a/scripts/install-global.mjs +++ b/scripts/install-global.mjs @@ -1,12 +1,11 @@ #!/usr/bin/env node -import { cp, mkdir, readFile, rename, stat, writeFile } from 'node:fs/promises' +import { cp, mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises' import { createHash } from 'node:crypto' import { homedir } from 'node:os' -import { dirname, join, resolve } from 'node:path' +import { join, resolve } from 'node:path' const root = resolve(new URL('..', import.meta.url).pathname) const destination = process.env.TOOLBOX_SKILLS_DIR ?? join(homedir(), '.agents', 'skills') -const backupRoot = join(destination, '_agent', 'install-backups', `toolbox-${Date.now()}`) const retired = ['refine-agent-work'] const registry = JSON.parse(await readFile(join(root, 'skills-lock.json'), 'utf8')) const managed = Object.keys(registry.skills ?? registry) @@ -27,9 +26,7 @@ await mkdir(destination, { recursive: true }) for (const slug of [...managed, ...retired]) { const target = join(destination, slug) if (!(await exists(target))) continue - const backup = join(backupRoot, slug) - await mkdir(dirname(backup), { recursive: true }) - await rename(target, backup) + await rm(target, { recursive: true, force: true }) } for (const slug of managed) { const source = join(root, slug) @@ -48,16 +45,9 @@ await writeFile( installedAt: new Date().toISOString(), skills: installed, retired, - backups: (await exists(backupRoot)) ? backupRoot : null, }, null, 2, ) + '\n', ) -console.log( - JSON.stringify({ - destination, - skills: managed.length, - backups: (await exists(backupRoot)) ? backupRoot : null, - }), -) +console.log(JSON.stringify({ destination, skills: managed.length })) diff --git a/scripts/sync-claude-skills.mjs b/scripts/sync-claude-skills.mjs index 8231905..c8697db 100644 --- a/scripts/sync-claude-skills.mjs +++ b/scripts/sync-claude-skills.mjs @@ -8,7 +8,7 @@ * * Run via `npm run sync:skills` (Node strip-types for the shared slug list). */ -import { mkdir, rm, symlink, lstat, readlink, rename } from 'node:fs/promises' +import { mkdir, rm, symlink, lstat, readlink } from 'node:fs/promises' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' import { EXPECTED_SKILLS } from '../src/expected-skills.ts' @@ -32,11 +32,7 @@ for (const skillsRoot of MIRRORS) { (await readlink(retired)) === join(RELATIVE_TARGET, 'refine-agent-work') ) await rm(retired) - else { - const backup = join(root, '_agent', 'install-backups') - await mkdir(backup, { recursive: true }) - await rename(retired, join(backup, `refine-agent-work-${Date.now()}`)) - } + else await rm(retired, { recursive: true, force: true }) } catch (error) { if (error.code !== 'ENOENT') throw error } diff --git a/tests/skills.test.js b/tests/skills.test.js index eb2f842..0530d45 100644 --- a/tests/skills.test.js +++ b/tests/skills.test.js @@ -452,10 +452,13 @@ describe('toolbox skill SSOT', () => { it('sync:skills imports EXPECTED_SKILLS (no duplicated slug list)', () => { const sync = readFileSync(join(root, 'scripts/sync-claude-skills.mjs'), 'utf8') + const install = readFileSync(join(root, 'scripts/install-global.mjs'), 'utf8') const pkg = readFileSync(join(root, 'package.json'), 'utf8') expect(sync).toMatch(/from ['"]\.\.\/src\/expected-skills\.ts['"]/) expect(sync).toMatch(/EXPECTED_SKILLS/) expect(sync).not.toMatch(/const SKILL_SLUGS = \[\s*'subagents'/) + expect(sync).not.toMatch(/install-backups/) + expect(install).not.toMatch(/install-backups|backupRoot|backups:/) expect(pkg).toMatch(/sync:skills": "node --experimental-strip-types/) })