@stayicon/drift-guard 0.2.2 โ 0.2.4
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/README.md +23 -4
- package/dist/cli/index.js +146 -56
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,9 +7,18 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/@stayicon/drift-guard)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://github.com/Hwani-Net/drift-guard)
|
|
10
|
+
[](https://www.npmjs.com/package/@stayicon/drift-guard)
|
|
10
11
|
|
|
11
12
|
<p align="center">
|
|
12
|
-
<img src="docs/assets/cli-demo.png" alt="drift-guard CLI demo" width="680">
|
|
13
|
+
<img src="docs/assets/cli-demo.png" alt="drift-guard CLI demo showing design drift detection" width="680">
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<b>
|
|
18
|
+
<a href="https://hwani-net.github.io/drift-guard/">๐ฎ Try the Interactive Demo</a> ยท
|
|
19
|
+
<a href="https://www.npmjs.com/package/@stayicon/drift-guard">๐ฆ npm</a> ยท
|
|
20
|
+
<a href="#quick-start">๐ Quick Start</a>
|
|
21
|
+
</b>
|
|
13
22
|
</p>
|
|
14
23
|
|
|
15
24
|
---
|
|
@@ -39,6 +48,10 @@ npx drift-guard rules
|
|
|
39
48
|
npx drift-guard check
|
|
40
49
|
```
|
|
41
50
|
|
|
51
|
+
**Zero token overhead.** No MCP server. No configuration. Just CLI.
|
|
52
|
+
|
|
53
|
+
> ๐บ **[Try the Interactive Demo โ](https://hwani-net.github.io/drift-guard/)** โ See drift-guard in action, right in your browser.
|
|
54
|
+
|
|
42
55
|
## How It Works
|
|
43
56
|
|
|
44
57
|
```
|
|
@@ -115,7 +128,7 @@ npx drift-guard snapshot update
|
|
|
115
128
|
## What Gets Protected
|
|
116
129
|
|
|
117
130
|
| Category | Properties | Example |
|
|
118
|
-
|----------|-----------|---------|
|
|
131
|
+
|----------|-----------|---------|
|
|
119
132
|
| ๐จ Colors | `color`, `background-color`, `border-color`, CSS variables | `--primary: #1a73e8` |
|
|
120
133
|
| ๐ Fonts | `font-family`, `font-size`, `font-weight`, `line-height` | `font-family: Inter` |
|
|
121
134
|
| ๐ Spacing | `margin`, `padding`, `gap` | `padding: 16px 24px` |
|
|
@@ -125,9 +138,9 @@ npx drift-guard snapshot update
|
|
|
125
138
|
| โจ Effects | `backdrop-filter`, `filter`, `animation`, `transition` | `backdrop-filter: blur(10px)` |
|
|
126
139
|
| ๐๏ธ Structure | Semantic tags, DOM depth, layout hash, child sequence | `<header> โ <nav> โ <main> โ <footer>` |
|
|
127
140
|
|
|
128
|
-
### DOM Structure Detection (v0.2.0)
|
|
141
|
+
### DOM Structure Detection (v0.2.0+)
|
|
129
142
|
|
|
130
|
-
drift-guard
|
|
143
|
+
drift-guard fingerprints your HTML structure โ not just CSS tokens.
|
|
131
144
|
|
|
132
145
|
```bash
|
|
133
146
|
# Initialize with structure tracking (on by default)
|
|
@@ -216,6 +229,12 @@ const rules = generateRules(snapshot, 'claude-md');
|
|
|
216
229
|
| **Token overhead** | 0 tokens (CLI) | N/A |
|
|
217
230
|
| **Cost** | Free, forever | Percy: $99+/mo for teams |
|
|
218
231
|
|
|
232
|
+
## Why CLI, Not MCP?
|
|
233
|
+
|
|
234
|
+
> MCP tool registration costs ~10,000+ tokens per server at conversation start. drift-guard's CLI costs **0 tokens**. AI agents already know how to run `npx` commands.
|
|
235
|
+
|
|
236
|
+
Read more: [ADR-007: CLI-First Strategy](docs/DECISIONS.md#adr-007-cli-first-์ ๋ต--mcp-๋ํผ-๋ฐฐํฌ-๋ณด๋ฅ-2026-03-12)
|
|
237
|
+
|
|
219
238
|
## Philosophy
|
|
220
239
|
|
|
221
240
|
> AI should **add features**, not **destroy design**.
|
package/dist/cli/index.js
CHANGED
|
@@ -22,8 +22,13 @@ import {
|
|
|
22
22
|
// src/cli/index.ts
|
|
23
23
|
import { Command as Command2 } from "commander";
|
|
24
24
|
import chalk6 from "chalk";
|
|
25
|
+
import { readFileSync } from "fs";
|
|
26
|
+
import { fileURLToPath } from "url";
|
|
27
|
+
import { dirname, join } from "path";
|
|
25
28
|
|
|
26
29
|
// src/cli/init.ts
|
|
30
|
+
import fs from "fs";
|
|
31
|
+
import path from "path";
|
|
27
32
|
import chalk from "chalk";
|
|
28
33
|
async function initCommand(options) {
|
|
29
34
|
const projectRoot = process.cwd();
|
|
@@ -65,12 +70,94 @@ async function initCommand(options) {
|
|
|
65
70
|
console.log(chalk.dim(" \u{1F3D7}\uFE0F layout hash: ") + chalk.white(s.layoutHash));
|
|
66
71
|
}
|
|
67
72
|
console.log();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
if (!options.skipRules) {
|
|
74
|
+
try {
|
|
75
|
+
const content = generateRules(snapshot, "agents-md");
|
|
76
|
+
const rulesPath = saveRules(projectRoot, "agents-md", content, false);
|
|
77
|
+
console.log(chalk.green("\u2705 AI agent rules generated: ") + chalk.white(rulesPath));
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.log(chalk.yellow("\u26A0\uFE0F Could not generate rules: ") + chalk.dim(error.message));
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
console.log(chalk.dim(" \u23ED Skipped rules generation (--skip-rules)"));
|
|
83
|
+
}
|
|
84
|
+
if (!options.skipHook) {
|
|
85
|
+
const hasGit = fs.existsSync(path.join(projectRoot, ".git"));
|
|
86
|
+
if (hasGit) {
|
|
87
|
+
try {
|
|
88
|
+
installHookSilent(projectRoot, threshold.toString());
|
|
89
|
+
console.log(chalk.green("\u2705 Pre-commit hook installed: ") + chalk.dim("drift-guard check runs before every commit"));
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.log(chalk.yellow("\u26A0\uFE0F Could not install hook: ") + chalk.dim(error.message));
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
console.log(chalk.dim(" \u23ED No .git directory found \u2014 skipping hook install"));
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
console.log(chalk.dim(" \u23ED Skipped hook installation (--skip-hook)"));
|
|
98
|
+
}
|
|
99
|
+
console.log();
|
|
100
|
+
console.log(chalk.green.bold(" \u{1F6E1}\uFE0F Protection active!"));
|
|
101
|
+
console.log(chalk.dim(" Run ") + chalk.cyan("npx drift-guard check") + chalk.dim(" anytime to verify design integrity."));
|
|
102
|
+
if (!options.skipRules) {
|
|
103
|
+
console.log(chalk.dim(" Run ") + chalk.cyan("npx drift-guard rules --format all") + chalk.dim(" for additional AI tool formats."));
|
|
104
|
+
}
|
|
72
105
|
console.log();
|
|
73
106
|
}
|
|
107
|
+
function installHookSilent(projectRoot, threshold) {
|
|
108
|
+
const hasHusky = fs.existsSync(path.join(projectRoot, ".husky"));
|
|
109
|
+
const hookCommand = `npx drift-guard check --threshold ${threshold} --ci`;
|
|
110
|
+
if (hasHusky) {
|
|
111
|
+
const hookFile2 = path.join(projectRoot, ".husky", "pre-commit");
|
|
112
|
+
if (fs.existsSync(hookFile2)) {
|
|
113
|
+
const existing = fs.readFileSync(hookFile2, "utf-8");
|
|
114
|
+
if (existing.includes("drift-guard")) return;
|
|
115
|
+
fs.appendFileSync(hookFile2, `
|
|
116
|
+
${hookCommand}
|
|
117
|
+
`);
|
|
118
|
+
} else {
|
|
119
|
+
fs.writeFileSync(hookFile2, `#!/usr/bin/env sh
|
|
120
|
+
. "$(dirname -- "$0")/_/husky.sh"
|
|
121
|
+
|
|
122
|
+
${hookCommand}
|
|
123
|
+
`);
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const hooksDir = path.join(projectRoot, ".git", "hooks");
|
|
128
|
+
const hookFile = path.join(hooksDir, "pre-commit");
|
|
129
|
+
const hookScript = `#!/usr/bin/env sh
|
|
130
|
+
# drift-guard pre-commit hook
|
|
131
|
+
# Checks for design token drift before commits
|
|
132
|
+
# Bypass: git commit --no-verify
|
|
133
|
+
|
|
134
|
+
npx drift-guard check --threshold ${threshold} --ci
|
|
135
|
+
|
|
136
|
+
if [ $? -ne 0 ]; then
|
|
137
|
+
echo ""
|
|
138
|
+
echo "\\033[31m\u2717 Design drift detected! Commit blocked.\\033[0m"
|
|
139
|
+
echo " Run 'npx drift-guard check' for details."
|
|
140
|
+
echo " If changes are intentional, run 'npx drift-guard snapshot update'"
|
|
141
|
+
echo " Or use 'git commit --no-verify' to bypass."
|
|
142
|
+
exit 1
|
|
143
|
+
fi
|
|
144
|
+
`;
|
|
145
|
+
if (!fs.existsSync(hooksDir)) {
|
|
146
|
+
fs.mkdirSync(hooksDir, { recursive: true });
|
|
147
|
+
}
|
|
148
|
+
if (fs.existsSync(hookFile)) {
|
|
149
|
+
const existing = fs.readFileSync(hookFile, "utf-8");
|
|
150
|
+
if (existing.includes("drift-guard")) return;
|
|
151
|
+
fs.appendFileSync(hookFile, `
|
|
152
|
+
${hookScript}`);
|
|
153
|
+
} else {
|
|
154
|
+
fs.writeFileSync(hookFile, hookScript);
|
|
155
|
+
try {
|
|
156
|
+
fs.chmodSync(hookFile, 493);
|
|
157
|
+
} catch {
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
74
161
|
|
|
75
162
|
// src/cli/check.ts
|
|
76
163
|
import chalk2 from "chalk";
|
|
@@ -228,32 +315,32 @@ async function snapshotCommand(options) {
|
|
|
228
315
|
}
|
|
229
316
|
|
|
230
317
|
// src/cli/hook.ts
|
|
231
|
-
import
|
|
232
|
-
import
|
|
318
|
+
import fs2 from "fs";
|
|
319
|
+
import path2 from "path";
|
|
233
320
|
import chalk5 from "chalk";
|
|
234
321
|
async function hookInstallCommand(options) {
|
|
235
322
|
const cwd = process.cwd();
|
|
236
323
|
const threshold = options.threshold ?? "10";
|
|
237
|
-
if (!
|
|
324
|
+
if (!fs2.existsSync(path2.join(cwd, ".git"))) {
|
|
238
325
|
console.error(chalk5.red("\u2717 Not a git repository. Run this from a git project root."));
|
|
239
326
|
process.exit(1);
|
|
240
327
|
}
|
|
241
|
-
const hasHusky =
|
|
242
|
-
const hasLefthook =
|
|
328
|
+
const hasHusky = fs2.existsSync(path2.join(cwd, ".husky"));
|
|
329
|
+
const hasLefthook = fs2.existsSync(path2.join(cwd, "lefthook.yml")) || fs2.existsSync(path2.join(cwd, ".lefthook.yml"));
|
|
243
330
|
if (hasHusky) {
|
|
244
|
-
const hookFile2 =
|
|
331
|
+
const hookFile2 = path2.join(cwd, ".husky", "pre-commit");
|
|
245
332
|
const hookCommand = `npx drift-guard check --threshold ${threshold} --ci`;
|
|
246
|
-
if (
|
|
247
|
-
const existing =
|
|
333
|
+
if (fs2.existsSync(hookFile2)) {
|
|
334
|
+
const existing = fs2.readFileSync(hookFile2, "utf-8");
|
|
248
335
|
if (existing.includes("drift-guard")) {
|
|
249
336
|
console.log(chalk5.yellow("\u26A0 drift-guard hook already exists in .husky/pre-commit"));
|
|
250
337
|
return;
|
|
251
338
|
}
|
|
252
|
-
|
|
339
|
+
fs2.appendFileSync(hookFile2, `
|
|
253
340
|
${hookCommand}
|
|
254
341
|
`);
|
|
255
342
|
} else {
|
|
256
|
-
|
|
343
|
+
fs2.writeFileSync(hookFile2, `#!/usr/bin/env sh
|
|
257
344
|
. "$(dirname -- "$0")/_/husky.sh"
|
|
258
345
|
|
|
259
346
|
${hookCommand}
|
|
@@ -272,8 +359,8 @@ pre-commit:
|
|
|
272
359
|
`));
|
|
273
360
|
return;
|
|
274
361
|
}
|
|
275
|
-
const hooksDir =
|
|
276
|
-
const hookFile =
|
|
362
|
+
const hooksDir = path2.join(cwd, ".git", "hooks");
|
|
363
|
+
const hookFile = path2.join(hooksDir, "pre-commit");
|
|
277
364
|
const hookScript = `#!/usr/bin/env sh
|
|
278
365
|
# drift-guard pre-commit hook
|
|
279
366
|
# Checks for design token drift before commits
|
|
@@ -290,22 +377,22 @@ if [ $? -ne 0 ]; then
|
|
|
290
377
|
exit 1
|
|
291
378
|
fi
|
|
292
379
|
`;
|
|
293
|
-
if (!
|
|
294
|
-
|
|
380
|
+
if (!fs2.existsSync(hooksDir)) {
|
|
381
|
+
fs2.mkdirSync(hooksDir, { recursive: true });
|
|
295
382
|
}
|
|
296
|
-
if (
|
|
297
|
-
const existing =
|
|
383
|
+
if (fs2.existsSync(hookFile)) {
|
|
384
|
+
const existing = fs2.readFileSync(hookFile, "utf-8");
|
|
298
385
|
if (existing.includes("drift-guard")) {
|
|
299
386
|
console.log(chalk5.yellow("\u26A0 drift-guard hook already installed"));
|
|
300
387
|
return;
|
|
301
388
|
}
|
|
302
|
-
|
|
389
|
+
fs2.appendFileSync(hookFile, `
|
|
303
390
|
${hookScript}`);
|
|
304
391
|
console.log(chalk5.green("\u2713 Appended drift-guard to existing pre-commit hook"));
|
|
305
392
|
} else {
|
|
306
|
-
|
|
393
|
+
fs2.writeFileSync(hookFile, hookScript);
|
|
307
394
|
try {
|
|
308
|
-
|
|
395
|
+
fs2.chmodSync(hookFile, 493);
|
|
309
396
|
} catch {
|
|
310
397
|
}
|
|
311
398
|
console.log(chalk5.green("\u2713 Installed drift-guard pre-commit hook"));
|
|
@@ -315,26 +402,26 @@ ${hookScript}`);
|
|
|
315
402
|
}
|
|
316
403
|
async function hookUninstallCommand() {
|
|
317
404
|
const cwd = process.cwd();
|
|
318
|
-
const huskyHook =
|
|
319
|
-
if (
|
|
320
|
-
const content =
|
|
405
|
+
const huskyHook = path2.join(cwd, ".husky", "pre-commit");
|
|
406
|
+
if (fs2.existsSync(huskyHook)) {
|
|
407
|
+
const content = fs2.readFileSync(huskyHook, "utf-8");
|
|
321
408
|
if (content.includes("drift-guard")) {
|
|
322
409
|
const cleaned = content.replace(/\n?npx drift-guard.*\n?/g, "\n");
|
|
323
|
-
|
|
410
|
+
fs2.writeFileSync(huskyHook, cleaned);
|
|
324
411
|
console.log(chalk5.green("\u2713 Removed drift-guard from .husky/pre-commit"));
|
|
325
412
|
return;
|
|
326
413
|
}
|
|
327
414
|
}
|
|
328
|
-
const gitHook =
|
|
329
|
-
if (
|
|
330
|
-
const content =
|
|
415
|
+
const gitHook = path2.join(cwd, ".git", "hooks", "pre-commit");
|
|
416
|
+
if (fs2.existsSync(gitHook)) {
|
|
417
|
+
const content = fs2.readFileSync(gitHook, "utf-8");
|
|
331
418
|
if (content.includes("drift-guard")) {
|
|
332
419
|
if (content.includes("# drift-guard pre-commit hook") && !content.includes("\n#!/usr/bin/env sh\n")) {
|
|
333
|
-
|
|
420
|
+
fs2.unlinkSync(gitHook);
|
|
334
421
|
console.log(chalk5.green("\u2713 Removed drift-guard pre-commit hook"));
|
|
335
422
|
} else {
|
|
336
423
|
const cleaned = content.replace(/# drift-guard pre-commit hook[\s\S]*?fi\n?/g, "");
|
|
337
|
-
|
|
424
|
+
fs2.writeFileSync(gitHook, cleaned);
|
|
338
425
|
console.log(chalk5.green("\u2713 Removed drift-guard from pre-commit hook"));
|
|
339
426
|
}
|
|
340
427
|
return;
|
|
@@ -345,8 +432,8 @@ async function hookUninstallCommand() {
|
|
|
345
432
|
|
|
346
433
|
// src/cli/sync.ts
|
|
347
434
|
import { Command } from "commander";
|
|
348
|
-
import
|
|
349
|
-
import
|
|
435
|
+
import path3 from "path";
|
|
436
|
+
import fs3 from "fs";
|
|
350
437
|
import fg from "fast-glob";
|
|
351
438
|
var syncCommand = new Command("sync").description("Synchronize design tokens between Stitch and your codebase").requiredOption(
|
|
352
439
|
"-d, --direction <direction>",
|
|
@@ -447,12 +534,12 @@ async function handleToCode(projectRoot, options) {
|
|
|
447
534
|
);
|
|
448
535
|
process.exit(1);
|
|
449
536
|
}
|
|
450
|
-
const absPath =
|
|
451
|
-
if (!
|
|
537
|
+
const absPath = path3.resolve(projectRoot, stitchHtmlPath);
|
|
538
|
+
if (!fs3.existsSync(absPath)) {
|
|
452
539
|
console.error(`\u274C Stitch HTML file not found: ${absPath}`);
|
|
453
540
|
process.exit(1);
|
|
454
541
|
}
|
|
455
|
-
const htmlContent =
|
|
542
|
+
const htmlContent = fs3.readFileSync(absPath, "utf-8");
|
|
456
543
|
const stitchTokens = [];
|
|
457
544
|
const htmlTokens = parseHtml(htmlContent, stitchHtmlPath);
|
|
458
545
|
stitchTokens.push(...htmlTokens);
|
|
@@ -478,10 +565,10 @@ async function handleToCode(projectRoot, options) {
|
|
|
478
565
|
if (localStitchFiles.length > 0) {
|
|
479
566
|
console.log("\u{1F4C4} Step 1: Full HTML replacement");
|
|
480
567
|
for (const localFile of localStitchFiles) {
|
|
481
|
-
const localAbsPath =
|
|
482
|
-
const localContent =
|
|
568
|
+
const localAbsPath = path3.resolve(projectRoot, localFile);
|
|
569
|
+
const localContent = fs3.readFileSync(localAbsPath, "utf-8");
|
|
483
570
|
if (localContent !== htmlContent) {
|
|
484
|
-
|
|
571
|
+
fs3.writeFileSync(localAbsPath, htmlContent, "utf-8");
|
|
485
572
|
console.log(` \u2705 Replaced: ${localFile} (Stitch \u2192 local)`);
|
|
486
573
|
htmlReplaced = true;
|
|
487
574
|
} else {
|
|
@@ -505,8 +592,8 @@ async function handleToCode(projectRoot, options) {
|
|
|
505
592
|
const { modifiedFiles, appliedCount } = applySyncChanges(result.changes, cssFileMap);
|
|
506
593
|
if (appliedCount > 0) {
|
|
507
594
|
for (const [file, content] of modifiedFiles) {
|
|
508
|
-
const fullPath =
|
|
509
|
-
|
|
595
|
+
const fullPath = path3.resolve(projectRoot, file);
|
|
596
|
+
fs3.writeFileSync(fullPath, content, "utf-8");
|
|
510
597
|
console.log(` \u2705 Patched: ${file}`);
|
|
511
598
|
}
|
|
512
599
|
}
|
|
@@ -518,7 +605,7 @@ async function handleToCode(projectRoot, options) {
|
|
|
518
605
|
const { execSync } = await import("child_process");
|
|
519
606
|
try {
|
|
520
607
|
execSync(
|
|
521
|
-
`node "${
|
|
608
|
+
`node "${path3.resolve(projectRoot, "..", "drift-guard", "dist", "cli", "index.js")}" snapshot update`,
|
|
522
609
|
{ cwd: projectRoot, stdio: "pipe" }
|
|
523
610
|
);
|
|
524
611
|
} catch {
|
|
@@ -537,8 +624,8 @@ async function handleToCode(projectRoot, options) {
|
|
|
537
624
|
if (localStitchFiles.length > 0) {
|
|
538
625
|
let allMatch = true;
|
|
539
626
|
for (const localFile of localStitchFiles) {
|
|
540
|
-
const localAbsPath =
|
|
541
|
-
const localContent =
|
|
627
|
+
const localAbsPath = path3.resolve(projectRoot, localFile);
|
|
628
|
+
const localContent = fs3.readFileSync(localAbsPath, "utf-8");
|
|
542
629
|
if (localContent === htmlContent) {
|
|
543
630
|
console.log(` \u2705 ${localFile} \u2014 100% identical to Stitch`);
|
|
544
631
|
} else {
|
|
@@ -574,12 +661,12 @@ async function handleToCode(projectRoot, options) {
|
|
|
574
661
|
console.log("");
|
|
575
662
|
console.log("\u2501".repeat(60));
|
|
576
663
|
if (!options.dryRun) {
|
|
577
|
-
const patchPath =
|
|
664
|
+
const patchPath = path3.join(
|
|
578
665
|
projectRoot,
|
|
579
666
|
".design-guard",
|
|
580
667
|
"sync-patch.css"
|
|
581
668
|
);
|
|
582
|
-
|
|
669
|
+
fs3.writeFileSync(patchPath, result.patchFile, "utf-8");
|
|
583
670
|
console.log(`
|
|
584
671
|
\u{1F4BE} Patch saved to: ${patchPath}`);
|
|
585
672
|
console.log(" Use --apply for full HTML content + token sync.");
|
|
@@ -601,7 +688,7 @@ async function findLocalStitchHtml(projectRoot, sourceAbsPath, targetPath) {
|
|
|
601
688
|
absolute: false
|
|
602
689
|
}
|
|
603
690
|
);
|
|
604
|
-
const sourceRelative =
|
|
691
|
+
const sourceRelative = path3.relative(projectRoot, sourceAbsPath);
|
|
605
692
|
return stitchFiles.filter((f) => f !== sourceRelative);
|
|
606
693
|
}
|
|
607
694
|
async function loadProjectCssFiles(projectRoot, config) {
|
|
@@ -613,9 +700,9 @@ async function loadProjectCssFiles(projectRoot, config) {
|
|
|
613
700
|
absolute: false
|
|
614
701
|
});
|
|
615
702
|
for (const file of matches) {
|
|
616
|
-
const absPath =
|
|
617
|
-
if (
|
|
618
|
-
cssFileMap.set(file,
|
|
703
|
+
const absPath = path3.resolve(projectRoot, file);
|
|
704
|
+
if (fs3.existsSync(absPath)) {
|
|
705
|
+
cssFileMap.set(file, fs3.readFileSync(absPath, "utf-8"));
|
|
619
706
|
}
|
|
620
707
|
}
|
|
621
708
|
}
|
|
@@ -627,20 +714,23 @@ async function loadProjectCssFiles(projectRoot, config) {
|
|
|
627
714
|
absolute: false
|
|
628
715
|
});
|
|
629
716
|
for (const file of htmlMatches) {
|
|
630
|
-
const absPath =
|
|
631
|
-
if (
|
|
632
|
-
cssFileMap.set(file,
|
|
717
|
+
const absPath = path3.resolve(projectRoot, file);
|
|
718
|
+
if (fs3.existsSync(absPath)) {
|
|
719
|
+
cssFileMap.set(file, fs3.readFileSync(absPath, "utf-8"));
|
|
633
720
|
}
|
|
634
721
|
}
|
|
635
722
|
return cssFileMap;
|
|
636
723
|
}
|
|
637
724
|
|
|
638
725
|
// src/cli/index.ts
|
|
726
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
727
|
+
var __dirname = dirname(__filename);
|
|
728
|
+
var pkg = JSON.parse(readFileSync(join(__dirname, "..", "..", "package.json"), "utf-8"));
|
|
639
729
|
var program = new Command2();
|
|
640
730
|
program.name("drift-guard").description(
|
|
641
731
|
chalk6.bold("\u{1F6E1}\uFE0F drift-guard") + " \u2014 Protect your UI from AI coding agents' design drift.\n\n Detect and prevent design token changes during AI-assisted development.\n Lock your colors, fonts, spacing, and layout before AI agents touch your code."
|
|
642
|
-
).version(
|
|
643
|
-
program.command("init").description("Initialize drift-guard
|
|
732
|
+
).version(pkg.version);
|
|
733
|
+
program.command("init").description("Initialize drift-guard: snapshot + AI rules + git hook (all-in-one)").option("--from <path>", "Create snapshot from a Stitch/HTML file").option("--threshold <number>", "Set default drift threshold percentage", "10").option("--skip-rules", "Skip auto-generating AGENTS.md rules file").option("--skip-hook", "Skip auto-installing pre-commit git hook").action(initCommand);
|
|
644
734
|
program.command("check").description("Check for design drift against the saved snapshot").option("--threshold <number>", "Override drift threshold percentage").option("--output <format>", "Output format: text or json", "text").option("--ci", "CI mode: exit with code 1 on drift exceeding threshold").action(checkCommand);
|
|
645
735
|
program.command("rules").description("Generate AI agent rule files from the design snapshot").option("--format <type>", "Rule format: cursorrules, claude-md, agents-md, copilot, clinerules, all", "all").option("--append", "Append to existing rule files instead of overwriting").action(rulesCommand);
|
|
646
736
|
program.command("snapshot").description("Manage design snapshots").command("update").description("Update the snapshot to reflect current design (after intentional changes)").option("--from <path>", "Update from a specific Stitch/HTML file").action(snapshotCommand);
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/init.ts","../../src/cli/check.ts","../../src/cli/rules.ts","../../src/cli/snapshot-cmd.ts","../../src/cli/hook.ts","../../src/cli/sync.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport { initCommand } from './init.js';\nimport { checkCommand } from './check.js';\nimport { rulesCommand } from './rules.js';\nimport { snapshotCommand } from './snapshot-cmd.js';\nimport { hookInstallCommand, hookUninstallCommand } from './hook.js';\nimport { syncCommand } from './sync.js';\n\nconst program = new Command();\n\nprogram\n .name('drift-guard')\n .description(\n chalk.bold('๐ก๏ธ drift-guard') +\n ' โ Protect your UI from AI coding agents\\' design drift.\\n\\n' +\n ' Detect and prevent design token changes during AI-assisted development.\\n' +\n ' Lock your colors, fonts, spacing, and layout before AI agents touch your code.'\n )\n .version('0.2.0');\n\nprogram\n .command('init')\n .description('Initialize drift-guard and create a design snapshot')\n .option('--from <path>', 'Create snapshot from a Stitch/HTML file')\n .option('--threshold <number>', 'Set default drift threshold percentage', '10')\n .action(initCommand);\n\nprogram\n .command('check')\n .description('Check for design drift against the saved snapshot')\n .option('--threshold <number>', 'Override drift threshold percentage')\n .option('--output <format>', 'Output format: text or json', 'text')\n .option('--ci', 'CI mode: exit with code 1 on drift exceeding threshold')\n .action(checkCommand);\n\nprogram\n .command('rules')\n .description('Generate AI agent rule files from the design snapshot')\n .option('--format <type>', 'Rule format: cursorrules, claude-md, agents-md, copilot, clinerules, all', 'all')\n .option('--append', 'Append to existing rule files instead of overwriting')\n .action(rulesCommand);\n\nprogram\n .command('snapshot')\n .description('Manage design snapshots')\n .command('update')\n .description('Update the snapshot to reflect current design (after intentional changes)')\n .option('--from <path>', 'Update from a specific Stitch/HTML file')\n .action(snapshotCommand);\n\nconst hook = program\n .command('hook')\n .description('Manage pre-commit hook for automatic drift checking');\n\nhook\n .command('install')\n .description('Install a pre-commit hook that runs drift-guard check')\n .option('--threshold <number>', 'Drift threshold percentage for the hook', '10')\n .action(hookInstallCommand);\n\nhook\n .command('uninstall')\n .description('Remove the drift-guard pre-commit hook')\n .action(hookUninstallCommand);\n\nprogram.addCommand(syncCommand);\n\nprogram.parse();\n\n","import chalk from 'chalk';\nimport { createSnapshot, saveSnapshot, saveConfig } from '../core/snapshot.js';\nimport { DEFAULT_CONFIG } from '../types/index.js';\n\ninterface InitOptions {\n from?: string;\n threshold?: string;\n}\n\nexport async function initCommand(options: InitOptions): Promise<void> {\n const projectRoot = process.cwd();\n const threshold = parseInt(options.threshold ?? '10', 10);\n\n console.log(chalk.bold('\\n๐ก๏ธ drift-guard init\\n'));\n console.log(chalk.dim('Scanning project for design tokens...\\n'));\n\n // Save config\n const config = { ...DEFAULT_CONFIG, threshold };\n saveConfig(projectRoot, config);\n\n // Create snapshot\n const snapshot = await createSnapshot(projectRoot, options.from);\n\n if (snapshot.tokens.length === 0) {\n console.log(chalk.yellow('โ ๏ธ No design tokens found.'));\n console.log(chalk.dim(' Make sure you have CSS files or use --from <stitch.html>'));\n console.log(chalk.dim(' Supported patterns: src/**/*.css, app/**/*.css, styles/**/*.css\\n'));\n return;\n }\n\n // Save snapshot\n const snapshotPath = saveSnapshot(projectRoot, snapshot);\n\n // Report\n console.log(chalk.green('โ
Design snapshot created!\\n'));\n console.log(chalk.dim(' Snapshot: ') + chalk.white(snapshotPath));\n console.log(chalk.dim(' Files scanned: ') + chalk.white(snapshot.sourceFiles.length.toString()));\n console.log(chalk.dim(' Tokens locked: ') + chalk.white(snapshot.tokens.length.toString()));\n console.log(chalk.dim(' Threshold: ') + chalk.white(`${threshold}%`));\n console.log();\n\n // Token summary\n console.log(chalk.bold(' Token Summary:'));\n const categories = ['color', 'font', 'spacing', 'shadow', 'radius', 'layout'] as const;\n for (const cat of categories) {\n const count = snapshot.summary[cat];\n if (count > 0) {\n const icon = { color: '๐จ', font: '๐', spacing: '๐', shadow: '๐ซ๏ธ', radius: 'โญ', layout: '๐' }[cat];\n console.log(chalk.dim(` ${icon} ${cat}: `) + chalk.white(count.toString()));\n }\n }\n\n // Structure fingerprint summary (v0.2.0+)\n if (snapshot.structure) {\n const s = snapshot.structure;\n const tagList = Object.entries(s.semanticTags)\n .filter(([, count]) => count > 0)\n .map(([tag, count]) => `${tag}(${count})`)\n .join(', ');\n console.log();\n console.log(chalk.bold(' Structure Fingerprint:'));\n console.log(chalk.dim(' ๐๏ธ semantic tags: ') + chalk.white(tagList));\n console.log(chalk.dim(' ๐๏ธ max depth: ') + chalk.white(s.maxDepth.toString()));\n console.log(chalk.dim(' ๐๏ธ layout hash: ') + chalk.white(s.layoutHash));\n }\n\n console.log();\n console.log(chalk.dim('Next steps:'));\n console.log(chalk.cyan(' 1. ') + 'Add .design-guard/ to .gitignore (optional)');\n console.log(chalk.cyan(' 2. ') + chalk.bold('npx drift-guard rules') + ' โ Generate AI agent protection rules');\n console.log(chalk.cyan(' 3. ') + chalk.bold('npx drift-guard check') + ' โ Check for design drift anytime');\n console.log();\n}\n","import chalk from 'chalk';\nimport { loadSnapshot, loadConfig } from '../core/snapshot.js';\nimport { detectDrift } from '../core/drift.js';\nimport type { DriftReport, DriftItem } from '../types/index.js';\n\ninterface CheckOptions {\n threshold?: string;\n output?: string;\n ci?: boolean;\n}\n\nexport async function checkCommand(options: CheckOptions): Promise<void> {\n const projectRoot = process.cwd();\n\n // Load snapshot\n const snapshot = loadSnapshot(projectRoot);\n if (!snapshot) {\n console.log(chalk.red('\\nโ No snapshot found.'));\n console.log(chalk.dim(' Run ') + chalk.cyan('npx drift-guard init') + chalk.dim(' first.\\n'));\n process.exit(1);\n }\n\n const config = loadConfig(projectRoot);\n const threshold = options.threshold\n ? parseInt(options.threshold, 10)\n : config.threshold;\n\n console.log(chalk.bold('\\n๐ก๏ธ drift-guard check\\n'));\n\n // Snapshot age warning\n const snapshotAge = Date.now() - new Date(snapshot.createdAt).getTime();\n const ageDays = Math.floor(snapshotAge / (1000 * 60 * 60 * 24));\n if (ageDays >= 7) {\n const ageStr = ageDays >= 30 ? `${Math.floor(ageDays / 30)} month(s)` : `${ageDays} days`;\n console.log(chalk.yellow(`โ ๏ธ Snapshot is ${ageStr} old (created ${snapshot.createdAt.split('T')[0]}).`));\n console.log(chalk.yellow(' If your design has changed, run: ') + chalk.cyan('drift-guard init --from <latest.html>\\n'));\n }\n\n console.log(chalk.dim(`Comparing against snapshot from ${snapshot.createdAt}...\\n`));\n\n // Detect drift\n const report = await detectDrift(projectRoot, snapshot, threshold);\n\n if (options.output === 'json') {\n console.log(JSON.stringify(report, null, 2));\n } else {\n printTextReport(report);\n }\n\n // Exit code for CI\n if (!report.passed && (options.ci || process.env['CI'])) {\n process.exit(1);\n }\n\n if (!report.passed) {\n process.exitCode = 1;\n }\n}\n\nfunction printTextReport(report: DriftReport): void {\n // Score display\n const scoreColor = report.passed ? chalk.green : chalk.red;\n const icon = report.passed ? 'โ
' : '๐จ';\n\n console.log(`${icon} ${chalk.bold('Drift Score:')} ${scoreColor(`${report.driftScore}%`)} (threshold: ${report.threshold}%)`);\n console.log(chalk.dim(` ${report.changedTokens} of ${report.totalTokens} tokens changed\\n`));\n\n if (report.items.length === 0 && !(report.structureDrift?.changed)) {\n console.log(chalk.green(' No design drift detected. Your design is intact! ๐\\n'));\n return;\n }\n\n if (report.items.length > 0) {\n // Category breakdown\n console.log(chalk.bold(' Category Breakdown:'));\n const categories = ['color', 'font', 'spacing', 'shadow', 'radius', 'layout'] as const;\n for (const cat of categories) {\n const summary = report.categorySummary[cat];\n if (summary.total === 0) continue;\n\n const catIcon = { color: '๐จ', font: '๐', spacing: '๐', shadow: '๐ซ๏ธ', radius: 'โญ', layout: '๐' }[cat];\n const catColor = summary.changed > 0 ? chalk.red : chalk.green;\n console.log(` ${catIcon} ${cat}: ${catColor(`${summary.changed}/${summary.total}`)} (${summary.driftPercent}%)`);\n }\n console.log();\n\n // Detailed changes (max 20)\n const itemsToShow = report.items.slice(0, 20);\n if (itemsToShow.length > 0) {\n console.log(chalk.bold(' Changes:'));\n for (const item of itemsToShow) {\n printDriftItem(item);\n }\n\n if (report.items.length > 20) {\n console.log(chalk.dim(` ... and ${report.items.length - 20} more changes\\n`));\n }\n }\n\n console.log();\n }\n\n // Structure drift (v0.2.0+)\n if (report.structureDrift) {\n if (report.structureDrift.changed) {\n console.log(chalk.bold(' ๐๏ธ Structure Drift:'));\n for (const detail of report.structureDrift.details) {\n console.log(chalk.yellow(` โ ๏ธ ${detail}`));\n }\n console.log();\n } else {\n console.log(chalk.green(' ๐๏ธ DOM structure: No changes detected โ
\\n'));\n }\n }\n\n if (!report.passed) {\n console.log(chalk.yellow(' ๐ก To accept these changes, run:'));\n console.log(chalk.cyan(' npx drift-guard snapshot update\\n'));\n }\n}\n\nfunction printDriftItem(item: DriftItem): void {\n const { original, current, changeType } = item;\n\n switch (changeType) {\n case 'modified':\n console.log(\n chalk.yellow(' ~') +\n chalk.dim(` ${original.file} `) +\n chalk.white(`${original.property}: `) +\n chalk.red(original.value) +\n chalk.dim(' โ ') +\n chalk.green(current?.value ?? 'removed')\n );\n break;\n case 'deleted':\n console.log(\n chalk.red(' -') +\n chalk.dim(` ${original.file} `) +\n chalk.white(`${original.property}: `) +\n chalk.red(original.value) +\n chalk.dim(' [deleted]')\n );\n break;\n case 'added':\n console.log(\n chalk.green(' +') +\n chalk.dim(` ${original.file} `) +\n chalk.white(`${original.property}: `) +\n chalk.green(original.value)\n );\n break;\n }\n}\n","import chalk from 'chalk';\nimport { loadSnapshot } from '../core/snapshot.js';\nimport { generateRules, saveRules } from '../core/rules-generator.js';\nimport type { RuleFormat } from '../types/index.js';\n\ninterface RulesOptions {\n format?: string;\n append?: boolean;\n}\n\nconst ALL_FORMATS: RuleFormat[] = ['cursorrules', 'claude-md', 'agents-md', 'copilot', 'clinerules'];\n\nexport async function rulesCommand(options: RulesOptions): Promise<void> {\n const projectRoot = process.cwd();\n\n const snapshot = loadSnapshot(projectRoot);\n if (!snapshot) {\n console.log(chalk.red('\\nโ No snapshot found.'));\n console.log(chalk.dim(' Run ') + chalk.cyan('npx drift-guard init') + chalk.dim(' first.\\n'));\n process.exit(1);\n }\n\n const formats: RuleFormat[] = options.format === 'all' || !options.format\n ? ALL_FORMATS\n : [options.format as RuleFormat];\n\n console.log(chalk.bold('\\n๐ก๏ธ drift-guard rules\\n'));\n console.log(chalk.dim(`Generating AI protection rules from ${snapshot.tokens.length} locked tokens...\\n`));\n\n for (const format of formats) {\n try {\n const content = generateRules(snapshot, format);\n const filePath = saveRules(projectRoot, format, content, options.append ?? false);\n console.log(chalk.green(' โ
') + chalk.white(filePath));\n } catch (error) {\n console.log(chalk.red(' โ ') + chalk.white(format) + chalk.dim(`: ${(error as Error).message}`));\n }\n }\n\n console.log();\n console.log(chalk.dim('Your AI coding agents will now protect these design tokens.'));\n console.log(chalk.dim('Supported tools: Cursor, Claude Code, Codex, GitHub Copilot, Cline\\n'));\n}\n","import chalk from 'chalk';\nimport { createSnapshot, saveSnapshot } from '../core/snapshot.js';\n\ninterface SnapshotOptions {\n from?: string;\n}\n\nexport async function snapshotCommand(options: SnapshotOptions): Promise<void> {\n const projectRoot = process.cwd();\n\n console.log(chalk.bold('\\n๐ก๏ธ drift-guard snapshot update\\n'));\n console.log(chalk.dim('Re-scanning project and updating snapshot...\\n'));\n\n const snapshot = await createSnapshot(projectRoot, options.from);\n\n if (snapshot.tokens.length === 0) {\n console.log(chalk.yellow('โ ๏ธ No design tokens found.\\n'));\n return;\n }\n\n const snapshotPath = saveSnapshot(projectRoot, snapshot);\n\n console.log(chalk.green('โ
Snapshot updated!\\n'));\n console.log(chalk.dim(' File: ') + chalk.white(snapshotPath));\n console.log(chalk.dim(' Tokens: ') + chalk.white(snapshot.tokens.length.toString()));\n console.log(chalk.dim(' Updated: ') + chalk.white(snapshot.createdAt));\n console.log();\n console.log(chalk.dim('๐ก Remember to regenerate rules: ') + chalk.cyan('npx drift-guard rules\\n'));\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { execSync } from 'node:child_process';\nimport chalk from 'chalk';\n\n/**\n * Install a pre-commit hook that runs drift-guard check\n */\nexport async function hookInstallCommand(options: { threshold?: string }): Promise<void> {\n const cwd = process.cwd();\n const threshold = options.threshold ?? '10';\n\n // Check if git repo\n if (!fs.existsSync(path.join(cwd, '.git'))) {\n console.error(chalk.red('โ Not a git repository. Run this from a git project root.'));\n process.exit(1);\n }\n\n // Detect hook manager\n const hasHusky = fs.existsSync(path.join(cwd, '.husky'));\n const hasLefthook = fs.existsSync(path.join(cwd, 'lefthook.yml')) ||\n fs.existsSync(path.join(cwd, '.lefthook.yml'));\n\n if (hasHusky) {\n // Add to existing husky setup\n const hookFile = path.join(cwd, '.husky', 'pre-commit');\n const hookCommand = `npx drift-guard check --threshold ${threshold} --ci`;\n\n if (fs.existsSync(hookFile)) {\n const existing = fs.readFileSync(hookFile, 'utf-8');\n if (existing.includes('drift-guard')) {\n console.log(chalk.yellow('โ drift-guard hook already exists in .husky/pre-commit'));\n return;\n }\n fs.appendFileSync(hookFile, `\\n${hookCommand}\\n`);\n } else {\n fs.writeFileSync(hookFile, `#!/usr/bin/env sh\\n. \"$(dirname -- \"$0\")/_/husky.sh\"\\n\\n${hookCommand}\\n`);\n }\n\n console.log(chalk.green('โ Added drift-guard check to .husky/pre-commit'));\n return;\n }\n\n if (hasLefthook) {\n console.log(chalk.yellow('โ lefthook detected. Add this to your lefthook.yml:'));\n console.log(chalk.cyan(`\npre-commit:\n commands:\n drift-guard:\n run: npx drift-guard check --threshold ${threshold} --ci\n`));\n return;\n }\n\n // No hook manager โ install via .git/hooks directly\n const hooksDir = path.join(cwd, '.git', 'hooks');\n const hookFile = path.join(hooksDir, 'pre-commit');\n const hookScript = `#!/usr/bin/env sh\n# drift-guard pre-commit hook\n# Checks for design token drift before commits\n# Use --force flag to bypass: git commit --no-verify\n\nnpx drift-guard check --threshold ${threshold} --ci\n\nif [ $? -ne 0 ]; then\n echo \"\"\n echo \"\\\\033[31mโ Design drift detected! Commit blocked.\\\\033[0m\"\n echo \" Run 'npx drift-guard check' for details.\"\n echo \" If changes are intentional, run 'npx drift-guard snapshot update'\"\n echo \" Or use 'git commit --no-verify' to bypass.\"\n exit 1\nfi\n`;\n\n if (!fs.existsSync(hooksDir)) {\n fs.mkdirSync(hooksDir, { recursive: true });\n }\n\n if (fs.existsSync(hookFile)) {\n const existing = fs.readFileSync(hookFile, 'utf-8');\n if (existing.includes('drift-guard')) {\n console.log(chalk.yellow('โ drift-guard hook already installed'));\n return;\n }\n // Append to existing hook\n fs.appendFileSync(hookFile, `\\n${hookScript}`);\n console.log(chalk.green('โ Appended drift-guard to existing pre-commit hook'));\n } else {\n fs.writeFileSync(hookFile, hookScript);\n // Make executable on Unix\n try {\n fs.chmodSync(hookFile, 0o755);\n } catch {\n // Windows may not support chmod, skip\n }\n console.log(chalk.green('โ Installed drift-guard pre-commit hook'));\n }\n\n console.log(chalk.dim(` Threshold: ${threshold}%`));\n console.log(chalk.dim(' Bypass: git commit --no-verify'));\n}\n\n/**\n * Uninstall the pre-commit hook\n */\nexport async function hookUninstallCommand(): Promise<void> {\n const cwd = process.cwd();\n\n // Check husky\n const huskyHook = path.join(cwd, '.husky', 'pre-commit');\n if (fs.existsSync(huskyHook)) {\n const content = fs.readFileSync(huskyHook, 'utf-8');\n if (content.includes('drift-guard')) {\n const cleaned = content.replace(/\\n?npx drift-guard.*\\n?/g, '\\n');\n fs.writeFileSync(huskyHook, cleaned);\n console.log(chalk.green('โ Removed drift-guard from .husky/pre-commit'));\n return;\n }\n }\n\n // Check .git/hooks\n const gitHook = path.join(cwd, '.git', 'hooks', 'pre-commit');\n if (fs.existsSync(gitHook)) {\n const content = fs.readFileSync(gitHook, 'utf-8');\n if (content.includes('drift-guard')) {\n // If the entire file is our hook, remove it\n if (content.includes('# drift-guard pre-commit hook') && !content.includes('\\n#!/usr/bin/env sh\\n')) {\n fs.unlinkSync(gitHook);\n console.log(chalk.green('โ Removed drift-guard pre-commit hook'));\n } else {\n // Remove just our part\n const cleaned = content.replace(/# drift-guard pre-commit hook[\\s\\S]*?fi\\n?/g, '');\n fs.writeFileSync(gitHook, cleaned);\n console.log(chalk.green('โ Removed drift-guard from pre-commit hook'));\n }\n return;\n }\n }\n\n console.log(chalk.yellow('โ No drift-guard hook found to uninstall'));\n}\n","import { Command } from 'commander';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport fg from 'fast-glob';\nimport { loadSnapshot, loadConfig } from '../core/snapshot.js';\nimport { detectDrift } from '../core/drift.js';\nimport {\n syncToStitch,\n syncFromStitch,\n applySyncChanges,\n} from '../core/sync.js';\nimport { parseCss, extractCssVariables } from '../parsers/css-parser.js';\nimport { parseHtml, extractStyleBlocks, extractTailwindConfig } from '../parsers/html-parser.js';\nimport type { DesignToken, SyncDirection } from '../types/index.js';\n\nexport const syncCommand = new Command('sync')\n .description('Synchronize design tokens between Stitch and your codebase')\n .requiredOption(\n '-d, --direction <direction>',\n 'Sync direction: to-stitch (push code changes to Stitch) or to-code (pull Stitch changes)',\n )\n .option(\n '--stitch-html <path>',\n 'Path to Stitch HTML file (for to-code direction)',\n )\n .option(\n '--stitch-project <id>',\n 'Stitch project ID (for to-stitch direction)',\n )\n .option(\n '--stitch-screen <id>',\n 'Stitch screen ID (for to-stitch direction)',\n )\n .option('--apply', 'Auto-apply changes: full HTML replacement + CSS patching (to-code only)', false)\n .option('--target <path>', 'Target local HTML file to replace with Stitch version (to-code --apply)')\n .option('--dry-run', 'Preview changes without applying', false)\n .option('--json', 'Output as JSON', false)\n .action(async (options) => {\n const projectRoot = process.cwd();\n const direction = options.direction as SyncDirection;\n\n if (direction !== 'to-stitch' && direction !== 'to-code') {\n console.error(\n 'โ Invalid direction. Use \"to-stitch\" or \"to-code\".',\n );\n process.exit(1);\n }\n\n if (direction === 'to-stitch') {\n await handleToStitch(projectRoot, options);\n } else {\n await handleToCode(projectRoot, options);\n }\n });\n\n/**\n * Handle to-stitch direction:\n * Compare current code against snapshot โ generate Stitch edit prompt\n */\nasync function handleToStitch(\n projectRoot: string,\n options: { dryRun: boolean; json: boolean; stitchProject?: string; stitchScreen?: string },\n): Promise<void> {\n const snapshot = loadSnapshot(projectRoot);\n if (!snapshot) {\n console.error('โ No snapshot found. Run \"drift-guard init\" first.');\n process.exit(1);\n }\n\n // Detect drift (code vs snapshot)\n const report = await detectDrift(projectRoot, snapshot, 0);\n\n if (report.items.length === 0) {\n console.log('โ
No changes detected. Stitch and code are in sync!');\n return;\n }\n\n const result = syncToStitch(report.items);\n\n if (options.json) {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n // Pretty output\n console.log('');\n console.log('๐ drift-guard sync โ to-stitch');\n console.log(` ${result.changes.length} change(s) detected\\n`);\n\n for (const change of result.changes) {\n const icon =\n change.action === 'update' ? 'โ๏ธ' :\n change.action === 'add' ? 'โ' : '๐๏ธ';\n console.log(\n ` ${icon} ${change.property}: ${change.fromValue || '(none)'} โ ${change.toValue || '(removed)'}`,\n );\n }\n\n console.log('');\n console.log('โ'.repeat(60));\n console.log('๐ Stitch edit_screens prompt:');\n console.log('โ'.repeat(60));\n console.log('');\n console.log(result.prompt);\n console.log('');\n console.log('โ'.repeat(60));\n\n const projectId = options.stitchProject;\n const screenId = options.stitchScreen;\n\n if (projectId && screenId) {\n console.log('');\n console.log('๐ก To apply these changes in Stitch, run:');\n console.log('');\n console.log(` edit_screens({`);\n console.log(` projectId: \"${projectId}\",`);\n console.log(` selectedScreenIds: [\"${screenId}\"],`);\n console.log(` prompt: \"<the prompt above>\"`);\n console.log(` })`);\n } else {\n console.log('');\n console.log(\n '๐ก Copy the prompt above and use it with Stitch MCP edit_screens',\n );\n console.log(\n ' or pass --stitch-project and --stitch-screen for a ready-to-use call.',\n );\n }\n}\n\n/**\n * Handle to-code direction:\n * Compare Stitch HTML against snapshot โ generate CSS patch โ optionally apply.\n *\n * With --apply: Stitch HTML is the SOURCE OF TRUTH.\n * 1. Replace the local Stitch HTML file entirely (fixes text/layout/content diffs)\n * 2. Patch design tokens in other CSS files\n * 3. Update snapshot\n * 4. Verify 0% drift\n */\nasync function handleToCode(\n projectRoot: string,\n options: { dryRun: boolean; json: boolean; apply: boolean; stitchHtml?: string; target?: string },\n): Promise<void> {\n const snapshot = loadSnapshot(projectRoot);\n if (!snapshot) {\n console.error('โ No snapshot found. Run \"drift-guard init\" first.');\n process.exit(1);\n }\n\n // Get Stitch HTML path (new/downloaded version)\n const config = loadConfig(projectRoot);\n const stitchHtmlPath =\n options.stitchHtml ?? config.stitch?.htmlPath;\n\n if (!stitchHtmlPath) {\n console.error(\n 'โ No Stitch HTML file specified.',\n );\n console.error(\n ' Use --stitch-html <path> or set stitch.htmlPath in .design-guard/config.json',\n );\n process.exit(1);\n }\n\n const absPath = path.resolve(projectRoot, stitchHtmlPath);\n if (!fs.existsSync(absPath)) {\n console.error(`โ Stitch HTML file not found: ${absPath}`);\n process.exit(1);\n }\n\n // Parse Stitch HTML for tokens\n const htmlContent = fs.readFileSync(absPath, 'utf-8');\n const stitchTokens: DesignToken[] = [];\n\n const htmlTokens = parseHtml(htmlContent, stitchHtmlPath);\n stitchTokens.push(...htmlTokens);\n\n const styleBlocks = extractStyleBlocks(htmlContent);\n for (const block of styleBlocks) {\n stitchTokens.push(...parseCss(block, stitchHtmlPath));\n stitchTokens.push(...extractCssVariables(block, stitchHtmlPath));\n }\n\n const twTokens = extractTailwindConfig(htmlContent, stitchHtmlPath);\n stitchTokens.push(...twTokens);\n\n // Compare Stitch tokens against snapshot\n const result = syncFromStitch(stitchTokens, snapshot.tokens);\n\n if (options.json) {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n // === FULL SYNC (--apply): Stitch is source of truth ===\n if (options.apply && !options.dryRun) {\n console.log('');\n console.log('๐ drift-guard sync โ to-code (FULL SYNC)');\n console.log(' Stitch HTML is the source of truth.\\n');\n\n // Step 1: Find local Stitch HTML files to replace\n const targetPath = options.target;\n const localStitchFiles = await findLocalStitchHtml(projectRoot, absPath, targetPath);\n let htmlReplaced = false;\n\n if (localStitchFiles.length > 0) {\n console.log('๐ Step 1: Full HTML replacement');\n for (const localFile of localStitchFiles) {\n const localAbsPath = path.resolve(projectRoot, localFile);\n const localContent = fs.readFileSync(localAbsPath, 'utf-8');\n\n if (localContent !== htmlContent) {\n fs.writeFileSync(localAbsPath, htmlContent, 'utf-8');\n console.log(` โ
Replaced: ${localFile} (Stitch โ local)`);\n htmlReplaced = true;\n } else {\n console.log(` โน๏ธ Already identical: ${localFile}`);\n }\n }\n } else {\n console.log('๐ Step 1: No local Stitch HTML found to replace.');\n console.log(' ๐ก Use --target <path> to specify the target file.');\n }\n\n // Step 2: Patch design tokens in CSS files\n if (result.changes.length > 0) {\n console.log(`\\n๐ Step 2: Patching ${result.changes.length} design token(s) in CSS files`);\n for (const change of result.changes) {\n const icon =\n change.action === 'update' ? 'โ๏ธ' :\n change.action === 'add' ? 'โ' : '๐๏ธ';\n console.log(\n ` ${icon} ${change.property}: ${change.fromValue || '(none)'} โ ${change.toValue || '(removed)'}`,\n );\n }\n\n const cssFileMap = await loadProjectCssFiles(projectRoot, config);\n const { modifiedFiles, appliedCount } = applySyncChanges(result.changes, cssFileMap);\n\n if (appliedCount > 0) {\n for (const [file, content] of modifiedFiles) {\n const fullPath = path.resolve(projectRoot, file);\n fs.writeFileSync(fullPath, content, 'utf-8');\n console.log(` โ
Patched: ${file}`);\n }\n }\n } else {\n console.log('\\n๐ Step 2: No design token changes โ tokens already match.');\n }\n\n // Step 3: Update snapshot to reflect new state\n if (htmlReplaced || result.changes.length > 0) {\n console.log('\\n๐ธ Step 3: Updating snapshot...');\n\n const { execSync } = await import('node:child_process');\n try {\n execSync(\n `node \"${path.resolve(projectRoot, '..', 'drift-guard', 'dist', 'cli', 'index.js')}\" snapshot update`,\n { cwd: projectRoot, stdio: 'pipe' },\n );\n } catch {\n // Try the global command\n try {\n execSync('npx drift-guard snapshot update', {\n cwd: projectRoot,\n stdio: 'pipe',\n });\n } catch {\n console.log(' โ ๏ธ Could not auto-update snapshot. Run: drift-guard snapshot update');\n }\n }\n console.log(' โ
Snapshot updated.');\n }\n\n // Step 4: Verify full sync\n console.log('\\n๐ Step 4: Verifying full sync...');\n\n // Compare the Stitch source HTML with the local file\n if (localStitchFiles.length > 0) {\n let allMatch = true;\n for (const localFile of localStitchFiles) {\n const localAbsPath = path.resolve(projectRoot, localFile);\n const localContent = fs.readFileSync(localAbsPath, 'utf-8');\n if (localContent === htmlContent) {\n console.log(` โ
${localFile} โ 100% identical to Stitch`);\n } else {\n console.log(` โ ${localFile} โ content differs!`);\n allMatch = false;\n }\n }\n if (allMatch) {\n console.log('\\n ๐ FULL SYNC VERIFIED โ Stitch and code are 100% identical!');\n }\n }\n } else if (result.changes.length === 0) {\n console.log('โ
Stitch and code design tokens are already in sync!');\n console.log(' ๐ก Use --apply for full HTML content sync (text, layout, structure).');\n } else {\n // Show token diff and patch\n console.log('');\n console.log('๐ drift-guard sync โ to-code');\n console.log(` ${result.changes.length} design token change(s) from Stitch\\n`);\n\n for (const change of result.changes) {\n const icon =\n change.action === 'update' ? 'โ๏ธ' :\n change.action === 'add' ? 'โ' : '๐๏ธ';\n console.log(\n ` ${icon} ${change.property}: ${change.fromValue || '(none)'} โ ${change.toValue || '(removed)'}`,\n );\n }\n\n if (result.patchFile) {\n console.log('');\n console.log('โ'.repeat(60));\n console.log('๐ CSS patch to apply:');\n console.log('โ'.repeat(60));\n console.log('');\n console.log(result.patchFile);\n console.log('');\n console.log('โ'.repeat(60));\n\n if (!options.dryRun) {\n const patchPath = path.join(\n projectRoot,\n '.design-guard',\n 'sync-patch.css',\n );\n fs.writeFileSync(patchPath, result.patchFile, 'utf-8');\n console.log(`\\n๐พ Patch saved to: ${patchPath}`);\n console.log(' Use --apply for full HTML content + token sync.');\n } else {\n console.log('\\n๐ Dry run โ no files written.');\n }\n }\n }\n}\n\n/**\n * Find local Stitch HTML files that should be replaced.\n * Searches for stitch-design.html or files matching --target.\n */\nasync function findLocalStitchHtml(\n projectRoot: string,\n sourceAbsPath: string,\n targetPath?: string,\n): Promise<string[]> {\n if (targetPath) {\n return [targetPath];\n }\n\n // Search for stitch-design.html files in the project\n const stitchFiles = await fg(\n ['**/stitch-design.html', '**/stitch*.html'],\n {\n cwd: projectRoot,\n ignore: ['node_modules/**', 'dist/**', 'build/**'],\n absolute: false,\n },\n );\n\n // Exclude the source file itself\n const sourceRelative = path.relative(projectRoot, sourceAbsPath);\n return stitchFiles.filter(f => f !== sourceRelative);\n}\n\n/**\n * Load all CSS files from the project into a map\n */\nasync function loadProjectCssFiles(\n projectRoot: string,\n config: { cssFiles: string[]; ignore: string[] },\n): Promise<Map<string, string>> {\n const cssFileMap = new Map<string, string>();\n\n for (const pattern of config.cssFiles) {\n const matches = await fg(pattern, {\n cwd: projectRoot,\n ignore: config.ignore,\n absolute: false,\n });\n\n for (const file of matches) {\n const absPath = path.resolve(projectRoot, file);\n if (fs.existsSync(absPath)) {\n cssFileMap.set(file, fs.readFileSync(absPath, 'utf-8'));\n }\n }\n }\n\n // Also include HTML files that might have Tailwind config\n const htmlPatterns = ['**/*.html'];\n const htmlIgnore = ['node_modules/**', 'dist/**', 'build/**', '.next/**'];\n const htmlMatches = await fg(htmlPatterns, {\n cwd: projectRoot,\n ignore: htmlIgnore,\n absolute: false,\n });\n\n for (const file of htmlMatches) {\n const absPath = path.resolve(projectRoot, file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YAAY,uDAAuD,EACnE,OAAO,wBAAwB,2CAA2C,IAAI,EAC9E,OAAO,kBAAkB;AAE5B,KACG,QAAQ,WAAW,EACnB,YAAY,wCAAwC,EACpD,OAAO,oBAAoB;AAE9B,QAAQ,WAAW,WAAW;AAE9B,QAAQ,MAAM;","names":["Command","chalk","chalk","chalk","chalk","chalk","chalk","chalk","chalk","hookFile","path","fs","path","fs","Command","chalk"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/init.ts","../../src/cli/check.ts","../../src/cli/rules.ts","../../src/cli/snapshot-cmd.ts","../../src/cli/hook.ts","../../src/cli/sync.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\nimport { initCommand } from './init.js';\nimport { checkCommand } from './check.js';\nimport { rulesCommand } from './rules.js';\nimport { snapshotCommand } from './snapshot-cmd.js';\nimport { hookInstallCommand, hookUninstallCommand } from './hook.js';\nimport { syncCommand } from './sync.js';\n\n// Read version from package.json dynamically\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst pkg = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf-8'));\n\nconst program = new Command();\n\nprogram\n .name('drift-guard')\n .description(\n chalk.bold('๐ก๏ธ drift-guard') +\n ' โ Protect your UI from AI coding agents\\' design drift.\\n\\n' +\n ' Detect and prevent design token changes during AI-assisted development.\\n' +\n ' Lock your colors, fonts, spacing, and layout before AI agents touch your code.'\n )\n .version(pkg.version);\n\nprogram\n .command('init')\n .description('Initialize drift-guard: snapshot + AI rules + git hook (all-in-one)')\n .option('--from <path>', 'Create snapshot from a Stitch/HTML file')\n .option('--threshold <number>', 'Set default drift threshold percentage', '10')\n .option('--skip-rules', 'Skip auto-generating AGENTS.md rules file')\n .option('--skip-hook', 'Skip auto-installing pre-commit git hook')\n .action(initCommand);\n\nprogram\n .command('check')\n .description('Check for design drift against the saved snapshot')\n .option('--threshold <number>', 'Override drift threshold percentage')\n .option('--output <format>', 'Output format: text or json', 'text')\n .option('--ci', 'CI mode: exit with code 1 on drift exceeding threshold')\n .action(checkCommand);\n\nprogram\n .command('rules')\n .description('Generate AI agent rule files from the design snapshot')\n .option('--format <type>', 'Rule format: cursorrules, claude-md, agents-md, copilot, clinerules, all', 'all')\n .option('--append', 'Append to existing rule files instead of overwriting')\n .action(rulesCommand);\n\nprogram\n .command('snapshot')\n .description('Manage design snapshots')\n .command('update')\n .description('Update the snapshot to reflect current design (after intentional changes)')\n .option('--from <path>', 'Update from a specific Stitch/HTML file')\n .action(snapshotCommand);\n\nconst hook = program\n .command('hook')\n .description('Manage pre-commit hook for automatic drift checking');\n\nhook\n .command('install')\n .description('Install a pre-commit hook that runs drift-guard check')\n .option('--threshold <number>', 'Drift threshold percentage for the hook', '10')\n .action(hookInstallCommand);\n\nhook\n .command('uninstall')\n .description('Remove the drift-guard pre-commit hook')\n .action(hookUninstallCommand);\n\nprogram.addCommand(syncCommand);\n\nprogram.parse();\n\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport chalk from 'chalk';\nimport { createSnapshot, saveSnapshot, saveConfig } from '../core/snapshot.js';\nimport { generateRules, saveRules } from '../core/rules-generator.js';\nimport { DEFAULT_CONFIG } from '../types/index.js';\n\ninterface InitOptions {\n from?: string;\n threshold?: string;\n skipRules?: boolean;\n skipHook?: boolean;\n}\n\nexport async function initCommand(options: InitOptions): Promise<void> {\n const projectRoot = process.cwd();\n const threshold = parseInt(options.threshold ?? '10', 10);\n\n console.log(chalk.bold('\\n๐ก๏ธ drift-guard init\\n'));\n console.log(chalk.dim('Scanning project for design tokens...\\n'));\n\n // Save config\n const config = { ...DEFAULT_CONFIG, threshold };\n saveConfig(projectRoot, config);\n\n // Create snapshot\n const snapshot = await createSnapshot(projectRoot, options.from);\n\n if (snapshot.tokens.length === 0) {\n console.log(chalk.yellow('โ ๏ธ No design tokens found.'));\n console.log(chalk.dim(' Make sure you have CSS files or use --from <stitch.html>'));\n console.log(chalk.dim(' Supported patterns: src/**/*.css, app/**/*.css, styles/**/*.css\\n'));\n return;\n }\n\n // Save snapshot\n const snapshotPath = saveSnapshot(projectRoot, snapshot);\n\n // Report\n console.log(chalk.green('โ
Design snapshot created!\\n'));\n console.log(chalk.dim(' Snapshot: ') + chalk.white(snapshotPath));\n console.log(chalk.dim(' Files scanned: ') + chalk.white(snapshot.sourceFiles.length.toString()));\n console.log(chalk.dim(' Tokens locked: ') + chalk.white(snapshot.tokens.length.toString()));\n console.log(chalk.dim(' Threshold: ') + chalk.white(`${threshold}%`));\n console.log();\n\n // Token summary\n console.log(chalk.bold(' Token Summary:'));\n const categories = ['color', 'font', 'spacing', 'shadow', 'radius', 'layout'] as const;\n for (const cat of categories) {\n const count = snapshot.summary[cat];\n if (count > 0) {\n const icon = { color: '๐จ', font: '๐', spacing: '๐', shadow: '๐ซ๏ธ', radius: 'โญ', layout: '๐' }[cat];\n console.log(chalk.dim(` ${icon} ${cat}: `) + chalk.white(count.toString()));\n }\n }\n\n // Structure fingerprint summary (v0.2.0+)\n if (snapshot.structure) {\n const s = snapshot.structure;\n const tagList = Object.entries(s.semanticTags)\n .filter(([, count]) => count > 0)\n .map(([tag, count]) => `${tag}(${count})`)\n .join(', ');\n console.log();\n console.log(chalk.bold(' Structure Fingerprint:'));\n console.log(chalk.dim(' ๐๏ธ semantic tags: ') + chalk.white(tagList));\n console.log(chalk.dim(' ๐๏ธ max depth: ') + chalk.white(s.maxDepth.toString()));\n console.log(chalk.dim(' ๐๏ธ layout hash: ') + chalk.white(s.layoutHash));\n }\n\n console.log();\n\n // โโโ Auto-generate AI agent rules (AGENTS.md) โโโโโโโโโโโโโโโ\n if (!options.skipRules) {\n try {\n const content = generateRules(snapshot, 'agents-md');\n const rulesPath = saveRules(projectRoot, 'agents-md', content, false);\n console.log(chalk.green('โ
AI agent rules generated: ') + chalk.white(rulesPath));\n } catch (error) {\n console.log(chalk.yellow('โ ๏ธ Could not generate rules: ') + chalk.dim((error as Error).message));\n }\n } else {\n console.log(chalk.dim(' โญ Skipped rules generation (--skip-rules)'));\n }\n\n // โโโ Auto-install git pre-commit hook โโโโโโโโโโโโโโโโโโโโโโโ\n if (!options.skipHook) {\n const hasGit = fs.existsSync(path.join(projectRoot, '.git'));\n if (hasGit) {\n try {\n installHookSilent(projectRoot, threshold.toString());\n console.log(chalk.green('โ
Pre-commit hook installed: ') + chalk.dim('drift-guard check runs before every commit'));\n } catch (error) {\n console.log(chalk.yellow('โ ๏ธ Could not install hook: ') + chalk.dim((error as Error).message));\n }\n } else {\n console.log(chalk.dim(' โญ No .git directory found โ skipping hook install'));\n }\n } else {\n console.log(chalk.dim(' โญ Skipped hook installation (--skip-hook)'));\n }\n\n console.log();\n console.log(chalk.green.bold(' ๐ก๏ธ Protection active!'));\n console.log(chalk.dim(' Run ') + chalk.cyan('npx drift-guard check') + chalk.dim(' anytime to verify design integrity.'));\n if (!options.skipRules) {\n console.log(chalk.dim(' Run ') + chalk.cyan('npx drift-guard rules --format all') + chalk.dim(' for additional AI tool formats.'));\n }\n console.log();\n}\n\n/**\n * Install pre-commit hook without verbose output (used by init auto-setup)\n */\nfunction installHookSilent(projectRoot: string, threshold: string): void {\n const hasHusky = fs.existsSync(path.join(projectRoot, '.husky'));\n const hookCommand = `npx drift-guard check --threshold ${threshold} --ci`;\n\n if (hasHusky) {\n const hookFile = path.join(projectRoot, '.husky', 'pre-commit');\n if (fs.existsSync(hookFile)) {\n const existing = fs.readFileSync(hookFile, 'utf-8');\n if (existing.includes('drift-guard')) return; // already installed\n fs.appendFileSync(hookFile, `\\n${hookCommand}\\n`);\n } else {\n fs.writeFileSync(hookFile, `#!/usr/bin/env sh\\n. \"$(dirname -- \"$0\")/_/husky.sh\"\\n\\n${hookCommand}\\n`);\n }\n return;\n }\n\n // Direct .git/hooks installation\n const hooksDir = path.join(projectRoot, '.git', 'hooks');\n const hookFile = path.join(hooksDir, 'pre-commit');\n const hookScript = `#!/usr/bin/env sh\n# drift-guard pre-commit hook\n# Checks for design token drift before commits\n# Bypass: git commit --no-verify\n\nnpx drift-guard check --threshold ${threshold} --ci\n\nif [ $? -ne 0 ]; then\n echo \"\"\n echo \"\\\\033[31mโ Design drift detected! Commit blocked.\\\\033[0m\"\n echo \" Run 'npx drift-guard check' for details.\"\n echo \" If changes are intentional, run 'npx drift-guard snapshot update'\"\n echo \" Or use 'git commit --no-verify' to bypass.\"\n exit 1\nfi\n`;\n\n if (!fs.existsSync(hooksDir)) {\n fs.mkdirSync(hooksDir, { recursive: true });\n }\n\n if (fs.existsSync(hookFile)) {\n const existing = fs.readFileSync(hookFile, 'utf-8');\n if (existing.includes('drift-guard')) return; // already installed\n fs.appendFileSync(hookFile, `\\n${hookScript}`);\n } else {\n fs.writeFileSync(hookFile, hookScript);\n try {\n fs.chmodSync(hookFile, 0o755);\n } catch {\n // Windows may not support chmod\n }\n }\n}\n","import chalk from 'chalk';\nimport { loadSnapshot, loadConfig } from '../core/snapshot.js';\nimport { detectDrift } from '../core/drift.js';\nimport type { DriftReport, DriftItem } from '../types/index.js';\n\ninterface CheckOptions {\n threshold?: string;\n output?: string;\n ci?: boolean;\n}\n\nexport async function checkCommand(options: CheckOptions): Promise<void> {\n const projectRoot = process.cwd();\n\n // Load snapshot\n const snapshot = loadSnapshot(projectRoot);\n if (!snapshot) {\n console.log(chalk.red('\\nโ No snapshot found.'));\n console.log(chalk.dim(' Run ') + chalk.cyan('npx drift-guard init') + chalk.dim(' first.\\n'));\n process.exit(1);\n }\n\n const config = loadConfig(projectRoot);\n const threshold = options.threshold\n ? parseInt(options.threshold, 10)\n : config.threshold;\n\n console.log(chalk.bold('\\n๐ก๏ธ drift-guard check\\n'));\n\n // Snapshot age warning\n const snapshotAge = Date.now() - new Date(snapshot.createdAt).getTime();\n const ageDays = Math.floor(snapshotAge / (1000 * 60 * 60 * 24));\n if (ageDays >= 7) {\n const ageStr = ageDays >= 30 ? `${Math.floor(ageDays / 30)} month(s)` : `${ageDays} days`;\n console.log(chalk.yellow(`โ ๏ธ Snapshot is ${ageStr} old (created ${snapshot.createdAt.split('T')[0]}).`));\n console.log(chalk.yellow(' If your design has changed, run: ') + chalk.cyan('drift-guard init --from <latest.html>\\n'));\n }\n\n console.log(chalk.dim(`Comparing against snapshot from ${snapshot.createdAt}...\\n`));\n\n // Detect drift\n const report = await detectDrift(projectRoot, snapshot, threshold);\n\n if (options.output === 'json') {\n console.log(JSON.stringify(report, null, 2));\n } else {\n printTextReport(report);\n }\n\n // Exit code for CI\n if (!report.passed && (options.ci || process.env['CI'])) {\n process.exit(1);\n }\n\n if (!report.passed) {\n process.exitCode = 1;\n }\n}\n\nfunction printTextReport(report: DriftReport): void {\n // Score display\n const scoreColor = report.passed ? chalk.green : chalk.red;\n const icon = report.passed ? 'โ
' : '๐จ';\n\n console.log(`${icon} ${chalk.bold('Drift Score:')} ${scoreColor(`${report.driftScore}%`)} (threshold: ${report.threshold}%)`);\n console.log(chalk.dim(` ${report.changedTokens} of ${report.totalTokens} tokens changed\\n`));\n\n if (report.items.length === 0 && !(report.structureDrift?.changed)) {\n console.log(chalk.green(' No design drift detected. Your design is intact! ๐\\n'));\n return;\n }\n\n if (report.items.length > 0) {\n // Category breakdown\n console.log(chalk.bold(' Category Breakdown:'));\n const categories = ['color', 'font', 'spacing', 'shadow', 'radius', 'layout'] as const;\n for (const cat of categories) {\n const summary = report.categorySummary[cat];\n if (summary.total === 0) continue;\n\n const catIcon = { color: '๐จ', font: '๐', spacing: '๐', shadow: '๐ซ๏ธ', radius: 'โญ', layout: '๐' }[cat];\n const catColor = summary.changed > 0 ? chalk.red : chalk.green;\n console.log(` ${catIcon} ${cat}: ${catColor(`${summary.changed}/${summary.total}`)} (${summary.driftPercent}%)`);\n }\n console.log();\n\n // Detailed changes (max 20)\n const itemsToShow = report.items.slice(0, 20);\n if (itemsToShow.length > 0) {\n console.log(chalk.bold(' Changes:'));\n for (const item of itemsToShow) {\n printDriftItem(item);\n }\n\n if (report.items.length > 20) {\n console.log(chalk.dim(` ... and ${report.items.length - 20} more changes\\n`));\n }\n }\n\n console.log();\n }\n\n // Structure drift (v0.2.0+)\n if (report.structureDrift) {\n if (report.structureDrift.changed) {\n console.log(chalk.bold(' ๐๏ธ Structure Drift:'));\n for (const detail of report.structureDrift.details) {\n console.log(chalk.yellow(` โ ๏ธ ${detail}`));\n }\n console.log();\n } else {\n console.log(chalk.green(' ๐๏ธ DOM structure: No changes detected โ
\\n'));\n }\n }\n\n if (!report.passed) {\n console.log(chalk.yellow(' ๐ก To accept these changes, run:'));\n console.log(chalk.cyan(' npx drift-guard snapshot update\\n'));\n }\n}\n\nfunction printDriftItem(item: DriftItem): void {\n const { original, current, changeType } = item;\n\n switch (changeType) {\n case 'modified':\n console.log(\n chalk.yellow(' ~') +\n chalk.dim(` ${original.file} `) +\n chalk.white(`${original.property}: `) +\n chalk.red(original.value) +\n chalk.dim(' โ ') +\n chalk.green(current?.value ?? 'removed')\n );\n break;\n case 'deleted':\n console.log(\n chalk.red(' -') +\n chalk.dim(` ${original.file} `) +\n chalk.white(`${original.property}: `) +\n chalk.red(original.value) +\n chalk.dim(' [deleted]')\n );\n break;\n case 'added':\n console.log(\n chalk.green(' +') +\n chalk.dim(` ${original.file} `) +\n chalk.white(`${original.property}: `) +\n chalk.green(original.value)\n );\n break;\n }\n}\n","import chalk from 'chalk';\nimport { loadSnapshot } from '../core/snapshot.js';\nimport { generateRules, saveRules } from '../core/rules-generator.js';\nimport type { RuleFormat } from '../types/index.js';\n\ninterface RulesOptions {\n format?: string;\n append?: boolean;\n}\n\nconst ALL_FORMATS: RuleFormat[] = ['cursorrules', 'claude-md', 'agents-md', 'copilot', 'clinerules'];\n\nexport async function rulesCommand(options: RulesOptions): Promise<void> {\n const projectRoot = process.cwd();\n\n const snapshot = loadSnapshot(projectRoot);\n if (!snapshot) {\n console.log(chalk.red('\\nโ No snapshot found.'));\n console.log(chalk.dim(' Run ') + chalk.cyan('npx drift-guard init') + chalk.dim(' first.\\n'));\n process.exit(1);\n }\n\n const formats: RuleFormat[] = options.format === 'all' || !options.format\n ? ALL_FORMATS\n : [options.format as RuleFormat];\n\n console.log(chalk.bold('\\n๐ก๏ธ drift-guard rules\\n'));\n console.log(chalk.dim(`Generating AI protection rules from ${snapshot.tokens.length} locked tokens...\\n`));\n\n for (const format of formats) {\n try {\n const content = generateRules(snapshot, format);\n const filePath = saveRules(projectRoot, format, content, options.append ?? false);\n console.log(chalk.green(' โ
') + chalk.white(filePath));\n } catch (error) {\n console.log(chalk.red(' โ ') + chalk.white(format) + chalk.dim(`: ${(error as Error).message}`));\n }\n }\n\n console.log();\n console.log(chalk.dim('Your AI coding agents will now protect these design tokens.'));\n console.log(chalk.dim('Supported tools: Cursor, Claude Code, Codex, GitHub Copilot, Cline\\n'));\n}\n","import chalk from 'chalk';\nimport { createSnapshot, saveSnapshot } from '../core/snapshot.js';\n\ninterface SnapshotOptions {\n from?: string;\n}\n\nexport async function snapshotCommand(options: SnapshotOptions): Promise<void> {\n const projectRoot = process.cwd();\n\n console.log(chalk.bold('\\n๐ก๏ธ drift-guard snapshot update\\n'));\n console.log(chalk.dim('Re-scanning project and updating snapshot...\\n'));\n\n const snapshot = await createSnapshot(projectRoot, options.from);\n\n if (snapshot.tokens.length === 0) {\n console.log(chalk.yellow('โ ๏ธ No design tokens found.\\n'));\n return;\n }\n\n const snapshotPath = saveSnapshot(projectRoot, snapshot);\n\n console.log(chalk.green('โ
Snapshot updated!\\n'));\n console.log(chalk.dim(' File: ') + chalk.white(snapshotPath));\n console.log(chalk.dim(' Tokens: ') + chalk.white(snapshot.tokens.length.toString()));\n console.log(chalk.dim(' Updated: ') + chalk.white(snapshot.createdAt));\n console.log();\n console.log(chalk.dim('๐ก Remember to regenerate rules: ') + chalk.cyan('npx drift-guard rules\\n'));\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { execSync } from 'node:child_process';\nimport chalk from 'chalk';\n\n/**\n * Install a pre-commit hook that runs drift-guard check\n */\nexport async function hookInstallCommand(options: { threshold?: string }): Promise<void> {\n const cwd = process.cwd();\n const threshold = options.threshold ?? '10';\n\n // Check if git repo\n if (!fs.existsSync(path.join(cwd, '.git'))) {\n console.error(chalk.red('โ Not a git repository. Run this from a git project root.'));\n process.exit(1);\n }\n\n // Detect hook manager\n const hasHusky = fs.existsSync(path.join(cwd, '.husky'));\n const hasLefthook = fs.existsSync(path.join(cwd, 'lefthook.yml')) ||\n fs.existsSync(path.join(cwd, '.lefthook.yml'));\n\n if (hasHusky) {\n // Add to existing husky setup\n const hookFile = path.join(cwd, '.husky', 'pre-commit');\n const hookCommand = `npx drift-guard check --threshold ${threshold} --ci`;\n\n if (fs.existsSync(hookFile)) {\n const existing = fs.readFileSync(hookFile, 'utf-8');\n if (existing.includes('drift-guard')) {\n console.log(chalk.yellow('โ drift-guard hook already exists in .husky/pre-commit'));\n return;\n }\n fs.appendFileSync(hookFile, `\\n${hookCommand}\\n`);\n } else {\n fs.writeFileSync(hookFile, `#!/usr/bin/env sh\\n. \"$(dirname -- \"$0\")/_/husky.sh\"\\n\\n${hookCommand}\\n`);\n }\n\n console.log(chalk.green('โ Added drift-guard check to .husky/pre-commit'));\n return;\n }\n\n if (hasLefthook) {\n console.log(chalk.yellow('โ lefthook detected. Add this to your lefthook.yml:'));\n console.log(chalk.cyan(`\npre-commit:\n commands:\n drift-guard:\n run: npx drift-guard check --threshold ${threshold} --ci\n`));\n return;\n }\n\n // No hook manager โ install via .git/hooks directly\n const hooksDir = path.join(cwd, '.git', 'hooks');\n const hookFile = path.join(hooksDir, 'pre-commit');\n const hookScript = `#!/usr/bin/env sh\n# drift-guard pre-commit hook\n# Checks for design token drift before commits\n# Use --force flag to bypass: git commit --no-verify\n\nnpx drift-guard check --threshold ${threshold} --ci\n\nif [ $? -ne 0 ]; then\n echo \"\"\n echo \"\\\\033[31mโ Design drift detected! Commit blocked.\\\\033[0m\"\n echo \" Run 'npx drift-guard check' for details.\"\n echo \" If changes are intentional, run 'npx drift-guard snapshot update'\"\n echo \" Or use 'git commit --no-verify' to bypass.\"\n exit 1\nfi\n`;\n\n if (!fs.existsSync(hooksDir)) {\n fs.mkdirSync(hooksDir, { recursive: true });\n }\n\n if (fs.existsSync(hookFile)) {\n const existing = fs.readFileSync(hookFile, 'utf-8');\n if (existing.includes('drift-guard')) {\n console.log(chalk.yellow('โ drift-guard hook already installed'));\n return;\n }\n // Append to existing hook\n fs.appendFileSync(hookFile, `\\n${hookScript}`);\n console.log(chalk.green('โ Appended drift-guard to existing pre-commit hook'));\n } else {\n fs.writeFileSync(hookFile, hookScript);\n // Make executable on Unix\n try {\n fs.chmodSync(hookFile, 0o755);\n } catch {\n // Windows may not support chmod, skip\n }\n console.log(chalk.green('โ Installed drift-guard pre-commit hook'));\n }\n\n console.log(chalk.dim(` Threshold: ${threshold}%`));\n console.log(chalk.dim(' Bypass: git commit --no-verify'));\n}\n\n/**\n * Uninstall the pre-commit hook\n */\nexport async function hookUninstallCommand(): Promise<void> {\n const cwd = process.cwd();\n\n // Check husky\n const huskyHook = path.join(cwd, '.husky', 'pre-commit');\n if (fs.existsSync(huskyHook)) {\n const content = fs.readFileSync(huskyHook, 'utf-8');\n if (content.includes('drift-guard')) {\n const cleaned = content.replace(/\\n?npx drift-guard.*\\n?/g, '\\n');\n fs.writeFileSync(huskyHook, cleaned);\n console.log(chalk.green('โ Removed drift-guard from .husky/pre-commit'));\n return;\n }\n }\n\n // Check .git/hooks\n const gitHook = path.join(cwd, '.git', 'hooks', 'pre-commit');\n if (fs.existsSync(gitHook)) {\n const content = fs.readFileSync(gitHook, 'utf-8');\n if (content.includes('drift-guard')) {\n // If the entire file is our hook, remove it\n if (content.includes('# drift-guard pre-commit hook') && !content.includes('\\n#!/usr/bin/env sh\\n')) {\n fs.unlinkSync(gitHook);\n console.log(chalk.green('โ Removed drift-guard pre-commit hook'));\n } else {\n // Remove just our part\n const cleaned = content.replace(/# drift-guard pre-commit hook[\\s\\S]*?fi\\n?/g, '');\n fs.writeFileSync(gitHook, cleaned);\n console.log(chalk.green('โ Removed drift-guard from pre-commit hook'));\n }\n return;\n }\n }\n\n console.log(chalk.yellow('โ No drift-guard hook found to uninstall'));\n}\n","import { Command } from 'commander';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport fg from 'fast-glob';\nimport { loadSnapshot, loadConfig } from '../core/snapshot.js';\nimport { detectDrift } from '../core/drift.js';\nimport {\n syncToStitch,\n syncFromStitch,\n applySyncChanges,\n} from '../core/sync.js';\nimport { parseCss, extractCssVariables } from '../parsers/css-parser.js';\nimport { parseHtml, extractStyleBlocks, extractTailwindConfig } from '../parsers/html-parser.js';\nimport type { DesignToken, SyncDirection } from '../types/index.js';\n\nexport const syncCommand = new Command('sync')\n .description('Synchronize design tokens between Stitch and your codebase')\n .requiredOption(\n '-d, --direction <direction>',\n 'Sync direction: to-stitch (push code changes to Stitch) or to-code (pull Stitch changes)',\n )\n .option(\n '--stitch-html <path>',\n 'Path to Stitch HTML file (for to-code direction)',\n )\n .option(\n '--stitch-project <id>',\n 'Stitch project ID (for to-stitch direction)',\n )\n .option(\n '--stitch-screen <id>',\n 'Stitch screen ID (for to-stitch direction)',\n )\n .option('--apply', 'Auto-apply changes: full HTML replacement + CSS patching (to-code only)', false)\n .option('--target <path>', 'Target local HTML file to replace with Stitch version (to-code --apply)')\n .option('--dry-run', 'Preview changes without applying', false)\n .option('--json', 'Output as JSON', false)\n .action(async (options) => {\n const projectRoot = process.cwd();\n const direction = options.direction as SyncDirection;\n\n if (direction !== 'to-stitch' && direction !== 'to-code') {\n console.error(\n 'โ Invalid direction. Use \"to-stitch\" or \"to-code\".',\n );\n process.exit(1);\n }\n\n if (direction === 'to-stitch') {\n await handleToStitch(projectRoot, options);\n } else {\n await handleToCode(projectRoot, options);\n }\n });\n\n/**\n * Handle to-stitch direction:\n * Compare current code against snapshot โ generate Stitch edit prompt\n */\nasync function handleToStitch(\n projectRoot: string,\n options: { dryRun: boolean; json: boolean; stitchProject?: string; stitchScreen?: string },\n): Promise<void> {\n const snapshot = loadSnapshot(projectRoot);\n if (!snapshot) {\n console.error('โ No snapshot found. Run \"drift-guard init\" first.');\n process.exit(1);\n }\n\n // Detect drift (code vs snapshot)\n const report = await detectDrift(projectRoot, snapshot, 0);\n\n if (report.items.length === 0) {\n console.log('โ
No changes detected. Stitch and code are in sync!');\n return;\n }\n\n const result = syncToStitch(report.items);\n\n if (options.json) {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n // Pretty output\n console.log('');\n console.log('๐ drift-guard sync โ to-stitch');\n console.log(` ${result.changes.length} change(s) detected\\n`);\n\n for (const change of result.changes) {\n const icon =\n change.action === 'update' ? 'โ๏ธ' :\n change.action === 'add' ? 'โ' : '๐๏ธ';\n console.log(\n ` ${icon} ${change.property}: ${change.fromValue || '(none)'} โ ${change.toValue || '(removed)'}`,\n );\n }\n\n console.log('');\n console.log('โ'.repeat(60));\n console.log('๐ Stitch edit_screens prompt:');\n console.log('โ'.repeat(60));\n console.log('');\n console.log(result.prompt);\n console.log('');\n console.log('โ'.repeat(60));\n\n const projectId = options.stitchProject;\n const screenId = options.stitchScreen;\n\n if (projectId && screenId) {\n console.log('');\n console.log('๐ก To apply these changes in Stitch, run:');\n console.log('');\n console.log(` edit_screens({`);\n console.log(` projectId: \"${projectId}\",`);\n console.log(` selectedScreenIds: [\"${screenId}\"],`);\n console.log(` prompt: \"<the prompt above>\"`);\n console.log(` })`);\n } else {\n console.log('');\n console.log(\n '๐ก Copy the prompt above and use it with Stitch MCP edit_screens',\n );\n console.log(\n ' or pass --stitch-project and --stitch-screen for a ready-to-use call.',\n );\n }\n}\n\n/**\n * Handle to-code direction:\n * Compare Stitch HTML against snapshot โ generate CSS patch โ optionally apply.\n *\n * With --apply: Stitch HTML is the SOURCE OF TRUTH.\n * 1. Replace the local Stitch HTML file entirely (fixes text/layout/content diffs)\n * 2. Patch design tokens in other CSS files\n * 3. Update snapshot\n * 4. Verify 0% drift\n */\nasync function handleToCode(\n projectRoot: string,\n options: { dryRun: boolean; json: boolean; apply: boolean; stitchHtml?: string; target?: string },\n): Promise<void> {\n const snapshot = loadSnapshot(projectRoot);\n if (!snapshot) {\n console.error('โ No snapshot found. Run \"drift-guard init\" first.');\n process.exit(1);\n }\n\n // Get Stitch HTML path (new/downloaded version)\n const config = loadConfig(projectRoot);\n const stitchHtmlPath =\n options.stitchHtml ?? config.stitch?.htmlPath;\n\n if (!stitchHtmlPath) {\n console.error(\n 'โ No Stitch HTML file specified.',\n );\n console.error(\n ' Use --stitch-html <path> or set stitch.htmlPath in .design-guard/config.json',\n );\n process.exit(1);\n }\n\n const absPath = path.resolve(projectRoot, stitchHtmlPath);\n if (!fs.existsSync(absPath)) {\n console.error(`โ Stitch HTML file not found: ${absPath}`);\n process.exit(1);\n }\n\n // Parse Stitch HTML for tokens\n const htmlContent = fs.readFileSync(absPath, 'utf-8');\n const stitchTokens: DesignToken[] = [];\n\n const htmlTokens = parseHtml(htmlContent, stitchHtmlPath);\n stitchTokens.push(...htmlTokens);\n\n const styleBlocks = extractStyleBlocks(htmlContent);\n for (const block of styleBlocks) {\n stitchTokens.push(...parseCss(block, stitchHtmlPath));\n stitchTokens.push(...extractCssVariables(block, stitchHtmlPath));\n }\n\n const twTokens = extractTailwindConfig(htmlContent, stitchHtmlPath);\n stitchTokens.push(...twTokens);\n\n // Compare Stitch tokens against snapshot\n const result = syncFromStitch(stitchTokens, snapshot.tokens);\n\n if (options.json) {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n // === FULL SYNC (--apply): Stitch is source of truth ===\n if (options.apply && !options.dryRun) {\n console.log('');\n console.log('๐ drift-guard sync โ to-code (FULL SYNC)');\n console.log(' Stitch HTML is the source of truth.\\n');\n\n // Step 1: Find local Stitch HTML files to replace\n const targetPath = options.target;\n const localStitchFiles = await findLocalStitchHtml(projectRoot, absPath, targetPath);\n let htmlReplaced = false;\n\n if (localStitchFiles.length > 0) {\n console.log('๐ Step 1: Full HTML replacement');\n for (const localFile of localStitchFiles) {\n const localAbsPath = path.resolve(projectRoot, localFile);\n const localContent = fs.readFileSync(localAbsPath, 'utf-8');\n\n if (localContent !== htmlContent) {\n fs.writeFileSync(localAbsPath, htmlContent, 'utf-8');\n console.log(` โ
Replaced: ${localFile} (Stitch โ local)`);\n htmlReplaced = true;\n } else {\n console.log(` โน๏ธ Already identical: ${localFile}`);\n }\n }\n } else {\n console.log('๐ Step 1: No local Stitch HTML found to replace.');\n console.log(' ๐ก Use --target <path> to specify the target file.');\n }\n\n // Step 2: Patch design tokens in CSS files\n if (result.changes.length > 0) {\n console.log(`\\n๐ Step 2: Patching ${result.changes.length} design token(s) in CSS files`);\n for (const change of result.changes) {\n const icon =\n change.action === 'update' ? 'โ๏ธ' :\n change.action === 'add' ? 'โ' : '๐๏ธ';\n console.log(\n ` ${icon} ${change.property}: ${change.fromValue || '(none)'} โ ${change.toValue || '(removed)'}`,\n );\n }\n\n const cssFileMap = await loadProjectCssFiles(projectRoot, config);\n const { modifiedFiles, appliedCount } = applySyncChanges(result.changes, cssFileMap);\n\n if (appliedCount > 0) {\n for (const [file, content] of modifiedFiles) {\n const fullPath = path.resolve(projectRoot, file);\n fs.writeFileSync(fullPath, content, 'utf-8');\n console.log(` โ
Patched: ${file}`);\n }\n }\n } else {\n console.log('\\n๐ Step 2: No design token changes โ tokens already match.');\n }\n\n // Step 3: Update snapshot to reflect new state\n if (htmlReplaced || result.changes.length > 0) {\n console.log('\\n๐ธ Step 3: Updating snapshot...');\n\n const { execSync } = await import('node:child_process');\n try {\n execSync(\n `node \"${path.resolve(projectRoot, '..', 'drift-guard', 'dist', 'cli', 'index.js')}\" snapshot update`,\n { cwd: projectRoot, stdio: 'pipe' },\n );\n } catch {\n // Try the global command\n try {\n execSync('npx drift-guard snapshot update', {\n cwd: projectRoot,\n stdio: 'pipe',\n });\n } catch {\n console.log(' โ ๏ธ Could not auto-update snapshot. Run: drift-guard snapshot update');\n }\n }\n console.log(' โ
Snapshot updated.');\n }\n\n // Step 4: Verify full sync\n console.log('\\n๐ Step 4: Verifying full sync...');\n\n // Compare the Stitch source HTML with the local file\n if (localStitchFiles.length > 0) {\n let allMatch = true;\n for (const localFile of localStitchFiles) {\n const localAbsPath = path.resolve(projectRoot, localFile);\n const localContent = fs.readFileSync(localAbsPath, 'utf-8');\n if (localContent === htmlContent) {\n console.log(` โ
${localFile} โ 100% identical to Stitch`);\n } else {\n console.log(` โ ${localFile} โ content differs!`);\n allMatch = false;\n }\n }\n if (allMatch) {\n console.log('\\n ๐ FULL SYNC VERIFIED โ Stitch and code are 100% identical!');\n }\n }\n } else if (result.changes.length === 0) {\n console.log('โ
Stitch and code design tokens are already in sync!');\n console.log(' ๐ก Use --apply for full HTML content sync (text, layout, structure).');\n } else {\n // Show token diff and patch\n console.log('');\n console.log('๐ drift-guard sync โ to-code');\n console.log(` ${result.changes.length} design token change(s) from Stitch\\n`);\n\n for (const change of result.changes) {\n const icon =\n change.action === 'update' ? 'โ๏ธ' :\n change.action === 'add' ? 'โ' : '๐๏ธ';\n console.log(\n ` ${icon} ${change.property}: ${change.fromValue || '(none)'} โ ${change.toValue || '(removed)'}`,\n );\n }\n\n if (result.patchFile) {\n console.log('');\n console.log('โ'.repeat(60));\n console.log('๐ CSS patch to apply:');\n console.log('โ'.repeat(60));\n console.log('');\n console.log(result.patchFile);\n console.log('');\n console.log('โ'.repeat(60));\n\n if (!options.dryRun) {\n const patchPath = path.join(\n projectRoot,\n '.design-guard',\n 'sync-patch.css',\n );\n fs.writeFileSync(patchPath, result.patchFile, 'utf-8');\n console.log(`\\n๐พ Patch saved to: ${patchPath}`);\n console.log(' Use --apply for full HTML content + token sync.');\n } else {\n console.log('\\n๐ Dry run โ no files written.');\n }\n }\n }\n}\n\n/**\n * Find local Stitch HTML files that should be replaced.\n * Searches for stitch-design.html or files matching --target.\n */\nasync function findLocalStitchHtml(\n projectRoot: string,\n sourceAbsPath: string,\n targetPath?: string,\n): Promise<string[]> {\n if (targetPath) {\n return [targetPath];\n }\n\n // Search for stitch-design.html files in the project\n const stitchFiles = await fg(\n ['**/stitch-design.html', '**/stitch*.html'],\n {\n cwd: projectRoot,\n ignore: ['node_modules/**', 'dist/**', 'build/**'],\n absolute: false,\n },\n );\n\n // Exclude the source file itself\n const sourceRelative = path.relative(projectRoot, sourceAbsPath);\n return stitchFiles.filter(f => f !== sourceRelative);\n}\n\n/**\n * Load all CSS files from the project into a map\n */\nasync function loadProjectCssFiles(\n projectRoot: string,\n config: { cssFiles: string[]; ignore: string[] },\n): Promise<Map<string, string>> {\n const cssFileMap = new Map<string, string>();\n\n for (const pattern of config.cssFiles) {\n const matches = await fg(pattern, {\n cwd: projectRoot,\n ignore: config.ignore,\n absolute: false,\n });\n\n for (const file of matches) {\n const absPath = path.resolve(projectRoot, file);\n if (fs.existsSync(absPath)) {\n cssFileMap.set(file, fs.readFileSync(absPath, 'utf-8'));\n }\n }\n }\n\n // Also include HTML files that might have Tailwind config\n const htmlPatterns = ['**/*.html'];\n const htmlIgnore = ['node_modules/**', 'dist/**', 'build/**', '.next/**'];\n const htmlMatches = await fg(htmlPatterns, {\n cwd: projectRoot,\n ignore: htmlIgnore,\n absolute: false,\n });\n\n for (const file of htmlMatches) {\n const absPath = path.resolve(projectRoot, file);\n if (fs.existsSync(absPath)) {\n cssFileMap.set(file, fs.readFileSync(absPath, 'utf-8'));\n }\n }\n\n return cssFileMap;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,WAAAA,gBAAe;AACxB,OAAOC,YAAW;AAClB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;;;ACL9B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,WAAW;AAYlB,eAAsB,YAAY,SAAqC;AACrE,QAAM,cAAc,QAAQ,IAAI;AAChC,QAAM,YAAY,SAAS,QAAQ,aAAa,MAAM,EAAE;AAExD,UAAQ,IAAI,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AQ;AAE5B,QACG,KAAK,aAAa,EAClB;AAAA,EACCC,OAAM,KAAK,8BAAkB,IAC7B;AAGF,EACC,QAAQ,IAAI,OAAO;AAEtB,QACG,QAAQ,MAAM,EACd,YAAY,qEAAqE,EACjF,OAAO,iBAAiB,yCAAyC,EACjE,OAAO,wBAAwB,0CAA0C,IAAI,EAC7E,OAAO,gBAAgB,2CAA2C,EAClE,OAAO,eAAe,0CAA0C,EAChE,OAAO,WAAW;AAErB,QACG,QAAQ,OAAO,EACf,YAAY,mDAAmD,EAC/D,OAAO,wBAAwB,qCAAqC,EACpE,OAAO,qBAAqB,+BAA+B,MAAM,EACjE,OAAO,QAAQ,wDAAwD,EACvE,OAAO,YAAY;AAEtB,QACG,QAAQ,OAAO,EACf,YAAY,uDAAuD,EACnE,OAAO,mBAAmB,4EAA4E,KAAK,EAC3G,OAAO,YAAY,sDAAsD,EACzE,OAAO,YAAY;AAEtB,QACG,QAAQ,UAAU,EAClB,YAAY,yBAAyB,EACrC,QAAQ,QAAQ,EAChB,YAAY,2EAA2E,EACvF,OAAO,iBAAiB,yCAAyC,EACjE,OAAO,eAAe;AAEzB,IAAM,OAAO,QACV,QAAQ,MAAM,EACd,YAAY,qDAAqD;AAEpE,KACG,QAAQ,SAAS,EACjB,YAAY,uDAAuD,EACnE,OAAO,wBAAwB,2CAA2C,IAAI,EAC9E,OAAO,kBAAkB;AAE5B,KACG,QAAQ,WAAW,EACnB,YAAY,wCAAwC,EACpD,OAAO,oBAAoB;AAE9B,QAAQ,WAAW,WAAW;AAE9B,QAAQ,MAAM;","names":["Command","chalk","hookFile","chalk","chalk","chalk","chalk","chalk","chalk","fs","path","chalk","hookFile","path","fs","path","fs","Command","chalk"]}
|
package/package.json
CHANGED