decklight 0.5.0 → 0.6.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.
@@ -0,0 +1,350 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * `--commit-messages` — an agent writes the subject decklight would otherwise
6
+ * template (SPEC `PRESENTING`).
7
+ *
8
+ * The wall of `decklight: autosave deck.html` is the problem. It is what the
9
+ * cadence has to say when nobody told it what changed, and after an afternoon
10
+ * the H overlay is a column of the same sentence with no way to see what
11
+ * happened when. An agent reading the diff can say `tighten the four-variables
12
+ * build to one line per idea` instead.
13
+ *
14
+ * THE COMMIT LANDS FIRST, ALWAYS. Autocommit exists so a crash cannot cost you
15
+ * an afternoon, and nothing here is allowed to weaken that: decklight commits
16
+ * with its own template exactly as before, and the agent's subject arrives
17
+ * afterwards as an amend. So a slow agent, a wedged agent, a missing agent, an
18
+ * agent that answers a paragraph of prose — every one of those costs a
19
+ * generically-worded commit, never a lost one.
20
+ *
21
+ * That ordering is also why the amend is safe. It rewrites one message, on the
22
+ * tip commit, seconds old, that nothing has been built on: the guard refuses
23
+ * the moment HEAD has moved or the commit has reached a remote.
24
+ *
25
+ * OPT-IN, and the reason is not cost. A diff of your deck goes to whichever
26
+ * agent CLI is installed, and most of them are cloud-backed. decklight does not
27
+ * infer that permission from what happens to be on PATH — the same rule
28
+ * `lipsync --veo` follows for the one part of it that leaves the machine.
29
+ */
30
+
31
+ import { execFile } from 'node:child_process';
32
+ import { basename, relative } from 'node:path';
33
+ import { agentAsk } from './agents.mjs';
34
+ import { commitSubject, git } from './git.mjs';
35
+
36
+ /** How much diff the agent is shown. */
37
+ export const MAX_DIFF = 24 * 1024;
38
+
39
+ /** How long it may take before the commit keeps the message it already has. */
40
+ export const ASK_TIMEOUT_MS = 45_000;
41
+
42
+ /**
43
+ * The change a commit made to the deck, trimmed to something worth sending.
44
+ *
45
+ * `--unified=1` and a byte cap, because the unit here is a single-file HTML
46
+ * deck: swapping a theme rewrites a 70 KB `<style>` block, and a bundled deck
47
+ * carries its whole runtime inline. An unbounded diff would be most of a
48
+ * megabyte of machine-generated CSS with the author's two edited sentences
49
+ * somewhere inside it — slower, more expensive, and harder to summarise than
50
+ * the same diff cut off.
51
+ *
52
+ * Truncation is SAID rather than hidden: an agent that knows it is seeing part
53
+ * of a change writes a subject about the part it saw, instead of a confident
54
+ * one about a change it never read.
55
+ */
56
+ export function changeDiff(cwd, sha, deckRel, { max = MAX_DIFF, run = git } = {}) {
57
+ const out = run(['show', '--format=', '--unified=1', sha, '--', deckRel], cwd) ?? '';
58
+ if (out.length <= max) return { diff: out, truncated: false };
59
+ return { diff: out.slice(0, max), truncated: true };
60
+ }
61
+
62
+ /** How many slide headings the prompt lists before it says "and N more". */
63
+ export const MAX_SLIDES_NAMED = 6;
64
+
65
+ /**
66
+ * The NEW-file line ranges a diff touches. Pure.
67
+ *
68
+ * Only the `+` side: the question is what the deck says now, and a heading
69
+ * looked up in the version that no longer exists would name the slide a line
70
+ * used to be on.
71
+ */
72
+ export function parseHunks(diff) {
73
+ const out = [];
74
+ for (const m of String(diff ?? '').matchAll(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/gm)) {
75
+ const start = Number(m[1]);
76
+ const count = m[2] === undefined ? 1 : Number(m[2]);
77
+ if (Number.isFinite(start) && Number.isFinite(count)) out.push({ start, count });
78
+ }
79
+ return out;
80
+ }
81
+
82
+ /**
83
+ * The deck's slides as `{ index, heading, from, to }`, by line. Pure.
84
+ *
85
+ * A depth counter rather than a regex over the whole document, because a slide
86
+ * may contain a nested `<section>` and only the top-level ones are slides —
87
+ * the same rule the runtime applies when it counts them.
88
+ */
89
+ export function deckOutline(html) {
90
+ const lines = String(html ?? '').split('\n');
91
+ const slides = [];
92
+ let depth = 0;
93
+ let open = null;
94
+ lines.forEach((line, i) => {
95
+ const opens = (line.match(/<section\b/gi) ?? []).length;
96
+ const closes = (line.match(/<\/section\s*>/gi) ?? []).length;
97
+ for (let k = 0; k < opens; k++) {
98
+ if (depth === 0) open = { index: slides.length + 1, heading: null, from: i + 1, to: i + 1 };
99
+ depth += 1;
100
+ }
101
+ if (open && !open.heading) {
102
+ const h = /<h[12][^>]*>([\s\S]*?)<\/h[12]>/i.exec(line);
103
+ if (h) open.heading = h[1].replace(/<[^>]*>/g, '').replace(/\s+/g, ' ').trim() || null;
104
+ }
105
+ for (let k = 0; k < closes; k++) {
106
+ depth = Math.max(0, depth - 1);
107
+ if (depth === 0 && open) { open.to = i + 1; slides.push(open); open = null; }
108
+ }
109
+ });
110
+ if (open) { open.to = lines.length; slides.push(open); }
111
+ return slides;
112
+ }
113
+
114
+ /**
115
+ * Which slides a diff touched, in order. Pure.
116
+ *
117
+ * This is the context the agent could not otherwise have. `--unified=1` shows
118
+ * it the changed line and one line either side, and git's own hunk header is
119
+ * worse than nothing on a deck — the function-context heuristic picks the last
120
+ * thing that looked like a definition, which in a single-file deck is a CSS
121
+ * selector from the inlined stylesheet thousands of lines above. A real run
122
+ * offered `mtable.tml-small mtd {` for an edit to a slide's table, and the
123
+ * agent, with nothing better, invented a framing the deck never had.
124
+ *
125
+ * An empty result is itself an answer, and a useful one: the change is in the
126
+ * theme, the runtime or the metadata rather than in anything the audience
127
+ * sees, and a subject about "the slides" would be fiction.
128
+ */
129
+ export function changedSlides(html, diff) {
130
+ const slides = deckOutline(html);
131
+ if (!slides.length) return [];
132
+ const hit = new Set();
133
+ for (const { start, count } of parseHunks(diff)) {
134
+ const last = start + Math.max(count, 1) - 1;
135
+ for (const s of slides) if (s.from <= last && s.to >= start) hit.add(s.index);
136
+ }
137
+ return slides.filter((s) => hit.has(s.index));
138
+ }
139
+
140
+ /** `<title>` — what the deck calls itself. */
141
+ export function deckTitle(html) {
142
+ const m = /<title[^>]*>([\s\S]*?)<\/title>/i.exec(String(html ?? ''));
143
+ return m ? m[1].replace(/\s+/g, ' ').trim() || null : null;
144
+ }
145
+
146
+ /**
147
+ * The deck as it stood at `sha`, for the two questions above. Best effort:
148
+ * without it the prompt simply carries less context, which is where this
149
+ * feature started.
150
+ */
151
+ export function deckAtCommit(cwd, sha, deckRel, { run = git } = {}) {
152
+ try { return run(['show', `${sha}:./${deckRel}`], cwd) ?? ''; } catch { return ''; }
153
+ }
154
+
155
+ /**
156
+ * What the agent is asked. Pure, so the wording is reviewable without an agent.
157
+ *
158
+ * Every constraint here exists because of how the answer is used: it goes
159
+ * straight into `git commit --amend -m`, so it has to be ONE line, short
160
+ * enough to survive `commitSubject`'s 72-character cap unmangled, and free of
161
+ * the conversational framing every CLI adds by default. Asking for the bare
162
+ * line is worth more than parsing one out afterwards.
163
+ */
164
+ export function messagePrompt({ deck, diff, truncated, template, title = null, slides = [] }) {
165
+ // WHERE the change is, before WHAT it is. Without this the agent sees the
166
+ // changed line and one line either side of it — enough to say a row was
167
+ // added to a table, not enough to know which talk the table is in, and an
168
+ // agent with a gap will fill it. It did: a row added to a brewing deck's
169
+ // troubleshooting table came back as "the espresso troubleshooting table",
170
+ // a word that appears nowhere in the deck.
171
+ const named = slides.slice(0, MAX_SLIDES_NAMED)
172
+ .map((s) => ` slide ${s.index}${s.heading ? ` — "${s.heading}"` : ' (no heading)'}`);
173
+ const more = slides.length - named.length;
174
+ const where = slides.length
175
+ ? ['The change is on:', ...named, ...(more > 0 ? [` …and ${more} more`] : [])]
176
+ // Not a shrug: a change outside every <section> is the theme, the runtime
177
+ // or the metadata, and a subject about "the slides" would be fiction.
178
+ : ['This change touches NO slide — it is in the theme, the inlined runtime,',
179
+ 'or the deck\'s metadata. Say that, rather than describing slide content.'];
180
+ return [
181
+ `Write the git commit subject for this change to "${deck}", a Decklight deck`,
182
+ '(a single-file HTML presentation; one top-level <section> per slide).',
183
+ '',
184
+ ...(title ? [`The deck is titled "${title}".`] : []),
185
+ ...where,
186
+ '',
187
+ 'Rules:',
188
+ '- ONE line. No body, no preamble, no quotes, no markdown, no trailing period.',
189
+ '- At most 72 characters.',
190
+ '- Say what changed and why it matters to the talk, not which lines moved.',
191
+ ' "cut the pour-over slide down to one claim" — not "edit deck.html".',
192
+ '- Describe the slides, not the HTML: a reader of this log is looking for a',
193
+ ' moment in the deck, not a diff.',
194
+ '- Name a slide by its own words, never by its number: "the troubleshooting',
195
+ ' table" beats "slide 4", which stops being true the moment one is inserted.',
196
+ '- Reply with the subject line and nothing else.',
197
+ '',
198
+ truncated
199
+ ? 'The diff below is TRUNCATED — describe only what you can see in it.'
200
+ : 'The diff:',
201
+ '',
202
+ diff,
203
+ '',
204
+ `If the diff says nothing useful, reply with exactly: ${template}`,
205
+ ].join('\n');
206
+ }
207
+
208
+ /**
209
+ * The subject inside whatever the CLI printed.
210
+ *
211
+ * Agents are chatty and inconsistently so: some answer the bare line, some wrap
212
+ * it in a code fence, some open with "Here's the commit message:". The rule is
213
+ * the LAST non-empty line that is not obviously framing — last, because the
214
+ * preamble comes first and the answer comes last, and because a CLI's own
215
+ * trailing banner is stripped by the same filters that catch the preamble.
216
+ *
217
+ * Deliberately not clever. Anything this does not recognise falls through to
218
+ * the caller's fallback, which is the templated subject the commit already has
219
+ * — a wrong-but-confident subject is worse than a generic one.
220
+ */
221
+ export function subjectFrom(raw) {
222
+ const lines = String(raw ?? '')
223
+ .split('\n')
224
+ .map((l) => l.replace(/^\s*[-*>]\s+/, '').trim())
225
+ .filter(Boolean)
226
+ // fences, banners, and the "here is your answer" line every CLI has
227
+ .filter((l) => !/^```/.test(l))
228
+ .filter((l) => !/^(here'?s?|sure|okay|certainly|the commit|commit message)\b/i.test(l))
229
+ .filter((l) => !/^\[?(info|warn|error|debug)\]?[: ]/i.test(l));
230
+ const last = lines[lines.length - 1];
231
+ if (!last) return null;
232
+ // strip surrounding quotes/backticks an agent added around the line itself
233
+ const bare = last.replace(/^["'`]+|["'`]+$/g, '').replace(/\.$/, '').trim();
234
+ return bare || null;
235
+ }
236
+
237
+ /**
238
+ * Is `sha` still the tip, and still only here?
239
+ *
240
+ * The two conditions that make amending a message a formatting change rather
241
+ * than a rewrite of history. If a commit landed in between — the agent flow's
242
+ * own commit, a restore, a second cadence tick — the message we were about to
243
+ * fix belongs to a commit that is no longer the one we are on, and rewriting
244
+ * anything below the tip is not something this feature is allowed to do.
245
+ */
246
+ export function amendable(cwd, sha, { run = git } = {}) {
247
+ try {
248
+ if (run(['rev-parse', 'HEAD'], cwd) !== sha) return false;
249
+ // `--remotes` needs no upstream, and answers for a repo with no remote at
250
+ // all — where nothing is pushed and every commit is fair game.
251
+ return (run(['branch', '--remotes', '--contains', sha], cwd) ?? '') === '';
252
+ } catch { return false; }
253
+ }
254
+
255
+ /** Replace the tip's subject, leaving its tree, author and date alone. */
256
+ export function amendSubject(cwd, sha, subject, { run = git } = {}) {
257
+ if (!amendable(cwd, sha, { run })) return false;
258
+ try {
259
+ run(['commit', '--amend', '--only', '--no-edit', '-m', subject], cwd);
260
+ return true;
261
+ } catch { return false; }
262
+ }
263
+
264
+ /** Run the agent and resolve its stdout, or null. Never rejects. */
265
+ function ask(cmd, cwd, timeoutMs) {
266
+ return new Promise((resolve) => {
267
+ let done = false;
268
+ const finish = (v) => { if (!done) { done = true; resolve(v); } };
269
+ let child;
270
+ try {
271
+ child = execFile(cmd.bin, cmd.args, {
272
+ cwd,
273
+ timeout: timeoutMs,
274
+ maxBuffer: 4 * 1024 * 1024,
275
+ // The agent is being asked a question about a diff it is given in the
276
+ // prompt; it needs no input and a CLI that waits on one would otherwise
277
+ // hang until the timeout.
278
+ stdio: ['ignore', 'pipe', 'pipe'],
279
+ }, (err, stdout) => finish(err && !stdout ? null : String(stdout ?? '')));
280
+ } catch { return finish(null); }
281
+ child.on('error', () => finish(null));
282
+ });
283
+ }
284
+
285
+ /**
286
+ * Give commit `sha` a subject an agent wrote. Resolves to the new subject, or
287
+ * null when anything at all did not work out.
288
+ *
289
+ * Asynchronous and unawaited by design — see the note at the top of the file.
290
+ * The caller has already committed.
291
+ */
292
+ export async function describeCommit({
293
+ cwd, sha, deckPath, template, agent = null,
294
+ env = process.env, timeoutMs = ASK_TIMEOUT_MS, run = git, exec = ask,
295
+ // Injected alongside `exec`, and it has to be: a caller that supplies the
296
+ // RUNNER is not asking whether this machine happens to have an agent CLI on
297
+ // PATH. Leaving this one un-injectable made the tests pass here and fail on
298
+ // CI — for the honest reason that CI installs no agent, so the resolver said
299
+ // no before the fake runner was ever reached.
300
+ resolve = agentAsk,
301
+ } = {}) {
302
+ const deck = basename(deckPath);
303
+ const cmd = resolve(agent, 'x', { env });
304
+ if (!cmd) return null;
305
+ // Checked BEFORE the agent is spawned as well as after: a commit that has
306
+ // already been superseded is one whose message nobody will ever see, and
307
+ // paying an agent to describe it would be the feature's own busywork.
308
+ if (!amendable(cwd, sha, { run })) return null;
309
+
310
+ const rel = relative(cwd, deckPath) || deck;
311
+ let diff;
312
+ try { diff = changeDiff(cwd, sha, rel, { run }); }
313
+ catch { return null; }
314
+ if (!diff.diff.trim()) return null;
315
+
316
+ // The deck AT the commit, not on disk: the working tree may have moved on
317
+ // while the agent was being asked, and a heading read from it would name a
318
+ // slide the commit does not contain.
319
+ const html = deckAtCommit(cwd, sha, rel, { run });
320
+ const prompt = messagePrompt({
321
+ deck, template, ...diff,
322
+ title: deckTitle(html),
323
+ slides: changedSlides(html, diff.diff),
324
+ });
325
+ const spawned = resolve(agent, prompt, { env });
326
+ if (!spawned) return null;
327
+ // Caught, not propagated. This is called unawaited from the commit path, so
328
+ // a rejection here would be an unhandled one — and the whole contract is that
329
+ // a misbehaving agent costs a generic subject, never anything louder.
330
+ let out;
331
+ try { out = await exec(spawned, cwd, timeoutMs); }
332
+ catch { return null; }
333
+ if (out == null) return null;
334
+
335
+ const found = subjectFrom(out);
336
+ if (!found) return null;
337
+ const subject = commitSubject(found, template);
338
+ // The agent echoing the template back (the prompt's own escape hatch) is a
339
+ // successful answer meaning "nothing worth saying" — and amending a message
340
+ // to itself is a rewrite for no reason.
341
+ if (subject === template) return null;
342
+ return amendSubject(cwd, sha, subject, { run }) ? subject : null;
343
+ }
344
+
345
+ /** The startup line: what is on, who does it, and what leaves the machine. */
346
+ export function messagesLine(agentName) {
347
+ return agentName
348
+ ? `git: ${agentName} writes the commit subjects — the deck's diffs are sent to it`
349
+ : 'git: --commit-messages needs an agent on PATH — subjects stay generic';
350
+ }
package/cli/decklight.mjs CHANGED
@@ -58,6 +58,8 @@ Commands:
58
58
  restore list the commits that touched a deck, and put it back to any of them
59
59
  EXAMPLE: decklight restore deck.html (list)
60
60
  EXAMPLE: decklight restore deck.html a1b2c3d (restore, as a new commit on top)
61
+ history what decklight committed, and which commits are only on this machine
62
+ EXAMPLE: decklight history deck.html
61
63
  upgrade bring a self-contained deck's inlined runtime + themes up to the installed version, in place
62
64
  EXAMPLE: decklight upgrade deck.html --dry-run (see what would change; drop the flag to apply)
63
65
  pdf render the deck to a PDF — one slide per page, at its own size, in its theme
@@ -281,6 +283,11 @@ switch (cmd) {
281
283
  process.exitCode = await restoreMain(rest);
282
284
  break;
283
285
  }
286
+ case 'history': {
287
+ const { historyMain } = await import('./history.mjs');
288
+ process.exitCode = await historyMain(rest);
289
+ break;
290
+ }
284
291
  case 'author':
285
292
  case 'dev': { // permanent hidden alias — the pre-rename name; works forever, documented nowhere
286
293
  const { devMain } = await import('./dev.mjs');
package/cli/dev.mjs CHANGED
@@ -29,7 +29,7 @@ import { createInterface } from 'node:readline/promises';
29
29
  import { onPath, detectAgents } from './agents.mjs';
30
30
  import { validProjectId } from '../tools/gemini-tts.mjs';
31
31
  import {
32
- ENGINES as TTS_ENGINES, PIPER_DEFAULT_VOICE, piperModelDir, piperModelPath,
32
+ ENGINES as TTS_ENGINES, PIPER_DEFAULT_VOICE, piperModelDir, engineStatus,
33
33
  piperDownloadCmd, piperDownloadLine,
34
34
  } from '../tools/tts-engines.mjs';
35
35
  import { KEY_ENV as ELEVENLABS_KEY_ENV } from '../tools/elevenlabs-tts.mjs';
@@ -61,6 +61,11 @@ const USAGE = `usage: decklight author <deck.html> [--port 8788] [--tts-port 878
61
61
  agent edit, with the agent's own message), off [timer]
62
62
  (no repo + no flag: author ASKS whether to create one)
63
63
  --commit-every N autocommit cadence in seconds [300]
64
+ --commit-messages an agent writes the commit subjects instead of the generic
65
+ "autosave" — reads each commit's diff and amends the subject
66
+ afterwards, so the commit itself is never delayed or risked.
67
+ Opt-in: it sends the deck's diffs to the agent, and most
68
+ agent CLIs are cloud-backed.
64
69
  --agent <name> preferred AI agent for A (default: first detected)
65
70
 
66
71
  every server binds 127.0.0.1; for a phone remote: decklight present --remote
@@ -131,7 +136,8 @@ export function planServices({
131
136
  entry: EDIT,
132
137
  args: [deck, '--port', editPort,
133
138
  ...(has('--git') ? ['--git'] : []), ...(has('--no-git') ? ['--no-git'] : []),
134
- ...pass('--commit-every'), ...pass('--agent'), ...pass('--git-mode')],
139
+ ...pass('--commit-every'), ...pass('--agent'), ...pass('--git-mode'),
140
+ ...(has('--commit-messages') ? ['--commit-messages'] : [])],
135
141
  url: `http://127.0.0.1:${editPort}/${deck ?? ''}`,
136
142
  });
137
143
 
@@ -168,31 +174,43 @@ export function planServices({
168
174
  ...pass('--voice'), ...pass('--data-dir'), ...pass('--lang'), ...pass('--tts-format'),
169
175
  ...pass('--tts-stability'),
170
176
  ];
177
+ // The SAME readiness check the bridge runs when the deck asks what it may
178
+ // switch to (SPEC NARRATION). Sharing the decision is the point: a picker
179
+ // that offered an engine `author` would have refused to start is a picker
180
+ // that lies. Only the phrasing differs — here there is a terminal, a
181
+ // presenter still setting things up, and room for the whole answer.
182
+ const ttsVoice = opt('--voice', saved?.voice ?? PIPER_DEFAULT_VOICE);
183
+ const ttsData = opt('--data-dir', piperModelDir(env));
184
+ const status = engineStatus(ttsEngine, {
185
+ env, project, voice: ttsVoice, dataDir: ttsData, lang: opt('--lang'),
186
+ // every probe threaded through, `detect` included: these are the injection
187
+ // points that let planServices be tested on any machine, and a readiness
188
+ // check reaching for the REAL PATH or the REAL synthesizer would decide a
189
+ // test's answer from the host it happened to run on
190
+ hasBin, exists, detect,
191
+ });
171
192
  if (has('--no-tts')) {
172
193
  skip.push({ name: 'voice', why: 'disabled with --no-tts' });
173
- } else if (!TTS_ENGINES.includes(ttsEngine)) {
194
+ } else if (status.reason === 'unknown') {
174
195
  skip.push({ name: 'voice', why: `unknown --tts-engine '${ttsEngine}' — use ${TTS_ENGINES.join(', ')}` });
175
- } else if (ttsEngine === 'piper' && !hasBin('piper', env)) {
196
+ } else if (status.reason === 'no-binary') {
176
197
  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))))) {
198
+ } else if (status.reason === 'no-model') {
179
199
  // piper is installed but has no voice to speak with. The bridge would come
180
200
  // up looking healthy and fail on the first sentence — a keypress into
181
201
  // 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) });
202
+ const download = piperDownloadCmd(ttsVoice, ttsData, { hasBin: (b) => hasBin(b, env) });
185
203
  skip.push({
186
204
  name: 'voice',
187
- why: `the piper voice ${voice} is not in ${models} (~120 MB, one time)`
205
+ why: `the piper voice ${ttsVoice} is not in ${ttsData} (~120 MB, one time)`
188
206
  + ` — ${piperDownloadLine(download)}`,
189
207
  download, // author offers to run this on a TTY; nothing is ever pulled silently
190
208
  });
191
- } else if (ttsEngine === 'elevenlabs' && !env[ELEVENLABS_KEY_ENV]?.trim()) {
209
+ } else if (status.reason === 'no-key') {
192
210
  // The key never lands in the saved config, so the environment is the only
193
211
  // place it can come from — say that, and where to make one.
194
212
  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) {
213
+ } else if (status.reason === 'no-project') {
196
214
  skip.push({
197
215
  name: 'voice',
198
216
  why: `${ttsEngine} needs a GCP project — pass --project <id> or set GOOGLE_CLOUD_PROJECT`
@@ -202,11 +220,15 @@ export function planServices({
202
220
  // and being told why beats concluding decklight ignores their stack.
203
221
  + (ollama ? `\n ${OLLAMA_NOTE}` : ''),
204
222
  });
205
- } else if (cloudVoice && !validProjectId(project)) {
223
+ } else if (status.reason === 'bad-project') {
206
224
  // caught here rather than at the first narration: the bridge would start,
207
225
  // look healthy, and only fail on a keypress — with a 403 naming a project
208
226
  // nobody typed
209
227
  skip.push({ name: 'voice', why: `not a GCP project id: ${JSON.stringify(project)} — stray punctuation from a copy-paste?` });
228
+ } else if (status.reason === 'no-native-voice') {
229
+ // New with the shared check: `--tts-engine say` on a machine whose OS has
230
+ // no synthesizer used to start a bridge that failed on the first keypress.
231
+ skip.push({ name: 'voice', why: `${ttsEngine}: ${status.why ?? 'no system voice on this machine'}` });
210
232
  } else {
211
233
  run.push({ name: 'tts', tag: 'voice', entry: CLI, args: ttsArgs(), url: `http://127.0.0.1:${ttsPort}` });
212
234
  }