@reqvire-org/ads 0.3.24 → 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/behaviors.mjs +6 -4
- 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 +3 -3
- package/dist/contracts.d.mts +2 -3
- package/dist/declarative-flow.mjs +144 -0
- package/dist/design-values.mjs +81 -0
- package/dist/evidence.mjs +1 -1
- package/dist/mcp/catalog.mjs +4 -2
- 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/runtime-contracts.mjs +26 -37
- package/dist/scenario-trace.mjs +47 -18
- package/dist/scenarios.mjs +15 -15
- package/dist/skills/README.md +7 -3
- package/dist/skills/ads-break-ui/SKILL.md +24 -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 +61 -40
- 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 +26 -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 +61 -40
- 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 +29 -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 +61 -40
- 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 +23 -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 +61 -40
- 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 +59 -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 +61 -40
- 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/source-values.mjs +3 -3
- package/dist/tokens.mjs +5 -8
- package/dist/unit-contracts.mjs +24 -12
- package/docs/ADS.md +42 -73
- package/docs/ARCHITECTURE.md +54 -20
- package/docs/BEHAVIORS.md +46 -36
- package/docs/CHANGELOG.md +34 -0
- package/docs/CONTRACTS.md +67 -39
- package/docs/GUIDE.md +21 -13
- package/docs/MCP.md +67 -11
- 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/behaviors.mjs
CHANGED
|
@@ -15,7 +15,7 @@ const id = z.string().regex(/^[a-zA-Z0-9][\w.-]{0,99}$/);
|
|
|
15
15
|
const reference = z.string().min(1).max(500);
|
|
16
16
|
const subject = z.union([
|
|
17
17
|
z.object({ api: reference }).strict(),
|
|
18
|
-
z.object({ source: reference, symbol: reference.optional() }).strict(),
|
|
18
|
+
z.object({ source: reference, symbol: reference.optional(), role:z.enum(["controller","implementation"]).optional() }).strict(),
|
|
19
19
|
]);
|
|
20
20
|
export const behaviorSchema = z.object({
|
|
21
21
|
schemaVersion: z.literal(1),
|
|
@@ -92,7 +92,9 @@ export function inspectBehaviors(options, suppliedProgram, suppliedRegistry) {
|
|
|
92
92
|
for(const entry of [...Object.values(declaration?.bindings??{}),...(declaration?.declarativeParts??[])])for(const name of entry.checks) {
|
|
93
93
|
const check=value.checks[name],scenario=check&&scenarios.find(scenario=>scenario.id===check.scenario);
|
|
94
94
|
const parent=entry.parentName??entry.scope.apiName;
|
|
95
|
-
|
|
95
|
+
const roots=entry.rootNames??[parent];
|
|
96
|
+
const nested=declaration?.declarativeParts?.some(part=>part.apiName===parent);
|
|
97
|
+
if(!check||config.mcp.behaviorProfiles[check.profile]?.mode!=="browser"||!roots.some(root=>scenario?.covers.includes(root))||entry.parentName&&(!scenario?.exercises?.includes(entry.apiName)||nested&&!scenario?.exercises?.includes(parent)))report(`Required contract check ${name} must use a browser profile and a scenario covering a rendering root (${roots.join(", ")||parent})${entry.parentName?` and exercising ${entry.apiName}${nested?` through ${parent}`:""}`:""}. Source registration does not establish rendered behavior.`);
|
|
96
98
|
if(!value.guarantees.some(guarantee=>guarantee.checks.includes(name)))report(`Required contract check ${name} must back a named guarantee, not remain an unclaimed execution.`);
|
|
97
99
|
}
|
|
98
100
|
contracts.push({ ...value, unit, file: relative(file), demonstrations: Object.fromEntries(Object.entries(value.subjects).filter(([, item]) => item.api).map(([name, item]) => [name, scenarios.filter(scenario => scenario.exercises?.includes(item.api)).map(scenario => scenario.id)])) });
|
|
@@ -107,7 +109,7 @@ export function inspectControllers(options, program, report, contracts = []) {
|
|
|
107
109
|
const pkg = existsSync(path.join(root, "package.json")) ? JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")) : {};
|
|
108
110
|
const declared = new Set(Object.keys({ ...pkg.dependencies, ...pkg.devDependencies, ...pkg.peerDependencies, ...pkg.optionalDependencies }));
|
|
109
111
|
const privateFiles = new Map();
|
|
110
|
-
for (const contract of contracts) for (const subject of Object.values(contract.subjects).filter(item => item.source)) {
|
|
112
|
+
for (const contract of contracts) for (const subject of Object.values(contract.subjects).filter(item => item.source&&item.role!=="implementation")) {
|
|
111
113
|
const file = path.resolve(root, path.dirname(contract.file), subject.source);
|
|
112
114
|
if (!privateFiles.has(file)) privateFiles.set(file, new Set());
|
|
113
115
|
privateFiles.get(file).add(subject.symbol ?? null);
|
|
@@ -119,7 +121,7 @@ export function inspectControllers(options, program, report, contracts = []) {
|
|
|
119
121
|
const wholeFile = isInside(path.join(dsRoot, "controllers"), file) || privateFiles.get(file)?.has(null);
|
|
120
122
|
const subjects = wholeFile ? [] : checker.getSymbolsInScope(source, ts.SymbolFlags.Value).filter(symbol => privateFiles.get(file)?.has(symbol.name)).flatMap(symbol => symbol.declarations ?? []);
|
|
121
123
|
const headless = node => wholeFile || subjects.some(subject => subject.getSourceFile() === source && node.pos >= subject.pos && node.end <= subject.end);
|
|
122
|
-
function emit(node, rule, message) { const p = source.getLineAndCharacterOfPosition(node.getStart()); report(file, rule, message, p.line + 1, p.character + 1); }
|
|
124
|
+
function emit(node, rule, message) { const p = source.getLineAndCharacterOfPosition(node.getStart()); report(file, rule, message+(rule==="controller-skin"&&!isInside(path.join(dsRoot,"controllers"),file)?' An intentional visual behavior subject can declare role: "implementation"; controller subjects remain headless.':""), p.line + 1, p.character + 1); }
|
|
123
125
|
function visit(node) {
|
|
124
126
|
let specifier;
|
|
125
127
|
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier)) specifier = node.moduleSpecifier.text;
|
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");
|
|
@@ -75,12 +75,12 @@ export function migrateContractDraft(options, prepared) {
|
|
|
75
75
|
const subjects={};
|
|
76
76
|
for(const [id,subject]of Object.entries(value.subjects??{})) {
|
|
77
77
|
if(subject.api) {const api=apis.find(api=>api.name===subject.api);if(!api)throw new Error(`Unknown API ${subject.api}`);subjects[id]={api:importReference(slash(path.relative(options.root,api.file)),api.declaration.name?.text??subject.api)};}
|
|
78
|
-
else if(subject.symbol)subjects[id]={implementation:importReference(slash(path.normalize(path.join(path.dirname(file),subject.source))),subject.symbol)};
|
|
78
|
+
else if(subject.symbol)subjects[id]={implementation:importReference(slash(path.normalize(path.join(path.dirname(file),subject.source))),subject.symbol),...(subject.role!==undefined?{role:subject.role}:{})};
|
|
79
79
|
else throw new Error(`Subject ${id} names a whole file. Select an actual implementation symbol before migrating this behavior section.`);
|
|
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,19 +3,18 @@ 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 };
|
|
10
9
|
producer: Implementation;
|
|
11
|
-
valueFrom: string;
|
|
10
|
+
valueFrom: string | readonly string[];
|
|
12
11
|
variable: string;
|
|
13
12
|
scope: { api: Implementation; selector: string };
|
|
14
13
|
checks: readonly string[];
|
|
15
14
|
}>>;
|
|
16
15
|
declarativeParts?: readonly { api: Implementation; parent: Implementation; consumer: Implementation; checks: readonly string[] }[];
|
|
17
16
|
behavior?: {
|
|
18
|
-
subjects: Readonly<Record<string, { api: Implementation } | { implementation: Implementation }>>;
|
|
17
|
+
subjects: Readonly<Record<string, { api: Implementation } | { implementation: Implementation; role?: "controller" | "implementation" }>>;
|
|
19
18
|
guarantees: readonly { id: string; description: string; subjects: readonly string[]; checks: readonly string[] }[];
|
|
20
19
|
checks: Readonly<Record<string, BehaviorCheck>>;
|
|
21
20
|
};
|