@sloppy-ai/core 1.1.0 → 1.4.0

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.
Files changed (46) hide show
  1. package/dist/assets/check.d.ts +44 -0
  2. package/dist/assets/check.d.ts.map +1 -0
  3. package/dist/assets/check.js +132 -0
  4. package/dist/assets/check.js.map +1 -0
  5. package/dist/brief/kind.d.ts +29 -0
  6. package/dist/brief/kind.d.ts.map +1 -0
  7. package/dist/brief/kind.js +69 -0
  8. package/dist/brief/kind.js.map +1 -0
  9. package/dist/gate/guards.d.ts +28 -0
  10. package/dist/gate/guards.d.ts.map +1 -0
  11. package/dist/gate/guards.js +107 -0
  12. package/dist/gate/guards.js.map +1 -0
  13. package/dist/index.d.ts +3 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/linter/design-contract.d.ts +17 -1
  18. package/dist/linter/design-contract.d.ts.map +1 -1
  19. package/dist/linter/design-contract.js +61 -3
  20. package/dist/linter/design-contract.js.map +1 -1
  21. package/dist/linter/index.d.ts.map +1 -1
  22. package/dist/linter/index.js +628 -372
  23. package/dist/linter/index.js.map +1 -1
  24. package/dist/linter/rule-metadata.d.ts.map +1 -1
  25. package/dist/linter/rule-metadata.js +19 -0
  26. package/dist/linter/rule-metadata.js.map +1 -1
  27. package/dist/linter/source-scan.d.ts.map +1 -1
  28. package/dist/linter/source-scan.js +32 -21
  29. package/dist/linter/source-scan.js.map +1 -1
  30. package/dist/linter/types.d.ts +10 -1
  31. package/dist/linter/types.d.ts.map +1 -1
  32. package/dist/linter/types.js +13 -0
  33. package/dist/linter/types.js.map +1 -1
  34. package/dist/looks/deal.d.ts +42 -0
  35. package/dist/looks/deal.d.ts.map +1 -0
  36. package/dist/looks/deal.js +126 -0
  37. package/dist/looks/deal.js.map +1 -0
  38. package/dist/looks/index.d.ts +21 -0
  39. package/dist/looks/index.d.ts.map +1 -1
  40. package/dist/looks/index.js +5 -0
  41. package/dist/looks/index.js.map +1 -1
  42. package/dist/looks/material.d.ts +72 -0
  43. package/dist/looks/material.d.ts.map +1 -0
  44. package/dist/looks/material.js +223 -0
  45. package/dist/looks/material.js.map +1 -0
  46. package/package.json +1 -1
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Image provenance checks for source files. Real photography needs a licence and a
3
+ * credit; placeholder services and missing files are defects the eye forgives too
4
+ * easily in a screenshot.
5
+ */
6
+ export interface AssetManifestEntry {
7
+ url: string;
8
+ source?: string;
9
+ license?: string;
10
+ credit?: string;
11
+ }
12
+ export interface AssetFinding {
13
+ id: 'GATE-ASSET-PLACEHOLDER' | 'GATE-ASSET-UNLICENSED' | 'GATE-ASSET-CREDIT' | 'GATE-ASSET-MISSING';
14
+ severity: 'critical' | 'high' | 'medium' | 'low';
15
+ file: string;
16
+ line: number;
17
+ message: string;
18
+ recommendation: string;
19
+ }
20
+ /** Hosts that serve stand-in images. A page using them is not finished. */
21
+ export declare const PLACEHOLDER_HOSTS: string[];
22
+ /** Hosts that serve real photography. Using one requires a manifest entry with a licence and credit. */
23
+ export declare const PHOTO_HOSTS: string[];
24
+ interface ImageReference {
25
+ url: string;
26
+ line: number;
27
+ }
28
+ /** Finds `src` attributes and CSS `url()` references that point at images. */
29
+ export declare function extractImageReferences(text: string): ImageReference[];
30
+ /**
31
+ * Checks manifest entries: each photo needs a licence and a credit line, otherwise
32
+ * the page is publishing images it cannot justify.
33
+ */
34
+ export declare function checkAssetManifest(manifest: AssetManifestEntry[], file?: string): AssetFinding[];
35
+ /**
36
+ * Scans one source file. `manifest` lists approved photo URLs. `localExists` lets the
37
+ * caller confirm local image paths against the filesystem; omit it to skip that check.
38
+ */
39
+ export declare function scanAssets(file: string, text: string, options?: {
40
+ manifest?: AssetManifestEntry[];
41
+ localExists?: (url: string) => boolean;
42
+ }): AssetFinding[];
43
+ export {};
44
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/assets/check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,wBAAwB,GAAG,uBAAuB,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;IACpG,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,UAY7B,CAAC;AAEF,wGAAwG;AACxG,eAAO,MAAM,WAAW,UAAuI,CAAC;AAIhK,UAAU,cAAc;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAQD,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE,CAgBrE;AAcD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,EAAE,IAAI,SAAuB,GAAG,YAAY,EAAE,CAgB9G;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAAC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;CAAO,GACxF,YAAY,EAAE,CAwChB"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Image provenance checks for source files. Real photography needs a licence and a
3
+ * credit; placeholder services and missing files are defects the eye forgives too
4
+ * easily in a screenshot.
5
+ */
6
+ /** Hosts that serve stand-in images. A page using them is not finished. */
7
+ export const PLACEHOLDER_HOSTS = [
8
+ 'picsum.photos',
9
+ 'placehold.co',
10
+ 'placehold.it',
11
+ 'placeholder.com',
12
+ 'via.placeholder.com',
13
+ 'placeimg.com',
14
+ 'dummyimage.com',
15
+ 'loremflickr.com',
16
+ 'fakeimg.pl',
17
+ 'placekitten.com',
18
+ 'placebear.com'
19
+ ];
20
+ /** Hosts that serve real photography. Using one requires a manifest entry with a licence and credit. */
21
+ export const PHOTO_HOSTS = ['images.unsplash.com', 'plus.unsplash.com', 'images.pexels.com', 'upload.wikimedia.org', 'images.ctfassets.net', 'cdn.shopify.com'];
22
+ const IMAGE_EXTENSION = /\.(avif|bmp|gif|jpe?g|png|svg|webp)(?:[?#]|$)/i;
23
+ function lineOf(text, index) {
24
+ let line = 1;
25
+ for (let i = 0; i < index && i < text.length; i += 1)
26
+ if (text.charCodeAt(i) === 10)
27
+ line += 1;
28
+ return line;
29
+ }
30
+ /** Finds `src` attributes and CSS `url()` references that point at images. */
31
+ export function extractImageReferences(text) {
32
+ const refs = [];
33
+ const srcPattern = /\bsrc\s*[=:]\s*\{?\s*["'`]([^"'`\s}]+)["'`]/g;
34
+ const cssPattern = /url\(\s*["']?([^"')\s]+)["']?\s*\)/g;
35
+ for (const pattern of [srcPattern, cssPattern]) {
36
+ for (const match of text.matchAll(pattern)) {
37
+ const url = match[1];
38
+ if (!url || url.startsWith('data:'))
39
+ continue;
40
+ const isRemote = /^https?:\/\//i.test(url);
41
+ const isLocal = url.startsWith('/') || url.startsWith('./') || url.startsWith('../') || url.startsWith('assets/') || url.startsWith('public/');
42
+ if (!isRemote && !isLocal)
43
+ continue;
44
+ if (pattern === cssPattern && !IMAGE_EXTENSION.test(url))
45
+ continue;
46
+ refs.push({ url, line: lineOf(text, match.index ?? 0) });
47
+ }
48
+ }
49
+ return refs;
50
+ }
51
+ function hostOf(url) {
52
+ try {
53
+ return new URL(url).hostname.toLowerCase();
54
+ }
55
+ catch {
56
+ return null;
57
+ }
58
+ }
59
+ function hostMatches(host, list) {
60
+ return list.some(candidate => host === candidate || host.endsWith(`.${candidate}`));
61
+ }
62
+ /**
63
+ * Checks manifest entries: each photo needs a licence and a credit line, otherwise
64
+ * the page is publishing images it cannot justify.
65
+ */
66
+ export function checkAssetManifest(manifest, file = 'sloppy.assets.json') {
67
+ const findings = [];
68
+ for (const entry of manifest) {
69
+ const missing = [!entry.license && 'license', !entry.credit && 'credit'].filter(Boolean);
70
+ if (missing.length) {
71
+ findings.push({
72
+ id: 'GATE-ASSET-CREDIT',
73
+ severity: 'medium',
74
+ file,
75
+ line: 1,
76
+ message: `Photo ${entry.url} has no ${missing.join(' or ')}.`,
77
+ recommendation: 'Add a licence (e.g. "Unsplash License") and a one-line credit for every photo in the manifest.'
78
+ });
79
+ }
80
+ }
81
+ return findings;
82
+ }
83
+ /**
84
+ * Scans one source file. `manifest` lists approved photo URLs. `localExists` lets the
85
+ * caller confirm local image paths against the filesystem; omit it to skip that check.
86
+ */
87
+ export function scanAssets(file, text, options = {}) {
88
+ const findings = [];
89
+ const approved = new Set((options.manifest ?? []).map(entry => entry.url));
90
+ for (const ref of extractImageReferences(text)) {
91
+ if (/^https?:\/\//i.test(ref.url)) {
92
+ const host = hostOf(ref.url);
93
+ if (!host)
94
+ continue;
95
+ const isImage = IMAGE_EXTENSION.test(ref.url) || hostMatches(host, PHOTO_HOSTS) || hostMatches(host, PLACEHOLDER_HOSTS);
96
+ if (!isImage)
97
+ continue;
98
+ if (hostMatches(host, PLACEHOLDER_HOSTS)) {
99
+ findings.push({
100
+ id: 'GATE-ASSET-PLACEHOLDER',
101
+ severity: 'high',
102
+ file,
103
+ line: ref.line,
104
+ message: `Image served by placeholder host ${host}.`,
105
+ recommendation: 'Replace it with a real photograph from the manifest, or a local brand mark. Placeholder images look finished in a screenshot and are not.'
106
+ });
107
+ }
108
+ else if (!approved.has(ref.url)) {
109
+ findings.push({
110
+ id: 'GATE-ASSET-UNLICENSED',
111
+ severity: 'medium',
112
+ file,
113
+ line: ref.line,
114
+ message: `Remote image ${ref.url} is not listed in the asset manifest.`,
115
+ recommendation: 'Add the URL to sloppy.assets.json with its licence and credit, or host the file locally.'
116
+ });
117
+ }
118
+ }
119
+ else if (options.localExists && !options.localExists(ref.url)) {
120
+ findings.push({
121
+ id: 'GATE-ASSET-MISSING',
122
+ severity: 'high',
123
+ file,
124
+ line: ref.line,
125
+ message: `Local image ${ref.url} does not exist.`,
126
+ recommendation: 'Fix the path or add the file. A broken image in a screenshot is a visible defect.'
127
+ });
128
+ }
129
+ }
130
+ return findings;
131
+ }
132
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/assets/check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,eAAe;IACf,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,qBAAqB;IACrB,cAAc;IACd,gBAAgB;IAChB,iBAAiB;IACjB,YAAY;IACZ,iBAAiB;IACjB,eAAe;CAChB,CAAC;AAEF,wGAAwG;AACxG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,qBAAqB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,iBAAiB,CAAC,CAAC;AAEhK,MAAM,eAAe,GAAG,gDAAgD,CAAC;AAOzE,SAAS,MAAM,CAAC,IAAY,EAAE,KAAa;IACzC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;QAAE,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE;Y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AG,CAAC,GAAG,CAAC,EAAE,CAAC;YAChE,QAAQ,CAAC,IAAI,CAAC;gBACZ,EAAE,EAAE,oBAAoB;gBACxB,QAAQ,EAAE,MAAM;gBAChB,IAAI;gBACJ,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,OAAO,EAAE,eAAe,GAAG,CAAC,GAAG,kBAAkB;gBACjD,cAAc,EAAE,mFAAmF;aACpG,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Brief classification: maps a free-text product brief to a site kind, and the
3
+ * policy that kind implies for effects, photography and colour theme.
4
+ *
5
+ * The kinds mirror the planning step other agent design skills use: decide what
6
+ * sort of thing is being built before choosing any visual device. Effects (WebGL,
7
+ * shaders, canvases) are only allowed where the subject calls for them.
8
+ */
9
+ export declare const SITE_KINDS: readonly ["software", "gaming", "tech", "product", "service", "place"];
10
+ export type SiteKind = (typeof SITE_KINDS)[number];
11
+ export interface KindPolicy {
12
+ /** WebGL, shaders and 3D scenes may appear on this kind of site. */
13
+ effectsAllowed: boolean;
14
+ /** Real photography should lead the hero: the subject is physical. */
15
+ photoFirst: boolean;
16
+ /** Preferred theme. `either` means the deal may pick light or dark. */
17
+ themeBias: 'light' | 'dark' | 'either';
18
+ }
19
+ export interface KindClassification {
20
+ kind: SiteKind;
21
+ confidence: 'high' | 'medium' | 'low';
22
+ /** Keywords from the brief that voted for the chosen kind. */
23
+ matched: string[];
24
+ policy: KindPolicy;
25
+ }
26
+ export declare function classifyBrief(brief: string): KindClassification;
27
+ export declare function policyFor(kind: SiteKind): KindPolicy;
28
+ export declare function isSiteKind(value: string): value is SiteKind;
29
+ //# sourceMappingURL=kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.d.ts","sourceRoot":"","sources":["../../src/brief/kind.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,UAAU,wEAAyE,CAAC;AACjG,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,oEAAoE;IACpE,cAAc,EAAE,OAAO,CAAC;IACxB,sEAAsE;IACtE,UAAU,EAAE,OAAO,CAAC;IACpB,uEAAuE;IACvE,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACtC,8DAA8D;IAC9D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;CACpB;AAsCD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAsB/D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAEpD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ,CAE3D"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Brief classification: maps a free-text product brief to a site kind, and the
3
+ * policy that kind implies for effects, photography and colour theme.
4
+ *
5
+ * The kinds mirror the planning step other agent design skills use: decide what
6
+ * sort of thing is being built before choosing any visual device. Effects (WebGL,
7
+ * shaders, canvases) are only allowed where the subject calls for them.
8
+ */
9
+ export const SITE_KINDS = ['software', 'gaming', 'tech', 'product', 'service', 'place'];
10
+ const POLICY = {
11
+ software: { effectsAllowed: false, photoFirst: false, themeBias: 'either' },
12
+ gaming: { effectsAllowed: true, photoFirst: false, themeBias: 'dark' },
13
+ tech: { effectsAllowed: true, photoFirst: false, themeBias: 'dark' },
14
+ product: { effectsAllowed: false, photoFirst: true, themeBias: 'light' },
15
+ service: { effectsAllowed: false, photoFirst: true, themeBias: 'light' },
16
+ place: { effectsAllowed: false, photoFirst: true, themeBias: 'light' }
17
+ };
18
+ // Ordered by priority: when two kinds tie, the earlier one wins. Place and service
19
+ // words are specific, so they beat the broad software and tech vocabulary.
20
+ const KEYWORDS = {
21
+ gaming: ['game', 'gaming', 'arcade', 'esports', 'multiplayer', 'rpg', 'quest', 'leaderboard', 'controller', 'boss', 'level', 'speedrun', 'mmo', 'indie'],
22
+ place: ['cafe', 'coffee', 'restaurant', 'bakery', 'bar', 'pub', 'hotel', 'resort', 'hostel', 'museum', 'gallery', 'park', 'venue', 'gym', 'bookshop', 'bookstore', 'brewery', 'winery', 'bistro', 'diner', 'spa', 'salon', 'town', 'city', 'island', 'kitchen', 'farm', 'school', 'library', 'club'],
23
+ service: ['agency', 'consultancy', 'consulting', 'clinic', 'law', 'legal', 'accounting', 'accountant', 'plumber', 'plumbing', 'repair', 'repairs', 'cleaning', 'freelance', 'freelancer', 'coaching', 'therapy', 'therapist', 'insurance', 'booking', 'appointments', 'lawyer', 'dentist', 'tutoring', 'tutor', 'bureau', 'services', 'service', 'firm'],
24
+ product: ['product', 'products', 'store', 'ecommerce', 'e-commerce', 'buy', 'sell', 'sneaker', 'sneakers', 'headphones', 'watch', 'watches', 'device', 'hardware', 'consumer', 'apparel', 'clothing', 'furniture', 'jewellery', 'jewelry', 'candle', 'candles', 'skincare', 'merch', 'gadget', 'gadgets', 'packaging', 'brand', 'boutique', 'shop'],
25
+ tech: ['developer', 'developers', 'api', 'sdk', 'cli', 'devtools', 'infrastructure', 'cloud', 'open-source', 'opensource', 'ai', 'agent', 'agents', 'llm', 'database', 'observability', 'deploy', 'deployment', 'kubernetes', 'compiler', 'framework', 'library', 'engineering', 'code', 'terminal'],
26
+ software: ['saas', 'app', 'apps', 'tool', 'tools', 'dashboard', 'workspace', 'editor', 'productivity', 'crm', 'admin', 'console', 'cockpit', 'platform', 'software', 'analytics', 'project', 'scheduler', 'invoice', 'invoices', 'billing', 'helpdesk', 'notes', 'todo', 'chat', 'mobile']
27
+ };
28
+ const PRIORITY = ['gaming', 'place', 'service', 'product', 'tech', 'software'];
29
+ function words(text) {
30
+ return text.toLowerCase().match(/[a-z][a-z-]*/g) ?? [];
31
+ }
32
+ /**
33
+ * Compare by singular form so "cafes", "services" and "cafe" all match. Only the
34
+ * sibilant plurals (-sses, -xes, -zes, -ches, -shes) take "es"; everything else drops "s".
35
+ */
36
+ function stem(word) {
37
+ if (/(ss|x|z|ch|sh)es$/.test(word) && word.length > 4)
38
+ return word.slice(0, -2);
39
+ if (word.length > 3 && word.endsWith('s') && !word.endsWith('ss'))
40
+ return word.slice(0, -1);
41
+ return word;
42
+ }
43
+ export function classifyBrief(brief) {
44
+ const tokens = words(brief);
45
+ const stems = new Set(tokens.map(stem));
46
+ const scores = new Map();
47
+ for (const kind of PRIORITY) {
48
+ const hits = [...new Set(KEYWORDS[kind].filter(keyword => stems.has(stem(keyword))))];
49
+ scores.set(kind, hits);
50
+ }
51
+ let best = 'software';
52
+ let bestHits = [];
53
+ for (const kind of PRIORITY) {
54
+ const hits = scores.get(kind) ?? [];
55
+ if (hits.length > bestHits.length) {
56
+ best = kind;
57
+ bestHits = hits;
58
+ }
59
+ }
60
+ const confidence = bestHits.length >= 2 ? 'high' : bestHits.length === 1 ? 'medium' : 'low';
61
+ return { kind: best, confidence, matched: bestHits, policy: { ...POLICY[best] } };
62
+ }
63
+ export function policyFor(kind) {
64
+ return { ...POLICY[kind] };
65
+ }
66
+ export function isSiteKind(value) {
67
+ return SITE_KINDS.includes(value);
68
+ }
69
+ //# sourceMappingURL=kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.js","sourceRoot":"","sources":["../../src/brief/kind.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AAoBjG,MAAM,MAAM,GAAiC;IAC3C,QAAQ,EAAE,EAAE,cAAc,EAAE,KAAK,EAA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MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtF,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,IAAI,GAAa,UAAU,CAAC;IAChC,IAAI,QAAQ,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;YAClC,IAAI,GAAG,IAAI,CAAC;YACZ,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAqC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9H,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAQ,UAAgC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Guards the finish gate applies to source files. They are not style rules: they
3
+ * catch an agent working around the checker, or building an effect the brief
4
+ * does not call for. Guard findings cannot be waived.
5
+ */
6
+ import type { KindPolicy } from '../brief/kind.js';
7
+ export interface GuardFinding {
8
+ id: 'GATE-CHECKER-GAMING' | 'GATE-KIND-EFFECT' | 'GATE-WEBGL-CAP';
9
+ severity: 'critical' | 'high' | 'medium' | 'low';
10
+ file: string;
11
+ line: number;
12
+ message: string;
13
+ recommendation: string;
14
+ unwaivable: true;
15
+ }
16
+ export declare const WEBGL_CONTEXT_CAP = 4;
17
+ export declare function scanCheckerGaming(file: string, text: string): GuardFinding[];
18
+ /**
19
+ * Flags effect code when the brief's kind does not allow effects. With no policy
20
+ * (no brief recorded), nothing is flagged.
21
+ */
22
+ export declare function scanKindEffects(file: string, text: string, policy?: KindPolicy, kind?: string): GuardFinding[];
23
+ /** Counts WebGL contexts across the whole project. Each context costs a GPU slot; browsers cap them. */
24
+ export declare function scanWebglCap(files: Array<{
25
+ file: string;
26
+ text: string;
27
+ }>): GuardFinding[];
28
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/gate/guards.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,qBAAqB,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;IAClE,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,IAAI,CAAC;CAClB;AA4BD,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAQnC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CAgB5E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,EAAE,CAkB9G;AAED,wGAAwG;AACxG,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,YAAY,EAAE,CAuBzF"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Guards the finish gate applies to source files. They are not style rules: they
3
+ * catch an agent working around the checker, or building an effect the brief
4
+ * does not call for. Guard findings cannot be waived.
5
+ */
6
+ /**
7
+ * Code that detects headless or automated browsers so it can behave differently
8
+ * under the checker. A page doing this passes the check without being good.
9
+ */
10
+ const CHECKER_GAMING_PATTERNS = [
11
+ /navigator\.webdriver/,
12
+ /HeadlessChrome/,
13
+ /\b__playwright\w*/,
14
+ /\b__puppeteer\w*/,
15
+ /\bcallPhantom\b|\b_phantom\b/,
16
+ /\b__nightmare\b/,
17
+ /\bdomAutomation\b/,
18
+ /\bwindow\.chrome\s*===?\s*undefined/
19
+ ];
20
+ /** Imports and API calls that build WebGL, shader or 3D output. */
21
+ const EFFECT_PATTERNS = [
22
+ /from\s+["'](three|ogl|regl|pixi\.js|@pixi\/[\w-]+)["']/,
23
+ /from\s+["']@react-three\/[\w-]+["']/,
24
+ /\bTHREE\.[A-Z]\w*/,
25
+ /\bShaderMaterial\b|\bRawShaderMaterial\b/,
26
+ /gl_FragColor|gl_Position/,
27
+ /\bgetContext\(\s*["'](webgl2?|experimental-webgl)["']/
28
+ ];
29
+ const WEBGL_CONTEXT = /\bgetContext\(\s*["'](webgl2?|experimental-webgl)["']/g;
30
+ export const WEBGL_CONTEXT_CAP = 4;
31
+ function lineOf(text, index) {
32
+ let line = 1;
33
+ for (let i = 0; i < index && i < text.length; i += 1)
34
+ if (text.charCodeAt(i) === 10)
35
+ line += 1;
36
+ return line;
37
+ }
38
+ export function scanCheckerGaming(file, text) {
39
+ const findings = [];
40
+ for (const pattern of CHECKER_GAMING_PATTERNS) {
41
+ const match = pattern.exec(text);
42
+ if (!match)
43
+ continue;
44
+ findings.push({
45
+ id: 'GATE-CHECKER-GAMING',
46
+ severity: 'critical',
47
+ file,
48
+ line: lineOf(text, match.index),
49
+ message: `Code detects an automated browser (${match[0]}). Checks must measure the page, not change for the checker.`,
50
+ recommendation: 'Remove the detection. Make the page look right to every browser.',
51
+ unwaivable: true
52
+ });
53
+ }
54
+ return findings;
55
+ }
56
+ /**
57
+ * Flags effect code when the brief's kind does not allow effects. With no policy
58
+ * (no brief recorded), nothing is flagged.
59
+ */
60
+ export function scanKindEffects(file, text, policy, kind) {
61
+ if (!policy || policy.effectsAllowed)
62
+ return [];
63
+ const findings = [];
64
+ for (const pattern of EFFECT_PATTERNS) {
65
+ const match = pattern.exec(text);
66
+ if (!match)
67
+ continue;
68
+ findings.push({
69
+ id: 'GATE-KIND-EFFECT',
70
+ severity: 'high',
71
+ file,
72
+ line: lineOf(text, match.index),
73
+ message: `WebGL or 3D effect (${match[0].trim()}) on a ${kind ?? 'non-tech'} site. The brief does not call for one.`,
74
+ recommendation: 'Use photography or a static composition for this kind of site. Effects belong on tech and gaming sites.',
75
+ unwaivable: true
76
+ });
77
+ break;
78
+ }
79
+ return findings;
80
+ }
81
+ /** Counts WebGL contexts across the whole project. Each context costs a GPU slot; browsers cap them. */
82
+ export function scanWebglCap(files) {
83
+ let total = 0;
84
+ let firstFile = '';
85
+ let firstLine = 1;
86
+ for (const { file, text } of files) {
87
+ for (const match of text.matchAll(WEBGL_CONTEXT)) {
88
+ if (total === 0) {
89
+ firstFile = file;
90
+ firstLine = lineOf(text, match.index ?? 0);
91
+ }
92
+ total += 1;
93
+ }
94
+ }
95
+ if (total <= WEBGL_CONTEXT_CAP)
96
+ return [];
97
+ return [{
98
+ id: 'GATE-WEBGL-CAP',
99
+ severity: 'high',
100
+ file: firstFile,
101
+ line: firstLine,
102
+ message: `${total} WebGL contexts created; the cap is ${WEBGL_CONTEXT_CAP}. Browsers drop the oldest beyond that.`,
103
+ recommendation: 'Share one renderer across scenes, or replace static ones with images.',
104
+ unwaivable: true
105
+ }];
106
+ }
107
+ //# sourceMappingURL=guards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/gate/guards.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH;;;GAGG;AACH,MAAM,uBAAuB,GAAa;IACxC,sBAAsB;IACtB,gBAAgB;IAChB,mBAAmB;IACnB,kBAAkB;IAClB,8BAA8B;IAC9B,iBAAiB;IACjB,mBAAmB;IACnB,qCAAqC;CACtC,CAAC;AAEF,mEAAmE;AACnE,MAAM,eAAe,GAAa;IAChC,wDAAwD;IACxD,qCAAqC;IACrC,mBAAmB;IACnB,0CAA0C;IAC1C,0BAA0B;IAC1B,uDAAuD;CACxD,CAAC;AAEF,MAAM,aAAa,GAAG,wDAAwD,CAAC;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC,SAAS,MAAM,CAAC,IAAY,EAAE,KAAa;IACzC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;QAAE,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE;YAAE,IAAI,IAAI,CAAC,CAAC;IAC/F,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,IAAY;IAC1D,MAAM,QAAQ,GAAmB,EAAE,CAAC;IACpC,KAAK,MAAM,OAAO,IAAI,uBAAuB,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,KAA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G,CAAC,CAAC;IAClB,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC;QACnC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YACjD,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBAChB,SAAS,GAAG,IAAI,CAAC;gBACjB,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;YAC7C,CAAC;YACD,KAAK,IAAI,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IACD,IAAI,KAAK,IAAI,iBAAiB;QAAE,OAAO,EAAE,CAAC;IAC1C,OAAO,CAAC;YACN,EAAE,EAAE,gBAAgB;YACpB,QAAQ,EAAE,MAAM;YAChB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,GAAG,KAAK,uCAAuC,iBAAiB,yCAAyC;YAClH,cAAc,EAAE,uEAAuE;YACvF,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;AACL,CAAC"}
package/dist/index.d.ts CHANGED
@@ -5,4 +5,7 @@ export * from './registry/index.js';
5
5
  export * from './archetypes/index.js';
6
6
  export * from './extractor/dna-extractor.js';
7
7
  export * from './stack/detect.js';
8
+ export * from './brief/kind.js';
9
+ export * from './assets/check.js';
10
+ export * from './gate/guards.js';
8
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -5,4 +5,7 @@ export * from './registry/index.js';
5
5
  export * from './archetypes/index.js';
6
6
  export * from './extractor/dna-extractor.js';
7
7
  export * from './stack/detect.js';
8
+ export * from './brief/kind.js';
9
+ export * from './assets/check.js';
10
+ export * from './gate/guards.js';
8
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
@@ -1,4 +1,13 @@
1
1
  import type { SloppyConfig } from './types.js';
2
+ export interface MotionContract {
3
+ fast?: number;
4
+ base?: number;
5
+ slow?: number;
6
+ maxFeedback?: number;
7
+ easeEnter?: string;
8
+ easeExit?: string;
9
+ signature?: string;
10
+ }
2
11
  export interface DesignContract {
3
12
  found: boolean;
4
13
  path?: string;
@@ -10,6 +19,7 @@ export interface DesignContract {
10
19
  body?: string;
11
20
  };
12
21
  signature?: string;
22
+ motion?: MotionContract;
13
23
  lockedTokens: string[];
14
24
  }
15
25
  export declare const DEFAULT_BLUR_CAP = 2;
@@ -22,5 +32,11 @@ export declare function parseDesignContract(content: string): Omit<DesignContrac
22
32
  export declare function loadDesignContract(startPath?: string): DesignContract;
23
33
  export declare function resolveDesignContract(filepath: string | undefined, config: SloppyConfig | null): DesignContract;
24
34
  export declare function declaredAccentAllows(contract: DesignContract | null | undefined, candidate: string): boolean;
25
- export declare const DESIGN_MD_TEMPLATE = "# DESIGN.md \u2014 Sloppy Design Contract (Token Lock)\n\nDeclare the project's own identity before generating UI. Sloppy enforces these\nvalues during `sloppy check` and suppresses Gen-2 defaults only when a token is\nexplicitly declared here.\n\n## Palette lock\n\n- brand-primary: <accent name or token, e.g. slate>\n- color-ink: <text token>\n- color-surface: <surface token>\n- color-border: <border token>\n\n## Typography lock\n\n- heading-font: <one display/heading family>\n- body-font: <one body family>\n\n## Surface lock\n\n- radius: 6px\n- blur-cap: 2\n\n## Signature element\n\n- signature: <the one focal element each page may spend visual emphasis on>\n\n## Notes\n\nRules suppressed by this contract are still reported as declared exceptions in\n`sloppy check --json` under `designContract`.\n";
35
+ export declare const DESIGN_MD_TEMPLATE = "# DESIGN.md \u2014 Sloppy Design Contract (Token Lock)\n\nDeclare the project's own identity before generating UI. Sloppy enforces these\nvalues during `sloppy check` and suppresses Gen-2 defaults only when a token is\nexplicitly declared here.\n\n## Palette lock\n\n- brand-primary: <accent name or token, e.g. slate>\n- color-ink: <text token>\n- color-surface: <surface token>\n- color-border: <border token>\n\n## Typography lock\n\n- heading-font: <one display/heading family>\n- body-font: <one body family>\n\n## Surface lock\n\n- radius: 6px\n- blur-cap: 2\n\n## Signature element\n\n- signature: <the one focal element each page may spend visual emphasis on>\n\n## Motion lock\n\nDeclare one motion contract so scanners compare against the project's values, not a\nuniversal threshold. All values are optional; the default feedback ceiling is 600ms.\n\n- motion-fast: 150ms\n- motion-base: 250ms\n- motion-slow: 400ms\n- motion-max-feedback: 300ms\n- motion-ease-enter: cubic-bezier(0.16, 1, 0.3, 1)\n- motion-ease-exit: cubic-bezier(0.4, 0, 1, 1)\n- motion-signature: <the one motion move this product owns>\n\n## Notes\n\nRules suppressed by this contract are still reported as declared exceptions in\n`sloppy check --json` under `designContract`.\n";
36
+ /**
37
+ * Starter spec for `sloppy verify --motion`. The selectors are deliberately
38
+ * placeholders: running it before editing reports a missing selector instead of
39
+ * a false pass, which keeps the evidence honest.
40
+ */
41
+ export declare const MOTION_SPEC_TEMPLATE = "{\n \"interactions\": [\n {\n \"name\": \"Replace with one real flow (menu, tabs, form, or filter)\",\n \"trigger\": \"[data-sloppy-trigger]\",\n \"target\": \"[data-sloppy-target]\",\n \"anchor\": \"[data-sloppy-anchor]\",\n \"kind\": \"click\",\n \"waitMs\": 500\n }\n ]\n}\n";
26
42
  //# sourceMappingURL=design-contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"design-contract.d.ts","sourceRoot":"","sources":["../../src/linter/design-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;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AS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,CAAC,CAyF3F;AAED,wBAAgB,kBAAkB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,CAarE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,cAAc,CAU/G;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAI5G;AAED,eAAO,MAAM,kBAAkB,ivCA4C9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,gUAYhC,CAAC"}
@@ -12,11 +12,22 @@ export function parseDesignContract(content) {
12
12
  let blurCap;
13
13
  let radius;
14
14
  let signature;
15
+ const motion = {};
16
+ const parseMs = (value) => {
17
+ const match = value.match(/(\d+(?:\.\d+)?)\s*(ms|s)?/i);
18
+ if (!match)
19
+ return undefined;
20
+ const number = Number(match[1]);
21
+ if (!Number.isFinite(number))
22
+ return undefined;
23
+ return (match[2] || '').toLowerCase() === 's' ? Math.round(number * 1000) : Math.round(number);
24
+ };
15
25
  const assign = (key, value) => {
16
26
  const normalized = key.trim().toLowerCase().replace(/[_\s]+/g, '-');
17
27
  const clean = value.trim().replace(/^['"`]|['"`]$/g, '');
18
28
  if (!clean)
19
29
  return;
30
+ const motionKey = (name) => ['motion-fast', 'motion-base', 'motion-slow', 'motion-max-feedback', 'motion-ease-enter', 'motion-ease-exit', 'motion-signature', 'ease-enter', 'ease-exit'].includes(name);
20
31
  if (['brand-primary', 'brand-accent', 'accent', 'primary'].includes(normalized))
21
32
  brandAccent = clean;
22
33
  else if (['blur-cap', 'backdrop-blur-cap', 'blur'].includes(normalized)) {
@@ -32,9 +43,24 @@ export function parseDesignContract(content) {
32
43
  fonts.body = clean;
33
44
  else if (['signature', 'signature-element', 'focal-point'].includes(normalized))
34
45
  signature = clean;
46
+ else if (['motion-fast', 'motion-duration-fast'].includes(normalized))
47
+ motion.fast = parseMs(clean) ?? motion.fast;
48
+ else if (['motion-base', 'motion-duration-base'].includes(normalized))
49
+ motion.base = parseMs(clean) ?? motion.base;
50
+ else if (['motion-slow', 'motion-duration-slow'].includes(normalized))
51
+ motion.slow = parseMs(clean) ?? motion.slow;
52
+ else if (['motion-max-feedback', 'motion-feedback-max'].includes(normalized))
53
+ motion.maxFeedback = parseMs(clean) ?? motion.maxFeedback;
54
+ else if (['motion-ease-enter', 'ease-enter', 'motion-enter-ease'].includes(normalized))
55
+ motion.easeEnter = clean;
56
+ else if (['motion-ease-exit', 'ease-exit', 'motion-exit-ease'].includes(normalized))
57
+ motion.easeExit = clean;
58
+ else if (['motion-signature', 'signature-motion', 'motion-move'].includes(normalized))
59
+ motion.signature = clean;
35
60
  else if (/(?:^|-)(?:color|palette|surface|background|foreground|ink|border)(?:-|$)/.test(normalized)) {
36
61
  // Palette tokens are recorded in lockedTokens and enforced by TOK-02.
37
62
  }
63
+ else if (motionKey(normalized)) { /* handled above */ }
38
64
  else
39
65
  return;
40
66
  lockedTokens.push(`${normalized}: ${clean}`);
@@ -77,8 +103,9 @@ export function parseDesignContract(content) {
77
103
  assign(key, String(value));
78
104
  else if (value && typeof value === 'object' && !Array.isArray(value)) {
79
105
  for (const [nestedKey, nestedValue] of Object.entries(value)) {
80
- if (typeof nestedValue === 'string')
81
- assign(nestedKey, nestedValue);
106
+ if (typeof nestedValue === 'string' || typeof nestedValue === 'number') {
107
+ assign(key.toLowerCase() === 'motion' ? `motion-${nestedKey}` : nestedKey, String(nestedValue));
108
+ }
82
109
  }
83
110
  }
84
111
  }
@@ -89,7 +116,7 @@ export function parseDesignContract(content) {
89
116
  // A malformed JSON block must never break the scanner.
90
117
  }
91
118
  }
92
- return { brandAccent, blurCap, radius, fonts, signature, lockedTokens };
119
+ return { brandAccent, blurCap, radius, fonts, signature, motion: Object.keys(motion).length ? motion : undefined, lockedTokens };
93
120
  }
94
121
  export function loadDesignContract(startPath) {
95
122
  let result = { found: false, lockedTokens: [] };
@@ -151,9 +178,40 @@ explicitly declared here.
151
178
 
152
179
  - signature: <the one focal element each page may spend visual emphasis on>
153
180
 
181
+ ## Motion lock
182
+
183
+ Declare one motion contract so scanners compare against the project's values, not a
184
+ universal threshold. All values are optional; the default feedback ceiling is 600ms.
185
+
186
+ - motion-fast: 150ms
187
+ - motion-base: 250ms
188
+ - motion-slow: 400ms
189
+ - motion-max-feedback: 300ms
190
+ - motion-ease-enter: cubic-bezier(0.16, 1, 0.3, 1)
191
+ - motion-ease-exit: cubic-bezier(0.4, 0, 1, 1)
192
+ - motion-signature: <the one motion move this product owns>
193
+
154
194
  ## Notes
155
195
 
156
196
  Rules suppressed by this contract are still reported as declared exceptions in
157
197
  \`sloppy check --json\` under \`designContract\`.
158
198
  `;
199
+ /**
200
+ * Starter spec for `sloppy verify --motion`. The selectors are deliberately
201
+ * placeholders: running it before editing reports a missing selector instead of
202
+ * a false pass, which keeps the evidence honest.
203
+ */
204
+ export const MOTION_SPEC_TEMPLATE = `{
205
+ "interactions": [
206
+ {
207
+ "name": "Replace with one real flow (menu, tabs, form, or filter)",
208
+ "trigger": "[data-sloppy-trigger]",
209
+ "target": "[data-sloppy-target]",
210
+ "anchor": "[data-sloppy-anchor]",
211
+ "kind": "click",
212
+ "waitMs": 500
213
+ }
214
+ ]
215
+ }
216
+ `;
159
217
  //# sourceMappingURL=design-contract.js.map