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.
- package/NOTICE +2 -0
- package/PLATFORM.md +61 -3
- package/README.md +58 -28
- package/SPEC.md +1326 -85
- package/cli/agent-review.mjs +5 -4
- package/cli/agents.mjs +148 -18
- package/cli/bundle-audio.mjs +10 -3
- package/cli/bundle-module.mjs +95 -0
- package/cli/bundle.mjs +125 -7
- package/cli/cast.mjs +86 -19
- package/cli/check-fixes.mjs +194 -0
- package/cli/check-watch.mjs +151 -0
- package/cli/check.mjs +491 -75
- package/cli/code-editor.mjs +287 -0
- package/cli/commands.mjs +13 -2
- package/cli/commit-flow.mjs +7 -3
- package/cli/commit-message.mjs +35 -8
- package/cli/commit-split.mjs +125 -25
- package/cli/deck-refs.mjs +8 -3
- package/cli/decklight.mjs +11 -1
- package/cli/design-system-edit.mjs +37 -1
- package/cli/design-system-refs.mjs +263 -6
- package/cli/design-system.mjs +82 -14
- package/cli/edit-address.mjs +184 -0
- package/cli/edit-git.mjs +23 -6
- package/cli/edit-handover.mjs +257 -40
- package/cli/edit-look.mjs +293 -6
- package/cli/edit-open.mjs +143 -0
- package/cli/edit-slides.mjs +1043 -67
- package/cli/edit-translate.mjs +243 -0
- package/cli/edit.mjs +3680 -319
- package/cli/editor-support.mjs +286 -0
- package/cli/enhance.mjs +157 -27
- package/cli/find-replace.mjs +142 -0
- package/cli/fix-review.mjs +368 -0
- package/cli/git.mjs +13 -0
- package/cli/init.mjs +101 -22
- package/cli/keep-awake.mjs +68 -0
- package/cli/marketplace-autocheck.mjs +200 -0
- package/cli/marketplace.mjs +250 -13
- package/cli/migrate-writing.mjs +214 -0
- package/cli/narrate.mjs +121 -5
- package/cli/open.mjs +53 -15
- package/cli/outside-edit.mjs +257 -0
- package/cli/paste.mjs +92 -0
- package/cli/pdf.mjs +88 -10
- package/cli/pptx-export.mjs +10 -5
- package/cli/publish.mjs +24 -3
- package/cli/record.mjs +86 -15
- package/cli/remote.mjs +32 -6
- package/cli/rewrite.mjs +265 -0
- package/cli/runtime-link.mjs +218 -17
- package/cli/serve.mjs +9 -6
- package/cli/setup.mjs +2 -2
- package/cli/skill-content.mjs +251 -10
- package/cli/skills/slide-writing.md +333 -0
- package/cli/skills/voiceover.md +423 -0
- package/cli/skills.mjs +282 -15
- package/cli/starter-full.mjs +353 -0
- package/cli/supervise.mjs +14 -0
- package/cli/theme-refs.mjs +14 -2
- package/cli/theme.mjs +3 -2
- package/cli/translate-core.mjs +466 -0
- package/cli/translate-files.mjs +149 -0
- package/cli/translate.mjs +458 -0
- package/cli/units.mjs +75 -7
- package/cli/util.mjs +25 -0
- package/cli/vocabulary-docs.mjs +138 -0
- package/dist/decklight.css +2506 -113
- package/dist/decklight.js +385 -175
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +9 -2
- package/docs/WRITING_RESEARCH.md +327 -0
- package/package.json +5 -3
- package/themes/coastal.css +3 -0
- package/themes/metropolis.css +2 -0
- package/themes/reveal-blood.css +3 -0
- package/themes/reveal-league.css +2 -0
- package/themes/reveal-moon.css +2 -0
- package/themes/reveal-serif.css +1 -0
- package/themes/reveal-sky.css +1 -0
- package/themes/reveal-solarized.css +4 -0
- package/tools/brand-palette.mjs +6 -1
- package/tools/build-groups.mjs +28 -8
- package/tools/cdp.mjs +176 -0
- package/tools/chart-spec.mjs +242 -0
- package/tools/click-match.mjs +70 -0
- package/tools/code-options.mjs +174 -0
- package/tools/conversation.mjs +49 -0
- package/tools/deck-family.mjs +101 -0
- package/tools/deck-html.mjs +212 -15
- package/tools/design-system-format.mjs +40 -1
- package/tools/design-system-migrations.mjs +207 -0
- package/tools/diagram-shapes.mjs +221 -0
- package/tools/elevenlabs-tts.mjs +62 -53
- package/tools/exec.mjs +10 -2
- package/tools/face-clip.mjs +96 -0
- package/tools/face-layout.mjs +94 -0
- package/tools/gemini-tts.mjs +1 -1
- package/tools/invisible-in-print.mjs +27 -0
- package/tools/lipsync-auto.mjs +197 -0
- package/tools/lipsync-config.mjs +16 -0
- package/tools/lipsync-engines.mjs +22 -4
- package/tools/lipsync-server.mjs +8 -5
- package/tools/lipsync.mjs +122 -30
- package/tools/local-voice.mjs +1 -1
- package/tools/mouth-file.mjs +26 -0
- package/tools/mouth.mjs +320 -0
- package/tools/narration-manifest.mjs +100 -6
- package/tools/narration-synth.mjs +96 -76
- package/tools/recording-impact.mjs +16 -1
- package/tools/sentences.mjs +7 -1
- package/tools/site-clip.mjs +114 -0
- package/tools/starters.mjs +402 -0
- package/tools/steps.mjs +118 -0
- package/tools/take-check.mjs +146 -0
- package/tools/template-theme.mjs +3 -1
- package/tools/test-impact.mjs +36 -12
- package/tools/theme-check.mjs +196 -1
- package/tools/tone-cue.mjs +108 -0
- package/tools/tts-cache.mjs +9 -3
- package/tools/tts-engines.mjs +100 -11
- package/tools/video-cache.mjs +93 -0
- package/tools/video-live.mjs +349 -0
- package/tools/video-options.mjs +11 -0
- package/tools/video.mjs +825 -117
- package/tools/viseme-fit.mjs +27 -0
- package/tools/viseme-match.mjs +77 -0
- package/tools/vocabulary.mjs +397 -0
- package/tools/voice-renumber.mjs +605 -0
- package/tools/voiceover-server.mjs +42 -11
- package/tools/voiceover.mjs +48 -20
- package/dist/build-info.json +0 -1
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Languages…, the edit server's half (SPEC TRANSLATE_PANEL): a deck's
|
|
6
|
+
* languages listed with what is behind, a run of `decklight translate`
|
|
7
|
+
* started, followed and stopped, and a translation's slide marked read.
|
|
8
|
+
*
|
|
9
|
+
* A SECOND DOOR TO THE COMMAND, NOT A SECOND IMPLEMENTATION. A run is the
|
|
10
|
+
* `decklight translate` a terminal would run, started as a child process: the
|
|
11
|
+
* same matching, the same checks, the same report, its lines relayed to the
|
|
12
|
+
* page as `translate` events. The list is `readLanguage`, which is what
|
|
13
|
+
* `--status` and `decklight check` read. Nothing here asks a model.
|
|
14
|
+
*
|
|
15
|
+
* And the one refusal: a translation takes its structure from its source, so
|
|
16
|
+
* the routes that change a slide's structure, its look or the deck's
|
|
17
|
+
* configuration are refused on one, naming the file to make the change in.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { spawn } from 'node:child_process';
|
|
21
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
22
|
+
import { basename, dirname, join } from 'node:path';
|
|
23
|
+
import { fileURLToPath } from 'node:url';
|
|
24
|
+
import { writeFileAtomic } from '../tools/atomic-write.mjs';
|
|
25
|
+
import { deckFamily } from '../tools/deck-family.mjs';
|
|
26
|
+
import { deckLang, sectionBodies, slideName } from '../tools/deck-html.mjs';
|
|
27
|
+
import { formatRecord, languageName, parseRecord } from './translate-core.mjs';
|
|
28
|
+
import { voiceFolders } from '../tools/voice-renumber.mjs';
|
|
29
|
+
import { slideNotes, staleSlides } from '../tools/narration-manifest.mjs';
|
|
30
|
+
import { knownLanguages, readLanguage, recordOf, resolveSource, slidesPhrase } from './translate-files.mjs';
|
|
31
|
+
|
|
32
|
+
const CLI = join(dirname(fileURLToPath(import.meta.url)), 'decklight.mjs');
|
|
33
|
+
const TAG = /^[a-z]{2,3}(?:-[a-z0-9]{2,8})*$/i;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The edit routes a translation refuses: everything that changes a slide's
|
|
37
|
+
* structure, the deck's look or its configuration. Its words (the text and
|
|
38
|
+
* notes editors, find and replace, the writing tools) stay open.
|
|
39
|
+
*/
|
|
40
|
+
export const STRUCTURAL_ROUTES = new Set([
|
|
41
|
+
'slide', 'slide/attr', 'slide/background', 'slide/builds', 'slide/face', 'slide/hidden', 'slide/layout',
|
|
42
|
+
'slide/template', 'slide/sources', 'timings', 'asset',
|
|
43
|
+
'element/build', 'element/canvas', 'element/concept', 'element/concepts', 'element/connector', 'element/content',
|
|
44
|
+
'element/duplicate', 'element/effect', 'element/geometry', 'element/group', 'element/image', 'element/insert',
|
|
45
|
+
'element/join', 'element/move', 'element/options', 'element/order', 'element/paste', 'element/picture',
|
|
46
|
+
'element/remove', 'element/shape', 'element/style', 'element/turn',
|
|
47
|
+
'theme', 'theme/add', 'theme/mark', 'brand-themes', 'concepts', 'config', 'font/mark',
|
|
48
|
+
'design-system/apply', 'design-system/mark', 'design-system/migrate',
|
|
49
|
+
].map((r) => `/deck/edit/${r}`));
|
|
50
|
+
|
|
51
|
+
/** Is the deck at `deckPath` a translation, and of which file? `{ source, lang }` or null. */
|
|
52
|
+
export function translationOf(deckPath) {
|
|
53
|
+
const fam = deckFamily(deckPath);
|
|
54
|
+
if (!fam.lang || !existsSync(recordOf(deckPath))) return null;
|
|
55
|
+
const { source } = resolveSource(deckPath);
|
|
56
|
+
return source === deckPath ? null : { source, lang: fam.lang };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Why `pathname` is refused on this deck, or null: `{ error, source }`, the source file's name to open. */
|
|
60
|
+
export function structureRefusal(deckPath, pathname) {
|
|
61
|
+
if (!STRUCTURAL_ROUTES.has(pathname)) return null;
|
|
62
|
+
const t = translationOf(deckPath);
|
|
63
|
+
if (!t) return null;
|
|
64
|
+
return {
|
|
65
|
+
source: basename(t.source),
|
|
66
|
+
error: `${basename(deckPath)} is the ${languageName(t.lang, { in: 'en' })} of ${basename(t.source)}, made from it by decklight translate: `
|
|
67
|
+
+ `change the slides in ${basename(t.source)}, and the next run brings the change here. This file takes edits to its words only`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The recorded takes a language's script has moved away from: its own tracks
|
|
73
|
+
* (voiceFolders, which keeps to the deck's language) whose manifest says a
|
|
74
|
+
* slide was voiced from other notes than the translation has now.
|
|
75
|
+
* `{ tracks, slides }`, or null when it has none.
|
|
76
|
+
*/
|
|
77
|
+
export function staleTakes(deckPath, html, { read = (p) => readFileSync(p, 'utf8') } = {}) {
|
|
78
|
+
const texts = slideNotes(html);
|
|
79
|
+
const slides = new Set();
|
|
80
|
+
let tracks = 0;
|
|
81
|
+
for (const dir of voiceFolders(deckPath)) {
|
|
82
|
+
let manifest;
|
|
83
|
+
try { manifest = JSON.parse(read(join(dirname(deckPath), dir, 'manifest.json'))); } catch { continue; }
|
|
84
|
+
const s = staleSlides(manifest, texts).stale;
|
|
85
|
+
if (s.length) { tracks++; s.forEach((n) => slides.add(n)); }
|
|
86
|
+
}
|
|
87
|
+
return tracks ? { tracks, slides: [...slides].sort((a, b) => a - b) } : null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** What Languages… lists, for the deck at `deckPath`, from either side. No model. */
|
|
91
|
+
export function languagesList(deckPath, { read = (p) => readFileSync(p, 'utf8') } = {}) {
|
|
92
|
+
const t = translationOf(deckPath);
|
|
93
|
+
const source = t?.source ?? deckPath;
|
|
94
|
+
const sourceHtml = read(source);
|
|
95
|
+
const langs = knownLanguages(source, sourceHtml);
|
|
96
|
+
const languages = langs.map((lang) => {
|
|
97
|
+
const l = readLanguage(source, sourceHtml, lang, { read });
|
|
98
|
+
const row = { lang, name: languageName(lang), file: basename(l.files.deck), exists: l.exists };
|
|
99
|
+
if (l.error) return { ...row, error: l.error };
|
|
100
|
+
if (!l.exists) return row;
|
|
101
|
+
const st = l.status;
|
|
102
|
+
const overflow = Array.isArray(l.record.overflow) ? l.record.overflow : [];
|
|
103
|
+
const stale = staleTakes(l.files.deck, l.translation, { read });
|
|
104
|
+
return {
|
|
105
|
+
...row, up: st.up, changed: st.changed, missing: st.missing, reviewed: st.reviewed, total: st.total,
|
|
106
|
+
behind: st.behind, behindPhrase: slidesPhrase(sourceHtml, st.behind), structure: l.back.structure.length > 0,
|
|
107
|
+
corrected: l.back.corrected,
|
|
108
|
+
overflow, overflowPhrase: slidesPhrase(l.translation, overflow),
|
|
109
|
+
staleTakes: stale && { ...stale, phrase: slidesPhrase(l.translation, stale.slides) },
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
const out = {
|
|
113
|
+
ok: true, deck: basename(deckPath), source: basename(source), sourceLang: deckLang(sourceHtml),
|
|
114
|
+
sourceName: languageName(deckLang(sourceHtml) ?? 'en'), isTranslation: !!t, lang: t?.lang ?? deckLang(sourceHtml), languages,
|
|
115
|
+
};
|
|
116
|
+
if (t) {
|
|
117
|
+
// a translation lists the slides a person has not read yet
|
|
118
|
+
const rec = parseRecord(read(recordOf(deckPath)));
|
|
119
|
+
const bodies = sectionBodies(read(deckPath));
|
|
120
|
+
out.unread = rec.slides.map((S, i) => ({ slide: i + 1, n: S.filter((u) => u.state === 'machine').length }))
|
|
121
|
+
.filter((x) => x.n).map((x) => ({ ...x, name: slideName(bodies[x.slide - 1] ?? '') || `slide ${x.slide}` }));
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** A translation's slide as the record has it: each unit's source beside its translation. */
|
|
127
|
+
export function translationSlide(deckPath, slide, { read = (p) => readFileSync(p, 'utf8') } = {}) {
|
|
128
|
+
const rec = parseRecord(read(recordOf(deckPath)));
|
|
129
|
+
const S = rec.slides[slide - 1];
|
|
130
|
+
if (!S) return null;
|
|
131
|
+
return S.map((u) => ({ kind: u.kind, source: u.source, target: u.target, state: u.state }));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Mark a translation's slide read: its `machine` units `reviewed`. Returns how many. */
|
|
135
|
+
export function markReviewed(deckPath, slide, { read = (p) => readFileSync(p, 'utf8'), write = writeFileAtomic } = {}) {
|
|
136
|
+
const file = recordOf(deckPath);
|
|
137
|
+
const rec = parseRecord(read(file));
|
|
138
|
+
const S = rec.slides[slide - 1];
|
|
139
|
+
if (!S) return null;
|
|
140
|
+
let n = 0;
|
|
141
|
+
rec.slides[slide - 1] = S.map((u) => (u.state === 'machine' ? (n++, { ...u, state: 'reviewed' }) : u));
|
|
142
|
+
if (n) write(file, formatRecord(rec));
|
|
143
|
+
return n;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The routes, registered into the edit server's table. `spawnRun` is how a
|
|
148
|
+
* run is started (a test hands in its own); it returns the child.
|
|
149
|
+
*/
|
|
150
|
+
export function registerTranslateRoutes(routes, {
|
|
151
|
+
deckPath, broadcast = () => {}, spawnRun = (args) => spawn(process.execPath, [CLI, 'translate', ...args], {
|
|
152
|
+
env: { ...process.env, DECKLIGHT_NO_UPDATE_CHECK: '1', DECKLIGHT_BANNER: '1' }, stdio: ['pipe', 'pipe', 'pipe'],
|
|
153
|
+
}),
|
|
154
|
+
}) {
|
|
155
|
+
let running = null; // { child, langs }
|
|
156
|
+
|
|
157
|
+
function listRoute({ json }) {
|
|
158
|
+
try { return json(200, { ...languagesList(deckPath), running: running ? { langs: running.langs } : null }); }
|
|
159
|
+
catch (e) { return json(500, { ok: false, error: String(e.message ?? e) }); }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function slideRoute({ url, json }) {
|
|
163
|
+
const n = Number(url.searchParams.get('slide'));
|
|
164
|
+
if (!translationOf(deckPath)) return json(409, { ok: false, error: 'this deck is not a translation' });
|
|
165
|
+
const units = Number.isInteger(n) && n > 0 ? translationSlide(deckPath, n) : null;
|
|
166
|
+
if (!units) return json(400, { ok: false, error: 'which slide? — a number of this deck' });
|
|
167
|
+
return json(200, { ok: true, slide: n, units });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function runRoute({ body, json }) {
|
|
171
|
+
if (running) return json(409, { ok: false, error: `a translation is already running (${running.langs.join(', ')})` });
|
|
172
|
+
const { to, slides = null, agent = true } = JSON.parse(body || '{}');
|
|
173
|
+
const langs = Array.isArray(to) ? to.filter((x) => typeof x === 'string') : [];
|
|
174
|
+
if (!langs.length || !langs.every((l) => TAG.test(l))) return json(400, { ok: false, error: 'to: the languages, as tags (fr, pt-BR)' });
|
|
175
|
+
if (slides !== null && !(Array.isArray(slides) && slides.every((n) => Number.isInteger(n) && n > 0))) return json(400, { ok: false, error: 'slides: slide numbers' });
|
|
176
|
+
const source = translationOf(deckPath)?.source ?? deckPath;
|
|
177
|
+
const args = [source, '--to', langs.join(','), '--from-server',
|
|
178
|
+
...(slides?.length ? ['--slides', slides.join(',')] : []), ...(agent === false ? ['--no-agent'] : [])];
|
|
179
|
+
const child = spawnRun(args);
|
|
180
|
+
running = { child, langs };
|
|
181
|
+
broadcast('translate', { state: 'start', langs });
|
|
182
|
+
let tail = '';
|
|
183
|
+
const relay = (stream) => {
|
|
184
|
+
let buf = '';
|
|
185
|
+
stream?.on('data', (b) => {
|
|
186
|
+
buf += String(b);
|
|
187
|
+
const lines = buf.split('\n');
|
|
188
|
+
buf = lines.pop();
|
|
189
|
+
for (const line of lines.map((l) => l.trimEnd()).filter(Boolean)) {
|
|
190
|
+
tail = line;
|
|
191
|
+
broadcast('translate', { state: 'line', text: line.replace(/^(?:decklight )?translate: /, '') });
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
relay(child.stdout); relay(child.stderr);
|
|
196
|
+
child.on('close', (code) => {
|
|
197
|
+
running = null;
|
|
198
|
+
console.log(` translate: ${tail || `finished (${code})`}`);
|
|
199
|
+
broadcast('translate', { state: 'done', code, tail: tail.replace(/^(?:decklight )?translate: /, '') });
|
|
200
|
+
});
|
|
201
|
+
return json(200, { ok: true, started: true, langs });
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function stopRoute({ json }) {
|
|
205
|
+
if (!running) return json(200, { ok: true, stopped: false });
|
|
206
|
+
// the slides in flight finish and what passed is written: the command
|
|
207
|
+
// reads "stop" on its input when the server started it
|
|
208
|
+
try { running.child.stdin?.write('stop\n'); } catch { running.child.kill(); }
|
|
209
|
+
return json(200, { ok: true, stopped: true });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function reviewedRoute({ body, json }) {
|
|
213
|
+
if (!translationOf(deckPath)) return json(409, { ok: false, error: 'this deck is not a translation' });
|
|
214
|
+
const { slide } = JSON.parse(body || '{}');
|
|
215
|
+
const n = Number.isInteger(slide) && slide > 0 ? markReviewed(deckPath, slide) : null;
|
|
216
|
+
if (n === null) return json(400, { ok: false, error: 'which slide? — a number of this deck' });
|
|
217
|
+
broadcast('translate', { state: 'reviewed', slide, n });
|
|
218
|
+
return json(200, { ok: true, slide, marked: n });
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
routes.set('GET /deck/edit/translations', listRoute);
|
|
222
|
+
routes.set('GET /deck/edit/translation/slide', slideRoute);
|
|
223
|
+
routes.set('POST /deck/edit/translate', runRoute);
|
|
224
|
+
routes.set('POST /deck/edit/translate/stop', stopRoute);
|
|
225
|
+
routes.set('POST /deck/edit/translation/reviewed', reviewedRoute);
|
|
226
|
+
return { running: () => running };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* After a save to a source, the languages it put behind: `[{ lang, name, n }]`
|
|
231
|
+
* for each language that was up to date before the save and is not after.
|
|
232
|
+
*/
|
|
233
|
+
export function newlyBehind(deckPath, before, afterHtml) {
|
|
234
|
+
if (translationOf(deckPath)) return [];
|
|
235
|
+
const out = [];
|
|
236
|
+
for (const lang of knownLanguages(deckPath, afterHtml)) {
|
|
237
|
+
const was = readLanguage(deckPath, before, lang);
|
|
238
|
+
const now = readLanguage(deckPath, afterHtml, lang);
|
|
239
|
+
if (!was.exists || was.error || now.error) continue;
|
|
240
|
+
if (was.status.up && !now.status.up) out.push({ lang, name: languageName(lang, { in: 'en' }), n: now.status.changed + now.status.missing });
|
|
241
|
+
}
|
|
242
|
+
return out;
|
|
243
|
+
}
|