@reqvire-org/ads 0.3.34 → 0.3.36
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/check-runner.mjs +7 -0
- package/dist/mcp/drafts.mjs +5 -2
- package/dist/mcp/mutation-limits.mjs +2 -0
- package/dist/mcp/mutations.mjs +20 -11
- package/dist/mcp/patch.mjs +5 -3
- package/dist/mcp/preview-owner-guard.mjs +36 -1
- package/dist/mcp/preview-watch.mjs +88 -13
- package/dist/mcp/preview-work.mjs +41 -0
- package/dist/mcp/server.mjs +29 -16
- package/dist/preview-builder.mjs +1 -0
- package/dist/scenario-inspector.mjs +11 -5
- package/dist/scenario-registry.mjs +16 -0
- package/dist/scenarios-compiler.mjs +90 -23
- package/dist/skills/ads-break-ui/references/drafts.md +6 -0
- package/dist/skills/ads-break-ui/references/guarded-editing.md +2 -2
- package/dist/skills/ads-break-ui/references/runtimes.md +9 -0
- package/dist/skills/ads-designer/references/drafts.md +6 -0
- package/dist/skills/ads-designer/references/guarded-editing.md +2 -2
- package/dist/skills/ads-designer/references/runtimes.md +9 -0
- package/dist/skills/ads-import/references/drafts.md +6 -0
- package/dist/skills/ads-import/references/guarded-editing.md +2 -2
- package/dist/skills/ads-import/references/runtimes.md +9 -0
- package/dist/skills/ads-motion/references/drafts.md +6 -0
- package/dist/skills/ads-motion/references/guarded-editing.md +2 -2
- package/dist/skills/ads-motion/references/runtimes.md +9 -0
- package/dist/skills/ads-port/references/drafts.md +6 -0
- package/dist/skills/ads-port/references/guarded-editing.md +2 -2
- package/dist/skills/ads-port/references/runtimes.md +9 -0
- package/dist/validation-checks.mjs +23 -3
- package/dist/validation.mjs +19 -10
- package/dist/verification.mjs +5 -4
- package/docs/ARCHITECTURE.md +28 -0
- package/docs/CHANGELOG.md +41 -12
- package/docs/GUIDE.md +5 -1
- package/docs/MCP.md +12 -7
- package/docs/benchmarks/gidi-preview-memory.md +141 -0
- package/package.json +1 -1
package/dist/mcp/server.mjs
CHANGED
|
@@ -3,14 +3,14 @@ import path from "node:path";
|
|
|
3
3
|
import { Server, ProtocolError, INVALID_PARAMS, ResourceNotFoundError } from "@modelcontextprotocol/server";
|
|
4
4
|
import { serveStdio, StdioServerTransport } from "@modelcontextprotocol/server/stdio";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import {
|
|
6
|
+
import { checkCandidate } from "../validation-checks.mjs";
|
|
7
7
|
import { createValidationController } from "../validation.mjs";
|
|
8
8
|
import { loadConfig, sourceFiles } from "../config.mjs";
|
|
9
9
|
import { createVerificationController, BEHAVIOR_URI } from "../verification.mjs";
|
|
10
10
|
import { INVESTIGATIONS_URI, investigationIndex, investigationPage, investigationSections, readInvestigation, readInvestigationResource } from "../investigations.mjs";
|
|
11
11
|
import { failure } from "../evidence.mjs";
|
|
12
12
|
import { inspectTokens } from "../tokens.mjs";
|
|
13
|
-
import { discoverScenarioRegistry } from "../scenario-registry.mjs";
|
|
13
|
+
import { discoverScenarioRegistry, releaseScenarioRegistry } from "../scenario-registry.mjs";
|
|
14
14
|
import { scenarioGroupFingerprint } from "../scenario-groups.mjs";
|
|
15
15
|
import { startShowcaseHost } from "./showcase-host.mjs";
|
|
16
16
|
import { createSkillStore, page, SKILLS_EXTENSION } from "./skills.mjs";
|
|
@@ -23,6 +23,7 @@ import { createReconfigurablePreviewWatch } from "./preview-watch.mjs";
|
|
|
23
23
|
import { BUILD_URI, buildFailure, inspectBuildStatus, summarizeBuild } from "./build-status.mjs";
|
|
24
24
|
import { GUIDE_URI, projectContext, projectGuide, serverInstructions, workflow } from "./context.mjs";
|
|
25
25
|
import { createMutationController, mutationLimits } from "./mutations.mjs";
|
|
26
|
+
import { createPreviewWork } from "./preview-work.mjs";
|
|
26
27
|
import { prepareUnitPatch, storePreparedPatch } from "./edit-preparation.mjs";
|
|
27
28
|
import { reconcileTokenSamples } from "../token-fixtures.mjs";
|
|
28
29
|
import { createCaptureController } from "../capture.mjs";
|
|
@@ -70,13 +71,13 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
70
71
|
const cache = inspection ?? {};
|
|
71
72
|
const skills = cache.skills ??= createSkillStore(skillDirectory);
|
|
72
73
|
const captures = cache.captures ??= createCaptureController(root);
|
|
73
|
-
const edits = cache.edits ??= createMutationController(root, { captures });
|
|
74
|
+
const edits = cache.edits ??= createMutationController(root, { captures, previewWork: cache.previewWork });
|
|
74
75
|
const draftObservers = cache.draftObservers ??= new Set();
|
|
75
76
|
const drafts = cache.drafts ??= createDraftController(root, { edits, prewarm: true,
|
|
76
77
|
onChange: () => { for (const observer of draftObservers) void observer().catch(error => { process.stderr.write(`ads mcp: ${error.message}\n`); }); },
|
|
77
|
-
startPreview: workspace => startAdsMcp(workspace, { stdio: false, mutations: false }) });
|
|
78
|
-
const verification = cache.verification ??= createVerificationController(root);
|
|
79
|
-
const validation = cache.validation ??= createValidationController(root);
|
|
78
|
+
startPreview: workspace => startAdsMcp(workspace, { stdio: false, mutations: false, previewWork: cache.previewWork }) });
|
|
79
|
+
const verification = cache.verification ??= createVerificationController(root, { previewWork: cache.previewWork });
|
|
80
|
+
const validation = cache.validation ??= createValidationController(root, { previewWork: cache.previewWork });
|
|
80
81
|
const executionResults = cache.executionResults ??= createExecutionResults(root);
|
|
81
82
|
const reports = cache.reports ??= createReportStore(root, { context: reportContext, resolveEvidence: reportEvidence });
|
|
82
83
|
let options = loadConfig(root);
|
|
@@ -87,6 +88,13 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
87
88
|
cache.registry = cache.catalog = cache.documents = undefined;
|
|
88
89
|
}
|
|
89
90
|
const getShowcaseUrl = () => showcaseUrl?.() ?? options.config.mcp.showcaseUrl;
|
|
91
|
+
async function architecture(signal) {
|
|
92
|
+
let release;
|
|
93
|
+
try {
|
|
94
|
+
if (cache.previewWork) release = await cache.previewWork.acquire(signal);
|
|
95
|
+
return await checkCandidate(root, signal);
|
|
96
|
+
} finally { release?.(); }
|
|
97
|
+
}
|
|
90
98
|
function scenarioUrl(id) {
|
|
91
99
|
const base = getShowcaseUrl();
|
|
92
100
|
if (!base) return null;
|
|
@@ -105,7 +113,9 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
105
113
|
const getRegistry = () => {
|
|
106
114
|
const current = loadConfig(root), revision = previewSourceRevision(current);
|
|
107
115
|
if (!cache.registry || cache.registryRevision !== revision) {
|
|
108
|
-
cache.registry = discoverScenarioRegistry(current);
|
|
116
|
+
try { cache.registry = discoverScenarioRegistry(current); }
|
|
117
|
+
finally { releaseScenarioRegistry(root); }
|
|
118
|
+
cache.registryRevision = revision; cache.catalog = undefined; cache.behaviorLibraries = undefined;
|
|
109
119
|
}
|
|
110
120
|
cache.lastRegistry = cache.registry; return cache.registry;
|
|
111
121
|
};
|
|
@@ -268,7 +278,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
268
278
|
else if (uri === `${PROJECT_URI}/catalog`) value = { items: annotateDrafts(getCatalog()) };
|
|
269
279
|
else if (uri === DRAFTS_URI) value = drafts.list();
|
|
270
280
|
else if (uri === `${PROJECT_URI}/scenarios`) value = getRegistry();
|
|
271
|
-
else if (uri === `${PROJECT_URI}/checks`) value =
|
|
281
|
+
else if (uri === `${PROJECT_URI}/checks`) value = await architecture(signal);
|
|
272
282
|
else if (uri === BEHAVIOR_URI || uri.startsWith(`${BEHAVIOR_URI}?`)) value = behaviorPage(options, resourceQuery(uri, ["unit", "api", "query", "section", "cursor", "limit"]));
|
|
273
283
|
else if (uri === INVESTIGATIONS_URI || uri.startsWith(`${INVESTIGATIONS_URI}?`)) value = investigationPage(root, resourceQuery(uri, ["unit", "check", "runId", "section", "cursor", "limit", "recordIndex", "offset", "chars"]));
|
|
274
284
|
else if (uri === RESULTS_URI || uri.startsWith("ads://results/")) return { contents: [executionResults.readResource(uri)] };
|
|
@@ -356,7 +366,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
356
366
|
return json({...value,isolatedShowcaseUrl:value.showcaseUrl,showcaseUrl:comparisonUrl??value.showcaseUrl,comparisonUrl});
|
|
357
367
|
} },
|
|
358
368
|
...(mutations ? [
|
|
359
|
-
{ name:"ads_create_draft", description:"Create a Git-committable proposal under ads-drafts/ for 1–
|
|
369
|
+
{ name:"ads_create_draft", description:"Create a Git-committable proposal under ads-drafts/ for 1–64 coupled ADS owners, copying only their source/companions into non-importable .ads files. New owners are allowed. Optional dependencies name separate unaccepted drafts used by pattern/composition previews. Creation does not change accepted source. Edit the returned files normally; use ads_update_draft to register additions/deletions.", schema:z.object({units:z.array(z.string().min(1).max(256)).min(1).max(mutationLimits.units),title:z.string().min(1).max(160).optional(),id:draftIdSchema.optional(),dependencies:z.array(draftIdSchema).max(8).default([]),tokenGroups:z.array(z.string().min(1).max(160)).max(32).default([])}).strict(),_meta:{ui:{visibility:["model"]}},annotations:{...annotations,readOnlyHint:false,idempotentHint:false},call:async args=>{const result=drafts.create(args);if(observeChanges)await refresh();return json(result);} },
|
|
360
370
|
{ name:"ads_update_draft", description:"Update marked draft source or register new/deleted canonical target paths. Pass the current revision from ads_drafts. Source is UTF-8 unless encoding:base64; content:null proposes deletion. Optional dependencies replaces the draft dependency list. Normal local file edits need no iteration tool. Accepted source remains unchanged; ownership and all required checks run at acceptance.",schema:z.object({id:draftIdSchema,revision:draftRevisionSchema,dependencies:z.array(draftIdSchema).max(8).optional(),changes:z.array(z.object({unit:z.string().max(256),path:z.string().min(1).max(500),content:z.string().max(256*1024).nullable(),encoding:z.enum(["utf8","base64"]).optional()}).strict()).max(32).default([])}).strict(),_meta:{ui:{visibility:["model"]}},annotations:{...annotations,readOnlyHint:false,idempotentHint:false},call:async args=>{const result=drafts.update(args);if(observeChanges)await refresh();return json(result);} },
|
|
361
371
|
{ name:"ads_drop_draft",description:"Delete an exact tracked draft and its generated preview. This is Drop, not a separate refusal workflow. Accepted source is unchanged. Dependents report a missing dependency until corrected.",schema:z.object({id:draftIdSchema,revision:draftRevisionSchema}).strict(),_meta:{ui:{visibility:["model"]}},annotations:{...annotations,readOnlyHint:false,destructiveHint:true,idempotentHint:false},call:async args=>{const result=await drafts.drop(args);if(observeChanges)await refresh();return json(result);} },
|
|
362
372
|
{ name:"ads_accept",title:"Accept a reviewed draft",description:"Auto-mode acceptance: validate and apply the exact rendered/reviewed draft revision in one operation. Accept dependency drafts first; dependent drafts automatically switch to their final @ds implementations. Mandatory architecture, registered Oxlint/project and affected behavior checks run once on the candidate. Draft/source changes invalidate acceptance. On failure retain the draft and inspect ads_results; on success apply normal source, remove the draft and publish an event. No additional human approval or manual Apply step.",schema:z.object({id:draftIdSchema,revision:draftRevisionSchema}).strict(),_meta:{ui:{visibility:["model"]}},annotations:{...annotations,readOnlyHint:false,destructiveHint:true,idempotentHint:false},call:async(args,signal,progress)=>{
|
|
@@ -408,8 +418,8 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
408
418
|
const matches = inventory.tokens.filter((token) => token.name.toLowerCase().includes(search.toLowerCase()));
|
|
409
419
|
return json({ total: matches.length, tokens: matches.slice(0, limit), categories: tokenScenarios(), tokenGroups:drafts.tokenGroups(), diagnosticCount: inventory.diagnostics.length, resourceUri: `${PROJECT_URI}/tokens` });
|
|
410
420
|
} },
|
|
411
|
-
{ name: "ads_check", description: "Run read-only core ADS architecture checks; returns blocking diagnostics separately from nonblocking advisories, with warnings before informational limits. Atomic warnings include helper/forwarded-class paths and ads://guides/atomic-styles guidance; unresolved paths do not establish safe composition. Project Oxlint, typecheck, build and browser tests remain separate.", schema: z.object({ limit: z.number().int().min(1).max(50).default(20) }).strict(), call: ({ limit }) => {
|
|
412
|
-
const result =
|
|
421
|
+
{ name: "ads_check", description: "Run read-only core ADS architecture checks; returns blocking diagnostics separately from nonblocking advisories, with warnings before informational limits. Atomic warnings include helper/forwarded-class paths and ads://guides/atomic-styles guidance; unresolved paths do not establish safe composition. Project Oxlint, typecheck, build and browser tests remain separate.", schema: z.object({ limit: z.number().int().min(1).max(50).default(20) }).strict(), call: async ({ limit }, signal) => {
|
|
422
|
+
const result = await architecture(signal);
|
|
413
423
|
return json({ ok: result.ok, acceptance:result.acceptance, total: result.diagnostics.length, diagnostics: result.diagnostics.slice(0, limit), advisoryCount: result.advisories?.length ?? 0, advisories: (result.advisories ?? []).slice(0, limit), resourceUri: `${PROJECT_URI}/checks` });
|
|
414
424
|
} },
|
|
415
425
|
{ name: "ads_skills", description: "Select one ADS workflow after ads_status: ads-designer for building/refining/debugging UI; ads-port for a library reference; ads-import for another project's ADS; ads-motion for animation; ads-break-ui for stress testing. Then read that workflow with ads_read_skill. Listing does not activate a native skill.", schema: empty, call: () => json({ skills: skills.skills.map(({ uri, frontmatter }) => ({ uri, ...frontmatter })) }) },
|
|
@@ -467,7 +477,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
467
477
|
schema: z.object({ unit: z.string().min(1).max(256), dryRun: z.boolean(), patch: z.string().min(1).max(mutationLimits.patchBytes).optional(), patchFile: z.string().min(1).max(500).optional(), ...screenshotFields }).strict().refine(args => (args.patch !== undefined) !== (args.patchFile !== undefined), "Provide exactly one of patch or patchFile."),
|
|
468
478
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false }, _meta: { ui: { visibility: ["model"] } },
|
|
469
479
|
call: applyEdits,
|
|
470
|
-
}, {name:"ads_apply_transaction",description:"Apply genuinely coupled ADS changes as 2–
|
|
480
|
+
}, {name:"ads_apply_transaction",description:"Apply genuinely coupled ADS changes as 2–64 distinct owner Git patches. Each patch must obey its unit and narrow companion rules. Patches run in order; later patches use the earlier candidate's shared-entry content. Core guards, registered Oxlint/project checks and affected behavior checks validate the complete final candidate before any live source is written. Maximum 256 distinct files/16 MiB combined. Dry runs, failures and cancellation publish nothing; publication rolls back on write failure. Optional screenshot:true with dryRun:true and explicit captures selects current/candidate images. Prefer ads_apply_patch for independent edits. Reply is a bounded summary; page diagnostics, outcomes and captures with ads_results using the returned resultId.",schema:z.object({patches:z.array(ownerPatch).min(2).max(mutationLimits.units),dryRun:z.boolean(),...screenshotFields}).strict(),annotations:{readOnlyHint:false,destructiveHint:true,idempotentHint:false,openWorldHint:false},_meta:{ui:{visibility:["model"]}},call:applyEdits}] : []),
|
|
471
481
|
...options.config.mcp.apps.map((app) => ({ name: `ads_show_${app.id.replaceAll("-", "_")}`, title: app.title, description: `${app.description ?? app.title}. Renders the project's built ${app.kind} examples through MCP Apps; text fallback provides the showcase URL.`, schema: empty, _meta: { ui: { resourceUri: appUri(app.id) } }, call: async (_args, signal) => {
|
|
472
482
|
// Validate readiness without embedding executable HTML in model results.
|
|
473
483
|
const build = await previewBuild(app, signal);
|
|
@@ -667,14 +677,15 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
667
677
|
await previewWatch.warm(files);
|
|
668
678
|
for (const file of files) await previewWatch.ensure(file, signal);
|
|
669
679
|
}
|
|
670
|
-
return { server, refresh, warmScenarios, readResource:read, async callTool(name,args,signal){const tool=tools().find(tool=>tool.name===name);if(!tool)throw new Error("Unknown preview tool.");return tool.call(tool.schema.parse(args),signal);}, async close() { stopObservation(); if (!inspection) { await drafts.close(); await validation.close(); await verification.close(); await captures.close(); } await server.close(); } };
|
|
680
|
+
return { server, refresh, warmScenarios, buildAll(signal, options) { previewWatch.setApps(allApps()); return previewWatch.buildAll(signal, options); }, readResource:read, async callTool(name,args,signal){const tool=tools().find(tool=>tool.name===name);if(!tool)throw new Error("Unknown preview tool.");return tool.call(tool.schema.parse(args),signal);}, async close() { stopObservation(); if (!inspection) { await drafts.close(); await validation.close(); await verification.close(); await captures.close(); } await server.close(); } };
|
|
671
681
|
}
|
|
672
682
|
|
|
673
|
-
export async function startAdsMcp(directory = process.cwd(), { stdio = true, showcase = true, port = 0, mutations = false } = {}) {
|
|
683
|
+
export async function startAdsMcp(directory = process.cwd(), { stdio = true, showcase = true, port = 0, mutations = false, previewWork = createPreviewWork() } = {}) {
|
|
674
684
|
// Fail before opening the transport for configuration/distribution errors.
|
|
675
685
|
const { root, config } = loadConfig(directory);
|
|
676
|
-
const inspection = { skills: createSkillStore() };
|
|
686
|
+
const inspection = { skills: createSkillStore(), previewWork };
|
|
677
687
|
const previewWatch = createReconfigurablePreviewWatch(root, config.mcp);
|
|
688
|
+
const unregisterPreview = previewWork.register(previewWatch);
|
|
678
689
|
let host, api;
|
|
679
690
|
let buildWatcher, buildChangeTimer;
|
|
680
691
|
const buildListeners = new Set();
|
|
@@ -705,6 +716,7 @@ export async function startAdsMcp(directory = process.cwd(), { stdio = true, sho
|
|
|
705
716
|
buildListeners.clear();
|
|
706
717
|
clearTimeout(buildChangeTimer); buildWatcher?.close();
|
|
707
718
|
inspection.edits?.cancel();
|
|
719
|
+
unregisterPreview();
|
|
708
720
|
// Stop every owned resource even if another close fails or has in-flight RPCs.
|
|
709
721
|
const results = await Promise.allSettled([
|
|
710
722
|
Promise.resolve().then(() => host?.close()),
|
|
@@ -720,6 +732,7 @@ export async function startAdsMcp(directory = process.cwd(), { stdio = true, sho
|
|
|
720
732
|
for (const signal of ["SIGINT", "SIGTERM"]) process.removeListener(signal, disconnect);
|
|
721
733
|
process.removeListener("exit", forceCleanup);
|
|
722
734
|
const errors = results.filter(result => result.status === "rejected").map(result => result.reason);
|
|
735
|
+
releaseScenarioRegistry(root);
|
|
723
736
|
if (errors.length) throw new AggregateError(errors, "ADS shutdown failed");
|
|
724
737
|
})();
|
|
725
738
|
}
|
|
@@ -737,7 +750,7 @@ export async function startAdsMcp(directory = process.cwd(), { stdio = true, sho
|
|
|
737
750
|
for (const signal of ["SIGINT", "SIGTERM"]) process.once(signal, disconnect);
|
|
738
751
|
process.once("exit", forceCleanup);
|
|
739
752
|
const previewApi=()=>api??=createAdsMcp(root,{era:"modern",inspection,previewWatch,showcaseUrl,mutations:false,pollInterval:0,observeChanges:false});
|
|
740
|
-
return { close, url: host?.url, warmScenarios: (ids, signal) => previewApi().warmScenarios(ids, signal), prewarm: () => previewWatch.initialize(), onBuildChange(listener) { buildListeners.add(listener); return () => buildListeners.delete(listener); }, buildStatus: () => previewWatch.buildStatus(), primeRegistry(registry) {
|
|
753
|
+
return { close, url: host?.url, async buildAll(signal, options) { await previewWatch.initialize(); return previewApi().buildAll(signal, options); }, warmScenarios: (ids, signal) => previewApi().warmScenarios(ids, signal), prewarm: () => previewWatch.initialize(), onBuildChange(listener) { buildListeners.add(listener); return () => buildListeners.delete(listener); }, buildStatus: () => previewWatch.buildStatus(), primeRegistry(registry) {
|
|
741
754
|
if (inspection.registry === registry || inspection.lastRegistry === registry) return;
|
|
742
755
|
inspection.registry = inspection.lastRegistry = registry; inspection.registryRevision = undefined; inspection.catalog = undefined;
|
|
743
756
|
}, callTool:(name,args,signal)=>previewApi().callTool(name,args,signal),readResource:(uri,signal)=>previewApi().readResource(uri,signal),previewRevision: () => readPreviewManifest(withPreviewSession(loadConfig(root), previewWatch.resourceSession()))?.revision ?? null };
|
package/dist/preview-builder.mjs
CHANGED
|
@@ -23,6 +23,7 @@ export function createVitePreviewBuilder({ build, configure }) {
|
|
|
23
23
|
}
|
|
24
24
|
const builder = async (entries, options, track, { watched = false } = {}) => {
|
|
25
25
|
if (!watched) {
|
|
26
|
+
await close();
|
|
26
27
|
const config = await configure(entries, options);
|
|
27
28
|
const output = await build({ ...config, plugins: [...config.plugins ?? [], track], build: { ...config.build, write: false, watch: null } });
|
|
28
29
|
return createPreviewResources(output, options, entries);
|
|
@@ -11,24 +11,30 @@ if (!isMainThread && workerData?.adsScenarioInspector) {
|
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export function createScenarioInspector(root) {
|
|
15
|
-
let worker, sequence = 0;
|
|
14
|
+
export function createScenarioInspector(root, { idleMs = 5000 } = {}) {
|
|
15
|
+
let worker, sequence = 0, idle;
|
|
16
16
|
const pending = new Map();
|
|
17
17
|
function fail(error) { for (const task of pending.values()) task.reject(error); pending.clear(); }
|
|
18
18
|
return {
|
|
19
19
|
inspect(directory = root) {
|
|
20
|
+
clearTimeout(idle);
|
|
20
21
|
if (!worker) {
|
|
21
22
|
worker = new Worker(new URL(import.meta.url), { workerData: { adsScenarioInspector: true, root } });
|
|
23
|
+
const current = worker;
|
|
22
24
|
worker.on("message", ({ id, result, error }) => {
|
|
23
25
|
const task = pending.get(id); pending.delete(id);
|
|
24
26
|
if (task) { if (error) task.reject(new Error(error)); else task.resolve(result); }
|
|
27
|
+
if (!pending.size && worker === current) {
|
|
28
|
+
idle = setTimeout(() => { if (worker === current && !pending.size) { worker = undefined; void current.terminate(); } }, idleMs);
|
|
29
|
+
idle.unref();
|
|
30
|
+
}
|
|
25
31
|
});
|
|
26
|
-
worker.on("error", fail);
|
|
27
|
-
worker.on("exit", () => { fail(new Error("Scenario inspector closed.")); worker = undefined; });
|
|
32
|
+
worker.on("error", error => { if (worker === current) fail(error); });
|
|
33
|
+
worker.on("exit", () => { if (worker === current) { fail(new Error("Scenario inspector closed.")); worker = undefined; } });
|
|
28
34
|
}
|
|
29
35
|
const id = ++sequence;
|
|
30
36
|
return new Promise((resolve, reject) => { pending.set(id, { resolve, reject }); worker.postMessage({ id, root: directory }); });
|
|
31
37
|
},
|
|
32
|
-
async close() { const previous = worker; worker = undefined; fail(new Error("Scenario inspector closed.")); await previous?.terminate(); },
|
|
38
|
+
async close() { clearTimeout(idle); const previous = worker; worker = undefined; fail(new Error("Scenario inspector closed.")); await previous?.terminate(); },
|
|
33
39
|
};
|
|
34
40
|
}
|
|
@@ -10,6 +10,10 @@ const hash = value => createHash("sha256").update(value).digest("hex");
|
|
|
10
10
|
const filename = "scenario-registry.json";
|
|
11
11
|
const maxBytes = 8 * 1024 * 1024;
|
|
12
12
|
const programs = new Map();
|
|
13
|
+
export function releaseScenarioRegistry(root) {
|
|
14
|
+
programs.get(root)?.clear();
|
|
15
|
+
programs.delete(root);
|
|
16
|
+
}
|
|
13
17
|
function programFor(root) {
|
|
14
18
|
const program = programs.get(root) ?? createScenarioProgram();
|
|
15
19
|
programs.delete(root); programs.set(root, program);
|
|
@@ -71,6 +75,18 @@ function write(options, revision, registry) {
|
|
|
71
75
|
finally { try { rmSync(temporary, { force: true }); } catch { /* Optional cache cleanup must not prevent discovery. */ } }
|
|
72
76
|
}
|
|
73
77
|
|
|
78
|
+
/** Relocate metadata only after identical accepted source is in place. This
|
|
79
|
+
* never supplies passing checks; validation continues to inspect source. */
|
|
80
|
+
export function prepareScenarioRegistryTransfer(candidate, target) {
|
|
81
|
+
const revision = previewSourceRevision(candidate), registry = read(candidate, revision);
|
|
82
|
+
if (!registry) return null;
|
|
83
|
+
return () => {
|
|
84
|
+
if (previewSourceRevision(target) !== revision || !validRegistry(registry, target)) return false;
|
|
85
|
+
write(target, revision, registry);
|
|
86
|
+
return true;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
74
90
|
/** Share semantic discovery between preview hosts and compiler processes.
|
|
75
91
|
* This snapshot contains metadata/diagnostics only, never validated outputs or
|
|
76
92
|
* passing check results. Validation continues to inspect source independently. */
|
|
@@ -3,16 +3,19 @@ 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 { discoverScenarioRegistry } from "./scenario-registry.mjs";
|
|
6
|
+
import { discoverScenarioRegistry, prepareScenarioRegistryTransfer, releaseScenarioRegistry } 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";
|
|
10
10
|
import { previewSourceRevision } from "./preview-inputs.mjs";
|
|
11
11
|
import { previewFileIgnored, previewWatchDirectories } from "./preview-files.mjs";
|
|
12
12
|
import { createScenarioInspector } from "./scenario-inspector.mjs";
|
|
13
|
+
import { configurationFiles } from "./units.mjs";
|
|
14
|
+
import { validationInputFiles } from "./validation-inputs.mjs";
|
|
13
15
|
|
|
14
16
|
const digest = value => createHash("sha256").update(value).digest("hex");
|
|
15
17
|
const fileDigest = file => { try { return digest(readFileSync(file)); } catch { return null; } };
|
|
18
|
+
const cacheVersion = 3, maxCacheBytes = 8 * 1024 * 1024;
|
|
16
19
|
|
|
17
20
|
/** Cache only successful validation + matching source/dependency/output content.
|
|
18
21
|
* Cache state is development output, never proof that a failed build is current. */
|
|
@@ -24,12 +27,12 @@ export function createPreviewCache(options, compilerFiles = []) {
|
|
|
24
27
|
const adapterDigest = () => digest(JSON.stringify(adapterFiles.map(file => [key(file), fileDigest(file)])));
|
|
25
28
|
const loadedAdapter = adapterDigest();
|
|
26
29
|
const target = path.join(root, ".ds/preview-cache.json");
|
|
27
|
-
let value = { schemaVersion:
|
|
30
|
+
let value = { schemaVersion: cacheVersion, validation: null, entries: {}, dependencySets: {} };
|
|
28
31
|
function reload() {
|
|
29
32
|
try {
|
|
30
|
-
if (realpathSync(target) === target && statSync(target).size <
|
|
33
|
+
if (realpathSync(target) === target && statSync(target).size < maxCacheBytes) {
|
|
31
34
|
const stored = JSON.parse(readFileSync(target, "utf8"));
|
|
32
|
-
if (stored.schemaVersion ===
|
|
35
|
+
if (stored.schemaVersion === cacheVersion && stored.entries && typeof stored.entries === "object" && stored.dependencySets && typeof stored.dependencySets === "object") value = stored;
|
|
33
36
|
}
|
|
34
37
|
} catch { /* Missing or corrupt cache means validate and rebuild. */ }
|
|
35
38
|
}
|
|
@@ -45,38 +48,72 @@ export function createPreviewCache(options, compilerFiles = []) {
|
|
|
45
48
|
return digest(JSON.stringify(rows.sort((a, b) => a[0].localeCompare(b[0]))));
|
|
46
49
|
}
|
|
47
50
|
function save() {
|
|
48
|
-
value.compilerFiles = compilerFiles.map(file => isInside(root,file) ? path.relative(root,file) : null);
|
|
49
51
|
mkdirSync(path.dirname(target), { recursive: true });
|
|
50
52
|
if (realpathSync(path.dirname(target)) !== path.dirname(target)) throw new Error("Preview cache cannot resolve through a symlink.");
|
|
53
|
+
value.compilerFiles = compilerFiles.map(file => isInside(root,file) ? path.relative(root,file) : null);
|
|
54
|
+
const used = new Set(Object.values(value.entries).map(entry => entry.dependencySet));
|
|
55
|
+
value.dependencySets = Object.fromEntries([...used].filter(id=>value.dependencySets[id]).map(id=>[id,value.dependencySets[id]]));
|
|
56
|
+
const content = JSON.stringify(value);
|
|
57
|
+
if (Buffer.byteLength(content) >= maxCacheBytes) {
|
|
58
|
+
rmSync(target, {force:true});
|
|
59
|
+
console.warn("ADS preview cache exceeds 8 MiB after deduplication; this build remains current, but a new compiler will rebuild it.");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
51
62
|
const temporary = `${target}.${randomUUID()}.tmp`;
|
|
52
|
-
try { writeFileSync(temporary,
|
|
63
|
+
try { writeFileSync(temporary, content); renameSync(temporary, target); }
|
|
53
64
|
finally { rmSync(temporary, { force: true }); }
|
|
54
65
|
}
|
|
66
|
+
function compilerInputs() {
|
|
67
|
+
const configured = new Set([...configurationFiles(options)].filter(file=>!/^(?:biome|oxlint|\.oxlint)/.test(file)));
|
|
68
|
+
const packages = new Set(["package-lock.json","npm-shrinkwrap.json","yarn.lock","pnpm-lock.yaml","bun.lock","bun.lockb","bunfig.toml",".npmrc",".yarnrc.yml","installed-dependencies"]);
|
|
69
|
+
const opaque = (options.config.validation?.inputs ?? []).map(file=>path.resolve(root,file));
|
|
70
|
+
// Use the same declared configuration/input boundary as guarded copies.
|
|
71
|
+
// Unrelated local launcher JSON must not make a candidate unportable.
|
|
72
|
+
return Object.entries(validationInputFiles(options)).filter(([file])=>configured.has(file)||packages.has(file)||opaque.some(directory=>isInside(directory,path.resolve(root,file))))
|
|
73
|
+
.sort(([a],[b])=>a.localeCompare(b));
|
|
74
|
+
}
|
|
55
75
|
const compilerDigest = () => digest(JSON.stringify([
|
|
56
76
|
["adapter", adapterDigest()],
|
|
57
77
|
...compilerFiles.map(file => [key(file), fileDigest(file)]),
|
|
58
|
-
...
|
|
78
|
+
...compilerInputs(),
|
|
59
79
|
["installed-packages", fileDigest(path.join(root, "node_modules/.package-lock.json"))],
|
|
60
80
|
["scheduler", fileDigest(import.meta.filename)],
|
|
61
81
|
["node-runtime", `${process.version}/${process.platform}/${process.arch}`],
|
|
62
82
|
]));
|
|
63
|
-
function reusable(entry, expectedHtml) {
|
|
83
|
+
function reusable(entry, expectedHtml, inspection) {
|
|
64
84
|
const cached = value.entries[entry.id];
|
|
65
|
-
if (!cached || cached.metadata !== JSON.stringify(entry) || cached.compiler !== compilerDigest()) return false;
|
|
66
|
-
|
|
67
|
-
if (Object.
|
|
85
|
+
if (!cached || cached.metadata !== JSON.stringify(entry) || cached.compiler !== (inspection?.compiler ?? compilerDigest())) return false;
|
|
86
|
+
const dependencies = value.dependencySets[cached.dependencySet];
|
|
87
|
+
if (!dependencies || !Object.keys(dependencies).length) return false;
|
|
88
|
+
let valid = inspection?.sets.get(cached.dependencySet);
|
|
89
|
+
if (valid === undefined) valid = !Object.entries(dependencies).some(([file, hash]) => {
|
|
90
|
+
const absolute = path.resolve(root, file);
|
|
91
|
+
if (!inspection) return fileDigest(absolute) !== hash;
|
|
92
|
+
if (!inspection.files.has(absolute)) inspection.files.set(absolute, fileDigest(absolute));
|
|
93
|
+
return inspection.files.get(absolute) !== hash;
|
|
94
|
+
});
|
|
95
|
+
inspection?.sets.set(cached.dependencySet, valid);
|
|
96
|
+
if (!valid) return false;
|
|
68
97
|
if (expectedHtml !== undefined) return cached.artifact === `sha256:${digest(expectedHtml)}`;
|
|
69
98
|
const file = path.join(root, previewArtifactPath(options, entry.artifact));
|
|
70
99
|
try { return cached.artifact === artifactDigest(file); } catch { return false; }
|
|
71
100
|
}
|
|
101
|
+
function reusableEntries(entries, revision) {
|
|
102
|
+
// Scope memoization to this one operation; the caller still fences source
|
|
103
|
+
// before publication. Never retain hashes across edits or requests.
|
|
104
|
+
const inspection = { compiler: compilerDigest(), files: new Map(), sets: new Map() };
|
|
105
|
+
return entries.every(entry => reusable(entry, previewArtifactHtml(entry.id, revision), inspection));
|
|
106
|
+
}
|
|
72
107
|
function recordEntries(entries, dependencies) {
|
|
73
108
|
const compiler = compilerDigest(), hashes = new Map();
|
|
74
109
|
for (const entry of entries) {
|
|
75
110
|
const files = [...new Set([path.join(root, entry.file), ...dependencies])]
|
|
76
111
|
.filter(file => isInside(root, file) && !file.includes(`${path.sep}node_modules${path.sep}`));
|
|
77
112
|
for (const file of files) if (!hashes.has(file)) hashes.set(file, fileDigest(file));
|
|
78
|
-
|
|
79
|
-
|
|
113
|
+
const dependencyHashes = Object.fromEntries(files.map(file => [path.relative(root,file),hashes.get(file)]).sort(([a],[b])=>a.localeCompare(b)));
|
|
114
|
+
const dependencySet = digest(JSON.stringify(dependencyHashes));
|
|
115
|
+
value.dependencySets[dependencySet] = dependencyHashes;
|
|
116
|
+
value.entries[entry.id] = { metadata: JSON.stringify(entry), compiler, dependencySet,
|
|
80
117
|
artifact: artifactDigest(path.join(root, previewArtifactPath(options, entry.artifact))) };
|
|
81
118
|
}
|
|
82
119
|
}
|
|
@@ -85,7 +122,7 @@ export function createPreviewCache(options, compilerFiles = []) {
|
|
|
85
122
|
// Never attach the previous output to bytes newer than its compiled stamp.
|
|
86
123
|
if (inputs() !== stamp) return false;
|
|
87
124
|
const previous = value;
|
|
88
|
-
value = { ...value, entries: { ...value.entries } };
|
|
125
|
+
value = { ...value, entries: { ...value.entries }, dependencySets: { ...value.dependencySets } };
|
|
89
126
|
try {
|
|
90
127
|
update();
|
|
91
128
|
if (inputs() !== stamp) { value = previous; return false; }
|
|
@@ -95,13 +132,15 @@ export function createPreviewCache(options, compilerFiles = []) {
|
|
|
95
132
|
}
|
|
96
133
|
function graph(revision, entries, stamp) { value.graphRevision=revision;value.graphInputs=stamp;value.registry=entries; }
|
|
97
134
|
function recordGraph(revision, entries, stamp = inputs()) { return recordCurrent(stamp, () => graph(revision, entries, stamp)); }
|
|
98
|
-
return { inputs, reusable, reload, snapshot: () => structuredClone(value), seed(state) { value=structuredClone(state);save(); }, graphRevision: () => value.graphRevision, recordGraph, validated: stamp => value.validation === stamp,
|
|
135
|
+
return { inputs, reusable, reusableEntries, reload, snapshot: () => structuredClone(value), seed(state) { value=structuredClone(state);save(); }, graphRevision: () => value.graphRevision, recordGraph, validated: stamp => value.validation === stamp,
|
|
136
|
+
production(stamp) { return value.production?.stamp === stamp && value.production.revision === value.graphRevision; },
|
|
137
|
+
recordProduction(stamp) { return recordCurrent(stamp, () => { value.production = { stamp, revision: value.graphRevision }; }); },
|
|
99
138
|
registry(stamp) {
|
|
100
139
|
if(value.validation!==stamp || value.graphInputs!==stamp || !Array.isArray(value.registry) || !value.registry.length || value.registry.length>1000)return null;
|
|
101
140
|
const valid=value.registry.every(entry=>typeof entry?.id==="string" && /^(?:tokens|components|patterns|composition)\/[\w./-]+$/.test(entry.id) && path.posix.normalize(entry.id)===entry.id
|
|
102
141
|
&& typeof entry.file==="string" && isInside(options.dsRoot,path.resolve(root,entry.file))
|
|
103
|
-
&& entry.artifact===`.ds/scenarios/${entry.id}/index.html`
|
|
104
|
-
return valid?structuredClone(value.registry):null;
|
|
142
|
+
&& entry.artifact===`.ds/scenarios/${entry.id}/index.html`);
|
|
143
|
+
return valid && reusableEntries(value.registry,value.graphRevision)?structuredClone(value.registry):null;
|
|
105
144
|
},
|
|
106
145
|
assertCompiler() {
|
|
107
146
|
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" });
|
|
@@ -119,9 +158,9 @@ export function createPreviewCache(options, compilerFiles = []) {
|
|
|
119
158
|
export function preparePreviewCache(candidate, target) {
|
|
120
159
|
if (!candidate.config.mcp.previewManifest || candidate.config.framework !== target.config.framework || !target.config.mcp.previewManifest) return false;
|
|
121
160
|
const file=path.join(candidate.root,".ds/preview-cache.json");
|
|
122
|
-
if (!existsSync(file) || realpathSync(file)!==file || statSync(file).size
|
|
161
|
+
if (!existsSync(file) || realpathSync(file)!==file || statSync(file).size>=maxCacheBytes) return false;
|
|
123
162
|
const state=JSON.parse(readFileSync(file,"utf8"));
|
|
124
|
-
if(state.schemaVersion!==
|
|
163
|
+
if(state.schemaVersion!==cacheVersion || !Array.isArray(state.compilerFiles) || state.compilerFiles.some(file=>typeof file!=="string"||!isInside(candidate.root,path.resolve(candidate.root,file))))return false;
|
|
125
164
|
const source=createPreviewCache(candidate,state.compilerFiles.map(file=>path.resolve(candidate.root,file)));
|
|
126
165
|
const destination=createPreviewCache(target,state.compilerFiles.map(file=>path.resolve(target.root,file)));
|
|
127
166
|
const stamp=source.inputs();
|
|
@@ -130,10 +169,12 @@ export function preparePreviewCache(candidate, target) {
|
|
|
130
169
|
const publication=cachedPreviewPublication(candidate,entries,state.graphRevision,target);
|
|
131
170
|
if(!publication || source.inputs()!==stamp)return false;
|
|
132
171
|
const snapshot=source.snapshot();
|
|
172
|
+
const transferRegistry=prepareScenarioRegistryTransfer(candidate,target);
|
|
133
173
|
return () => {
|
|
134
174
|
if(destination.inputs()!==stamp)return false;
|
|
135
175
|
publication.publish("accepted-mutation");
|
|
136
176
|
destination.seed(snapshot);
|
|
177
|
+
transferRegistry?.();
|
|
137
178
|
return {revision:publication.revision,scenarios:entries.map(entry=>entry.id)};
|
|
138
179
|
};
|
|
139
180
|
}
|
|
@@ -160,6 +201,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
160
201
|
if (!watched) throw error;
|
|
161
202
|
registryFailure = error; entries = error.scenarios ?? [];
|
|
162
203
|
}
|
|
204
|
+
finally { if (watched && buildGraph) releaseScenarioRegistry(root); }
|
|
163
205
|
const buildApps = () => entries.map(entry => ({ id: entry.id, file: previewArtifactPath(options, entry.artifact) }));
|
|
164
206
|
const reporter = createBuildReporter(root, { apps: buildApps() });
|
|
165
207
|
const requested = new Set();
|
|
@@ -173,6 +215,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
173
215
|
let validation;
|
|
174
216
|
let observedSourceRevision = previewSourceRevision(options);
|
|
175
217
|
let invalidation;
|
|
218
|
+
let fullRequest, completedFull;
|
|
176
219
|
const inspector = watched && buildGraph ? createScenarioInspector(root) : null;
|
|
177
220
|
let discovering, unknownRevision;
|
|
178
221
|
let liveCandidate, verifying = false;
|
|
@@ -269,12 +312,12 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
269
312
|
} };
|
|
270
313
|
cache.assertCompiler();
|
|
271
314
|
const cached = cachedPreviewPublication(options, entries, cache.graphRevision());
|
|
272
|
-
let reusable =
|
|
315
|
+
let reusable = cache.production(stamp) && cached && cache.reusableEntries(entries,cached.revision);
|
|
273
316
|
if (reusable) {
|
|
274
317
|
try { readPreviewManifest(options, { verify: true }); }
|
|
275
318
|
catch { reusable = false; }
|
|
276
319
|
}
|
|
277
|
-
const outcomes = await checkedBuild(stamp, () => reusable ? null : buildGraph(entries, options, track, { watched }));
|
|
320
|
+
const outcomes = await checkedBuild(stamp, () => reusable ? null : buildGraph(entries, options, track, { watched: false }));
|
|
278
321
|
const failure = outcomes.find(outcome => outcome.status === "rejected");
|
|
279
322
|
if (failure) throw failure.reason;
|
|
280
323
|
cache.assertCompiler();
|
|
@@ -289,13 +332,17 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
289
332
|
}
|
|
290
333
|
for (const entry of entries) { pending.delete(entry.id); reporter.ready(entry.id, revisions.get(entry.id)); }
|
|
291
334
|
publishedStamp = stamp;
|
|
335
|
+
publishedEntries = new Set(entries.map(entry => entry.id));
|
|
336
|
+
cache.recordProduction(stamp);
|
|
292
337
|
reporter.progress("idle");
|
|
338
|
+
return true;
|
|
293
339
|
} catch (error) {
|
|
294
340
|
if (started !== generation) return;
|
|
295
341
|
for (const entry of entries) { pending.delete(entry.id); reporter.error(entry.id, revisions.get(entry.id), error); }
|
|
296
342
|
reporter.progress("idle");
|
|
297
343
|
console.error(error);
|
|
298
344
|
if (!watched) process.exitCode = 1;
|
|
345
|
+
return false;
|
|
299
346
|
}
|
|
300
347
|
}
|
|
301
348
|
// Visual feedback and verified publication have separate lifecycles. Edits
|
|
@@ -339,7 +386,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
339
386
|
candidate.build = Promise.resolve().then(() => {
|
|
340
387
|
cache.assertCompiler();
|
|
341
388
|
const cached = cachedPreviewPublication(options, candidate.entries, cache.graphRevision());
|
|
342
|
-
if (cached &&
|
|
389
|
+
if (cached && cache.reusableEntries(candidate.entries,cached.revision)) { candidate.reused = true; return cached; }
|
|
343
390
|
return buildGraph(candidate.entries, options, track, { watched: true });
|
|
344
391
|
});
|
|
345
392
|
liveCandidate = candidate;
|
|
@@ -431,7 +478,26 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
431
478
|
if (compiling) return;
|
|
432
479
|
compiling = true;
|
|
433
480
|
try {
|
|
434
|
-
while (pending.size &&
|
|
481
|
+
while ((pending.size || fullRequest && fullRequest !== completedFull) && !stopped) {
|
|
482
|
+
if (fullRequest && fullRequest !== completedFull) {
|
|
483
|
+
const token = fullRequest, sourceRevision = previewSourceRevision(options);
|
|
484
|
+
// Production compilation and incremental compilation never overlap.
|
|
485
|
+
// The same process then serves this checked graph to verification.
|
|
486
|
+
if (verifying) { await new Promise(resolve => setTimeout(resolve, 20)); continue; }
|
|
487
|
+
let ok = false;
|
|
488
|
+
try {
|
|
489
|
+
entries = registry(); registryFailure = undefined;
|
|
490
|
+
reporter.setApps(buildApps()); reporter.clearFailure();
|
|
491
|
+
ok = await compileGraph();
|
|
492
|
+
} catch (error) {
|
|
493
|
+
registryFailure = error; failure(error);
|
|
494
|
+
} finally { releaseScenarioRegistry(root); }
|
|
495
|
+
completedFull = token;
|
|
496
|
+
const file = path.join(root, ".ds", `full-build-${reporter.session}.json`), temporary = `${file}.tmp`;
|
|
497
|
+
writeFileSync(temporary, JSON.stringify({ token, ok: !!ok, sourceRevision })); renameSync(temporary, file);
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
500
|
+
if (registryFailure) break;
|
|
435
501
|
const id = pending.has(active) ? active : pending.values().next().value;
|
|
436
502
|
pending.delete(id);
|
|
437
503
|
const entry = entries.find(entry => entry.id === id);
|
|
@@ -463,6 +529,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
|
|
|
463
529
|
try {
|
|
464
530
|
const value = JSON.parse(readFileSync(file, "utf8"));
|
|
465
531
|
if (value.session !== process.env.ADS_MCP_BUILD_SESSION) return;
|
|
532
|
+
if (typeof value.full === "string" && /^[\w-]{1,100}$/.test(value.full)) fullRequest = value.full;
|
|
466
533
|
if (value.invalidation !== invalidation) {
|
|
467
534
|
invalidation = value.invalidation;
|
|
468
535
|
if (requested.size) sourceChanged("invalidate",options.config.dsDir,true);
|
|
@@ -24,6 +24,12 @@ For example, `Button.tsx.ads` maps to the normal `Button.tsx` target. The final
|
|
|
24
24
|
`.ads` extension keeps proposed code out of default TypeScript/lint discovery,
|
|
25
25
|
without editing project tsconfig files. The manifest remains
|
|
26
26
|
`proposal.ads.draft.json`. These are ordinary tracked project files: commit them and review them in a PR.
|
|
27
|
+
|
|
28
|
+
A draft may group up to 64 owners and 256 tracked files. For related changes,
|
|
29
|
+
use one multi-owner draft: its previews share a compiler workspace and acceptance
|
|
30
|
+
validates the combined candidate once, then applies all changes together. The
|
|
31
|
+
existing source and patch byte budgets still apply.
|
|
32
|
+
|
|
27
33
|
Git is not required to create or recover a draft. Restarting ADS or cloning the
|
|
28
34
|
project discovers the same source. Generated compiler workspaces and execution
|
|
29
35
|
events remain under ignored `.ds/`; an interrupted check is never a pass.
|
|
@@ -104,8 +104,8 @@ of duplicating them across units. Do not create an asset group or bypass a guard
|
|
|
104
104
|
to add these documents. Code/configuration and hidden/generated paths remain
|
|
105
105
|
outside documentation ownership.
|
|
106
106
|
|
|
107
|
-
For genuinely coupled changes, `ads_apply_transaction` accepts 2–
|
|
108
|
-
patches (
|
|
107
|
+
For genuinely coupled changes, `ads_apply_transaction` accepts 2–64 distinct owner
|
|
108
|
+
patches (256 distinct files and 16 MiB combined). Each patch keeps its ownership and
|
|
109
109
|
companion restrictions. Patches apply in order; later shared-entry hunks match the
|
|
110
110
|
earlier candidate. All guards, registered checks and affected behavior checks run
|
|
111
111
|
on the final candidate before live source is written. Dry-run first. Rejection,
|
|
@@ -103,6 +103,15 @@ compiler. Existing custom adapters still work; they must adopt the helper to gai
|
|
|
103
103
|
incremental transforms. Upgrade the project dependency and restart the builder.
|
|
104
104
|
Keep the full validation callback and production build behavior.
|
|
105
105
|
|
|
106
|
+
Managed acceptance builds every scenario in production mode and shares the
|
|
107
|
+
candidate compiler/checked output with browser verification. Remove
|
|
108
|
+
`build:mcp-previews` from `mcp.mutationChecks` after upgrading ADS; keep that script
|
|
109
|
+
in normal builds. Explicit project commands still run as configured. During
|
|
110
|
+
acceptance ADS parks accepted/draft compilers but retains their publications;
|
|
111
|
+
an old view remains visible while verified preview requests wait. Do not launch
|
|
112
|
+
a second compiler to work around that wait. Semantic workers retire after five
|
|
113
|
+
idle seconds and rediscover from revision-fenced metadata when needed.
|
|
114
|
+
|
|
106
115
|
The shared watched builder reuses completed self-contained IIFE worker bundles
|
|
107
116
|
for constructor URLs and standard `?worker`/`?worker&url` imports. It uses Vite's
|
|
108
117
|
configured worker plugins, deduplicates pending requests, tracks real worker and
|
|
@@ -24,6 +24,12 @@ For example, `Button.tsx.ads` maps to the normal `Button.tsx` target. The final
|
|
|
24
24
|
`.ads` extension keeps proposed code out of default TypeScript/lint discovery,
|
|
25
25
|
without editing project tsconfig files. The manifest remains
|
|
26
26
|
`proposal.ads.draft.json`. These are ordinary tracked project files: commit them and review them in a PR.
|
|
27
|
+
|
|
28
|
+
A draft may group up to 64 owners and 256 tracked files. For related changes,
|
|
29
|
+
use one multi-owner draft: its previews share a compiler workspace and acceptance
|
|
30
|
+
validates the combined candidate once, then applies all changes together. The
|
|
31
|
+
existing source and patch byte budgets still apply.
|
|
32
|
+
|
|
27
33
|
Git is not required to create or recover a draft. Restarting ADS or cloning the
|
|
28
34
|
project discovers the same source. Generated compiler workspaces and execution
|
|
29
35
|
events remain under ignored `.ds/`; an interrupted check is never a pass.
|
|
@@ -104,8 +104,8 @@ of duplicating them across units. Do not create an asset group or bypass a guard
|
|
|
104
104
|
to add these documents. Code/configuration and hidden/generated paths remain
|
|
105
105
|
outside documentation ownership.
|
|
106
106
|
|
|
107
|
-
For genuinely coupled changes, `ads_apply_transaction` accepts 2–
|
|
108
|
-
patches (
|
|
107
|
+
For genuinely coupled changes, `ads_apply_transaction` accepts 2–64 distinct owner
|
|
108
|
+
patches (256 distinct files and 16 MiB combined). Each patch keeps its ownership and
|
|
109
109
|
companion restrictions. Patches apply in order; later shared-entry hunks match the
|
|
110
110
|
earlier candidate. All guards, registered checks and affected behavior checks run
|
|
111
111
|
on the final candidate before live source is written. Dry-run first. Rejection,
|
|
@@ -103,6 +103,15 @@ compiler. Existing custom adapters still work; they must adopt the helper to gai
|
|
|
103
103
|
incremental transforms. Upgrade the project dependency and restart the builder.
|
|
104
104
|
Keep the full validation callback and production build behavior.
|
|
105
105
|
|
|
106
|
+
Managed acceptance builds every scenario in production mode and shares the
|
|
107
|
+
candidate compiler/checked output with browser verification. Remove
|
|
108
|
+
`build:mcp-previews` from `mcp.mutationChecks` after upgrading ADS; keep that script
|
|
109
|
+
in normal builds. Explicit project commands still run as configured. During
|
|
110
|
+
acceptance ADS parks accepted/draft compilers but retains their publications;
|
|
111
|
+
an old view remains visible while verified preview requests wait. Do not launch
|
|
112
|
+
a second compiler to work around that wait. Semantic workers retire after five
|
|
113
|
+
idle seconds and rediscover from revision-fenced metadata when needed.
|
|
114
|
+
|
|
106
115
|
The shared watched builder reuses completed self-contained IIFE worker bundles
|
|
107
116
|
for constructor URLs and standard `?worker`/`?worker&url` imports. It uses Vite's
|
|
108
117
|
configured worker plugins, deduplicates pending requests, tracks real worker and
|
|
@@ -24,6 +24,12 @@ For example, `Button.tsx.ads` maps to the normal `Button.tsx` target. The final
|
|
|
24
24
|
`.ads` extension keeps proposed code out of default TypeScript/lint discovery,
|
|
25
25
|
without editing project tsconfig files. The manifest remains
|
|
26
26
|
`proposal.ads.draft.json`. These are ordinary tracked project files: commit them and review them in a PR.
|
|
27
|
+
|
|
28
|
+
A draft may group up to 64 owners and 256 tracked files. For related changes,
|
|
29
|
+
use one multi-owner draft: its previews share a compiler workspace and acceptance
|
|
30
|
+
validates the combined candidate once, then applies all changes together. The
|
|
31
|
+
existing source and patch byte budgets still apply.
|
|
32
|
+
|
|
27
33
|
Git is not required to create or recover a draft. Restarting ADS or cloning the
|
|
28
34
|
project discovers the same source. Generated compiler workspaces and execution
|
|
29
35
|
events remain under ignored `.ds/`; an interrupted check is never a pass.
|
|
@@ -104,8 +104,8 @@ of duplicating them across units. Do not create an asset group or bypass a guard
|
|
|
104
104
|
to add these documents. Code/configuration and hidden/generated paths remain
|
|
105
105
|
outside documentation ownership.
|
|
106
106
|
|
|
107
|
-
For genuinely coupled changes, `ads_apply_transaction` accepts 2–
|
|
108
|
-
patches (
|
|
107
|
+
For genuinely coupled changes, `ads_apply_transaction` accepts 2–64 distinct owner
|
|
108
|
+
patches (256 distinct files and 16 MiB combined). Each patch keeps its ownership and
|
|
109
109
|
companion restrictions. Patches apply in order; later shared-entry hunks match the
|
|
110
110
|
earlier candidate. All guards, registered checks and affected behavior checks run
|
|
111
111
|
on the final candidate before live source is written. Dry-run first. Rejection,
|