@reqvire-org/ads 0.3.36 → 0.3.37
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 -8
- package/dist/bootstrap-ds/README.md +8 -9
- package/dist/bootstrap-ds/ds.config.json +1 -8
- package/dist/bootstrap-ds/package.json +4 -3
- package/dist/bootstrap-ds/scripts/build-mcp-previews.mjs +2 -32
- package/dist/bun-compiler.mjs +13 -0
- package/dist/bun-worker.mjs +9 -0
- package/dist/check.mjs +7 -4
- package/dist/cli.mjs +11 -7
- package/dist/config.mjs +22 -4
- package/dist/development-runtime.mjs +3 -1
- package/dist/init.mjs +16 -18
- package/dist/mcp/build-status.mjs +6 -4
- package/dist/mcp/context.mjs +9 -4
- package/dist/mcp/drafts.mjs +4 -2
- package/dist/mcp/mutations.mjs +4 -14
- package/dist/mcp/preview-watch.mjs +21 -9
- package/dist/mcp/preview-widget.bundle.js +58 -63
- package/dist/mcp/preview-work.mjs +1 -15
- package/dist/mcp/project-widget.bundle.js +57 -62
- package/dist/mcp/prompts.mjs +2 -2
- package/dist/mcp/resource-loader.js +32 -10
- package/dist/mcp/server.mjs +89 -34
- package/dist/mcp/widget.bundle.js +59 -64
- package/dist/preview-builder.mjs +17 -5
- package/dist/preview-bun.mjs +266 -0
- package/dist/preview-imports.mjs +73 -0
- package/dist/preview-resources.mjs +26 -14
- package/dist/scenario-inspector.mjs +11 -4
- package/dist/scenarios-compiler.mjs +47 -6
- package/dist/showcase/client.bundle.js +68 -72
- package/dist/showcase/index.html +2 -2
- package/dist/showcase/sandbox.bundle.js +1 -1
- package/dist/showcase/style.css +4 -0
- package/dist/skills/ads-break-ui/SKILL.md +39 -40
- package/dist/skills/ads-break-ui/references/drafts.md +6 -3
- package/dist/skills/ads-break-ui/references/guarded-editing.md +4 -3
- package/dist/skills/ads-break-ui/references/runtimes.md +91 -140
- package/dist/skills/ads-break-ui/references/validation.md +13 -3
- package/dist/skills/ads-break-ui/references/workflows.md +82 -0
- package/dist/skills/ads-designer/SKILL.md +38 -39
- package/dist/skills/ads-designer/assets/bootstrap-ds/README.md +8 -9
- package/dist/skills/ads-designer/assets/bootstrap-ds/ds.config.json +1 -8
- package/dist/skills/ads-designer/assets/bootstrap-ds/package.json +4 -3
- package/dist/skills/ads-designer/assets/bootstrap-ds/scripts/build-mcp-previews.mjs +2 -32
- package/dist/skills/ads-designer/references/cli.md +24 -20
- package/dist/skills/ads-designer/references/drafts.md +6 -3
- package/dist/skills/ads-designer/references/guarded-editing.md +4 -3
- package/dist/skills/ads-designer/references/runtimes.md +91 -140
- package/dist/skills/ads-designer/references/validation.md +13 -3
- package/dist/skills/ads-designer/references/workflows.md +82 -0
- package/dist/skills/ads-import/SKILL.md +40 -42
- package/dist/skills/ads-import/references/cli.md +24 -20
- package/dist/skills/ads-import/references/drafts.md +6 -3
- package/dist/skills/ads-import/references/guarded-editing.md +4 -3
- package/dist/skills/ads-import/references/runtimes.md +91 -140
- package/dist/skills/ads-import/references/validation.md +13 -3
- package/dist/skills/ads-import/references/workflows.md +82 -0
- package/dist/skills/ads-motion/SKILL.md +37 -38
- package/dist/skills/ads-motion/references/drafts.md +6 -3
- package/dist/skills/ads-motion/references/guarded-editing.md +4 -3
- package/dist/skills/ads-motion/references/runtimes.md +91 -140
- package/dist/skills/ads-motion/references/validation.md +13 -3
- package/dist/skills/ads-motion/references/workflows.md +82 -0
- package/dist/skills/ads-port/SKILL.md +37 -38
- package/dist/skills/ads-port/references/cli.md +24 -20
- package/dist/skills/ads-port/references/drafts.md +6 -3
- package/dist/skills/ads-port/references/guarded-editing.md +4 -3
- package/dist/skills/ads-port/references/runtimes.md +91 -140
- package/dist/skills/ads-port/references/validation.md +13 -3
- package/dist/skills/ads-port/references/workflows.md +82 -0
- package/dist/usage.mjs +84 -0
- package/dist/validation.mjs +0 -12
- package/dist/verification/browser.mjs +77 -48
- package/docs/ADS.md +17 -11
- package/docs/ARCHITECTURE.md +43 -29
- package/docs/BEHAVIORS.md +3 -3
- package/docs/CHANGELOG.md +60 -12
- package/docs/GUIDE.md +96 -53
- package/docs/MCP.md +96 -122
- package/docs/benchmarks/bun-previews.md +91 -0
- package/docs/benchmarks/gidi-preview-memory.md +4 -0
- package/package.json +15 -13
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ADS compilation and project runtimes
|
|
2
2
|
|
|
3
|
-
ADS
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
ADS tooling and MCP previews use Bun 1.3.13+ for bundling. Install Bun before
|
|
4
|
+
using the ADS CLI. The consuming application keeps its own package manager,
|
|
5
|
+
bundler, framework and production build. Node-compatible ADS checking APIs remain
|
|
6
|
+
available to projects that run their own checks under Node.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Use the installed/pinned ADS version. For npm projects:
|
|
8
9
|
|
|
9
10
|
```sh
|
|
10
11
|
npx @reqvire-org/ads init --framework react
|
|
@@ -12,156 +13,106 @@ npm install
|
|
|
12
13
|
npm run build
|
|
13
14
|
```
|
|
14
15
|
|
|
15
|
-
For Bun:
|
|
16
|
+
For Bun projects:
|
|
16
17
|
|
|
17
18
|
```sh
|
|
18
|
-
bunx
|
|
19
|
+
bunx @reqvire-org/ads init --framework react
|
|
19
20
|
bun install
|
|
20
|
-
bun
|
|
21
|
+
bun run build
|
|
21
22
|
```
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
`--bun` is essential to an explicit Bun runtime choice: many JavaScript tools
|
|
30
|
-
have a `#!/usr/bin/env node` shebang. Bun can otherwise launch Node when it is
|
|
31
|
-
available. Generated ADS scripts force Bun, including Oxlint and its JavaScript
|
|
32
|
-
plugins. Existing application scripts and lockfiles are preserved; translate
|
|
33
|
-
nested `npm` commands when intentionally converting an application to Bun.
|
|
34
|
-
Dependency packages and custom build commands must support the chosen runtime.
|
|
35
|
-
|
|
36
|
-
For ordinary `bun run build` commands to always select Bun, the project may
|
|
37
|
-
set its own `bunfig.toml`:
|
|
38
|
-
|
|
39
|
-
```toml
|
|
40
|
-
[run]
|
|
41
|
-
bun = true
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
This is equivalent to passing `--bun` for script execution. ADS does not replace
|
|
45
|
-
an existing Bun configuration. Keep the explicit flag in MCP launch settings.
|
|
24
|
+
Select `preact` for native Preact. Preserve project metadata and lockfiles.
|
|
25
|
+
ADS's `lint:ds` setup runs `ads check .` directly. ADS gates do not require
|
|
26
|
+
Oxlint. Projects can run their chosen linter through their own explicitly
|
|
27
|
+
configured check scripts. Init preserves application scripts and adds the ADS
|
|
28
|
+
check/assets step to its existing build hook.
|
|
46
29
|
|
|
47
30
|
## MCP connection
|
|
48
31
|
|
|
49
|
-
|
|
32
|
+
Choose [direct code editing or MCP-only editing](workflows.md) independently of
|
|
33
|
+
compiler ownership. Read-only MCP supports direct editors using preview/check
|
|
34
|
+
tools. `--mutations` exposes MCP source editing; it does not force that workflow.
|
|
50
35
|
|
|
51
36
|
```json
|
|
52
|
-
{
|
|
53
|
-
"command": "bunx",
|
|
54
|
-
"args": ["--bun", "@reqvire-org/ads", "mcp"]
|
|
55
|
-
}
|
|
37
|
+
{"command":"bunx","args":["--bun","@reqvire-org/ads","mcp"]}
|
|
56
38
|
```
|
|
57
39
|
|
|
58
|
-
Add `--mutations`
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
Add `--mutations` for guarded edits and `--port` if a fixed Explorer port is
|
|
41
|
+
needed. Use the generated `ads-mcp` / `ads-read-mcp` package scripts for a local
|
|
42
|
+
installation. Keep stdout for JSON-RPC. Explicit project behavior-profile
|
|
43
|
+
commands retain their own runtime requirements; `runtime` selects ADS's launcher.
|
|
44
|
+
ADS dispatches Bun project checks with `bun run`, preserving explicitly selected
|
|
45
|
+
Node/Bun commands and their flags. Use `bun` in a script when that individual tool
|
|
46
|
+
must run on Bun; ADS does not force the application's tools onto its own runtime.
|
|
62
47
|
|
|
63
|
-
##
|
|
48
|
+
## Native preview compilation
|
|
64
49
|
|
|
65
|
-
|
|
50
|
+
Configure the framework and generated manifest:
|
|
66
51
|
|
|
67
52
|
```json
|
|
68
|
-
{
|
|
69
|
-
"mcp": {
|
|
70
|
-
"previewWatch": {
|
|
71
|
-
"command": "runtime",
|
|
72
|
-
"args": ["scripts/build-mcp-previews.mjs", "--watch"]
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
53
|
+
{"framework":"react","mcp":{"previewManifest":".ds/preview/manifest.json"}}
|
|
76
54
|
```
|
|
77
55
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
ADS
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
`
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
checks and
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
incompatible output falls back to background compilation. The connected showcase
|
|
142
|
-
can prefetch changed peers' static bytes without evaluating or mounting them.
|
|
143
|
-
Reuse depends on content and dependencies, with no time-based expiry. Preparation
|
|
144
|
-
does not establish additional behavior or visual evidence.
|
|
145
|
-
|
|
146
|
-
The App preserves selected form/scroll state across accepted unrelated graph
|
|
147
|
-
updates, reruns audits and remounts when its own module/style/asset closure changes.
|
|
148
|
-
Do not promise component-level HMR. Guarded edits select affected behavior owners
|
|
149
|
-
from their input dependencies and run their registered checks; project scripts
|
|
150
|
-
remain as configured and releases run the complete suite. Incremental compilation
|
|
151
|
-
alone does not make arbitrary lint/typecheck/test scripts incremental.
|
|
152
|
-
|
|
153
|
-
Preview watching excludes standard output trees by default, including nested
|
|
154
|
-
Cargo `target/` directories, without allocating watches inside them. Explicit
|
|
155
|
-
`sourceDir` and `dsDir` take priority over those default output names. Register
|
|
156
|
-
custom outputs in `assets.generatedPaths`; do not copy the default list into a
|
|
157
|
-
new project's config. `ENOSPC` from `fs.watch` can mean the OS watch limit rather
|
|
158
|
-
than disk space: inspect the failing path and generated-tree traversal before
|
|
159
|
-
raising system limits or deleting files. Generated churn must not mark previews
|
|
160
|
-
stale; actual source changes must still rebuild.
|
|
161
|
-
|
|
162
|
-
Bundled binary renderers may load their forwarded `blob:` resources. ADS's
|
|
163
|
-
showcase/explorer permits WebAssembly compilation while keeping JavaScript eval
|
|
164
|
-
and undeclared network requests blocked. External MCP hosts control their CSP.
|
|
165
|
-
Test the actual renderer inside the App; a successful website build does not
|
|
166
|
-
establish binary-resource or WebAssembly support. Keep transport and resource
|
|
167
|
-
loading in explicit injected adapters or declared renderer dependencies.
|
|
56
|
+
ADS supplies its Bun compiler automatically. Remove the project's former
|
|
57
|
+
`mcp.previewWatch` command when adopting native compilation. No Vite/Rollup
|
|
58
|
+
preview adapter or application compiler configuration is needed. Keep the
|
|
59
|
+
framework mount in `design-system/showcase/mcp/main.tsx` (relative to the actual
|
|
60
|
+
ADS root); it exports `mountScenario(Scenario,container)` and returns cleanup.
|
|
61
|
+
ADS resolves the public alias, extracts Linaria using the shared atomic tag
|
|
62
|
+
resolver, and registers compiled modules, CSS, fonts, images and workers as
|
|
63
|
+
immutable MCP resources. The selected ADS framework controls JSX compilation.
|
|
64
|
+
|
|
65
|
+
`ads compile .` builds all production previews for project builds or CI.
|
|
66
|
+
`ads compile . --watch` runs the same source scheduler continuously.
|
|
67
|
+
Programmatic project setup can call `compilePreviews` from
|
|
68
|
+
`@reqvire-org/ads/scenarios/compile`. A project may run `ads check`, `ads verify`
|
|
69
|
+
or `ads validate` explicitly in its own scripts/CI; these commands use the same
|
|
70
|
+
ADS gates and registered behavior tests as MCP. Keep application production
|
|
71
|
+
builds and project tests as registered checks where integration needs them.
|
|
72
|
+
|
|
73
|
+
## Responsive Explorer
|
|
74
|
+
|
|
75
|
+
MCP starts serving before warming finishes. One shared compiler warms the last selected view first, then the remaining
|
|
76
|
+
graph in one background build. Compiler jobs run sequentially; a foreground
|
|
77
|
+
selection takes priority over queued background work. Reuse retained output and the current per-file
|
|
78
|
+
Linaria/worker cache; do not introduce one compiler per view or retain revision
|
|
79
|
+
histories in memory. Completed unchanged views require no compilation to open.
|
|
80
|
+
For direct editing with an external builder, set `mcp.previewWatch: false`.
|
|
81
|
+
An agent or human edits code and runs `ads compile .` (or manages its watch mode
|
|
82
|
+
externally); MCP only serves/inspects the published previews and starts no
|
|
83
|
+
compiler. A compatible builder must publish the ADS resource graph and build
|
|
84
|
+
evidence, not just an application bundle. Existing views can remain visible while
|
|
85
|
+
building, but changed source makes their evidence stale until a verified update
|
|
86
|
+
is published. Direct editing normally uses the managed compiler; omit the setting
|
|
87
|
+
or use null for that default. See [the two editing workflows](workflows.md).
|
|
88
|
+
|
|
89
|
+
`ads://project/build` exposes `warmup` progress (`state`, `completed`, `total`,
|
|
90
|
+
`failed`) alongside each view's freshness and diagnostics. Supported clients
|
|
91
|
+
subscribe to build/resource updates; Explorer follows them automatically.
|
|
92
|
+
Navigation bootstraps through the compact `ads://project/explorer` resource.
|
|
93
|
+
Semantic discovery runs in a worker, outside the interactive request loop.
|
|
94
|
+
|
|
95
|
+
Watched builds publish explicitly unverified feedback while ADS validation and
|
|
96
|
+
semantic checks continue. Keep the previous preview visible until the replacement
|
|
97
|
+
is available. A preview request has a bounded compiler budget and Retry action;
|
|
98
|
+
changing the selection cancels the superseded request. Do not use network idle
|
|
99
|
+
as readiness: persistent MCP streams remain active.
|
|
100
|
+
|
|
101
|
+
`ads_show_scenario` and `ads_show_tokens` default to `waitFor:"verified"`.
|
|
102
|
+
Interactive browsing may use `waitFor:"compiled"`; `build.current:false` or
|
|
103
|
+
`build.live.validated:false` cannot establish passing evidence. Captures,
|
|
104
|
+
behavior checks and publication still require verified current output.
|
|
105
|
+
|
|
106
|
+
Acceptance builds the complete candidate in production mode, then releases its
|
|
107
|
+
compiler while browser checks use the hosted immutable graph. Interactive
|
|
108
|
+
accepted/draft previews stay available throughout. Background checks serialize
|
|
109
|
+
without borrowing the interactive compiler. Keep configured project checks;
|
|
110
|
+
remove a duplicate standalone preview build from `mcp.mutationChecks` because
|
|
111
|
+
ADS already performs that build once. Keep `ads compile` in ordinary builds if
|
|
112
|
+
that project needs preview artifacts there.
|
|
113
|
+
|
|
114
|
+
Workers compile to self-contained scripts for the opaque-origin MCP App sandbox.
|
|
115
|
+
Unchanged worker output reuses dependency hashes; changes to transitive inputs
|
|
116
|
+
rebuild it. Temporary worker compiler processes run sequentially and exit after
|
|
117
|
+
producing output. Their build lifetime is separate from runtime worker cleanup,
|
|
118
|
+
which remains owned by the component/controller.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Validation scope
|
|
2
2
|
|
|
3
|
+
These checks apply to both [direct editing and MCP-only editing](workflows.md).
|
|
4
|
+
Direct source edits need current checks and rendered review; ordinary edits do
|
|
5
|
+
not require a draft or acceptance call. Tracked proposals validate on acceptance.
|
|
6
|
+
|
|
3
7
|
Use `ads_validate({})` for the complete project audit, equivalent to `ads validate`.
|
|
4
8
|
Use `ads_validate({scope:"changed"})`, equivalent to `ads validate --changed`, during
|
|
5
9
|
editing when a successful full baseline exists. Both interfaces call the same
|
|
@@ -19,16 +23,22 @@ engine. Full is the default.
|
|
|
19
23
|
checks and configured scripts, not arbitrary assertions, visual parity or every
|
|
20
24
|
application state.
|
|
21
25
|
|
|
22
|
-
Full validation runs core architecture/test-boundary guards, registered
|
|
23
|
-
project scripts and every registered behavior contract. Defaults use the existing
|
|
26
|
+
Full validation runs core architecture/test-boundary guards, configured project scripts and every registered behavior contract. Defaults use the existing
|
|
24
27
|
mutation-check scripts plus a project's `test` and build scripts when present.
|
|
25
28
|
Build selection prefers `build:lib`, then `build:app`, then `build`.
|
|
26
29
|
Projects can declare `validation.checks` as a list of package
|
|
27
|
-
script names for the complete audit; core
|
|
30
|
+
script names for the complete audit; core ADS and registered behaviors remain
|
|
28
31
|
mandatory. Commands are trusted project configuration, never MCP arguments.
|
|
29
32
|
Use scripts that check/build without changing source. Avoid calling `ads validate`
|
|
30
33
|
from a script selected by validation.
|
|
31
34
|
|
|
35
|
+
Prefer native ADS usage policies over project lint plugins. Notification APIs
|
|
36
|
+
and hosts can be registered as `usage.notifications: [{api, host, rootFiles}]`;
|
|
37
|
+
`usage.restrictedImports` blocks packages that bypass the project-owned API.
|
|
38
|
+
`ads check`, acceptance and validation enforce these in the existing AST pass.
|
|
39
|
+
Do not keep an additional toast lint runner after migrating its policy. Preserve
|
|
40
|
+
ordinary project tests and independent linters for checks ADS does not own.
|
|
41
|
+
|
|
32
42
|
Freshness tracks ADS and consuming UI roots, public assets, their local dependency
|
|
33
43
|
chains, registered configuration/command entrypoints, package files, and supported
|
|
34
44
|
project tests plus helpers. Unrelated native/backend/docs edits can continue during
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Direct editing and MCP-only editing
|
|
2
|
+
|
|
3
|
+
Choose the route from the user's instructions and the editor/filesystem access
|
|
4
|
+
actually available to the agent. `ads_status.mutations.enabled` describes MCP
|
|
5
|
+
capabilities; it does not require a local editor to use MCP mutation tools.
|
|
6
|
+
Compiler ownership is a separate choice from editing access.
|
|
7
|
+
|
|
8
|
+
## Direct design-system code access
|
|
9
|
+
|
|
10
|
+
An agent or human edits the project's owned source with their normal editor.
|
|
11
|
+
MCP provides discovery, rendered previews, captures and validation; it need not
|
|
12
|
+
write source. A read-only MCP connection is sufficient for this workflow.
|
|
13
|
+
|
|
14
|
+
1. Use `ads_status` to establish the connected project root, commands, compiler
|
|
15
|
+
state and public API. Inspect relevant source, tokens, guides and real scenarios.
|
|
16
|
+
2. Edit the implementation, its scenarios/fixtures and required public exports
|
|
17
|
+
directly. Ordinary working-tree edits do not require `ads_create_draft` or
|
|
18
|
+
`ads_accept`; they change project source immediately, without isolated rollback.
|
|
19
|
+
3. With the default ADS-managed compiler, let the existing watcher rebuild. Open
|
|
20
|
+
the scenario through `ads_show_scenario` or Explorer and inspect the rendered
|
|
21
|
+
result. Do not launch a second compiler beside the managed one.
|
|
22
|
+
4. Inspect `ads_status.build` or `ads://project/build`. Run native ADS gates and
|
|
23
|
+
appropriate project/registered behavior checks, using MCP or the equivalent
|
|
24
|
+
CLI/project commands. Review the final current view before finishing. See
|
|
25
|
+
[validation scope](validation.md).
|
|
26
|
+
|
|
27
|
+
### External builder: `mcp.previewWatch: false`
|
|
28
|
+
|
|
29
|
+
This is the direct-editing workflow with compilation managed outside the MCP
|
|
30
|
+
process. An agent or human edits code and runs a builder; MCP is used to preview
|
|
31
|
+
and inspect the published output rather than to edit or compile it.
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{"framework":"react","mcp":{"previewManifest":".ds/preview/manifest.json","previewWatch":false}}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
ADS does not start a compiler in this mode. Run `ads compile .` after edits, or
|
|
38
|
+
manage `ads compile . --watch` externally. A custom compatible builder must publish
|
|
39
|
+
the ADS resource graph, manifest and build evidence; an ordinary application
|
|
40
|
+
bundle alone is insufficient. Keep only one builder responsible for these outputs.
|
|
41
|
+
MCP serves the published resources and reports their freshness. Existing views
|
|
42
|
+
can remain visible during the build, but source changes make their evidence stale
|
|
43
|
+
until a verified update is published. Inspect build state explicitly; resource
|
|
44
|
+
notifications help supported clients refresh but do not establish passing checks.
|
|
45
|
+
|
|
46
|
+
Omitting `previewWatch` or setting it to `null` selects ADS's native compiler when
|
|
47
|
+
the framework and preview manifest are configured. Direct editing does not imply
|
|
48
|
+
`false`: the managed compiler is the usual direct-editing setup. See
|
|
49
|
+
[runtimes](runtimes.md) for compilation and publication details.
|
|
50
|
+
|
|
51
|
+
## MCP-only design-system access
|
|
52
|
+
|
|
53
|
+
When no authorized source editor/filesystem channel is available, use the
|
|
54
|
+
server's tools for source reads and changes. Do not assume returned server-local
|
|
55
|
+
paths can be opened by the client. Discover capabilities with `ads_status`.
|
|
56
|
+
|
|
57
|
+
With mutation tools enabled, follow [tracked drafts](drafts.md): discover owners
|
|
58
|
+
with `ads_units`, create a coherent proposal with `ads_create_draft`, read/edit its
|
|
59
|
+
marked source through `ads_read_file` and `ads_update_draft`, preview with
|
|
60
|
+
`ads_show_draft`, review the rendered result and accept its exact revision with
|
|
61
|
+
`ads_accept`. Accept dependencies first and review dependents again. The agent
|
|
62
|
+
performs auto-mode review; no additional human approval step is implied.
|
|
63
|
+
|
|
64
|
+
Use [guarded patches](guarded-editing.md) for focused repairs and migrations.
|
|
65
|
+
Without mutation tools, an MCP-only client can inspect, preview and validate,
|
|
66
|
+
but cannot change source. Report that capability limit if editing is required.
|
|
67
|
+
|
|
68
|
+
## Completion and shared rules
|
|
69
|
+
|
|
70
|
+
Both routes preserve project ownership, framework, public APIs, shared tokens,
|
|
71
|
+
styling/geometry boundaries and configured checks. Compilation and HTML delivery
|
|
72
|
+
do not prove visual or behavioral correctness. Report the scope and revision of
|
|
73
|
+
actual passing checks; stale, failed or incomplete evidence remains unfinished.
|
|
74
|
+
Never change access routes to bypass a rejected patch or failed acceptance.
|
|
75
|
+
|
|
76
|
+
Direct editors may deliberately choose tracked drafts for isolation, comparison
|
|
77
|
+
or PR review. Once using a tracked proposal, finish a coherent design change by
|
|
78
|
+
reviewing and accepting its required drafts, unless the user asks to retain the
|
|
79
|
+
proposal. Do not silently leave requested work only in drafts. This completion
|
|
80
|
+
rule also applies to MCP-only drafts; it does not impose draft acceptance on
|
|
81
|
+
ordinary direct source edits. Never import marked `.ads` draft source into
|
|
82
|
+
application or accepted ADS runtime code.
|
package/dist/usage.mjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { isInside, isTestFile, isContractFile } from "./config.mjs";
|
|
4
|
+
import { sourceSymbol } from "./source-symbols.mjs";
|
|
5
|
+
|
|
6
|
+
const effects = new Set(["useEffect", "useLayoutEffect"]);
|
|
7
|
+
const frameworks = new Set(["react", "preact/hooks", "preact/compat"]);
|
|
8
|
+
const fn = node => node && (ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodDeclaration(node));
|
|
9
|
+
const property = node => ts.isPropertyAccessExpression(node) ? node.name.text : ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression) ? node.argumentExpression.text : null;
|
|
10
|
+
|
|
11
|
+
/** Inspect configured public notification APIs in the existing ADS AST pass.
|
|
12
|
+
* Registrations are data, never executable project lint plugins. */
|
|
13
|
+
export function inspectUsage(options, program, report) {
|
|
14
|
+
const policy = options.config.usage;
|
|
15
|
+
if (!policy.notifications.length && !policy.restrictedImports.length) return;
|
|
16
|
+
const checker = program.getTypeChecker();
|
|
17
|
+
const imported = expression => {
|
|
18
|
+
const parts = [];
|
|
19
|
+
while (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) {
|
|
20
|
+
const name = property(expression); if (!name) return null;
|
|
21
|
+
parts.unshift(name); expression = expression.expression;
|
|
22
|
+
}
|
|
23
|
+
if (!ts.isIdentifier(expression)) return null;
|
|
24
|
+
for (const declaration of sourceSymbol(checker, expression)?.declarations ?? []) {
|
|
25
|
+
if (ts.isImportSpecifier(declaration)) {
|
|
26
|
+
const clause = declaration.parent.parent, statement = clause.parent;
|
|
27
|
+
if (!clause.isTypeOnly && !declaration.isTypeOnly) return { source: statement.moduleSpecifier.text, names: [(declaration.propertyName ?? declaration.name).text, ...parts] };
|
|
28
|
+
}
|
|
29
|
+
if (ts.isNamespaceImport(declaration) && !declaration.parent.isTypeOnly && parts.length) return { source: declaration.parent.parent.moduleSpecifier.text, names: parts };
|
|
30
|
+
if (ts.isImportClause(declaration) && !declaration.isTypeOnly && parts.length && frameworks.has(declaration.parent.moduleSpecifier.text)) return { source: declaration.parent.moduleSpecifier.text, names: parts };
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
const nearest = node => { for (let parent = node.parent; parent; parent = parent.parent) if (fn(parent)) return parent; return null; };
|
|
35
|
+
const name = node => node.name?.text ?? (ts.isVariableDeclaration(node.parent) ? node.parent.name.getText() : "");
|
|
36
|
+
for (const source of program.getSourceFiles()) {
|
|
37
|
+
const file = source.fileName;
|
|
38
|
+
if ((!isInside(options.sourceRoot, file) && !isInside(options.dsRoot, file)) || file.includes(`${path.sep}node_modules${path.sep}`) || isTestFile(file, options) || isContractFile(file)) continue;
|
|
39
|
+
const relative = path.relative(options.root, file).replaceAll("\\", "/");
|
|
40
|
+
const ids = new Map();
|
|
41
|
+
const emit = (node, rule, message) => { const at = source.getLineAndCharacterOfPosition(node.getStart()); report(file, rule, message, at.line + 1, at.character + 1); };
|
|
42
|
+
const server = source.statements.some(statement => ts.isExpressionStatement(statement) && ts.isStringLiteralLike(statement.expression) && statement.expression.text === "use server");
|
|
43
|
+
function visit(node) {
|
|
44
|
+
let specifier;
|
|
45
|
+
if (ts.isImportDeclaration(node) && !node.importClause?.isTypeOnly && !(node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings) && !node.importClause.name && node.importClause.namedBindings.elements.length && node.importClause.namedBindings.elements.every(item => item.isTypeOnly))) specifier = node.moduleSpecifier;
|
|
46
|
+
if (ts.isExportDeclaration(node) && !node.isTypeOnly && !(node.exportClause && ts.isNamedExports(node.exportClause) && node.exportClause.elements.length && node.exportClause.elements.every(item => item.isTypeOnly))) specifier = node.moduleSpecifier;
|
|
47
|
+
if (ts.isCallExpression(node) && (node.expression.kind === ts.SyntaxKind.ImportKeyword || ts.isIdentifier(node.expression) && node.expression.text === "require" && !sourceSymbol(checker, node.expression)?.declarations?.length)) specifier = node.arguments[0];
|
|
48
|
+
if (specifier && ts.isStringLiteralLike(specifier) && policy.restrictedImports.some(pkg => specifier.text === pkg || specifier.text.startsWith(pkg + "/"))) emit(specifier, "usage-restricted-import", `Use the project-owned public API from ${options.config.publicAlias} instead of importing ${specifier.text} directly.`);
|
|
49
|
+
if (ts.isCallExpression(node)) {
|
|
50
|
+
const target = imported(node.expression);
|
|
51
|
+
const entry = target?.source === options.config.publicAlias && policy.notifications.find(entry => entry.api === target.names[0] && target.names.length <= 2);
|
|
52
|
+
if (entry) {
|
|
53
|
+
const parent = nearest(node);
|
|
54
|
+
if (server) emit(node, "notification-client-usage", `Trigger ${entry.api} from the client receiving the server result, not a 'use server' module.`);
|
|
55
|
+
else if (!parent || /^[A-Z]/.test(name(parent)) || ts.isExportAssignment(parent.parent) && !name(parent)) emit(node, "notification-client-usage", `Call ${entry.api} in an event handler or effect, not at module scope or during component rendering.`);
|
|
56
|
+
const effect = parent?.parent;
|
|
57
|
+
const effectApi = effect && ts.isCallExpression(effect) && effect.arguments[0] === parent ? imported(effect.expression) : null;
|
|
58
|
+
if (effectApi && frameworks.has(effectApi.source) && effects.has(effectApi.names[0]) && !["update", "dismiss"].includes(target.names[1])) {
|
|
59
|
+
const args = node.arguments[1];
|
|
60
|
+
// Dynamic/spread options cannot be concluded from syntax alone.
|
|
61
|
+
if (!args || ts.isObjectLiteralExpression(args) && !args.properties.some(ts.isSpreadAssignment) && !args.properties.some(prop => prop.name && (ts.isIdentifier(prop.name) || ts.isStringLiteralLike(prop.name)) && prop.name.text === "id")) emit(node, "notification-effect-id", `${entry.api} created directly in an effect needs an explicit stable id to avoid duplicates on reruns and remounts.`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
|
|
66
|
+
const target = imported(node.tagName);
|
|
67
|
+
const entry = target?.source === options.config.publicAlias && target.names.length === 1 && policy.notifications.find(entry => entry.host === target.names[0]);
|
|
68
|
+
if (entry) {
|
|
69
|
+
if (!entry.rootFiles.includes(relative)) emit(node, "notification-host-root", `Mount ${entry.host} in an approved application or scenario root listed in usage.notifications.rootFiles.`);
|
|
70
|
+
for (let parent = node.parent; parent && !fn(parent); parent = parent.parent) if (ts.isConditionalExpression(parent) || ts.isIfStatement(parent) || ts.isBinaryExpression(parent) && [ts.SyntaxKind.AmpersandAmpersandToken, ts.SyntaxKind.BarBarToken, ts.SyntaxKind.QuestionQuestionToken].includes(parent.operatorToken.kind)) { emit(node, "notification-host-conditional", `Keep ${entry.host} mounted unconditionally so navigation and state changes do not lose notifications.`); break; }
|
|
71
|
+
const id = node.attributes.properties.find(item => ts.isJsxAttribute(item) && item.name.text === "id");
|
|
72
|
+
const value = !id ? "default" : id.initializer && ts.isStringLiteralLike(id.initializer) ? id.initializer.text : id.initializer && ts.isJsxExpression(id.initializer) && id.initializer.expression && ts.isStringLiteralLike(id.initializer.expression) ? id.initializer.expression.text : null;
|
|
73
|
+
if (value !== null) {
|
|
74
|
+
let seen = ids.get(entry.host); if (!seen) ids.set(entry.host, seen = new Set());
|
|
75
|
+
if (seen.has(value)) emit(node, "notification-host-duplicate", `This file mounts more than one ${entry.host} with id ${JSON.stringify(value)}. Use one instance per scope.`);
|
|
76
|
+
seen.add(value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
ts.forEachChild(node, visit);
|
|
81
|
+
}
|
|
82
|
+
visit(source);
|
|
83
|
+
}
|
|
84
|
+
}
|
package/dist/validation.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
3
|
import path from "node:path";
|
|
5
4
|
import { fileURLToPath } from "node:url";
|
|
6
5
|
import { loadConfig, isInside } from "./config.mjs";
|
|
7
|
-
import { createLintConfig } from "./lint-config.mjs";
|
|
8
6
|
import { inspectUnits } from "./units.mjs";
|
|
9
7
|
import { inspectBehaviors } from "./behaviors.mjs";
|
|
10
8
|
import { affectedBehaviorUnits, createVerificationController } from "./verification.mjs";
|
|
@@ -98,16 +96,6 @@ export function createValidationController(directory, { previewWork } = {}) {
|
|
|
98
96
|
return /\bads\s+validate\b|\bcli\.mjs["']?\s+validate\b/.test(text) || [...text.matchAll(/\b(?:npm|bun)\s+(?:--bun\s+)?run\s+([\w:.-]+)/g)].some(match=>recursive(match[1],seen));
|
|
99
97
|
}
|
|
100
98
|
if (scripts.some(launch=>recursive(launch.args.at(-1)))) throw new Error("A selected project script calls ads validate recursively. Use leaf check/build scripts in validation.checks.");
|
|
101
|
-
stage("registered-oxlint");
|
|
102
|
-
const require = createRequire(path.join(root,"package.json"));
|
|
103
|
-
const oxlintPackage = require.resolve("oxlint/package.json");
|
|
104
|
-
const bin = JSON.parse(readFileSync(oxlintPackage,"utf8")).bin;
|
|
105
|
-
const lintConfig = outputFile(root,`validation-lint-${randomUUID()}.json`);
|
|
106
|
-
try {
|
|
107
|
-
writeFileSync(lintConfig,JSON.stringify(createLintConfig(options)));
|
|
108
|
-
const paths = [...new Set([options.config.dsDir,options.config.sourceDir,...inspectUnits(options).units.find(unit=>unit.id==="configuration").files.filter(file=>/\.[cm]?[jt]sx?$/.test(file))])].filter(file=>existsSync(path.join(root,file)));
|
|
109
|
-
await command("registered-oxlint",{command:process.execPath,args:[path.resolve(path.dirname(oxlintPackage),typeof bin === "string" ? bin : bin.oxlint),"--deny-warnings","--config",lintConfig,...paths]},options);
|
|
110
|
-
} finally { rmSync(lintConfig,{force:true}); }
|
|
111
99
|
for (const launch of scripts) await command(`project:${launch.args.at(-1)}`,launch,options);
|
|
112
100
|
if (options.config.mcp.previewManifest && options.config.mcp.previewWatch) {
|
|
113
101
|
stage("preview-build");
|