@reqvire-org/ads 0.3.52 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- package/dist/assets.mjs +16 -2
- package/dist/behaviors.mjs +6 -5
- package/dist/boundaries.mjs +5 -5
- package/dist/browser-audit/first-render.mjs +22 -0
- package/dist/browser-audit/image-shape.mjs +36 -0
- package/dist/browser-audit/render-states.mjs +61 -35
- package/dist/browser-audit/worker.mjs +47 -12
- package/dist/browser-audit.mjs +75 -12
- package/dist/bun-compiler.mjs +14 -7
- package/dist/check-service.mjs +83 -0
- package/dist/check.mjs +20 -18
- package/dist/cli.mjs +5 -3
- package/dist/config.mjs +20 -41
- package/dist/contracts.d.mts +9 -0
- package/dist/finding-rules.mjs +8 -1
- package/dist/font-rules.mjs +103 -0
- package/dist/fonts-generated.mjs +32 -12
- package/dist/generated-entries.mjs +131 -0
- package/dist/icons.mjs +1 -1
- package/dist/init.mjs +11 -32
- package/dist/layers.mjs +7 -3
- package/dist/lint-config.mjs +4 -2
- package/dist/mcp/catalog.mjs +2 -1
- package/dist/mcp/context.mjs +3 -3
- package/dist/mcp/drafts.mjs +136 -121
- package/dist/mcp/mutations.mjs +65 -19
- package/dist/mcp/preview-watch.mjs +31 -5
- package/dist/mcp/preview-widget.bundle.js +50 -47
- package/dist/mcp/project-widget.bundle.js +45 -42
- package/dist/mcp/prompts.mjs +1 -1
- package/dist/mcp/server.mjs +81 -40
- package/dist/mcp/showcase-host.mjs +20 -7
- package/dist/mcp/widget.bundle.js +49 -46
- package/dist/oxlint.mjs +3 -2
- package/dist/program-cache.mjs +36 -0
- package/dist/public-api.mjs +2 -1
- package/dist/scenarios-compiler.mjs +82 -14
- package/dist/scenarios-vite.mjs +1 -1
- package/dist/scenarios.mjs +4 -3
- package/dist/showcase/client.bundle.js +27 -27
- package/dist/showcase/index.html +2 -2
- package/dist/skills/ads-break-ui/SKILL.md +25 -28
- package/dist/skills/ads-break-ui/references/behaviors.md +7 -6
- package/dist/skills/ads-break-ui/references/captures.md +7 -32
- package/dist/skills/ads-break-ui/references/contracts.md +58 -25
- package/dist/skills/ads-break-ui/references/drafts.md +59 -43
- package/dist/skills/ads-break-ui/references/evidence.md +1 -1
- package/dist/skills/ads-break-ui/references/guarded-editing.md +58 -47
- package/dist/skills/ads-break-ui/references/review.md +9 -8
- package/dist/skills/ads-break-ui/references/scenarios.md +1 -1
- package/dist/skills/ads-break-ui/references/validation.md +8 -4
- package/dist/skills/ads-break-ui/references/workflows.md +15 -8
- package/dist/skills/ads-designer/SKILL.md +30 -31
- package/dist/skills/ads-designer/references/accessibility.md +9 -5
- package/dist/skills/ads-designer/references/behaviors.md +7 -6
- package/dist/skills/ads-designer/references/branding.md +2 -2
- package/dist/skills/ads-designer/references/captures.md +7 -32
- package/dist/skills/ads-designer/references/cli.md +5 -1
- package/dist/skills/ads-designer/references/contracts.md +58 -25
- package/dist/skills/ads-designer/references/drafts.md +59 -43
- package/dist/skills/ads-designer/references/evidence.md +1 -1
- package/dist/skills/ads-designer/references/guarded-editing.md +58 -47
- package/dist/skills/ads-designer/references/performance.md +57 -6
- package/dist/skills/ads-designer/references/review.md +9 -8
- package/dist/skills/ads-designer/references/scenarios.md +1 -1
- package/dist/skills/ads-designer/references/validation.md +8 -4
- package/dist/skills/ads-designer/references/workflows.md +15 -8
- package/dist/skills/ads-import/SKILL.md +25 -28
- package/dist/skills/ads-import/references/behaviors.md +7 -6
- package/dist/skills/ads-import/references/captures.md +7 -32
- package/dist/skills/ads-import/references/cli.md +5 -1
- package/dist/skills/ads-import/references/contracts.md +58 -25
- package/dist/skills/ads-import/references/drafts.md +59 -43
- package/dist/skills/ads-import/references/evidence.md +1 -1
- package/dist/skills/ads-import/references/guarded-editing.md +58 -47
- package/dist/skills/ads-import/references/review.md +9 -8
- package/dist/skills/ads-import/references/scenarios.md +1 -1
- package/dist/skills/ads-import/references/validation.md +8 -4
- package/dist/skills/ads-import/references/workflows.md +15 -8
- package/dist/skills/ads-motion/SKILL.md +25 -28
- package/dist/skills/ads-motion/references/behaviors.md +7 -6
- package/dist/skills/ads-motion/references/captures.md +7 -32
- package/dist/skills/ads-motion/references/contracts.md +58 -25
- package/dist/skills/ads-motion/references/drafts.md +59 -43
- package/dist/skills/ads-motion/references/evidence.md +1 -1
- package/dist/skills/ads-motion/references/guarded-editing.md +58 -47
- package/dist/skills/ads-motion/references/review.md +9 -8
- package/dist/skills/ads-motion/references/scenarios.md +1 -1
- package/dist/skills/ads-motion/references/validation.md +8 -4
- package/dist/skills/ads-motion/references/workflows.md +15 -8
- package/dist/skills/ads-port/SKILL.md +25 -28
- package/dist/skills/ads-port/references/behaviors.md +7 -6
- package/dist/skills/ads-port/references/captures.md +7 -32
- package/dist/skills/ads-port/references/cli.md +5 -1
- package/dist/skills/ads-port/references/contracts.md +58 -25
- package/dist/skills/ads-port/references/drafts.md +59 -43
- package/dist/skills/ads-port/references/evidence.md +1 -1
- package/dist/skills/ads-port/references/guarded-editing.md +58 -47
- package/dist/skills/ads-port/references/native-implementation.md +6 -6
- package/dist/skills/ads-port/references/review.md +9 -8
- package/dist/skills/ads-port/references/scenarios.md +1 -1
- package/dist/skills/ads-port/references/validation.md +8 -4
- package/dist/skills/ads-port/references/workflows.md +15 -8
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.ads.contract.ts +6 -0
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.ads.contract.ts +6 -0
- package/dist/starters/preact/ds.config.json +0 -14
- package/dist/starters/react/README.md +9 -5
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +1 -1
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +2 -2
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +2 -2
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.contract.ts +6 -0
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/controllers/Palette/Palette.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/index.ts +3 -7
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/grid-cell/GridCell.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/index.ts +4 -3
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.contract.ts +6 -0
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/styles.css +1 -0
- package/dist/starters/react/ds.config.json +0 -14
- package/dist/style-boundaries.mjs +7 -6
- package/dist/test-boundaries.mjs +2 -2
- package/dist/themes-watch.mjs +9 -3
- package/dist/token-fixtures.mjs +1 -1
- package/dist/unit-contracts.mjs +38 -4
- package/dist/units.mjs +16 -91
- package/dist/validation-checks.mjs +7 -1
- package/docs/ADS.md +10 -10
- package/docs/ARCHITECTURE.md +104 -44
- package/docs/BEHAVIORS.md +8 -7
- package/docs/CACHING.md +15 -6
- package/docs/CHANGELOG.md +107 -12
- package/docs/COMPARISON.md +1 -1
- package/docs/CONTRACTS.md +10 -25
- package/docs/GUIDE.md +98 -57
- package/docs/MCP.md +116 -151
- package/package.json +7 -7
- package/dist/contract-migration.mjs +0 -110
- package/dist/mcp/draft-exports.mjs +0 -40
- package/dist/mcp/edit-preparation.mjs +0 -115
package/docs/MCP.md
CHANGED
|
@@ -95,9 +95,11 @@ the slots. Read the returned PNG resources before visual acceptance; the result
|
|
|
95
95
|
is explicitly `previewOnly`, not behavioral or acceptance evidence.
|
|
96
96
|
|
|
97
97
|
`ads_accept({id,revision})` validates and applies the exact reviewed revision in
|
|
98
|
-
one operation
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
one operation; `dryRun:true` runs every check and writes nothing. It is the only way
|
|
99
|
+
MCP writes accepted source. Architecture, configured project commands and affected
|
|
100
|
+
behavior checks remain mandatory. `acceptance.browserAudit` chooses the axe-core
|
|
101
|
+
audit: `"owners"` (default) renders the draft owners' own UI scenarios, `"affected"`
|
|
102
|
+
every scenario the change reaches, `false` none; each in every declared brand and
|
|
101
103
|
theme, with the non-text contrast and overflow checks; any `a11y-axe`,
|
|
102
104
|
`a11y-non-text-contrast` or `layout-overflow` error rejects acceptance. Edits during checking and baseline conflicts
|
|
103
105
|
prevent application; failures retain the draft and return execution evidence.
|
|
@@ -366,11 +368,8 @@ The server supplies agent guidance through its instructions, tool descriptions,
|
|
|
366
368
|
| `ads_capture_clear` | Remove generated captures or discard only the candidate |
|
|
367
369
|
| `ads_show_<id>` | Optional explicitly configured grouped App |
|
|
368
370
|
| `ads_units` | Discover edit owners and the files belonging to one unit |
|
|
369
|
-
| `
|
|
370
|
-
| `ads_prepare_token_samples` | Reconcile real-token fixture samples using explicit project bindings |
|
|
371
|
-
| `ads_apply_transaction` | Validate and apply coupled owner patches as one final candidate |
|
|
371
|
+
| `ads_prepare_token_samples` | Reconcile real-token fixture samples into a draft, using explicit project bindings |
|
|
372
372
|
| `ads_read_file` | Read bounded source ranges, with owning unit and full-file digest |
|
|
373
|
-
| `ads_apply_patch` | Opt-in Git unified diff for one ADS unit, with dry-run validation |
|
|
374
373
|
|
|
375
374
|
Scenario results include `group` only when folder structure supplies one. It is
|
|
376
375
|
computed output, never scenario metadata. `ads_scenarios({query: "Forms"})` searches
|
|
@@ -435,11 +434,10 @@ viewport; optional `captureTargets` metadata names an element within the scenari
|
|
|
435
434
|
Token/component/pattern/composition scenarios share this path. The tool adds no
|
|
436
435
|
project-specific renderer or fixture assumptions.
|
|
437
436
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
scenario has a candidate with an explicit absent current baseline.
|
|
437
|
+
`ads_capture` with a draft `id` and exact `revision` captures current and candidate
|
|
438
|
+
under matching settings without acceptance checks; acceptance and its dry run take
|
|
439
|
+
no screenshots. A newly added scenario has a candidate with an explicit absent
|
|
440
|
+
current baseline.
|
|
443
441
|
|
|
444
442
|
`ads://project/captures` lists current/candidate slots, metadata and freshness.
|
|
445
443
|
Read returned `ads://captures/{key}/{slot}` resources as `image/png` binary content;
|
|
@@ -554,10 +552,12 @@ Enable editing in the MCP launch arguments and reconnect:
|
|
|
554
552
|
npx -y @reqvire-org/ads mcp --mutations
|
|
555
553
|
```
|
|
556
554
|
|
|
557
|
-
`ads_status.mutations` reports the mode, checks, limits and latest
|
|
558
|
-
is disabled by default.
|
|
559
|
-
|
|
560
|
-
|
|
555
|
+
`ads_status.mutations` reports the mode (`route: "draft"`), checks, limits and latest
|
|
556
|
+
result. Editing is disabled by default. Every change goes through a draft of one or
|
|
557
|
+
more owners: `ads_create_draft`, edits through its files or `ads_update_draft`
|
|
558
|
+
(contents, or a Git unified diff as `patch`/`patchFile`), `ads_show_draft`, then
|
|
559
|
+
`ads_accept`. An owner is in at most one open draft; genuinely coupled owners share
|
|
560
|
+
one draft.
|
|
561
561
|
|
|
562
562
|
Find the owner with `ads_units({ "query": "Button" })`, then request its file
|
|
563
563
|
manifest with `ads_units({ "unit": "components/core/Button" })`. IDs derive from
|
|
@@ -574,27 +574,23 @@ reviews and the token export; `ads://guides/branding` for brand artwork, web ico
|
|
|
574
574
|
committed targets and glyph sets; `ads://guides/accessibility` for the WCAG 2.2 AA
|
|
575
575
|
guards (`token-contrast`, `component-contrast`, `a11y-*`) and the practice no tool can check.
|
|
576
576
|
|
|
577
|
-
The
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
Unused inline exceptions and properties never written fail `stale-style-boundary`;
|
|
592
|
-
configuration-first registration of an unused boundary therefore fails validation.
|
|
593
|
-
General policy, component customization hooks and compiler changes still use the
|
|
594
|
-
`configuration` unit.
|
|
577
|
+
No owner edits a shared entry. The styles entry is generated from the canonical
|
|
578
|
+
token sheets in foundation order: adding `tokens/fonts.css` adds its import, and
|
|
579
|
+
removing the sheet removes it. The public barrel and review entry are generated
|
|
580
|
+
from the owners' `<Owner>.ads.exports.ts` files. A draft that edits a generated entry
|
|
581
|
+
is refused.
|
|
582
|
+
|
|
583
|
+
An owner declares its own style permissions in its contract: `styles.writes`
|
|
584
|
+
(properties a file writes at runtime), `styles.inline` (files with inline geometry
|
|
585
|
+
styles) and, for a component, `customization` (non-state `--ds-*` variables others may
|
|
586
|
+
set). A JSX-to-imperative geometry change edits the source and the contract together
|
|
587
|
+
in the owner's draft. Unused inline permissions and properties never written fail
|
|
588
|
+
`stale-style-boundary` on the contract, so a permission cannot be declared before its
|
|
589
|
+
implementation. `ds.config.json` holds no per-owner entries; general policy and
|
|
590
|
+
compiler changes use the `configuration` unit.
|
|
595
591
|
|
|
596
592
|
A directory owner's runtime entry (`index` or a source file matching its directory
|
|
597
|
-
name)
|
|
593
|
+
name) keeps ownership stable without its `<Dir>.ads.scenario.tsx`.
|
|
598
594
|
A redundant standalone scenario can be removed when other registered scenarios
|
|
599
595
|
still declare and actually render its public exports. Coverage requirements remain
|
|
600
596
|
in force; there is no metadata waiver for uncovered UI.
|
|
@@ -605,7 +601,7 @@ The same discovery covers the rest of the project ADS:
|
|
|
605
601
|
|
|
606
602
|
| Unit | Scope |
|
|
607
603
|
|------|-------|
|
|
608
|
-
| `review/<Owner>` | Development-only frames, token renderers, demo controls, local checks and review
|
|
604
|
+
| `review/<Owner>` | Development-only frames, token renderers, demo controls, local checks and their review exports file |
|
|
609
605
|
| `foundation` | Shared ADS entry styles and root helpers |
|
|
610
606
|
| `documentation` | ADS/project guides, shared credits and license notices, and `licenses/` text collections |
|
|
611
607
|
| `assets/brand`, `assets/fonts`, other `assets/*` groups | Original SVG, image, font and other asset files |
|
|
@@ -632,115 +628,83 @@ Unregistered application code and installed dependencies retain their own owners
|
|
|
632
628
|
Read relevant source with `ads_read_file({ "path": "design-system/components/core/Button.tsx" })`.
|
|
633
629
|
Reads are bounded to 12,000 UTF-16 characters. `offset`, `nextOffset`, `startLine`
|
|
634
630
|
and `totalChars` support focused follow-up reads. The digest describes the whole
|
|
635
|
-
file
|
|
636
|
-
digest to apply a patch.
|
|
631
|
+
file; the agent does not need to read or send the whole file.
|
|
637
632
|
|
|
638
|
-
|
|
639
|
-
{
|
|
640
|
-
"unit": "components/core/Button",
|
|
641
|
-
"dryRun": true,
|
|
642
|
-
"patch": "<Git unified diff for this unit>"
|
|
643
|
-
}
|
|
644
|
-
```
|
|
645
|
-
|
|
646
|
-
Send this to `ads_apply_patch`. Use ordinary `diff --git`, `--- a/path`,
|
|
647
|
-
`+++ b/path` and `@@ -old,count +new,count @@` text hunks with project-relative
|
|
648
|
-
paths. Context and removed lines must match the current source at the stated
|
|
649
|
-
positions; ADS uses no fuzzy matching. `/dev/null` identifies a created or deleted
|
|
650
|
-
file. New files naturally contain their added lines. Original binary images,
|
|
651
|
-
fonts and other assets use `git diff --binary --full-index`; Git 2.29 or newer must be installed
|
|
652
|
-
to validate/apply those blocks. Rename metadata and permission changes are
|
|
653
|
-
unsupported; owned deletion/creation can move a file within its unit.
|
|
654
|
-
|
|
655
|
-
For a large or binary diff, write the Git patch to a regular file in
|
|
656
|
-
`.ds/patches/`, then send a reference instead of its bytes:
|
|
633
|
+
Create the owner's draft, edit it, review it and accept it:
|
|
657
634
|
|
|
658
635
|
```json
|
|
659
|
-
{
|
|
660
|
-
"unit": "assets/fonts",
|
|
661
|
-
"dryRun": false,
|
|
662
|
-
"patchFile": ".ds/patches/font.patch"
|
|
663
|
-
}
|
|
636
|
+
{ "units": ["components/core/Button"] }
|
|
664
637
|
```
|
|
665
638
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
byte count without encoded content. Git verifies the original binary blob and
|
|
669
|
-
reconstructs the result inside the validation copy.
|
|
670
|
-
|
|
671
|
-
For local editing without a second Git mirror, call
|
|
672
|
-
`ads_prepare_patch({unit, action:"create"})`. It returns a draft ID and a local
|
|
673
|
-
directory containing only the owner and declared companions. Edit that directory
|
|
674
|
-
using the client's local file tools, then call
|
|
675
|
-
`ads_prepare_patch({unit, action:"diff", draft})`. It checks source/baseline
|
|
676
|
-
freshness and owner paths and returns a `patchFile`; it changes no live source.
|
|
677
|
-
Pass that `patchFile` to `ads_apply_patch` with `dryRun:true` to validate before
|
|
678
|
-
applying. This runs the normal candidate gates, including affected registered
|
|
679
|
-
behavior checks against an isolated candidate and its configured browser preview
|
|
680
|
-
and, unless `acceptance.browserAudit` is false, the candidate accessibility audit.
|
|
681
|
-
It writes no live source and does not persist passing evidence for live inputs.
|
|
682
|
-
Read the summary, then use its `resultId` with `ads_results` for failing
|
|
683
|
-
`outcomes`, `diagnostics` or named pipeline `checks`; update the draft, diff again
|
|
684
|
-
and repeat as needed. Apply with `dryRun:false` after validation;
|
|
685
|
-
the gates run again. `ads_verify({unit,checks?})` checks current source and accepts
|
|
686
|
-
no draft argument; a selected-check draft runner is not currently exposed.
|
|
687
|
-
Use `action:"discard"` to remove the draft. Remote clients can continue sending
|
|
688
|
-
inline Git diffs. Drafts are local conveniences, not an alternative mutation API.
|
|
689
|
-
|
|
690
|
-
`ads_prepare_token_samples({id, bindings?})` reconciles the selected token
|
|
691
|
-
scenario's consumed literal sample array. Existing bindings and other fixture
|
|
692
|
-
fields are preserved; undeclared samples are removed. New bindings explicitly
|
|
693
|
-
name a real `token`, CSS `property` and `probe`. Missing mappings are reported as
|
|
694
|
-
`unresolved`; ADS never guesses a property or renderer from the token name.
|
|
695
|
-
The result is an owner patch file for guarded application. This preparation does
|
|
696
|
-
not establish rendered effects or waive token coverage.
|
|
697
|
-
|
|
698
|
-
For a coupled rename or upgrade, call `ads_apply_transaction`:
|
|
639
|
+
`ads_create_draft` returns the draft `id`, `revision` and its folder; edit the `.ads`
|
|
640
|
+
files there with local tools, or send the change through `ads_update_draft`:
|
|
699
641
|
|
|
700
642
|
```json
|
|
701
643
|
{
|
|
702
|
-
"
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
],
|
|
706
|
-
"dryRun": true
|
|
644
|
+
"id": "<draft id>",
|
|
645
|
+
"revision": "<current revision>",
|
|
646
|
+
"patch": "<Git unified diff>"
|
|
707
647
|
}
|
|
708
648
|
```
|
|
709
649
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
650
|
+
Use ordinary `diff --git`, `--- a/path`, `+++ b/path` and `@@ -old,count +new,count @@`
|
|
651
|
+
text hunks with project-relative paths. Context and removed lines must match the
|
|
652
|
+
draft's current proposal at the stated positions; ADS uses no fuzzy matching.
|
|
653
|
+
`/dev/null` identifies a created or deleted file, and a new path joins its declared
|
|
654
|
+
owner. Rename metadata and permission changes are unsupported; owned
|
|
655
|
+
deletion/creation can move a file within its unit. For a large diff, write it to a
|
|
656
|
+
regular file in `.ds/patches/` and pass `patchFile` instead of `patch`. Binary
|
|
657
|
+
images, fonts and other assets go through `changes` with `encoding:"base64"`; binary
|
|
658
|
+
`ads_read_file` results return the digest and byte count without encoded content.
|
|
659
|
+
|
|
660
|
+
Review the draft with `ads_show_draft`, then check it with
|
|
661
|
+
`ads_accept({id, revision, dryRun:true})`. This runs the normal candidate gates,
|
|
662
|
+
including affected registered behavior checks and the acceptance accessibility audit,
|
|
663
|
+
in the draft's workspace through the project's compiler; it writes no live source and
|
|
664
|
+
does not persist passing evidence for live inputs. Read the summary, then use its
|
|
665
|
+
`resultId` with `ads_results` for failing `outcomes`, `diagnostics` or named pipeline
|
|
666
|
+
`checks`; update the draft and repeat. Accept with `ads_accept({id, revision})`; the
|
|
667
|
+
gates run again, reusing the dry run's results for the same revision.
|
|
668
|
+
`ads_verify({unit,checks?})` checks current source and accepts no draft argument.
|
|
669
|
+
|
|
670
|
+
`ads_prepare_token_samples({id, bindings?, draft?})` reconciles the selected token
|
|
671
|
+
scenario's consumed literal sample array. Existing bindings and other fixture fields
|
|
672
|
+
are preserved; undeclared samples are removed. New bindings explicitly name a real
|
|
673
|
+
`token`, CSS `property` and `probe`. Missing mappings are reported as `unresolved`;
|
|
674
|
+
ADS never guesses a property or renderer from the token name. The result is written
|
|
675
|
+
into a draft (the given one, or a new one for the scenario's owner) for review and
|
|
676
|
+
acceptance. This preparation does not establish rendered effects or waive token
|
|
677
|
+
coverage.
|
|
678
|
+
|
|
679
|
+
For a coupled rename or upgrade, create one draft for all its owners (2–64 owners, at
|
|
680
|
+
most 256 distinct files) and accept it once. Core checks, configured project
|
|
681
|
+
commands, all affected behavior checks and the accessibility audit run against the
|
|
682
|
+
final candidate. Dry runs, failures, conflicts and cancellation write no source; a
|
|
683
|
+
publication failure rolls back prior writes. This coordinates owned source changes,
|
|
684
|
+
not dependency installation or arbitrary application files. Install changed
|
|
685
|
+
dependencies before verification; candidates use the project's installed
|
|
686
|
+
`node_modules`.
|
|
721
687
|
|
|
722
688
|
Resolve ownership diagnostics by preserving the required capability in its proper
|
|
723
689
|
layer. Demo-only sizing, borders and framing belong in a development-only review
|
|
724
690
|
helper; a component API addition needs a runtime use case. Measured imperative
|
|
725
|
-
geometry uses exact `
|
|
726
|
-
|
|
727
|
-
After the gates pass, verify the behavior in a
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
and validates a temporary project copy with mandatory native ADS guards. The
|
|
743
|
-
project's acceptance policy selects additional scripts and registered tests:
|
|
691
|
+
geometry uses exact `styles.writes` properties in the owner's contract. After
|
|
692
|
+
moving JSX inline geometry to imperative writes, update the contract in the same
|
|
693
|
+
draft and check the final state. After the gates pass, verify the behavior in a
|
|
694
|
+
browser.
|
|
695
|
+
|
|
696
|
+
A small change needs only its hunk. A complete new component's draft includes its
|
|
697
|
+
implementation, its `<Owner>.ads.exports.ts`, scenario and fixture, so coverage is
|
|
698
|
+
checked against a complete candidate; the barrel is regenerated from the exports
|
|
699
|
+
file. New units use a new `components/`, `patterns/`, `controllers/`, `review/` or
|
|
700
|
+
`composition/` owner ID following the same colocation convention. A draft cannot
|
|
701
|
+
include a peer unit or capture existing peers beneath a new directory owner, and a
|
|
702
|
+
failed acceptance requires correcting its owner or policy, never a direct-write
|
|
703
|
+
bypass.
|
|
704
|
+
|
|
705
|
+
Acceptance reconstructs complete candidate files and validates a temporary project
|
|
706
|
+
copy with mandatory native ADS guards. The project's acceptance policy selects
|
|
707
|
+
additional scripts and registered tests:
|
|
744
708
|
|
|
745
709
|
```json
|
|
746
710
|
{
|
|
@@ -755,8 +719,7 @@ behavior checks default to false; validation behavior checks default to true.
|
|
|
755
719
|
Managed previews are built for required behavior checks or requested captures,
|
|
756
720
|
sharing one production graph. Core-only acceptance does not build the whole
|
|
757
721
|
preview graph. Keep standalone preview builds in normal project builds; avoid
|
|
758
|
-
selecting the same build twice.
|
|
759
|
-
`acceptance.checks` and choose `acceptance.behaviorChecks` explicitly.
|
|
722
|
+
selecting the same build twice.
|
|
760
723
|
|
|
761
724
|
Every listed script must exist. An empty list still runs mandatory ADS guards; registered tests run only when the policy enables them. Scripts use the project's npm/Bun runner; installed dependencies are
|
|
762
725
|
shared with the validation copy. These are trusted project commands, not an OS
|
|
@@ -1012,7 +975,11 @@ compiler and warms the prioritized view followed by the remaining graph in
|
|
|
1012
975
|
the background. Jobs run sequentially; foreground selections have priority. The client configuration above stays the same; no second terminal
|
|
1013
976
|
or separately managed server is needed. An explicit `mcp.previewWatch` is reserved
|
|
1014
977
|
for a custom compiler integration; remove former project Vite build commands to
|
|
1015
|
-
adopt native compilation.
|
|
978
|
+
adopt native compilation. A custom compiler calls
|
|
979
|
+
`runScenarioCompiler(root, root => ({ watched, compilerFiles, validate, buildGraph }))`:
|
|
980
|
+
the function of the root lets the same process compile every draft preview too, each
|
|
981
|
+
with its own builder, after the project's selected view. Options fixed to one root build
|
|
982
|
+
only the project, and each draft preview then reports that it cannot be compiled.
|
|
1016
983
|
For direct editing with external compilation, set `mcp.previewWatch: false`.
|
|
1017
984
|
An agent or human edits code and runs `ads compile .` or an external watch/builder
|
|
1018
985
|
that publishes the ADS resource graph and build evidence. MCP serves that output
|
|
@@ -1125,8 +1092,7 @@ source changes. Such previews retain their last successful revision and output,
|
|
|
1125
1092
|
but report `current: false`, `stale: true` and `ADS_PREVIEW_STALE_SOURCE` while
|
|
1126
1093
|
awaiting the current build. Changes during compilation also invalidate success.
|
|
1127
1094
|
|
|
1128
|
-
|
|
1129
|
-
compiler after publication. Filesystem events provide fast updates; one-second
|
|
1095
|
+
Accepted drafts explicitly invalidate the managed compiler after publication. Filesystem events provide fast updates; one-second
|
|
1130
1096
|
input reconciliation recovers missed atomic replacements without touching source
|
|
1131
1097
|
or restarting MCP. Keep the project compiler's ADS dependency and the MCP package
|
|
1132
1098
|
updated together: older reports without source evidence cannot establish freshness.
|
|
@@ -1167,7 +1133,7 @@ not repair source automatically.
|
|
|
1167
1133
|
### Custom builder integration (advanced)
|
|
1168
1134
|
|
|
1169
1135
|
The standard graph adapter already uses this reporter through
|
|
1170
|
-
`runScenarioCompiler`; use [
|
|
1136
|
+
`runScenarioCompiler`; use [managed preview builds](#one-client-command-managed-preview-builds)
|
|
1171
1137
|
for that path. Custom builders can integrate the framework-independent reporter
|
|
1172
1138
|
with their own publication step. A selective HTML builder, for example, uses one
|
|
1173
1139
|
shared reporter for the compiler process:
|
|
@@ -1255,7 +1221,7 @@ addressable at its original resource URI.
|
|
|
1255
1221
|
`ads-import` assesses the destination and adapts selected source to its contracts.
|
|
1256
1222
|
Its compatibility reference is available at
|
|
1257
1223
|
`skill://ads/ads-import/references/compatibility.md`. Existing owner drafts,
|
|
1258
|
-
coupled
|
|
1224
|
+
coupled multi-owner drafts and candidate checks support the workflow; there is no
|
|
1259
1225
|
separate import tool, version-based acceptance filter or compatibility certificate.
|
|
1260
1226
|
The agent resolves semantic differences and reviews rendered behavior. Candidate
|
|
1261
1227
|
validation uses installed project dependencies; package installation remains a
|
|
@@ -1345,11 +1311,7 @@ contract source for additional relationships. Read the relevant source range;
|
|
|
1345
1311
|
these summaries establish registration, not completed verification. Detailed
|
|
1346
1312
|
results remain bounded and paged.
|
|
1347
1313
|
|
|
1348
|
-
|
|
1349
|
-
filenames and compatible legacy sections in a local draft. Inspect its notes,
|
|
1350
|
-
then use the existing diff and guarded dry-run/apply workflow. It does not write
|
|
1351
|
-
live source, loosen policy or add a second contract-editing protocol. See
|
|
1352
|
-
[CONTRACTS.md](CONTRACTS.md) for the static schema, compatibility and browser audits.
|
|
1314
|
+
See [CONTRACTS.md](CONTRACTS.md) for the static schema, compatibility and browser audits.
|
|
1353
1315
|
The same guide is available at `ads://guides/contracts`.
|
|
1354
1316
|
|
|
1355
1317
|
A registered binding producer gives a per-theme value with `themed()` or
|
|
@@ -1423,13 +1385,16 @@ scenario's failure. A retained earlier view is not current-source evidence.
|
|
|
1423
1385
|
`ads_validate({policy:"acceptance"})` matches `ads validate --policy acceptance`:
|
|
1424
1386
|
it checks the acceptance policy against current source without applying anything.
|
|
1425
1387
|
Validation and acceptance keep separate baselines; acceptance cannot establish
|
|
1426
|
-
full validation. Each policy chooses `checks`, `behaviorChecks` and `browserAudit
|
|
1427
|
-
axe-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1388
|
+
full validation. Each policy chooses `checks`, `behaviorChecks` and `browserAudit`;
|
|
1389
|
+
its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors, and
|
|
1390
|
+
skipped tests are reported as skipped, without a passing label. `validation.browserAudit`
|
|
1391
|
+
(on by default, `false` turns it off) audits every UI scenario in every brand and theme;
|
|
1392
|
+
with `scope:"changed"` it is the stage check after a series of accepted drafts. Draft
|
|
1393
|
+
preview/edit triggers neither policy. Draft acceptance runs the acceptance policy on
|
|
1394
|
+
its candidate before writing source; `acceptance.browserAudit` audits the draft owners'
|
|
1395
|
+
own UI scenarios (`"owners"`, the default), every scenario the change reaches
|
|
1396
|
+
(`"affected"`: all of them after configuration, foundation, token or asset changes) or
|
|
1397
|
+
none (`false`). `mcp.auditPages` (1–16, default 4) sets how many pages render at once. Any `a11y-axe`, `a11y-non-text-contrast` or
|
|
1433
1398
|
`layout-overflow` error, a scenario that fails all 3 attempts (`browser-audit`, naming it and the
|
|
1434
1399
|
last cause, with retried passes listed under `retries`), or an audit that
|
|
1435
1400
|
cannot run (`browser-audit`: no project Playwright or browser; the message names what to
|
|
@@ -1480,8 +1445,8 @@ selected commands; ADS cannot infer arbitrary filesystem access inside a command
|
|
|
1480
1445
|
## Shared-process execution coordination
|
|
1481
1446
|
|
|
1482
1447
|
One ADS process has an exclusive execution lease shared by its HTTP and stdio
|
|
1483
|
-
clients. `ads_validate` (both policies/scopes), `ads_verify
|
|
1484
|
-
|
|
1448
|
+
clients. `ads_validate` (both policies/scopes), `ads_verify` and `ads_accept` acquire
|
|
1449
|
+
it before work and retain it
|
|
1485
1450
|
through child/ownership-guard cleanup and result publication. Changed scope still
|
|
1486
1451
|
runs full project scripts. Parallel units and `wait: true` are not supported.
|
|
1487
1452
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reqvire-org/ads",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A design system your agent can see and shape. Your components. Your look. Your code.",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"ads-read-mcp": "node scripts/build-ads-tool.mjs 1>&2 && bun dist/cli.mjs mcp",
|
|
26
26
|
"dev:showcase": "node scripts/build-ads-tool.mjs && bun dist/cli.mjs showcase",
|
|
27
27
|
"dev:mcp-explorer": "node scripts/build-ads-tool.mjs && node mcp-explorer/server.mjs",
|
|
28
|
-
"build": "npm run lint:tool && npm run build:tool",
|
|
28
|
+
"build": "npm run sync:skill-references && npm run lint:tool && npm run build:tool",
|
|
29
29
|
"build:tool": "node scripts/build-ads-tool.mjs",
|
|
30
30
|
"build:project": "npm run build:tool && npm run lint:project && npm run generate:icons && npm run typecheck && vite build && node scripts/build-mcp-previews.mjs",
|
|
31
31
|
"build:lib": "npm run generate:icons && vite build",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"pack:tool": "node scripts/pack-ads-tool.mjs",
|
|
48
48
|
"ads": "bun dist/cli.mjs",
|
|
49
49
|
"prepack": "npm run build",
|
|
50
|
-
"release:verify": "node scripts/local-test-proof.mjs",
|
|
50
|
+
"release:verify": "node scripts/sync-skill-references.mjs --check && node scripts/local-test-proof.mjs",
|
|
51
51
|
"release:proof": "node scripts/local-test-proof.mjs --check"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@modelcontextprotocol/server": "2.
|
|
54
|
+
"@modelcontextprotocol/server": "2.4.0",
|
|
55
55
|
"@wyw-in-js/transform": "2.1.3",
|
|
56
56
|
"axe-core": "4.14.0",
|
|
57
57
|
"css-tree": "3.2.1",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"@linaria/atomic": "^8.0.0",
|
|
73
73
|
"@linaria/core": "^7.0.0",
|
|
74
74
|
"@linaria/react": "^7.0.1",
|
|
75
|
-
"@modelcontextprotocol/client": "2.
|
|
76
|
-
"@modelcontextprotocol/ext-apps": "2.0.
|
|
77
|
-
"@modelcontextprotocol/sdk": "1.32.
|
|
75
|
+
"@modelcontextprotocol/client": "2.4.0",
|
|
76
|
+
"@modelcontextprotocol/ext-apps": "2.0.4",
|
|
77
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
78
78
|
"@playwright/test": "1.64.1",
|
|
79
79
|
"@preact/signals": "2.11.3",
|
|
80
80
|
"@types/node": "^25.9.2",
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import ts from "typescript";
|
|
4
|
-
import { adsFileRole, isBehaviorFile, isScenarioFile, loadConfig, scenarioIdentity } from "./config.mjs";
|
|
5
|
-
import { inspectUnitContracts } from "./unit-contracts.mjs";
|
|
6
|
-
import { publicApi } from "./public-api.mjs";
|
|
7
|
-
import { projectCompilerOptions } from "./boundaries.mjs";
|
|
8
|
-
|
|
9
|
-
const slash=value=>value.replaceAll("\\","/");
|
|
10
|
-
|
|
11
|
-
/** Mechanical edits in an ordinary owner draft. Never writes live source. */
|
|
12
|
-
export function migrateContractDraft(options, prepared) {
|
|
13
|
-
const base=prepared.directory, name=path.posix.basename(prepared.unit), renames=new Map(), notes=[];
|
|
14
|
-
const relative=file=>slash(path.relative(base,file));
|
|
15
|
-
const resolve=file=>path.join(base,file);
|
|
16
|
-
const files=prepared.files.filter(file=>!file.endsWith("ds.config.json")&&file.startsWith(options.config.dsDir+"/"));
|
|
17
|
-
const owned=files.filter(file=>!file.endsWith("/"+options.config.publicEntry)&&!file.endsWith("/"+options.config.reviewEntry));
|
|
18
|
-
for(const file of owned) {
|
|
19
|
-
if(adsFileRole(file)||!/\.[cm]?[jt]sx?$/.test(file))continue;
|
|
20
|
-
let next;
|
|
21
|
-
if(isScenarioFile(file))next=path.basename(file).startsWith("Scenario.")?path.join(path.dirname(file),`${name}.ads.scenario${path.extname(file)}`):file.replace(/\.scenario\./,".ads.scenario.");
|
|
22
|
-
else if(/(?:^|\/)fixture\.[cm]?[jt]sx?$/.test(file))next=path.join(path.dirname(file),`${name}.ads.fixture${path.extname(file)}`);
|
|
23
|
-
else if(/\.(?:fixture|fixtures|test|spec)\.[cm]?[jt]sx?$/.test(file))next=file.replace(/\.(behavior\.spec|fixture|fixtures|test|spec)(\.[^.]+)$/,".ads.$1$2");
|
|
24
|
-
else if(/\.scenario-adapter\.[cm]?[jt]sx?$/.test(file))next=file.replace(/\.scenario-adapter\./,".ads.helpers.");
|
|
25
|
-
if(next&&next!==file) {
|
|
26
|
-
next=slash(next);
|
|
27
|
-
if(isScenarioFile(file)&&scenarioIdentity(path.join(options.root,file),options.dsRoot)===prepared.unit&&scenarioIdentity(path.join(options.root,next),options.dsRoot)!==prepared.unit){notes.push(`Kept ${file}: a default-directory rename would change this flat owner's identity. Review a deliberate owner migration separately.`);continue;}
|
|
28
|
-
if([...renames.values()].includes(next)&&isScenarioFile(file))next=next.replace(".ads.scenario.",".named.ads.scenario.");
|
|
29
|
-
if(existsSync(resolve(next)))throw new Error(`Migration would overwrite ${next}; resolve the naming conflict in this draft.`);
|
|
30
|
-
renames.set(file,next);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
for(const file of owned.filter(isScenarioFile)) {
|
|
34
|
-
const fixtureBase=path.basename(file).startsWith("Scenario.")?path.join(path.dirname(file),"fixture"):file.replace(/\.scenario\.[^.]+$/,".fixture");
|
|
35
|
-
const fixture=owned.find(candidate=>candidate.startsWith(fixtureBase+".")&&/\.(?:[cm]?[jt]sx?|json)$/.test(candidate));
|
|
36
|
-
if(!fixture)continue;
|
|
37
|
-
const scenario=renames.get(file);
|
|
38
|
-
if(scenario)renames.set(fixture,scenario.replace(/\.scenario\.[^.]+$/,".fixture")+path.extname(fixture));
|
|
39
|
-
else renames.delete(fixture);
|
|
40
|
-
}
|
|
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(isBehaviorFile);
|
|
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
|
-
const text=readFileSync(resolve(from),"utf8"),source=ts.createSourceFile(from,text,ts.ScriptTarget.Latest,true,ts.ScriptKind.TSX);
|
|
45
|
-
const declaration=source.statements.filter(ts.isVariableStatement).flatMap(statement=>statement.declarationList.declarations).find(declaration=>ts.isIdentifier(declaration.name)&&declaration.name.text==="scenario");
|
|
46
|
-
let expression=declaration?.initializer;while(expression&&(ts.isAsExpression(expression)||ts.isSatisfiesExpression(expression)||ts.isParenthesizedExpression(expression)))expression=expression.expression;
|
|
47
|
-
if(expression&&ts.isObjectLiteralExpression(expression)) {
|
|
48
|
-
if(!expression.properties.some(property=>property.name?.getText()==="id")){const at=expression.getStart()+1;writeFileSync(resolve(from),text.slice(0,at)+`id:${JSON.stringify(scenarioIdentity(path.join(options.root,from),options.dsRoot))},`+text.slice(at));}
|
|
49
|
-
}else {renames.delete(from);notes.push(`Kept ${from}: its indirect metadata needs an explicit stable id before this rename.`);}
|
|
50
|
-
}
|
|
51
|
-
const runtime=owned.find(file=>!adsFileRole(file)&&!isScenarioFile(file)&&new RegExp(`(?:^|/)${name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\.[cm]?[jt]sx?$`).test(file));
|
|
52
|
-
const directory=runtime?path.dirname(runtime):path.dirname(owned[0]??path.join(options.config.dsDir,prepared.unit,"entry.ts"));
|
|
53
|
-
const contractFile=slash(path.join(directory,`${name}.ads.contract.ts`));
|
|
54
|
-
const contract={schemaVersion:1},imports=[],references=new Map();
|
|
55
|
-
const compiler=ts.createProgram(files.filter(file=>/\.[cm]?[jt]sx?$/.test(file)).map(file=>path.resolve(options.root,file)),{...projectCompilerOptions(options),allowJs:true});
|
|
56
|
-
const checker=compiler.getTypeChecker(),apis=publicApi(compiler,options);
|
|
57
|
-
function importReference(file,symbol) {
|
|
58
|
-
const source=compiler.getSourceFile(path.resolve(options.root,file));
|
|
59
|
-
const module=source&&checker.getSymbolAtLocation(source);
|
|
60
|
-
const exported=module&&checker.getExportsOfModule(module).find(item=>item.name===symbol);
|
|
61
|
-
if(!exported)throw new Error(`${file}#${symbol} is not an importable internal export; keep the legacy section until its owner deliberately exposes a local contract reference.`);
|
|
62
|
-
const key=`${file}#${symbol}`;
|
|
63
|
-
if(!references.has(key)) {
|
|
64
|
-
const alias=`subject${references.size}`;references.set(key,alias);
|
|
65
|
-
let specifier=slash(path.relative(path.dirname(contractFile),file)).replace(/\.[cm]?[jt]sx?$/,"");if(!specifier.startsWith("."))specifier="./"+specifier;
|
|
66
|
-
imports.push(`import { ${symbol} as ${alias} } from ${JSON.stringify(specifier)};`);
|
|
67
|
-
}
|
|
68
|
-
return `__ads_reference_${references.get(key)}__`;
|
|
69
|
-
}
|
|
70
|
-
const remove=[];
|
|
71
|
-
if(!existsSync(resolve(contractFile)))for(const file of jsonFiles) {
|
|
72
|
-
const value=JSON.parse(readFileSync(resolve(file),"utf8"));
|
|
73
|
-
if(isBehaviorFile(file)) {
|
|
74
|
-
try {
|
|
75
|
-
const subjects={};
|
|
76
|
-
for(const [id,subject]of Object.entries(value.subjects??{})) {
|
|
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),...(subject.role!==undefined?{role:subject.role}:{})};
|
|
79
|
-
else throw new Error(`Subject ${id} names a whole file. Select an actual implementation symbol before migrating this behavior section.`);
|
|
80
|
-
}
|
|
81
|
-
const {schemaVersion:_version,...behavior}=value;contract.behavior={...behavior,subjects};remove.push(file);
|
|
82
|
-
}catch(error){notes.push(error.message);}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
for(const file of files) {
|
|
86
|
-
if(!/\.[cm]?[jt]sx?$|\.json$|\.md$/.test(file)||remove.includes(file))continue;
|
|
87
|
-
const original=readFileSync(resolve(file),"utf8");let text=original;
|
|
88
|
-
for(const [before,after]of renames) {
|
|
89
|
-
let from=slash(path.relative(path.dirname(file),before)),to=slash(path.relative(path.dirname(renames.get(file)??file),after));
|
|
90
|
-
if(!from.startsWith("."))from="./"+from;if(!to.startsWith("."))to="./"+to;
|
|
91
|
-
for(const [left,right]of [[before,after],[from,to],[from.replace(/\.[cm]?[jt]sx?$/,""),to.replace(/\.[cm]?[jt]sx?$/,"")]]) {
|
|
92
|
-
for(const quote of ['"',"'","`"] )text=text.replaceAll(quote+left+quote,quote+right+quote);
|
|
93
|
-
if(file.endsWith(".md"))text=text.replaceAll(`](${left})`,`](${right})`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if(text!==original)writeFileSync(resolve(file),text);
|
|
97
|
-
}
|
|
98
|
-
if(remove.length) {
|
|
99
|
-
if(contract.behavior)for(const check of Object.values(contract.behavior.checks)) {
|
|
100
|
-
const old=slash(path.normalize(path.join(directory,check.file))),next=renames.get(old);
|
|
101
|
-
if(next)check.file="./"+slash(path.relative(directory,next));
|
|
102
|
-
}
|
|
103
|
-
let text=JSON.stringify(contract,null,2);
|
|
104
|
-
for(const alias of references.values())text=text.replaceAll(JSON.stringify(`__ads_reference_${alias}__`),alias);
|
|
105
|
-
writeFileSync(resolve(contractFile),`import type { UnitContract } from "@reqvire-org/ads/contracts";\n${imports.filter(line=>[...references.values()].some(alias=>line.includes(` as ${alias} `)&&new RegExp(`\\b${alias}\\b`).test(text))).join("\n")}\nexport default ${text} satisfies UnitContract;\n`);
|
|
106
|
-
for(const file of remove) {const fsPath=resolve(file);renameSync(fsPath,path.join(base,"..",`migrated-${path.basename(file)}`));}
|
|
107
|
-
}else if(inspectUnitContracts(loadConfig(options.root)).contracts.some(contract=>contract.unit===prepared.unit))notes.push("Existing TypeScript contract retained. Only legacy file roles/references were renamed.");
|
|
108
|
-
for(const [from,to]of renames)renameSync(resolve(from),resolve(to));
|
|
109
|
-
return {...prepared,migration:{renamed:[...renames].map(([from,to])=>({from,to})),converted:remove,contractFile:remove.length?relative(resolve(contractFile)):null,notes},next:"Review the migrated draft and its references, then use action: diff and ads_apply_patch dryRun: true. Live source is unchanged; unresolved sections retain their legacy registration. Migrate one passing owner at a time."};
|
|
110
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
const parse = content => ts.createSourceFile("index.ts", content, ts.ScriptTarget.Latest, true);
|
|
5
|
-
function exportOwner(node, file, options, units) {
|
|
6
|
-
if (!ts.isExportDeclaration(node) || !node.moduleSpecifier || !ts.isStringLiteralLike(node.moduleSpecifier)) return null;
|
|
7
|
-
const target = path.resolve(path.dirname(file), node.moduleSpecifier.text).replace(/\.[cm]?[jt]sx?$/, "");
|
|
8
|
-
return [...units].sort((a,b)=>b.length-a.length).find(unit => {
|
|
9
|
-
const base = path.join(options.dsRoot,unit);
|
|
10
|
-
return target === base || target.startsWith(base + path.sep) || target.startsWith(base + ".");
|
|
11
|
-
}) ?? null;
|
|
12
|
-
}
|
|
13
|
-
const emptyExport = node => ts.isExportDeclaration(node) && !node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && !node.exportClause.elements.length;
|
|
14
|
-
export function isDraftExportEntry(target, options) {
|
|
15
|
-
return [options.config.publicEntry,options.config.reviewEntry].some(entry => path.resolve(options.root,target) === path.join(options.dsRoot,entry));
|
|
16
|
-
}
|
|
17
|
-
/** Shared barrels merge only declared owners' re-exports; all other code is preserved. */
|
|
18
|
-
export function mergeDraftExports(current, proposed, baseline, target, options, units) {
|
|
19
|
-
const file = path.resolve(options.root,target), before = parse(baseline), next = parse(proposed);
|
|
20
|
-
const owner = node => exportOwner(node,file,options,units);
|
|
21
|
-
const cleanup = next.statements.some(owner) && !next.statements.some(emptyExport);
|
|
22
|
-
const unrelated = ast => ast.statements.filter(node => !owner(node) && !(cleanup && emptyExport(node))).map(node=>node.getText(ast));
|
|
23
|
-
if (JSON.stringify(unrelated(before)) !== JSON.stringify(unrelated(next))) throw new Error("Draft public-entry changes may change only declared owners' re-exports; preserve other statements.");
|
|
24
|
-
let result = current;
|
|
25
|
-
const stages = [];
|
|
26
|
-
for (const unit of units) {
|
|
27
|
-
const ast = parse(result), replacement = next.statements.filter(node=>owner(node)===unit).map(node=>node.getFullText(next)).join("");
|
|
28
|
-
let inserted = false;
|
|
29
|
-
let value = ast.statements.map(node => {
|
|
30
|
-
if (owner(node) !== unit) return cleanup && emptyExport(node) ? "" : node.getFullText(ast);
|
|
31
|
-
if (inserted) return "";
|
|
32
|
-
inserted = true; return replacement;
|
|
33
|
-
}).join("");
|
|
34
|
-
if (!inserted && replacement) value += "\n" + replacement;
|
|
35
|
-
value = value.trimEnd() + "\n";
|
|
36
|
-
if (value !== result) stages.push({unit,before:result,content:value});
|
|
37
|
-
result = value;
|
|
38
|
-
}
|
|
39
|
-
return { content:result, stages };
|
|
40
|
-
}
|