impeccable 2.1.4 → 2.1.6
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/commands/skills.mjs +69 -52
- package/package.json +1 -1
package/bin/commands/skills.mjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { execSync } from 'node:child_process';
|
|
11
|
-
import { existsSync, readFileSync, readdirSync, statSync, lstatSync, symlinkSync, readlinkSync, unlinkSync, mkdirSync, writeFileSync, rmSync, renameSync, createWriteStream } from 'node:fs';
|
|
11
|
+
import { existsSync, readFileSync, readdirSync, statSync, lstatSync, symlinkSync, readlinkSync, 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';
|
|
@@ -60,26 +60,18 @@ async function showHelp() {
|
|
|
60
60
|
|
|
61
61
|
// ─── version helpers ─────────────────────────────────────────────────────────
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Read the skills version from the impeccable SKILL.md frontmatter.
|
|
65
|
+
*/
|
|
66
|
+
function getSkillsVersion(root) {
|
|
67
|
+
for (const d of PROVIDER_DIRS) {
|
|
68
|
+
const skillMd = join(root, d, 'skills', 'impeccable', 'SKILL.md');
|
|
69
|
+
if (!existsSync(skillMd)) continue;
|
|
70
|
+
const content = readFileSync(skillMd, 'utf-8');
|
|
71
|
+
const match = content.match(/^version:\s*(.+)$/m);
|
|
72
|
+
if (match) return match[1].trim().replace(/^["']|["']$/g, '');
|
|
69
73
|
}
|
|
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
|
-
});
|
|
74
|
+
return null;
|
|
83
75
|
}
|
|
84
76
|
|
|
85
77
|
/**
|
|
@@ -119,34 +111,57 @@ async function downloadAndExtractBundle() {
|
|
|
119
111
|
* (e.g. .agents vs .claude), so we strip those differences.
|
|
120
112
|
*/
|
|
121
113
|
function normalizeForHash(content) {
|
|
122
|
-
return content
|
|
114
|
+
return content
|
|
115
|
+
.replace(/\.(claude|cursor|agents|gemini|codex|kiro|opencode|pi|trae|trae-cn|rovodev)\/skills\//g, '.PROVIDER/skills/')
|
|
116
|
+
.replace(/^version:\s*.+$/m, 'version: NORMALIZED');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Deduplicate providers by resolved path. When .claude/skills is a
|
|
121
|
+
* symlink to ../.agents/skills, both resolve to the same directory.
|
|
122
|
+
* Returns an array of { provider, localSkillsDir } with one entry
|
|
123
|
+
* per unique real path. The first provider that maps to a real path
|
|
124
|
+
* wins (so the bundle uses that provider's build).
|
|
125
|
+
*/
|
|
126
|
+
function deduplicateProviders(root, providers) {
|
|
127
|
+
const seen = new Map(); // realPath -> { provider, localSkillsDir }
|
|
128
|
+
for (const provider of providers) {
|
|
129
|
+
const skillsDir = join(root, provider, 'skills');
|
|
130
|
+
if (!existsSync(skillsDir)) continue;
|
|
131
|
+
const real = realpathSync(skillsDir);
|
|
132
|
+
if (!seen.has(real)) {
|
|
133
|
+
seen.set(real, { provider, localSkillsDir: skillsDir });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return [...seen.values()];
|
|
123
137
|
}
|
|
124
138
|
|
|
125
139
|
/**
|
|
126
140
|
* Compare local skills against a downloaded bundle.
|
|
127
141
|
* Only checks skills that exist in the bundle (ignores user's custom
|
|
128
|
-
* skills that aren't part of impeccable).
|
|
129
|
-
* the
|
|
142
|
+
* skills that aren't part of impeccable). Deduplicates providers that
|
|
143
|
+
* share the same real path (symlinks). Normalizes provider-specific
|
|
144
|
+
* paths and version fields before comparing.
|
|
130
145
|
* Returns true if every bundle skill matches the local copy.
|
|
131
146
|
*/
|
|
132
147
|
function isUpToDate(root, providers, bundleDir) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const localSkillsDir
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
const unique = deduplicateProviders(root, providers);
|
|
149
|
+
if (unique.length === 0) return false;
|
|
150
|
+
|
|
151
|
+
for (const { provider, localSkillsDir } of unique) {
|
|
152
|
+
const bundleSkillsDir = join(bundleDir, provider, 'skills');
|
|
153
|
+
if (!existsSync(bundleSkillsDir)) continue;
|
|
154
|
+
|
|
155
|
+
for (const name of readdirSync(bundleSkillsDir)) {
|
|
156
|
+
const bundleMd = join(bundleSkillsDir, name, 'SKILL.md');
|
|
157
|
+
const localMd = join(localSkillsDir, name, 'SKILL.md');
|
|
158
|
+
if (!existsSync(bundleMd)) continue;
|
|
159
|
+
if (!existsSync(localMd)) return false;
|
|
160
|
+
|
|
161
|
+
const bundleHash = createHash('sha256').update(normalizeForHash(readFileSync(bundleMd, 'utf-8'))).digest('hex');
|
|
162
|
+
const localHash = createHash('sha256').update(normalizeForHash(readFileSync(localMd, 'utf-8'))).digest('hex');
|
|
163
|
+
if (bundleHash !== localHash) return false;
|
|
164
|
+
}
|
|
150
165
|
}
|
|
151
166
|
return true;
|
|
152
167
|
}
|
|
@@ -164,7 +179,6 @@ async function check() {
|
|
|
164
179
|
}
|
|
165
180
|
|
|
166
181
|
const providers = findInstalledProviders(root);
|
|
167
|
-
const version = getLocalVersion();
|
|
168
182
|
|
|
169
183
|
console.log('Checking for updates...\n');
|
|
170
184
|
try {
|
|
@@ -173,9 +187,10 @@ async function check() {
|
|
|
173
187
|
rmSync(bundleDir, { recursive: true, force: true });
|
|
174
188
|
|
|
175
189
|
if (upToDate) {
|
|
176
|
-
|
|
190
|
+
const v = getSkillsVersion(root);
|
|
191
|
+
console.log(`Skills are up to date${v ? ` (v${v})` : ''}.`);
|
|
177
192
|
} else {
|
|
178
|
-
console.log(
|
|
193
|
+
console.log('Updates available.');
|
|
179
194
|
console.log('Run `npx impeccable skills update` to update.');
|
|
180
195
|
}
|
|
181
196
|
} catch (e) {
|
|
@@ -532,10 +547,10 @@ async function update(flags = []) {
|
|
|
532
547
|
}
|
|
533
548
|
|
|
534
549
|
// Compare local vs remote -- skip if already up to date
|
|
535
|
-
if (
|
|
550
|
+
if (isUpToDate(root, providers, tmpDir)) {
|
|
536
551
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
537
|
-
const
|
|
538
|
-
console.log(`Skills are up to date${
|
|
552
|
+
const v = getSkillsVersion(root);
|
|
553
|
+
console.log(`Skills are up to date${v ? ` (v${v})` : ''}. Nothing to do.`);
|
|
539
554
|
process.exit(0);
|
|
540
555
|
}
|
|
541
556
|
|
|
@@ -552,18 +567,20 @@ async function update(flags = []) {
|
|
|
552
567
|
|
|
553
568
|
try {
|
|
554
569
|
|
|
555
|
-
// Copy from the
|
|
570
|
+
// Copy from the bundle to each unique provider folder.
|
|
571
|
+
// Deduplicate so symlinked dirs (e.g. .claude/skills -> .agents/skills)
|
|
572
|
+
// are only written once with the correct provider's content.
|
|
573
|
+
const unique = deduplicateProviders(root, providers);
|
|
556
574
|
let updated = 0;
|
|
557
|
-
for (const provider of
|
|
575
|
+
for (const { provider, localSkillsDir } of unique) {
|
|
558
576
|
const srcDir = join(tmpDir, provider, 'skills');
|
|
559
|
-
const destDir = join(root, provider, 'skills');
|
|
560
577
|
if (!existsSync(srcDir)) continue;
|
|
561
578
|
|
|
562
579
|
const skills = readdirSync(srcDir, { withFileTypes: true });
|
|
563
580
|
for (const skill of skills) {
|
|
564
581
|
if (!skill.isDirectory()) continue;
|
|
565
582
|
const src = join(srcDir, skill.name);
|
|
566
|
-
const dest = join(
|
|
583
|
+
const dest = join(localSkillsDir, skill.name);
|
|
567
584
|
if (existsSync(dest)) rmSync(dest, { recursive: true });
|
|
568
585
|
copyDirSync(src, dest);
|
|
569
586
|
updated++;
|
|
@@ -587,8 +604,8 @@ async function update(flags = []) {
|
|
|
587
604
|
// Not available -- skip
|
|
588
605
|
}
|
|
589
606
|
|
|
590
|
-
const
|
|
591
|
-
console.log(`Updated ${updated}
|
|
607
|
+
const v = getSkillsVersion(root);
|
|
608
|
+
console.log(`Updated ${updated} skill(s)${v ? ` to v${v}` : ''}.`);
|
|
592
609
|
console.log('Done!\n');
|
|
593
610
|
} catch (e) {
|
|
594
611
|
console.error(`Update failed: ${e.message}`);
|