decklight 0.4.0 → 0.5.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/README.md +8 -2
- package/SPEC.md +22 -7
- package/cli/agents.mjs +125 -17
- package/cli/decklight.mjs +9 -0
- package/cli/edit.mjs +10 -2
- package/cli/report-bug.mjs +9 -1
- package/cli/skill-content.mjs +5 -5
- package/cli/update-check.mjs +156 -0
- package/cli/wizard.mjs +184 -16
- package/dist/decklight.js +47 -47
- package/dist/decklight.js.map +4 -4
- package/package.json +5 -3
- package/tools/local-voice.mjs +33 -2
- package/tools/tts-engines.mjs +10 -1
- package/tools/video.mjs +66 -17
- package/tools/voiceover.mjs +69 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "decklight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A presentation library designed to be authored by AI agents and humans alike: single-file decks, Keynote-style builds, theme-aware SVG diagrams, and truthful terminal recordings.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/decklight.js",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"prepare": "npm run build",
|
|
39
39
|
"test": "node test/run.mjs",
|
|
40
40
|
"verify": "npm run build && node test/verify.mjs",
|
|
41
|
-
"soak": "node test/soak.mjs"
|
|
41
|
+
"soak": "node test/soak.mjs",
|
|
42
|
+
"cross-engine": "node test/cross-engine.mjs"
|
|
42
43
|
},
|
|
43
44
|
"engines": {
|
|
44
45
|
"node": ">=20"
|
|
@@ -51,7 +52,8 @@
|
|
|
51
52
|
"optionalDependencies": {
|
|
52
53
|
"js-yaml": "^4.3.0",
|
|
53
54
|
"node-pty": "^1.1.0",
|
|
54
|
-
"sigstore": "^5.0.0"
|
|
55
|
+
"sigstore": "^5.0.0",
|
|
56
|
+
"playwright": "^1.56.0"
|
|
55
57
|
},
|
|
56
58
|
"author": "Gilles Philippart <gilles.philippart@gmail.com>",
|
|
57
59
|
"license": "Apache-2.0"
|
package/tools/local-voice.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// Copyright 2026 Gilles Philippart
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import { existsSync } from 'node:fs';
|
|
6
|
+
import { delimiter, join } from 'node:path';
|
|
7
|
+
|
|
4
8
|
// What can this machine say out loud, without a credential and without a
|
|
5
9
|
// download?
|
|
6
10
|
//
|
|
@@ -120,10 +124,37 @@ export function sapiArgs(text, voice, file) {
|
|
|
120
124
|
* reason THIS machine has none, which differs enough between an Android
|
|
121
125
|
* device, a bare Linux box and a Mac with a broken `say` to be worth saying.
|
|
122
126
|
*/
|
|
127
|
+
/**
|
|
128
|
+
* Is `bin` runnable? The default for the probe below.
|
|
129
|
+
*
|
|
130
|
+
* This has to be a REAL answer, and that is the whole point of it existing:
|
|
131
|
+
* `hasBin` defaulted to `() => false`, so every caller that did not inject one
|
|
132
|
+
* — `tools/tts-engines.mjs` creating a `say`/`sapi` engine is the only one, and
|
|
133
|
+
* it is the one that matters — was told the machine had no synthesizer, on a
|
|
134
|
+
* Mac where `say -v '?'` lists forty voices. The seams here exist so the tests
|
|
135
|
+
* can drive every OS from one OS; a seam whose DEFAULT is "no" turns the
|
|
136
|
+
* production path into a stub that always refuses, and every test still passes
|
|
137
|
+
* because every test injects.
|
|
138
|
+
*/
|
|
139
|
+
export function onPath(bin, env = process.env) {
|
|
140
|
+
const exts = process.platform === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
|
|
141
|
+
for (const dir of String(env.PATH ?? '').split(delimiter)) {
|
|
142
|
+
if (!dir) continue;
|
|
143
|
+
for (const ext of exts) if (existsSync(join(dir, bin + ext))) return true;
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Run a probe and return its stdout; anything at all going wrong is ''. */
|
|
149
|
+
export const probe = (bin, args) => {
|
|
150
|
+
try { return execFileSync(bin, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }); }
|
|
151
|
+
catch { return ''; }
|
|
152
|
+
};
|
|
153
|
+
|
|
123
154
|
export function detectLocalVoice({
|
|
124
155
|
platform = process.platform,
|
|
125
|
-
hasBin =
|
|
126
|
-
exec =
|
|
156
|
+
hasBin = onPath,
|
|
157
|
+
exec = probe,
|
|
127
158
|
lang,
|
|
128
159
|
} = {}) {
|
|
129
160
|
if (platform === 'android') {
|
package/tools/tts-engines.mjs
CHANGED
|
@@ -347,7 +347,16 @@ function createNative({ kind, voice, shell = 'powershell.exe' }) {
|
|
|
347
347
|
execFileSync(bin, build(line, voice, file), { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
348
348
|
const wav = readFileSync(file);
|
|
349
349
|
if (!wav.length) throw new Error(`${kind} produced no audio`);
|
|
350
|
-
|
|
350
|
+
// `{ wav, usage }`, like every other engine and like this file's own
|
|
351
|
+
// contract at the top. It returned a bare Buffer, so a caller that
|
|
352
|
+
// destructured `{ wav }` — tools/voiceover.mjs does — got undefined and
|
|
353
|
+
// wrote it to disk. Nobody had ever reached this line: detectLocalVoice's
|
|
354
|
+
// default probe answered "no synthesizer" first, so the shape was wrong
|
|
355
|
+
// behind a door that never opened.
|
|
356
|
+
return {
|
|
357
|
+
wav,
|
|
358
|
+
usage: { model: voice ?? kind, chars: line.length, cost: 0, note: `${line.length} chars · local` },
|
|
359
|
+
};
|
|
351
360
|
} catch (e) {
|
|
352
361
|
throw new Error(`${kind}: ${String(e.stderr ?? e.message).trim().split('\n')[0] || 'synthesis failed'}`);
|
|
353
362
|
} finally {
|
package/tools/video.mjs
CHANGED
|
@@ -64,9 +64,12 @@ const HELP = `decklight video <deck.html> [options] — render the deck to a nar
|
|
|
64
64
|
--slides <a-b> only this slide range (1-based, inclusive)
|
|
65
65
|
--voiceover run the voiceover batch (tools/voiceover.mjs) first
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
Every slide BUILDS, one frame per step. A narrated slide takes its timing from
|
|
68
|
+
its own audio: ⟨CLICK⟩ in the speaker notes splits the narration, and segment k
|
|
69
|
+
is spoken over build step k — the same rule the live player follows. Without
|
|
70
|
+
markers it holds fully built for the audio's real duration. A silent slide holds
|
|
71
|
+
--hold seconds, --build-hold per step. Either way the audio track is continuous
|
|
72
|
+
and the finished slide gets a ${TAIL_SECONDS}s breath before the cut.
|
|
70
73
|
Needs ffmpeg + ffprobe on PATH, and a Chrome ($CHROME or an installed one).
|
|
71
74
|
`;
|
|
72
75
|
|
|
@@ -117,9 +120,13 @@ const round = (s) => Math.round(s * 1000) / 1000;
|
|
|
117
120
|
* ONE ENTRY PER FRAME, not per slide. A silent slide with builds is a sequence
|
|
118
121
|
* — the slide bare, then each build revealed — because a video of a built slide
|
|
119
122
|
* that opens fully built has thrown away the thing the builds were for. A
|
|
120
|
-
* NARRATED slide
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
+
* A NARRATED slide follows its own notes: where those notes are segmented by
|
|
124
|
+
* ⟨CLICK⟩ and the segment count matches the build count, segment k narrates
|
|
125
|
+
* build step k and holds for that segment's REAL audio. Nothing is inferred —
|
|
126
|
+
* the markers are the author's, tools/voiceover.mjs synthesises one file per
|
|
127
|
+
* segment, and this reads their ffprobe'd durations. A narrated slide with no
|
|
128
|
+
* markers, or a count that does not line up, is one fully-built still for the
|
|
129
|
+
* length of its audio, as it always was.
|
|
123
130
|
*
|
|
124
131
|
* Timing, for a silent slide with `b` build steps (so `b + 1` frames): EVERY
|
|
125
132
|
* frame holds for the slide's hold, so a build lands at the pace the rest of
|
|
@@ -141,19 +148,53 @@ const round = (s) => Math.round(s * 1000) / 1000;
|
|
|
141
148
|
* build-up frame (null ⇒ the slide's own hold)
|
|
142
149
|
* @returns {Array<{slide, step, audio, duration}>} audio null ⇒ silent hold
|
|
143
150
|
*/
|
|
144
|
-
export function planTimeline(manifest, durations, holds, range = null, { steps = null, buildHold = null } = {}) {
|
|
151
|
+
export function planTimeline(manifest, durations, holds, range = null, { steps = null, buildHold = null, onWarn = null } = {}) {
|
|
145
152
|
const from = range?.from ?? 1;
|
|
146
153
|
const to = range?.to ?? holds.length;
|
|
147
154
|
const plan = [];
|
|
148
155
|
for (let n = from; n <= to; n++) {
|
|
149
|
-
const
|
|
156
|
+
const entry = manifest?.[n - 1] ?? null;
|
|
157
|
+
const file = entry?.file ?? null;
|
|
150
158
|
const dur = file ? durations?.[file] : null;
|
|
159
|
+
|
|
160
|
+
// A narrated slide whose notes are segmented by ⟨CLICK⟩ builds AS IT
|
|
161
|
+
// SPEAKS: segment k narrates build step k. That rule is not invented here —
|
|
162
|
+
// src/core/narration.js already speaks live narration that way ("exactly
|
|
163
|
+
// like a presenter reading the notes and clicking between segments"), and
|
|
164
|
+
// captions, rehearse mode and the notes editor all run on the same
|
|
165
|
+
// segmentation. This makes the recorded render the mirror of it.
|
|
166
|
+
const segs = entry?.segments ?? null;
|
|
167
|
+
const builds = steps?.[n - 1] ?? 0;
|
|
168
|
+
if (Number.isFinite(dur) && segs?.length && builds) {
|
|
169
|
+
const times = segs.map((sg) => durations?.[sg.file]);
|
|
170
|
+
if (segs.length === builds + 1 && times.every((t) => Number.isFinite(t))) {
|
|
171
|
+
segs.forEach((sg, k) => {
|
|
172
|
+
const last = k === segs.length - 1;
|
|
173
|
+
plan.push({
|
|
174
|
+
slide: n,
|
|
175
|
+
step: last ? LAST_STEP : k,
|
|
176
|
+
audio: sg.file,
|
|
177
|
+
// Only the finished slide gets the breath. A build that paused for
|
|
178
|
+
// it would read as hesitation rather than as a beat.
|
|
179
|
+
duration: round(times[k] + (last ? TAIL_SECONDS : 0)),
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
// A marker count that does not match the build count is the author's to
|
|
185
|
+
// fix, and guessing which build a segment belongs to would bake a wrong
|
|
186
|
+
// sync into an mp4 — worse than no sync. Say which slide, and render it
|
|
187
|
+
// the way an unsegmented one renders.
|
|
188
|
+
onWarn?.(`slide ${n}: ${segs.length} narration segment${segs.length === 1 ? '' : 's'}`
|
|
189
|
+
+ ` but ${builds + 1} frames (${builds} build${builds === 1 ? '' : 's'} + the finished slide)`
|
|
190
|
+
+ ' — narrating the whole slide over one still instead');
|
|
191
|
+
}
|
|
192
|
+
|
|
151
193
|
if (Number.isFinite(dur)) {
|
|
152
194
|
plan.push({ slide: n, step: LAST_STEP, audio: file, duration: round(dur + TAIL_SECONDS) });
|
|
153
195
|
continue;
|
|
154
196
|
}
|
|
155
197
|
const hold = holds[n - 1];
|
|
156
|
-
const builds = steps?.[n - 1] ?? 0;
|
|
157
198
|
if (!builds) { plan.push({ slide: n, step: LAST_STEP, audio: null, duration: hold }); continue; }
|
|
158
199
|
const each = buildHold ?? hold;
|
|
159
200
|
for (let k = 0; k < builds; k++) plan.push({ slide: n, step: k, audio: null, duration: each });
|
|
@@ -338,14 +379,21 @@ export async function videoMain(argv, { exec = run, log = console.log } = {}) {
|
|
|
338
379
|
// real durations, not the manifest's word count: ffprobe each audio file
|
|
339
380
|
const durations = {};
|
|
340
381
|
for (let n = range.from; n <= range.to; n++) {
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
382
|
+
const entry = narration?.slides?.[n - 1];
|
|
383
|
+
// The slide's own audio AND its ⟨CLICK⟩ segments. Measured here rather
|
|
384
|
+
// than trusted from the manifest, for the reason the per-slide durations
|
|
385
|
+
// already are: what a file says it is worth is not what ffprobe says.
|
|
386
|
+
const files = [entry?.file, ...(entry?.segments ?? []).map((sg) => sg.file)].filter(Boolean);
|
|
387
|
+
for (const file of files) {
|
|
388
|
+
if (durations[file] != null) continue;
|
|
389
|
+
const path = join(narration.dir, file);
|
|
390
|
+
if (!existsSync(path)) {
|
|
391
|
+
console.warn(` slide ${String(n).padStart(2, '0')}: ${file} is in the manifest but not on disk`
|
|
392
|
+
+ `${file === entry?.file ? ` — holding ${holds[n - 1]}s of silence` : ' — narrating the whole slide instead'}`);
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
durations[file] = Number((await exec('ffprobe', ffprobeArgs(path))).stdout.trim());
|
|
347
396
|
}
|
|
348
|
-
durations[file] = Number((await exec('ffprobe', ffprobeArgs(path))).stdout.trim());
|
|
349
397
|
}
|
|
350
398
|
|
|
351
399
|
|
|
@@ -385,7 +433,8 @@ export async function videoMain(argv, { exec = run, log = console.log } = {}) {
|
|
|
385
433
|
probing = false;
|
|
386
434
|
if (!steps) console.warn(' builds: the deck did not report its build steps — one still per slide');
|
|
387
435
|
|
|
388
|
-
plan = planTimeline(narration?.slides ?? null, durations, holds, range,
|
|
436
|
+
plan = planTimeline(narration?.slides ?? null, durations, holds, range,
|
|
437
|
+
{ steps, buildHold, onWarn: (w) => console.warn(` ${w}`) });
|
|
389
438
|
const slideCount = new Set(plan.map((p) => p.slide)).size;
|
|
390
439
|
log(`${basename(deck)}: ${slideCount} slide${slideCount === 1 ? '' : 's'}, `
|
|
391
440
|
+ `${plan.filter((p) => p.audio).length} narrated`
|
package/tools/voiceover.mjs
CHANGED
|
@@ -108,13 +108,36 @@ const clean = (s) => s
|
|
|
108
108
|
.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&')
|
|
109
109
|
.replace(/\s+/g, ' ')
|
|
110
110
|
.trim();
|
|
111
|
-
const
|
|
111
|
+
const raw = sections.map((sec) => {
|
|
112
112
|
const aside = sec.match(NOTES_ASIDE);
|
|
113
|
-
if (aside) return
|
|
113
|
+
if (aside) return aside[1];
|
|
114
114
|
const md = sec.match(/^Note:\s*$([\s\S]*?)(?=^Rehearse:\s*$|<\/script>)/m);
|
|
115
|
-
|
|
116
|
-
return '';
|
|
115
|
+
return md ? md[1] : '';
|
|
117
116
|
});
|
|
117
|
+
const slides = raw.map(clean);
|
|
118
|
+
/**
|
|
119
|
+
* A slide's ⟨CLICK⟩ segments, or null when there is only one.
|
|
120
|
+
*
|
|
121
|
+
* These are the author's own build cues, and the sync rule they carry already
|
|
122
|
+
* ships: src/core/narration.js speaks segment k over build step k in live
|
|
123
|
+
* playback, and captions, rehearse mode and the notes editor all read the same
|
|
124
|
+
* segmentation. Recording them separately is what lets a rendered mp4 mirror
|
|
125
|
+
* that (SPEC PRESENTING). An empty segment is dropped rather than synthesised
|
|
126
|
+
* as silence — a ⟨CLICK⟩ at the very start or end of a note is punctuation,
|
|
127
|
+
* not a beat.
|
|
128
|
+
*/
|
|
129
|
+
export const notesSegments = (notes) => {
|
|
130
|
+
const parts = String(notes ?? '').split('⟨CLICK⟩').map(clean).filter(Boolean);
|
|
131
|
+
return parts.length > 1 ? parts : null;
|
|
132
|
+
};
|
|
133
|
+
// Segmenting needs ffmpeg specifically: the per-slide file is CONCATENATED from
|
|
134
|
+
// the segments, and afconvert (Core Audio, macOS-only) has no concat demuxer.
|
|
135
|
+
// Without it the slide is synthesised whole, exactly as before.
|
|
136
|
+
const canSegment = encoder === 'ffmpeg';
|
|
137
|
+
const segmented = raw.map((r) => (canSegment ? notesSegments(r) : null));
|
|
138
|
+
if (!canSegment && raw.some((r) => notesSegments(r))) {
|
|
139
|
+
console.log(' note: ⟨CLICK⟩ segments need ffmpeg to concatenate — narrating each slide whole');
|
|
140
|
+
}
|
|
118
141
|
console.log(`${basename(deckPath)}: ${slides.length} slides, ${slides.filter(Boolean).length} with notes`);
|
|
119
142
|
|
|
120
143
|
// ── optional narration pass through a local model ────────────────────────────
|
|
@@ -164,17 +187,52 @@ for (let i = 0; i < slides.length; i++) {
|
|
|
164
187
|
const hash = slideHash(text);
|
|
165
188
|
manifest.push({ file: `slide-${n}.m4a`, hash });
|
|
166
189
|
if (prev?.slides?.[i]?.hash === hash && existsSync(m4a)) {
|
|
190
|
+
// Carry the segments across, or an unchanged slide loses its build sync on
|
|
191
|
+
// the next rerun: the audio is still on disk and the manifest is the only
|
|
192
|
+
// thing that knows it is there.
|
|
193
|
+
const kept = prev.slides[i].segments;
|
|
194
|
+
if (kept?.every((sg) => existsSync(join(outDir, sg.file)))) manifest[i].segments = kept;
|
|
167
195
|
skipped++;
|
|
168
|
-
console.log(` slide ${n}: unchanged — kept`);
|
|
196
|
+
console.log(` slide ${n}: unchanged — kept${manifest[i].segments ? ` (${manifest[i].segments.length} segments)` : ''}`);
|
|
169
197
|
continue;
|
|
170
198
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
199
|
+
// A segmented slide is synthesised segment by segment, and the per-slide file
|
|
200
|
+
// is CONCATENATED from those — one synthesis, both shapes. TTS is billed per
|
|
201
|
+
// character; asking for the same words twice to get the same audio cut two
|
|
202
|
+
// ways would be a bill nobody agreed to. --reuse-text takes the whole-slide
|
|
203
|
+
// path, since its prior text is one script rather than segments.
|
|
204
|
+
const segs = prior ? null : segmented[i];
|
|
205
|
+
let usage = { cost: 0 };
|
|
206
|
+
if (segs) {
|
|
207
|
+
const parts = [];
|
|
208
|
+
for (let k = 0; k < segs.length; k++) {
|
|
209
|
+
const kk = String(k + 1).padStart(2, '0');
|
|
210
|
+
const sWav = join(outDir, `slide-${n}-${kk}.wav`);
|
|
211
|
+
const sM4a = join(outDir, `slide-${n}-${kk}.m4a`);
|
|
212
|
+
const out = await tts.synth(segs[k], { voice, style });
|
|
213
|
+
writeFileSync(sWav, out.wav);
|
|
214
|
+
usage = { cost: usage.cost + (out.usage?.cost ?? 0) };
|
|
215
|
+
toAac(sWav, sM4a);
|
|
216
|
+
if (!keepWav) rmSync(sWav);
|
|
217
|
+
parts.push({ file: `slide-${n}-${kk}.m4a`, path: sM4a });
|
|
218
|
+
}
|
|
219
|
+
const list = join(outDir, `slide-${n}.concat`);
|
|
220
|
+
writeFileSync(list, `${parts.map((p) => `file '${p.path.replaceAll("'", "'\\''")}'`).join('\n')}\n`);
|
|
221
|
+
execFileSync('ffmpeg', ['-y', '-f', 'concat', '-safe', '0', '-i', list, '-c', 'copy', m4a],
|
|
222
|
+
{ stdio: 'ignore' });
|
|
223
|
+
rmSync(list, { force: true });
|
|
224
|
+
manifest[i].segments = parts.map((p) => ({ file: p.file }));
|
|
225
|
+
} else {
|
|
226
|
+
const out = await tts.synth(text, { voice, style });
|
|
227
|
+
writeFileSync(wav, out.wav);
|
|
228
|
+
usage = out.usage ?? { cost: 0 };
|
|
229
|
+
toAac(wav, m4a);
|
|
230
|
+
if (!keepWav) rmSync(wav);
|
|
231
|
+
}
|
|
232
|
+
totalCost += usage.cost ?? 0;
|
|
174
233
|
const costNote = usage.cost ? ` · ~$${usage.cost.toFixed(4)}` : '';
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
console.log(` slide ${n}: ${text.length} chars → ${basename(m4a)}${costNote}`);
|
|
234
|
+
console.log(` slide ${n}: ${text.length} chars → ${basename(m4a)}`
|
|
235
|
+
+ `${segs ? ` (${segs.length} ⟨CLICK⟩ segments)` : ''}${costNote}`);
|
|
178
236
|
// crash-safe: persist progress after every slide so an interrupted run
|
|
179
237
|
// resumes incrementally instead of re-synthesizing everything
|
|
180
238
|
writeFileSync(join(outDir, 'manifest.json'),
|