decklight 0.8.1 → 0.10.0

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 (138) hide show
  1. package/PLATFORM.md +707 -0
  2. package/README.md +226 -150
  3. package/SPEC.md +803 -888
  4. package/cli/agent-review.mjs +246 -0
  5. package/cli/agents.mjs +35 -9
  6. package/cli/associate.mjs +12 -12
  7. package/cli/audit.mjs +42 -10
  8. package/cli/banner.mjs +41 -17
  9. package/cli/bundle-audio.mjs +190 -0
  10. package/cli/bundle-module.mjs +95 -0
  11. package/cli/bundle.mjs +439 -35
  12. package/cli/cast.mjs +48 -12
  13. package/cli/check-fixes.mjs +186 -0
  14. package/cli/check.mjs +988 -0
  15. package/cli/clone-deck.mjs +179 -0
  16. package/cli/commands.mjs +345 -0
  17. package/cli/comments.mjs +64 -18
  18. package/cli/commit-flow.mjs +51 -22
  19. package/cli/commit-message.mjs +51 -74
  20. package/cli/commit-split.mjs +601 -0
  21. package/cli/deck-refs.mjs +64 -0
  22. package/cli/deck-routes.mjs +67 -0
  23. package/cli/deckfile.mjs +3 -5
  24. package/cli/decklight.mjs +68 -289
  25. package/cli/design-system-deps.mjs +209 -0
  26. package/cli/design-system-edit.mjs +194 -0
  27. package/cli/design-system-refs.mjs +666 -0
  28. package/cli/design-system.mjs +497 -0
  29. package/cli/doctor.mjs +115 -0
  30. package/cli/edit-git.mjs +353 -0
  31. package/cli/edit-handover.mjs +551 -0
  32. package/cli/edit-look.mjs +631 -0
  33. package/cli/edit-slides.mjs +683 -0
  34. package/cli/edit.mjs +2585 -855
  35. package/cli/enhance.mjs +485 -0
  36. package/cli/extension.mjs +10 -10
  37. package/cli/font-refs.mjs +273 -0
  38. package/cli/font.mjs +246 -0
  39. package/cli/git-tree.mjs +1 -1
  40. package/cli/git.mjs +78 -11
  41. package/cli/import.mjs +56 -10
  42. package/cli/init.mjs +407 -236
  43. package/cli/library.mjs +127 -0
  44. package/cli/loader.mjs +3 -1
  45. package/cli/marketplace-autocheck.mjs +200 -0
  46. package/cli/marketplace.mjs +460 -29
  47. package/cli/narrate.mjs +251 -0
  48. package/cli/open-browser.mjs +63 -0
  49. package/cli/open.mjs +961 -0
  50. package/cli/pdf.mjs +64 -17
  51. package/cli/pkg.mjs +44 -2
  52. package/cli/plugin.mjs +43 -41
  53. package/cli/port-conflict.mjs +53 -23
  54. package/cli/pptx-export.mjs +63 -27
  55. package/cli/publish.mjs +8 -4
  56. package/cli/qr.mjs +1 -1
  57. package/cli/record.mjs +85 -23
  58. package/cli/remote.mjs +43 -17
  59. package/cli/restore.mjs +11 -4
  60. package/cli/review-ref.mjs +125 -0
  61. package/cli/review-remote.mjs +92 -48
  62. package/cli/review-routes.mjs +254 -0
  63. package/cli/review-store.mjs +47 -7
  64. package/cli/review-submit.mjs +47 -57
  65. package/cli/runtime-link.mjs +560 -0
  66. package/cli/serve.mjs +236 -45
  67. package/cli/setup.mjs +112 -0
  68. package/cli/sign.mjs +1 -1
  69. package/cli/skill-content.mjs +229 -35
  70. package/cli/skills.mjs +353 -26
  71. package/cli/start.mjs +110 -0
  72. package/cli/supervise.mjs +6 -6
  73. package/cli/theme-refs.mjs +527 -0
  74. package/cli/theme.mjs +181 -137
  75. package/cli/trust.mjs +83 -0
  76. package/cli/units.mjs +112 -47
  77. package/cli/update-check.mjs +1 -5
  78. package/cli/upgrade.mjs +194 -28
  79. package/cli/upstream.mjs +4 -3
  80. package/cli/util.mjs +4 -4
  81. package/cli/wizard.mjs +6 -6
  82. package/dist/build-info.json +1 -1
  83. package/dist/decklight.css +1533 -59
  84. package/dist/decklight.js +258 -115
  85. package/dist/decklight.js.map +4 -4
  86. package/docs/GLOSSARY.md +141 -0
  87. package/docs/architecture.svg +17 -17
  88. package/package.json +4 -2
  89. package/themes/README.md +9 -8
  90. package/themes/reveal-solarized.css +10 -0
  91. package/tools/args.mjs +20 -0
  92. package/tools/atomic-write.mjs +48 -0
  93. package/tools/brand-palette.mjs +717 -0
  94. package/tools/bridge.mjs +1 -1
  95. package/tools/build-groups.mjs +42 -0
  96. package/tools/color.mjs +48 -0
  97. package/tools/deck-html.mjs +396 -11
  98. package/tools/design-system-format.mjs +778 -0
  99. package/tools/design-system-migrations.mjs +207 -0
  100. package/tools/elevenlabs-tts.mjs +110 -17
  101. package/tools/exec.mjs +11 -3
  102. package/tools/extension-check.mjs +31 -7
  103. package/tools/font-format.mjs +190 -0
  104. package/tools/font-stacks.mjs +24 -0
  105. package/tools/gemini-tts.mjs +3 -0
  106. package/tools/lipsync-config.mjs +103 -0
  107. package/tools/lipsync-engines.mjs +205 -2
  108. package/tools/lipsync-server.mjs +264 -41
  109. package/tools/lipsync.mjs +37 -18
  110. package/tools/local-voice.mjs +32 -42
  111. package/tools/narration-manifest.mjs +270 -0
  112. package/tools/narration-synth.mjs +416 -0
  113. package/tools/pptx.mjs +776 -19
  114. package/tools/publish-targets.mjs +1 -1
  115. package/tools/publish-voices.mjs +3 -3
  116. package/tools/recording-impact.mjs +7 -3
  117. package/tools/render-theme.mjs +33 -0
  118. package/tools/review-anchor.mjs +28 -12
  119. package/tools/semver.mjs +40 -0
  120. package/tools/sentences.mjs +180 -0
  121. package/tools/shot.mjs +14 -7
  122. package/tools/site-clip.mjs +114 -0
  123. package/tools/site-voices.mjs +232 -0
  124. package/tools/template-theme.mjs +1 -1
  125. package/tools/test-impact.mjs +17 -10
  126. package/tools/theme-check.mjs +30 -3
  127. package/tools/tts-cache.mjs +4 -3
  128. package/tools/tts-engines.mjs +38 -20
  129. package/tools/tts-setup.mjs +7 -7
  130. package/tools/video-options.mjs +34 -0
  131. package/tools/video.mjs +530 -54
  132. package/tools/voiceover-server.mjs +185 -104
  133. package/tools/voiceover.mjs +119 -261
  134. package/tools/zip.mjs +1 -1
  135. package/cli/dev.mjs +0 -623
  136. package/cli/present.mjs +0 -853
  137. package/cli/review.mjs +0 -361
  138. package/tools/publish-site-voices.mjs +0 -75
package/cli/pdf.mjs CHANGED
@@ -19,10 +19,12 @@
19
19
  // have already emailed is a slide nobody can fix.
20
20
 
21
21
  import { existsSync, readFileSync, rmSync, statSync } from 'node:fs';
22
- import { basename, resolve } from 'node:path';
22
+ import { basename, dirname, relative, resolve, sep } from 'node:path';
23
+ import { serveForRender } from './serve.mjs';
23
24
  import { chromeBin, chromeArgs } from '../tools/chrome.mjs';
24
25
  import { argReader, isMain } from '../tools/args.mjs';
25
- import { run, CODEC_MS } from '../tools/exec.mjs';
26
+ import { renderThemeParams } from '../tools/render-theme.mjs';
27
+ import { runAsync, CODEC_MS } from '../tools/exec.mjs';
26
28
  import { sectionBodies, isHiddenSection } from '../tools/deck-html.mjs';
27
29
 
28
30
  /**
@@ -42,7 +44,7 @@ import { sectionBodies, isHiddenSection } from '../tools/deck-html.mjs';
42
44
  */
43
45
  export const HANDOUT_PER_PAGE = 3;
44
46
 
45
- const USAGE = `usage: decklight pdf <deck.html> [-o out.pdf] [--theme <name>] [--wait <ms>]
47
+ const USAGE = `usage: decklight pdf <deck.html> [-o out.pdf] [--theme <name> | --gen <b64url>] [--wait <ms>]
46
48
  [--notes | --handout]
47
49
  renders the deck's ?print view to a PDF — one slide per page, at the deck's
48
50
  own 1280×720, in its theme, with every build complete
@@ -53,6 +55,8 @@ const USAGE = `usage: decklight pdf <deck.html> [-o out.pdf] [--theme <name>] [-
53
55
  --handout three slides a page, portrait, ruled lines beside each for
54
56
  the audience to write on [out: <deck>.handout.pdf]
55
57
  --theme <name> export in another theme (rides ?theme=)
58
+ --gen <b64url> export in a custom or generated theme, as {name, tokens}
59
+ base64url JSON (rides ?gen=)
56
60
  --wait <ms> render budget for heavy decks [8000]
57
61
 
58
62
  slides the print-mode overflow guardrail flags are named on stderr; the PDF
@@ -68,12 +72,14 @@ export function pdfOut(deckPath, oFlag, variant = '') {
68
72
  /**
69
73
  * The URL to print. `?print` is the whole rendering contract; `?theme=` is the
70
74
  * existing startup override, so exporting in another theme costs nothing here.
75
+ * `base` is where the deck is served — a `file://` path, or the render
76
+ * server's origin plus the deck's path under its root.
71
77
  */
72
- export function printUrl(absDeckPath, { theme, variant = '' } = {}) {
78
+ export function printUrl(base, { theme, gen, variant = '' } = {}) {
73
79
  // `?print=notes` / `?print=handout` are the runtime's own variants (src/core/print.js)
74
80
  const print = variant ? `?print=${variant}` : '?print';
75
- const q = theme ? `${print}&theme=${encodeURIComponent(theme)}` : print;
76
- return `file://${absDeckPath}${q}`;
81
+ const q = [print, ...renderThemeParams({ theme, gen })].join('&');
82
+ return `${/^[a-z]+:\/\//i.test(base) ? base : `file://${base}`}${q}`;
77
83
  }
78
84
 
79
85
  /**
@@ -134,13 +140,21 @@ export const slideCount = (html) => sectionBodies(html).filter((b) => !isHiddenS
134
140
 
135
141
  const KB = (n) => (n < 1024 * 1024 ? `${Math.round(n / 1024)} KB` : `${(n / 1048576).toFixed(1)} MB`);
136
142
 
137
- export async function pdfMain(args = []) {
143
+ // `signal` stops Chrome mid-print (the edit server's stop route): it throws the
144
+ // AbortError, and leaves no half-written PDF behind.
145
+ export async function pdfMain(args = [], { signal = null } = {}) {
138
146
  if (args.includes('--help') || args.includes('-h')) { console.log(USAGE); return 0; }
139
147
  const { opt } = argReader(args);
140
148
  const deck = args.find((a) => !a.startsWith('-') && /\.html?$/i.test(a));
141
149
  if (!deck) { console.error(`decklight pdf: needs a deck\n\n${USAGE}`); return 1; }
142
150
  const src = resolve(deck);
143
151
  if (!existsSync(src)) { console.error(`decklight pdf: no such deck: ${deck}`); return 1; }
152
+ // The deck is served from its folder (below), and the render server never
153
+ // serves a dotfile: Chrome would print its 403 as one blank page
154
+ if (basename(src).startsWith('.')) {
155
+ console.error(`decklight pdf: ${basename(src)} is a dotfile, and a deck is rendered by serving it, which never serves a name that starts with a dot — copy or rename it without the dot`);
156
+ return 1;
157
+ }
144
158
 
145
159
  const variant = args.includes('--notes') ? 'notes' : args.includes('--handout') ? 'handout' : '';
146
160
  if (args.includes('--notes') && args.includes('--handout')) {
@@ -149,29 +163,55 @@ export async function pdfMain(args = []) {
149
163
  }
150
164
  const out = pdfOut(src, opt('-o'), variant);
151
165
  const theme = opt('--theme');
166
+ const gen = opt('--gen');
167
+ try { renderThemeParams({ theme, gen }); } catch (e) { console.error(`decklight pdf: ${e.message}`); return 1; }
152
168
  const wait = Number(opt('--wait', 8000));
153
- const url = printUrl(src, { theme, variant });
154
169
  const bin = chromeBin('pdf');
155
- // file:// decks load their runtime, themes and casts as siblings
156
- const shared = chromeArgs('--allow-file-access-from-files', `--virtual-time-budget=${wait}`);
170
+ // The deck is SERVED, from its own directory, the way shot and video serve
171
+ // theirs: a deck that references the runtime (#517) or carries none at all
172
+ // (#520) plays from the installed package that way, where a file:// load
173
+ // would find no engine beside it. Same-origin, so its casts and media load
174
+ // exactly as siblings did.
175
+ const root = dirname(src);
176
+ const server = await serveForRender(root);
177
+ const url = printUrl(`${server.origin}/${relative(root, src).split(sep).join('/')}`, { theme, gen, variant });
178
+ const shared = chromeArgs(`--virtual-time-budget=${wait}`);
179
+ try {
180
+ return await printDeck({ src, out, url, bin, shared, variant, theme, signal });
181
+ } finally {
182
+ await server.close();
183
+ }
184
+ }
157
185
 
186
+ async function printDeck({ src, out, url, bin, shared, variant, theme, signal }) {
187
+
188
+ // Chrome is AWAITED, never `run`: the in-process render server above has
189
+ // to answer the browser it launched (the deadlock pptx documents), and the
190
+ // edit server runs `pdfMain` in its own process for the palette's Export
191
+ // rows, where a synchronous child would freeze live reload, the SSE stream
192
+ // and the page itself for the ten seconds Chrome takes to print.
193
+ //
158
194
  // Pass one: the DOM, for the slide count and the overflow audit. Cheap — the
159
195
  // same URL, the same budget, and it is the only way to know what the PDF is
160
196
  // about to hide.
161
197
  let html = '';
162
198
  try {
163
- html = run(bin, [...shared, '--dump-dom', url],
164
- { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'], timeout: CODEC_MS, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
165
- } catch { /* the print pass below is the one that must succeed */ }
199
+ html = await runAsync(bin, [...shared, '--dump-dom', url],
200
+ { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, timeout: CODEC_MS, signal, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
201
+ } catch (e) {
202
+ if (e.name === 'AbortError') throw e;
203
+ // the print pass below is the one that must succeed
204
+ }
166
205
  const slides = slideCount(html);
167
206
  console.error(`pdf: rendering ${basename(src)}?print${variant ? `=${variant}` : ''}${theme ? ` · theme ${theme}` : ''}`
168
207
  + `${slides ? ` — ${slides} slides, builds complete, casts expanded` : ''}`);
169
208
 
170
209
  rmSync(out, { force: true }); // never leave a stale PDF looking like a fresh one
171
210
  try {
172
- run(bin, [...shared, '--no-pdf-header-footer', `--print-to-pdf=${out}`, url],
173
- { stdio: ['ignore', 'ignore', 'ignore'], timeout: CODEC_MS, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
211
+ await runAsync(bin, [...shared, '--no-pdf-header-footer', `--print-to-pdf=${out}`, url],
212
+ { maxBuffer: 32 * 1024 * 1024, timeout: CODEC_MS, signal, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
174
213
  } catch (e) {
214
+ if (e.name === 'AbortError') { rmSync(out, { force: true }); throw e; }
175
215
  console.error(`decklight pdf: Chrome failed — ${String(e.message ?? e).split('\n')[0]}`);
176
216
  return 1;
177
217
  }
@@ -189,11 +229,18 @@ export async function pdfMain(args = []) {
189
229
  }
190
230
  const buf = readFileSync(out);
191
231
  const pages = pdfPageCount(buf);
192
- const want = slides ? expectedPages(slides, variant) : 0;
232
+ // No slides in the rendered page is no deck at all (a refused or broken
233
+ // load): held to the file's own count, so the mismatch below is said
234
+ let written = 0;
235
+ if (!slides) {
236
+ try { written = slideCount(readFileSync(src, 'utf8')); } catch { written = 0; }
237
+ if (written) console.error(`pdf: ⚠ the rendered page had no slides, the file has ${written}: the deck did not load`);
238
+ }
239
+ const want = slides || written ? expectedPages(slides || written, variant) : 0;
193
240
  const geometry = variant === 'handout' ? 'portrait, 3 slides a page' : variant === 'notes' ? 'slide + notes per page' : '1280×720 (16:9)';
194
241
  console.log(`${out} · ${pages || '?'} pages · ${geometry} · ${KB(buf.length)}`);
195
242
  if (want && pages && pages !== want) {
196
- console.error(`pdf: ⚠ expected ${want} pages for ${slides} slides${variant ? ` (${variant})` : ''}, got ${pages}`);
243
+ console.error(`pdf: ⚠ expected ${want} pages for ${slides || written} slides${variant ? ` (${variant})` : ''}, got ${pages}`);
197
244
  }
198
245
  return 0;
199
246
  }
package/cli/pkg.mjs CHANGED
@@ -7,8 +7,8 @@
7
7
  // WHY THIS IS ONE MODULE AND NOT FIVE CONSTANTS. Four commands write a deck
8
8
  // that carries the runtime inline — `init` scaffolds one, `import` converts
9
9
  // one, `upgrade` refreshes one, `bundle` inlines a referenced one — and
10
- // `audit` recomputes what they SHOULD have produced, so that `present` can
11
- // say whether the runtime in a file is this install's build (PRESENT#AUDIT).
10
+ // `audit` recomputes what they SHOULD have produced, so that `--no-trust` can
11
+ // say whether the runtime in a file is this install's build (NO_TRUST#AUDIT).
12
12
  // That makes the inlining transform a contract between five files, and it was
13
13
  // copied into each of them. `import` copied it slightly wrong: its local
14
14
  // escape covered `</script` and `</style` but not `<!--`, so an imported deck
@@ -41,6 +41,23 @@ export const PKG_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)
41
41
  /** package.json, parsed once. `PKG.version` is the version every command prints. */
42
42
  export const PKG = JSON.parse(fs.readFileSync(path.join(PKG_ROOT, 'package.json'), 'utf8'));
43
43
 
44
+ /**
45
+ * How to type decklight here, for a line that tells someone to run it.
46
+ * `npx decklight` when this install is the project's own (a node_modules on
47
+ * the way up from `cwd` resolves to it), plain `decklight` otherwise: a
48
+ * global install or a link puts the bin on PATH, a project install does not,
49
+ * and a bare `decklight skills` in a project reads as a remark rather than a
50
+ * command, because typing it says "command not found".
51
+ */
52
+ export function selfCommand(cwd = process.cwd(), root = PKG_ROOT) {
53
+ let mine;
54
+ try { mine = fs.realpathSync(root); } catch { return 'decklight'; }
55
+ for (let dir = path.resolve(cwd); ; dir = path.dirname(dir)) {
56
+ try { if (fs.realpathSync(path.join(dir, 'node_modules', 'decklight')) === mine) return 'npx decklight'; } catch { /* not here */ }
57
+ if (path.dirname(dir) === dir) return 'decklight';
58
+ }
59
+ }
60
+
44
61
  /** The shipped theme set — the graded and compat themes that stay in core. */
45
62
  export const THEMES_DIR = path.join(PKG_ROOT, 'themes');
46
63
 
@@ -67,3 +84,28 @@ export function runtimeJs() {
67
84
 
68
85
  /** The installed runtime stylesheet. */
69
86
  export const runtimeCss = () => fs.readFileSync(path.join(PKG_ROOT, 'dist/decklight.css'), 'utf8');
87
+
88
+ /**
89
+ * The installed package's own copy of a file a deck references beside itself
90
+ * but does not ship — `decklight.js`, `decklight.css`, `themes/<name>.css` —
91
+ * as `{ file, type }`, or null for anything else (#517).
92
+ *
93
+ * A deck that LINKS the runtime instead of carrying it is a few KB of slides
94
+ * whose runtime is whatever is installed. Every server (`open`, `--no-trust`,
95
+ * the render server behind pdf/pptx/video) answers those three shapes from
96
+ * here when nothing is on disk, and `bundle` inlines from here at hand-over,
97
+ * so the same deck plays served and travels self-contained. Matched on the
98
+ * path's TAIL, so a deck in `slides/` asking for `slides/decklight.js`, or a
99
+ * source deck reaching up for `../dist/decklight.js`, both resolve. A theme
100
+ * that is not shipped is null, like any other missing file.
101
+ */
102
+ export function packageAsset(rel) {
103
+ const p = String(rel ?? '').split('\\').join('/');
104
+ const base = p.split('/').pop();
105
+ const at = (file, type) => (fs.existsSync(file) ? { file, type } : null);
106
+ if (base === 'decklight.js') return at(path.join(PKG_ROOT, 'dist', 'decklight.js'), 'text/javascript; charset=utf-8');
107
+ if (base === 'decklight.css') return at(path.join(PKG_ROOT, 'dist', 'decklight.css'), 'text/css; charset=utf-8');
108
+ const theme = /(?:^|\/)themes\/([\w-]+)\.css$/.exec(p);
109
+ if (theme) return at(path.join(THEMES_DIR, `${theme[1]}.css`), 'text/css; charset=utf-8');
110
+ return null;
111
+ }
package/cli/plugin.mjs CHANGED
@@ -3,13 +3,13 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
5
  /**
6
- * `decklight plugin` — the presenter's own chrome, installed from a
7
- * marketplace and loaded by `present` (MARKETPLACE.md PRESENT#PLUGINS).
6
+ * `decklight library … plugin` — the presenter's own chrome, installed from a
7
+ * marketplace and loaded by `--no-trust` (MARKETPLACE.md NO_TRUST#PLUGINS).
8
8
  *
9
- * decklight plugin add <name[@marketplace]>
10
- * decklight plugin list
11
- * decklight plugin check <name | directory>
12
- * decklight plugin remove <name>
9
+ * decklight library add plugin <name[@marketplace]>
10
+ * decklight library list plugin
11
+ * decklight library gate plugin <name | directory>
12
+ * decklight library remove plugin <name>
13
13
  *
14
14
  * WHY THIS IS ALLOWED TO EXIST AT ALL. The asymmetry MARKETPLACE.md WHY is
15
15
  * built on: a plugin is safe when the installer is the risk-bearer, and unsafe
@@ -42,8 +42,8 @@
42
42
  *
43
43
  * WHAT IT COSTS THE DECK: nothing. The chrome is injected on the way OUT of
44
44
  * the presenting server, after the ingredients label has already read the
45
- * bytes on disk (PRESENT#AUDIT) and after strict mode has stripped what it
46
- * could not account for (PRESENT#STRICT) — so a plugin is never audited as if
45
+ * bytes on disk (NO_TRUST#AUDIT) and after strict mode has stripped what it
46
+ * could not account for (NO_TRUST#STRICT) — so a plugin is never audited as if
47
47
  * it came from the deck, and never stripped as if it were unaccounted. The
48
48
  * srcdoc frame needs no route and no CSP change (see `chromeMarkup`).
49
49
  */
@@ -56,14 +56,14 @@ import { isMain } from '../tools/args.mjs';
56
56
  import { injectBeforeBodyEnd } from '../tools/deck-html.mjs';
57
57
  // Cache reads only. `loadCatalog` and `resolveEntry` read JSON already on
58
58
  // disk; the fetching half of marketplace.mjs is deliberately not imported
59
- // here, because `present` imports this file and a presenting path that COULD
59
+ // here, because `--no-trust` imports this file and a presenting path that COULD
60
60
  // fetch a catalog breaks registered-not-fetched (SPEC MARKETPLACE_REGISTRY) —
61
61
  // a deck on a plane has to behave exactly like a deck at a desk. The one
62
62
  // network call in this module is `fetchPlugin`, which is an ARTIFACT fetch on
63
63
  // an explicit `plugin add`; `resolveSource` is imported dynamically there so
64
64
  // it is not even resolved on the serving path.
65
65
  import {
66
- configHome, loadRegistry, loadCatalog, resolveEntry, MarketplaceError, NAME_RE,
66
+ configHome, loadRegistry, loadCatalog, resolveEntry, MarketplaceError, NAME_RE, recordInstall, forgetInstall,
67
67
  } from './marketplace.mjs';
68
68
 
69
69
  /** A failure with a message for a human — the mains print it, never a stack. */
@@ -93,7 +93,7 @@ export const SLOTS = ['corner-tl', 'corner-tr', 'corner-bl', 'corner-br', 'edge-
93
93
  * determinism rule is about mutation, and the speaker view already puts these
94
94
  * exact words on this exact machine. What keeps it honest is that it is
95
95
  * DECLARED: a plugin gets notes only by asking for them in its manifest, and
96
- * both `plugin list` and the `present` startup line say which plugins read
96
+ * both `plugin list` and the `--no-trust` startup line say which plugins read
97
97
  * them. A timer never sees a word of the talk.
98
98
  */
99
99
  export const NEEDS = ['position', 'notes'];
@@ -255,7 +255,7 @@ export function loadPlugin(dir) {
255
255
  *
256
256
  * A bad plugin is skipped, never fatal: the alternative is a command that
257
257
  * refuses to present a talk because of a timer, ten minutes before the talk —
258
- * the same argument PRESENT#STRICT settles the same way.
258
+ * the same argument NO_TRUST#STRICT settles the same way.
259
259
  */
260
260
  export function loadLibrary(home = configHome()) {
261
261
  const dir = pluginsDir(home);
@@ -326,7 +326,7 @@ ${plugin.source}
326
326
  * them, and this way the shim needs no handle on a root that may not exist
327
327
  * yet when it runs.
328
328
  *
329
- * Nothing here is added to the runtime: `present` injects this, `bundle` never
329
+ * Nothing here is added to the runtime: `--no-trust` injects this, `bundle` never
330
330
  * does, and a deck opened any other way has never heard of it.
331
331
  */
332
332
  function hostShim(plugins) {
@@ -408,7 +408,7 @@ const CHROME_CSS = `<style>
408
408
  * instead, and the presenting CSP already carries `script-src 'unsafe-inline'`
409
409
  * because a bundled deck IS inline script. So the chrome loads under exactly
410
410
  * the header the deck is served with, no route is registered for it, and
411
- * `present`'s policy string is untouched by a plugin being installed.
411
+ * the no-trust mode's policy string is untouched by a plugin being installed.
412
412
  *
413
413
  * `sandbox="allow-scripts"` without `allow-same-origin` is the load-bearing
414
414
  * attribute: it hands the frame an opaque origin, so `parent.document` throws.
@@ -426,11 +426,11 @@ export function chromeMarkup(plugins) {
426
426
  /**
427
427
  * Put the chrome into a served document, immediately before `</body>`.
428
428
  *
429
- * Called by `present` AFTER the audit has read the file and AFTER strict mode
429
+ * Called by `--no-trust` AFTER the audit has read the file and AFTER strict mode
430
430
  * has run, which is the whole reason the ingredients label stays honest: the
431
431
  * label describes the bytes on disk, and these bytes were never on disk.
432
432
  * With no plugins installed this returns its input unchanged — byte for byte,
433
- * which is what keeps `present` on a machine with an empty library exactly the
433
+ * which is what keeps `--no-trust` on a machine with an empty library exactly the
434
434
  * command it was before this existed.
435
435
  */
436
436
  export function injectChrome(html, plugins) {
@@ -446,24 +446,24 @@ export function injectChrome(html, plugins) {
446
446
 
447
447
  // ── the command ────────────────────────────────────────────────────────────
448
448
 
449
- const USAGE = `usage: decklight plugin <add|list|check|remove> …
449
+ const USAGE = `usage: decklight library <add|list|check|remove> plugin …
450
450
 
451
- decklight plugin add <name[@marketplace]>
451
+ decklight library add plugin <name[@marketplace]>
452
452
  install a presenter plugin from a registered marketplace into your own
453
453
  library under ~/.decklight/plugins/. It is yours: it never enters a deck,
454
454
  never travels with one, and bundle cannot see it
455
- EXAMPLE: decklight plugin add timer
456
- EXAMPLE: decklight plugin add teleprompter@decklight
455
+ EXAMPLE: decklight library add plugin timer
456
+ EXAMPLE: decklight library add plugin teleprompter@decklight
457
457
 
458
- decklight plugin list
458
+ decklight library list plugin
459
459
  what is installed, where each sits, and which ones read your speaker notes
460
460
 
461
- decklight plugin check <name | directory>
461
+ decklight library gate plugin <name | directory>
462
462
  validate a plugin without installing it — the same manifest vocabulary and
463
463
  the same lint the loader applies. Exits non-zero on a refusal, so a
464
464
  plugin's own CI can gate on it
465
465
 
466
- decklight plugin remove <name>
466
+ decklight library remove plugin <name>
467
467
  delete it from your library
468
468
 
469
469
  A plugin is two files. Its code runs in a sandboxed frame with an opaque
@@ -491,10 +491,10 @@ const USAGE = `usage: decklight plugin <add|list|check|remove> …
491
491
 
492
492
  slots: ${SLOTS.join(', ')}
493
493
  needs: ${NEEDS.join(', ')} — "notes" must be declared, and is named in
494
- plugin list and at present startup so you know who is reading them
494
+ plugin list and at every --no-trust start so you know who is reading them
495
495
 
496
- present loads the library; bundle never does. With nothing installed,
497
- present behaves exactly as it does with this command absent.
496
+ --no-trust loads the library; write mode and bundle never do. With nothing
497
+ installed, --no-trust behaves exactly as it does with this command absent.
498
498
  DECKLIGHT_HOME overrides ~/.decklight/.`;
499
499
 
500
500
  /** Read a plugin's two files from a resolved source (a URL or a local dir). */
@@ -530,7 +530,7 @@ function vet(name, files) {
530
530
 
531
531
  async function addMain(args, home) {
532
532
  const [ref] = args.filter((a) => !a.startsWith('-'));
533
- if (!ref) { console.error(`decklight plugin add: needs a plugin name\n\n${USAGE}`); return 1; }
533
+ if (!ref) { console.error(`decklight library add plugin: needs a plugin name\n\n${USAGE}`); return 1; }
534
534
 
535
535
  const reg = loadRegistry(home);
536
536
  const catalogs = {};
@@ -539,18 +539,18 @@ async function addMain(args, home) {
539
539
  if (c?.ok) catalogs[name] = c.manifest;
540
540
  }
541
541
  if (!Object.keys(catalogs).length) {
542
- console.error('decklight plugin add: no marketplace has been fetched yet'
542
+ console.error('decklight library add plugin: no marketplace has been fetched yet'
543
543
  + ' — decklight marketplace update <name> (registered is not fetched)');
544
544
  return 1;
545
545
  }
546
546
 
547
547
  let hit;
548
548
  try { hit = resolveEntry(ref, catalogs); } catch (e) {
549
- console.error(`decklight plugin add: ${e.message}`);
549
+ console.error(`decklight library add plugin: ${e.message}`);
550
550
  return 1;
551
551
  }
552
552
  if (hit.entry.type !== 'plugin') {
553
- console.error(`decklight plugin add: ${hit.qualified} is a ${hit.entry.type}, not a plugin`);
553
+ console.error(`decklight library add plugin: ${hit.qualified} is a ${hit.entry.type}, not a plugin`);
554
554
  return 1;
555
555
  }
556
556
 
@@ -561,7 +561,7 @@ async function addMain(args, home) {
561
561
  { name: hit.marketplace, source: reg.marketplaces[hit.marketplace]?.source }, home);
562
562
  } catch (e) {
563
563
  if (!(e instanceof MarketplaceError)) throw e;
564
- console.error(`decklight plugin add: ${e.message}`);
564
+ console.error(`decklight library add plugin: ${e.message}`);
565
565
  return 1;
566
566
  }
567
567
  let manifest;
@@ -571,7 +571,7 @@ async function addMain(args, home) {
571
571
  manifest = vet(hit.entry.name, files);
572
572
  } catch (e) {
573
573
  if (!(e instanceof PluginError)) throw e;
574
- console.error(`decklight plugin add: ${e.message}`);
574
+ console.error(`decklight library add plugin: ${e.message}`);
575
575
  console.error(`\n ${hit.qualified} was NOT installed`);
576
576
  return 1;
577
577
  }
@@ -580,8 +580,9 @@ async function addMain(args, home) {
580
580
  mkdirSync(dir, { recursive: true });
581
581
  writeFileSync(join(dir, 'plugin.json'), files.manifest);
582
582
  writeFileSync(join(dir, 'plugin.js'), files.source);
583
- console.log(`installed ${manifest.name} from ${hit.qualified} — ${manifest.slot}, reads ${manifest.needs.join(' + ')}`);
584
- console.log(` it is yours, not the deck's: decklight present loads it, bundle never will`);
583
+ recordInstall({ type: 'plugin', name: manifest.name, marketplace: hit.marketplace, version: hit.entry.version, commit: reg.marketplaces[hit.marketplace]?.commit }, home);
584
+ console.log(`installed ${manifest.name}${hit.entry.version ? ` ${hit.entry.version}` : ''} from ${hit.qualified} — ${manifest.slot}, reads ${manifest.needs.join(' + ')}`);
585
+ console.log(` it is yours, not the deck's: decklight <deck> shows it, with or without trust; bundle never will`);
585
586
  if (manifest.needs.includes('notes')) console.log(' it reads your speaker notes — it asked, and plugin list says so');
586
587
  return 0;
587
588
  }
@@ -589,7 +590,7 @@ async function addMain(args, home) {
589
590
  function listMain(home) {
590
591
  const { plugins, refused } = loadLibrary(home);
591
592
  if (!plugins.length && !refused.length) {
592
- console.log('no presenter plugins installed — decklight plugin add <name>');
593
+ console.log('no presenter plugins installed — decklight library add plugin <name>');
593
594
  console.log(` (a plugin is your own chrome: a timer, a teleprompter. It never enters a deck.)`);
594
595
  return 0;
595
596
  }
@@ -604,9 +605,9 @@ function listMain(home) {
604
605
 
605
606
  function checkMain(args, home) {
606
607
  const [target] = args.filter((a) => !a.startsWith('-'));
607
- if (!target) { console.error(`decklight plugin check: needs a plugin name or directory\n\n${USAGE}`); return 1; }
608
+ if (!target) { console.error(`decklight library gate plugin: needs a plugin name or directory\n\n${USAGE}`); return 1; }
608
609
  const dir = existsSync(target) ? resolve(target) : join(pluginsDir(home), target);
609
- if (!existsSync(dir)) { console.error(`decklight plugin check: no such plugin or directory: ${target}`); return 1; }
610
+ if (!existsSync(dir)) { console.error(`decklight library gate plugin: no such plugin or directory: ${target}`); return 1; }
610
611
  let p;
611
612
  try { p = loadPlugin(dir); } catch (e) {
612
613
  if (!(e instanceof PluginError)) throw e;
@@ -621,10 +622,11 @@ function checkMain(args, home) {
621
622
 
622
623
  function removeMain(args, home) {
623
624
  const [name] = args.filter((a) => !a.startsWith('-'));
624
- if (!name) { console.error(`decklight plugin remove: which one?\n\n${USAGE}`); return 1; }
625
+ if (!name) { console.error(`decklight library remove plugin: which one?\n\n${USAGE}`); return 1; }
625
626
  const dir = join(pluginsDir(home), name);
626
- if (!existsSync(dir)) { console.error(`decklight plugin remove: no plugin "${name}" installed (decklight plugin list)`); return 1; }
627
+ if (!existsSync(dir)) { console.error(`decklight library remove plugin: no plugin "${name}" installed (decklight library list plugin)`); return 1; }
627
628
  rmSync(dir, { recursive: true, force: true });
629
+ forgetInstall({ type: 'plugin', name }, home);
628
630
  console.log(`removed ${name}`);
629
631
  return 0;
630
632
  }
@@ -642,12 +644,12 @@ export async function pluginMain(args = []) {
642
644
  if (sub === 'remove') return removeMain(rest, home);
643
645
  } catch (e) {
644
646
  if (e instanceof PluginError || e instanceof MarketplaceError) {
645
- console.error(`decklight plugin ${sub}: ${e.message}`);
647
+ console.error(`decklight library ${sub} plugin: ${e.message}`);
646
648
  return 1;
647
649
  }
648
650
  throw e;
649
651
  }
650
- console.error(`decklight plugin: unknown subcommand "${sub}"\n\n${USAGE}`);
652
+ console.error(`decklight library: unknown verb "${sub}" for a plugin\n\n${USAGE}`);
651
653
  return 1;
652
654
  }
653
655
 
@@ -1,11 +1,11 @@
1
1
  // Copyright 2026 Gilles Philippart
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- // Shared "the port's taken" resolution for `decklight author`'s edit server.
4
+ // Shared "the port's taken" resolution for `decklight <deck>`'s edit server.
5
5
  // The occupant is usually a PAST edit server (you started one
6
- // yesterday, forgot, and now `init`/`author` wants the same default port) — so
6
+ // yesterday, forgot, and now `init`/`open` wants the same default port) — so
7
7
  // rather than guess at a PID, ask it directly: every edit server answers
8
- // GET /edit/ping with the deck it's serving, and POST /edit/shutdown stops it
8
+ // GET /deck/ping with the deck it's serving, and POST /deck/edit/shutdown stops it
9
9
  // as cleanly as its own Ctrl-C (final autocommit included). That makes "kill
10
10
  // it and take over" a plain HTTP round trip, no lsof/ps, no platform split.
11
11
  //
@@ -30,7 +30,7 @@ export function isPortOpen(port, host = '127.0.0.1', timeout = 400) {
30
30
  /** Ask the occupant what it's editing — null if it isn't an edit server at all. */
31
31
  export async function identifyEditServer(port, host = '127.0.0.1') {
32
32
  try {
33
- const res = await fetch(`http://${host}:${port}/edit/ping`, { signal: AbortSignal.timeout(800) });
33
+ const res = await fetch(`http://${host}:${port}/deck/ping`, { signal: AbortSignal.timeout(800) });
34
34
  if (!res.ok) return null;
35
35
  const data = await res.json();
36
36
  return data?.ok ? data : null;
@@ -40,16 +40,18 @@ export async function identifyEditServer(port, host = '127.0.0.1') {
40
40
  }
41
41
 
42
42
  /**
43
- * The same question for a BRIDGE — the voice and lip-sync servers answer
44
- * `/ping`, not `/edit/ping`, so an edit-server probe reports them as strangers
45
- * and the offer to take the port over never appears.
43
+ * The same question for a BRIDGE — the voice bridge answers `/tts/ping` and
44
+ * the lip-sync bridge `/ping`, not `/deck/ping`, so an edit-server probe
45
+ * reports them as strangers and the offer to take the port over never
46
+ * appears.
46
47
  *
47
48
  * Returns the same shape the caller already handles: something with a `name`
48
49
  * to put in a sentence.
49
50
  */
50
51
  export async function identifyBridge(port, host = '127.0.0.1') {
51
52
  try {
52
- const res = await fetch(`http://${host}:${port}/ping`, { signal: AbortSignal.timeout(800) });
53
+ let res = await fetch(`http://${host}:${port}/tts/ping`, { signal: AbortSignal.timeout(800) });
54
+ if (!res.ok) res = await fetch(`http://${host}:${port}/ping`, { signal: AbortSignal.timeout(800) });
53
55
  if (!res.ok) return null;
54
56
  const d = await res.json();
55
57
  if (!d?.ok) return null;
@@ -88,10 +90,10 @@ export function identifyStranger(port, { exec = null } = {}) {
88
90
  }
89
91
  }
90
92
 
91
- /** Ask it to stop — it auto-commits and exits, same as its own Ctrl-C. Resolves once the port is free. */
93
+ /** Ask it to stop — it saves (a snapshot, or a commit under --git-mode timer) and exits, same as its own Ctrl-C. Resolves once the port is free. */
92
94
  export async function shutdownEditServer(port, host = '127.0.0.1') {
93
95
  try {
94
- await fetch(`http://${host}:${port}/edit/shutdown`, { method: 'POST', signal: AbortSignal.timeout(800) });
96
+ await fetch(`http://${host}:${port}/deck/edit/shutdown`, { method: 'POST', signal: AbortSignal.timeout(800) });
95
97
  } catch {
96
98
  // it may hang up mid-response as it exits — that's the expected shape
97
99
  }
@@ -154,14 +156,13 @@ export async function nextFreePort(port, host = '127.0.0.1', tries = 64) {
154
156
  * actually bound and you open that one, so bumping costs nothing.
155
157
  *
156
158
  * a BRIDGE hands its address to nobody. The deck does not discover the
157
- * bridge, it ASSUMES it: `src/core/narration.js` hardcodes
158
- * `http://127.0.0.1:8787/tts` (and derives /ping, /engines, /voices from
159
- * it), `src/core/character.js` hardcodes `:8789`, and the only override is
160
- * a `liveUrl`/`bridgeUrl` written into the deck itself. author passes
161
- * `--tts-port` to the bridge process and never tells the deck — it could
162
- * not tell it anyway, since the deck is served verbatim and is as often
163
- * opened over `file://`. The two sides agree only because both default to
164
- * the same literal.
159
+ * bridge, it ASSUMES it: served over http, `src/core/narration.js` asks its
160
+ * own origin for `/tts` (and derives /ping, /engines, /voices from it) and
161
+ * `src/core/character.js` for `/lipsync`, which the edit server proxies
162
+ * to the ports it gave the bridges (#520); opened from disk, both fall back
163
+ * to `127.0.0.1:8787` and `:8789`, and the only override is a
164
+ * `liveUrl`/`bridgeUrl` written into the deck itself. A bridge run alone
165
+ * for a file:// deck is therefore still assumed at its literal port.
165
166
  *
166
167
  * So a bridge that bumps is a bridge nobody is talking to: the deck keeps
167
168
  * knocking on 8787, reaches whatever squats there, and reports no live voice
@@ -192,11 +193,36 @@ export function planPortConflict({ tty = false, identified = null, stranger = nu
192
193
  * planPortConflict). `kind: 'edit'` never returns null, so the two existing
193
194
  * callers are unaffected.
194
195
  */
196
+ /**
197
+ * The sentence a caller prints for how a conflict ended, when it prints one
198
+ * itself (`outcome` below) rather than taking this file's lines. Pure, so the
199
+ * banner row and the standalone line are tested as words, not by binding ports.
200
+ */
201
+ export function describePortOutcome({ ending, port, next = null, identified = null, stranger = null, kind = 'edit' }) {
202
+ const holder = identified
203
+ ? (identified.bridge ? identified.name : `another decklight editing "${identified.name}"`)
204
+ : stranger ? `${stranger.command} (pid ${stranger.pid})` : null;
205
+ if (ending === 'moved') {
206
+ return `${port} ${holder ? (identified ? `has ${holder}` : `is held by ${holder}`) : 'was taken'} — this one is on ${next}`;
207
+ }
208
+ if (ending === 'reuse') return `${identified?.name ?? 'a decklight bridge'} is already on :${port} — using it`;
209
+ // refuse: a bridge that may not move, on a port somebody else holds
210
+ const sides = kind === 'bridge'
211
+ ? '; free it, or move both sides (--port N and narration.liveUrl in the deck, or --tts-port N alone in write mode)'
212
+ : '';
213
+ return `port ${port} is held by ${holder ?? 'another program'} — not a decklight bridge${sides}`;
214
+ }
215
+
195
216
  export async function resolvePortConflict(port, {
196
217
  host = '127.0.0.1', ask, log = () => {}, kind = 'edit', stranger = identifyStranger,
197
218
  identify = null,
219
+ // How it ENDED, for a caller that says so in its own shape — a banner row
220
+ // under `open` — instead of this file's lines: called with { ending:
221
+ // 'moved' | 'reuse' | 'refuse', port, next, identified, stranger }. The
222
+ // questions above it still print through `log`, since they are asked live.
223
+ outcome = null,
198
224
  } = {}) {
199
- // Ours, whichever kind: an edit server answers /edit/ping, a bridge answers
225
+ // Ours, whichever kind: an edit server answers /deck/ping, a bridge answers
200
226
  // /ping. Asking only the first reported every bridge as a stranger.
201
227
  //
202
228
  // Injectable for the same reason `stranger` is: this REALLY CONNECTS to the
@@ -272,14 +298,16 @@ export async function resolvePortConflict(port, {
272
298
  // deck never calls, so the useful move is to stand aside and say so: null
273
299
  // means "do not listen", and the one on `port` serves the deck as before.
274
300
  if (ending === 'reuse') {
275
- log(` port ${port} already has ${identified.name} on it — using that one rather than starting a second`);
301
+ if (outcome) outcome({ ending, port, identified });
302
+ else log(` port ${port} already has ${identified.name} on it — using that one rather than starting a second`);
276
303
  return null;
277
304
  }
278
305
 
279
306
  // Somebody else's, and a bridge cannot work anywhere but here. Say who has
280
- // it and both ways out, then decline: author reports the bridge as gone and
307
+ // it and both ways out, then decline: `open` reports the bridge as gone and
281
308
  // the deck degrades honestly, which beats a live voice that fails silently.
282
309
  if (ending === 'refuse') {
310
+ if (outcome) { outcome({ ending, port, stranger: other, named }); return null; }
283
311
  if (!named) {
284
312
  log(other
285
313
  ? ` port ${port} is held by ${other.command} (pid ${other.pid}) — not a decklight bridge`
@@ -287,14 +315,16 @@ export async function resolvePortConflict(port, {
287
315
  }
288
316
  log(` the deck asks for this bridge on ${port} and nowhere else, so it will not start.`);
289
317
  log(` free the port (kill ${other ? other.pid : 'the process holding it'}), or move BOTH sides:`);
290
- log(` run with --port N and set narration.liveUrl in the deck to match.`);
318
+ log(` run with --port N and set narration.liveUrl in the deck to match — or, in write mode,`);
319
+ log(` --tts-port N alone: the deck reaches the bridge on the edit server's own origin (/tts).`);
291
320
  return null;
292
321
  }
293
322
 
323
+ const next = await nextFreePort(port + 1, host);
324
+ if (outcome) { outcome({ ending: 'moved', port, next, identified, stranger: other }); return next; }
294
325
  log(identified
295
326
  ? ` port ${port} is already in use — ${identified.bridge ? identified.name : `decklight is editing "${identified.name}"`} there; using a different port`
296
327
  : ` port ${port} is already in use; using a different port`);
297
- const next = await nextFreePort(port + 1, host);
298
328
  log(` → using port ${next}`);
299
329
  return next;
300
330
  }