@reqvire-org/ads 0.3.25 → 0.3.27

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 (128) hide show
  1. package/README.md +28 -15
  2. package/dist/bootstrap-ds/ADS.md +28 -30
  3. package/dist/bootstrap-ds/README.md +13 -11
  4. package/dist/bootstrap-ds/design-system/assets/brand/README.md +3 -2
  5. package/dist/bootstrap-ds/ds.config.json +1 -1
  6. package/dist/bootstrap-ds/scripts/build-mcp-previews.mjs +1 -1
  7. package/dist/boundaries.mjs +0 -3
  8. package/dist/capture.mjs +1 -1
  9. package/dist/check.mjs +15 -22
  10. package/dist/config.mjs +3 -7
  11. package/dist/contract-migration.mjs +2 -2
  12. package/dist/contracts.d.mts +0 -1
  13. package/dist/design-values.mjs +81 -0
  14. package/dist/development-runtime.mjs +17 -0
  15. package/dist/evidence.mjs +1 -1
  16. package/dist/index.mjs +1 -1
  17. package/dist/init.mjs +14 -12
  18. package/dist/mcp/apps.mjs +1 -1
  19. package/dist/mcp/context.mjs +8 -7
  20. package/dist/mcp/mutations.mjs +3 -2
  21. package/dist/mcp/preview-watch.mjs +2 -1
  22. package/dist/mcp/prompts.mjs +4 -4
  23. package/dist/mcp/reports.mjs +101 -0
  24. package/dist/mcp/server.mjs +41 -3
  25. package/dist/mcp/widget.bundle.js +1 -1
  26. package/dist/paint-contracts.mjs +4 -5
  27. package/dist/preview-files.mjs +33 -0
  28. package/dist/preview-inputs.mjs +6 -5
  29. package/dist/preview-resources.mjs +1 -2
  30. package/dist/scenarios-compiler.mjs +7 -7
  31. package/dist/scenarios.mjs +14 -14
  32. package/dist/showcase/sandbox.bundle.js +1 -1
  33. package/dist/skills/README.md +14 -4
  34. package/dist/skills/ads-break-ui/SKILL.md +29 -15
  35. package/dist/skills/ads-break-ui/references/atomic-styles.md +9 -2
  36. package/dist/skills/ads-break-ui/references/behaviors.md +396 -0
  37. package/dist/skills/ads-break-ui/references/captures.md +1 -1
  38. package/dist/skills/ads-break-ui/references/contracts.md +18 -37
  39. package/dist/skills/ads-break-ui/references/design-data.md +91 -0
  40. package/dist/skills/ads-break-ui/references/evidence.md +4 -0
  41. package/dist/skills/ads-break-ui/references/guarded-editing.md +7 -11
  42. package/dist/skills/ads-break-ui/references/layers.md +16 -0
  43. package/dist/skills/ads-break-ui/references/reporting.md +101 -0
  44. package/dist/skills/ads-break-ui/references/runtimes.md +110 -0
  45. package/dist/skills/ads-break-ui/references/scenarios.md +9 -15
  46. package/dist/skills/ads-designer/README.md +6 -0
  47. package/dist/skills/ads-designer/SKILL.md +35 -20
  48. package/dist/skills/ads-designer/assets/bootstrap-ds/ADS.md +28 -30
  49. package/dist/skills/ads-designer/assets/bootstrap-ds/README.md +13 -11
  50. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/brand/README.md +3 -2
  51. package/dist/skills/ads-designer/assets/bootstrap-ds/ds.config.json +1 -1
  52. package/dist/skills/ads-designer/assets/bootstrap-ds/scripts/build-mcp-previews.mjs +1 -1
  53. package/dist/skills/ads-designer/references/atomic-styles.md +9 -2
  54. package/dist/skills/ads-designer/references/behaviors.md +396 -0
  55. package/dist/skills/ads-designer/references/captures.md +1 -1
  56. package/dist/skills/ads-designer/references/cli.md +10 -7
  57. package/dist/skills/ads-designer/references/contracts.md +18 -37
  58. package/dist/skills/ads-designer/references/design-craft.md +32 -1
  59. package/dist/skills/ads-designer/references/design-data.md +91 -0
  60. package/dist/skills/ads-designer/references/evidence.md +4 -0
  61. package/dist/skills/ads-designer/references/guarded-editing.md +7 -11
  62. package/dist/skills/ads-designer/references/layers.md +16 -0
  63. package/dist/skills/ads-designer/references/mobile.md +1 -1
  64. package/dist/skills/ads-designer/references/reporting.md +101 -0
  65. package/dist/skills/ads-designer/references/runtimes.md +110 -0
  66. package/dist/skills/ads-designer/references/scenarios.md +9 -15
  67. package/dist/skills/ads-import/SKILL.md +51 -20
  68. package/dist/skills/ads-import/agents/openai.yaml +2 -2
  69. package/dist/skills/ads-import/references/atomic-styles.md +9 -2
  70. package/dist/skills/ads-import/references/behaviors.md +396 -0
  71. package/dist/skills/ads-import/references/branding.md +1 -1
  72. package/dist/skills/ads-import/references/captures.md +1 -1
  73. package/dist/skills/ads-import/references/cli.md +10 -7
  74. package/dist/skills/ads-import/references/compatibility.md +113 -0
  75. package/dist/skills/ads-import/references/contracts.md +18 -37
  76. package/dist/skills/ads-import/references/design-data.md +91 -0
  77. package/dist/skills/ads-import/references/evidence.md +4 -0
  78. package/dist/skills/ads-import/references/guarded-editing.md +7 -11
  79. package/dist/skills/ads-import/references/implementation.md +9 -2
  80. package/dist/skills/ads-import/references/layers.md +16 -0
  81. package/dist/skills/ads-import/references/reporting.md +101 -0
  82. package/dist/skills/ads-import/references/runtimes.md +110 -0
  83. package/dist/skills/ads-import/references/scenarios.md +9 -15
  84. package/dist/skills/ads-import/references/tokens.md +11 -9
  85. package/dist/skills/ads-motion/SKILL.md +28 -14
  86. package/dist/skills/ads-motion/references/atomic-styles.md +9 -2
  87. package/dist/skills/ads-motion/references/behaviors.md +396 -0
  88. package/dist/skills/ads-motion/references/captures.md +1 -1
  89. package/dist/skills/ads-motion/references/contracts.md +18 -37
  90. package/dist/skills/ads-motion/references/design-data.md +91 -0
  91. package/dist/skills/ads-motion/references/evidence.md +4 -0
  92. package/dist/skills/ads-motion/references/guarded-editing.md +7 -11
  93. package/dist/skills/ads-motion/references/layers.md +16 -0
  94. package/dist/skills/ads-motion/references/reporting.md +101 -0
  95. package/dist/skills/ads-motion/references/runtimes.md +110 -0
  96. package/dist/skills/ads-motion/references/scenarios.md +9 -15
  97. package/dist/skills/{ads-migrate → ads-port}/SKILL.md +64 -33
  98. package/dist/skills/ads-port/agents/openai.yaml +4 -0
  99. package/dist/skills/{ads-migrate → ads-port}/references/atomic-styles.md +9 -2
  100. package/dist/skills/ads-port/references/behaviors.md +396 -0
  101. package/dist/skills/{ads-migrate → ads-port}/references/captures.md +1 -1
  102. package/dist/skills/{ads-migrate → ads-port}/references/cli.md +10 -7
  103. package/dist/skills/{ads-migrate → ads-port}/references/contracts.md +18 -37
  104. package/dist/skills/ads-port/references/design-data.md +91 -0
  105. package/dist/skills/{ads-migrate → ads-port}/references/evidence.md +4 -0
  106. package/dist/skills/{ads-migrate → ads-port}/references/guarded-editing.md +7 -11
  107. package/dist/skills/{ads-migrate → ads-port}/references/layers.md +16 -0
  108. package/dist/skills/{ads-migrate → ads-port}/references/lint-and-docs.md +5 -0
  109. package/dist/skills/{ads-migrate → ads-port}/references/native-implementation.md +49 -15
  110. package/dist/skills/ads-port/references/reporting.md +101 -0
  111. package/dist/skills/ads-port/references/runtimes.md +110 -0
  112. package/dist/skills/{ads-migrate → ads-port}/references/scenarios.md +9 -15
  113. package/dist/skills/{ads-migrate → ads-port}/references/testing.md +11 -1
  114. package/dist/tokens.mjs +5 -8
  115. package/dist/unit-contracts.mjs +1 -8
  116. package/dist/verification.mjs +4 -3
  117. package/docs/ADS.md +59 -73
  118. package/docs/ARCHITECTURE.md +68 -20
  119. package/docs/BEHAVIORS.md +46 -41
  120. package/docs/CHANGELOG.md +44 -1
  121. package/docs/COMPARISON.md +63 -0
  122. package/docs/CONTRACTS.md +18 -37
  123. package/docs/GUIDE.md +41 -23
  124. package/docs/MCP.md +100 -15
  125. package/package.json +5 -4
  126. package/dist/scoped-tokens.mjs +0 -68
  127. package/dist/skills/ads-migrate/agents/openai.yaml +0 -4
  128. /package/dist/skills/{ads-migrate → ads-port}/references/review.md +0 -0
@@ -138,7 +138,7 @@ Boolean requesting whether a visible border and background is provided by the ho
138
138
  - omitted: host decides border`)}),q_=i.object({method:i.literal("ui/request-display-mode"),params:i.object({mode:Sa.describe("The display mode being requested.")})}),N_=i.object({mode:Sa.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),wR=i.union([i.literal("model"),i.literal("app")]).describe("Tool visibility scope - who can access the tool."),KT=i.object({resourceUri:i.string().optional(),visibility:i.array(wR).optional().describe(`Who can access this tool. Default: ["model", "app"]
139
139
  - "model": Tool visible to and callable by the agent
140
140
  - "app": Tool callable by the app from this server only`),csp:i.never().optional(),permissions:i.never().optional()}),GT=i.object({mimeTypes:i.array(i.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),xR=i.object({method:i.literal("ui/download-file"),params:i.object({contents:i.array(i.union([ht,mt])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),TR=i.object({method:i.literal("ui/message"),params:i.object({role:i.literal("user").describe('Message role, currently only "user" is supported.'),content:i.array(Ee).describe("Message content blocks (text, image, etc.).")})}),YT=i.object({method:i.literal("ui/notifications/sandbox-resource-ready"),params:i.object({html:i.string().describe("HTML content to load into the inner iframe."),sandbox:i.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Ef.optional().describe("CSP configuration from resource metadata."),permissions:kf.optional().describe("Sandbox permissions from resource metadata.")})}),QT=i.object({method:i.literal("ui/notifications/tool-result"),params:Ye.describe("Standard MCP tool execution result.")}),j_=i.object({toolInfo:i.object({id:Te.optional().describe("JSON-RPC id of the tools/call request."),tool:Ge.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:cR.optional().describe("Current color theme preference."),styles:_R.optional().describe("Style configuration for theming the app."),displayMode:Sa.optional().describe("How the UI is currently displayed."),availableDisplayModes:i.array(Sa).optional().describe("Display modes the host supports."),containerDimensions:i.union([i.object({height:i.number().describe("Fixed container height in pixels.")}),i.object({maxHeight:i.union([i.number(),i.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(i.union([i.object({width:i.number().describe("Fixed container width in pixels.")}),i.object({maxWidth:i.union([i.number(),i.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
141
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:i.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:i.string().optional().describe("User's timezone in IANA format."),userAgent:i.string().optional().describe("Host application identifier."),platform:i.union([i.literal("web"),i.literal("desktop"),i.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:i.object({touch:i.boolean().optional().describe("Whether the device supports touch input."),hover:i.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:i.object({top:i.number().describe("Top safe area inset in pixels."),right:i.number().describe("Right safe area inset in pixels."),bottom:i.number().describe("Bottom safe area inset in pixels."),left:i.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),XT=i.object({method:i.literal("ui/notifications/host-context-changed"),params:j_.describe("Partial context update containing only changed fields.")}),PR=i.object({method:i.literal("ui/update-model-context"),params:i.object({content:i.array(Ee).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:i.record(i.string(),i.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),ER=i.object({method:i.literal("ui/initialize"),params:i.object({appInfo:Pe.describe("App identification (name and version)."),appCapabilities:zR.describe("Features and capabilities this app provides."),protocolVersion:i.string().describe("Protocol version this app supports.")})}),kR=i.object({protocolVersion:i.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Pe.describe("Host application identification and version."),hostCapabilities:vR.describe("Features and capabilities provided by the host."),hostContext:j_.describe("Rich context about the host environment.")}).passthrough();var Ql=class{eventTarget;eventSource;messageListener;constructor(t=window.parent,o){this.eventTarget=t,this.eventSource=o,this.messageListener=r=>{if(o&&r.source!==this.eventSource){console.debug("Ignoring message from unknown source",r);return}let n=ct.safeParse(r.data);n.success?(console.debug("Parsed message",n.data),this.onmessage?.(n.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",n.error.message,r):(console.error("Failed to parse message",n.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+n.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,o){t.method!==aR&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion};var $R=[A_],Xl=class extends ma{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new Tf;_methods=new Pf;setRequestHandler=(...t)=>{let[o,...r]=O_("request",t)??t;this._methods.claim(o,"setRequestHandler"),super.setRequestHandler.call(this,o,...r)};setNotificationHandler=(...t)=>{let[o,...r]=O_("notification",t)??t;this._methods.claim(o,"setNotificationHandler"),super.setNotificationHandler.call(this,o,...r)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...o)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...o)};_wrapHandler(t,o){let r=super._wrapHandler(t,o);return t==="ui/initialize"||t==="ping"?r:async(n,s)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${t}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),r(n,s))}eventSchemas={sizechange:gR,sandboxready:fR,initialized:RR,requestteardown:yR,loggingmessage:bo};setEventHandler(t,o){this._ensureEventSlot(t),this._events.setHandler(t,o)}getEventHandler(t){return this._events.getHandler(t)}addEventListener(t,o){this._ensureEventSlot(t),this._events.addEventListener(t,o)}removeEventListener(t,o){this._events.removeEventListener(t,o)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let o=this.eventSchemas[t];if(!o)throw Error(`Unknown event: ${String(t)}`);let r=n=>{t==="initialized"&&(this._initializedReceived=!0),this._events.dispatch(t,n)};t==="loggingmessage"?this.setNotificationHandler("notifications/message",n=>{r(n.params)}):this.setNotificationHandler(o.shape.method.value,{params:o.shape.params},n=>r(n)),this._registeredEvents.add(t)}warnIfRequestHandlerReplaced(t,o,r){o&&r&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,o,r,n){super(n),this._client=t,this._hostInfo=o,this._hostCapabilities=r,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),this._ensureEventSlot("initialized"),this._hostContext=n?.hostContext||{},this.replaceRequestHandler("ui/initialize",{params:ER.shape.params,result:kR},s=>this._onAppsInitialize(s)),this.replaceRequestHandler("ping",(s,a)=>(this.onping?.(s.params,a),{})),this.replaceRequestHandler("ui/request-display-mode",{params:q_.shape.params,result:N_},()=>({mode:this._hostContext.displayMode??"inline"}))}buildContext(t){return t}assertCapabilityForMethod(t){}assertRequestHandlerCapability(t){}assertNotificationCapability(t){}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(t){this.setEventHandler("sizechange",t)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(t){this.setEventHandler("sandboxready",t)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(t){this.setEventHandler("initialized",t)}_onmessage;get onmessage(){return this._onmessage}set onmessage(t){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,t),this._onmessage=t,this.replaceRequestHandler("ui/message",{params:TR.shape.params,result:mR},async(o,r)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(o,r)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(t){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,t),this._onopenlink=t,this.replaceRequestHandler("ui/open-link",{params:dR.shape.params,result:pR},async(o,r)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(o,r)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(t){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,t),this._ondownloadfile=t,this.replaceRequestHandler("ui/download-file",{params:xR.shape.params,result:hR},async(o,r)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(o,r)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(t){this.setEventHandler("requestteardown",t)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(t){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,t),this._onrequestdisplaymode=t,this.replaceRequestHandler("ui/request-display-mode",{params:q_.shape.params,result:N_},async(o,r)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(o,r)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(t){this.setEventHandler("loggingmessage",t)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(t){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,t),this._onupdatemodelcontext=t,this.replaceRequestHandler("ui/update-model-context",{params:PR.shape.params,result:We},async(o,r)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(o,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",async(o,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(o.params,r)})}_oncreatesamplingmessage;get oncreatesamplingmessage(){return this._oncreatesamplingmessage}set oncreatesamplingmessage(t){this.warnIfRequestHandlerReplaced("oncreatesamplingmessage",this._oncreatesamplingmessage,t),this._oncreatesamplingmessage=t,this.replaceRequestHandler("sampling/createMessage",async(o,r)=>{if(!this._oncreatesamplingmessage)throw Error("No oncreatesamplingmessage handler set");return this._oncreatesamplingmessage(o.params,r)})}sendToolListChanged(t={}){return this.notification({method:"notifications/tools/list_changed",params:t})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(t){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,t),this._onlistresources=t,this.replaceRequestHandler("resources/list",async(o,r)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(o.params,r)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(t){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,t),this._onlistresourcetemplates=t,this.replaceRequestHandler("resources/templates/list",async(o,r)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(o.params,r)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(t){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,t),this._onreadresource=t,this.replaceRequestHandler("resources/read",async(o,r)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(o.params,r)})}sendResourceListChanged(t={}){return this.notification({method:"notifications/resources/list_changed",params:t})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(t){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,t),this._onlistprompts=t,this.replaceRequestHandler("prompts/list",async(o,r)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(o.params,r)})}sendPromptListChanged(t={}){return this.notification({method:"notifications/prompts/list_changed",params:t})}getCapabilities(){return this._hostCapabilities}async _onAppsInitialize(t){let o=t.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=t.appCapabilities,this._appInfo=t.appInfo,{protocolVersion:$R.includes(o)?o:A_,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(t){let o={},r=!1;for(let n of Object.keys(t)){let s=this._hostContext[n],a=t[n];CR(s,a)||(o[n]=a,r=!0)}r&&(this._hostContext=t,this.sendHostContextChange(o))}sendHostContextChange(t){return this.notification({method:"ui/notifications/host-context-changed",params:t})}sendToolInput(t){return this.notification({method:"ui/notifications/tool-input",params:t})}sendToolInputPartial(t){return this.notification({method:"ui/notifications/tool-input-partial",params:t})}sendToolResult(t){return this.notification({method:"ui/notifications/tool-result",params:t})}sendToolCancelled(t){return this.notification({method:"ui/notifications/tool-cancelled",params:t})}sendSandboxResourceReady(t){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:t})}teardownResource(t,o){return this.request({method:"ui/resource-teardown",params:t},bR,o)}sendResourceTeardown=this.teardownResource;callTool(t,o){return this.request({method:"tools/call",params:t},o)}listTools(t,o){return this.request({method:"tools/list",params:t},o)}async connect(t){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let o=this._client.getServerCapabilities();if(!o)throw Error("Client server capabilities not available");o.tools&&(this.oncalltool=async(r,n)=>this._client.request({method:"tools/call",params:r},{signal:n.mcpReq.signal}),o.tools.listChanged&&this._client.setNotificationHandler("notifications/tools/list_changed",r=>this.sendToolListChanged(r.params))),o.resources&&(this.onlistresources=async(r,n)=>this._client.request({method:"resources/list",params:r},{signal:n.mcpReq.signal}),this.onlistresourcetemplates=async(r,n)=>this._client.request({method:"resources/templates/list",params:r},{signal:n.mcpReq.signal}),this.onreadresource=async(r,n)=>this._client.request({method:"resources/read",params:r},{signal:n.mcpReq.signal}),o.resources.listChanged&&this._client.setNotificationHandler("notifications/resources/list_changed",r=>this.sendResourceListChanged(r.params))),o.prompts&&(this.onlistprompts=async(r,n)=>this._client.request({method:"prompts/list",params:r},{signal:n.mcpReq.signal}),o.prompts.listChanged&&this._client.setNotificationHandler("notifications/prompts/list_changed",r=>this.sendPromptListChanged(r.params)))}return super.connect(t)}};function CR(e,t){return JSON.stringify(e)===JSON.stringify(t)}function L_(e,t){let o=new DOMParser().parseFromString(e,"text/html"),r=o.createElement("meta");if(r.httpEquiv="Content-Security-Policy",r.content=t,o.head.prepend(r),!o.querySelector("base[href]")){let n=o.querySelector("base")??o.createElement("base");n.setAttribute("href","about:srcdoc"),r.after(n)}return"<!doctype html>"+o.documentElement.outerHTML}var $e=new Yl({name:"ADS preview",version:"1.0.0"},{},{autoResize:!0}),Wr=document.getElementById("ads-token-root"),Lt=document.getElementById("ads-widget-status"),tu=document.getElementById("ads-token-theme"),eu=document.getElementById("ads-scenario-root"),To,Me=0,U_="",Br=30,Z_=document.createElement("style");Wr&&document.head.append(Z_);function ou(e){e!=="light"&&e!=="dark"||(document.documentElement.dataset.theme=e,tu&&(tu.value=e),Wr&&To&&wo())}function Oe(e,t){let o=document.createElement(e);return o.textContent=t,o}function IR(e){let t=Oe("li","");t.dataset.token=e.name;let o=getComputedStyle(document.documentElement).getPropertyValue(e.name).trim(),r=Oe("details","");r.className="token-source";let n=Oe("summary","");n.title=`${e.name}: ${o||"Conditional or unset"}. Click to inspect source definitions.`;let s=Oe("code",e.name);s.className="token-name";let a=Oe("span",o||"Conditional or unset");n.append(s,a);let l=Oe("dl","");l.append(Oe("dt","Computed in preview"),Oe("dd",o||"Conditional or unset")),e.meaning&&l.append(Oe("dt","Meaning"),Oe("dd",e.meaning));for(let u of e.definitions)l.append(Oe("dt",u.scope),Oe("dd",`${u.value} \xB7 ${u.file}:${u.line}`));return r.append(n,l),t.append(r),t}function wo(){Z_.textContent=To.css;let e=To.tokens.filter(t=>`${t.name} ${t.type??""}`.toLowerCase().includes(U_.toLowerCase()));document.getElementById("ads-token-list").replaceChildren(...e.slice(Me,Me+Br).map(IR)),document.querySelector("footer").hidden=e.length<=Br,document.getElementById("ads-token-count").textContent=e.length?`${Me+1}\u2013${Math.min(Me+Br,e.length)} of ${e.length}`:"No matching tokens",document.getElementById("ads-token-prev").disabled=Me===0,document.getElementById("ads-token-next").disabled=Me+Br>=e.length,Lt.textContent=`${e.length} matching definitions \xB7 ${To.diagnostics.length} diagnostics`}Wr&&($e.ontoolinput=()=>{Me=0,To&&wo()},To=JSON.parse(document.getElementById("ads-token-seed").textContent),ou("light"),document.getElementById("ads-token-search").addEventListener("input",e=>{U_=e.target.value,Me=0,wo()}),tu.addEventListener("change",()=>ou(tu.value)),document.getElementById("ads-token-prev").addEventListener("click",()=>{Me=Math.max(0,Me-Br),wo()}),document.getElementById("ads-token-next").addEventListener("click",()=>{Me+=Br,wo()}),document.getElementById("ads-token-refresh").addEventListener("click",async()=>{try{let e=await $e.readServerResource({uri:"ads://project/tokens"});To=JSON.parse(e.contents.find(t=>"text"in t).text),Me=0,wo()}catch(e){Lt.textContent=`Refresh failed: ${e.message}`}}));var xo,$f,D_=!1,_a=0;async function H_(e){if($f=e,!D_||!eu)return;let t=e?.structuredContent?.scenario?.resourceUri;if(!t||!t.startsWith("ui://ads/previews/"))return;let o=++_a;Wr&&(Wr.hidden=!0,Lt=document.getElementById("ads-scenario-status")),eu.hidden=!1;try{if(!$e.getHostCapabilities()?.serverResources)throw new Error("This Apps host does not forward server resources. Use the project showcase URL from the tool result.");let n=(await $e.readServerResource({uri:t})).contents.find(u=>u.mimeType==="text/html;profile=mcp-app"&&typeof u.text=="string");if(!n)throw new Error("Scenario HTML is unavailable.");if(o!==_a)return;xo&&(await xo.close(),xo=void 0);let s=document.createElement("iframe");s.title=e.structuredContent.scenario.title,s.setAttribute("sandbox","allow-scripts allow-forms"),eu.replaceChildren(s);let a=new Xl(null,{name:"ADS scenario host",version:"1.0.0"},{serverResources:{},serverTools:{}},{hostContext:$e.getHostContext()});xo=a,a.onreadresource=u=>$e.readServerResource(u),a.oncalltool=u=>$e.callServerTool(u),a.onsizechange=({height:u})=>{u&&(s.height=String(Math.min(1e4,Math.max(120,u))))},a.oninitialized=async()=>{await a.sendToolInput({arguments:{}}),await a.sendToolResult(e),o===_a&&window.parent.postMessage({type:"ads-preview-ready"},"*")},await a.connect(new Ql(s.contentWindow,s.contentWindow));let l="default-src 'none'; script-src 'unsafe-inline' blob:; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; worker-src blob: data:; connect-src 'none'; base-uri about:; object-src 'none'; form-action 'none'";s.srcdoc=L_(n.text,l),Lt.hidden=!0}catch(r){o===_a&&(Lt.hidden=!1,Lt.textContent=r.message,window.parent.postMessage({type:"ads-preview-ready"},"*"))}}eu&&($e.ontoolresult=e=>{H_(e)},$e.onteardown=async()=>{++_a;let e=xo;xo=void 0;try{await e?.teardownResource({},{timeout:500})}catch{}return await e?.close(),{}});$e.onhostcontextchanged=e=>{ou(e.theme),xo?.setHostContext(e)};try{await $e.connect(),D_=!0,$f&&H_($f),ou($e.getHostContext()?.theme),Wr&&(document.getElementById("ads-token-refresh").disabled=!$e.getHostCapabilities()?.serverResources,wo())}catch{Lt&&(Lt.textContent="Apps bridge unavailable. Samples remain usable; inspect project data through ADS tools/resources.")}
141
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:i.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:i.string().optional().describe("User's timezone in IANA format."),userAgent:i.string().optional().describe("Host application identifier."),platform:i.union([i.literal("web"),i.literal("desktop"),i.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:i.object({touch:i.boolean().optional().describe("Whether the device supports touch input."),hover:i.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:i.object({top:i.number().describe("Top safe area inset in pixels."),right:i.number().describe("Right safe area inset in pixels."),bottom:i.number().describe("Bottom safe area inset in pixels."),left:i.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),XT=i.object({method:i.literal("ui/notifications/host-context-changed"),params:j_.describe("Partial context update containing only changed fields.")}),PR=i.object({method:i.literal("ui/update-model-context"),params:i.object({content:i.array(Ee).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:i.record(i.string(),i.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),ER=i.object({method:i.literal("ui/initialize"),params:i.object({appInfo:Pe.describe("App identification (name and version)."),appCapabilities:zR.describe("Features and capabilities this app provides."),protocolVersion:i.string().describe("Protocol version this app supports.")})}),kR=i.object({protocolVersion:i.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Pe.describe("Host application identification and version."),hostCapabilities:vR.describe("Features and capabilities provided by the host."),hostContext:j_.describe("Rich context about the host environment.")}).passthrough();var Ql=class{eventTarget;eventSource;messageListener;constructor(t=window.parent,o){this.eventTarget=t,this.eventSource=o,this.messageListener=r=>{if(o&&r.source!==this.eventSource){console.debug("Ignoring message from unknown source",r);return}let n=ct.safeParse(r.data);n.success?(console.debug("Parsed message",n.data),this.onmessage?.(n.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",n.error.message,r):(console.error("Failed to parse message",n.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+n.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,o){t.method!==aR&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion};var $R=[A_],Xl=class extends ma{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new Tf;_methods=new Pf;setRequestHandler=(...t)=>{let[o,...r]=O_("request",t)??t;this._methods.claim(o,"setRequestHandler"),super.setRequestHandler.call(this,o,...r)};setNotificationHandler=(...t)=>{let[o,...r]=O_("notification",t)??t;this._methods.claim(o,"setNotificationHandler"),super.setNotificationHandler.call(this,o,...r)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...o)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...o)};_wrapHandler(t,o){let r=super._wrapHandler(t,o);return t==="ui/initialize"||t==="ping"?r:async(n,s)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${t}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),r(n,s))}eventSchemas={sizechange:gR,sandboxready:fR,initialized:RR,requestteardown:yR,loggingmessage:bo};setEventHandler(t,o){this._ensureEventSlot(t),this._events.setHandler(t,o)}getEventHandler(t){return this._events.getHandler(t)}addEventListener(t,o){this._ensureEventSlot(t),this._events.addEventListener(t,o)}removeEventListener(t,o){this._events.removeEventListener(t,o)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let o=this.eventSchemas[t];if(!o)throw Error(`Unknown event: ${String(t)}`);let r=n=>{t==="initialized"&&(this._initializedReceived=!0),this._events.dispatch(t,n)};t==="loggingmessage"?this.setNotificationHandler("notifications/message",n=>{r(n.params)}):this.setNotificationHandler(o.shape.method.value,{params:o.shape.params},n=>r(n)),this._registeredEvents.add(t)}warnIfRequestHandlerReplaced(t,o,r){o&&r&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,o,r,n){super(n),this._client=t,this._hostInfo=o,this._hostCapabilities=r,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),this._ensureEventSlot("initialized"),this._hostContext=n?.hostContext||{},this.replaceRequestHandler("ui/initialize",{params:ER.shape.params,result:kR},s=>this._onAppsInitialize(s)),this.replaceRequestHandler("ping",(s,a)=>(this.onping?.(s.params,a),{})),this.replaceRequestHandler("ui/request-display-mode",{params:q_.shape.params,result:N_},()=>({mode:this._hostContext.displayMode??"inline"}))}buildContext(t){return t}assertCapabilityForMethod(t){}assertRequestHandlerCapability(t){}assertNotificationCapability(t){}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(t){this.setEventHandler("sizechange",t)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(t){this.setEventHandler("sandboxready",t)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(t){this.setEventHandler("initialized",t)}_onmessage;get onmessage(){return this._onmessage}set onmessage(t){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,t),this._onmessage=t,this.replaceRequestHandler("ui/message",{params:TR.shape.params,result:mR},async(o,r)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(o,r)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(t){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,t),this._onopenlink=t,this.replaceRequestHandler("ui/open-link",{params:dR.shape.params,result:pR},async(o,r)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(o,r)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(t){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,t),this._ondownloadfile=t,this.replaceRequestHandler("ui/download-file",{params:xR.shape.params,result:hR},async(o,r)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(o,r)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(t){this.setEventHandler("requestteardown",t)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(t){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,t),this._onrequestdisplaymode=t,this.replaceRequestHandler("ui/request-display-mode",{params:q_.shape.params,result:N_},async(o,r)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(o,r)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(t){this.setEventHandler("loggingmessage",t)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(t){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,t),this._onupdatemodelcontext=t,this.replaceRequestHandler("ui/update-model-context",{params:PR.shape.params,result:We},async(o,r)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(o,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",async(o,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(o.params,r)})}_oncreatesamplingmessage;get oncreatesamplingmessage(){return this._oncreatesamplingmessage}set oncreatesamplingmessage(t){this.warnIfRequestHandlerReplaced("oncreatesamplingmessage",this._oncreatesamplingmessage,t),this._oncreatesamplingmessage=t,this.replaceRequestHandler("sampling/createMessage",async(o,r)=>{if(!this._oncreatesamplingmessage)throw Error("No oncreatesamplingmessage handler set");return this._oncreatesamplingmessage(o.params,r)})}sendToolListChanged(t={}){return this.notification({method:"notifications/tools/list_changed",params:t})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(t){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,t),this._onlistresources=t,this.replaceRequestHandler("resources/list",async(o,r)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(o.params,r)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(t){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,t),this._onlistresourcetemplates=t,this.replaceRequestHandler("resources/templates/list",async(o,r)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(o.params,r)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(t){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,t),this._onreadresource=t,this.replaceRequestHandler("resources/read",async(o,r)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(o.params,r)})}sendResourceListChanged(t={}){return this.notification({method:"notifications/resources/list_changed",params:t})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(t){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,t),this._onlistprompts=t,this.replaceRequestHandler("prompts/list",async(o,r)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(o.params,r)})}sendPromptListChanged(t={}){return this.notification({method:"notifications/prompts/list_changed",params:t})}getCapabilities(){return this._hostCapabilities}async _onAppsInitialize(t){let o=t.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=t.appCapabilities,this._appInfo=t.appInfo,{protocolVersion:$R.includes(o)?o:A_,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(t){let o={},r=!1;for(let n of Object.keys(t)){let s=this._hostContext[n],a=t[n];CR(s,a)||(o[n]=a,r=!0)}r&&(this._hostContext=t,this.sendHostContextChange(o))}sendHostContextChange(t){return this.notification({method:"ui/notifications/host-context-changed",params:t})}sendToolInput(t){return this.notification({method:"ui/notifications/tool-input",params:t})}sendToolInputPartial(t){return this.notification({method:"ui/notifications/tool-input-partial",params:t})}sendToolResult(t){return this.notification({method:"ui/notifications/tool-result",params:t})}sendToolCancelled(t){return this.notification({method:"ui/notifications/tool-cancelled",params:t})}sendSandboxResourceReady(t){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:t})}teardownResource(t,o){return this.request({method:"ui/resource-teardown",params:t},bR,o)}sendResourceTeardown=this.teardownResource;callTool(t,o){return this.request({method:"tools/call",params:t},o)}listTools(t,o){return this.request({method:"tools/list",params:t},o)}async connect(t){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let o=this._client.getServerCapabilities();if(!o)throw Error("Client server capabilities not available");o.tools&&(this.oncalltool=async(r,n)=>this._client.request({method:"tools/call",params:r},{signal:n.mcpReq.signal}),o.tools.listChanged&&this._client.setNotificationHandler("notifications/tools/list_changed",r=>this.sendToolListChanged(r.params))),o.resources&&(this.onlistresources=async(r,n)=>this._client.request({method:"resources/list",params:r},{signal:n.mcpReq.signal}),this.onlistresourcetemplates=async(r,n)=>this._client.request({method:"resources/templates/list",params:r},{signal:n.mcpReq.signal}),this.onreadresource=async(r,n)=>this._client.request({method:"resources/read",params:r},{signal:n.mcpReq.signal}),o.resources.listChanged&&this._client.setNotificationHandler("notifications/resources/list_changed",r=>this.sendResourceListChanged(r.params))),o.prompts&&(this.onlistprompts=async(r,n)=>this._client.request({method:"prompts/list",params:r},{signal:n.mcpReq.signal}),o.prompts.listChanged&&this._client.setNotificationHandler("notifications/prompts/list_changed",r=>this.sendPromptListChanged(r.params)))}return super.connect(t)}};function CR(e,t){return JSON.stringify(e)===JSON.stringify(t)}function L_(e,t){let o=new DOMParser().parseFromString(e,"text/html"),r=o.createElement("meta");if(r.httpEquiv="Content-Security-Policy",r.content=t,o.head.prepend(r),!o.querySelector("base[href]")){let n=o.querySelector("base")??o.createElement("base");n.setAttribute("href","about:srcdoc"),r.after(n)}return"<!doctype html>"+o.documentElement.outerHTML}var $e=new Yl({name:"ADS preview",version:"1.0.0"},{},{autoResize:!0}),Wr=document.getElementById("ads-token-root"),Lt=document.getElementById("ads-widget-status"),tu=document.getElementById("ads-token-theme"),eu=document.getElementById("ads-scenario-root"),To,Me=0,U_="",Br=30,Z_=document.createElement("style");Wr&&document.head.append(Z_);function ou(e){e!=="light"&&e!=="dark"||(document.documentElement.dataset.theme=e,tu&&(tu.value=e),Wr&&To&&wo())}function Oe(e,t){let o=document.createElement(e);return o.textContent=t,o}function IR(e){let t=Oe("li","");t.dataset.token=e.name;let o=getComputedStyle(document.documentElement).getPropertyValue(e.name).trim(),r=Oe("details","");r.className="token-source";let n=Oe("summary","");n.title=`${e.name}: ${o||"Conditional or unset"}. Click to inspect source definitions.`;let s=Oe("code",e.name);s.className="token-name";let a=Oe("span",o||"Conditional or unset");n.append(s,a);let l=Oe("dl","");l.append(Oe("dt","Computed in preview"),Oe("dd",o||"Conditional or unset")),e.meaning&&l.append(Oe("dt","Meaning"),Oe("dd",e.meaning));for(let u of e.definitions)l.append(Oe("dt",u.scope),Oe("dd",`${u.value} \xB7 ${u.file}:${u.line}`));return r.append(n,l),t.append(r),t}function wo(){Z_.textContent=To.css;let e=To.tokens.filter(t=>`${t.name} ${t.type??""}`.toLowerCase().includes(U_.toLowerCase()));document.getElementById("ads-token-list").replaceChildren(...e.slice(Me,Me+Br).map(IR)),document.querySelector("footer").hidden=e.length<=Br,document.getElementById("ads-token-count").textContent=e.length?`${Me+1}\u2013${Math.min(Me+Br,e.length)} of ${e.length}`:"No matching tokens",document.getElementById("ads-token-prev").disabled=Me===0,document.getElementById("ads-token-next").disabled=Me+Br>=e.length,Lt.textContent=`${e.length} matching definitions \xB7 ${To.diagnostics.length} diagnostics`}Wr&&($e.ontoolinput=()=>{Me=0,To&&wo()},To=JSON.parse(document.getElementById("ads-token-seed").textContent),ou("light"),document.getElementById("ads-token-search").addEventListener("input",e=>{U_=e.target.value,Me=0,wo()}),tu.addEventListener("change",()=>ou(tu.value)),document.getElementById("ads-token-prev").addEventListener("click",()=>{Me=Math.max(0,Me-Br),wo()}),document.getElementById("ads-token-next").addEventListener("click",()=>{Me+=Br,wo()}),document.getElementById("ads-token-refresh").addEventListener("click",async()=>{try{let e=await $e.readServerResource({uri:"ads://project/tokens"});To=JSON.parse(e.contents.find(t=>"text"in t).text),Me=0,wo()}catch(e){Lt.textContent=`Refresh failed: ${e.message}`}}));var xo,$f,D_=!1,_a=0;async function H_(e){if($f=e,!D_||!eu)return;let t=e?.structuredContent?.scenario?.resourceUri;if(!t||!t.startsWith("ui://ads/previews/"))return;let o=++_a;Wr&&(Wr.hidden=!0,Lt=document.getElementById("ads-scenario-status")),eu.hidden=!1;try{if(!$e.getHostCapabilities()?.serverResources)throw new Error("This Apps host does not forward server resources. Use the project showcase URL from the tool result.");let n=(await $e.readServerResource({uri:t})).contents.find(u=>u.mimeType==="text/html;profile=mcp-app"&&typeof u.text=="string");if(!n)throw new Error("Scenario HTML is unavailable.");if(o!==_a)return;xo&&(await xo.close(),xo=void 0);let s=document.createElement("iframe");s.title=e.structuredContent.scenario.title,s.setAttribute("sandbox","allow-scripts allow-forms"),eu.replaceChildren(s);let a=new Xl(null,{name:"ADS scenario host",version:"1.0.0"},{serverResources:{},serverTools:{}},{hostContext:$e.getHostContext()});xo=a,a.onreadresource=u=>$e.readServerResource(u),a.oncalltool=u=>$e.callServerTool(u),a.onsizechange=({height:u})=>{u&&(s.height=String(Math.min(1e4,Math.max(120,u))))},a.oninitialized=async()=>{await a.sendToolInput({arguments:{}}),await a.sendToolResult(e),o===_a&&window.parent.postMessage({type:"ads-preview-ready"},"*")},await a.connect(new Ql(s.contentWindow,s.contentWindow));let l="default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob:; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; worker-src blob: data:; connect-src blob:; base-uri about:; object-src 'none'; form-action 'none'";s.srcdoc=L_(n.text,l),Lt.hidden=!0}catch(r){o===_a&&(Lt.hidden=!1,Lt.textContent=r.message,window.parent.postMessage({type:"ads-preview-ready"},"*"))}}eu&&($e.ontoolresult=e=>{H_(e)},$e.onteardown=async()=>{++_a;let e=xo;xo=void 0;try{await e?.teardownResource({},{timeout:500})}catch{}return await e?.close(),{}});$e.onhostcontextchanged=e=>{ou(e.theme),xo?.setHostContext(e)};try{await $e.connect(),D_=!0,$f&&H_($f),ou($e.getHostContext()?.theme),Wr&&(document.getElementById("ads-token-refresh").disabled=!$e.getHostCapabilities()?.serverResources,wo())}catch{Lt&&(Lt.textContent="Apps bridge unavailable. Samples remain usable; inspect project data through ADS tools/resources.")}
142
142
  /*! Bundled license information:
143
143
 
144
144
  @modelcontextprotocol/client/dist/src-WCy6ifGf.mjs:
@@ -1,6 +1,7 @@
1
1
  import path from "node:path";
2
2
  import ts from "typescript";
3
3
  import valueParser from "postcss-value-parser";
4
+ import { isSharedToken } from "./token-policy.mjs";
4
5
  import { isContractFile, isInside } from "./config.mjs";
5
6
  import { inspectUnitContracts, implementationIdentity, runtimeBindingOwner } from "./unit-contracts.mjs";
6
7
  import { createSourceValues, reference } from "./source-values.mjs";
@@ -61,8 +62,7 @@ export function inspectPaintContracts(options) {
61
62
  const paintProp=/^(?:background(?:Color)?|color|fill|stroke|stopColor|stop-color|floodColor|flood-color|(?:\w+)?ColorToken)$/i;
62
63
 
63
64
  /** Check resolved values at the consuming source, so exports cannot launder privacy. */
64
- export function inspectTokenValueFlows(program, options, inventory, scoped, report) {
65
- if(!scoped.definitions.length && !inspectUnitContracts(options).contracts.some(contract=>contract.paintInputs?.length))return;
65
+ export function inspectTokenValueFlows(program, options, inventory, units, report) {
66
66
  const values=createSourceValues(program,options), checker=program.getTypeChecker();
67
67
  const declarations=inspectUnitContracts(options).contracts;
68
68
  function strings(input, context=values.state()) {
@@ -82,14 +82,13 @@ export function inspectTokenValueFlows(program, options, inventory, scoped, repo
82
82
  }
83
83
  for(const source of program.getSourceFiles()) {
84
84
  if(!isInside(options.root,source.fileName)||source.fileName.includes(`${path.sep}node_modules${path.sep}`)||isContractFile(source.fileName))continue;
85
- const owner=scoped.inventory.owner(scoped.inventory.relative(path.relative(options.root,source.fileName)));
85
+ const owner=units.owner(units.relative(path.relative(options.root,source.fileName)));
86
86
  const emitted=new Set();
87
87
  function check(node,text,bare=false,requirePaint=false,allowedBindings=null) {
88
88
  const names=bare&&/^--[\w-]+$/.test(text)?[text]:valueParser(text).nodes.flatMap(function walk(value){return value.type==="function"&&value.value==="var"?[value.nodes.find(item=>item.type==="word")?.value]:value.nodes?value.nodes.flatMap(walk):[];}).filter(Boolean);
89
89
  for(const name of names) {
90
- const tokenOwner=scoped.definitions.find(entry=>name.startsWith(entry.namespace));
91
90
  const binding=runtimeBindingOwner(options,name);
92
- const issue=tokenOwner&&tokenOwner.unit!==owner?`${name} is private to ${tokenOwner.unit}; ${owner??"application source"} cannot consume it through props, aliases or helpers. Promote a cross-owner design value to shared tokens.`:binding&&(binding.unit!==owner||allowedBindings&&!allowedBindings.includes(binding.id))?`${name} is an instance binding private to ${binding.unit} and is not permitted by this consuming paint input.`:requirePaint&&!inventory.tokens.some(token=>token.name===name)&&!binding?`Undefined paint reference ${name}. Declare a real accessible token or a scoped runtime binding.`:null;
91
+ const issue=binding&&(binding.unit!==owner||allowedBindings&&!allowedBindings.includes(binding.id))?`${name} is an instance binding private to ${binding.unit} and is not permitted by this consuming paint input.`:!binding&&(!isSharedToken(name)&&!/^--(?:ds|ux|showcase)-/.test(name)||requirePaint&&!inventory.tokens.some(token=>token.name===name))?`Undefined paint reference ${name}. Declare a real accessible token or a scoped runtime binding.`:null;
93
92
  if(issue&&!emitted.has(`${node.pos}:${name}`)) {emitted.add(`${node.pos}:${name}`);const p=source.getLineAndCharacterOfPosition(node.getStart());report(source.fileName,"token-reference",issue,p.line+1,p.character+1);}
94
93
  }
95
94
  if(requirePaint&&!paintReference(text)) {const p=source.getLineAndCharacterOfPosition(node.getStart());report(source.fileName,"paint-reference",`Invalid paint reference ${JSON.stringify(text)}. Use an accessible token, declared scoped binding, local SVG paint resource, none or currentColor.`,p.line+1,p.character+1);}
@@ -0,0 +1,33 @@
1
+ import { readdirSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { isInside } from "./config.mjs";
4
+
5
+ const metadata = new Set(["node_modules", ".git", ".ds", ".vite", "coverage"]);
6
+ const generated = new Set(["dist", "build", "target", "out", ".next", ".nuxt", ".svelte-kit", ".turbo"]);
7
+
8
+ /** Shared watch/fingerprint policy. Explicit source roots take priority over default outputs. */
9
+ export function previewFileIgnored({root, config}, file) {
10
+ const absolute = path.resolve(file), relative = path.relative(root, absolute);
11
+ if (relative.split(path.sep).some(name => metadata.has(name))) return true;
12
+ if (config.assets.generatedPaths.some(base => isInside(path.resolve(root, base), absolute))) return true;
13
+ const sources = [config.dsDir, config.sourceDir].map(base => path.resolve(root, base));
14
+ for (const name of relative.split(path.sep)) {
15
+ if (!generated.has(name)) continue;
16
+ if (!sources.some(source => isInside(source, absolute) || isInside(absolute, source))) return true;
17
+ }
18
+ return false;
19
+ }
20
+
21
+ /** Allocate individual watches so excluded descendants never consume OS watches. */
22
+ export function previewWatchDirectories(options) {
23
+ const directories = [];
24
+ function visit(directory) {
25
+ directories.push(directory);
26
+ for (const entry of readdirSync(directory, {withFileTypes:true})) {
27
+ const child = path.join(directory, entry.name);
28
+ if (entry.isDirectory() && !entry.isSymbolicLink() && !previewFileIgnored(options, child)) visit(child);
29
+ }
30
+ }
31
+ visit(options.root);
32
+ return directories;
33
+ }
@@ -1,18 +1,19 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { existsSync, readFileSync, readdirSync } from "node:fs";
3
3
  import path from "node:path";
4
- import { isInside } from "./config.mjs";
4
+ import { previewFileIgnored } from "./preview-files.mjs";
5
5
 
6
6
  /** Shared source evidence for compilation, watch recovery and status reads. */
7
- export function previewSourceRevision({root,config}, apps = config.mcp.apps ?? []) {
8
- const rows = [], generated = config.assets.generatedPaths.map(file => path.resolve(root,file));
7
+ export function previewSourceRevision(options, apps = options.config.mcp.apps ?? []) {
8
+ const {root} = options;
9
+ const rows = [];
9
10
  const outputs = new Set(apps.map(app => path.resolve(root,app.file)));
10
11
  function digest(file) { return createHash("sha256").update(readFileSync(file)).digest("hex"); }
11
12
  function visit(directory) {
12
13
  for (const entry of readdirSync(directory,{withFileTypes:true})) {
13
- if (entry.isSymbolicLink() || ["node_modules",".git",".ds",".vite","coverage"].includes(entry.name)) continue;
14
+ if (entry.isSymbolicLink()) continue;
14
15
  const file = path.join(directory,entry.name);
15
- if (outputs.has(file) || generated.some(base => isInside(base,file))) continue;
16
+ if (outputs.has(file) || previewFileIgnored(options,file)) continue;
16
17
  if (entry.isDirectory()) visit(file);
17
18
  else if (entry.isFile() && /\.(?:[cm]?[jt]sx?|css|html|json|md|svg|png|jpe?g|webp|gif|woff2?|ttf|otf|lock|lockb)$/.test(file)) rows.push([path.relative(root,file),digest(file)]);
18
19
  }
@@ -38,8 +38,7 @@ export function previewEntriesPlugin(entries, mountEntry) {
38
38
  load(id) {
39
39
  const entry = ids.get(id.slice(1));
40
40
  if (!entry) return;
41
- const styles = (entry.stylesheets ?? []).map(file => `import ${JSON.stringify(path.resolve(entry.root, file))};`).join("");
42
- return `import { mountScenario } from ${JSON.stringify(mountEntry)};${styles}import Scenario from ${JSON.stringify(path.resolve(entry.root, entry.file))};export const mount = container => mountScenario(Scenario,container);`;
41
+ return `import { mountScenario } from ${JSON.stringify(mountEntry)};import Scenario from ${JSON.stringify(path.resolve(entry.root, entry.file))};export const mount = container => mountScenario(Scenario,container);`;
43
42
  },
44
43
  };
45
44
  }
@@ -7,6 +7,7 @@ import { artifactDigest, createBuildReporter } from "./mcp/build-status.mjs";
7
7
  import { cachedPreviewPublication, previewArtifactHtml, readPreviewManifest } from "./preview-resources.mjs";
8
8
  import { previewArtifactPath, withPreviewSession } from "./preview-scope.mjs";
9
9
  import { previewSourceRevision } from "./preview-inputs.mjs";
10
+ import { previewFileIgnored, previewWatchDirectories } from "./preview-files.mjs";
10
11
 
11
12
  const digest = value => createHash("sha256").update(value).digest("hex");
12
13
  const fileDigest = file => { try { return digest(readFileSync(file)); } catch { return null; } };
@@ -15,7 +16,7 @@ const fileDigest = file => { try { return digest(readFileSync(file)); } catch {
15
16
  * Cache state is development output, never proof that a failed build is current. */
16
17
  export function createPreviewCache(options, compilerFiles = []) {
17
18
  const { root } = options;
18
- const adapterFiles = [import.meta.filename, ...["preview-inputs.mjs", "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,
19
+ const adapterFiles = [import.meta.filename, ...["preview-files.mjs", "preview-inputs.mjs", "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,
19
20
  ...["package.json", "package-lock.json", "bun.lock", "bun.lockb", "node_modules/.package-lock.json"].map(file => path.join(root, file))];
20
21
  const adapterDigest = () => digest(JSON.stringify(adapterFiles.map(file => [file, fileDigest(file)])));
21
22
  const loadedAdapter = adapterDigest();
@@ -273,7 +274,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
273
274
  function sourceChanged(_event, file, topology = false) {
274
275
  if (!file || !topology && !/\.(?:[cm]?[jt]sx?|css|html|json|md|svg|png|jpe?g|webp|gif|woff2?|ttf|otf|lock|lockb)$/.test(file)) return;
275
276
  const absolute = path.join(root, file);
276
- if (file.split(path.sep).some(name => ["node_modules", ".git", ".ds", ".vite", "coverage"].includes(name)) || options.config.assets.generatedPaths.some(base => isInside(path.resolve(root, base), absolute))) return;
277
+ if (previewFileIgnored(options, absolute)) return;
277
278
  changed.add(absolute);
278
279
  clearTimeout(timer);
279
280
  timer = setTimeout(() => {
@@ -324,12 +325,11 @@ export async function runScenarioCompiler(directory, { watched = false, validate
324
325
  try {
325
326
  addWatch(root, sourceChanged);
326
327
  const wanted = new Set([root, path.join(root, ".ds")]);
327
- for (const entry of readdirSync(root, { withFileTypes: true })) {
328
- const directory = path.join(root, entry.name);
329
- if (!entry.isDirectory() || entry.isSymbolicLink() || ["node_modules", ".git", ".ds", ".vite", "coverage"].includes(entry.name)
330
- || options.config.assets.generatedPaths.some(base => isInside(path.resolve(root, base), directory))) continue;
328
+ for (const directory of previewWatchDirectories(options)) {
329
+ if (directory === root) continue;
331
330
  wanted.add(directory);
332
- if (addWatch(directory, (event, file) => sourceChanged(event, file && path.join(entry.name, file)), true) && !initial) sourceChanged("rename", entry.name, true);
331
+ const relative = path.relative(root, directory);
332
+ if (addWatch(directory, (event, file) => sourceChanged(event, file && path.join(relative, file))) && !initial) sourceChanged("rename", relative, true);
333
333
  }
334
334
  mkdirSync(path.join(root, ".ds"), { recursive: true });
335
335
  addWatch(path.join(root, ".ds"), (_event, file) => { if (file === path.basename(process.env.ADS_MCP_REQUEST_FILE ?? "")) request(); });
@@ -8,7 +8,7 @@ import { projectCompilerOptions } from "./boundaries.mjs";
8
8
  import { inspectTokens } from "./tokens.mjs";
9
9
  import { isSharedToken } from "./token-policy.mjs";
10
10
  import { validTokenSamples } from "./token-samples.mjs";
11
- import { scopedTokens } from "./scoped-tokens.mjs";
11
+ import { inspectUnits } from "./units.mjs";
12
12
  import { createScenarioTrace } from "./scenario-trace.mjs";
13
13
  import { inspectRuntimeContracts } from "./runtime-contracts.mjs";
14
14
  import { inspectUnitContracts } from "./unit-contracts.mjs";
@@ -51,7 +51,7 @@ export function inspectScenarios(options, suppliedProgram) {
51
51
  const behaviorApis = new Map(publicApi(program, options).filter(item => !item.renderable && item.behavioral).map(item => [item.name, item]));
52
52
  const tokenInventory = inspectTokens(root, options);
53
53
  const tokenNames = new Set(tokenInventory.tokens.map(token => token.name));
54
- const scoped = scopedTokens(options);
54
+ const units = inspectUnits(options);
55
55
  const scenarios = [];
56
56
  const diagnostics = [...inspectUnitContracts(options).diagnostics,...inspectRuntimeContracts(options,program).diagnostics,...inspectPaintContracts(options).diagnostics];
57
57
  const ids = new Set();
@@ -76,7 +76,7 @@ export function inspectScenarios(options, suppliedProgram) {
76
76
  }
77
77
  }
78
78
  if(metadata?.id!==undefined) {
79
- const owner=scoped.inventory.owner(relative);
79
+ const owner=units.owner(relative);
80
80
  if(typeof metadata.id!=="string"||metadata.id.length>256||!/^[\w-]+(?:[/.][\w-]+)*$/.test(metadata.id)||!owner||!(metadata.id===owner||metadata.id.startsWith(owner+"/")||metadata.id.startsWith(owner+".")))report(file,"Scenario id must be a safe stable identity inside this owner; it cannot capture another layer/owner.",metadataExpression,{entry:"id"});
81
81
  else id=metadata.id;
82
82
  }
@@ -84,8 +84,8 @@ export function inspectScenarios(options, suppliedProgram) {
84
84
  if (ids.has(id)) { report(file, `Duplicate scenario id ${id}. Use one entrypoint per identity.`); continue; }
85
85
  ids.add(id);
86
86
  if (metadata?.kind !== undefined) {
87
- const owner = scoped.inventory.owner(relative);
88
- if (metadata.kind !== "tokens" || !scoped.definitions.some(entry => entry.unit === owner)) report(file, "Only an owner with registered local tokens may set kind: tokens for a colocated token preview.",entryNode("kind"),{entry:"kind"});
87
+ const owner = units.owner(relative);
88
+ if (metadata.kind !== "tokens" || owner !== "tokens") report(file, "Token previews belong in the shared Data token directory. Components and patterns map shared tokens; they do not own independent token catalogues.",entryNode("kind"),{entry:"kind"});
89
89
  else kind = "tokens";
90
90
  }
91
91
  if (!entry) report(file, "Export a default independently mountable scenario entrypoint.");
@@ -117,7 +117,7 @@ export function inspectScenarios(options, suppliedProgram) {
117
117
  return index !== undefined && property && ts.isArrayLiteralExpression(property.initializer) ? property.initializer.elements[index] : property?.initializer ?? metadataExpression;
118
118
  }
119
119
  if (!metadata) {
120
- report(file, "Scenario metadata is not statically readable. Render coverage is not established until this prerequisite is repaired.", metadataExpression, {coverage:"not-established",owner:scoped.inventory.owner(relative)});
120
+ report(file, "Scenario metadata is not statically readable. Render coverage is not established until this prerequisite is repaired.", metadataExpression, {coverage:"not-established",owner:units.owner(relative)});
121
121
  continue;
122
122
  }
123
123
  for(const field of Object.keys(metadata))if(!["id","title","kind","covers","exercises","tokens","samples","captureTargets"].includes(field))report(file,`Unknown scenario field ${field}.`,entryNode(field),{entry:field});
@@ -126,7 +126,7 @@ export function inspectScenarios(options, suppliedProgram) {
126
126
  metadata.title=id;
127
127
  }
128
128
  if(!Array.isArray(metadata.covers)||!metadata.covers.length) {
129
- report(file,"Scenario covers must be a nonempty static array naming rendered public UI. Coverage is not established until repaired.",entryNode("covers"),{entry:"covers",coverage:"not-established",owner:scoped.inventory.owner(relative)});
129
+ report(file,"Scenario covers must be a nonempty static array naming rendered public UI. Coverage is not established until repaired.",entryNode("covers"),{entry:"covers",coverage:"not-established",owner:units.owner(relative)});
130
130
  metadata.covers=[];
131
131
  }
132
132
  if(Object.hasOwn(metadata,"tokens")&&(!Array.isArray(metadata.tokens)||metadata.tokens.some(name=>typeof name!=="string"||!name.startsWith("--")))) {
@@ -163,16 +163,16 @@ export function inspectScenarios(options, suppliedProgram) {
163
163
  const tokens = [...new Set([...(metadata.tokens ?? []), ...(metadata.samples ?? []).map(sample => sample.token)])];
164
164
  for (const name of tokens) if (!tokenNames.has(name)) diagnostics.push({ file: path.relative(root, file).replaceAll("\\", "/"), rule: "token-scenario-reference", line: 1, column: 1, message: `Scenario references undeclared token ${name}. Use a real token from its defining owner.` });
165
165
  if (kind === "tokens") {
166
- const owner = scoped.inventory.owner(relative);
167
- for (const name of tokens) if (tokenInventory.tokens.find(token => token.name === name)?.owner !== owner) report(file, `Token ${name} needs a preview beside its defining owner. Shared tokens belong under the configured token directory; local tokens stay with their component/pattern.`);
166
+ const owner = units.owner(relative);
167
+ for (const name of tokens) if (tokenInventory.tokens.find(token => token.name === name)?.owner !== owner) report(file, `Token ${name} needs a preview beside its defining owner. All design tokens and their previews belong under the configured shared token directory.`);
168
168
  }
169
- const stylesheets = kind === "tokens" ? scoped.definitions.filter(entry => entry.unit === scoped.inventory.owner(relative)).map(entry => entry.file) : [];
169
+
170
170
  const reachable = new Set(metadata.covers);
171
171
  function findBindings(node) { if(ts.isJsxElement(node)||ts.isJsxSelfClosingElement(node))for(const name of bindingTrace.traceRenders(node).rendered)reachable.add(name);ts.forEachChild(node,findBindings); }
172
172
  if(bindingTrace) findBindings(source);
173
173
  const paintBindings = inspectRuntimeContracts(options,program).bindings.filter(binding=>reachable.has(binding.scope.apiName)).map(binding=>({owner:binding.unit,name:binding.name,scope:binding.scope.selector,prefix:binding.prefix,suffix:binding.suffix,tokens:tokenInventory.tokens.filter(token=>!token.owner||token.owner==="tokens"||token.owner===binding.unit).map(token=>token.name)}));
174
174
  const paintAudit=contractDeclarations.some(contract=>contract.paintInputs?.some(input=>reachable.has(input.apiName)));
175
- scenarios.push({ id, kind, title: metadata.title, ...(fixture ? { fixture: path.relative(root, fixture).replaceAll("\\", "/") } : {}), covers: [...new Set(metadata.covers)], ...(captureTargets ? { captureTargets } : {}), ...(Object.hasOwn(metadata, "exercises") ? { exercises: [...new Set(exercises)] } : {}), tokens, ...(metadata.samples ? { samples: metadata.samples } : {}), ...(stylesheets.length ? { stylesheets } : {}), ...(paintBindings.length?{paintBindings}:{}), ...(paintAudit?{paintAudit:true}:{}), file: path.relative(root, file).replaceAll("\\", "/"), artifact: path.relative(root, scenarioArtifact(root, id)).replaceAll("\\", "/") });
175
+ scenarios.push({ id, kind, title: metadata.title, ...(fixture ? { fixture: path.relative(root, fixture).replaceAll("\\", "/") } : {}), covers: [...new Set(metadata.covers)], ...(captureTargets ? { captureTargets } : {}), ...(Object.hasOwn(metadata, "exercises") ? { exercises: [...new Set(exercises)] } : {}), tokens, ...(metadata.samples ? { samples: metadata.samples } : {}), ...(paintBindings.length?{paintBindings}:{}), ...(paintAudit?{paintAudit:true}:{}), file: path.relative(root, file).replaceAll("\\", "/"), artifact: path.relative(root, scenarioArtifact(root, id)).replaceAll("\\", "/") });
176
176
  }
177
177
  return { scenarios: scenarios.sort((a, b) => a.id.localeCompare(b.id)), diagnostics };
178
178
  }
@@ -300,7 +300,7 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
300
300
  }
301
301
  }
302
302
  const blockedOwners=new Set(registry.diagnostics.filter(item=>item.coverage==="not-established").map(item=>item.owner));
303
- for (const item of ui.filter((item) => item.renderable && !covered.has(item.name) && !blockedOwners.has(scopedTokens(options).inventory.owner(scopedTokens(options).inventory.relative(path.relative(options.root,item.file)))))) report(item.file, "scenario-coverage", `Public UI ${item.name} needs a colocated, registered scenario render reference. Related parts may share a scenario.`);
303
+ for (const item of ui.filter((item) => item.renderable && !covered.has(item.name) && !blockedOwners.has(inspectUnits(options).owner(inspectUnits(options).relative(path.relative(options.root,item.file)))))) report(item.file, "scenario-coverage", `Public UI ${item.name} needs a colocated, registered scenario render reference. Related parts may share a scenario.`);
304
304
  for (const token of tokenInventory.tokens.filter(token => !coveredTokens.has(token.name))) {
305
305
  const definition = token.definitions[0];
306
306
  report(path.join(options.root, definition.file), "token-scenario-coverage", `Token ${token.name} needs a registered scenario with a reachable token fixture reference.`, definition.line, definition.column);
@@ -335,9 +335,9 @@ export function tokenSampleSource(options, scenario) {
335
335
  const array = property && resolve(property.initializer);
336
336
  if (array && ts.isArrayLiteralExpression(array)) {
337
337
  const source = array.getSourceFile();
338
- const scoped = scopedTokens(options), owner = scoped.inventory.owner(scoped.inventory.relative(scenario.file));
338
+ const units = inspectUnits(options), owner = units.owner(units.relative(scenario.file));
339
339
  const relative = path.relative(options.root, source.fileName).replaceAll("\\", "/");
340
- if (!isDevelopmentFile(source.fileName, options) || scoped.inventory.owner(scoped.inventory.relative(relative)) !== owner) throw new Error("The consumed samples array must live in this scenario's own development fixture.");
340
+ if (!isDevelopmentFile(source.fileName, options) || units.owner(units.relative(relative)) !== owner) throw new Error("The consumed samples array must live in this scenario's own development fixture.");
341
341
  return {file:relative, content:source.text, start:array.getStart(source), end:array.end};
342
342
  }
343
343
  }
@@ -1 +1 @@
1
- function c(e,t){let o=new DOMParser().parseFromString(e,"text/html"),r=o.createElement("meta");if(r.httpEquiv="Content-Security-Policy",r.content=t,o.head.prepend(r),!o.querySelector("base[href]")){let i=o.querySelector("base")??o.createElement("base");i.setAttribute("href","about:srcdoc"),r.after(i)}return"<!doctype html>"+o.documentElement.outerHTML}var a=new URL(location.href).searchParams.get("parent"),n;function s(e=[]){return e.filter(t=>/^(?:https?:\/\/[a-z0-9.*:[\]-]+(?::\d+)?|data:|blob:|about:)$/i.test(t)).join(" ")}function d(e={}){let t=s(e.resourceDomains);return`default-src 'none';script-src 'unsafe-inline' ${t};style-src 'unsafe-inline' ${t};img-src data: ${t};font-src ${t||"'none'"};media-src ${t||"'none'"};worker-src ${t||"'none'"};connect-src ${s(e.connectDomains)||"'none'"};frame-src ${s(e.frameDomains)||"'none'"};base-uri about: ${s(e.baseUriDomains)};object-src 'none';form-action 'none'`}window.addEventListener("message",e=>{if(e.source===parent&&e.origin===a){let t=e.data;if(t?.method==="ui/notifications/sandbox-resource-ready"){let{html:o,csp:r}=t.params??{};if(typeof o!="string")return;n?.remove(),n=window.document.createElement("iframe"),n.title="Design-system App",n.setAttribute("sandbox","allow-scripts allow-forms"),window.document.body.append(n),n.srcdoc=c(o,d(r))}else t?.jsonrpc==="2.0"&&!t.method?.startsWith("ui/notifications/sandbox-")&&n?.contentWindow.postMessage(t,"*")}else e.source===n?.contentWindow&&e.data?.jsonrpc==="2.0"&&!e.data.method?.startsWith("ui/notifications/sandbox-")&&parent.postMessage(e.data,a)});parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-ready",params:{}},a);
1
+ function c(e,t){let n=new DOMParser().parseFromString(e,"text/html"),s=n.createElement("meta");if(s.httpEquiv="Content-Security-Policy",s.content=t,n.head.prepend(s),!n.querySelector("base[href]")){let i=n.querySelector("base")??n.createElement("base");i.setAttribute("href","about:srcdoc"),s.after(i)}return"<!doctype html>"+n.documentElement.outerHTML}var a=new URL(location.href).searchParams.get("parent"),o;function r(e=[]){return e.filter(t=>/^(?:https?:\/\/[a-z0-9.*:[\]-]+(?::\d+)?|data:|blob:|about:)$/i.test(t)).join(" ")}function d(e={}){let t=r(e.resourceDomains);return`default-src 'none';script-src 'unsafe-inline' 'wasm-unsafe-eval' ${t};style-src 'unsafe-inline' ${t};img-src data: ${t};font-src ${t||"'none'"};media-src ${t||"'none'"};worker-src ${t||"'none'"};connect-src ${r(e.connectDomains)||"'none'"};frame-src ${r(e.frameDomains)||"'none'"};base-uri about: ${r(e.baseUriDomains)};object-src 'none';form-action 'none'`}window.addEventListener("message",e=>{if(e.source===parent&&e.origin===a){let t=e.data;if(t?.method==="ui/notifications/sandbox-resource-ready"){let{html:n,csp:s}=t.params??{};if(typeof n!="string")return;o?.remove(),o=window.document.createElement("iframe"),o.title="Design-system App",o.setAttribute("sandbox","allow-scripts allow-forms"),window.document.body.append(o),o.srcdoc=c(n,d(s))}else t?.jsonrpc==="2.0"&&!t.method?.startsWith("ui/notifications/sandbox-")&&o?.contentWindow.postMessage(t,"*")}else e.source===o?.contentWindow&&e.data?.jsonrpc==="2.0"&&!e.data.method?.startsWith("ui/notifications/sandbox-")&&parent.postMessage(e.data,a)});parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-ready",params:{}},a);
@@ -3,13 +3,13 @@
3
3
  Install the skills you need with `npx skills`:
4
4
 
5
5
  ```sh
6
- npx skills add reqvire-org/ads --skill ads-designer --skill ads-import --skill ads-migrate --skill ads-break-ui --skill ads-motion
6
+ npx skills add reqvire-org/ads --skill ads-designer --skill ads-import --skill ads-port --skill ads-break-ui --skill ads-motion
7
7
  ```
8
8
 
9
9
  For local development, install from this checkout:
10
10
 
11
11
  ```sh
12
- npx skills add ./skills --skill ads-designer --skill ads-import --skill ads-migrate --skill ads-break-ui --skill ads-motion
12
+ npx skills add ./skills --skill ads-designer --skill ads-import --skill ads-port --skill ads-break-ui --skill ads-motion
13
13
  ```
14
14
 
15
15
  Each skill includes its own instructions and references. `ads-designer` also
@@ -17,6 +17,12 @@ includes an empty bootstrap scaffold, so starting from zero needs no example
17
17
  repository. Skills operate on a project's local ADS; they do not install a UI
18
18
  catalogue or replace the project's theme values.
19
19
 
20
+ Build and adapt UI through the same public APIs for websites and MCP Apps.
21
+ Application adapters own routing, stores, MCP communication, tool-result mapping,
22
+ mounting and serving. Use the real ADS showcase and relevant application checks;
23
+ reuse existing verification and add targeted checks for uncovered behavior.
24
+ Report the states and environments actually verified.
25
+
20
26
  The [stdio MCP server](../docs/MCP.md#skills) also serves these skills and supporting
21
27
  files from the npm distribution. Native Skills discovery is available on the
22
28
  newer protocol; ordinary tools/resources provide explicit access on older
@@ -35,14 +41,18 @@ the browser, and provides a running URL or exact command for review. See the
35
41
  | Skill | Use | Example |
36
42
  |-------|-----|---------|
37
43
  | [ads-designer](ads-designer/SKILL.md) | Bootstrap or build UI using the local ADS, with craft/mobile guidance | `$ads-designer build a settings page using this project's ADS` |
38
- | [ads-import](ads-import/SKILL.md) | Import selected external ADS source, brand artwork, or compatible source token values | `$ads-import /path/to/source-repo component Toast` |
39
- | [ads-migrate](ads-migrate/SKILL.md) | Study an external component library and implement a native counterpart | `$ads-migrate https://github.com/emilkowalski/sonner` |
44
+ | [ads-import](ads-import/SKILL.md) | Check destination compatibility, then integrate selected ADS source, artwork or theme values | `$ads-import /path/to/source-repo component Toast` |
45
+ | [ads-port](ads-port/SKILL.md) | Port library capabilities into a coherent ADS using shared tokens and primitives | `$ads-port https://github.com/emilkowalski/sonner` |
40
46
  | [ads-break-ui](ads-break-ui/SKILL.md) | Stress-test real components/patterns; optionally fix demonstrated failures | `$ads-break-ui AppShell +fix` |
41
47
  | [ads-motion](ads-motion/SKILL.md) | Implement, review, audit, or profile motion | `$ads-motion review Toast` |
42
48
 
43
49
  For token values, use `$ads-import /path/to/source-repo tokens`; for original
44
50
  artwork and its guidance, use `$ads-import /path/to/source-repo brand`. ADS token
45
51
  names and ownership prefixes are fixed; imports conform to that architecture.
52
+ Shared Data is the only design-value catalogue. Existing project font, text and
53
+ spacing roles take precedence over divergent upstream constants. Each skill
54
+ includes `references/design-data.md` for source rules and duplication review;
55
+ demo framing lives in development-only `review/`.
46
56
  For motion, the
47
57
  request selects the mode, for example `build`, `audit`, or `performance`.
48
58
  Review/audit requests report findings; a fix request authorizes implementation.
@@ -3,6 +3,9 @@ name: ads-break-ui
3
3
  description: Stress-test a project's local design-system components or patterns with extreme realistic content, empty and failure states, narrow containers, and accessibility settings. Build development fixtures, report layout failures, and fix them when requested.
4
4
  ---
5
5
 
6
+ For Node/Bun setup, MCP launch and compiler workers, read
7
+ [runtimes.md](references/runtimes.md).
8
+
6
9
  Exercise the real component through its public API. Accept an item name, screen,
7
10
  file, or local project path; discover the relevant exports and usage when the
8
11
  request already identifies the target.
@@ -49,7 +52,7 @@ ADS gates. For binary/large assets, generate `git diff --binary --full-index` in
49
52
  stay out of model context. Binary changes require Git. When editing is disabled,
50
53
  use the client's normal source-editing tools.
51
54
  For owner drafts, token-sample reconciliation, coupled transactions and local
52
- constant namespaces, read [guarded-editing.md](references/guarded-editing.md).
55
+ shared Data ownership, read [guarded-editing.md](references/guarded-editing.md).
53
56
  For on-demand current/candidate screenshots and visual dry-run review, read
54
57
  [captures.md](references/captures.md).
55
58
  For a rejected patch, failed check or loading error, read
@@ -67,8 +70,9 @@ renderers, build aliases or `review-import` / `review-contract` diagnostics, rea
67
70
 
68
71
  A component provides one cohesive UI capability; a pattern arranges capabilities
69
72
  into reusable structures or workflows. Components may compose components/controllers;
70
- layout patterns may arrange slots. Do not classify by component count. For owner
71
- selection or `component-dependency`, `component-contract` or `component-style`, read
73
+ layout patterns may arrange slots. Do not classify by component count. For shared
74
+ website/MCP App use, owner selection, or `component-dependency`,
75
+ `component-contract` or `component-style` diagnostics, read
72
76
  [layer responsibilities and contracts](references/layers.md), also served as
73
77
  `ads://guides/layers`. Preserve public APIs and documented non-state styling hooks.
74
78
 
@@ -93,11 +97,11 @@ pattern; reusable controllers use discovered `controllers/<Name>` units. Use the
93
97
  project's configured framework and declared dependencies, or plain TypeScript,
94
98
  browser APIs and local helpers. MCP hosts supply no ad hoc runtime APIs. The
95
99
  framework setting selects compilation/mounting; controller checks also validate
96
- imports. For controller/behavior work, read `ads://guides/behaviors` (offline:
97
- the installed ADS package's `docs/BEHAVIORS.md`). Discover registered guarantees
100
+ imports. For controller/behavior work, read
101
+ [behaviors.md](references/behaviors.md), also served as `ads://guides/behaviors`. Discover registered guarantees
98
102
  with `ads_behaviors`; use `ads_verify` for selected real checks. Optional
99
103
  `exercises` links public behavioral APIs to scenarios; keep `covers` for rendered
100
- UI. Registration and demonstration are not passing evidence. `behavior.json`,
104
+ UI. Registration and demonstration are not passing evidence. `<Owner>.ads.contract.ts`,
101
105
  scenarios, fixtures and checks stay out of production exports/imports. Verify
102
106
  current results, including lifecycle setup/cleanup/setup and the actual browser
103
107
  profile when promised. React StrictMode needs a development harness; wrapping a
@@ -154,7 +158,7 @@ failure is reproducible.
154
158
 
155
159
  Scenarios own sample data and example selection. Missing reusable UI belongs in the
156
160
  ADS implementation and public exports, not in a scenario-only control. The tool supplies the neutral client shell; reusable scenario review layouts
157
- are public project ADS entities.
161
+ are exported through the separate development-only review entry.
158
162
  Showcase/scenario files define no CSS, custom classes, or widget markup. Change
159
163
  the owning ADS frame pattern when a necessary layout is missing. Run shared ADS/project guards for its build and the app
160
164
  build, then give a full running URL or exact run command for human review.
@@ -179,26 +183,27 @@ The host shows errors and marks retained output as stale. Other hosts may need a
179
183
  explicit preview-tool invocation. Compilation remains project-owned and required
180
184
  for TSX/Linaria; it is automatic, not eliminated.
181
185
 
182
- Reusable review layouts belong in public project ADS patterns, while scenario
186
+ Reusable review layouts belong in development-only `review/`, exported through
187
+ the separate review entry, while scenario
183
188
  files define no CSS, custom classes or widget replicas. Keep real presentation in
184
189
  its component/pattern owner. The tooling shell's CSS is outside that project
185
190
  contract. Legacy custom showcase pages may be retained during migration; new
186
191
  projects require no TokensPage/ComponentsPage/PatternsPage/CompositionPage files.
187
192
 
188
- Colocate `Scenario.tsx` and `fixture.ts` with tokens and each component/pattern; flat owners
189
- may use `<Owner>.scenario.tsx` and `<Owner>.fixture.ts`. Put larger entries under
190
- `composition/<Name>/Scenario.tsx` with their own `fixture.ts`. Export a default
193
+ Colocate `<Owner>.ads.scenario.tsx` and `<Owner>.ads.fixture.ts` with tokens and
194
+ each component/pattern. Put larger entries under `composition/<Name>/` with their
195
+ own marked scenario and fixture. Export a default
191
196
  zero-input mountable view and literal metadata, for example
192
197
  `export const scenario = { title: "Button states", covers: ["Button"] };`.
193
198
  Import the real UI from the public ADS alias. Keep fixture inputs, simulated
194
199
  services and initial state/callback adapters beside the scenario. Empty fixtures
195
200
  are valid for an entry with no inputs. Extra development helpers use a
196
- `scenario/` or `fixtures/` subfolder, or `<Owner>.scenario-adapter.ts`, so guards
201
+ `<Owner>.ads.helpers.ts` file, so guards
197
202
  recognize their role even beside runtime code. Never require a page, router or store to
198
203
  initialize the entry. Several contextual public parts may share one scenario.
199
204
 
200
- IDs derive from ADS-relative filenames: both `components/core/Button/Scenario.tsx`
201
- and `components/core/Button.scenario.tsx` identify `components/core/Button`.
205
+ IDs derive from ADS-relative filenames: both `components/core/Button/Button.ads.scenario.tsx`
206
+ and `components/core/Button.ads.scenario.tsx` identify `components/core/Button`.
202
207
  Use one form, no duplicate IDs or hand-maintained registry. Renames change IDs.
203
208
  The showcase and external hosts mount the same discovered entry. The Vite
204
209
  adapter uses `previewEntriesPlugin` and `createPreviewResources` with
@@ -358,5 +363,14 @@ Source credits and retained MIT terms: [README.md](README.md) and
358
363
 
359
364
  For static owner contracts, `.ads.` development roles, typed paint/binding APIs,
360
365
  declarative parent graphs, constrained theme bindings, private visual subject roles,
361
- token privacy and guarded migration, read
366
+ shared Data ownership and guarded migration, read
362
367
  [contracts.md](references/contracts.md) when the task touches those contracts.
368
+
369
+ For a suspected ADS defect or missing capability after targeted investigation, read
370
+ [reporting.md](references/reporting.md). Record actionable observations with
371
+ `ads_report_bug` or `ads_request_feature`; preserve valid APIs and rejected drafts.
372
+
373
+ For Data/UX/Skin boundaries, shared token reuse and private-value diagnostics, read
374
+ [design-data.md](references/design-data.md). Components own mappings and mechanics,
375
+ not independent token catalogues. Existing project font, text and spacing roles
376
+ take precedence over divergent upstream constants during adaptation.
@@ -110,8 +110,7 @@ MCP delivers it inside the App document, not the outer showcase host.
110
110
  ownership, and rejects conflicting schemas or registrations shared by unrelated
111
111
  owners. Identical registrations from the same owner are permitted. Runtime
112
112
  `--ds-*` / `--ux-*` variables stay with their runtime owner. A shared token's
113
- registration belongs beside its actual definition in a foundation value sheet;
114
- a namespaced owner token's registration belongs in its registered `tokens.css`.
113
+ registration belongs beside its actual definition in a foundation value sheet.
115
114
  Neither `base.css` nor `fonts.css` becomes a registration escape hatch. Registration
116
115
  alone does not define a token or satisfy its sample/fixture coverage.
117
116
 
@@ -258,6 +257,14 @@ contract; an overlap warning remains a review signal.
258
257
  with `severity: "warning"`. CLI checks still exit successfully when there are no
259
258
  errors; MCP checks and mutations preserve the warning and its guidance URI.
260
259
 
260
+ An unchanged advisory baseline is not evidence that the affected styles are
261
+ correct. Triage warnings that reach an edited owner or its shared helpers against
262
+ the actual DOM classes and computed styles in a compiled scenario. Interaction
263
+ checks may pass without measuring padding, alignment or sizing. When an intended
264
+ layout is known, add a focused rendered assertion for that contract; when keeping
265
+ an overlap, state why it is intentional and which states/directions were checked.
266
+ Keep unresolved paths and unsupported writing modes explicit in the evidence.
267
+
261
268
  The source review examines atomic Linaria templates and statically traceable
262
269
  `cx` arguments, including aliases, local imports/re-exports, local helper returns,
263
270
  arguments/defaults, nested composition, conditional expressions and variant-object