@reqvire-org/ads 0.3.36 → 0.3.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +10 -8
  2. package/dist/bootstrap-ds/README.md +8 -9
  3. package/dist/bootstrap-ds/ds.config.json +1 -8
  4. package/dist/bootstrap-ds/package.json +4 -3
  5. package/dist/bootstrap-ds/scripts/build-mcp-previews.mjs +2 -32
  6. package/dist/bun-compiler.mjs +13 -0
  7. package/dist/bun-worker.mjs +9 -0
  8. package/dist/check.mjs +7 -4
  9. package/dist/cli.mjs +11 -7
  10. package/dist/config.mjs +22 -4
  11. package/dist/development-runtime.mjs +3 -1
  12. package/dist/init.mjs +16 -18
  13. package/dist/mcp/build-status.mjs +6 -4
  14. package/dist/mcp/context.mjs +9 -4
  15. package/dist/mcp/drafts.mjs +4 -2
  16. package/dist/mcp/mutations.mjs +4 -14
  17. package/dist/mcp/preview-watch.mjs +21 -9
  18. package/dist/mcp/preview-widget.bundle.js +58 -63
  19. package/dist/mcp/preview-work.mjs +1 -15
  20. package/dist/mcp/project-widget.bundle.js +57 -62
  21. package/dist/mcp/prompts.mjs +2 -2
  22. package/dist/mcp/resource-loader.js +32 -10
  23. package/dist/mcp/server.mjs +89 -34
  24. package/dist/mcp/widget.bundle.js +59 -64
  25. package/dist/preview-builder.mjs +17 -5
  26. package/dist/preview-bun.mjs +266 -0
  27. package/dist/preview-imports.mjs +73 -0
  28. package/dist/preview-resources.mjs +26 -14
  29. package/dist/scenario-inspector.mjs +11 -4
  30. package/dist/scenarios-compiler.mjs +47 -6
  31. package/dist/showcase/client.bundle.js +68 -72
  32. package/dist/showcase/index.html +2 -2
  33. package/dist/showcase/sandbox.bundle.js +1 -1
  34. package/dist/showcase/style.css +4 -0
  35. package/dist/skills/ads-break-ui/SKILL.md +39 -40
  36. package/dist/skills/ads-break-ui/references/drafts.md +6 -3
  37. package/dist/skills/ads-break-ui/references/guarded-editing.md +4 -3
  38. package/dist/skills/ads-break-ui/references/runtimes.md +91 -140
  39. package/dist/skills/ads-break-ui/references/validation.md +13 -3
  40. package/dist/skills/ads-break-ui/references/workflows.md +82 -0
  41. package/dist/skills/ads-designer/SKILL.md +38 -39
  42. package/dist/skills/ads-designer/assets/bootstrap-ds/README.md +8 -9
  43. package/dist/skills/ads-designer/assets/bootstrap-ds/ds.config.json +1 -8
  44. package/dist/skills/ads-designer/assets/bootstrap-ds/package.json +4 -3
  45. package/dist/skills/ads-designer/assets/bootstrap-ds/scripts/build-mcp-previews.mjs +2 -32
  46. package/dist/skills/ads-designer/references/cli.md +24 -20
  47. package/dist/skills/ads-designer/references/drafts.md +6 -3
  48. package/dist/skills/ads-designer/references/guarded-editing.md +4 -3
  49. package/dist/skills/ads-designer/references/runtimes.md +91 -140
  50. package/dist/skills/ads-designer/references/validation.md +13 -3
  51. package/dist/skills/ads-designer/references/workflows.md +82 -0
  52. package/dist/skills/ads-import/SKILL.md +40 -42
  53. package/dist/skills/ads-import/references/cli.md +24 -20
  54. package/dist/skills/ads-import/references/drafts.md +6 -3
  55. package/dist/skills/ads-import/references/guarded-editing.md +4 -3
  56. package/dist/skills/ads-import/references/runtimes.md +91 -140
  57. package/dist/skills/ads-import/references/validation.md +13 -3
  58. package/dist/skills/ads-import/references/workflows.md +82 -0
  59. package/dist/skills/ads-motion/SKILL.md +37 -38
  60. package/dist/skills/ads-motion/references/drafts.md +6 -3
  61. package/dist/skills/ads-motion/references/guarded-editing.md +4 -3
  62. package/dist/skills/ads-motion/references/runtimes.md +91 -140
  63. package/dist/skills/ads-motion/references/validation.md +13 -3
  64. package/dist/skills/ads-motion/references/workflows.md +82 -0
  65. package/dist/skills/ads-port/SKILL.md +37 -38
  66. package/dist/skills/ads-port/references/cli.md +24 -20
  67. package/dist/skills/ads-port/references/drafts.md +6 -3
  68. package/dist/skills/ads-port/references/guarded-editing.md +4 -3
  69. package/dist/skills/ads-port/references/runtimes.md +91 -140
  70. package/dist/skills/ads-port/references/validation.md +13 -3
  71. package/dist/skills/ads-port/references/workflows.md +82 -0
  72. package/dist/usage.mjs +84 -0
  73. package/dist/validation.mjs +0 -12
  74. package/dist/verification/browser.mjs +77 -48
  75. package/docs/ADS.md +17 -11
  76. package/docs/ARCHITECTURE.md +43 -29
  77. package/docs/BEHAVIORS.md +3 -3
  78. package/docs/CHANGELOG.md +60 -12
  79. package/docs/GUIDE.md +96 -53
  80. package/docs/MCP.md +96 -122
  81. package/docs/benchmarks/bun-previews.md +91 -0
  82. package/docs/benchmarks/gidi-preview-memory.md +4 -0
  83. package/package.json +15 -13
@@ -207,6 +207,20 @@ export async function runScenarioCompiler(directory, { watched = false, validate
207
207
  const requested = new Set();
208
208
  const pending = new Set();
209
209
  let active;
210
+ const prewarm = watched && process.env.ADS_MCP_PREWARM_VIEWS === "1";
211
+ const warmed = new Set(), warmFailures = new Set();
212
+ let preferred, warming;
213
+ if(prewarm)try{preferred=JSON.parse(readFileSync(path.join(root,".ds/last-preview.json"),"utf8")).scenario;}catch{/* First startup warms the first view. */}
214
+ function warmProgress() {
215
+ if(!prewarm)return;
216
+ const completed=entries.filter(entry=>warmed.has(entry.id)).length,failed=entries.filter(entry=>warmFailures.has(entry.id)).length;
217
+ reporter.warmup({state:completed===entries.length?"ready":completed+failed===entries.length?"error":"warming",completed,total:entries.length,failed,...(warming?{active:warming}:{})});
218
+ }
219
+ function nextWarm() {
220
+ if(!prewarm||registryFailure)return;
221
+ return entries.find(entry=>entry.id===preferred&&!requested.has(entry.id)&&!warmed.has(entry.id))??entries.find(entry=>!requested.has(entry.id)&&!warmed.has(entry.id));
222
+ }
223
+ warmProgress();
210
224
  let compiling = false;
211
225
  let stopped = false;
212
226
  let generation = 0;
@@ -317,7 +331,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
317
331
  try { readPreviewManifest(options, { verify: true }); }
318
332
  catch { reusable = false; }
319
333
  }
320
- const outcomes = await checkedBuild(stamp, () => reusable ? null : buildGraph(entries, options, track, { watched: false }));
334
+ const outcomes = await checkedBuild(stamp, () => reusable ? null : buildGraph(entries, options, track, { watched: false, sourceRevision }));
321
335
  const failure = outcomes.find(outcome => outcome.status === "rejected");
322
336
  if (failure) throw failure.reason;
323
337
  cache.assertCompiler();
@@ -334,6 +348,8 @@ export async function runScenarioCompiler(directory, { watched = false, validate
334
348
  publishedStamp = stamp;
335
349
  publishedEntries = new Set(entries.map(entry => entry.id));
336
350
  cache.recordProduction(stamp);
351
+ for(const entry of entries){warmed.add(entry.id);warmFailures.delete(entry.id);}
352
+ warmProgress();
337
353
  reporter.progress("idle");
338
354
  return true;
339
355
  } catch (error) {
@@ -360,7 +376,10 @@ export async function runScenarioCompiler(directory, { watched = false, validate
360
376
  reporter.setApps(buildApps());
361
377
  }
362
378
  const registryReused = !!prepared && JSON.stringify(prepared) === JSON.stringify(entries);
363
- const selected = registryReused ? prepared : entries.filter(entry => requested.has(entry.id));
379
+ // Publication/cache identities follow discovery order, never navigation
380
+ // order. Otherwise warming a non-first view produces a full graph that
381
+ // cannot match the next process's canonical registry and rebuilds forever.
382
+ const selected = registryReused ? prepared : entries.filter(entry=>requested.has(entry.id));
364
383
  const candidate = { generation, stamp, sourceRevision, registry: [...entries], entries: selected, dependencies: new Set(), registryReused };
365
384
  // Retain roots requested by other mounted Apps, without compiling untouched
366
385
  // catalogue entries. Production/unwatched builds still cover all entries.
@@ -387,7 +406,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
387
406
  cache.assertCompiler();
388
407
  const cached = cachedPreviewPublication(options, candidate.entries, cache.graphRevision());
389
408
  if (cached && cache.reusableEntries(candidate.entries,cached.revision)) { candidate.reused = true; return cached; }
390
- return buildGraph(candidate.entries, options, track, { watched: true });
409
+ return buildGraph(candidate.entries, options, track, { watched: true, sourceRevision });
391
410
  });
392
411
  liveCandidate = candidate;
393
412
  try {
@@ -396,6 +415,8 @@ export async function runScenarioCompiler(directory, { watched = false, validate
396
415
  if (publication.publishLive) {
397
416
  publication.publishLive(reporter.session);
398
417
  reporter.live({ revision: publication.revision, sourceRevision });
418
+ for(const entry of candidate.entries){warmed.add(entry.id);warmFailures.delete(entry.id);}
419
+ warmProgress();
399
420
  }
400
421
  reporter.progress("validation");
401
422
  } catch (error) {
@@ -406,6 +427,8 @@ export async function runScenarioCompiler(directory, { watched = false, validate
406
427
  }
407
428
  function rejectLive(candidate, error) {
408
429
  candidate.failed = true;
430
+ for(const entry of candidate.entries){warmed.delete(entry.id);warmFailures.add(entry.id);}
431
+ warmProgress();
409
432
  reporter.batch(() => {
410
433
  reporter.live(undefined);
411
434
  for (const entry of candidate.entries) reporter.error(entry.id, candidate.revisions.get(entry.id), error);
@@ -478,7 +501,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
478
501
  if (compiling) return;
479
502
  compiling = true;
480
503
  try {
481
- while ((pending.size || fullRequest && fullRequest !== completedFull) && !stopped) {
504
+ while ((pending.size || fullRequest && fullRequest !== completedFull || nextWarm()) && !stopped) {
482
505
  if (fullRequest && fullRequest !== completedFull) {
483
506
  const token = fullRequest, sourceRevision = previewSourceRevision(options);
484
507
  // Production compilation and incremental compilation never overlap.
@@ -498,10 +521,26 @@ export async function runScenarioCompiler(directory, { watched = false, validate
498
521
  continue;
499
522
  }
500
523
  if (registryFailure) break;
524
+ if(!pending.size){
525
+ // Let incoming foreground selections enter the queue before the next
526
+ // background job in the shared compiler.
527
+ await new Promise(resolve=>setTimeout(resolve,50));
528
+ if(stopped)break;
529
+ if(!pending.size){
530
+ const entry=nextWarm();
531
+ if(entry){
532
+ // Bun can finish the remaining graph in one bounded build after
533
+ // the first view. Rebuilding 1, 2, ... N roots repeats bundling N
534
+ // times despite the persistent per-file transform cache.
535
+ const warm=buildGraph?.warmBatch&&warmed.size?entries.filter(item=>!requested.has(item.id)&&!warmed.has(item.id)):[entry];
536
+ for(const item of warm){requested.add(item.id);pending.add(item.id);}
537
+ }
538
+ }
539
+ }
501
540
  const id = pending.has(active) ? active : pending.values().next().value;
502
541
  pending.delete(id);
503
542
  const entry = entries.find(entry => entry.id === id);
504
- if (entry) await compile(entry);
543
+ if (entry) {warming=id;warmProgress();try{await compile(entry);}finally{warming=undefined;warmProgress();}}
505
544
  }
506
545
  } catch (error) { failure(error); }
507
546
  finally { compiling = false; }
@@ -565,6 +604,7 @@ export async function runScenarioCompiler(directory, { watched = false, validate
565
604
  ++generation;
566
605
  reporter.progress("queued");
567
606
  validation = undefined;
607
+ warmed.clear();warmFailures.clear();warmProgress();
568
608
  const changes = [...changed]; changed.clear();
569
609
  try {
570
610
  // Registry inspection for live graphs runs in the verification worker.
@@ -639,7 +679,8 @@ export async function runScenarioCompiler(directory, { watched = false, validate
639
679
  } catch (error) { failure(error); }
640
680
  }, 1000);
641
681
  request();
642
- console.log(`Scenario compiler ready: ${entries.length} entries; builds are requested on demand.`);
682
+ if(prewarm)void drain();
683
+ console.log(`Scenario compiler ready: ${entries.length} entries; ${prewarm?"sequential background warming enabled":"builds are requested on demand"}.`);
643
684
  for (const signal of ["SIGINT", "SIGTERM"]) process.once(signal, () => {
644
685
  stopped = true; clearTimeout(timer); clearInterval(reconcileTimer); for (const { watcher } of watchers.values()) watcher.close();
645
686
  void inspector?.close();