@reqvire-org/ads 0.3.3 → 0.3.6
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 +17 -5
- package/dist/behaviors.mjs +157 -0
- package/dist/bootstrap-ds/ADS.md +16 -3
- package/dist/bootstrap-ds/README.md +10 -0
- package/dist/bootstrap-ds/design-system/controllers/.gitkeep +0 -0
- package/dist/boundaries.mjs +3 -0
- package/dist/check.mjs +20 -2
- package/dist/cli.mjs +17 -0
- package/dist/config.mjs +23 -3
- package/dist/css-values.mjs +26 -0
- package/dist/index.mjs +2 -0
- package/dist/init.mjs +1 -1
- package/dist/mcp/build-status.mjs +17 -7
- package/dist/mcp/catalog.mjs +11 -8
- package/dist/mcp/context.mjs +3 -3
- package/dist/mcp/edit-preparation.mjs +111 -0
- package/dist/mcp/mutations.mjs +64 -38
- package/dist/mcp/preview-owner-guard.mjs +29 -0
- package/dist/mcp/preview-watch.mjs +38 -8
- package/dist/mcp/preview-widget.bundle.js +2 -2
- package/dist/mcp/prompts.mjs +2 -2
- package/dist/mcp/server.mjs +88 -41
- package/dist/mcp/showcase-host.mjs +9 -5
- package/dist/mcp/text-diff.mjs +19 -0
- package/dist/preview-resources.mjs +45 -8
- package/dist/preview-scope.mjs +30 -0
- package/dist/public-api.mjs +39 -0
- package/dist/scenarios-compiler.mjs +41 -19
- package/dist/scenarios.mjs +72 -42
- package/dist/scoped-tokens.mjs +57 -0
- package/dist/skills/README.md +3 -3
- package/dist/skills/ads-break-ui/SKILL.md +26 -2
- package/dist/skills/ads-break-ui/references/guarded-editing.md +44 -0
- package/dist/skills/ads-break-ui/references/verification.md +6 -0
- package/dist/skills/ads-designer/SKILL.md +27 -3
- package/dist/skills/ads-designer/assets/bootstrap-ds/ADS.md +16 -3
- package/dist/skills/ads-designer/assets/bootstrap-ds/README.md +10 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/controllers/.gitkeep +0 -0
- package/dist/skills/ads-designer/references/cli.md +1 -1
- package/dist/skills/ads-designer/references/design-craft.md +1 -1
- package/dist/skills/ads-designer/references/guarded-editing.md +44 -0
- package/dist/skills/ads-import/SKILL.md +26 -2
- package/dist/skills/ads-import/references/cli.md +1 -1
- package/dist/skills/ads-import/references/guarded-editing.md +44 -0
- package/dist/skills/ads-import/references/tokens.md +4 -2
- package/dist/skills/{ads-assimilate → ads-migrate}/SKILL.md +32 -8
- package/dist/skills/ads-migrate/agents/openai.yaml +4 -0
- package/dist/skills/{ads-assimilate → ads-migrate}/references/cli.md +1 -1
- package/dist/skills/ads-migrate/references/guarded-editing.md +44 -0
- package/dist/skills/{ads-assimilate → ads-migrate}/references/native-implementation.md +11 -0
- package/dist/skills/ads-motion/SKILL.md +26 -2
- package/dist/skills/ads-motion/references/guarded-editing.md +44 -0
- package/dist/token-fixtures.mjs +30 -0
- package/dist/tokens.mjs +11 -4
- package/dist/units.mjs +35 -9
- package/dist/verification/browser.mjs +27 -0
- package/dist/verification/playwright-reporter.cjs +20 -0
- package/dist/verification.mjs +214 -0
- package/docs/ADS.md +72 -4
- package/docs/ARCHITECTURE.md +60 -1
- package/docs/BEHAVIORS.md +241 -0
- package/docs/CHANGELOG.md +56 -0
- package/docs/GUIDE.md +24 -4
- package/docs/MCP.md +106 -12
- package/package.json +4 -2
- package/dist/skills/ads-assimilate/agents/openai.yaml +0 -4
- /package/dist/skills/{ads-assimilate → ads-migrate}/references/lint-and-docs.md +0 -0
- /package/dist/skills/{ads-assimilate → ads-migrate}/references/testing.md +0 -0
|
@@ -68,8 +68,8 @@ and `boundaries.styleWrites` entries together with its source. Unused permission
|
|
|
68
68
|
fail the core checks; do not pre-register a boundary without its implementation.
|
|
69
69
|
Use `dryRun: true` to
|
|
70
70
|
inspect validation; applying re-runs the gates. Fix rejected patches in their
|
|
71
|
-
owner.
|
|
72
|
-
direct source writes. Shared styles/helpers use `foundation`, root guides use
|
|
71
|
+
owner. Use `ads_apply_transaction` for genuinely coupled owner patches;
|
|
72
|
+
never bypass a rejection with direct source writes. Shared styles/helpers use `foundation`, root guides use
|
|
73
73
|
`documentation`, and branding/fonts use their discovered `assets/*` unit.
|
|
74
74
|
Intentional configuration, rule exceptions, registered guard code and compiler
|
|
75
75
|
changes use `configuration`; validate the proposed settings and keep mandatory
|
|
@@ -77,6 +77,25 @@ ADS gates. For binary/large assets, generate `git diff --binary --full-index` in
|
|
|
77
77
|
`.ds/patches/<name>.patch` and send `patchFile` instead of inline `patch`, so bytes
|
|
78
78
|
stay out of model context. Binary changes require Git. When editing is disabled,
|
|
79
79
|
use the client's normal source-editing tools.
|
|
80
|
+
For owner drafts, token-sample reconciliation, coupled transactions and local
|
|
81
|
+
constant namespaces, read [guarded-editing.md](references/guarded-editing.md).
|
|
82
|
+
|
|
83
|
+
Controllers are UI behavior owners: private helpers stay with their component or
|
|
84
|
+
pattern; reusable controllers use discovered `controllers/<Name>` units. Use the
|
|
85
|
+
project's configured framework and declared dependencies, or plain TypeScript,
|
|
86
|
+
browser APIs and local helpers. MCP hosts supply no ad hoc runtime APIs. The
|
|
87
|
+
framework setting selects compilation/mounting; controller checks also validate
|
|
88
|
+
imports. For controller/behavior work, read `ads://guides/behaviors` (offline:
|
|
89
|
+
the installed ADS package's `docs/BEHAVIORS.md`). Discover registered guarantees
|
|
90
|
+
with `ads_behaviors`; use `ads_verify` for selected real checks. Optional
|
|
91
|
+
`exercises` links public behavioral APIs to scenarios; keep `covers` for rendered
|
|
92
|
+
UI. Registration and demonstration are not passing evidence. `behavior.json`,
|
|
93
|
+
scenarios, fixtures and checks stay out of production exports/imports. Verify
|
|
94
|
+
current results, including lifecycle setup/cleanup/setup and the actual browser
|
|
95
|
+
profile when promised. React StrictMode needs a development harness; wrapping a
|
|
96
|
+
production widget cannot replay development effects. Keep dynamic behavior and
|
|
97
|
+
capabilities intact rather than rewriting them only for static coverage.
|
|
98
|
+
|
|
80
99
|
|
|
81
100
|
Check `ads_status.previewWatch` before launching another preview builder. With a
|
|
82
101
|
managed watcher, edit owned sources, wait for the rebuild and invoke the preview
|
|
@@ -153,7 +172,7 @@ Do not assume it has a particular component, hook, font, or token helper.
|
|
|
153
172
|
Record the source revision and required dependencies.
|
|
154
173
|
|
|
155
174
|
Use the ADS import workflow to bring selected existing ADS items into the target,
|
|
156
|
-
or
|
|
175
|
+
or migration to create a native component from an upstream library. Follow
|
|
157
176
|
those workflows directly if the corresponding skills are unavailable: copy
|
|
158
177
|
selected source and its dependency closure, or study/reproduce the upstream
|
|
159
178
|
contract; integrate local ownership, exports, styles, assets, credits, applicable
|
|
@@ -364,6 +383,11 @@ Do not copy an unchecked upstream preflight or turn a component repair into a re
|
|
|
364
383
|
Keep behavior and skin in their runtime owner. Put demo-only sizing and framing
|
|
365
384
|
in a public review/layout pattern; add component props for a deliberate runtime
|
|
366
385
|
API need. Preserve required capabilities while following ownership rules.
|
|
386
|
+
Use tokens for absolute/font-relative lengths, including `ch`, `ex`, `cap`, `ic`
|
|
387
|
+
and `lh`; calculations and fallback values follow the same rule. Structural
|
|
388
|
+
angle units remain available for orientation, skew and spin. Put tunable visual
|
|
389
|
+
angles in project tokens; static checks cannot infer that intent. Percentages,
|
|
390
|
+
grid fractions and viewport/container relationships retain structural use.
|
|
367
391
|
Browser review still verifies the effects.
|
|
368
392
|
|
|
369
393
|
Invalid metadata and source failures keep the managed compiler alive for repairs.
|
|
@@ -36,8 +36,14 @@ 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
37
|
when importing components/patterns, add missing shared definitions, and import
|
|
38
38
|
source token values only when adopting that theme is requested.
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
Shared token names and prefixes follow the ADS contract. A component/pattern may
|
|
40
|
+
register one unique local namespace in colocated `tokens.json` and define it in
|
|
41
|
+
`tokens.css`, imported by its runtime. Flat owners use `<Owner>.tokens.json` and
|
|
42
|
+
`<Owner>.tokens.css`. These definition-only sheets contain root/theme custom
|
|
43
|
+
properties, not UI selectors or ordinary styles. Other owners consume shared
|
|
44
|
+
tokens; they cannot override or consume a peer's local namespace. A colocated
|
|
45
|
+
`kind:"tokens"` scenario needs real samples for every local token. Shared
|
|
46
|
+
assignments remain in the shared token files. Components own
|
|
41
47
|
`--ds-*`, patterns `--ux-*`, and the showcase `--showcase-*`; token files cannot
|
|
42
48
|
assign those local variables or override component state.
|
|
43
49
|
|
|
@@ -183,7 +189,7 @@ mounting, correct props, every branch/state or visual parity. The older
|
|
|
183
189
|
|
|
184
190
|
`token-scenario-reference` rejects undeclared token names in metadata and reachable
|
|
185
191
|
inputs. `token-scenario-render` rejects claimed tokens with no reachable input
|
|
186
|
-
reference; `token-scenario-coverage` requires every discovered
|
|
192
|
+
reference; `token-scenario-coverage` requires every discovered shared or owner-local token
|
|
187
193
|
to have coverage. A new or removed token therefore needs a scenario/fixture
|
|
188
194
|
update. All three are errors in `ads check`, run by `lint:ds` and the build.
|
|
189
195
|
Coverage is static reachability, not proof that every branch actually renders
|
|
@@ -241,3 +247,10 @@ Run `npm run build` after adding or changing components. Add meaningful tests
|
|
|
241
247
|
for stateful behavior, accessibility, gestures, or async lifecycle where needed.
|
|
242
248
|
Run `npm run dev` to inspect the real showcase. A screenshot alone does not
|
|
243
249
|
verify interaction or animation. Generated output and dependencies are not source.
|
|
250
|
+
|
|
251
|
+
Shared behavior may live in `controllers/<Name>/`; private controllers stay with
|
|
252
|
+
their component/pattern. Use the configured framework and declared dependencies.
|
|
253
|
+
Behavior contracts/checks are development-only, and scenario `exercises` links
|
|
254
|
+
public hooks to demonstrations separately from rendered `covers`. Read the
|
|
255
|
+
installed ADS package's `docs/BEHAVIORS.md` or MCP `ads://guides/behaviors` before
|
|
256
|
+
registering guarantees, profiles and verification.
|
|
@@ -62,6 +62,10 @@ the public `TokenPreview` pattern owns their presentation and applies the real C
|
|
|
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
64
|
in the browser. Extend or replace the project-owned pattern as your tokens evolve.
|
|
65
|
+
`ads_prepare_token_samples` can prepare a fixture patch from explicit project
|
|
66
|
+
property/probe bindings. It preserves existing samples and reports unmapped tokens;
|
|
67
|
+
it does not guess how a new value should look. Component/pattern constants can use
|
|
68
|
+
the colocated namespace contract in [ADS.md](ADS.md), with their own token scenario.
|
|
65
69
|
|
|
66
70
|
Create a component under `design-system/components/`, export it through `@ds`,
|
|
67
71
|
and colocate `Scenario.tsx` plus `fixture.ts` (or `<Owner>.scenario.tsx` and
|
|
@@ -79,6 +83,8 @@ stale retained output. Switching or rebuilding a scenario unmounts its previous
|
|
|
79
83
|
state. `showcase/mcp/main.tsx` exports `mountScenario(Scenario, container)` and
|
|
80
84
|
returns an unmount callback; it is not the shell. Keep the saved `framework`,
|
|
81
85
|
compiler and mount adapter consistent.
|
|
86
|
+
Managed sessions own their graph output; standalone prebuilds cannot replace it.
|
|
87
|
+
Verified generated graph snapshots preserve warm-start reuse across sessions.
|
|
82
88
|
|
|
83
89
|
The application and previews use the same foundation CSS and Linaria pipeline.
|
|
84
90
|
The source barrel loads the foundation once. The private `build:lib` script uses
|
|
@@ -98,3 +104,7 @@ from a user-selected external repository, preserving revisions and licenses.
|
|
|
98
104
|
inspection builds it automatically, then loads selected entries. Browser review
|
|
99
105
|
still checks layout, accessibility, keyboard/focus, states, themes and motion. A clean
|
|
100
106
|
build or delivered HTML alone does not establish those behaviors.
|
|
107
|
+
Opt-in MCP editing uses owner Git patches. `ads_prepare_patch` creates a temporary
|
|
108
|
+
owner draft/diff; `ads_apply_transaction` validates bounded coupled owner patches
|
|
109
|
+
against one final candidate. Preparation changes no live source. Keep all guards
|
|
110
|
+
and review the rendered result after applying.
|
|
File without changes
|
|
@@ -102,7 +102,7 @@ script but does not install the project preview compiler. Integrate its graph
|
|
|
102
102
|
compiler/mount adapter and configure `mcp.previewManifest` plus `mcp.previewWatch`;
|
|
103
103
|
then use the same foundation and Linaria extraction as the application. Source discovery,
|
|
104
104
|
selected component/pattern/style/brand imports, explicit theme-value imports, and
|
|
105
|
-
|
|
105
|
+
migration are agent workflows. There is no CLI `import` command. Core checks
|
|
106
106
|
do not copy source, import values, or establish behavior/motion parity; continue
|
|
107
107
|
project type checking, meaningful tests, and browser comparisons.
|
|
108
108
|
|
|
@@ -56,7 +56,7 @@ changing them to a generic default.
|
|
|
56
56
|
|
|
57
57
|
Keep typed props, examples, state behavior, token hooks, and important tradeoffs
|
|
58
58
|
in the item README. Record concrete upstream influences, authors, revision, and
|
|
59
|
-
applicable notices when importing or
|
|
59
|
+
applicable notices when importing or migrating source. Do not describe an
|
|
60
60
|
adapted implementation as independent solely because it uses native primitives.
|
|
61
61
|
|
|
62
62
|
Run the actual project's checks after changes and inspect the real consumer
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Advanced guarded editing
|
|
2
|
+
|
|
3
|
+
Use `ads_apply_patch` for independent owner edits. `ads_prepare_patch` can create a
|
|
4
|
+
local draft of one owner and its companions; edit that directory with local file
|
|
5
|
+
tools, request `action:"diff"`, then apply the returned patchFile. Discard the
|
|
6
|
+
draft afterward. Remote clients can keep sending inline Git diffs. Neither draft
|
|
7
|
+
preparation nor diff generation validates or changes live source.
|
|
8
|
+
|
|
9
|
+
For genuinely coupled changes, `ads_apply_transaction` accepts 2–8 distinct owner
|
|
10
|
+
patches (32 distinct files and 16 MiB combined). Each patch keeps its ownership and
|
|
11
|
+
companion restrictions. Patches apply in order; later shared-entry hunks match the
|
|
12
|
+
earlier candidate. All guards, registered checks and affected behavior checks run
|
|
13
|
+
on the final candidate before live source is written. Dry-run first. Rejection,
|
|
14
|
+
conflict and cancellation publish nothing. Dependency installation remains local;
|
|
15
|
+
the candidate uses installed node_modules. Never bypass a rejected gate directly.
|
|
16
|
+
|
|
17
|
+
A component/pattern can own constants without expanding the shared vocabulary:
|
|
18
|
+
colocate `tokens.json` with `{ "schemaVersion":1, "namespace":"--<owner>-" }`
|
|
19
|
+
and a definition-only `tokens.css`, imported by its runtime source. Flat owners use
|
|
20
|
+
`<Owner>.tokens.json`/`<Owner>.tokens.css`. Namespaces are unique and cannot overlap
|
|
21
|
+
shared or --ds-/--ux-/--showcase- variables. Only that owner consumes/defines its
|
|
22
|
+
local tokens; aliases can use shared or own tokens. UI styles stay in Linaria.
|
|
23
|
+
Add a colocated token scenario with `kind:"tokens"`, real fixture `samples` and a
|
|
24
|
+
public review pattern. These inputs belong to the same owner and need real sample
|
|
25
|
+
coverage. Manifests and fixtures stay out of the product bundle.
|
|
26
|
+
|
|
27
|
+
`ads_prepare_token_samples({id, bindings?})` preserves existing project samples,
|
|
28
|
+
removes undeclared names and returns an owner patchFile. Supply explicit
|
|
29
|
+
`{token,property,probe}` bindings for new samples; unresolved tokens stay reported.
|
|
30
|
+
ADS does not infer visual meaning or fabricate renderers. Apply through the guard,
|
|
31
|
+
then inspect the actual App sample effects.
|
|
32
|
+
|
|
33
|
+
An empty .gitkeep can be deleted alongside new source beneath it in the selected
|
|
34
|
+
owner. Nonempty markers and other hidden files stay protected. A redundant
|
|
35
|
+
Scenario.tsx can be deleted when real coverage remains elsewhere; removing a
|
|
36
|
+
scenario does not erase ownership of the unit's runtime source.
|
|
37
|
+
|
|
38
|
+
Keep contextual public parts public when they are intended consumer API. Demonstrate
|
|
39
|
+
them through their actual public composition/customization path and list their real
|
|
40
|
+
render references in covers. Do not count internal production renders as public API
|
|
41
|
+
coverage. Behavioral APIs use exercises and registered guarantees instead.
|
|
42
|
+
Scenario controls still use public UI; native link/button markup belongs in an
|
|
43
|
+
owned public primitive/pattern or an owner-local test, including polymorphic/slot
|
|
44
|
+
adaptation. Do not add demo-only component props or global styles for review glue.
|
|
@@ -32,8 +32,8 @@ and `boundaries.styleWrites` entries together with its source. Unused permission
|
|
|
32
32
|
fail the core checks; do not pre-register a boundary without its implementation.
|
|
33
33
|
Use `dryRun: true` to
|
|
34
34
|
inspect validation; applying re-runs the gates. Fix rejected patches in their
|
|
35
|
-
owner.
|
|
36
|
-
direct source writes. Shared styles/helpers use `foundation`, root guides use
|
|
35
|
+
owner. Use `ads_apply_transaction` for genuinely coupled owner patches;
|
|
36
|
+
never bypass a rejection with direct source writes. Shared styles/helpers use `foundation`, root guides use
|
|
37
37
|
`documentation`, and branding/fonts use their discovered `assets/*` unit.
|
|
38
38
|
Intentional configuration, rule exceptions, registered guard code and compiler
|
|
39
39
|
changes use `configuration`; validate the proposed settings and keep mandatory
|
|
@@ -41,6 +41,25 @@ ADS gates. For binary/large assets, generate `git diff --binary --full-index` in
|
|
|
41
41
|
`.ds/patches/<name>.patch` and send `patchFile` instead of inline `patch`, so bytes
|
|
42
42
|
stay out of model context. Binary changes require Git. When editing is disabled,
|
|
43
43
|
use the client's normal source-editing tools.
|
|
44
|
+
For owner drafts, token-sample reconciliation, coupled transactions and local
|
|
45
|
+
constant namespaces, read [guarded-editing.md](references/guarded-editing.md).
|
|
46
|
+
|
|
47
|
+
Controllers are UI behavior owners: private helpers stay with their component or
|
|
48
|
+
pattern; reusable controllers use discovered `controllers/<Name>` units. Use the
|
|
49
|
+
project's configured framework and declared dependencies, or plain TypeScript,
|
|
50
|
+
browser APIs and local helpers. MCP hosts supply no ad hoc runtime APIs. The
|
|
51
|
+
framework setting selects compilation/mounting; controller checks also validate
|
|
52
|
+
imports. For controller/behavior work, read `ads://guides/behaviors` (offline:
|
|
53
|
+
the installed ADS package's `docs/BEHAVIORS.md`). Discover registered guarantees
|
|
54
|
+
with `ads_behaviors`; use `ads_verify` for selected real checks. Optional
|
|
55
|
+
`exercises` links public behavioral APIs to scenarios; keep `covers` for rendered
|
|
56
|
+
UI. Registration and demonstration are not passing evidence. `behavior.json`,
|
|
57
|
+
scenarios, fixtures and checks stay out of production exports/imports. Verify
|
|
58
|
+
current results, including lifecycle setup/cleanup/setup and the actual browser
|
|
59
|
+
profile when promised. React StrictMode needs a development harness; wrapping a
|
|
60
|
+
production widget cannot replay development effects. Keep dynamic behavior and
|
|
61
|
+
capabilities intact rather than rewriting them only for static coverage.
|
|
62
|
+
|
|
44
63
|
|
|
45
64
|
Before trusting a preview after edits, check `ads_status.build` or
|
|
46
65
|
`ads://project/build`. Fix build diagnostics in owned source; an older view or
|
|
@@ -331,6 +350,11 @@ Do not copy an unchecked upstream preflight or turn a component repair into a re
|
|
|
331
350
|
Keep behavior and skin in their runtime owner. Put demo-only sizing and framing
|
|
332
351
|
in a public review/layout pattern; add component props for a deliberate runtime
|
|
333
352
|
API need. Preserve required capabilities while following ownership rules.
|
|
353
|
+
Use tokens for absolute/font-relative lengths, including `ch`, `ex`, `cap`, `ic`
|
|
354
|
+
and `lh`; calculations and fallback values follow the same rule. Structural
|
|
355
|
+
angle units remain available for orientation, skew and spin. Put tunable visual
|
|
356
|
+
angles in project tokens; static checks cannot infer that intent. Percentages,
|
|
357
|
+
grid fractions and viewport/container relationships retain structural use.
|
|
334
358
|
Browser review still verifies the effects.
|
|
335
359
|
|
|
336
360
|
Invalid metadata and source failures keep the managed compiler alive for repairs.
|
|
@@ -102,7 +102,7 @@ script but does not install the project preview compiler. Integrate its graph
|
|
|
102
102
|
compiler/mount adapter and configure `mcp.previewManifest` plus `mcp.previewWatch`;
|
|
103
103
|
then use the same foundation and Linaria extraction as the application. Source discovery,
|
|
104
104
|
selected component/pattern/style/brand imports, explicit theme-value imports, and
|
|
105
|
-
|
|
105
|
+
migration are agent workflows. There is no CLI `import` command. Core checks
|
|
106
106
|
do not copy source, import values, or establish behavior/motion parity; continue
|
|
107
107
|
project type checking, meaningful tests, and browser comparisons.
|
|
108
108
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Advanced guarded editing
|
|
2
|
+
|
|
3
|
+
Use `ads_apply_patch` for independent owner edits. `ads_prepare_patch` can create a
|
|
4
|
+
local draft of one owner and its companions; edit that directory with local file
|
|
5
|
+
tools, request `action:"diff"`, then apply the returned patchFile. Discard the
|
|
6
|
+
draft afterward. Remote clients can keep sending inline Git diffs. Neither draft
|
|
7
|
+
preparation nor diff generation validates or changes live source.
|
|
8
|
+
|
|
9
|
+
For genuinely coupled changes, `ads_apply_transaction` accepts 2–8 distinct owner
|
|
10
|
+
patches (32 distinct files and 16 MiB combined). Each patch keeps its ownership and
|
|
11
|
+
companion restrictions. Patches apply in order; later shared-entry hunks match the
|
|
12
|
+
earlier candidate. All guards, registered checks and affected behavior checks run
|
|
13
|
+
on the final candidate before live source is written. Dry-run first. Rejection,
|
|
14
|
+
conflict and cancellation publish nothing. Dependency installation remains local;
|
|
15
|
+
the candidate uses installed node_modules. Never bypass a rejected gate directly.
|
|
16
|
+
|
|
17
|
+
A component/pattern can own constants without expanding the shared vocabulary:
|
|
18
|
+
colocate `tokens.json` with `{ "schemaVersion":1, "namespace":"--<owner>-" }`
|
|
19
|
+
and a definition-only `tokens.css`, imported by its runtime source. Flat owners use
|
|
20
|
+
`<Owner>.tokens.json`/`<Owner>.tokens.css`. Namespaces are unique and cannot overlap
|
|
21
|
+
shared or --ds-/--ux-/--showcase- variables. Only that owner consumes/defines its
|
|
22
|
+
local tokens; aliases can use shared or own tokens. UI styles stay in Linaria.
|
|
23
|
+
Add a colocated token scenario with `kind:"tokens"`, real fixture `samples` and a
|
|
24
|
+
public review pattern. These inputs belong to the same owner and need real sample
|
|
25
|
+
coverage. Manifests and fixtures stay out of the product bundle.
|
|
26
|
+
|
|
27
|
+
`ads_prepare_token_samples({id, bindings?})` preserves existing project samples,
|
|
28
|
+
removes undeclared names and returns an owner patchFile. Supply explicit
|
|
29
|
+
`{token,property,probe}` bindings for new samples; unresolved tokens stay reported.
|
|
30
|
+
ADS does not infer visual meaning or fabricate renderers. Apply through the guard,
|
|
31
|
+
then inspect the actual App sample effects.
|
|
32
|
+
|
|
33
|
+
An empty .gitkeep can be deleted alongside new source beneath it in the selected
|
|
34
|
+
owner. Nonempty markers and other hidden files stay protected. A redundant
|
|
35
|
+
Scenario.tsx can be deleted when real coverage remains elsewhere; removing a
|
|
36
|
+
scenario does not erase ownership of the unit's runtime source.
|
|
37
|
+
|
|
38
|
+
Keep contextual public parts public when they are intended consumer API. Demonstrate
|
|
39
|
+
them through their actual public composition/customization path and list their real
|
|
40
|
+
render references in covers. Do not count internal production renders as public API
|
|
41
|
+
coverage. Behavioral APIs use exercises and registered guarantees instead.
|
|
42
|
+
Scenario controls still use public UI; native link/button markup belongs in an
|
|
43
|
+
owned public primitive/pattern or an owner-local test, including polymorphic/slot
|
|
44
|
+
adaptation. Do not add demo-only component props or global styles for review glue.
|
|
@@ -47,9 +47,11 @@ overwriting destination theme behavior during an item import.
|
|
|
47
47
|
|
|
48
48
|
## Explicit `tokens` mode imports values
|
|
49
49
|
|
|
50
|
-
ADS token names and prefixes
|
|
50
|
+
Shared ADS token names and prefixes retain their semantics. Owner-local constants
|
|
51
|
+
may use the registered namespace contract described in [guarded-editing.md](guarded-editing.md);
|
|
52
|
+
they do not create a second shared branding vocabulary. New shared definitions follow the existing
|
|
51
53
|
architecture; components use `--ds-*`, patterns `--ux-*`, and owned scenario review layouts
|
|
52
|
-
`--ux-*` (`--showcase-*` is reserved, not permission for fixture CSS).
|
|
54
|
+
`--ux-*` (`--showcase-*` is reserved, not permission for fixture CSS). Keep shared names canonical; owner-local namespaces remain separate, explicit contracts.
|
|
53
55
|
Normalize nonconforming source references to canonical ADS names during import,
|
|
54
56
|
preserving destination values unless this mode explicitly requests changes.
|
|
55
57
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: ads-
|
|
3
|
-
description: "Implement or refine a native design-system component from a component-library URL, studying the original implementation and verifying behavior, visuals, and motion against the real reference. Use for component
|
|
2
|
+
name: ads-migrate
|
|
3
|
+
description: "Implement or refine a native design-system component from a component-library URL, studying the original implementation and verifying behavior, visuals, and motion against the real reference. Use for component migration, including local documentation and justified usage lint rules; not for simply installing or wrapping a dependency."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# ADS
|
|
6
|
+
# ADS Migrate
|
|
7
7
|
|
|
8
8
|
When ADS MCP is connected, discover public UI and addressable scenarios with
|
|
9
9
|
`ads_status`/`ads_catalog`; use `ads_tokens` for definitions and values, and
|
|
@@ -33,8 +33,8 @@ and `boundaries.styleWrites` entries together with its source. Unused permission
|
|
|
33
33
|
fail the core checks; do not pre-register a boundary without its implementation.
|
|
34
34
|
Use `dryRun: true` to
|
|
35
35
|
inspect validation; applying re-runs the gates. Fix rejected patches in their
|
|
36
|
-
owner.
|
|
37
|
-
direct source writes. Shared styles/helpers use `foundation`, root guides use
|
|
36
|
+
owner. Use `ads_apply_transaction` for genuinely coupled owner patches;
|
|
37
|
+
never bypass a rejection with direct source writes. Shared styles/helpers use `foundation`, root guides use
|
|
38
38
|
`documentation`, and branding/fonts use their discovered `assets/*` unit.
|
|
39
39
|
Intentional configuration, rule exceptions, registered guard code and compiler
|
|
40
40
|
changes use `configuration`; validate the proposed settings and keep mandatory
|
|
@@ -42,6 +42,25 @@ ADS gates. For binary/large assets, generate `git diff --binary --full-index` in
|
|
|
42
42
|
`.ds/patches/<name>.patch` and send `patchFile` instead of inline `patch`, so bytes
|
|
43
43
|
stay out of model context. Binary changes require Git. When editing is disabled,
|
|
44
44
|
use the client's normal source-editing tools.
|
|
45
|
+
For owner drafts, token-sample reconciliation, coupled transactions and local
|
|
46
|
+
constant namespaces, read [guarded-editing.md](references/guarded-editing.md).
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Controllers are UI behavior owners: private helpers stay with their component or
|
|
50
|
+
pattern; reusable controllers use discovered `controllers/<Name>` units. Use the
|
|
51
|
+
project's configured framework and declared dependencies, or plain TypeScript,
|
|
52
|
+
browser APIs and local helpers. MCP hosts supply no ad hoc runtime APIs. The
|
|
53
|
+
framework setting selects compilation/mounting; controller checks also validate
|
|
54
|
+
imports. For controller/behavior work, read `ads://guides/behaviors` (offline:
|
|
55
|
+
the installed ADS package's `docs/BEHAVIORS.md`). Discover registered guarantees
|
|
56
|
+
with `ads_behaviors`; use `ads_verify` for selected real checks. Optional
|
|
57
|
+
`exercises` links public behavioral APIs to scenarios; keep `covers` for rendered
|
|
58
|
+
UI. Registration and demonstration are not passing evidence. `behavior.json`,
|
|
59
|
+
scenarios, fixtures and checks stay out of production exports/imports. Verify
|
|
60
|
+
current results, including lifecycle setup/cleanup/setup and the actual browser
|
|
61
|
+
profile when promised. React StrictMode needs a development harness; wrapping a
|
|
62
|
+
production widget cannot replay development effects. Keep dynamic behavior and
|
|
63
|
+
capabilities intact rather than rewriting them only for static coverage.
|
|
45
64
|
|
|
46
65
|
Before trusting a preview after edits, check `ads_status.build` or
|
|
47
66
|
`ads://project/build`. Fix build diagnostics in owned source; an older view or
|
|
@@ -75,8 +94,8 @@ workflows. Do not look for a built-in or optional UI catalogue in the tool.
|
|
|
75
94
|
Invocation accepts a library/repository/documentation URL as its first argument:
|
|
76
95
|
|
|
77
96
|
```text
|
|
78
|
-
$ads-
|
|
79
|
-
$ads-
|
|
97
|
+
$ads-migrate <library-url> [component-name] [requirements]
|
|
98
|
+
$ads-migrate https://github.com/emilkowalski/sonner toast
|
|
80
99
|
```
|
|
81
100
|
|
|
82
101
|
The URL is the required reference, not a request to install the library into the
|
|
@@ -147,7 +166,7 @@ the scenario; larger entries belong under `composition/`. Browsing pages only
|
|
|
147
166
|
select these entries. The scenario labels, controls and review layouts are public ADS entities with defined
|
|
148
167
|
APIs. The outer shell belongs to the tool client. Showcase/scenario files define no CSS, custom classes, or widget markup.
|
|
149
168
|
Change the owning ADS pattern when a frame layout is missing; do not recreate
|
|
150
|
-
the
|
|
169
|
+
the migrated UI there or override its internals.
|
|
151
170
|
|
|
152
171
|
The showcase is a minimal shell plus an MCP client and Apps host, supplied by ADS
|
|
153
172
|
tooling. It discovers Tokens/Components/Patterns/Composition entries through MCP
|
|
@@ -274,6 +293,11 @@ Do not copy an unchecked upstream preflight or turn a component repair into a re
|
|
|
274
293
|
Keep behavior and skin in their runtime owner. Put demo-only sizing and framing
|
|
275
294
|
in a public review/layout pattern; add component props for a deliberate runtime
|
|
276
295
|
API need. Preserve required capabilities while following ownership rules.
|
|
296
|
+
Use tokens for absolute/font-relative lengths, including `ch`, `ex`, `cap`, `ic`
|
|
297
|
+
and `lh`; calculations and fallback values follow the same rule. Structural
|
|
298
|
+
angle units remain available for orientation, skew and spin. Put tunable visual
|
|
299
|
+
angles in project tokens; static checks cannot infer that intent. Percentages,
|
|
300
|
+
grid fractions and viewport/container relationships retain structural use.
|
|
277
301
|
Browser review still verifies the effects.
|
|
278
302
|
|
|
279
303
|
Invalid metadata and source failures keep the managed compiler alive for repairs.
|
|
@@ -102,7 +102,7 @@ script but does not install the project preview compiler. Integrate its graph
|
|
|
102
102
|
compiler/mount adapter and configure `mcp.previewManifest` plus `mcp.previewWatch`;
|
|
103
103
|
then use the same foundation and Linaria extraction as the application. Source discovery,
|
|
104
104
|
selected component/pattern/style/brand imports, explicit theme-value imports, and
|
|
105
|
-
|
|
105
|
+
migration are agent workflows. There is no CLI `import` command. Core checks
|
|
106
106
|
do not copy source, import values, or establish behavior/motion parity; continue
|
|
107
107
|
project type checking, meaningful tests, and browser comparisons.
|
|
108
108
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Advanced guarded editing
|
|
2
|
+
|
|
3
|
+
Use `ads_apply_patch` for independent owner edits. `ads_prepare_patch` can create a
|
|
4
|
+
local draft of one owner and its companions; edit that directory with local file
|
|
5
|
+
tools, request `action:"diff"`, then apply the returned patchFile. Discard the
|
|
6
|
+
draft afterward. Remote clients can keep sending inline Git diffs. Neither draft
|
|
7
|
+
preparation nor diff generation validates or changes live source.
|
|
8
|
+
|
|
9
|
+
For genuinely coupled changes, `ads_apply_transaction` accepts 2–8 distinct owner
|
|
10
|
+
patches (32 distinct files and 16 MiB combined). Each patch keeps its ownership and
|
|
11
|
+
companion restrictions. Patches apply in order; later shared-entry hunks match the
|
|
12
|
+
earlier candidate. All guards, registered checks and affected behavior checks run
|
|
13
|
+
on the final candidate before live source is written. Dry-run first. Rejection,
|
|
14
|
+
conflict and cancellation publish nothing. Dependency installation remains local;
|
|
15
|
+
the candidate uses installed node_modules. Never bypass a rejected gate directly.
|
|
16
|
+
|
|
17
|
+
A component/pattern can own constants without expanding the shared vocabulary:
|
|
18
|
+
colocate `tokens.json` with `{ "schemaVersion":1, "namespace":"--<owner>-" }`
|
|
19
|
+
and a definition-only `tokens.css`, imported by its runtime source. Flat owners use
|
|
20
|
+
`<Owner>.tokens.json`/`<Owner>.tokens.css`. Namespaces are unique and cannot overlap
|
|
21
|
+
shared or --ds-/--ux-/--showcase- variables. Only that owner consumes/defines its
|
|
22
|
+
local tokens; aliases can use shared or own tokens. UI styles stay in Linaria.
|
|
23
|
+
Add a colocated token scenario with `kind:"tokens"`, real fixture `samples` and a
|
|
24
|
+
public review pattern. These inputs belong to the same owner and need real sample
|
|
25
|
+
coverage. Manifests and fixtures stay out of the product bundle.
|
|
26
|
+
|
|
27
|
+
`ads_prepare_token_samples({id, bindings?})` preserves existing project samples,
|
|
28
|
+
removes undeclared names and returns an owner patchFile. Supply explicit
|
|
29
|
+
`{token,property,probe}` bindings for new samples; unresolved tokens stay reported.
|
|
30
|
+
ADS does not infer visual meaning or fabricate renderers. Apply through the guard,
|
|
31
|
+
then inspect the actual App sample effects.
|
|
32
|
+
|
|
33
|
+
An empty .gitkeep can be deleted alongside new source beneath it in the selected
|
|
34
|
+
owner. Nonempty markers and other hidden files stay protected. A redundant
|
|
35
|
+
Scenario.tsx can be deleted when real coverage remains elsewhere; removing a
|
|
36
|
+
scenario does not erase ownership of the unit's runtime source.
|
|
37
|
+
|
|
38
|
+
Keep contextual public parts public when they are intended consumer API. Demonstrate
|
|
39
|
+
them through their actual public composition/customization path and list their real
|
|
40
|
+
render references in covers. Do not count internal production renders as public API
|
|
41
|
+
coverage. Behavioral APIs use exercises and registered guarantees instead.
|
|
42
|
+
Scenario controls still use public UI; native link/button markup belongs in an
|
|
43
|
+
owned public primitive/pattern or an owner-local test, including polymorphic/slot
|
|
44
|
+
adaptation. Do not add demo-only component props or global styles for review glue.
|
|
@@ -112,3 +112,14 @@ README and in a References and credits section in the component-local README.
|
|
|
112
112
|
Link the library and the actual source/docs/articles studied, identify the
|
|
113
113
|
version or commit, name the authors, and explain the concrete influences.
|
|
114
114
|
Document material adaptations and agreed deviations beside the public contract.
|
|
115
|
+
|
|
116
|
+
## Behavioral evidence
|
|
117
|
+
|
|
118
|
+
Keep private controllers in their owner; extract a shared controller only for a
|
|
119
|
+
real reuse need. Register optional behavior guarantees and real colocated checks;
|
|
120
|
+
see `ads://guides/behaviors` or the installed package's `docs/BEHAVIORS.md`. Link
|
|
121
|
+
public hooks with scenario `exercises`, while `covers` still requires rendered UI.
|
|
122
|
+
Move reviewed scratchpad investigations into maintained owner checks. Disabling
|
|
123
|
+
StrictMode can isolate an upstream lifecycle defect; keep a development StrictMode
|
|
124
|
+
check and verify the native port's setup/cleanup/setup independently. Use first-
|
|
125
|
+
render browser cases for lazy intrinsic sizing, retaining offscreen rendering.
|
|
@@ -53,8 +53,8 @@ and `boundaries.styleWrites` entries together with its source. Unused permission
|
|
|
53
53
|
fail the core checks; do not pre-register a boundary without its implementation.
|
|
54
54
|
Use `dryRun: true` to
|
|
55
55
|
inspect validation; applying re-runs the gates. Fix rejected patches in their
|
|
56
|
-
owner.
|
|
57
|
-
direct source writes. Shared styles/helpers use `foundation`, root guides use
|
|
56
|
+
owner. Use `ads_apply_transaction` for genuinely coupled owner patches;
|
|
57
|
+
never bypass a rejection with direct source writes. Shared styles/helpers use `foundation`, root guides use
|
|
58
58
|
`documentation`, and branding/fonts use their discovered `assets/*` unit.
|
|
59
59
|
Intentional configuration, rule exceptions, registered guard code and compiler
|
|
60
60
|
changes use `configuration`; validate the proposed settings and keep mandatory
|
|
@@ -62,6 +62,25 @@ ADS gates. For binary/large assets, generate `git diff --binary --full-index` in
|
|
|
62
62
|
`.ds/patches/<name>.patch` and send `patchFile` instead of inline `patch`, so bytes
|
|
63
63
|
stay out of model context. Binary changes require Git. When editing is disabled,
|
|
64
64
|
use the client's normal source-editing tools.
|
|
65
|
+
For owner drafts, token-sample reconciliation, coupled transactions and local
|
|
66
|
+
constant namespaces, read [guarded-editing.md](references/guarded-editing.md).
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Controllers are UI behavior owners: private helpers stay with their component or
|
|
70
|
+
pattern; reusable controllers use discovered `controllers/<Name>` units. Use the
|
|
71
|
+
project's configured framework and declared dependencies, or plain TypeScript,
|
|
72
|
+
browser APIs and local helpers. MCP hosts supply no ad hoc runtime APIs. The
|
|
73
|
+
framework setting selects compilation/mounting; controller checks also validate
|
|
74
|
+
imports. For controller/behavior work, read `ads://guides/behaviors` (offline:
|
|
75
|
+
the installed ADS package's `docs/BEHAVIORS.md`). Discover registered guarantees
|
|
76
|
+
with `ads_behaviors`; use `ads_verify` for selected real checks. Optional
|
|
77
|
+
`exercises` links public behavioral APIs to scenarios; keep `covers` for rendered
|
|
78
|
+
UI. Registration and demonstration are not passing evidence. `behavior.json`,
|
|
79
|
+
scenarios, fixtures and checks stay out of production exports/imports. Verify
|
|
80
|
+
current results, including lifecycle setup/cleanup/setup and the actual browser
|
|
81
|
+
profile when promised. React StrictMode needs a development harness; wrapping a
|
|
82
|
+
production widget cannot replay development effects. Keep dynamic behavior and
|
|
83
|
+
capabilities intact rather than rewriting them only for static coverage.
|
|
65
84
|
|
|
66
85
|
Before trusting a preview after edits, check `ads_status.build` or
|
|
67
86
|
`ads://project/build`. Fix build diagnostics in owned source; an older view or
|
|
@@ -221,6 +240,11 @@ Do not copy an unchecked upstream preflight or turn a component repair into a re
|
|
|
221
240
|
Keep behavior and skin in their runtime owner. Put demo-only sizing and framing
|
|
222
241
|
in a public review/layout pattern; add component props for a deliberate runtime
|
|
223
242
|
API need. Preserve required capabilities while following ownership rules.
|
|
243
|
+
Use tokens for absolute/font-relative lengths, including `ch`, `ex`, `cap`, `ic`
|
|
244
|
+
and `lh`; calculations and fallback values follow the same rule. Structural
|
|
245
|
+
angle units remain available for orientation, skew and spin. Put tunable visual
|
|
246
|
+
angles in project tokens; static checks cannot infer that intent. Percentages,
|
|
247
|
+
grid fractions and viewport/container relationships retain structural use.
|
|
224
248
|
Browser review still verifies the effects.
|
|
225
249
|
|
|
226
250
|
Invalid metadata and source failures keep the managed compiler alive for repairs.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Advanced guarded editing
|
|
2
|
+
|
|
3
|
+
Use `ads_apply_patch` for independent owner edits. `ads_prepare_patch` can create a
|
|
4
|
+
local draft of one owner and its companions; edit that directory with local file
|
|
5
|
+
tools, request `action:"diff"`, then apply the returned patchFile. Discard the
|
|
6
|
+
draft afterward. Remote clients can keep sending inline Git diffs. Neither draft
|
|
7
|
+
preparation nor diff generation validates or changes live source.
|
|
8
|
+
|
|
9
|
+
For genuinely coupled changes, `ads_apply_transaction` accepts 2–8 distinct owner
|
|
10
|
+
patches (32 distinct files and 16 MiB combined). Each patch keeps its ownership and
|
|
11
|
+
companion restrictions. Patches apply in order; later shared-entry hunks match the
|
|
12
|
+
earlier candidate. All guards, registered checks and affected behavior checks run
|
|
13
|
+
on the final candidate before live source is written. Dry-run first. Rejection,
|
|
14
|
+
conflict and cancellation publish nothing. Dependency installation remains local;
|
|
15
|
+
the candidate uses installed node_modules. Never bypass a rejected gate directly.
|
|
16
|
+
|
|
17
|
+
A component/pattern can own constants without expanding the shared vocabulary:
|
|
18
|
+
colocate `tokens.json` with `{ "schemaVersion":1, "namespace":"--<owner>-" }`
|
|
19
|
+
and a definition-only `tokens.css`, imported by its runtime source. Flat owners use
|
|
20
|
+
`<Owner>.tokens.json`/`<Owner>.tokens.css`. Namespaces are unique and cannot overlap
|
|
21
|
+
shared or --ds-/--ux-/--showcase- variables. Only that owner consumes/defines its
|
|
22
|
+
local tokens; aliases can use shared or own tokens. UI styles stay in Linaria.
|
|
23
|
+
Add a colocated token scenario with `kind:"tokens"`, real fixture `samples` and a
|
|
24
|
+
public review pattern. These inputs belong to the same owner and need real sample
|
|
25
|
+
coverage. Manifests and fixtures stay out of the product bundle.
|
|
26
|
+
|
|
27
|
+
`ads_prepare_token_samples({id, bindings?})` preserves existing project samples,
|
|
28
|
+
removes undeclared names and returns an owner patchFile. Supply explicit
|
|
29
|
+
`{token,property,probe}` bindings for new samples; unresolved tokens stay reported.
|
|
30
|
+
ADS does not infer visual meaning or fabricate renderers. Apply through the guard,
|
|
31
|
+
then inspect the actual App sample effects.
|
|
32
|
+
|
|
33
|
+
An empty .gitkeep can be deleted alongside new source beneath it in the selected
|
|
34
|
+
owner. Nonempty markers and other hidden files stay protected. A redundant
|
|
35
|
+
Scenario.tsx can be deleted when real coverage remains elsewhere; removing a
|
|
36
|
+
scenario does not erase ownership of the unit's runtime source.
|
|
37
|
+
|
|
38
|
+
Keep contextual public parts public when they are intended consumer API. Demonstrate
|
|
39
|
+
them through their actual public composition/customization path and list their real
|
|
40
|
+
render references in covers. Do not count internal production renders as public API
|
|
41
|
+
coverage. Behavioral APIs use exercises and registered guarantees instead.
|
|
42
|
+
Scenario controls still use public UI; native link/button markup belongs in an
|
|
43
|
+
owned public primitive/pattern or an owner-local test, including polymorphic/slot
|
|
44
|
+
adaptation. Do not add demo-only component props or global styles for review glue.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { inspectTokens } from "./tokens.mjs";
|
|
2
|
+
import { inspectScenarios, tokenSampleSource } from "./scenarios.mjs";
|
|
3
|
+
import { inspectUnits } from "./units.mjs";
|
|
4
|
+
import { validTokenSamples } from "./token-samples.mjs";
|
|
5
|
+
import { textDiff } from "./mcp/text-diff.mjs";
|
|
6
|
+
|
|
7
|
+
/** Preserve project bindings; new meanings always need project-selected inputs. */
|
|
8
|
+
export function reconcileTokenSamples(options, {id, bindings = []}) {
|
|
9
|
+
if (bindings.length && !validTokenSamples(bindings)) throw new Error("Bindings need distinct {token, property, probe} CSS samples.");
|
|
10
|
+
const inventory = inspectTokens(options.root), registry = inspectScenarios(options), units = inspectUnits(options);
|
|
11
|
+
const scenario = registry.scenarios.find(entry => entry.id === id && entry.kind === "tokens");
|
|
12
|
+
if (!scenario) throw new Error("Select an exact token scenario ID from ads_scenarios.");
|
|
13
|
+
const owner = units.owner(units.relative(scenario.file));
|
|
14
|
+
const owned = new Set(inventory.tokens.filter(token => token.owner === owner).map(token => token.name));
|
|
15
|
+
if (bindings.some(sample => !owned.has(sample.token))) throw new Error("New sample bindings must name real tokens from this scenario's owner.");
|
|
16
|
+
const removed = scenario.samples.filter(sample => !owned.has(sample.token)).map(sample => sample.token);
|
|
17
|
+
const samples = new Map(scenario.samples.filter(sample => owned.has(sample.token)).map(sample => [`${sample.token}:${sample.property}`, sample]));
|
|
18
|
+
for (const sample of bindings) samples.set(`${sample.token}:${sample.property}`, sample);
|
|
19
|
+
if (!samples.size) throw new Error("A token scenario needs at least one real sample; supply a binding or remove the obsolete scenario with an owner patch.");
|
|
20
|
+
const represented = new Set(registry.scenarios.filter(entry => entry.kind === "tokens" && entry.id !== id).flatMap(entry => entry.samples.map(sample => sample.token)));
|
|
21
|
+
for (const sample of samples.values()) represented.add(sample.token);
|
|
22
|
+
const unresolved = [...owned].filter(name => !represented.has(name));
|
|
23
|
+
const source = tokenSampleSource(options,scenario);
|
|
24
|
+
const list = [...samples.values()];
|
|
25
|
+
const current = scenario.samples;
|
|
26
|
+
const next = JSON.stringify(current) === JSON.stringify(list) ? source.content : source.content.slice(0,source.start) + JSON.stringify(list,null,2) + source.content.slice(source.end);
|
|
27
|
+
return {unit:owner,id,file:source.file,sampleCount:list.length,removed,unresolved,
|
|
28
|
+
patch:textDiff(source.file,source.content,next),
|
|
29
|
+
guidance:"Bindings and probes belong to the project. No token-name/type heuristic chooses a renderer or probe. Apply the proposed owner patch through ads_apply_patch, then verify its real preview."};
|
|
30
|
+
}
|