@reqvire-org/ads 0.3.45 → 0.3.47

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 (160) hide show
  1. package/README.md +23 -11
  2. package/dist/a11y.mjs +102 -0
  3. package/dist/assets.mjs +37 -8
  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 +45 -0
  8. package/dist/browser-audit.mjs +117 -0
  9. package/dist/capture/worker.mjs +2 -1
  10. package/dist/capture-store.mjs +4 -1
  11. package/dist/capture.mjs +10 -4
  12. package/dist/check.mjs +40 -9
  13. package/dist/cli.mjs +55 -8
  14. package/dist/color-values.mjs +325 -0
  15. package/dist/config.mjs +19 -2
  16. package/dist/contracts/tokens.json +1 -1
  17. package/dist/control-padding.mjs +93 -0
  18. package/dist/design-values.mjs +11 -4
  19. package/dist/finding-rules.mjs +61 -0
  20. package/dist/foundation.mjs +17 -1
  21. package/dist/icons.mjs +107 -0
  22. package/dist/init.mjs +3 -0
  23. package/dist/mcp/apps.mjs +9 -6
  24. package/dist/mcp/drafts.mjs +3 -0
  25. package/dist/mcp/mutations.mjs +17 -1
  26. package/dist/mcp/preview-widget.bundle.js +45 -39
  27. package/dist/mcp/project-widget.bundle.js +26 -26
  28. package/dist/mcp/server.mjs +23 -9
  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/captures.md +3 -2
  43. package/dist/skills/ads-break-ui/references/contracts.md +13 -10
  44. package/dist/skills/ads-break-ui/references/design-data.md +199 -2
  45. package/dist/skills/ads-break-ui/references/validation.md +8 -4
  46. package/dist/skills/ads-designer/SKILL.md +32 -15
  47. package/dist/skills/ads-designer/references/accessibility.md +77 -0
  48. package/dist/skills/ads-designer/references/atomic-styles.md +12 -12
  49. package/dist/skills/ads-designer/references/branding.md +61 -6
  50. package/dist/skills/ads-designer/references/captures.md +3 -2
  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 +199 -2
  54. package/dist/skills/ads-designer/references/validation.md +8 -4
  55. package/dist/skills/ads-import/SKILL.md +9 -8
  56. package/dist/skills/ads-import/references/atomic-styles.md +12 -12
  57. package/dist/skills/ads-import/references/captures.md +3 -2
  58. package/dist/skills/ads-import/references/cli.md +8 -2
  59. package/dist/skills/ads-import/references/contracts.md +13 -10
  60. package/dist/skills/ads-import/references/design-data.md +199 -2
  61. package/dist/skills/ads-import/references/tokens.md +7 -3
  62. package/dist/skills/ads-import/references/validation.md +8 -4
  63. package/dist/skills/ads-motion/SKILL.md +6 -5
  64. package/dist/skills/ads-motion/references/atomic-styles.md +12 -12
  65. package/dist/skills/ads-motion/references/build.md +33 -0
  66. package/dist/skills/ads-motion/references/captures.md +3 -2
  67. package/dist/skills/ads-motion/references/contracts.md +13 -10
  68. package/dist/skills/ads-motion/references/design-data.md +199 -2
  69. package/dist/skills/ads-motion/references/motion-review.md +2 -2
  70. package/dist/skills/ads-motion/references/validation.md +8 -4
  71. package/dist/skills/ads-port/SKILL.md +6 -5
  72. package/dist/skills/ads-port/references/atomic-styles.md +12 -12
  73. package/dist/skills/ads-port/references/captures.md +3 -2
  74. package/dist/skills/ads-port/references/cli.md +8 -2
  75. package/dist/skills/ads-port/references/contracts.md +13 -10
  76. package/dist/skills/ads-port/references/design-data.md +199 -2
  77. package/dist/skills/ads-port/references/validation.md +8 -4
  78. package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +76 -0
  79. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +19 -1
  80. package/dist/starters/preact/ds.config.json +13 -1
  81. package/dist/starters/react/ADS.md +43 -10
  82. package/dist/starters/react/README.md +61 -9
  83. package/dist/starters/react/design-system/assets/brand/README.md +8 -3
  84. package/dist/starters/react/design-system/assets/glyphs/README.md +15 -0
  85. package/dist/starters/react/design-system/assets/glyphs/aliases.json +1 -0
  86. package/dist/starters/react/design-system/assets/glyphs/check.svg +1 -0
  87. package/dist/starters/react/design-system/assets/glyphs/chevron-down.svg +1 -0
  88. package/dist/starters/react/design-system/assets/glyphs/chevron-right.svg +1 -0
  89. package/dist/starters/react/design-system/assets/glyphs/close.svg +1 -0
  90. package/dist/starters/react/design-system/assets/glyphs/external-link.svg +1 -0
  91. package/dist/starters/react/design-system/assets/glyphs/info.svg +1 -0
  92. package/dist/starters/react/design-system/assets/glyphs/menu.svg +1 -0
  93. package/dist/starters/react/design-system/assets/glyphs/plus.svg +1 -0
  94. package/dist/starters/react/design-system/assets/glyphs/search.svg +1 -0
  95. package/dist/starters/react/design-system/assets/glyphs/warning.svg +1 -0
  96. package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +11 -4
  97. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.fixture.ts +9 -0
  98. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.scenario.tsx +16 -0
  99. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +44 -0
  100. package/dist/starters/react/design-system/components/Actions/IconButton/README.md +14 -0
  101. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +6 -0
  102. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +16 -0
  103. package/dist/starters/react/design-system/components/Content/Icon/Icon.tsx +42 -0
  104. package/dist/starters/react/design-system/components/Content/Icon/README.md +17 -0
  105. package/dist/starters/react/design-system/components/Content/Icon/glyphs.ts +17 -0
  106. package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +3 -9
  107. package/dist/starters/react/design-system/components/Content/Logo/README.md +4 -2
  108. package/dist/starters/react/design-system/components/Forms/TextField/TextField.tsx +9 -5
  109. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +12 -0
  110. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +17 -0
  111. package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +75 -0
  112. package/dist/starters/react/design-system/components/Layout/Grid/README.md +21 -0
  113. package/dist/starters/react/design-system/controllers/Palette/Palette.ts +164 -0
  114. package/dist/starters/react/design-system/index.ts +6 -0
  115. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +2 -5
  116. package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +18 -0
  117. package/dist/starters/react/design-system/review/index.ts +1 -0
  118. package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +19 -1
  119. package/dist/starters/react/design-system/styles.css +1 -0
  120. package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +114 -8
  121. package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +23 -0
  122. package/dist/starters/react/design-system/tokens/{SpaceTypeMotion.ads.scenario.tsx → Layout.ads.scenario.tsx} +1 -1
  123. package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +18 -0
  124. package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +4 -0
  125. package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +30 -0
  126. package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +4 -0
  127. package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +37 -0
  128. package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +4 -0
  129. package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +29 -0
  130. package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +4 -0
  131. package/dist/starters/react/design-system/tokens/base.css +9 -3
  132. package/dist/starters/react/design-system/tokens/colors.css +210 -24
  133. package/dist/starters/react/design-system/tokens/elevation.css +44 -6
  134. package/dist/starters/react/design-system/tokens/spacing.css +67 -3
  135. package/dist/starters/react/design-system/tokens/themes.generated.css +142 -0
  136. package/dist/starters/react/design-system/tokens/themes.generated.ts +402 -0
  137. package/dist/starters/react/design-system/tokens/typography.css +25 -7
  138. package/dist/starters/react/ds.config.json +13 -1
  139. package/dist/style-boundaries.mjs +2 -1
  140. package/dist/themes-generated.mjs +150 -0
  141. package/dist/themes-watch.mjs +42 -0
  142. package/dist/themes.mjs +257 -0
  143. package/dist/token-export.mjs +69 -0
  144. package/dist/token-policy.mjs +2 -1
  145. package/dist/token-quality.mjs +112 -0
  146. package/dist/tokens.mjs +32 -30
  147. package/dist/validation.mjs +18 -1
  148. package/dist/verification/browser.mjs +14 -3
  149. package/docs/ADS.md +56 -13
  150. package/docs/ARCHITECTURE.md +82 -10
  151. package/docs/CACHING.md +2 -3
  152. package/docs/CHANGELOG.md +149 -13
  153. package/docs/CONTRACTS.md +13 -10
  154. package/docs/GUIDE.md +104 -8
  155. package/docs/MCP.md +46 -27
  156. package/docs/benchmarks/bun-previews.md +5 -5
  157. package/docs/benchmarks/{gidi-preview-memory.md → preview-memory.md} +14 -12
  158. package/docs/benchmarks/turbo-poc.md +24 -6
  159. package/package.json +2 -1
  160. package/dist/starters/react/design-system/tokens/SpaceTypeMotion.ads.fixture.ts +0 -36
@@ -0,0 +1,117 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { createRequire } from "node:module";
3
+ import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { loadConfig } from "./config.mjs";
7
+ import { discoverScenarioRegistry } from "./scenario-registry.mjs";
8
+ import { executeDevelopmentCommand } from "./verification.mjs";
9
+ import { findingSeverity } from "./finding-rules.mjs";
10
+
11
+ // Browser accessibility audit: axe-core (Deque, MPL-2.0, an unmodified ADS dependency
12
+ // injected at run time, never bundled) runs inside each rendered scenario document, once per
13
+ // declared brand and theme. Only the scenario's #root is audited; the preview status chrome is excluded.
14
+ // Findings are errors: they fail `ads audit` and any validation/acceptance policy with
15
+ // browserAudit. Automated rules catch a subset of WCAG failures; passing proves nothing more.
16
+
17
+ export const AUDIT_RULE = "a11y-axe";
18
+ /** WCAG A/AA rule tags. Best-practice and page-level rules (landmarks, one h1) don't fit isolated scenarios. */
19
+ export const auditTags = Object.freeze(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"]);
20
+ const viewport = { width: 1280, height: 800 };
21
+ export const auditedKinds = Object.freeze(["components", "patterns", "composition"]);
22
+ const limits = { scenarios: 500, nodes: 5, findings: 2000, reportBytes: 8 * 1024 * 1024 };
23
+
24
+ /** WCAG success criteria named by axe tags such as wcag143 or wcag1412. */
25
+ export function wcagCriteria(tags) {
26
+ return [...new Set(tags.map(tag => tag.match(/^wcag(\d)(\d)(\d{1,2})$/)).filter(Boolean).map(([, a, b, c]) => `${a}.${b}.${c}`))];
27
+ }
28
+
29
+ /** Collapse per-brand, per-theme axe violations into ADS errors: one per scenario, rule and failing element set. */
30
+ export function auditFindings(runs, scenarios) {
31
+ const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), groups = new Map();
32
+ const add = (list, value) => { if (value !== undefined && !list.includes(value)) list.push(value); };
33
+ for (const run of runs) for (const violation of run.violations) {
34
+ const selectors = violation.nodes.map(node => node.selector);
35
+ const key = JSON.stringify([run.scenario, violation.id, [...selectors].sort()]);
36
+ const group = groups.get(key) ?? { scenario: run.scenario, themes: [], brands: [], violation };
37
+ groups.set(key, group); add(group.themes, run.theme); add(group.brands, run.brand);
38
+ }
39
+ return [...groups.values()].slice(0, limits.findings).map(({ scenario, themes, brands, violation }) => {
40
+ const wcag = wcagCriteria(violation.tags), contrast = violation.id === "color-contrast";
41
+ const where = violation.nodes.map(node => node.selector).slice(0, 3).join(", ") + (violation.nodeCount > 3 ? ` and ${violation.nodeCount - 3} more` : "");
42
+ return {
43
+ rule: AUDIT_RULE, severity: findingSeverity(AUDIT_RULE), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "axe-core",
44
+ axeRule: violation.id, impact: violation.impact ?? null, wcag, tags: violation.tags, scenario, themes, ...(brands.length ? { brands } : {}),
45
+ nodes: violation.nodes, nodeCount: violation.nodeCount, helpUrl: violation.helpUrl, guidanceUri: "ads://guides/accessibility",
46
+ ...(contrast ? { overlaps: "token-contrast" } : {}),
47
+ message: `${contrast ? "Rendered contrast (browser audit; token-contrast checks declared token pairs statically): " : ""}axe ${violation.id}${violation.impact ? ` (${violation.impact})` : ""}${wcag.length ? `, WCAG ${wcag.join("/")}` : ""} in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${violation.help}. ${violation.nodeCount} element${violation.nodeCount === 1 ? "" : "s"}: ${where}. ${violation.helpUrl}`,
48
+ };
49
+ });
50
+ }
51
+
52
+ function projectPlaywright(root) {
53
+ const require = createRequire(path.join(root, "package.json"));
54
+ for (const name of ["@playwright/test", "playwright"]) { try { return require.resolve(name); } catch { /* Try the other supported project-installed entry. */ } }
55
+ return null;
56
+ }
57
+
58
+ /** Whether the project can run the audit: project-local Playwright, as for captures. */
59
+ export const browserAuditAvailable = root => !!projectPlaywright(path.resolve(root));
60
+
61
+ /**
62
+ * Render every selected scenario in every declared brand and theme and run axe-core on it.
63
+ * Without declared brands it renders the single default brand.
64
+ * Reuses a showcase-serving preview host when given one; otherwise starts and closes its own.
65
+ */
66
+ export async function runBrowserAudit(root, { scenarios: selected, themes: selectedThemes, brands: selectedBrands, previewHost, signal = new AbortController().signal, onProgress } = {}) {
67
+ root = path.resolve(root);
68
+ const startedAt = Date.now(), options = loadConfig(root);
69
+ const playwright = projectPlaywright(root);
70
+ if (!playwright) throw Object.assign(new Error("The browser accessibility audit requires project-local @playwright/test or playwright and its installed browser. ADS installs neither; mcp.capture selects browser/channel/timeoutMs."), { code: "ADS_AUDIT_UNAVAILABLE" });
71
+ const registry = discoverScenarioRegistry(options);
72
+ if (registry.diagnostics.length) throw new Error(`Scenario registration failed: ${registry.diagnostics[0].message}`);
73
+ const unknown = (selected ?? []).filter(id => !registry.scenarios.some(scenario => scenario.id === id));
74
+ if (unknown.length) throw new Error(`Unknown scenario ${unknown[0]}. Discover exact IDs with ads_scenarios.`);
75
+ // Token and brand scenarios display raw values (token-contrast reviews those pairs); UI scenarios are audited.
76
+ // An explicit selection may still name one.
77
+ const scenarios = registry.scenarios.filter(scenario => selected?.length ? selected.includes(scenario.id) : auditedKinds.includes(scenario.kind)).slice(0, limits.scenarios);
78
+ const themes = options.config.themes.filter(theme => !selectedThemes?.length || selectedThemes.includes(theme.name));
79
+ if (selectedThemes?.length && themes.length !== new Set(selectedThemes).size) throw new Error(`Unknown theme; the project declares ${options.config.themes.map(theme => theme.name).join(", ")}.`);
80
+ const declaredBrands = options.config.brands ?? [];
81
+ if (selectedBrands?.length && !declaredBrands.length) throw new Error("Unknown brand; the project declares no brands.");
82
+ const brands = declaredBrands.filter(brand => !selectedBrands?.length || selectedBrands.includes(brand.name));
83
+ if (selectedBrands?.length && brands.length !== new Set(selectedBrands).size) throw new Error(`Unknown brand; the project declares ${declaredBrands.map(brand => brand.name).join(", ")}.`);
84
+ const summary = { scenarios: scenarios.length, themes: themes.map(theme => theme.name), ...(brands.length ? { brands: brands.map(brand => brand.name) } : {}), tags: auditTags, engine: `axe-core ${axeVersion()}` };
85
+ if (!scenarios.length) return { ...summary, runs: 0, findings: [], elapsedMs: Date.now() - startedAt };
86
+ const outputRoot = path.join(root, ".ds");
87
+ mkdirSync(outputRoot, { recursive: true });
88
+ if (realpathSync(outputRoot) !== outputRoot) throw new Error("Audit work output cannot resolve through a symlink.");
89
+ const temporary = mkdtempSync(path.join(outputRoot, "audit-work-"));
90
+ let host = previewHost;
91
+ try {
92
+ onProgress?.({ stage: "browser-audit", message: `Accessibility audit: building ${scenarios.length} scenario previews.`, elapsedMs: Date.now() - startedAt });
93
+ if (!host?.url) { const { startAdsMcp } = await import("./mcp/server.mjs"); host = await startAdsMcp(root, { stdio: false, showcase: true }); }
94
+ await host.warmScenarios?.(scenarios.map(scenario => scenario.id), signal);
95
+ const apps = themes.flatMap(theme => (brands.length ? brands : [undefined]).flatMap(brand => scenarios.map(scenario => {
96
+ const url = new URL(host.url); url.searchParams.set("scenario", scenario.id); url.searchParams.set("capture", "1"); url.searchParams.set("theme", theme.name);
97
+ if (brand) url.searchParams.set("brand", brand.name);
98
+ return { scenario: scenario.id, theme: theme.name, ...(brand ? { brand: brand.name } : {}), scheme: theme.scheme, url: url.href };
99
+ })));
100
+ const settings = { browser: "chromium", timeoutMs: 60000, ...options.config.mcp.capture };
101
+ const request = path.join(temporary, "request.json"), report = path.join(temporary, "report.json"), runId = randomUUID();
102
+ writeFileSync(request, JSON.stringify({ schemaVersion: 1, runId, playwright, axe: requireTool.resolve("axe-core/axe.min.js"), settings, viewport, tags: auditTags, nodeLimit: limits.nodes, apps, output: temporary }));
103
+ onProgress?.({ stage: "browser-audit", message: `Accessibility audit: ${apps.length} renders (${scenarios.length} scenarios × ${themes.length} themes${brands.length ? ` × ${brands.length} brands` : ""}).`, elapsedMs: Date.now() - startedAt });
104
+ const timeoutMs = Math.min(30 * 60 * 1000, settings.timeoutMs + apps.length * Math.min(settings.timeoutMs, 15000));
105
+ const run = await executeDevelopmentCommand({ command: "runtime", timeoutMs, label: "Accessibility audit" }, [fileURLToPath(new URL("./browser-audit/worker.mjs", import.meta.url)), request], root, {}, signal);
106
+ if (run.code !== 0) throw new Error(`Accessibility audit browser failed (${run.code}): ${run.output.slice(-3000)}`);
107
+ if (!existsSync(report) || realpathSync(report) !== report || lstatSync(report).size > limits.reportBytes) throw new Error("Accessibility audit produced no bounded report.");
108
+ const value = JSON.parse(readFileSync(report, "utf8"));
109
+ if (value.schemaVersion !== 1 || value.runId !== runId || !Array.isArray(value.runs) || value.runs.length !== apps.length) throw new Error("Accessibility audit returned the wrong run identity or render count.");
110
+ return { ...summary, runs: value.runs.length, incomplete: value.runs.reduce((sum, item) => sum + item.incomplete, 0), findings: auditFindings(value.runs, scenarios), elapsedMs: Date.now() - startedAt };
111
+ } finally {
112
+ try { if (host !== previewHost) await host?.close(); } finally { rmSync(temporary, { recursive: true, force: true }); }
113
+ }
114
+ }
115
+
116
+ const requireTool = createRequire(import.meta.url);
117
+ function axeVersion() { return JSON.parse(readFileSync(requireTool.resolve("axe-core/package.json"), "utf8")).version; }
@@ -11,12 +11,13 @@ try {
11
11
  browser = await playwright[request.settings.browser].launch({ headless: true, ...(request.settings.channel ? { channel: request.settings.channel } : {}) });
12
12
  const images = [];
13
13
  for (const [index, app] of request.apps.entries()) {
14
- const context = await browser.newContext({ viewport: app.viewport, deviceScaleFactor: 1, colorScheme: app.theme });
14
+ const context = await browser.newContext({ viewport: app.viewport, deviceScaleFactor: 1, colorScheme: app.scheme });
15
15
  try {
16
16
  const page = await context.newPage(), timeout = request.settings.timeoutMs;
17
17
  const frame = await openPreviewScenario(page, app.url, app.scenario, { timeout });
18
18
  await frame.locator("html").waitFor({ state: "visible", timeout });
19
19
  await frame.waitForFunction(theme => document.documentElement.dataset.theme === theme, app.theme, { timeout });
20
+ if (app.brand) await frame.waitForFunction(brand => document.documentElement.dataset.brand === brand, app.brand, { timeout });
20
21
  await frame.evaluate(async () => {
21
22
  await document.fonts.ready;
22
23
  await Promise.all([...document.images].map(image => image.decode().catch(() => {})));
@@ -7,7 +7,10 @@ export const CAPTURES_URI = "ads://project/captures";
7
7
  export const captureLimits = { selections: 8, imageBytes: 4 * 1024 * 1024, pixels: 8 * 1024 * 1024, storeBytes: 256 * 1024 * 1024, pairBytes: 12 * 1024 * 1024 };
8
8
  export const captureSpec = z.object({
9
9
  scenario: z.string().min(1).max(256), target: z.string().regex(/^[a-zA-Z0-9][\w.-]{0,79}$/).optional(),
10
- theme: z.enum(["light", "dark"]).default("light"),
10
+ // A declared theme's name; the project's default theme when omitted.
11
+ theme: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/).optional(),
12
+ // A declared brand's name; the project's default brand when omitted. Only with declared brands.
13
+ brand: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/).optional(),
11
14
  viewport: z.object({ width: z.number().int().min(100).max(4096), height: z.number().int().min(100).max(4096) }).strict().default({ width: 1280, height: 800 }),
12
15
  animations: z.enum(["disabled", "allow"]).default("disabled"),
13
16
  }).strict().refine(value => value.viewport.width * value.viewport.height <= captureLimits.pixels, "Capture viewport exceeds 8 megapixels.");
package/dist/capture.mjs CHANGED
@@ -11,7 +11,7 @@ import { executeDevelopmentCommand } from "./verification.mjs";
11
11
  import { captureKey, captureSpec, captureLimits, createCaptureStore } from "./capture-store.mjs";
12
12
 
13
13
  export function captureSelections(values) {
14
- if (!Array.isArray(values) || !values.length || values.length > captureLimits.selections) throw new Error("Select 1–8 exact scenarios/targets with captures:[{scenario,target?,theme?,viewport?}]. Discover IDs with ads_scenarios.");
14
+ if (!Array.isArray(values) || !values.length || values.length > captureLimits.selections) throw new Error("Select 1–8 exact scenarios/targets with captures:[{scenario,target?,theme?,brand?,viewport?}]. Discover IDs with ads_scenarios.");
15
15
  const selections = values.map(value => captureSpec.parse(value));
16
16
  if (new Set(selections.map(captureKey)).size !== selections.length) throw new Error("Select each scenario/target once; settings replace that target's slots rather than creating extra history.");
17
17
  return selections;
@@ -80,9 +80,15 @@ export function createCaptureController(root) {
80
80
  const host = previewHosts[projectIndex] ?? await startAdsMcp(project.options.root, { stdio: false, showcase: true });
81
81
  if(!previewHosts[projectIndex])ownedHosts.push(host);
82
82
  hosts.push(host);
83
+ const themes = project.options.config.themes, brands = project.options.config.brands;
83
84
  for (const selection of project.apps) {
84
- const url = new URL(host.url); url.searchParams.set("scenario", selection.scenario); url.searchParams.set("capture", "1"); url.searchParams.set("theme", selection.theme);
85
- apps.push({ ...selection, projectIndex, url: url.href });
85
+ const theme = themes.find(item => item.name === (selection.theme ?? themes[0].name));
86
+ if (!theme) throw new Error(`Unknown theme "${selection.theme}"; the project declares ${themes.map(item => item.name).join(", ")}.`);
87
+ const brand = selection.brand === undefined ? brands[0] : brands.find(item => item.name === selection.brand);
88
+ if (!brand && selection.brand !== undefined) throw new Error(`Unknown brand "${selection.brand}"; ${brands.length ? `the project declares ${brands.map(item => item.name).join(", ")}` : "the project declares no brands"}.`);
89
+ const url = new URL(host.url); url.searchParams.set("scenario", selection.scenario); url.searchParams.set("capture", "1"); url.searchParams.set("theme", theme.name);
90
+ if (brand) url.searchParams.set("brand", brand.name);
91
+ apps.push({ ...selection, theme: theme.name, ...(brand ? { brand: brand.name } : {}), scheme: theme.scheme, projectIndex, url: url.href });
86
92
  }
87
93
  }
88
94
  const request = path.join(temporary, "request.json"), report = path.join(temporary, "report.json"), runId = randomUUID();
@@ -101,7 +107,7 @@ export function createCaptureController(root) {
101
107
  const bytes = readFileSync(file), metadata = await sharp(bytes).metadata();
102
108
  if (metadata.format !== "png" || !metadata.width || !metadata.height || metadata.width * metadata.height > captureLimits.pixels) throw new Error("Screenshot output exceeds 8 megapixels or is not PNG.");
103
109
  const project = projects[app.projectIndex];
104
- images.set(`${app.projectIndex}:${app.selectionIndex}`, { mimeType: "image/png", blob: bytes.toString("base64"), digest: `sha256:${createHash("sha256").update(bytes).digest("hex")}`, width: metadata.width, height: metadata.height, bytes: bytes.length, capturedAt: value.images[index].capturedAt, sourceRevision: project.revision, buildRevision: hosts[app.projectIndex].previewRevision(), settings: { theme: app.theme, viewport: app.viewport, animations: app.animations, browser: settings.browser, ...(settings.channel ? { channel: settings.channel } : {}), scale: "css" }, scenarioFile: app.scenarioFile, fixtureFile: app.fixtureFile });
110
+ images.set(`${app.projectIndex}:${app.selectionIndex}`, { mimeType: "image/png", blob: bytes.toString("base64"), digest: `sha256:${createHash("sha256").update(bytes).digest("hex")}`, width: metadata.width, height: metadata.height, bytes: bytes.length, capturedAt: value.images[index].capturedAt, sourceRevision: project.revision, buildRevision: hosts[app.projectIndex].previewRevision(), settings: { theme: app.theme, ...(app.brand ? { brand: app.brand } : {}), viewport: app.viewport, animations: app.animations, browser: settings.browser, ...(settings.channel ? { channel: settings.channel } : {}), scale: "css" }, scenarioFile: app.scenarioFile, fixtureFile: app.fixtureFile });
105
111
  }
106
112
  for (const project of projects) if (previewSourceRevision(loadConfig(project.options.root)) !== project.revision) throw new Error("Project inputs changed while capturing. No capture slots were replaced; retry against current source.");
107
113
  if (signal.aborted) throw new Error("Screenshot capture cancelled before publication.");
package/dist/check.mjs CHANGED
@@ -5,8 +5,12 @@ import postcss from "postcss";
5
5
  import valueParser from "postcss-value-parser";
6
6
  import { importViolation, isInside, loadConfig, sourceFiles, isDevelopmentFile, isTestFile, isReviewFile } from "./config.mjs";
7
7
  import { inspectTokens, references } from "./tokens.mjs";
8
+ import { displaySwitches, generatedPaletteFile, generatedThemeFiles } from "./themes-generated.mjs";
9
+ import { createRenderColorProbe } from "./render-color-probe.mjs";
10
+ import { themeAncestorSelector } from "./themes.mjs";
8
11
  import { foundationFiles, foundationImportTarget, isSharedToken } from "./token-policy.mjs";
9
12
  import { inspectAssets } from "./assets.mjs";
13
+ import { a11ySourceAdvisories } from "./a11y.mjs";
10
14
  import { appImportViolation, showcaseImportViolation, checkComponentVariable, importResolver, projectCompilerOptions, isUiCssProperties, styleWriteViolation } from "./boundaries.mjs";
11
15
  import { inspectPublicProps } from "./public-props.mjs";
12
16
  import { adsFileRole } from "./config.mjs";
@@ -34,6 +38,8 @@ import { createDesignValues, inspectDesignAliases, isColorKeyword } from "./desi
34
38
  import { inspectTestBoundaries } from "./test-boundaries.mjs";
35
39
  import { inspectBehaviorLibraries } from "./behavior-libraries.mjs";
36
40
  import { inspectUsage } from "./usage.mjs";
41
+ import { controlPaddingAdvisories } from "./control-padding.mjs";
42
+ import { findingSeverity, routeFindings } from "./finding-rules.mjs";
37
43
 
38
44
  const scenarioLayoutGuidance = "Put demo-only sizing and framing in the development-only review/ layer, imported through the separate review entry. Patterns are production UI. Keep required behavior in the runtime owner; add component props for deliberate product API needs.";
39
45
  const inlineStyleGuidance = `Own visual styles in component/pattern Linaria. ${scenarioLayoutGuidance} Reserve inlineStyleFiles for documented measured geometry, not demo layout.`;
@@ -53,10 +59,12 @@ export function checkProject(directory, { trackingRoot } = {}) {
53
59
  if (diagnostics.length) return architectureEvidence({ ok: false, diagnostics });
54
60
  const tokenInventory = inspectTokens(root, options);
55
61
  const declaredTokens = new Set(tokenInventory.tokens.map((token) => token.name));
62
+ // Display switches are defined by the generated themes.generated.css, not a token sheet.
63
+ const generatedSwitches = new Set(displaySwitches(config));
56
64
  diagnostics.push(...tokenInventory.diagnostics);
57
65
  const assetFindings = inspectAssets(options);
58
- diagnostics.push(...assetFindings.filter(finding => finding.severity !== "warning"));
59
- const assetAdvisories = assetFindings.filter(finding => finding.severity === "warning");
66
+ diagnostics.push(...assetFindings.filter(finding => !finding.severity || finding.severity === "error"));
67
+ const assetAdvisories = assetFindings.filter(finding => finding.severity && finding.severity !== "error");
60
68
  const resolveImport = importResolver(options);
61
69
  const units = inspectUnits(options);
62
70
  options.testOwner = file => units.owner(units.relative(path.relative(root,file)));
@@ -75,6 +83,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
75
83
  const runtimeContracts = inspectRuntimeContracts(options, program);
76
84
  diagnostics.push(...runtimeContracts.diagnostics);
77
85
  const atomicCompositionReview = createAtomicCompositionReview(program, options);
86
+ const renderColorProbe = createRenderColorProbe(program);
78
87
  const scenarioTrace = createScenarioTrace(program, options);
79
88
  let scenarioSlot, scenarioSelector;
80
89
  function report(file, rule, message, line = 1, column = 1, detail = {}) {
@@ -95,7 +104,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
95
104
  inspectControllers(options, program, report, behaviors.contracts);
96
105
  // The foundation remains a fixed import-only entry, not an extra styling layer.
97
106
  const foundationEntry = path.join(dsRoot, config.stylesEntry);
98
- const registeredProperties=new Map();
107
+ const registeredProperties=new Map(), controlPaddingSeen=new Set();
99
108
  function checkRegistrations(file,css,offset={line:1}){
100
109
  css.walkAtRules(/^property$/i,rule=>{
101
110
  const line=offset.line+(rule.source?.start.line??1)-1;
@@ -123,7 +132,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
123
132
  const imports = css.nodes.filter((node) => node.type !== "comment");
124
133
  const expected = foundationFiles.filter((name) => name !== "fonts.css" || existsSync(path.join(dsRoot, config.tokenDir, name))).map((name) => path.join(dsRoot, config.tokenDir, name));
125
134
  const actual = imports.map(node => foundationImportTarget(node, foundationEntry));
126
- if (actual.length !== expected.length || actual.some((file, index) => file !== expected[index] || !existsSync(file))) report(foundationEntry, "styles-entry", "Foundation CSS must import only fonts (when present), colors, typography, spacing, elevation, and base, in that order.");
135
+ if (actual.length !== expected.length || actual.some((file, index) => file !== expected[index] || !existsSync(file))) report(foundationEntry, "styles-entry", "Foundation CSS must import only fonts (when present), colors, typography, spacing, elevation, base and the generated themes.generated.css, in that order.");
127
136
  } catch (error) { report(foundationEntry, "css-syntax", error.reason ?? error.message, error.line ?? 1); }
128
137
  function checkCss(file, text, offset = { line: 1, column: 1 }, foundation = false) {
129
138
  let css;
@@ -132,6 +141,11 @@ export function checkProject(directory, { trackingRoot } = {}) {
132
141
  layers.collectComponentStyles(file, css);
133
142
  layerStyles.push({ file, css, offset });
134
143
  checkRegistrations(file,css,offset);
144
+ // Linaria templates are checked once per resolved interpolation variant.
145
+ if (!foundation) for (const finding of controlPaddingAdvisories(css, { tokens: declaredTokens, file: path.relative(root, file).replaceAll("\\", "/"), offset })) {
146
+ const key = JSON.stringify([finding.file, finding.line, finding.column, finding.message]);
147
+ if (!controlPaddingSeen.has(key)) { controlPaddingSeen.add(key); advisories.push(finding); }
148
+ }
135
149
  if (!foundation && !isReviewFile(file, options) && (isDevelopmentFile(file, options) || !isInside(path.join(dsRoot, "components"), file) && !isInside(path.join(dsRoot, "patterns"), file) && file !== foundationEntry)) report(file, "style-ownership", "Visual CSS belongs to the local ADS's runtime components/patterns or development review implementations.");
136
150
  if (isDevelopmentFile(file, options) && !isReviewFile(file, options) && css.nodes.some((node) => node.type !== "comment" && !(node.type === "atrule" && node.name === "import"))) report(file, "showcase-style", `Scenarios and fixtures define no styles. ${scenarioLayoutGuidance}`, offset.line);
137
151
  css.walkAtRules("import", (rule) => {
@@ -150,6 +164,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
150
164
  if (violation) report(file, "foundation-selector", violation, rule.source.start.line, rule.source.start.column);
151
165
  }
152
166
  if (isInside(path.join(dsRoot, "showcase"), file) && /:(?:hover|active|focus(?:-visible|-within)?|checked|disabled|enabled)\b|\[(?:aria-(?:selected|pressed|checked|disabled|expanded)|data-state)\b/.test(rule.selector)) report(file, "showcase-state", "Interactive state styling belongs to the real ADS component or pattern, not showcase or mock styles.", offset.line + rule.source.start.line - 1);
167
+ if (!foundation && (isReviewFile(file, options) || ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file))) && themeAncestorSelector(rule.selector)) report(file, "theme-selector", "Theme and brand selectors don't follow the nearest section; show theme- or brand-specific content with display: var(--display-<theme>, <display>), and give theme- or brand-specific values as token halves.", offset.line + rule.source.start.line - 1, rule.source.start.column, { severity: findingSeverity("theme-selector") });
153
168
  if (/\.ads-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "components"), file)) report(file, "style-ownership", "ADS component internals are owned by components, not app or showcase CSS.", offset.line + rule.source.start.line - 1);
154
169
  if (/\.ux-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "patterns"), file) && !isReviewFile(file, options)) report(file, "style-ownership", "Pattern internals are owned by patterns, not app or scenario CSS.", offset.line + rule.source.start.line - 1);
155
170
  if (/\.showcase-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "showcase"), file)) report(file, "style-ownership", "Showcase internals are owned by showcase scaffolding.", offset.line + rule.source.start.line - 1);
@@ -160,6 +175,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
160
175
  });
161
176
  css.walkDecls((decl) => {
162
177
  const propertyDescriptor=decl.parent.type==="atrule"&&decl.parent.name.toLowerCase()==="property";
178
+ if ((foundation || ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file))) && /\blight-dark\(/i.test(decl.value)) report(file, "theme-light-dark", "Give per-theme values as token halves (--x-light, --x-dark); light-dark() is limited to two schemes.", offset.line + decl.source.start.line - 1, decl.source.start.column, { severity: findingSeverity("theme-light-dark") });
163
179
  if (foundation && decl.prop.startsWith("--")) {
164
180
  if (path.basename(file) === "base.css") report(file, "foundation-role", "Shared token definitions belong in value sheets, not base.css.", decl.source.start.line, decl.source.start.column);
165
181
  return; // Definition names, values and aliases are validated by inspectTokens.
@@ -178,6 +194,8 @@ export function checkProject(directory, { trackingRoot } = {}) {
178
194
  if (units.owner(units.relative(path.relative(root, file))) !== binding.unit) report(file, "binding-ownership", `${ref.name} is an instance binding owned by ${binding.unit}, not a shared design token.`, offset.line + decl.source.start.line - 1, decl.source.start.column);
179
195
  continue;
180
196
  }
197
+ if (generatedSwitches.has(ref.name)) continue;
198
+ if (ref.name.startsWith("--display-")) { report(file, "token-reference", `${ref.name} is not a display switch; themes.generated.css defines ${[...generatedSwitches].join(", ")} from ds.config.json themes and brands.`, offset.line + decl.source.start.line - 1, decl.source.start.column); continue; }
181
199
  const local = /^(?:--ds-|--ux-|--showcase-)/.test(ref.name);
182
200
  if (foundation && local) report(file, "foundation-role", "Foundation defaults consume shared tokens, not component, pattern or scenario-local variables.", offset.line + decl.source.start.line - 1, decl.source.start.column);
183
201
  if (!local && !isSharedToken(ref.name)) report(file, "token-name", `${ref.name} does not follow ADS's fixed token naming contract.`, offset.line + decl.source.start.line - 1, decl.source.start.column);
@@ -203,6 +221,8 @@ export function checkProject(directory, { trackingRoot } = {}) {
203
221
  const role = adsFileRole(file);
204
222
  const roleExtension=role==="contract"?/\.[cm]?ts$/.test(file):["fixture","fixtures"].includes(role)?/\.(?:[cm]?[jt]sx?|json)$/.test(file):/\.[cm]?[jt]sx?$/.test(file);
205
223
  if (role && !configurationScripts.has(file) && (!["contract", "scenario", "fixture", "fixtures", "helpers", "test", "spec", "behavior.spec"].includes(role)||!roleExtension)) report(file, "development-role", `Unknown .ads. role or unsupported extension: ${role}. Use a TypeScript contract, a script scenario/fixture/helpers/test/behavior.spec, or JSON fixture; marking development code does not grant styling or mutation permissions.`);
224
+ // The generated theme sheet and palette are checked for freshness with the tokens, not authored.
225
+ if (generatedThemeFiles.some(generated => file === path.join(dsRoot, config.tokenDir, generated))) continue;
206
226
  if (file.endsWith(".css") && isInside(path.join(dsRoot, config.tokenDir), file) && !isDevelopmentFile(file, options)) { checkCss(file, readFileSync(file, "utf8"), undefined, true); continue; }
207
227
  if (file.endsWith(".html")) { inspectHtml(readFileSync(file, "utf8"), (rule, message, line) => report(file, rule, message, line)); continue; }
208
228
  if (file.endsWith(".css")) {
@@ -214,6 +234,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
214
234
  if (!source) continue;
215
235
  advisories.push(...pointerCaptureAdvisories(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
216
236
  advisories.push(...atomicCompositionReview(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
237
+ if (["components", "patterns"].some(section => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options)) advisories.push(...renderColorProbe(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
217
238
  for (const diagnostic of program.getSyntacticDiagnostics(source)) {
218
239
  const position = source.getLineAndCharacterOfPosition(diagnostic.start ?? 0);
219
240
  report(file, "source-syntax", ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"), position.line + 1, position.character + 1);
@@ -272,6 +293,12 @@ export function checkProject(directory, { trackingRoot } = {}) {
272
293
  function checkSvgAttribute(node, name) {
273
294
  if (svgPresentation.has(name)) nodeReport(node, "svg-attribute", `Native Preact SVG needs ${name.replace(/[A-Z]/g, letter => "-" + letter.toLowerCase())}; React-style ${name} is not normalized by its native renderer.`);
274
295
  }
296
+ const lightDarkLiterals = ["components", "patterns"].some(section => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options);
297
+ function inLinariaTemplate(node) {
298
+ const template = ts.isTemplateMiddle(node) || ts.isTemplateTail(node) ? node.parent.parent : node.parent;
299
+ const tagged = ts.isTemplateExpression(template) ? template.parent : template;
300
+ return ts.isTaggedTemplateExpression(tagged) && isLinariaTag(tagged.tag);
301
+ }
275
302
  function visit(node) {
276
303
  if (nativePreact && ts.isJsxAttribute(node) && ts.isIdentifier(node.name)) {
277
304
  const parent = node.parent.parent;
@@ -325,6 +352,10 @@ export function checkProject(directory, { trackingRoot } = {}) {
325
352
  if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "className" && node.initializer) {
326
353
  inspectClass(node.initializer);
327
354
  }
355
+ // Runtime inline values (style objects, inline custom properties, <style> text) give
356
+ // per-theme values with the generated themed(), not light-dark(); Linaria templates are
357
+ // checked as CSS above.
358
+ if (lightDarkLiterals && (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node) || ts.isTemplateHead(node) || ts.isTemplateMiddle(node) || ts.isTemplateTail(node)) && /\blight-dark\(/i.test(node.text) && !inLinariaTemplate(node)) nodeReport(node, "theme-light-dark", `Give per-theme values as token halves (--x-light, --x-dark); light-dark() is limited to two schemes; for runtime values use themed() from ${config.tokenDir}/${generatedPaletteFile}.`, { severity: findingSeverity("theme-light-dark") });
328
359
  if (ts.isTaggedTemplateExpression(node) && isLinariaTag(node.tag)) {
329
360
  const template = node.template;
330
361
  const texts = ts.isNoSubstitutionTemplateLiteral(template) ? [template.text] : template.templateSpans.reduce((prefixes,span)=>{const parts=designValues(span.expression);return prefixes.flatMap(prefix=>(parts.length?parts:["__ds_expression__"]).map(value=>prefix+value+span.literal.text)).slice(0,32);},[template.head.text]);
@@ -336,10 +367,10 @@ export function checkProject(directory, { trackingRoot } = {}) {
336
367
  visit(source);
337
368
  }
338
369
  inspectDesignAliases(layerStyles,options,report);
339
- // Bounded clients should see actionable warnings before source-analysis limits.
340
370
  for (const { file, css, offset } of layerStyles) layers.inspectStyles(file, css, offset);
341
- advisories.push(...(tokenInventory.advisories??[]), ...assetAdvisories);
342
- advisories.sort((first, second) => Number(first.severity === "info") - Number(second.severity === "info"));
343
- const uniqueDiagnostics=[...new Map(diagnostics.map(diagnostic=>[JSON.stringify([diagnostic.file,diagnostic.rule,diagnostic.line,diagnostic.column,diagnostic.message]),diagnostic])).values()];
344
- return architectureEvidence({ ok: uniqueDiagnostics.length === 0, diagnostics:uniqueDiagnostics, ...(advisories.length ? { advisories } : {}) });
371
+ advisories.push(...(tokenInventory.advisories??[]), ...assetAdvisories, ...a11ySourceAdvisories(options));
372
+ // Errors block by class; bounded clients see review items before informational limits.
373
+ const routed=routeFindings(diagnostics,advisories);
374
+ const uniqueDiagnostics=[...new Map(routed.diagnostics.map(diagnostic=>[JSON.stringify([diagnostic.file,diagnostic.rule,diagnostic.line,diagnostic.column,diagnostic.message]),diagnostic])).values()];
375
+ return architectureEvidence({ ok: uniqueDiagnostics.length === 0, diagnostics:uniqueDiagnostics, ...(routed.advisories.length ? { advisories: routed.advisories } : {}) });
345
376
  }
package/dist/cli.mjs CHANGED
@@ -20,8 +20,13 @@ Usage: ads create <directory> --framework react|preact New design-system proje
20
20
  --policy acceptance|validation (default validation)
21
21
  behaviors [dir] Inspect behavior contracts and current verification evidence
22
22
  verify [directory] Run registered behavior checks (--unit and --check select)
23
+ audit [directory] Run axe-core in each rendered scenario, once per brand and theme
24
+ (--scenario, --theme and --brand select; findings are errors)
23
25
  tokens [directory] Inspect local token values and theme definitions
24
- assets [directory] Generate standard web icons in .ds/assets from assets.iconSource
26
+ --format dtcg prints them as W3C Design Tokens JSON;
27
+ --theme <name> exports that theme's values (default: the first)
28
+ --brand <name> exports that brand's values (default: the first)
29
+ assets [directory] Generate configured brand assets, glyphs, themes.generated.css and .ts
25
30
  lint-config [dir] Generate .ds/oxlintrc.json with core and project plugins
26
31
  mcp [directory] Serve stdio MCP tools/Apps and the local showcase website
27
32
  showcase [directory] Serve the built-in MCP client website (no stdio connection)
@@ -37,6 +42,7 @@ Usage: ads create <directory> --framework react|preact New design-system proje
37
42
  --mutations MCP only: enable guarded ADS source editing
38
43
  --unit id Verify only: select one discovered behavior contract owner
39
44
  --check id Verify only: select a registered check (repeatable)
45
+ --scenario id Audit only: select a discovered scenario (repeatable)
40
46
  --changed Validate only: select affected checks since the last full audit
41
47
  --fresh Check/validate: execute batch checks without task-cache reads
42
48
 
@@ -53,9 +59,11 @@ async function main(args) {
53
59
  let packageManager;
54
60
  let framework;
55
61
  let name;
62
+ let format, theme;
63
+ let brand;
56
64
  let port;
57
65
  let unit;
58
- const selectedChecks = [];
66
+ const selectedChecks = [], selectedScenarios = [];
59
67
  let showcase = true;
60
68
  let mutations = false;
61
69
  let changed = false, watched = false, policy, fresh = false;
@@ -75,6 +83,11 @@ async function main(args) {
75
83
  if (argument === "--unit") { if (unit) throw new Error("Specify one --unit."); unit = value; }
76
84
  else selectedChecks.push(value);
77
85
  }
86
+ else if (argument === "--scenario") {
87
+ const value = args[++index];
88
+ if (!value || value.startsWith("-")) throw new Error("--scenario needs a discovered scenario ID.");
89
+ selectedScenarios.push(value);
90
+ }
78
91
  else if (argument === "--port") {
79
92
  const value = args[++index];
80
93
  if (port !== undefined || !/^\d+$/.test(value ?? "") || Number(value) > 65535) throw new Error("--port requires one port between 0 and 65535.");
@@ -86,6 +99,15 @@ async function main(args) {
86
99
  } else if (argument === "--package-manager") {
87
100
  if (packageManager !== undefined || !args[index + 1] || args[index + 1].startsWith("-")) throw new Error("Specify one package manager after --package-manager: npm or bun.");
88
101
  packageManager = args[++index];
102
+ } else if (argument === "--theme") {
103
+ if (theme !== undefined || !args[index + 1] || args[index + 1].startsWith("--")) throw new Error("Specify --theme <name>.");
104
+ theme = args[++index];
105
+ } else if (argument === "--brand") {
106
+ if (brand !== undefined || !args[index + 1] || args[index + 1].startsWith("--")) throw new Error("Specify --brand <name>.");
107
+ brand = args[++index];
108
+ } else if (argument === "--format") {
109
+ if (format !== undefined || args[index + 1] !== "dtcg") throw new Error("Specify --format dtcg (the W3C Design Tokens format).");
110
+ format = args[++index];
89
111
  } else if (argument === "--name") {
90
112
  if (name !== undefined || !args[index + 1] || args[index + 1].startsWith("-")) throw new Error("Specify one package name after --name.");
91
113
  name = args[++index];
@@ -115,6 +137,10 @@ async function main(args) {
115
137
  if (packageManager !== undefined && !setup) throw new Error("--package-manager is supported only by create and init.");
116
138
  if (framework !== undefined && !setup) throw new Error("--framework is supported only by create and init.");
117
139
  if (name !== undefined && command !== "create") throw new Error("--name is supported only by create.");
140
+ if (format !== undefined && command !== "tokens") throw new Error("--format is supported only by tokens.");
141
+ if (theme !== undefined && format !== "dtcg" && command !== "audit") throw new Error("--theme is supported only by tokens --format dtcg and audit.");
142
+ if (brand !== undefined && format !== "dtcg" && command !== "audit") throw new Error("--brand is supported only by tokens --format dtcg and audit.");
143
+ if (selectedScenarios.length && command !== "audit") throw new Error("--scenario is supported only by audit.");
118
144
  if (command === "create" && !directory) throw new Error("Name the new project's folder: ads create <directory> --framework react|preact.");
119
145
  if (command === "init" && directory) throw new Error("Run ads init inside the project, without a directory argument.");
120
146
  if ((unit || selectedChecks.length) && command !== "verify") throw new Error("--unit and --check are supported only by verify.");
@@ -138,25 +164,46 @@ async function main(args) {
138
164
  }
139
165
  else if (command === "behaviors") { const {behaviorStatus}=await import("./verification.mjs"); const {loadConfig}=await import("./config.mjs"); result=behaviorStatus(loadConfig(target)); }
140
166
  else if (command === "verify") { const {createVerificationController}=await import("./verification.mjs"); const verification=createVerificationController(target); try {result=await verification.run({...(unit?{unit}:{}),...(selectedChecks.length?{checks:selectedChecks}:{})});} finally {await verification.close();} }
167
+ else if (command === "audit") {
168
+ const { runBrowserAudit } = await import("./browser-audit.mjs");
169
+ const controller = new AbortController(), abort = () => controller.abort();
170
+ process.once("SIGINT", abort); process.once("SIGTERM", abort);
171
+ try {
172
+ const { routeFindings } = await import("./finding-rules.mjs");
173
+ const audit = await runBrowserAudit(target, { scenarios: selectedScenarios, themes: theme ? [theme] : undefined, brands: brand ? [brand] : undefined, signal: controller.signal });
174
+ // a11y-axe findings are errors, as in validation; any review-class finding stays nonblocking.
175
+ const routed = routeFindings([], audit.findings);
176
+ result = { ...audit, ok: !routed.diagnostics.length, findings: routed.advisories, diagnostics: routed.diagnostics };
177
+ }
178
+ finally { process.removeListener("SIGINT", abort); process.removeListener("SIGTERM", abort); }
179
+ }
180
+ else if (command === "tokens" && format === "dtcg") { const { exportTokensDtcg } = await import("./token-export.mjs"); console.log(JSON.stringify(exportTokensDtcg(target, { theme, brand }), null, 2)); return; }
141
181
  else if (command === "tokens") result = inspectTokens(target);
142
- else if (command === "assets") result = await generateBrandAssets(target);
182
+ else if (command === "assets") { const { refreshThemesCss } = await import("./themes-watch.mjs"); const themes = refreshThemesCss(target); result = { ...await generateBrandAssets(target), themes: { file: themes.file, written: themes.files[0]?.written ?? false, ...(themes.skipped ? { skipped: themes.skipped } : {}) }, ...(themes.files[1] ? { palette: { file: themes.files[1].file, written: themes.files[1].written } } : {}) }; }
143
183
  else if (command === "lint-config") result = generateLintConfig(target);
144
184
  else throw new Error(`Unknown command: ${command}. Run ads --help.`);
145
185
  if (json) console.log(JSON.stringify(result, null, 2));
146
186
  else if (command === "create") console.log(`Created ${result.name} in ${target}\nFramework: ${result.framework}\nNext: cd ${((folder) => /[\s'"$`\\]/.test(folder) ? JSON.stringify(folder) : folder)(path.relative(process.cwd(), target) || ".")} && ${result.packageManager} install && ${result.packageManager} run build && ${result.packageManager} run dev:showcase`);
147
187
  else if (command === "init") console.log(`Initialized ${target}\nFramework: ${result.framework}\nAdded ${result.toolDependency.name} (${result.toolDependency.spec}) as a development dependency.\nRun ${result.packageManager} install and ${result.packageManager} run build; the build runs ADS checks and generates configured brand assets automatically.`);
148
- else if (command === "assets") console.log(result.skipped ? "No assets.iconSource configured; brand generation skipped." : `Generated ${result.files.length} brand assets in ${result.directory}.`);
188
+ else if (command === "assets") {
189
+ console.log(result.skipped ? "No assets.iconSource configured; brand generation skipped." : `Generated ${result.files.length} brand assets in ${result.directory}.`);
190
+ const themesFile = path.relative(process.cwd(), result.themes.file) || result.themes.file;
191
+ console.log(result.themes.skipped ? `Skipped ${themesFile}: the token sheets still use the old theme form.` : `${result.themes.written ? "Wrote" : "Unchanged"} ${themesFile}.`);
192
+ if (result.palette) console.log(`${result.palette.written ? "Wrote" : "Unchanged"} ${path.relative(process.cwd(), result.palette.file) || result.palette.file}.`);
193
+ }
149
194
  else if (command === "lint-config") console.log(`Generated ${result.file}\nUse this optional configuration only in the project linter you choose to run.`);
150
195
  else if (command === "behaviors") console.log(JSON.stringify(result, null, 2));
196
+ else if (command === "audit") { const { findingCounts } = await import("./finding-rules.mjs"); console.log(`ADS accessibility audit (${result.engine}): ${findingCounts(result.diagnostics.length, result.findings.length)} across ${result.scenarios} scenarios × ${result.themes.length} themes (${result.themes.join(", ")})${result.brands ? ` × ${result.brands.length} brands (${result.brands.join(", ")})` : ""}.`); for (const finding of result.findings) console.error(`${finding.file}:${finding.line}:${finding.column} [${finding.severity}:${finding.rule}] ${finding.message}`); }
151
197
  else if (command === "verify") { for (const item of result.results) console.log(`${item.unit}#${item.check}: ${item.status} (${item.profile})`); }
152
198
  else if (command === "validate") {console.log(`ADS ${result.policy} ${result.ok?"passed":"failed"}: ${result.scope}${result.fallback?` (${result.fallback})`:""}`);for(const check of result.checks)console.log(`${check.name}: ${check.skipped?"skipped":check.passed?"passed":"failed"}${check.reason?` (${check.reason})`:""}`);}
153
199
  else if (command === "tokens") {
154
- for (const token of result.tokens) console.log(`${token.name}${token.type ? ` (${token.type})` : ""}: ${token.definitions.map((entry) => `${entry.scope}: ${entry.value}`).join("; ")}`);
155
- } else if (result.ok) console.log(`ADS check passed: ${target}`);
200
+ for (const token of result.tokens) console.log(`${token.name}${token.type ? ` (${token.type})` : ""}: ${token.definitions.map((entry) => `${entry.scope}${entry.theme ? ` (${entry.theme})` : ""}: ${entry.value}`).join("; ")}`);
201
+ } else if (command === "check") { const { findingCounts } = await import("./finding-rules.mjs"); console.log(`ADS check ${result.ok ? "passed" : "failed"}: ${target} (${findingCounts(result.diagnostics?.length ?? 0, (result.advisories ?? []).filter(advisory => advisory.severity === "review").length)})`); }
202
+ else if (result.ok) console.log(`ADS check passed: ${target}`);
156
203
  if (!json && result.diagnostics?.length) {
157
- for (const diagnostic of result.diagnostics) console.error(`${diagnostic.file}:${diagnostic.line}:${diagnostic.column} [${diagnostic.rule}] ${diagnostic.message}`);
204
+ for (const diagnostic of result.diagnostics) console.error(`${diagnostic.file}:${diagnostic.line}:${diagnostic.column} [error:${diagnostic.rule}] ${diagnostic.message}`);
158
205
  }
159
- if (!json) for (const advisory of result.advisories ?? []) if(advisory.severity!=="info") console.error(`${advisory.file}:${advisory.line}:${advisory.column} [${advisory.severity ?? "advisory"}:${advisory.rule}] ${advisory.message}`);
206
+ if (!json) for (const advisory of result.advisories ?? []) if(advisory.severity!=="info") console.error(`${advisory.file}:${advisory.line}:${advisory.column} [${advisory.severity ?? "review"}:${advisory.rule}] ${advisory.message}`);
160
207
  if (result.ok === false || result.diagnostics?.length) process.exitCode = 1;
161
208
  }
162
209