@reqvire-org/ads 0.3.7 → 0.3.9

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 (43) hide show
  1. package/dist/atomic-composition.mjs +85 -54
  2. package/dist/atomic-trace.mjs +92 -0
  3. package/dist/bootstrap-ds/scripts/build-mcp-previews.mjs +2 -1
  4. package/dist/bootstrap-ds/vite.config.ts +2 -1
  5. package/dist/check.mjs +14 -3
  6. package/dist/linaria/atomic-css.cjs +2 -0
  7. package/dist/linaria/atomic-styled.cjs +2 -0
  8. package/dist/linaria/preserve-values.cjs +32 -0
  9. package/dist/linaria.d.mts +1 -0
  10. package/dist/linaria.mjs +9 -0
  11. package/dist/mcp/preview-widget.bundle.js +1 -1
  12. package/dist/mcp/resource-loader.js +5 -2
  13. package/dist/mcp/server.mjs +4 -2
  14. package/dist/scenario-trace.mjs +149 -0
  15. package/dist/scenarios-compiler.mjs +2 -1
  16. package/dist/scenarios.mjs +22 -6
  17. package/dist/skills/ads-break-ui/SKILL.md +10 -2
  18. package/dist/skills/ads-break-ui/references/atomic-styles.md +122 -7
  19. package/dist/skills/ads-break-ui/references/scenarios.md +83 -0
  20. package/dist/skills/ads-designer/SKILL.md +13 -3
  21. package/dist/skills/ads-designer/assets/bootstrap-ds/scripts/build-mcp-previews.mjs +2 -1
  22. package/dist/skills/ads-designer/assets/bootstrap-ds/vite.config.ts +2 -1
  23. package/dist/skills/ads-designer/references/atomic-styles.md +122 -7
  24. package/dist/skills/ads-designer/references/scenarios.md +83 -0
  25. package/dist/skills/ads-import/SKILL.md +10 -2
  26. package/dist/skills/ads-import/references/atomic-styles.md +122 -7
  27. package/dist/skills/ads-import/references/scenarios.md +83 -0
  28. package/dist/skills/ads-migrate/SKILL.md +10 -2
  29. package/dist/skills/ads-migrate/references/atomic-styles.md +122 -7
  30. package/dist/skills/ads-migrate/references/scenarios.md +83 -0
  31. package/dist/skills/ads-motion/SKILL.md +10 -2
  32. package/dist/skills/ads-motion/references/atomic-styles.md +122 -7
  33. package/dist/skills/ads-motion/references/scenarios.md +83 -0
  34. package/dist/source-values.mjs +247 -0
  35. package/dist/verification/browser.mjs +21 -12
  36. package/dist/verification/playwright-reporter.cjs +6 -2
  37. package/dist/verification.mjs +8 -3
  38. package/docs/ADS.md +18 -5
  39. package/docs/ARCHITECTURE.md +19 -0
  40. package/docs/BEHAVIORS.md +15 -1
  41. package/docs/CHANGELOG.md +28 -1
  42. package/docs/MCP.md +18 -0
  43. package/package.json +10 -1
@@ -85,7 +85,8 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
85
85
  return [
86
86
  { uri: GUIDE_URI, name: "Start here: design-system workflow", description: "Read first for UI/ADS tasks, especially when only resource access is exposed. Explains the exact workspace, tool sequence, skill selection, previews, project commands and fallback.", mimeType: "text/markdown" },
87
87
  { uri: "ads://guides/behaviors", name: "Controller and behavioral verification guide", mimeType: "text/markdown" },
88
- { uri: "ads://guides/atomic-styles", name: "Atomic style composition: conflicts, prevention and fixes", mimeType: "text/markdown" },
88
+ { uri: "ads://guides/atomic-styles", name: "Atomic styles: composition conflicts and custom-property extraction", mimeType: "text/markdown" },
89
+ { uri: "ads://guides/scenarios", name: "Scenario coverage and public class-helper contracts", mimeType: "text/markdown" },
89
90
  { uri: `${PROJECT_URI}/status`, name: "ADS project status", mimeType: "application/json" },
90
91
  { uri: BUILD_URI, name: "Preview build status and diagnostics", mimeType: "application/json" },
91
92
  { uri: `${PROJECT_URI}/tokens`, name: "Project token values and themes", mimeType: "application/json" },
@@ -123,6 +124,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
123
124
  if (uri === GUIDE_URI) return { contents: [{ uri, mimeType: "text/markdown", text: projectGuide(project(), [...previews(), ...scenarioApps()]) }] };
124
125
  if (uri === "ads://guides/behaviors") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../../docs/BEHAVIORS.md", import.meta.url), "utf8") }] };
125
126
  if (uri === "ads://guides/atomic-styles") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/atomic-styles.md", import.meta.url), "utf8") }] };
127
+ if (uri === "ads://guides/scenarios") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/scenarios.md", import.meta.url), "utf8") }] };
126
128
  if (skills.files.has(uri)) return { contents: [skills.read(uri)] };
127
129
  let value;
128
130
  if (uri === `${PROJECT_URI}/status`) value = status();
@@ -205,7 +207,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
205
207
  const matches = inventory.tokens.filter((token) => token.name.toLowerCase().includes(search.toLowerCase()));
206
208
  return json({ total: matches.length, tokens: matches.slice(0, limit), categories: tokenScenarios(), diagnosticCount: inventory.diagnostics.length, resourceUri: `${PROJECT_URI}/tokens` });
207
209
  } },
208
- { name: "ads_check", description: "Run read-only core ADS architecture checks; returns blocking diagnostics separately from nonblocking review advisories. Atomic composition warnings identify overlapping properties and link ads://guides/atomic-styles for causes and fixes. Project Oxlint, typecheck, build and browser tests remain separate.", schema: z.object({ limit: z.number().int().min(1).max(50).default(20) }).strict(), call: ({ limit }) => {
210
+ { name: "ads_check", description: "Run read-only core ADS architecture checks; returns blocking diagnostics separately from nonblocking advisories, with warnings before informational limits. Atomic warnings include helper/forwarded-class paths and ads://guides/atomic-styles guidance; unresolved paths do not establish safe composition. Project Oxlint, typecheck, build and browser tests remain separate.", schema: z.object({ limit: z.number().int().min(1).max(50).default(20) }).strict(), call: ({ limit }) => {
209
211
  const result = checkProject(root);
210
212
  return json({ ok: result.ok, total: result.diagnostics.length, diagnostics: result.diagnostics.slice(0, limit), advisoryCount: result.advisories?.length ?? 0, advisories: (result.advisories ?? []).slice(0, limit), resourceUri: `${PROJECT_URI}/checks` });
211
213
  } },
@@ -0,0 +1,149 @@
1
+ import path from "node:path";
2
+ import ts from "typescript";
3
+ import postcss from "postcss";
4
+ import { isDevelopmentFile, isInside } from "./config.mjs";
5
+ import { publicApi } from "./public-api.mjs";
6
+ import { uiOperation } from "./ui-framework.mjs";
7
+ import { inspectUnits } from "./units.mjs";
8
+ import { createSourceValues, reference, union, isFunction } from "./source-values.mjs";
9
+
10
+ /** Source evidence only. No project modules execute, and unknown paths grant no
11
+ * permission. Coverage uses intersections across unresolved render branches;
12
+ * class helpers must retain provenance through every possible returned value. */
13
+ export function createScenarioTrace(program, options) {
14
+ const checker = program.getTypeChecker(), maxBranches = 32;
15
+ function linaria(expression, name, seen = new Set()) {
16
+ if (!expression || seen.has(expression)) return false;
17
+ seen.add(expression);
18
+ const base = ts.isPropertyAccessExpression(expression) ? expression.expression : expression;
19
+ const symbol = checker.getSymbolAtLocation(base);
20
+ for (const declaration of symbol?.declarations ?? []) {
21
+ if (ts.isImportSpecifier(declaration) && (declaration.propertyName ?? declaration.name).text === name && ["@linaria/atomic", "@linaria/core"].includes(declaration.parent.parent.parent.moduleSpecifier.text)) return true;
22
+ if (ts.isNamespaceImport(declaration) && ts.isPropertyAccessExpression(expression) && expression.name.text === name && ["@linaria/atomic", "@linaria/core"].includes(declaration.parent.parent.moduleSpecifier.text)) return true;
23
+ if (ts.isVariableDeclaration(declaration) && declaration.parent.flags & ts.NodeFlags.Const && linaria(declaration.initializer, name, seen)) return true;
24
+ }
25
+ return false;
26
+ }
27
+ const isCx = expression => linaria(expression, "cx");
28
+ const { state, next, at, resolve, get, arrays, returns, props } = createSourceValues(program, options, { preserveCall: expression => isCx(expression) || uiOperation(expression, checker) === "createElement", strict: true });
29
+ const publicNodes = new Map(), helpers = new Map(), inventory = inspectUnits(options);
30
+ const locationKey = value => JSON.stringify([value.file, value.line, value.column]);
31
+ function runtimeOwner(file) {
32
+ return ["components", "patterns"].some(folder => isInside(path.join(options.dsRoot, folder), file)) && !isDevelopmentFile(file, options)
33
+ ? inventory.owner(inventory.relative(path.relative(options.root, file))) : null;
34
+ }
35
+ for (const item of publicApi(program, options)) {
36
+ const value = resolve(reference(item.declaration.name ?? item.declaration), state());
37
+ if (value.kind !== "node") continue;
38
+ if (item.renderable) {
39
+ if (!publicNodes.has(value.node)) publicNodes.set(value.node, new Set());
40
+ publicNodes.get(value.node).add(item.name);
41
+ } else if (item.behavioral && item.kind !== "controllers" && isFunction(value.node)) helpers.set(locationKey(at(value.node, "helper", "")), runtimeOwner(item.file));
42
+ }
43
+ const combine = sets => new Set(sets.flatMap(value => [...value]));
44
+ const common = sets => new Set(sets[0] ? [...sets[0]].filter(name => sets.every(set => set.has(name))) : []);
45
+
46
+ function element(node, env, via) {
47
+ if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) {
48
+ const opening = ts.isJsxElement(node) ? node.openingElement : node;
49
+ const attributes = props(opening, env, via);
50
+ const children = ts.isJsxElement(node) ? node.children.filter(child => !ts.isJsxText(child) || child.text.trim()) : [];
51
+ if (children.length) attributes.layers.push(new Map([["children", children.length === 1 ? reference(children[0], env, via) : { kind: "array", values: children.map(child => reference(child, env, via)) }]]));
52
+ return { tag: reference(opening.tagName, env, via), attributes, intrinsic: ts.isIdentifier(opening.tagName) && /^[a-z]/.test(opening.tagName.text) };
53
+ }
54
+ if (ts.isCallExpression(node) && uiOperation(node.expression, checker) === "createElement") {
55
+ const attributes = { kind: "object", layers: node.arguments[1] && node.arguments[1].kind !== ts.SyntaxKind.NullKeyword ? [reference(node.arguments[1], env, via)] : [] };
56
+ const children = node.arguments.slice(2).map(child => reference(child, env, via));
57
+ if (children.length) attributes.layers.push(new Map([["children", children.length === 1 ? children[0] : { kind: "array", values: children }]]));
58
+ return { tag: reference(node.arguments[0], env, via), attributes, intrinsic: !!node.arguments[0] && ts.isStringLiteralLike(node.arguments[0]) };
59
+ }
60
+ return null;
61
+ }
62
+
63
+ function traceRenders(site) {
64
+ const limits = new Set();
65
+ function render(input, context) {
66
+ const value = resolve(input, next(context));
67
+ context = value.context ?? input.context ?? context;
68
+ if (value.kind === "unknown") { if (value.reason) limits.add(value.reason); return new Set(); }
69
+ if (value.kind === "union") {
70
+ if (value.values.length > maxBranches) { limits.add("Scenario render tracing reached its alternative limit."); return new Set(); }
71
+ return common(value.values.map(item => render(item, next(context))));
72
+ }
73
+ if (value.kind === "array") return combine(value.values.map(item => render(item, next(context))));
74
+ if (value.kind !== "node") return new Set();
75
+ const { node, env, via } = value;
76
+ if (ts.isJsxExpression(node)) return render(reference(node.expression, env, via), next(context));
77
+ if (ts.isJsxFragment(node)) return combine(node.children.map(child => render(reference(child, env, via), next(context))));
78
+ if (ts.isArrayLiteralExpression(node)) return combine(node.elements.map(child => render(reference(ts.isSpreadElement(child) ? child.expression : child, env, via), next(context))));
79
+ const view = element(node, env, via);
80
+ if (!view) return new Set();
81
+ if (view.intrinsic) return render(get(view.attributes, "children", next(context)), next(context));
82
+ function component(input) {
83
+ const target = resolve(input, next(context));
84
+ if (["provider", "context"].includes(target.kind)) return render(get(view.attributes, "children", next(context)), next(context));
85
+ if (target.kind === "union") return target.values.length <= maxBranches ? common(target.values.map(component)) : new Set();
86
+ if (target.kind !== "node") return new Set();
87
+ const names = new Set(publicNodes.get(target.node) ?? []);
88
+ if (isFunction(target.node) && !isDevelopmentFile(target.node.getSourceFile().fileName, options)) {
89
+ const outputs = returns(target, [view.attributes], next(context), "component");
90
+ for (const name of render(union(outputs), next(context))) names.add(name);
91
+ }
92
+ return names;
93
+ }
94
+ return component(view.tag);
95
+ }
96
+ return { rendered: render(reference(site), state()), limits: [...limits].slice(0, 3) };
97
+ }
98
+
99
+ function classValue(expression, property = false) {
100
+ const reasons = new Set();
101
+ const result = (ok, atoms = false, hooks = false) => ({ ok, branches: [{ atoms, hooks }] });
102
+ const owned = (file, via) => {
103
+ const owner = runtimeOwner(file);
104
+ return !!owner && via?.some(location => helpers.get(locationKey(location)) === owner);
105
+ };
106
+ function verify(input, context) {
107
+ const value = resolve(input, next(context));
108
+ context = value.context ?? input.context ?? context;
109
+ if (value.kind === "union") {
110
+ if (value.values.length > maxBranches) { reasons.add("Class provenance reached its alternative limit."); return result(false); }
111
+ const branches = value.values.map(item => verify(item, next(context)));
112
+ return { ok: branches.every(item => item.ok), branches: branches.flatMap(item => item.branches) };
113
+ }
114
+ if (value.kind === "literal" && !value.value) return result(true);
115
+ if (value.kind === "literal" && typeof value.value === "string" && value.origin && owned(value.origin.getSourceFile().fileName, value.via)) return result(true, false, true);
116
+ if (value.kind === "node") {
117
+ const { node, env, via } = value;
118
+ if (ts.isTaggedTemplateExpression(node) && linaria(node.tag, "css")) {
119
+ const source = node.getSourceFile().fileName;
120
+ let declarations = 0;
121
+ const template = node.template;
122
+ const text = ts.isNoSubstitutionTemplateLiteral(template) ? template.text : template.head.text + template.templateSpans.map(span => `__ads_expression__${span.literal.text}`).join("");
123
+ try { postcss.parse(text).walkDecls(() => ++declarations); } catch { /* Source CSS guards own malformed templates. */ }
124
+ if (owned(source, via) && declarations) return result(true, true);
125
+ reasons.add("The returned style must originate in runtime component/pattern Linaria through a public callable helper.");
126
+ return result(false);
127
+ }
128
+ if (ts.isCallExpression(node) && isCx(node.expression)) {
129
+ const arguments_ = node.arguments.flatMap(argument => ts.isSpreadElement(argument) ? arrays(reference(argument.expression, env, via), context) ?? [reference(argument.expression, env, via)] : [reference(argument, env, via)]);
130
+ const values = arguments_.map(argument => verify(argument, next(context)));
131
+ let branches = [{ atoms: false, hooks: false }];
132
+ for (const value of values) branches = [...new Map(branches.flatMap(first => value.branches.map(second => ({ atoms: first.atoms || second.atoms, hooks: first.hooks || second.hooks }))).map(branch => [JSON.stringify(branch), branch])).values()];
133
+ return { ok: values.every(item => item.ok), branches };
134
+ }
135
+ }
136
+ reasons.add(value.reason || "A returned class value is an arbitrary string or cannot be traced to owned Linaria.");
137
+ return result(false);
138
+ }
139
+ const context = state();
140
+ const input = property ? get(reference(expression), "className", next(context)) : reference(expression);
141
+ const value = resolve(input, next(context));
142
+ if (property && value.kind === "literal" && value.value === undefined) return { present: false, ok: true, reasons: [] };
143
+ const proof = verify(input, context);
144
+ const ok = proof.ok && proof.branches.some(branch => branch.atoms) && proof.branches.every(branch => !branch.hooks || branch.atoms);
145
+ if (!ok && !reasons.size) reasons.add("Each nonempty return path needs owned Linaria styles; stable hooks alone are not styling evidence.");
146
+ return { present: !property || value.kind !== "unknown", ok, reasons: [...reasons].slice(0, 3) };
147
+ }
148
+ return { traceRenders, classValue };
149
+ }
@@ -14,7 +14,7 @@ const fileDigest = file => { try { return digest(readFileSync(file)); } catch {
14
14
  * Cache state is development output, never proof that a failed build is current. */
15
15
  export function createPreviewCache(options, compilerFiles = []) {
16
16
  const { root, config } = options;
17
- const adapterFiles = [import.meta.filename, path.join(import.meta.dirname, "preview-resources.mjs"), path.join(import.meta.dirname, "preview-scope.mjs"), path.join(import.meta.dirname, "scenarios-vite.mjs"), ...compilerFiles,
17
+ const adapterFiles = [import.meta.filename, ...["preview-resources.mjs", "preview-scope.mjs", "scenarios-vite.mjs", "linaria.mjs", "linaria/atomic-css.cjs", "linaria/atomic-styled.cjs", "linaria/preserve-values.cjs"].map(file => path.join(import.meta.dirname, file)), ...compilerFiles,
18
18
  ...["package.json", "package-lock.json", "bun.lock", "bun.lockb", "node_modules/.package-lock.json"].map(file => path.join(root, file))];
19
19
  const adapterDigest = () => digest(JSON.stringify(adapterFiles.map(file => [file, fileDigest(file)])));
20
20
  const loadedAdapter = adapterDigest();
@@ -46,6 +46,7 @@ export function createPreviewCache(options, compilerFiles = []) {
46
46
  for (const name of readdirSync(import.meta.dirname).filter(name => name.endsWith(".mjs"))) {
47
47
  rows.push([`ads-tool/${name}`, fileDigest(path.join(import.meta.dirname, name))]);
48
48
  }
49
+ for (const name of readdirSync(path.join(import.meta.dirname, "linaria"))) rows.push([`ads-tool/linaria/${name}`, fileDigest(path.join(import.meta.dirname, "linaria", name))]);
49
50
  return digest(JSON.stringify(rows.sort((a, b) => a[0].localeCompare(b[0]))));
50
51
  }
51
52
  function save() {
@@ -9,6 +9,7 @@ import { inspectTokens } from "./tokens.mjs";
9
9
  import { isSharedToken } from "./token-policy.mjs";
10
10
  import { validTokenSamples } from "./token-samples.mjs";
11
11
  import { scopedTokens } from "./scoped-tokens.mjs";
12
+ import { createScenarioTrace } from "./scenario-trace.mjs";
12
13
 
13
14
  export const scenarioArtifact = (root, id) => path.join(root, ".ds/scenarios", id, "index.html");
14
15
 
@@ -114,7 +115,7 @@ export function inspectScenarios(options, suppliedProgram) {
114
115
  return { scenarios: scenarios.sort((a, b) => a.id.localeCompare(b.id)), diagnostics };
115
116
  }
116
117
 
117
- export function inspectScenarioCoverage(options, program, report, advise = () => {}) {
118
+ export function inspectScenarioCoverage(options, program, report, advise = () => {}, trace = createScenarioTrace(program, options)) {
118
119
  const registry = inspectScenarios(options, program);
119
120
  for (const item of registry.diagnostics) report(path.join(options.root, item.file), item.rule, item.message, item.line, item.column);
120
121
  const checker = program.getTypeChecker();
@@ -147,10 +148,11 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
147
148
  }
148
149
  return symbol.declarations?.length ? symbol : null;
149
150
  }
150
- const identities = new Map();
151
+ const identities = new Map(), behaviorIdentities = new Set();
151
152
  for (const item of publicApi(program, options)) {
152
153
  if (!identities.has(item.declaration)) identities.set(item.declaration, new Set());
153
154
  identities.get(item.declaration).add(item.name);
155
+ if (item.behavioral && !item.renderable) behaviorIdentities.add(item.declaration);
154
156
  }
155
157
 
156
158
  const covered = new Set();
@@ -163,6 +165,7 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
163
165
  const exercised = new Set(), referencedApis = new Set();
164
166
  const referencedTokens = new Set();
165
167
  let samplesPassed = false;
168
+ const renderLimits = new Set();
166
169
  const visited = new Set();
167
170
  function visit(node, reached = false) {
168
171
  if (!node || visited.has(node)) return;
@@ -177,6 +180,10 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
177
180
  if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) expression = node.tagName;
178
181
  if (ts.isCallExpression(node) && uiOperation(node.expression, checker) === "createElement") expression = node.arguments[0];
179
182
  if (expression) {
183
+ const site = ts.isJsxOpeningElement(node) ? node.parent : node;
184
+ const evidence = trace.traceRenders(site);
185
+ for (const name of evidence.rendered) rendered.add(name);
186
+ for (const reason of evidence.limits) renderLimits.add(reason);
180
187
  const symbol = canonical(symbolOf(expression));
181
188
  const names = identities.get(symbol?.valueDeclaration ?? symbol?.declarations?.[0]);
182
189
  for (const name of names ?? []) { rendered.add(name); exercised.add(name); }
@@ -190,10 +197,19 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
190
197
  if (ts.isPropertyAccessExpression(expression) && ["call", "apply"].includes(expression.name.text)) expression = expression.expression;
191
198
  const symbol = canonical(symbolOf(expression));
192
199
  for (const name of identities.get(symbol?.valueDeclaration ?? symbol?.declarations?.[0]) ?? []) exercised.add(name);
200
+ // A call on an attached method exercises its public behavioral receiver.
201
+ // Follow symbol identities through aliases, namespaces and re-exports;
202
+ // a property read or an unused callback still does not establish a call.
203
+ while (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression) && expression.argumentExpression && ts.isStringLiteralLike(expression.argumentExpression)) {
204
+ expression = expression.expression;
205
+ const receiver = canonical(symbolOf(expression));
206
+ const owner = receiver?.valueDeclaration ?? receiver?.declarations?.[0];
207
+ if (behaviorIdentities.has(owner)) for (const name of identities.get(owner) ?? []) exercised.add(name);
208
+ }
193
209
  }
194
- // Follow local adapters reachable from the default entry. Unused example
195
- // functions do not satisfy coverage; production implementations are never
196
- // traversed to manufacture coverage for their internal dependencies.
210
+ // Follow local adapters reachable from the default entry. Production
211
+ // children get evidence only from bounded returned-JSX tracing above,
212
+ // never by scanning every reference in their implementation.
197
213
  if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) || ts.isIdentifier(node) && !(ts.isPropertyAccessExpression(node.parent) || ts.isElementAccessExpression(node.parent))) {
198
214
  const symbol = canonical(symbolOf(node));
199
215
  const declaration = symbol?.valueDeclaration;
@@ -204,7 +220,7 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
204
220
  }
205
221
  for (const node of source.statements) if (ts.isExportAssignment(node) || node.modifiers?.some(item => item.kind === ts.SyntaxKind.DefaultKeyword)) visit(node, true);
206
222
  for (const name of scenario.covers) {
207
- if (!rendered.has(name)) report(source.fileName, "scenario-render", `${name} is declared in covers but has no public render reference in this scenario. Render the real API; an import alone does not count.`);
223
+ if (!rendered.has(name)) report(source.fileName, "scenario-render", `${name} is declared in covers but has no reachable public render reference. Render it directly or through a traced parent with fixture props/defaults selecting that child. Imports, unused JSX and unknown conditional paths do not establish coverage.${renderLimits.size ? ` Source tracing could not establish: ${[...renderLimits].slice(0, 2).join(" ")}` : ""} Review the real scenario in a browser; do not hide a valid public part just to avoid coverage. See ads://guides/scenarios.`);
208
224
  else covered.add(name);
209
225
  }
210
226
  for (const name of scenario.exercises ?? []) {
@@ -49,10 +49,18 @@ For owner drafts, token-sample reconciliation, coupled transactions and local
49
49
  constant namespaces, read [guarded-editing.md](references/guarded-editing.md).
50
50
 
51
51
 
52
- For atomic base/variant styling or an `atomic-composition-review` warning, read
52
+ For parent/child `covers`, public style-helper use in scenarios, or
53
+ `scenario-render` / `showcase-class` findings, read
54
+ [scenario contracts](references/scenarios.md). Traced parents can cover declared
55
+ public children; verified public Linaria helpers do not grant custom scenario CSS.
56
+
57
+ For atomic base/variant styling, helper/wrapper class composition, extracted
58
+ custom-property arithmetic, or an
59
+ `atomic-composition-review` / `atomic-composition-limit` advisory, read
53
60
  [atomic style composition](references/atomic-styles.md). The same guide is served
54
61
  as `ads://guides/atomic-styles`. It explains shorthand/logical conflicts and
55
- matching-property fixes. Review warnings in the real `cx` composition and verify
62
+ matching-property fixes, plus the build resolver for preserving opaque custom
63
+ properties through extraction. Review warnings in the real `cx` composition and verify
56
64
  computed styles across affected sizes/states; retain intentional product behavior.
57
65
 
58
66
  Controllers are UI behavior owners: private helpers stay with their component or
@@ -81,6 +81,91 @@ const treatment = css`
81
81
  This is a distinct state, not two competing base atoms. Whether changing padding
82
82
  on hover is desirable remains a product decision.
83
83
 
84
+ ## Preserve custom-property arithmetic during extraction
85
+
86
+ Custom properties can hold an unevaluated token stream that becomes arithmetic
87
+ only after substitution into a later `calc()`. For example:
88
+
89
+ ```css
90
+ --i: 2;
91
+ --scale: var(--i) * 0.05 + 1;
92
+ transform: scale(calc(-1 * var(--scale)));
93
+ ```
94
+
95
+ The result is scale `0.9`: substitution does not add parentheses around the
96
+ custom property. Some Linaria/Stylis extraction versions strip the whitespace
97
+ around the bare `+`, leaving `0.05+1`. The browser then treats the transform as
98
+ invalid. This can happen with CSS minification disabled. Source guards cannot
99
+ prove what a later extractor emits.
100
+
101
+ Use ADS's build-only resolver in **both** the application's Linaria configuration
102
+ and its separately configured MCP preview builder:
103
+
104
+ ```js
105
+ import wyw from "@wyw-in-js/vite";
106
+ import { linariaTagResolver } from "@reqvire-org/ads/linaria";
107
+
108
+ // In the project's Vite plugins:
109
+ wyw({ tagResolver: linariaTagResolver });
110
+ ```
111
+
112
+ The resolver keeps the project's installed atomic processor and preserves opaque
113
+ custom-property values through its nesting/atomization pass. It does not add a
114
+ browser runtime or alter token ownership. Existing projects must adopt it in
115
+ each extraction pipeline; upgrading ADS alone does not rewrite custom builders.
116
+ If an existing `tagResolver` handles other tags, delegate atomic imports to
117
+ `linariaTagResolver(source, tag)` and retain the existing fallback. WyW config
118
+ files also support this resolver when a build integration requires serializable
119
+ inline options.
120
+
121
+ For a source workaround, write a self-contained formula and consume it directly:
122
+
123
+ ```css
124
+ --scale: calc(1 - var(--i) * 0.05);
125
+ transform: scale(var(--scale));
126
+ ```
127
+
128
+ This also produces `0.9`. Simply wrapping the old value in `calc()` while keeping
129
+ the outer `-1 *` changes its grouping and result. Verify extracted CSS text and a
130
+ computed style after any rewrite, including nested `var()` fallbacks/transforms.
131
+ Do not globally insert spaces into already extracted CSS: that can change valid
132
+ signed numbers, identifiers, strings or URLs.
133
+
134
+ ## Follow helpers and forwarded classes
135
+
136
+ Composition can cross a helper or a component boundary. For example, in component
137
+ implementation source:
138
+
139
+ ```tsx
140
+ function baseClasses() { return base; }
141
+ function Primitive({ className, ...props }) {
142
+ return <button {...props} className={cx(baseClasses(), className)} />;
143
+ }
144
+ function CompactPrimitive(props) {
145
+ return <Primitive {...props} className={small} />;
146
+ }
147
+ ```
148
+
149
+ The base and small atoms can reach the same button. Inspect both owners when
150
+ correcting their property vocabulary. The wrapper's class does not style every
151
+ descendant: a class on a child or sibling element is a separate composition.
152
+ An imported stylesheet alone does not show that its classes co-apply.
153
+
154
+ Spread order matters. `<button className={base} {...props} />` can replace the
155
+ entire className; `<button {...props} className={cx(base, className)} />` composes
156
+ it explicitly. Keep the product's intended forwarding behavior when fixing an
157
+ overlap. Do not change the public API simply to make tracing easier.
158
+
159
+ Warnings include a bounded `composition` path through traced helpers and
160
+ components. A `target` identifies a statically reached DOM element. This
161
+ establishes source composition, not that a scenario mounted it or that its
162
+ computed result is wrong. `writingModeDependent: true` identifies overlaps that
163
+ change with direction or writing mode; evaluate those against supported modes.
164
+ Literal overlaps with provably equal values are omitted where the analyzer can
165
+ expand them safely. Token formulas, inheritance and runtime values still need
166
+ review. A margin shorthand and `margin-inline: auto` may agree horizontally but
167
+ disagree in vertical text, so horizontal equality alone is insufficient.
168
+
84
169
  ## Respond to a warning
85
170
 
86
171
  1. Follow the warning's related file/line locations and inspect the actual `cx`
@@ -101,6 +186,24 @@ the conflict. Prefer resolving the composition itself. If an overlap is
101
186
  intentional, document why its precedence is stable and verify the resulting
102
187
  behavior rather than changing product capabilities to silence a warning.
103
188
 
189
+ Use existing behavior contracts and `ads_verify` for important geometry. Register
190
+ a check beside its owner, link its real scenario and use the project's browser
191
+ profile. An assertion can inspect the actual control in the App frame:
192
+
193
+ ```ts
194
+ const frame = await openBehaviorScenario(page, "compact-spacing");
195
+ await expect(frame.getByRole("button", { name: "Compact" }))
196
+ .toHaveCSS("padding-inline-start", "8px");
197
+ ```
198
+
199
+ The name, check ID and expected value above are examples. Derive assertions from
200
+ the project's intended API and design, with relevant variants, open/hover/focus
201
+ states, themes and supported writing modes. Wait for observable readiness; an
202
+ event-stream connection can prevent `networkidle` from settling. A generic
203
+ overlap scan cannot decide which dimensions the product intended. A failed
204
+ registered geometry assertion is blocking through the existing verification
205
+ contract; an overlap warning remains a review signal.
206
+
104
207
  ## What ADS checks
105
208
 
106
209
  `atomic-composition-review` is a nonblocking warning, returned under `advisories`
@@ -108,14 +211,26 @@ with `severity: "warning"`. CLI checks still exit successfully when there are no
108
211
  errors; MCP checks and mutations preserve the warning and its guidance URI.
109
212
 
110
213
  The source review examines atomic Linaria templates and statically traceable
111
- `cx` arguments, including aliases, local imports, nested composition, conditional
112
- expressions and variant-object lookups. It checks known overlaps involving box
214
+ `cx` arguments, including aliases, local imports/re-exports, local helper returns,
215
+ arguments/defaults, nested composition, conditional expressions and variant-object
216
+ lookups. It follows explicit `className` forwarding through local function
217
+ components, props/rest spreads and imported React/Preact `memo`/`forwardRef`
218
+ wrappers to an intrinsic JSX element. It checks known overlaps involving box
113
219
  spacing, inset, borders/corners, dimensions, overflow, backgrounds, typography,
114
220
  motion and common layout shorthands, plus `all` resets. It compares shared selector/condition contexts; separate alternatives
115
- within one conditional or lookup are not assumed to apply together.
221
+ within one conditional or lookup are not assumed to apply together. Matching
222
+ atomic property/selector/condition keys are replaced during traced `cx`
223
+ composition before comparing the surviving declarations.
116
224
 
117
225
  This is a bounded source review, not a CSS engine or a proof of precedence. It
118
- does not enumerate every external class, runtime function result, selector
119
- interaction or overlapping media query. An empty warning list does not establish
120
- visual correctness. Actual failed registered browser/behavior checks remain
121
- blocking; potentially intentional source overlaps remain warnings.
226
+ does not execute helpers or import project modules, enumerate every external
227
+ class, or model arbitrary runtime mutation, component rendering, selectors or
228
+ overlapping media queries. Recursive calls, unsupported call/control-flow paths,
229
+ unresolved DOM targets and traversal limits produce bounded
230
+ `atomic-composition-limit` informational advisories where known atomic styles
231
+ reach an unresolved composition. Ordinary externally supplied className values
232
+ remain open inputs, not guaranteed safe styles. Depth, work and alternative
233
+ limits keep source inspection bounded; an unreported path or an empty warning
234
+ list does not establish visual correctness. Actual failed registered
235
+ browser/behavior checks remain blocking; potentially intentional source overlaps
236
+ remain warnings.
@@ -0,0 +1,83 @@
1
+ # Scenario render evidence and public class helpers
2
+
3
+ Use this reference for `scenario-render`, `scenario-coverage` or `showcase-class`
4
+ diagnostics. MCP serves the same guide as `ads://guides/scenarios`.
5
+
6
+ ## Public children can share their parent's scenario
7
+
8
+ Declare the public parts actually demonstrated in `covers`, even when their
9
+ parent renders them internally:
10
+
11
+ ```tsx
12
+ // Runtime owner
13
+ export function Part() { return <span>Content</span>; }
14
+ export function Frame({ visible = true } = {}) {
15
+ return <section>{visible && <Part />}</section>;
16
+ }
17
+
18
+ // Colocated Scenario.tsx
19
+ import { Frame } from "@ds";
20
+ export const scenario = { title: "Frame", covers: ["Frame", "Part"] };
21
+ export default function Scenario() { return <Frame />; }
22
+ ```
23
+
24
+ ADS follows returned JSX through local components/helpers, aliases, registered
25
+ framework factories, memo/ref wrappers and context providers. Fixture props,
26
+ spreads and destructuring defaults select the child path. An explicit
27
+ `visible={false}` does not cover `Part`. When a condition remains unknown, only
28
+ parts returned on every possible path receive transitive credit. Imports, unused
29
+ JSX, event-handler bodies and uncalled functions do not establish child rendering.
30
+ Only the explicitly declared `covers` entries acquire coverage; dependencies are
31
+ not silently added to metadata or the catalogue.
32
+
33
+ Tracing is bounded and does not execute the project. Recursion, written/escaped inputs,
34
+ opaque external wrappers and unsupported control flow can prevent proof. The
35
+ diagnostic explains known limits. Use meaningful fixture states or another real
36
+ scenario; do not make a valid public part private or duplicate it in a parent
37
+ just to satisfy a guard. Static evidence does not establish successful mounting,
38
+ visibility, interaction, every state or visual parity. Verify those in the built
39
+ App and registered browser checks.
40
+
41
+ ## Scenarios may consume verified public style helpers
42
+
43
+ A deliberately public helper can expose its owner's Linaria treatment:
44
+
45
+ ```tsx
46
+ // Runtime owner
47
+ const treatment = css`padding-inline: var(--space-4);`;
48
+ export function controlClasses() {
49
+ return cx("control-hook", treatment);
50
+ }
51
+
52
+ // Scenario: consume the public API; define no styles here
53
+ <PublicLink className={controlClasses()}>Documentation</PublicLink>
54
+ ```
55
+
56
+ The sample token and APIs are illustrative; use the project's real exports and
57
+ tokens. Import helpers through the public ADS entry. ADS traces helper calls,
58
+ returns, local aliases, finite known selections and Linaria `cx` composition.
59
+ Styling must originate in component/pattern Linaria through a public callable
60
+ helper. A literal stable hook authored in that runtime owner may accompany the
61
+ verified styles. Each nonempty return path needs actual Linaria declarations;
62
+ empty templates and hook-only/string-only returns do not qualify.
63
+
64
+ These are still rejected:
65
+
66
+ ```tsx
67
+ <PublicLink className="custom-layout" />
68
+ <PublicLink className={arbitraryPublicFunctionReturningAString()} />
69
+ <PublicLink className={controlClasses({ className: "custom-layout" })} />
70
+ ```
71
+
72
+ Scenario-supplied strings, generated styles in fixtures, private style imports,
73
+ spoofed Linaria functions and untraceable results acquire no permission by being
74
+ passed through a public function. Known className values in props/spreads receive
75
+ the same provenance check. Opaque spreads remain outside complete source proof.
76
+ An `exercises` entry records behavioral use; it never grants styling permission.
77
+
78
+ Keep helper signatures compatible with the product API. Fix ownership/provenance
79
+ in the runtime owner when genuinely wrong; retain intentional public APIs when
80
+ reporting an unsupported trace. Demo-only sizing, framing and arrangement still
81
+ belong in public review/layout patterns. A style helper is not permission to
82
+ author a second design in the scenario. For cascade risks and extraction issues,
83
+ read [atomic-styles.md](atomic-styles.md).
@@ -80,10 +80,18 @@ use the client's normal source-editing tools.
80
80
  For owner drafts, token-sample reconciliation, coupled transactions and local
81
81
  constant namespaces, read [guarded-editing.md](references/guarded-editing.md).
82
82
 
83
- For atomic base/variant styling or an `atomic-composition-review` warning, read
83
+ For parent/child `covers`, public style-helper use in scenarios, or
84
+ `scenario-render` / `showcase-class` findings, read
85
+ [scenario contracts](references/scenarios.md). Traced parents can cover declared
86
+ public children; verified public Linaria helpers do not grant custom scenario CSS.
87
+
88
+ For atomic base/variant styling, helper/wrapper class composition, extracted
89
+ custom-property arithmetic, or an
90
+ `atomic-composition-review` / `atomic-composition-limit` advisory, read
84
91
  [atomic style composition](references/atomic-styles.md). The same guide is served
85
92
  as `ads://guides/atomic-styles`. It explains shorthand/logical conflicts and
86
- matching-property fixes. Review warnings in the real `cx` composition and verify
93
+ matching-property fixes, plus the build resolver for preserving opaque custom
94
+ properties through extraction. Review warnings in the real `cx` composition and verify
87
95
  computed styles across affected sizes/states; retain intentional product behavior.
88
96
 
89
97
  Controllers are UI behavior owners: private helpers stay with their component or
@@ -327,7 +335,9 @@ Screen reuse remains skill guidance, not a dedicated screen-parity lint.
327
335
  Resolve `scenario-contract`, `scenario-render` and `scenario-coverage` findings
328
336
  with meaningful entries. Every public renderable component and pattern needs an
329
337
  addressable scenario, including unused exports; types/constants/utilities do not.
330
- Only public render references reachable from the default entry count. Tests and
338
+ Direct and traced parent/child public render references reachable from the default
339
+ entry count. Declared children need returned JSX selected by known props/defaults;
340
+ unresolved branches do not grant speculative coverage. Tests and
331
341
  unused imports/functions do not. Static reachability does not prove successful
332
342
  mounting, correct content, every branch/state or visual parity: open each affected
333
343
  entry independently and verify real behavior at narrow/wide sizes in both themes.
@@ -4,6 +4,7 @@ import { execFile } from "node:child_process";
4
4
  import { promisify } from "node:util";
5
5
  import { build } from "vite";
6
6
  import wyw from "@wyw-in-js/vite";
7
+ import { linariaTagResolver } from "@reqvire-org/ads/linaria";
7
8
  import react from "@vitejs/plugin-react";
8
9
  import { runScenarioCompiler } from "@reqvire-org/ads/scenarios/compiler";
9
10
  import { createPreviewResources, previewEntriesPlugin } from "@reqvire-org/ads/scenarios/vite";
@@ -22,7 +23,7 @@ await runScenarioCompiler(root, {
22
23
  async buildGraph(entries, options, track) {
23
24
  const mount = path.join(options.dsRoot, "showcase/mcp/main.tsx");
24
25
  const output = await build({ configFile: false, root, base: "./", publicDir: false,
25
- plugins: [previewEntriesPlugin(entries.map(entry => ({ ...entry, root })), mount), wyw({ include: ["**/*.{ts,tsx}"], exclude: ["**/node_modules/**"] }), react(), track],
26
+ plugins: [previewEntriesPlugin(entries.map(entry => ({ ...entry, root })), mount), wyw({ tagResolver: linariaTagResolver, include: ["**/*.{ts,tsx}"], exclude: ["**/node_modules/**"] }), react(), track],
26
27
  resolve: { alias: { "@ds": path.join(options.dsRoot, options.config.publicEntry) } },
27
28
  worker: { format: "iife" },
28
29
  build: { write: false, cssCodeSplit: true, assetsInlineLimit: 0, modulePreload: false,
@@ -2,9 +2,10 @@ import path from "node:path";
2
2
  import { defineConfig } from "vite";
3
3
  import react from "@vitejs/plugin-react";
4
4
  import wyw from "@wyw-in-js/vite";
5
+ import { linariaTagResolver } from "@reqvire-org/ads/linaria";
5
6
 
6
7
  export default defineConfig({
7
- plugins: [wyw(), react()],
8
+ plugins: [wyw({ tagResolver: linariaTagResolver }), react()],
8
9
  resolve: {
9
10
  alias: { "@ds": path.resolve(import.meta.dirname, "design-system/index.ts") },
10
11
  },