cli.js

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