@reqvire-org/ads 0.0.0-stage → 0.3.0

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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +284 -2
  3. package/dist/assets.mjs +52 -0
  4. package/dist/bootstrap-ds/ADS.md +203 -0
  5. package/dist/bootstrap-ds/README.md +98 -0
  6. package/dist/bootstrap-ds/biome.css.json +21 -0
  7. package/dist/bootstrap-ds/design-system/assets/brand/README.md +28 -0
  8. package/dist/bootstrap-ds/design-system/assets/fonts/.gitkeep +0 -0
  9. package/dist/bootstrap-ds/design-system/components/.gitkeep +0 -0
  10. package/dist/bootstrap-ds/design-system/composition/.gitkeep +0 -0
  11. package/dist/bootstrap-ds/design-system/index.ts +5 -0
  12. package/dist/bootstrap-ds/design-system/patterns/.gitkeep +0 -0
  13. package/dist/bootstrap-ds/design-system/showcase/mcp/index.html +1 -0
  14. package/dist/bootstrap-ds/design-system/showcase/mcp/main.tsx +8 -0
  15. package/dist/bootstrap-ds/design-system/styles.css +5 -0
  16. package/dist/bootstrap-ds/design-system/tokens/Foundation.fixture.ts +47 -0
  17. package/dist/bootstrap-ds/design-system/tokens/Foundation.scenario.tsx +14 -0
  18. package/dist/bootstrap-ds/design-system/tokens/base.css +27 -0
  19. package/dist/bootstrap-ds/design-system/tokens/colors.css +29 -0
  20. package/dist/bootstrap-ds/design-system/tokens/elevation.css +15 -0
  21. package/dist/bootstrap-ds/design-system/tokens/spacing.css +15 -0
  22. package/dist/bootstrap-ds/design-system/tokens/typography.css +13 -0
  23. package/dist/bootstrap-ds/ds.config.json +13 -0
  24. package/dist/bootstrap-ds/gitignore.template +8 -0
  25. package/dist/bootstrap-ds/package-lock.json +4660 -0
  26. package/dist/bootstrap-ds/package.json +41 -0
  27. package/dist/bootstrap-ds/scripts/build-mcp-previews.mjs +33 -0
  28. package/dist/bootstrap-ds/src/vite-env.d.ts +7 -0
  29. package/dist/bootstrap-ds/tsconfig.build.json +12 -0
  30. package/dist/bootstrap-ds/tsconfig.json +20 -0
  31. package/dist/bootstrap-ds/vite.config.ts +21 -0
  32. package/dist/boundaries.mjs +130 -0
  33. package/dist/brand-assets.mjs +82 -0
  34. package/dist/check.mjs +222 -0
  35. package/dist/cli.mjs +106 -0
  36. package/dist/config.mjs +181 -0
  37. package/dist/contracts/tokens.json +52 -0
  38. package/dist/html.mjs +30 -0
  39. package/dist/index.mjs +9 -0
  40. package/dist/init.mjs +194 -0
  41. package/dist/lint-config.mjs +40 -0
  42. package/dist/mcp/THIRD_PARTY_NOTICES.md +786 -0
  43. package/dist/mcp/apps.mjs +53 -0
  44. package/dist/mcp/build-status.mjs +164 -0
  45. package/dist/mcp/catalog.mjs +65 -0
  46. package/dist/mcp/context.mjs +69 -0
  47. package/dist/mcp/mutations.mjs +301 -0
  48. package/dist/mcp/patch.mjs +114 -0
  49. package/dist/mcp/preview-watch.mjs +169 -0
  50. package/dist/mcp/preview-widget.bundle.js +113 -0
  51. package/dist/mcp/project-widget.bundle.js +113 -0
  52. package/dist/mcp/prompts.mjs +28 -0
  53. package/dist/mcp/resource-loader.js +138 -0
  54. package/dist/mcp/sandbox-host.mjs +22 -0
  55. package/dist/mcp/server.mjs +377 -0
  56. package/dist/mcp/showcase-host.mjs +68 -0
  57. package/dist/mcp/skills.mjs +77 -0
  58. package/dist/mcp/widget.bundle.js +150 -0
  59. package/dist/oxlint.mjs +81 -0
  60. package/dist/preview-resources.mjs +198 -0
  61. package/dist/project-documents.mjs +27 -0
  62. package/dist/public-props.mjs +74 -0
  63. package/dist/scenarios-compiler.mjs +287 -0
  64. package/dist/scenarios-vite.d.mts +3 -0
  65. package/dist/scenarios-vite.mjs +71 -0
  66. package/dist/scenarios.mjs +212 -0
  67. package/dist/showcase/client.bundle.js +127 -0
  68. package/dist/showcase/index.html +17 -0
  69. package/dist/showcase/sandbox.js +30 -0
  70. package/dist/showcase/style.css +7 -0
  71. package/dist/showcase-coverage.mjs +118 -0
  72. package/dist/showcase.mjs +77 -0
  73. package/dist/skills/README.md +68 -0
  74. package/dist/skills/ads-assimilate/SKILL.md +292 -0
  75. package/dist/skills/ads-assimilate/agents/openai.yaml +4 -0
  76. package/dist/skills/ads-assimilate/references/cli.md +111 -0
  77. package/dist/skills/ads-assimilate/references/lint-and-docs.md +87 -0
  78. package/dist/skills/ads-assimilate/references/native-implementation.md +98 -0
  79. package/dist/skills/ads-assimilate/references/testing.md +107 -0
  80. package/dist/skills/ads-break-ui/LICENSE.upstream +21 -0
  81. package/dist/skills/ads-break-ui/README.md +16 -0
  82. package/dist/skills/ads-break-ui/SKILL.md +235 -0
  83. package/dist/skills/ads-break-ui/agents/openai.yaml +4 -0
  84. package/dist/skills/ads-break-ui/references/catalog.md +135 -0
  85. package/dist/skills/ads-break-ui/references/verification.md +48 -0
  86. package/dist/skills/ads-designer/LICENSE.upstream +21 -0
  87. package/dist/skills/ads-designer/README.md +19 -0
  88. package/dist/skills/ads-designer/SKILL.md +400 -0
  89. package/dist/skills/ads-designer/agents/openai.yaml +4 -0
  90. package/dist/skills/ads-designer/assets/bootstrap-ds/ADS.md +203 -0
  91. package/dist/skills/ads-designer/assets/bootstrap-ds/README.md +98 -0
  92. package/dist/skills/ads-designer/assets/bootstrap-ds/biome.css.json +21 -0
  93. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/brand/README.md +28 -0
  94. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/fonts/.gitkeep +0 -0
  95. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/.gitkeep +0 -0
  96. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/composition/.gitkeep +0 -0
  97. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/index.ts +5 -0
  98. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/patterns/.gitkeep +0 -0
  99. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/showcase/mcp/index.html +1 -0
  100. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/showcase/mcp/main.tsx +8 -0
  101. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/styles.css +5 -0
  102. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/Foundation.fixture.ts +47 -0
  103. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/Foundation.scenario.tsx +14 -0
  104. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/base.css +27 -0
  105. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/colors.css +29 -0
  106. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/elevation.css +15 -0
  107. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/spacing.css +15 -0
  108. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/typography.css +13 -0
  109. package/dist/skills/ads-designer/assets/bootstrap-ds/ds.config.json +13 -0
  110. package/dist/skills/ads-designer/assets/bootstrap-ds/gitignore.template +8 -0
  111. package/dist/skills/ads-designer/assets/bootstrap-ds/package-lock.json +4660 -0
  112. package/dist/skills/ads-designer/assets/bootstrap-ds/package.json +41 -0
  113. package/dist/skills/ads-designer/assets/bootstrap-ds/scripts/build-mcp-previews.mjs +33 -0
  114. package/dist/skills/ads-designer/assets/bootstrap-ds/src/vite-env.d.ts +7 -0
  115. package/dist/skills/ads-designer/assets/bootstrap-ds/tsconfig.build.json +12 -0
  116. package/dist/skills/ads-designer/assets/bootstrap-ds/tsconfig.json +20 -0
  117. package/dist/skills/ads-designer/assets/bootstrap-ds/vite.config.ts +21 -0
  118. package/dist/skills/ads-designer/references/cli.md +111 -0
  119. package/dist/skills/ads-designer/references/design-craft.md +65 -0
  120. package/dist/skills/ads-designer/references/mobile.md +73 -0
  121. package/dist/skills/ads-import/SKILL.md +335 -0
  122. package/dist/skills/ads-import/agents/openai.yaml +4 -0
  123. package/dist/skills/ads-import/references/branding.md +44 -0
  124. package/dist/skills/ads-import/references/cli.md +111 -0
  125. package/dist/skills/ads-import/references/implementation.md +111 -0
  126. package/dist/skills/ads-import/references/tokens.md +96 -0
  127. package/dist/skills/ads-motion/LICENSE.upstream +21 -0
  128. package/dist/skills/ads-motion/README.md +22 -0
  129. package/dist/skills/ads-motion/SKILL.md +217 -0
  130. package/dist/skills/ads-motion/agents/openai.yaml +4 -0
  131. package/dist/skills/ads-motion/references/audit.md +44 -0
  132. package/dist/skills/ads-motion/references/build.md +81 -0
  133. package/dist/skills/ads-motion/references/performance.md +55 -0
  134. package/dist/skills/ads-motion/references/review.md +35 -0
  135. package/dist/skills/ads-motion/references/verification.md +39 -0
  136. package/dist/token-policy.mjs +10 -0
  137. package/dist/tokens.mjs +142 -0
  138. package/dist/ui-framework.mjs +59 -0
  139. package/dist/units.mjs +168 -0
  140. package/docs/ADS.md +310 -0
  141. package/docs/ARCHITECTURE.md +311 -0
  142. package/docs/CHANGELOG.md +106 -0
  143. package/docs/GUIDE.md +722 -0
  144. package/docs/MCP.md +690 -0
  145. package/package.json +107 -4
package/docs/ADS.md ADDED
@@ -0,0 +1,310 @@
1
+ # ADS tooling contract
2
+
3
+ This document defines enforceable ownership, token, integration, and build
4
+ rules. [ARCHITECTURE.md](ARCHITECTURE.md) explains their purpose and the Data,
5
+ UX, and Skin pillars. [GUIDE.md](GUIDE.md) gives setup and configuration steps.
6
+
7
+ ## Ownership boundary
8
+
9
+ MCP source editing is opt-in through `ads mcp --mutations`. Its write operation
10
+ accepts a Git unified diff for one ADS unit and validates its source, scenario and
11
+ fixture changes against core checks, registered Oxlint rules and project checks
12
+ before application. This includes
13
+ foundation, documentation, original assets and an explicit configuration unit for
14
+ project settings, registered guard code and compiler integration. Configuration
15
+ patches validate the proposed policy; mandatory core gates remain enabled.
16
+ Source checks do not establish visual correctness; normal lint/build gates
17
+ remain required for edits made through other tools.
18
+ See the [MCP editing contract](MCP.md#guarded-editing).
19
+
20
+ Tooling updates must preserve project-owned source and token values. Content
21
+ imports and adaptations are explicit operations; tool installation and upgrades
22
+ load no UI catalogue. Empty scaffold files become project-owned when copied or
23
+ generated.
24
+
25
+ Application code imports its local public barrel, normally through `@ds`.
26
+ The default layout keeps application code in `src/` and project ADS source in
27
+ root `design-system/`. Configure existing alternate layouts explicitly.
28
+
29
+
30
+ Framework choice belongs to the receiving project. Linaria is required for the
31
+ component and pattern styling pipeline. Source checks support React and native Preact, including JSX, UI factories and
32
+ DOM/CSS types. The empty scaffold uses React; the working example uses Preact. See [implementation support](GUIDE.md#implementation-support)
33
+ for checked formats and gaps.
34
+
35
+ ## Showcase contract
36
+
37
+ The showcase is a minimal shell plus an MCP client and Apps host, shipped with
38
+ ADS tooling. It discovers token/component/pattern/composition
39
+ scenarios from MCP tool results, invokes preview tools and responds to resource
40
+ notifications. The project does not author a second catalogue or browser app.
41
+
42
+ `ads mcp` starts the loopback website alongside stdio. Open the URL returned by
43
+ `ads_status`. Without an agent connection, `ads showcase` starts the same runtime
44
+ for browser use. Both transports share one configured preview compiler.
45
+
46
+ The shell owns section tabs, collapsible navigation, theme controls and the App
47
+ slot. The browser host uses a separate-origin sandbox proxy; project runtimes,
48
+ styles, fonts and UI execute/apply only in the App iframe. Components, patterns,
49
+ token values, scenarios, fixtures and their Linaria styles remain project-owned.
50
+ App presentation comes from the selected compiled scenario; reusable review layouts live in public ADS patterns. Do not recreate
51
+ production widgets inside the client or scenario.
52
+
53
+ There are four sections: Tokens, Components, Patterns and Composition. There are
54
+ no required `TokensPage`/`ComponentsPage`/`PatternsPage`/`CompositionPage` files.
55
+ Legacy custom browsing pages remain checked when present, but new projects use
56
+ the built-in client. Its tooling CSS is separate from the project style contract.
57
+
58
+ The shared resource compiler builds one graph for all discovered scenarios on
59
+ first demand. Selections reuse the App and load their dependency closure. The
60
+ project's `mountScenario(Scenario, container)` adapter returns an unmount callback
61
+ that releases owned roots, listeners, timers, portals and workers. Switching or
62
+ rebuilding a scenario resets its state while retaining unchanged shared modules.
63
+ Host context selects the project theme; it does not replace the project's skin.
64
+
65
+
66
+ Colocate development entries and fixture inputs:
67
+
68
+ ```text
69
+ design-system/
70
+ tokens/
71
+ typography.css
72
+ Typography.scenario.tsx
73
+ Typography.fixture.ts
74
+ components/core/Button/
75
+ Button.tsx
76
+ Scenario.tsx
77
+ fixture.ts
78
+ patterns/Editor/
79
+ Editor.tsx
80
+ Scenario.tsx
81
+ fixture.ts
82
+ composition/Workspace/
83
+ Scenario.tsx
84
+ fixture.ts
85
+ showcase/mcp/ Project compiler adapter
86
+ main.tsx
87
+ ```
88
+
89
+ Flat owners may use `Button.scenario.tsx` and `Button.fixture.ts` instead.
90
+ `Scenario.tsx` exports a default independently mountable view and literal metadata
91
+ `export const scenario = { title: "Button states", covers: ["Button"] };`.
92
+ Token entries under the configured token directory also declare `tokens`:
93
+ `export const scenario = { title: "Typography", covers: ["TokenSamples"], tokens: fixture.tokens };`.
94
+ Metadata may read literal const fixture fields; it cannot run expressions,
95
+ functions, wildcard lists or token discovery. The same fixture list must be
96
+ consumed by the default entry. `covers: []` is valid for a minimal token value
97
+ inspection entry without public UI; styled samples use a real public review
98
+ pattern. Names and sample text belong to the fixture, values to foundation CSS.
99
+ It imports real public UI through `@ds` and its local fixture. The adapter supplies
100
+ initial state, callbacks and simulated services. The default entry needs no
101
+ mandatory caller inputs or prior page initialization. Related parts may share a
102
+ scenario containing their required public parent. Larger composition scenarios
103
+ reuse production screen patterns; that screen reuse remains skill guidance.
104
+
105
+ IDs derive from the ADS-relative path: `components/core/Button/Scenario.tsx` and
106
+ `components/core/Button.scenario.tsx` both identify `components/core/Button`.
107
+ Use one form per owner. Renaming moves the ID. No manually assigned ID or parallel
108
+ registry is maintained. Fixture files use `fixture.ts`/`<Owner>.fixture.ts`; JS,
109
+ TSX or JSON equivalents are supported. An empty fixture is valid without inputs. Extra development helpers use
110
+ `scenario/` or `fixtures/` subfolders, or `<Owner>.scenario-adapter.ts`.
111
+
112
+ `scenario-contract`, `scenario-render` and `scenario-coverage` checks require valid
113
+ entries and reachable public render references for every public renderable
114
+ component/pattern, including unused exports and Linaria styled exports. Types, constants and utility functions
115
+ are excluded. Coverage is a static source policy; it does not prove runtime
116
+ mounting, correct props, every branch/state or visual parity. The older
117
+ `showcase-coverage` policy also checks application render references.
118
+
119
+ `token-scenario-reference` rejects undeclared token names in metadata and reachable
120
+ inputs. `token-scenario-render` rejects claimed tokens with no reachable input
121
+ reference; `token-scenario-coverage` requires every discovered foundation token
122
+ to have coverage. A new or removed token therefore needs a scenario/fixture
123
+ update. All three are errors in `ads check`, run by `lint:ds` and the build.
124
+ Coverage is static reachability, not proof that every branch actually renders
125
+ or applies the right CSS property. Browser review still verifies the samples.
126
+
127
+ Scenarios and fixture helpers are development-only wherever colocated. Runtime
128
+ source and the public barrel cannot import or re-export them. Showcase/scenario
129
+ code defines no CSS, custom classes or native controls; use public ADS APIs.
130
+ Neither ADS implementations nor scenarios import application code. Live business
131
+ data belongs to application adapters; ADS receives inputs or injected callbacks.
132
+ Direct global `fetch`, XHR, WebSocket and EventSource use is rejected. Renderer
133
+ workers, lazy imports and injected services remain supported; custom HTTP clients
134
+ and computed API access need project checks and review.
135
+
136
+ Tests may import local fixtures. Load real foundation CSS in DOM/browser tests
137
+ instead of assigning shared tokens in JavaScript. Full application harnesses
138
+ belong in application test support. Run ADS/project checks before application,
139
+ preview builds; review meaningful states in both themes and sizes.
140
+
141
+ ## Shared token contract
142
+
143
+ Keep compatible token names, meanings, value types, and alias relationships;
144
+ project values and theme overrides may differ. The
145
+ [Data pillar](ARCHITECTURE.md#data-gives-implementations-a-common-language)
146
+ explains the model.
147
+
148
+ Consume token references instead of raw visual values. Color formulas, effects,
149
+ durations, easing, typography, sizing, and layering values belong in the token
150
+ source.
151
+
152
+ Token names and ownership prefixes are fixed by ADS architecture, not project
153
+ configuration. `--ds-*` belongs to components, `--ux-*` to patterns, and
154
+ `--showcase-*` is reserved to showcase-local boundaries; it does not authorize
155
+ custom styling in fixture files. The ADS frame pattern uses `--ux-*`. Foreign brand prefixes are rejected. Foundation
156
+ CSS imports the approved token files in order; shared assignments belong in
157
+ those token files, never in consumer styles or component state overrides.
158
+
159
+ Store original branding and its usage, credits, and licenses in
160
+ `assets/brand/`, and fonts in `assets/fonts/`. Configure generated icons and
161
+ asset mounts as described in the [branding guide](GUIDE.md#branding).
162
+
163
+ - Component, pattern, and style imports reuse destination values and add
164
+ missing shared definitions with initial values.
165
+ - An explicit token-values import adopts all source-provided compatible values
166
+ and theme variants, preserving target-only definitions and variants.
167
+ - Incompatible names, meanings, or types require a documented mapping or
168
+ contract migration. Do not create a second prefixed token vocabulary as the
169
+ normal import strategy.
170
+ - New tool token definitions must preserve existing project values.
171
+ Importing a theme is a separate operation.
172
+
173
+ Tool updates may add or migrate definitions, types, aliases, and validation.
174
+ They must not silently replace a project's brand, typography, spacing, or
175
+ motion values.
176
+
177
+ ## External source workflows
178
+
179
+ External content workflows are agent skills; there is no CLI
180
+ `ads import` command. Use the [skill guide](../skills/README.md) for installation,
181
+ selection, import, assimilation, stress testing, and motion workflows.
182
+
183
+ Record the source revision and integrate selected source, dependencies, public
184
+ exports, assets, documentation, and applicable rules. Preserve destination token
185
+ values unless a theme-value import is requested. Keep project-specific renderer,
186
+ framework, and component guards during adoption; shared checks complement them.
187
+ See [guard configuration](GUIDE.md#generic-architecture-guards).
188
+
189
+ ## Project integration
190
+
191
+ Keep the framework, application configuration, and unrelated dependencies.
192
+ Declare React or native Preact in `ds.config.json` through the first
193
+ `ads init --framework react` or `ads init --framework preact` run. Existing saved
194
+ choices are reused; init does not migrate the application's framework.
195
+ Merge the needed scaffold or source into the destination rather than replacing
196
+ its project configuration.
197
+
198
+ Resolve `@ds` to the project's local public barrel in TypeScript and its app
199
+ bundler. Export components and their public types through that barrel. Load the
200
+ local foundation CSS once and integrate Linaria extraction with both the app
201
+ and preview builds. Init does not install or configure Linaria; follow the
202
+ [setup guide](GUIDE.md#linaria-integration). Follow the target's component, pattern, and style
203
+ ownership rules. Export a new entity and its public types before migrating
204
+ consumers; consumers import through the public barrel. Keep lint modules,
205
+ fixtures, and generators out of that runtime API.
206
+
207
+ Keep detailed usage, API, lifecycle, motion, token hooks, tests, and provenance
208
+ in each item's local README. Record source repository/file links, revision,
209
+ authors, concrete influences, and integration differences. Preserve applicable
210
+ license notices for copied/adapted source and assets. The project guide records
211
+ local implementation choices and links to the local item guides.
212
+
213
+ ## Build contract
214
+
215
+ The installed tool is a project development dependency. `ds.config.json`
216
+ describes source locations, public entry points, asset sources, and explicit
217
+ boundaries. Initialized builds use the local CLI in this order:
218
+
219
+ ```text
220
+ ads lint-config → ads check → Oxlint → ads assets → existing prebuild → existing build
221
+ ```
222
+
223
+ `lint-config` regenerates ignored `.ds/oxlintrc.json` for the installed tool and
224
+ registered project rules. `ads check` validates the architecture before asset
225
+ generation; Oxlint runs the core and registered usage rules. `ads assets`
226
+ generates configured browser icons from the source SVG into ignored `.ds/assets/`.
227
+ A failed check or generation stops the build. Keep the project's CSS lint,
228
+ type checks, behavior tests, and framework compilation in its build/test flow.
229
+ `ads init` preserves existing lint tools and build commands.
230
+
231
+ Application and project preview builds validate the same source and use the same
232
+ foundation and component style processing. The built-in client is already bundled
233
+ in the tool; the project compiler validates and publishes the shared scenario graph.
234
+ Init also wires an existing `build:showcase` script; other preview build entry
235
+ points need the same checks explicitly. Build output and generated configuration/assets remain
236
+ separate from authored ADS source. Source assets and public asset mounts must
237
+ have distinct output paths; collisions fail validation.
238
+
239
+ ## Lint ownership
240
+
241
+ Core tooling owns reusable checks for token use, public imports, and style
242
+ ownership. It must remain usable with an empty ADS and without any particular
243
+ external component library.
244
+
245
+ The checks enforce the architecture's ownership boundaries:
246
+
247
+ | Boundary | Core enforcement |
248
+ |----------|------------------|
249
+ | Tokens and styles | Fixed token vocabulary, required definitions, declared value types and references, raw visual values, shared-token assignments, foundation import order, and component/pattern namespaces |
250
+ | Public API and dependencies | Consumers use public ADS imports; ADS implementations and showcase do not import application source; runtime code does not import showcase fixtures |
251
+ | Interaction policy | Primitive state variables stay inside components; non-state customization hooks require explicit registration |
252
+ | Renderer exceptions | Inline JSX styles and imperative style writes require narrow configured boundaries; public props omit inherited style and reject open-ended visual strings |
253
+ | Preview ownership | Scenarios define no CSS, custom classes, or native controls; all declared tokens and public renderable UI have reachable registered scenarios; token references must exist; legacy catalogue pages are checked when present |
254
+ | Assets | Source/public collisions and configured generated artifacts in source are rejected |
255
+
256
+ Document a new ownership exception with its guard/configuration change and
257
+ tests. Passing static checks establishes only the policies and source formats
258
+ they cover. Browser review and behavior tests still verify accessibility,
259
+ interaction, responsive layout, themes, and motion.
260
+
261
+ Component-specific usage rules belong to that component in the receiving
262
+ project. Import applicable rules with the item and register them through
263
+ project configuration or maintained tooling integration. Core tooling must
264
+ not hardcode imports from an external catalogue or assume Toast, Button, or a
265
+ particular shell is installed.
266
+
267
+ Register project plugins and rules in `ds.config.json` under `oxlint`. Use scoped
268
+ `oxlint.overrides` for file-specific rule settings. These settings configure
269
+ Oxlint; they do not disable the independent architecture checks in `ads check`.
270
+ Renderer property boundaries and documented component hooks use `boundaries`,
271
+ not broad rule suppression. See the [configuration guide](GUIDE.md#generic-architecture-guards).
272
+
273
+ Add a rule only for a concrete misuse that static analysis can establish.
274
+ Keep rule modules, generators, and test harnesses out of runtime exports.
275
+ Validate accepted and rejected cases, configuration, and false-positive limits.
276
+
277
+ ## Bootstrap and updates
278
+
279
+ Root [bootstrap-ds/](../bootstrap-ds/README.md) is the canonical empty scaffold.
280
+ Its identical copy under `skills/ads-designer/assets/bootstrap-ds/` makes the
281
+ skill self-contained. Run `npm run sync:skill-starter` after edits and
282
+ `npm run check:skill-starter` to verify the copy. Both contain empty component
283
+ and pattern directories, not a catalogue.
284
+
285
+ Tool releases should version contract changes, rules, skills, bootstrap support,
286
+ and migration guidance. Existing project implementations and external source
287
+ revisions have their own update lifecycle. Apply external changes through
288
+ explicit source imports or reviewed merges that preserve local customizations.
289
+
290
+ Validate the relevant tooling and scaffold changes. For imported items, run the
291
+ receiving project's lint, type checking, build, and meaningful behavior/rule
292
+ tests, plus browser comparisons where interaction or animation warrants them.
293
+ Do not require a particular component's tests in every project.
294
+
295
+ ## Current checkout
296
+
297
+ The root package builds the ADS tool from `src/`; its tests and dummy project
298
+ live under `tests/`. Runtime dependencies contain no React or UI library.
299
+ Dependencies for the working example are development-only. The package allowlist contains only
300
+ the CLI, core checks, MCP/Apps tooling and its browser client, skills, token contract, and empty scaffold. Packed-install tests
301
+ verify it runs in a clean project without this repository's UI implementation.
302
+
303
+ This repository's own design system lives in `design-system/` for proofs of
304
+ concept, showcase review, and integration tests. Its UI source, project-specific
305
+ scripts, and component registrations remain outside the published tool package.
306
+ Run `npm run build:project` for that implementation into `dist-project/` and
307
+ its shared preview graph into `.ds/preview/` and scenario descriptors into
308
+ `.ds/scenarios/`; `npm run build`
309
+ builds the tool into `dist/`. Core rule integration uses
310
+ explicit project configuration, with no imports from the local component catalogue.
@@ -0,0 +1,311 @@
1
+ # Architecture
2
+
3
+ ADS makes shared design standards a tooling contract while keeping UI source in
4
+ the project. Coding agents can build and evolve that source directly; the tools
5
+ keep changes within a defined architecture. The project owns its components,
6
+ patterns, token values, and branding.
7
+
8
+ This document explains the what, why, and high-level how. [ADS.md](ADS.md) defines
9
+ the enforceable contract, [GUIDE.md](GUIDE.md) covers tool integration, and the
10
+ [working example guide](../design-system/README.md) covers implementation details.
11
+
12
+ ## Shared tooling, project-owned design
13
+
14
+ The shared layer supplies architectural rules, token definitions, checks,
15
+ skills, and setup. Components, patterns, themes, and examples are authored in
16
+ the project or brought in through explicit imports and adaptations.
17
+
18
+ This lets standards evolve without tying the product's UI to a centrally
19
+ distributed component catalogue. A project can change its implementation,
20
+ branding, or external dependencies while retaining compatible contracts.
21
+ Tool updates preserve local values and customized source; content updates have
22
+ their own reviewed lifecycle.
23
+
24
+ ADS is opinionated about tooling and ownership. Linaria is required for the
25
+ component and pattern styling pipeline. Visual choices belong to the project.
26
+ The project declares React or native Preact in `ds.config.json` and uses the
27
+ matching compiler and mount adapter. Both integrate with the required styling
28
+ and validation pipeline; additional frameworks need explicit tooling support.
29
+
30
+ ADS checks run during development and builds. The tool adds no production UI
31
+ runtime. Its ownership boundaries preserve a project's optimization strategy:
32
+ lazy loading, code splitting, memoized data, caching, worker execution, and
33
+ cancellable work can remain behind public APIs. Sharing a screen pattern does
34
+ not require eager loading of its renderer or moving application services into
35
+ the ADS. Validate these properties when migrating an existing application.
36
+
37
+ ## Data, UX, and Skin
38
+
39
+ Every UI implementation has three cooperating responsibilities:
40
+
41
+ | Pillar | Defines | Implemented through | Result |
42
+ |--------|---------|---------------------|--------|
43
+ | **Data** | Design values, semantic roles, and their relationships | Shared token definitions with project-owned values and themes | A consistent visual vocabulary |
44
+ | **UX** | Structure, behavior, accessibility, states, and layout | Markup, interaction logic, and structural styles in components and patterns | Operable controls and reusable compositions |
45
+ | **Skin** | Visual identity and the appearance of each state or variant | Token-backed styles composed with the UX structure | The project's visual treatment |
46
+
47
+ The separation makes each decision's purpose clear while keeping related code
48
+ together. A button gets its dimensions and colors from Data, its native semantics
49
+ and focus behavior from UX, and its fills, borders, and typography from Skin.
50
+ A form group or application shell applies the same model to composition.
51
+
52
+ ### Data gives implementations a common language
53
+
54
+ Data includes both primitive values and semantic roles. A color ramp describes
55
+ available values; a surface or accent token describes their intended use.
56
+ Typography, spacing, elevation, and motion follow the same principle.
57
+
58
+ Projects share compatible token names, meanings, types, and relationships while
59
+ choosing their own values. Stable names let implementations move between
60
+ projects without importing an unrelated brand. Themes evolve by changing
61
+ values behind those names, and visual formulas have one source of truth.
62
+
63
+ ### UX owns the interaction contract
64
+
65
+ Components own control semantics, input handling, focus, accessibility, and
66
+ state mechanics. Patterns own reusable layout and composition. Application
67
+ containers provide domain data, routing, application effects, and callbacks through public
68
+ APIs.
69
+
70
+ The Data pillar describes design values; business data is a separate input to
71
+ the UX contract. Application adapters own live business-data loading,
72
+ authentication, stores, routing, caching and refresh policy. Components and
73
+ patterns receive typed inputs and callbacks. They may invoke an injected
74
+ callback or service to request work and present its loading/error state, while
75
+ the consumer retains ownership of the data source. They do not bind themselves
76
+ to a product backend or application provider.
77
+
78
+ UI mechanics remain with their owner: lazy implementation imports, asset
79
+ loading, measured geometry and cancellable layout workers are compatible with
80
+ this boundary. Separating business-data access does not require moving renderer
81
+ work into the application or sacrificing performance.
82
+
83
+ A visual change should preserve the interaction contract unless behavior is
84
+ deliberately changed. A disabled control remains disabled across skins; a field
85
+ keeps its label association and error semantics. Keeping this policy with its
86
+ owner prevents consumers from creating conflicting versions of the same UI.
87
+
88
+ ### Skin applies identity to that structure
89
+
90
+ Skin maps the visual vocabulary to the structure and its states. Visual
91
+ variants reuse the same UX implementation when their behavior is the same.
92
+
93
+ Broad identity changes flow through token values. Changes to a particular
94
+ control's treatment live with that control as a supported variant. Changes to
95
+ layout or interaction also involve UX. Some decisions span all three pillars:
96
+ motion uses Data for timing, UX for when transitions happen, and Skin for their
97
+ visual expression.
98
+
99
+ ## Linaria is the implementation mechanism
100
+
101
+ Linaria connects these responsibilities in the component and pattern styling
102
+ pipeline. The native Preact working example in `design-system/` and the empty React starter
103
+ in `bootstrap-ds/` implement that pipeline. Both are supported: the project
104
+ chooses its rendering runtime, while ADS checks the same architecture and serves
105
+ its actual compiled scenarios. A React application remains React; MCP does not
106
+ substitute a different runtime or a visual reproduction.
107
+
108
+ The choice serves both architecture and performance:
109
+
110
+ | Reason | How it supports ADS |
111
+ |--------|--------------------|
112
+ | **Colocation and ownership** | Structural UX styles, Skin styles, and modifiers remain distinct local blocks beside their behavior. A change has one reviewable owner. |
113
+ | **Explicit composition** | Atomic styles assemble a UX base, visual treatment, and size/state variants with precedence for matching declarations. Different visual variants can reuse the same UX implementation. |
114
+ | **Less browser work** | Style templates become CSS at build time, avoiding render-time CSS generation, serialization, and stylesheet injection for those styles. |
115
+ | **Independent CSS caching** | Extracted CSS can be delivered and cached separately from JavaScript. With stable content-hashed assets and suitable cache headers, unchanged CSS can be reused across code changes. |
116
+ | **Bundle optimization** | Colocated style dependencies and static extraction let build tooling analyze usage and remove unreachable code and styles. The result depends on references, extraction, and side-effect configuration. |
117
+ | **Declaration reuse** | Atomic extraction can deduplicate identical declarations across components and combinations, reducing repeated CSS. |
118
+ | **Token-driven themes** | The browser applies theme values to already compiled rules. Changing token values does not need a runtime CSS generator. |
119
+ | **Inspectable policy** | Source checks inspect Linaria templates alongside their owner for token use and ownership violations before bundling. |
120
+
121
+ Linaria's [colocation and extraction model](https://github.com/callstack/linaria/blob/master/docs/BENEFITS.md)
122
+ and [atomic composition model](https://github.com/callstack/linaria/blob/master/docs/ATOMIC_CSS.md)
123
+ support this combination of local ownership and compiled styling.
124
+
125
+ Airbnb's 2022 [migration report](https://medium.com/airbnb-engineering/airbnbs-trip-to-linaria-dc169230bd12)
126
+ provides practical evidence for this choice: performance was its leading
127
+ criterion, with separate CSS caching and colocated authoring among the benefits.
128
+ Its measurements describe Airbnb's workloads, not promised gains for ADS projects.
129
+
130
+ The requirement concerns how styling is authored and built; visual identity
131
+ belongs to the project. Foundation tokens and base document styles remain CSS.
132
+ “Zero runtime” describes CSS generation, not the whole component: rendering,
133
+ interaction, class composition, and dynamic values can still require JavaScript.
134
+ Colocation makes dependencies explicit; it does not by itself guarantee removal
135
+ of every unused variant. Atomic composition still requires care with the cascade.
136
+
137
+ Apply extraction to application and project preview builds, preserve intentional
138
+ foundation CSS, and inspect compiled output when performance matters. The
139
+ [implementation guide](../design-system/README.md#bundling-notes) covers these details.
140
+
141
+ ## Public APIs preserve the boundary
142
+
143
+ The application and project-owned preview scenarios consume a project's public ADS entry. Components
144
+ and patterns expose supported behavior and visual variants; internal styling
145
+ blocks and external implementation dependencies stay with their owner.
146
+
147
+ That boundary lets the project replace or adapt an implementation while
148
+ preserving compatible consumer APIs. Markup, accessibility, events, layout, and
149
+ motion still need verification when an implementation changes. Imported or
150
+ adapted source carries its credits and applicable notices in its local guide.
151
+
152
+ ## The showcase is the shared design workspace
153
+
154
+ Humans and coding agents inspect the same project through MCP. The showcase is
155
+ **a minimal shell plus an MCP client and Apps host**, shipped as development
156
+ tooling. Its header, section tabs, collapsible left menu, theme switch and preview
157
+ area stay neutral. The client discovers entries, invokes tools, forwards App
158
+ resource requests and subscribes to changes. It contains no project UI catalogue
159
+ or implementation imports.
160
+
161
+ The server supplies catalogues, discovered token scenarios, source guides, preview Apps,
162
+ build status and diagnostics. Agents connect over stdio; the browser uses a
163
+ loopback HTTP MCP endpoint in the same runtime. Both share one project-configured
164
+ compiler. Starting MCP starts the website; a browser-only command starts the same
165
+ runtime without stdio. Shutdown closes the website, connections and compiler.
166
+ Local and external compatible hosts load the same reusable preview App. The
167
+ browser host uses a separate-origin sandbox proxy around its opaque App iframe.
168
+ Project JavaScript, styles, fonts and UI run only inside that App; the outer
169
+ shell forwards resource bytes without applying project styles or executing its
170
+ runtime. This keeps the host neutral while compositions retain their full skin.
171
+
172
+ The project compiler publishes a versioned dependency graph: shared runtime and
173
+ foundation assets, plus independently addressable scenario modules. Inside the
174
+ App, a resource loader obtains the selected dependency closure through MCP,
175
+ verifies its content and mounts it using the project's framework adapter. Native
176
+ ES modules preserve shared runtime identity, cycles and live bindings. Switching
177
+ scenarios unmounts the previous view while keeping unchanged dependencies cached.
178
+ Persistence is a host lifecycle choice; a new external widget loads the same
179
+ resources independently. Resource sharing is scoped to an App instance.
180
+
181
+ ```mermaid
182
+ flowchart LR
183
+ Host[Minimal host: navigation and MCP client] --> Proxy[Separate-origin sandbox proxy]
184
+ Proxy --> App[Opaque App: loader and project preview]
185
+ App -->|resource reads via bridge| MCP[ADS MCP server]
186
+ MCP --> Graph[Compiled graph: runtime, CSS, fonts, scenarios]
187
+ ```
188
+
189
+ The shell belongs to tooling. Components, patterns, design values, scenario inputs
190
+ and the UI rendered inside Apps belong to the project. This keeps the tool useful
191
+ with an empty ADS while making every implementation addressable once its scenario
192
+ exists.
193
+
194
+ ### A preview scenario is the unit of review
195
+
196
+ A component export alone may need inputs, parent context, local state or callbacks
197
+ to produce useful UI. A scenario supplies that development context around the
198
+ real public implementation. It mounts independently, without opening a showcase
199
+ page or initializing the application's router, store or services first.
200
+
201
+ Scenarios and their fixtures live beside the tokens, component or pattern they exercise.
202
+ Token scenarios choose real token names and sample inputs; a project-owned
203
+ review pattern applies the foundation variables. The tool contains no project
204
+ token list, sample templates or assumed visual identity. A minimal foundation
205
+ scenario can inspect values before a project has any components.
206
+ Larger scenarios live under `composition/`. They use the same public screen
207
+ patterns as production: application adapters supply live data and effects;
208
+ scenario adapters supply fixture data, local state and simulated services.
209
+ Reassembling a second screen from shared primitives still allows design drift.
210
+
211
+ The server discovers one path-derived scenario registry. The showcase's four
212
+ sections—Tokens, Components, Patterns and Composition—browse that same registry
213
+ through MCP results. They do not initialize the entry or define
214
+ its UI. The host supplies theme and available space; the public implementation
215
+ supplies presentation. Several related public parts may share a scenario with
216
+ their required parent. Every declared token and every public renderable component
217
+ and pattern needs addressable coverage. Token references must exist in the real
218
+ foundation; claimed token/UI coverage must be reachable from the scenario entry.
219
+ Types, constants and utilities do not require UI scenarios.
220
+
221
+ After source changes, validation and compilation must both succeed before a new
222
+ graph becomes current. MCP announces build/resource updates. The built-in client
223
+ refreshes discovery and sends the current selection to the existing App, whose
224
+ loader mounts the new module graph. Failed builds retain the previous view with
225
+ visible stale diagnostics. Compilation remains necessary for TSX and Linaria;
226
+ there is one preview pipeline with automatic updates.
227
+
228
+ Scenario entries, adapters and fixtures are development source even when
229
+ colocated with production components. Runtime imports and public-barrel exports
230
+ cannot cross that boundary. Static checks require real public render references
231
+ reachable from the scenario entry; browser tests still verify mounting, states,
232
+ accessibility and visual parity.
233
+
234
+ The working example and starter build one shared multi-entry graph on first
235
+ preview demand, then reuse it across selections and unchanged restarts. Only the
236
+ selected scenario's static dependency closure loads in the App; dynamic imports
237
+ remain lazy. Production bundles, workers and cancellation stay project-owned.
238
+ The MCP server serves compiled bytes without evaluating project TSX. Compiler
239
+ adapters normalize each entry to mount/unmount, retaining native React or Preact
240
+ semantics; choosing a framework does not install one into the tooling host.
241
+
242
+ ## Build checks keep the architecture in place
243
+
244
+ The project build runs ADS checks before producing application or showcase
245
+ output. These checks enforce token use, source ownership, public imports,
246
+ showcase coverage, component state boundaries, and separation of runtime code from development
247
+ fixtures. Component-specific usage rules extend the shared checks when needed.
248
+
249
+ Static checks establish the policies and source formats they cover. Behavior
250
+ tests and browser review verify the resulting accessibility, layout, themes,
251
+ states, and motion. Both forms of verification support agent-driven iteration.
252
+
253
+ ## MCP makes the project ADS available to agents
254
+
255
+ The stdio server exposes the same token inspection and core architecture checks
256
+ as the CLI, alongside the project's public UI catalogue and source guides.
257
+ Bounded tools establish what exists; explicit resource reads provide detail.
258
+ Prompts and packaged skills explain how to reason through Data, UX and Skin and
259
+ how to inspect the real implementation before changing it.
260
+
261
+ Opt-in MCP editing makes validation part of the write operation. The agent sends
262
+ a Git unified diff for one logical ADS unit: its implementation and owned preview
263
+ context, or the shared token foundation. ADS resolves file ownership, reconstructs
264
+ candidate files locally and validates a temporary project copy with architecture
265
+ checks, registered lint rules and project validation scripts. This keeps edits
266
+ focused without requiring entire file bodies in model context. Peer units and
267
+ unrelated owners remain outside the selected unit's edit boundary. Shared foundation,
268
+ branding and guides have their own units. Project configuration, registered guards
269
+ and compiler integration form an explicit configuration unit; their proposed
270
+ settings pass the same mandatory validation. Binary assets can travel as Git patch
271
+ artifacts without entering model context, and compiler configuration changes
272
+ replace the managed process while retaining the MCP connection. Normal build gates
273
+ remain in place for source changes made through other editors; preview review remains
274
+ necessary after either editing path.
275
+
276
+ The architecture makes that inspection practical. A public export has an owning
277
+ source and addressable preview coverage. Token definitions expose its visual
278
+ vocabulary; local guides explain contracts when present. An agent can discover a
279
+ small set of relevant entities, read their source and mount a real scenario with
280
+ its fixture context. Humans can exercise the same entry in the showcase. This
281
+ keeps inspection connected to the implementation that will reach the application.
282
+
283
+ MCP provides a progressive interface to those sources: structured listings,
284
+ explicit detail reads, selectable workflows and rendered Apps where supported.
285
+ Reported revisions and diagnostics make preview freshness inspectable after a
286
+ change. Reading source, compiling it and interacting with it are separate forms
287
+ of evidence; source checks and metadata cannot establish visual or behavioral
288
+ correctness. Text/resource access and the normal showcase keep the workflow
289
+ usable when a client lacks experimental presentation capabilities.
290
+
291
+ Experimental MCP Apps are another development review surface. Token, component,
292
+ pattern and composition views are project-built scenarios with the project's
293
+ own extracted CSS and public implementations. A generic tool-owned definition
294
+ inspector remains available for token source/alias diagnostics, even if project
295
+ previews cannot compile; it does not substitute for token scenario coverage.
296
+ The server serves those artifacts; it does not interpret arbitrary component
297
+ code or introduce production UI dependencies. File-change notifications let
298
+ hosts refresh their views. An optional project-configured compiler watcher is
299
+ managed by MCP, giving clients one launch command while leaving preview builds
300
+ owned by the project. Structured build reports distinguish running compilers
301
+ from successful, current previews; diagnostics remain readable even when a host
302
+ does not forward notifications. Older clients retain tools/resources/prompts;
303
+ native skill discovery and Apps presentation depend on the host's capabilities.
304
+ Concrete setup and compatibility evidence belong in the [MCP guide](MCP.md).
305
+
306
+ For concrete instructions, use:
307
+
308
+ - [ADS tooling contract](ADS.md) for naming, ownership rules, updates, and lint responsibilities.
309
+ - [Tool guide](GUIDE.md) for prerequisites, supported formats, configuration, and build wiring.
310
+ - [Working example guide](../design-system/README.md) for Linaria composition, extraction, and project commands.
311
+ - Component-local READMEs for APIs, lifecycle, tests, and provenance.