impeccable 2.0.1 → 2.0.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/LICENSE +77 -191
- package/README.md +11 -2
- package/bin/cli.js +63 -0
- package/bin/commands/skills.mjs +514 -0
- package/package.json +20 -29
- package/{source/skills/critique/scripts → src}/detect-antipatterns-browser.js +30 -2
- package/{source/skills/critique/scripts → src}/detect-antipatterns.mjs +463 -12
- package/README.bak.md +0 -237
- package/README.npm.md +0 -67
- package/bin/impeccable +0 -49
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `impeccable skills` subcommand
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* impeccable skills help Show all available skills and commands
|
|
6
|
+
* impeccable skills install Install skills via npx skills add
|
|
7
|
+
* impeccable skills update Update skills to latest version
|
|
8
|
+
*/
|
|
9
|
+
|
|
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';
|
|
12
|
+
import { join, resolve, dirname } from 'node:path';
|
|
13
|
+
import { createInterface } from 'node:readline';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
import { get } from 'node:https';
|
|
16
|
+
import { tmpdir } from 'node:os';
|
|
17
|
+
|
|
18
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const API_BASE = 'https://impeccable.style';
|
|
20
|
+
|
|
21
|
+
// Provider folder names in project roots
|
|
22
|
+
const PROVIDER_DIRS = ['.claude', '.cursor', '.gemini', '.codex', '.agents', '.kiro', '.opencode', '.pi', '.trae', '.trae-cn'];
|
|
23
|
+
|
|
24
|
+
function ask(question) {
|
|
25
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
26
|
+
return new Promise(r => rl.question(question, ans => { rl.close(); r(ans.trim().toLowerCase()); }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ─── skills help ──────────────────────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
async function showHelp() {
|
|
32
|
+
let commands;
|
|
33
|
+
try {
|
|
34
|
+
const res = await fetch(`${API_BASE}/api/commands`);
|
|
35
|
+
commands = await res.json();
|
|
36
|
+
} catch {
|
|
37
|
+
console.error('Could not fetch command list from impeccable.style. Check your network connection.');
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const pad = (s, n) => s + ' '.repeat(Math.max(0, n - s.length));
|
|
42
|
+
|
|
43
|
+
console.log('\n Impeccable Skills & Commands\n');
|
|
44
|
+
console.log(' Install: npx impeccable skills install');
|
|
45
|
+
console.log(' Update: npx impeccable skills update');
|
|
46
|
+
console.log(' Docs: https://impeccable.style/cheatsheet\n');
|
|
47
|
+
console.log(` ${pad('Command', 22)} Description`);
|
|
48
|
+
console.log(` ${'-'.repeat(22)} ${'-'.repeat(52)}`);
|
|
49
|
+
|
|
50
|
+
for (const cmd of commands.sort((a, b) => a.id.localeCompare(b.id))) {
|
|
51
|
+
// Trim description to fit terminal
|
|
52
|
+
const desc = cmd.description.length > 72
|
|
53
|
+
? cmd.description.substring(0, 69) + '...'
|
|
54
|
+
: cmd.description;
|
|
55
|
+
console.log(` ${pad('/' + cmd.id, 22)} ${desc}`);
|
|
56
|
+
}
|
|
57
|
+
console.log(`\n ${commands.length} commands available. Run /<command> in your AI harness.\n`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ─── skills install ───────────────────────────────────────────────────────────
|
|
61
|
+
|
|
62
|
+
// Check if impeccable skills are already present in any provider folder
|
|
63
|
+
function isAlreadyInstalled(root) {
|
|
64
|
+
for (const d of PROVIDER_DIRS) {
|
|
65
|
+
const skillsDir = join(root, d, 'skills');
|
|
66
|
+
if (!existsSync(skillsDir)) continue;
|
|
67
|
+
try {
|
|
68
|
+
const entries = readdirSync(skillsDir);
|
|
69
|
+
// Look for 'impeccable' skill (or prefixed variant, or legacy 'teach-impeccable')
|
|
70
|
+
if (entries.some(e =>
|
|
71
|
+
e === 'impeccable' || e.endsWith('-impeccable') ||
|
|
72
|
+
e === 'teach-impeccable' || e.endsWith('-teach-impeccable')
|
|
73
|
+
)) {
|
|
74
|
+
return d;
|
|
75
|
+
}
|
|
76
|
+
} catch {}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function escapeRegex(str) {
|
|
82
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function prefixSkillContent(content, prefix, allSkillNames) {
|
|
86
|
+
// Prefix the name in frontmatter
|
|
87
|
+
let result = content.replace(/^name:\s*(.+)$/m, (_, name) => `name: ${prefix}${name.trim()}`);
|
|
88
|
+
|
|
89
|
+
// Prefix cross-references: /skillname -> /prefix-skillname
|
|
90
|
+
const sorted = [...allSkillNames].sort((a, b) => b.length - a.length);
|
|
91
|
+
for (const name of sorted) {
|
|
92
|
+
// Command invocations: /skillname
|
|
93
|
+
result = result.replace(
|
|
94
|
+
new RegExp(`/(?=${escapeRegex(name)}(?:[^a-zA-Z0-9_-]|$))`, 'g'),
|
|
95
|
+
`/${prefix}`
|
|
96
|
+
);
|
|
97
|
+
// Prose references: "the skillname skill"
|
|
98
|
+
result = result.replace(
|
|
99
|
+
new RegExp(`(the) ${escapeRegex(name)} skill`, 'gi'),
|
|
100
|
+
(_, article) => `${article} ${prefix}${name} skill`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function isSkillDir(skillsDir, name) {
|
|
107
|
+
// Skill entries can be real directories or symlinks to directories (npx skills uses symlinks)
|
|
108
|
+
const full = join(skillsDir, name);
|
|
109
|
+
try {
|
|
110
|
+
return statSync(full).isDirectory() && existsSync(join(full, 'SKILL.md'));
|
|
111
|
+
} catch { return false; }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function isRealSkillDir(skillsDir, name) {
|
|
115
|
+
// Only real directories, not symlinks -- renaming the real dir renames the symlink targets too
|
|
116
|
+
const full = join(skillsDir, name);
|
|
117
|
+
try {
|
|
118
|
+
const lstat = lstatSync(full);
|
|
119
|
+
return lstat.isDirectory() && !lstat.isSymbolicLink() && existsSync(join(full, 'SKILL.md'));
|
|
120
|
+
} catch { return false; }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function renameSkillsWithPrefix(root, prefix) {
|
|
124
|
+
// First pass: collect all skill names across all providers (use first provider found)
|
|
125
|
+
let allSkillNames = [];
|
|
126
|
+
for (const d of PROVIDER_DIRS) {
|
|
127
|
+
const skillsDir = join(root, d, 'skills');
|
|
128
|
+
if (!existsSync(skillsDir)) continue;
|
|
129
|
+
const entries = readdirSync(skillsDir);
|
|
130
|
+
allSkillNames = entries.filter(name => isSkillDir(skillsDir, name));
|
|
131
|
+
if (allSkillNames.length > 0) break;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Second pass: rename real dirs and update their content
|
|
135
|
+
let count = 0;
|
|
136
|
+
for (const d of PROVIDER_DIRS) {
|
|
137
|
+
const skillsDir = join(root, d, 'skills');
|
|
138
|
+
if (!existsSync(skillsDir)) continue;
|
|
139
|
+
try {
|
|
140
|
+
const entries = readdirSync(skillsDir);
|
|
141
|
+
for (const name of entries) {
|
|
142
|
+
if (name.startsWith(prefix)) continue;
|
|
143
|
+
if (!isRealSkillDir(skillsDir, name)) continue;
|
|
144
|
+
|
|
145
|
+
const src = join(skillsDir, name);
|
|
146
|
+
const dest = join(skillsDir, prefix + name);
|
|
147
|
+
|
|
148
|
+
renameSync(src, dest);
|
|
149
|
+
|
|
150
|
+
// Prefix frontmatter name + all cross-references in SKILL.md
|
|
151
|
+
let content = readFileSync(join(dest, 'SKILL.md'), 'utf8');
|
|
152
|
+
content = prefixSkillContent(content, prefix, allSkillNames);
|
|
153
|
+
writeFileSync(join(dest, 'SKILL.md'), content);
|
|
154
|
+
count++;
|
|
155
|
+
}
|
|
156
|
+
} catch {}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Third pass: fix symlinks that now point to renamed targets (npx skills uses these)
|
|
160
|
+
for (const d of PROVIDER_DIRS) {
|
|
161
|
+
const skillsDir = join(root, d, 'skills');
|
|
162
|
+
if (!existsSync(skillsDir)) continue;
|
|
163
|
+
try {
|
|
164
|
+
const entries = readdirSync(skillsDir);
|
|
165
|
+
for (const name of entries) {
|
|
166
|
+
if (name.startsWith(prefix)) continue;
|
|
167
|
+
const full = join(skillsDir, name);
|
|
168
|
+
try {
|
|
169
|
+
if (!lstatSync(full).isSymbolicLink()) continue;
|
|
170
|
+
const target = readlinkSync(full);
|
|
171
|
+
const newTarget = target.replace(new RegExp(`/${escapeRegex(name)}$`), `/${prefix}${name}`);
|
|
172
|
+
unlinkSync(full);
|
|
173
|
+
symlinkSync(newTarget, join(skillsDir, prefix + name));
|
|
174
|
+
} catch {}
|
|
175
|
+
}
|
|
176
|
+
} catch {}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return count;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function install(flags) {
|
|
183
|
+
const force = flags.includes('--force');
|
|
184
|
+
const yes = flags.includes('-y') || flags.includes('--yes');
|
|
185
|
+
const prefixFlag = flags.find(f => f.startsWith('--prefix='));
|
|
186
|
+
const root = findProjectRoot();
|
|
187
|
+
const existing = isAlreadyInstalled(root);
|
|
188
|
+
|
|
189
|
+
if (existing && !force) {
|
|
190
|
+
console.log(`Impeccable skills are already installed (found in ${existing}/).`);
|
|
191
|
+
console.log('Run with --force to reinstall.\n');
|
|
192
|
+
process.exit(0);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
console.log('Installing impeccable skills via npx skills...\n');
|
|
196
|
+
try {
|
|
197
|
+
execSync(`npx skills add pbakaus/impeccable${yes ? ' -y' : ''}`, { stdio: 'inherit' });
|
|
198
|
+
} catch (e) {
|
|
199
|
+
process.exit(e.status ?? 1);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Ask about prefixing (skip in CI mode unless --prefix= is set)
|
|
203
|
+
let prefix = '';
|
|
204
|
+
if (prefixFlag) {
|
|
205
|
+
prefix = prefixFlag.split('=')[1] || 'i-';
|
|
206
|
+
} else if (!yes) {
|
|
207
|
+
console.log();
|
|
208
|
+
const wantPrefix = await ask('Prefix commands to avoid conflicts? e.g. /i-audit instead of /audit (y/N) ');
|
|
209
|
+
if (wantPrefix === 'y' || wantPrefix === 'yes') {
|
|
210
|
+
const custom = await ask('Prefix (default: i-): ');
|
|
211
|
+
prefix = custom || 'i-';
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (prefix) {
|
|
216
|
+
const count = renameSkillsWithPrefix(root, prefix);
|
|
217
|
+
if (count > 0) {
|
|
218
|
+
console.log(`\nRenamed ${count} skills with "${prefix}" prefix.`);
|
|
219
|
+
console.log(`Commands are now available as /${prefix}<command> (e.g. /${prefix}audit).`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
console.log(`\nDone! Run /${prefix}impeccable teach in your AI harness to set up design context.\n`);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Detect prefix by looking for the 'impeccable' skill (or legacy 'teach-impeccable') */
|
|
227
|
+
function detectPrefix(root) {
|
|
228
|
+
for (const d of PROVIDER_DIRS) {
|
|
229
|
+
const skillsDir = join(root, d, 'skills');
|
|
230
|
+
if (!existsSync(skillsDir)) continue;
|
|
231
|
+
for (const name of readdirSync(skillsDir)) {
|
|
232
|
+
if (name === 'impeccable') return '';
|
|
233
|
+
if (name.endsWith('-impeccable') && name !== 'teach-impeccable') return name.slice(0, -'impeccable'.length);
|
|
234
|
+
// Legacy fallback
|
|
235
|
+
if (name === 'teach-impeccable') return '';
|
|
236
|
+
if (name.endsWith('-teach-impeccable')) return name.slice(0, -'teach-impeccable'.length);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return '';
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Undo prefixing: rename folders back and strip prefix from SKILL.md content */
|
|
243
|
+
function undoPrefix(root, prefix) {
|
|
244
|
+
if (!prefix) return;
|
|
245
|
+
// Collect the unprefixed names (strip our prefix)
|
|
246
|
+
let allPrefixedNames = [];
|
|
247
|
+
for (const d of PROVIDER_DIRS) {
|
|
248
|
+
const skillsDir = join(root, d, 'skills');
|
|
249
|
+
if (!existsSync(skillsDir)) continue;
|
|
250
|
+
allPrefixedNames = readdirSync(skillsDir).filter(n => n.startsWith(prefix) && isRealSkillDir(skillsDir, n));
|
|
251
|
+
if (allPrefixedNames.length > 0) break;
|
|
252
|
+
}
|
|
253
|
+
const unprefixedNames = allPrefixedNames.map(n => n.slice(prefix.length));
|
|
254
|
+
|
|
255
|
+
for (const d of PROVIDER_DIRS) {
|
|
256
|
+
const skillsDir = join(root, d, 'skills');
|
|
257
|
+
if (!existsSync(skillsDir)) continue;
|
|
258
|
+
for (const name of readdirSync(skillsDir)) {
|
|
259
|
+
if (!name.startsWith(prefix)) continue;
|
|
260
|
+
const unprefixed = name.slice(prefix.length);
|
|
261
|
+
const src = join(skillsDir, name);
|
|
262
|
+
const dest = join(skillsDir, unprefixed);
|
|
263
|
+
|
|
264
|
+
if (lstatSync(src).isSymbolicLink()) {
|
|
265
|
+
const target = readlinkSync(src);
|
|
266
|
+
const newTarget = target.replace(`/${name}`, `/${unprefixed}`);
|
|
267
|
+
unlinkSync(src);
|
|
268
|
+
symlinkSync(newTarget, dest);
|
|
269
|
+
} else {
|
|
270
|
+
renameSync(src, dest);
|
|
271
|
+
// Strip prefix from SKILL.md content
|
|
272
|
+
const skillMd = join(dest, 'SKILL.md');
|
|
273
|
+
if (existsSync(skillMd)) {
|
|
274
|
+
let content = readFileSync(skillMd, 'utf8');
|
|
275
|
+
// Reverse the prefixing: replace prefixed names with unprefixed
|
|
276
|
+
content = content.replace(new RegExp(`^name:\\s*${escapeRegex(prefix)}`, 'm'), 'name: ');
|
|
277
|
+
const sorted = [...allPrefixedNames].sort((a, b) => b.length - a.length);
|
|
278
|
+
for (const pName of sorted) {
|
|
279
|
+
const uName = pName.slice(prefix.length);
|
|
280
|
+
content = content.replace(new RegExp(`/${escapeRegex(pName)}(?=[^a-zA-Z0-9_-]|$)`, 'g'), `/${uName}`);
|
|
281
|
+
content = content.replace(new RegExp(`(the) ${escapeRegex(pName)} skill`, 'gi'), `$1 ${uName} skill`);
|
|
282
|
+
}
|
|
283
|
+
writeFileSync(skillMd, content);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ─── skills update ────────────────────────────────────────────────────────────
|
|
291
|
+
|
|
292
|
+
function findProjectRoot() {
|
|
293
|
+
let dir = process.cwd();
|
|
294
|
+
while (dir !== dirname(dir)) {
|
|
295
|
+
if (existsSync(join(dir, '.git'))) return dir;
|
|
296
|
+
dir = dirname(dir);
|
|
297
|
+
}
|
|
298
|
+
return process.cwd();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function findInstalledProviders(root) {
|
|
302
|
+
const found = [];
|
|
303
|
+
for (const d of PROVIDER_DIRS) {
|
|
304
|
+
const skillsDir = join(root, d, 'skills');
|
|
305
|
+
if (!existsSync(skillsDir)) continue;
|
|
306
|
+
try {
|
|
307
|
+
const entries = readdirSync(skillsDir);
|
|
308
|
+
if (entries.some(name => isSkillDir(skillsDir, name))) found.push(d);
|
|
309
|
+
} catch {}
|
|
310
|
+
}
|
|
311
|
+
return found;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function getModifiedSkillFiles(root, providerDirs) {
|
|
315
|
+
// Use git to check if any skill files have local modifications
|
|
316
|
+
const modified = [];
|
|
317
|
+
try {
|
|
318
|
+
const status = execSync('git status --porcelain', { cwd: root, encoding: 'utf8' });
|
|
319
|
+
for (const line of status.split('\n')) {
|
|
320
|
+
if (!line.trim()) continue;
|
|
321
|
+
const file = line.substring(3);
|
|
322
|
+
for (const d of providerDirs) {
|
|
323
|
+
if (file.startsWith(`${d}/skills/`)) {
|
|
324
|
+
const flag = line.substring(0, 2).trim();
|
|
325
|
+
modified.push({ file, flag });
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
} catch {
|
|
330
|
+
// Not a git repo or git not available
|
|
331
|
+
}
|
|
332
|
+
return modified;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function downloadFile(url, dest) {
|
|
336
|
+
return new Promise((resolve, reject) => {
|
|
337
|
+
const file = createWriteStream(dest);
|
|
338
|
+
get(url, (res) => {
|
|
339
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
340
|
+
// Follow redirect
|
|
341
|
+
get(res.headers.location, (res2) => {
|
|
342
|
+
res2.pipe(file);
|
|
343
|
+
file.on('finish', () => { file.close(); resolve(); });
|
|
344
|
+
}).on('error', reject);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (res.statusCode !== 200) {
|
|
348
|
+
reject(new Error(`HTTP ${res.statusCode}`));
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
res.pipe(file);
|
|
352
|
+
file.on('finish', () => { file.close(); resolve(); });
|
|
353
|
+
}).on('error', reject);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
async function update(flags = []) {
|
|
358
|
+
const yes = flags.includes('-y') || flags.includes('--yes');
|
|
359
|
+
// Try npx skills update first
|
|
360
|
+
console.log('Checking for skills manager...');
|
|
361
|
+
let noLockFile = true;
|
|
362
|
+
try {
|
|
363
|
+
const output = execSync('npx skills check', { encoding: 'utf8', timeout: 15000 });
|
|
364
|
+
noLockFile = output.includes('No skills tracked');
|
|
365
|
+
} catch {
|
|
366
|
+
// npx skills not available or errored
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (!noLockFile) {
|
|
370
|
+
const root = findProjectRoot();
|
|
371
|
+
const prefix = detectPrefix(root);
|
|
372
|
+
|
|
373
|
+
// Temporarily undo prefix so npx skills can find its tracked skill names
|
|
374
|
+
if (prefix) {
|
|
375
|
+
console.log(`Detected "${prefix}" prefix, temporarily reverting for update...`);
|
|
376
|
+
undoPrefix(root, prefix);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
console.log('Updating via npx skills...\n');
|
|
380
|
+
try {
|
|
381
|
+
execSync('npx skills update', { stdio: 'inherit' });
|
|
382
|
+
} catch (e) {
|
|
383
|
+
// Re-apply prefix even if update fails
|
|
384
|
+
if (prefix) renameSkillsWithPrefix(root, prefix);
|
|
385
|
+
process.exit(e.status ?? 1);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Re-apply prefix after update
|
|
389
|
+
if (prefix) {
|
|
390
|
+
const count = renameSkillsWithPrefix(root, prefix);
|
|
391
|
+
console.log(`\nRe-applied "${prefix}" prefix to ${count} skills.`);
|
|
392
|
+
}
|
|
393
|
+
process.exit(0);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Fallback: manual update by downloading the universal bundle
|
|
397
|
+
console.log('Skills not managed by npx skills. Using direct download.\n');
|
|
398
|
+
|
|
399
|
+
const root = findProjectRoot();
|
|
400
|
+
const providers = findInstalledProviders(root);
|
|
401
|
+
|
|
402
|
+
if (providers.length === 0) {
|
|
403
|
+
console.log('No impeccable skill folders found in this project.');
|
|
404
|
+
console.log('Run `npx impeccable skills install` to install first.');
|
|
405
|
+
process.exit(1);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
console.log(`Found impeccable skills in: ${providers.join(', ')}`);
|
|
409
|
+
|
|
410
|
+
// Check for local modifications
|
|
411
|
+
const modified = getModifiedSkillFiles(root, providers);
|
|
412
|
+
if (modified.length > 0) {
|
|
413
|
+
console.log(`\n Warning: ${modified.length} skill file(s) have local changes:\n`);
|
|
414
|
+
for (const m of modified.slice(0, 10)) {
|
|
415
|
+
console.log(` ${m.flag} ${m.file}`);
|
|
416
|
+
}
|
|
417
|
+
if (modified.length > 10) console.log(` ... and ${modified.length - 10} more`);
|
|
418
|
+
console.log();
|
|
419
|
+
if (!yes) {
|
|
420
|
+
const ans = await ask(' Overwrite local changes? (y/N) ');
|
|
421
|
+
if (ans !== 'y' && ans !== 'yes') {
|
|
422
|
+
console.log('Aborted.');
|
|
423
|
+
process.exit(0);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
} else if (!yes) {
|
|
427
|
+
const ans = await ask(`Update skills in ${providers.length} provider folder(s)? (Y/n) `);
|
|
428
|
+
if (ans === 'n' || ans === 'no') {
|
|
429
|
+
console.log('Aborted.');
|
|
430
|
+
process.exit(0);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Download universal bundle
|
|
435
|
+
const tmpZip = join(tmpdir(), `impeccable-update-${Date.now()}.zip`);
|
|
436
|
+
console.log('\nDownloading latest skills...');
|
|
437
|
+
try {
|
|
438
|
+
await downloadFile(`${API_BASE}/api/download/bundle/universal`, tmpZip);
|
|
439
|
+
} catch (e) {
|
|
440
|
+
console.error(`Download failed: ${e.message}`);
|
|
441
|
+
process.exit(1);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// Extract and copy to each provider folder
|
|
445
|
+
let unzip;
|
|
446
|
+
try {
|
|
447
|
+
// Use built-in decompress if available (Node 22+), otherwise shell unzip
|
|
448
|
+
const tmpDir = join(tmpdir(), `impeccable-update-${Date.now()}`);
|
|
449
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
450
|
+
execSync(`unzip -qo "${tmpZip}" -d "${tmpDir}"`, { encoding: 'utf8' });
|
|
451
|
+
|
|
452
|
+
// The universal bundle has provider folders at the top level
|
|
453
|
+
let updated = 0;
|
|
454
|
+
for (const provider of providers) {
|
|
455
|
+
const srcDir = join(tmpDir, provider, 'skills');
|
|
456
|
+
const destDir = join(root, provider, 'skills');
|
|
457
|
+
if (!existsSync(srcDir)) continue;
|
|
458
|
+
|
|
459
|
+
// Copy each skill folder
|
|
460
|
+
const skills = readdirSync(srcDir, { withFileTypes: true });
|
|
461
|
+
for (const skill of skills) {
|
|
462
|
+
if (!skill.isDirectory()) continue;
|
|
463
|
+
const src = join(srcDir, skill.name);
|
|
464
|
+
const dest = join(destDir, skill.name);
|
|
465
|
+
// Remove old and copy new
|
|
466
|
+
if (existsSync(dest)) rmSync(dest, { recursive: true });
|
|
467
|
+
copyDirSync(src, dest);
|
|
468
|
+
updated++;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// Cleanup
|
|
473
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
474
|
+
rmSync(tmpZip, { force: true });
|
|
475
|
+
|
|
476
|
+
console.log(`Updated ${updated} skills across ${providers.length} provider(s).`);
|
|
477
|
+
console.log('Done!\n');
|
|
478
|
+
} catch (e) {
|
|
479
|
+
console.error(`Extract failed: ${e.message}`);
|
|
480
|
+
rmSync(tmpZip, { force: true });
|
|
481
|
+
process.exit(1);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function copyDirSync(src, dest) {
|
|
486
|
+
mkdirSync(dest, { recursive: true });
|
|
487
|
+
for (const entry of readdirSync(src, { withFileTypes: true })) {
|
|
488
|
+
const s = join(src, entry.name);
|
|
489
|
+
const d = join(dest, entry.name);
|
|
490
|
+
if (entry.isDirectory()) {
|
|
491
|
+
copyDirSync(s, d);
|
|
492
|
+
} else {
|
|
493
|
+
writeFileSync(d, readFileSync(s));
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// ─── Router ───────────────────────────────────────────────────────────────────
|
|
499
|
+
|
|
500
|
+
export async function run(args) {
|
|
501
|
+
const sub = args[0];
|
|
502
|
+
|
|
503
|
+
if (!sub || sub === 'help' || sub === '--help' || sub === '-h') {
|
|
504
|
+
await showHelp();
|
|
505
|
+
} else if (sub === 'install') {
|
|
506
|
+
await install(args.slice(1));
|
|
507
|
+
} else if (sub === 'update') {
|
|
508
|
+
await update(args.slice(1));
|
|
509
|
+
} else {
|
|
510
|
+
console.error(`Unknown skills command: ${sub}`);
|
|
511
|
+
console.error(`Run 'impeccable skills --help' for available commands.`);
|
|
512
|
+
process.exit(1);
|
|
513
|
+
}
|
|
514
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "impeccable",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
|
+
"description": "Detect UI anti-patterns and design quality issues from the command line",
|
|
4
5
|
"author": "Paul Bakaus",
|
|
6
|
+
"license": "BSL-1.1",
|
|
7
|
+
"type": "module",
|
|
5
8
|
"bin": {
|
|
6
|
-
"impeccable": "
|
|
9
|
+
"impeccable": "bin/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "./src/detect-antipatterns.mjs",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./src/detect-antipatterns.mjs",
|
|
14
|
+
"./browser": "./src/detect-antipatterns-browser.js"
|
|
7
15
|
},
|
|
8
16
|
"files": [
|
|
9
17
|
"bin/",
|
|
10
|
-
"
|
|
11
|
-
"source/skills/critique/scripts/detect-antipatterns-browser.js",
|
|
18
|
+
"src/",
|
|
12
19
|
"LICENSE"
|
|
13
20
|
],
|
|
14
21
|
"dependencies": {
|
|
@@ -17,7 +24,10 @@
|
|
|
17
24
|
"optionalDependencies": {
|
|
18
25
|
"puppeteer": "^24.39.1"
|
|
19
26
|
},
|
|
20
|
-
"
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "bun test tests/detect-antipatterns.test.js && node --test tests/detect-antipatterns-fixtures.test.mjs",
|
|
29
|
+
"build:browser": "node scripts/build-browser-detector.js"
|
|
30
|
+
},
|
|
21
31
|
"keywords": [
|
|
22
32
|
"design",
|
|
23
33
|
"frontend",
|
|
@@ -27,34 +37,15 @@
|
|
|
27
37
|
"accessibility",
|
|
28
38
|
"css",
|
|
29
39
|
"html",
|
|
30
|
-
"
|
|
40
|
+
"detection",
|
|
41
|
+
"ci-cd",
|
|
42
|
+
"skills"
|
|
31
43
|
],
|
|
32
|
-
"license": "SEE LICENSE FILE",
|
|
33
44
|
"repository": {
|
|
34
45
|
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/pbakaus/impeccable.git"
|
|
46
|
+
"url": "git+https://github.com/pbakaus/impeccable-detect.git"
|
|
36
47
|
},
|
|
37
48
|
"engines": {
|
|
38
|
-
"node": ">=18"
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"prepublishOnly": "cp README.md README.bak.md && cp README.npm.md README.md",
|
|
42
|
-
"postpublish": "mv README.bak.md README.md",
|
|
43
|
-
"build": "bun run scripts/build.js",
|
|
44
|
-
"clean": "rm -rf dist build",
|
|
45
|
-
"rebuild": "bun run clean && bun run build",
|
|
46
|
-
"dev": "bun run server/index.js",
|
|
47
|
-
"preview": "bun run build && wrangler pages dev",
|
|
48
|
-
"deploy": "bun run build && wrangler pages deploy build/",
|
|
49
|
-
"test": "bun test tests/build.test.js tests/detect-antipatterns.test.js && node --test tests/detect-antipatterns-fixtures.test.mjs",
|
|
50
|
-
"screenshot": "bun run scripts/screenshot-antipatterns.js",
|
|
51
|
-
"og-image": "bun run scripts/generate-og-image.js"
|
|
52
|
-
},
|
|
53
|
-
"type": "module",
|
|
54
|
-
"devDependencies": {
|
|
55
|
-
"archiver": "^7.0.1",
|
|
56
|
-
"motion": "^12.38.0",
|
|
57
|
-
"playwright": "^1.58.2",
|
|
58
|
-
"wrangler": "^4.75.0"
|
|
49
|
+
"node": ">=18.0.0"
|
|
59
50
|
}
|
|
60
51
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anti-Pattern Browser Detector for Impeccable
|
|
3
|
-
*
|
|
3
|
+
* Copyright (c) 2026 Paul Bakaus
|
|
4
|
+
* SPDX-License-Identifier: BSL-1.1
|
|
5
|
+
*
|
|
6
|
+
* GENERATED -- do not edit. Source: detect-antipatterns.mjs
|
|
4
7
|
* Rebuild: node scripts/build-browser-detector.js
|
|
5
8
|
*
|
|
6
9
|
* Usage: <script src="detect-antipatterns-browser.js"></script>
|
|
@@ -11,6 +14,8 @@ if (typeof window === 'undefined') return;
|
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Anti-Pattern Detector for Impeccable
|
|
17
|
+
* Copyright (c) 2026 Paul Bakaus
|
|
18
|
+
* SPDX-License-Identifier: BSL-1.1
|
|
14
19
|
*
|
|
15
20
|
* Universal file — auto-detects environment (browser vs Node) and adapts.
|
|
16
21
|
*
|
|
@@ -1210,11 +1215,20 @@ if (IS_BROWSER) {
|
|
|
1210
1215
|
// Inject hover styles via CSS (more reliable than JS event listeners)
|
|
1211
1216
|
const styleEl = document.createElement('style');
|
|
1212
1217
|
styleEl.textContent = `
|
|
1218
|
+
@keyframes impeccable-reveal {
|
|
1219
|
+
from { opacity: 0; outline-color: transparent; }
|
|
1220
|
+
to { opacity: 1; outline-color: ${OUTLINE_COLOR}; }
|
|
1221
|
+
}
|
|
1213
1222
|
.impeccable-overlay:not(.impeccable-banner) {
|
|
1214
1223
|
pointer-events: none;
|
|
1215
1224
|
outline: 2px solid ${OUTLINE_COLOR};
|
|
1216
1225
|
border-radius: 4px;
|
|
1217
1226
|
transition: outline-color 0.3s ease;
|
|
1227
|
+
animation: impeccable-reveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
1228
|
+
animation-play-state: paused;
|
|
1229
|
+
}
|
|
1230
|
+
.impeccable-overlay.impeccable-visible {
|
|
1231
|
+
animation-play-state: running;
|
|
1218
1232
|
}
|
|
1219
1233
|
.impeccable-overlay.impeccable-hover {
|
|
1220
1234
|
outline-color: rgba(0,0,0,0.85);
|
|
@@ -1287,6 +1301,7 @@ if (IS_BROWSER) {
|
|
|
1287
1301
|
// Uses a huge rootMargin so all *rendered* elements count as intersecting,
|
|
1288
1302
|
// while display:none / closed <details> / hidden modals etc. do not.
|
|
1289
1303
|
// This is event-driven -- no polling needed.
|
|
1304
|
+
let overlayIndex = 0;
|
|
1290
1305
|
const visibilityObserver = new IntersectionObserver((entries) => {
|
|
1291
1306
|
for (const entry of entries) {
|
|
1292
1307
|
const overlay = entry.target._impeccableOverlay;
|
|
@@ -1294,6 +1309,11 @@ if (IS_BROWSER) {
|
|
|
1294
1309
|
if (entry.isIntersecting) {
|
|
1295
1310
|
overlay.style.display = '';
|
|
1296
1311
|
positionOverlay(overlay);
|
|
1312
|
+
if (!overlay._revealed) {
|
|
1313
|
+
overlay._revealed = true;
|
|
1314
|
+
overlay.style.animationDelay = `${(overlay._staggerIndex || 0) * 80}ms`;
|
|
1315
|
+
requestAnimationFrame(() => overlay.classList.add('impeccable-visible'));
|
|
1316
|
+
}
|
|
1297
1317
|
} else {
|
|
1298
1318
|
overlay.style.display = 'none';
|
|
1299
1319
|
}
|
|
@@ -1360,6 +1380,7 @@ if (IS_BROWSER) {
|
|
|
1360
1380
|
|
|
1361
1381
|
// Start hidden; the IntersectionObserver will show it once the target is rendered
|
|
1362
1382
|
outline.style.display = 'none';
|
|
1383
|
+
outline._staggerIndex = overlayIndex++;
|
|
1363
1384
|
el._impeccableOverlay = outline;
|
|
1364
1385
|
visibilityObserver.observe(el);
|
|
1365
1386
|
|
|
@@ -1380,8 +1401,13 @@ if (IS_BROWSER) {
|
|
|
1380
1401
|
background: LABEL_BG, color: 'white',
|
|
1381
1402
|
fontFamily: 'system-ui, sans-serif', fontSize: '13px',
|
|
1382
1403
|
display: 'flex', alignItems: 'center', pointerEvents: 'auto',
|
|
1383
|
-
height: '36px',
|
|
1404
|
+
height: '36px', overflow: 'hidden', maxWidth: '100vw',
|
|
1405
|
+
transform: 'translateY(-100%)',
|
|
1406
|
+
transition: 'transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)',
|
|
1384
1407
|
});
|
|
1408
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
1409
|
+
banner.style.transform = 'translateY(0)';
|
|
1410
|
+
}));
|
|
1385
1411
|
|
|
1386
1412
|
// Scrollable findings area
|
|
1387
1413
|
const scrollArea = document.createElement('div');
|
|
@@ -1475,6 +1501,8 @@ if (IS_BROWSER) {
|
|
|
1475
1501
|
// Skip browser extension elements (Claude, etc.)
|
|
1476
1502
|
const elId = el.id || '';
|
|
1477
1503
|
if (elId.startsWith('claude-') || elId.startsWith('cic-')) continue;
|
|
1504
|
+
// Skip html/body -- page-level findings go in the banner, not a full-page overlay
|
|
1505
|
+
if (el === document.body || el === document.documentElement) continue;
|
|
1478
1506
|
|
|
1479
1507
|
const findings = [
|
|
1480
1508
|
...checkElementBordersDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
|