decklight 0.6.0 → 0.8.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 (61) hide show
  1. package/README.md +23 -11
  2. package/SPEC.md +187 -23
  3. package/cli/agents.mjs +52 -2
  4. package/cli/associate.mjs +2 -2
  5. package/cli/banner.mjs +125 -0
  6. package/cli/bundle.mjs +15 -5
  7. package/cli/{rec.mjs → cast.mjs} +25 -8
  8. package/cli/comments.mjs +389 -0
  9. package/cli/commit-flow.mjs +157 -0
  10. package/cli/commit-message.mjs +125 -0
  11. package/cli/decklight.mjs +96 -25
  12. package/cli/dev.mjs +159 -13
  13. package/cli/edit.mjs +981 -40
  14. package/cli/git-tree.mjs +87 -0
  15. package/cli/git.mjs +22 -0
  16. package/cli/import.mjs +41 -11
  17. package/cli/init.mjs +37 -5
  18. package/cli/pdf.mjs +59 -14
  19. package/cli/port-conflict.mjs +187 -16
  20. package/cli/pptx-export.mjs +107 -0
  21. package/cli/present.mjs +8 -4
  22. package/cli/publish.mjs +25 -42
  23. package/cli/record.mjs +154 -0
  24. package/cli/review-remote.mjs +330 -0
  25. package/cli/review-store.mjs +107 -0
  26. package/cli/review-submit.mjs +292 -0
  27. package/cli/review.mjs +361 -0
  28. package/cli/serve.mjs +36 -1
  29. package/cli/skill-content.mjs +4 -1
  30. package/cli/units.mjs +2 -2
  31. package/cli/util.mjs +59 -0
  32. package/dist/build-info.json +1 -0
  33. package/dist/decklight.css +254 -1
  34. package/dist/decklight.js +153 -79
  35. package/dist/decklight.js.map +4 -4
  36. package/docs/architecture.svg +10 -3
  37. package/package.json +3 -1
  38. package/tools/args.mjs +20 -0
  39. package/tools/bridge.mjs +25 -2
  40. package/tools/deck-html.mjs +59 -0
  41. package/tools/elevenlabs-tts.mjs +3 -3
  42. package/tools/exec.mjs +54 -0
  43. package/tools/gemini-tts.mjs +4 -4
  44. package/tools/lipsync-server.mjs +70 -2
  45. package/tools/lipsync.mjs +46 -30
  46. package/tools/local-voice.mjs +243 -19
  47. package/tools/pptx-write.mjs +151 -0
  48. package/tools/pptx.mjs +82 -2
  49. package/tools/publish-site-voices.mjs +2 -2
  50. package/tools/publish-targets.mjs +39 -2
  51. package/tools/publish-voices.mjs +80 -20
  52. package/tools/recording-impact.mjs +110 -0
  53. package/tools/review-anchor.mjs +180 -0
  54. package/tools/template-theme.mjs +154 -0
  55. package/tools/test-impact.mjs +266 -0
  56. package/tools/tts-cache.mjs +191 -0
  57. package/tools/tts-engines.mjs +85 -8
  58. package/tools/tts-setup.mjs +4 -3
  59. package/tools/video.mjs +21 -6
  60. package/tools/voiceover-server.mjs +163 -17
  61. package/tools/voiceover.mjs +124 -16
package/cli/agents.mjs CHANGED
@@ -30,8 +30,13 @@ export const AGENTS = [
30
30
  {
31
31
  name: 'claude', label: 'Claude Code', bin: 'claude',
32
32
  // -p is print (headless) mode; acceptEdits lets it write the deck file
33
- // without an interactive approval it has no TTY to ask on.
34
- args: (prompt) => ['-p', prompt, '--permission-mode', 'acceptEdits'],
33
+ // without an interactive approval it has no TTY to ask on. stream-json
34
+ // (which requires --verbose) narrates the run as it happens — each tool
35
+ // call is a line — so the deck's chip can say WHAT the agent is doing
36
+ // instead of only how long it has been doing it.
37
+ args: (prompt) => ['-p', prompt, '--permission-mode', 'acceptEdits',
38
+ '--output-format', 'stream-json', '--verbose'],
39
+ stream: 'claude-json',
35
40
  // no --permission-mode: an ASK is read-only by construction, and a
36
41
  // commit-message call has no business being able to edit the deck.
37
42
  ask: (prompt) => ['-p', prompt],
@@ -346,6 +351,12 @@ export function agentCommand(name, instruction, deck, { env = process.env, hasBi
346
351
  if (!agent) return null;
347
352
  const prompt = `Edit the Decklight deck file "${deck}" — a single-file HTML presentation ` +
348
353
  '(one top-level <section> per slide; see SPEC.md or the decklight skill if present). ' +
354
+ // Prevention, paired with the server's detection: a track is minutes of a
355
+ // recorded voice, and "rewrite the voiceover" reads like license to
356
+ // replace the init call wholesale. Say the config is load-bearing.
357
+ 'Preserve the deck\'s existing narration config (the `narration` key of ' +
358
+ 'Decklight.init, which points at recorded audio) and any `data-narration-*` ' +
359
+ 'attributes on sections, unless the change is explicitly about them. ' +
349
360
  `Apply this change, editing the file in place: ${instruction}`;
350
361
  // The spawn spec, not the bare name: on Windows an npm-installed agent is a
351
362
  // batch shim, and `prefix` is the script node has to be handed for the
@@ -357,5 +368,44 @@ export function agentCommand(name, instruction, deck, { env = process.env, hasBi
357
368
  args: [...how.prefix, ...agent.args(prompt, deck)],
358
369
  label: agent.label,
359
370
  name: agent.name,
371
+ // which stream dialect stdout speaks, if any — the server's activity
372
+ // parser keys off it, and agents without one still get the generic
373
+ // last-line clue
374
+ stream: agent.stream ?? null,
360
375
  };
361
376
  }
377
+
378
+ /**
379
+ * One line of claude's stream-json → a short human clue, or null.
380
+ *
381
+ * `{activity}` while the run is going ("editing talk.html", "running: npm
382
+ * test"), `{result}` when the final answer arrives — which is also the text
383
+ * the done-toast should carry, because with stream-json the raw stdout is a
384
+ * wall of JSON nobody should ever be shown. Unparseable lines are null, not
385
+ * errors: the stream carries system chatter this deliberately ignores.
386
+ */
387
+ export function claudeActivity(line) {
388
+ let j;
389
+ try { j = JSON.parse(line); } catch { return null; }
390
+ if (j?.type === 'result') {
391
+ return { result: typeof j.result === 'string' ? j.result : '' };
392
+ }
393
+ if (j?.type !== 'assistant') return null;
394
+ for (const block of j.message?.content ?? []) {
395
+ if (block?.type !== 'tool_use') continue;
396
+ const file = block.input?.file_path ? String(block.input.file_path).split(/[/\\]/).pop() : null;
397
+ switch (block.name) {
398
+ case 'Edit': case 'Write': case 'MultiEdit': case 'NotebookEdit':
399
+ return { activity: `editing ${file ?? 'the deck'}` };
400
+ case 'Read':
401
+ return { activity: `reading ${file ?? 'a file'}` };
402
+ case 'Bash':
403
+ return { activity: `running: ${String(block.input?.command ?? '').slice(0, 48) || 'a command'}` };
404
+ case 'Grep': case 'Glob':
405
+ return { activity: `searching for ${String(block.input?.pattern ?? '').slice(0, 40) || '…'}` };
406
+ default:
407
+ return { activity: `${block.name}…` };
408
+ }
409
+ }
410
+ return null;
411
+ }
package/cli/associate.mjs CHANGED
@@ -32,12 +32,12 @@
32
32
  */
33
33
 
34
34
  import { writeFileSync, mkdirSync, rmSync, existsSync, chmodSync } from 'node:fs';
35
- import { execFileSync } from 'node:child_process';
36
35
  import { homedir, platform } from 'node:os';
37
36
  import path from 'node:path';
38
37
  import { fileURLToPath } from 'node:url';
39
38
  import { isMain } from '../tools/args.mjs';
40
39
  import { DECK_EXT } from './deckfile.mjs';
40
+ import { run, PROBE_MS } from '../tools/exec.mjs';
41
41
 
42
42
  export const MIME_TYPE = 'application/vnd.decklight';
43
43
  export const UTI = 'io.decklight.deck';
@@ -208,7 +208,7 @@ const windowsUninstall = () => [
208
208
 
209
209
  /** Refresh a desktop database if the tool is there; never fail over its absence. */
210
210
  function refresh(argv) {
211
- try { execFileSync(argv[0], argv.slice(1), { stdio: 'ignore' }); return true; }
211
+ try { run(argv[0], argv.slice(1), { stdio: 'ignore', timeout: PROBE_MS }); return true; }
212
212
  catch { return false; }
213
213
  }
214
214
 
package/cli/banner.mjs ADDED
@@ -0,0 +1,125 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * One banner for `decklight author`, and the deck's URL is the last thing on it.
6
+ *
7
+ * author runs its servers as child processes and used to let each one print its
8
+ * own startup lines through a pipe that did nothing but prefix them. That gave
9
+ * two problems no amount of rewording fixes:
10
+ *
11
+ * THE ORDER WAS A RACE. `deck` and `voice` are separate processes announcing
12
+ * themselves whenever they happen to be ready, so the URL a person is meant
13
+ * to click landed wherever it landed — often above the bridge's line, which
14
+ * is also a URL, and the wrong one to click.
15
+ *
16
+ * NOBODY OWNED THE WHOLE. Each line was defensible alone and the eight
17
+ * together were a wall, because no single place could see them all and
18
+ * decide what mattered.
19
+ *
20
+ * So author prints the banner and the children stop printing startup lines —
21
+ * they hand author a FACT instead, on the same pipe, behind a sentinel
22
+ * (`readyLine`). Only under author: with no `DECKLIGHT_BANNER` in the
23
+ * environment every child prints exactly what it printed before, which is what
24
+ * `decklight edit` and `decklight tts` run on their own still do.
25
+ *
26
+ * Nothing here does I/O. `renderBanner` takes facts and returns lines, so the
27
+ * layout is a unit test rather than something you check by starting a server.
28
+ */
29
+
30
+ /**
31
+ * The marker a child puts in front of a startup fact.
32
+ *
33
+ * The leading \u0001 is deliberate: it cannot occur in a human-facing line, so
34
+ * ordinary child output can never be mistaken for a fact, and a fact can never
35
+ * leak onto the terminal as something to read.
36
+ */
37
+ export const READY = '\u0001decklight:ready ';
38
+
39
+ /** What a child writes instead of its own startup line. */
40
+ export function readyLine(fact) {
41
+ return READY + JSON.stringify(fact);
42
+ }
43
+
44
+ /** A child's line as a fact, or null if it is ordinary output to pass through. */
45
+ export function parseReady(line) {
46
+ if (typeof line !== 'string' || !line.startsWith(READY)) return null;
47
+ try {
48
+ const fact = JSON.parse(line.slice(READY.length));
49
+ return fact && typeof fact === 'object' && !Array.isArray(fact) ? fact : null;
50
+ } catch { return null; }
51
+ }
52
+
53
+ /**
54
+ * The order rows appear in, whatever order the processes woke up in — which is
55
+ * the entire point of collecting them all before printing any.
56
+ *
57
+ * `reviews` is last because it is the only row that is a THING TO DO rather
58
+ * than a thing that is merely true, so it sits closest to the URL.
59
+ */
60
+ export const ROW_ORDER = ['voice', 'lips', 'skipped', 'git', 'agents', 'reviews'];
61
+
62
+ const ESC = { dim: '\x1b[2m', bold: '\x1b[1m', cyan: '\x1b[36m', under: '\x1b[4m', reset: '\x1b[0m' };
63
+
64
+ /**
65
+ * The banner, as lines. `rows` is `[{ key, text }]` in any order; a key not in
66
+ * ROW_ORDER keeps its arrival position after the known ones, so a service added
67
+ * later still appears without anyone having to remember to edit that list.
68
+ */
69
+ export function renderBanner({ deck, url, keys, rows = [], color = false } = {}) {
70
+ const c = (s, ...codes) => (color ? codes.map((k) => ESC[k]).join('') + s + ESC.reset : s);
71
+ const rank = (k) => { const i = ROW_ORDER.indexOf(k); return i === -1 ? ROW_ORDER.length : i; };
72
+ const shown = rows
73
+ .filter((r) => r && r.key && r.text)
74
+ .map((r, i) => ({ ...r, i }))
75
+ .sort((a, b) => rank(a.key) - rank(b.key) || a.i - b.i);
76
+
77
+ const out = [`decklight author${deck ? ` ${c('·', 'dim')} ${deck}` : ''}`];
78
+ if (shown.length) {
79
+ out.push('');
80
+ const w = Math.max(...shown.map((r) => r.key.length));
81
+ for (const r of shown) out.push(` ${c(r.key.padEnd(w), 'dim')} ${r.text}`);
82
+ }
83
+ // The URL last, and the only coloured thing here, because a person scanning
84
+ // this is looking for exactly one thing and it is this.
85
+ out.push('', ` ${c('▸', 'cyan')} ${c(url, 'bold', 'cyan', 'under')}`);
86
+ if (keys) out.push(` ${c(keys, 'dim')}`);
87
+ return out;
88
+ }
89
+
90
+ /**
91
+ * How long to wait before printing the banner, or null for "not yet".
92
+ *
93
+ * Pure, because the ordering bug it encodes is not one you want to find by
94
+ * starting three servers and squinting. A grace window ALONE is not enough:
95
+ * the voice bridge enumerates the machine's voices before it can say what it
96
+ * is, so it reports hundreds of milliseconds after the deck server does, and
97
+ * any grace short enough to feel instant printed the banner without it — the
98
+ * bridge's row then landed UNDER the url, which is the one thing the banner
99
+ * exists to prevent. So the wait is on NAMES: nobody still owed, then a short
100
+ * grace for the genuinely late (the review check fires detached, after the
101
+ * deck server is already listening), and a cap so one silent child cannot sit
102
+ * on the url forever.
103
+ */
104
+ export function nextFlushDelay({ waiting = 0, elapsed = 0, cap = 5000, grace = 350 } = {}) {
105
+ if (waiting > 0) return null;
106
+ return Math.max(0, Math.min(grace, cap - elapsed));
107
+ }
108
+
109
+ /**
110
+ * How anything WATCHING author's output finds the deck's url.
111
+ *
112
+ * Exported because six harnesses each carried their own copy of the old
113
+ * `decklight author on http://…`, and the day that line changed shape all six
114
+ * timed out for the same reason in six different files. A banner is a thing
115
+ * people read, so its wording will change again; this is the part that is a
116
+ * contract, and it lives next to the code that prints it.
117
+ *
118
+ * Group 1 is the port. Tolerant of the colour codes a terminal gets and a pipe
119
+ * does not, so it matches whichever way author was run — and the escapes and
120
+ * the space INTERLEAVE: the reset that closes the ▸ lands between the arrow
121
+ * and the space before the url. A pattern that expected the whitespace first
122
+ * matched every piped harness and none of the ones driven through a pty,
123
+ * which is a single test and a 45-second timeout rather than a failure.
124
+ */
125
+ export const DECK_URL_RE = /\u25b8(?:\s|\x1b\[[0-9;]*m)*http:\/\/127\.0\.0\.1:(\d+)/;
package/cli/bundle.mjs CHANGED
@@ -433,7 +433,7 @@ html = html.replace(
433
433
  // ---------------------------------------------- narration lip-sync sidecars
434
434
 
435
435
  // slide-NN.visemes.json next to a narration track (tools/lipsync.mjs, or the
436
- // ⇧V export) inlines as a data-decklight-visemes block — fetch() is blocked
436
+ // the recorder's export) inlines as a data-decklight-visemes block — fetch() is blocked
437
437
  // on file:// and a bundle should not depend on a sidecar folder. Per-slide
438
438
  // MP4s stay external: video cannot inline sanely (a deck's worth is
439
439
  // 50–150 MB), same posture as playlist links.
@@ -446,14 +446,20 @@ html = html.replace(
446
446
  if (!fs.existsSync(abs) || !fs.statSync(abs).isDirectory()) continue;
447
447
  let mp4s = 0;
448
448
  for (const f of fs.readdirSync(abs).sort()) {
449
- const vm = f.match(/^slide-(\d+)\.visemes\.json$/);
449
+ // slide-NN and slide-NN-KK alike: a beat-paced track carries a sidecar
450
+ // per ⟨CLICK⟩ beat, and a bundle that inlined only the slide ones would
451
+ // leave the character animating from amplitude the moment it is opened
452
+ // from file:// — which is the one place a bundle is always opened.
453
+ const vm = f.match(/^(slide-\d+(?:-\d+)?)\.visemes\.json$/);
450
454
  if (vm) {
455
+ // vm[1] is the whole STEM (`slide-07`, `slide-07-02`) — the same name
456
+ // the runtime looks the block up by, so the two cannot drift apart.
451
457
  if (seen.has(vm[1])) {
452
- notices.push(`character visemes: ${d}/${f} skipped — slide ${vm[1]} already inlined from another track`);
458
+ notices.push(`character visemes: ${d}/${f} skipped — ${vm[1]} already inlined from another track`);
453
459
  continue;
454
460
  }
455
461
  seen.add(vm[1]);
456
- embeds.push(`<script type="application/json" data-decklight-visemes="slide-${vm[1]}">\n`
462
+ embeds.push(`<script type="application/json" data-decklight-visemes="${vm[1]}">\n`
457
463
  + `${scriptSafe(fs.readFileSync(path.join(abs, f), 'utf8'))}\n</script>`);
458
464
  } else if (/^slide-\d+\.mp4$/.test(f)) mp4s++;
459
465
  }
@@ -461,7 +467,11 @@ html = html.replace(
461
467
  notices.push(`character video: ${mp4s} slide-NN.mp4 in ${d}/ stay external — ship the folder next to the bundle`);
462
468
  }
463
469
  }
464
- if (seen.size) notices.push(`character visemes: inlined ${seen.size} slide timeline(s)`);
470
+ if (seen.size) {
471
+ const beats = [...seen].filter((k) => /^slide-\d+-\d+$/.test(k)).length;
472
+ notices.push(`character visemes: inlined ${seen.size} timeline(s)`
473
+ + (beats ? ` (${seen.size - beats} slides + ${beats} ⟨CLICK⟩ beats)` : ''));
474
+ }
465
475
  }
466
476
 
467
477
  // --------------------------------------------- narration manifest tracks
@@ -3,11 +3,22 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
5
  /**
6
- * decklight-rec — record truthful terminal casts for Decklight decks (SPEC RECORDER_CLI/CAST_FORMAT).
6
+ * decklight-cast — record truthful terminal casts for Decklight decks (SPEC RECORDER_CLI/CAST_FORMAT).
7
7
  *
8
- * decklight rec <script.term.yaml> [-o out.cast.json] [--allow-fail] [--quiet]
8
+ * decklight cast <script.term.yaml> [-o out.cast.json] [--allow-fail] [--quiet]
9
9
  * decklight refresh <dir | cast.json…> [--allow-fail]
10
10
  *
11
+ * This briefly shipped as `decklight rec`, a name dropped without an alias or
12
+ * a refusal stub: `rec` reads as an abbreviation of `record`, and `decklight
13
+ * record` now records something else entirely — the author's voice — so the
14
+ * old name would have gone on quietly meaning the opposite of what its reader
15
+ * assumes. Nothing depends on it (decklight has no released users yet), so
16
+ * there is nothing to migrate and no stub worth carrying.
17
+ *
18
+ * `cast` is not a new word here: the file is `.cast.json`, the format is SPEC
19
+ * CAST_FORMAT, `refresh` takes casts and `export` flattens one. Only the
20
+ * command that made them ever said `rec`.
21
+ *
11
22
  * How a step boundary is detected (the sentinel technique):
12
23
  * All commands run in ONE persistent PTY shell session. For each step we
13
24
  * write two lines to the PTY: the command itself, then
@@ -25,7 +36,7 @@ import fs from 'node:fs';
25
36
  import path from 'node:path';
26
37
  import os from 'node:os';
27
38
  import { createRequire } from 'node:module';
28
- import { makeFail, runMain } from './util.mjs';
39
+ import { makeFail, runMain, wrongRecorder } from './util.mjs';
29
40
  import { isMain } from '../tools/args.mjs';
30
41
 
31
42
  const require = createRequire(import.meta.url);
@@ -41,7 +52,7 @@ const READY_MARK = `${GS}DECKLIGHT-READY${GS}`;
41
52
 
42
53
  // ---------------------------------------------------------------- utilities
43
54
 
44
- const fail = makeFail('rec');
55
+ const fail = makeFail('cast');
45
56
 
46
57
  function loadDeps() {
47
58
  let yaml, pty;
@@ -445,10 +456,11 @@ async function refresh(targets, { allowFail }) {
445
456
 
446
457
  // --------------------------------------------------------------------- main
447
458
 
448
- const HELP = `decklight rec — record terminal casts for Decklight decks
459
+ const HELP = `decklight cast — record terminal casts for Decklight decks
460
+ (recording your VOICE narrating a deck is a different command: decklight record)
449
461
 
450
462
  Usage:
451
- decklight rec <script.term.yaml> [-o out.cast.json] [--allow-fail] [--quiet]
463
+ decklight cast <script.term.yaml> [-o out.cast.json] [--allow-fail] [--quiet]
452
464
  decklight refresh <dir | cast.json…> [--allow-fail]
453
465
  decklight export <cast.json> [-o out.cast] # asciicast v2
454
466
 
@@ -489,7 +501,7 @@ Notes:
489
501
  decklight export demo.cast.json && agg demo.cast demo.gif
490
502
  `;
491
503
 
492
- export async function recMain(argv = process.argv.slice(2)) {
504
+ export async function castMain(argv = process.argv.slice(2)) {
493
505
  if (!argv.length || argv.includes('--help') || argv.includes('-h')) { console.log(HELP); return; }
494
506
  const allowFail = argv.includes('--allow-fail');
495
507
  const quiet = argv.includes('--quiet');
@@ -517,6 +529,11 @@ export async function recMain(argv = process.argv.slice(2)) {
517
529
 
518
530
  const { yaml } = loadDeps();
519
531
  const scriptPath = rest[0];
532
+ // Named before the YAML parser gets it: a deck handed to this command used
533
+ // to come back as `script has no steps`, which is true of every HTML file
534
+ // and says nothing about the one thing that went wrong.
535
+ const mixedUp = wrongRecorder('cast', scriptPath);
536
+ if (mixedUp) fail(mixedUp);
520
537
  if (!scriptPath || !fs.existsSync(scriptPath)) fail(`script not found: ${scriptPath}`);
521
538
  const oIdx = rest.indexOf('-o');
522
539
  const outPath = oIdx !== -1 && rest[oIdx + 1]
@@ -539,4 +556,4 @@ export async function recMain(argv = process.argv.slice(2)) {
539
556
 
540
557
  // Import-safe: only run the CLI when executed directly (recordScript and
541
558
  // exportAsciicast are importable for tests/tooling).
542
- if (isMain(import.meta.url)) process.exitCode = await runMain('rec', recMain);
559
+ if (isMain(import.meta.url)) process.exitCode = await runMain('cast', castMain);