@reqvire-org/ads 0.3.46 → 0.3.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +21 -11
  2. package/dist/a11y.mjs +4 -2
  3. package/dist/assets.mjs +20 -15
  4. package/dist/atomic-composition.mjs +3 -2
  5. package/dist/brand-assets.mjs +48 -11
  6. package/dist/brands.mjs +82 -0
  7. package/dist/browser-audit/worker.mjs +51 -0
  8. package/dist/browser-audit.mjs +147 -0
  9. package/dist/capture/worker.mjs +1 -0
  10. package/dist/capture-store.mjs +2 -0
  11. package/dist/capture.mjs +7 -4
  12. package/dist/check.mjs +38 -8
  13. package/dist/cli.mjs +45 -10
  14. package/dist/color-values.mjs +325 -0
  15. package/dist/config.mjs +16 -2
  16. package/dist/control-padding.mjs +93 -0
  17. package/dist/design-values.mjs +3 -2
  18. package/dist/finding-rules.mjs +61 -0
  19. package/dist/foundation.mjs +17 -4
  20. package/dist/icons.mjs +107 -0
  21. package/dist/init.mjs +3 -0
  22. package/dist/mcp/apps.mjs +9 -6
  23. package/dist/mcp/context.mjs +1 -1
  24. package/dist/mcp/drafts.mjs +3 -0
  25. package/dist/mcp/mutations.mjs +40 -1
  26. package/dist/mcp/preview-widget.bundle.js +36 -36
  27. package/dist/mcp/project-widget.bundle.js +12 -12
  28. package/dist/mcp/server.mjs +23 -11
  29. package/dist/mcp/widget.bundle.js +17 -17
  30. package/dist/palette-generated.mjs +180 -0
  31. package/dist/preview-resources.mjs +12 -3
  32. package/dist/render-color-probe.mjs +148 -0
  33. package/dist/runtime-contracts.mjs +14 -4
  34. package/dist/scenarios.mjs +1 -1
  35. package/dist/showcase/client.bundle.js +28 -28
  36. package/dist/showcase/icons.js +146 -0
  37. package/dist/showcase/index.html +2 -1
  38. package/dist/showcase/style.css +19 -2
  39. package/dist/skills/README.md +2 -1
  40. package/dist/skills/ads-break-ui/SKILL.md +6 -5
  41. package/dist/skills/ads-break-ui/references/atomic-styles.md +12 -12
  42. package/dist/skills/ads-break-ui/references/contracts.md +13 -10
  43. package/dist/skills/ads-break-ui/references/design-data.md +137 -29
  44. package/dist/skills/ads-break-ui/references/drafts.md +3 -1
  45. package/dist/skills/ads-break-ui/references/guarded-editing.md +3 -2
  46. package/dist/skills/ads-break-ui/references/validation.md +13 -4
  47. package/dist/skills/ads-designer/SKILL.md +23 -16
  48. package/dist/skills/ads-designer/references/accessibility.md +41 -5
  49. package/dist/skills/ads-designer/references/atomic-styles.md +12 -12
  50. package/dist/skills/ads-designer/references/branding.md +37 -10
  51. package/dist/skills/ads-designer/references/cli.md +8 -2
  52. package/dist/skills/ads-designer/references/contracts.md +13 -10
  53. package/dist/skills/ads-designer/references/design-data.md +137 -29
  54. package/dist/skills/ads-designer/references/drafts.md +3 -1
  55. package/dist/skills/ads-designer/references/guarded-editing.md +3 -2
  56. package/dist/skills/ads-designer/references/validation.md +13 -4
  57. package/dist/skills/ads-import/SKILL.md +9 -8
  58. package/dist/skills/ads-import/references/atomic-styles.md +12 -12
  59. package/dist/skills/ads-import/references/cli.md +8 -2
  60. package/dist/skills/ads-import/references/contracts.md +13 -10
  61. package/dist/skills/ads-import/references/design-data.md +137 -29
  62. package/dist/skills/ads-import/references/drafts.md +3 -1
  63. package/dist/skills/ads-import/references/guarded-editing.md +3 -2
  64. package/dist/skills/ads-import/references/tokens.md +7 -3
  65. package/dist/skills/ads-import/references/validation.md +13 -4
  66. package/dist/skills/ads-motion/SKILL.md +6 -5
  67. package/dist/skills/ads-motion/references/atomic-styles.md +12 -12
  68. package/dist/skills/ads-motion/references/contracts.md +13 -10
  69. package/dist/skills/ads-motion/references/design-data.md +137 -29
  70. package/dist/skills/ads-motion/references/drafts.md +3 -1
  71. package/dist/skills/ads-motion/references/guarded-editing.md +3 -2
  72. package/dist/skills/ads-motion/references/validation.md +13 -4
  73. package/dist/skills/ads-port/SKILL.md +6 -5
  74. package/dist/skills/ads-port/references/atomic-styles.md +12 -12
  75. package/dist/skills/ads-port/references/cli.md +8 -2
  76. package/dist/skills/ads-port/references/contracts.md +13 -10
  77. package/dist/skills/ads-port/references/design-data.md +137 -29
  78. package/dist/skills/ads-port/references/drafts.md +3 -1
  79. package/dist/skills/ads-port/references/guarded-editing.md +3 -2
  80. package/dist/skills/ads-port/references/validation.md +13 -4
  81. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +11 -2
  82. package/dist/starters/react/ADS.md +43 -10
  83. package/dist/starters/react/README.md +14 -9
  84. package/dist/starters/react/design-system/assets/brand/README.md +8 -3
  85. package/dist/starters/react/design-system/assets/glyphs/README.md +4 -1
  86. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +6 -1
  87. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +3 -2
  88. package/dist/starters/react/design-system/components/Content/Icon/README.md +2 -1
  89. package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +3 -9
  90. package/dist/starters/react/design-system/components/Content/Logo/README.md +4 -2
  91. package/dist/starters/react/design-system/controllers/Palette/Palette.ts +164 -0
  92. package/dist/starters/react/design-system/index.ts +3 -0
  93. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +2 -5
  94. package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +11 -2
  95. package/dist/starters/react/design-system/styles.css +1 -0
  96. package/dist/starters/react/design-system/tokens/base.css +8 -5
  97. package/dist/starters/react/design-system/tokens/colors.css +167 -175
  98. package/dist/starters/react/design-system/tokens/elevation.css +14 -21
  99. package/dist/starters/react/design-system/tokens/themes.generated.css +142 -0
  100. package/dist/starters/react/design-system/tokens/themes.generated.ts +402 -0
  101. package/dist/style-boundaries.mjs +2 -1
  102. package/dist/themes-generated.mjs +150 -0
  103. package/dist/themes-watch.mjs +42 -0
  104. package/dist/themes.mjs +214 -63
  105. package/dist/token-export.mjs +22 -11
  106. package/dist/token-policy.mjs +2 -1
  107. package/dist/token-quality.mjs +28 -25
  108. package/dist/tokens.mjs +27 -32
  109. package/dist/validation.mjs +17 -1
  110. package/dist/verification/browser.mjs +14 -3
  111. package/dist/verification.mjs +25 -4
  112. package/docs/ADS.md +41 -27
  113. package/docs/ARCHITECTURE.md +49 -22
  114. package/docs/CACHING.md +2 -3
  115. package/docs/CHANGELOG.md +117 -13
  116. package/docs/CONTRACTS.md +13 -10
  117. package/docs/GUIDE.md +94 -22
  118. package/docs/MCP.md +50 -30
  119. package/docs/benchmarks/bun-previews.md +5 -5
  120. package/docs/benchmarks/{gidi-preview-memory.md → preview-memory.md} +14 -12
  121. package/docs/benchmarks/turbo-poc.md +24 -6
  122. package/package.json +2 -1
package/dist/icons.mjs ADDED
@@ -0,0 +1,107 @@
1
+ import { existsSync, lstatSync, readFileSync, readdirSync, statSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { glyphViewBox, inspectGlyphs } from "./assets.mjs";
4
+ import { glyphAliases, glyphMarkup } from "./brand-assets.mjs";
5
+ import { isTestFile } from "./config.mjs";
6
+ import { inspectTokens } from "./tokens.mjs";
7
+
8
+ export const ICONS_URI = "ads://project/icons";
9
+ const logoTypes = { ".svg": "image/svg+xml", ".png": "image/png", ".webp": "image/webp", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif" };
10
+ const logoBytes = 1024 * 1024;
11
+ const relative = (root, file) => path.relative(root, file).replaceAll("\\", "/");
12
+
13
+ function files(directory) {
14
+ const stat = lstatSync(directory, { throwIfNoEntry: false });
15
+ if (!stat || stat.isSymbolicLink() || !stat.isDirectory()) return [];
16
+ return readdirSync(directory, { withFileTypes: true }).filter(entry => entry.isFile()).map(entry => entry.name).sort();
17
+ }
18
+
19
+ /** The folders the Icons view reads; their files' changes refresh it. */
20
+ export function iconInputs({ dsRoot, config }) {
21
+ const glyphs = config.assets.glyphs;
22
+ if (!glyphs) return [];
23
+ const directories = [path.join(dsRoot, glyphs.source), path.join(dsRoot, "assets/logos")];
24
+ return [...directories, ...directories.flatMap(directory => files(directory).map(name => path.join(directory, name)))];
25
+ }
26
+
27
+ /** Each --icon-* token resolved to pixels through var() chains; unresolvable sizes are left out. */
28
+ function iconSizes(options) {
29
+ let tokens;
30
+ try { tokens = inspectTokens(options.root, options).tokens; } catch { return []; }
31
+ const values = new Map();
32
+ for (const token of tokens) {
33
+ const definitions = token.definitions ?? [];
34
+ const plain = definitions.find(item => !item.theme && !item.brand && !item.conditional && item.scope === ":root") ?? definitions.find(item => !item.theme && !item.brand) ?? definitions[0];
35
+ if (plain) values.set(token.name, plain.value);
36
+ }
37
+ const resolve = (value, depth = 0) => {
38
+ if (depth > 12) return null;
39
+ const match = String(value).trim().match(/^var\(\s*(--[\w-]+)\s*(?:,\s*(.+))?\)$/);
40
+ if (match) return values.has(match[1]) ? resolve(values.get(match[1]), depth + 1) : match[2] ? resolve(match[2], depth + 1) : null;
41
+ const length = String(value).trim().match(/^(-?\d*\.?\d+)(px|rem)$/i);
42
+ if (!length) return null;
43
+ const px = Number(length[1]) * (length[2].toLowerCase() === "rem" ? 16 : 1);
44
+ return px > 0 ? Math.round(px * 100) / 100 : null;
45
+ };
46
+ return [...values.keys()].filter(name => /^--icon-[\w-]+$/.test(name))
47
+ .map(token => ({ token, px: resolve(values.get(token)) })).filter(size => size.px !== null)
48
+ .sort((a, b) => a.px - b.px || a.token.localeCompare(b.token));
49
+ }
50
+
51
+ /** The size the project's Icon draws beside text: the first --icon-* its own sources (beside the glyph module) use, else the smallest of 16 px or more. */
52
+ function textSize({ dsRoot, config }, sizes) {
53
+ const output = path.join(dsRoot, config.assets.glyphs.output), folder = path.dirname(output);
54
+ for (const name of files(folder)) {
55
+ const file = path.join(folder, name);
56
+ if (file === output || !/\.[cm]?[jt]sx?$/.test(name) || isTestFile(name) || /\.(?:scenario|fixture)\.[jt]sx?$/.test(name)) continue;
57
+ for (const match of readFileSync(file, "utf8").matchAll(/var\(\s*(--icon-[\w-]+)/g)) {
58
+ const size = sizes.find(item => item.token === match[1]);
59
+ if (size) return size;
60
+ }
61
+ }
62
+ return sizes.find(size => size.px >= 16) ?? sizes.at(-1) ?? null;
63
+ }
64
+
65
+ function parseBox(box) {
66
+ const numbers = box?.split(/[\s,]+/).map(Number);
67
+ return numbers?.length === 4 && numbers.every(Number.isFinite) && numbers[2] > 0 && numbers[3] > 0 ? { x: numbers[0], y: numbers[1], width: numbers[2], height: numbers[3] } : null;
68
+ }
69
+
70
+ /** The glyph set, its aliases, icon sizes, per-glyph findings and other products' logos for the showcase's Icons view. */
71
+ export function iconSet(options) {
72
+ const { root, dsRoot, config } = options;
73
+ const glyphs = config.assets.glyphs;
74
+ if (!glyphs) return { configured: false };
75
+ const directory = path.join(dsRoot, glyphs.source);
76
+ const findings = [];
77
+ const names = files(directory).filter(name => name.toLowerCase().endsWith(".svg")).map(name => name.slice(0, -4));
78
+ const { aliases } = glyphAliases(directory, names);
79
+ const attributes = glyphs.attributes ?? {};
80
+ const set = files(directory).filter(name => name.toLowerCase().endsWith(".svg")).map(name => {
81
+ const file = path.join(directory, name), text = readFileSync(file, "utf8"), viewBox = glyphViewBox(text);
82
+ return { name: name.slice(0, -4), file: relative(root, file), viewBox, grid: parseBox(viewBox), svg: glyphMarkup(text, attributes), aliases: [], findings: [] };
83
+ }).filter(glyph => !Object.hasOwn(aliases, glyph.name));
84
+ const byName = new Map(set.map(glyph => [glyph.name, glyph]));
85
+ // Alias problems come with the glyph check's findings below.
86
+ for (const [alias, target] of Object.entries(aliases).sort(([a], [b]) => a.localeCompare(b))) byName.get(target)?.aliases.push(alias);
87
+ const byFile = new Map(set.map(glyph => [glyph.file, glyph]));
88
+ for (const { rule, severity, file, message } of inspectGlyphs(options)) {
89
+ const finding = { rule, severity: severity ?? "error", file, message };
90
+ (byFile.get(file)?.findings ?? findings).push(finding);
91
+ }
92
+ const boxes = [...new Set(set.map(glyph => glyph.viewBox).filter(Boolean))];
93
+ const sizes = iconSizes(options);
94
+ const logoDirectory = path.join(dsRoot, "assets/logos");
95
+ const logos = files(logoDirectory).filter(name => Object.hasOwn(logoTypes, path.extname(name).toLowerCase())).flatMap(name => {
96
+ const file = path.join(logoDirectory, name);
97
+ if (statSync(file).size > logoBytes) return [{ name: path.basename(name, path.extname(name)), file: relative(root, file), tooLarge: true }];
98
+ return [{ name: path.basename(name, path.extname(name)), file: relative(root, file), src: `data:${logoTypes[path.extname(name).toLowerCase()]};base64,${readFileSync(file).toString("base64")}` }];
99
+ });
100
+ return {
101
+ configured: true, source: relative(root, directory),
102
+ grid: boxes.length === 1 ? parseBox(boxes[0]) : null, mixed: boxes.length > 1,
103
+ aliasCount: Object.keys(aliases).length, sizes, textSize: textSize(options, sizes),
104
+ glyphs: set, findings,
105
+ logos: existsSync(logoDirectory) ? { source: relative(root, logoDirectory), files: logos } : null,
106
+ };
107
+ }
package/dist/init.mjs CHANGED
@@ -4,6 +4,7 @@ import { fileURLToPath } from "node:url";
4
4
  import ts from "typescript";
5
5
  import { isInside, loadConfig, sourceFiles, supportedFrameworks } from "./config.mjs";
6
6
  import { foundationFiles } from "./token-policy.mjs";
7
+ import { generatedPaletteFile } from "./palette-generated.mjs";
7
8
  import { assertFrameworkCompiler } from "./ui-framework.mjs";
8
9
 
9
10
  const tool = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
@@ -156,6 +157,8 @@ export function initProject(directory = process.cwd(), { toolPackage, packageMan
156
157
  return file;
157
158
  });
158
159
  if (!existingTokens.length) {
160
+ // The renderer palette generated from the starter's token sheets, beside its theme sheet.
161
+ addMissing(path.join(tokenRoot, generatedPaletteFile), readFileSync(path.join(starter, "design-system/tokens", generatedPaletteFile)));
159
162
  // The starter's token groups, each a scenario with its fixture.
160
163
  for (const name of readdirSync(path.join(starter, "design-system/tokens")).filter(name => /\.ads\.(?:scenario\.tsx|fixture\.ts)$/.test(name)).sort()) {
161
164
  const content = readFileSync(path.join(starter, "design-system/tokens", name), "utf8").replaceAll('"@ds/review"', JSON.stringify(`${config.publicAlias}/review`)).replaceAll('"@ds"', JSON.stringify(config.publicAlias));
package/dist/mcp/apps.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  import { readFileSync, realpathSync, statSync } from "node:fs";
2
2
  import { isInside, projectPath } from "../config.mjs";
3
3
  import { PREVIEW_APP_URI } from "../preview-resources.mjs";
4
+ import { themesCss } from "../themes-generated.mjs";
5
+ import { defaultThemes } from "../themes.mjs";
4
6
  export { PREVIEW_APP_URI };
5
7
 
6
8
  export const APP_MIME = "text/html;profile=mcp-app";
@@ -18,19 +20,20 @@ export function previewApp(selection) {
18
20
  export function tokenWidgetData(inventory) {
19
21
  const scopes = new Map();
20
22
  for (const token of inventory.tokens) for (const definition of token.definitions) {
21
- // Conditional definitions are displayed verbatim; simple theme selectors
22
- // also drive the in-frame browser samples, including alias resolution.
23
- if (definition.scope.includes("@") || definition.scope.includes(" > ")) continue;
23
+ // Conditional definitions are displayed verbatim; the root and brand definitions, with the
24
+ // generated theme resolvers, drive the in-frame browser samples, including alias resolution.
25
+ if (definition.conditional) continue;
24
26
  if (!scopes.has(definition.scope)) scopes.set(definition.scope, []);
25
- scopes.get(definition.scope).push(`${token.name}:${definition.value};`);
27
+ scopes.get(definition.scope).push(`${definition.property ?? token.name}:${definition.authored ?? definition.value};`);
26
28
  }
27
- return { ...inventory, css: [...scopes].map(([selector, declarations]) => `${selector}{${declarations.join("")}}`).join("\n") };
29
+ const css = [...scopes].map(([selector, declarations]) => `${selector}{${declarations.join("")}}`).join("\n");
30
+ return { ...inventory, css: `${css}\n${themesCss(inventory.tokens, { themes: inventory.themes ?? defaultThemes, brands: inventory.brands ?? [] })}` };
28
31
  }
29
32
 
30
33
  export function tokensApp(data) {
31
34
  return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>ADS tokens</title><style>
32
35
  html{color-scheme:light dark;background:Canvas;color:CanvasText;font:13px/1.55 system-ui}html,body{height:100%}body{margin:0}#ads-token-root{padding:32px}#ads-scenario-root{height:100%}header{display:flex;gap:8px;flex-wrap:wrap;align-items:center}h1{font-size:18px;margin:0 auto 0 0}button,input,select{font:inherit;color:CanvasText;background:Canvas;border:1px solid GrayText;border-radius:4px;padding:6px 8px}ul{padding:0;list-style:none}li{margin:12px 0}summary{cursor:pointer;display:flex;gap:16px;align-items:baseline;flex-wrap:wrap}code{font:12px monospace;overflow-wrap:anywhere}dl{border:1px solid GrayText;padding:12px;overflow-wrap:anywhere}dt{font-weight:600}dd{margin:2px 0 12px}footer{display:flex;gap:8px;align-items:center}iframe{display:block;width:100%;height:100%;border:0}[hidden]{display:none!important}:root[data-theme="light"]{color-scheme:light}:root[data-theme="dark"]{color-scheme:dark}
33
- </style></head><body><p id="ads-scenario-status" role="status" hidden></p><main id="ads-scenario-root" hidden></main><main id="ads-token-root"><header><h1>Token definitions</h1><input id="ads-token-search" type="search" aria-label="Find token" placeholder="Find a token"><select id="ads-token-theme" aria-label="Preview theme"></select><button id="ads-token-refresh" type="button" disabled>Refresh</button></header><p id="ads-widget-status" role="status">Connecting to the Apps host…</p><ul id="ads-token-list"></ul><footer><button id="ads-token-prev" type="button">Previous</button><span id="ads-token-count"></span><button id="ads-token-next" type="button">Next</button></footer></main><script type="application/json" id="ads-token-seed">${safeJson(data)}</script><script type="module">${bridge()}</script></body></html>`;
36
+ </style></head><body><p id="ads-scenario-status" role="status" hidden></p><main id="ads-scenario-root" hidden></main><main id="ads-token-root"><header><h1>Token definitions</h1><input id="ads-token-search" type="search" aria-label="Find token" placeholder="Find a token"><select id="ads-token-theme" aria-label="Preview theme"></select><select id="ads-token-brand" aria-label="Preview brand" hidden></select><button id="ads-token-refresh" type="button" disabled>Refresh</button></header><p id="ads-widget-status" role="status">Connecting to the Apps host…</p><ul id="ads-token-list"></ul><footer><button id="ads-token-prev" type="button">Previous</button><span id="ads-token-count"></span><button id="ads-token-next" type="button">Next</button></footer></main><script type="application/json" id="ads-token-seed">${safeJson(data)}</script><script type="module">${bridge()}</script></body></html>`;
34
37
  }
35
38
 
36
39
  export function scenarioApp() {
@@ -6,7 +6,7 @@ import { developmentRuntime, packageScriptCommand } from "../development-runtime
6
6
 
7
7
  export const GUIDE_URI = "ads://project/guide";
8
8
  // Put the task triggers and entry path first: some hosts shorten server guidance.
9
- export const serverInstructions = "Use ADS for UI work: components, patterns, controllers, hooks, tokens, themes, branding, layout, interaction, accessibility, motion and showcase review. Start with ads_status; if tools are not exposed, read ads://project/guide then ads://project/status. Use the returned projectRoot and commands. Choose direct source editing or MCP-only editing using ads://guides/workflows, based on actual editor access and user preference, not mutations.enabled. With direct code access, edit owned files normally and use MCP for preview/checks; ordinary direct edits do not require drafts or ads_accept. MCP-only iterative design uses enabled draft tools, rendered review and exact-revision ads_accept; read ads://guides/drafts. Complete tracked proposals by accepting required drafts; accept dependencies first and review dependents again. Without a source editor or enabled mutation tools, inspection is available but editing is not. Low-level MCP repairs can use ads_units and guarded ads_apply_patch for one owner or ads_apply_transaction for coupled owners. Find existing public UI with ads_catalog; discover its previews with ads_scenarios and open ads_show_scenario. Starting ADS also serves its built-in showcase: use ads_status.showcaseUrl for browser review instead of starting another runtime/compiler or project browser app. Read one relevant ADS skill before editing. Inspect the real preview, edit its owned source, check the build and review again. Scope source/guides to the project, its instruction ancestry and user-selected import/reference sources; broad searches of /mnt or home are not ADS discovery. Domain-model/requirements work is a separate project workflow. For requested visual evidence, use ads_capture or screenshot-enabled patch dry runs; read ads://guides/captures for named targets, image resources and the current/candidate lifecycle. For behavior work, read ads://guides/behaviors and use ads_behaviors/ads_verify: scenario exercises are demonstrations, and registered guarantees need current passing execution evidence. For direct edits, use ads_validate with policy acceptance to enforce the project acceptance policy without applying source. Draft acceptance uses the same configured policy on its candidate; draft edit/show runs neither policy. Test registration alone does not gate acceptance. Use ads_validate with scope changed during editing, and the default full validation policy/scope after test/ownership/config migrations, before releases, or for explicit complete audits. Read ads://guides/validation; report actual scope/revision and inspect failures through ads_results. Execution replies are bounded summaries. Read only needed sections with ads_results(resultId, section, status, cursor); follow nextCursor without rerunning. For a failure, inspect its boundary and acceptance, then ads_investigate with the outcome's exact unit/check/runId; detail sections and artifacts load separately (ads://guides/evidence). Preserve valid APIs when source tracing is inconclusive. After targeted investigation, record suspected ADS defects with ads_report_bug or missing capabilities with ads_request_feature; read ads://guides/reporting. These are local untriaged reports, not established causes or upstream issues. Use the configured project framework and declared dependencies; MCP hosts supply no ad hoc APIs. MCP source checks do not replace browser tests; direct edits still need project checks. Reading HTML is not rendering, and reading a skill is not native activation. A running watcher is not proof of current source: inspect ads_status.build or ads://project/build after edits. Notifications may not reach the agent. Only explicitly enabled mutation tools edit project-owned ADS units after validation. Checks and compiler commands come from validated project configuration, never an ad hoc command argument.";
9
+ export const serverInstructions = "Use ADS for UI work: components, patterns, controllers, hooks, tokens, themes, branding, layout, interaction, accessibility, motion and showcase review. Start with ads_status; if tools are not exposed, read ads://project/guide then ads://project/status. Use the returned projectRoot and commands. Choose direct source editing or MCP-only editing using ads://guides/workflows, based on actual editor access and user preference, not mutations.enabled. With direct code access, edit owned files normally and use MCP for preview/checks; ordinary direct edits do not require drafts or ads_accept. MCP-only iterative design uses enabled draft tools, rendered review and exact-revision ads_accept; read ads://guides/drafts. Complete tracked proposals by accepting required drafts; accept dependencies first and review dependents again. Without a source editor or enabled mutation tools, inspection is available but editing is not. Low-level MCP repairs can use ads_units and guarded ads_apply_patch for one owner or ads_apply_transaction for coupled owners. Find existing public UI with ads_catalog; discover its previews with ads_scenarios and open ads_show_scenario. Starting ADS also serves its built-in showcase: use ads_status.showcaseUrl for browser review instead of starting another runtime/compiler or project browser app. Read one relevant ADS skill before editing. Inspect the real preview, edit its owned source, check the build and review again. Scope source/guides to the project, its instruction ancestry and user-selected import/reference sources; broad searches of /mnt or home are not ADS discovery. Domain-model/requirements work is a separate project workflow. For requested visual evidence, use ads_capture or screenshot-enabled patch dry runs; read ads://guides/captures for named targets, image resources and the current/candidate lifecycle. For behavior work, read ads://guides/behaviors and use ads_behaviors/ads_verify: scenario exercises are demonstrations, and registered guarantees need current passing execution evidence. For direct edits, use ads_validate with policy acceptance to enforce the project acceptance policy without applying source. Draft acceptance and guarded patches use the same configured policy on their candidate, including the axe-core audit of affected UI scenarios when acceptance.browserAudit is true; draft edit/show runs neither policy. Test registration alone does not gate acceptance. Use ads_validate with scope changed during editing, and the default full validation policy/scope after test/ownership/config migrations, before releases, or for explicit complete audits. Read ads://guides/validation; report actual scope/revision and inspect failures through ads_results. Execution replies are bounded summaries. Read only needed sections with ads_results(resultId, section, status, cursor); follow nextCursor without rerunning. For a failure, inspect its boundary and acceptance, then ads_investigate with the outcome's exact unit/check/runId; detail sections and artifacts load separately (ads://guides/evidence). Preserve valid APIs when source tracing is inconclusive. After targeted investigation, record suspected ADS defects with ads_report_bug or missing capabilities with ads_request_feature; read ads://guides/reporting. These are local untriaged reports, not established causes or upstream issues. Use the configured project framework and declared dependencies; MCP hosts supply no ad hoc APIs. MCP source checks do not replace browser tests; direct edits still need project checks. Reading HTML is not rendering, and reading a skill is not native activation. A running watcher is not proof of current source: inspect ads_status.build or ads://project/build after edits. Notifications may not reach the agent. Only explicitly enabled mutation tools edit project-owned ADS units after validation. Checks and compiler commands come from validated project configuration, never an ad hoc command argument.";
10
10
 
11
11
  function manager(root, pkg) {
12
12
  if (typeof pkg.packageManager === "string") return pkg.packageManager.split("@")[0];
@@ -1,4 +1,5 @@
1
1
  import { spawnSync } from "node:child_process";
2
+ import { writeThemesCss } from "../themes-generated.mjs";
2
3
  import { mkdtempSync } from "node:fs";
3
4
  import { tmpdir } from "node:os";
4
5
  import { createHash, randomUUID } from "node:crypto";
@@ -327,6 +328,8 @@ export function createDraftController(directory, { edits, startPreview, prewarm
327
328
  for (const target of session.inputs.keys()) if (!desired.has(target)) rmSync(safe(session.workspace, target), { force: true });
328
329
  for (const [target, content] of desired) if (session.inputs.get(target) !== hash(content) || !existsSync(safe(session.workspace,target))) atomic(safe(session.workspace, target), content);
329
330
  session.inputs = new Map([...desired].map(([target, content]) => [target, hash(content)]));
331
+ // A draft's token edits preview with their own generated theme sheet.
332
+ try { const draftOptions = loadConfig(session.workspace); writeThemesCss(draftOptions, inspectTokens(session.workspace, draftOptions)); } catch { /* Acceptance checks report broken token sheets. */ }
330
333
  const modules = path.join(session.workspace, "node_modules");
331
334
  if (!existsSync(modules) && existsSync(path.join(root, "node_modules"))) symlinkSync(realpathSync(path.join(root, "node_modules")), modules, process.platform === "win32" ? "junction" : "dir");
332
335
  if (!existsSync(path.join(session.workspace, "dist")) && existsSync(path.join(root, "dist/cli.mjs"))) {
@@ -16,6 +16,8 @@ import { checkCandidate, checkCommand, projectChecks as checks } from "../valida
16
16
  import { preparePreviewCache } from "../scenarios-compiler.mjs";
17
17
  import { validationInputFiles } from "../validation-inputs.mjs";
18
18
  import { mutationLimits } from "./mutation-limits.mjs";
19
+ import { writeThemesCss } from "../themes-generated.mjs";
20
+ import { inspectTokens } from "../tokens.mjs";
19
21
 
20
22
  export { mutationLimits } from "./mutation-limits.mjs";
21
23
  const digest = bytes => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
@@ -178,7 +180,7 @@ export function createMutationController(directory, { captures = createCaptureCo
178
180
  const verified = [];
179
181
  try {
180
182
  const options = loadConfig(root);
181
- if (screenshot && !dryRun || selections !== undefined && !screenshot) throw fail("mutation-capture", "Use screenshot:true only with dryRun:true and an explicit captures:[{scenario,target?,theme?,viewport?}] selection. Ordinary patches create no screenshots.");
183
+ if (screenshot && !dryRun || selections !== undefined && !screenshot) throw fail("mutation-capture", "Use screenshot:true only with dryRun:true and an explicit captures:[{scenario,target?,theme?,brand?,viewport?}] selection. Ordinary patches create no screenshots.");
182
184
  if (screenshot) selections = captureSelections(selections);
183
185
  if (patches !== undefined && (unit !== undefined || patch !== undefined || patchFile !== undefined || !Array.isArray(patches) || patches.length < 2 || patches.length > mutationLimits.units)) throw fail("mutation-batch", `A transaction requires 2–${mutationLimits.units} distinct owner patches, without a top-level unit/patch.`);
184
186
  const groups = patches ?? [{unit,patch,patchFile}];
@@ -259,6 +261,20 @@ export function createMutationController(directory, { captures = createCaptureCo
259
261
  }
260
262
  checkUnitCandidate(loadConfig(candidate),plan.unit,selected,inventory);
261
263
  }
264
+ // Token sheet and theme/brand config patches carry the regenerated theme sheet with them.
265
+ {
266
+ const generatedOptions = loadConfig(candidate);
267
+ for (const generated of writeThemesCss(generatedOptions, inspectTokens(candidate, generatedOptions)).files) {
268
+ const relative = path.relative(candidate, generated.file).replaceAll("\\", "/"), current = generated.text !== undefined && read(options, relative);
269
+ if (current && current.content !== generated.text) {
270
+ if (!byPath.has(relative)) {
271
+ originals.push({...current,mode:current.exists ? lstatSync(address(options,relative)).mode : undefined});
272
+ byPath.set(relative,changes.length);
273
+ changes.push({path:relative,originalContent:current.content,content:generated.text,expectedDigest:current.digest});
274
+ } else changes[byPath.get(relative)].content = generated.text;
275
+ }
276
+ }
277
+ }
262
278
  const candidateOptions = loadConfig(candidate);
263
279
  // A proposed configuration may add roots or explicit inputs. Preserve
264
280
  // already patched files while bringing those additional live inputs in.
@@ -293,6 +309,11 @@ export function createMutationController(directory, { captures = createCaptureCo
293
309
  verified.push(await checkCommand(check.command, check.args, candidate, signal, undefined, {category:"build",phase:`project-check:${check.args.at(-1)}`}, candidateOptions.config.mcp.mutationCheckTimeoutMs));
294
310
  }
295
311
  const behaviorUnits = candidateOptions.config.acceptance.behaviorChecks ? affectedBehaviorUnits(candidateOptions, changes.map(change => change.path)) : [];
312
+ // acceptance.browserAudit: axe-core audits the candidate's affected UI scenarios before any source is written.
313
+ // It reuses the candidate preview host built for behavior checks/captures; on its own it starts a
314
+ // candidate host that compiles only the selected scenarios.
315
+ const audit = candidateOptions.config.acceptance.browserAudit ? await import("../browser-audit.mjs") : null;
316
+ const auditSelection = audit?.auditScenarioSelection(candidateOptions, changes.map(change => change.path));
296
317
  if ((behaviorUnits.length || screenshot) && candidateOptions.config.mcp.previewManifest && candidateOptions.config.mcp.previewWatch) {
297
318
  boundary=evidenceFailure("build","preview-build","ADS_PREVIEW_BUILD");
298
319
  progress={stage:"preview-build",message:"Building all candidate previews"};notifyProgress?.(progress);
@@ -314,6 +335,24 @@ export function createMutationController(directory, { captures = createCaptureCo
314
335
  verified.push({ name: "registered behavior checks", passed: true, results: evidence.results });
315
336
  }
316
337
  else verified.push({name:"registered behavior checks",skipped:true,reason:candidateOptions.config.acceptance.behaviorChecks ? "No affected behavior contracts." : "Not required by acceptance policy."});
338
+ if (auditSelection) {
339
+ boundary=evidenceFailure("runner","browser-audit","ADS_AUDIT_FAILED");
340
+ const selection = {selection:auditSelection.mode,...(auditSelection.reason?{selectionReason:auditSelection.reason}:{}),auditedScenarios:auditSelection.scenarios};
341
+ if (!auditSelection.scenarios.length) verified.push({name:"browser-accessibility-audit",skipped:true,reason:"No affected UI scenarios.",scenarios:0,...selection});
342
+ else {
343
+ progress={stage:"browser-audit",message:`Accessibility audit of ${auditSelection.scenarios.length} candidate scenarios`};notifyProgress?.(progress);
344
+ let result;
345
+ try { result = await audit.runBrowserAudit(candidate, {scenarios:auditSelection.scenarios,previewHost,signal,onProgress:value=>{progress=value;notifyProgress?.(value);}}); }
346
+ catch (error) {
347
+ if (signal.aborted) throw error;
348
+ verified.push({name:"browser-accessibility-audit",passed:false,...selection});
349
+ return lastResult = mutationEvidence({ ok: false, applied: false, diagnostics: [{ rule: "browser-audit", message: error.message, failure: evidenceFailure("runner","browser-audit",error.code ?? "ADS_AUDIT_FAILED") }], checks: verified },candidateRevision);
350
+ }
351
+ const {routed,check} = audit.auditCheck(result,selection);
352
+ verified.push(check);
353
+ if (!check.passed) return lastResult = mutationEvidence({ ok: false, applied: false, diagnostics: routed.diagnostics.map(item => ({...item,failure:evidenceFailure("assertion","browser-audit",item.rule)})), total: routed.diagnostics.length, checks: verified, ...(routed.advisories.length ? {advisories:routed.advisories,advisoryCount:routed.advisories.length} : {}) },candidateRevision);
354
+ }
355
+ }
317
356
  let screenshots;
318
357
  if (screenshot) {
319
358
  boundary=evidenceFailure("runner","capture","ADS_CAPTURE_FAILED");