@reqvire-org/ads 0.3.27 → 0.3.29
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/dist/atomic-composition.mjs +2 -1
- package/dist/behaviors.mjs +2 -2
- package/dist/bootstrap-ds/scripts/build-mcp-previews.mjs +6 -7
- package/dist/boundaries.mjs +6 -3
- package/dist/check.mjs +3 -0
- package/dist/cli.mjs +13 -0
- package/dist/config.mjs +5 -3
- package/dist/mcp/build-status.mjs +17 -4
- package/dist/mcp/context.mjs +2 -1
- package/dist/mcp/execution-results.mjs +4 -3
- package/dist/mcp/mutations.mjs +5 -43
- package/dist/mcp/preview-watch.mjs +23 -3
- package/dist/mcp/preview-widget.bundle.js +16 -15
- package/dist/mcp/project-widget.bundle.js +13 -13
- package/dist/mcp/resource-loader.js +50 -13
- package/dist/mcp/server.mjs +81 -39
- package/dist/oxlint.mjs +6 -1
- package/dist/preview-builder.mjs +114 -0
- package/dist/preview-inputs.mjs +8 -1
- package/dist/preview-resources.mjs +11 -4
- package/dist/preview-scope.mjs +6 -0
- package/dist/preview-workers.mjs +184 -0
- package/dist/scenario-groups.mjs +47 -0
- package/dist/scenario-inspector.mjs +34 -0
- package/dist/scenario-trace.mjs +3 -2
- package/dist/scenarios-compiler.mjs +203 -27
- package/dist/scenarios-vite.mjs +13 -5
- package/dist/scenarios.mjs +4 -1
- package/dist/showcase/client.bundle.js +23 -22
- package/dist/showcase/index.html +2 -2
- package/dist/showcase/navigation.js +13 -0
- package/dist/showcase/style.css +3 -1
- package/dist/skills/ads-break-ui/SKILL.md +4 -1
- package/dist/skills/ads-break-ui/references/runtimes.md +48 -0
- package/dist/skills/ads-break-ui/references/scenarios.md +19 -0
- package/dist/skills/ads-break-ui/references/validation.md +53 -0
- package/dist/skills/ads-designer/SKILL.md +4 -1
- package/dist/skills/ads-designer/assets/bootstrap-ds/scripts/build-mcp-previews.mjs +6 -7
- package/dist/skills/ads-designer/references/runtimes.md +48 -0
- package/dist/skills/ads-designer/references/scenarios.md +19 -0
- package/dist/skills/ads-designer/references/validation.md +53 -0
- package/dist/skills/ads-import/SKILL.md +4 -1
- package/dist/skills/ads-import/references/runtimes.md +48 -0
- package/dist/skills/ads-import/references/scenarios.md +19 -0
- package/dist/skills/ads-import/references/validation.md +53 -0
- package/dist/skills/ads-motion/SKILL.md +4 -1
- package/dist/skills/ads-motion/references/runtimes.md +48 -0
- package/dist/skills/ads-motion/references/scenarios.md +19 -0
- package/dist/skills/ads-motion/references/validation.md +53 -0
- package/dist/skills/ads-port/SKILL.md +4 -1
- package/dist/skills/ads-port/references/runtimes.md +48 -0
- package/dist/skills/ads-port/references/scenarios.md +19 -0
- package/dist/skills/ads-port/references/validation.md +53 -0
- package/dist/source-symbols.mjs +11 -0
- package/dist/source-values.mjs +10 -3
- package/dist/test-boundaries.mjs +95 -0
- package/dist/ui-framework.mjs +2 -1
- package/dist/units.mjs +12 -1
- package/dist/validation-checks.mjs +50 -0
- package/dist/validation.mjs +172 -0
- package/dist/verification/browser.mjs +3 -1
- package/dist/verification.mjs +1 -0
- package/docs/ADS.md +12 -2
- package/docs/ARCHITECTURE.md +125 -7
- package/docs/BEHAVIORS.md +7 -0
- package/docs/CHANGELOG.md +54 -0
- package/docs/GUIDE.md +31 -0
- package/docs/MCP.md +127 -16
- package/package.json +1 -1
|
@@ -23,6 +23,25 @@ on-demand element screenshots. It grants no render/behavior coverage and no extr
|
|
|
23
23
|
styling permission. Use [captures.md](captures.md) for current/candidate review,
|
|
24
24
|
target selection, resource reads and storage lifecycle.
|
|
25
25
|
|
|
26
|
+
## Folder-derived showcase groups
|
|
27
|
+
|
|
28
|
+
Components, patterns and compositions use container folders to organize
|
|
29
|
+
navigation: `components/Forms/Input/Input.ads.scenario.tsx` appears under
|
|
30
|
+
**Forms** when `Forms/` contains only real directories. Hidden entries are ignored;
|
|
31
|
+
a regular file such as `index.ts` or `README.md`, or a symlink, prevents that
|
|
32
|
+
container from becoming a group. An owner's own directory and layer root never
|
|
33
|
+
form a group. Nested containers produce one path label: **Forms / Selection**.
|
|
34
|
+
Folder spelling and case are preserved: `form-controls/` displays `form-controls`.
|
|
35
|
+
|
|
36
|
+
Folders are the only grouping source. Do not add `group` metadata to a scenario
|
|
37
|
+
or owner contract. MCP's optional `group` field is computed discovery output;
|
|
38
|
+
`ads_scenarios(query: "Forms")` searches it along with existing scenario fields.
|
|
39
|
+
Use returned IDs with `ads_show_scenario`; `ads_catalog` previews, `ads_units` and
|
|
40
|
+
source resources retain the actual nested owner paths. Ungrouped entries remain
|
|
41
|
+
visible with no Default heading. Flat layouts keep working; tokens retain their
|
|
42
|
+
categories. When moving an owner, update its imports/public exports and any
|
|
43
|
+
references to changed path-derived scenario, behavior or capture IDs.
|
|
44
|
+
|
|
26
45
|
## Fragment links inside Apps
|
|
27
46
|
|
|
28
47
|
Keep intended `href="#"` and named fragments in the project API and fixtures.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Validation scope
|
|
2
|
+
|
|
3
|
+
Use `ads_validate({})` for the complete project audit, equivalent to `ads validate`.
|
|
4
|
+
Use `ads_validate({scope:"changed"})`, equivalent to `ads validate --changed`, during
|
|
5
|
+
editing when a successful full baseline exists. Both interfaces call the same
|
|
6
|
+
engine. Full is the default.
|
|
7
|
+
|
|
8
|
+
- During local editing, use existing guarded edits and affected behavior checks.
|
|
9
|
+
Reuse completed guards for unchanged source rather than repeatedly auditing all
|
|
10
|
+
owners. Direct edits need `ads_check` and appropriate project/behavior checks.
|
|
11
|
+
- After test migrations, ownership changes or validation/runner configuration
|
|
12
|
+
changes, run full validation. Also run it before a release or an explicit request
|
|
13
|
+
to validate everything. It validates the current source, not a prepared draft.
|
|
14
|
+
- Inspect failures through `ads_results` using the returned resultId and sections
|
|
15
|
+
diagnostics, checks or outcomes. For browser failures, use the outcome's exact
|
|
16
|
+
unit/check/runId with `ads_investigate`. Fix the owner and rerun the appropriate scope.
|
|
17
|
+
- Report the actual scope and revision. Scoped, stale, cancelled or incomplete
|
|
18
|
+
runs cannot establish successful full validation. Passing covers registered
|
|
19
|
+
checks and configured scripts, not arbitrary assertions, visual parity or every
|
|
20
|
+
application state.
|
|
21
|
+
|
|
22
|
+
Full validation runs core architecture/test-boundary guards, registered Oxlint,
|
|
23
|
+
project scripts and every registered behavior contract. Defaults use the existing
|
|
24
|
+
mutation-check scripts plus a project's `test` and build scripts when present.
|
|
25
|
+
Build selection prefers `build:lib`, then `build:app`, then `build`.
|
|
26
|
+
Projects can declare `validation.checks` as a list of package
|
|
27
|
+
script names for the complete audit; core/Oxlint and registered behaviors remain
|
|
28
|
+
mandatory. Commands are trusted project configuration, never MCP arguments.
|
|
29
|
+
Use scripts that check/build without changing source. Avoid calling `ads validate`
|
|
30
|
+
from a script selected by validation.
|
|
31
|
+
|
|
32
|
+
Changed mode compares current content, including added/deleted files, with the
|
|
33
|
+
last successful full baseline in `.ds/validation-baseline.json`. No Git history is
|
|
34
|
+
required. A missing/incompatible baseline or a change to configuration, foundation,
|
|
35
|
+
ownership that no longer resolves, or unclassified input expands to full and
|
|
36
|
+
reports the reason. Scoped runs leave the full baseline unchanged. Core architecture
|
|
37
|
+
checks and opaque project commands still run in full; behavior selection narrows
|
|
38
|
+
to affected owner contracts. This is not a per-test-result cache.
|
|
39
|
+
|
|
40
|
+
ADS tests live with their component, pattern, controller, composition or review
|
|
41
|
+
owner. Private imports must resolve to that owner, including through helpers;
|
|
42
|
+
peer implementations use the public API. Marked behavior specs must be registered
|
|
43
|
+
in an owner contract. Pure ADS tests outside those owners fail the boundary guard.
|
|
44
|
+
Application integration tests may exercise public UI alongside their real application
|
|
45
|
+
runtime subject. Ordinary local unit tests retain their project's runner; full
|
|
46
|
+
validation includes the configured test script. Registration is enforced for ADS
|
|
47
|
+
behavior specs, not inferred for every case in an arbitrary runner.
|
|
48
|
+
|
|
49
|
+
During execution `ads_status.validation` reports progress. MCP summaries retain a
|
|
50
|
+
separate latest validation result, alongside verification and mutation results.
|
|
51
|
+
Source changes during execution reject success and leave the previous full
|
|
52
|
+
baseline intact. Skipped registered behavior cases never pass; a project with no
|
|
53
|
+
registered behavior contracts reports that stage as skipped with a reason.
|
|
@@ -3,6 +3,9 @@ name: ads-port
|
|
|
3
3
|
description: "Port existing library components into a coherent project-owned ADS, reusing shared tokens and primitives while preserving required behavior. Use for native adaptation from a library URL, with reference comparison and provenance; not dependency installation or wrapping."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
For validation scope, full audits, and CLI/MCP parity, read
|
|
7
|
+
[validation.md](references/validation.md).
|
|
8
|
+
|
|
6
9
|
For Node/Bun setup, MCP launch and compiler workers, read
|
|
7
10
|
[runtimes.md](references/runtimes.md).
|
|
8
11
|
|
|
@@ -80,7 +83,7 @@ website/MCP App use, owner selection, or `component-dependency`,
|
|
|
80
83
|
[layer responsibilities and contracts](references/layers.md), also served as
|
|
81
84
|
`ads://guides/layers`. Preserve public APIs and documented non-state styling hooks.
|
|
82
85
|
|
|
83
|
-
For parent/child `covers`, conditional-control review, reference comparisons,
|
|
86
|
+
For folder-group navigation, parent/child `covers`, conditional-control review, reference comparisons,
|
|
84
87
|
public style-helper use, native slot/selector composition, fragment navigation,
|
|
85
88
|
or `scenario-render` / `showcase-control` / `showcase-class` findings, read [scenario contracts](references/scenarios.md). Its verification
|
|
86
89
|
examples explain API visibility, reference baselines and state-transition checks.
|
|
@@ -93,6 +93,54 @@ commands with the appropriate Bun flags. The MCP process and agent shell may
|
|
|
93
93
|
have different PATHs; use these reported values instead of scanning the machine
|
|
94
94
|
or installing another runtime without evidence.
|
|
95
95
|
|
|
96
|
+
For incremental preview compilation, the project adapter passes
|
|
97
|
+
`createVitePreviewBuilder({ build, configure })` from
|
|
98
|
+
`@reqvire-org/ads/scenarios/vite` as `runScenarioCompiler`'s `buildGraph`.
|
|
99
|
+
`configure(entries, options)` returns the existing Vite configuration, including
|
|
100
|
+
framework/Linaria plugins, aliases and entries. The helper retains a watched
|
|
101
|
+
Rollup graph, captures private output, tracks dependencies and closes with the
|
|
102
|
+
compiler. Existing custom adapters still work; they must adopt the helper to gain
|
|
103
|
+
incremental transforms. Upgrade the project dependency and restart the builder.
|
|
104
|
+
Keep the full validation callback and production build behavior.
|
|
105
|
+
|
|
106
|
+
The shared watched builder reuses completed self-contained IIFE worker bundles
|
|
107
|
+
for constructor URLs and standard `?worker`/`?worker&url` imports. It uses Vite's
|
|
108
|
+
configured worker plugins, deduplicates pending requests, tracks real worker and
|
|
109
|
+
configuration dependencies and checks resolution-directory changes. Assets are
|
|
110
|
+
included on every refresh. Changing a transitive worker import rebuilds its
|
|
111
|
+
bundle; failed or superseded work cannot populate the cache. Nested, inline and
|
|
112
|
+
split workers keep the normal Vite path. Keep worker lifetimes/cancellation in
|
|
113
|
+
their owning component/controller; compiler reuse does not keep runtime workers
|
|
114
|
+
alive. Do not add project-specific worker names or lists to ADS.
|
|
115
|
+
|
|
116
|
+
Watched resource builds publish explicitly unverified live feedback while full
|
|
117
|
+
checks and semantic registry inspection run in the background. Rapid edits
|
|
118
|
+
coalesce behind one verification run. The showcase can browse that feedback
|
|
119
|
+
without a blocking loading overlay; a quiet header indicator exposes checking,
|
|
120
|
+
reload, failure and fallback details. A failed edit restores the last verified
|
|
121
|
+
view. Preview minification is disabled only for watched builds.
|
|
122
|
+
|
|
123
|
+
`ads_show_scenario` and `ads_show_tokens` default to `waitFor: "verified"`.
|
|
124
|
+
Interactive browsing can request `waitFor: "compiled"`, which may return live or
|
|
125
|
+
retained output with `build.current: false`. `build.live.validated: false` and
|
|
126
|
+
`ads://preview/live` are never proof of passing checks. Captures, behavior checks
|
|
127
|
+
and guarded publication still require accepted, current output. Do not replace
|
|
128
|
+
the validation callback with a faster incomplete check to speed up the viewer.
|
|
129
|
+
|
|
130
|
+
Accepted MCP edits prepare previews without requiring a viewer request. Matching
|
|
131
|
+
checked candidate graphs and registry metadata reuse the existing project cache;
|
|
132
|
+
incompatible output falls back to background compilation. The connected showcase
|
|
133
|
+
can prefetch changed peers' static bytes without evaluating or mounting them.
|
|
134
|
+
Reuse depends on content and dependencies, with no time-based expiry. Preparation
|
|
135
|
+
does not establish additional behavior or visual evidence.
|
|
136
|
+
|
|
137
|
+
The App preserves selected form/scroll state across accepted unrelated graph
|
|
138
|
+
updates, reruns audits and remounts when its own module/style/asset closure changes.
|
|
139
|
+
Do not promise component-level HMR. Guarded edits select affected behavior owners
|
|
140
|
+
from their input dependencies and run their registered checks; project scripts
|
|
141
|
+
remain as configured and releases run the complete suite. Incremental compilation
|
|
142
|
+
alone does not make arbitrary lint/typecheck/test scripts incremental.
|
|
143
|
+
|
|
96
144
|
Preview watching excludes standard output trees by default, including nested
|
|
97
145
|
Cargo `target/` directories, without allocating watches inside them. Explicit
|
|
98
146
|
`sourceDir` and `dsDir` take priority over those default output names. Register
|
|
@@ -23,6 +23,25 @@ on-demand element screenshots. It grants no render/behavior coverage and no extr
|
|
|
23
23
|
styling permission. Use [captures.md](captures.md) for current/candidate review,
|
|
24
24
|
target selection, resource reads and storage lifecycle.
|
|
25
25
|
|
|
26
|
+
## Folder-derived showcase groups
|
|
27
|
+
|
|
28
|
+
Components, patterns and compositions use container folders to organize
|
|
29
|
+
navigation: `components/Forms/Input/Input.ads.scenario.tsx` appears under
|
|
30
|
+
**Forms** when `Forms/` contains only real directories. Hidden entries are ignored;
|
|
31
|
+
a regular file such as `index.ts` or `README.md`, or a symlink, prevents that
|
|
32
|
+
container from becoming a group. An owner's own directory and layer root never
|
|
33
|
+
form a group. Nested containers produce one path label: **Forms / Selection**.
|
|
34
|
+
Folder spelling and case are preserved: `form-controls/` displays `form-controls`.
|
|
35
|
+
|
|
36
|
+
Folders are the only grouping source. Do not add `group` metadata to a scenario
|
|
37
|
+
or owner contract. MCP's optional `group` field is computed discovery output;
|
|
38
|
+
`ads_scenarios(query: "Forms")` searches it along with existing scenario fields.
|
|
39
|
+
Use returned IDs with `ads_show_scenario`; `ads_catalog` previews, `ads_units` and
|
|
40
|
+
source resources retain the actual nested owner paths. Ungrouped entries remain
|
|
41
|
+
visible with no Default heading. Flat layouts keep working; tokens retain their
|
|
42
|
+
categories. When moving an owner, update its imports/public exports and any
|
|
43
|
+
references to changed path-derived scenario, behavior or capture IDs.
|
|
44
|
+
|
|
26
45
|
## Fragment links inside Apps
|
|
27
46
|
|
|
28
47
|
Keep intended `href="#"` and named fragments in the project API and fixtures.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Validation scope
|
|
2
|
+
|
|
3
|
+
Use `ads_validate({})` for the complete project audit, equivalent to `ads validate`.
|
|
4
|
+
Use `ads_validate({scope:"changed"})`, equivalent to `ads validate --changed`, during
|
|
5
|
+
editing when a successful full baseline exists. Both interfaces call the same
|
|
6
|
+
engine. Full is the default.
|
|
7
|
+
|
|
8
|
+
- During local editing, use existing guarded edits and affected behavior checks.
|
|
9
|
+
Reuse completed guards for unchanged source rather than repeatedly auditing all
|
|
10
|
+
owners. Direct edits need `ads_check` and appropriate project/behavior checks.
|
|
11
|
+
- After test migrations, ownership changes or validation/runner configuration
|
|
12
|
+
changes, run full validation. Also run it before a release or an explicit request
|
|
13
|
+
to validate everything. It validates the current source, not a prepared draft.
|
|
14
|
+
- Inspect failures through `ads_results` using the returned resultId and sections
|
|
15
|
+
diagnostics, checks or outcomes. For browser failures, use the outcome's exact
|
|
16
|
+
unit/check/runId with `ads_investigate`. Fix the owner and rerun the appropriate scope.
|
|
17
|
+
- Report the actual scope and revision. Scoped, stale, cancelled or incomplete
|
|
18
|
+
runs cannot establish successful full validation. Passing covers registered
|
|
19
|
+
checks and configured scripts, not arbitrary assertions, visual parity or every
|
|
20
|
+
application state.
|
|
21
|
+
|
|
22
|
+
Full validation runs core architecture/test-boundary guards, registered Oxlint,
|
|
23
|
+
project scripts and every registered behavior contract. Defaults use the existing
|
|
24
|
+
mutation-check scripts plus a project's `test` and build scripts when present.
|
|
25
|
+
Build selection prefers `build:lib`, then `build:app`, then `build`.
|
|
26
|
+
Projects can declare `validation.checks` as a list of package
|
|
27
|
+
script names for the complete audit; core/Oxlint and registered behaviors remain
|
|
28
|
+
mandatory. Commands are trusted project configuration, never MCP arguments.
|
|
29
|
+
Use scripts that check/build without changing source. Avoid calling `ads validate`
|
|
30
|
+
from a script selected by validation.
|
|
31
|
+
|
|
32
|
+
Changed mode compares current content, including added/deleted files, with the
|
|
33
|
+
last successful full baseline in `.ds/validation-baseline.json`. No Git history is
|
|
34
|
+
required. A missing/incompatible baseline or a change to configuration, foundation,
|
|
35
|
+
ownership that no longer resolves, or unclassified input expands to full and
|
|
36
|
+
reports the reason. Scoped runs leave the full baseline unchanged. Core architecture
|
|
37
|
+
checks and opaque project commands still run in full; behavior selection narrows
|
|
38
|
+
to affected owner contracts. This is not a per-test-result cache.
|
|
39
|
+
|
|
40
|
+
ADS tests live with their component, pattern, controller, composition or review
|
|
41
|
+
owner. Private imports must resolve to that owner, including through helpers;
|
|
42
|
+
peer implementations use the public API. Marked behavior specs must be registered
|
|
43
|
+
in an owner contract. Pure ADS tests outside those owners fail the boundary guard.
|
|
44
|
+
Application integration tests may exercise public UI alongside their real application
|
|
45
|
+
runtime subject. Ordinary local unit tests retain their project's runner; full
|
|
46
|
+
validation includes the configured test script. Registration is enforced for ADS
|
|
47
|
+
behavior specs, not inferred for every case in an arbitrary runner.
|
|
48
|
+
|
|
49
|
+
During execution `ads_status.validation` reports progress. MCP summaries retain a
|
|
50
|
+
separate latest validation result, alongside verification and mutation results.
|
|
51
|
+
Source changes during execution reject success and leave the previous full
|
|
52
|
+
baseline intact. Skipped registered behavior cases never pass; a project with no
|
|
53
|
+
registered behavior contracts reports that stage as skipped with a reason.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// TypeScript programs/checkers are immutable inspection snapshots. Share only
|
|
2
|
+
// context-free symbol lookups, including misses, within that checker. A new
|
|
3
|
+
// inspection gets a new checker; no filesystem result or diagnostic is retained.
|
|
4
|
+
const snapshots = new WeakMap();
|
|
5
|
+
|
|
6
|
+
export function sourceSymbol(checker, node) {
|
|
7
|
+
let symbols = snapshots.get(checker);
|
|
8
|
+
if (!symbols) snapshots.set(checker, symbols = new WeakMap());
|
|
9
|
+
if (!symbols.has(node)) symbols.set(node, checker.getSymbolAtLocation(node));
|
|
10
|
+
return symbols.get(node);
|
|
11
|
+
}
|
package/dist/source-values.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { isInside } from "./config.mjs";
|
|
3
3
|
import { uiOperation } from "./ui-framework.mjs";
|
|
4
|
+
import { sourceSymbol } from "./source-symbols.mjs";
|
|
4
5
|
|
|
5
6
|
export const unknown = reason => ({ kind: "unknown", reason });
|
|
6
7
|
export const literal = value => ({ kind: "literal", value });
|
|
@@ -16,8 +17,14 @@ export function unwrap(node) {
|
|
|
16
17
|
/** Bounded symbolic source traversal. No project code is imported or executed. */
|
|
17
18
|
export function createSourceValues(program, options, { preserveCall = () => false, strict = false } = {}) {
|
|
18
19
|
const checker = program.getTypeChecker();
|
|
20
|
+
const ownedFiles = new Map();
|
|
21
|
+
function owned(node) {
|
|
22
|
+
const file = node.getSourceFile().fileName;
|
|
23
|
+
if (!ownedFiles.has(file)) ownedFiles.set(file, isInside(options.dsRoot, file));
|
|
24
|
+
return ownedFiles.get(file);
|
|
25
|
+
}
|
|
19
26
|
const symbol = node => {
|
|
20
|
-
const value = checker
|
|
27
|
+
const value = sourceSymbol(checker, ts.isPropertyAccessExpression(node) ? node.name : node);
|
|
21
28
|
return value?.valueDeclaration && ts.isShorthandPropertyAssignment(value.valueDeclaration) ? checker.getShorthandAssignmentValueSymbol(value.valueDeclaration) ?? value : value;
|
|
22
29
|
};
|
|
23
30
|
function declaration(node) {
|
|
@@ -180,7 +187,7 @@ export function createSourceValues(program, options, { preserveCall = () => fals
|
|
|
180
187
|
return strict && escapes.has(symbol(node)) && (result.kind === "object" || result.kind === "array" || result.kind === "node" && (ts.isObjectLiteralExpression(result.node) || ts.isArrayLiteralExpression(result.node))) ? unknown("An object passed to another call may have been mutated.") : result;
|
|
181
188
|
}
|
|
182
189
|
const owner = declaration(node);
|
|
183
|
-
if (owner &&
|
|
190
|
+
if (owner && owned(owner)) {
|
|
184
191
|
if (isFunction(owner)) return reference(owner, env, via);
|
|
185
192
|
if (ts.isVariableDeclaration(owner) && owner.initializer && owner.parent.flags & ts.NodeFlags.Const) {
|
|
186
193
|
const result = resolve(reference(owner.initializer, env, via), next(context));
|
|
@@ -196,7 +203,7 @@ export function createSourceValues(program, options, { preserveCall = () => fals
|
|
|
196
203
|
if (key.kind === "literal") {
|
|
197
204
|
const selected = get(object, String(key.value), next(context));
|
|
198
205
|
const owner = declaration(node);
|
|
199
|
-
if (selected.kind === "unknown" && owner &&
|
|
206
|
+
if (selected.kind === "unknown" && owner && owned(owner)) {
|
|
200
207
|
if (isFunction(owner)) return reference(owner, env, via);
|
|
201
208
|
if (ts.isVariableDeclaration(owner) && owner.initializer && owner.parent.flags & ts.NodeFlags.Const) return resolve(reference(owner.initializer, env, via), next(context));
|
|
202
209
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { adsFileRole, isInside, isDevelopmentFile, isTestFile } from "./config.mjs";
|
|
5
|
+
import { importResolver } from "./boundaries.mjs";
|
|
6
|
+
import { previewFileIgnored } from "./preview-files.mjs";
|
|
7
|
+
|
|
8
|
+
/** Test ownership is structural; arbitrary assertion intent remains the runner's concern. */
|
|
9
|
+
export function inspectTestBoundaries(options, inventory, contracts, program) {
|
|
10
|
+
const diagnostics = [], resolve = importResolver(options), parsed = new Map(), tests = [];
|
|
11
|
+
const owner = file => inventory.owner(inventory.relative(path.relative(options.root,file)));
|
|
12
|
+
function source(file) {
|
|
13
|
+
if (!parsed.has(file)) parsed.set(file,program?.getSourceFile(file) ?? ts.createSourceFile(file,readFileSync(file,"utf8"),ts.ScriptTarget.Latest,true));
|
|
14
|
+
return parsed.get(file);
|
|
15
|
+
}
|
|
16
|
+
function walk(directory) {
|
|
17
|
+
for (const entry of readdirSync(directory,{withFileTypes:true})) {
|
|
18
|
+
const file = path.join(directory,entry.name);
|
|
19
|
+
if (entry.isSymbolicLink() || previewFileIgnored(options,file) || ["output","test-results","playwright-report",".playwright-cli"].includes(entry.name)) continue;
|
|
20
|
+
if (entry.isDirectory()) walk(file);
|
|
21
|
+
else if (entry.isFile() && /\.[cm]?[jt]sx?$/.test(file) && isTestFile(file)) {
|
|
22
|
+
let executable=/\.(?:test|spec)\.[cm]?[jt]sx?$/.test(file);
|
|
23
|
+
const names=new Set(["test","it","describe"]);
|
|
24
|
+
const ast=source(file);
|
|
25
|
+
for(const statement of ast.statements) if(ts.isImportDeclaration(statement)&&ts.isStringLiteralLike(statement.moduleSpecifier)&&/^(?:vitest|@playwright\/test|node:test|bun:test|@jest\/globals)$/.test(statement.moduleSpecifier.text)) {
|
|
26
|
+
const bindings=statement.importClause?.namedBindings;
|
|
27
|
+
if(statement.importClause?.name)names.add(statement.importClause.name.text);
|
|
28
|
+
if(bindings&&ts.isNamespaceImport(bindings))names.add(bindings.name.text);
|
|
29
|
+
if(bindings&&ts.isNamedImports(bindings))for(const item of bindings.elements)if(["test","it","describe"].includes((item.propertyName??item.name).text))names.add(item.name.text);
|
|
30
|
+
}
|
|
31
|
+
function visit(node){if(ts.isCallExpression(node)){let base=node.expression;while(ts.isPropertyAccessExpression(base)||ts.isCallExpression(base))base=base.expression;if(ts.isIdentifier(base)&&names.has(base.text))executable=true;}if(!executable)ts.forEachChild(node,visit);}
|
|
32
|
+
if(!executable)visit(ast);
|
|
33
|
+
if(executable)tests.push(file);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
walk(options.root);
|
|
38
|
+
const registered = new Set(contracts.flatMap(contract=>Object.values(contract.checks).map(check=>path.resolve(options.root,path.dirname(contract.file),check.file))));
|
|
39
|
+
function imports(file) {
|
|
40
|
+
const edges = [];
|
|
41
|
+
function visit(node) {
|
|
42
|
+
let specifier;
|
|
43
|
+
if ((ts.isImportDeclaration(node)||ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier)) specifier=node.moduleSpecifier.text;
|
|
44
|
+
if (ts.isCallExpression(node) && (node.expression.kind === ts.SyntaxKind.ImportKeyword || ts.isIdentifier(node.expression)&&node.expression.text === "require") && node.arguments[0] && ts.isStringLiteralLike(node.arguments[0])) specifier=node.arguments[0].text;
|
|
45
|
+
const typeOnly=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))||ts.isExportDeclaration(node)&&node.isTypeOnly;
|
|
46
|
+
if (specifier&&!typeOnly) for (const target of resolve(specifier,file)) if (existsSync(target) && isInside(options.root,target) && !target.split(path.sep).includes("node_modules") && /\.[cm]?[jt]sx?$/.test(target)) edges.push({specifier,target,node});
|
|
47
|
+
ts.forEachChild(node,visit);
|
|
48
|
+
}
|
|
49
|
+
visit(source(file));return edges;
|
|
50
|
+
}
|
|
51
|
+
function report(file,rule,message) { diagnostics.push({file:path.relative(options.root,file).replaceAll("\\","/"),rule,line:1,column:1,message}); }
|
|
52
|
+
for (const file of tests) {
|
|
53
|
+
const own = owner(file), inside = isInside(options.dsRoot,file);
|
|
54
|
+
const edges = imports(file);
|
|
55
|
+
const marked = adsFileRole(file) === "behavior.spec" || /@ads:[\w.-]+/.test(source(file).text);
|
|
56
|
+
if (marked && !registered.has(file)) report(file,"test-registration","ADS behavior specs must be registered by their owning contract. Register this file or remove the obsolete spec.");
|
|
57
|
+
if (inside) {
|
|
58
|
+
const unit = inventory.units.find(unit=>unit.id===own);
|
|
59
|
+
const real = ["configuration","foundation","tokens"].includes(own) || unit?.files.some(relative=>{const target=path.resolve(options.root,relative);return !isDevelopmentFile(target,options) || own?.startsWith("composition/") && /\.scenario\.[cm]?[jt]sx?$/.test(target);});
|
|
60
|
+
if (!real) report(file,"test-ownership","ADS tests belong beside a real runtime or composition owner. A test/helper file alone cannot create an owner.");
|
|
61
|
+
}
|
|
62
|
+
if (!inside) {
|
|
63
|
+
// Application tests may integrate public UI alongside application runtime.
|
|
64
|
+
// Helpers under test/ do not masquerade as the application subject.
|
|
65
|
+
let hasAppSubject = edges.some(edge=>isInside(options.sourceRoot,edge.target)&&!isInside(options.dsRoot,edge.target)&&!isDevelopmentFile(edge.target,options));
|
|
66
|
+
const seen = new Set(); let usesAds = marked;
|
|
67
|
+
function trace(target) {
|
|
68
|
+
if (seen.has(target)) return;seen.add(target);
|
|
69
|
+
for (const edge of imports(target)) {
|
|
70
|
+
if (isInside(options.dsRoot,edge.target)) usesAds=true;
|
|
71
|
+
else if (isDevelopmentFile(edge.target,options)) trace(edge.target);
|
|
72
|
+
else if (isInside(options.sourceRoot,edge.target)) hasAppSubject=true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
trace(file);
|
|
76
|
+
if (usesAds && !hasAppSubject) report(file,"test-ownership","This test exercises ADS without an application runtime subject. Move it beside its owning component/pattern or composition; application integration tests stay beside their application subject.");
|
|
77
|
+
}
|
|
78
|
+
// Development helpers cannot hide a private import across owners. Public
|
|
79
|
+
// barrel imports are permitted and stop at the declared API boundary.
|
|
80
|
+
if (inside) {
|
|
81
|
+
const seen = new Set();
|
|
82
|
+
function trace(target) {
|
|
83
|
+
if (seen.has(target)) return;seen.add(target);
|
|
84
|
+
for (const edge of imports(target)) {
|
|
85
|
+
if (edge.specifier === options.config.publicAlias || edge.specifier === `${options.config.publicAlias}/review`) continue;
|
|
86
|
+
if (!isInside(options.dsRoot,edge.target)) continue;
|
|
87
|
+
if (isDevelopmentFile(edge.target,options)) { trace(edge.target);continue; }
|
|
88
|
+
if (owner(edge.target) !== own && edge.target !== path.join(options.dsRoot,options.config.stylesEntry)) report(file,"test-private-import",`Test ${own} reaches private source owned by ${owner(edge.target)} through ${path.relative(options.root,target)}. Use the public ADS API for peers; private helpers stay with their owner.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
trace(file);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return diagnostics;
|
|
95
|
+
}
|
package/dist/ui-framework.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import ts from "typescript";
|
|
4
|
+
import { sourceSymbol } from "./source-symbols.mjs";
|
|
4
5
|
|
|
5
6
|
const modules = new Set(["react", "preact", "preact/compat", "preact/jsx-runtime"]);
|
|
6
7
|
|
|
@@ -37,7 +38,7 @@ export function importedUiApi(expression, checker) {
|
|
|
37
38
|
base = base.left ?? base.expression;
|
|
38
39
|
}
|
|
39
40
|
if (!ts.isIdentifier(base)) return null;
|
|
40
|
-
for (const declaration of checker
|
|
41
|
+
for (const declaration of sourceSymbol(checker, base)?.declarations ?? []) {
|
|
41
42
|
if (ts.isImportSpecifier(declaration) && modules.has(declaration.parent.parent.parent.moduleSpecifier.text)) {
|
|
42
43
|
return { name: [(declaration.propertyName ?? declaration.name).text, ...parts].join("."), module: declaration.parent.parent.parent.moduleSpecifier.text };
|
|
43
44
|
}
|
package/dist/units.mjs
CHANGED
|
@@ -66,7 +66,7 @@ export function configurationFiles(options) {
|
|
|
66
66
|
for (const match of command.matchAll(/\b(?:npm|bun)\s+run\s+([\w:.-]+)/g)) script(match[1]);
|
|
67
67
|
for (const match of command.matchAll(/\b(?:node|bun|tsx|ts-node)\s+([^\s;&|]+\.[cm]?[jt]sx?)(?=\s|$)/g)) visit(path.resolve(root, match[1]), true);
|
|
68
68
|
}
|
|
69
|
-
for (const name of ["lint:ds", "lint:style", "lint:project", "typecheck", "build:mcp-previews", "generate:icons", ...(config.mcp.mutationChecks ?? [])]) script(name);
|
|
69
|
+
for (const name of ["lint:ds", "lint:style", "lint:project", "typecheck", "build:mcp-previews", "generate:icons", "build:lib", "build:app", ...(config.validation?.checks ?? []), ...(config.mcp.mutationChecks ?? [])]) script(name);
|
|
70
70
|
const watch = config.mcp.previewWatch;
|
|
71
71
|
if (watch) {
|
|
72
72
|
if (["npm", "bun"].includes(watch.command) && watch.args[0] === "run") script(watch.args[1]);
|
|
@@ -76,6 +76,17 @@ export function configurationFiles(options) {
|
|
|
76
76
|
if (["npm", "bun"].includes(profile.command) && profile.args[0] === "run") script(profile.args[1]);
|
|
77
77
|
else for (const argument of [profile.command, ...profile.args]) if (/\.[cm]?[jt]sx?$/.test(argument)) visit(path.resolve(root, argument), true);
|
|
78
78
|
}
|
|
79
|
+
// Build/configuration tests follow their actual setup source, without
|
|
80
|
+
// capturing component tests invoked by a registered runner.
|
|
81
|
+
const setupSources = [...files];
|
|
82
|
+
for (const file of setupSources) {
|
|
83
|
+
if (!source.test(file)) continue;
|
|
84
|
+
const stem=file.replace(/\.[cm]?[jt]sx?$/,"");
|
|
85
|
+
for (const role of ["test","spec"]) for (const extension of ["ts","tsx","js","mjs","mts"]) {
|
|
86
|
+
const sidecar=`${stem}.ads.${role}.${extension}`;
|
|
87
|
+
if (existsSync(path.join(root,sidecar))) files.add(sidecar);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
79
90
|
return files;
|
|
80
91
|
}
|
|
81
92
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { projectContext } from "./mcp/context.mjs";
|
|
5
|
+
import { packageScriptCommand } from "./development-runtime.mjs";
|
|
6
|
+
import { failure as evidenceFailure } from "./evidence.mjs";
|
|
7
|
+
const fail = (rule, message, file, failure) => Object.assign(new Error(message), { diagnostic: {rule, message, ...(file ? {file} : {}), ...(failure ? {failure} : {})} });
|
|
8
|
+
|
|
9
|
+
export function checkCommand(command, args, cwd, signal, input, gate = {category:"architecture",phase:"patch-preparation"}, timeoutMs = 60000) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
if (signal?.aborted) { reject(fail("mutation-cancelled", "Mutation cancelled before validation.",undefined,evidenceFailure("runner","mutation-execution","ADS_CANCELLED"))); return; }
|
|
12
|
+
const child = spawn(command, args, { cwd, shell: false, detached: process.platform !== "win32", windowsHide: true, stdio: [input === undefined ? "ignore" : "pipe", "pipe", "pipe"],
|
|
13
|
+
env: { ...process.env, PATH: [path.join(cwd, "node_modules/.bin"), path.dirname(process.execPath), process.env.PATH ?? ""].join(path.delimiter) } });
|
|
14
|
+
let output = "", failure;
|
|
15
|
+
const startedAt=Date.now();
|
|
16
|
+
if (input !== undefined) { child.stdin.on("error", () => {}); child.stdin.end(input); }
|
|
17
|
+
function kill() {
|
|
18
|
+
if (!child.pid) return;
|
|
19
|
+
if (process.platform === "win32") {
|
|
20
|
+
const stop = spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
21
|
+
stop.on("error", () => child.kill("SIGKILL"));
|
|
22
|
+
} else { try { process.kill(-child.pid, "SIGKILL"); } catch (error) { if (error.code !== "ESRCH") failure ??= error; } }
|
|
23
|
+
}
|
|
24
|
+
const abort = () => { failure = fail("mutation-cancelled", "Mutation cancelled during validation."); kill(); };
|
|
25
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
26
|
+
const timer = setTimeout(() => { failure = fail("mutation-check", `${path.basename(command)} ${args.join(" ")} exceeded its ${timeoutMs} ms command budget.`); failure.code="ADS_COMMAND_TIMEOUT"; kill(); }, timeoutMs);
|
|
27
|
+
for (const stream of [child.stdout, child.stderr]) stream.on("data", chunk => { output = (output + chunk.toString()).slice(-12000); });
|
|
28
|
+
child.once("error", error => { failure = error; });
|
|
29
|
+
child.once("exit", kill); // Also clean up descendants of a finished launcher.
|
|
30
|
+
child.once("close", code => {
|
|
31
|
+
clearTimeout(timer); signal?.removeEventListener("abort", abort);
|
|
32
|
+
const detail={command:path.basename(command),args,timeoutMs,elapsedMs:Date.now()-startedAt,exitCode:code};
|
|
33
|
+
if (failure || code !== 0) {
|
|
34
|
+
const error=failure??fail("mutation-check", `${path.basename(command)} ${args.join(" ")} failed (${code}).\n${output}`);
|
|
35
|
+
error.diagnostic={...(error.diagnostic??{rule:"mutation-check",message:error.message}),...detail,output:output.slice(-4000),failure:evidenceFailure(failure?"runner":gate.category,gate.phase,failure?.code??(failure?"ADS_COMMAND_INTERRUPTED":"ADS_COMMAND_EXIT"),{certainty:"observed-boundary"})};
|
|
36
|
+
reject(error);
|
|
37
|
+
} else resolve({ ...detail,phase:gate.phase, passed: true });
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
export function projectChecks(options) {
|
|
44
|
+
const context = projectContext(options);
|
|
45
|
+
const pkg = JSON.parse(readFileSync(path.join(options.root, "package.json"), "utf8"));
|
|
46
|
+
const scripts = options.config.mcp.mutationChecks ?? [pkg.scripts?.["lint:project"] ? "lint:project" : "lint", "typecheck", "build:mcp-previews"].filter(name => typeof pkg.scripts?.[name] === "string");
|
|
47
|
+
if (scripts.some(name => typeof pkg.scripts?.[name] !== "string")) throw fail("mutation-check", "Every configured mcp.mutationChecks script must exist in package.json.");
|
|
48
|
+
if (scripts.length && !["npm", "bun"].includes(context.packageManager)) throw fail("mutation-check", "Declare packageManager as npm or bun to run mutation checks.");
|
|
49
|
+
return scripts.map(script => packageScriptCommand(context.packageManager, script));
|
|
50
|
+
}
|