@hypersocial/decks-cli 0.9.23 → 0.9.25

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 (91) hide show
  1. package/package.json +1 -1
  2. package/skills/hyperdecks/SKILL.md +124 -67
  3. package/skills/hyperdecks/chat.md +11 -8
  4. package/skills/hyperdecks/terminal.md +83 -0
  5. package/src/bars.mjs +268 -0
  6. package/src/brand.mjs +51 -8
  7. package/src/check.mjs +333 -20
  8. package/src/checkRules.mjs +677 -27
  9. package/src/commands.mjs +171 -31
  10. package/src/deckSlug.mjs +41 -0
  11. package/src/embedCapture.mjs +126 -0
  12. package/src/embedSources.mjs +252 -0
  13. package/src/embedsGuide.mjs +36 -0
  14. package/src/export-video.mjs +20 -3
  15. package/src/files.mjs +36 -0
  16. package/src/guide.mjs +93 -13
  17. package/src/hosted.mjs +18 -8
  18. package/src/iconAliasNames.mjs +70 -0
  19. package/src/iconChoice.mjs +97 -0
  20. package/src/iconSets.mjs +89 -0
  21. package/src/iconSlots.mjs +48 -0
  22. package/src/icons.mjs +285 -45
  23. package/src/iconsCli.mjs +76 -0
  24. package/src/layoutRoutes.mjs +97 -0
  25. package/src/layouts.mjs +9 -4
  26. package/src/mediaPreviews.mjs +3 -1
  27. package/src/narrate.mjs +31 -4
  28. package/src/opening.mjs +9 -3
  29. package/src/ops.mjs +125 -0
  30. package/src/photosGuide.mjs +47 -0
  31. package/src/picturesGuide.mjs +54 -0
  32. package/src/play.mjs +3 -2
  33. package/src/presenter.mjs +3 -1
  34. package/src/preview-capture.mjs +70 -1
  35. package/src/release.mjs +13 -5
  36. package/src/runtime.mjs +9 -2
  37. package/src/scaffold.mjs +73 -13
  38. package/src/source.mjs +86 -14
  39. package/src/stockMedia.mjs +299 -0
  40. package/src/themeCli.mjs +41 -0
  41. package/src/themes.mjs +345 -0
  42. package/templates/icons/material.LICENSE +202 -0
  43. package/templates/icons/material.json.gz +0 -0
  44. package/templates/icons/phosphor.LICENSE +21 -0
  45. package/templates/icons/phosphor.json.gz +0 -0
  46. package/templates/icons/tabler.LICENSE +21 -0
  47. package/templates/icons/tabler.json.gz +0 -0
  48. package/templates/layouts/_deck.html +231 -41
  49. package/templates/layouts/bento.html +76 -0
  50. package/templates/layouts/chart.html +6 -4
  51. package/templates/layouts/closer.html +13 -4
  52. package/templates/layouts/compare.html +13 -4
  53. package/templates/layouts/cover-band.html +13 -9
  54. package/templates/layouts/cover-frame.html +13 -7
  55. package/templates/layouts/cover-poster.html +9 -5
  56. package/templates/layouts/cover-split.html +19 -7
  57. package/templates/layouts/cover-type.html +2 -1
  58. package/templates/layouts/embed.html +93 -0
  59. package/templates/layouts/features.html +18 -10
  60. package/templates/layouts/funnel.html +62 -0
  61. package/templates/layouts/hero.html +41 -23
  62. package/templates/layouts/lanes.html +63 -0
  63. package/templates/layouts/loop.html +81 -0
  64. package/templates/layouts/number.html +3 -2
  65. package/templates/layouts/phone-stage.html +78 -0
  66. package/templates/layouts/phones.html +1 -0
  67. package/templates/layouts/picture-full.html +58 -0
  68. package/templates/layouts/portrait.html +53 -0
  69. package/templates/layouts/product.html +7 -6
  70. package/templates/layouts/quote.html +5 -3
  71. package/templates/layouts/rail.html +74 -0
  72. package/templates/layouts/scorecard.html +71 -0
  73. package/templates/layouts/screens.html +85 -0
  74. package/templates/layouts/sentence.html +39 -0
  75. package/templates/layouts/split.html +35 -7
  76. package/templates/layouts/spotlight.html +80 -0
  77. package/templates/layouts/stack.html +84 -0
  78. package/templates/layouts/staircase.html +78 -0
  79. package/templates/layouts/strike.html +46 -0
  80. package/templates/layouts/tap-through.html +73 -0
  81. package/templates/layouts/team.html +21 -6
  82. package/templates/layouts/timeline.html +21 -8
  83. package/templates/layouts/two-bars.html +53 -0
  84. package/templates/layouts/two-by-two.html +75 -0
  85. package/templates/layouts/video-beats.html +66 -0
  86. package/templates/layouts/video-full.html +62 -0
  87. package/templates/layouts/wall.html +109 -0
  88. package/templates/layouts/zoom.html +144 -0
  89. package/templates/narrated-deck.html +12 -7
  90. package/templates/script.md +2 -2
  91. /package/templates/icons/{LICENSE → lucide.LICENSE} +0 -0
@@ -0,0 +1,252 @@
1
+ // The embed slide's allowed sources (docs/roadmap/embed-slide-a-still-first-live-on-tap-maps-video-figma-booki.md):
2
+ // one table, read by check (a source not on it), the guide (embeds topic), the still capture (screenshot --embed,
3
+ // capture_url { embed: true }) and the player, which loads a live frame only for a URL this table turns into an embed
4
+ // URL. Anything else shows its still with a link that opens in a new tab. No Node imports: the player and the hosted
5
+ // check run it too.
6
+ //
7
+ // Each row: the hosts it answers to, a function from the author's URL to the frame's URL (null when the URL is on
8
+ // that host but not something it can embed), the control's words, and the frame's `allow` and `sandbox`. `opaque`:
9
+ // the source still draws inside a page with no origin of its own. A shared deck is served in a CSP sandbox without
10
+ // allow-same-origin (lib/deckSandbox.ts), and a frame inside it inherits that, so YouTube, Vimeo, Loom, Figma and
11
+ // Calendly draw nothing there (checked in Chromium on 2026-11-28): on such a page the player opens them in a new tab instead.
12
+ // `inline: false`: never in a frame, on any page. Calendly's cookie banner (not the GDPR one hide_gdpr_banner turns
13
+ // off) covers half its booking page in a frame and cannot be dismissed from outside it, so it always opens in a tab.
14
+
15
+ const SANDBOX = "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox";
16
+
17
+ // A path segment's words; a malformed escape ("50%off") stays as written rather than throwing.
18
+ const decoded = (s) => { try { return decodeURIComponent(s); } catch { return s; } };
19
+
20
+ // A Google Maps link as an embed URL: an embed URL as it is; a place (/maps/place/<name>) or a search (?q=) by its
21
+ // words; a point (/@lat,lng,zoomz) by its coordinates. The keyless maps?output=embed form needs no API key.
22
+ function googleMaps(u) {
23
+ const host = u.hostname.replace(/^www\./, "");
24
+ if (!(host === "maps.google.com" || (host === "google.com" && /^\/maps(\/|$)/.test(u.pathname)))) return null;
25
+ if (/^\/maps\/embed(\/|$)/.test(u.pathname) || (/^\/maps\/?$/.test(u.pathname) && u.searchParams.get("output") === "embed")) return u.href;
26
+ const at = /@(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)(?:,(\d+(?:\.\d+)?)z)?/.exec(u.pathname);
27
+ const place = /\/maps\/(?:place|search)\/([^/@]+)/.exec(u.pathname)?.[1];
28
+ const q = u.searchParams.get("q") ?? u.searchParams.get("query") ?? (place ? decoded(place.replace(/\+/g, " ")) : at ? `${at[1]},${at[2]}` : null);
29
+ if (!q) return null;
30
+ const z = u.searchParams.get("z") ?? (at?.[3] ? String(Math.round(Number(at[3]))) : null);
31
+ return `https://maps.google.com/maps?q=${encodeURIComponent(q)}${z ? `&z=${encodeURIComponent(z)}` : ""}&output=embed`;
32
+ }
33
+
34
+ // A YouTube video (watch?v=, youtu.be/, /embed/, /shorts/, /live/) on youtube-nocookie.com, from its start time if the link has one.
35
+ function youtube(u) {
36
+ const host = u.hostname.replace(/^(www|m)\./, "");
37
+ let id = null;
38
+ if (host === "youtu.be") id = u.pathname.slice(1).split("/")[0];
39
+ else if (host === "youtube.com" || host === "youtube-nocookie.com") id = u.pathname === "/watch" ? u.searchParams.get("v") : /^\/(?:embed|shorts|live)\/([^/]+)/.exec(u.pathname)?.[1] ?? null;
40
+ else return null;
41
+ if (!id || !/^[\w-]{6,20}$/.test(id)) return null;
42
+ const t = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/.exec(u.searchParams.get("t") ?? u.searchParams.get("start") ?? "");
43
+ const start = t ? Number(t[1] ?? 0) * 3600 + Number(t[2] ?? 0) * 60 + Number(t[3] ?? 0) : 0;
44
+ return `https://www.youtube-nocookie.com/embed/${id}?autoplay=1&rel=0&playsinline=1${start ? `&start=${start}` : ""}`;
45
+ }
46
+
47
+ // A Vimeo video (vimeo.com/<id>, an unlisted vimeo.com/<id>/<hash>, player.vimeo.com/video/<id>?h=<hash>).
48
+ function vimeo(u) {
49
+ const host = u.hostname.replace(/^www\./, "");
50
+ let m;
51
+ if (host === "player.vimeo.com") m = /^\/video\/(\d+)\/?$/.exec(u.pathname);
52
+ else if (host === "vimeo.com") m = /^\/(?:channels\/[\w-]+\/)?(\d+)(?:\/([0-9a-f]+))?\/?$/.exec(u.pathname);
53
+ else return null;
54
+ if (!m) return null;
55
+ const hash = m[2] ?? u.searchParams.get("h");
56
+ return `https://player.vimeo.com/video/${m[1]}?autoplay=1&dnt=1${hash && /^[0-9a-f]+$/.test(hash) ? `&h=${hash}` : ""}`;
57
+ }
58
+
59
+ // A Loom recording (loom.com/share/<id> or /embed/<id>).
60
+ function loom(u) {
61
+ if (u.hostname.replace(/^www\./, "") !== "loom.com") return null;
62
+ const id = /^\/(?:share|embed)\/([0-9a-f]{16,64})\/?$/.exec(u.pathname)?.[1];
63
+ return id ? `https://www.loom.com/embed/${id}?autoplay=1&hide_owner=true&hide_share=true` : null;
64
+ }
65
+
66
+ // A Figma design, prototype, board or slides on embed.figma.com, Figma's embed host (the file must be shared to anyone
67
+ // with the link). An older /file/ link is a design; the page to open (node-id) and a prototype's start come along.
68
+ function figma(u) {
69
+ const host = u.hostname.replace(/^www\./, "");
70
+ if (host !== "figma.com" && host !== "embed.figma.com") return null;
71
+ const m = /^\/(file|design|proto|board|slides)\/([\w-]+)(\/[^/?#]*)?/.exec(u.pathname);
72
+ if (!m) return null;
73
+ const keep = new URLSearchParams();
74
+ for (const k of ["node-id", "starting-point-node-id", "page-id", "scaling", "content-scaling"]) if (u.searchParams.get(k)) keep.set(k, u.searchParams.get(k));
75
+ keep.set("embed-host", "hyperdecks");
76
+ return `https://embed.figma.com/${m[1] === "file" ? "design" : m[1]}/${m[2]}${m[3] ?? ""}?${keep}`;
77
+ }
78
+
79
+ // A Calendly scheduling page (calendly.com/<user> or /<user>/<event>), inline.
80
+ function calendly(u) {
81
+ if (u.hostname.replace(/^www\./, "") !== "calendly.com") return null;
82
+ const m = /^\/([\w.-]+)(?:\/([\w.-]+))?\/?$/.exec(u.pathname);
83
+ if (!m || ["app", "event_types", "login", "signup", "pages"].includes(m[1])) return null;
84
+ return `https://calendly.com/${m[1]}${m[2] ? `/${m[2]}` : ""}?embed_type=Inline&hide_gdpr_banner=1`;
85
+ }
86
+
87
+ export const EMBED_SOURCES = [
88
+ { id: "google-maps", name: "Google Maps", kind: "map", label: "Open map", hosts: ["google.com/maps", "maps.google.com"], embed: googleMaps, allow: "fullscreen", sandbox: SANDBOX, opaque: true },
89
+ { id: "youtube", name: "YouTube", kind: "video", label: "Play video", hosts: ["youtube.com", "youtu.be"], embed: youtube, allow: "autoplay; encrypted-media; picture-in-picture; fullscreen", sandbox: `${SANDBOX} allow-presentation` },
90
+ { id: "vimeo", name: "Vimeo", kind: "video", label: "Play video", hosts: ["vimeo.com"], embed: vimeo, allow: "autoplay; picture-in-picture; fullscreen", sandbox: `${SANDBOX} allow-presentation` },
91
+ { id: "loom", name: "Loom", kind: "video", label: "Play video", hosts: ["loom.com"], embed: loom, allow: "autoplay; fullscreen", sandbox: `${SANDBOX} allow-presentation` },
92
+ { id: "figma", name: "Figma", kind: "design", label: "Open design", hosts: ["figma.com", "embed.figma.com"], embed: figma, allow: "fullscreen; clipboard-write", sandbox: SANDBOX },
93
+ { id: "calendly", name: "Calendly", kind: "booking", label: "Book a time", hosts: ["calendly.com"], embed: calendly, allow: "", sandbox: `${SANDBOX} allow-forms allow-top-navigation-by-user-activation`, inline: false },
94
+ ];
95
+
96
+ // An https URL with no user, password or port of its own, or null.
97
+ export function parseEmbedUrl(url) {
98
+ let u;
99
+ try { u = new URL(String(url ?? "").trim()); } catch { return null; }
100
+ if (u.protocol !== "https:" || u.username || u.password || u.port) return null;
101
+ return u;
102
+ }
103
+
104
+ // What the slide does with `url`: { live: true, source, src, label, allow, sandbox } for a source on the table (src: the
105
+ // frame's URL), or { live: false, href, label, host } for any other https page (a still and a link out), or null when
106
+ // the URL is not an https link at all.
107
+ export function resolveEmbed(url) {
108
+ const u = parseEmbedUrl(url);
109
+ if (!u) return null;
110
+ for (const s of EMBED_SOURCES) {
111
+ const src = s.embed(new URL(u.href));
112
+ if (src) return { live: true, source: s.id, name: s.name, kind: s.kind, src, label: s.label, allow: s.allow, sandbox: s.sandbox, opaque: !!s.opaque, inline: s.inline !== false, href: u.href };
113
+ }
114
+ const host = u.hostname.replace(/^www\./, "");
115
+ // On a source's site but not a link it can embed (a channel, a sign-in page, a short link): named, so check can say what to change.
116
+ const site = EMBED_SOURCES.find((s) => s.hosts.some((h) => { const [name, path] = h.split(/(?=\/)/); return (host === name || host.endsWith(`.${name}`)) && (!path || u.pathname.startsWith(path)); }))
117
+ ?? (host === "maps.app.goo.gl" || host === "goo.gl" ? EMBED_SOURCES[0] : null);
118
+ return { live: false, href: u.href, host, label: "Open page", ...(site ? { site: site.name } : {}) };
119
+ }
120
+
121
+ // Where a live source plays: inside the slide everywhere (opaque), or only on the deck's own page, a shared link
122
+ // (a sandboxed page) opening it in a new tab.
123
+ export const sharedLinkNote = (resolved) =>
124
+ !resolved?.live ? null
125
+ : resolved.inline === false ? `${resolved.name} opens in a new tab from the slide's control (in a frame its cookie banner covers the page), so the slide is a still and a link`
126
+ : !resolved.opaque ? `${resolved.name} plays inside the slide on the deck's own page; on a shared link the deck runs in a sandbox where it cannot draw, so the control opens it in a new tab`
127
+ : null;
128
+
129
+ // The control's label for a slide: the author's own (data-embed-label) when given, else the source's.
130
+ export const embedLabel = (resolved, own) => (own && String(own).trim()) || resolved?.label || "Open page";
131
+
132
+ const escapeAttr = (s) => String(s).replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
133
+
134
+ // The markup for the embed slide's frame: the author's URL and the captured still. The player adds the control and,
135
+ // for a source on the table, the live frame on tap; without the player (an export, a thumbnail) the still is all.
136
+ // `mid`: { src, width, height }, the still beside a presenter on a wide screen (class still-mid); `phone`: the portrait
137
+ // still a phone shows (class still-tall). The layout picks one by width and presenter (a <picture> cannot see the presenter).
138
+ export function embedMarkup(url, still, { alt = "", width, height, id, kind, phone, mid } = {}) {
139
+ const size = width && height ? ` width="${width}" height="${height}"` : "";
140
+ // The frame takes each still's shape (--ar, and --ar-phone on a phone), so neither is cropped.
141
+ const ratio = (name, w, h) => (w && h ? `${name}: ${(w / h).toFixed(4)}` : "");
142
+ const shapes = [ratio("--ar", width, height), ratio("--ar-mid", mid?.width, mid?.height), ratio("--ar-phone", phone?.width, phone?.height)].filter(Boolean);
143
+ const style = shapes.length ? ` style="${shapes.join("; ")}"` : "";
144
+ const img = `<img class="still" src="${escapeAttr(still)}" alt="${escapeAttr(alt)}"${size}>`;
145
+ const extra = (cls, s) => (s?.src ? `<img class="still ${cls}" src="${escapeAttr(s.src)}" alt="${escapeAttr(alt)}" width="${s.width}" height="${s.height}">` : "");
146
+ const pic = `${img}${extra("still-mid", mid)}${extra("still-tall", phone)}`;
147
+ return `<div class="embed"${id ? ` id="${escapeAttr(id)}"` : ""}${kind ? ` data-kind="${escapeAttr(kind)}"` : ""}${style} data-embed="${escapeAttr(url)}">${pic}</div>`;
148
+ }
149
+
150
+ // What to use instead of a link on a source's site that cannot be embedded (check and the capture say the same).
151
+ export const embedSiteHint = (site, host) => `this ${site} link (${host}) is not one that can be embedded; use ${site === "Google Maps" ? "the full google.com/maps link of a place or a search (open a maps.app.goo.gl short link and copy the address it lands on)" : `the link to one ${site === "Calendly" ? "scheduling page" : site === "Figma" ? "file shared to anyone with the link" : "video"}`}`;
152
+
153
+ // The table as markdown, for the embeds topic.
154
+ export function embedSourcesMarkdown() {
155
+ const where = (s) => (s.inline === false ? "never: a new tab, from the still" : s.opaque ? "everywhere" : "on the deck's own page; a new tab on a shared link");
156
+ return ["| Source | Links it takes | The control says | Plays inside the slide |", "|---|---|---|---|", ...EMBED_SOURCES.map((s) => `| ${s.name} | ${s.hosts.join(", ")} | ${s.label} | ${where(s)} |`)].join("\n");
157
+ }
158
+
159
+ // ---- the still (screenshot --embed, capture_url { embed: true }) ----
160
+ // A video or a Figma file's still is the picture its own site publishes for it (oEmbed's thumbnail_url; YouTube's
161
+ // largest thumbnail): what a viewer would see before pressing play, never an error or consent page. `oembed`: the
162
+ // endpoint for a source's oEmbed answer, or null for a source whose still is a capture of its frame (a map, a booking page).
163
+ export function stillSource(resolved) {
164
+ if (!resolved?.live) return null;
165
+ const u = encodeURIComponent(resolved.href);
166
+ if (resolved.source === "youtube") {
167
+ const id = /\/embed\/([\w-]+)/.exec(resolved.src)?.[1];
168
+ return { oembed: `https://www.youtube.com/oembed?format=json&url=${u}`, images: [`https://i.ytimg.com/vi/${id}/maxresdefault.jpg`, `https://i.ytimg.com/vi/${id}/hqdefault.jpg`] };
169
+ }
170
+ if (resolved.source === "vimeo") return { oembed: `https://vimeo.com/api/oembed.json?width=1600&url=${u}` };
171
+ if (resolved.source === "loom") return { oembed: `https://www.loom.com/v1/oembed?url=${u}` };
172
+ if (resolved.source === "figma") return { oembed: `https://www.figma.com/api/oembed?url=${u}` };
173
+ return null;
174
+ }
175
+
176
+ // The stills a page or a map gets, each at the shape its frame is shown at, so none is ever cropped: a wide one for
177
+ // the slide (the embed layout's area with no presenter, 2.5:1; with the presenter the frame keeps this shape, narrower)
178
+ // and a portrait one for a phone, rendered at a phone's width so a page shows its own mobile layout. A video's poster
179
+ // is one 16:9 picture for both.
180
+ export const STILL_WIDTH = 1600;
181
+ export const STILL_HEIGHT = 640;
182
+ export const PHONE_STILL = { width: 390, height: 620, scale: 2 };
183
+ // The slide beside a presenter: the area left of the presenter's corner, 16:10 (about 920x576 at 1440x900).
184
+ export const MID_STILL = { width: 1440, height: 900 };
185
+
186
+ // Words a frame shows instead of the thing itself (an embed refused, a file not public, a video blocked): a capture
187
+ // that shows any of them is not a still, so the capture fails and says what the frame said.
188
+ export const EMBED_ERROR_TEXT = [
189
+ /must be used in an iframe/i,
190
+ /video player configuration error/i,
191
+ /error 15\d\b/i,
192
+ /video unavailable/i,
193
+ /rights issue/i,
194
+ /we can.t seem to find that/i,
195
+ /can.t find (?:that|this) page/i,
196
+ /page (?:not found|doesn.t exist|does not exist)/i,
197
+ /this calendly url is not valid/i,
198
+ /not publicly accessible/i,
199
+ /this (?:video|page|content) (?:is|isn.t) (?:private|not available|unavailable)/i,
200
+ /page not found|404 not found/i,
201
+ /sign in to (?:continue|view)|log in to (?:continue|view)/i,
202
+ ];
203
+ export const embedErrorIn = (text) => EMBED_ERROR_TEXT.find((re) => re.test(String(text ?? "")))?.source ?? null;
204
+
205
+ // Run in each frame of the capture page (serialized: no closure). Dismisses a cookie or consent banner the polite
206
+ // way (Decline or Reject first, else the only way to close it) and answers the frame's visible text and whether a
207
+ // banner is still showing, so the capture can refuse a picture with one baked in.
208
+ export function framePass() {
209
+ const words = (el) => (el.innerText || el.textContent || el.getAttribute("aria-label") || "").trim().toLowerCase();
210
+ const buttons = [...document.querySelectorAll("button, [role=button], a")].filter((b) => b.offsetParent !== null);
211
+ const banner = () => [...document.querySelectorAll("[id*=onetrust i], [class*=cookie i], [id*=cookie i], [class*=consent i], [id*=consent i], [aria-label*=cookie i]")].find((n) => n.offsetParent !== null && n.getBoundingClientRect().height > 40);
212
+ let clicked = null;
213
+ if (banner()) {
214
+ for (const want of [/^(decline|reject all|reject|decline all|only necessary|necessary only)$/, /^(i understand|got it|ok|close|accept|accept all)$/]) {
215
+ const b = buttons.find((x) => want.test(words(x)));
216
+ if (b) { b.click(); clicked = words(b); break; }
217
+ }
218
+ }
219
+ // What the frame draws besides words (a map's canvas or tiles, a picture), so a blank frame can be told from a quiet one.
220
+ const media = [...document.querySelectorAll("img, canvas, svg, video")].filter((n) => { const r = n.getBoundingClientRect(); return r.width > 40 && r.height > 40; }).length;
221
+ const title = (document.querySelector("h1")?.innerText || document.title || "").trim().slice(0, 120);
222
+ // A fixed or sticky layer over more than a quarter of the view (a fundraising or newsletter banner, a sign-up wall).
223
+ const view = innerWidth * innerHeight;
224
+ // Or one in the page's flow that names itself an appeal or a pop-up (Wikipedia's #centralNotice fundraising banner).
225
+ const appeal = /notice|donat|fundrais|newsletter|subscribe|paywall|sign-?up|modal|popup|interstitial/i;
226
+ const covers = (n) => {
227
+ const r = n.getBoundingClientRect(), w = Math.max(0, Math.min(r.right, innerWidth) - Math.max(r.left, 0)), h = Math.max(0, Math.min(r.bottom, innerHeight) - Math.max(r.top, 0));
228
+ return w * h > view / 4 && getComputedStyle(n).visibility !== "hidden" && Number(getComputedStyle(n).opacity) > 0.1;
229
+ };
230
+ const overlay = [...document.querySelectorAll("body *")].some((n) => {
231
+ const p = getComputedStyle(n).position;
232
+ if (p === "fixed" || p === "sticky") return covers(n);
233
+ return appeal.test(`${n.id} ${typeof n.className === "string" ? n.className : ""}`) && covers(n);
234
+ });
235
+ return { text: (document.body?.innerText || "").slice(0, 4000), clicked, banner: !!banner() && !clicked, media, title, top: window === window.top, overlay };
236
+ }
237
+
238
+ // The page a capture loads for a source shown in a frame: the frame's URL inside an iframe, as a slide shows it (a
239
+ // Google Maps embed refuses to draw as a page of its own).
240
+ export const framePage = (src, { width = STILL_WIDTH, height = STILL_HEIGHT } = {}) =>
241
+ `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html,body{margin:0;height:100%;overflow:hidden;background:#fff}iframe{display:block;border:0;width:${width}px;height:${height}px}</style><iframe src="${String(src).replace(/&/g, "&amp;").replace(/"/g, "&quot;")}" allow="fullscreen" referrerpolicy="strict-origin-when-cross-origin"></iframe>`;
242
+
243
+ // Whether `url` is the frame URL the table builds for a live source (the render route wraps such a URL in framePage).
244
+ export function isEmbedFrameUrl(url) {
245
+ for (const s of EMBED_SOURCES) {
246
+ let u;
247
+ try { u = new URL(url); } catch { return false; }
248
+ if (u.protocol !== "https:") return false;
249
+ if (s.embed(new URL(u.href)) === u.href && /(output=embed|embed_type=Inline|embed\.figma\.com|\/embed\/|player\.vimeo\.com)/.test(u.href)) return true;
250
+ }
251
+ return false;
252
+ }
@@ -0,0 +1,36 @@
1
+ // hyperdecks guide embeds (deck_guide topic embeds): when a live map, video, design or booking page earns a slide,
2
+ // and how to add one with the embed layout. The sources come from embedSources.mjs, so the list cannot drift.
3
+ import { embedSourcesMarkdown } from "./embedSources.mjs";
4
+
5
+ export function embedsGuide(surface) {
6
+ const cli = surface === "cli";
7
+ const capture = cli ? "`hyperdecks screenshot <url> --embed --slug <deck> --id <slide-id>-embed`" : "`capture_url { url, embed: true, slug, id: \"<slide-id>-embed\" }`";
8
+ const scaffold = cli ? "`hyperdecks deck new <slug> \"<title>\" --narrated --layouts …,embed,…`" : '`new_deck { …, layouts: [ …, "embed", … ] }`';
9
+ const detail = cli ? "`hyperdecks guide layouts embed`" : '`deck_guide { topic: "layouts", layouts: ["embed"] }`';
10
+ return [
11
+ "# Embeds: a live map, video, design or booking page on a slide",
12
+ "",
13
+ "An embed slide shows a captured still of the page with one control named for it (Open map, Play video, Open design, Book a time). Nothing loads from the other site until the viewer taps it; then the live frame opens over the still, the narration pauses and the deck stops advancing until they close it (the close control, or Escape). Video and PDF exports, thumbnails and link previews show the still.",
14
+ "",
15
+ "## When an embed earns a slide",
16
+ "",
17
+ "Only when the viewer will **use** it, not just look at it: drag a map of the venues, pick a slot on the closer's booking page, click through a Figma prototype, play a video that lives on YouTube. If they would only look, a picture is better: a screenshot, a recording (video-full), or a still with no control. One or two embeds a deck at most; the closer's booking page is the one that most often earns it.",
18
+ "",
19
+ "## The sources",
20
+ "",
21
+ embedSourcesMarkdown(),
22
+ "",
23
+ "Use the page's ordinary share link (a Google Maps place or search link, not a maps.app.goo.gl short link; a Figma file shared to anyone with the link; a public Calendly page). Any other https link becomes a still with a link that opens it in a new tab. On a shared link the deck runs in a security sandbox, and today only Google Maps can draw inside it: the others open their page in a new tab from the same tap. Calendly always opens in a new tab (in a frame its cookie banner covers the booking page). To see what a recipient gets, open the QA link `release --qa` prints: it is served exactly as a shared link is. Never write an `<iframe>` yourself: check warns on one, because it loads for every viewer on open, keeps the narration going and shows empty in exports.",
24
+ "",
25
+ "## How to add one",
26
+ "",
27
+ `1. Put an \`embed\` slide in the deck: ${scaffold}. Read its detail first: ${detail}.`,
28
+ `2. Capture the still: ${capture}. For a map or a page it captures two stills, each at the shape its frame is shown at (a wide one for the slide, a portrait one at a phone's width), so neither is cropped; for a video it saves the poster its site publishes. It refuses an error page, a blank page or a page under a banner, and returns the frame's markup: paste that over the layout's placeholder frame. **Look at the saved stills before you use them**: no check catches every banner or pop-up. Give the still an alt that says what it shows.`,
29
+ "3. Name the control for what the viewer will do when the source's own words do not fit: `data-embed-label=\"See the three venues\"` on the frame.",
30
+ "4. In script.md, say what to do before the slide asks it (\"Tap the map to look around; I'll wait\"). The narration pauses when they open it and goes on when they close it.",
31
+ "",
32
+ "Close (top right of the open frame) always closes it. Escape does too while the keyboard is on the deck; once the viewer clicks inside the other site's page, its keys are that page's, and Close is the way out.",
33
+ "",
34
+ "A silent deck and a narrated deck both work: on a silent deck the control is the same and nothing advances while the frame is open. On a phone the open frame takes the whole card and has its own close control, so the deck can still be swiped once it is closed.",
35
+ ].join("\n");
36
+ }
@@ -324,7 +324,8 @@ export const HEAD_READY_MS = 30000;
324
324
  // SDK's word), then draws each one's current frame (a step of 0). A page
325
325
  // without stepped heads (an older bundle, no head) passes at once. A head that
326
326
  // is not ready in `ms` fails the export with a plain message (as would a
327
- // rejected ready, though the SDK's settles even on a failed load).
327
+ // rejected ready; the player's registry lists a failed load instead, see
328
+ // headFailureWarnings).
328
329
  export async function waitForHeads(page, ms = HEAD_READY_MS, { draw = true } = {}) {
329
330
  const said = await within(page.evaluate(async (draw) => {
330
331
  const heads = window.__hdExportHeads;
@@ -341,6 +342,20 @@ export async function waitForHeads(page, ms = HEAD_READY_MS, { draw = true } = {
341
342
  return said.count;
342
343
  }
343
344
 
345
+ // The page's heads whose load failed, as export warnings: a bundle with
346
+ // Minimoji PR 358 rejects a stepped head's ready with what failed, and the
347
+ // player's registry lists it (stepped-heads.js failures) instead of failing
348
+ // the export. The presenter's own head falls back in the player and is warned
349
+ // about through the export log (state.presenter). [] for an older player or bundle.
350
+ // A check that could not run is a warning too, never a silent "all loaded".
351
+ export async function headFailureWarnings(page, ms = 5000) {
352
+ let list;
353
+ try { list = await within(page.evaluate(() => window.__hdExportHeads?.failures ?? []), ms, null); }
354
+ catch (e) { return [`could not check whether every head loaded (${String(e?.message ?? e).split('\n')[0]}); a head may be missing or incomplete in the video`]; }
355
+ if (list === null) return [`could not check whether every head loaded (the page did not answer within ${ms / 1000}s); a head may be missing or incomplete in the video`];
356
+ return (Array.isArray(list) ? list : []).map((f) => `${f.label} did not fully load (${f.why}); it may be missing or incomplete in the video`);
357
+ }
358
+
344
359
  // Freezes the page clock once every stepped head is ready: frame 0 is the deck
345
360
  // as it starts, with its heads drawn. Returns the clock's epoch ms at freeze.
346
361
  export async function freezeWhenHeadsReady(page, ms = HEAD_READY_MS) {
@@ -663,6 +678,7 @@ export async function recordVideo(config, { log = () => {}, chromium: injected,
663
678
  const worst = drift.reduce((a, d) => (Math.abs(d.drift) > Math.abs(a.drift) ? d : a), { drift: 0 });
664
679
  if (Math.abs(worst.drift) > 2) warnings.push(`the player ran up to ${worst.drift.toFixed(1)}s off the manifest's timeline (by ${worst.id}: clip loads, transitions); each clip's audio is placed where it really started, so the voice stays in sync`);
665
680
  const render = { frames, seconds: wall };
681
+ warnings.push(...await headFailureWarnings(page));
666
682
 
667
683
  if (endCard) {
668
684
  phase = 'end card';
@@ -809,11 +825,12 @@ const mb = (n) => `${(n / 1e6).toFixed(1)} MB`;
809
825
  export async function exportVideo(arg, opts = {}, { log = (l) => process.stderr.write(`${l}\n`), print = (l) => console.log(l), cwd = process.cwd(), deps = {} } = {}) {
810
826
  const o = videoOptions(opts);
811
827
  const { existsSync, readFileSync } = await import('node:fs');
812
- const { resolve, join: joinPath, basename } = await import('node:path');
828
+ const { resolve, join: joinPath } = await import('node:path');
829
+ const { deckSlug } = await import('./deckSlug.mjs');
813
830
  const ops = deps.ops ?? await import('./ops.mjs');
814
831
  const local = [resolve(cwd, arg), joinPath(cwd, 'decks', arg)].find((d) => existsSync(joinPath(d, 'index.html')));
815
832
  // --upload files the MP4 under a deck you own: checked before minutes of recording.
816
- if (o.upload) await ops.ownedDeck(opts, local ? (opts.slug || basename(local)) : arg);
833
+ if (o.upload) await ops.ownedDeck(opts, local ? deckSlug(local, opts) : arg);
817
834
  let source;
818
835
  if (local) {
819
836
  const { startPlay } = deps.play ?? await import('./play.mjs');
package/src/files.mjs CHANGED
@@ -3,6 +3,7 @@
3
3
  // bundler copies next to the route and the CLI resolves next to this file. A
4
4
  // path that is not here cannot be read, so nothing outside the package is.
5
5
  import { readFileSync } from "node:fs";
6
+ import { gunzipSync } from "node:zlib";
6
7
 
7
8
  const FILES = {
8
9
  "templates/narrated-deck.html": () => new URL("../templates/narrated-deck.html", import.meta.url),
@@ -26,11 +27,38 @@ const FILES = {
26
27
  "templates/layouts/quote.html": () => new URL("../templates/layouts/quote.html", import.meta.url),
27
28
  "templates/layouts/team.html": () => new URL("../templates/layouts/team.html", import.meta.url),
28
29
  "templates/layouts/timeline.html": () => new URL("../templates/layouts/timeline.html", import.meta.url),
30
+ "templates/layouts/phone-stage.html": () => new URL("../templates/layouts/phone-stage.html", import.meta.url),
31
+ "templates/layouts/tap-through.html": () => new URL("../templates/layouts/tap-through.html", import.meta.url),
32
+ "templates/layouts/screens.html": () => new URL("../templates/layouts/screens.html", import.meta.url),
33
+ "templates/layouts/zoom.html": () => new URL("../templates/layouts/zoom.html", import.meta.url),
34
+ "templates/layouts/video-full.html": () => new URL("../templates/layouts/video-full.html", import.meta.url),
35
+ "templates/layouts/video-beats.html": () => new URL("../templates/layouts/video-beats.html", import.meta.url),
36
+ "templates/layouts/picture-full.html": () => new URL("../templates/layouts/picture-full.html", import.meta.url),
37
+ "templates/layouts/wall.html": () => new URL("../templates/layouts/wall.html", import.meta.url),
38
+ "templates/layouts/portrait.html": () => new URL("../templates/layouts/portrait.html", import.meta.url),
39
+ "templates/layouts/sentence.html": () => new URL("../templates/layouts/sentence.html", import.meta.url),
40
+ "templates/layouts/strike.html": () => new URL("../templates/layouts/strike.html", import.meta.url),
41
+ "templates/layouts/spotlight.html": () => new URL("../templates/layouts/spotlight.html", import.meta.url),
42
+ "templates/layouts/funnel.html": () => new URL("../templates/layouts/funnel.html", import.meta.url),
43
+ "templates/layouts/scorecard.html": () => new URL("../templates/layouts/scorecard.html", import.meta.url),
44
+ "templates/layouts/bento.html": () => new URL("../templates/layouts/bento.html", import.meta.url),
45
+ "templates/layouts/two-by-two.html": () => new URL("../templates/layouts/two-by-two.html", import.meta.url),
46
+ "templates/layouts/staircase.html": () => new URL("../templates/layouts/staircase.html", import.meta.url),
47
+ "templates/layouts/rail.html": () => new URL("../templates/layouts/rail.html", import.meta.url),
48
+ "templates/layouts/loop.html": () => new URL("../templates/layouts/loop.html", import.meta.url),
49
+ "templates/layouts/lanes.html": () => new URL("../templates/layouts/lanes.html", import.meta.url),
50
+ "templates/layouts/two-bars.html": () => new URL("../templates/layouts/two-bars.html", import.meta.url),
51
+ "templates/layouts/stack.html": () => new URL("../templates/layouts/stack.html", import.meta.url),
52
+ "templates/layouts/embed.html": () => new URL("../templates/layouts/embed.html", import.meta.url),
29
53
  "templates/icons/lucide.json": () => new URL("../templates/icons/lucide.json", import.meta.url),
54
+ "templates/icons/phosphor.json.gz": () => new URL("../templates/icons/phosphor.json.gz", import.meta.url),
55
+ "templates/icons/tabler.json.gz": () => new URL("../templates/icons/tabler.json.gz", import.meta.url),
56
+ "templates/icons/material.json.gz": () => new URL("../templates/icons/material.json.gz", import.meta.url),
30
57
  "templates/first-deck/self.json": () => new URL("../templates/first-deck/self.json", import.meta.url),
31
58
  "templates/first-deck/character.json": () => new URL("../templates/first-deck/character.json", import.meta.url),
32
59
  "skills/hyperdecks/SKILL.md": () => new URL("../skills/hyperdecks/SKILL.md", import.meta.url),
33
60
  "skills/hyperdecks/chat.md": () => new URL("../skills/hyperdecks/chat.md", import.meta.url),
61
+ "skills/hyperdecks/terminal.md": () => new URL("../skills/hyperdecks/terminal.md", import.meta.url),
34
62
  };
35
63
 
36
64
  const cache = new Map();
@@ -42,4 +70,12 @@ export function packageText(path) {
42
70
  return cache.get(path);
43
71
  }
44
72
 
73
+ // A packaged gzipped file (the larger icon sets), read and unzipped as text.
74
+ export function packageGzipText(path) {
75
+ const url = FILES[path];
76
+ if (!url || !path.endsWith(".gz")) throw new Error(`no packaged gzip file ${path}`);
77
+ if (!cache.has(path)) cache.set(path, gunzipSync(readFileSync(url())).toString("utf8"));
78
+ return cache.get(path);
79
+ }
80
+
45
81
  export const PACKAGE_FILES = Object.keys(FILES);
package/src/guide.mjs CHANGED
@@ -1,14 +1,23 @@
1
1
  // hyperdecks guide [topic]
2
2
  //
3
3
  // The skill, served in sections, for agents that cannot install it (chat apps on
4
- // the hosted MCP call deck_guide). `workflow` is chat.md; the other topics are
4
+ // the hosted MCP call deck_guide). `workflow` is chat.md on the hosted MCP and
5
+ // terminal.md for the CLI (surface "cli"); the other topics are
5
6
  // the SKILL.md sections marked <!-- topic: … -->, and `layouts` is built from
6
- // each layout file's leading comment.
7
+ // each layout file's leading comment (an index, or named layouts' detail).
7
8
  import { packageText } from "./files.mjs";
8
- import { LAYOUTS, readLayout } from "./layouts.mjs";
9
+ import { LAYOUTS, parseLayouts, readLayout } from "./layouts.mjs";
9
10
  import { fontPairingsMarkdown } from "./brand.mjs";
11
+ import { themesMarkdown } from "./themes.mjs";
12
+ import { photosGuide } from "./photosGuide.mjs";
13
+ import { picturesGuide } from "./picturesGuide.mjs";
14
+ import { embedsGuide } from "./embedsGuide.mjs";
15
+ import { ICON_SLOTS } from "./iconSlots.mjs";
16
+ import { FLIPPABLE, routesMarkdown, suggestLayouts } from "./layoutRoutes.mjs";
10
17
 
11
- export const GUIDE_TOPICS = ["workflow", "format", "script", "scripts", "design", "look", "layouts", "presenter", "transitions", "check"];
18
+ export const GUIDE_TOPICS = ["workflow", "format", "script", "scripts", "design", "look", "themes", "layouts", "photos", "pictures", "embeds", "presenter", "transitions", "check"];
19
+ // Other names a topic answers to: gifs is the photos topic, icons the pictures one.
20
+ const TOPIC_ALIASES = { gifs: "photos", icons: "pictures", embed: "embeds", maps: "embeds" };
12
21
  const CLI_NOTE = "_Written for the CLI. On the hosted MCP there is no folder: use the tool names in `deck_guide` (workflow), hosted URLs for every file, and write_deck_source for edits._\n\n";
13
22
 
14
23
  // One <!-- topic: name --> section of SKILL.md: its heading and body, up to the
@@ -26,21 +35,82 @@ export function skillSection(skill, topic) {
26
35
  return out.join("\n").trim();
27
36
  }
28
37
 
29
- function layoutsTopic() {
38
+ // The layouts topic is an index: one line a layout (its name, what it says and
39
+ // needs, a short brief), small enough for the whole library in one read. The
40
+ // detail (what to put in, slots, cues, without a presenter) is read by name.
41
+ function layoutsIndex(surface) {
30
42
  const rows = LAYOUTS.map((name) => {
31
43
  const { meta } = readLayout(name);
32
- return [`### ${name}`, meta.summary, meta.use && `Use: ${meta.use}`, meta.slot && `Slots: ${meta.slot}`, meta.nopresenter && `Without a presenter: ${meta.nopresenter}`, meta.cues && `Cues: ${meta.cues}`].filter(Boolean).join("\n");
44
+ const tags = [meta.says, meta.needs].filter(Boolean).join(" · ");
45
+ return `- \`${name}\`${tags ? ` (${tags})` : ""}: ${meta.brief ?? meta.summary}`;
33
46
  });
34
- return `# Layouts\n\nPass any of these, in order, as new_deck's \`layouts\` (repeat one for more of the same: number, number gives slides number and number-2).\n\n${rows.join("\n\n")}`;
47
+ const suggest = surface === "cli" ? '`hyperdecks layouts suggest "<what the slide says>"`' : '`deck_guide { topic: "layouts", suggest: "<what the slide says>" }`';
48
+ return `# Layouts\n\n## Pick the shape from what the slide says\n\nName what each slide carries, then take a shape from its row; ${suggest} does the same from a slide's words. Vary the shapes: one layout on more than about a third of the slides, or three in a row, reads as the same slide again (check warns). The side-panel layouts (${FLIPPABLE.map((n) => `\`${n}\``).join(", ")}) also flip: \`data-flip\` on the section mirrors one, its panel and the presenter to the other side. Alternate sides between neighbours: the same layout twice in a row with its panel on the same side reads as the same slide twice (check warns; ${surface === "cli" ? "`deck new`" : "new_deck"} flips a repeated one for you). Where a row offers a picture layout and a word shape, take the picture layout when you have the real screenshot, recording or photo; the word shape is for when you do not. For a list of what is allowed and what is not, use compare: put the allowed items in the right-hand column, the highlighted one, and label both columns. For a single rule and the right way to do it, use strike.\n\n${routesMarkdown()}\n\n## Every layout\n\nPass any of these, in order, as new_deck's \`layouts\` (repeat one for more of the same: number, number gives slides number and number-2). Read a layout's detail (what to put in, slots, cues, without a presenter) before you fill it: \`deck_guide { topic: "layouts", layouts: ["zoom"] }\` (CLI: \`hyperdecks guide layouts zoom\`); several names in one call is fine.\n\n${rows.join("\n")}`;
35
49
  }
36
50
 
37
- // { topic, topics, text } for one topic; no topic gives the workflow.
38
- export function deckGuide(topic = "workflow") {
39
- const t = String(topic || "workflow").toLowerCase();
51
+ // The built-in themes, each with what it is for, and how an agent picks one.
52
+ function themesGuide(surface) {
53
+ const pick = surface === "cli" ? "`hyperdecks deck new <slug> \"<title>\" --narrated --layouts … --theme <name>`" : "`new_deck { …, theme: \"<name>\" }`";
54
+ const change = surface === "cli" ? "`hyperdecks theme set <deck-dir> <name>` (it keeps the deck's words and swaps only the look; a released deck changes when it is released again)" : "make the deck again with new_deck and the other theme, or ask the person to run `hyperdecks theme set`";
55
+ return [
56
+ "# Themes",
57
+ "",
58
+ `A theme is a whole look: outlines, corners, shadows, tilt, title style and case, the grounds the slides alternate, a texture, and how photos and charts are drawn. Mark each picture by what it is, whatever its frame: a photo or illustration is \`pic\` (\`art\` on a cover), a capture of a screen or a recording is \`shot\` (\`clip\`); screenshots and recordings are never recoloured. \`data-as-is\` on a photo keeps its own colours (an illustration whose colour matters). A photo can carry a caption: \`<figure class='mount' data-caption='Where, when'><img class='pic' …></figure>\`. A named theme comes in its own colours and fonts, with no brand logo; the saved brand goes on only with no theme named, or when asked (\`${surface === "cli" ? "--brand" : "brand: true"}\`), and then recolours the theme (its colours and logo, and its fonts only if it set them) while the shape and title style stay the theme's.`,
59
+ "",
60
+ themesMarkdown(),
61
+ "",
62
+ `Pick one with ${pick}. When the person names none, pick one from the subject and the audience (a fund's update: quiet; a founder's essay: longform; a dev tool: blueprint; a launch: loud) and say which you picked and why in one line, so they can ask for another. With no theme the deck is in house.`,
63
+ "",
64
+ `To change a deck's theme: ${change}.`,
65
+ ].join("\n");
66
+ }
67
+
68
+ // A layout's markup as a deck gets it (deck new --layouts), for the guide: its own <section>, comments out and each
69
+ // inline SVG (an icon, a stand-in) shortened, so an agent sees the classes and structure it writes. Generated from the
70
+ // layout file, so it cannot drift from the scaffold.
71
+ export function layoutMarkup(section) {
72
+ // An <svg>'s opening tag stays whole (its id, role and aria-* are what cues and readers use); only its drawing is cut.
73
+ return section.replace(/<!--[\s\S]*?-->\s*/g, "").replace(/(<svg\b[^>]*[^/]>)[\s\S]*?<\/svg>/g, "$1…</svg>").replace(/\n\s*\n/g, "\n").trim();
74
+ }
75
+
76
+ // The full entry of each named layout (aliases work), in the order asked.
77
+ function layoutsDetail(names) {
78
+ const rows = parseLayouts(names.join(",")).filter((n, i, all) => all.indexOf(n) === i).map((name) => {
79
+ const { meta, section } = readLayout(name);
80
+ return [`### ${name}`, meta.summary, meta.says && `Says: ${meta.says}`, meta.needs && `Needs: ${meta.needs}`, meta.use && `Use: ${meta.use}`, meta.slot && `Slots: ${meta.slot}`, meta.flip && `Flip: ${meta.flip}`, ICON_SLOTS[name] && `Icon slot (optional): ${ICON_SLOTS[name].where}; \`hyperdecks icons search <word> --for ${name}\` (search_icons { query, for: "${name}" }) gives the svg. Use one where it helps the reader find or remember an item; leave it out where the words carry it (deck_guide topic pictures).`, meta.nopresenter && `Without a presenter: ${meta.nopresenter}`, meta.cues && `Cues: ${meta.cues}`, `Markup (ids start with the slide's id; __ID__ in the scaffold):\n\n\`\`\`html\n${layoutMarkup(section)}\n\`\`\``].filter(Boolean).join("\n");
81
+ });
82
+ return `# Layouts: detail\n\n${rows.join("\n\n")}`;
83
+ }
84
+
85
+ // Two or three layouts for what one slide says, from the routing table's keywords (no model call).
86
+ export function suggestText(says, surface) {
87
+ const found = suggestLayouts(says);
88
+ const detail = surface === "cli" ? "`hyperdecks guide layouts <name>`" : '`deck_guide { topic: "layouts", layouts: ["<name>"] }`';
89
+ if (!found.length) return `# Layouts for "${says}"\n\nNo row of the table matched these words. Name what the slide carries (a process, a cycle, who does what, one claim, a choice, status, numbers, a person, the product…) and read the table in the layouts topic.`;
90
+ return `# Layouts for "${says}"\n\n${found.map((s) => `- \`${s.layout}\`: ${s.kind} (${s.why}); matched ${s.matched.map((w) => `"${w}"`).join(", ")}`).join("\n")}\n\nFirst one first. These come from keywords, so check the fit; read one's detail before you fill it: ${detail}.${found.some((s) => FLIPPABLE.includes(s.layout)) ? ` If the slide before this one uses the same side-panel layout (${FLIPPABLE.join(", ")}), put \`data-flip\` on this one so the two alternate sides.` : ""}`;
91
+ }
92
+
93
+ // { topic, topics, text } for one topic; no topic gives the workflow. `layouts`
94
+ // (names, with topic layouts) gives those layouts' detail instead of the index;
95
+ // `suggest` (what a slide says) gives the layouts that fit it.
96
+ export function deckGuide(topic, { layouts, surface, suggest } = {}) {
97
+ const names = [layouts ?? []].flat().flatMap((n) => String(n).split(",")).map((n) => n.trim()).filter(Boolean);
98
+ const says = String(suggest ?? "").trim();
99
+ // Names or a suggest alone (no topic) mean the layouts topic.
100
+ const asked = String(topic || (names.length || says ? "layouts" : "workflow")).toLowerCase();
101
+ const t = TOPIC_ALIASES[asked] ?? asked;
40
102
  if (!GUIDE_TOPICS.includes(t)) throw new Error(`unknown topic "${topic}": pick one of ${GUIDE_TOPICS.join(", ")}`);
103
+ if (names.length && t !== "layouts") throw new Error(`layout names go with the layouts topic, not ${t}`);
104
+ if (says && t !== "layouts") throw new Error(`suggest goes with the layouts topic, not ${t}`);
105
+ if (says && names.length) throw new Error("pass layout names or suggest, not both");
106
+ if (says) return { topic: t, topics: GUIDE_TOPICS, text: suggestText(says, surface), suggestions: suggestLayouts(says) };
41
107
  let text;
42
- if (t === "workflow") text = packageText("skills/hyperdecks/chat.md");
43
- else if (t === "layouts") text = layoutsTopic();
108
+ if (t === "workflow") text = packageText(surface === "cli" ? "skills/hyperdecks/terminal.md" : "skills/hyperdecks/chat.md");
109
+ else if (t === "themes") text = themesGuide(surface);
110
+ else if (t === "photos") text = photosGuide(surface);
111
+ else if (t === "pictures") text = picturesGuide(surface);
112
+ else if (t === "embeds") text = embedsGuide(surface);
113
+ else if (t === "layouts") text = names.length ? layoutsDetail(names) : layoutsIndex(surface);
44
114
  else {
45
115
  const section = skillSection(packageText("skills/hyperdecks/SKILL.md"), t);
46
116
  if (!section) throw new Error(`SKILL.md has no <!-- topic: ${t} --> section`);
@@ -50,8 +120,18 @@ export function deckGuide(topic = "workflow") {
50
120
  return { topic: t, topics: GUIDE_TOPICS, text };
51
121
  }
52
122
 
123
+ // hyperdecks guide layouts zoom wall (or zoom,wall): those layouts' detail.
53
124
  export async function guide(pos, opts = {}, { log = (line) => console.log(line) } = {}) {
54
- const out = deckGuide(pos[0]);
125
+ const out = deckGuide(pos[0], { layouts: pos.slice(1), surface: "cli" });
126
+ if (!opts.json) log(out.text);
127
+ return out;
128
+ }
129
+
130
+ // hyperdecks layouts suggest "<what the slide says>": two or three layouts that fit it.
131
+ export async function layoutsSuggest(words, opts = {}, { log = (line) => console.log(line) } = {}) {
132
+ const says = words.join(" ").trim();
133
+ if (!says) throw new Error('usage: layouts suggest "<what the slide says>" [--json]');
134
+ const out = deckGuide("layouts", { suggest: says, surface: "cli" });
55
135
  if (!opts.json) log(out.text);
56
136
  return out;
57
137
  }