@intentius/behold 0.29.40 → 0.29.42

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 (61) hide show
  1. package/AGENTS.md +180 -10
  2. package/README.md +6 -2
  3. package/dist/cli.js +16121 -13141
  4. package/example-writes/README.md +1 -1
  5. package/example-writes/chant.config.ts +0 -6
  6. package/package.json +5 -2
  7. package/web/app.js +327 -21
  8. package/web/carve-export.js +142 -0
  9. package/web/carve-narration.js +294 -0
  10. package/web/carve-narration.test.js +48 -0
  11. package/web/change-set-overlay.js +147 -0
  12. package/web/change-set-overlay.test.js +83 -0
  13. package/web/dots-border.js +66 -0
  14. package/web/dots-border.test.js +27 -0
  15. package/web/dots-kiosk.js +279 -0
  16. package/web/dots-kiosk.test.js +60 -0
  17. package/web/dots-layout.d.ts +10 -0
  18. package/web/dots-layout.js +201 -0
  19. package/web/dots-live.js +316 -0
  20. package/web/dots-live.test.js +220 -0
  21. package/web/dots-lod.js +122 -0
  22. package/web/dots-lod.test.js +78 -0
  23. package/web/dots-recording.d.ts +7 -0
  24. package/web/dots-recording.js +247 -0
  25. package/web/dots-recording.test.js +71 -0
  26. package/web/dots-scene.js +294 -0
  27. package/web/dots-scene.test.js +118 -0
  28. package/web/dots-timeline.js +128 -0
  29. package/web/dots-timeline.test.js +83 -0
  30. package/web/dots-tour.js +153 -0
  31. package/web/dots.js +2124 -0
  32. package/web/dots.test.js +15 -0
  33. package/web/event-help-modal.js +1 -1
  34. package/web/index.html +215 -121
  35. package/web/kiosk-carve.js +225 -0
  36. package/web/kiosk-carve.test.js +26 -0
  37. package/web/kiosk-event-help-ui.js +7 -1
  38. package/web/kiosk-link.js +68 -0
  39. package/web/kiosk-link.test.js +69 -0
  40. package/web/kiosk-metrics.js +2 -2
  41. package/web/kiosk-trace.js +1 -1
  42. package/web/kiosk.html +186 -135
  43. package/web/kiosk.js +65 -7
  44. package/web/motion.js +42 -0
  45. package/web/motion.test.js +64 -0
  46. package/web/operator.js +1 -1
  47. package/web/run-playhead.js +102 -19
  48. package/web/run-playhead.test.js +81 -11
  49. package/web/terralith.html +2 -2
  50. package/web/theme.js +99 -26
  51. package/web/theme.test.js +70 -6
  52. package/web/tooltip.js +212 -0
  53. package/web/tooltip.test.js +193 -0
  54. package/web/tour-player.js +204 -0
  55. package/web/tour-player.test.js +115 -0
  56. package/web/tours/behold.tour.v1.schema.json +182 -0
  57. package/web/tours/terralith.json +330 -0
  58. package/web/trunk-lane.js +406 -0
  59. package/web/trunk-lane.test.js +224 -0
  60. package/web/workspace-gates.js +29 -4
  61. package/web/workspace-gates.test.js +23 -2
@@ -3,8 +3,17 @@
3
3
  //
4
4
  // One approve path per gate. Framed in a host (#476), behold draws the gate
5
5
  // and no button: the host knows who is looking and records it. Standalone, the
6
- // button stays, and the card says the approval is recorded as the user running
7
- // behold, since behold has no other identity to give chant.
6
+ // button stays, and its label names who chant records the approval as (#690):
7
+ // the person behold's proxy signed in, the one `--as` names, or else the user
8
+ // running behold. A gate that needs a signed approval gets a button only when
9
+ // behold holds that person's key.
10
+
11
+ /** Where the approver's name came from, in the words a button's tooltip uses. */
12
+ const SOURCE_WORDS = {
13
+ header: "from your sign-in",
14
+ configured: "set when behold started",
15
+ process: "the user running behold",
16
+ };
8
17
 
9
18
  /** The words a framed card uses instead of a button. */
10
19
  export const HOST_APPROVES = "approve in the host that framed this graph";
@@ -31,14 +40,30 @@ export function gateCards(answer, { embed = false, member = null } = {}) {
31
40
  command: g.approve,
32
41
  };
33
42
  if (embed) card.note = HOST_APPROVES;
34
- else if (g.signed) card.note = `wants a signed approval; run ${g.approve}`;
35
- else card.button = { label: `Approve as ${answer.approver || "you"}`, title: `${g.approve}, run by behold. chant records the approval as ${answer.approver || "the user running behold"}.` };
43
+ else Object.assign(card, approveAffordance(g, answer));
36
44
  return card;
37
45
  });
38
46
  const elsewhere = all.length - shown.length;
39
47
  return { cards, elsewhere, refusal: (answer && answer.refusal) || null };
40
48
  }
41
49
 
50
+ /**
51
+ * #690: the button, or the note in its place, for a standalone card. The label
52
+ * says who the approval is recorded as before the click.
53
+ */
54
+ export function approveAffordance(g, answer) {
55
+ const refusal = answer && answer.approverRefusal;
56
+ if (refusal) return { note: `can't approve here: ${refusal.error}. Run ${g.approve}` };
57
+ const id = (answer && answer.approverIdentity) || null;
58
+ const who = (answer && answer.approver) || "you";
59
+ const from = SOURCE_WORDS[id ? id.source : "process"] || SOURCE_WORDS.process;
60
+ if (g.signed) {
61
+ if (!id || !id.signs) return { note: `needs a signed approval, and behold has no key for ${who}. Run ${g.approve}` };
62
+ return { button: { label: `Approve as ${who}, signed`, title: `behold runs ${g.approve} with ${who}'s key. chant records ${who}, ${from}.` } };
63
+ }
64
+ return { button: { label: `Approve as ${who}`, title: `behold runs ${g.approve}. chant records ${who}, ${from}.` } };
65
+ }
66
+
42
67
  /**
43
68
  * #519: a policy denial. chant's override needs the denied rules and a
44
69
  * person's reason, so the card shows them and the command to run, and never a
@@ -26,9 +26,30 @@ describe("gateCards (#477)", () => {
26
26
  expect(cards.map((c) => c.key)).toEqual(["delivery/ship/approve-ship"]);
27
27
  expect(elsewhere).toBe(1);
28
28
  });
29
- it("sends a signed gate to the command line", () => {
29
+ it("sends a signed gate to the command line when behold holds no key", () => {
30
30
  const { cards } = gateCards({ ...answer, gates: [{ ...answer.gates[0], signed: true, approve: "chant approve ship approve-ship --sign" }] });
31
31
  expect(cards[0].button).toBeUndefined();
32
- expect(cards[0].note).toBe("wants a signed approval; run chant approve ship approve-ship --sign");
32
+ expect(cards[0].note).toBe("needs a signed approval, and behold has no key for alex. Run chant approve ship approve-ship --sign");
33
+ });
34
+ });
35
+
36
+ describe("who the approval is recorded as (#690)", () => {
37
+ const as = (identity) => ({ ...answer, approver: identity.principal, approverIdentity: identity });
38
+ const alice = { principal: "github:alice", source: "configured", forge: true, signs: false };
39
+ it("names the person on the button, and where the name came from in its title", () => {
40
+ const { cards } = gateCards(as(alice));
41
+ expect(cards[0].button).toEqual({ label: "Approve as github:alice", title: "behold runs chant approve ship approve-ship. chant records github:alice, set when behold started." });
42
+ const signedIn = gateCards(as({ ...alice, source: "header" })).cards[0];
43
+ expect(signedIn.button.title).toMatch(/github:alice, from your sign-in\.$/);
44
+ });
45
+ it("offers a signed gate when behold holds the person's key", () => {
46
+ const { cards } = gateCards({ ...as({ ...alice, signs: true }), gates: [{ ...answer.gates[0], signed: true, approve: "chant approve ship approve-ship --sign" }] });
47
+ expect(cards[0].button.label).toBe("Approve as github:alice, signed");
48
+ expect(cards[0].button.title).toBe("behold runs chant approve ship approve-ship --sign with github:alice's key. chant records github:alice, set when behold started.");
49
+ });
50
+ it("draws no button when behold can't tell who is asking", () => {
51
+ const { cards } = gateCards({ ...answer, approver: null, approverRefusal: { error: "behold reads who you are from the x-forwarded-user header, and this request has none", code: "no-identity" } });
52
+ expect(cards[0].button).toBeUndefined();
53
+ expect(cards[0].note).toBe("can't approve here: behold reads who you are from the x-forwarded-user header, and this request has none. Run chant approve ship approve-ship");
33
54
  });
34
55
  });