@reqvire-org/ads 0.3.46 → 0.3.48

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 (122) hide show
  1. package/README.md +21 -11
  2. package/dist/a11y.mjs +4 -2
  3. package/dist/assets.mjs +20 -15
  4. package/dist/atomic-composition.mjs +3 -2
  5. package/dist/brand-assets.mjs +48 -11
  6. package/dist/brands.mjs +82 -0
  7. package/dist/browser-audit/worker.mjs +51 -0
  8. package/dist/browser-audit.mjs +147 -0
  9. package/dist/capture/worker.mjs +1 -0
  10. package/dist/capture-store.mjs +2 -0
  11. package/dist/capture.mjs +7 -4
  12. package/dist/check.mjs +38 -8
  13. package/dist/cli.mjs +45 -10
  14. package/dist/color-values.mjs +325 -0
  15. package/dist/config.mjs +16 -2
  16. package/dist/control-padding.mjs +93 -0
  17. package/dist/design-values.mjs +3 -2
  18. package/dist/finding-rules.mjs +61 -0
  19. package/dist/foundation.mjs +17 -4
  20. package/dist/icons.mjs +107 -0
  21. package/dist/init.mjs +3 -0
  22. package/dist/mcp/apps.mjs +9 -6
  23. package/dist/mcp/context.mjs +1 -1
  24. package/dist/mcp/drafts.mjs +3 -0
  25. package/dist/mcp/mutations.mjs +40 -1
  26. package/dist/mcp/preview-widget.bundle.js +36 -36
  27. package/dist/mcp/project-widget.bundle.js +12 -12
  28. package/dist/mcp/server.mjs +23 -11
  29. package/dist/mcp/widget.bundle.js +17 -17
  30. package/dist/palette-generated.mjs +180 -0
  31. package/dist/preview-resources.mjs +12 -3
  32. package/dist/render-color-probe.mjs +148 -0
  33. package/dist/runtime-contracts.mjs +14 -4
  34. package/dist/scenarios.mjs +1 -1
  35. package/dist/showcase/client.bundle.js +28 -28
  36. package/dist/showcase/icons.js +146 -0
  37. package/dist/showcase/index.html +2 -1
  38. package/dist/showcase/style.css +19 -2
  39. package/dist/skills/README.md +2 -1
  40. package/dist/skills/ads-break-ui/SKILL.md +6 -5
  41. package/dist/skills/ads-break-ui/references/atomic-styles.md +12 -12
  42. package/dist/skills/ads-break-ui/references/contracts.md +13 -10
  43. package/dist/skills/ads-break-ui/references/design-data.md +137 -29
  44. package/dist/skills/ads-break-ui/references/drafts.md +3 -1
  45. package/dist/skills/ads-break-ui/references/guarded-editing.md +3 -2
  46. package/dist/skills/ads-break-ui/references/validation.md +13 -4
  47. package/dist/skills/ads-designer/SKILL.md +23 -16
  48. package/dist/skills/ads-designer/references/accessibility.md +41 -5
  49. package/dist/skills/ads-designer/references/atomic-styles.md +12 -12
  50. package/dist/skills/ads-designer/references/branding.md +37 -10
  51. package/dist/skills/ads-designer/references/cli.md +8 -2
  52. package/dist/skills/ads-designer/references/contracts.md +13 -10
  53. package/dist/skills/ads-designer/references/design-data.md +137 -29
  54. package/dist/skills/ads-designer/references/drafts.md +3 -1
  55. package/dist/skills/ads-designer/references/guarded-editing.md +3 -2
  56. package/dist/skills/ads-designer/references/validation.md +13 -4
  57. package/dist/skills/ads-import/SKILL.md +9 -8
  58. package/dist/skills/ads-import/references/atomic-styles.md +12 -12
  59. package/dist/skills/ads-import/references/cli.md +8 -2
  60. package/dist/skills/ads-import/references/contracts.md +13 -10
  61. package/dist/skills/ads-import/references/design-data.md +137 -29
  62. package/dist/skills/ads-import/references/drafts.md +3 -1
  63. package/dist/skills/ads-import/references/guarded-editing.md +3 -2
  64. package/dist/skills/ads-import/references/tokens.md +7 -3
  65. package/dist/skills/ads-import/references/validation.md +13 -4
  66. package/dist/skills/ads-motion/SKILL.md +6 -5
  67. package/dist/skills/ads-motion/references/atomic-styles.md +12 -12
  68. package/dist/skills/ads-motion/references/contracts.md +13 -10
  69. package/dist/skills/ads-motion/references/design-data.md +137 -29
  70. package/dist/skills/ads-motion/references/drafts.md +3 -1
  71. package/dist/skills/ads-motion/references/guarded-editing.md +3 -2
  72. package/dist/skills/ads-motion/references/validation.md +13 -4
  73. package/dist/skills/ads-port/SKILL.md +6 -5
  74. package/dist/skills/ads-port/references/atomic-styles.md +12 -12
  75. package/dist/skills/ads-port/references/cli.md +8 -2
  76. package/dist/skills/ads-port/references/contracts.md +13 -10
  77. package/dist/skills/ads-port/references/design-data.md +137 -29
  78. package/dist/skills/ads-port/references/drafts.md +3 -1
  79. package/dist/skills/ads-port/references/guarded-editing.md +3 -2
  80. package/dist/skills/ads-port/references/validation.md +13 -4
  81. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +11 -2
  82. package/dist/starters/react/ADS.md +43 -10
  83. package/dist/starters/react/README.md +14 -9
  84. package/dist/starters/react/design-system/assets/brand/README.md +8 -3
  85. package/dist/starters/react/design-system/assets/glyphs/README.md +4 -1
  86. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +6 -1
  87. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +3 -2
  88. package/dist/starters/react/design-system/components/Content/Icon/README.md +2 -1
  89. package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +3 -9
  90. package/dist/starters/react/design-system/components/Content/Logo/README.md +4 -2
  91. package/dist/starters/react/design-system/controllers/Palette/Palette.ts +164 -0
  92. package/dist/starters/react/design-system/index.ts +3 -0
  93. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +2 -5
  94. package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +11 -2
  95. package/dist/starters/react/design-system/styles.css +1 -0
  96. package/dist/starters/react/design-system/tokens/base.css +8 -5
  97. package/dist/starters/react/design-system/tokens/colors.css +167 -175
  98. package/dist/starters/react/design-system/tokens/elevation.css +14 -21
  99. package/dist/starters/react/design-system/tokens/themes.generated.css +142 -0
  100. package/dist/starters/react/design-system/tokens/themes.generated.ts +402 -0
  101. package/dist/style-boundaries.mjs +2 -1
  102. package/dist/themes-generated.mjs +150 -0
  103. package/dist/themes-watch.mjs +42 -0
  104. package/dist/themes.mjs +214 -63
  105. package/dist/token-export.mjs +22 -11
  106. package/dist/token-policy.mjs +2 -1
  107. package/dist/token-quality.mjs +28 -25
  108. package/dist/tokens.mjs +27 -32
  109. package/dist/validation.mjs +17 -1
  110. package/dist/verification/browser.mjs +14 -3
  111. package/dist/verification.mjs +25 -4
  112. package/docs/ADS.md +41 -27
  113. package/docs/ARCHITECTURE.md +49 -22
  114. package/docs/CACHING.md +2 -3
  115. package/docs/CHANGELOG.md +117 -13
  116. package/docs/CONTRACTS.md +13 -10
  117. package/docs/GUIDE.md +94 -22
  118. package/docs/MCP.md +50 -30
  119. package/docs/benchmarks/bun-previews.md +5 -5
  120. package/docs/benchmarks/{gidi-preview-memory.md → preview-memory.md} +14 -12
  121. package/docs/benchmarks/turbo-poc.md +24 -6
  122. package/package.json +2 -1
@@ -1,7 +1,8 @@
1
- import { defaultThemes, themeDefinition } from "./themes.mjs";
1
+ import { contextValues, defaultThemes, resolveValue } from "./themes.mjs";
2
+ import { findingSeverity } from "./finding-rules.mjs";
2
3
 
3
4
  /** Accessibility and rhythm reviews of token values: WCAG contrast between the roles that
4
- * meet on screen, in every theme, and spacing steps on the 2 px grid. Both are advisories. */
5
+ * meet on screen, in every theme, and spacing steps on the 2 px grid. Both are errors. */
5
6
 
6
7
  const named = { white: [255, 255, 255, 1], black: [0, 0, 0, 1] };
7
8
 
@@ -56,28 +57,30 @@ function contrastPairs(names) {
56
57
  return pairs.filter(([foreground, background]) => names.has(foreground) && names.has(background));
57
58
  }
58
59
 
59
- export function tokenContrastAdvisories(tokens, themes = defaultThemes) {
60
- const byName = new Map(tokens.map(token => [token.name, token]));
61
- const definition = (name, theme) => byName.has(name) ? themeDefinition(byName.get(name), theme) : undefined;
62
- // A theme value follows var() references, each resolved in the same theme.
63
- const resolve = (name, theme, seen = new Set()) => {
64
- if (seen.has(name)) return null;
65
- const value = definition(name, theme)?.value?.trim();
66
- const reference = value?.match(/^var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)$/);
67
- return reference ? resolve(reference[1], theme, new Set([...seen, name])) : value ?? null;
68
- };
60
+ export function tokenContrastAdvisories(tokens, themes = defaultThemes, brands = []) {
61
+ const names = new Set(tokens.map(token => token.name));
69
62
  const advisories = [];
63
+ const pairs = contrastPairs(names);
64
+ // Every brand in every theme; a brand other than the default reports only the pairs it changes.
70
65
  for (const { name: scope } of themes) {
71
- for (const [foreground, background, minimum] of contrastPairs(new Set(byName.keys()))) {
72
- const front = parseColor(resolve(foreground, scope) ?? ""), back = parseColor(resolve(background, scope) ?? "");
73
- if (!front || !back) continue;
74
- const ratio = contrastRatio(front, back[3] < 1 ? over(back, [255, 255, 255, 1]) : back);
75
- if (ratio + 1e-9 >= minimum) continue;
76
- const at = definition(foreground, scope);
77
- if (!at) continue;
78
- const { file, line, column } = at;
79
- advisories.push({ rule: "token-contrast", severity: "warning", file, line, column, tokens: [foreground, background], guidanceUri: "ads://guides/tokens",
80
- message: `${foreground} on ${background} is ${ratio.toFixed(2)}:1 in the ${scope} theme; ${minimum === 4.5 ? "text needs 4.5:1 (WCAG 1.4.3)" : "focus indicators and control borders need 3:1 (WCAG 1.4.11)"}.` });
66
+ const defaults = contextValues(tokens, { theme: scope, themes });
67
+ for (const brand of brands.length ? brands.map(item => item.name) : [undefined]) {
68
+ const own = brand === undefined || brand === brands[0].name;
69
+ const values = own ? defaults : contextValues(tokens, { theme: scope, brand, themes });
70
+ for (const [foreground, background, minimum] of pairs) {
71
+ const fore = resolveValue(values, foreground), backValue = resolveValue(values, background);
72
+ const front = parseColor(fore ?? ""), back = parseColor(backValue ?? "");
73
+ if (!front || !back) continue;
74
+ if (!own && fore === resolveValue(defaults, foreground) && backValue === resolveValue(defaults, background)) continue;
75
+ const ratio = contrastRatio(front, back[3] < 1 ? over(back, [255, 255, 255, 1]) : back);
76
+ if (ratio + 1e-9 >= minimum) continue;
77
+ const at = values.get(foreground);
78
+ if (!at) continue;
79
+ const { file, line, column } = at;
80
+ const where = own ? `the ${scope} theme` : `the ${scope} theme of brand "${brand}"`;
81
+ advisories.push({ rule: "token-contrast", severity: findingSeverity("token-contrast"), file, line, column, tokens: [foreground, background], guidanceUri: "ads://guides/tokens",
82
+ message: `${foreground} on ${background} is ${ratio.toFixed(2)}:1 in ${where}; ${minimum === 4.5 ? "text needs 4.5:1 (WCAG 1.4.3)" : "focus indicators and control borders need 3:1 (WCAG 1.4.11)"}.` });
83
+ }
81
84
  }
82
85
  }
83
86
  return advisories;
@@ -96,13 +99,13 @@ export function tokenRhythmAdvisories(tokens) {
96
99
  for (const token of tokens) {
97
100
  const step = token.name.match(/^--space-(\d+)$/)?.[1];
98
101
  if (step === undefined) continue;
99
- for (const { file, line, column, value, scope } of token.definitions) {
102
+ for (const { file, line, column, value, scope, property } of token.definitions) {
100
103
  const size = pixels(value);
101
104
  if (size === null) continue;
102
105
  const expected = Number(step) * 2;
103
106
  if (size % 2 === 0 && size === expected) continue;
104
- advisories.push({ rule: "token-rhythm", severity: "warning", file, line, column, tokens: [token.name], guidanceUri: "ads://guides/tokens",
105
- message: `${token.name} is ${size}px${scope === ":root" ? "" : ` in ${scope}`}; the spacing scale is --space-N = N × 2 px (${expected}px), on a 2 px grid.` });
107
+ advisories.push({ rule: "token-rhythm", severity: findingSeverity("token-rhythm"), file, line, column, tokens: [token.name], guidanceUri: "ads://guides/tokens",
108
+ message: `${token.name} is ${size}px${property ? ` as ${property}` : ""}${scope === ":root" ? "" : ` in ${scope}`}; the spacing scale is --space-N = N × 2 px (${expected}px), on a 2 px grid.` });
106
109
  }
107
110
  }
108
111
  return advisories;
package/dist/tokens.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { tokenContrastAdvisories, tokenRhythmAdvisories } from "./token-quality.mjs";
3
3
  import { a11yTokenAdvisories } from "./a11y.mjs";
4
- import { scopeTheme, themeFindings } from "./themes.mjs";
4
+ import { buildTokens, contextValues, themeFindings } from "./themes.mjs";
5
+ import { generatedThemesFile, themesCssDiagnostics } from "./themes-generated.mjs";
6
+ import { brandFindings } from "./brands.mjs";
5
7
  import path from "node:path";
6
8
  import postcss from "postcss";
7
9
  import valueParser from "postcss-value-parser";
@@ -10,6 +12,7 @@ import { foundationFiles, isSharedToken, tokenContract } from "./token-policy.mj
10
12
  import { dimensionValue, numericCssUnit } from "./css-values.mjs";
11
13
  import { checkComponentVariable } from "./boundaries.mjs";
12
14
  import { tokenOverlapAdvisories } from "./design-values.mjs";
15
+ import { routeFindings } from "./finding-rules.mjs";
13
16
 
14
17
  export { tokenContract };
15
18
 
@@ -52,9 +55,9 @@ export function inspectTokens(directory, suppliedOptions) {
52
55
  const options = suppliedOptions ?? loadConfig(directory);
53
56
  if(options.tokenInventory)return options.tokenInventory;
54
57
  const { root, dsRoot, config } = options;
55
- const definitions = new Map();
58
+ const declarations = [];
56
59
  const diagnostics = [];
57
- const files = sourceFiles(path.join(dsRoot, config.tokenDir)).filter((file) => file.endsWith(".css"));
60
+ const files = sourceFiles(path.join(dsRoot, config.tokenDir)).filter((file) => file.endsWith(".css") && path.basename(file) !== generatedThemesFile);
58
61
  files.sort((a, b) => foundationFiles.indexOf(path.basename(a)) - foundationFiles.indexOf(path.basename(b)) || a.localeCompare(b));
59
62
  for (const file of files) {
60
63
  let css;
@@ -67,40 +70,26 @@ export function inspectTokens(directory, suppliedOptions) {
67
70
  if (!decl.prop.startsWith("--")) return;
68
71
  const ownership = checkComponentVariable(decl.prop, file, options);
69
72
  if (ownership) diagnostics.push({ rule: ownership.rule, file: path.relative(root, file), line: decl.source.start.line, column: decl.source.start.column, message: ownership.message });
70
- const definition = {
71
- file: path.relative(root, file).replaceAll("\\", "/"),
72
- line: decl.source.start.line,
73
- column: decl.source.start.column,
74
- scope: context(decl),
75
- value: decl.value,
76
- };
77
- if (!definitions.has(decl.prop)) definitions.set(decl.prop, []);
78
- definitions.get(decl.prop).push(definition);
73
+ declarations.push({ prop: decl.prop, value: decl.value, file: path.relative(root, file).replaceAll("\\", "/"), line: decl.source.start.line, column: decl.source.start.column, scope: context(decl) });
79
74
  });
80
75
  }
81
- const base = new Map();
82
- const scopes = new Map();
83
- for (const [name, entries] of definitions) {
84
- for (const entry of entries) {
85
- if (scopeTheme(entry.scope)?.base) base.set(name, entry);
86
- else {
87
- if (!scopes.has(entry.scope)) scopes.set(entry.scope, new Map());
88
- scopes.get(entry.scope).set(name, entry);
89
- }
90
- }
91
- }
76
+ const tokens = buildTokens(declarations, config).map((token) => ({ ...token, ...tokenContract.tokens[token.name], owner: "tokens" }));
77
+ const defined = new Set(tokens.filter((token) => token.definitions.some((definition) => !definition.conditional && definition.brand === null)).map((token) => token.name));
92
78
  for (const name of Object.keys(tokenContract.tokens)) {
93
- if (!base.has(name)) diagnostics.push({ rule: "missing-token", file: config.dsDir, line: 1, column: 1, message: `Define ${name} in :root using the project's chosen value.` });
79
+ if (!defined.has(name)) diagnostics.push({ rule: "missing-token", file: config.dsDir, line: 1, column: 1, message: `Define ${name} in :root using the project's chosen value.` });
94
80
  }
95
81
  const emitted = new Set();
96
82
  function report(rule, name, entry, message) {
97
83
  const key = `${rule}:${name}:${entry.file}:${entry.line}:${message}`;
98
84
  if (emitted.has(key)) return;
99
85
  emitted.add(key);
100
- diagnostics.push({ rule, ...entry, message });
86
+ const { file, line, column, scope, value } = entry;
87
+ diagnostics.push({ rule, file, line, column, scope, value, message });
101
88
  }
102
- const effectiveScopes = [base, ...[...scopes.values()].map((overrides) => new Map([...base, ...overrides]))];
103
- for (const scope of effectiveScopes) {
89
+ // Every theme in every brand, as the browser resolves it there; halves are names too.
90
+ const contexts = config.themes.flatMap(({ name: theme }) => [undefined, ...config.brands.slice(1).map((brand) => brand.name)].map((brand) => contextValues(tokens, { theme, brand, themes: config.themes })));
91
+ const themedNames = new Set(tokens.filter((token) => token.themed).map((token) => token.name));
92
+ for (const scope of contexts) {
104
93
  const cache = new Map();
105
94
  function resolveAlias(name, chain = []) {
106
95
  if (cache.has(name)) return cache.get(name);
@@ -112,7 +101,8 @@ export function inspectTokens(directory, suppliedOptions) {
112
101
  }
113
102
  const resolvedReferences = new Map();
114
103
  for (const ref of references(entry.value)) {
115
- if (!isSharedToken(ref.name)) report("token-name", name, entry, `${name} references ${ref.name} outside the shared Data token contract.`);
104
+ const half = !themedNames.has(ref.name) && [...themedNames].some((base) => ref.name.startsWith(`${base}-`) && scope.has(ref.name));
105
+ if (!half && !isSharedToken(ref.name)) report("token-name", name, entry, `${name} references ${ref.name} outside the shared Data token contract.`);
116
106
  if (!scope.has(ref.name) && !ref.fallback) report("token-reference", name, entry, `${name} references undefined ${ref.name}.`);
117
107
  else if (scope.has(ref.name)) resolvedReferences.set(ref.name, resolveAlias(ref.name, [...chain, name]));
118
108
  }
@@ -140,15 +130,20 @@ export function inspectTokens(directory, suppliedOptions) {
140
130
  if (type && resolved !== undefined && !matchesType(resolved, type)) report("token-type", name, entry, `${name} expects ${type}; found ${resolved}.`);
141
131
  }
142
132
  }
143
- const tokens = [...definitions].sort(([a], [b]) => a.localeCompare(b)).map(([name, entries]) => ({ name, ...tokenContract.tokens[name], owner:"tokens", definitions: entries }));
144
133
  const themes = themeFindings(tokens, config.themes, { dsDir: config.dsDir });
145
134
  diagnostics.push(...themes.diagnostics);
135
+ const brands = brandFindings(tokens, config.brands, config.themes, { dsDir: config.dsDir });
136
+ diagnostics.push(...brands.diagnostics);
137
+ diagnostics.push(...themesCssDiagnostics(options, { tokens }));
138
+ // Token-value findings are errors or review items by rule; errors join the diagnostics.
139
+ const findings = routeFindings(diagnostics, [...tokenOverlapAdvisories(tokens), ...tokenContrastAdvisories(tokens, config.themes, config.brands), ...tokenRhythmAdvisories(tokens), ...themes.advisories, ...brands.advisories,
140
+ ...a11yTokenAdvisories(tokens, { root, foundationFile: path.join(dsRoot, config.tokenDir, "base.css") })]);
146
141
  return options.tokenInventory = {
147
142
  contractVersion: tokenContract.version,
148
143
  themes: config.themes,
144
+ ...(config.brands.length ? { brands: config.brands } : {}),
149
145
  tokens,
150
- advisories: [...tokenOverlapAdvisories(tokens), ...tokenContrastAdvisories(tokens, config.themes), ...tokenRhythmAdvisories(tokens), ...themes.advisories,
151
- ...a11yTokenAdvisories(tokens, { root, foundationFile: path.join(dsRoot, config.tokenDir, "base.css") })],
152
- diagnostics,
146
+ advisories: findings.advisories,
147
+ diagnostics: findings.diagnostics,
153
148
  };
154
149
  }
@@ -86,7 +86,7 @@ export function createValidationController(directory, { previewWork } = {}) {
86
86
  const behaviors = inspectBehaviors(options);
87
87
  units = options.config[policy].behaviorChecks ? (scope === "all" ? behaviors.contracts.map(contract=>contract.unit) : affectedBehaviorUnits(options,changed)) : [];
88
88
  onProgress?.({stage:"selection",scope,requestedScope,units,elapsedMs:Date.now()-startedAt});
89
- const requirePreviews=policy === "validation" || units.length>0;
89
+ const requirePreviews=policy === "validation" || units.length>0 || options.config[policy].browserAudit;
90
90
  if (requirePreviews && options.config.mcp.previewManifest && options.config.mcp.previewWatch) {
91
91
  stage("preview-build");
92
92
  const { startAdsMcp } = await import("./mcp/server.mjs");
@@ -119,6 +119,22 @@ export function createValidationController(directory, { previewWork } = {}) {
119
119
  checks.push({name:"registered-behavior",passed:result.ok});
120
120
  if (!result.ok && !result.diagnostics.length) diagnostics.push({rule:"validation-behavior",message:"Registered behavior checks did not all pass. Inspect the recorded outcomes."});
121
121
  } else checks.push({name:"registered-behavior",skipped:true,reason:!options.config[policy].behaviorChecks ? `Not required by ${policy} policy.` : scope === "all" ? "No registered behavior contracts." : "No affected behavior contracts."});
122
+ if (options.config[policy].browserAudit) {
123
+ // Rendered axe-core audit per scenario, brand and theme. a11y-axe findings are errors:
124
+ // they fail this policy.
125
+ stage("browser-audit");
126
+ const { auditCheck, runBrowserAudit } = await import("./browser-audit.mjs");
127
+ try {
128
+ const audit = await runBrowserAudit(root, {previewHost,signal,onProgress:value=>{ progress={...value,completed:checks.length}; onProgress?.(progress); }});
129
+ const {routed,check}=auditCheck(audit);
130
+ diagnostics.push(...routed.diagnostics); advisories.push(...routed.advisories);
131
+ checks.push(check);
132
+ } catch (error) {
133
+ if (signal.aborted) throw error;
134
+ checks.push({name:"browser-accessibility-audit",passed:false});
135
+ diagnostics.push({rule:"browser-audit",message:error.message});
136
+ }
137
+ } else checks.push({name:"browser-accessibility-audit",skipped:true,reason:`Not enabled by ${policy}.browserAudit.`});
122
138
  } catch (error) { diagnostics.push(error.diagnostic ?? {rule:signal.aborted ? "validation-cancelled" : "validation-execution",message:error.message}); }
123
139
  finally { try { await previewHost?.close(); } finally { releasePreview?.();active=undefined;progress=undefined;finish(); } }
124
140
  return complete();
@@ -20,9 +20,20 @@ function auditPaintBindings({ container = document.getElementById("root"), bindi
20
20
  const resolved = view.getComputedStyle(node).getPropertyValue(name).trim();
21
21
  return !!resolved && view.CSS.supports("color", resolved);
22
22
  }
23
- const themed = /^light-dark\(\s*(var\(\s*--[\w-]+\s*\)|currentColor)\s*,\s*(var\(\s*--[\w-]+\s*\)|currentColor)\s*\)$/.exec(value);
24
- if (themed)
25
- return view.CSS.supports("color", value) && reference(themed[1], node, descriptor, seen) && reference(themed[2], node, descriptor, seen);
23
+ const themes = Array.isArray(descriptor.themes) ? descriptor.themes : [];
24
+ if (themes.length && value.startsWith("var(--ads-if-")) {
25
+ const branch = /^var\(\s*--ads-if-([a-z][a-z0-9-]*)\s*,\s*(var\(\s*--[\w-]+\s*\)|currentColor|none)\s*\)/;
26
+ let rest = value;
27
+ const branches = [];
28
+ while (rest) {
29
+ const match = branch.exec(rest);
30
+ if (!match)
31
+ return false;
32
+ branches.push(match);
33
+ rest = rest.slice(match[0].length).trimStart();
34
+ }
35
+ return branches.length === themes.length && branches.every((match, index) => match[1] === themes[index] && reference(match[2], node, descriptor, seen));
36
+ }
26
37
  const resource = /^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(value);
27
38
  if (resource && view.CSS.supports("fill", value)) {
28
39
  const candidates = [...document2.querySelectorAll("[id]")].filter((item) => item.id === resource[2]);
@@ -55,7 +55,8 @@ function inputContext(options) {
55
55
  };
56
56
  }
57
57
 
58
- export function behaviorInputs(options, contract, check, context = inputContext(options)) {
58
+ /** Project files reachable from the given entry files through real imports, CSS imports and local assets. */
59
+ function inputClosure(options, context, entries) {
59
60
  const files = new Set(), demands = new Map(), effectsVisited = new Set();
60
61
  const resolve = context.resolve;
61
62
  function effects(file) {
@@ -120,10 +121,16 @@ export function behaviorInputs(options, contract, check, context = inputContext(
120
121
  }
121
122
  walk(ast);
122
123
  }
123
- for (const file of context.inventory.units.find(unit => unit.id === contract.unit)?.files ?? []) visit(path.join(options.root, file));
124
- for (const file of context.seeds) visit(file);
124
+ for (const file of entries) visit(file);
125
+ return files;
126
+ }
127
+
128
+ export function behaviorInputs(options, contract, check, context = inputContext(options)) {
125
129
  const scenario = check.scenario && context.scenarios.find(item => item.id === check.scenario);
126
- if (scenario) visit(path.join(options.root, scenario.file));
130
+ const files = inputClosure(options, context, [
131
+ ...(context.inventory.units.find(unit => unit.id === contract.unit)?.files ?? []).map(file => path.join(options.root, file)),
132
+ ...context.seeds, ...(scenario ? [path.join(options.root, scenario.file)] : []),
133
+ ]);
127
134
  const rows = [...files].sort().map(file => [slash(path.relative(options.root, file)), context.digest(file)]);
128
135
  for (const file of ["package-lock.json", "bun.lock", "bun.lockb", "pnpm-lock.yaml", "yarn.lock", "node_modules/.package-lock.json"]) rows.push([file, existsSync(path.join(options.root, file)) ? context.digest(path.join(options.root, file)) : null]);
129
136
  rows.push(["profile", JSON.stringify(options.config.mcp.behaviorProfiles[check.profile])], ["runtime", JSON.stringify(developmentRuntime())]);
@@ -172,6 +179,20 @@ export function affectedBehaviorUnits(options, changedFiles) {
172
179
  return contracts.filter(contract => Object.values(contract.checks).some(check => behaviorInputs(options, contract, check, context).files.some(file => changed.has(file)))).map(contract => contract.unit);
173
180
  }
174
181
 
182
+ /**
183
+ * Scenarios whose rendering a change can affect: those owned by a changed unit and those whose
184
+ * import closure (scenario file, its fixture/component imports, CSS and local assets) reaches a
185
+ * changed file. Shared configuration, foundation and token inputs are not traced here; callers
186
+ * treat changes to them as affecting every scenario.
187
+ */
188
+ export function affectedScenarios(options, changedFiles, scenarios = inspectScenarios(options).scenarios) {
189
+ const changed = new Set(changedFiles.map(file => slash(path.relative(options.root, path.resolve(options.root, file)))));
190
+ const context = inputContext(options), inventory = context.inventory;
191
+ const owners = new Set([...changed].map(file => inventory.owner(inventory.relative(file))).filter(Boolean));
192
+ return scenarios.filter(scenario => owners.has(inventory.owner(inventory.relative(scenario.file)))
193
+ || [...inputClosure(options, context, [path.join(options.root, scenario.file)])].some(file => changed.has(slash(path.relative(options.root, file))))).map(scenario => scenario.id);
194
+ }
195
+
175
196
  export function executeDevelopmentCommand(profile, args, root, env, signal) {
176
197
  return new Promise((resolve, reject) => {
177
198
  const label = profile.label ?? "Behavior verification";
package/docs/ADS.md CHANGED
@@ -79,8 +79,10 @@ App presentation comes from the selected compiled scenario; reusable review layo
79
79
  production widgets inside the client or scenario.
80
80
 
81
81
  There are five sections: Brand (first, shown only when the project has scenarios in
82
- `brand/`), Tokens, Components, Patterns and Composition. Brand previews are grouped by
83
- folder like components and have no token samples. There are
82
+ `brand/`), Tokens, Components, Patterns and Composition, plus an Icons tab after Tokens
83
+ when the project has a glyph set (`assets.glyphs`), rendered natively from
84
+ `ads://project/icons`. Brand previews are grouped by folder like components and have no
85
+ token samples. There are
84
86
  no required `TokensPage`/`ComponentsPage`/`PatternsPage`/`CompositionPage` files.
85
87
  Legacy custom browsing pages remain checked when present, but new projects use
86
88
  the built-in client. Its tooling CSS is separate from the project style contract.
@@ -250,16 +252,23 @@ bindings retain their narrow runtime contracts; they are not static design scale
250
252
  ### Themes
251
253
 
252
254
  A theme is a named set of values for the same tokens. `themes` in `ds.config.json` lists
253
- them with the color scheme each uses (`light` or `dark`); the first is the default and holds
254
- its values on `:root`. Other themes override values under `[data-theme="<name>"]`, which
255
- applies to the page on `<html>` or to one section on any element; the foundation guard
256
- accepts these selectors as it does the root. Because a custom property resolves `var()`
257
- where it is declared, roles that alias ramp steps are declared on `:root, [data-theme]` so a
258
- themed section resolves them against its own values. Contrast reviews, captures, the
259
- showcase theme button and `ads tokens --format dtcg --theme` work per declared theme;
260
- `theme-undeclared`, `theme-new-token`, `theme-coverage` and `theme-empty` keep theme
261
- definitions consistent. Switching themes at runtime (user choice, `prefers-color-scheme`,
262
- remembering the choice) belongs to the application.
255
+ them with the color scheme each uses (`light` or `dark`); the first is the default. Optional
256
+ `brands` add a second axis; the first brand is the default. A token that differs per theme is
257
+ authored as one plain half per theme on `:root` (`--x-light`, `--x-dark`), halves refer only
258
+ to halves, and a brand re-sets halves on `[data-brand="<name>"]`. ADS generates
259
+ `themes.generated.css` (theme switches, display switches `--display-<theme>` and
260
+ `--display-brand-<brand>`, one resolver per themed token, and the `prefers-color-scheme`
261
+ block under `followSystemTheme`) and `themes.generated.ts` (every color token resolved per
262
+ theme and brand, `themed()`/`themedByScheme()` for runtime values). Both are generated by
263
+ `ads assets`, the showcase and the MCP server, committed, and checked for freshness
264
+ (`themes-generated`). `data-theme` and `data-brand` apply to the page on `<html>` or to a
265
+ section on any element; every element follows its nearest theme and brand. Token values
266
+ under `[data-theme]` or `prefers-color-scheme` (`theme-old-form`), theme or brand selectors
267
+ in components (`theme-selector`) and `light-dark()` (`theme-light-dark`) are errors, as are
268
+ the coverage, half-reference and brand rules. Contrast checks, captures, the browser audit,
269
+ the showcase theme and brand controls and `ads tokens --format dtcg --theme/--brand` work
270
+ per declared theme and brand. Letting the user choose a theme and remembering it belongs to
271
+ the application.
263
272
 
264
273
  Shared token previews and sample coverage live under the configured token directory.
265
274
  The project mount adapter imports its foundation for both runtime and independent
@@ -267,16 +276,21 @@ token previews. No owner stylesheet dependencies are injected into preview entri
267
276
  `ads_prepare_token_samples` reconciles real shared bindings from project-selected
268
277
  properties/probes; it does not invent missing semantics.
269
278
 
270
- `ads check` reviews token values as advisories: `token-contrast` (WCAG AA for the roles
271
- that meet on screen, in every theme, through aliases), `token-rhythm` (`--space-N` =
272
- N × 2 px) and `token-overlap-review` (equal values within one token family). The
273
- accessibility guards (`a11y-*`) read tokens and runtime component source. `ads tokens
279
+ `ads check` checks token values: `token-contrast` (WCAG AA for the roles that meet on
280
+ screen, in every theme and brand, through aliases) and `token-rhythm` (`--space-N` = N × 2
281
+ px) are errors; `token-overlap-review` (equal values within one token family) is a review
282
+ item. The accessibility guards (`a11y-*`) read tokens and runtime component source;
283
+ `ads audit` adds axe-core in the rendered scenarios (`a11y-axe`). `ads tokens
274
284
  --format dtcg` exports the tokens as W3C Design Tokens JSON. See the
275
285
  [token guide](../skills/ads-designer/references/design-data.md) and the
276
286
  [accessibility guide](../skills/ads-designer/references/accessibility.md).
277
287
 
278
- `token-overlap-review` warns about identical normalized shared definitions across
279
- their declared theme scopes. It never merges semantic roles or blocks a build merely
288
+ ADS findings are errors, which fail `ads check`, validation and acceptance, or review items,
289
+ which are listed and never block; `info` items note an analysis limit. No configuration
290
+ changes a finding's kind.
291
+
292
+ `token-overlap-review` is a review item for identical normalized shared definitions
293
+ across their declared theme scopes. It never merges semantic roles or blocks a build merely
280
294
  because values coincide. Shared Data boundary violations are errors. See the
281
295
  [portable Data guide](../skills/ads-designer/references/design-data.md).
282
296
 
@@ -350,8 +364,8 @@ Store original branding and its usage, credits, and licenses in
350
364
  `assets/brand/`, and fonts in `assets/fonts/`. Configure generated web icons,
351
365
  committed targets (`assets.targets`), glyph sets (`assets.glyphs`) and asset
352
366
  mounts as described in the [branding guide](GUIDE.md#branding); `ads check` fails
353
- on stale committed outputs and warns about undescribed, unlicensed, unpreviewed or
354
- unused artwork.
367
+ on stale committed outputs and on undescribed, unlicensed or unpreviewed artwork, and
368
+ lists unused artwork for review.
355
369
 
356
370
  Before importing, compare the selected source and its dependencies with the
357
371
  destination's framework, public APIs, shared tokens, styling ownership and
@@ -432,9 +446,9 @@ ads check → ads assets → existing prebuild → existing build
432
446
  before asset generation. Additional project linters run only through explicit scripts.
433
447
  `lint-config` is an optional adapter for projects that choose Oxlint. `ads assets`
434
448
  generates configured browser icons from `assets.iconSource` into ignored `.ds/assets/`,
435
- renders committed `assets.targets` (recorded in `assets/generated.json`) and writes the
436
- `assets.glyphs` module; `ads check` fails when a committed output or the glyph module is
437
- stale.
449
+ renders committed `assets.targets` (recorded in `assets/generated.json`), writes the
450
+ `assets.glyphs` module and writes `themes.generated.css` and `themes.generated.ts`; `ads
451
+ check` fails when a committed output, the glyph module or a generated theme file is stale.
438
452
  A failed check or generation stops the build. Keep the project's CSS lint,
439
453
  type checks, behavior tests, and framework compilation in its build/test flow.
440
454
  `ads init` preserves existing lint tools and build commands.
@@ -467,10 +481,10 @@ The checks enforce the architecture's ownership boundaries:
467
481
  | Assets | Source/public collisions and configured generated artifacts in source are rejected |
468
482
 
469
483
  Pointer capture without locally visible capture-loss cleanup produces a
470
- nonblocking advisory. Review delegated cleanup and browser behavior; neither a
471
- warning nor a handler's presence establishes lifecycle correctness.
484
+ nonblocking review item. Review delegated cleanup and browser behavior; neither a
485
+ review item nor a handler's presence establishes lifecycle correctness.
472
486
 
473
- Potential atomic CSS overlaps produce `atomic-composition-review` warnings with
487
+ Potential atomic CSS overlaps produce `atomic-composition-review` review items with
474
488
  related declarations and a guidance URI. They are nonblocking, including during
475
489
  guarded mutations: valid CSS can intentionally overlap. Read
476
490
  [atomic style composition](../skills/ads-designer/references/atomic-styles.md) for causes, matching-property fixes
@@ -478,7 +492,7 @@ and the source review's limits. Registered rendered checks can enforce a
478
492
  project's intended computed geometry; token validity alone cannot establish it.
479
493
  Bounded tracing follows local helpers and explicit `className` forwarding;
480
494
  diagnostics distinguish a reached DOM target from informational analysis limits.
481
- Neither a trace nor an absent warning establishes the intended rendered result.
495
+ Neither a trace nor an absent review item establishes the intended rendered result.
482
496
 
483
497
  Document a new ownership exception with its guard/configuration change and
484
498
  tests. Passing static checks establishes only the policies and source formats
@@ -196,7 +196,7 @@ builds keep their own bundler's splitting and caching policy.
196
196
 
197
197
  Atomic merging matches property/selector/condition keys; it does not resolve
198
198
  every shorthand/logical-property overlap. ADS reports detectable composition
199
- risks as nonblocking warnings with guidance, while registered rendered checks
199
+ risks as nonblocking review items with guidance, while registered rendered checks
200
200
  can enforce actual geometry. See the skill-local
201
201
  [atomic style composition guide](../skills/ads-designer/references/atomic-styles.md).
202
202
  Bounded source tracing follows local class helpers and explicit component
@@ -318,7 +318,8 @@ completion requirements, build integration and recovery.
318
318
  Humans and coding agents inspect the same project through MCP. The showcase is
319
319
  **a minimal shell plus an MCP client and Apps host**, shipped as development
320
320
  tooling. Its header, section tabs (Brand, shown first when the project previews its
321
- artwork, then Tokens, Components, Patterns and Composition), collapsible left menu,
321
+ artwork, then Tokens, Icons when the project has a glyph set, Components, Patterns and
322
+ Composition), collapsible left menu,
322
323
  grid overlay and theme switches and preview area stay neutral. The grid overlay draws
323
324
  the project's `--grid-*` columns over every preview through the App's host context, so
324
325
  alignment is checked on real previews without a second renderer. The client discovers entries, invokes tools, forwards App
@@ -397,8 +398,9 @@ exists.
397
398
 
398
399
  ### The foundation has a narrow styling role
399
400
 
400
- Shared token sheets define values on the document root and its themes. The
401
- import-only entry loads them in canonical order. `fonts.css` declares font faces;
401
+ Shared token sheets define values on the document root, per-theme values as halves, and
402
+ brand values on `[data-brand]`; the generated `themes.generated.css` resolves them. The
403
+ import-only entry loads them in canonical order, the generated sheet last. `fonts.css` declares font faces;
402
404
  `base.css` establishes shared native defaults and normalization. Components and
403
405
  patterns own their layout, skin, states and animations in Linaria.
404
406
 
@@ -438,8 +440,8 @@ patterns as production: application adapters supply live data and effects;
438
440
  scenario adapters supply fixture data, local state and simulated services.
439
441
  Reassembling a second screen from shared primitives still allows design drift.
440
442
 
441
- The server discovers one path-derived scenario registry. The showcase's four
442
- sections—Tokens, Components, Patterns and Composition—browse that same registry
443
+ The server discovers one path-derived scenario registry. The showcase's scenario
444
+ sections (Brand, Tokens, Components, Patterns and Composition) browse that same registry
443
445
  through MCP results. They do not initialize the entry or define
444
446
  its UI. Every preview uses `?scenario=<id>`; discovered `kind` selects its section,
445
447
  including token scenarios colocated with component/pattern owners. Existing
@@ -741,7 +743,12 @@ its master hash, settings and output hash. A glyph set (`assets.glyphs`) turns a
741
743
  icon SVGs into one typed module. Freshness is checked by comparing recorded hashes, never by
742
744
  rendering, so the result is the same on every machine; a finished image is never enlarged.
743
745
  The starter's `Icon` and `IconButton` read that module: icons take `currentColor`, pair
744
- their size with text, and an icon-only button always has a label.
746
+ their size with text, and an icon-only button always has a label. The showcase renders the
747
+ glyph set itself in its Icons tab, from the folder and the same default attributes the
748
+ module uses, so a set is reviewed without a project scenario. Other products' logos
749
+ live in `assets/logos/`, outside both the brand artwork and the glyph set: they keep their
750
+ owners' colors, render as images (or a mask silhouette for a muted use), and ADS generates
751
+ and checks nothing there.
745
752
 
746
753
  ## Build checks keep the architecture in place
747
754
 
@@ -750,20 +757,40 @@ output. These checks enforce token use, source ownership, public imports,
750
757
  showcase coverage, component state boundaries, and separation of runtime code from development
751
758
  fixtures. Component-specific usage rules extend the shared checks when needed.
752
759
 
753
- Themes are declared in `ds.config.json` and are only value sets: every theme shares the
754
- same token names, and a theme applies to the page or to one section through
755
- `[data-theme]`. The declaration is the one theme list the showcase, captures, preview
756
- host context, contrast review and token export read, so a project can add a high-contrast
757
- or brand theme without tool changes.
758
-
759
- Token, brand and accessibility reviews run in the same check as advisories: they warn
760
- with a location and a reference (WCAG criteria for accessibility) but never fail a
761
- project's build. They cover contrast between the roles that meet on screen in every theme,
762
- the 2 px spacing rhythm, duplicate values within a token family, brand artwork that is
763
- undescribed, unlicensed, unpreviewed or unused, glyphs off the shared viewBox or with fixed
764
- colors, and accessibility rules readable from tokens and source (target size, focus, text
765
- resize, reduced motion, text spacing, image alternatives, keyboard reach, icon-only
766
- controls). Stale or hand-edited committed brand outputs are errors, since they ship.
760
+ Themes and brands are declared in `ds.config.json` and are only value sets: every theme and
761
+ brand shares the same token names. A theme sets the color mode and a brand sets identity
762
+ values (an accent ramp, a font), so a white-label product needs one brand per customer
763
+ rather than one theme per customer and mode. The declaration is the one list the showcase,
764
+ captures, preview host context, contrast review, browser audit and token export read, so a
765
+ project can add a high-contrast theme or a brand without tool changes.
766
+
767
+ A token that differs per theme is authored as one plain half per theme (`--x-light`,
768
+ `--x-dark`) on `:root`, and a brand re-sets its halves on `[data-brand]`. ADS generates
769
+ `themes.generated.css` from them: each `[data-theme]` sets inherited switch properties,
770
+ and each themed token resolves from its halves through those switches on every theme and
771
+ brand anchor. Custom properties inherit and resolve where they are declared, so every
772
+ element takes the halves of its nearest brand and the switch of its nearest theme, at any
773
+ nesting depth and in any order, with plain CSS variables. The same switches give display
774
+ switches (`--display-<theme>`, `--display-brand-<brand>`) for content that belongs to one
775
+ theme or brand. Theme and brand selectors are not used, in tokens or components, because
776
+ CSS resolves them by specificity and order, not by nearest ancestor.
777
+
778
+ Because every themed value is a plain half, ADS also resolves every color token for every
779
+ theme and brand ahead of time into `themes.generated.ts`. Renderers that need colors as
780
+ values (Canvas, WebGL, SVG graphs) look them up there for the element's nearest context,
781
+ instead of asking the browser to normalize a color per drawn item.
782
+
783
+ ADS findings are errors, review items or info items. An error is a rule ADS can decide: it
784
+ fails `ads check`, validation and acceptance, and no setting turns it off. Token, theme, brand,
785
+ glyph and accessibility rules read from tokens and source are errors: contrast between the
786
+ roles that meet on screen in every theme and brand, the 2 px spacing rhythm, theme and brand
787
+ coverage, brand artwork that is undescribed, unlicensed or unpreviewed, glyphs off the
788
+ shared viewBox or with fixed colors, controls padded off their size, target size, focus,
789
+ text resize, reduced motion, text spacing, image alternatives and icon-only controls. A
790
+ review item names something source analysis cannot settle (overlapping atomic declarations,
791
+ equal token values with possibly different roles, keyboard reach, unused artwork, color reads
792
+ in a render path); it is shown with guidance and never blocks. An info item notes an analysis
793
+ limit. Stale or hand-edited generated outputs are errors, since they ship.
767
794
 
768
795
  Static checks establish the policies and source formats they cover. Behavior
769
796
  tests and browser review verify the resulting accessibility, layout, themes,
@@ -974,7 +1001,7 @@ bindings keep their existing narrow contracts. Shared token previews consume the
974
1001
  same foundation through the project mount adapter.
975
1002
 
976
1003
  Shared tokens with identical normalized theme/condition definitions receive a
977
- nonblocking `token-overlap-review` advisory. Equal values do not establish equal
1004
+ nonblocking `token-overlap-review` review item. Equal values do not establish equal
978
1005
  meaning; ownership/value-source violations remain errors. See the
979
1006
  [shared Data contract](ADS.md#shared-data-and-component-mappings).
980
1007
 
package/docs/CACHING.md CHANGED
@@ -94,6 +94,5 @@ Turbo is a normal dependency of the ADS tool package, which a project installs a
94
94
  `@reqvire-org/ads` in `devDependencies`. Hermit should pin Bun >=1.4.1 for ADS;
95
95
  it should not install a second global Turbo executable or manage a project
96
96
  `turbo.json`. Keep the project's other Rust/native/Node tools as its build requires.
97
- This ADS repository and the local shadcn example have no Hermit environment.
98
- Reqvire pins Bun 1.4.2. Neezler's native-client Hermit environment also supplies
99
- Bun 1.4.2 for the root ADS/frontend commands invoked by its Makefile.
97
+ When a Makefile or script runs ADS commands, run them inside the Hermit environment so they
98
+ use the pinned Bun.