decklight 0.5.0 → 0.7.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 (53) hide show
  1. package/README.md +20 -9
  2. package/SPEC.md +239 -17
  3. package/cli/agents.mjs +97 -2
  4. package/cli/banner.mjs +125 -0
  5. package/cli/bundle.mjs +14 -4
  6. package/cli/{rec.mjs → cast.mjs} +25 -8
  7. package/cli/comments.mjs +389 -0
  8. package/cli/commit-flow.mjs +157 -0
  9. package/cli/commit-message.mjs +475 -0
  10. package/cli/decklight.mjs +95 -25
  11. package/cli/dev.mjs +193 -25
  12. package/cli/edit.mjs +1055 -39
  13. package/cli/git-tree.mjs +87 -0
  14. package/cli/git.mjs +370 -0
  15. package/cli/history.mjs +145 -0
  16. package/cli/init.mjs +199 -7
  17. package/cli/marketplace.mjs +123 -17
  18. package/cli/port-conflict.mjs +228 -22
  19. package/cli/present.mjs +297 -12
  20. package/cli/publish.mjs +15 -40
  21. package/cli/record.mjs +154 -0
  22. package/cli/restore.mjs +120 -4
  23. package/cli/review-remote.mjs +330 -0
  24. package/cli/review-store.mjs +107 -0
  25. package/cli/review-submit.mjs +292 -0
  26. package/cli/review.mjs +361 -0
  27. package/cli/serve.mjs +60 -1
  28. package/cli/skill-content.mjs +12 -1
  29. package/cli/theme.mjs +78 -11
  30. package/cli/units.mjs +2 -2
  31. package/cli/upstream.mjs +256 -0
  32. package/cli/util.mjs +59 -0
  33. package/dist/build-info.json +1 -0
  34. package/dist/decklight.css +534 -3
  35. package/dist/decklight.js +102 -76
  36. package/dist/decklight.js.map +4 -4
  37. package/docs/architecture.svg +7 -0
  38. package/package.json +2 -1
  39. package/tools/args.mjs +20 -0
  40. package/tools/deck-html.mjs +84 -0
  41. package/tools/elevenlabs-tts.mjs +1 -1
  42. package/tools/lipsync-server.mjs +64 -2
  43. package/tools/lipsync.mjs +40 -24
  44. package/tools/local-voice.mjs +170 -16
  45. package/tools/publish-voices.mjs +78 -18
  46. package/tools/recording-impact.mjs +110 -0
  47. package/tools/review-anchor.mjs +180 -0
  48. package/tools/test-impact.mjs +259 -0
  49. package/tools/tts-engines.mjs +211 -12
  50. package/tools/tts-setup.mjs +2 -9
  51. package/tools/video.mjs +56 -12
  52. package/tools/voiceover-server.mjs +262 -11
  53. package/tools/voiceover.mjs +32 -13
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
@@ -58,6 +60,8 @@ Commands:
58
60
  restore list the commits that touched a deck, and put it back to any of them
59
61
  EXAMPLE: decklight restore deck.html (list)
60
62
  EXAMPLE: decklight restore deck.html a1b2c3d (restore, as a new commit on top)
63
+ history what decklight committed, and which commits are only on this machine
64
+ EXAMPLE: decklight history deck.html
61
65
  upgrade bring a self-contained deck's inlined runtime + themes up to the installed version, in place
62
66
  EXAMPLE: decklight upgrade deck.html --dry-run (see what would change; drop the flag to apply)
63
67
  pdf render the deck to a PDF — one slide per page, at its own size, in its theme
@@ -104,6 +108,21 @@ Commands:
104
108
  author one command for the whole authoring loop: live-reload editing + every bridge this
105
109
  machine can run, one Ctrl-C; E in the player edits speaker notes back into the file
106
110
  EXAMPLE: decklight author demo/showcase.html (bridges without prerequisites are skipped)
111
+ record capture the deck's narration in YOUR voice — the deck reads you its notes
112
+ one ⟨CLICK⟩ beat at a time, and → ends a beat AND reveals the next build
113
+ (this records YOU — decklight cast records a terminal)
114
+ EXAMPLE: decklight record talk.html (serves it: a microphone needs 127.0.0.1)
115
+ voiceover batch-synthesize the deck's narration into a folder with a live engine
116
+ (piper/chirp/gemini/elevenlabs) — the headless counterpart of the deck's ⇧V
117
+ EXAMPLE: decklight voiceover talk.html -o voices/chirp --engine chirp --voice Achernar
118
+ review leave comments on somebody's deck, anchored to slides and carried by git
119
+ (writes <deck>.review.jsonl beside it; never touches the deck itself)
120
+ EXAMPLE: decklight review talk.html (then M in the deck)
121
+ \`review submit\` pushes them to a review/<you>-<date> branch (--pr opens one)
122
+ comments what reviewers said, resolved against the deck as it is now — a comment
123
+ whose slide moved is found anyway, and one whose slide is gone is still shown
124
+ EXAMPLE: decklight comments talk.html (--import to take in a reviewer's file,
125
+ --incoming to see what reviews are waiting on the remote)
107
126
  present play a deck you did not author — read-only over localhost, under a CSP header;
108
127
  prints what the file will execute, and strips what it cannot account for
109
128
  EXAMPLE: decklight present talk.html (no editing surface, nothing is written)
@@ -127,6 +146,26 @@ let rest = argv.slice(1);
127
146
  const { version } = JSON.parse(
128
147
  readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
129
148
  );
149
+ // which BUILD of that version — commits past the release tag and the sha.
150
+ // TWO sources, strictly ordered: a git CHECKOUT answers live (one ~10ms
151
+ // describe, dev machines only), because the stamped dist/build-info.json
152
+ // describes the tree at BUILD time and dist/ survives `git checkout` — a
153
+ // stale stamp once named the feature-branch build while main was the thing
154
+ // actually running, which is the exact misdirection this banner exists to
155
+ // prevent. A tarball ships no .git, pays nothing, and reads the stamp its
156
+ // build froze beside the code — there the two cannot diverge.
157
+ let buildInfo = null;
158
+ if (existsSync(new URL('../.git', import.meta.url))) {
159
+ try {
160
+ const { execFileSync } = await import('node:child_process');
161
+ buildInfo = parseDescribe(execFileSync('git', ['describe', '--tags', '--long', '--dirty=.dirty'],
162
+ { cwd: new URL('..', import.meta.url), encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }));
163
+ } catch { buildInfo = null; } // a tagless clone: plain is the whole truth
164
+ } else {
165
+ try { buildInfo = JSON.parse(readFileSync(new URL('../dist/build-info.json', import.meta.url), 'utf8')); }
166
+ catch { buildInfo = null; }
167
+ }
168
+ const banner = versionLine(version, buildInfo);
130
169
 
131
170
  if (!cmd || cmd === '--help' || cmd === '-h') globalHelp();
132
171
  // A newer decklight than the one npx pinned (#314). Read from a cache the last
@@ -137,7 +176,7 @@ const notice = updateNotice(version);
137
176
  refreshInBackground();
138
177
 
139
178
  if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
140
- process.stdout.write(`decklight ${version}\n`);
179
+ process.stdout.write(`${banner}\n`);
141
180
  if (notice) process.stderr.write(`${notice}\n`);
142
181
  process.exit(0);
143
182
  }
@@ -148,9 +187,15 @@ if (cmd === 'help') {
148
187
  }
149
188
 
150
189
  // every real command announces the version it runs as — on stderr, so piped
151
- // output (export, bundle) stays clean
152
- process.stderr.write(`decklight ${version}\n`);
153
- if (notice) process.stderr.write(`${notice}\n`);
190
+ // output (export, bundle) stays clean.
191
+ //
192
+ // EXCEPT under author, which spawns this same CLI two or three times: the
193
+ // parent has already said which version everything runs as, and repeating it
194
+ // once per child was the first third of author's startup wall.
195
+ if (!process.env.DECKLIGHT_BANNER) {
196
+ process.stderr.write(`${banner}\n`);
197
+ if (notice) process.stderr.write(`${notice}\n`);
198
+ }
154
199
 
155
200
  // When a parent supervises us (author runs the deck server and the bridges), go when it
156
201
  // goes — a SIGKILLed parent never gets to reap its children. No-op otherwise.
@@ -185,19 +230,19 @@ switch (cmd) {
185
230
  await skillsMain(rest);
186
231
  break;
187
232
  }
188
- case 'rec': {
189
- const { recMain } = await import('./rec.mjs');
190
- await recMain(rest);
233
+ case 'cast': {
234
+ const { castMain } = await import('./cast.mjs');
235
+ await castMain(rest);
191
236
  break;
192
237
  }
193
238
  case 'refresh': {
194
- const { recMain } = await import('./rec.mjs');
195
- await recMain(rest.includes('--help') ? ['--help'] : ['refresh', ...rest]);
239
+ const { castMain } = await import('./cast.mjs');
240
+ await castMain(rest.includes('--help') ? ['--help'] : ['refresh', ...rest]);
196
241
  break;
197
242
  }
198
243
  case 'export': {
199
- const { recMain } = await import('./rec.mjs');
200
- await recMain(rest.includes('--help') ? ['--help'] : ['export', ...rest]);
244
+ const { castMain } = await import('./cast.mjs');
245
+ await castMain(rest.includes('--help') ? ['--help'] : ['export', ...rest]);
201
246
  break;
202
247
  }
203
248
  case 'bundle': {
@@ -281,12 +326,44 @@ switch (cmd) {
281
326
  process.exitCode = await restoreMain(rest);
282
327
  break;
283
328
  }
329
+ case 'history': {
330
+ const { historyMain } = await import('./history.mjs');
331
+ process.exitCode = await historyMain(rest);
332
+ break;
333
+ }
284
334
  case 'author':
285
335
  case 'dev': { // permanent hidden alias — the pre-rename name; works forever, documented nowhere
286
336
  const { devMain } = await import('./dev.mjs');
287
337
  await devMain(rest);
288
338
  break;
289
339
  }
340
+ case 'record': {
341
+ const { recordMain } = await import('./record.mjs');
342
+ process.exitCode = await recordMain(rest);
343
+ break;
344
+ }
345
+ case 'voiceover': {
346
+ // tools/voiceover.mjs arg-parses and exits at LOAD (it cannot be imported
347
+ // — deck-html.mjs's note), so it is spawned, exactly as `video
348
+ // --voiceover` already spawns it. stdio inherited: its per-slide progress
349
+ // and cost lines are the whole point of running it in a terminal.
350
+ const { spawnSync } = await import('node:child_process');
351
+ const { fileURLToPath } = await import('node:url');
352
+ const script = fileURLToPath(new URL('../tools/voiceover.mjs', import.meta.url));
353
+ const r = spawnSync(process.execPath, [script, ...rest], { stdio: 'inherit' });
354
+ process.exitCode = r.status ?? 1;
355
+ break;
356
+ }
357
+ case 'review': {
358
+ const { reviewMain } = await import('./review.mjs');
359
+ process.exitCode = await reviewMain(rest);
360
+ break;
361
+ }
362
+ case 'comments': {
363
+ const { commentsMain } = await import('./comments.mjs');
364
+ process.exitCode = await commentsMain(rest);
365
+ break;
366
+ }
290
367
  case 'present': {
291
368
  const { presentMain } = await import('./present.mjs');
292
369
  process.exitCode = await presentMain(rest);
@@ -297,13 +374,6 @@ switch (cmd) {
297
374
  process.exitCode = await associateMain(rest);
298
375
  break;
299
376
  }
300
- case 'edit': {
301
- // Removed as a command (COMMANDS in MARKETPLACE.md) — but a removal must
302
- // refuse out loud, naming the way forward, not shrug "unknown command".
303
- // The server itself lives on in edit.mjs; `author` starts it.
304
- process.stderr.write('decklight edit was folded into the authoring loop — run `decklight author <deck.html>` instead\n');
305
- process.exit(1);
306
- }
307
377
  default:
308
378
  process.stderr.write(`decklight: unknown command "${cmd}"\n\n`);
309
379
  globalHelp(1);
package/cli/dev.mjs CHANGED
@@ -27,9 +27,10 @@ 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
- ENGINES as TTS_ENGINES, PIPER_DEFAULT_VOICE, piperModelDir, piperModelPath,
33
+ ENGINES as TTS_ENGINES, PIPER_DEFAULT_VOICE, piperModelDir, engineStatus,
33
34
  piperDownloadCmd, piperDownloadLine,
34
35
  } from '../tools/tts-engines.mjs';
35
36
  import { KEY_ENV as ELEVENLABS_KEY_ENV } from '../tools/elevenlabs-tts.mjs';
@@ -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,16 @@ 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]
66
+ --commit-messages an agent writes the commit subjects instead of the generic
67
+ "autosave" — reads each commit's diff and amends the subject
68
+ afterwards, so the commit itself is never delayed or risked.
69
+ Opt-in: it sends the deck's diffs to the agent, and most
70
+ agent CLIs are cloud-backed.
64
71
  --agent <name> preferred AI agent for A (default: first detected)
65
72
 
66
73
  every server binds 127.0.0.1; for a phone remote: decklight present --remote
@@ -131,7 +138,11 @@ export function planServices({
131
138
  entry: EDIT,
132
139
  args: [deck, '--port', editPort,
133
140
  ...(has('--git') ? ['--git'] : []), ...(has('--no-git') ? ['--no-git'] : []),
134
- ...pass('--commit-every'), ...pass('--agent'), ...pass('--git-mode')],
141
+ ...pass('--commit-every'), ...pass('--agent'), ...pass('--git-mode'),
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'] : [])],
135
146
  url: `http://127.0.0.1:${editPort}/${deck ?? ''}`,
136
147
  });
137
148
 
@@ -168,31 +179,43 @@ export function planServices({
168
179
  ...pass('--voice'), ...pass('--data-dir'), ...pass('--lang'), ...pass('--tts-format'),
169
180
  ...pass('--tts-stability'),
170
181
  ];
182
+ // The SAME readiness check the bridge runs when the deck asks what it may
183
+ // switch to (SPEC NARRATION). Sharing the decision is the point: a picker
184
+ // that offered an engine `author` would have refused to start is a picker
185
+ // that lies. Only the phrasing differs — here there is a terminal, a
186
+ // presenter still setting things up, and room for the whole answer.
187
+ const ttsVoice = opt('--voice', saved?.voice ?? PIPER_DEFAULT_VOICE);
188
+ const ttsData = opt('--data-dir', piperModelDir(env));
189
+ const status = engineStatus(ttsEngine, {
190
+ env, project, voice: ttsVoice, dataDir: ttsData, lang: opt('--lang'),
191
+ // every probe threaded through, `detect` included: these are the injection
192
+ // points that let planServices be tested on any machine, and a readiness
193
+ // check reaching for the REAL PATH or the REAL synthesizer would decide a
194
+ // test's answer from the host it happened to run on
195
+ hasBin, exists, detect,
196
+ });
171
197
  if (has('--no-tts')) {
172
198
  skip.push({ name: 'voice', why: 'disabled with --no-tts' });
173
- } else if (!TTS_ENGINES.includes(ttsEngine)) {
199
+ } else if (status.reason === 'unknown') {
174
200
  skip.push({ name: 'voice', why: `unknown --tts-engine '${ttsEngine}' — use ${TTS_ENGINES.join(', ')}` });
175
- } else if (ttsEngine === 'piper' && !hasBin('piper', env)) {
201
+ } else if (status.reason === 'no-binary') {
176
202
  skip.push({ name: 'voice', why: 'piper not on PATH — install it (uv tool install piper-tts)' });
177
- } else if (ttsEngine === 'piper' && !exists(piperModelPath(
178
- opt('--voice', saved?.voice ?? PIPER_DEFAULT_VOICE), opt('--data-dir', piperModelDir(env))))) {
203
+ } else if (status.reason === 'no-model') {
179
204
  // piper is installed but has no voice to speak with. The bridge would come
180
205
  // up looking healthy and fail on the first sentence — a keypress into
181
206
  // silence — so it is caught here, where the fix can be offered instead.
182
- const voice = opt('--voice', saved?.voice ?? PIPER_DEFAULT_VOICE);
183
- const models = opt('--data-dir', piperModelDir(env));
184
- const download = piperDownloadCmd(voice, models, { hasBin: (b) => hasBin(b, env) });
207
+ const download = piperDownloadCmd(ttsVoice, ttsData, { hasBin: (b) => hasBin(b, env) });
185
208
  skip.push({
186
209
  name: 'voice',
187
- why: `the piper voice ${voice} is not in ${models} (~120 MB, one time)`
210
+ why: `the piper voice ${ttsVoice} is not in ${ttsData} (~120 MB, one time)`
188
211
  + ` — ${piperDownloadLine(download)}`,
189
212
  download, // author offers to run this on a TTY; nothing is ever pulled silently
190
213
  });
191
- } else if (ttsEngine === 'elevenlabs' && !env[ELEVENLABS_KEY_ENV]?.trim()) {
214
+ } else if (status.reason === 'no-key') {
192
215
  // The key never lands in the saved config, so the environment is the only
193
216
  // place it can come from — say that, and where to make one.
194
217
  skip.push({ name: 'voice', why: `elevenlabs needs $${ELEVENLABS_KEY_ENV} — create a key at https://elevenlabs.io/app/settings/api-keys and export it` });
195
- } else if (cloudVoice && !project) {
218
+ } else if (status.reason === 'no-project') {
196
219
  skip.push({
197
220
  name: 'voice',
198
221
  why: `${ttsEngine} needs a GCP project — pass --project <id> or set GOOGLE_CLOUD_PROJECT`
@@ -202,11 +225,15 @@ export function planServices({
202
225
  // and being told why beats concluding decklight ignores their stack.
203
226
  + (ollama ? `\n ${OLLAMA_NOTE}` : ''),
204
227
  });
205
- } else if (cloudVoice && !validProjectId(project)) {
228
+ } else if (status.reason === 'bad-project') {
206
229
  // caught here rather than at the first narration: the bridge would start,
207
230
  // look healthy, and only fail on a keypress — with a 403 naming a project
208
231
  // nobody typed
209
232
  skip.push({ name: 'voice', why: `not a GCP project id: ${JSON.stringify(project)} — stray punctuation from a copy-paste?` });
233
+ } else if (status.reason === 'no-native-voice') {
234
+ // New with the shared check: `--tts-engine say` on a machine whose OS has
235
+ // no synthesizer used to start a bridge that failed on the first keypress.
236
+ skip.push({ name: 'voice', why: `${ttsEngine}: ${status.why ?? 'no system voice on this machine'}` });
210
237
  } else {
211
238
  run.push({ name: 'tts', tag: 'voice', entry: CLI, args: ttsArgs(), url: `http://127.0.0.1:${ttsPort}` });
212
239
  }
@@ -322,6 +349,21 @@ export async function devMain(args) {
322
349
  const mode = await rl.question(" commit once per agent edit, with the agent's own message, instead of on a timer? [y/N] ");
323
350
  if (/^y/i.test(mode.trim())) args = [...args, '--git-mode', 'agent'];
324
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
+ }
325
367
  rl.close();
326
368
  plan = planServices({ args, saved: loadTtsConfig() });
327
369
  } else {
@@ -355,7 +397,7 @@ export async function devMain(args) {
355
397
  if (voiceSetupOffer(plan) && process.stdin.isTTY && process.stdout.isTTY) {
356
398
  const rl = createInterface({ input: process.stdin, output: process.stdout });
357
399
  try {
358
- 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] ');
359
401
  if (!/^n/i.test(answer.trim())) {
360
402
  const result = await runSetupWizard({ ask: (q) => rl.question(q) });
361
403
  if (result) {
@@ -394,6 +436,110 @@ export async function devMain(args) {
394
436
  const children = new Map();
395
437
  let shuttingDown = false;
396
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
+
397
543
  // Children write their own startup/progress lines; prefix each so three
398
544
  // servers in one terminal stay readable.
399
545
  const pipe = (stream, tag, out) => {
@@ -403,7 +549,16 @@ export async function devMain(args) {
403
549
  buf += chunk;
404
550
  const lines = buf.split('\n');
405
551
  buf = lines.pop() ?? '';
406
- 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
+ }
407
562
  });
408
563
  };
409
564
 
@@ -414,7 +569,10 @@ export async function devMain(args) {
414
569
  // never reached shutdown() below.
415
570
  const child = spawn(process.execPath, [svc.entry, ...svc.args], {
416
571
  stdio: ['pipe', 'pipe', 'pipe'],
417
- 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' },
418
576
  });
419
577
  children.set(svc.name, child);
420
578
  pipe(child.stdout, svc.tag, process.stdout);
@@ -423,19 +581,29 @@ export async function devMain(args) {
423
581
  child.on('exit', (code) => {
424
582
  children.delete(svc.name);
425
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.
426
588
  if (svc.name === 'edit') {
427
589
  // the deck server is the one service author cannot run without
428
- console.error(`${paint(svc.tag)} exited (${code}) — stopping decklight author`);
590
+ say(`${paint(svc.tag)} exited (${code}) — stopping decklight author`);
591
+ flushBanner();
429
592
  shutdown(code ?? 1);
430
593
  } else {
431
- 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
432
596
  }
433
597
  });
434
598
  }
435
599
 
436
- for (const s of skip) console.log(note(` ${s.name.padEnd(8)} skipped — ${s.why}`));
437
- if (!agents.length) console.log(note(' agents none detected — install claude, codex, or bob to ask an agent from the deck (A)'));
438
- 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)');
439
607
 
440
608
  function shutdown(code = 0) {
441
609
  if (shuttingDown) return;