impeccable 2.1.1 → 2.1.3

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 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
@@ -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,121 @@ 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
+ * Only checks skills that exist in the bundle (ignores user's custom
118
+ * skills that aren't part of impeccable).
119
+ * Returns true if every bundle skill matches the local copy.
120
+ */
121
+ function isUpToDate(root, providers, bundleDir) {
122
+ for (const provider of providers) {
123
+ const bundleSkillsDir = join(bundleDir, provider, 'skills');
124
+ const localSkillsDir = join(root, provider, 'skills');
125
+ if (!existsSync(bundleSkillsDir)) continue;
126
+
127
+ for (const name of readdirSync(bundleSkillsDir)) {
128
+ const bundleMd = join(bundleSkillsDir, name, 'SKILL.md');
129
+ const localMd = join(localSkillsDir, name, 'SKILL.md');
130
+ if (!existsSync(bundleMd)) continue;
131
+
132
+ // Missing locally = needs update
133
+ if (!existsSync(localMd)) return false;
134
+
135
+ const bundleHash = createHash('sha256').update(readFileSync(bundleMd)).digest('hex');
136
+ const localHash = createHash('sha256').update(readFileSync(localMd)).digest('hex');
137
+ if (bundleHash !== localHash) return false;
138
+ }
139
+ }
140
+ return true;
141
+ }
142
+
143
+ // ─── skills check ────────────────────────────────────────────────────────────
144
+
145
+ async function check() {
146
+ const root = findProjectRoot();
147
+ const installed = isAlreadyInstalled(root);
148
+
149
+ if (!installed) {
150
+ console.log('Impeccable is not installed in this project.');
151
+ console.log('Run `npx impeccable skills install` to install.');
152
+ process.exit(0);
153
+ }
154
+
155
+ const providers = findInstalledProviders(root);
156
+ const version = getLocalVersion();
157
+
158
+ console.log('Checking for updates...\n');
159
+ try {
160
+ const bundleDir = await downloadAndExtractBundle();
161
+ const upToDate = isUpToDate(root, providers, bundleDir);
162
+ rmSync(bundleDir, { recursive: true, force: true });
163
+
164
+ if (upToDate) {
165
+ console.log(`Skills are up to date${version ? ` (v${version})` : ''}.`);
166
+ } else {
167
+ console.log(`Updates available${version ? ` (currently v${version})` : ''}.`);
168
+ console.log('Run `npx impeccable skills update` to update.');
169
+ }
170
+ } catch (e) {
171
+ console.error(`Could not check for updates: ${e.message}`);
172
+ process.exit(1);
173
+ }
174
+ }
175
+
60
176
  // ─── skills install ───────────────────────────────────────────────────────────
61
177
 
62
178
  // Check if impeccable skills are already present in any provider folder
@@ -385,8 +501,6 @@ async function update(flags = []) {
385
501
  // Download the latest skills directly from impeccable.style.
386
502
  // We skip `npx skills update` because it has a known upstream bug
387
503
  // (vercel-labs/skills#775) where it can't find the lock file.
388
- console.log('Checking for updates...\n');
389
-
390
504
  const root = findProjectRoot();
391
505
  const providers = findInstalledProviders(root);
392
506
 
@@ -396,73 +510,56 @@ async function update(flags = []) {
396
510
  process.exit(1);
397
511
  }
398
512
 
399
- console.log(`Found impeccable skills in: ${providers.join(', ')}`);
513
+ console.log('Checking for updates...');
400
514
 
401
- // Check for local modifications
402
- const modified = getModifiedSkillFiles(root, providers);
403
- if (modified.length > 0) {
404
- console.log(`\n Warning: ${modified.length} skill file(s) have local changes:\n`);
405
- for (const m of modified.slice(0, 10)) {
406
- console.log(` ${m.flag} ${m.file}`);
407
- }
408
- if (modified.length > 10) console.log(` ... and ${modified.length - 10} more`);
409
- console.log();
410
- if (!yes) {
411
- const ans = await ask(' Overwrite local changes? (y/N) ');
412
- if (ans !== 'y' && ans !== 'yes') {
413
- console.log('Aborted.');
414
- process.exit(0);
415
- }
416
- }
417
- } else if (!yes) {
515
+ let tmpDir;
516
+ try {
517
+ tmpDir = await downloadAndExtractBundle();
518
+ } catch (e) {
519
+ console.error(`Download failed: ${e.message}`);
520
+ process.exit(1);
521
+ }
522
+
523
+ // Compare local vs remote -- skip if already up to date
524
+ if (!yes && isUpToDate(root, providers, tmpDir)) {
525
+ rmSync(tmpDir, { recursive: true, force: true });
526
+ const version = getLocalVersion();
527
+ console.log(`Skills are up to date${version ? ` (v${version})` : ''}. Nothing to do.`);
528
+ process.exit(0);
529
+ }
530
+
531
+ console.log(`Found skills in: ${providers.join(', ')}`);
532
+
533
+ if (!yes) {
418
534
  const ans = await ask(`Update skills in ${providers.length} provider folder(s)? (Y/n) `);
419
535
  if (ans === 'n' || ans === 'no') {
536
+ rmSync(tmpDir, { recursive: true, force: true });
420
537
  console.log('Aborted.');
421
538
  process.exit(0);
422
539
  }
423
540
  }
424
541
 
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
542
  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
543
 
443
- // The universal bundle has provider folders at the top level
544
+ // Copy from the already-downloaded bundle to each provider folder
444
545
  let updated = 0;
445
546
  for (const provider of providers) {
446
547
  const srcDir = join(tmpDir, provider, 'skills');
447
548
  const destDir = join(root, provider, 'skills');
448
549
  if (!existsSync(srcDir)) continue;
449
550
 
450
- // Copy each skill folder
451
551
  const skills = readdirSync(srcDir, { withFileTypes: true });
452
552
  for (const skill of skills) {
453
553
  if (!skill.isDirectory()) continue;
454
554
  const src = join(srcDir, skill.name);
455
555
  const dest = join(destDir, skill.name);
456
- // Remove old and copy new
457
556
  if (existsSync(dest)) rmSync(dest, { recursive: true });
458
557
  copyDirSync(src, dest);
459
558
  updated++;
460
559
  }
461
560
  }
462
561
 
463
- // Cleanup
464
562
  rmSync(tmpDir, { recursive: true, force: true });
465
- rmSync(tmpZip, { force: true });
466
563
 
467
564
  // Re-apply prefix if detected
468
565
  const prefix = detectPrefix(root);
@@ -471,7 +568,7 @@ async function update(flags = []) {
471
568
  if (count > 0) console.log(`Re-applied "${prefix}" prefix to ${count} skills.`);
472
569
  }
473
570
 
474
- // Run cleanup again to remove deprecated stubs from the fresh download
571
+ // Run cleanup to remove deprecated stubs from the fresh download
475
572
  try {
476
573
  const { cleanup: postCleanup } = await import('../../source/skills/impeccable/scripts/cleanup-deprecated.mjs');
477
574
  postCleanup(root);
@@ -479,11 +576,12 @@ async function update(flags = []) {
479
576
  // Not available -- skip
480
577
  }
481
578
 
482
- console.log(`Updated ${updated} skills across ${providers.length} provider(s).`);
579
+ const version = await fetchRemoteVersion();
580
+ console.log(`Updated ${updated} skills across ${providers.length} provider(s)${version ? ` to v${version}` : ''}.`);
483
581
  console.log('Done!\n');
484
582
  } catch (e) {
485
- console.error(`Extract failed: ${e.message}`);
486
- rmSync(tmpZip, { force: true });
583
+ console.error(`Update failed: ${e.message}`);
584
+ if (tmpDir) rmSync(tmpDir, { recursive: true, force: true });
487
585
  process.exit(1);
488
586
  }
489
587
  }
@@ -512,6 +610,8 @@ export async function run(args) {
512
610
  await install(args.slice(1));
513
611
  } else if (sub === 'update') {
514
612
  await update(args.slice(1));
613
+ } else if (sub === 'check') {
614
+ await check();
515
615
  } else {
516
616
  console.error(`Unknown skills command: ${sub}`);
517
617
  console.error(`Run 'impeccable skills --help' for available commands.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impeccable",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "author": "Paul Bakaus",
5
5
  "description": "Design skills, commands, and anti-pattern detection for AI coding agents",
6
6
  "keywords": [