decklight 0.9.0 → 0.11.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 (133) hide show
  1. package/NOTICE +2 -0
  2. package/PLATFORM.md +61 -3
  3. package/README.md +58 -28
  4. package/SPEC.md +1326 -85
  5. package/cli/agent-review.mjs +5 -4
  6. package/cli/agents.mjs +148 -18
  7. package/cli/bundle-audio.mjs +10 -3
  8. package/cli/bundle-module.mjs +95 -0
  9. package/cli/bundle.mjs +125 -7
  10. package/cli/cast.mjs +86 -19
  11. package/cli/check-fixes.mjs +194 -0
  12. package/cli/check-watch.mjs +151 -0
  13. package/cli/check.mjs +491 -75
  14. package/cli/code-editor.mjs +287 -0
  15. package/cli/commands.mjs +13 -2
  16. package/cli/commit-flow.mjs +7 -3
  17. package/cli/commit-message.mjs +35 -8
  18. package/cli/commit-split.mjs +125 -25
  19. package/cli/deck-refs.mjs +8 -3
  20. package/cli/decklight.mjs +11 -1
  21. package/cli/design-system-edit.mjs +37 -1
  22. package/cli/design-system-refs.mjs +263 -6
  23. package/cli/design-system.mjs +82 -14
  24. package/cli/edit-address.mjs +184 -0
  25. package/cli/edit-git.mjs +23 -6
  26. package/cli/edit-handover.mjs +257 -40
  27. package/cli/edit-look.mjs +293 -6
  28. package/cli/edit-open.mjs +143 -0
  29. package/cli/edit-slides.mjs +1043 -67
  30. package/cli/edit-translate.mjs +243 -0
  31. package/cli/edit.mjs +3680 -319
  32. package/cli/editor-support.mjs +286 -0
  33. package/cli/enhance.mjs +157 -27
  34. package/cli/find-replace.mjs +142 -0
  35. package/cli/fix-review.mjs +368 -0
  36. package/cli/git.mjs +13 -0
  37. package/cli/init.mjs +101 -22
  38. package/cli/keep-awake.mjs +68 -0
  39. package/cli/marketplace-autocheck.mjs +200 -0
  40. package/cli/marketplace.mjs +250 -13
  41. package/cli/migrate-writing.mjs +214 -0
  42. package/cli/narrate.mjs +121 -5
  43. package/cli/open.mjs +53 -15
  44. package/cli/outside-edit.mjs +257 -0
  45. package/cli/paste.mjs +92 -0
  46. package/cli/pdf.mjs +88 -10
  47. package/cli/pptx-export.mjs +10 -5
  48. package/cli/publish.mjs +24 -3
  49. package/cli/record.mjs +86 -15
  50. package/cli/remote.mjs +32 -6
  51. package/cli/rewrite.mjs +265 -0
  52. package/cli/runtime-link.mjs +218 -17
  53. package/cli/serve.mjs +9 -6
  54. package/cli/setup.mjs +2 -2
  55. package/cli/skill-content.mjs +251 -10
  56. package/cli/skills/slide-writing.md +333 -0
  57. package/cli/skills/voiceover.md +423 -0
  58. package/cli/skills.mjs +282 -15
  59. package/cli/starter-full.mjs +353 -0
  60. package/cli/supervise.mjs +14 -0
  61. package/cli/theme-refs.mjs +14 -2
  62. package/cli/theme.mjs +3 -2
  63. package/cli/translate-core.mjs +466 -0
  64. package/cli/translate-files.mjs +149 -0
  65. package/cli/translate.mjs +458 -0
  66. package/cli/units.mjs +75 -7
  67. package/cli/util.mjs +25 -0
  68. package/cli/vocabulary-docs.mjs +138 -0
  69. package/dist/decklight.css +2506 -113
  70. package/dist/decklight.js +385 -175
  71. package/dist/decklight.js.map +4 -4
  72. package/docs/GLOSSARY.md +9 -2
  73. package/docs/WRITING_RESEARCH.md +327 -0
  74. package/package.json +5 -3
  75. package/themes/coastal.css +3 -0
  76. package/themes/metropolis.css +2 -0
  77. package/themes/reveal-blood.css +3 -0
  78. package/themes/reveal-league.css +2 -0
  79. package/themes/reveal-moon.css +2 -0
  80. package/themes/reveal-serif.css +1 -0
  81. package/themes/reveal-sky.css +1 -0
  82. package/themes/reveal-solarized.css +4 -0
  83. package/tools/brand-palette.mjs +6 -1
  84. package/tools/build-groups.mjs +28 -8
  85. package/tools/cdp.mjs +176 -0
  86. package/tools/chart-spec.mjs +242 -0
  87. package/tools/click-match.mjs +70 -0
  88. package/tools/code-options.mjs +174 -0
  89. package/tools/conversation.mjs +49 -0
  90. package/tools/deck-family.mjs +101 -0
  91. package/tools/deck-html.mjs +212 -15
  92. package/tools/design-system-format.mjs +40 -1
  93. package/tools/design-system-migrations.mjs +207 -0
  94. package/tools/diagram-shapes.mjs +221 -0
  95. package/tools/elevenlabs-tts.mjs +62 -53
  96. package/tools/exec.mjs +10 -2
  97. package/tools/face-clip.mjs +96 -0
  98. package/tools/face-layout.mjs +94 -0
  99. package/tools/gemini-tts.mjs +1 -1
  100. package/tools/invisible-in-print.mjs +27 -0
  101. package/tools/lipsync-auto.mjs +197 -0
  102. package/tools/lipsync-config.mjs +16 -0
  103. package/tools/lipsync-engines.mjs +22 -4
  104. package/tools/lipsync-server.mjs +8 -5
  105. package/tools/lipsync.mjs +122 -30
  106. package/tools/local-voice.mjs +1 -1
  107. package/tools/mouth-file.mjs +26 -0
  108. package/tools/mouth.mjs +320 -0
  109. package/tools/narration-manifest.mjs +100 -6
  110. package/tools/narration-synth.mjs +96 -76
  111. package/tools/recording-impact.mjs +16 -1
  112. package/tools/sentences.mjs +7 -1
  113. package/tools/site-clip.mjs +114 -0
  114. package/tools/starters.mjs +402 -0
  115. package/tools/steps.mjs +118 -0
  116. package/tools/take-check.mjs +146 -0
  117. package/tools/template-theme.mjs +3 -1
  118. package/tools/test-impact.mjs +36 -12
  119. package/tools/theme-check.mjs +196 -1
  120. package/tools/tone-cue.mjs +108 -0
  121. package/tools/tts-cache.mjs +9 -3
  122. package/tools/tts-engines.mjs +100 -11
  123. package/tools/video-cache.mjs +93 -0
  124. package/tools/video-live.mjs +349 -0
  125. package/tools/video-options.mjs +11 -0
  126. package/tools/video.mjs +825 -117
  127. package/tools/viseme-fit.mjs +27 -0
  128. package/tools/viseme-match.mjs +77 -0
  129. package/tools/vocabulary.mjs +397 -0
  130. package/tools/voice-renumber.mjs +605 -0
  131. package/tools/voiceover-server.mjs +42 -11
  132. package/tools/voiceover.mjs +48 -20
  133. package/dist/build-info.json +0 -1
@@ -25,7 +25,7 @@
25
25
 
26
26
  import { parseXml, find, findAll } from './ooxml.mjs';
27
27
  import { parseColor, contrast } from './color.mjs';
28
- import { validateTheme, GATES } from './theme-check.mjs';
28
+ import { validateTheme, GATES, settleMark } from './theme-check.mjs';
29
29
 
30
30
  const SLOTS = ['dk1', 'lt1', 'dk2', 'lt2', 'accent1', 'accent2', 'accent3', 'accent4', 'accent5', 'accent6', 'hlink', 'folHlink'];
31
31
 
@@ -146,6 +146,8 @@ export function themeFromTemplate(parsed, { name } = {}) {
146
146
  if (f.startsWith('d-')) continue; // settled above, against every fill at once
147
147
  if (tok[f] && tok[b] && /^#/.test(tok[f]) && /^#/.test(tok[b]) && contrast(rgb(tok[f]), rgb(tok[b])) < min) tok[f] = pushUntil(tok[f], tok[b], min);
148
148
  }
149
+ // a highlight readable on what was derived (PRESENTING_EDITING: emphasis while typing)
150
+ Object.assign(tok, settleMark(tok));
149
151
  const themeName = name ?? `template-${String(parsed.name).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'template'}`;
150
152
  const lines = Object.entries(tok).map(([k, v]) => ` --${k}: ${v};`);
151
153
  const css = `/* Decklight theme · ${themeName}\n light · derived from the PowerPoint template's colour and font schemes\n Token contract: SPEC.md THEMING */\n.decklight {\n${lines.join('\n')}\n}\n`;
@@ -43,16 +43,16 @@ const repo = path.resolve(here, '..');
43
43
  /** narration-render's five concerns, as verify runs them (see test/verify.mjs). */
44
44
  const NARRATION = ['narration-render:live', 'narration-render:picker', 'narration-render:recorded', 'narration-render:segments', 'narration-render:record'];
45
45
  /** engine-render's concerns, likewise (see test/verify.mjs). */
46
- const ENGINE = ['engine-render:themes', 'engine-render:palette', 'engine-render:narration', 'engine-render:navigation', 'engine-render:handover', 'engine-render:sources', 'engine-render:authoring', 'engine-render:builds'];
46
+ const ENGINE = ['engine-render:themes', 'engine-render:palette', 'engine-render:narration', 'engine-render:navigation', 'engine-render:handover', 'engine-render:sources', 'engine-render:typing', 'engine-render:blocks', 'engine-render:diagrams', 'engine-render:builds'];
47
47
 
48
48
  /** Every harness `verify` knows, in its running order. */
49
49
  export const ALL = [
50
50
  'render', 'player-render',
51
51
  'narration-render:live', 'narration-render:picker', 'narration-render:recorded', 'narration-render:segments', 'narration-render:record',
52
52
  'record-render', 'review-render',
53
- 'character-render', 'engine-render:themes', 'engine-render:palette', 'engine-render:narration', 'engine-render:navigation', 'engine-render:handover', 'engine-render:sources', 'engine-render:authoring', 'engine-render:builds', 'pin-render', 'overflow-render', 'split-render',
53
+ 'character-render', 'engine-render:themes', 'engine-render:palette', 'engine-render:narration', 'engine-render:navigation', 'engine-render:handover', 'engine-render:sources', 'engine-render:typing', 'engine-render:blocks', 'engine-render:diagrams', 'engine-render:builds', 'pin-render', 'overflow-render', 'split-render', 'fit-render', 'lines-render', 'figure-render', 'steps-render', 'travel-render', 'conversation-render', 'print-visibility-render',
54
54
  'strict-render', 'shot-render', 'plugin-render', 'extension-check-render',
55
- 'deckfile-render', 'pdf-render', 'pptx-render', 'import-render', 'theme-config-render', 'contrast', 'palette-rules',
55
+ 'deckfile-render', 'pdf-render', 'pptx-render', 'import-render', 'starter-render', 'theme-config-render', 'edit-e2e', 'contrast', 'palette-rules',
56
56
  ];
57
57
 
58
58
  /**
@@ -88,24 +88,45 @@ const RULES = [
88
88
  [/^src\/core\/character\.js$/, ['character-render', ...NARRATION], 'the talking head'],
89
89
  [/^src\/core\/character-art\.js$/, ['character-render'], 'the head it draws'],
90
90
  [/^src\/core\/review\.js$/, ['review-render'], 'the review overlay and its anchor resolver'],
91
- [/^src\/core\/overflow\.js$/, ['overflow-render', 'pin-render'], 'the overflow guardrail and the pinned-title case'],
91
+ [/^src\/core\/print-visibility\.js$/, ['print-visibility-render', 'pdf-render', 'pptx-render', 'engine-render:builds'],
92
+ 'a still finishes the deck\'s own CSS entrances and names what print still does not show: the PDF, the pptx pictures, and the engine\'s loops left alone'],
93
+ [/^src\/core\/overflow\.js$/, ['overflow-render', 'pin-render', 'engine-render:typing', 'engine-render:sources'], 'the overflow guardrail, the pinned-title case, and what clipped says: write mode\'s badge (clipbadge) and the inspector\'s fit row'],
94
+ [/^src\/core\/fit-visual\.js$/, ['overflow-render', 'split-render', 'pin-render', 'pdf-render'], 'a wrapped or split-column diagram shrinking under a long title: the guardrail it answers to, the split and pinned layouts it fits in, and the printed page'],
95
+ [/^src\/core\/(builds-panel|buildlist|build-edit)\.js$/, ['engine-render:builds', 'engine-render:sources', 'engine-render:blocks'], 'the inspector\'s Builds tab and what it writes (buildpanel, buildsettings, buildorder, drawstages, buildselect, contextmenu) and the tab bar it sits in (inspector, inspectortabs)'],
96
+ [/^src\/core\/several\.js$/, ['engine-render:blocks', 'edit-e2e'], 'several selected: the menu, keys and inspector acting on all of them (multiselect)'],
97
+ [/^src\/core\/(block-kind|turn-into)\.js$/, ['engine-render:blocks', 'edit-e2e'], 'Turn into ▸, one block or several joined into one (turninto, multiselect)'],
92
98
  [/^src\/core\/annotate\.js$/, [...ENGINE, 'render'], 'ink rides the engine scale'],
93
99
  [/^src\/core\/themes\.js$/, ['render', 'contrast', 'theme-config-render'], 'theme picking, the theme a deck opens on, and the contrast gate behind it'],
94
- [/^src\/core\/(editmode|history|templates|authoring|colorpicker)\.js$/, ENGINE, 'the author surfaces the engine harness drives'],
100
+ [/^src\/core\/(editmode|history|templates|authoring|links|colorpicker|editbar)\.js$/, [...ENGINE, 'edit-e2e'], 'the author surfaces the engine harness drives, and the real-server pass'],
101
+ [/^src\/core\/list-(edit|session)\.js$/, [...ENGINE, 'edit-e2e'], 'lists and tables typed in like a document: the engine harness drives the keys, the real server writes them'],
102
+ [/^src\/core\/(add-content|element-move|pictures|chartgrid|chartdata|options-tab|shapes|connectors|edit-commit|outside-edit)\.js$/, [...ENGINE, 'edit-e2e'], 'editing a slide in place: the engine harness and the real-server pass'],
103
+ [/^cli\/edit-(slides|address)\.mjs$|^tools\/starters\.mjs$/, ['edit-e2e'], 'the edit routes and where they land in the file, read back by the real-server pass'],
104
+ [/^cli\/outside-edit\.mjs$/, ['edit-e2e'], 'an outside edit, swapped in place or reloaded: the real-server pass writes the file under a page'],
105
+ [/^test\/edit-e2e\.mjs$/, ['edit-e2e'], 'the real-server pass itself'],
95
106
  [/^src\/core\/hud\.js$/, ENGINE, 'clock and progress live on the engine'],
107
+ [/^src\/core\/slide-media\.js$/, [...ENGINE, 'pdf-render'], 'a slide\'s own videos: the engine harness steps through them, print shows their first frame'],
96
108
  [/^src\/core\/finder\.js$/, [...ENGINE, 'review-render'], 'slide titles: the finder names them, review anchors by them'],
109
+ [/^(src\/core\/steps\.js|tools\/steps\.mjs)$/, ['steps-render', 'pdf-render', ...ENGINE], 'a run\'s strip: drawn, numbered, printed, and folded in the finder'],
110
+ [/^src\/core\/travel\.js$/, ['travel-render', 'engine-render:builds', 'engine-render:diagrams', 'edit-e2e'], 'a token along a wire: its trip, its end state, print and the overview; the Builds tab row and Wire ▸ that add and set it'],
111
+ [/^src\/core\/conversation(-menu)?\.js$|^tools\/conversation\.mjs$/, ['conversation-render', 'pdf-render', 'engine-render:blocks', 'edit-e2e'], 'a conversation: its bubbles, its scroll to the newest turn, its printed page, and Turn ▸'],
112
+ [/^src\/core\/figure\.js$/, ['figure-render', 'starter-render', 'pdf-render'], 'figures: their clamp and their count, the starter\'s figures slide, and the printed page'],
97
113
  [/^src\/terminal\//, ['player-render'], 'the cast player'],
114
+ [/^src\/code\/fit\.js$/, ['fit-render', 'pdf-render', 'lines-render'], 'data-fit, the print view pdf reads it from, and the gutter a line walk keeps for its callouts'],
115
+ [/^src\/code\/code\.js$/, ['render', 'lines-render'], 'code blocks render in the smoke deck, and how a line walk ends and names its steps'],
98
116
  [/^src\/code\//, ['render'], 'code blocks render in the smoke deck'],
99
117
  [/^src\/core\//, BROWSER, 'an unmapped core module — assume every harness'],
100
118
 
101
119
  // ── the CLI and tools, each spawned by the harness that tests it ────────
102
120
  [/^cli\/audit\.mjs$/, ['strict-render'], 'the ingredients label and --strict stripping'],
121
+ [/^cli\/check-watch\.mjs$/, [], 'decklight check --watch: its unit test drives it, no harness spawns it'],
103
122
  [/^cli\/bundle\.mjs$/, ['strict-render', 'render'], 'bundling, and the deck it produces'],
104
123
  [/^cli\/plugin\.mjs$/, ['plugin-render'], 'presenter plugins'],
105
124
  [/^cli\/import\.mjs$/, ['import-render'], 'deck import'],
125
+ [/^cli\/(init|starter-full)\.mjs$/, ['starter-render'], 'the starter deck init writes, walked in every theme'],
106
126
  [/^cli\/deckfile\.mjs$/, ['deckfile-render'], 'the .decklight container'],
107
- [/^cli\/pdf\.mjs$/, ['pdf-render'], 'PDF export'],
108
- [/^cli\/pptx-export\.mjs$/, ['pptx-render'], 'PowerPoint export'],
127
+ [/^cli\/pdf\.mjs$/, ['pdf-render', 'print-visibility-render'], 'PDF export, and what it says about a slide that prints with a hole'],
128
+ [/^tools\/invisible-in-print\.mjs$/, ['print-visibility-render', 'pdf-render'], 'the sentence pdf, check and the Check deck panel say about a slide that prints with a hole'],
129
+ [/^cli\/pptx-export\.mjs$/, ['pptx-render', 'lines-render'], 'PowerPoint export, and the printed page it asks for (capture=print)'],
109
130
  [/^tools\/pptx-write\.mjs$/, ['pptx-render'], 'the file the PowerPoint export writes'],
110
131
  [/^cli\/(edit|shot)\.mjs$/, ['shot-render'], 'the deck server, and the screenshot containment it asserts'],
111
132
  [/^cli\/(comments|review-anchor|review-store|review-remote|review-submit)\.mjs$/, ['review-render'],
@@ -117,9 +138,11 @@ const RULES = [
117
138
  [/^tools\/chrome\.mjs$/, ALL, 'every harness starts a browser through it'],
118
139
  [/^tools\/render-theme\.mjs$/, ['pdf-render', 'pptx-render', 'shot-render'], 'the theme a render is told to open on'],
119
140
  [/^tools\/review-anchor\.mjs$/, ['review-render'], 'the anchor resolver both halves share'],
141
+ [/^tools\/code-options\.mjs$/, ['engine-render:blocks', 'edit-e2e', 'lines-render'], 'a code block\'s settings: the Options tab shows them, the edit server writes them, and the runtime reads its callouts'],
142
+ [/^tools\/vocabulary\.mjs$/, ['engine-render:palette'], 'the authoring vocabulary: Check deck… reads it off the live page'],
120
143
  [/^tools\/(tts-engines|local-voice|voiceover-server|lipsync)\.mjs$/, [...NARRATION, 'record-render'],
121
144
  'the voice bridge narration talks to'],
122
- [/^themes\//, ['render', ...LINT], 'a theme, and the gates that read every theme'],
145
+ [/^themes\//, ['render', 'starter-render', ...LINT], 'a theme, the gates that read every theme, and the full starter walked in each'],
123
146
  [/^demo\//, ['render'], 'the smoke deck itself'],
124
147
 
125
148
  // ── things no harness reads ────────────────────────────────────────────
@@ -128,6 +151,7 @@ const RULES = [
128
151
  [/^(docs|\.github|\.claude)\//, [], 'not read by any harness'],
129
152
  [/^(SPEC|README|CONTRIBUTING|CLAUDE|CHANGELOG)\.md$/, [], 'prose'],
130
153
  [/^test\/.*\.test\.mjs$/, [], 'a unit test — the unit suite covers it'],
154
+ [/^cli\/(editor-support|vocabulary-docs)\.mjs$/, [], 'the .vscode/ files init and vscode write: no browser reads them, the unit suite does'],
131
155
  ];
132
156
 
133
157
  /** Which harnesses a single path implicates, and why. */
@@ -223,13 +247,13 @@ const selected = ALL.filter((h) => picked.has(h));
223
247
  const COST = {
224
248
  'narration-render:live': 25, 'narration-render:picker': 12, 'narration-render:recorded': 12,
225
249
  'narration-render:segments': 12, 'narration-render:record': 40, 'extension-check-render': 23, render: 20,
226
- // engine-render's seven, roughly a second a mode plus a browser start
250
+ // engine-render's ten, roughly a second a mode plus a browser start
227
251
  'engine-render:themes': 6, 'engine-render:palette': 5, 'engine-render:narration': 4,
228
252
  'engine-render:navigation': 4, 'engine-render:handover': 4,
229
- 'engine-render:sources': 3, 'engine-render:authoring': 3, 'engine-render:builds': 3,
230
- 'pdf-render': 10, 'split-render': 9, 'review-render': 8, 'pin-render': 7, 'record-render': 7,
253
+ 'engine-render:sources': 3, 'engine-render:typing': 2, 'engine-render:blocks': 2, 'engine-render:diagrams': 1, 'engine-render:builds': 3,
254
+ 'pdf-render': 10, 'split-render': 9, 'fit-render': 8, 'lines-render': 4, 'figure-render': 3, 'conversation-render': 3, 'steps-render': 3, 'travel-render': 3, 'print-visibility-render': 6, 'review-render': 8, 'pin-render': 7, 'record-render': 7,
231
255
  'strict-render': 6, 'overflow-render': 6, 'plugin-render': 6, 'deckfile-render': 4,
232
- 'shot-render': 4, 'pptx-render': 6, 'player-render': 3, 'character-render': 2, 'import-render': 2, 'theme-config-render': 3,
256
+ 'shot-render': 4, 'pptx-render': 6, 'edit-e2e': 30, 'player-render': 3, 'character-render': 2, 'import-render': 2, 'starter-render': 12, 'theme-config-render': 3,
233
257
  contrast: 1, 'palette-rules': 1,
234
258
  };
235
259
  const cost = (list) => list.reduce((n, h) => n + (COST[h] ?? 10), 0);
@@ -144,7 +144,202 @@ export function validateTheme(css) {
144
144
  }
145
145
  }
146
146
 
147
- return { ok: errors.length === 0, tokens, exceptions, missing, failures, errors, empty: false };
147
+ // A highlight (`<mark>`, PRESENTING_EDITING): words marked while typing sit
148
+ // on the theme's accent tinted over the slide, `--mark-bg`, by default
149
+ // `--mark-tint` (25%) of the accent; a theme may set the tint, or its own
150
+ // `--mark-bg` and `--mark-fg`. Over every background stop the marked words
151
+ // must stay as readable as body text, headings and muted words, and the
152
+ // mark must show. These are WARNINGS: a theme written before highlights
153
+ // existed (a marketplace's, a deck's own) still applies, and `theme gate`
154
+ // names what to set. The shipped themes are held to them (test/contrast.mjs).
155
+ // A line walk's callout (CODE_AND_MATH, #1182) draws its bracket in
156
+ // `--callout-ink`, the accent unless the theme says otherwise, on the code's
157
+ // ground: a warning too, for the same reason. So is a figure's value
158
+ // (DECK_ANATOMY), `--figure-ink`, else the accent, on the slide, and a
159
+ // run's current group in its strip, `--steps-ink`, else the accent; and a
160
+ // conversation's bubbles (DECK_ANATOMY), `--turn-*`, else the block's
161
+ // ground and the body ink, and the accent and its contrast for the user.
162
+ const warnings = [...markGates(tokens), ...calloutGates(tokens), ...figureGates(tokens), ...stepsGates(tokens), ...turnGates(tokens)].map((m) => m.message);
163
+
164
+ return { ok: errors.length === 0, tokens, exceptions, missing, failures, errors, warnings, empty: false };
165
+ }
166
+
167
+ /** The accent's share in a highlight when the theme says nothing: `color-mix(in srgb, var(--accent) 25%, transparent)`. */
168
+ export const MARK_TINT = 0.25;
169
+ /** How far a highlight must stand from the slide behind it, in OKLab distance, to read as one. */
170
+ export const MARK_MIN_DISTANCE = 0.05;
171
+
172
+ /**
173
+ * What a theme made from a palette (a PowerPoint template, a brand) adds so
174
+ * its highlight passes: nothing when the default tint does, else the
175
+ * nearest `--mark-tint` that does (lighter first, down to 6%, then stronger,
176
+ * up to 70%, for an accent too pale to show), else a highlight of its own
177
+ * (`--mark-bg`, the accent at 12% over the first background stop, and
178
+ * `--mark-fg`, whichever of fg and heading-color reads best on it). Tokens
179
+ * without the `--`, as `markGates` takes them.
180
+ */
181
+ export function settleMark(tokens) {
182
+ if (!markGates(tokens).length) return {};
183
+ // lighter first (the words lose their edge on a strong tint), then stronger (a pale accent does not show)
184
+ const tints = [22, 20, 18, 16, 14, 12, 10, 8, 6, 30, 35, 40, 45, 50, 60, 70];
185
+ for (const pct of tints) {
186
+ const add = { 'mark-tint': `${pct}%` };
187
+ if (!markGates({ ...tokens, ...add }).length) return add;
188
+ }
189
+ const accent = colorsIn(tokens.accent ?? '')[0];
190
+ const stop = colorsIn(tokens.bg ?? '')[0];
191
+ if (!accent || !stop) return {};
192
+ const tone = tintOver(accent, stop, 0.12);
193
+ const inks = ['fg', 'heading-color'].map((k) => colorsIn(tokens[k] ?? '')[0]).filter(Boolean);
194
+ const ink = inks.sort((a, b) => contrast(b, tone) - contrast(a, tone))[0];
195
+ const hex = (c) => '#' + c.map((v) => Math.round(v).toString(16).padStart(2, '0')).join('');
196
+ return ink ? { 'mark-bg': hex(tone), 'mark-fg': hex(ink) } : {};
197
+ }
198
+
199
+ /** `tint` over `bg`, as the page composites a translucent accent: in sRGB, by alpha. */
200
+ const tintOver = (tint, bg, alpha) => tint.map((c, i) => Math.round(c * alpha + bg[i] * (1 - alpha)));
201
+
202
+ /**
203
+ * The highlight's gates for a theme's tokens, as failures (none: it passes).
204
+ * The mark behind the words is the theme's opaque `--mark-bg` when it sets
205
+ * one, else its accent at `--mark-tint` over each background stop.
206
+ */
207
+ export function markGates(tokens) {
208
+ const out = [];
209
+ const accent = colorsIn(tokens.accent ?? '')[0];
210
+ const stops = colorsIn(tokens.bg ?? '');
211
+ if (!accent || !stops.length) return out; // missing or unparseable: already reported
212
+ const own = tokens['mark-bg'] ? colorsIn(tokens['mark-bg'])[0] : null;
213
+ const pct = /^\s*([\d.]+)%\s*$/.exec(tokens['mark-tint'] ?? '');
214
+ const alpha = pct ? Number(pct[1]) / 100 : MARK_TINT;
215
+ const ink = (name) => colorsIn(tokens['mark-fg'] ?? tokens[name] ?? '')[0];
216
+ // body text as body text; a heading as a heading; a subtitle's muted words as a diagram's sublabels
217
+ const gates = [['fg', 4.5], ['heading-color', 3.0], ['muted', 2.6]];
218
+ for (const stop of stops) {
219
+ const tone = own ?? tintOver(accent, stop, alpha);
220
+ for (const [name, min] of gates) {
221
+ const fg = ink(name);
222
+ if (!fg) continue;
223
+ const ratio = contrast(fg, tone);
224
+ if (ratio < min) {
225
+ out.push({ fg: tokens['mark-fg'] ? 'mark-fg' : name, bg: 'mark-bg', min, ratio,
226
+ message: `--${tokens['mark-fg'] ? 'mark-fg' : name} on a highlight (--mark-bg${own ? '' : `, the accent at ${Math.round(alpha * 100)}%`}): ${ratio.toFixed(2)} < ${min} — lower --mark-tint, or set --mark-bg and --mark-fg` });
227
+ }
228
+ }
229
+ const [a, b] = [toOklab(tone), toOklab(stop)];
230
+ const distance = Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
231
+ if (distance < MARK_MIN_DISTANCE) {
232
+ out.push({ fg: 'mark-bg', bg: 'bg', min: MARK_MIN_DISTANCE, ratio: distance,
233
+ message: `--mark-bg on --bg: OKLab distance ${distance.toFixed(3)} < ${MARK_MIN_DISTANCE} — a highlight would not show` });
234
+ }
235
+ }
236
+ return out;
237
+ }
238
+
239
+ /** How far a callout's bracket stands from the code's ground: a graphic, not words (WCAG 1.4.11). */
240
+ export const CALLOUT_MIN = 3.0;
241
+
242
+ /**
243
+ * The callout bracket's gate (CODE_AND_MATH, #1182) for a theme's tokens, as
244
+ * failures (none: it passes): `--callout-ink`, else `--accent`, on every stop
245
+ * of `--code-bg`. The label itself is `--code-fg`, which the contract gates.
246
+ */
247
+ export function calloutGates(tokens) {
248
+ const name = tokens['callout-ink'] ? 'callout-ink' : 'accent';
249
+ if (!tokens[name] || !tokens['code-bg']) return []; // missing: already reported
250
+ const ratio = minContrast(tokens[name], tokens['code-bg']);
251
+ if (ratio === null || ratio >= CALLOUT_MIN) return [];
252
+ return [{ fg: name, bg: 'code-bg', min: CALLOUT_MIN, ratio,
253
+ message: `--${name} on --code-bg: ${ratio.toFixed(2)} < ${CALLOUT_MIN} — a code callout's bracket would not show: set --callout-ink` }];
254
+ }
255
+
256
+ /** How far a figure's value stands from the slide: large type, WCAG 1.4.3's 3:1. */
257
+ export const FIGURE_MIN = 3.0;
258
+
259
+ /**
260
+ * A figure's gate (DECK_ANATOMY) for a theme's tokens, as failures (none: it
261
+ * passes): its value, `--figure-ink`, else `--accent`, on every stop of
262
+ * `--bg`. The value is set several times the body size, so large text's 3:1.
263
+ */
264
+ export function figureGates(tokens) {
265
+ const name = tokens['figure-ink'] ? 'figure-ink' : 'accent';
266
+ if (!tokens[name] || !tokens.bg) return []; // missing: already reported
267
+ const ratio = minContrast(tokens[name], tokens.bg);
268
+ if (ratio === null || ratio >= FIGURE_MIN) return [];
269
+ return [{ fg: name, bg: 'bg', min: FIGURE_MIN, ratio,
270
+ message: `--${name} on --bg: ${ratio.toFixed(2)} < ${FIGURE_MIN} — a figure's value would not read: set --figure-ink` }];
271
+ }
272
+
273
+ /** How far a run's current group stands from the slide: bold type at 19 design px, WCAG 1.4.3's large-text 3:1. */
274
+ export const STEPS_MIN = 3.0;
275
+
276
+ /**
277
+ * A run's strip's gate (DECK_ANATOMY, #1188) for a theme's tokens, as
278
+ * failures (none: it passes): the group the slide is in, `--steps-ink`, else
279
+ * `--accent`, on every stop of `--bg`. The other groups and the count are
280
+ * `--fg` and `--muted`, which the contract gates.
281
+ */
282
+ export function stepsGates(tokens) {
283
+ const name = tokens['steps-ink'] ? 'steps-ink' : 'accent';
284
+ if (!tokens[name] || !tokens.bg) return []; // missing: already reported
285
+ const ratio = minContrast(tokens[name], tokens.bg);
286
+ if (ratio === null || ratio >= STEPS_MIN) return [];
287
+ return [{ fg: name, bg: 'bg', min: STEPS_MIN, ratio,
288
+ message: `--${name} on --bg: ${ratio.toFixed(2)} < ${STEPS_MIN} — a run's current step would not read: set --steps-ink` }];
289
+ }
290
+
291
+ /** A conversation's words on their bubble are body text: WCAG 1.4.3's 4.5:1. */
292
+ export const TURN_MIN = 4.5;
293
+
294
+ /** A colour literal's alpha (rgba(), hsla(), #rrggbbaa, #rgba), 1 when it has none. */
295
+ function alphaOf(value) {
296
+ const v = String(value ?? '').trim();
297
+ const fn = /^(?:rgb|hsl)a?\(([^)]*)\)$/i.exec(v);
298
+ if (fn) {
299
+ const parts = fn[1].split(/[\s,/]+/).filter(Boolean);
300
+ if (parts.length < 4) return 1;
301
+ const a = parts[3].endsWith('%') ? parseFloat(parts[3]) / 100 : parseFloat(parts[3]);
302
+ return Number.isFinite(a) ? Math.min(1, Math.max(0, a)) : 1;
303
+ }
304
+ const hex = /^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(v);
305
+ if (hex) return parseInt(hex[1].length === 4 ? hex[1][3].repeat(2) : hex[1].slice(6), 16) / 255;
306
+ return 1;
307
+ }
308
+
309
+ /**
310
+ * A conversation's gates (DECK_ANATOMY, #1179) for a theme's tokens, as
311
+ * failures (none: it passes). An agent's, a tool's or a system's bubble is
312
+ * `--turn-bg`, else `--block-bg` (a translucent one over every stop of
313
+ * `--bg`), its words `--turn-ink`, else `--fg`; the user's is `--turn-user-bg`,
314
+ * else `--accent`, its words `--turn-user-ink`, else `--accent-contrast`. Both
315
+ * are read as body text. A thought is `--muted` on the slide and a tool's turn
316
+ * the code's ink on the code's ground, which the contract gates.
317
+ */
318
+ export function turnGates(tokens) {
319
+ const out = [];
320
+ const bgName = tokens['turn-bg'] ? 'turn-bg' : 'block-bg';
321
+ const inkName = tokens['turn-ink'] ? 'turn-ink' : 'fg';
322
+ const ink = colorsIn(tokens[inkName] ?? '')[0];
323
+ const ground = colorsIn(tokens[bgName] ?? '')[0];
324
+ const stops = colorsIn(tokens.bg ?? '');
325
+ if (ink && ground && stops.length) {
326
+ const alpha = alphaOf(tokens[bgName]);
327
+ const ratio = Math.min(...stops.map((s) => contrast(ink, tintOver(ground, s, alpha))));
328
+ if (ratio < TURN_MIN) {
329
+ out.push({ fg: inkName, bg: bgName, min: TURN_MIN, ratio,
330
+ message: `--${inkName} on --${bgName}: ${ratio.toFixed(2)} < ${TURN_MIN} — a conversation's turn would not read: set --turn-bg and --turn-ink` });
331
+ }
332
+ }
333
+ const userBg = tokens['turn-user-bg'] ? 'turn-user-bg' : 'accent';
334
+ const userInk = tokens['turn-user-ink'] ? 'turn-user-ink' : 'accent-contrast';
335
+ if (tokens[userBg] && tokens[userInk]) {
336
+ const ratio = minContrast(tokens[userInk], tokens[userBg]);
337
+ if (ratio !== null && ratio < TURN_MIN) {
338
+ out.push({ fg: userInk, bg: userBg, min: TURN_MIN, ratio,
339
+ message: `--${userInk} on --${userBg}: ${ratio.toFixed(2)} < ${TURN_MIN} — a user's turn would not read: set --turn-user-bg and --turn-user-ink` });
340
+ }
341
+ }
342
+ return out;
148
343
  }
149
344
 
150
345
  /** The least OKLab lightness step between a panel and the tone of a box nested in it. */
@@ -0,0 +1,108 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // A tone, as each engine can take it. Gemini reads a delivery instruction as a
5
+ // prompt prefix, so a tone there is a sentence of prose. ElevenLabs v3/v4 read
6
+ // a bracketed audio tag in front of the text, and a tag is a short performance
7
+ // cue: a paragraph cut to fit one is a fragment the model cannot act on, and
8
+ // in front of a four-word sentence it is the shape ElevenLabs warns makes a
9
+ // take stutter (#1005).
10
+ //
11
+ // In tools/ because the deck's tone picker (src/core/narration.js), the bridge
12
+ // and `decklight narrate` (tools/elevenlabs-tts.mjs) all need the same tones
13
+ // and the same cut. Pure, so the runtime bundles it.
14
+
15
+ /**
16
+ * The built-in tones: `[label, Gemini directive, ElevenLabs cue, group]`.
17
+ *
18
+ * The directives are single instruction clauses: instruction-shaped text
19
+ * steers, while persona sentences ("You're a…") can stochastically be read
20
+ * aloud. Each cue is the SAME tone in a few words, short enough to reach
21
+ * ElevenLabs whole, and close to the tags ElevenLabs documents: an invented
22
+ * cue is one the model ignores or reads aloud. The group is the heading the
23
+ * V panel lists it under: ways to present first, then moods, then the ones
24
+ * for a laugh.
25
+ */
26
+ const PRESENTING = 'presenting';
27
+ const MOODS = 'moods';
28
+ const FOR_A_LAUGH = 'for a laugh';
29
+ export const TONES = [
30
+ ['Warm senior engineer', 'Read in a warm, welcoming tone, like a friendly battle-hardened senior engineer who is still curious about new technology.', 'warmly, like a seasoned engineer', PRESENTING],
31
+ ['Professional', 'Read in a clear, professional tone — measured, confident, and articulate.', 'clear and professional', PRESENTING],
32
+ ['Calm explainer', 'Read in a calm, patient tone, like a teacher walking a class through something for the first time, pausing on the key words.', 'calm, patient', PRESENTING],
33
+ ['Conversational', 'Read in a relaxed, conversational tone, as if talking to one colleague across a desk rather than to a room.', 'conversational, relaxed', PRESENTING],
34
+ ['Keynote', 'Read in a confident, energetic tone with clear emphasis, like a speaker opening a conference.', 'confident, energetic', PRESENTING],
35
+ ['Documentary', "Read in a measured, unhurried narrator's voice, with weight on the facts and no sales pitch.", 'narrating a documentary', PRESENTING],
36
+ ['Storyteller', 'Read as a storyteller, with warmth and a sense of anticipation, letting each sentence land before the next.', 'storytelling, warm', PRESENTING],
37
+ ['Plain and brisk', 'Read in a plain, brisk tone with no flourish, like release notes read aloud.', 'neutral, brisk', PRESENTING],
38
+ ['Joyful', 'Read in a joyful, light-hearted tone, smiling through every sentence.', 'joyfully, smiling', MOODS],
39
+ ['Super excited', 'Read in a super-excited, high-energy tone, barely containing your enthusiasm.', 'super excited', MOODS],
40
+ ['Sad', 'Read in a somber, melancholic tone, on the verge of a sigh.', 'sadly, on the verge of a sigh', MOODS],
41
+ ['Too serious', 'Read in an extremely grave, deadly serious tone, as if announcing news of the utmost importance.', 'gravely serious', FOR_A_LAUGH],
42
+ ['Deadpan', 'Read in a completely flat, deadpan tone, never acknowledging that anything is funny.', 'deadpan', FOR_A_LAUGH],
43
+ ['Breaking news', 'Read in an urgent, breathless tone, like a reporter breaking a story live.', 'urgent, breaking news', FOR_A_LAUGH],
44
+ ['Whisper', 'Read in a hushed whisper, as if sharing a secret in a library.', 'whispers', FOR_A_LAUGH],
45
+ ['Sports commentator', 'Read like a sports commentator calling the final minute of a close match, fast and rising.', 'excited sports commentary', FOR_A_LAUGH],
46
+ ['Noir detective', "Read in a low, world-weary noir detective's voice, slow and full of pauses.", 'low, world-weary', FOR_A_LAUGH],
47
+ ];
48
+
49
+ // A tag this long stops being a short performance cue and starts being a
50
+ // second sentence. 40 chars covers every named ElevenLabs tag with room for a
51
+ // typed phrase like "on the verge of tears" and still reads as direction.
52
+ export const MAX_TAG_LEN = 40;
53
+
54
+ /**
55
+ * The cue a style stands for on an engine that reads tags: a built-in tone's
56
+ * Gemini directive is its short cue, anything else is itself. So a deck or a
57
+ * track that saved the directive (picked on Gemini, then moved to ElevenLabs)
58
+ * still sends the tone, not the first forty characters of its prose.
59
+ */
60
+ export function cueFor(style) {
61
+ const raw = String(style ?? '').trim();
62
+ return TONES.find(([, directive]) => directive === raw)?.[2] ?? raw;
63
+ }
64
+
65
+ // Words a cut cue cannot end on: "like a" is not direction, "warm" is.
66
+ const DANGLING = /(?:[\s,;:—–-]+|\s+(?:a|an|the|and|or|but|nor|as|like|of|to|with|who|which|that|is|are|in|on|at|for|from|by|than|while|your|my|its|very|so|quite|really|most|more|just))+$/i;
67
+
68
+ /**
69
+ * A style as one ElevenLabs audio tag, and whether it had to be cut to be one:
70
+ * `{ tag, cut }`, `tag` '' when there is nothing to say.
71
+ *
72
+ * Someone who already knows the syntax can type `[whispers]` and get exactly
73
+ * that cue: the first well-formed bracketed group survives untouched (and only
74
+ * the first: a second `[…]` would be a second cue riding along uninvited).
75
+ * Anyone else types a word or a phrase, which is wrapped in brackets for them.
76
+ * A cue longer than `maxLen` is cut at the last word that fits, and a trailing
77
+ * comma or connective goes with the cut, so the tag ends on a word that stands.
78
+ */
79
+ export function cutTag(style, maxLen = MAX_TAG_LEN) {
80
+ const raw = cueFor(style);
81
+ if (!raw) return { tag: '', cut: false };
82
+ const bracketed = raw.match(/^\[([^[\]]+)\]/);
83
+ const whole = (bracketed ? bracketed[1] : raw).trim().replace(/\s+/g, ' ');
84
+ if (whole.length <= maxLen) return { tag: whole ? `[${whole}]` : '', cut: false };
85
+ // the slice ends on a word when the character after it is a space
86
+ const space = whole[maxLen] === ' ' ? maxLen : whole.lastIndexOf(' ', maxLen);
87
+ // one word longer than the cap has no boundary to cut at: cut it there
88
+ let cue = space > 0 ? whole.slice(0, space) : whole.slice(0, maxLen);
89
+ for (let was; was !== cue;) { was = cue; cue = cue.replace(DANGLING, ''); }
90
+ cue = cue.trim();
91
+ return { tag: cue ? `[${cue}]` : '', cut: true };
92
+ }
93
+
94
+ /** {@link cutTag}'s tag alone. */
95
+ export const styleTag = (style, maxLen = MAX_TAG_LEN) => cutTag(style, maxLen).tag;
96
+
97
+ /**
98
+ * The line that tells an author their tone will not reach ElevenLabs as they
99
+ * wrote it, or null when it does. One wording for the deck's tone row and for
100
+ * `decklight narrate`.
101
+ */
102
+ export function cutNote(style, maxLen = MAX_TAG_LEN) {
103
+ const { tag, cut } = cutTag(style, maxLen);
104
+ if (!cut) return null;
105
+ return tag
106
+ ? `cut to ${tag} for ElevenLabs — tones here are short cues`
107
+ : 'too long for an ElevenLabs cue and dropped — tones here are short cues';
108
+ }
@@ -3,7 +3,7 @@
3
3
 
4
4
  /**
5
5
  * The synthesis cache on disk — one clip per (engine, model, format, voice,
6
- * style, text), shared by everything that speaks.
6
+ * style, text, and the language the engine was told), shared by everything that speaks.
7
7
  *
8
8
  * It lived inside tools/voiceover-server.mjs and served only the free local
9
9
  * engines, on the argument that a cloud engine's output drifts with the
@@ -74,8 +74,13 @@ export const CACHE_EXTS = ['.wav', '.mp3'];
74
74
  * written as an ESCAPE, not a raw byte: git calls any file with a NUL in its
75
75
  * first 8 KB binary, and this file would silently become undiffable.
76
76
  */
77
- export function cacheKey({ engine, model, format, voice, style, text } = {}) {
78
- const fields = [engine, model, format, voice, style, text];
77
+ export function cacheKey({ engine, model, format, voice, style, text, lang } = {}) {
78
+ // `lang` is the language an engine was TOLD to speak, and only that: an
79
+ // engine told none (every one, before a deck's language reached the voice)
80
+ // hashes exactly as it always has, so no clip and no recorded take goes
81
+ // stale for a field it never had. Told one, "Six" in French and "Six" in
82
+ // English are different audio under different names.
83
+ const fields = [engine, model, format, voice, style, text, ...(lang ? [lang] : [])];
79
84
  return createHash('sha256')
80
85
  .update(fields.map((f) => f ?? '').join('\u0000'))
81
86
  .digest('hex');
@@ -127,6 +132,7 @@ export function clipKey(engine, { voice, style, text } = {}) {
127
132
  voice: voiceId,
128
133
  style: engine?.stylable ? style : undefined,
129
134
  text,
135
+ lang: engine?.lang,
130
136
  });
131
137
  }
132
138