impeccable 2.3.1 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/bin/commands/skills.mjs +46 -173
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { execSync } from 'node:child_process';
|
|
11
|
-
import { existsSync, readFileSync, readdirSync, statSync, lstatSync,
|
|
11
|
+
import { existsSync, readFileSync, readdirSync, statSync, lstatSync, unlinkSync, mkdirSync, writeFileSync, rmSync, renameSync, createWriteStream, realpathSync } from 'node:fs';
|
|
12
12
|
import { join, resolve, dirname } from 'node:path';
|
|
13
13
|
import { createInterface } from 'node:readline';
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
@@ -237,31 +237,6 @@ function isAlreadyInstalled(root) {
|
|
|
237
237
|
return null;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
function escapeRegex(str) {
|
|
241
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function prefixSkillContent(content, prefix, allSkillNames) {
|
|
245
|
-
// Prefix the name in frontmatter
|
|
246
|
-
let result = content.replace(/^name:\s*(.+)$/m, (_, name) => `name: ${prefix}${name.trim()}`);
|
|
247
|
-
|
|
248
|
-
// Prefix cross-references: /skillname -> /prefix-skillname
|
|
249
|
-
const sorted = [...allSkillNames].sort((a, b) => b.length - a.length);
|
|
250
|
-
for (const name of sorted) {
|
|
251
|
-
// Command invocations: /skillname
|
|
252
|
-
result = result.replace(
|
|
253
|
-
new RegExp(`/(?=${escapeRegex(name)}(?:[^a-zA-Z0-9_-]|$))`, 'g'),
|
|
254
|
-
`/${prefix}`
|
|
255
|
-
);
|
|
256
|
-
// Prose references: "the skillname skill"
|
|
257
|
-
result = result.replace(
|
|
258
|
-
new RegExp(`(the) ${escapeRegex(name)} skill`, 'gi'),
|
|
259
|
-
(_, article) => `${article} ${prefix}${name} skill`
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
return result;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
240
|
function isSkillDir(skillsDir, name) {
|
|
266
241
|
// Skill entries can be real directories or symlinks to directories (npx skills uses symlinks)
|
|
267
242
|
const full = join(skillsDir, name);
|
|
@@ -279,63 +254,40 @@ function isRealSkillDir(skillsDir, name) {
|
|
|
279
254
|
} catch { return false; }
|
|
280
255
|
}
|
|
281
256
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
let
|
|
295
|
-
for (const d of PROVIDER_DIRS) {
|
|
296
|
-
const skillsDir = join(root, d, 'skills');
|
|
297
|
-
if (!existsSync(skillsDir)) continue;
|
|
298
|
-
try {
|
|
299
|
-
const entries = readdirSync(skillsDir);
|
|
300
|
-
for (const name of entries) {
|
|
301
|
-
if (name.startsWith(prefix)) continue;
|
|
302
|
-
if (!isRealSkillDir(skillsDir, name)) continue;
|
|
303
|
-
|
|
304
|
-
const src = join(skillsDir, name);
|
|
305
|
-
const dest = join(skillsDir, prefix + name);
|
|
306
|
-
|
|
307
|
-
renameSync(src, dest);
|
|
308
|
-
|
|
309
|
-
// Prefix frontmatter name + all cross-references in SKILL.md
|
|
310
|
-
let content = readFileSync(join(dest, 'SKILL.md'), 'utf8');
|
|
311
|
-
content = prefixSkillContent(content, prefix, allSkillNames);
|
|
312
|
-
writeFileSync(join(dest, 'SKILL.md'), content);
|
|
313
|
-
count++;
|
|
314
|
-
}
|
|
315
|
-
} catch {}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Third pass: fix symlinks that now point to renamed targets (npx skills uses these)
|
|
257
|
+
/**
|
|
258
|
+
* One-way migration for installs from the era when the CLI offered a command
|
|
259
|
+
* prefix (default `i-`), renaming the skill to e.g. `i-impeccable`. The prefix
|
|
260
|
+
* only earned its keep when every command was its own skill; with a single
|
|
261
|
+
* `impeccable` skill it does nothing, so it is no longer offered. Rename any
|
|
262
|
+
* prefixed impeccable skill back to the canonical `impeccable` (the fresh
|
|
263
|
+
* install/update content lands there next) so users aren't left with a stale,
|
|
264
|
+
* orphaned `i-impeccable` alongside the new one. Scoped to the impeccable skill
|
|
265
|
+
* by name -- never touches third-party skills that happen to start with `i-`.
|
|
266
|
+
* Returns the number of skills migrated.
|
|
267
|
+
*/
|
|
268
|
+
function migrateUnprefixImpeccable(root) {
|
|
269
|
+
let migrated = 0;
|
|
319
270
|
for (const d of PROVIDER_DIRS) {
|
|
320
271
|
const skillsDir = join(root, d, 'skills');
|
|
321
272
|
if (!existsSync(skillsDir)) continue;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
273
|
+
let entries;
|
|
274
|
+
try { entries = readdirSync(skillsDir); } catch { continue; }
|
|
275
|
+
for (const name of entries) {
|
|
276
|
+
// A prefixed impeccable skill is `<prefix>impeccable` -- not the canonical
|
|
277
|
+
// `impeccable`, and not the legacy `teach-impeccable` (cleanup handles that).
|
|
278
|
+
if (name === 'impeccable' || name === 'teach-impeccable') continue;
|
|
279
|
+
if (!name.endsWith('-impeccable')) continue;
|
|
280
|
+
if (!isRealSkillDir(skillsDir, name)) continue;
|
|
281
|
+
|
|
282
|
+
const dest = join(skillsDir, 'impeccable');
|
|
283
|
+
try {
|
|
284
|
+
rmSync(dest, { recursive: true, force: true });
|
|
285
|
+
renameSync(join(skillsDir, name), dest);
|
|
286
|
+
migrated++;
|
|
287
|
+
} catch {}
|
|
288
|
+
}
|
|
336
289
|
}
|
|
337
|
-
|
|
338
|
-
return count;
|
|
290
|
+
return migrated;
|
|
339
291
|
}
|
|
340
292
|
|
|
341
293
|
/**
|
|
@@ -401,7 +353,6 @@ function copyProviderSkills(bundleDir, root, targets) {
|
|
|
401
353
|
async function install(flags) {
|
|
402
354
|
const force = flags.includes('--force');
|
|
403
355
|
const yes = flags.includes('-y') || flags.includes('--yes');
|
|
404
|
-
const prefixFlag = flags.find(f => f.startsWith('--prefix='));
|
|
405
356
|
const providersFlag = flags.find(f => f.startsWith('--providers='));
|
|
406
357
|
const root = findProjectRoot();
|
|
407
358
|
const existing = isAlreadyInstalled(root);
|
|
@@ -442,6 +393,10 @@ async function install(flags) {
|
|
|
442
393
|
process.exit(1);
|
|
443
394
|
}
|
|
444
395
|
|
|
396
|
+
// Retire any old `i-`-prefixed install so the fresh copy lands on the
|
|
397
|
+
// canonical `impeccable` dir instead of orphaning the prefixed one.
|
|
398
|
+
migrateUnprefixImpeccable(root);
|
|
399
|
+
|
|
445
400
|
let written = 0;
|
|
446
401
|
try {
|
|
447
402
|
written = copyProviderSkills(bundleDir, root, targets);
|
|
@@ -458,27 +413,6 @@ async function install(flags) {
|
|
|
458
413
|
}
|
|
459
414
|
console.log(`Installed impeccable into: ${targets.join(', ')}`);
|
|
460
415
|
|
|
461
|
-
// Ask about prefixing (skip in CI mode unless --prefix= is set)
|
|
462
|
-
let prefix = '';
|
|
463
|
-
if (prefixFlag) {
|
|
464
|
-
prefix = prefixFlag.split('=')[1] || 'i-';
|
|
465
|
-
} else if (!yes) {
|
|
466
|
-
console.log();
|
|
467
|
-
const wantPrefix = await ask('Prefix commands to avoid conflicts? e.g. /i-audit instead of /audit (y/N) ');
|
|
468
|
-
if (wantPrefix === 'y' || wantPrefix === 'yes') {
|
|
469
|
-
const custom = await ask('Prefix (default: i-): ');
|
|
470
|
-
prefix = custom || 'i-';
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
if (prefix) {
|
|
475
|
-
const count = renameSkillsWithPrefix(root, prefix);
|
|
476
|
-
if (count > 0) {
|
|
477
|
-
console.log(`\nRenamed ${count} skills with "${prefix}" prefix.`);
|
|
478
|
-
console.log(`Commands are now available as /${prefix}<command> (e.g. /${prefix}audit).`);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
416
|
// Clean up deprecated skills from previous versions
|
|
483
417
|
try {
|
|
484
418
|
const { cleanup } = await import('../../../skill/scripts/cleanup-deprecated.mjs');
|
|
@@ -491,71 +425,7 @@ async function install(flags) {
|
|
|
491
425
|
// Cleanup script not available -- skip
|
|
492
426
|
}
|
|
493
427
|
|
|
494
|
-
console.log(
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
/** Detect prefix by looking for the 'impeccable' skill (or legacy 'teach-impeccable') */
|
|
498
|
-
function detectPrefix(root) {
|
|
499
|
-
for (const d of PROVIDER_DIRS) {
|
|
500
|
-
const skillsDir = join(root, d, 'skills');
|
|
501
|
-
if (!existsSync(skillsDir)) continue;
|
|
502
|
-
for (const name of readdirSync(skillsDir)) {
|
|
503
|
-
if (name === 'impeccable') return '';
|
|
504
|
-
if (name.endsWith('-impeccable') && name !== 'teach-impeccable') return name.slice(0, -'impeccable'.length);
|
|
505
|
-
// Legacy fallback
|
|
506
|
-
if (name === 'teach-impeccable') return '';
|
|
507
|
-
if (name.endsWith('-teach-impeccable')) return name.slice(0, -'teach-impeccable'.length);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
return '';
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/** Undo prefixing: rename folders back and strip prefix from SKILL.md content */
|
|
514
|
-
function undoPrefix(root, prefix) {
|
|
515
|
-
if (!prefix) return;
|
|
516
|
-
// Collect the unprefixed names (strip our prefix)
|
|
517
|
-
let allPrefixedNames = [];
|
|
518
|
-
for (const d of PROVIDER_DIRS) {
|
|
519
|
-
const skillsDir = join(root, d, 'skills');
|
|
520
|
-
if (!existsSync(skillsDir)) continue;
|
|
521
|
-
allPrefixedNames = readdirSync(skillsDir).filter(n => n.startsWith(prefix) && isRealSkillDir(skillsDir, n));
|
|
522
|
-
if (allPrefixedNames.length > 0) break;
|
|
523
|
-
}
|
|
524
|
-
const unprefixedNames = allPrefixedNames.map(n => n.slice(prefix.length));
|
|
525
|
-
|
|
526
|
-
for (const d of PROVIDER_DIRS) {
|
|
527
|
-
const skillsDir = join(root, d, 'skills');
|
|
528
|
-
if (!existsSync(skillsDir)) continue;
|
|
529
|
-
for (const name of readdirSync(skillsDir)) {
|
|
530
|
-
if (!name.startsWith(prefix)) continue;
|
|
531
|
-
const unprefixed = name.slice(prefix.length);
|
|
532
|
-
const src = join(skillsDir, name);
|
|
533
|
-
const dest = join(skillsDir, unprefixed);
|
|
534
|
-
|
|
535
|
-
if (lstatSync(src).isSymbolicLink()) {
|
|
536
|
-
const target = readlinkSync(src);
|
|
537
|
-
const newTarget = target.replace(`/${name}`, `/${unprefixed}`);
|
|
538
|
-
unlinkSync(src);
|
|
539
|
-
symlinkSync(newTarget, dest);
|
|
540
|
-
} else {
|
|
541
|
-
renameSync(src, dest);
|
|
542
|
-
// Strip prefix from SKILL.md content
|
|
543
|
-
const skillMd = join(dest, 'SKILL.md');
|
|
544
|
-
if (existsSync(skillMd)) {
|
|
545
|
-
let content = readFileSync(skillMd, 'utf8');
|
|
546
|
-
// Reverse the prefixing: replace prefixed names with unprefixed
|
|
547
|
-
content = content.replace(new RegExp(`^name:\\s*${escapeRegex(prefix)}`, 'm'), 'name: ');
|
|
548
|
-
const sorted = [...allPrefixedNames].sort((a, b) => b.length - a.length);
|
|
549
|
-
for (const pName of sorted) {
|
|
550
|
-
const uName = pName.slice(prefix.length);
|
|
551
|
-
content = content.replace(new RegExp(`/${escapeRegex(pName)}(?=[^a-zA-Z0-9_-]|$)`, 'g'), `/${uName}`);
|
|
552
|
-
content = content.replace(new RegExp(`(the) ${escapeRegex(pName)} skill`, 'gi'), `$1 ${uName} skill`);
|
|
553
|
-
}
|
|
554
|
-
writeFileSync(skillMd, content);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
}
|
|
428
|
+
console.log('\nDone! Run /impeccable init in your AI harness to set up design context.\n');
|
|
559
429
|
}
|
|
560
430
|
|
|
561
431
|
// ─── skills update ────────────────────────────────────────────────────────────
|
|
@@ -684,6 +554,11 @@ async function update(flags = []) {
|
|
|
684
554
|
|
|
685
555
|
try {
|
|
686
556
|
|
|
557
|
+
// Retire any old `i-`-prefixed install up front so the refresh lands on the
|
|
558
|
+
// canonical `impeccable` dir rather than orphaning the prefixed copy.
|
|
559
|
+
const migrated = migrateUnprefixImpeccable(root);
|
|
560
|
+
if (migrated > 0) console.log('Migrated a prefixed install back to /impeccable (the i- prefix is no longer used).');
|
|
561
|
+
|
|
687
562
|
// Copy from the bundle to each unique provider folder.
|
|
688
563
|
// Deduplicate so symlinked dirs (e.g. .claude/skills -> .agents/skills)
|
|
689
564
|
// are only written once with the correct provider's content.
|
|
@@ -706,13 +581,6 @@ async function update(flags = []) {
|
|
|
706
581
|
|
|
707
582
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
708
583
|
|
|
709
|
-
// Re-apply prefix if detected
|
|
710
|
-
const prefix = detectPrefix(root);
|
|
711
|
-
if (prefix) {
|
|
712
|
-
const count = renameSkillsWithPrefix(root, prefix);
|
|
713
|
-
if (count > 0) console.log(`Re-applied "${prefix}" prefix to ${count} skills.`);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
584
|
// Run cleanup to remove deprecated stubs from the fresh download
|
|
717
585
|
try {
|
|
718
586
|
const { cleanup: postCleanup } = await import('../../../skill/scripts/cleanup-deprecated.mjs');
|
|
@@ -744,6 +612,11 @@ function copyDirSync(src, dest) {
|
|
|
744
612
|
}
|
|
745
613
|
}
|
|
746
614
|
|
|
615
|
+
// ─── Test surface ───────────────────────────────────────────────────────────
|
|
616
|
+
// Exported so the test suite exercises the real implementation rather than a
|
|
617
|
+
// reimplementation in a helper script (which is how bugs slip through).
|
|
618
|
+
export { migrateUnprefixImpeccable };
|
|
619
|
+
|
|
747
620
|
// ─── Router ───────────────────────────────────────────────────────────────────
|
|
748
621
|
|
|
749
622
|
export async function run(args) {
|