@intentius/behold 0.30.1 → 0.30.2

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 (56) hide show
  1. package/AGENTS.md +31 -1
  2. package/README.md +11 -6
  3. package/dist/cli.js +1516 -840
  4. package/example-choudoufu-estate/chant.workspace.json +1 -1
  5. package/example-terraform-estate/README.md +1 -1
  6. package/example-terraform-estate/chant.workspace.json +1 -1
  7. package/example-terralith/README.md +1 -1
  8. package/example-three-cloud/package-lock.json +19 -19
  9. package/example-three-cloud/package.json +4 -4
  10. package/package.json +5 -5
  11. package/web/app.js +263 -16
  12. package/web/embed.js +2 -2
  13. package/web/event-help-modal.js +18 -12
  14. package/web/event-help-modal.test.js +28 -1
  15. package/web/index.html +18 -0
  16. package/web/kiosk-ask-layout.js +85 -0
  17. package/web/kiosk-ask-layout.test.js +83 -0
  18. package/web/kiosk-ask-tips.js +467 -0
  19. package/web/kiosk-ask-tips.test.js +359 -0
  20. package/web/kiosk-ask.js +774 -0
  21. package/web/kiosk-ask.test.js +593 -0
  22. package/web/kiosk-banner.js +108 -0
  23. package/web/kiosk-banner.test.js +72 -0
  24. package/web/kiosk-center-cards.test.js +110 -0
  25. package/web/kiosk-estate-scene.js +203 -0
  26. package/web/kiosk-estate-scene.test.js +21 -0
  27. package/web/kiosk-event-help.js +4 -1
  28. package/web/kiosk-graph-pane.js +63 -0
  29. package/web/kiosk-graph-pane.test.js +105 -0
  30. package/web/kiosk-light-frame.js +196 -0
  31. package/web/kiosk-light.js +509 -0
  32. package/web/kiosk-light.test.js +297 -0
  33. package/web/kiosk-metrics.js +7 -4
  34. package/web/kiosk-modal-sticky.test.js +2 -1
  35. package/web/kiosk-refit.test.js +81 -0
  36. package/web/kiosk-reset.js +49 -0
  37. package/web/kiosk-reset.test.js +11 -0
  38. package/web/kiosk-shot.js +40 -2
  39. package/web/kiosk-shot.test.js +23 -1
  40. package/web/kiosk-vendor.js +85 -7
  41. package/web/kiosk-vendor.test.js +9 -9
  42. package/web/kiosk-watch.js +8 -4
  43. package/web/kiosk.html +107 -1
  44. package/web/kiosk.js +149 -23
  45. package/web/kiosk.test.js +25 -1
  46. package/web/small-stage.test.js +4 -0
  47. package/web/terragucci-change.js +30 -13
  48. package/web/tool-mark.js +4 -4
  49. package/web/tool-mark.test.js +1 -1
  50. package/web/vendors/atmos.svg +1 -0
  51. package/web/vendors/chant.svg +1 -0
  52. package/web/vendors/choudoufu.svg +1 -0
  53. package/web/vendors/terragrunt.svg +9 -0
  54. package/web/vendors/terragucci.svg +1 -0
  55. package/web/vendors/choudoufu-128.png +0 -0
  56. package/web/vendors/choudoufu-64.png +0 -0
@@ -4,7 +4,7 @@
4
4
  "pins": [
5
5
  {
6
6
  "package": "@intentius/chant-lexicon-terraform",
7
- "version": "0.124.51"
7
+ "version": "0.124.52"
8
8
  }
9
9
  ],
10
10
  "members": [
@@ -93,7 +93,7 @@ naming both packages, the ranges behold declares, where it looked, and the line
93
93
  that puts them back:
94
94
 
95
95
  ```sh
96
- npm install @intentius/chant-lexicon-terraform@^0.124.51 @cdktn/hcl2json@^0.24.0
96
+ npm install @intentius/chant-lexicon-terraform@^0.124.52 @cdktn/hcl2json@^0.24.0
97
97
  ```
98
98
 
99
99
  The estate is a declared chant workspace, and chant reads a member's kind from
@@ -4,7 +4,7 @@
4
4
  "pins": [
5
5
  {
6
6
  "package": "@intentius/chant-lexicon-terraform",
7
- "version": "0.124.51"
7
+ "version": "0.124.52"
8
8
  }
9
9
  ],
10
10
  "members": [
@@ -2,7 +2,7 @@
2
2
 
3
3
  One Terraform root that holds everything, taken to four choudoufu estates in
4
4
  two reviewed steps. [choudoufu](https://github.com/INTENTIUS/choudoufu) is the
5
- OpenTofu fork for AWS and Kubernetes whose ownership lives on each resource as
5
+ OpenTofu fork for AWS, GCP, Azure and Kubernetes whose ownership lives on each resource as
6
6
  two tags, `tofu-estate` and `tofu-address`.
7
7
 
8
8
  ```sh
@@ -6,10 +6,10 @@
6
6
  "": {
7
7
  "name": "behold-example-three-cloud",
8
8
  "dependencies": {
9
- "@intentius/chant": "^0.124.51",
10
- "@intentius/chant-lexicon-aws": "^0.124.51",
11
- "@intentius/chant-lexicon-azure": "^0.124.51",
12
- "@intentius/chant-lexicon-gcp": "^0.124.51"
9
+ "@intentius/chant": "^0.124.52",
10
+ "@intentius/chant-lexicon-aws": "^0.124.52",
11
+ "@intentius/chant-lexicon-azure": "^0.124.52",
12
+ "@intentius/chant-lexicon-gcp": "^0.124.52"
13
13
  }
14
14
  },
15
15
  "node_modules/@dagrejs/dagre": {
@@ -444,9 +444,9 @@
444
444
  }
445
445
  },
446
446
  "node_modules/@intentius/chant": {
447
- "version": "0.124.51",
448
- "resolved": "https://registry.npmjs.org/@intentius/chant/-/chant-0.124.51.tgz",
449
- "integrity": "sha512-68nNpD7jvpqIjsJSTbIeudeyN0SoYr0+pVrXp2Wc2wVtYWdtmam3O7ANDBBDYWRnWT9I0vuo/L/urZB/EBtERg==",
447
+ "version": "0.124.52",
448
+ "resolved": "https://registry.npmjs.org/@intentius/chant/-/chant-0.124.52.tgz",
449
+ "integrity": "sha512-+njDb55CwzB0LxvNmUU3LA8iuE0qljahDl48/N73PIYOqcP9z+ec/kMVXgBOjNE85VOdiy2//oB6liMipANsTA==",
450
450
  "license": "Apache-2.0",
451
451
  "dependencies": {
452
452
  "@dagrejs/dagre": "^3.0.0",
@@ -473,34 +473,34 @@
473
473
  }
474
474
  },
475
475
  "node_modules/@intentius/chant-lexicon-aws": {
476
- "version": "0.124.51",
477
- "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-aws/-/chant-lexicon-aws-0.124.51.tgz",
478
- "integrity": "sha512-IgiZ7RTTlaVSNocHwhd1JwRc/VYrL6Eylmz9Y0ueedRpnRd/WgQRdpSyII2qE5Qh2NKUUigLJvSc9J0rC9ONeA==",
476
+ "version": "0.124.52",
477
+ "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-aws/-/chant-lexicon-aws-0.124.52.tgz",
478
+ "integrity": "sha512-i8UOQwlTUBukICNeLtG1RZCjsp/BoKxEVszdEvffw8nlA3pzD3snqfNzrtjoxs03MSfuVSyRlhdJ+TORBMjCjg==",
479
479
  "license": "Apache-2.0",
480
480
  "dependencies": {
481
481
  "fflate": "^0.8.2",
482
482
  "js-yaml": "^4.3.1"
483
483
  },
484
484
  "peerDependencies": {
485
- "@intentius/chant": "^0.124.51"
485
+ "@intentius/chant": "^0.124.52"
486
486
  }
487
487
  },
488
488
  "node_modules/@intentius/chant-lexicon-azure": {
489
- "version": "0.124.51",
490
- "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-azure/-/chant-lexicon-azure-0.124.51.tgz",
491
- "integrity": "sha512-+oaLuw08hm0mQw7DdcezUrStY8YgzOTwCF/5n3aoJEJt2n2p70iY9xLa/4UEk4u+mG7pb4B8QPoSHzSn3fi+lA==",
489
+ "version": "0.124.52",
490
+ "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-azure/-/chant-lexicon-azure-0.124.52.tgz",
491
+ "integrity": "sha512-ZyEXZQWjx90BZJuO9WAZTKAgbwQ30pjyQxWmlP9uOdhIfKm609+8PJwJSYLK6XrfeAG9HHHSkZUKHToa2AQG9g==",
492
492
  "license": "Apache-2.0",
493
493
  "dependencies": {
494
494
  "fflate": "^0.8.2"
495
495
  },
496
496
  "peerDependencies": {
497
- "@intentius/chant": "^0.124.51"
497
+ "@intentius/chant": "^0.124.52"
498
498
  }
499
499
  },
500
500
  "node_modules/@intentius/chant-lexicon-gcp": {
501
- "version": "0.124.51",
502
- "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-gcp/-/chant-lexicon-gcp-0.124.51.tgz",
503
- "integrity": "sha512-AthygbSUsL0ZlYQk13UA1tu1SHJ0AoZGZrFdt5NSj8SVWjQx2waszDz2wjxdvgc/Cfw47dJF92Yv3NHGV/JO4Q==",
501
+ "version": "0.124.52",
502
+ "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-gcp/-/chant-lexicon-gcp-0.124.52.tgz",
503
+ "integrity": "sha512-Sr+Kd8yBSC8kp0SRtVlnlH5gvthu6SRHw4tGb2wQnkrWqWSqITMMOb/+fk1WMNxz86xOPJVMDUrnmcLjhO0VxA==",
504
504
  "license": "Apache-2.0",
505
505
  "dependencies": {
506
506
  "@types/js-yaml": "^4.0.9",
@@ -508,7 +508,7 @@
508
508
  "js-yaml": "^4.3.1"
509
509
  },
510
510
  "peerDependencies": {
511
- "@intentius/chant": "^0.124.51"
511
+ "@intentius/chant": "^0.124.52"
512
512
  }
513
513
  },
514
514
  "node_modules/@types/js-yaml": {
@@ -8,9 +8,9 @@
8
8
  "front-door": "tsx scripts/front-door.ts all --out export"
9
9
  },
10
10
  "dependencies": {
11
- "@intentius/chant": "^0.124.51",
12
- "@intentius/chant-lexicon-aws": "^0.124.51",
13
- "@intentius/chant-lexicon-azure": "^0.124.51",
14
- "@intentius/chant-lexicon-gcp": "^0.124.51"
11
+ "@intentius/chant": "^0.124.52",
12
+ "@intentius/chant-lexicon-aws": "^0.124.52",
13
+ "@intentius/chant-lexicon-azure": "^0.124.52",
14
+ "@intentius/chant-lexicon-gcp": "^0.124.52"
15
15
  }
16
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/behold",
3
- "version": "0.30.1",
3
+ "version": "0.30.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
@@ -48,9 +48,9 @@
48
48
  "dependencies": {
49
49
  "@cdktn/hcl2json": "^0.24.0",
50
50
  "@hono/node-server": "^2.0.5",
51
- "@intentius/chant": "^0.124.51",
52
- "@intentius/chant-k8s-client": "^0.124.51",
53
- "@intentius/chant-lexicon-terraform": "^0.124.51",
51
+ "@intentius/chant": "^0.124.52",
52
+ "@intentius/chant-k8s-client": "^0.124.52",
53
+ "@intentius/chant-lexicon-terraform": "^0.124.52",
54
54
  "@intentius/pinhole": "^0.5.0",
55
55
  "@modelcontextprotocol/sdk": "1.30.1",
56
56
  "ajv": "^8.20.0",
@@ -65,7 +65,7 @@
65
65
  }
66
66
  },
67
67
  "devDependencies": {
68
- "@intentius/chant-lexicon-sql": "^0.124.51",
68
+ "@intentius/chant-lexicon-sql": "^0.124.52",
69
69
  "@types/node": "^26.4.1",
70
70
  "esbuild": "^0.28.0",
71
71
  "playwright": "^1.62.1",
package/web/app.js CHANGED
@@ -40,6 +40,11 @@ import { FORGES, MARK, componentsForge, forgeOfName, iconSvg, markLink, markTitl
40
40
  import { TOOLS, orderTools } from "./tool-mark.js";
41
41
  import { STATE_WORDS as tgStateWords, changeSection as tgChangeSection, readCardIds as tgReadCardIds, readEdges as tgReadEdges, readLabel as tgReadLabel, readLine as tgReadLine, readTag as tgReadTag, rootStates as tgRootStates, viewCaption as tgViewCaption, pinnedAnswer as tgPinnedAnswer, pinnedCaption as tgPinnedCaption, pinsCommit as tgPinsCommit, pinWaits as tgPinWaits } from "./terragucci-change.js";
42
42
  import { auditLines as yrAuditLines, cornerText as yrCorner, datedWords as yrDated, environmentLines as yrEnvLines, joinMarks as yrJoin, legend as yrLegend, markLine as yrMarkLine } from "./yodel-report.js";
43
+ import { drawLight as klDraw } from "./kiosk-light-frame.js"; // behold#937
44
+ import { badgeWords as klBadge, planOf as klPlanOf } from "./kiosk-light.js"; // behold#940
45
+ import { composedRun } from "./kiosk-light.js";
46
+ import { graphMayShow, keepsSceneInAsk, mayTellDrawn, refusalHoldsScene } from "./kiosk-graph-pane.js";
47
+ import { askDeltas, clearScene, drawScene, sceneModel, slotCounts as klSlotCounts } from "./kiosk-estate-scene.js"; // behold#940
43
48
  import { cardProgress as tgCardProgress, progressLines as tgProgressLines, progressSection as tgProgressSection, stampProgress as tgStampProgress } from "./terragucci-progress.js";
44
49
  import { seconds, whyQuery, whyView } from "./why.js";
45
50
  import { edgeKey, edgeLabel, edgeLegend, edgeTitle, isCiKind, viaIndex } from "./edge-kind.js";
@@ -129,7 +134,7 @@ import { danglingFor, danglingRows, danglingHeading, DANGLING_EXPLAINED } from "
129
134
  import { comparisonRow, comparisonSummary } from "./cross-env.js";
130
135
  // The marker-vs-derived mark on a choudoufu card: how its identity was found.
131
136
  import { identityMark, tagGlyphSvg } from "./identity-mark.js";
132
- import { shotFromMessage, shotViewBox, tweenViewBox, unionBox, sameViewBox, heldFrame, heldInsets, heldTarget, holdsStage, medianWidth, smallStage } from "./kiosk-shot.js"; // behold#571: Watch's camera
137
+ import { ASK_MAX_SCALE, afterFrames, debounced, shotFromMessage, shotViewBox, tweenViewBox, unionBox, sameViewBox, heldFrame, heldInsets, heldTarget, holdsStage, medianWidth, smallStage } from "./kiosk-shot.js"; // behold#571: Watch's camera
133
138
  import { SHOT_ATTR, SHOT_CAPTION_PX, SHOT_DIM, queryFrame, readShotFrame, shotCaption, shotLit, shotProvenance, shotState } from "./shot-frame.js"; // behold#915: the page `behold shot` photographs
134
139
  import { countsLine, groupLabel, groupMarks, queryLine, queryMarks, searchKey, searchUrl, stackIndex, uncapturedLine } from "./search-view.js"; // behold#913: `q` drawn; behold#922: groups
135
140
  // #712, #715: the dots layer, the zoom past the cards. Mounted for a live
@@ -2181,6 +2186,10 @@ function ensureViewToggles(host) {
2181
2186
  host.appendChild(bar);
2182
2187
  }
2183
2188
  bar.innerHTML = "";
2189
+ if (document.documentElement.classList.contains("kiosk-ask")) {
2190
+ bar.style.display = "none"; // behold#940: ask mode shows the graph and the prompt alone
2191
+ return;
2192
+ }
2184
2193
  if (isEstate()) {
2185
2194
  const b = button("▦ stack alike", "vt" + (view.alike && alikeZoom() ? " active" : ""), toggleAlike);
2186
2195
  b.title = ALIKE_TITLE;
@@ -4532,6 +4541,8 @@ async function loadTerragucci({ fresh = false } = {}) {
4532
4541
  .then((r) => r.json())
4533
4542
  .catch((e) => ({ error: String(e), code: "terragucci-report", remedy: "" }));
4534
4543
  tgAnswer = answer;
4544
+ sceneInPlaceOfRefusal();
4545
+ klGate();
4535
4546
  // #506: the timeline, whole; the inspect pane filters it by a card's root.
4536
4547
  tgTimeline = await apiFetch(`/api/terragucci/timeline${fresh ? "?fresh=1" : ""}`)
4537
4548
  .then((r) => r.json())
@@ -4559,6 +4570,7 @@ async function refreshTgAnswer() {
4559
4570
  .then((r) => r.json())
4560
4571
  .catch((e) => ({ error: String(e), code: "terragucci-report", remedy: "" }));
4561
4572
  if (!answer.error || !tgAnswer) tgAnswer = answer;
4573
+ sceneInPlaceOfRefusal();
4562
4574
  renderTerragucciPanel();
4563
4575
  markTerragucciCards();
4564
4576
  drawTgReads();
@@ -4608,11 +4620,135 @@ function tgPushFits(answer) {
4608
4620
  function tgAnswerDrawn() {
4609
4621
  return tgPinnedAnswer(tgAnswer, view.run, view.pull || null);
4610
4622
  }
4623
+ // A prompt-driven step holds the graph from the moment its prompt starts until its reply is done or its status shows
4624
+ // (the kiosk posts behold:hold, then a behold:light): progress that lands in between is queued, the latest one drawn then.
4625
+ let klHold = null;
4626
+ let klHeldPaint = false;
4627
+ function klReleaseHold() {
4628
+ if (klHold) clearTimeout(klHold);
4629
+ klHold = null;
4630
+ if (klHeldPaint) {
4631
+ klHeldPaint = false;
4632
+ paintTgProgress();
4633
+ }
4634
+ }
4611
4635
  function paintTgProgress() {
4636
+ if (klHold) {
4637
+ klHeldPaint = true;
4638
+ return;
4639
+ }
4612
4640
  tgStampProgress(document.querySelector("#graph svg"), tgProgress, new Date());
4613
4641
  drawTgReads(); // #568: the run view's reads, once the change merged
4614
4642
  renderTerragucciPanel();
4615
4643
  }
4644
+ // behold#937: the kiosk's last `behold:light` message and what draws it (web/kiosk-light-frame.js).
4645
+ let klMsg = null;
4646
+ let klCtx = null;
4647
+ const klPulsed = { token: null };
4648
+ function klRedraw() {
4649
+ if (!klCtx || !klMsg || !klCtx.svg.isConnected) return;
4650
+ klDraw(klCtx.svg, klMsg, klCtx.drawnAnswer, tgStoryOn() ? tgPacedProgress() : tgProgress, { cardsOf: klCtx.cardsOf, rootBox: klCtx.rootBox, boxHost: klCtx.boxHost, compMode: klCtx.compMode, pulsed: klCtx.pulsed, below: document.documentElement.classList.contains("kiosk-ask") });
4651
+ klTellLit();
4652
+ }
4653
+ // behold#tips-yield: where the lit cards are on screen (frame pixels), so the kiosk's tip card never covers what the
4654
+ // prompt talks about. Told when the lighting is drawn and again whenever the boxes move (a fit, a zoom), only on change.
4655
+ let klLitSaid = "";
4656
+ function klTellLit() {
4657
+ if (!embedOpts.host || window.parent === window || !document.documentElement.classList.contains("kiosk-ask")) return;
4658
+ const rects = [...document.querySelectorAll('#graph [data-kl="lit"]')]
4659
+ .map((g) => g.getBoundingClientRect())
4660
+ .filter((r) => r.width > 0 && r.height > 0)
4661
+ .map((r) => [Math.round(r.left), Math.round(r.top), Math.round(r.width), Math.round(r.height)]);
4662
+ const said = JSON.stringify(rects);
4663
+ if (said === klLitSaid) return;
4664
+ klLitSaid = said;
4665
+ try {
4666
+ window.parent.postMessage({ type: "behold:lit-rects", rects }, embedOpts.host);
4667
+ } catch {
4668
+ /* the parent went away */
4669
+ }
4670
+ }
4671
+ setInterval(klTellLit, 400);
4672
+ // behold#940: the kiosk's word that ask mode is on, which holds between the shots (the frame's class follows it or a shot's `ask`).
4673
+ let klAskFlag = false;
4674
+ let klAskHeard = false;
4675
+ let klArranged = false;
4676
+ function klSetAsk(on) {
4677
+ const root = document.documentElement.classList;
4678
+ const was = root.contains("kiosk-ask");
4679
+ root.toggle("kiosk-ask", on);
4680
+ klGate();
4681
+ if (was !== on && embedOpts.bare) drawTgReads();
4682
+ }
4683
+ /** The room the graph has in ask mode, in the pane's own pixels: the pane less what the prompt covers. */
4684
+ function klRoom() {
4685
+ const host = document.getElementById("graph");
4686
+ if (!host) return null;
4687
+ const pane = host.getBoundingClientRect();
4688
+ const i = kioskShot ? kioskPaneInsets(kioskShot) : { top: 0, right: 0, bottom: 0, left: 0 };
4689
+ const width = pane.width - i.left - i.right;
4690
+ const height = pane.height - i.top - i.bottom;
4691
+ return width > 0 && height > 0 ? { width, height } : { width: pane.width, height: pane.height };
4692
+ }
4693
+ /**
4694
+ * Ask mode lays the roots out for the room (web/kiosk-ask-layout.js): stacked, upstream on top, so the cards fill a
4695
+ * wide screen. A composed choudoufu run has none of its resources in the graph, so its scene is drawn from the run's
4696
+ * reports in place of the graph's cards (web/kiosk-estate-scene.js). Left, the graph goes back as it was drawn.
4697
+ * Idempotent: each call paints from what the graph drew.
4698
+ */
4699
+ function sceneUpOn(svg) {
4700
+ return !!(svg && svg.querySelector(":scope > [data-kl-scene]"));
4701
+ }
4702
+ /** The frame may show its svg (web/kiosk-graph-pane.js graphMayShow), and the class that lets it (kiosk.html: hidden otherwise in ask mode). */
4703
+ function klGate() {
4704
+ const svg = document.querySelector("#graph svg");
4705
+ const settled = !!(tgAnswer && !tgAnswer.error && Array.isArray(tgAnswer.roots));
4706
+ const mayShow = graphMayShow({ askOn: document.documentElement.classList.contains("kiosk-ask"), components: !!view.components, sceneUp: sceneUpOn(svg), answerSettled: settled, answerHasScene: settled && !!tgAnswer.estateScene });
4707
+ document.documentElement.classList.toggle("kl-show", mayShow);
4708
+ return { mayShow };
4709
+ }
4710
+ function klArrange(svg) {
4711
+ const on = document.documentElement.classList.contains("kiosk-ask") && !view.components;
4712
+ const answer = on ? tgAnswerDrawn() : null;
4713
+ if (!on || !answer || answer.error || !Array.isArray(answer.roots) || !answer.roots.length) {
4714
+ // Ask mode still on and a scene up: a read that is stale or failed for a moment (the reports as they are written)
4715
+ // keeps the last drawn scene. A composed run's graph has no cards of its own, so going back to it would be blank.
4716
+ if (keepsSceneInAsk({ askOn: on, sceneUp: sceneUpOn(svg) })) return;
4717
+ if (klArranged) {
4718
+ clearScene(svg);
4719
+ reloadLayoutDeltas();
4720
+ klArranged = false;
4721
+ }
4722
+ return;
4723
+ }
4724
+ const progress = tgStoryOn() ? tgPacedProgress() : tgProgress;
4725
+ const plan = klPlanOf(answer, progress);
4726
+ const open = klRoom();
4727
+ const model = sceneModel(answer, plan, progress, open);
4728
+ if (model) {
4729
+ const first = !klArranged;
4730
+ drawScene(svg, model);
4731
+ klArranged = true;
4732
+ klGate();
4733
+ // The first draw: fit to it at once (no swoop from the graph's own framing), and again once layout and paint settle.
4734
+ if (first) {
4735
+ refitNow();
4736
+ afterFrames(requestAnimationFrame, refitNow);
4737
+ }
4738
+ return;
4739
+ }
4740
+ // Ask mode: the plain graph never paints. A scene up stays when the pin hides the plan for a moment, and with none up
4741
+ // yet the graph's own drawing is held back (klPlainGate) until the scene comes.
4742
+ if (sceneUpOn(svg) || !klGate().mayShow) return;
4743
+ if (svg.__klStash) clearScene(svg);
4744
+ if (!layoutIndex) return;
4745
+ const extras = Object.fromEntries(Object.entries(klSlotCounts(plan)).map(([id, n]) => [id, n * 22 + 6]));
4746
+ const got = askDeltas({ roots: answer.roots, nodes: layoutIndex.nodes, boxes: layoutIndex.boxes, extras, edges: plan.edges, open });
4747
+ if (!got) return;
4748
+ layoutDeltas = got.deltas;
4749
+ renderLayout();
4750
+ klArranged = true;
4751
+ }
4616
4752
  // #568: the reads edges between roots of one repo, drawn over the card view.
4617
4753
  // #569: drawn so the view shows the change without the panel: each read is a
4618
4754
  // line from the reader (its data card when the checkout draws one, else its
@@ -4627,6 +4763,7 @@ const TG_TONE = { plan: "var(--frame-pending, var(--pending))", wait: "var(--fra
4627
4763
  /** The same, for words on a card: read on the card's own ground. */
4628
4764
  const TG_CARD_TONE = Object.fromEntries(Object.entries(TG_TONE).map(([k, v]) => [k, v.replace("--frame-", "--frame-card-")]));
4629
4765
  function drawTgReads() {
4766
+ klGate();
4630
4767
  if (embedOpts.bare) queueMicrotask(kioskDecorate); // behold#571: once this draw is done
4631
4768
  if (embedOpts.bare) queueMicrotask(() => (kioskShot ? applyKioskShot(false) : kioskTellBoxes())); // behold#571: the marks moved the boxes
4632
4769
  if (embedOpts.bare) queueMicrotask(kioskTellDrawn); // behold#571: the kiosk swaps a reloaded frame in once it has drawn
@@ -4668,6 +4805,7 @@ function drawTgReads() {
4668
4805
  // Report minor 34: last draw's cone lights go; drawConeLights sets this draw's.
4669
4806
  if (chantMode || !tgAnswer || tgAnswer.error || !tgAnswer.roots) drawConeLights(svg, { stage: null });
4670
4807
  if (!chantMode && (!tgAnswer || tgAnswer.error || !tgAnswer.roots)) return;
4808
+ if (embedOpts.bare && !chantMode) klArrange(svg); // behold#940
4671
4809
  const toSvg = svg.getScreenCTM && svg.getScreenCTM();
4672
4810
  if (!toSvg) return;
4673
4811
  const inv = toSvg.inverse();
@@ -4712,6 +4850,16 @@ function drawTgReads() {
4712
4850
  const rect = groupRect(path);
4713
4851
  return (rect && boxOf(rect)) || union(cardsOf(path).map(boxOf).filter(Boolean));
4714
4852
  };
4853
+ // behold#940: the box's own group and rect, in the group's own units, for a label that rides with the box.
4854
+ const boxHost = (path) => {
4855
+ const rect = groupRect(path);
4856
+ const parent = rect && rect.parentNode;
4857
+ if (!parent || !parent.hasAttribute || !parent.hasAttribute("data-layout-box")) return null;
4858
+ const x = parseFloat(rect.getAttribute("x"));
4859
+ const y = parseFloat(rect.getAttribute("y"));
4860
+ const h = parseFloat(rect.getAttribute("height"));
4861
+ return Number.isFinite(x) && Number.isFinite(y) && h > 0 ? { parent, x, y, y2: y + h } : null;
4862
+ };
4715
4863
  const NS = "http://www.w3.org/2000/svg";
4716
4864
  const make = (tag, attrs, text) => {
4717
4865
  const n = document.createElementNS(NS, tag);
@@ -4793,7 +4941,9 @@ function drawTgReads() {
4793
4941
  layer.parentNode.insertBefore(mark, layer);
4794
4942
  // The badge: on the box's top border, right-aligned, like a tab; the "N
4795
4943
  // resources" count in the header row under it gives way.
4796
- const local = rect.getBBox();
4944
+ // In the svg's own units, where the box is now: a box moved by a layout delta sits in a group that carries its offset.
4945
+ const placed = boxOf(rect);
4946
+ const local = placed ? { x: placed.x, y: placed.y, width: placed.x2 - placed.x, height: placed.y2 - placed.y } : rect.getBBox();
4797
4947
  const headY = local.y + 23;
4798
4948
  const tabY = local.y;
4799
4949
  for (const t of svg.querySelectorAll("text")) {
@@ -4806,8 +4956,11 @@ function drawTgReads() {
4806
4956
  }
4807
4957
  // Filled when something happened or waits on the root; an outline when nothing has yet.
4808
4958
  const solid = st.state !== "outside" && st.state !== "not-started" && st.state !== "unchanged";
4809
- const badge = pill(mark, local.x + local.width - 16, tabY, st.words, { stroke: tone, fill: solid ? tone : "var(--panel)", color: solid ? "var(--bg)" : "var(--fg)", size: 14, weight: 700, anchor: "end", cls: st.state === "applying" ? "pin-pulse" : "" });
4810
- badge.g.appendChild(make("title", {}, [st.words, ...st.facts].join("\n") + "\n(from terragucci's reports, not live)"));
4959
+ // behold#940: in ask mode the badge says the step's own word, with no wave.
4960
+ const askWords = embedOpts.bare && document.documentElement.classList.contains("kiosk-ask") ? klBadge(st, r.path, tgStoryOn() ? tgPacedProgress() : tgProgress) : null;
4961
+ const badgeText = askWords || st.words;
4962
+ const badge = pill(mark, local.x + local.width - 16, tabY, badgeText, { stroke: tone, fill: solid ? tone : "var(--panel)", color: solid ? "var(--bg)" : "var(--fg)", size: 14, weight: 700, anchor: "end", cls: st.state === "applying" ? "pin-pulse" : "" });
4963
+ badge.g.appendChild(make("title", {}, [badgeText, ...st.facts].join("\n") + "\n(from terragucci's reports, not live)"));
4811
4964
  // The facts under it, at the box's bottom right: the plan a wave waits on, its changes.
4812
4965
  // Packed into one line that fits the box, most telling first; the rest is in the badge's tooltip.
4813
4966
  if (st.facts.length) {
@@ -4841,7 +4994,7 @@ function drawTgReads() {
4841
4994
  const shown = lines.slice(0, 1);
4842
4995
  if (lines.length > 1) shown[0] += " …";
4843
4996
  shown.forEach((t, i) => {
4844
- mark.appendChild(make("text", { x: local.x + local.width - 14, y: local.y + local.height - 10 - (shown.length - 1 - i) * 15, "text-anchor": "end", "font-size": 12.5, "font-weight": 600, fill }, t));
4997
+ mark.appendChild(make("text", { x: local.x + local.width - 14, y: local.y + local.height - 10 - (shown.length - 1 - i) * 15, "text-anchor": "end", "font-size": 12.5, "font-weight": 600, fill, "data-tg-box-facts": "1" }, t));
4845
4998
  });
4846
4999
  }
4847
5000
  }
@@ -5069,6 +5222,11 @@ function drawTgReads() {
5069
5222
  }
5070
5223
  tgReadEdgesNow = edges;
5071
5224
  tgReadShow(svg);
5225
+ // behold#937: a demo step's lighting, the states' files and looks, the unknown slots, over the marks just drawn.
5226
+ if (embedOpts.bare) {
5227
+ klCtx = { svg, drawnAnswer, rootBox, boxHost, compMode, cardsOf, pulsed: klPulsed };
5228
+ klRedraw();
5229
+ }
5072
5230
 
5073
5231
  // Which run the marks come from, above the boxes.
5074
5232
  // #569: a pin that holds the view off every plan says why in its own words.
@@ -5479,6 +5637,9 @@ function ensureTgReadStyle() {
5479
5637
  #graph g[data-tg-read-pill].tg-flash { animation: tg-read-flash 6s linear both; }
5480
5638
  #graph line[data-tg-read].tg-hot { stroke-width: 5; filter: drop-shadow(0 0 3px var(--bg)); }
5481
5639
  #graph g[data-tg-read-covers] { display: none !important; }
5640
+ /* Ask mode never paints the checkout's plain resource graph: the svg is held (kl-show) until the estate scene is drawn. */
5641
+ html.kiosk-ask:not(.kl-show) #graph svg { visibility: hidden; }
5642
+ html.kiosk-ask #view-toggles, html.kiosk-ask #graph text[data-tg-reads="caption"], html.kiosk-ask #graph text[data-tg-root="wave-fact"], html.kiosk-ask #graph text[data-tg-box-facts] { display: none; }
5482
5643
  @keyframes tg-read-flash { 0% { opacity: 0; } 4%, 80% { opacity: 1; } 100% { opacity: 0; } }
5483
5644
  @keyframes tg-read-flash-step { 0%, 99.9% { opacity: 1; } 100% { opacity: 0; } }
5484
5645
  @media (prefers-reduced-motion: reduce) {
@@ -5812,7 +5973,7 @@ function chantKioskWaves(svg, boxOf, size) {
5812
5973
  else path.setAttribute("marker-end", "url(#k-then-arrow)");
5813
5974
  }
5814
5975
  // The bottom box says which way the waves go, once.
5815
- if (!svg.querySelector("text[data-kiosk-upward]")) {
5976
+ if (!svg.querySelector("text[data-kiosk-upward]") && !composedRun(tgAnswer, tgProgress)) {
5816
5977
  const boxes = [...svg.querySelectorAll("rect[data-group-id]")].filter((r) => tgWaveOfKey(r.getAttribute("data-group-id")) !== null);
5817
5978
  const low = boxes.map((r) => ({ r, b: boxOf(r) })).filter((x) => x.b).sort((a, b) => b.b.y2 - a.b.y2)[0];
5818
5979
  if (low) {
@@ -6382,8 +6543,10 @@ function userBoxOf(svg, el) {
6382
6543
  } catch {
6383
6544
  return null;
6384
6545
  }
6385
- const ctm = el.getCTM && el.getCTM();
6386
- const root = svg.getCTM && svg.getCTM();
6546
+ // getScreenCTM on both: svg.getCTM() is the viewBox's matrix in Chrome but the identity in Firefox, which put every box off
6547
+ // screen there. The screen matrices both include the viewBox, so root^-1 * el is the element's matrix in the svg's user units.
6548
+ const ctm = el.getScreenCTM && el.getScreenCTM();
6549
+ const root = svg.getScreenCTM && svg.getScreenCTM();
6387
6550
  if (!ctm || !root || !(b.width > 0 || b.height > 0)) return null;
6388
6551
  const m = root.inverse().multiply(ctm);
6389
6552
  const pts = [[b.x, b.y], [b.x + b.width, b.y + b.height]].map(([x, y]) => new DOMPoint(x, y).matrixTransform(m));
@@ -6391,14 +6554,23 @@ function userBoxOf(svg, el) {
6391
6554
  }
6392
6555
 
6393
6556
  /** What a shot frames, in svg units: its roots' cards and the reads between them, its waves' boxes, else the whole graph. */
6557
+ /** What hangs under the lowest box in ask mode: its state label. */
6558
+ const ASK_LABEL_ROOM = 32;
6394
6559
  function kioskShotTarget(svg, shot) {
6395
6560
  if (!vbInit) return null;
6396
6561
  const boxes = [];
6397
6562
  if (shot.whole) {
6398
6563
  // The whole graph is what is drawn: the boxes, the cards and the reads, not pinhole's margins round them.
6399
6564
  // behold#744: not the reads' pills, which show and go while the shot stays.
6400
- for (const n of svg.querySelectorAll("rect[data-group-id], [data-node-id], [data-tg-reads] > g:not([data-tg-read-pill]), line[data-tg-read-from], text[data-tg-reads='caption']")) boxes.push(userBoxOf(svg, n));
6401
- return unionBox(boxes) || { x: vbInit[0], y: vbInit[1], x2: vbInit[0] + vbInit[2], y2: vbInit[1] + vbInit[3] };
6565
+ for (const n of svg.querySelectorAll("rect[data-group-id], [data-node-id], [data-tg-reads] > g:not([data-tg-read-pill]), line[data-tg-read-from], text[data-tg-reads='caption'], g[data-kl-state]")) boxes.push(userBoxOf(svg, n));
6566
+ const u = unionBox(boxes);
6567
+ // Ask mode: each box's state label hangs under it, and may not have drawn yet; the fit always leaves room for it, so the
6568
+ // stack sits the same before and after the labels (and centred, not low).
6569
+ if (u && shot.ask) {
6570
+ const low = Math.max(...[...svg.querySelectorAll("rect[data-group-id]")].map((r) => (userBoxOf(svg, r) || { y2: -Infinity }).y2));
6571
+ if (Number.isFinite(low)) u.y2 = Math.max(u.y2, low + ASK_LABEL_ROOM);
6572
+ }
6573
+ return u || { x: vbInit[0], y: vbInit[1], x2: vbInit[0] + vbInit[2], y2: vbInit[1] + vbInit[3] };
6402
6574
  }
6403
6575
  const named = (tgComponentFacets && tgComponentFacets.roots) || {};
6404
6576
  const roots = new Set(shot.roots);
@@ -6464,7 +6636,8 @@ function kioskShotBox() {
6464
6636
  // Only an estate on choudoufu's live backend (the cone scenario's) is held; every other keeps a shot per step, as on main.
6465
6637
  // behold#736: a story's stage (fan-out-choudoufu, a chapter-carrying scenario, behold#741) is never held: it keeps
6466
6638
  // the story's own look, its result card, #745's pills and #748's outside mark.
6467
- if (whole && !tgStoryOn() && holdsStage(tgAnswer && !tgAnswer.error ? tgAnswer.binaries : null) && smallStage(whole, pane, held ? held.insets : docked, cardW)) {
6639
+ // Ask mode is never held: the held framing is the union of every target it has seen (the graph before the scene drew included), which leaves the scene off-centre. It is fitted to the scene as drawn, every time.
6640
+ if (whole && !kioskShot.ask && !tgStoryOn() && holdsStage(tgAnswer && !tgAnswer.error ? tgAnswer.binaries : null) && smallStage(whole, pane, held ? held.insets : docked, cardW)) {
6468
6641
  kioskHeld = heldFrame(kioskHeld, { key: graph, pane, insets: docked, target: whole });
6469
6642
  writeHeld(kioskHeld);
6470
6643
  document.documentElement.classList.add("kiosk-held");
@@ -6474,7 +6647,8 @@ function kioskShotBox() {
6474
6647
  }
6475
6648
  kioskHeld = null;
6476
6649
  document.documentElement.classList.remove("kiosk-held");
6477
- return shotViewBox(kioskShotTarget(svg, kioskShot), pane, { ...insets, right: Math.max(insets.right, railInset(pane)) });
6650
+ // behold#939: a prompt-driven step fills the room above the pane (the graph is small, and the pane says the rest).
6651
+ return shotViewBox(kioskShotTarget(svg, kioskShot), pane, { ...insets, right: Math.max(insets.right, railInset(pane)) }, kioskShot.ask ? { maxScale: ASK_MAX_SCALE } : undefined);
6478
6652
  }
6479
6653
  /** The whole-graph framing Watch holds on a small stage while the graph and the pane stay (web/kiosk-shot.js heldFrame); null on a bigger one. */
6480
6654
  var kioskHeld = null;
@@ -6512,6 +6686,14 @@ function kioskPaneInsets(shot) {
6512
6686
 
6513
6687
  /** Move to the shot: a pan and zoom over its time, or at once (a re-render, a resize, reduced motion). */
6514
6688
  function applyKioskShot(animate) {
6689
+ // "now": a refit (a resize, the fonts, the first draw settling) sets the view directly, over any move under way.
6690
+ if (animate === "now") {
6691
+ animate = false;
6692
+ if (shotAnim) {
6693
+ cancelAnimationFrame(shotAnim.raf);
6694
+ shotAnim = null;
6695
+ }
6696
+ }
6515
6697
  // #715: while a live carve runs, its director has the camera; the shot waits for it to end.
6516
6698
  if (dotsCarving()) return kioskTellBoxes();
6517
6699
  const to = kioskShotBox();
@@ -6627,6 +6809,8 @@ function kioskTellDrawn() {
6627
6809
  if (drawnTold || !embedOpts.host || window.parent === window) return;
6628
6810
  const drawnState = graphDrawnState();
6629
6811
  if (!drawnState) return;
6812
+ // Ask mode: not drawn until the estate scene is (or the kiosk's word that ask mode is on has not come in a while: a failed draw says so at once).
6813
+ if (drawnState !== "failed" && !mayTellDrawn({ askHeard: klAskHeard, waitedMs: performance.now(), askOn: document.documentElement.classList.contains("kiosk-ask"), mayShow: klGate().mayShow })) return;
6630
6814
  const failed = drawnState === "failed";
6631
6815
  drawnTold = true;
6632
6816
  try {
@@ -6738,10 +6922,13 @@ window.addEventListener("message", (e) => {
6738
6922
  shotAnim = null;
6739
6923
  kioskShot = null;
6740
6924
  document.documentElement.classList.remove("kiosk-held"); // Inspect: the zoom rail is the viewer's again
6925
+ klSetAsk(klAskFlag);
6741
6926
  fitGraph();
6742
6927
  return;
6743
6928
  }
6744
6929
  kioskShot = shot;
6930
+ klAskHeard = true;
6931
+ klSetAsk(!!shot.ask || klAskFlag);
6745
6932
  applyKioskShot(true);
6746
6933
  });
6747
6934
 
@@ -6808,6 +6995,38 @@ function wireKioskFrame() {
6808
6995
  window.addEventListener("message", (e) => {
6809
6996
  if (!embedOpts.host || e.origin !== embedOpts.host) return;
6810
6997
  if (e.data && e.data.type === "behold:unpin") return kioskPopEvent({ type: "outside" });
6998
+ // behold#937: the demo step's lighting from the kiosk (web/kiosk-light.js lightMessage).
6999
+ if (e.data && e.data.type === "behold:hold") {
7000
+ if (klHold) clearTimeout(klHold);
7001
+ klHold = setTimeout(klReleaseHold, 120000); // slow typing and queued steps hold it for a while; a step that never finishes does not freeze the graph for good
7002
+ return;
7003
+ }
7004
+ if (e.data && e.data.type === "behold:light") {
7005
+ const wasHeld = !!klHold;
7006
+ if (klHold) {
7007
+ clearTimeout(klHold);
7008
+ klHold = null;
7009
+ }
7010
+ klMsg = { labels: e.data.labels === true, lit: e.data.lit === true, ids: Array.isArray(e.data.ids) ? e.data.ids.filter((x) => typeof x === "string") : [], roots: Array.isArray(e.data.roots) ? e.data.roots.filter((x) => typeof x === "string") : [], ghost: e.data.ghost === true, token: e.data.token ?? null };
7011
+ klRedraw();
7012
+ if (wasHeld && klHeldPaint) {
7013
+ klHeldPaint = false;
7014
+ paintTgProgress();
7015
+ }
7016
+ // behold#940: drawn at once from what the frame holds, and again as soon as its reads are fresh: never at a poll's turn.
7017
+ if (!staticMode && tgAnswer) {
7018
+ void refreshTgAnswer();
7019
+ void loadTgProgress({ fresh: true });
7020
+ }
7021
+ return;
7022
+ }
7023
+ // behold#940: ask mode is on or off for this step, whatever the shots say between prompts.
7024
+ if (e.data && e.data.type === "behold:ask") {
7025
+ klAskFlag = e.data.on === true;
7026
+ klAskHeard = true;
7027
+ klSetAsk(klAskFlag || !!(kioskShot && kioskShot.ask));
7028
+ return;
7029
+ }
6811
7030
  // behold#571: the kiosk's theme picker moved; follow it here without a reload.
6812
7031
  if (e.data && e.data.type === "behold:theme" && typeof e.data.name === "string") return void setTheme(e.data.name, { persist: false });
6813
7032
  // behold#741: the scenario carries chapters (or stopped carrying them): the kiosk's look, and the wave blocks, follow.
@@ -9728,10 +9947,20 @@ function fitGraph() {
9728
9947
  let vbAtFit = false;
9729
9948
  function watchPaneForFit(host) {
9730
9949
  if (typeof ResizeObserver === "undefined") return;
9731
- new ResizeObserver(() => {
9732
- if (kioskShot) applyKioskShot(false);
9733
- else if (vbAtFit) fitGraph();
9734
- }).observe(host);
9950
+ // The refit waits for the last size change and sets the view directly: no swoop, and a resize burst fits once.
9951
+ // It moves the viewBox, never the host's box, so the observer cannot trigger itself.
9952
+ // Each change also sets the view at once, so a box is never off screen on the old framing while the burst lasts.
9953
+ const refit = debounced(refitNow);
9954
+ const onSize = () => (refitNow(), refit());
9955
+ new ResizeObserver(onSize).observe(host);
9956
+ window.addEventListener("resize", onSize);
9957
+ // Web fonts change the text's width, and with it the boxes.
9958
+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(refitNow, () => {});
9959
+ }
9960
+ /** Fit again as things stand, at once. Idempotent: a fit that is already right sets nothing. */
9961
+ function refitNow() {
9962
+ if (kioskShot) applyKioskShot("now");
9963
+ else if (vbAtFit) fitGraph();
9735
9964
  }
9736
9965
 
9737
9966
  // --- #396 item 7b: box titles and badges that survive the fit ---------------
@@ -10704,6 +10933,21 @@ function renderPreconditionError(body) {
10704
10933
  host.appendChild(card);
10705
10934
  }
10706
10935
 
10936
+ // A kiosk frame's graph refused its checkout (a precondition: a chant project whose packages the view never
10937
+ // installed fails lint). A composed run's scene is drawn from the run's reports in place of the graph's cards
10938
+ // (web/kiosk-estate-scene.js), so it needs none of the graph: once the reports hold a scene, the frame draws it on an
10939
+ // empty svg instead of the refusal's card. A frame whose reports hold no scene keeps the card.
10940
+ let graphRefusal = null;
10941
+ const SCENE_ONLY_SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600" width="800" height="600"></svg>';
10942
+ function sceneInPlaceOfRefusal() {
10943
+ if (!refusalHoldsScene({ refusal: graphRefusal, bare: embedOpts.bare, answer: tgAnswer })) return false;
10944
+ const note = `the graph is not drawn (${graphRefusal.code}): the run's reports draw the scene`;
10945
+ graphRefusal = null;
10946
+ render({ nodes: [], edges: [], groups: [] }, SCENE_ONLY_SVG, { note, noteShort: note });
10947
+ afterPaint({ nodes: [] });
10948
+ return true;
10949
+ }
10950
+
10707
10951
  // Fetch the current view (source graph, or the picked env's live overlay).
10708
10952
  const load = createRefreshQueue(loadOnce);
10709
10953
  async function loadOnce(opts = {}, isCurrent = () => true) {
@@ -10832,6 +11076,8 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
10832
11076
  // tier that needs credentials) gets the calmer entry/error card instead
10833
11077
  // of the generic red error box — see renderPreconditionError().
10834
11078
  if (body.code) {
11079
+ graphRefusal = embedOpts.bare ? body : null;
11080
+ if (sceneInPlaceOfRefusal()) return;
10835
11081
  renderPreconditionError(body);
10836
11082
  meta.textContent = body.code === "tier" ? `tier ${view.tier} unavailable here` : "error";
10837
11083
  renderDial();
@@ -10857,6 +11103,7 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
10857
11103
  pendingMembers = body.meta && body.meta.mode === "progressive" ? [...(body.meta.pending || [])] : [];
10858
11104
  pendingTotal = pendingMembers.length;
10859
11105
  if (view.components) takeTerragucciFacets(body.meta);
11106
+ graphRefusal = null;
10860
11107
  render(body.ir, body.svg, body.meta);
10861
11108
  afterPaint(body.ir);
10862
11109
  if (progressive) replayMemberFrames(frameLoad);