@hypersocial/decks-cli 0.9.29 → 0.9.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/commands.mjs CHANGED
@@ -15,8 +15,9 @@ import {
15
15
  target,
16
16
  VERSION,
17
17
  } from "./runtime.mjs";
18
- import { fetchVersionInfo, updatePreflight } from "./update.mjs";
18
+ import { compareVersions, dueToday, fetchVersionInfo, onceADay, quietEnv, UPGRADE, updatePreflight } from "./update.mjs";
19
19
  import { refreshSkillCopies } from "./skillFreshness.mjs";
20
+ import { skillCopies, skillNotices, skillSummary } from "./notices.mjs";
20
21
  import * as ops from "./ops.mjs";
21
22
  import { FOR_HINT } from "./stockMedia.mjs";
22
23
  import { MAX_TAGS, normalizeTags } from "./tags.mjs";
@@ -48,6 +49,15 @@ async function whoamiCmd(opts) {
48
49
  return null;
49
50
  });
50
51
  const [who, cli] = await Promise.all([signedIn, cliVersions(opts)]);
52
+ // The skill copies agents read on this machine, and their versions (local).
53
+ let copies = null;
54
+ let skillError = null;
55
+ try {
56
+ copies = skillCopies({ agents: agentTable() });
57
+ } catch (e) {
58
+ skillError = e?.message ?? String(e);
59
+ }
60
+ const skill = copies ? { copies: copies.map(({ agent, path, version, target, unreadable }) => ({ agent, path, version, ...(target ? { linkTo: target } : {}), ...(unreadable ? { unreadable } : {}) })) } : { error: skillError };
51
61
  // Early access: joins the waitlist on first use. A backend without it says
52
62
  // nothing; any other failure shows as access unknown, with why.
53
63
  let accessError = null;
@@ -59,14 +69,20 @@ async function whoamiCmd(opts) {
59
69
  const accessFields = access
60
70
  ? { access: access.status === "approved" ? "approved" : "waitlisted", ...(access.status === "approved" ? {} : { accessNote: ops.WAITLIST_NOTE }) }
61
71
  : accessError ? { access: "unknown", accessError } : {};
62
- console.log(JSON.stringify({ ...(who || {}), ...accessFields, deployment: t.name, convexUrl: t.convexUrl, cli }, null, 2));
72
+ console.log(JSON.stringify({ ...(who || {}), ...accessFields, deployment: t.name, convexUrl: t.convexUrl, cli, skill }, null, 2));
63
73
  if (signedOut) throw signedOut;
64
74
  return;
65
75
  }
66
- const cliLine = `cli: ${cli.version}${cli.latest ? ` (latest ${cli.latest}, minimum ${cli.minimum})` : " (could not reach the server for the latest)"}`;
76
+ const behind = cli.latest && compareVersions(cli.latest, cli.version) > 0 ? `; update: ${UPGRADE}` : "";
77
+ const cliLine = `cli: ${cli.version}${cli.latest ? ` (latest ${cli.latest}, minimum ${cli.minimum}${behind})` : " (could not reach the server for the latest)"}`;
78
+ const skillLine = `skill: ${copies ? skillSummary(copies) : `unknown (${skillError})`}`;
79
+ // What to do about a copy that is behind, a link or unreadable (a newer copy shows in the versions).
80
+ const skillHints = (copies ? skillNotices(VERSION, copies) : []).filter((n) => n.kind !== "cli-behind-skill").map((n) => ` ${n.message}`);
67
81
  if (!who) {
68
82
  console.log(`not authenticated (${t.name})`);
69
83
  console.log(cliLine);
84
+ console.log(skillLine);
85
+ for (const h of skillHints) console.log(h);
70
86
  if (signedOut) throw signedOut;
71
87
  return;
72
88
  }
@@ -77,6 +93,8 @@ async function whoamiCmd(opts) {
77
93
  else if (accessError) console.log(`access: unknown (${accessError})`);
78
94
  console.log(`deployment: ${t.name} (${t.convexUrl})`);
79
95
  console.log(cliLine);
96
+ console.log(skillLine);
97
+ for (const h of skillHints) console.log(h);
80
98
  }
81
99
 
82
100
  // A flag that takes a value but was given none (`--tag` last, or followed by
@@ -741,6 +759,8 @@ commands:
741
759
  deck view <slug> [slides|scroll|default] [--toggle on|off] [--pace auto|slide|step|default] [--ai-readable on|off]
742
760
  how the deck opens in the player (default: as its HTML says, data-view or slides) and
743
761
  whether viewers get the slides/scroll toggle (on by default). Every link, next load; no re-release.
762
+ --pace: auto (Auto-play) plays by itself, slide after slide; slide (Whole slide): Next goes to
763
+ the next slide; step (Step by step): Next shows a slide part by part.
744
764
  --ai-readable: whether each link + /md serves the deck as markdown for AI assistants (on by default).
745
765
  deck new <slug> "<title>" --narrated [--layouts hero,product,number,closer] [--presenter-style stage|bubble|glass|corner] [--presenter <narrator>] [--theme <name>] [--icons "<set> [weight]"] [--brand|--no-brand] [--dir <path>] [--tag <tag,...>]
746
766
  --theme: a built-in theme (hyperdecks theme list; default house). A named theme (house too) keeps
@@ -784,9 +804,10 @@ ${layoutList()}
784
804
  recipient archive|unarchive
785
805
  import <html-or-zip-or-url> --slug <slug> [--title title] [--status draft|live]
786
806
  import-design <project-id> --serve-token <token> --entry <file.html> --slug <slug>
787
- skill install [--agent codex,claude-code] [--all-agents]
807
+ skill install [--agent codex,claude-code] [--all-agents] [--force]
788
808
  skills install [--agent codex,claude-code] [--all-agents]
789
- default: every agent found in your home directory (else codex, claude-code)
809
+ default: every agent found in your home directory (else codex, claude-code);
810
+ refuses to replace a newer skill (from a newer CLI) unless --force
790
811
  activity [--deck <slug>] [--limit <n>] [--json]
791
812
  engagement <recipient|token> [--deck <slug>] [--json]
792
813
  what one recipient watched per deck: narration heard, replays, drop-off, visits
@@ -1723,29 +1744,66 @@ export async function runCli(argv = process.argv.slice(2)) {
1723
1744
  // touching the network or ~/.hyperdecks.
1724
1745
  // 1. refresh this machine's stale hyperdecks skill copies (local, no network);
1725
1746
  // 2. below the server's minimum, refuse the commands that make or ship a deck;
1726
- // 3. after the command, print the once-a-day "newer version is out" line.
1747
+ // 3. after the command, print at most one line from these checks (the CLI is
1748
+ // behind npm or its skill, once a day; a copy refreshed or left alone),
1749
+ // and with --json put every notice in the result's `notices`.
1750
+ // The opt-out (HYPERDECKS_NO_UPDATE_CHECK=1|true) and CI skip 1, the request
1751
+ // and the line; a minimum already on disk still holds.
1727
1752
  // Only an installed copy (global or an npx cache, both under node_modules) does
1728
1753
  // this: run from a source checkout it would push a work-in-progress skill into
1729
1754
  // the developer's agents, and the repo's tests spawn the bin.
1730
1755
  export const isInstalledCopy = (dir = PACKAGED_SKILLS_DIR) => /[\\/]node_modules[\\/]/.test(dir);
1731
1756
 
1732
- export async function main(argv = process.argv.slice(2), { env = process.env, home, fetchImpl = fetch, stateFile, now, log, installed = isInstalledCopy() } = {}) {
1733
- if (!installed) return runCli(argv);
1757
+ // How long a --json result waits for the version check's answer before it
1758
+ // goes out with the answer already on disk instead.
1759
+ export const NOTICE_WAIT_MS = 250;
1760
+
1761
+ // Which housekeeping line wins when there are several (lower first): the one
1762
+ // thing worth saying after a command.
1763
+ function refreshRank(line) {
1764
+ if (/^↻ replaced /.test(line)) return 0; // names the backup of a copy it replaced
1765
+ if (/^⚠ could not refresh |freshness check failed/.test(line)) return 3;
1766
+ if (/edited by hand|isn't a version/.test(line)) return 4;
1767
+ if (/^↻ refreshed /.test(line)) return 5;
1768
+ return 6; // a link it left alone
1769
+ }
1770
+
1771
+ export async function main(argv = process.argv.slice(2), { env = process.env, home, fetchImpl = fetch, stateFile, now, log, installed = isInstalledCopy(), run = runCli, preflight = updatePreflight } = {}) {
1772
+ if (!installed) return run(argv);
1734
1773
  let parsed;
1735
1774
  try {
1736
1775
  parsed = parse(argv);
1737
1776
  } catch {
1738
- return runCli(argv);
1777
+ return run(argv);
1739
1778
  }
1740
1779
  const { pos, opts } = parsed;
1741
- if (opts.version || opts.help || pos.length === 0) return runCli(argv);
1780
+ if (opts.version || opts.help || pos.length === 0) return run(argv);
1742
1781
 
1743
- try {
1744
- refreshSkillCopies({ version: VERSION, bundledDir: join(PACKAGED_SKILLS_DIR, "hyperdecks"), skillsDirs: agentTable({ home, env }).map((a) => a.skills), ...(home ? { home } : {}), ...(now ? { now } : {}), ...(log ? { log } : {}) });
1745
- } catch (e) {
1746
- // Never let housekeeping stop a command, but say what went wrong.
1747
- (log ?? ((line) => console.error(line)))(`⚠ hyperdecks skill freshness check failed: ${e?.message ?? e}`);
1782
+ const say = log ?? ((line) => console.error(line));
1783
+ const quiet = quietEnv(env);
1784
+ const daily = { ...(stateFile ? { stateFile } : {}), ...(now ? { now } : {}) };
1785
+ // Lines from the checks: one (the most useful) is printed after the command.
1786
+ const lines = [];
1787
+ const note = (text, rank, key) => lines.push({ text, rank, key });
1788
+
1789
+ // Quiet (opt-out or CI): the skill copies are left as they are.
1790
+ if (!quiet) {
1791
+ try {
1792
+ refreshSkillCopies({ version: VERSION, bundledDir: join(PACKAGED_SKILLS_DIR, "hyperdecks"), skillsDirs: agentTable({ home, env }).map((a) => a.skills), ...(home ? { home } : {}), ...(now ? { now } : {}), log: (l) => note(l, refreshRank(l)) });
1793
+ } catch (e) {
1794
+ // Never let housekeeping stop a command, but say what went wrong.
1795
+ note(`⚠ hyperdecks skill freshness check failed: ${e?.message ?? e}`, 3);
1796
+ }
1748
1797
  }
1798
+ const readNotices = () => {
1799
+ try {
1800
+ const found = skillNotices(VERSION, skillCopies({ agents: agentTable({ home, env }), ...(home ? { home } : {}) }));
1801
+ return quiet ? found.filter((n) => n.kind !== "cli-behind-skill") : found;
1802
+ } catch (e) {
1803
+ note(`⚠ could not read the installed hyperdecks skill: ${e?.message ?? e}`, 3);
1804
+ return [];
1805
+ }
1806
+ };
1749
1807
 
1750
1808
  let base = null;
1751
1809
  try {
@@ -1754,9 +1812,97 @@ export async function main(argv = process.argv.slice(2), { env = process.env, ho
1754
1812
  } catch {
1755
1813
  // A bad --dev setup is reported by the command itself.
1756
1814
  }
1757
- const pre = await updatePreflight(pos, { version: VERSION, base, env, fetchImpl, headers: CLIENT_HEADERS, ...(stateFile ? { stateFile } : {}), ...(now ? { now } : {}), ...(log ? { warn: log } : {}) });
1758
- if (pre.refuse) return 1;
1759
- const code = await runCli(argv);
1760
- await pre.after();
1815
+ // Refusals and the HYPERDECKS_ALLOW_OLD warning print at once.
1816
+ // One line on stderr from the checks: the lowest rank; a key makes it once a day.
1817
+ const printOne = () => {
1818
+ if (!lines.length) return;
1819
+ const [top] = [...lines].sort((x, y) => x.rank - y.rank);
1820
+ const more = lines.length > 1 ? ` (and ${lines.length - 1} more: \`hyperdecks whoami\`)` : "";
1821
+ if (top.key) onceADay(top.key, top.text + more, { ...daily, warn: say });
1822
+ else say(top.text + more);
1823
+ };
1824
+ const pre = await preflight(pos, { version: VERSION, base, env, fetchImpl, headers: CLIENT_HEADERS, ...daily, warn: say });
1825
+ if (pre.refuse) {
1826
+ // The refresh may have replaced a copy: its backup path is said only now.
1827
+ printOne();
1828
+ return 1;
1829
+ }
1830
+ const checked = Promise.resolve()
1831
+ .then(() => pre.after({ announce: false }))
1832
+ .catch((e) => {
1833
+ note(`⚠ hyperdecks update check failed: ${e?.message ?? e}`, 7);
1834
+ return null;
1835
+ });
1836
+ const held = opts.json ? holdLastJsonObject() : null;
1837
+ let code;
1838
+ let skillNotes = [];
1839
+ let notices = [];
1840
+ let jsonCli = null;
1841
+ try {
1842
+ code = await run(argv);
1843
+ // Read after the command: it may have installed the skill (init, skill install).
1844
+ skillNotes = readNotices();
1845
+ if (held) {
1846
+ // The result never waits long for the check: past NOTICE_WAIT_MS, the answer on disk.
1847
+ jsonCli = await Promise.race([checked, new Promise((r) => setTimeout(() => r(pre.cached ?? null), NOTICE_WAIT_MS).unref?.())]);
1848
+ notices = [...(jsonCli ? [jsonCli] : []), ...skillNotes];
1849
+ }
1850
+ } finally {
1851
+ held?.release(notices);
1852
+ }
1853
+
1854
+ // One line on stderr. A CLI that is behind (npm, else its own skill) beats
1855
+ // the skill housekeeping, but not a replaced copy's backup path. With
1856
+ // --json it names the same answer the JSON did, so the two never disagree.
1857
+ const cli = held ? jsonCli : await checked;
1858
+ const ahead = skillNotes.find((n) => n.kind === "cli-behind-skill");
1859
+ if (cli && dueToday("notifiedAt", daily)) note(cli.message, 1, "notifiedAt");
1860
+ else if (!cli && ahead && dueToday("skillAheadNotedAt", daily)) note(ahead.message, 2, "skillAheadNotedAt");
1861
+ printOne();
1761
1862
  return code;
1762
1863
  }
1864
+
1865
+ // --json: hold back the last JSON object a command prints to stdout, so the
1866
+ // version notices (known only once the command is done) can go in it as
1867
+ // `notices`. Anything else printed (a non-object, an array, a second line)
1868
+ // lets the held object through unchanged, in order. An object that already
1869
+ // has `notices` of its own is left as it is. A command that prints its object
1870
+ // and keeps running (play --json serves until stopped) gets it out after
1871
+ // `waitMs`, without notices: the hold never delays a result for long.
1872
+ export function holdLastJsonObject({ waitMs = 1000 } = {}) {
1873
+ const original = console.log;
1874
+ let held = null;
1875
+ let timer = null;
1876
+ const flush = () => {
1877
+ clearTimeout(timer);
1878
+ if (held) original(held.text);
1879
+ held = null;
1880
+ };
1881
+ console.log = (...args) => {
1882
+ flush();
1883
+ if (args.length === 1 && typeof args[0] === "string" && args[0].trimStart().startsWith("{")) {
1884
+ try {
1885
+ const obj = JSON.parse(args[0]);
1886
+ if (obj && typeof obj === "object" && !Array.isArray(obj) && !("notices" in obj)) {
1887
+ held = { text: args[0], obj };
1888
+ timer = setTimeout(flush, waitMs);
1889
+ timer.unref?.();
1890
+ return;
1891
+ }
1892
+ } catch {
1893
+ // Not JSON: print it as it is.
1894
+ }
1895
+ }
1896
+ original(...args);
1897
+ };
1898
+ return {
1899
+ release(notices) {
1900
+ console.log = original;
1901
+ clearTimeout(timer);
1902
+ if (!held) return;
1903
+ const { text, obj } = held;
1904
+ held = null;
1905
+ original(notices.length ? JSON.stringify({ ...obj, notices }, null, text.includes("\n") ? 2 : undefined) : text);
1906
+ },
1907
+ };
1908
+ }
@@ -205,7 +205,7 @@ export const embedErrorIn = (text) => EMBED_ERROR_TEXT.find((re) => re.test(Stri
205
205
  // Run in each frame of the capture page (serialized: no closure). Dismisses a cookie or consent banner the polite
206
206
  // way (Decline or Reject first, else the only way to close it) and answers the frame's visible text and whether a
207
207
  // banner is still showing, so the capture can refuse a picture with one baked in.
208
- export function framePass() {
208
+ export function framePass({ devHosts = false } = {}) {
209
209
  const words = (el) => (el.innerText || el.textContent || el.getAttribute("aria-label") || "").trim().toLowerCase();
210
210
  const buttons = [...document.querySelectorAll("button, [role=button], a")].filter((b) => b.offsetParent !== null);
211
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);
@@ -227,7 +227,21 @@ export function framePass() {
227
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
228
  return w * h > view / 4 && getComputedStyle(n).visibility !== "hidden" && Number(getComputedStyle(n).opacity) > 0.1;
229
229
  };
230
+ // The Hyperdecks player's own layers are the page, not a banner over it: its viewport is a fixed layer over the page
231
+ // (the whole window, or between the masthead and the dock when framed), so a draft review or a deck's poster (requireOk
232
+ // on our own deck page) would be refused on every slide. Only the layers the player made (it answers through
233
+ // window.__hdIsLayer, by identity in its own closure, defined not writable and not configurable), and only on a page whose
234
+ // player script comes from our own hosts (localhost too only when the caller passes devHosts, for a local test or
235
+ // dev server): anything inside them, a banner named like them, and the player's start card (#hd-open) still count.
236
+ // Not covered: a script that runs before the player and defines __hdIsLayer itself (the player's own definition then
237
+ // fails), and a page that restyles one of the player's layers into a banner; either takes a page loading our player
238
+ // from our hosts with a script written to fool a still of itself.
239
+ const OURS = ["hyperdecks.ai", "www.hyperdecks.ai", "decks.hypersocial.ai", ...(devHosts ? ["localhost", "127.0.0.1"] : [])];
240
+ const ours = [...document.querySelectorAll("script[src]")].some((s) => { try { const u = new URL(s.src, location.href); return OURS.includes(u.hostname) && /^\/player\/v\d+\/(b\/[\w-]+\/)?player\.js$/.test(u.pathname); } catch { return false; } });
241
+ const isLayer = ours && typeof window.__hdIsLayer === "function" ? window.__hdIsLayer : null;
242
+ const player = (n) => !!isLayer && isLayer(n) === true;
230
243
  const overlay = [...document.querySelectorAll("body *")].some((n) => {
244
+ if (player(n)) return false;
231
245
  const p = getComputedStyle(n).position;
232
246
  if (p === "fixed" || p === "sticky") return covers(n);
233
247
  return appeal.test(`${n.id} ${typeof n.className === "string" ? n.className : ""}`) && covers(n);
package/src/files.mjs CHANGED
@@ -13,6 +13,10 @@ const FILES = {
13
13
  "templates/layouts/chart.html": () => new URL("../templates/layouts/chart.html", import.meta.url),
14
14
  "templates/layouts/closer.html": () => new URL("../templates/layouts/closer.html", import.meta.url),
15
15
  "templates/layouts/compare.html": () => new URL("../templates/layouts/compare.html", import.meta.url),
16
+ "templates/layouts/statement.html": () => new URL("../templates/layouts/statement.html", import.meta.url),
17
+ "templates/layouts/pictures.html": () => new URL("../templates/layouts/pictures.html", import.meta.url),
18
+ "templates/layouts/scale.html": () => new URL("../templates/layouts/scale.html", import.meta.url),
19
+ "templates/layouts/sieve.html": () => new URL("../templates/layouts/sieve.html", import.meta.url),
16
20
  "templates/layouts/features.html": () => new URL("../templates/layouts/features.html", import.meta.url),
17
21
  "templates/layouts/cover-frame.html": () => new URL("../templates/layouts/cover-frame.html", import.meta.url),
18
22
  "templates/layouts/cover-split.html": () => new URL("../templates/layouts/cover-split.html", import.meta.url),
package/src/guide.mjs CHANGED
@@ -45,7 +45,7 @@ function layoutsIndex(surface) {
45
45
  return `- \`${name}\`${tags ? ` (${tags})` : ""}: ${meta.brief ?? meta.summary}`;
46
46
  });
47
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")}`;
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. Never put two lists in two boxes side by side. One thing in two halves: statement (the halves as one sentence, a line on each), pictures (one real picture per half) or scale (when the items are a spectrum, not two bins). What is allowed and what is not: sieve (one list, a tick or a cross on each line), or features with ticks and crosses when each item has an icon. Before and after: compare (rows, each old line struck beside the new); a change that is one figure: number. For a single rule and the right way to do it, use strike. Two equal things side by side (them and us, two products): statement, a line on each; pictures when each can be shown; two-by-two or scale when they differ on axes.\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")}`;
49
49
  }
50
50
 
51
51
  // The built-in themes, each with what it is for, and how an agent picks one.
package/src/iconSlots.mjs CHANGED
@@ -18,7 +18,7 @@ export const ICON_SLOTS = {
18
18
  stack: { where: 'first inside each layer\'s <li>, before its <b>', at: /(<li\b[^>]*>)/g },
19
19
  timeline: { where: 'first inside each milestone\'s <li>, before its <time>', at: /(<li\b[^>]*>)/g },
20
20
  split: { where: 'inside the <span class="sticker">, in place of its icon (or put the product\'s logo there instead)', at: /(<span class="sticker"[^>]*>)(?:<svg\b[\s\S]*?<\/svg>)?/g, count: /<span class="sticker"/g },
21
- compare: { where: 'first inside each <div class="label">, before its text', at: /(<div class="label">)/g },
21
+ compare: { where: 'first inside each <span class="label"> (the Before and After heads), before its text', at: /(<(?:span|div) class="label"[^>]*>)/g },
22
22
  };
23
23
  export const ICON_SLOT_LAYOUTS = Object.keys(ICON_SLOTS);
24
24
 
package/src/importer.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { strFromU8, strToU8, unzipSync } from "fflate";
2
- import { assetTypeForPath } from "./assetTypes.mjs";
2
+ import { MAX_SAVED_NAME, assetTypeForPath } from "./assetTypes.mjs";
3
3
 
4
4
  const ZIP_MAGIC = [0x50, 0x4b, 0x03, 0x04];
5
5
  const TEXT_TYPES = new Set([
@@ -60,9 +60,18 @@ export function prepareDeckImport({ bytes, filename = "deck.html", htmlFile } =
60
60
  }
61
61
 
62
62
  const unzipped = unzipSync(input);
63
- const files = Object.entries(unzipped)
64
- .map(([path, data]) => ({ path: normalizePath(path), data }))
65
- .filter((f) => isUsableArchiveFile(f.path));
63
+ const warnings = [];
64
+ const skipped = [];
65
+ const entries = Object.entries(unzipped).map(([path, data]) => ({ path: normalizePath(path), data }));
66
+ const paths = new Set(entries.map((f) => f.path));
67
+ const files = entries.filter((f) => {
68
+ if (!f.path || f.path.endsWith("/")) return false;
69
+ // A name of only spaces is no file a deck can name, and saveAsset refuses it.
70
+ if (isJunkArchiveFile(f.path, paths) || !basename(f.path).trim()) { skipped.push(f.path); return false; }
71
+ return true;
72
+ });
73
+ // Said, not silent: a zip from a Mac carries its own housekeeping files, which no deck loads.
74
+ if (skipped.length) warnings.push(`skipped ${skipped.length} file${skipped.length > 1 ? "s" : ""} no deck loads (system files, or a name of only spaces): ${skipped.slice(0, 5).map((p) => JSON.stringify(p)).join(", ")}${skipped.length > 5 ? `, and ${skipped.length - 5} more` : ""}`);
66
75
  const htmlEntry = chooseHtmlEntry(files.map((f) => f.path), htmlFile);
67
76
  if (!htmlEntry) throw new Error("zip does not contain an HTML file");
68
77
 
@@ -71,11 +80,16 @@ export function prepareDeckImport({ bytes, filename = "deck.html", htmlFile } =
71
80
  const html = textFromBytes(htmlFileRow.data);
72
81
  const baseDir = dirname(htmlEntry);
73
82
  const seenNames = new Set();
74
- const assets = files
75
- .filter((f) => f.path !== htmlEntry && !/\.html?$/i.test(f.path))
76
- .map((f) => {
83
+ const kept = files.filter((f) => f.path !== htmlEntry && !/\.html?$/i.test(f.path));
84
+ // The name is only the asset's key (rewrites go by sourcePath): make it one saveAsset takes.
85
+ const wanted = kept.map((f) => assetNameFor(stripBaseDir(f.path, baseDir) || basename(f.path)));
86
+ const merged = [];
87
+ const assets = kept
88
+ .map((f, i) => {
77
89
  const relative = stripBaseDir(f.path, baseDir);
78
- const name = uniqueAssetName(relative || basename(f.path), seenNames);
90
+ const name = uniqueAssetName(wanted[i], seenNames);
91
+ // Cleaning made two entries one name ("a/./b.png", "a/b.png"): each keeps its file, under its own name.
92
+ if (wanted.indexOf(wanted[i]) !== wanted.lastIndexOf(wanted[i]) && wanted.some((w, j) => w === wanted[i] && w !== (stripBaseDir(kept[j].path, baseDir) || basename(kept[j].path)))) merged.push(`${f.path} → ${name}`);
79
93
  return {
80
94
  sourcePath: f.path,
81
95
  relativePath: relative,
@@ -85,12 +99,14 @@ export function prepareDeckImport({ bytes, filename = "deck.html", htmlFile } =
85
99
  };
86
100
  });
87
101
 
102
+ // Two entries whose names clean to one ("a/./b.png" and "a/b.png"): each keeps its own file, but say so.
103
+ if (merged.length) warnings.push(`${merged.length} files clean to one name, so each is filed under its own: ${merged.slice(0, 5).join(", ")}${merged.length > 5 ? `, and ${merged.length - 5} more` : ""}`);
88
104
  return {
89
105
  html,
90
106
  htmlEntry,
91
107
  title: titleFromHtml(html) || titleFromFilename(filename),
92
108
  assets,
93
- warnings: [],
109
+ warnings,
94
110
  };
95
111
  }
96
112
 
@@ -275,11 +291,38 @@ function normalizePath(path) {
275
291
  .replace(/\/+/g, "/");
276
292
  }
277
293
 
278
- function isUsableArchiveFile(path) {
279
- if (!path || path.endsWith("/")) return false;
280
- if (path.includes("__MACOSX/")) return false;
281
- if (basename(path) === ".DS_Store") return false;
282
- return true;
294
+ // Housekeeping a zip picks up on a Mac or Windows: macOS's resource forks and its
295
+ // custom-folder icon ("Icon\r"), Finder's .DS_Store, Windows' Thumbs.db and desktop.ini.
296
+ // "._x" is AppleDouble (x's resource fork) only under __MACOSX/ or beside an "x": a deck's own
297
+ // "._sprite.png" with no "sprite.png" next to it is a real file.
298
+ function isJunkArchiveFile(path, paths) {
299
+ const name = basename(path);
300
+ if (path.includes("__MACOSX/") || name === ".DS_Store" || name === "Icon\r" || /^(thumbs\.db|desktop\.ini)$/i.test(name)) return true;
301
+ return name.startsWith("._") && paths.has(`${path.slice(0, path.length - name.length)}${name.slice(2)}`);
302
+ }
303
+
304
+ // A path's "." parts and empty parts gone, and ".." resolved inside it; one that climbs above
305
+ // its start is dropped. For an asset's name only: references resolve with normalizePath.
306
+ function cleanPath(path) {
307
+ const parts = [];
308
+ for (const seg of String(path).split("/")) {
309
+ if (seg === "" || seg === ".") continue;
310
+ if (seg === "..") parts.pop();
311
+ else parts.push(seg);
312
+ }
313
+ return parts.join("/");
314
+ }
315
+
316
+ // A name saveAsset takes (assetTypes.mjs savedNameError): no control characters, and at most
317
+ // MAX_SAVED_NAME characters with room for uniqueAssetName's "-2"; a long path keeps its extension.
318
+ function assetNameFor(path) {
319
+ const clean = cleanPath(normalizePath(String(path).replace(/[\u0000-\u001f\u007f]+/g, "-"))) || "asset";
320
+ const room = MAX_SAVED_NAME - 8;
321
+ if (clean.length <= room) return clean;
322
+ const ext = /\.[A-Za-z0-9]{1,8}$/.exec(clean)?.[0] ?? "";
323
+ let hash = 0;
324
+ for (const c of clean) hash = (hash * 31 + c.codePointAt(0)) >>> 0;
325
+ return `${clean.slice(0, room - ext.length - 9)}-${hash.toString(36).padStart(7, "0").slice(0, 7)}${ext}`;
283
326
  }
284
327
 
285
328
  function stripBaseDir(path, baseDir) {
package/src/init.mjs CHANGED
@@ -17,7 +17,8 @@ import { createInterface } from "node:readline/promises";
17
17
  import { fileURLToPath } from "node:url";
18
18
  import * as ops from "./ops.mjs";
19
19
  import { ANSWER_MAX, DASH_AVATAR, FIRST_DECK_LAYOUTS, cleanAnswer, fillFirstDeck, firstDeckCopy, firstDeckSlug } from "./firstDeck.mjs";
20
- import { agentTable, api, chooseAgents, client, CRED_DIR, installHyperdecksSkill, linkBase, login as runLogin, openBrowser, target } from "./runtime.mjs";
20
+ import { agentTable, api, chooseAgents, client, CRED_DIR, installHyperdecksSkill, linkBase, login as runLogin, openBrowser, target, VERSION } from "./runtime.mjs";
21
+ import { skillCopies, skillSummary } from "./notices.mjs";
21
22
  import { skillHash } from "./skillFreshness.mjs";
22
23
  import { READING_PASSAGE, voiceClone as runVoiceClone } from "./voice.mjs";
23
24
  import { assembleLayoutDeck, deckNew as runDeckNew } from "./scaffold.mjs";
@@ -171,6 +172,7 @@ export async function init(pos = [], opts = {}, io = {}) {
171
172
  random = () => randomBytes(2).toString("hex"),
172
173
  fetch,
173
174
  avatars = null, // the avatar.mjs commands (tests pass fakes)
175
+ readCopies = skillCopies,
174
176
  } = io;
175
177
  if (pos.length) throw new Error(`unexpected argument(s): ${pos.join(" ")}; init takes flags only (hyperdecks init --help)`);
176
178
  for (const k of ["voice", "name", "about", "ask", "dir"]) if (k in opts && typeof opts[k] !== "string") throw new Error(`--${k} requires a value`);
@@ -196,7 +198,17 @@ export async function init(pos = [], opts = {}, io = {}) {
196
198
  const finish = (status, extra = {}) => {
197
199
  const next = nextSteps(state);
198
200
  if (status === "incomplete") log(`\nNot finished yet. When that is done, run \`${RESUME}\` again: it picks up where it stopped.`);
199
- return { status, steps, slug: state.slug ?? null, deckDir: state.deckDir ?? null, shareUrl: state.shareUrl ?? null, next, ...extra };
201
+ // Which CLI and which skill this run left you with, every time.
202
+ let copies = null;
203
+ let why = null;
204
+ try {
205
+ copies = readCopies({ agents: agentTable({ home, env }), home });
206
+ } catch (e) {
207
+ why = e?.message ?? String(e);
208
+ }
209
+ log(`\ncli ${VERSION} · skill ${copies ? skillSummary(copies) : `unknown (${why})`}`);
210
+ const versions = { cli: VERSION, skill: copies ? copies.map(({ agent, path, version }) => ({ agent, path, version })) : null, ...(why ? { skillError: why } : {}) };
211
+ return { status, steps, slug: state.slug ?? null, deckDir: state.deckDir ?? null, shareUrl: state.shareUrl ?? null, next, versions, ...extra };
200
212
  };
201
213
 
202
214
  // 1. Sign in.
@@ -10,6 +10,9 @@ export const ROUTES = [
10
10
  { kind: "dates, a roadmap", layouts: ["timeline", "rail"], why: "milestones on a line", words: ["roadmap", "history", "milestone*", "years", "quarter*", "month*", "since", "launch*", "q1", "q2", "q3", "q4"] },
11
11
  { kind: "a cycle", layouts: ["loop", "rail", "staircase"], why: "what feeds back into itself", words: ["cycle", "loop", "flywheel", "repeat*", "feeds back", "compound*", "virtuous"] },
12
12
  { kind: "who does what", layouts: ["lanes", "rail", "team"], why: "one row per actor over the same steps", words: ["who does what", "who", "role*", "handoff", "hands off", "hand off", "owner*", "responsib*"] },
13
+ { kind: "one thing in two halves", layouts: ["statement", "pictures", "scale"], why: "statement: the halves as one sentence, a line on each; pictures: one real picture per half; scale: the items on a spectrum when they are not two bins", words: ["halves", "two halves", "two parts", "two sides", "two kinds", "two types", "two audiences", "two moments", "two modes", "split between", "on one side"] },
14
+ { kind: "a spectrum", layouts: ["scale", "two-by-two"], why: "items placed along one bar from one end to the other", words: ["spectrum", "somewhere between", "gradual*", "sliding scale", "a matter of degree", "range from", "from cheap", "to premium", "from local", "least to most", "low end", "high end"] },
15
+ { kind: "two equal things side by side", layouts: ["statement", "pictures", "two-by-two"], why: "statement: one line on each, the second marked; pictures: each one shown; two-by-two: where they differ on two axes. Never two boxes", words: ["side by side", "two products", "two options", "two plans", "two vendors", "two tools", "two approaches"] },
13
16
  { kind: "one claim", layouts: ["sentence", "number", "quote"], why: "one line, set large", words: ["claim", "thesis", "believe", "the point", "one thing", "the idea", "bet", "insight"] },
14
17
  { kind: "a correction", layouts: ["strike", "compare", "sentence"], why: "the wrong line struck, the right one under it", words: ["myth*", "wrong", "misconception*", "actually", "not really", "people think", "instead", "correct*", "rewrite"] },
15
18
  { kind: "a choice among options", layouts: ["spotlight", "two-by-two"], why: "the options, the pick lit", words: ["choose", "chose", "pick*", "option*", "which one", "alternative*", "plans", "tier*", "pricing"] },
@@ -17,12 +20,12 @@ export const ROUTES = [
17
20
  { kind: "status", layouts: ["scorecard", "number", "chart"], why: "measures against plan, a state each: scorecard; one figure: number", words: ["status", "on track", "goal*", "kpi*", "okr*", "progress", "checklist", "health", "where we stand", "monthly update"] },
18
21
  { kind: "a problem or a miss, and its causes", layouts: ["bento", "features", "scorecard"], why: "the main cause big, two factors beside it; strike only for a belief that was wrong", words: ["missed", "miss", "why we", "didn't work", "did not work", "went wrong", "problem*", "failed", "fell short", "behind plan", "root cause", "causes", "lessons"] },
19
22
  { kind: "one main reason and two backers", layouts: ["bento", "features"], why: "one big tile, two small", words: ["main reason", "above all", "most important", "biggest", "mainly", "headline", "and also"] },
20
- { kind: "positioning", layouts: ["two-by-two", "compare"], why: "two axes, us in our corner", words: ["position*", "quadrant", "matrix", "competitor*", "landscape", "market map", "versus the market", "axes"] },
23
+ { kind: "positioning", layouts: ["two-by-two", "scale"], why: "two axes, us in our corner; one axis: scale", words: ["position*", "quadrant", "matrix", "competitor*", "landscape", "market map", "versus the market", "axes", "them and us", "us and them"] },
21
24
  { kind: "two quantities", layouts: ["two-bars", "number"], why: "two bars, the gap is the point", words: ["vs", "versus", "faster", "cheaper", "slower", "times", "half", "double", "compared to", "more than", "less than"] },
22
25
  { kind: "layers", layouts: ["stack", "staircase", "features"], why: "what sits on what", words: ["layer*", "stack", "built on", "architecture", "platform", "underneath", "infrastructure", "foundation"] },
23
26
  { kind: "three equal things", layouts: ["features", "bento", "spotlight"], why: "three cards, none bigger (bento when one leads, spotlight when one is the pick)", words: ["three", "feature*", "reason*", "pillar*", "benefit*", "parts", "what you get"] },
24
- { kind: "before and after", layouts: ["compare", "strike"], why: "two columns, the new one lit", words: ["before", "after", "today", "used to", "old way", "new way", "them and us", "change*"] },
25
- { kind: "allowed and not allowed", layouts: ["compare", "strike"], why: "compare: the allowed items in the highlighted right column, both columns labelled; strike: one rule and the right way", words: ["do and don't", "dos and don'ts", "do's", "don'ts", "allowed", "not allowed", "goes in", "stays out", "never", "always", "rules", "include*", "exclude*", "avoid", "accept*", "reject*"] },
27
+ { kind: "before and after", layouts: ["compare", "strike", "number"], why: "compare: rows, each old line struck beside the new; strike: one line; number: a change that is one figure", words: ["before", "after", "today", "used to", "old way", "new way", "change*", "the old", "old and new"] },
28
+ { kind: "allowed and not allowed", layouts: ["sieve", "features", "strike"], why: "sieve: one list, a tick or a cross on each line; features: with ticks and crosses, when each item has an icon; strike: one rule and the right way", words: ["do and don't", "dos and don'ts", "do's", "don'ts", "allowed", "not allowed", "goes in", "stays out", "never", "always", "rules", "include*", "exclude*", "avoid", "accept*", "reject*", "we keep", "we drop", "keep and drop", "keep vs drop", "in scope", "out of scope"] },
26
29
  { kind: "the product", layouts: ["product", "split", "zoom", "screens"], why: "a real screenshot, framed", words: ["product", "app", "screen*", "screenshot*", "dashboard", "interface", "ui", "website", "feature", "demo", "tool"] },
27
30
  { kind: "the product on a phone", layouts: ["phone-stage", "phones", "tap-through"], why: "one phone, a row of them, or one to tap", words: ["phone*", "mobile", "iphone", "ios", "android", "tap", "taps"] },
28
31
  { kind: "a walk through a flow", layouts: ["screens", "tap-through", "video-beats"], why: "the screens in order, or a recording paused at each", words: ["walkthrough", "walk through", "flow", "flows", "tour", "click*", "sign up flow", "checkout"] },
@@ -91,7 +94,7 @@ export function alternativesFor(layout, text = "", { avoid = [], limit = 2 } = {
91
94
  // declares it in its header's `flip:` line). Two neighbours of one of these on the same side read as the same slide
92
95
  // twice; the scaffold alternates them and check warns.
93
96
  export const FLIPPABLE = ["cover-split", "split", "picture-full", "wall", "portrait"];
94
- export const PICTURE_LAYOUTS = new Set(["product", "split", "phones", "phone-stage", "tap-through", "screens", "zoom", "video-full", "video-beats", "embed", "picture-full", "wall", "portrait", "team", "chart"]);
97
+ export const PICTURE_LAYOUTS = new Set(["product", "split", "pictures", "phones", "phone-stage", "tap-through", "screens", "zoom", "video-full", "video-beats", "embed", "picture-full", "wall", "portrait", "team", "chart"]);
95
98
 
96
99
  // The covers and the closer frame a deck; they are not counted as its content.
97
100
  export const COVERS = new Set(ROUTES[0].layouts.concat("cover-band"));
package/src/layouts.mjs CHANGED
@@ -7,8 +7,8 @@ import { FLIPPABLE } from "./layoutRoutes.mjs";
7
7
  export const NARRATED_FILES = { "index.html": "narrated-deck.html", "script.md": "script.md", "evidence.md": "evidence.md" };
8
8
  // The library: the six covers first (hero is the default; a deck opens on one; the
9
9
  // clean picture covers cover-frame and cover-split next), then the rest in a sensible deck order. `--layouts` takes any order and repeats.
10
- export const LAYOUTS = ["hero", "cover-frame", "cover-split", "cover-band", "cover-poster", "cover-type", "number", "product", "split", "phones", "phone-stage", "tap-through", "screens", "zoom", "video-full", "video-beats", "picture-full", "wall", "portrait", "embed", "quote", "compare", "timeline", "features", "sentence", "strike", "spotlight", "funnel", "scorecard", "bento", "two-by-two", "staircase", "rail", "loop", "lanes", "two-bars", "stack", "chart", "team", "question-choice", "question-text", "closer"];
11
- const LAYOUT_ALIASES = { "big-number": "number", "product-shot": "product", "phone-row": "phones", comparison: "compare", "three-up": "features", "image-copy": "split", "image-text": "split", "phone-centre": "phone-stage", "phone-center": "phone-stage", prototype: "tap-through", "click-through": "tap-through", "picture-strip": "screens", storyboard: "screens", flow: "screens", "detail-zoom": "zoom", map: "embed", "live-map": "embed", booking: "embed", "book-a-call": "embed", calendly: "embed", figma: "embed", "live-embed": "embed", video: "video-full", "full-video": "video-full", "video-moments": "video-beats", "full-picture": "picture-full", "photo-full": "picture-full", "picture-wall": "wall", "photo-wall": "wall", "portrait-line": "portrait", "one-sentence": "sentence", statement: "sentence", "big-line": "sentence", "strike-and-rewrite": "strike", "strike-rewrite": "strike", myth: "strike", rewrite: "strike", "pick-one": "spotlight", highlight: "spotlight", "one-of-many": "spotlight", pipeline: "funnel", conversion: "funnel", "score-card": "scorecard", status: "scorecard", "one-big-two-small": "bento", "big-and-small": "bento", "two-x-two": "two-by-two", "2x2": "two-by-two", quadrant: "two-by-two", matrix: "two-by-two", stairs: "staircase", "step-up": "staircase", "process-line": "rail", stops: "rail", cycle: "loop", flywheel: "loop", swimlanes: "lanes", "who-does-what": "lanes", "two-bar": "two-bars", "bar-pair": "two-bars", layers: "stack", "layer-cake": "stack", question: "question-choice", poll: "question-choice", choice: "question-choice", "short-answer": "question-text", "open-question": "question-text" };
10
+ export const LAYOUTS = ["hero", "cover-frame", "cover-split", "cover-band", "cover-poster", "cover-type", "number", "product", "split", "phones", "phone-stage", "tap-through", "screens", "zoom", "video-full", "video-beats", "picture-full", "wall", "portrait", "embed", "quote", "compare", "statement", "pictures", "scale", "sieve", "timeline", "features", "sentence", "strike", "spotlight", "funnel", "scorecard", "bento", "two-by-two", "staircase", "rail", "loop", "lanes", "two-bars", "stack", "chart", "team", "question-choice", "question-text", "closer"];
11
+ const LAYOUT_ALIASES = { "big-number": "number", "product-shot": "product", "phone-row": "phones", comparison: "compare", "rewrite-rows": "compare", "before-after": "compare", "two-halves": "statement", halves: "statement", "big-statement": "statement", "two-pictures": "pictures", "two-screens": "pictures", spectrum: "scale", gradient: "scale", "one-list": "sieve", "in-and-out": "sieve", "ticks-and-crosses": "sieve", "dos-and-donts": "sieve", "three-up": "features", "image-copy": "split", "image-text": "split", "phone-centre": "phone-stage", "phone-center": "phone-stage", prototype: "tap-through", "click-through": "tap-through", "picture-strip": "screens", storyboard: "screens", flow: "screens", "detail-zoom": "zoom", map: "embed", "live-map": "embed", booking: "embed", "book-a-call": "embed", calendly: "embed", figma: "embed", "live-embed": "embed", video: "video-full", "full-video": "video-full", "video-moments": "video-beats", "full-picture": "picture-full", "photo-full": "picture-full", "picture-wall": "wall", "photo-wall": "wall", "portrait-line": "portrait", "one-sentence": "sentence", "big-line": "sentence", "strike-and-rewrite": "strike", "strike-rewrite": "strike", myth: "strike", rewrite: "strike", "pick-one": "spotlight", highlight: "spotlight", "one-of-many": "spotlight", pipeline: "funnel", conversion: "funnel", "score-card": "scorecard", status: "scorecard", "one-big-two-small": "bento", "big-and-small": "bento", "two-x-two": "two-by-two", "2x2": "two-by-two", quadrant: "two-by-two", matrix: "two-by-two", stairs: "staircase", "step-up": "staircase", "process-line": "rail", stops: "rail", cycle: "loop", flywheel: "loop", swimlanes: "lanes", "who-does-what": "lanes", "two-bar": "two-bars", "bar-pair": "two-bars", layers: "stack", "layer-cake": "stack", question: "question-choice", poll: "question-choice", choice: "question-choice", "short-answer": "question-text", "open-question": "question-text" };
12
12
 
13
13
  const escapeHtml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
14
14