impeccable 2.1.1 → 2.1.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/bin/cli.js +1 -0
- package/bin/commands/skills.mjs +130 -45
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -29,6 +29,7 @@ Commands:
|
|
|
29
29
|
skills help List all available skills and commands
|
|
30
30
|
skills install Install impeccable skills into your project
|
|
31
31
|
skills update Update skills to the latest version
|
|
32
|
+
skills check Check if skill updates are available
|
|
32
33
|
|
|
33
34
|
Options:
|
|
34
35
|
--help Show this help message
|
package/bin/commands/skills.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { join, resolve, dirname } from 'node:path';
|
|
|
13
13
|
import { createInterface } from 'node:readline';
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
15
15
|
import { get } from 'node:https';
|
|
16
|
+
import { createHash } from 'node:crypto';
|
|
16
17
|
import { tmpdir } from 'node:os';
|
|
17
18
|
|
|
18
19
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -57,6 +58,106 @@ async function showHelp() {
|
|
|
57
58
|
console.log(`\n ${commands.length} commands available. Run /<command> in your AI harness.\n`);
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
// ─── version helpers ─────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
function getLocalVersion() {
|
|
64
|
+
try {
|
|
65
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf-8'));
|
|
66
|
+
return pkg.version;
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function fetchRemoteVersion() {
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
get('https://registry.npmjs.org/impeccable/latest', (res) => {
|
|
75
|
+
if (res.statusCode !== 200) { resolve(null); res.resume(); return; }
|
|
76
|
+
let data = '';
|
|
77
|
+
res.on('data', (chunk) => { data += chunk; });
|
|
78
|
+
res.on('end', () => {
|
|
79
|
+
try { resolve(JSON.parse(data).version); } catch { resolve(null); }
|
|
80
|
+
});
|
|
81
|
+
}).on('error', () => resolve(null));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Hash all SKILL.md files in a directory tree for comparison.
|
|
87
|
+
* Returns a sorted string of "name:hash" pairs.
|
|
88
|
+
*/
|
|
89
|
+
function hashSkillsDir(skillsDir) {
|
|
90
|
+
if (!existsSync(skillsDir)) return '';
|
|
91
|
+
const entries = [];
|
|
92
|
+
for (const name of readdirSync(skillsDir).sort()) {
|
|
93
|
+
const skillMd = join(skillsDir, name, 'SKILL.md');
|
|
94
|
+
if (!existsSync(skillMd)) continue;
|
|
95
|
+
const hash = createHash('sha256').update(readFileSync(skillMd)).digest('hex').slice(0, 12);
|
|
96
|
+
entries.push(`${name}:${hash}`);
|
|
97
|
+
}
|
|
98
|
+
return entries.join(',');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Download the universal bundle to a temp dir and return its path.
|
|
103
|
+
* Caller is responsible for cleanup.
|
|
104
|
+
*/
|
|
105
|
+
async function downloadAndExtractBundle() {
|
|
106
|
+
const tmpZip = join(tmpdir(), `impeccable-update-${Date.now()}.zip`);
|
|
107
|
+
const tmpDir = join(tmpdir(), `impeccable-update-${Date.now()}`);
|
|
108
|
+
await downloadFile(`${API_BASE}/api/download/bundle/universal`, tmpZip);
|
|
109
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
110
|
+
execSync(`unzip -qo "${tmpZip}" -d "${tmpDir}"`, { encoding: 'utf8' });
|
|
111
|
+
rmSync(tmpZip, { force: true });
|
|
112
|
+
return tmpDir;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Compare local skills against a downloaded bundle.
|
|
117
|
+
* Returns true if all local SKILL.md files match the bundle.
|
|
118
|
+
*/
|
|
119
|
+
function isUpToDate(root, providers, bundleDir) {
|
|
120
|
+
for (const provider of providers) {
|
|
121
|
+
const localHash = hashSkillsDir(join(root, provider, 'skills'));
|
|
122
|
+
const remoteHash = hashSkillsDir(join(bundleDir, provider, 'skills'));
|
|
123
|
+
if (localHash !== remoteHash) return false;
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ─── skills check ────────────────────────────────────────────────────────────
|
|
129
|
+
|
|
130
|
+
async function check() {
|
|
131
|
+
const root = findProjectRoot();
|
|
132
|
+
const installed = isAlreadyInstalled(root);
|
|
133
|
+
|
|
134
|
+
if (!installed) {
|
|
135
|
+
console.log('Impeccable is not installed in this project.');
|
|
136
|
+
console.log('Run `npx impeccable skills install` to install.');
|
|
137
|
+
process.exit(0);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const providers = findInstalledProviders(root);
|
|
141
|
+
const version = getLocalVersion();
|
|
142
|
+
|
|
143
|
+
console.log('Checking for updates...\n');
|
|
144
|
+
try {
|
|
145
|
+
const bundleDir = await downloadAndExtractBundle();
|
|
146
|
+
const upToDate = isUpToDate(root, providers, bundleDir);
|
|
147
|
+
rmSync(bundleDir, { recursive: true, force: true });
|
|
148
|
+
|
|
149
|
+
if (upToDate) {
|
|
150
|
+
console.log(`Skills are up to date${version ? ` (v${version})` : ''}.`);
|
|
151
|
+
} else {
|
|
152
|
+
console.log(`Updates available${version ? ` (currently v${version})` : ''}.`);
|
|
153
|
+
console.log('Run `npx impeccable skills update` to update.');
|
|
154
|
+
}
|
|
155
|
+
} catch (e) {
|
|
156
|
+
console.error(`Could not check for updates: ${e.message}`);
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
60
161
|
// ─── skills install ───────────────────────────────────────────────────────────
|
|
61
162
|
|
|
62
163
|
// Check if impeccable skills are already present in any provider folder
|
|
@@ -385,8 +486,6 @@ async function update(flags = []) {
|
|
|
385
486
|
// Download the latest skills directly from impeccable.style.
|
|
386
487
|
// We skip `npx skills update` because it has a known upstream bug
|
|
387
488
|
// (vercel-labs/skills#775) where it can't find the lock file.
|
|
388
|
-
console.log('Checking for updates...\n');
|
|
389
|
-
|
|
390
489
|
const root = findProjectRoot();
|
|
391
490
|
const providers = findInstalledProviders(root);
|
|
392
491
|
|
|
@@ -396,73 +495,56 @@ async function update(flags = []) {
|
|
|
396
495
|
process.exit(1);
|
|
397
496
|
}
|
|
398
497
|
|
|
399
|
-
console.log(
|
|
498
|
+
console.log('Checking for updates...');
|
|
400
499
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
500
|
+
let tmpDir;
|
|
501
|
+
try {
|
|
502
|
+
tmpDir = await downloadAndExtractBundle();
|
|
503
|
+
} catch (e) {
|
|
504
|
+
console.error(`Download failed: ${e.message}`);
|
|
505
|
+
process.exit(1);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// Compare local vs remote -- skip if already up to date
|
|
509
|
+
if (!yes && isUpToDate(root, providers, tmpDir)) {
|
|
510
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
511
|
+
const version = getLocalVersion();
|
|
512
|
+
console.log(`Skills are up to date${version ? ` (v${version})` : ''}. Nothing to do.`);
|
|
513
|
+
process.exit(0);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
console.log(`Found skills in: ${providers.join(', ')}`);
|
|
517
|
+
|
|
518
|
+
if (!yes) {
|
|
418
519
|
const ans = await ask(`Update skills in ${providers.length} provider folder(s)? (Y/n) `);
|
|
419
520
|
if (ans === 'n' || ans === 'no') {
|
|
521
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
420
522
|
console.log('Aborted.');
|
|
421
523
|
process.exit(0);
|
|
422
524
|
}
|
|
423
525
|
}
|
|
424
526
|
|
|
425
|
-
// Download universal bundle
|
|
426
|
-
const tmpZip = join(tmpdir(), `impeccable-update-${Date.now()}.zip`);
|
|
427
|
-
console.log('\nDownloading latest skills...');
|
|
428
|
-
try {
|
|
429
|
-
await downloadFile(`${API_BASE}/api/download/bundle/universal`, tmpZip);
|
|
430
|
-
} catch (e) {
|
|
431
|
-
console.error(`Download failed: ${e.message}`);
|
|
432
|
-
process.exit(1);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// Extract and copy to each provider folder
|
|
436
|
-
let unzip;
|
|
437
527
|
try {
|
|
438
|
-
// Use built-in decompress if available (Node 22+), otherwise shell unzip
|
|
439
|
-
const tmpDir = join(tmpdir(), `impeccable-update-${Date.now()}`);
|
|
440
|
-
mkdirSync(tmpDir, { recursive: true });
|
|
441
|
-
execSync(`unzip -qo "${tmpZip}" -d "${tmpDir}"`, { encoding: 'utf8' });
|
|
442
528
|
|
|
443
|
-
//
|
|
529
|
+
// Copy from the already-downloaded bundle to each provider folder
|
|
444
530
|
let updated = 0;
|
|
445
531
|
for (const provider of providers) {
|
|
446
532
|
const srcDir = join(tmpDir, provider, 'skills');
|
|
447
533
|
const destDir = join(root, provider, 'skills');
|
|
448
534
|
if (!existsSync(srcDir)) continue;
|
|
449
535
|
|
|
450
|
-
// Copy each skill folder
|
|
451
536
|
const skills = readdirSync(srcDir, { withFileTypes: true });
|
|
452
537
|
for (const skill of skills) {
|
|
453
538
|
if (!skill.isDirectory()) continue;
|
|
454
539
|
const src = join(srcDir, skill.name);
|
|
455
540
|
const dest = join(destDir, skill.name);
|
|
456
|
-
// Remove old and copy new
|
|
457
541
|
if (existsSync(dest)) rmSync(dest, { recursive: true });
|
|
458
542
|
copyDirSync(src, dest);
|
|
459
543
|
updated++;
|
|
460
544
|
}
|
|
461
545
|
}
|
|
462
546
|
|
|
463
|
-
// Cleanup
|
|
464
547
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
465
|
-
rmSync(tmpZip, { force: true });
|
|
466
548
|
|
|
467
549
|
// Re-apply prefix if detected
|
|
468
550
|
const prefix = detectPrefix(root);
|
|
@@ -471,7 +553,7 @@ async function update(flags = []) {
|
|
|
471
553
|
if (count > 0) console.log(`Re-applied "${prefix}" prefix to ${count} skills.`);
|
|
472
554
|
}
|
|
473
555
|
|
|
474
|
-
// Run cleanup
|
|
556
|
+
// Run cleanup to remove deprecated stubs from the fresh download
|
|
475
557
|
try {
|
|
476
558
|
const { cleanup: postCleanup } = await import('../../source/skills/impeccable/scripts/cleanup-deprecated.mjs');
|
|
477
559
|
postCleanup(root);
|
|
@@ -479,11 +561,12 @@ async function update(flags = []) {
|
|
|
479
561
|
// Not available -- skip
|
|
480
562
|
}
|
|
481
563
|
|
|
482
|
-
|
|
564
|
+
const version = await fetchRemoteVersion();
|
|
565
|
+
console.log(`Updated ${updated} skills across ${providers.length} provider(s)${version ? ` to v${version}` : ''}.`);
|
|
483
566
|
console.log('Done!\n');
|
|
484
567
|
} catch (e) {
|
|
485
|
-
console.error(`
|
|
486
|
-
rmSync(
|
|
568
|
+
console.error(`Update failed: ${e.message}`);
|
|
569
|
+
if (tmpDir) rmSync(tmpDir, { recursive: true, force: true });
|
|
487
570
|
process.exit(1);
|
|
488
571
|
}
|
|
489
572
|
}
|
|
@@ -512,6 +595,8 @@ export async function run(args) {
|
|
|
512
595
|
await install(args.slice(1));
|
|
513
596
|
} else if (sub === 'update') {
|
|
514
597
|
await update(args.slice(1));
|
|
598
|
+
} else if (sub === 'check') {
|
|
599
|
+
await check();
|
|
515
600
|
} else {
|
|
516
601
|
console.error(`Unknown skills command: ${sub}`);
|
|
517
602
|
console.error(`Run 'impeccable skills --help' for available commands.`);
|