@reqvire-org/ads 0.3.25 → 0.3.26
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.
- package/README.md +7 -5
- package/dist/bootstrap-ds/ADS.md +28 -30
- package/dist/bootstrap-ds/README.md +6 -6
- package/dist/bootstrap-ds/design-system/assets/brand/README.md +3 -2
- package/dist/boundaries.mjs +0 -3
- package/dist/check.mjs +15 -22
- package/dist/config.mjs +3 -7
- package/dist/contract-migration.mjs +2 -2
- package/dist/contracts.d.mts +0 -1
- package/dist/design-values.mjs +81 -0
- package/dist/evidence.mjs +1 -1
- package/dist/mcp/context.mjs +3 -3
- package/dist/mcp/prompts.mjs +4 -4
- package/dist/mcp/reports.mjs +101 -0
- package/dist/mcp/server.mjs +38 -3
- package/dist/paint-contracts.mjs +4 -5
- package/dist/preview-resources.mjs +1 -2
- package/dist/scenarios.mjs +14 -14
- package/dist/skills/README.md +7 -3
- package/dist/skills/ads-break-ui/SKILL.md +23 -13
- package/dist/skills/ads-break-ui/references/atomic-styles.md +9 -2
- package/dist/skills/ads-break-ui/references/behaviors.md +393 -0
- package/dist/skills/ads-break-ui/references/captures.md +1 -1
- package/dist/skills/ads-break-ui/references/contracts.md +18 -37
- package/dist/skills/ads-break-ui/references/design-data.md +91 -0
- package/dist/skills/ads-break-ui/references/evidence.md +4 -0
- package/dist/skills/ads-break-ui/references/guarded-editing.md +7 -11
- package/dist/skills/ads-break-ui/references/reporting.md +101 -0
- package/dist/skills/ads-break-ui/references/scenarios.md +9 -15
- package/dist/skills/ads-designer/SKILL.md +25 -15
- package/dist/skills/ads-designer/assets/bootstrap-ds/ADS.md +28 -30
- package/dist/skills/ads-designer/assets/bootstrap-ds/README.md +6 -6
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/brand/README.md +3 -2
- package/dist/skills/ads-designer/references/atomic-styles.md +9 -2
- package/dist/skills/ads-designer/references/behaviors.md +393 -0
- package/dist/skills/ads-designer/references/captures.md +1 -1
- package/dist/skills/ads-designer/references/contracts.md +18 -37
- package/dist/skills/ads-designer/references/design-craft.md +1 -1
- package/dist/skills/ads-designer/references/design-data.md +91 -0
- package/dist/skills/ads-designer/references/evidence.md +4 -0
- package/dist/skills/ads-designer/references/guarded-editing.md +7 -11
- package/dist/skills/ads-designer/references/mobile.md +1 -1
- package/dist/skills/ads-designer/references/reporting.md +101 -0
- package/dist/skills/ads-designer/references/scenarios.md +9 -15
- package/dist/skills/ads-import/SKILL.md +28 -17
- package/dist/skills/ads-import/references/atomic-styles.md +9 -2
- package/dist/skills/ads-import/references/behaviors.md +393 -0
- package/dist/skills/ads-import/references/branding.md +1 -1
- package/dist/skills/ads-import/references/captures.md +1 -1
- package/dist/skills/ads-import/references/contracts.md +18 -37
- package/dist/skills/ads-import/references/design-data.md +91 -0
- package/dist/skills/ads-import/references/evidence.md +4 -0
- package/dist/skills/ads-import/references/guarded-editing.md +7 -11
- package/dist/skills/ads-import/references/implementation.md +3 -2
- package/dist/skills/ads-import/references/reporting.md +101 -0
- package/dist/skills/ads-import/references/scenarios.md +9 -15
- package/dist/skills/ads-import/references/tokens.md +11 -9
- package/dist/skills/ads-motion/SKILL.md +22 -12
- package/dist/skills/ads-motion/references/atomic-styles.md +9 -2
- package/dist/skills/ads-motion/references/behaviors.md +393 -0
- package/dist/skills/ads-motion/references/captures.md +1 -1
- package/dist/skills/ads-motion/references/contracts.md +18 -37
- package/dist/skills/ads-motion/references/design-data.md +91 -0
- package/dist/skills/ads-motion/references/evidence.md +4 -0
- package/dist/skills/ads-motion/references/guarded-editing.md +7 -11
- package/dist/skills/ads-motion/references/reporting.md +101 -0
- package/dist/skills/ads-motion/references/scenarios.md +9 -15
- package/dist/skills/{ads-migrate → ads-port}/SKILL.md +58 -31
- package/dist/skills/ads-port/agents/openai.yaml +4 -0
- package/dist/skills/{ads-migrate → ads-port}/references/atomic-styles.md +9 -2
- package/dist/skills/ads-port/references/behaviors.md +393 -0
- package/dist/skills/{ads-migrate → ads-port}/references/captures.md +1 -1
- package/dist/skills/{ads-migrate → ads-port}/references/contracts.md +18 -37
- package/dist/skills/ads-port/references/design-data.md +91 -0
- package/dist/skills/{ads-migrate → ads-port}/references/evidence.md +4 -0
- package/dist/skills/{ads-migrate → ads-port}/references/guarded-editing.md +7 -11
- package/dist/skills/{ads-migrate → ads-port}/references/lint-and-docs.md +5 -0
- package/dist/skills/{ads-migrate → ads-port}/references/native-implementation.md +49 -15
- package/dist/skills/ads-port/references/reporting.md +101 -0
- package/dist/skills/{ads-migrate → ads-port}/references/scenarios.md +9 -15
- package/dist/skills/{ads-migrate → ads-port}/references/testing.md +11 -1
- package/dist/tokens.mjs +5 -8
- package/dist/unit-contracts.mjs +1 -8
- package/docs/ADS.md +42 -73
- package/docs/ARCHITECTURE.md +49 -20
- package/docs/BEHAVIORS.md +40 -38
- package/docs/CHANGELOG.md +23 -0
- package/docs/CONTRACTS.md +18 -37
- package/docs/GUIDE.md +21 -13
- package/docs/MCP.md +57 -10
- package/package.json +1 -1
- package/dist/scoped-tokens.mjs +0 -68
- package/dist/skills/ads-migrate/agents/openai.yaml +0 -4
- /package/dist/skills/{ads-migrate → ads-port}/references/cli.md +0 -0
- /package/dist/skills/{ads-migrate → ads-port}/references/layers.md +0 -0
- /package/dist/skills/{ads-migrate → ads-port}/references/review.md +0 -0
package/README.md
CHANGED
|
@@ -34,7 +34,9 @@ uses Preact. See [implementation support](docs/GUIDE.md#implementation-support).
|
|
|
34
34
|
- **Keep contracts explicit** for typed paint inputs, scoped data bindings and
|
|
35
35
|
declarative APIs, without adding ADS to production components.
|
|
36
36
|
- **Guide agents** with prompts and portable skills for building, importing,
|
|
37
|
-
|
|
37
|
+
porting, motion and UI stress testing.
|
|
38
|
+
- **Collect feedback** as local bug reports and feature requests with compact
|
|
39
|
+
evidence, deduplication and submission receipts.
|
|
38
40
|
|
|
39
41
|
See [using ADS through MCP](docs/GUIDE.md#use-ads-through-mcp) for the workflow and
|
|
40
42
|
[visual captures](docs/MCP.md#screenshots-and-candidate-comparison) for screenshot
|
|
@@ -238,13 +240,13 @@ app's bundler. With no icon source, generation is skipped. See the
|
|
|
238
240
|
Install skills with `npx skills`:
|
|
239
241
|
|
|
240
242
|
```sh
|
|
241
|
-
npx skills add reqvire-org/ads --skill ads-designer --skill ads-import --skill ads-
|
|
243
|
+
npx skills add reqvire-org/ads --skill ads-designer --skill ads-import --skill ads-port --skill ads-break-ui --skill ads-motion
|
|
242
244
|
```
|
|
243
245
|
|
|
244
246
|
For local development, install from this checkout:
|
|
245
247
|
|
|
246
248
|
```sh
|
|
247
|
-
npx skills add ./skills --skill ads-designer --skill ads-import --skill ads-
|
|
249
|
+
npx skills add ./skills --skill ads-designer --skill ads-import --skill ads-port --skill ads-break-ui --skill ads-motion
|
|
248
250
|
```
|
|
249
251
|
|
|
250
252
|
Acknowledgments: `ads-designer`'s craft/mobile guidance, `ads-break-ui`, and
|
|
@@ -256,7 +258,7 @@ notice beside its files.
|
|
|
256
258
|
|
|
257
259
|
- [ads-designer](skills/ads-designer/SKILL.md): start an ADS or build UI with your local ADS.
|
|
258
260
|
- [ads-import](skills/ads-import/SKILL.md): import external components, patterns, styles, token values, or brand artwork.
|
|
259
|
-
- [ads-
|
|
261
|
+
- [ads-port](skills/ads-port/SKILL.md): port library components into your ADS using shared tokens and primitives.
|
|
260
262
|
- [ads-break-ui](skills/ads-break-ui/SKILL.md): stress-test real components and patterns with difficult content.
|
|
261
263
|
- [ads-motion](skills/ads-motion/SKILL.md): implement, review, audit, or profile component animation.
|
|
262
264
|
|
|
@@ -308,7 +310,7 @@ The [dummy project](tests/fixtures/guard-project/README.md) tests the generic gu
|
|
|
308
310
|
There are two different starting points in this checkout:
|
|
309
311
|
|
|
310
312
|
- [bootstrap-ds/](bootstrap-ds/README.md) is an empty React application starter:
|
|
311
|
-
token defaults, build setup, empty product component folders, a
|
|
313
|
+
token defaults, build setup, empty product component folders, a development-only token review renderer, and a project preview compiler adapter. It is bundled with `ads-designer` so an agent can copy it when starting
|
|
312
314
|
from zero. `ads init` uses its empty foundation files when a project has no ADS.
|
|
313
315
|
- [design-system/](design-system/README.md) is this repository's working example,
|
|
314
316
|
with real components, patterns, and scenarios inspected through the built-in showcase. It demonstrates the architecture
|
package/dist/bootstrap-ds/ADS.md
CHANGED
|
@@ -34,18 +34,16 @@ Keep public exports in `design-system/index.ts`; consumers use its `@ds` alias.
|
|
|
34
34
|
Use semantic CSS tokens for visual values. Raw values belong in the token files.
|
|
35
35
|
Projects sharing this ADS use the same token names, meanings, and value types;
|
|
36
36
|
their concrete values and theme overrides can differ. Reuse existing local values
|
|
37
|
-
when importing components/patterns
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
`--ds-*`, patterns `--ux-*`, and the showcase `--showcase-*`; token files cannot
|
|
48
|
-
assign those local variables or override component state.
|
|
37
|
+
when importing components/patterns. Existing font, text, spacing and other roles
|
|
38
|
+
take precedence over divergent upstream constants. Add genuinely missing shared
|
|
39
|
+
decisions, and import source token values only when adopting that theme is requested.
|
|
40
|
+
Shared token names and prefixes follow the ADS contract. All design values live
|
|
41
|
+
in the shared foundation; reuse meaningful project roles before adding new ones.
|
|
42
|
+
Components own `--ds-*` mappings and runtime mechanics, patterns own `--ux-*`, and
|
|
43
|
+
the showcase owns `--showcase-*`. These variables consume shared Data; they do
|
|
44
|
+
not create independent token catalogues. Private value sheets and namespace
|
|
45
|
+
registrations are not supported. Shared token files cannot assign runtime state
|
|
46
|
+
variables. Every shared token needs a real sample in a shared token scenario.
|
|
49
47
|
|
|
50
48
|
Foundation roles are enforced by `foundation-role`, `foundation-selector` and
|
|
51
49
|
`foundation-import`, alongside the regular token checks. Shared definitions
|
|
@@ -107,7 +105,7 @@ The shell owns section tabs, collapsible navigation, theme controls and the App
|
|
|
107
105
|
slot. Components, patterns, token values, scenarios, fixtures and their Linaria
|
|
108
106
|
styles remain project-owned. Only the sandboxed App loads and applies project
|
|
109
107
|
runtime, CSS and fonts, through MCP resources. App presentation comes from the
|
|
110
|
-
selected compiled scenario; reusable review layouts live in public
|
|
108
|
+
selected compiled scenario; reusable review layouts live in development-only `review/` through its separate public entry. Do not recreate
|
|
111
109
|
production widgets inside the client or scenario.
|
|
112
110
|
|
|
113
111
|
There are four sections: Tokens, Components, Patterns and Composition. There are
|
|
@@ -129,25 +127,25 @@ Colocate development entries and fixture inputs:
|
|
|
129
127
|
design-system/
|
|
130
128
|
tokens/
|
|
131
129
|
typography.css
|
|
132
|
-
Typography.scenario.tsx
|
|
133
|
-
Typography.fixture.ts
|
|
130
|
+
Typography.ads.scenario.tsx
|
|
131
|
+
Typography.ads.fixture.ts
|
|
134
132
|
components/core/Button/
|
|
135
133
|
Button.tsx
|
|
136
|
-
|
|
137
|
-
fixture.ts
|
|
134
|
+
Button.ads.scenario.tsx
|
|
135
|
+
Button.ads.fixture.ts
|
|
138
136
|
patterns/Editor/
|
|
139
137
|
Editor.tsx
|
|
140
|
-
|
|
141
|
-
fixture.ts
|
|
138
|
+
Editor.ads.scenario.tsx
|
|
139
|
+
Editor.ads.fixture.ts
|
|
142
140
|
composition/Workspace/
|
|
143
|
-
|
|
144
|
-
fixture.ts
|
|
141
|
+
Workspace.ads.scenario.tsx
|
|
142
|
+
Workspace.ads.fixture.ts
|
|
145
143
|
showcase/mcp/ Project compiler adapter
|
|
146
144
|
main.tsx
|
|
147
145
|
```
|
|
148
146
|
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
Use `<Owner>.ads.scenario.tsx` and `<Owner>.ads.fixture.ts` for new entries.
|
|
148
|
+
The scenario exports a default independently mountable view and literal metadata
|
|
151
149
|
`export const scenario = { title: "Button states", covers: ["Button"] };`.
|
|
152
150
|
Token entries under the configured token directory declare
|
|
153
151
|
`export const scenario = { title: fixture.title, covers: ["TokenSamples"], samples: fixture.samples };`.
|
|
@@ -155,7 +153,7 @@ Token entries under the configured token directory declare
|
|
|
155
153
|
Its colocated fixture declares literal `samples: [{ token, property, probe }]`.
|
|
156
154
|
Each token must exist and have sample coverage; duplicate bindings, missing probes,
|
|
157
155
|
empty covers and value-only inspectors fail. The default entry passes the declared
|
|
158
|
-
samples to a rendered public
|
|
156
|
+
samples to a rendered public review renderer's `samples` prop. No token-name/property mapping
|
|
159
157
|
or sample values are embedded in the tool. Display values come from foundation CSS;
|
|
160
158
|
probes are isolated verification inputs owned by the fixture.
|
|
161
159
|
|
|
@@ -173,12 +171,12 @@ mandatory caller inputs or prior page initialization. Related parts may share a
|
|
|
173
171
|
scenario containing their required public parent. Larger composition scenarios
|
|
174
172
|
reuse production screen patterns; that screen reuse remains skill guidance.
|
|
175
173
|
|
|
176
|
-
IDs derive from the ADS-relative path: `components/core/Button/
|
|
177
|
-
`components/core/Button.scenario.tsx` both identify `components/core/Button`.
|
|
174
|
+
IDs derive from the ADS-relative path: `components/core/Button/Button.ads.scenario.tsx` and
|
|
175
|
+
`components/core/Button.ads.scenario.tsx` both identify `components/core/Button`.
|
|
178
176
|
Use one form per owner. Renaming moves the ID. No manually assigned ID or parallel
|
|
179
|
-
registry is maintained.
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
registry is maintained. New fixture files use `<Owner>.ads.fixture.ts`; extra development
|
|
178
|
+
adapters use `<Owner>.ads.helpers.ts`. An empty fixture is valid without inputs.
|
|
179
|
+
Keep all `.ads.` files outside production imports and exports.
|
|
182
180
|
|
|
183
181
|
`scenario-contract`, `scenario-render` and `scenario-coverage` checks require valid
|
|
184
182
|
entries and reachable public render references for every public renderable
|
|
@@ -189,7 +187,7 @@ mounting, correct props, every branch/state or visual parity. The older
|
|
|
189
187
|
|
|
190
188
|
`token-scenario-reference` rejects undeclared token names in metadata and reachable
|
|
191
189
|
inputs. `token-scenario-render` rejects claimed tokens with no reachable input
|
|
192
|
-
reference; `token-scenario-coverage` requires every discovered shared
|
|
190
|
+
reference; `token-scenario-coverage` requires every discovered shared token
|
|
193
191
|
to have coverage. A new or removed token therefore needs a scenario/fixture
|
|
194
192
|
update. All three are errors in `ads check`, run by `lint:ds` and the build.
|
|
195
193
|
Coverage is static reachability, not proof that every branch actually renders
|
|
@@ -58,18 +58,18 @@ files, and no separate project browser app to implement or rebuild.
|
|
|
58
58
|
|
|
59
59
|
The existing `tokens/Foundation.ads.scenario.tsx` and colocated fixture visually demonstrate all
|
|
60
60
|
starter token values. The fixture owns `{ token, property, probe }` bindings;
|
|
61
|
-
the
|
|
61
|
+
the development-only `TokenPreview` renderer, exported through `@ds/review`, owns their presentation and applies the real CSS
|
|
62
62
|
variables. Add/remove samples alongside token definitions. `ads check` rejects
|
|
63
63
|
missing coverage and invented names; the App verifies the declared CSS bindings
|
|
64
|
-
in the browser. Extend or replace the project-owned
|
|
64
|
+
in the browser. Extend or replace the project-owned review renderer as your tokens evolve.
|
|
65
65
|
`ads_prepare_token_samples` can prepare a fixture patch from explicit project
|
|
66
66
|
property/probe bindings. It preserves existing samples and reports unmapped tokens;
|
|
67
|
-
it does not guess how a new value should look.
|
|
68
|
-
|
|
67
|
+
it does not guess how a new value should look. Design values belong in the shared
|
|
68
|
+
foundation. Component/pattern variables map shared roles; they do not define
|
|
69
|
+
independent token catalogues. See [ADS.md](ADS.md).
|
|
69
70
|
|
|
70
71
|
Create a component under `design-system/components/`, export it through `@ds`,
|
|
71
|
-
and colocate
|
|
72
|
-
`<Owner>.fixture.ts`). Reusable compositions belong under `patterns/`; larger
|
|
72
|
+
and colocate `<Owner>.ads.scenario.tsx` plus `<Owner>.ads.fixture.ts`. Reusable compositions belong under `patterns/`; larger
|
|
73
73
|
scenarios live under `composition/`. Each entry mounts independently with its
|
|
74
74
|
fixture inputs and state/callback adapter. Use public ADS APIs and owned Linaria
|
|
75
75
|
styles, keeping business data/services in the application.
|
|
@@ -4,9 +4,10 @@ Keep original logos, app icons, and artwork variants here. This starter contains
|
|
|
4
4
|
no artwork. Record each asset's purpose, suitable backgrounds, usage, source
|
|
5
5
|
credits, and applicable licenses when adding it.
|
|
6
6
|
|
|
7
|
-
UI branding uses the
|
|
7
|
+
UI branding uses the project-owned shared roles in `tokens/`: change values such as
|
|
8
8
|
`--accent`, `--font-sans`, and `--radius-md`. Components own `--ds-*` variables;
|
|
9
|
-
patterns own `--ux-*`; the showcase owns
|
|
9
|
+
patterns and development review helpers own `--ux-*`; the showcase owns
|
|
10
|
+
`--showcase-*`. Do not introduce a
|
|
10
11
|
brand-prefixed token vocabulary or override component state variables.
|
|
11
12
|
|
|
12
13
|
Put licensed font files in `assets/fonts/` and their declarations in
|
package/dist/boundaries.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import ts from "typescript";
|
|
|
3
3
|
import { importedUiName } from "./ui-framework.mjs";
|
|
4
4
|
import { isInside, isStateVariable, isTestFile, isDevelopmentFile } from "./config.mjs";
|
|
5
5
|
import { isSharedToken } from "./token-policy.mjs";
|
|
6
|
-
import { scopedTokenOwner } from "./scoped-tokens.mjs";
|
|
7
6
|
import { runtimeBindingOwner } from "./unit-contracts.mjs";
|
|
8
7
|
|
|
9
8
|
export function projectCompilerOptions({ root, config, dsRoot }) {
|
|
@@ -63,8 +62,6 @@ export function checkComponentVariable(name, filename, options) {
|
|
|
63
62
|
const components = !development && isInside(path.join(dsRoot, "components"), filename);
|
|
64
63
|
const patterns = !development && isInside(path.join(dsRoot, "patterns"), filename);
|
|
65
64
|
const showcase = development;
|
|
66
|
-
const owned = scopedTokenOwner(options, name);
|
|
67
|
-
if (owned) return path.resolve(options.root, owned.file) === filename ? null : { rule: "token-ownership", message: `Define ${name} only in ${owned.file}, owned by ${owned.unit}. Consume it with var(); runtime geometry remains a separate styleWrites boundary.` };
|
|
68
65
|
if (runtimeBindingOwner(options, name)) return { rule: "binding-ownership", message: `${name} belongs to a declared runtime producer. Do not redefine instance bindings in CSS or arbitrary style objects.` };
|
|
69
66
|
if (isSharedToken(name)) return tokens ? null : { rule: "token-ownership", message: `Define ${name} in ADS tokens, not component, pattern, showcase, or app styles.` };
|
|
70
67
|
if (name.startsWith("--ux-")) return patterns || showcase ? null : { rule: "variable-ownership", message: "--ux-* variables belong to ADS patterns and showcase composition." };
|
package/dist/check.mjs
CHANGED
|
@@ -22,7 +22,7 @@ import { inspectStyleBoundaries, pointerCaptureAdvisories } from "./style-bounda
|
|
|
22
22
|
import { inspectBehaviors, inspectControllers } from "./behaviors.mjs";
|
|
23
23
|
import { numericCssUnit, tokenLengthLiteral } from "./css-values.mjs";
|
|
24
24
|
import { foundationDeclaration, foundationSelector } from "./foundation.mjs";
|
|
25
|
-
import {
|
|
25
|
+
import { inspectUnits } from "./units.mjs";
|
|
26
26
|
import { createAtomicCompositionReview } from "./atomic-composition.mjs";
|
|
27
27
|
import { createScenarioTrace } from "./scenario-trace.mjs";
|
|
28
28
|
import { createScenarioSlots } from "./scenario-slots.mjs";
|
|
@@ -30,6 +30,7 @@ import { createScenarioSelectors } from "./scenario-selectors.mjs";
|
|
|
30
30
|
import { architectureEvidence, failure } from "./evidence.mjs";
|
|
31
31
|
import { propertyRegistration } from "./property-registrations.mjs";
|
|
32
32
|
import { createLayerBoundaries, layerSourceFiles } from "./layers.mjs";
|
|
33
|
+
import { createDesignValues, inspectDesignAliases, isColorKeyword } from "./design-values.mjs";
|
|
33
34
|
|
|
34
35
|
const scenarioLayoutGuidance = "Put demo-only sizing and framing in the development-only review/ layer, imported through the separate review entry. Patterns are production UI. Keep required behavior in the runtime owner; add component props for deliberate product API needs.";
|
|
35
36
|
const inlineStyleGuidance = `Own visual styles in component/pattern Linaria. ${scenarioLayoutGuidance} Reserve inlineStyleFiles for documented measured geometry, not demo layout.`;
|
|
@@ -52,8 +53,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
52
53
|
diagnostics.push(...tokenInventory.diagnostics);
|
|
53
54
|
diagnostics.push(...inspectAssets(options));
|
|
54
55
|
const resolveImport = importResolver(options);
|
|
55
|
-
const
|
|
56
|
-
const scopedFiles = new Set(scoped.definitions.map(entry => path.resolve(root, entry.file)));
|
|
56
|
+
const units = inspectUnits(options);
|
|
57
57
|
const rootHtml = path.join(root, "index.html");
|
|
58
58
|
const files = [...new Set([...sourceFiles(sourceRoot), ...sourceFiles(dsRoot), ...(existsSync(rootHtml) ? [rootHtml] : [])])];
|
|
59
59
|
const boundaryFiles = [...config.inlineStyleFiles, ...config.boundaries.styleWrites.map(entry => entry.file)].map(file => path.resolve(root, file)).filter(file => existsSync(file) && statSync(file).isFile());
|
|
@@ -61,11 +61,11 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
61
61
|
const compiler = projectCompilerOptions(options);
|
|
62
62
|
const program = ts.createProgram(scriptFiles, { ...compiler, paths: { ...compiler.paths, [config.publicAlias]: [path.join(dsRoot, config.publicEntry)] }, allowJs: true, noResolve: true, noLib: true, types: [], target: ts.ScriptTarget.Latest, module: ts.ModuleKind.ESNext, jsx: ts.JsxEmit.Preserve });
|
|
63
63
|
const checker = program.getTypeChecker();
|
|
64
|
+
const designValues = createDesignValues(program,options);
|
|
64
65
|
const paintContracts = inspectPaintContracts(options);
|
|
65
66
|
diagnostics.push(...paintContracts.diagnostics);
|
|
66
67
|
const runtimeContracts = inspectRuntimeContracts(options, program);
|
|
67
68
|
diagnostics.push(...runtimeContracts.diagnostics);
|
|
68
|
-
for (const binding of runtimeContracts.bindings) if (scoped.definitions.some(entry=>entry.namespace.startsWith(binding.prefix)||binding.prefix.startsWith(entry.namespace))) diagnostics.push({file:binding.file,rule:"binding-collision",line:1,column:1,message:`Runtime family ${binding.variable} overlaps an owner-local design-token namespace. Keep instance bindings separate from token definitions.`});
|
|
69
69
|
const atomicCompositionReview = createAtomicCompositionReview(program, options);
|
|
70
70
|
const scenarioTrace = createScenarioTrace(program, options);
|
|
71
71
|
let scenarioSlot, scenarioSelector;
|
|
@@ -74,7 +74,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
74
74
|
}
|
|
75
75
|
const layers = createLayerBoundaries(program, options, report), layerStyles = [];
|
|
76
76
|
layers.inspectDependencies();
|
|
77
|
-
inspectTokenValueFlows(program, options, tokenInventory,
|
|
77
|
+
inspectTokenValueFlows(program, options, tokenInventory, units, report);
|
|
78
78
|
for (const file of layers.runtimeHelpers()) if (!files.includes(file)) files.push(file);
|
|
79
79
|
inspectStyleBoundaries(options, program, report);
|
|
80
80
|
inspectShowcasePages(options, program, resolveImport, report);
|
|
@@ -90,8 +90,8 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
90
90
|
css.walkAtRules(/^property$/i,rule=>{
|
|
91
91
|
const line=offset.line+(rule.source?.start.line??1)-1;
|
|
92
92
|
try{
|
|
93
|
-
const registration=propertyRegistration(rule),relative=
|
|
94
|
-
const owner=
|
|
93
|
+
const registration=propertyRegistration(rule),relative=units.relative(path.relative(root,file));
|
|
94
|
+
const owner=units.owner(relative),foundation=isInside(path.join(dsRoot,config.tokenDir),file);
|
|
95
95
|
if(foundation){
|
|
96
96
|
let defined=false;css.walkDecls(registration.name,()=>{defined=true;});
|
|
97
97
|
if(!isSharedToken(registration.name)||!declaredTokens.has(registration.name)||!defined||["base.css","fonts.css"].includes(path.basename(file)))throw new Error("Shared @property registrations belong beside their real token definitions in foundation value sheets, not base.css or fonts.css.");
|
|
@@ -100,8 +100,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
100
100
|
const violation=checkComponentVariable(registration.name,file,options);if(violation)throw new Error(violation.message);
|
|
101
101
|
}
|
|
102
102
|
for(const descriptor of rule.nodes??[])if(descriptor.type==="decl")for(const ref of references(descriptor.value)){
|
|
103
|
-
|
|
104
|
-
if(tokenOwner&&(tokenOwner.unit!==owner||!declaredTokens.has(ref.name))||!tokenOwner&&!/^(?:--ds-|--ux-|--showcase-)/.test(ref.name)&&(!isSharedToken(ref.name)||!declaredTokens.has(ref.name)&&!ref.fallback))throw new Error(`Invalid or cross-owner token reference ${ref.name} in registration metadata.`);
|
|
103
|
+
if(!/^(?:--ds-|--ux-|--showcase-)/.test(ref.name)&&(!isSharedToken(ref.name)||!declaredTokens.has(ref.name)&&!ref.fallback))throw new Error(`Invalid or cross-owner token reference ${ref.name} in registration metadata.`);
|
|
105
104
|
}
|
|
106
105
|
const previous=registeredProperties.get(registration.name);
|
|
107
106
|
if(previous&&(previous.owner!==owner||previous.signature!==registration.signature))throw new Error(`Conflicting @property registration for ${registration.name}; ${path.relative(root,previous.file)} already registers it. Keep one owner and identical descriptors across that owner's modules.`);
|
|
@@ -166,12 +165,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
166
165
|
for (const ref of references(decl.value)) {
|
|
167
166
|
const binding = runtimeBindingOwner(options, ref.name);
|
|
168
167
|
if (binding) {
|
|
169
|
-
if (
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
const owned = scopedTokenOwner(options, ref.name);
|
|
173
|
-
if (owned) {
|
|
174
|
-
if (scoped.inventory.owner(scoped.inventory.relative(path.relative(root, file))) !== owned.unit || !declaredTokens.has(ref.name)) report(file, "token-reference", `${ref.name} belongs to ${owned.unit}. Use shared tokens across owners; owner-local tokens must be defined and consumed by their owner.`, offset.line + decl.source.start.line - 1, decl.source.start.column);
|
|
168
|
+
if (units.owner(units.relative(path.relative(root, file))) !== binding.unit) report(file, "binding-ownership", `${ref.name} is an instance binding owned by ${binding.unit}, not a shared design token.`, offset.line + decl.source.start.line - 1, decl.source.start.column);
|
|
175
169
|
continue;
|
|
176
170
|
}
|
|
177
171
|
const local = /^(?:--ds-|--ux-|--showcase-)/.test(ref.name);
|
|
@@ -181,8 +175,10 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
181
175
|
}
|
|
182
176
|
if (fontDescriptor || propertyDescriptor) return; // Font metadata defines source assets, not token-backed UI styles.
|
|
183
177
|
const violations = new Set();
|
|
178
|
+
if(decl.value.includes("__ds_expression__"))violations.add("Cannot establish this interpolated design value from source. Use a source-resolvable shared token/mapping; unknown interpolation does not grant permission for private design values.");
|
|
184
179
|
valueParser(decl.value).walk((node) => {
|
|
185
180
|
if (node.type === "function" && node.value === "url") return false;
|
|
181
|
+
if (node.type === "word" && decl.prop.startsWith("--") && isColorKeyword(node.value)) violations.add("Component variables map shared Data; named colors also require shared tokens.");
|
|
186
182
|
if (node.type === "word" && (/^#[\da-f]{3,8}$/i.test(node.value) || tokenLengthLiteral(node.value) || ["s", "ms"].includes(numericCssUnit(node.value)))) violations.add("Use a token for colors, absolute/font-relative lengths (including ch), and durations. Unitless geometry and structural angle/viewport/container relationships remain valid.");
|
|
187
183
|
if (node.type === "function" && /^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|cubic-bezier)$/.test(node.value)) violations.add("Define color formulas and easing in tokens.");
|
|
188
184
|
if (node.type === "function" && /^(?:blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia)$/.test(node.value)) violations.add("Define visual filter effects in tokens.");
|
|
@@ -197,7 +193,6 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
197
193
|
const role = adsFileRole(file);
|
|
198
194
|
const roleExtension=role==="contract"?/\.[cm]?ts$/.test(file):["fixture","fixtures"].includes(role)?/\.(?:[cm]?[jt]sx?|json)$/.test(file):/\.[cm]?[jt]sx?$/.test(file);
|
|
199
195
|
if (role && (!["contract", "scenario", "fixture", "fixtures", "helpers", "test", "spec", "behavior.spec"].includes(role)||!roleExtension)) report(file, "development-role", `Unknown .ads. role or unsupported extension: ${role}. Use a TypeScript contract, a script scenario/fixture/helpers/test/behavior.spec, or JSON fixture; marking development code does not grant styling or mutation permissions.`);
|
|
200
|
-
if (scopedFiles.has(file)) { try{checkRegistrations(file,postcss.parse(readFileSync(file,"utf8"),{from:file}));}catch{/* Token inspection reports malformed sheets. */} continue; } // Closed definition-only contract checked by inspectTokens.
|
|
201
196
|
if (file.endsWith(".css") && isInside(path.join(dsRoot, config.tokenDir), file) && !isDevelopmentFile(file, options)) { checkCss(file, readFileSync(file, "utf8"), undefined, true); continue; }
|
|
202
197
|
if (file.endsWith(".html")) { inspectHtml(readFileSync(file, "utf8"), (rule, message, line) => report(file, rule, message, line)); continue; }
|
|
203
198
|
if (file.endsWith(".css")) {
|
|
@@ -306,10 +301,6 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
306
301
|
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) specifier = node.moduleSpecifier.text;
|
|
307
302
|
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword && node.arguments[0] && ts.isStringLiteral(node.arguments[0])) specifier = node.arguments[0].text;
|
|
308
303
|
if (specifier && importViolation(specifier, file, options, resolveImport)) nodeReport(node, "public-import", `Import through ${config.publicAlias}, not ADS implementation paths.`);
|
|
309
|
-
if (specifier) for (const target of resolveImport(specifier, file)) {
|
|
310
|
-
const tokenOwner = scoped.definitions.find(entry => path.resolve(root, entry.file) === target);
|
|
311
|
-
if (tokenOwner && scoped.inventory.owner(scoped.inventory.relative(path.relative(root, file))) !== tokenOwner.unit) nodeReport(node, "token-ownership", `Only ${tokenOwner.unit} imports its token sheet. Import the public component/pattern to consume its design.`);
|
|
312
|
-
}
|
|
313
304
|
if (specifier && resolveImport(specifier, file).some((target) => (specifier.startsWith(".") || existsSync(target)) && target.endsWith(".css") && isInside(root, target) && !isInside(dsRoot, target) && target !== path.join(sourceRoot, "app-mount.css") && !isInside(path.join(root, "node_modules"), target))) nodeReport(node, "style-ownership", "Imported project CSS belongs to ADS components, patterns, or the foundation. Only structural app-mount.css is allowed outside the ADS.");
|
|
314
305
|
if (specifier && appImportViolation(specifier, file, options, resolveImport)) nodeReport(node, "no-app-import", "ADS implementations and showcase fixtures must not import app code. Use public ADS APIs with local fixture data; keep application integration harnesses in application tests.");
|
|
315
306
|
if (specifier && showcaseImportViolation(specifier, file, options, resolveImport)) nodeReport(node, "showcase-import", "Showcase code and styles are development fixtures; runtime code must not import them.");
|
|
@@ -326,16 +317,18 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
326
317
|
}
|
|
327
318
|
if (ts.isTaggedTemplateExpression(node) && isLinariaTag(node.tag)) {
|
|
328
319
|
const template = node.template;
|
|
329
|
-
const
|
|
320
|
+
const texts = ts.isNoSubstitutionTemplateLiteral(template) ? [template.text] : template.templateSpans.reduce((prefixes,span)=>{const parts=designValues(span.expression);return prefixes.flatMap(prefix=>(parts.length?parts:["__ds_expression__"]).map(value=>prefix+value+span.literal.text)).slice(0,32);},[template.head.text]);
|
|
330
321
|
const position = source.getLineAndCharacterOfPosition(template.getStart(source) + 1);
|
|
331
|
-
checkCss(file, text, { line: position.line + 1, column: position.character + 1 });
|
|
322
|
+
for(const text of texts)checkCss(file, text, { line: position.line + 1, column: position.character + 1 });
|
|
332
323
|
}
|
|
333
324
|
ts.forEachChild(node, visit);
|
|
334
325
|
}
|
|
335
326
|
visit(source);
|
|
336
327
|
}
|
|
328
|
+
inspectDesignAliases(layerStyles,options,report);
|
|
337
329
|
// Bounded clients should see actionable warnings before source-analysis limits.
|
|
338
330
|
for (const { file, css, offset } of layerStyles) layers.inspectStyles(file, css, offset);
|
|
331
|
+
advisories.push(...(tokenInventory.advisories??[]));
|
|
339
332
|
advisories.sort((first, second) => Number(first.severity === "info") - Number(second.severity === "info"));
|
|
340
333
|
const uniqueDiagnostics=[...new Map(diagnostics.map(diagnostic=>[JSON.stringify([diagnostic.file,diagnostic.rule,diagnostic.line,diagnostic.column,diagnostic.message]),diagnostic])).values()];
|
|
341
334
|
return architectureEvidence({ ok: uniqueDiagnostics.length === 0, diagnostics:uniqueDiagnostics, ...(advisories.length ? { advisories } : {}) });
|
package/dist/config.mjs
CHANGED
|
@@ -160,10 +160,6 @@ export function isBehaviorFile(file) {
|
|
|
160
160
|
return /(?:^|[\\/])behavior\.json$|\.behavior\.json$/.test(file);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
export function isTokenManifestFile(file) {
|
|
164
|
-
return /(?:^|[\\/])tokens\.json$|\.tokens\.json$/.test(file);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
163
|
/** A visible development boundary, independent of whether its role is supported. */
|
|
168
164
|
export function adsFileRole(file) {
|
|
169
165
|
const match = path.basename(file).match(/\.ads\.(.+)\.[^.]+$/);
|
|
@@ -184,7 +180,7 @@ export function scenarioIdentity(file, dsRoot) {
|
|
|
184
180
|
export function isDevelopmentFile(file, { dsRoot }) {
|
|
185
181
|
if (!isInside(dsRoot, file)) return isTestFile(file) || adsFileRole(file) !== null;
|
|
186
182
|
const relative = path.relative(dsRoot, file).replaceAll("\\", "/");
|
|
187
|
-
return adsFileRole(file) !== null || isTestFile(file) || isScenarioFile(file) || isFixtureFile(file) || isBehaviorFile(file)
|
|
183
|
+
return adsFileRole(file) !== null || isTestFile(file) || isScenarioFile(file) || isFixtureFile(file) || isBehaviorFile(file)
|
|
188
184
|
|| /^(?:showcase|composition|review)\//.test(relative)
|
|
189
185
|
|| /(?:^|\/)(?:scenario|fixtures)(?:\/|$)/.test(relative)
|
|
190
186
|
|| /\.scenario(?:-adapter)?\.[cm]?[jt]sx?$/.test(relative);
|
|
@@ -192,7 +188,7 @@ export function isDevelopmentFile(file, { dsRoot }) {
|
|
|
192
188
|
|
|
193
189
|
/** Review implementations may own demo presentation; scenarios/fixtures may not. */
|
|
194
190
|
export function isReviewFile(file, { dsRoot }) {
|
|
195
|
-
return isInside(path.join(dsRoot, "review"), file) && adsFileRole(file) === null && !isTestFile(file) && !isScenarioFile(file) && !isFixtureFile(file) && !isBehaviorFile(file)
|
|
191
|
+
return isInside(path.join(dsRoot, "review"), file) && adsFileRole(file) === null && !isTestFile(file) && !isScenarioFile(file) && !isFixtureFile(file) && !isBehaviorFile(file);
|
|
196
192
|
}
|
|
197
193
|
|
|
198
194
|
const ignored = new Set(["node_modules", "dist", "dist-showcase", "dist-kit", ".git", ".vite", ".ds", "coverage"]);
|
|
@@ -204,7 +200,7 @@ export function sourceFiles(root) {
|
|
|
204
200
|
if (ignored.has(entry.name) || entry.isSymbolicLink()) continue;
|
|
205
201
|
const file = path.join(root, entry.name);
|
|
206
202
|
if (entry.isDirectory()) files.push(...sourceFiles(file));
|
|
207
|
-
else if (entry.isFile() && (/\.(css|html|[cm]?[jt]sx?)$/.test(entry.name) || isBehaviorFile(entry.name)
|
|
203
|
+
else if (entry.isFile() && (/\.(css|html|[cm]?[jt]sx?)$/.test(entry.name) || isBehaviorFile(entry.name))) files.push(file);
|
|
208
204
|
}
|
|
209
205
|
return files.sort();
|
|
210
206
|
}
|
|
@@ -39,7 +39,7 @@ export function migrateContractDraft(options, prepared) {
|
|
|
39
39
|
else renames.delete(fixture);
|
|
40
40
|
}
|
|
41
41
|
if(new Set(renames.values()).size!==renames.size)throw new Error("Migration has colliding development filenames; resolve the owner draft deliberately.");
|
|
42
|
-
const jsonFiles=owned.filter(
|
|
42
|
+
const jsonFiles=owned.filter(isBehaviorFile);
|
|
43
43
|
for(const [from,to]of renames)if(isScenarioFile(from)&&scenarioIdentity(path.join(options.root,from),options.dsRoot)!==scenarioIdentity(path.join(options.root,to),options.dsRoot)) {
|
|
44
44
|
const text=readFileSync(resolve(from),"utf8"),source=ts.createSourceFile(from,text,ts.ScriptTarget.Latest,true,ts.ScriptKind.TSX);
|
|
45
45
|
const declaration=source.statements.filter(ts.isVariableStatement).flatMap(statement=>statement.declarationList.declarations).find(declaration=>ts.isIdentifier(declaration.name)&&declaration.name.text==="scenario");
|
|
@@ -80,7 +80,7 @@ export function migrateContractDraft(options, prepared) {
|
|
|
80
80
|
}
|
|
81
81
|
const {schemaVersion:_version,...behavior}=value;contract.behavior={...behavior,subjects};remove.push(file);
|
|
82
82
|
}catch(error){notes.push(error.message);}
|
|
83
|
-
}
|
|
83
|
+
}
|
|
84
84
|
}
|
|
85
85
|
for(const file of files) {
|
|
86
86
|
if(!/\.[cm]?[jt]sx?$|\.json$|\.md$/.test(file)||remove.includes(file))continue;
|
package/dist/contracts.d.mts
CHANGED
|
@@ -3,7 +3,6 @@ export type Implementation = ((...args: never[]) => unknown) | (abstract new (..
|
|
|
3
3
|
export interface BehaviorCheck { file: string; case: string; scenario?: string; profile: string; }
|
|
4
4
|
export interface UnitContract {
|
|
5
5
|
schemaVersion: 1;
|
|
6
|
-
tokens?: { namespace: string; stylesheet: string };
|
|
7
6
|
paintInputs?: readonly { api: Implementation; property: string; kind: "paint-reference"; bindings?: readonly string[] }[];
|
|
8
7
|
bindings?: Readonly<Record<string, {
|
|
9
8
|
input: { api: Implementation; property: string };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { lexer, parse, generate } from "css-tree";
|
|
3
|
+
import valueParser from "postcss-value-parser";
|
|
4
|
+
import { isInside } from "./config.mjs";
|
|
5
|
+
import { createSourceValues, reference } from "./source-values.mjs";
|
|
6
|
+
|
|
7
|
+
const colorCache = new Map();
|
|
8
|
+
export function isColorKeyword(value) {
|
|
9
|
+
if (!/^[a-z]+$/i.test(value) || /^(?:currentcolor|transparent|none|inherit|initial|unset|revert)$/i.test(value)) return false;
|
|
10
|
+
const key=value.toLowerCase();
|
|
11
|
+
if(!colorCache.has(key))colorCache.set(key,!!lexer.matchType("color",key).matched);
|
|
12
|
+
return colorCache.get(key);
|
|
13
|
+
}
|
|
14
|
+
const refs = value => {
|
|
15
|
+
const names=[];
|
|
16
|
+
valueParser(value).walk(node=>{if(node.type==="function"&&node.value==="var"){const name=node.nodes.find(child=>child.type==="word")?.value;if(name?.startsWith("--"))names.push(name);}});
|
|
17
|
+
return names;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Resolve static interpolations through imports/local helpers; never execute project code. */
|
|
21
|
+
export function createDesignValues(program, options) {
|
|
22
|
+
const values=createSourceValues(program,options);
|
|
23
|
+
function strings(input, context=values.state()) {
|
|
24
|
+
const value=values.resolve(input,context);
|
|
25
|
+
if(value.kind==="literal")return ["string","number"].includes(typeof value.value)?[String(value.value)]:[];
|
|
26
|
+
if(value.kind==="union")return value.values.slice(0,16).flatMap(item=>strings(item,values.next(context)));
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
return expression => [...new Set(strings(reference(expression)))];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Variable names cannot conceal the typography/layering role of their consumer. */
|
|
33
|
+
export function inspectDesignAliases(styles, options, report) {
|
|
34
|
+
const declarations=[], roles=new Map(), protectedProperties=new Set(["font-family","font-weight","z-index"]);
|
|
35
|
+
const add=(name,role)=>{if(!roles.has(name))roles.set(name,new Set());const before=roles.get(name).size;roles.get(name).add(role);return roles.get(name).size!==before;};
|
|
36
|
+
for(const entry of styles) {
|
|
37
|
+
if(isInside(path.join(options.dsRoot,options.config.tokenDir),entry.file))continue;
|
|
38
|
+
entry.css.walkDecls(decl=>{
|
|
39
|
+
if(decl.parent.type==="atrule"&&decl.parent.name.toLowerCase()==="property")return;
|
|
40
|
+
declarations.push({...entry,decl});
|
|
41
|
+
if(protectedProperties.has(decl.prop))for(const name of refs(decl.value))add(name,decl.prop);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// A finite fixed point includes all alias/fallback branches and imported helper styles.
|
|
45
|
+
let changed=true;
|
|
46
|
+
while(changed){changed=false;for(const {decl} of declarations)for(const role of roles.get(decl.prop)??[])for(const name of refs(decl.value))changed=add(name,role)||changed;}
|
|
47
|
+
for(const {file,offset,decl} of declarations) {
|
|
48
|
+
const selected=protectedProperties.has(decl.prop)?new Set([decl.prop]):roles.get(decl.prop);
|
|
49
|
+
if(!selected)continue;
|
|
50
|
+
const nodes=valueParser(decl.value).nodes.filter(node=>!["space","comment"].includes(node.type));
|
|
51
|
+
function allowed(nodes){
|
|
52
|
+
nodes=nodes.filter(node=>!["space","comment"].includes(node.type));
|
|
53
|
+
if(nodes.length!==1)return false;
|
|
54
|
+
const [node]=nodes;
|
|
55
|
+
if(node.type==="word")return /^(?:inherit|initial|unset|revert(?:-layer)?|auto)$/.test(node.value);
|
|
56
|
+
if(node.type!=="function"||node.value!=="var"||node.unclosed)return false;
|
|
57
|
+
const parts=node.nodes.filter(node=>!["space","comment"].includes(node.type));
|
|
58
|
+
return parts[0]?.type==="word"&&/^--[\w-]+$/.test(parts[0].value)&&(parts.length===1||parts[1]?.type==="div"&&parts[1].value===","&&allowed(parts.slice(2)));
|
|
59
|
+
}
|
|
60
|
+
const valid=allowed(nodes);
|
|
61
|
+
if(!valid)report(file,"design-value-source",`${decl.prop} reaches ${[...selected].sort().join("/")}. Map it to shared Data with a token reference; a private variable or raw fallback cannot introduce independent typography/layering values.`,offset.line+decl.source.start.line-1,decl.source.start.column,{guidanceUri:"ads://guides/tokens"});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const canonical=value=>{try{return generate(parse(value,{context:"value"}));}catch{return value.trim();}};
|
|
66
|
+
/** Equal definitions invite review, not an automatic merge of different semantic roles. */
|
|
67
|
+
export function tokenOverlapAdvisories(tokens) {
|
|
68
|
+
const groups=new Map();
|
|
69
|
+
for(const token of tokens) {
|
|
70
|
+
if(token.owner!=="tokens"||!token.definitions.length)continue;
|
|
71
|
+
const definitions=token.definitions.map(({scope,value})=>[scope,canonical(value)]).sort(([a],[b])=>a.localeCompare(b));
|
|
72
|
+
if(definitions.every(([,value])=>/^var\(--[\w-]+\)$/.test(value))||definitions.every(([,value])=>/^(?:0|1|none|auto|inherit|initial|unset|transparent)$/.test(value)))continue;
|
|
73
|
+
const signature=JSON.stringify(definitions);
|
|
74
|
+
if(!groups.has(signature))groups.set(signature,[]);
|
|
75
|
+
groups.get(signature).push(token);
|
|
76
|
+
}
|
|
77
|
+
return [...groups.values()].filter(group=>group.length>1).map(group=>{
|
|
78
|
+
const [first]=group, {file,line,column}=first.definitions[0],names=group.map(token=>token.name);
|
|
79
|
+
return {rule:"token-overlap-review",severity:"warning",file,line,column,tokens:names,guidanceUri:"ads://guides/tokens",message:`Shared Data tokens have identical definitions across their declared theme/condition scopes: ${names.slice(0,6).join(", ")}${names.length>6?` and ${names.length-6} more`:""}. Review semantic roles and consumers before consolidating. Equal values do not prove equivalent purpose; preserve distinct roles or use an explicit shared alias when appropriate.`};
|
|
80
|
+
});
|
|
81
|
+
}
|
package/dist/evidence.mjs
CHANGED
|
@@ -12,7 +12,7 @@ export function acceptance(scope, passed, established, unverified) {
|
|
|
12
12
|
|
|
13
13
|
export function architectureEvidence(result) {
|
|
14
14
|
return { ...result,
|
|
15
|
-
diagnostics: result.diagnostics.map(diagnostic => ({ ...diagnostic, ...(/^(?:unit-contract|paint-.+|binding-.+|declarative-.+|development-role)$/.test(diagnostic.rule)&&!diagnostic.guidanceUri?{guidanceUri:"ads://guides/contracts"}:{}), failure: diagnostic.failure ?? failure("architecture", "source-analysis", diagnostic.rule) })),
|
|
15
|
+
diagnostics: result.diagnostics.map(diagnostic => ({ ...diagnostic, ...(["style-token","design-value-source","token-name","token-ownership"].includes(diagnostic.rule)&&!diagnostic.guidanceUri?{guidanceUri:"ads://guides/tokens"}:{}), ...(/^(?:unit-contract|paint-.+|binding-.+|declarative-.+|development-role)$/.test(diagnostic.rule)&&!diagnostic.guidanceUri?{guidanceUri:"ads://guides/contracts"}:{}), ...(["declarative-consumer","binding-producer","scenario-render","scenario-exercise","showcase-control"].includes(diagnostic.rule)?{reportingGuidanceUri:"ads://guides/reporting"}:{}), failure: diagnostic.failure ?? failure("architecture", "source-analysis", diagnostic.rule) })),
|
|
16
16
|
acceptance: acceptance("core-architecture", result.ok, result.ok ? ["core-source-guards"] : [], ["project-checks", "compiled-preview", "browser-behavior", "visual-parity", "accessibility-audit"]),
|
|
17
17
|
};
|
|
18
18
|
}
|
package/dist/mcp/context.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { projectGuideFiles } from "../project-documents.mjs";
|
|
|
5
5
|
|
|
6
6
|
export const GUIDE_URI = "ads://project/guide";
|
|
7
7
|
// Put the task triggers and entry path first: some hosts shorten server guidance.
|
|
8
|
-
export const serverInstructions = "Use ADS for UI work: components, patterns, controllers, hooks, tokens, themes, branding, layout, interaction, accessibility, motion and showcase review. Start with ads_status; if tools are not exposed, read ads://project/guide then ads://project/status. Use the returned projectRoot and commands. When ads_status.mutations.enabled, use ads_units and guarded ads_apply_patch for one owner; use ads_apply_transaction only for coupled owner patches. Find existing public UI with ads_catalog; discover its previews with ads_scenarios and open ads_show_scenario. Starting ADS also serves its built-in showcase: use ads_status.showcaseUrl for browser review instead of starting another runtime/compiler or project browser app. Read one relevant ADS skill before editing. Inspect the real preview, edit its owned source, check the build and review again. Scope source/guides to the project, its instruction ancestry and user-selected import/reference sources; broad searches of /mnt or home are not ADS discovery. Domain-model/requirements work is a separate project workflow. For requested visual evidence, use ads_capture or screenshot-enabled patch dry runs; read ads://guides/captures for named targets, image resources and the current/candidate lifecycle. For behavior work, read ads://guides/behaviors and use ads_behaviors/ads_verify: scenario exercises are demonstrations, and registered guarantees need current passing execution evidence. Execution replies are bounded summaries. Read only needed sections with ads_results(resultId, section, status, cursor); follow nextCursor without rerunning. For a failure, inspect its boundary and acceptance, then ads_investigate with the outcome's exact unit/check/runId; detail sections and artifacts load separately (ads://guides/evidence). Preserve valid APIs when source tracing is inconclusive. Use the configured project framework and declared dependencies; MCP hosts supply no ad hoc APIs. MCP source checks do not replace browser tests; direct edits still need project checks. Reading HTML is not rendering, and reading a skill is not native activation. A running watcher is not proof of current source: inspect ads_status.build or ads://project/build after edits. Notifications may not reach the agent. Only explicitly enabled mutation tools edit project-owned ADS units after validation. Checks and compiler commands come from validated project configuration, never an ad hoc command argument.";
|
|
8
|
+
export const serverInstructions = "Use ADS for UI work: components, patterns, controllers, hooks, tokens, themes, branding, layout, interaction, accessibility, motion and showcase review. Start with ads_status; if tools are not exposed, read ads://project/guide then ads://project/status. Use the returned projectRoot and commands. When ads_status.mutations.enabled, use ads_units and guarded ads_apply_patch for one owner; use ads_apply_transaction only for coupled owner patches. Find existing public UI with ads_catalog; discover its previews with ads_scenarios and open ads_show_scenario. Starting ADS also serves its built-in showcase: use ads_status.showcaseUrl for browser review instead of starting another runtime/compiler or project browser app. Read one relevant ADS skill before editing. Inspect the real preview, edit its owned source, check the build and review again. Scope source/guides to the project, its instruction ancestry and user-selected import/reference sources; broad searches of /mnt or home are not ADS discovery. Domain-model/requirements work is a separate project workflow. For requested visual evidence, use ads_capture or screenshot-enabled patch dry runs; read ads://guides/captures for named targets, image resources and the current/candidate lifecycle. For behavior work, read ads://guides/behaviors and use ads_behaviors/ads_verify: scenario exercises are demonstrations, and registered guarantees need current passing execution evidence. Execution replies are bounded summaries. Read only needed sections with ads_results(resultId, section, status, cursor); follow nextCursor without rerunning. For a failure, inspect its boundary and acceptance, then ads_investigate with the outcome's exact unit/check/runId; detail sections and artifacts load separately (ads://guides/evidence). Preserve valid APIs when source tracing is inconclusive. After targeted investigation, record suspected ADS defects with ads_report_bug or missing capabilities with ads_request_feature; read ads://guides/reporting. These are local untriaged reports, not established causes or upstream issues. Use the configured project framework and declared dependencies; MCP hosts supply no ad hoc APIs. MCP source checks do not replace browser tests; direct edits still need project checks. Reading HTML is not rendering, and reading a skill is not native activation. A running watcher is not proof of current source: inspect ads_status.build or ads://project/build after edits. Notifications may not reach the agent. Only explicitly enabled mutation tools edit project-owned ADS units after validation. Checks and compiler commands come from validated project configuration, never an ad hoc command argument.";
|
|
9
9
|
|
|
10
10
|
function manager(root, pkg) {
|
|
11
11
|
if (typeof pkg.packageManager === "string") return pkg.packageManager.split("@")[0];
|
|
@@ -36,7 +36,7 @@ export function workflow(previews) {
|
|
|
36
36
|
next: "Find the requested public UI with ads_catalog (query + kind + small limit), then read its source/guide and one selected ADS skill. For a broad UI request, inspect the public barrel and targeted application entry files in sourceRoot.",
|
|
37
37
|
skills: [
|
|
38
38
|
{ task: "Build, refine or debug UI using the project ADS", name: "ads-designer" },
|
|
39
|
-
{ task: "Adapt a component-library reference", name: "ads-
|
|
39
|
+
{ task: "Adapt a component-library reference", name: "ads-port" },
|
|
40
40
|
{ task: "Import from another project's design-system", name: "ads-import" },
|
|
41
41
|
{ task: "Implement or review motion", name: "ads-motion" },
|
|
42
42
|
{ task: "Stress-test layout, states and interactions", name: "ads-break-ui" },
|
|
@@ -57,7 +57,7 @@ Use this server for UI components/patterns, tokens/themes/branding, layout, inte
|
|
|
57
57
|
3. Select one workflow with ads_skills, then ads_read_skill. ${route.skills.map((skill) => `${skill.task}: ${skill.name}`).join("; ")}. Native skill activation is host-controlled. Relative skill references resolve from its SKILL.md URI. Read support files only when relevant.
|
|
58
58
|
4. ${route.preview} Token samples: ads_scenarios(kind: tokens), then ads_show_scenario or ads_show_tokens(category: id). Token source inspection: ads_tokens with a focused query. Registered previews: ${previews.map((preview) => `${preview.id}: ${preview.tool ?? "ads_show_scenario"}`).join(", ") || "none"}. Showcase URL: ${context.showcase.url ?? "not configured; use the project's showcase command"}.
|
|
59
59
|
Inspection connects a public export to its owning source, available guides, token values and discovered preview IDs. Bounded tools keep discovery focused; explicit resource reads supply detail. Source metadata does not prove layout, interaction or motion. A scenario renders the real public implementation and its fixture context in either review surface.
|
|
60
|
-
5. Check ads_status.mutations. When enabled, discover one owner with ads_units, read relevant source ranges with ads_read_file and submit only a Git unified diff through ads_apply_patch({unit, patch, dryRun}). Include that owner's scenarios, fixtures and required public re-exports, never peer units. tokens is the foundation unit; its manifest lists companionFiles for required canonical foundation imports when token files are created/deleted in the same patch. Preserve unrelated imports/comments and public-entry statements; a real selected-owner re-export can remove its redundant export {};. Dry-run to inspect validation; apply only a passing patch. Fix rejected patches in the owning unit; use ads_apply_transaction for coupled owners instead of bypassing rejection with direct writes. ads_prepare_patch creates a local owner draft/diff; ads_prepare_token_samples reconciles explicit project bindings without guessing visual meaning. Intentional project setup, registered guard/compiler code and exceptions use configuration; shared globals use foundation, guides documentation and assets their discovered assets/* unit. Keep mandatory ADS gates. Binary/large Git diffs may use patchFile under .ds/patches/ to avoid model-context bytes. In read-only mode, source edits use the client editor/filesystem tools. Reuse the local public API (${context.publicEntry}). Edit presentation in its ADS owner; keep application data/services/routing in application code and development fixtures beside their scenario; larger scenarios live in composition/. Demo framing and token renderers live in development-only review/, imported through ${context.review.importFrom}; never export them from the production barrel or import them into application runtime. Read ads://guides/review for review owners/aliases and ads://guides/contracts when editing static owner declarations, .ads. development roles, constrained paints/bindings or declarative APIs. Contract registration, source evidence and browser verification remain separate. Use ads_prepare_patch action: migrate for a reviewable owner draft, then normal diff and guarded application. Linaria extracts owned styling. Inspect relevant tokens with ads_tokens and source/owning guides before edits.
|
|
60
|
+
5. Check ads_status.mutations. When enabled, discover one owner with ads_units, read relevant source ranges with ads_read_file and submit only a Git unified diff through ads_apply_patch({unit, patch, dryRun}). Include that owner's scenarios, fixtures and required public re-exports, never peer units. tokens is the foundation unit; its manifest lists companionFiles for required canonical foundation imports when token files are created/deleted in the same patch. Preserve unrelated imports/comments and public-entry statements; a real selected-owner re-export can remove its redundant export {};. Dry-run to inspect validation; apply only a passing patch. Fix rejected patches in the owning unit; use ads_apply_transaction for coupled owners instead of bypassing rejection with direct writes. ads_prepare_patch creates a local owner draft/diff; ads_prepare_token_samples reconciles explicit project bindings without guessing visual meaning. Intentional project setup, registered guard/compiler code and exceptions use configuration; shared globals use foundation, guides documentation and assets their discovered assets/* unit. Keep mandatory ADS gates. Binary/large Git diffs may use patchFile under .ds/patches/ to avoid model-context bytes. In read-only mode, source edits use the client editor/filesystem tools. Reuse the local public API (${context.publicEntry}). Edit presentation in its ADS owner; keep application data/services/routing in application code and development fixtures beside their scenario; larger scenarios live in composition/. Demo framing and token renderers live in development-only review/, imported through ${context.review.importFrom}; never export them from the production barrel or import them into application runtime. Read ads://guides/review for review owners/aliases and ads://guides/contracts when editing static owner declarations, .ads. development roles, constrained paints/bindings or declarative APIs. Contract registration, source evidence and browser verification remain separate. Use ads_prepare_patch action: migrate for a reviewable owner draft, then normal diff and guarded application. Shared foundation Data is the only design-value catalogue. Components/patterns map shared roles; independent owner token namespaces and value sheets are rejected. Existing project font, text and spacing roles take precedence over divergent upstream constants. Read ads://guides/tokens for the source contract and overlap review. Linaria extracts owned styling. Inspect relevant tokens with ads_tokens and source/owning guides before edits.
|
|
61
61
|
6. ${route.validation} Registered commands: ${context.commands.map((command) => command.args?.join(" ") ?? `choose the project package manager for ${command.script}`).join("; ") || "none discovered; inspect the project's build setup"}. Run them from ${context.projectRoot}.
|
|
62
62
|
Execution replies from ads_verify and guarded edits contain counts, acceptance and resultId, not full reports. Read only needed outcomes/diagnostics/captures with ads_results, following nextCursor with identical filters. A truncated row has recordIndex for bounded text ranges. For one failure, use ads_investigate with its unit/check/runId; read request/error/artifact sections only when needed. Only the latest verification and mutation results, and latest investigation per check, are available. Notifications do not establish freshness.
|
|
63
63
|
|
package/dist/mcp/prompts.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export const reasoning = `ADS is development tooling. The project owns its components, patterns, token values and branding.
|
|
2
|
-
Start with ads_status and use its projectRoot, workflow and project commands; the MCP workspace may be nested inside the client repository. If ADS tools are not exposed, read ads://project/guide then ads://project/status. Find existing public UI with ads_catalog and load one relevant ADS workflow via ads_skills/ads_read_skill. UI implementation/refinement uses ads-designer; library adaptation ads-
|
|
3
|
-
When ads_status.mutations.enabled, discover one owner with ads_units, read relevant ranges with ads_read_file and send only a Git unified diff through ads_apply_patch({unit,patch,dryRun}). A unit includes its own scenarios/fixtures; imported peers remain separate. tokens is the token foundation unit. Only that owner's public re-exports may change in the shared entry; preserve unrelated statements
|
|
4
|
-
Reason through Data (design-token values, semantic roles and relationships), UX (structure, behavior, accessibility, states and layout), and Skin (token-backed identity and visual states). Business data is a separate application-owned input, supplied through typed props or injected callbacks/services. The project uses Linaria extraction for owned styles; MCP adds no production runtime.
|
|
2
|
+
Start with ads_status and use its projectRoot, workflow and project commands; the MCP workspace may be nested inside the client repository. If ADS tools are not exposed, read ads://project/guide then ads://project/status. Find existing public UI with ads_catalog and load one relevant ADS workflow via ads_skills/ads_read_skill. UI implementation/refinement uses ads-designer; library adaptation ads-port; ADS transfer ads-import; motion ads-motion; stress testing ads-break-ui. Domain-model workflows are separate. Inspect the relevant public API, local guide, token definitions and real showcase fixture before proposing changes. Keep source/instruction discovery scoped to the target project, ancestry and selected external sources; broad scans of /mnt or home are not needed to discover this ADS.
|
|
3
|
+
When ads_status.mutations.enabled, discover one owner with ads_units, read relevant ranges with ads_read_file and send only a Git unified diff through ads_apply_patch({unit,patch,dryRun}). A unit includes its own scenarios/fixtures; imported peers remain separate. tokens is the token foundation unit. Only that owner's public re-exports may change in the shared entry; preserve unrelated statements. A real re-export may replace a redundant export {}; placeholder; do not add empty exports. Token manifests list companionFiles: include required foundation import changes only for canonical token files created/deleted in the same patch, preserving other imports/comments and canonical order. Use dryRun to review validation. Rejected patches leave source unchanged; fix diagnostics rather than bypassing checks with direct writes. Shared globals use foundation; guides use documentation; assets use discovered assets/* units. Intentional configuration, registered project guards/builders and rule exceptions use configuration, which validates the proposed settings and refreshes its compiler. Keep mandatory ADS gates. For large/binary diffs, pass patchFile pointing to .ds/patches/<name>.patch rather than loading bytes into context; Git binary patches require installed Git. When editing is disabled, use local editing tools.
|
|
4
|
+
Reason through Data (design-token values, semantic roles and relationships), UX (structure, behavior, accessibility, states and layout), and Skin (token-backed identity and visual states). Business data is a separate application-owned input, supplied through typed props or injected callbacks/services. Shared foundation Data is the only design-value catalogue. Components map it with --ds-* and patterns/review with --ux-*; there are no independent owner token namespaces or value sheets. Reuse project font, text and spacing roles when upstream constants differ. Read ads://guides/tokens for source boundaries and duplication review. The project uses Linaria extraction for owned styles; MCP adds no production runtime.
|
|
5
5
|
Choose an existing public component or pattern first. Keep application data/routing/effects in the application and fixture data/state beside its scenario. Change presentation in its owning ADS implementation, then demonstrate the same public API in the showcase. Put demo-only sizing and framing in a development-only review/ helper, exported through the separate review entry rather than the production barrel; add component props for deliberate runtime API needs and preserve required behavior. Do not create a widget-only replica or override component internals.
|
|
6
6
|
For token source inspection, call ads_tokens with a focused query. For token samples, components, patterns and composition, use ads_scenarios to select a path-derived id and invoke ads_show_scenario. Showcase and MCP mount that exact entry and its colocated fixture; no page initialization is required. The showcase is a minimal tool-owned shell plus an MCP client and Apps host. Its menus come from tools; it invokes the same entry tools and refreshes the active scenario through notifications. The reusable App loads framework runtime, foundation CSS, fonts and selected modules via MCP resources inside its sandbox. Keep project execution and styles out of the outer host; preserve mount/unmount cleanup and lazy dependencies. Use the existing ads_status showcase URL, or ads showcase when no MCP runtime is connected. Projects supply scenarios/fixtures and the compiler, not browser page files or another shell. Tool metadata selects an MCP App; a resources/read of HTML alone is not proof of rendered UI. If the host has no Apps view, give the configured showcase URL and use text/resources.
|
|
7
7
|
Check ads_status.previewWatch before launching a separate preview builder. A configured watcher is managed by ads mcp. Check ads_status.build or ads://project/build after changes: running does not mean ready, and unreported freshness is not evidence of current source. Reported preview failures include structured diagnostics; fix the owning source and wait for a successful rebuild, then invoke the preview tool again. Notifications may not reach the agent, so read status explicitly. Build revisions identify reported compilation attempts, not proof of runtime/visual correctness. Do not invent replacement UI to bypass a failed preview.
|
|
8
8
|
Skills: use ads_skills to select a workflow and read its SKILL.md with ads_read_skill. Resolve relative supporting files from that skill URI. Reading instructions does not prove native skill activation or authorize unrelated actions.
|
|
9
|
-
Ask for missing intent only when it changes the outcome. State the proposed behavior, states and difficult content. Preserve lazy loading, workers, caches, cancellation, reduced motion, focus and keyboard behavior. For controllers and hooks, read ads://guides/behaviors. Discover guarantees/checks with ads_behaviors and run ads_verify; read current execution evidence. Keep
|
|
9
|
+
Ask for missing intent only when it changes the outcome. State the proposed behavior, states and difficult content. Preserve lazy loading, workers, caches, cancellation, reduced motion, focus and keyboard behavior. For controllers and hooks, read ads://guides/behaviors. Discover guarantees/checks with ads_behaviors and run ads_verify; read current execution evidence. Keep <Owner>.ads.contract.ts, marked scenarios/fixtures and checks development-only. Use the configured framework and declared dependencies, not MCP host globals. Preserve covers for rendered UI; exercises links behavioral APIs to demonstrations, not passing guarantees. Run ads_check plus the project's registered lint, typecheck, build and relevant tests; inspect the actual browser/rendered app at narrow and wide sizes in both themes. Static success does not establish visual or interaction parity.`;
|
|
10
10
|
|
|
11
11
|
export function promptDefinitions(skills) {
|
|
12
12
|
const prompts = [
|