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
@@ -29,6 +29,7 @@
29
29
  */
30
30
 
31
31
  import { execFile } from 'node:child_process';
32
+ import { readFileSync } from 'node:fs';
32
33
  import { basename, relative } from 'node:path';
33
34
  import { agentAsk } from './agents.mjs';
34
35
  import { commitSubject, git } from './git.mjs';
@@ -342,9 +343,133 @@ export async function describeCommit({
342
343
  return amendSubject(cwd, sha, subject, { run }) ? subject : null;
343
344
  }
344
345
 
346
+ /**
347
+ * A subject for work that is NOT COMMITTED YET — what the commit overlay's
348
+ * "write one for me" button asks for.
349
+ *
350
+ * The same prompt, the same read-only argv, the same cap and the same stated
351
+ * truncation as `describeCommit`; three things differ, and each is because
352
+ * there is no commit yet:
353
+ *
354
+ * the diff is `git diff HEAD` rather than `git show <sha>`;
355
+ * the deck is read FROM DISK, because the working tree is the subject here
356
+ * (in describeCommit reading from disk would name a slide the commit does
357
+ * not contain — here it is the only honest source);
358
+ * nothing is amended. It returns the sentence and the caller decides — a
359
+ * person is looking at a text box, and putting words in it is the most
360
+ * this is allowed to do.
361
+ *
362
+ * Returns null for every failure, exactly like its sibling: no agent, nothing
363
+ * changed, a timeout, an answer that was not a subject. The overlay then shows
364
+ * an empty box, which is the state it was in anyway.
365
+ */
366
+ export async function describeWorking({
367
+ cwd, deckPath, deckRel, template, agent = null,
368
+ env = process.env, timeoutMs = ASK_TIMEOUT_MS, run = git, exec = ask,
369
+ resolve = agentAsk, read = null,
370
+ } = {}) {
371
+ const deck = basename(deckPath);
372
+ const cmd = resolve(agent, 'x', { env });
373
+ if (!cmd) return null;
374
+ const rel = deckRel || relative(cwd, deckPath) || deck;
375
+
376
+ let out_;
377
+ try { out_ = run(['diff', '--unified=1', 'HEAD', '--', rel], cwd) ?? ''; }
378
+ catch { return null; }
379
+ if (!out_.trim()) return null;
380
+ const truncated = out_.length > MAX_DIFF;
381
+ const diff = truncated ? out_.slice(0, MAX_DIFF) : out_;
382
+
383
+ let html = '';
384
+ try { html = (read ?? readFileSync)(deckPath, 'utf8'); } catch { /* headings are optional */ }
385
+ const prompt = messagePrompt({
386
+ deck, template, diff, truncated,
387
+ title: deckTitle(html),
388
+ slides: changedSlides(html, diff),
389
+ });
390
+ const spawned = resolve(agent, prompt, { env });
391
+ if (!spawned) return null;
392
+ let answer;
393
+ try { answer = await exec(spawned, cwd, timeoutMs); }
394
+ catch { return null; }
395
+ if (answer == null) return null;
396
+ const found = subjectFrom(answer);
397
+ if (!found) return null;
398
+ const subject = commitSubject(found, template);
399
+ return subject === template ? null : subject;
400
+ }
401
+
345
402
  /** The startup line: what is on, who does it, and what leaves the machine. */
346
403
  export function messagesLine(agentName) {
347
404
  return agentName
348
405
  ? `git: ${agentName} writes the commit subjects — the deck's diffs are sent to it`
349
406
  : 'git: --commit-messages needs an agent on PATH — subjects stay generic';
350
407
  }
408
+
409
+ /**
410
+ * Where the answer lives: git's own config, in the repository it is about.
411
+ *
412
+ * The setting only means anything when there IS a repository — it describes
413
+ * what happens to that repository's commits — so git config is where it
414
+ * belongs rather than a file decklight invents. It is per-repo, it survives,
415
+ * and it is inspectable and reversible with the tool the user already knows:
416
+ * `git config decklight.commit-messages false`.
417
+ */
418
+ export const PREF_KEY = 'decklight.commit-messages';
419
+
420
+ /**
421
+ * The stored answer: true, false, or null when nobody has been asked yet.
422
+ *
423
+ * `git config --get` EXITS 1 for a key that is not set, and `git()` throws on a
424
+ * non-zero exit — so the unset case, which is every first run, arrives here as
425
+ * an exception rather than an empty string. Unreadable and unset are the same
426
+ * answer: nobody has said, so ask (or stay off).
427
+ */
428
+ export function storedPref(cwd, { run = git } = {}) {
429
+ let v = '';
430
+ try { v = (run(['config', '--get', PREF_KEY], cwd) ?? '').trim(); } catch { return null; }
431
+ return v === 'true' ? true : v === 'false' ? false : null;
432
+ }
433
+
434
+ /**
435
+ * Remember the answer, so the next session does not ask again.
436
+ *
437
+ * Never fatal: this is a convenience, and a repository that refuses the write
438
+ * (a read-only config, a worktree in a strange state) should cost the user a
439
+ * repeated question, not a failed startup.
440
+ */
441
+ export function rememberPref(cwd, on, { run = git } = {}) {
442
+ try { run(['config', PREF_KEY, on ? 'true' : 'false'], cwd); return true; } catch { return false; }
443
+ }
444
+
445
+ /**
446
+ * Whether to ask, and what the answer already is.
447
+ *
448
+ * Asked ONCE, at the moment a repository is created — the same moment the
449
+ * autocommit itself is offered, because that is when the commits this governs
450
+ * come into existence. An existing repository is never interrupted to be asked
451
+ * a new question; it uses the flag.
452
+ *
453
+ * The default is YES, and that is a defensible default only because it is a
454
+ * QUESTION. The permission is still explicitly given by a person who was told
455
+ * what leaves the machine — decklight still never infers it from what happens
456
+ * to be on PATH, which is the rule `lipsync --veo` follows. So: no agent
457
+ * installed, or no TTY to answer, means no question and no feature.
458
+ */
459
+ export function planCommitMessages({
460
+ args = [], tty = false, agents = 0, creatingRepo = false, stored = null,
461
+ } = {}) {
462
+ if (args.includes('--no-commit-messages')) return { action: 'off' };
463
+ if (args.includes('--commit-messages')) return { action: 'on' };
464
+ if (stored !== null) return { action: stored ? 'on' : 'off' };
465
+ // Nothing to drive it, nothing to write the subjects with: the feature is
466
+ // unavailable, and offering it would be offering a switch wired to nothing.
467
+ if (!agents) return { action: 'skip' };
468
+ if (!creatingRepo) return { action: 'skip' };
469
+ return { action: tty ? 'ask' : 'skip' };
470
+ }
471
+
472
+ /** The question, worded so the cost is on screen before the answer is given. */
473
+ export const ASK_MESSAGES =
474
+ ' let an agent write your commit subjects instead of "autosave"?'
475
+ + ' (sends the deck\'s diffs to it) [Y/n] ';
package/cli/decklight.mjs CHANGED
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * decklight — the Decklight command line.
7
7
  *
8
- * decklight rec record a terminal cast from a YAML script
8
+ * decklight cast record a terminal cast from a YAML script
9
9
  * decklight refresh re-run embedded scripts, rewrite drifted casts
10
10
  * decklight export convert a cast to asciicast v2
11
11
  * decklight pdf render a deck to a PDF — one slide per page, no print dialog
@@ -19,20 +19,21 @@
19
19
  * decklight template install deck templates for `init --from`
20
20
  * decklight importer install import adapters for formats decklight cannot read itself
21
21
  * decklight transform install build-time transforms, run via `bundle --transform <name>`
22
- * decklight engine install a speech engine beyond the six built in — the N picker then offers it
22
+ * decklight engine install a speech engine beyond the six built in — the V picker then offers it
23
23
  * decklight extension check a transform file — the marketplace admission gate, not a bundle step
24
- * decklight voice add a marketplace voice to the N picker — a reference, never a model
24
+ * decklight voice add a marketplace voice to the V picker — a reference, never a model
25
25
  * decklight agent teach A a coding agent beyond the built-in roster — a descriptor, never code
26
26
  * decklight tts serve the live voice bridge (on-the-fly Gemini narration)
27
27
  * decklight lipsync serve the lip-sync bridge (character visemes + talking-head video)
28
28
  * decklight video render a deck to a narrated mp4 (stills + voiceover audio)
29
29
  *
30
- * The subcommand implementations live in rec.mjs and
30
+ * The subcommand implementations live in cast.mjs and
31
31
  * bundle.mjs (importable modules; direct execution still works but
32
32
  * this dispatcher is the documented entry point).
33
33
  */
34
34
 
35
- import { readFileSync } from 'node:fs';
35
+ import { readFileSync, existsSync } from 'node:fs';
36
+ import { versionLine, parseDescribe } from './util.mjs';
36
37
 
37
38
  const GLOBAL_HELP = `decklight — author, record, and package Decklight presentations
38
39
 
@@ -46,8 +47,9 @@ Commands:
46
47
  EXAMPLE: decklight skills claude codex (or --all, or omit to use detected agents)
47
48
  EXAMPLE: decklight skills --global (install into each agent's config home, every project)
48
49
  EXAMPLE: decklight skills claude --pack (zip it to upload in your claude.ai skill settings)
49
- rec record a truthful terminal cast by running a YAML command script in a real PTY
50
- EXAMPLE: decklight rec deck.term.yaml -o deck.cast.json
50
+ cast record a truthful terminal cast by running a YAML command script in a real PTY
51
+ (this records a TERMINAL — decklight record records your VOICE)
52
+ EXAMPLE: decklight cast deck.term.yaml -o deck.cast.json
51
53
  refresh re-execute the script embedded in each cast; rewrite the ones whose output drifted
52
54
  EXAMPLE: decklight refresh casts/
53
55
  export flatten a cast to asciicast v2 (markers per step) for the asciinema ecosystem
@@ -64,6 +66,9 @@ Commands:
64
66
  EXAMPLE: decklight upgrade deck.html --dry-run (see what would change; drop the flag to apply)
65
67
  pdf render the deck to a PDF — one slide per page, at its own size, in its theme
66
68
  EXAMPLE: decklight pdf deck.html (writes deck.pdf; --theme exports in another)
69
+ EXAMPLE: decklight pdf deck.html --handout (three a page, ruled; --notes is your copy)
70
+ pptx write a PowerPoint file — every slide as a picture, its notes as notes (lossy on purpose)
71
+ EXAMPLE: decklight pptx deck.html (for the people around you who still ask for the file)
67
72
  import convert an existing PowerPoint, Keynote or Google Slides deck into a decklight deck
68
73
  EXAMPLE: decklight import "Q3 Review.pptx" (also .key on macOS, or a Slides URL)
69
74
  theme validate a theme file against the token contract, or install one into a deck
@@ -106,6 +111,21 @@ Commands:
106
111
  author one command for the whole authoring loop: live-reload editing + every bridge this
107
112
  machine can run, one Ctrl-C; E in the player edits speaker notes back into the file
108
113
  EXAMPLE: decklight author demo/showcase.html (bridges without prerequisites are skipped)
114
+ record capture the deck's narration in YOUR voice — the deck reads you its notes
115
+ one ⟨CLICK⟩ beat at a time, and → ends a beat AND reveals the next build
116
+ (this records YOU — decklight cast records a terminal)
117
+ EXAMPLE: decklight record talk.html (serves it: a microphone needs 127.0.0.1)
118
+ voiceover batch-synthesize the deck's narration into a folder with a live engine
119
+ (piper/chirp/gemini/elevenlabs) — the headless counterpart of the deck's V → Record this deck…
120
+ EXAMPLE: decklight voiceover talk.html -o voices/chirp --engine chirp --voice Achernar
121
+ review leave comments on somebody's deck, anchored to slides and carried by git
122
+ (writes <deck>.review.jsonl beside it; never touches the deck itself)
123
+ EXAMPLE: decklight review talk.html (then M in the deck)
124
+ \`review submit\` pushes them to a review/<you>-<date> branch (--pr opens one)
125
+ comments what reviewers said, resolved against the deck as it is now — a comment
126
+ whose slide moved is found anyway, and one whose slide is gone is still shown
127
+ EXAMPLE: decklight comments talk.html (--import to take in a reviewer's file,
128
+ --incoming to see what reviews are waiting on the remote)
109
129
  present play a deck you did not author — read-only over localhost, under a CSP header;
110
130
  prints what the file will execute, and strips what it cannot account for
111
131
  EXAMPLE: decklight present talk.html (no editing surface, nothing is written)
@@ -129,6 +149,26 @@ let rest = argv.slice(1);
129
149
  const { version } = JSON.parse(
130
150
  readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
131
151
  );
152
+ // which BUILD of that version — commits past the release tag and the sha.
153
+ // TWO sources, strictly ordered: a git CHECKOUT answers live (one ~10ms
154
+ // describe, dev machines only), because the stamped dist/build-info.json
155
+ // describes the tree at BUILD time and dist/ survives `git checkout` — a
156
+ // stale stamp once named the feature-branch build while main was the thing
157
+ // actually running, which is the exact misdirection this banner exists to
158
+ // prevent. A tarball ships no .git, pays nothing, and reads the stamp its
159
+ // build froze beside the code — there the two cannot diverge.
160
+ let buildInfo = null;
161
+ if (existsSync(new URL('../.git', import.meta.url))) {
162
+ try {
163
+ const { execFileSync } = await import('node:child_process');
164
+ buildInfo = parseDescribe(execFileSync('git', ['describe', '--tags', '--long', '--dirty=.dirty'],
165
+ { cwd: new URL('..', import.meta.url), encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }));
166
+ } catch { buildInfo = null; } // a tagless clone: plain is the whole truth
167
+ } else {
168
+ try { buildInfo = JSON.parse(readFileSync(new URL('../dist/build-info.json', import.meta.url), 'utf8')); }
169
+ catch { buildInfo = null; }
170
+ }
171
+ const banner = versionLine(version, buildInfo);
132
172
 
133
173
  if (!cmd || cmd === '--help' || cmd === '-h') globalHelp();
134
174
  // A newer decklight than the one npx pinned (#314). Read from a cache the last
@@ -139,7 +179,7 @@ const notice = updateNotice(version);
139
179
  refreshInBackground();
140
180
 
141
181
  if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
142
- process.stdout.write(`decklight ${version}\n`);
182
+ process.stdout.write(`${banner}\n`);
143
183
  if (notice) process.stderr.write(`${notice}\n`);
144
184
  process.exit(0);
145
185
  }
@@ -150,9 +190,15 @@ if (cmd === 'help') {
150
190
  }
151
191
 
152
192
  // every real command announces the version it runs as — on stderr, so piped
153
- // output (export, bundle) stays clean
154
- process.stderr.write(`decklight ${version}\n`);
155
- if (notice) process.stderr.write(`${notice}\n`);
193
+ // output (export, bundle) stays clean.
194
+ //
195
+ // EXCEPT under author, which spawns this same CLI two or three times: the
196
+ // parent has already said which version everything runs as, and repeating it
197
+ // once per child was the first third of author's startup wall.
198
+ if (!process.env.DECKLIGHT_BANNER) {
199
+ process.stderr.write(`${banner}\n`);
200
+ if (notice) process.stderr.write(`${notice}\n`);
201
+ }
156
202
 
157
203
  // When a parent supervises us (author runs the deck server and the bridges), go when it
158
204
  // goes — a SIGKILLed parent never gets to reap its children. No-op otherwise.
@@ -187,19 +233,19 @@ switch (cmd) {
187
233
  await skillsMain(rest);
188
234
  break;
189
235
  }
190
- case 'rec': {
191
- const { recMain } = await import('./rec.mjs');
192
- await recMain(rest);
236
+ case 'cast': {
237
+ const { castMain } = await import('./cast.mjs');
238
+ await castMain(rest);
193
239
  break;
194
240
  }
195
241
  case 'refresh': {
196
- const { recMain } = await import('./rec.mjs');
197
- await recMain(rest.includes('--help') ? ['--help'] : ['refresh', ...rest]);
242
+ const { castMain } = await import('./cast.mjs');
243
+ await castMain(rest.includes('--help') ? ['--help'] : ['refresh', ...rest]);
198
244
  break;
199
245
  }
200
246
  case 'export': {
201
- const { recMain } = await import('./rec.mjs');
202
- await recMain(rest.includes('--help') ? ['--help'] : ['export', ...rest]);
247
+ const { castMain } = await import('./cast.mjs');
248
+ await castMain(rest.includes('--help') ? ['--help'] : ['export', ...rest]);
203
249
  break;
204
250
  }
205
251
  case 'bundle': {
@@ -217,6 +263,11 @@ switch (cmd) {
217
263
  process.exitCode = await pdfMain(rest);
218
264
  break;
219
265
  }
266
+ case 'pptx': {
267
+ const { pptxMain } = await import('./pptx-export.mjs');
268
+ process.exitCode = await pptxMain(rest);
269
+ break;
270
+ }
220
271
  case 'import': {
221
272
  const { importMain } = await import('./import.mjs');
222
273
  process.exitCode = await importMain(rest);
@@ -294,6 +345,33 @@ switch (cmd) {
294
345
  await devMain(rest);
295
346
  break;
296
347
  }
348
+ case 'record': {
349
+ const { recordMain } = await import('./record.mjs');
350
+ process.exitCode = await recordMain(rest);
351
+ break;
352
+ }
353
+ case 'voiceover': {
354
+ // tools/voiceover.mjs arg-parses and exits at LOAD (it cannot be imported
355
+ // — deck-html.mjs's note), so it is spawned, exactly as `video
356
+ // --voiceover` already spawns it. stdio inherited: its per-slide progress
357
+ // and cost lines are the whole point of running it in a terminal.
358
+ const { spawnSync } = await import('node:child_process');
359
+ const { fileURLToPath } = await import('node:url');
360
+ const script = fileURLToPath(new URL('../tools/voiceover.mjs', import.meta.url));
361
+ const r = spawnSync(process.execPath, [script, ...rest], { stdio: 'inherit' });
362
+ process.exitCode = r.status ?? 1;
363
+ break;
364
+ }
365
+ case 'review': {
366
+ const { reviewMain } = await import('./review.mjs');
367
+ process.exitCode = await reviewMain(rest);
368
+ break;
369
+ }
370
+ case 'comments': {
371
+ const { commentsMain } = await import('./comments.mjs');
372
+ process.exitCode = await commentsMain(rest);
373
+ break;
374
+ }
297
375
  case 'present': {
298
376
  const { presentMain } = await import('./present.mjs');
299
377
  process.exitCode = await presentMain(rest);
@@ -304,13 +382,6 @@ switch (cmd) {
304
382
  process.exitCode = await associateMain(rest);
305
383
  break;
306
384
  }
307
- case 'edit': {
308
- // Removed as a command (COMMANDS in MARKETPLACE.md) — but a removal must
309
- // refuse out loud, naming the way forward, not shrug "unknown command".
310
- // The server itself lives on in edit.mjs; `author` starts it.
311
- process.stderr.write('decklight edit was folded into the authoring loop — run `decklight author <deck.html>` instead\n');
312
- process.exit(1);
313
- }
314
385
  default:
315
386
  process.stderr.write(`decklight: unknown command "${cmd}"\n\n`);
316
387
  globalHelp(1);
package/cli/dev.mjs CHANGED
@@ -27,6 +27,7 @@ import { existsSync } from 'node:fs';
27
27
  import { fileURLToPath } from 'node:url';
28
28
  import { createInterface } from 'node:readline/promises';
29
29
  import { onPath, detectAgents } from './agents.mjs';
30
+ import { ASK_MESSAGES, planCommitMessages } from './commit-message.mjs';
30
31
  import { validProjectId } from '../tools/gemini-tts.mjs';
31
32
  import {
32
33
  ENGINES as TTS_ENGINES, PIPER_DEFAULT_VOICE, piperModelDir, engineStatus,
@@ -38,6 +39,7 @@ import { detectLocalVoice, OLLAMA_NOTE } from '../tools/local-voice.mjs';
38
39
  import { argReader, isMain } from '../tools/args.mjs';
39
40
  import { isPortOpen, resolvePortConflict } from './port-conflict.mjs';
40
41
  import { leashEnv } from './supervise.mjs';
42
+ import { nextFlushDelay, parseReady, renderBanner } from './banner.mjs';
41
43
 
42
44
  const CLI = fileURLToPath(new URL('./decklight.mjs', import.meta.url));
43
45
  // The deck server's entry since `edit` stopped being a command: its module,
@@ -56,11 +58,11 @@ const USAGE = `usage: decklight author <deck.html> [--port 8788] [--tts-port 878
56
58
  --lipsync-port N lip-sync bridge (visemes + talking head) [8789]
57
59
  --no-tts don't start the voice bridge
58
60
  --no-lipsync don't start the lip-sync bridge
59
- --git / --no-git auto-commit the deck on a cadence / never touch git
60
- --git-mode M when to commit: timer (a cadence), agent (one commit per
61
- agent edit, with the agent's own message), off [timer]
61
+ --git / --no-git keep the deck in git (snapshot + K commits) / never touch git
62
+ --git-mode M when to commit: agent (one per agent edit, and whenever you
63
+ press K), timer (the old five-minute cadence), off [agent]
62
64
  (no repo + no flag: author ASKS whether to create one)
63
- --commit-every N autocommit cadence in seconds [300]
65
+ --commit-every N cadence in seconds, timer mode only [300]
64
66
  --commit-messages an agent writes the commit subjects instead of the generic
65
67
  "autosave" — reads each commit's diff and amends the subject
66
68
  afterwards, so the commit itself is never delayed or risked.
@@ -137,7 +139,10 @@ export function planServices({
137
139
  args: [deck, '--port', editPort,
138
140
  ...(has('--git') ? ['--git'] : []), ...(has('--no-git') ? ['--no-git'] : []),
139
141
  ...pass('--commit-every'), ...pass('--agent'), ...pass('--git-mode'),
140
- ...(has('--commit-messages') ? ['--commit-messages'] : [])],
142
+ // BOTH directions travel: the first-run question can answer no, and a no
143
+ // that did not reach the server would be a question asked and ignored.
144
+ ...(has('--commit-messages') ? ['--commit-messages'] : []),
145
+ ...(has('--no-commit-messages') ? ['--no-commit-messages'] : [])],
141
146
  url: `http://127.0.0.1:${editPort}/${deck ?? ''}`,
142
147
  });
143
148
 
@@ -344,6 +349,21 @@ export async function devMain(args) {
344
349
  const mode = await rl.question(" commit once per agent edit, with the agent's own message, instead of on a timer? [y/N] ");
345
350
  if (/^y/i.test(mode.trim())) args = [...args, '--git-mode', 'agent'];
346
351
  }
352
+ // The other half of what those commits say. Same moment, same reason as
353
+ // init's: the repository is being created right now, so this is when the
354
+ // commits it governs start existing. Default yes — but still a question,
355
+ // because the answer sends the deck's diffs to an agent.
356
+ if (yes) {
357
+ const msgs = planCommitMessages({
358
+ args, tty: true, agents: detectAgents().length, creatingRepo: true,
359
+ stored: null, // the repo does not exist yet, so nothing is stored
360
+ });
361
+ if (msgs.action === 'ask') {
362
+ const a = (await rl.question(ASK_MESSAGES)).trim();
363
+ if (!/^n/i.test(a)) args = [...args, '--commit-messages'];
364
+ else args = [...args, '--no-commit-messages'];
365
+ }
366
+ }
347
367
  rl.close();
348
368
  plan = planServices({ args, saved: loadTtsConfig() });
349
369
  } else {
@@ -377,7 +397,7 @@ export async function devMain(args) {
377
397
  if (voiceSetupOffer(plan) && process.stdin.isTTY && process.stdout.isTTY) {
378
398
  const rl = createInterface({ input: process.stdin, output: process.stdout });
379
399
  try {
380
- const answer = await rl.question(' no voice engine configured — set up live narration now? (V / N in the deck use it) [Y/n] ');
400
+ const answer = await rl.question(' no voice engine configured — set up live narration now? (V in the deck uses it) [Y/n] ');
381
401
  if (!/^n/i.test(answer.trim())) {
382
402
  const result = await runSetupWizard({ ask: (q) => rl.question(q) });
383
403
  if (result) {
@@ -416,6 +436,110 @@ export async function devMain(args) {
416
436
  const children = new Map();
417
437
  let shuttingDown = false;
418
438
 
439
+ // ── the startup banner ────────────────────────────────────────────────────
440
+ // Children report a row and author prints all of them at once, so the URL is
441
+ // last no matter which server woke up first (cli/banner.mjs says why).
442
+ //
443
+ // WHEN to print is the only hard part. Waiting for every service is wrong —
444
+ // one that never comes up would hold the URL hostage — and printing on the
445
+ // first fact is wrong too, since the rest arrive milliseconds later. So:
446
+ // settle after a short quiet gap, with a hard cap in case a child is slow or
447
+ // silent. The review check is the late one on purpose (edit.mjs fires it
448
+ // detached, after listening), and GRACE is sized for it; if it misses, it
449
+ // prints under the banner as its own row rather than delaying the URL.
450
+ // The cap is generous because it is the LAST resort, not the schedule: in the
451
+ // normal case every service reports and the banner goes out on the grace
452
+ // timer, well inside a second. The cap only matters when a child is silent,
453
+ // and then waiting is the right thing anyway — that row is missing from the
454
+ // banner either way, and a fast wrong banner is not better than a slow right
455
+ // one by four seconds.
456
+ const BANNER_CAP_MS = 5000;
457
+ const BANNER_GRACE_MS = 350;
458
+ const banner = {
459
+ done: false, held: [], rows: new Map(),
460
+ url: editSvc?.url ?? null, keys: null, timer: null, start: Date.now(),
461
+ // Who still owes us a row. The voice bridge enumerates the machine's
462
+ // voices before it can say what it is, which takes longer than any grace
463
+ // window worth having — so the banner waits on NAMES, not on a clock.
464
+ waiting: new Set(run.map((svc) => svc.tag)),
465
+ };
466
+
467
+ const bannerRow = (key, text) => ` ${tty ? `${DIM}${key}${RESET}` : key} ${text}`;
468
+
469
+ /**
470
+ * A line from author itself. Held while the banner is still being assembled,
471
+ * so nothing — an error included — can land above the URL; printed straight
472
+ * away once it is out.
473
+ */
474
+ function say(line) {
475
+ // Never a caller's choice. It was one, and the caller that passed its own
476
+ // answer got it wrong in the one case that mattered: the LAST service to
477
+ // exit computed "nobody is waiting" and printed straight away, while the
478
+ // flush timer it had just armed was still mid-flight — so its line landed
479
+ // above the banner it was supposed to sit under.
480
+ if (banner.done) process.stderr.write(`${line}\n`);
481
+ else banner.held.push(line);
482
+ }
483
+
484
+ function flushBanner() {
485
+ if (banner.done) return;
486
+ banner.done = true;
487
+ clearTimeout(banner.timer);
488
+ // Held output goes FIRST, and the banner closes. Everything in here is a
489
+ // child explaining itself — a bridge saying why it stood aside, a service
490
+ // saying why it exited — and an explanation belongs before the summary it
491
+ // explains. It also keeps the promise that matters: whatever was said on
492
+ // the way up, the deck's url is still the last line on screen.
493
+ for (const l of banner.held) process.stdout.write(`${l}\n`);
494
+ banner.held.length = 0;
495
+ if (banner.url) {
496
+ const rows = [...banner.rows].map(([key, text]) => ({ key, text }));
497
+ for (const l of renderBanner({ deck, url: banner.url, keys: banner.keys, rows, color: tty })) {
498
+ process.stdout.write(`${l}\n`);
499
+ }
500
+ }
501
+ }
502
+
503
+ /**
504
+ * A service has said its piece. Print once nobody is still owed, and keep a
505
+ * short grace after that for the genuinely late — the review check fires
506
+ * detached, after the deck server is already listening.
507
+ */
508
+ function settle(tag) {
509
+ banner.waiting.delete(tag);
510
+ const delay = nextFlushDelay({
511
+ waiting: banner.waiting.size,
512
+ elapsed: Date.now() - banner.start,
513
+ cap: BANNER_CAP_MS,
514
+ grace: BANNER_GRACE_MS,
515
+ });
516
+ if (delay === null) return;
517
+ clearTimeout(banner.timer);
518
+ banner.timer = setTimeout(flushBanner, delay);
519
+ banner.timer.unref?.();
520
+ }
521
+
522
+ function collect(tag, fact) {
523
+ if (fact.url) banner.url = fact.url;
524
+ if (fact.keys) banner.keys = fact.keys;
525
+ if (!fact.key || !fact.text) { if (fact.url) settle(tag); return; }
526
+ if (banner.done) {
527
+ // Arrived after the banner went out — still worth saying, in the shape
528
+ // it would have had, rather than swallowed for being late.
529
+ process.stdout.write(`${bannerRow(fact.key, fact.text)}\n`);
530
+ return;
531
+ }
532
+ // Two facts can share a key — `git` is both "commits on your word" and
533
+ // "claude writes the subjects", reported by different parts of the child.
534
+ // They join into one row rather than the later one erasing the earlier.
535
+ const had = banner.rows.get(fact.key);
536
+ banner.rows.set(fact.key, had && had !== fact.text ? `${had} · ${fact.text}` : fact.text);
537
+ settle(tag);
538
+ }
539
+ // Even if no child ever reports, the URL must still appear.
540
+ banner.timer = setTimeout(flushBanner, BANNER_CAP_MS);
541
+ banner.timer.unref?.();
542
+
419
543
  // Children write their own startup/progress lines; prefix each so three
420
544
  // servers in one terminal stay readable.
421
545
  const pipe = (stream, tag, out) => {
@@ -425,7 +549,16 @@ export async function devMain(args) {
425
549
  buf += chunk;
426
550
  const lines = buf.split('\n');
427
551
  buf = lines.pop() ?? '';
428
- for (const line of lines) out.write(`${paint(tag)} ${line}\n`);
552
+ for (const line of lines) {
553
+ // A startup FACT is for the banner, never for the terminal — it is the
554
+ // child saying "here is my row", not "here is a line to show someone".
555
+ const fact = parseReady(line);
556
+ if (fact) { collect(tag, fact); continue; }
557
+ // Anything else is ordinary output. Before the banner it is held back
558
+ // so nothing lands above the URL; after, it streams as it always did.
559
+ if (!banner.done) banner.held.push(`${paint(tag)} ${line}`);
560
+ else out.write(`${paint(tag)} ${line}\n`);
561
+ }
429
562
  });
430
563
  };
431
564
 
@@ -436,7 +569,10 @@ export async function devMain(args) {
436
569
  // never reached shutdown() below.
437
570
  const child = spawn(process.execPath, [svc.entry, ...svc.args], {
438
571
  stdio: ['pipe', 'pipe', 'pipe'],
439
- env: leashEnv(),
572
+ // DECKLIGHT_BANNER is how a child knows its startup lines belong to
573
+ // somebody else's banner. Unset — `decklight edit`, `decklight tts` run
574
+ // straight — and it prints exactly what it always printed.
575
+ env: { ...leashEnv(), DECKLIGHT_BANNER: '1' },
440
576
  });
441
577
  children.set(svc.name, child);
442
578
  pipe(child.stdout, svc.tag, process.stdout);
@@ -445,19 +581,29 @@ export async function devMain(args) {
445
581
  child.on('exit', (code) => {
446
582
  children.delete(svc.name);
447
583
  if (shuttingDown) return;
584
+ // It owes no row now — a dead process is never going to report one, and
585
+ // the banner must not sit on the URL waiting for it. This is the common
586
+ // case, not a pathological one: a voice bridge that stands aside because
587
+ // another already serves its port exits 0, seconds into startup.
448
588
  if (svc.name === 'edit') {
449
589
  // the deck server is the one service author cannot run without
450
- console.error(`${paint(svc.tag)} exited (${code}) — stopping decklight author`);
590
+ say(`${paint(svc.tag)} exited (${code}) — stopping decklight author`);
591
+ flushBanner();
451
592
  shutdown(code ?? 1);
452
593
  } else {
453
- console.error(`${paint(svc.tag)} exited (${code}) — carrying on without it; the deck degrades on its own`);
594
+ say(`${paint(svc.tag)} exited (${code}) — carrying on without it; the deck degrades on its own`);
595
+ settle(svc.tag); // settle() does the delete and the "is anyone left" itself
454
596
  }
455
597
  });
456
598
  }
457
599
 
458
- for (const s of skip) console.log(note(` ${s.name.padEnd(8)} skipped — ${s.why}`));
459
- if (!agents.length) console.log(note(' agents none detected — install claude, codex, or bob to ask an agent from the deck (A)'));
460
- console.log(note(' Ctrl-C stops everything.\n'));
600
+ // author's own facts join the children's rather than printing above them.
601
+ // `Ctrl-C stops everything` is gone: the banner's key line already says it,
602
+ // and saying it twice was most of why this block read as a wall.
603
+ if (skip.length) banner.rows.set('skipped', skip.map((s) => `${s.name} — ${s.why}`).join(' · '));
604
+ // Only when there are none — otherwise the edit child names them, and its
605
+ // row (which knows which is preferred and which is installed) wins.
606
+ if (!agents.length) banner.rows.set('agents', 'none — install claude, codex, or bob to ask one from the deck (A)');
461
607
 
462
608
  function shutdown(code = 0) {
463
609
  if (shuttingDown) return;