decklight 0.8.1 → 0.9.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/PLATFORM.md +666 -0
  2. package/README.md +224 -150
  3. package/SPEC.md +732 -886
  4. package/cli/agent-review.mjs +245 -0
  5. package/cli/agents.mjs +25 -5
  6. package/cli/associate.mjs +12 -12
  7. package/cli/audit.mjs +42 -10
  8. package/cli/banner.mjs +41 -17
  9. package/cli/bundle-audio.mjs +183 -0
  10. package/cli/bundle.mjs +383 -31
  11. package/cli/cast.mjs +7 -7
  12. package/cli/check.mjs +961 -0
  13. package/cli/clone-deck.mjs +179 -0
  14. package/cli/commands.mjs +345 -0
  15. package/cli/comments.mjs +64 -18
  16. package/cli/commit-flow.mjs +44 -19
  17. package/cli/commit-message.mjs +51 -74
  18. package/cli/commit-split.mjs +601 -0
  19. package/cli/deck-refs.mjs +59 -0
  20. package/cli/deck-routes.mjs +67 -0
  21. package/cli/deckfile.mjs +3 -5
  22. package/cli/decklight.mjs +68 -289
  23. package/cli/design-system-deps.mjs +209 -0
  24. package/cli/design-system-edit.mjs +194 -0
  25. package/cli/design-system-refs.mjs +409 -0
  26. package/cli/design-system.mjs +429 -0
  27. package/cli/doctor.mjs +115 -0
  28. package/cli/edit-git.mjs +353 -0
  29. package/cli/edit-handover.mjs +445 -0
  30. package/cli/edit-look.mjs +388 -0
  31. package/cli/edit-slides.mjs +683 -0
  32. package/cli/edit.mjs +2126 -842
  33. package/cli/enhance.mjs +483 -0
  34. package/cli/extension.mjs +10 -10
  35. package/cli/font-refs.mjs +273 -0
  36. package/cli/font.mjs +246 -0
  37. package/cli/git-tree.mjs +1 -1
  38. package/cli/git.mjs +65 -11
  39. package/cli/import.mjs +56 -10
  40. package/cli/init.mjs +400 -234
  41. package/cli/library.mjs +127 -0
  42. package/cli/loader.mjs +3 -1
  43. package/cli/marketplace.mjs +215 -21
  44. package/cli/narrate.mjs +176 -0
  45. package/cli/open-browser.mjs +63 -0
  46. package/cli/open.mjs +943 -0
  47. package/cli/pdf.mjs +41 -13
  48. package/cli/pkg.mjs +44 -2
  49. package/cli/plugin.mjs +43 -41
  50. package/cli/port-conflict.mjs +53 -23
  51. package/cli/pptx-export.mjs +57 -24
  52. package/cli/publish.mjs +8 -4
  53. package/cli/qr.mjs +1 -1
  54. package/cli/record.mjs +14 -12
  55. package/cli/remote.mjs +11 -11
  56. package/cli/restore.mjs +11 -4
  57. package/cli/review-ref.mjs +125 -0
  58. package/cli/review-remote.mjs +92 -48
  59. package/cli/review-routes.mjs +254 -0
  60. package/cli/review-store.mjs +47 -7
  61. package/cli/review-submit.mjs +47 -57
  62. package/cli/runtime-link.mjs +560 -0
  63. package/cli/serve.mjs +235 -44
  64. package/cli/setup.mjs +112 -0
  65. package/cli/sign.mjs +1 -1
  66. package/cli/skill-content.mjs +190 -33
  67. package/cli/skills.mjs +107 -24
  68. package/cli/start.mjs +110 -0
  69. package/cli/supervise.mjs +6 -6
  70. package/cli/theme-refs.mjs +515 -0
  71. package/cli/theme.mjs +181 -137
  72. package/cli/trust.mjs +83 -0
  73. package/cli/units.mjs +39 -42
  74. package/cli/update-check.mjs +1 -5
  75. package/cli/upgrade.mjs +194 -28
  76. package/cli/upstream.mjs +4 -3
  77. package/cli/util.mjs +4 -4
  78. package/cli/wizard.mjs +6 -6
  79. package/dist/build-info.json +1 -1
  80. package/dist/decklight.css +1126 -49
  81. package/dist/decklight.js +212 -115
  82. package/dist/decklight.js.map +4 -4
  83. package/docs/GLOSSARY.md +141 -0
  84. package/docs/architecture.svg +17 -17
  85. package/package.json +4 -2
  86. package/themes/README.md +9 -8
  87. package/themes/reveal-solarized.css +10 -0
  88. package/tools/args.mjs +20 -0
  89. package/tools/atomic-write.mjs +48 -0
  90. package/tools/brand-palette.mjs +717 -0
  91. package/tools/bridge.mjs +1 -1
  92. package/tools/build-groups.mjs +42 -0
  93. package/tools/color.mjs +48 -0
  94. package/tools/deck-html.mjs +396 -11
  95. package/tools/design-system-format.mjs +753 -0
  96. package/tools/elevenlabs-tts.mjs +110 -17
  97. package/tools/exec.mjs +1 -1
  98. package/tools/extension-check.mjs +31 -7
  99. package/tools/font-format.mjs +190 -0
  100. package/tools/font-stacks.mjs +24 -0
  101. package/tools/gemini-tts.mjs +3 -0
  102. package/tools/lipsync-config.mjs +103 -0
  103. package/tools/lipsync-engines.mjs +205 -2
  104. package/tools/lipsync-server.mjs +264 -41
  105. package/tools/lipsync.mjs +37 -18
  106. package/tools/local-voice.mjs +32 -42
  107. package/tools/narration-manifest.mjs +196 -0
  108. package/tools/narration-synth.mjs +416 -0
  109. package/tools/pptx.mjs +776 -19
  110. package/tools/publish-targets.mjs +1 -1
  111. package/tools/publish-voices.mjs +3 -3
  112. package/tools/recording-impact.mjs +7 -3
  113. package/tools/render-theme.mjs +33 -0
  114. package/tools/review-anchor.mjs +28 -12
  115. package/tools/semver.mjs +40 -0
  116. package/tools/sentences.mjs +180 -0
  117. package/tools/shot.mjs +14 -7
  118. package/tools/site-voices.mjs +232 -0
  119. package/tools/template-theme.mjs +1 -1
  120. package/tools/test-impact.mjs +17 -10
  121. package/tools/theme-check.mjs +30 -3
  122. package/tools/tts-cache.mjs +4 -3
  123. package/tools/tts-engines.mjs +38 -20
  124. package/tools/tts-setup.mjs +7 -7
  125. package/tools/video-options.mjs +34 -0
  126. package/tools/video.mjs +461 -48
  127. package/tools/voiceover-server.mjs +185 -104
  128. package/tools/voiceover.mjs +119 -261
  129. package/tools/zip.mjs +1 -1
  130. package/cli/dev.mjs +0 -623
  131. package/cli/present.mjs +0 -853
  132. package/cli/review.mjs +0 -361
  133. package/tools/publish-site-voices.mjs +0 -75
package/cli/review.mjs DELETED
@@ -1,361 +0,0 @@
1
- #!/usr/bin/env node
2
- // Copyright 2026 Gilles Philippart
3
- // SPDX-License-Identifier: Apache-2.0
4
-
5
- // decklight review — leave comments on somebody's deck. SPEC REVIEW.
6
- //
7
- // decklight review <deck.html> [--port 8790] [--no-open] [--no-git]
8
- //
9
- // WHY THIS IS ITS OWN COMMAND, AND ITS OWN SERVER.
10
- //
11
- // SPEC PRESENTING refuses, three separate times, to let a server that is not
12
- // the authoring server acquire a write capability: "a server that can move a
13
- // deck that did not ask is an editing server with the writes left out, and that
14
- // capability is not created here", and "a shared path with a boolean in it is
15
- // how a presenting server quietly acquires an editing capability later".
16
- //
17
- // So reviewing is not a flag on `present` (which writes nothing, by
18
- // construction — it registers no /edit/* route to have refused) and not a flag
19
- // on `author` (which would hand a reviewer the power to rewrite the deck they
20
- // were asked to read). It is a third command with a third route namespace, and
21
- // the capability it adds is stated by what it registers rather than by what it
22
- // checks:
23
- //
24
- // GET /review/ping who am I looking at
25
- // GET /review/comments what has been said
26
- // POST /review/comments say one thing
27
- //
28
- // There is no /edit/*, and the deck file is opened for READING only. The one
29
- // path this process will ever write is `<deck>.review.jsonl`. That is not a
30
- // promise in a comment — test/review-server.test.mjs asserts every /edit/* route
31
- // 405s and that the deck is byte-identical afterwards.
32
- //
33
- // Git is the backend but never the transport for the SERVER: with a repository,
34
- // each comment is committed (the sidecar alone, staged by itself); with none,
35
- // the file is just a file, which is the thing you send back. This server never
36
- // pushes — pushing is `review submit` (cli/review-submit.mjs), a one-shot the
37
- // reviewer types (or confirms in the overlay), and POST /review/submit below is
38
- // that same code behind the same explicit gesture.
39
-
40
- import { createServer } from 'node:http';
41
- import { existsSync, readFileSync, appendFileSync } from 'node:fs';
42
- import { basename, dirname, resolve, relative } from 'node:path';
43
- import { execFileSync } from 'node:child_process';
44
-
45
- import { argReader, firstPositional, isMain } from '../tools/args.mjs';
46
- import { staticFiles, allowEditRequest, listenTakingOverIfNeeded } from './serve.mjs';
47
- import { inGitRepo, gitAutocommit, gitAvailable, commitSubject, oneline } from './git.mjs';
48
- import { reviewPathFor, parseReview, serializeRecord, newId } from './review-store.mjs';
49
- import { openUrl } from './init.mjs';
50
- import { exitWhenOrphaned } from './supervise.mjs';
51
-
52
- const USAGE = `usage: decklight review <deck.html> [--port 8790] [--no-open] [--no-git]
53
- open somebody's deck and leave comments on it, anchored to slides
54
-
55
- ⇧M in the deck leaves a comment (M reads them all, or / → "Leave a comment…"); the
56
- comment is attached to the slide you are looking at, and remembers enough
57
- about it to find that slide again after the deck has moved on
58
-
59
- --port N port to serve on (taken? moves to the next free one) [8790]
60
- --no-open don't launch a browser — print the URL and wait
61
- --no-git write the file and never commit it (each comment still records
62
- WHICH COMMIT the deck was on — that is provenance, not bookkeeping)
63
-
64
- comments land in <deck>.review.jsonl beside the deck: one line each,
65
- append-only, so two reviewers never conflict and a push reads as a diff.
66
- In a repository each one is committed; without one it is a file to send back
67
- (the author reads it with: decklight comments <deck.html> --import <file>)
68
-
69
- this server writes that file and nothing else — it has no /edit/* routes and
70
- never opens the deck for writing
71
-
72
- when you are done, send them: decklight review submit <deck.html>
73
- `;
74
-
75
- /**
76
- * Who is speaking, from git's own answer — the only identity decklight has.
77
- *
78
- * `publish.mjs` reads it exactly this way, degrading to '' rather than failing,
79
- * and a comment with no name is still a comment worth keeping: an unsigned
80
- * remark from a machine with no git identity beats refusing to take it.
81
- */
82
- export function reviewerIdentity(cwd, exec = execFileSync) {
83
- const cfg = (key) => {
84
- try { return exec('git', ['config', key], { cwd, encoding: 'utf8' }).trim(); } catch { return ''; }
85
- };
86
- const name = cfg('user.name');
87
- const email = cfg('user.email');
88
- if (name && email) return `${name} <${email}>`;
89
- return name || email || '';
90
- }
91
-
92
- /**
93
- * The record a posted comment becomes.
94
- *
95
- * Pure, so the shape is testable without a server: the browser sends what it
96
- * knows about the slide (its number, title and fingerprint) and the server adds
97
- * what only it knows (who, when, and which commit of the deck was on screen).
98
- *
99
- * `body` is the reviewer's own prose and is stored verbatim — it is data here,
100
- * never an argument to anything. The one place it could reach a command line is
101
- * a commit subject, and that goes through `commitSubject`.
102
- */
103
- export function reviewRecord(input, { by, at, deck, id }) {
104
- const rec = { id, at, ...(by ? { by } : {}), ...(deck ? { deck } : {}) };
105
- if (input.re) rec.re = String(input.re);
106
- else {
107
- rec.slide = Number(input.slide);
108
- if (input.title) rec.title = String(input.title).slice(0, 200);
109
- if (input.fp) rec.fp = String(input.fp).slice(0, 32);
110
- }
111
- rec.body = String(input.body);
112
- return rec;
113
- }
114
-
115
- /** What a posted comment must carry to be worth storing, or the reason it is not. */
116
- export function commentProblem(input) {
117
- if (!input || typeof input !== 'object') return 'not a comment';
118
- const body = typeof input.body === 'string' ? input.body.trim() : '';
119
- if (!body) return 'a comment needs something in it';
120
- if (body.length > 4000) return 'that comment is longer than 4000 characters';
121
- if (input.re !== undefined && (typeof input.re !== 'string' || !/^[a-z0-9]{1,12}$/.test(input.re))) {
122
- return 'bad reply target';
123
- }
124
- if (input.re === undefined) {
125
- const n = Number(input.slide);
126
- if (!Number.isInteger(n) || n < 1 || n > 9999) return 'a comment belongs to a slide';
127
- }
128
- return null;
129
- }
130
-
131
- const SUBMIT_USAGE = `usage: decklight review submit <deck.html> [--pr] [--remote origin] [--dry-run]
132
- push the comments you left to a branch of their own, for the author to read
133
-
134
- the branch is review/<you>-<today>, and a second submit the same day lands on
135
- the branch already there — a morning of reviewing is one branch, one PR
136
-
137
- --pr also open a pull request (needs gh, signed in)
138
- --remote NAME which remote to push to [origin]
139
- --dry-run build the commit and stop before pushing anything
140
-
141
- this pushes ONE FILE: the comments. Your branch, your working tree and your
142
- index are never touched, and none of your own commits come along.
143
- `;
144
-
145
- /**
146
- * `decklight review submit <deck>`.
147
- *
148
- * Thin on purpose — everything that could be got wrong lives in
149
- * cli/review-submit.mjs, where it is testable without a process.
150
- */
151
- async function submitSubcommand(args, { out = process.stdout } = {}) {
152
- const { opt } = argReader(args);
153
- // The deck is the positional that LOOKS like a deck — `--remote upstream
154
- // talk.html` must not read "upstream" as the deck. comments.mjs's rule.
155
- const deckArg = args.find((a) => !a.startsWith('-') && /\.html?$/i.test(a));
156
- if (!deckArg || args.includes('--help') || args.includes('-h')) {
157
- out.write(SUBMIT_USAGE);
158
- return deckArg ? 0 : 1;
159
- }
160
- const { submitReview } = await import('./review-submit.mjs');
161
- try {
162
- submitReview(resolve(process.cwd(), deckArg), {
163
- remote: opt('--remote', 'origin'),
164
- pr: args.includes('--pr'),
165
- dryRun: args.includes('--dry-run'),
166
- out,
167
- });
168
- return 0;
169
- } catch (e) {
170
- // CommandError already carries the command name and a way forward.
171
- process.stderr.write(`${e?.message ?? e}\n`);
172
- return 1;
173
- }
174
- }
175
-
176
- export async function reviewMain(args, { open = openUrl, out = process.stdout, onListen = null } = {}) {
177
- // `review submit <deck>` is a one-shot: it pushes what is already written and
178
- // exits. It is dispatched here rather than as a command of its own because it
179
- // is the second half of `review` — the same store, the same reviewer, and a
180
- // person who typed one will look for the other in the same place.
181
- if (args[0] === 'submit') return submitSubcommand(args.slice(1), { out });
182
-
183
- if (args.includes('--help') || args.includes('-h') || !args.filter((a) => !a.startsWith('-')).length) {
184
- out.write(USAGE);
185
- return 0;
186
- }
187
- const { opt } = argReader(args);
188
- const deckArg = firstPositional(args, ['--port']);
189
- const root = process.cwd();
190
- const deckPath = resolve(root, deckArg);
191
- if (!existsSync(deckPath)) { process.stderr.write(`decklight review: no such deck: ${deckArg}\n`); return 1; }
192
- if (!deckPath.startsWith(root + '/') && dirname(deckPath) !== root) {
193
- process.stderr.write('decklight review: the deck must live under the current directory\n');
194
- return 1;
195
- }
196
-
197
- const deckDir = dirname(deckPath);
198
- const name = basename(deckPath);
199
- const storePath = reviewPathFor(deckPath);
200
- const storeName = basename(storePath);
201
-
202
- // Git is the backend, not a requirement: a reviewer who was sent a file has
203
- // no repository and must still be able to say something.
204
- const noGit = args.includes('--no-git');
205
- const inRepo = gitAvailable(deckDir) && inGitRepo(deckDir);
206
- const gitOn = !noGit && inRepo;
207
- // Whether THIS session pushed. Read by the Ctrl-C line below: a reviewer who
208
- // wrote comments and never submitted should hear so on the way out.
209
- let submitted = false;
210
- const by = inRepo ? reviewerIdentity(deckDir) : '';
211
- /**
212
- * WHICH VERSION OF THE DECK this comment is about.
213
- *
214
- * Gated on being in a repository, NOT on `--no-git`. Those are two different
215
- * questions: `--no-git` says "do not commit for me", and this says "which
216
- * bytes was the reviewer looking at" — provenance, not bookkeeping. Suppressing
217
- * it with the commit is how a comment loses the one fact that lets anybody
218
- * check what the slide said at the time.
219
- *
220
- * `--short`, because it is read by people and lives in a line somebody scans.
221
- */
222
- const deckHead = () => {
223
- if (!inRepo) return null;
224
- try { return execFileSync('git', ['rev-parse', '--short', 'HEAD'], { cwd: deckDir, encoding: 'utf8' }).trim(); }
225
- catch { return null; }
226
- };
227
-
228
- const files = staticFiles(deckDir, { knownTypesOnly: true });
229
- const json = (res, code, body) => {
230
- res.writeHead(code, { 'content-type': 'application/json', 'cache-control': 'no-store' });
231
- res.end(JSON.stringify(body));
232
- };
233
-
234
- const server = createServer(async (req, res) => {
235
- // The same origin gate the edit server uses, for the same reason: binding
236
- // loopback is the wrong boundary when the dangerous caller is another tab
237
- // in the reviewer's own browser.
238
- if (!allowEditRequest(req)) { res.writeHead(403); res.end('this server answers this machine only'); return; }
239
- const url = new URL(req.url, 'http://127.0.0.1');
240
-
241
- if (req.method === 'GET' && url.pathname === '/review/ping') {
242
- return json(res, 200, { ok: true, name, review: true, git: gitOn, by: by || null, store: storeName });
243
- }
244
-
245
- if (req.method === 'GET' && url.pathname === '/review/comments') {
246
- const text = existsSync(storePath) ? readFileSync(storePath, 'utf8') : '';
247
- const { records, skipped } = parseReview(text);
248
- // `skipped` travels rather than being swallowed: a reader showing fewer
249
- // comments than the file holds should be able to say so.
250
- return json(res, 200, { ok: true, records, skipped });
251
- }
252
-
253
- if (req.method === 'POST' && url.pathname === '/review/comments') {
254
- let body = '';
255
- try {
256
- for await (const chunk of req) { body += chunk; if (body.length > 1e5) throw new Error('too large'); }
257
- } catch { return json(res, 413, { ok: false, error: 'that comment is too large' }); }
258
- let input;
259
- try { input = JSON.parse(body || '{}'); } catch { return json(res, 400, { ok: false, error: 'bad payload' }); }
260
- const bad = commentProblem(input);
261
- if (bad) return json(res, 400, { ok: false, error: bad });
262
-
263
- const rec = reviewRecord(input, {
264
- by, at: new Date().toISOString(), deck: deckHead(), id: newId(),
265
- });
266
- try {
267
- // Append, never rewrite — that is what makes `merge=union` work and a
268
- // second reviewer harmless.
269
- appendFileSync(storePath, `${serializeRecord(rec)}\n`);
270
- } catch (e) { return json(res, 500, { ok: false, error: oneline(e) }); }
271
-
272
- let committed = false;
273
- if (gitOn) {
274
- // The reviewer's own prose reaching a command line, so it goes through
275
- // the sanitizer every other untrusted subject does: one line, capped,
276
- // never leading `-`.
277
- const subject = commitSubject(`review: ${rec.body}`, `review: a comment on ${name}`);
278
- committed = gitAutocommit(storePath, deckDir, subject);
279
- }
280
- out.write(` comment on slide ${rec.slide ?? '—'} → ${storeName}${committed ? ' (committed)' : ''}\n`);
281
- return json(res, 200, { ok: true, id: rec.id, committed });
282
- }
283
-
284
- if (req.method === 'POST' && url.pathname === '/review/submit') {
285
- // The browser NEVER runs git: it asks, and this server — the only thing
286
- // in the room holding a capability — does the pushing, with the same
287
- // code the typed `review submit` runs. Dynamically imported like the
288
- // subcommand, so review-submit's static import of reviewerIdentity from
289
- // this file never becomes a cycle.
290
- try {
291
- const { submitReview } = await import('./review-submit.mjs');
292
- const lines = [];
293
- const r = submitReview(deckPath, { out: { write: (t) => lines.push(t) } });
294
- out.write(lines.join('')); // the terminal is a log of what happened
295
- submitted = true;
296
- return json(res, 200, { ok: true, branch: r.branch, comments: r.comments, resubmit: r.resubmit });
297
- } catch (e) {
298
- // A refusal (no remote, nothing to send) arrives with its way forward
299
- // in the message — the browser toasts it verbatim.
300
- return json(res, 500, { ok: false, error: String(e?.message ?? e) });
301
- }
302
- }
303
-
304
- if (files(req, res, url)) return;
305
- // Everything else — including every /edit/* path — lands here. There is no
306
- // route to have refused, which is the point.
307
- res.writeHead(405);
308
- res.end();
309
- });
310
-
311
- const actual = await listenTakingOverIfNeeded(server, Number(opt('--port', 8790)), '127.0.0.1');
312
- const deckUrl = `/${relative(deckDir, deckPath)}`;
313
- const url = `http://127.0.0.1:${actual}${deckUrl}?review`;
314
- if (onListen) onListen({ port: actual, deckUrl, server });
315
-
316
- out.write(`decklight review on ${url}\n`);
317
- out.write(' M opens the composer · the comment attaches to the slide you are on · Esc closes\n');
318
- const existing = existsSync(storePath) ? parseReview(readFileSync(storePath, 'utf8')).records.length : 0;
319
- out.write(` comments go to ${storeName}`
320
- + `${existing ? ` (${existing} already there)` : ''}`
321
- // --no-git inside a clone means "don't auto-commit", not "there is no
322
- // repository" — saying the wrong one steers the reviewer away from
323
- // `review submit`, which works fine there.
324
- + `${gitOn ? ', committed as you go'
325
- : inRepo ? ', not committed (--no-git)'
326
- : ', not committed — this is not a git repository'}\n`);
327
- if (!gitOn && !noGit) {
328
- out.write(` send ${storeName} back when you are done; the author reads it with:\n`);
329
- out.write(` decklight comments ${name} --import ${storeName}\n`);
330
- }
331
- // Where the comments go next. Said at startup rather than only on Ctrl-C: a
332
- // reviewer who closes the terminal never sees an exit line, and a review that
333
- // stays on their laptop is a review that did not happen.
334
- // `deckArg`, not basename: this line exists to be PASTED, and for a deck in
335
- // a subdirectory `review submit deck.html` resolves against cwd and fails.
336
- // The path the reviewer just typed is, by construction, one that works here.
337
- out.write(` when you are done, send them: decklight review submit ${deckArg}`
338
- + `${inRepo ? '' : ` (no repository here — send ${storeName} back instead)`}\n`);
339
- out.write(' Ctrl-C when you are done.\n');
340
- if (!args.includes('--no-open')) await open(url, { out, what: url });
341
-
342
- // The exit line. Local prints only — cli/edit.mjs:604's rule: a SIGINT
343
- // handler that touched the network would hang the very keystroke that asks
344
- // to leave.
345
- process.on('SIGINT', () => {
346
- if (!submitted && inRepo && existsSync(storePath)) {
347
- const { records } = parseReview(readFileSync(storePath, 'utf8'));
348
- const open_ = records.filter((r) => !r.op && !r.re).length;
349
- if (open_) {
350
- out.write(`\n${open_} comment${open_ === 1 ? '' : 's'} not submitted — send them with: decklight review submit ${deckArg}\n`);
351
- }
352
- }
353
- process.exit(0);
354
- });
355
- return 0;
356
- }
357
-
358
- if (isMain(import.meta.url)) {
359
- exitWhenOrphaned();
360
- reviewMain(process.argv.slice(2)).then((code) => { if (code) process.exitCode = code; });
361
- }
@@ -1,75 +0,0 @@
1
- #!/usr/bin/env node
2
- // Copyright 2026 Gilles Philippart
3
- // SPDX-License-Identifier: Apache-2.0
4
-
5
- // Sync the locally generated voice tracks (demo/voiceover-site/<dir>/) to the
6
- // decklight.github.io repo under voices/<dir>/, in ONE commit via the Git
7
- // Data API. Only files whose git blob sha differs from the remote are
8
- // uploaded, so a regen that skipped unchanged slides uploads nothing for
9
- // them either. Audio lives ONLY in the site repo; this repo keeps the
10
- // staging dir gitignored.
11
- //
12
- // node tools/publish-site-voices.mjs [--repo decklight/decklight.github.io]
13
- //
14
- // Requires gh (authenticated) on PATH.
15
-
16
- import { readFileSync, readdirSync, existsSync } from 'node:fs';
17
- import { join } from 'node:path';
18
- import { createHash } from 'node:crypto';
19
- import { argReader } from './args.mjs';
20
- import { run, NETWORK_MS } from './exec.mjs';
21
-
22
- const args = process.argv.slice(2);
23
- const { opt } = argReader(args);
24
- const REPO = opt('--repo', 'decklight/decklight.github.io');
25
- const STAGING = 'demo/voiceover-site';
26
-
27
- const gh = (argv, input) =>
28
- JSON.parse(run('gh', ['api', ...argv], { encoding: 'utf8', input, maxBuffer: 1 << 28, timeout: NETWORK_MS, why: 'gh is waiting on the network or a login — run: gh auth status' }));
29
-
30
- // git blob sha1: sha1("blob <len>\0" + content)
31
- const blobSha = (buf) =>
32
- createHash('sha1').update(`blob ${buf.length}\0`).update(buf).digest('hex');
33
-
34
- const { voices } = JSON.parse(readFileSync('site/voices.json', 'utf8'));
35
-
36
- const head = gh([`repos/${REPO}/git/ref/heads/main`]).object.sha;
37
- const baseTree = gh([`repos/${REPO}/git/commits/${head}`]).tree.sha;
38
- const remote = new Map(
39
- gh([`repos/${REPO}/git/trees/${baseTree}?recursive=1`]).tree
40
- .filter((e) => e.type === 'blob')
41
- .map((e) => [e.path, e.sha]),
42
- );
43
-
44
- const changed = [];
45
- for (const v of voices) {
46
- const local = join(STAGING, v.dir.split('/').pop());
47
- if (!existsSync(local)) { console.warn(`skip ${v.voice}: ${local} missing (not generated yet)`); continue; }
48
- for (const f of readdirSync(local).sort()) {
49
- if (!/\.(m4a|json)$/.test(f)) continue; // .txt is a regen artifact, stays local
50
- const buf = readFileSync(join(local, f));
51
- const path = `${v.dir}/${f}`;
52
- if (remote.get(path) !== blobSha(buf)) changed.push({ path, buf });
53
- }
54
- }
55
-
56
- if (!changed.length) {
57
- console.log('site voices are up to date, nothing to upload');
58
- process.exit(0);
59
- }
60
-
61
- console.log(`uploading ${changed.length} changed file(s):`);
62
- const tree = [];
63
- for (const { path, buf } of changed) {
64
- const { sha } = gh([`repos/${REPO}/git/blobs`, '-f', `content=${buf.toString('base64')}`, '-f', 'encoding=base64']);
65
- tree.push({ path, mode: '100644', type: 'blob', sha });
66
- console.log(` ${path}`);
67
- }
68
- const newTree = gh([`repos/${REPO}/git/trees`, '--input', '-'], JSON.stringify({ base_tree: baseTree, tree }));
69
- const commit = gh([`repos/${REPO}/git/commits`, '--input', '-'], JSON.stringify({
70
- message: `voices: sync ${changed.length} file(s) from demo/voiceover-site`,
71
- tree: newTree.sha,
72
- parents: [head],
73
- }));
74
- gh([`repos/${REPO}/git/refs/heads/main`, '-X', 'PATCH', '-f', `sha=${commit.sha}`]);
75
- console.log(`done → ${REPO}@${commit.sha.slice(0, 7)}`);