Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions scripts/install-global.mjs
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -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 }))
8 changes: 2 additions & 6 deletions scripts/sync-claude-skills.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions tests/skills.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
})

Expand Down
Loading