@reqvire-org/ads 0.3.49 → 0.3.51

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 (93) hide show
  1. package/README.md +36 -6
  2. package/dist/active-clock.mjs +34 -0
  3. package/dist/assets.mjs +20 -2
  4. package/dist/boundaries.mjs +2 -0
  5. package/dist/browser-audit/first-render.mjs +18 -0
  6. package/dist/browser-audit/layout-overflow.mjs +98 -0
  7. package/dist/browser-audit/layout-shift.mjs +32 -0
  8. package/dist/browser-audit/non-text-contrast.mjs +87 -0
  9. package/dist/browser-audit/worker.mjs +52 -15
  10. package/dist/browser-audit.mjs +239 -22
  11. package/dist/capture/worker.mjs +2 -5
  12. package/dist/check.mjs +16 -1
  13. package/dist/cli.mjs +9 -5
  14. package/dist/component-contrast.mjs +138 -0
  15. package/dist/config.mjs +12 -6
  16. package/dist/finding-rules.mjs +16 -1
  17. package/dist/fonts-generated.mjs +85 -0
  18. package/dist/image-attributes.mjs +110 -0
  19. package/dist/init.mjs +2 -0
  20. package/dist/layout-widths.mjs +228 -0
  21. package/dist/mcp/context.mjs +1 -1
  22. package/dist/mcp/mutations.mjs +7 -5
  23. package/dist/mcp/preview-watch.mjs +9 -8
  24. package/dist/mcp/server.mjs +6 -4
  25. package/dist/preview-files.mjs +3 -0
  26. package/dist/project-boundary.mjs +23 -0
  27. package/dist/project-documents.mjs +2 -1
  28. package/dist/scenarios-compiler.mjs +23 -3
  29. package/dist/showcase/client.bundle.js +11 -11
  30. package/dist/showcase/icons.js +5 -5
  31. package/dist/showcase/style.css +1 -1
  32. package/dist/skills/ads-break-ui/SKILL.md +9 -0
  33. package/dist/skills/ads-break-ui/references/atomic-styles.md +2 -0
  34. package/dist/skills/ads-break-ui/references/design-data.md +52 -0
  35. package/dist/skills/ads-break-ui/references/drafts.md +1 -1
  36. package/dist/skills/ads-break-ui/references/guarded-editing.md +1 -1
  37. package/dist/skills/ads-break-ui/references/validation.md +9 -5
  38. package/dist/skills/ads-designer/SKILL.md +26 -4
  39. package/dist/skills/ads-designer/references/accessibility.md +30 -13
  40. package/dist/skills/ads-designer/references/atomic-styles.md +2 -0
  41. package/dist/skills/ads-designer/references/branding.md +10 -5
  42. package/dist/skills/ads-designer/references/cli.md +2 -1
  43. package/dist/skills/ads-designer/references/design-data.md +52 -0
  44. package/dist/skills/ads-designer/references/drafts.md +1 -1
  45. package/dist/skills/ads-designer/references/guarded-editing.md +1 -1
  46. package/dist/skills/ads-designer/references/mobile.md +3 -0
  47. package/dist/skills/ads-designer/references/performance.md +89 -0
  48. package/dist/skills/ads-designer/references/validation.md +9 -5
  49. package/dist/skills/ads-import/references/atomic-styles.md +2 -0
  50. package/dist/skills/ads-import/references/cli.md +2 -1
  51. package/dist/skills/ads-import/references/design-data.md +52 -0
  52. package/dist/skills/ads-import/references/drafts.md +1 -1
  53. package/dist/skills/ads-import/references/guarded-editing.md +1 -1
  54. package/dist/skills/ads-import/references/validation.md +9 -5
  55. package/dist/skills/ads-motion/references/atomic-styles.md +2 -0
  56. package/dist/skills/ads-motion/references/design-data.md +52 -0
  57. package/dist/skills/ads-motion/references/drafts.md +1 -1
  58. package/dist/skills/ads-motion/references/guarded-editing.md +1 -1
  59. package/dist/skills/ads-motion/references/validation.md +9 -5
  60. package/dist/skills/ads-port/references/atomic-styles.md +2 -0
  61. package/dist/skills/ads-port/references/cli.md +2 -1
  62. package/dist/skills/ads-port/references/design-data.md +52 -0
  63. package/dist/skills/ads-port/references/drafts.md +1 -1
  64. package/dist/skills/ads-port/references/guarded-editing.md +1 -1
  65. package/dist/skills/ads-port/references/validation.md +9 -5
  66. package/dist/starters/preact/package.json +1 -0
  67. package/dist/starters/react/ADS.md +1 -1
  68. package/dist/starters/react/README.md +16 -2
  69. package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +1 -1
  70. package/dist/starters/react/design-system/components/Content/Image/Image.ads.fixture.ts +2 -0
  71. package/dist/starters/react/design-system/components/Content/Image/Image.ads.scenario.tsx +13 -0
  72. package/dist/starters/react/design-system/components/Content/Image/Image.tsx +51 -0
  73. package/dist/starters/react/design-system/components/Content/Image/README.md +20 -0
  74. package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +2 -2
  75. package/dist/starters/react/design-system/index.ts +1 -0
  76. package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +16 -0
  77. package/dist/starters/react/design-system/tokens/spacing.css +18 -0
  78. package/dist/starters/react/package-lock.json +47 -0
  79. package/dist/starters/react/package.json +2 -1
  80. package/dist/test-boundaries.mjs +30 -1
  81. package/dist/themes-generated.mjs +15 -4
  82. package/dist/token-quality.mjs +27 -17
  83. package/dist/units.mjs +2 -1
  84. package/dist/validation-checks.mjs +5 -4
  85. package/dist/validation.mjs +1 -1
  86. package/dist/verification/browser.mjs +28 -2
  87. package/dist/verification.mjs +5 -4
  88. package/docs/ADS.md +4 -1
  89. package/docs/ARCHITECTURE.md +16 -3
  90. package/docs/CHANGELOG.md +127 -12
  91. package/docs/GUIDE.md +238 -14
  92. package/docs/MCP.md +14 -10
  93. package/package.json +1 -1
@@ -8,6 +8,7 @@ import { buildFailure, inspectBuildStatus } from "./build-status.mjs";
8
8
  import { previewSessionDirectories, withPreviewSession } from "../preview-scope.mjs";
9
9
  import { developmentExecutable } from "../development-runtime.mjs";
10
10
  import { readPreviewManifest } from "../preview-resources.mjs";
11
+ import { activeNow } from "../active-clock.mjs";
11
12
 
12
13
  function stamp(file) {
13
14
  try { const stat = statSync(file); return `${stat.mtimeMs}:${stat.ctimeMs}:${stat.size}`; }
@@ -173,13 +174,13 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
173
174
  if (signal?.aborted) throw new Error("Preview request cancelled.");
174
175
  const app = config.apps.find((entry) => path.resolve(root, entry.file) === file);
175
176
  let baseline = baselines.get(file) ?? null;
176
- let deadline = Date.now() + buildTimeout;
177
+ let deadline = activeNow() + buildTimeout;
177
178
  let restarted = false;
178
- while (Date.now() < deadline) {
179
+ while (activeNow() < deadline) {
179
180
  if (signal?.aborted) throw new Error("Preview request cancelled.");
180
181
  if (suspended) {
181
- const pausedAt = Date.now();
182
- await waitForResume(signal); deadline += Date.now() - pausedAt;
182
+ const pausedAt = activeNow();
183
+ await waitForResume(signal); deadline += activeNow() - pausedAt;
183
184
  if (disposed) throw new Error("Preview watcher is stopped.");
184
185
  start(); request(file, true); baseline = baselines.get(file) ?? null;
185
186
  }
@@ -255,8 +256,8 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
255
256
  if (!command || disposed) throw new Error("A full managed preview build requires mcp.previewWatch.");
256
257
  if (state === "failed" || restarting || stalled) await restart();
257
258
  start(); full = randomUUID(); request(active, true);
258
- const token = full, deadline = Date.now() + timeoutMs;
259
- while (Date.now() < deadline) {
259
+ const token = full, deadline = activeNow() + timeoutMs;
260
+ while (activeNow() < deadline) {
260
261
  if (signal?.aborted) throw new Error("Preview build cancelled.");
261
262
  if (state !== "running") throw new Error(error ?? "Preview compiler stopped during full build.");
262
263
  let result;
@@ -279,8 +280,8 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
279
280
  if (disposed) return;
280
281
  if (state === "failed" || restarting || stalled) await restart();
281
282
  start();
282
- const deadline = Date.now() + buildTimeout;
283
- while (!disposed && state === "running" && Date.now() < deadline) {
283
+ const deadline = activeNow() + buildTimeout;
284
+ while (!disposed && state === "running" && activeNow() < deadline) {
284
285
  try { if (JSON.parse(readFileSync(reportFile, "utf8")).session === session) return; } catch { /* Waiting for compiler initialization, without requesting a graph. */ }
285
286
  await new Promise(resolve => setTimeout(resolve, 20));
286
287
  }
@@ -284,6 +284,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
284
284
  { uri: "ads://guides/tokens", name: "Shared Data and component variable boundaries", mimeType: "text/markdown" },
285
285
  { uri: "ads://guides/branding", name: "Brand artwork, icons, committed targets and glyph sets", mimeType: "text/markdown" },
286
286
  { uri: "ads://guides/accessibility", name: "WCAG 2.2 AA guards and accessibility practice", mimeType: "text/markdown" },
287
+ { uri: "ads://guides/performance", name: "Images, fonts, layout shift and what ADS leaves to Lighthouse", mimeType: "text/markdown" },
287
288
  { uri: "ads://guides/reporting", name: "Report suspected ADS bugs and feature requests", mimeType: "text/markdown" },
288
289
  { uri: TOKENS_APP_URI, name: "Experimental token widget", mimeType: APP_MIME },
289
290
  { uri: SCENARIO_APP_URI, name: "Experimental scenario widget", mimeType: APP_MIME },
@@ -331,6 +332,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
331
332
  if (uri === "ads://guides/validation") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/validation.md", import.meta.url), "utf8") }] };
332
333
  if (uri === "ads://guides/runtimes") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/runtimes.md", import.meta.url), "utf8") }] };
333
334
  if (uri === "ads://guides/evidence") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/evidence.md", import.meta.url), "utf8") }] };
335
+ if (uri === "ads://guides/performance") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/performance.md", import.meta.url), "utf8") }] };
334
336
  if (uri === "ads://guides/accessibility") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/accessibility.md", import.meta.url), "utf8") }] };
335
337
  if (uri === "ads://guides/branding") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/branding.md", import.meta.url), "utf8") }] };
336
338
  if (uri === "ads://guides/tokens") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/design-data.md", import.meta.url), "utf8") }] };
@@ -442,7 +444,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
442
444
  { name:"ads_create_draft", description:"Create a Git-committable proposal under ads-drafts/ for 1–64 coupled ADS owners, copying only their source/companions into non-importable .ads files. New owners are allowed. Optional dependencies name separate unaccepted drafts used by pattern/composition previews. Creation does not change accepted source. Edit the returned files normally; use ads_update_draft to register additions/deletions.", schema:z.object({units:z.array(z.string().min(1).max(256)).min(1).max(mutationLimits.units),title:z.string().min(1).max(160).optional(),id:draftIdSchema.optional(),dependencies:z.array(draftIdSchema).max(8).default([]),tokenGroups:z.array(z.string().min(1).max(160)).max(32).default([])}).strict(),_meta:{ui:{visibility:["model"]}},annotations:{...annotations,readOnlyHint:false,idempotentHint:false},call:async args=>{const result=drafts.create(args);if(observeChanges)await refresh();return json(result);} },
443
445
  { name:"ads_update_draft", description:"Update marked draft source or register new/deleted canonical target paths. Pass the current revision from ads_drafts. Source is UTF-8 unless encoding:base64; content:null proposes deletion. refresh:true rebases onto current accepted source using stored baselines; non-overlapping edits merge and overlapping edits leave the draft unchanged with diagnostics. Use changes with refresh only for explicit resolved contents of existing draft files; refresh separately from dependency changes. Optional dependencies replaces the draft dependency list. Normal local file edits need no iteration tool. Accepted source remains unchanged; ownership and all required checks run at acceptance.",schema:z.object({id:draftIdSchema,revision:draftRevisionSchema,refresh:z.boolean().default(false),dependencies:z.array(draftIdSchema).max(8).optional(),changes:z.array(z.object({unit:z.string().max(256),path:z.string().min(1).max(500),content:z.string().max(256*1024).nullable(),encoding:z.enum(["utf8","base64"]).optional()}).strict()).max(32).default([])}).strict(),_meta:{ui:{visibility:["model"]}},annotations:{...annotations,readOnlyHint:false,idempotentHint:false},call:async args=>{const result=drafts.update(args);if(observeChanges)await refresh();return json(result);} },
444
446
  { name:"ads_drop_draft",description:"Delete an exact tracked draft and its generated preview. This is Drop, not a separate refusal workflow. Accepted source is unchanged. Dependents report a missing dependency until corrected.",schema:z.object({id:draftIdSchema,revision:draftRevisionSchema}).strict(),_meta:{ui:{visibility:["model"]}},annotations:{...annotations,readOnlyHint:false,destructiveHint:true,idempotentHint:false},call:async args=>{const result=await drafts.drop(args);if(observeChanges)await refresh();return json(result);} },
445
- { name:"ads_accept",title:"Accept a reviewed draft",description:"Auto-mode acceptance: validate and apply the exact rendered/reviewed draft revision in one operation. Accept dependency drafts first; dependent drafts automatically switch to their final @ds implementations. Mandatory ADS guards and acceptance.checks run once on the candidate; affected registered tests gate acceptance when acceptance.behaviorChecks is true. When acceptance.browserAudit is true, axe-core audits the candidate's affected UI scenarios in every declared brand and theme; any a11y-axe error (or an audit that cannot run) rejects acceptance. Draft/source changes invalidate acceptance. On failure retain the draft and inspect ads_results; on success apply normal source, remove the draft and publish an event. No additional human approval or manual Apply step.",schema:z.object({fresh:z.boolean().default(false),id:draftIdSchema,revision:draftRevisionSchema}).strict(),_meta:{ui:{visibility:["model"]}},annotations:{...annotations,readOnlyHint:false,destructiveHint:true,idempotentHint:false},call:async(args,signal,progress)=>{
447
+ { name:"ads_accept",title:"Accept a reviewed draft",description:"Auto-mode acceptance: validate and apply the exact rendered/reviewed draft revision in one operation. Accept dependency drafts first; dependent drafts automatically switch to their final @ds implementations. Mandatory ADS guards and acceptance.checks run once on the candidate; affected registered tests gate acceptance when acceptance.behaviorChecks is true. Unless acceptance.browserAudit is false, axe-core audits the candidate's affected UI scenarios in every declared brand and theme; any a11y-axe error (or an audit that cannot run) rejects acceptance. Draft/source changes invalidate acceptance. On failure retain the draft and inspect ads_results; on success apply normal source, remove the draft and publish an event. No additional human approval or manual Apply step.",schema:z.object({fresh:z.boolean().default(false),id:draftIdSchema,revision:draftRevisionSchema}).strict(),_meta:{ui:{visibility:["model"]}},annotations:{...annotations,readOnlyHint:false,destructiveHint:true,idempotentHint:false},call:async(args,signal,progress)=>{
446
448
  const result=await drafts.accept(args,signal,progress);
447
449
  if(result.applied){await previewWatch?.invalidate?.();await refresh(true);}else await refresh();
448
450
  return finishExecution("mutation",result);
@@ -526,7 +528,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
526
528
  { name:"ads_report_bug",title:"Report a suspected ADS defect",description:"Record an unexpected ADS guard, preview, build, transport or runner behavior after targeted investigation. Provide expected/observed behavior, minimal steps and frequency; keep suspectedCause separate. Evidence optionally selects a returned resultId or exact unit/check/runId. ADS snapshots compact evidence, version, configured framework and revisions. A report is an untriaged agent claim, not proof of an ADS cause. Returns a small receipt with the report ID and local file path; submitted reports cannot be read through MCP. Stored locally under .ds/reports/ with deduplication, no automatic expiry and no upload. Read ads://guides/reporting; ordinary valid guard rejections should be fixed in their owner.",schema:bugReportSchema,annotations:{readOnlyHint:false,destructiveHint:false,idempotentHint:false,openWorldHint:false},call:args=>submitReport("bug",args) },
527
529
  { name:"ads_request_feature",title:"Request an ADS capability",description:"Record a legitimate workflow that needs a missing ADS capability. Provide workflow, capability and impact; proposal is optional. Preserve valid design/API rather than weakening guards or inventing workaround props. Optional evidence references an existing execution/check, not pasted files/logs. ADS attaches compact context and returns a receipt with the report ID and local file path. Intake is submission-only; no report-reading tools or resources. Shared local report store: deduplicated, untriaged, no automatic expiry or upload. Read ads://guides/reporting; use ads_report_bug for suspected broken existing behavior.",schema:featureRequestSchema,annotations:{readOnlyHint:false,destructiveHint:false,idempotentHint:false,openWorldHint:false},call:args=>submitReport("feature",args) },
528
530
  { name: "ads_investigate", title: "Inspect check evidence", description: "Read a summary for an exact unit/check, or list latest investigations when no check is selected. Pass the outcome's runId to reject superseded evidence. Summary is at most 4 KiB JSON; details, requests, browserErrors and artifacts are separate paged sections (default 10/max 20 entries, 8 KiB). Read truncated rows with recordIndex/offset/chars and the exact runId. Artifact URIs are read separately. Does not rerun checks or infer root cause. Lists latest checks; an exact runId reads retained historical evidence, including candidate runs.", schema: z.object({unit:z.string().min(1).max(256).optional(),check:z.string().min(1).max(100).optional(),runId:z.string().min(1).max(100).optional(),section:z.enum(investigationSections).optional(),...paged,...recordRange}).strict(), call: args => json(investigationPage(root,args)) },
529
- { name: "ads_validate", description: "Run mandatory ADS architecture/freshness guards and the selected project policy. policy defaults to validation: its configured scripts, preview freshness, optional registered behavior checks and, when <policy>.browserAudit is true, an axe-core audit of every rendered UI scenario in every declared brand and theme (a11y-axe findings are blocking errors in the diagnostics section). policy acceptance runs acceptance.checks, acceptance.behaviorChecks and acceptance.browserAudit without applying source, for direct editing; draft acceptance and guarded patches run the same acceptance policy, auditing only the candidate's affected UI scenarios. No script names are inferred. scope changed selects affected registered checks from this policy's own successful full baseline; broad changes expand to all. Project scripts keep full scope. Draft edit/show never triggers policies. Reports skipped stages honestly and a bounded resultId; use ads_results for details. Read ads://guides/validation. Trusted configured commands run; nothing is installed.", schema: z.object({scope:z.enum(["all","changed"]).default("all"),policy:z.enum(["acceptance","validation"]).default("validation"),fresh:z.boolean().default(false)}).strict(), annotations: {readOnlyHint:false,destructiveHint:false,idempotentHint:false,openWorldHint:false}, call: async (args,signal,progress) => {
531
+ { name: "ads_validate", description: "Run mandatory ADS architecture/freshness guards and the selected project policy. policy defaults to validation: its configured scripts, preview freshness, optional registered behavior checks and, unless <policy>.browserAudit is false, an axe-core audit of every rendered UI scenario in every declared brand and theme (a11y-axe findings are blocking errors in the diagnostics section). policy acceptance runs acceptance.checks, acceptance.behaviorChecks and acceptance.browserAudit without applying source, for direct editing; draft acceptance and guarded patches run the same acceptance policy, auditing only the candidate's affected UI scenarios. No script names are inferred. scope changed selects affected registered checks from this policy's own successful full baseline; broad changes expand to all. Project scripts keep full scope. Draft edit/show never triggers policies. Reports skipped stages honestly and a bounded resultId; use ads_results for details. Read ads://guides/validation. Trusted configured commands run; nothing is installed.", schema: z.object({scope:z.enum(["all","changed"]).default("all"),policy:z.enum(["acceptance","validation"]).default("validation"),fresh:z.boolean().default(false)}).strict(), annotations: {readOnlyHint:false,destructiveHint:false,idempotentHint:false,openWorldHint:false}, call: async (args,signal,progress) => {
530
532
  return finishExecution("validation",await validation.run(args,signal,progress));
531
533
  } },
532
534
  { name: "ads_verify", description: "Run one owner's registered development behavior checks using its configured runner/profile. Executes trusted project commands with bounded output, cancellation and process-tree cleanup; installs nothing. Progress and per-check timings are available through ads_status; a profile timeout bounds the whole run. Browser profiles use an isolated managed showcase/MCP App. React StrictMode requires a project development harness, not a production widget. Missing/skipped cases, stale inputs and process exit alone cannot produce passing evidence. Replies contain counts, acceptance, at most three failure summaries and a resultId (4 KiB JSON maximum). Page outcomes with ads_results; inspect one exact unit/check/runId with ads_investigate. Discover exact unit/check IDs with ads_behaviors first.", schema: z.object({ unit: z.string().min(1).max(256), checks: z.array(z.string().min(1).max(100)).min(1).max(100).optional() }).strict(), annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }, call: async (args, signal, progress) => {
@@ -543,11 +545,11 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
543
545
  const {patch,...result}=reconcileTokenSamples(options,args);
544
546
  return json({...result,removed:result.removed.slice(0,50),unresolved:result.unresolved.slice(0,50),unresolvedCount:result.unresolved.length,...storePreparedPatch(options,patch)});
545
547
  }},
546
- { name: "ads_apply_patch", description: "Apply one Git diff to one ADS unit from ads_units. Pass exactly one of patch (inline) or patchFile (a regular .patch/.diff under .ds/patches/, for large/binary diffs without model-context bytes). Text uses --- a/path, +++ b/path and exact @@ hunks; /dev/null creates/deletes. Git binary patches require git diff --binary --full-index and installed Git. A unit owns its implementation, previews and fixtures; imported peers are separate. Foundation, documentation, assets and configuration are editable too. Configuration changes may register/edit project guards and builders; the proposed schema, mandatory ADS and candidate project checks must pass. Only selected-unit public re-exports may change; preserve unrelated statements. A real selected-unit re-export may remove a redundant export {}; placeholder. A tokens patch may include its companionFiles foundation entry only to add/remove canonical imports required by token files created/deleted in this patch, preserving other imports/comments and canonical order. A runtime owner patch may also include its ds.config.json companion solely for that owner's inlineStyleFiles/styleWrites entries alongside its source. Unused permissions fail validation. When acceptance.browserAudit is true, axe-core audits the candidate's affected UI scenarios in every brand and theme; a11y-axe errors reject the patch. Set dryRun true to validate without writing. Optional screenshot:true plus captures:[{scenario,target?,theme?,brand?,viewport?}] captures current/candidate only after gates pass. For genuinely coupled owner changes use ads_apply_transaction with one patch per owner. Fix rejected patches and inspect current previews after acceptance. Reply is a 4 KiB summary; read diagnostics, outcomes and requested captures through ads_results using its resultId.",
548
+ { name: "ads_apply_patch", description: "Apply one Git diff to one ADS unit from ads_units. Pass exactly one of patch (inline) or patchFile (a regular .patch/.diff under .ds/patches/, for large/binary diffs without model-context bytes). Text uses --- a/path, +++ b/path and exact @@ hunks; /dev/null creates/deletes. Git binary patches require git diff --binary --full-index and installed Git. A unit owns its implementation, previews and fixtures; imported peers are separate. Foundation, documentation, assets and configuration are editable too. Configuration changes may register/edit project guards and builders; the proposed schema, mandatory ADS and candidate project checks must pass. Only selected-unit public re-exports may change; preserve unrelated statements. A real selected-unit re-export may remove a redundant export {}; placeholder. A tokens patch may include its companionFiles foundation entry only to add/remove canonical imports required by token files created/deleted in this patch, preserving other imports/comments and canonical order. A runtime owner patch may also include its ds.config.json companion solely for that owner's inlineStyleFiles/styleWrites entries alongside its source. Unused permissions fail validation. Unless acceptance.browserAudit is false, axe-core audits the candidate's affected UI scenarios in every brand and theme; a11y-axe errors reject the patch. Set dryRun true to validate without writing. Optional screenshot:true plus captures:[{scenario,target?,theme?,brand?,viewport?}] captures current/candidate only after gates pass. For genuinely coupled owner changes use ads_apply_transaction with one patch per owner. Fix rejected patches and inspect current previews after acceptance. Reply is a 4 KiB summary; read diagnostics, outcomes and requested captures through ads_results using its resultId.",
547
549
  schema: z.object({ unit: z.string().min(1).max(256), dryRun: z.boolean(), patch: z.string().min(1).max(mutationLimits.patchBytes).optional(), patchFile: z.string().min(1).max(500).optional(), ...screenshotFields }).strict().refine(args => (args.patch !== undefined) !== (args.patchFile !== undefined), "Provide exactly one of patch or patchFile."),
548
550
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false }, _meta: { ui: { visibility: ["model"] } },
549
551
  call: applyEdits,
550
- }, {name:"ads_apply_transaction",description:"Apply genuinely coupled ADS changes as 2–64 distinct owner Git patches. Each patch must obey its unit and narrow companion rules. Patches run in order; later patches use the earlier candidate's shared-entry content. Core guards, configured project checks, affected behavior checks and, when acceptance.browserAudit is true, the axe-core audit of affected UI scenarios validate the complete final candidate before any live source is written. Maximum 256 distinct files/16 MiB combined. Dry runs, failures and cancellation publish nothing; publication rolls back on write failure. Optional screenshot:true with dryRun:true and explicit captures selects current/candidate images. Prefer ads_apply_patch for independent edits. Reply is a bounded summary; page diagnostics, outcomes and captures with ads_results using the returned resultId.",schema:z.object({patches:z.array(ownerPatch).min(2).max(mutationLimits.units),dryRun:z.boolean(),...screenshotFields}).strict(),annotations:{readOnlyHint:false,destructiveHint:true,idempotentHint:false,openWorldHint:false},_meta:{ui:{visibility:["model"]}},call:applyEdits}] : []),
552
+ }, {name:"ads_apply_transaction",description:"Apply genuinely coupled ADS changes as 2–64 distinct owner Git patches. Each patch must obey its unit and narrow companion rules. Patches run in order; later patches use the earlier candidate's shared-entry content. Core guards, configured project checks, affected behavior checks and, unless acceptance.browserAudit is false, the axe-core audit of affected UI scenarios validate the complete final candidate before any live source is written. Maximum 256 distinct files/16 MiB combined. Dry runs, failures and cancellation publish nothing; publication rolls back on write failure. Optional screenshot:true with dryRun:true and explicit captures selects current/candidate images. Prefer ads_apply_patch for independent edits. Reply is a bounded summary; page diagnostics, outcomes and captures with ads_results using the returned resultId.",schema:z.object({patches:z.array(ownerPatch).min(2).max(mutationLimits.units),dryRun:z.boolean(),...screenshotFields}).strict(),annotations:{readOnlyHint:false,destructiveHint:true,idempotentHint:false,openWorldHint:false},_meta:{ui:{visibility:["model"]}},call:applyEdits}] : []),
551
553
  ...options.config.mcp.apps.map((app) => ({ name: `ads_show_${app.id.replaceAll("-", "_")}`, title: app.title, description: `${app.description ?? app.title}. Renders the project's built ${app.kind} examples through MCP Apps; text fallback provides the showcase URL.`, schema: empty, _meta: { ui: { resourceUri: appUri(app.id) } }, call: async (_args, signal) => {
552
554
  // Validate readiness without embedding executable HTML in model results.
553
555
  const build = await previewBuild(app, signal);
@@ -1,6 +1,7 @@
1
1
  import { readdirSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { isDraftFile } from "./draft-boundary.mjs";
4
+ import { createNestedProjectFilter } from "./project-boundary.mjs";
4
5
 
5
6
  const metadata = new Set(["node_modules", ".git", ".ds", ".vite", "coverage"]);
6
7
  const generated = new Set(["dist", "build", "target", "out", ".next", ".nuxt", ".svelte-kit", ".turbo"]);
@@ -14,8 +15,10 @@ export function createPreviewFileFilter({root, config}) {
14
15
  const within = (parent, file) => parent === ""
15
16
  ? file !== ".." && !file.startsWith(`..${path.sep}`) && !path.isAbsolute(file)
16
17
  : file === parent || file.startsWith(parent + path.sep);
18
+ const nested = createNestedProjectFilter({root, config});
17
19
  return file => {
18
20
  if (isDraftFile(file)) return true;
21
+ if (nested(file)) return true;
19
22
  const relative = path.relative(root, path.resolve(file)), parts = relative.split(path.sep);
20
23
  if (parts.some(name => metadata.has(name))) return true;
21
24
  const key = canonical(relative);
@@ -0,0 +1,23 @@
1
+ import { existsSync } from "node:fs";
2
+ import path from "node:path";
3
+
4
+ /** A folder with its own ds.config.json is a separate ADS project, whose tests, sources and
5
+ * previews belong to it. Every project-wide walk stops there. */
6
+ export const hasProjectConfig = directory => existsSync(path.join(directory, "ds.config.json"));
7
+
8
+ /** Whether a path is a nested project or inside one. The project's own root, design system and
9
+ * source folders never count, and neither does a folder on the way to them. */
10
+ export function createNestedProjectFilter({ root, config }) {
11
+ const own = [config.dsDir, config.sourceDir].map(directory => path.resolve(root, directory));
12
+ const onOwnPath = directory => own.some(target => target === directory || target.startsWith(directory + path.sep));
13
+ return file => {
14
+ const relative = path.relative(root, path.resolve(root, file));
15
+ if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return false;
16
+ let directory = root;
17
+ for (const part of relative.split(path.sep)) {
18
+ directory = path.join(directory, part);
19
+ if (!onOwnPath(directory) && hasProjectConfig(directory)) return true;
20
+ }
21
+ return false;
22
+ };
23
+ }
@@ -1,5 +1,6 @@
1
1
  import { existsSync, lstatSync, readdirSync } from "node:fs";
2
2
  import path from "node:path";
3
+ import { hasProjectConfig } from "./project-boundary.mjs";
3
4
 
4
5
  const rootNames = ["README.md", "ADS.md", "DS.md", "ARCHITECTURE.md", "Architecture.md", "GUIDE.md", "MCP.md", "CHANGELOG.md"];
5
6
  const noticeStem = /^(?:CREDITS|LICEN[CS]ES?|NOTICES?|COPYING|COPYRIGHT)(?:[-_][A-Za-z0-9][A-Za-z0-9._-]*)?$/i;
@@ -33,7 +34,7 @@ export function projectDocumentFiles(root) {
33
34
  for (const entry of readdirSync(directory, { withFileTypes: true })) {
34
35
  if (entry.name.startsWith(".")) continue;
35
36
  const file = `${relative}/${entry.name}`;
36
- if (entry.isDirectory()) walk(file);
37
+ if (entry.isDirectory()) { if (!hasProjectConfig(path.join(root, file))) walk(file); }
37
38
  else if (entry.isFile() && isProjectDocument(file)) files.push(file);
38
39
  }
39
40
  }
@@ -2,6 +2,7 @@ import { scopedPreviewFailure } from "./preview-failure.mjs";
2
2
  import { createHash, randomUUID } from "node:crypto";
3
3
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
4
4
  import path from "node:path";
5
+ import { hasProjectConfig } from "./project-boundary.mjs";
5
6
  import { isDraftPreviewWorkspace } from "./draft-workspace.mjs";
6
7
  import { loadConfig, isInside } from "./config.mjs";
7
8
  import { discoverScenarioRegistry, prepareScenarioRegistryTransfer, releaseScenarioRegistry } from "./scenario-registry.mjs";
@@ -185,6 +186,16 @@ export function preparePreviewCache(candidate, target) {
185
186
  };
186
187
  }
187
188
 
189
+ /** An accepted edit writes source before it can publish the graph it checked.
190
+ * The hold keeps a watching compiler from rebuilding that source in the gap.
191
+ * Its age bound lets a crashed process cost one delay, not a stuck preview. */
192
+ const publicationHold = root => path.join(root,".ds/preview-publication.hold"), publicationHoldMs = 15000;
193
+ export function holdLivePreview(root) {
194
+ const file=publicationHold(root);
195
+ mkdirSync(path.dirname(file),{recursive:true});writeFileSync(file,"");
196
+ return () => rmSync(file,{force:true});
197
+ }
198
+
188
199
  export function promotePreviewCache(candidate,target) { const publish=preparePreviewCache(candidate,target);return publish?publish():false; }
189
200
 
190
201
  /** Restore a complete verified graph without rediscovering semantic scenarios or
@@ -299,7 +310,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
299
310
  for (const item of readdirSync(directory, { withFileTypes: true })) {
300
311
  if (item.isSymbolicLink() || ["node_modules", ".ds", ".vite", "dist"].includes(item.name)) continue;
301
312
  const file = path.join(directory, item.name);
302
- if (item.isDirectory()) assets(file);
313
+ if (item.isDirectory()) { if (!hasProjectConfig(file)) assets(file); }
303
314
  else if (/\.(?:css|svg|png|jpe?g|webp|gif|woff2?|ttf|otf)$/.test(file)) dependencies.add(file);
304
315
  }
305
316
  }
@@ -342,7 +353,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
342
353
  for (const item of readdirSync(directory, { withFileTypes: true })) {
343
354
  if (item.isSymbolicLink() || ["node_modules", ".ds", ".vite", "dist"].includes(item.name)) continue;
344
355
  const file = path.join(directory, item.name);
345
- if (item.isDirectory()) assets(file);
356
+ if (item.isDirectory()) { if (!hasProjectConfig(file)) assets(file); }
346
357
  else if (/\.(?:css|svg|png|jpe?g|webp|gif|woff2?|ttf|otf)$/.test(file)) dependencies.add(file);
347
358
  }
348
359
  }
@@ -390,10 +401,19 @@ export async function runScenarioCompiler(directory, { watched = false, validate
390
401
  return false;
391
402
  }
392
403
  }
404
+ async function publicationSettled() {
405
+ const file=publicationHold(root);
406
+ while(!stopped){
407
+ try{if(Date.now()-statSync(file).mtimeMs>=publicationHoldMs)return;}catch{return;}
408
+ await new Promise(resolve=>setTimeout(resolve,10));
409
+ }
410
+ }
393
411
  // Visual feedback and verified publication have separate lifecycles. Edits
394
412
  // replace the pending candidate immediately; verification has at most one run
395
413
  // in flight and coalesces intervening edits instead of queuing every keystroke.
396
414
  async function compileLiveGraph() {
415
+ await publicationSettled();
416
+ if (stopped) return;
397
417
  cache.reload();
398
418
  const sourceRevision = previewSourceRevision(options), stamp = cache.inputs();
399
419
  const prepared=cache.registry(stamp);
@@ -426,7 +446,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
426
446
  for (const item of readdirSync(directory, { withFileTypes: true })) {
427
447
  if (item.isSymbolicLink() || ["node_modules", ".ds", ".vite", "dist"].includes(item.name)) continue;
428
448
  const file = path.join(directory, item.name);
429
- if (item.isDirectory()) assets(file);
449
+ if (item.isDirectory()) { if (!hasProjectConfig(file)) assets(file); }
430
450
  else if (/\.(?:css|svg|png|jpe?g|webp|gif|woff2?|ttf|otf)$/.test(file)) candidate.dependencies.add(file);
431
451
  }
432
452
  }