@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.
- package/README.md +21 -11
- package/dist/a11y.mjs +4 -2
- package/dist/assets.mjs +20 -15
- package/dist/atomic-composition.mjs +3 -2
- package/dist/brand-assets.mjs +48 -11
- package/dist/brands.mjs +82 -0
- package/dist/browser-audit/worker.mjs +51 -0
- package/dist/browser-audit.mjs +147 -0
- package/dist/capture/worker.mjs +1 -0
- package/dist/capture-store.mjs +2 -0
- package/dist/capture.mjs +7 -4
- package/dist/check.mjs +38 -8
- package/dist/cli.mjs +45 -10
- package/dist/color-values.mjs +325 -0
- package/dist/config.mjs +16 -2
- package/dist/control-padding.mjs +93 -0
- package/dist/design-values.mjs +3 -2
- package/dist/finding-rules.mjs +61 -0
- package/dist/foundation.mjs +17 -4
- package/dist/icons.mjs +107 -0
- package/dist/init.mjs +3 -0
- package/dist/mcp/apps.mjs +9 -6
- package/dist/mcp/context.mjs +1 -1
- package/dist/mcp/drafts.mjs +3 -0
- package/dist/mcp/mutations.mjs +40 -1
- package/dist/mcp/preview-widget.bundle.js +36 -36
- package/dist/mcp/project-widget.bundle.js +12 -12
- package/dist/mcp/server.mjs +23 -11
- package/dist/mcp/widget.bundle.js +17 -17
- package/dist/palette-generated.mjs +180 -0
- package/dist/preview-resources.mjs +12 -3
- package/dist/render-color-probe.mjs +148 -0
- package/dist/runtime-contracts.mjs +14 -4
- package/dist/scenarios.mjs +1 -1
- package/dist/showcase/client.bundle.js +28 -28
- package/dist/showcase/icons.js +146 -0
- package/dist/showcase/index.html +2 -1
- package/dist/showcase/style.css +19 -2
- package/dist/skills/README.md +2 -1
- package/dist/skills/ads-break-ui/SKILL.md +6 -5
- package/dist/skills/ads-break-ui/references/atomic-styles.md +12 -12
- package/dist/skills/ads-break-ui/references/contracts.md +13 -10
- package/dist/skills/ads-break-ui/references/design-data.md +137 -29
- package/dist/skills/ads-break-ui/references/drafts.md +3 -1
- package/dist/skills/ads-break-ui/references/guarded-editing.md +3 -2
- package/dist/skills/ads-break-ui/references/validation.md +13 -4
- package/dist/skills/ads-designer/SKILL.md +23 -16
- package/dist/skills/ads-designer/references/accessibility.md +41 -5
- package/dist/skills/ads-designer/references/atomic-styles.md +12 -12
- package/dist/skills/ads-designer/references/branding.md +37 -10
- package/dist/skills/ads-designer/references/cli.md +8 -2
- package/dist/skills/ads-designer/references/contracts.md +13 -10
- package/dist/skills/ads-designer/references/design-data.md +137 -29
- package/dist/skills/ads-designer/references/drafts.md +3 -1
- package/dist/skills/ads-designer/references/guarded-editing.md +3 -2
- package/dist/skills/ads-designer/references/validation.md +13 -4
- package/dist/skills/ads-import/SKILL.md +9 -8
- package/dist/skills/ads-import/references/atomic-styles.md +12 -12
- package/dist/skills/ads-import/references/cli.md +8 -2
- package/dist/skills/ads-import/references/contracts.md +13 -10
- package/dist/skills/ads-import/references/design-data.md +137 -29
- package/dist/skills/ads-import/references/drafts.md +3 -1
- package/dist/skills/ads-import/references/guarded-editing.md +3 -2
- package/dist/skills/ads-import/references/tokens.md +7 -3
- package/dist/skills/ads-import/references/validation.md +13 -4
- package/dist/skills/ads-motion/SKILL.md +6 -5
- package/dist/skills/ads-motion/references/atomic-styles.md +12 -12
- package/dist/skills/ads-motion/references/contracts.md +13 -10
- package/dist/skills/ads-motion/references/design-data.md +137 -29
- package/dist/skills/ads-motion/references/drafts.md +3 -1
- package/dist/skills/ads-motion/references/guarded-editing.md +3 -2
- package/dist/skills/ads-motion/references/validation.md +13 -4
- package/dist/skills/ads-port/SKILL.md +6 -5
- package/dist/skills/ads-port/references/atomic-styles.md +12 -12
- package/dist/skills/ads-port/references/cli.md +8 -2
- package/dist/skills/ads-port/references/contracts.md +13 -10
- package/dist/skills/ads-port/references/design-data.md +137 -29
- package/dist/skills/ads-port/references/drafts.md +3 -1
- package/dist/skills/ads-port/references/guarded-editing.md +3 -2
- package/dist/skills/ads-port/references/validation.md +13 -4
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +11 -2
- package/dist/starters/react/ADS.md +43 -10
- package/dist/starters/react/README.md +14 -9
- package/dist/starters/react/design-system/assets/brand/README.md +8 -3
- package/dist/starters/react/design-system/assets/glyphs/README.md +4 -1
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +6 -1
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +3 -2
- package/dist/starters/react/design-system/components/Content/Icon/README.md +2 -1
- package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +3 -9
- package/dist/starters/react/design-system/components/Content/Logo/README.md +4 -2
- package/dist/starters/react/design-system/controllers/Palette/Palette.ts +164 -0
- package/dist/starters/react/design-system/index.ts +3 -0
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +2 -5
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +11 -2
- package/dist/starters/react/design-system/styles.css +1 -0
- package/dist/starters/react/design-system/tokens/base.css +8 -5
- package/dist/starters/react/design-system/tokens/colors.css +167 -175
- package/dist/starters/react/design-system/tokens/elevation.css +14 -21
- package/dist/starters/react/design-system/tokens/themes.generated.css +142 -0
- package/dist/starters/react/design-system/tokens/themes.generated.ts +402 -0
- package/dist/style-boundaries.mjs +2 -1
- package/dist/themes-generated.mjs +150 -0
- package/dist/themes-watch.mjs +42 -0
- package/dist/themes.mjs +214 -63
- package/dist/token-export.mjs +22 -11
- package/dist/token-policy.mjs +2 -1
- package/dist/token-quality.mjs +28 -25
- package/dist/tokens.mjs +27 -32
- package/dist/validation.mjs +17 -1
- package/dist/verification/browser.mjs +14 -3
- package/dist/verification.mjs +25 -4
- package/docs/ADS.md +41 -27
- package/docs/ARCHITECTURE.md +49 -22
- package/docs/CACHING.md +2 -3
- package/docs/CHANGELOG.md +117 -13
- package/docs/CONTRACTS.md +13 -10
- package/docs/GUIDE.md +94 -22
- package/docs/MCP.md +50 -30
- package/docs/benchmarks/bun-previews.md +5 -5
- package/docs/benchmarks/{gidi-preview-memory.md → preview-memory.md} +14 -12
- package/docs/benchmarks/turbo-poc.md +24 -6
- package/package.json +2 -1
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,12 +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;
|
|
83
|
+
const themes = project.options.config.themes, brands = project.options.config.brands;
|
|
84
84
|
for (const selection of project.apps) {
|
|
85
85
|
const theme = themes.find(item => item.name === (selection.theme ?? themes[0].name));
|
|
86
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"}.`);
|
|
87
89
|
const url = new URL(host.url); url.searchParams.set("scenario", selection.scenario); url.searchParams.set("capture", "1"); url.searchParams.set("theme", theme.name);
|
|
88
|
-
|
|
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 });
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
const request = path.join(temporary, "request.json"), report = path.join(temporary, "report.json"), runId = randomUUID();
|
|
@@ -104,7 +107,7 @@ export function createCaptureController(root) {
|
|
|
104
107
|
const bytes = readFileSync(file), metadata = await sharp(bytes).metadata();
|
|
105
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.");
|
|
106
109
|
const project = projects[app.projectIndex];
|
|
107
|
-
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 });
|
|
108
111
|
}
|
|
109
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.");
|
|
110
113
|
if (signal.aborted) throw new Error("Screenshot capture cancelled before publication.");
|
package/dist/check.mjs
CHANGED
|
@@ -5,6 +5,9 @@ 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";
|
|
10
13
|
import { a11ySourceAdvisories } from "./a11y.mjs";
|
|
@@ -35,6 +38,8 @@ import { createDesignValues, inspectDesignAliases, isColorKeyword } from "./desi
|
|
|
35
38
|
import { inspectTestBoundaries } from "./test-boundaries.mjs";
|
|
36
39
|
import { inspectBehaviorLibraries } from "./behavior-libraries.mjs";
|
|
37
40
|
import { inspectUsage } from "./usage.mjs";
|
|
41
|
+
import { controlPaddingAdvisories } from "./control-padding.mjs";
|
|
42
|
+
import { findingSeverity, routeFindings } from "./finding-rules.mjs";
|
|
38
43
|
|
|
39
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.";
|
|
40
45
|
const inlineStyleGuidance = `Own visual styles in component/pattern Linaria. ${scenarioLayoutGuidance} Reserve inlineStyleFiles for documented measured geometry, not demo layout.`;
|
|
@@ -54,10 +59,12 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
54
59
|
if (diagnostics.length) return architectureEvidence({ ok: false, diagnostics });
|
|
55
60
|
const tokenInventory = inspectTokens(root, options);
|
|
56
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));
|
|
57
64
|
diagnostics.push(...tokenInventory.diagnostics);
|
|
58
65
|
const assetFindings = inspectAssets(options);
|
|
59
|
-
diagnostics.push(...assetFindings.filter(finding => finding.severity
|
|
60
|
-
const assetAdvisories = assetFindings.filter(finding => finding.severity
|
|
66
|
+
diagnostics.push(...assetFindings.filter(finding => !finding.severity || finding.severity === "error"));
|
|
67
|
+
const assetAdvisories = assetFindings.filter(finding => finding.severity && finding.severity !== "error");
|
|
61
68
|
const resolveImport = importResolver(options);
|
|
62
69
|
const units = inspectUnits(options);
|
|
63
70
|
options.testOwner = file => units.owner(units.relative(path.relative(root,file)));
|
|
@@ -76,6 +83,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
76
83
|
const runtimeContracts = inspectRuntimeContracts(options, program);
|
|
77
84
|
diagnostics.push(...runtimeContracts.diagnostics);
|
|
78
85
|
const atomicCompositionReview = createAtomicCompositionReview(program, options);
|
|
86
|
+
const renderColorProbe = createRenderColorProbe(program);
|
|
79
87
|
const scenarioTrace = createScenarioTrace(program, options);
|
|
80
88
|
let scenarioSlot, scenarioSelector;
|
|
81
89
|
function report(file, rule, message, line = 1, column = 1, detail = {}) {
|
|
@@ -96,7 +104,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
96
104
|
inspectControllers(options, program, report, behaviors.contracts);
|
|
97
105
|
// The foundation remains a fixed import-only entry, not an extra styling layer.
|
|
98
106
|
const foundationEntry = path.join(dsRoot, config.stylesEntry);
|
|
99
|
-
const registeredProperties=new Map();
|
|
107
|
+
const registeredProperties=new Map(), controlPaddingSeen=new Set();
|
|
100
108
|
function checkRegistrations(file,css,offset={line:1}){
|
|
101
109
|
css.walkAtRules(/^property$/i,rule=>{
|
|
102
110
|
const line=offset.line+(rule.source?.start.line??1)-1;
|
|
@@ -124,7 +132,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
124
132
|
const imports = css.nodes.filter((node) => node.type !== "comment");
|
|
125
133
|
const expected = foundationFiles.filter((name) => name !== "fonts.css" || existsSync(path.join(dsRoot, config.tokenDir, name))).map((name) => path.join(dsRoot, config.tokenDir, name));
|
|
126
134
|
const actual = imports.map(node => foundationImportTarget(node, foundationEntry));
|
|
127
|
-
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
|
|
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.");
|
|
128
136
|
} catch (error) { report(foundationEntry, "css-syntax", error.reason ?? error.message, error.line ?? 1); }
|
|
129
137
|
function checkCss(file, text, offset = { line: 1, column: 1 }, foundation = false) {
|
|
130
138
|
let css;
|
|
@@ -133,6 +141,11 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
133
141
|
layers.collectComponentStyles(file, css);
|
|
134
142
|
layerStyles.push({ file, css, offset });
|
|
135
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
|
+
}
|
|
136
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.");
|
|
137
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);
|
|
138
151
|
css.walkAtRules("import", (rule) => {
|
|
@@ -151,6 +164,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
151
164
|
if (violation) report(file, "foundation-selector", violation, rule.source.start.line, rule.source.start.column);
|
|
152
165
|
}
|
|
153
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") });
|
|
154
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);
|
|
155
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);
|
|
156
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);
|
|
@@ -161,6 +175,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
161
175
|
});
|
|
162
176
|
css.walkDecls((decl) => {
|
|
163
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") });
|
|
164
179
|
if (foundation && decl.prop.startsWith("--")) {
|
|
165
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);
|
|
166
181
|
return; // Definition names, values and aliases are validated by inspectTokens.
|
|
@@ -179,6 +194,8 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
179
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);
|
|
180
195
|
continue;
|
|
181
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; }
|
|
182
199
|
const local = /^(?:--ds-|--ux-|--showcase-)/.test(ref.name);
|
|
183
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);
|
|
184
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);
|
|
@@ -204,6 +221,8 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
204
221
|
const role = adsFileRole(file);
|
|
205
222
|
const roleExtension=role==="contract"?/\.[cm]?ts$/.test(file):["fixture","fixtures"].includes(role)?/\.(?:[cm]?[jt]sx?|json)$/.test(file):/\.[cm]?[jt]sx?$/.test(file);
|
|
206
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;
|
|
207
226
|
if (file.endsWith(".css") && isInside(path.join(dsRoot, config.tokenDir), file) && !isDevelopmentFile(file, options)) { checkCss(file, readFileSync(file, "utf8"), undefined, true); continue; }
|
|
208
227
|
if (file.endsWith(".html")) { inspectHtml(readFileSync(file, "utf8"), (rule, message, line) => report(file, rule, message, line)); continue; }
|
|
209
228
|
if (file.endsWith(".css")) {
|
|
@@ -215,6 +234,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
215
234
|
if (!source) continue;
|
|
216
235
|
advisories.push(...pointerCaptureAdvisories(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
|
|
217
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 })));
|
|
218
238
|
for (const diagnostic of program.getSyntacticDiagnostics(source)) {
|
|
219
239
|
const position = source.getLineAndCharacterOfPosition(diagnostic.start ?? 0);
|
|
220
240
|
report(file, "source-syntax", ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"), position.line + 1, position.character + 1);
|
|
@@ -273,6 +293,12 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
273
293
|
function checkSvgAttribute(node, name) {
|
|
274
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.`);
|
|
275
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
|
+
}
|
|
276
302
|
function visit(node) {
|
|
277
303
|
if (nativePreact && ts.isJsxAttribute(node) && ts.isIdentifier(node.name)) {
|
|
278
304
|
const parent = node.parent.parent;
|
|
@@ -326,6 +352,10 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
326
352
|
if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "className" && node.initializer) {
|
|
327
353
|
inspectClass(node.initializer);
|
|
328
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") });
|
|
329
359
|
if (ts.isTaggedTemplateExpression(node) && isLinariaTag(node.tag)) {
|
|
330
360
|
const template = node.template;
|
|
331
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]);
|
|
@@ -337,10 +367,10 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
337
367
|
visit(source);
|
|
338
368
|
}
|
|
339
369
|
inspectDesignAliases(layerStyles,options,report);
|
|
340
|
-
// Bounded clients should see actionable warnings before source-analysis limits.
|
|
341
370
|
for (const { file, css, offset } of layerStyles) layers.inspectStyles(file, css, offset);
|
|
342
371
|
advisories.push(...(tokenInventory.advisories??[]), ...assetAdvisories, ...a11ySourceAdvisories(options));
|
|
343
|
-
|
|
344
|
-
const
|
|
345
|
-
|
|
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 } : {}) });
|
|
346
376
|
}
|
package/dist/cli.mjs
CHANGED
|
@@ -20,10 +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
26
|
--format dtcg prints them as W3C Design Tokens JSON;
|
|
25
27
|
--theme <name> exports that theme's values (default: the first)
|
|
26
|
-
|
|
28
|
+
--brand <name> exports that brand's values (default: the first)
|
|
29
|
+
assets [directory] Generate configured brand assets, glyphs, themes.generated.css and .ts
|
|
27
30
|
lint-config [dir] Generate .ds/oxlintrc.json with core and project plugins
|
|
28
31
|
mcp [directory] Serve stdio MCP tools/Apps and the local showcase website
|
|
29
32
|
showcase [directory] Serve the built-in MCP client website (no stdio connection)
|
|
@@ -39,6 +42,7 @@ Usage: ads create <directory> --framework react|preact New design-system proje
|
|
|
39
42
|
--mutations MCP only: enable guarded ADS source editing
|
|
40
43
|
--unit id Verify only: select one discovered behavior contract owner
|
|
41
44
|
--check id Verify only: select a registered check (repeatable)
|
|
45
|
+
--scenario id Audit only: select a discovered scenario (repeatable)
|
|
42
46
|
--changed Validate only: select affected checks since the last full audit
|
|
43
47
|
--fresh Check/validate: execute batch checks without task-cache reads
|
|
44
48
|
|
|
@@ -56,9 +60,10 @@ async function main(args) {
|
|
|
56
60
|
let framework;
|
|
57
61
|
let name;
|
|
58
62
|
let format, theme;
|
|
63
|
+
let brand;
|
|
59
64
|
let port;
|
|
60
65
|
let unit;
|
|
61
|
-
const selectedChecks = [];
|
|
66
|
+
const selectedChecks = [], selectedScenarios = [];
|
|
62
67
|
let showcase = true;
|
|
63
68
|
let mutations = false;
|
|
64
69
|
let changed = false, watched = false, policy, fresh = false;
|
|
@@ -78,6 +83,11 @@ async function main(args) {
|
|
|
78
83
|
if (argument === "--unit") { if (unit) throw new Error("Specify one --unit."); unit = value; }
|
|
79
84
|
else selectedChecks.push(value);
|
|
80
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
|
+
}
|
|
81
91
|
else if (argument === "--port") {
|
|
82
92
|
const value = args[++index];
|
|
83
93
|
if (port !== undefined || !/^\d+$/.test(value ?? "") || Number(value) > 65535) throw new Error("--port requires one port between 0 and 65535.");
|
|
@@ -92,6 +102,9 @@ async function main(args) {
|
|
|
92
102
|
} else if (argument === "--theme") {
|
|
93
103
|
if (theme !== undefined || !args[index + 1] || args[index + 1].startsWith("--")) throw new Error("Specify --theme <name>.");
|
|
94
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];
|
|
95
108
|
} else if (argument === "--format") {
|
|
96
109
|
if (format !== undefined || args[index + 1] !== "dtcg") throw new Error("Specify --format dtcg (the W3C Design Tokens format).");
|
|
97
110
|
format = args[++index];
|
|
@@ -125,7 +138,9 @@ async function main(args) {
|
|
|
125
138
|
if (framework !== undefined && !setup) throw new Error("--framework is supported only by create and init.");
|
|
126
139
|
if (name !== undefined && command !== "create") throw new Error("--name is supported only by create.");
|
|
127
140
|
if (format !== undefined && command !== "tokens") throw new Error("--format is supported only by tokens.");
|
|
128
|
-
if (theme !== undefined && format !== "dtcg") throw new Error("--theme is supported only by tokens --format dtcg.");
|
|
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.");
|
|
129
144
|
if (command === "create" && !directory) throw new Error("Name the new project's folder: ads create <directory> --framework react|preact.");
|
|
130
145
|
if (command === "init" && directory) throw new Error("Run ads init inside the project, without a directory argument.");
|
|
131
146
|
if ((unit || selectedChecks.length) && command !== "verify") throw new Error("--unit and --check are supported only by verify.");
|
|
@@ -149,26 +164,46 @@ async function main(args) {
|
|
|
149
164
|
}
|
|
150
165
|
else if (command === "behaviors") { const {behaviorStatus}=await import("./verification.mjs"); const {loadConfig}=await import("./config.mjs"); result=behaviorStatus(loadConfig(target)); }
|
|
151
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();} }
|
|
152
|
-
else if (command === "
|
|
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; }
|
|
153
181
|
else if (command === "tokens") result = inspectTokens(target);
|
|
154
|
-
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 } } : {}) }; }
|
|
155
183
|
else if (command === "lint-config") result = generateLintConfig(target);
|
|
156
184
|
else throw new Error(`Unknown command: ${command}. Run ads --help.`);
|
|
157
185
|
if (json) console.log(JSON.stringify(result, null, 2));
|
|
158
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`);
|
|
159
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.`);
|
|
160
|
-
else if (command === "assets")
|
|
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
|
+
}
|
|
161
194
|
else if (command === "lint-config") console.log(`Generated ${result.file}\nUse this optional configuration only in the project linter you choose to run.`);
|
|
162
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}`); }
|
|
163
197
|
else if (command === "verify") { for (const item of result.results) console.log(`${item.unit}#${item.check}: ${item.status} (${item.profile})`); }
|
|
164
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})`:""}`);}
|
|
165
199
|
else if (command === "tokens") {
|
|
166
|
-
for (const token of result.tokens) console.log(`${token.name}${token.type ? ` (${token.type})` : ""}: ${token.definitions.map((entry) => `${entry.scope}: ${entry.value}`).join("; ")}`);
|
|
167
|
-
} else if (
|
|
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}`);
|
|
168
203
|
if (!json && result.diagnostics?.length) {
|
|
169
|
-
for (const diagnostic of result.diagnostics) console.error(`${diagnostic.file}:${diagnostic.line}:${diagnostic.column} [
|
|
204
|
+
for (const diagnostic of result.diagnostics) console.error(`${diagnostic.file}:${diagnostic.line}:${diagnostic.column} [error:${diagnostic.rule}] ${diagnostic.message}`);
|
|
170
205
|
}
|
|
171
|
-
if (!json) for (const advisory of result.advisories ?? []) if(advisory.severity!=="info") console.error(`${advisory.file}:${advisory.line}:${advisory.column} [${advisory.severity ?? "
|
|
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}`);
|
|
172
207
|
if (result.ok === false || result.diagnostics?.length) process.exitCode = 1;
|
|
173
208
|
}
|
|
174
209
|
|