impeccable 2.1.0 → 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 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,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
@@ -369,8 +470,7 @@ function downloadFile(url, dest) {
369
470
  async function update(flags = []) {
370
471
  const yes = flags.includes('-y') || flags.includes('--yes');
371
472
 
372
- // Clean up deprecated skills before updating, so npx skills update
373
- // does not fail on entries that no longer exist in the source repo.
473
+ // Clean up deprecated skills from previous versions.
374
474
  try {
375
475
  const { cleanup } = await import('../../source/skills/impeccable/scripts/cleanup-deprecated.mjs');
376
476
  const root = findProjectRoot();
@@ -383,46 +483,9 @@ async function update(flags = []) {
383
483
  // Cleanup script not available (e.g. running from npm package) -- skip
384
484
  }
385
485
 
386
- // Try npx skills update first
387
- console.log('Checking for skills manager...');
388
- let noLockFile = true;
389
- try {
390
- const output = execSync('npx skills check', { encoding: 'utf8', timeout: 15000 });
391
- noLockFile = output.includes('No skills tracked');
392
- } catch {
393
- // npx skills not available or errored
394
- }
395
-
396
- if (!noLockFile) {
397
- const root = findProjectRoot();
398
- const prefix = detectPrefix(root);
399
-
400
- // Temporarily undo prefix so npx skills can find its tracked skill names
401
- if (prefix) {
402
- console.log(`Detected "${prefix}" prefix, temporarily reverting for update...`);
403
- undoPrefix(root, prefix);
404
- }
405
-
406
- console.log('Updating via npx skills...\n');
407
- try {
408
- execSync('npx skills update', { stdio: 'inherit' });
409
- } catch (e) {
410
- // Re-apply prefix even if update fails
411
- if (prefix) renameSkillsWithPrefix(root, prefix);
412
- process.exit(e.status ?? 1);
413
- }
414
-
415
- // Re-apply prefix after update
416
- if (prefix) {
417
- const count = renameSkillsWithPrefix(root, prefix);
418
- console.log(`\nRe-applied "${prefix}" prefix to ${count} skills.`);
419
- }
420
- process.exit(0);
421
- }
422
-
423
- // Fallback: manual update by downloading the universal bundle
424
- console.log('Skills not managed by npx skills. Using direct download.\n');
425
-
486
+ // Download the latest skills directly from impeccable.style.
487
+ // We skip `npx skills update` because it has a known upstream bug
488
+ // (vercel-labs/skills#775) where it can't find the lock file.
426
489
  const root = findProjectRoot();
427
490
  const providers = findInstalledProviders(root);
428
491
 
@@ -432,79 +495,78 @@ async function update(flags = []) {
432
495
  process.exit(1);
433
496
  }
434
497
 
435
- console.log(`Found impeccable skills in: ${providers.join(', ')}`);
498
+ console.log('Checking for updates...');
436
499
 
437
- // Check for local modifications
438
- const modified = getModifiedSkillFiles(root, providers);
439
- if (modified.length > 0) {
440
- console.log(`\n Warning: ${modified.length} skill file(s) have local changes:\n`);
441
- for (const m of modified.slice(0, 10)) {
442
- console.log(` ${m.flag} ${m.file}`);
443
- }
444
- if (modified.length > 10) console.log(` ... and ${modified.length - 10} more`);
445
- console.log();
446
- if (!yes) {
447
- const ans = await ask(' Overwrite local changes? (y/N) ');
448
- if (ans !== 'y' && ans !== 'yes') {
449
- console.log('Aborted.');
450
- process.exit(0);
451
- }
452
- }
453
- } else if (!yes) {
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) {
454
519
  const ans = await ask(`Update skills in ${providers.length} provider folder(s)? (Y/n) `);
455
520
  if (ans === 'n' || ans === 'no') {
521
+ rmSync(tmpDir, { recursive: true, force: true });
456
522
  console.log('Aborted.');
457
523
  process.exit(0);
458
524
  }
459
525
  }
460
526
 
461
- // Download universal bundle
462
- const tmpZip = join(tmpdir(), `impeccable-update-${Date.now()}.zip`);
463
- console.log('\nDownloading latest skills...');
464
527
  try {
465
- await downloadFile(`${API_BASE}/api/download/bundle/universal`, tmpZip);
466
- } catch (e) {
467
- console.error(`Download failed: ${e.message}`);
468
- process.exit(1);
469
- }
470
-
471
- // Extract and copy to each provider folder
472
- let unzip;
473
- try {
474
- // Use built-in decompress if available (Node 22+), otherwise shell unzip
475
- const tmpDir = join(tmpdir(), `impeccable-update-${Date.now()}`);
476
- mkdirSync(tmpDir, { recursive: true });
477
- execSync(`unzip -qo "${tmpZip}" -d "${tmpDir}"`, { encoding: 'utf8' });
478
528
 
479
- // The universal bundle has provider folders at the top level
529
+ // Copy from the already-downloaded bundle to each provider folder
480
530
  let updated = 0;
481
531
  for (const provider of providers) {
482
532
  const srcDir = join(tmpDir, provider, 'skills');
483
533
  const destDir = join(root, provider, 'skills');
484
534
  if (!existsSync(srcDir)) continue;
485
535
 
486
- // Copy each skill folder
487
536
  const skills = readdirSync(srcDir, { withFileTypes: true });
488
537
  for (const skill of skills) {
489
538
  if (!skill.isDirectory()) continue;
490
539
  const src = join(srcDir, skill.name);
491
540
  const dest = join(destDir, skill.name);
492
- // Remove old and copy new
493
541
  if (existsSync(dest)) rmSync(dest, { recursive: true });
494
542
  copyDirSync(src, dest);
495
543
  updated++;
496
544
  }
497
545
  }
498
546
 
499
- // Cleanup
500
547
  rmSync(tmpDir, { recursive: true, force: true });
501
- rmSync(tmpZip, { force: true });
502
548
 
503
- console.log(`Updated ${updated} skills across ${providers.length} provider(s).`);
549
+ // Re-apply prefix if detected
550
+ const prefix = detectPrefix(root);
551
+ if (prefix) {
552
+ const count = renameSkillsWithPrefix(root, prefix);
553
+ if (count > 0) console.log(`Re-applied "${prefix}" prefix to ${count} skills.`);
554
+ }
555
+
556
+ // Run cleanup to remove deprecated stubs from the fresh download
557
+ try {
558
+ const { cleanup: postCleanup } = await import('../../source/skills/impeccable/scripts/cleanup-deprecated.mjs');
559
+ postCleanup(root);
560
+ } catch {
561
+ // Not available -- skip
562
+ }
563
+
564
+ const version = await fetchRemoteVersion();
565
+ console.log(`Updated ${updated} skills across ${providers.length} provider(s)${version ? ` to v${version}` : ''}.`);
504
566
  console.log('Done!\n');
505
567
  } catch (e) {
506
- console.error(`Extract failed: ${e.message}`);
507
- rmSync(tmpZip, { force: true });
568
+ console.error(`Update failed: ${e.message}`);
569
+ if (tmpDir) rmSync(tmpDir, { recursive: true, force: true });
508
570
  process.exit(1);
509
571
  }
510
572
  }
@@ -533,6 +595,8 @@ export async function run(args) {
533
595
  await install(args.slice(1));
534
596
  } else if (sub === 'update') {
535
597
  await update(args.slice(1));
598
+ } else if (sub === 'check') {
599
+ await check();
536
600
  } else {
537
601
  console.error(`Unknown skills command: ${sub}`);
538
602
  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.0",
3
+ "version": "2.1.2",
4
4
  "author": "Paul Bakaus",
5
5
  "description": "Design skills, commands, and anti-pattern detection for AI coding agents",
6
6
  "keywords": [