@reqvire-org/ads 0.3.33 → 0.3.34
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/behavior-libraries.mjs +93 -0
- package/dist/behaviors.mjs +0 -6
- package/dist/bootstrap-ds/ds.config.json +1 -0
- package/dist/capture.mjs +3 -3
- package/dist/check.mjs +2 -0
- package/dist/config.mjs +4 -0
- package/dist/lint-config.mjs +7 -0
- package/dist/mcp/build-status.mjs +1 -1
- package/dist/mcp/catalog.mjs +4 -2
- package/dist/mcp/draft-discovery.mjs +55 -0
- package/dist/mcp/drafts.mjs +135 -16
- package/dist/mcp/preview-watch.mjs +13 -2
- package/dist/mcp/preview-widget.bundle.js +14 -14
- package/dist/mcp/server.mjs +109 -27
- package/dist/scenario-inspector.mjs +5 -5
- package/dist/scenario-program.mjs +36 -0
- package/dist/scenario-registry.mjs +90 -0
- package/dist/scenarios-compiler.mjs +66 -22
- package/dist/scenarios.mjs +2 -1
- package/dist/showcase/client.bundle.js +39 -39
- package/dist/showcase/comparison.js +29 -5
- package/dist/showcase/draft-navigation.js +41 -0
- package/dist/showcase/index.html +1 -2
- package/dist/showcase/preview-state.js +19 -0
- package/dist/showcase/style.css +2 -2
- package/dist/skills/ads-break-ui/references/behaviors.md +10 -0
- package/dist/skills/ads-break-ui/references/drafts.md +43 -4
- package/dist/skills/ads-break-ui/references/validation.md +6 -0
- package/dist/skills/ads-designer/SKILL.md +7 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/ds.config.json +1 -0
- package/dist/skills/ads-designer/references/behaviors.md +10 -0
- package/dist/skills/ads-designer/references/drafts.md +43 -4
- package/dist/skills/ads-designer/references/validation.md +6 -0
- package/dist/skills/ads-import/SKILL.md +4 -0
- package/dist/skills/ads-import/references/behaviors.md +10 -0
- package/dist/skills/ads-import/references/drafts.md +43 -4
- package/dist/skills/ads-import/references/validation.md +6 -0
- package/dist/skills/ads-motion/references/behaviors.md +10 -0
- package/dist/skills/ads-motion/references/drafts.md +43 -4
- package/dist/skills/ads-motion/references/validation.md +6 -0
- package/dist/skills/ads-port/SKILL.md +8 -1
- package/dist/skills/ads-port/references/behaviors.md +10 -0
- package/dist/skills/ads-port/references/drafts.md +43 -4
- package/dist/skills/ads-port/references/native-implementation.md +14 -1
- package/dist/skills/ads-port/references/validation.md +6 -0
- package/dist/unit-contracts.mjs +2 -2
- package/dist/units.mjs +6 -0
- package/dist/verification/browser.d.mts +27 -0
- package/dist/verification.mjs +3 -0
- package/docs/ARCHITECTURE.md +82 -0
- package/docs/CHANGELOG.md +92 -0
- package/docs/GUIDE.md +29 -4
- package/docs/MCP.md +44 -4
- package/package.json +6 -4
|
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameS
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { isDraftPreviewWorkspace } from "./draft-workspace.mjs";
|
|
5
5
|
import { loadConfig, isInside } from "./config.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { discoverScenarioRegistry } from "./scenario-registry.mjs";
|
|
7
7
|
import { artifactDigest, createBuildReporter } from "./mcp/build-status.mjs";
|
|
8
8
|
import { cachedPreviewPublication, previewArtifactHtml, readPreviewManifest } from "./preview-resources.mjs";
|
|
9
9
|
import { previewArtifactPath, withPreviewSession } from "./preview-scope.mjs";
|
|
@@ -19,7 +19,7 @@ const fileDigest = file => { try { return digest(readFileSync(file)); } catch {
|
|
|
19
19
|
export function createPreviewCache(options, compilerFiles = []) {
|
|
20
20
|
const { root } = options;
|
|
21
21
|
const key = file => isInside(import.meta.dirname,file) ? `ads-tool/${path.relative(import.meta.dirname,file)}` : isInside(root,file) ? `project/${path.relative(root,file)}` : file;
|
|
22
|
-
const adapterFiles = [import.meta.filename, ...["preview-builder.mjs", "preview-workers.mjs", "preview-files.mjs", "preview-inputs.mjs", "preview-resources.mjs", "preview-scope.mjs", "scenario-groups.mjs", "scenario-inspector.mjs", "scenarios-vite.mjs", "linaria.mjs", "linaria/atomic-css.cjs", "linaria/atomic-styled.cjs", "linaria/preserve-values.cjs"].map(file => path.join(import.meta.dirname, file)), ...compilerFiles,
|
|
22
|
+
const adapterFiles = [import.meta.filename, ...["preview-builder.mjs", "preview-workers.mjs", "preview-files.mjs", "preview-inputs.mjs", "preview-resources.mjs", "preview-scope.mjs", "scenario-groups.mjs", "scenario-inspector.mjs", "scenario-registry.mjs", "scenarios-vite.mjs", "linaria.mjs", "linaria/atomic-css.cjs", "linaria/atomic-styled.cjs", "linaria/preserve-values.cjs"].map(file => path.join(import.meta.dirname, file)), ...compilerFiles,
|
|
23
23
|
...["package.json", "package-lock.json", "bun.lock", "bun.lockb", "node_modules/.package-lock.json"].map(file => path.join(root, file))];
|
|
24
24
|
const adapterDigest = () => digest(JSON.stringify(adapterFiles.map(file => [key(file), fileDigest(file)])));
|
|
25
25
|
const loadedAdapter = adapterDigest();
|
|
@@ -80,7 +80,21 @@ export function createPreviewCache(options, compilerFiles = []) {
|
|
|
80
80
|
artifact: artifactDigest(path.join(root, previewArtifactPath(options, entry.artifact))) };
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function recordCurrent(stamp, update) {
|
|
84
|
+
// Publication and dependency hashing can overlap the next external edit.
|
|
85
|
+
// Never attach the previous output to bytes newer than its compiled stamp.
|
|
86
|
+
if (inputs() !== stamp) return false;
|
|
87
|
+
const previous = value;
|
|
88
|
+
value = { ...value, entries: { ...value.entries } };
|
|
89
|
+
try {
|
|
90
|
+
update();
|
|
91
|
+
if (inputs() !== stamp) { value = previous; return false; }
|
|
92
|
+
save();
|
|
93
|
+
return true;
|
|
94
|
+
} catch (error) { value = previous; throw error; }
|
|
95
|
+
}
|
|
96
|
+
function graph(revision, entries, stamp) { value.graphRevision=revision;value.graphInputs=stamp;value.registry=entries; }
|
|
97
|
+
function recordGraph(revision, entries, stamp = inputs()) { return recordCurrent(stamp, () => graph(revision, entries, stamp)); }
|
|
84
98
|
return { inputs, reusable, reload, snapshot: () => structuredClone(value), seed(state) { value=structuredClone(state);save(); }, graphRevision: () => value.graphRevision, recordGraph, validated: stamp => value.validation === stamp,
|
|
85
99
|
registry(stamp) {
|
|
86
100
|
if(value.validation!==stamp || value.graphInputs!==stamp || !Array.isArray(value.registry) || !value.registry.length || value.registry.length>1000)return null;
|
|
@@ -93,11 +107,10 @@ export function createPreviewCache(options, compilerFiles = []) {
|
|
|
93
107
|
if (adapterDigest() !== loadedAdapter) throw Object.assign(new Error("Preview compiler code or dependencies changed. Invoke the preview again to restart the builder and load current code."), { code: "ADS_PREVIEW_RESTART" });
|
|
94
108
|
},
|
|
95
109
|
validate(stamp) { value.validation = stamp; save(); },
|
|
96
|
-
recordAll(entries, dependencies, revision
|
|
97
|
-
|
|
98
|
-
recordEntries([entry], dependencies);
|
|
99
|
-
save();
|
|
110
|
+
recordAll(entries, dependencies, revision, stamp = inputs()) {
|
|
111
|
+
return recordCurrent(stamp, () => { recordEntries(entries, dependencies); graph(revision, entries, stamp); });
|
|
100
112
|
},
|
|
113
|
+
record(entry, dependencies, stamp = inputs()) { return recordCurrent(stamp, () => recordEntries([entry], dependencies)); },
|
|
101
114
|
};
|
|
102
115
|
}
|
|
103
116
|
|
|
@@ -135,7 +148,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
135
148
|
const cache = createPreviewCache(options, compilerFiles);
|
|
136
149
|
function registry() {
|
|
137
150
|
options = withPreviewSession(loadConfig(root), process.env.ADS_MCP_BUILD_SESSION);
|
|
138
|
-
const result =
|
|
151
|
+
const result = discoverScenarioRegistry(options);
|
|
139
152
|
if (result.diagnostics.length) throw Object.assign(new Error(result.diagnostics.map(item => `${item.file}: ${item.message}`).join("\n")), { scenarios: result.scenarios });
|
|
140
153
|
mkdirSync(path.join(root, ".ds/scenarios"), { recursive: true });
|
|
141
154
|
writeFileSync(path.join(root, ".ds/scenarios/manifest.json"), JSON.stringify({ schemaVersion: 1, scenarios: result.scenarios }, null, 2));
|
|
@@ -156,10 +169,12 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
156
169
|
let stopped = false;
|
|
157
170
|
let generation = 0;
|
|
158
171
|
let publishedStamp;
|
|
172
|
+
let publishedEntries = new Set();
|
|
159
173
|
let validation;
|
|
160
174
|
let observedSourceRevision = previewSourceRevision(options);
|
|
161
175
|
let invalidation;
|
|
162
176
|
const inspector = watched && buildGraph ? createScenarioInspector(root) : null;
|
|
177
|
+
let discovering, unknownRevision;
|
|
163
178
|
let liveCandidate, verifying = false;
|
|
164
179
|
function failure(error) {
|
|
165
180
|
try { reporter.failure(error); } catch (reportError) { console.error(reportError); }
|
|
@@ -218,7 +233,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
218
233
|
if (failure) throw failure.reason;
|
|
219
234
|
cache.assertCompiler();
|
|
220
235
|
if (stopped || started !== generation || stamp !== cache.inputs()) return; // Watch queued a newer revision.
|
|
221
|
-
if (!reuse
|
|
236
|
+
if (!reuse && !cache.record(entry, dependencies, stamp)) return;
|
|
222
237
|
reporter.ready(entry.id, revision);
|
|
223
238
|
reporter.progress("idle");
|
|
224
239
|
} catch (error) {
|
|
@@ -267,10 +282,10 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
267
282
|
const publication = outcomes[1].value;
|
|
268
283
|
if (publication) {
|
|
269
284
|
publication.publish(reporter.session);
|
|
270
|
-
cache.recordAll(entries, dependencies, publication.revision);
|
|
285
|
+
if (!cache.recordAll(entries, dependencies, publication.revision, stamp)) return;
|
|
271
286
|
} else {
|
|
272
287
|
cached.publish(reporter.session);
|
|
273
|
-
cache.recordGraph(cached.revision,entries);
|
|
288
|
+
if (!cache.recordGraph(cached.revision,entries,stamp)) return;
|
|
274
289
|
}
|
|
275
290
|
for (const entry of entries) { pending.delete(entry.id); reporter.ready(entry.id, revisions.get(entry.id)); }
|
|
276
291
|
publishedStamp = stamp;
|
|
@@ -290,12 +305,20 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
290
305
|
cache.reload();
|
|
291
306
|
const sourceRevision = previewSourceRevision(options), stamp = cache.inputs();
|
|
292
307
|
const prepared=cache.registry(stamp);
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
//
|
|
296
|
-
|
|
308
|
+
// A guarded edit can publish a checked graph while this watcher's discovery
|
|
309
|
+
// still describes the previous revision. Adopt its current metadata before
|
|
310
|
+
// comparing registries. A partial watched graph cannot replace the catalogue.
|
|
311
|
+
if (prepared?.length === entries.length && prepared.every((entry, index) => entry.id === entries[index].id)) {
|
|
312
|
+
entries = prepared;
|
|
313
|
+
reporter.setApps(buildApps());
|
|
314
|
+
}
|
|
315
|
+
const registryReused = !!prepared && JSON.stringify(prepared) === JSON.stringify(entries);
|
|
316
|
+
const selected = registryReused ? prepared : entries.filter(entry => requested.has(entry.id));
|
|
317
|
+
const candidate = { generation, stamp, sourceRevision, registry: [...entries], entries: selected, dependencies: new Set(), registryReused };
|
|
318
|
+
// Retain roots requested by other mounted Apps, without compiling untouched
|
|
319
|
+
// catalogue entries. Production/unwatched builds still cover all entries.
|
|
297
320
|
for (const entry of candidate.entries) pending.delete(entry.id);
|
|
298
|
-
candidate.revisions = reporter.batch(() => new Map(entries.map(entry => [entry.id, reporter.begin(entry.id, { sourceRevision })])));
|
|
321
|
+
candidate.revisions = reporter.batch(() => new Map(candidate.entries.map(entry => [entry.id, reporter.begin(entry.id, { sourceRevision })])));
|
|
299
322
|
reporter.progress("validation-and-compilation");
|
|
300
323
|
const track = { name: "ads-live-preview-dependencies", generateBundle() {
|
|
301
324
|
for (const id of this.getModuleIds()) {
|
|
@@ -357,7 +380,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
357
380
|
}
|
|
358
381
|
// Give compiled feedback priority before starting CPU-heavy validation.
|
|
359
382
|
// An already running check continues; later edits replace its candidate.
|
|
360
|
-
const inspection=candidate.reused&&candidate.registryReused?Promise.resolve({scenarios:candidate.
|
|
383
|
+
const inspection=candidate.reused&&candidate.registryReused?Promise.resolve({scenarios:candidate.registry,diagnostics:[]}):inspector.inspect();
|
|
361
384
|
const outcomes = [compiled, ...await Promise.allSettled([gate(candidate.stamp), inspection])];
|
|
362
385
|
if (stopped) return;
|
|
363
386
|
if (candidate !== liveCandidate || candidate.generation !== generation || candidate.stamp !== cache.inputs()) {
|
|
@@ -368,7 +391,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
368
391
|
if (outcomes[2].status === "rejected") throw outcomes[2].reason;
|
|
369
392
|
const registry = outcomes[2].value;
|
|
370
393
|
if (registry.diagnostics.length) throw new Error(registry.diagnostics.map(item => `${item.file}: ${item.message}`).join("\n"));
|
|
371
|
-
if (JSON.stringify(registry.scenarios) !== JSON.stringify(candidate.
|
|
394
|
+
if (JSON.stringify(registry.scenarios) !== JSON.stringify(candidate.registry)) {
|
|
372
395
|
entries = registry.scenarios;
|
|
373
396
|
writeFileSync(path.join(root, ".ds/scenarios/manifest.json"), JSON.stringify({ schemaVersion: 1, scenarios: entries }, null, 2));
|
|
374
397
|
reporter.batch(() => { reporter.setApps(buildApps()); reporter.live(undefined); reporter.progress("idle"); });
|
|
@@ -386,14 +409,17 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
386
409
|
const publication = outcomes[0].value;
|
|
387
410
|
if (stopped || candidate !== liveCandidate || candidate.generation !== generation || candidate.stamp !== cache.inputs()) continue;
|
|
388
411
|
publication.publish(reporter.session);
|
|
389
|
-
|
|
390
|
-
|
|
412
|
+
const recorded = !candidate.reused
|
|
413
|
+
? cache.recordAll(candidate.entries, candidate.dependencies, publication.revision, candidate.stamp)
|
|
414
|
+
: cache.recordGraph(publication.revision,candidate.entries,candidate.stamp);
|
|
415
|
+
if (!recorded) { if (candidate === liveCandidate) liveCandidate = undefined; continue; }
|
|
391
416
|
reporter.batch(() => {
|
|
392
417
|
for (const entry of candidate.entries) reporter.ready(entry.id, candidate.revisions.get(entry.id));
|
|
393
418
|
reporter.live(undefined);
|
|
394
419
|
reporter.progress("idle");
|
|
395
420
|
});
|
|
396
421
|
publishedStamp = candidate.stamp;
|
|
422
|
+
publishedEntries = new Set(candidate.entries.map(entry => entry.id));
|
|
397
423
|
} catch (error) {
|
|
398
424
|
if (!candidate.failed) rejectLive(candidate, error);
|
|
399
425
|
}
|
|
@@ -414,6 +440,23 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
414
440
|
} catch (error) { failure(error); }
|
|
415
441
|
finally { compiling = false; }
|
|
416
442
|
}
|
|
443
|
+
function discoverUnknownEntries() {
|
|
444
|
+
if (!inspector || discovering) return;
|
|
445
|
+
const revision = previewSourceRevision(options);
|
|
446
|
+
if (unknownRevision === revision) return;
|
|
447
|
+
unknownRevision = revision;
|
|
448
|
+
discovering = inspector.inspect().then(result => {
|
|
449
|
+
if (stopped) return;
|
|
450
|
+
if (previewSourceRevision(options) !== revision) { unknownRevision = undefined; return; }
|
|
451
|
+
if (result.diagnostics.length) throw new Error(result.diagnostics.map(item => `${item.file}: ${item.message}`).join("\n"));
|
|
452
|
+
if (JSON.stringify(result.scenarios) === JSON.stringify(entries)) return;
|
|
453
|
+
++generation; entries = result.scenarios; registryFailure = undefined; liveCandidate = undefined;
|
|
454
|
+
reporter.setApps(buildApps());
|
|
455
|
+
writeFileSync(path.join(root, ".ds/scenarios/manifest.json"), JSON.stringify({ schemaVersion: 1, scenarios: entries }));
|
|
456
|
+
for (const id of requested) if (!entries.some(entry => entry.id === id)) requested.delete(id);
|
|
457
|
+
request();
|
|
458
|
+
}).catch(error => { if (!stopped) failure(error); }).finally(() => { discovering = undefined; });
|
|
459
|
+
}
|
|
417
460
|
function request(startBuild = true) {
|
|
418
461
|
const file = process.env.ADS_MCP_REQUEST_FILE;
|
|
419
462
|
if (!file || !existsSync(file)) return;
|
|
@@ -425,13 +468,14 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
425
468
|
if (requested.size) sourceChanged("invalidate",options.config.dsDir,true);
|
|
426
469
|
}
|
|
427
470
|
active = entries.find(entry => entry.artifact === value.active)?.id;
|
|
471
|
+
if (value.files.some(file => !entries.some(entry => entry.artifact === file))) discoverUnknownEntries();
|
|
428
472
|
for (const file of value.files) {
|
|
429
473
|
const entry = entries.find(entry => entry.artifact === file);
|
|
430
474
|
if (entry && !requested.has(entry.id)) {
|
|
431
475
|
requested.add(entry.id);
|
|
432
476
|
const covered = liveCandidate && !liveCandidate.failed && liveCandidate.generation === generation
|
|
433
477
|
&& liveCandidate.stamp === cache.inputs() && liveCandidate.entries.some(item => item.id === entry.id);
|
|
434
|
-
if (!buildGraph || publishedStamp !== cache.inputs() && !covered) pending.add(entry.id);
|
|
478
|
+
if (!buildGraph || (!publishedEntries.has(entry.id) || publishedStamp !== cache.inputs()) && !covered) pending.add(entry.id);
|
|
435
479
|
}
|
|
436
480
|
}
|
|
437
481
|
if (startBuild) void drain();
|
|
@@ -476,7 +520,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
476
520
|
} catch (error) {
|
|
477
521
|
registryFailure = error; failure(error);
|
|
478
522
|
}
|
|
479
|
-
},
|
|
523
|
+
}, 16);
|
|
480
524
|
}
|
|
481
525
|
// Do not allocate recursive OS watches for node_modules or generated trees.
|
|
482
526
|
const watchers = new Map();
|
package/dist/scenarios.mjs
CHANGED
|
@@ -41,7 +41,8 @@ export function publicUi(program, options) {
|
|
|
41
41
|
export function inspectScenarios(options, suppliedProgram) {
|
|
42
42
|
const { root, dsRoot } = options;
|
|
43
43
|
const files = sourceFiles(dsRoot).filter(isScenarioFile);
|
|
44
|
-
const
|
|
44
|
+
const contracts = inspectUnitContracts(options, suppliedProgram);
|
|
45
|
+
const program = suppliedProgram ?? contracts.program ?? ts.createProgram([path.join(dsRoot, options.config.publicEntry), path.join(dsRoot, options.config.reviewEntry), ...files], { ...projectCompilerOptions(options), allowJs: true });
|
|
45
46
|
const apis = scenarioApi(program, options);
|
|
46
47
|
const duplicate = apis.find((item, index) => apis.some((other, otherIndex) => index !== otherIndex && item.name === other.name));
|
|
47
48
|
const known = new Map(apis.filter(item => item.kind !== "controllers").map((item) => [item.name, item]));
|