1#!/usr/bin/env node
2
3/**
4 * Impeccable CLI
5 *
6 * Usage:
7 * npx impeccable detect [file-or-dir-or-url...]
8 * npx impeccable live [--port=PORT]
9 * npx impeccable live stop
10 * npx impeccable skills help|install|update
11 * npx impeccable --help
12 */
13
14import { readFileSync } from 'node:fs';
15import { join, dirname } from 'node:path';
16import { fileURLToPath } from 'node:url';
17
18const __dirname = dirname(fileURLToPath(import.meta.url));
19const args = process.argv.slice(2);
20const command = args[0];
21
22if (!command || command === '--help' || command === '-h') {
23 console.log(`Usage: impeccable <command> [options]
24
25Commands:
26 detect [file-or-dir-or-url...] Scan for UI anti-patterns and design quality issues
27 live [--port=PORT] Start browser detection overlay server
28 live stop Stop a running live server
29 skills help List all available skills and commands
30 skills install Install impeccable skills into your project
31 skills update Update skills to the latest version
32 skills check Check if skill updates are available
33
34Options:
35 --help Show this help message
36 --version Show version number
37
38Run 'impeccable <command> --help' for command-specific options.`);
39 process.exit(0);
40}
41
42if (command === '--version' || command === '-v') {
43 const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
44 console.log(pkg.version);
45 process.exit(0);
46}
47
48if (command === 'detect') {
49 process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
50 const { detectCli } = await import('../src/detect-antipatterns.mjs');
51 await detectCli();
52} else if (command === 'live') {
53 process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
54 const { liveCli } = await import('../src/detect-antipatterns.mjs');
55 await liveCli();
56} else if (command === 'skills') {
57 const { run } = await import('./commands/skills.mjs');
58 await run(args.slice(1));
59} else {
60 // Default: treat as detect arguments (allow `npx impeccable src/` shorthand)
61 process.argv = [process.argv[0], process.argv[1], ...args];
62 const { detectCli } = await import('../src/detect-antipatterns.mjs');
63 await detectCli();
64}