decklight 0.2.0 → 0.4.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.
- package/README.md +69 -31
- package/SPEC.md +881 -80
- package/cli/agents.mjs +116 -10
- package/cli/associate.mjs +286 -0
- package/cli/audit.mjs +424 -0
- package/cli/bundle.mjs +174 -46
- package/cli/deckfile.mjs +233 -0
- package/cli/decklight.mjs +201 -8
- package/cli/dev.mjs +244 -55
- package/cli/edit.mjs +577 -107
- package/cli/extension.mjs +108 -0
- package/cli/git.mjs +141 -0
- package/cli/import.mjs +398 -0
- package/cli/init.mjs +421 -116
- package/cli/loader.mjs +263 -0
- package/cli/marketplace.mjs +911 -0
- package/cli/pdf.mjs +156 -0
- package/cli/pkg.mjs +69 -0
- package/cli/plugin.mjs +654 -0
- package/cli/port-conflict.mjs +94 -0
- package/cli/present.mjs +564 -0
- package/cli/publish.mjs +342 -0
- package/cli/qr.mjs +334 -0
- package/cli/rec.mjs +5 -8
- package/cli/remote.mjs +149 -0
- package/cli/report-bug.mjs +97 -0
- package/cli/restore.mjs +174 -0
- package/cli/serve.mjs +247 -0
- package/cli/sign.mjs +216 -0
- package/cli/skill-content.mjs +222 -0
- package/cli/skills.mjs +338 -0
- package/cli/supervise.mjs +57 -0
- package/cli/theme.mjs +219 -0
- package/cli/units.mjs +500 -0
- package/cli/upgrade.mjs +250 -0
- package/cli/util.mjs +90 -0
- package/cli/wizard.mjs +432 -0
- package/cli/zip.mjs +121 -0
- package/dist/decklight.css +716 -29
- package/dist/decklight.js +198 -125
- package/dist/decklight.js.map +4 -4
- package/docs/architecture.svg +1 -1
- package/package.json +7 -5
- package/themes/README.md +6 -4
- package/themes/aurora.css +1 -1
- package/themes/berry.css +1 -1
- package/themes/carbon.css +1 -1
- package/themes/citrus.css +1 -1
- package/themes/coastal.css +1 -1
- package/themes/cosmos.css +1 -1
- package/themes/dune.css +1 -1
- package/themes/eclipse.css +1 -1
- package/themes/ember.css +1 -1
- package/themes/fjord.css +1 -1
- package/themes/gallery.html +3 -11
- package/themes/glacier.css +1 -1
- package/themes/graphite.css +1 -1
- package/themes/harvest.css +1 -1
- package/themes/ibm-modern.css +1 -1
- package/themes/ink.css +1 -1
- package/themes/latte.css +1 -1
- package/themes/linen.css +1 -1
- package/themes/meadow.css +1 -1
- package/themes/metropolis.css +1 -1
- package/themes/midnight.css +1 -1
- package/themes/mint.css +1 -1
- package/themes/moss.css +1 -1
- package/themes/obsidian.css +1 -1
- package/themes/orchid.css +1 -1
- package/themes/packs.json +2 -30
- package/themes/paper.css +1 -1
- package/themes/peony.css +1 -1
- package/themes/porcelain.css +1 -1
- package/themes/reveal-beige.css +1 -1
- package/themes/reveal-black.css +1 -1
- package/themes/reveal-blood.css +1 -1
- package/themes/reveal-dracula.css +1 -1
- package/themes/reveal-league.css +1 -1
- package/themes/reveal-moon.css +1 -1
- package/themes/reveal-night.css +1 -1
- package/themes/reveal-serif.css +1 -1
- package/themes/reveal-simple.css +1 -1
- package/themes/reveal-sky.css +1 -1
- package/themes/reveal-solarized.css +1 -1
- package/themes/reveal-white.css +1 -1
- package/themes/sepia.css +1 -1
- package/themes/seriph.css +1 -1
- package/themes/slate.css +1 -1
- package/themes/storm.css +1 -1
- package/themes/synthwave.css +1 -1
- package/themes/velvet.css +1 -1
- package/themes/yamabuki.css +1 -1
- package/tools/args.mjs +32 -0
- package/tools/bridge.mjs +30 -0
- package/tools/chrome.mjs +46 -11
- package/tools/color.mjs +110 -0
- package/tools/deck-html.mjs +138 -0
- package/tools/elevenlabs-tts.mjs +248 -0
- package/tools/escape.mjs +40 -0
- package/tools/extension-check-runner.mjs +41 -0
- package/tools/extension-check.mjs +266 -0
- package/tools/gemini-tts.mjs +25 -3
- package/tools/lipsync-engines.mjs +81 -0
- package/tools/lipsync-server.mjs +78 -37
- package/tools/lipsync.mjs +36 -21
- package/tools/local-voice.mjs +209 -0
- package/tools/ooxml.mjs +151 -0
- package/tools/pptx.mjs +320 -0
- package/tools/publish-site-voices.mjs +2 -1
- package/tools/publish-targets.mjs +143 -0
- package/tools/publish-voices.mjs +230 -0
- package/tools/shot.mjs +91 -47
- package/tools/theme-check.mjs +144 -0
- package/tools/tts-engines.mjs +270 -41
- package/tools/tts-setup.mjs +257 -0
- package/tools/veo.mjs +204 -0
- package/tools/video.mjs +440 -0
- package/tools/voiceover-server.mjs +163 -54
- package/tools/voiceover.mjs +24 -7
- package/tools/zip.mjs +143 -0
- package/docs/demo.svg +0 -124
- package/themes/aliens.css +0 -87
- package/themes/apple2.css +0 -129
- package/themes/blade-runner.css +0 -86
- package/themes/c64.css +0 -88
- package/themes/friends.css +0 -85
- package/themes/gameboy.css +0 -121
- package/themes/genesis.css +0 -87
- package/themes/godfather.css +0 -85
- package/themes/ibm-oldschool.css +0 -87
- package/themes/miami-vice.css +0 -87
- package/themes/pulp-fiction.css +0 -87
- package/themes/severance.css +0 -85
- package/themes/snes.css +0 -85
- package/themes/star-wars.css +0 -88
- package/themes/stranger-things.css +0 -87
- package/themes/terminator.css +0 -87
package/cli/dev.mjs
CHANGED
|
@@ -2,84 +2,117 @@
|
|
|
2
2
|
// Copyright 2026 Gilles Philippart
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
-
// decklight
|
|
6
|
-
// plus whichever optional bridges this machine can actually run.
|
|
5
|
+
// decklight author — one command for the whole authoring loop: the edit
|
|
6
|
+
// server plus whichever optional bridges this machine can actually run.
|
|
7
|
+
// (`decklight dev` is its permanent hidden alias, from before the rename.)
|
|
7
8
|
//
|
|
8
|
-
// decklight
|
|
9
|
-
//
|
|
10
|
-
//
|
|
9
|
+
// decklight author <deck.html> [--port 8788] [--tts-port 8787] [--lipsync-port 8789]
|
|
10
|
+
// [--project <id>] [--rhubarb <bin>] [--portrait <name=img.png>]…
|
|
11
|
+
// [--no-tts] [--no-lipsync]
|
|
11
12
|
//
|
|
12
13
|
// The bridges keep their OWN PROCESSES on their own ports, exactly as if you
|
|
13
|
-
// had started them by hand —
|
|
14
|
-
// stops everything. That split is the point: edit needs nothing (no
|
|
14
|
+
// had started them by hand — author only owns their lifetime, so one Ctrl-C
|
|
15
|
+
// stops everything. That split is the point: the edit server needs nothing (no
|
|
15
16
|
// credentials, no cost), tts holds Google credentials and spends money per
|
|
16
17
|
// call, lipsync pins a GPU. Folding them into one process would let a Wav2Lip
|
|
17
18
|
// crash or an expired token take down the server you are editing through.
|
|
18
19
|
//
|
|
19
20
|
// A bridge whose prerequisites are missing is SKIPPED with the reason and the
|
|
20
|
-
// fix, never a hard failure: `decklight
|
|
21
|
-
// gives you live reload and notes editing, and the player degrades on
|
|
22
|
-
// (each bridge is probed via /ping).
|
|
21
|
+
// fix, never a hard failure: `decklight author deck.html` on a bare machine
|
|
22
|
+
// still gives you live reload and notes editing, and the player degrades on
|
|
23
|
+
// its own (each bridge is probed via /ping).
|
|
23
24
|
|
|
24
|
-
import { spawn,
|
|
25
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
25
26
|
import { existsSync } from 'node:fs';
|
|
26
27
|
import { fileURLToPath } from 'node:url';
|
|
27
28
|
import { createInterface } from 'node:readline/promises';
|
|
28
29
|
import { onPath, detectAgents } from './agents.mjs';
|
|
29
30
|
import { validProjectId } from '../tools/gemini-tts.mjs';
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
import {
|
|
32
|
+
ENGINES as TTS_ENGINES, PIPER_DEFAULT_VOICE, piperModelDir, piperModelPath,
|
|
33
|
+
piperDownloadCmd, piperDownloadLine,
|
|
34
|
+
} from '../tools/tts-engines.mjs';
|
|
35
|
+
import { KEY_ENV as ELEVENLABS_KEY_ENV } from '../tools/elevenlabs-tts.mjs';
|
|
36
|
+
import { loadTtsConfig, runSetupWizard } from '../tools/tts-setup.mjs';
|
|
37
|
+
import { detectLocalVoice, OLLAMA_NOTE } from '../tools/local-voice.mjs';
|
|
38
|
+
import { argReader, isMain } from '../tools/args.mjs';
|
|
39
|
+
import { isPortOpen, resolvePortConflict } from './port-conflict.mjs';
|
|
40
|
+
import { leashEnv } from './supervise.mjs';
|
|
33
41
|
|
|
34
42
|
const CLI = fileURLToPath(new URL('./decklight.mjs', import.meta.url));
|
|
43
|
+
// The deck server's entry since `edit` stopped being a command: its module,
|
|
44
|
+
// run directly. The dispatcher would refuse `edit` out loud.
|
|
45
|
+
const EDIT = fileURLToPath(new URL('./edit.mjs', import.meta.url));
|
|
35
46
|
|
|
36
|
-
const USAGE = `usage: decklight
|
|
37
|
-
[--tts-engine gemini|chirp|piper] [--project <id>] [--no-tts]
|
|
47
|
+
const USAGE = `usage: decklight author <deck.html> [--port 8788] [--tts-port 8787] [--lipsync-port 8789]
|
|
48
|
+
[--tts-engine gemini|chirp|piper|elevenlabs] [--project <id>] [--no-tts]
|
|
38
49
|
[--git | --no-git] [--commit-every <s>] [--agent <name>]
|
|
39
50
|
brings up the edit server plus every bridge this machine can run, under one Ctrl-C
|
|
40
51
|
|
|
41
52
|
--port N edit server (live reload + edit write-back) [8788]
|
|
53
|
+
(taken already? author offers to take over that session
|
|
54
|
+
on a TTY, or moves to the next free port otherwise)
|
|
42
55
|
--tts-port N live voice bridge [8787]
|
|
43
56
|
--lipsync-port N lip-sync bridge (visemes + talking head) [8789]
|
|
44
57
|
--no-tts don't start the voice bridge
|
|
45
58
|
--no-lipsync don't start the lip-sync bridge
|
|
46
59
|
--git / --no-git auto-commit the deck on a cadence / never touch git
|
|
47
|
-
|
|
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]
|
|
62
|
+
(no repo + no flag: author ASKS whether to create one)
|
|
48
63
|
--commit-every N autocommit cadence in seconds [300]
|
|
49
64
|
--agent <name> preferred AI agent for A (default: first detected)
|
|
50
65
|
|
|
66
|
+
every server binds 127.0.0.1; for a phone remote: decklight present --remote
|
|
67
|
+
|
|
51
68
|
--tts-engine E gemini Vertex AI, best delivery, honors a style — no free tier [default]
|
|
52
69
|
chirp Cloud TTS Chirp 3: HD — same voices, ~1s, 1M chars/month free
|
|
53
70
|
piper local, offline, unlimited, no project needed
|
|
71
|
+
elevenlabs your own account's voices, the ones you cloned first
|
|
72
|
+
in the picker — needs $ELEVENLABS_API_KEY
|
|
73
|
+
(nothing configured? on a terminal author offers a one-time
|
|
74
|
+
guided setup; decklight tts --setup re-runs it)
|
|
54
75
|
|
|
55
76
|
tts flags --project <id> (or $GOOGLE_CLOUD_PROJECT; gemini/chirp only),
|
|
56
|
-
--tts-model, --location, --voice, --data-dir, --lang
|
|
77
|
+
--tts-model, --location, --voice, --data-dir, --lang,
|
|
78
|
+
--tts-format pcm|mp3 (elevenlabs),
|
|
79
|
+
--tts-stability creative|natural|robust (elevenlabs eleven_v3 only)
|
|
57
80
|
lipsync flags --rhubarb <bin>, --portrait <name=img.png>…, --wav2lip-dir,
|
|
58
|
-
--wav2lip-ckpt, --sadtalker-dir, --python, --cache-dir
|
|
81
|
+
--wav2lip-ckpt, --sadtalker-dir, --python, --cache-dir,
|
|
82
|
+
--veo (animate the portrait once through Vertex — BILLED),
|
|
83
|
+
--veo-project, --veo-model, --veo-seconds, --veo-face-y
|
|
59
84
|
(all passed straight through — see decklight tts --help / lipsync --help)`;
|
|
60
85
|
|
|
61
86
|
// flags that take a value (so the deck argument can be found past them)
|
|
62
87
|
const VALUE_FLAGS = new Set([
|
|
63
88
|
'--port', '--tts-port', '--lipsync-port', '--tts-engine', '--project', '--tts-model',
|
|
64
|
-
'--location', '--voice', '--data-dir', '--lang',
|
|
89
|
+
'--location', '--voice', '--data-dir', '--lang', '--tts-format', '--tts-stability',
|
|
65
90
|
'--rhubarb', '--portrait', '--wav2lip-dir', '--wav2lip-ckpt', '--sadtalker-dir',
|
|
66
|
-
'--python', '--cache-dir', '--commit-every', '--agent',
|
|
91
|
+
'--python', '--cache-dir', '--commit-every', '--agent', '--git-mode',
|
|
92
|
+
'--veo-project', '--veo-model', '--veo-seconds', '--veo-prompt', '--veo-location', '--veo-face-y',
|
|
67
93
|
]);
|
|
68
94
|
|
|
69
95
|
/**
|
|
70
96
|
* Decide what to bring up, WITHOUT starting anything — the whole capability
|
|
71
97
|
* policy in one pure function, so it can be tested without binding a port.
|
|
72
|
-
*
|
|
73
|
-
*
|
|
98
|
+
* `saved` is the machine-level tts config (~/.config/decklight/tts.json,
|
|
99
|
+
* written by the setup wizard) — injected, not read here, so the plan stays
|
|
100
|
+
* pure; precedence is flags > environment > saved config > built-in default.
|
|
101
|
+
* Returns { deck, run: [{name, tag, entry, args, url}], skip: [{name, why}],
|
|
102
|
+
* agents: [names the machine can run] } — `entry` is the script to spawn:
|
|
103
|
+
* the bridges go through the dispatcher, the edit server (no longer a
|
|
104
|
+
* command there) runs its own module.
|
|
74
105
|
*/
|
|
75
|
-
export function planServices({
|
|
76
|
-
|
|
77
|
-
|
|
106
|
+
export function planServices({
|
|
107
|
+
args = [], env = process.env, hasBin = onPath, saved = null,
|
|
108
|
+
detect = detectLocalVoice, ollama = false, exists = existsSync,
|
|
109
|
+
} = {}) {
|
|
110
|
+
const { opt, opts } = argReader(args);
|
|
78
111
|
const has = (flag) => args.includes(flag);
|
|
79
112
|
const pass = (flag) => (opt(flag) !== undefined ? [flag, opt(flag)] : []);
|
|
80
113
|
|
|
81
114
|
// first bare token is the deck — step over flags that consume a value, so
|
|
82
|
-
// `
|
|
115
|
+
// `author --port 8788 deck.html` doesn't mistake "8788" for the deck
|
|
83
116
|
let deck;
|
|
84
117
|
for (let i = 0; i < args.length; i++) {
|
|
85
118
|
const a = args[i];
|
|
@@ -95,24 +128,45 @@ export function planServices({ args = [], env = process.env, hasBin = onPath } =
|
|
|
95
128
|
run.push({
|
|
96
129
|
name: 'edit',
|
|
97
130
|
tag: 'deck',
|
|
98
|
-
|
|
131
|
+
entry: EDIT,
|
|
132
|
+
args: [deck, '--port', editPort,
|
|
99
133
|
...(has('--git') ? ['--git'] : []), ...(has('--no-git') ? ['--no-git'] : []),
|
|
100
|
-
...pass('--commit-every'), ...pass('--agent')],
|
|
134
|
+
...pass('--commit-every'), ...pass('--agent'), ...pass('--git-mode')],
|
|
101
135
|
url: `http://127.0.0.1:${editPort}/${deck ?? ''}`,
|
|
102
136
|
});
|
|
103
137
|
|
|
104
|
-
// live voice —
|
|
105
|
-
//
|
|
138
|
+
// live voice — an engine that would exit for want of a credential should not
|
|
139
|
+
// be started at all: the Google ones need a project, ElevenLabs needs a key,
|
|
140
|
+
// and piper needs neither, only the binary
|
|
106
141
|
const ttsPort = opt('--tts-port', '8787');
|
|
107
|
-
const
|
|
108
|
-
|
|
142
|
+
const project = opt('--project', env.GOOGLE_CLOUD_PROJECT ?? saved?.project);
|
|
143
|
+
|
|
144
|
+
// Nothing chosen, nothing saved, no cloud credential: rather than default to
|
|
145
|
+
// an engine that will be skipped for want of a project, ask the machine what
|
|
146
|
+
// it can already say. Every desktop OS ships a synthesizer, and on current
|
|
147
|
+
// ones it is neural — free, offline, and nothing to download. An explicit
|
|
148
|
+
// --tts-engine, a saved engine, or a project all win over this: flags decide,
|
|
149
|
+
// detection only fills a vacuum.
|
|
150
|
+
const chosen = opt('--tts-engine', saved?.engine);
|
|
151
|
+
const native = chosen || project ? null : detect({ lang: opt('--lang') });
|
|
152
|
+
// Only a NATIVE voice is claimed automatically. It is the one engine that
|
|
153
|
+
// needs no setup at all — no install, no download, no credential — so using
|
|
154
|
+
// it silently costs the presenter nothing. piper is deliberately NOT picked
|
|
155
|
+
// here even when it is on PATH: it needs a toolchain and a ~120 MB model, and
|
|
156
|
+
// choosing it behind the user's back would skip the first-run wizard that
|
|
157
|
+
// exists to make (and save) exactly that choice.
|
|
158
|
+
const ttsEngine = chosen ?? native?.engine ?? 'gemini';
|
|
109
159
|
const cloudVoice = ttsEngine === 'gemini' || ttsEngine === 'chirp';
|
|
110
160
|
const ttsArgs = () => [
|
|
111
161
|
'tts', '--port', ttsPort,
|
|
112
|
-
|
|
162
|
+
// also when DETECTION chose the engine: without this the bridge would be
|
|
163
|
+
// started with no --engine and fall back to its own default, so a machine
|
|
164
|
+
// picked for its system voice would try to reach Vertex AI instead
|
|
165
|
+
...(has('--tts-engine') || saved?.engine || ttsEngine !== 'gemini' ? ['--engine', ttsEngine] : []),
|
|
113
166
|
...(cloudVoice ? ['--project', project] : []),
|
|
114
167
|
...pass('--tts-model'), ...pass('--location'),
|
|
115
|
-
...pass('--voice'), ...pass('--data-dir'), ...pass('--lang'),
|
|
168
|
+
...pass('--voice'), ...pass('--data-dir'), ...pass('--lang'), ...pass('--tts-format'),
|
|
169
|
+
...pass('--tts-stability'),
|
|
116
170
|
];
|
|
117
171
|
if (has('--no-tts')) {
|
|
118
172
|
skip.push({ name: 'voice', why: 'disabled with --no-tts' });
|
|
@@ -120,15 +174,41 @@ export function planServices({ args = [], env = process.env, hasBin = onPath } =
|
|
|
120
174
|
skip.push({ name: 'voice', why: `unknown --tts-engine '${ttsEngine}' — use ${TTS_ENGINES.join(', ')}` });
|
|
121
175
|
} else if (ttsEngine === 'piper' && !hasBin('piper', env)) {
|
|
122
176
|
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))))) {
|
|
179
|
+
// piper is installed but has no voice to speak with. The bridge would come
|
|
180
|
+
// up looking healthy and fail on the first sentence — a keypress into
|
|
181
|
+
// 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) });
|
|
185
|
+
skip.push({
|
|
186
|
+
name: 'voice',
|
|
187
|
+
why: `the piper voice ${voice} is not in ${models} (~120 MB, one time)`
|
|
188
|
+
+ ` — ${piperDownloadLine(download)}`,
|
|
189
|
+
download, // author offers to run this on a TTY; nothing is ever pulled silently
|
|
190
|
+
});
|
|
191
|
+
} else if (ttsEngine === 'elevenlabs' && !env[ELEVENLABS_KEY_ENV]?.trim()) {
|
|
192
|
+
// The key never lands in the saved config, so the environment is the only
|
|
193
|
+
// place it can come from — say that, and where to make one.
|
|
194
|
+
skip.push({ name: 'voice', why: `elevenlabs needs $${ELEVENLABS_KEY_ENV} — create a key at https://elevenlabs.io/app/settings/api-keys and export it` });
|
|
123
195
|
} else if (cloudVoice && !project) {
|
|
124
|
-
skip.push({
|
|
196
|
+
skip.push({
|
|
197
|
+
name: 'voice',
|
|
198
|
+
why: `${ttsEngine} needs a GCP project — pass --project <id> or set GOOGLE_CLOUD_PROJECT`
|
|
199
|
+
+ (native?.why ? `\n this machine has no system voice either: ${native.why}` : '')
|
|
200
|
+
+ (native?.suggest ? `\n ${native.suggest}` : ' — or use --tts-engine piper')
|
|
201
|
+
// Ollama is the thing a local-AI user assumes covers this. It does not,
|
|
202
|
+
// and being told why beats concluding decklight ignores their stack.
|
|
203
|
+
+ (ollama ? `\n ${OLLAMA_NOTE}` : ''),
|
|
204
|
+
});
|
|
125
205
|
} else if (cloudVoice && !validProjectId(project)) {
|
|
126
206
|
// caught here rather than at the first narration: the bridge would start,
|
|
127
207
|
// look healthy, and only fail on a keypress — with a 403 naming a project
|
|
128
208
|
// nobody typed
|
|
129
209
|
skip.push({ name: 'voice', why: `not a GCP project id: ${JSON.stringify(project)} — stray punctuation from a copy-paste?` });
|
|
130
210
|
} else {
|
|
131
|
-
run.push({ name: 'tts', tag: 'voice', args: ttsArgs(), url: `http://127.0.0.1:${ttsPort}` });
|
|
211
|
+
run.push({ name: 'tts', tag: 'voice', entry: CLI, args: ttsArgs(), url: `http://127.0.0.1:${ttsPort}` });
|
|
132
212
|
}
|
|
133
213
|
|
|
134
214
|
// lip-sync — starts degraded (it probes its own engines), so only bother when
|
|
@@ -144,27 +224,55 @@ export function planServices({ args = [], env = process.env, hasBin = onPath } =
|
|
|
144
224
|
run.push({
|
|
145
225
|
name: 'lipsync',
|
|
146
226
|
tag: 'lips',
|
|
227
|
+
entry: CLI,
|
|
147
228
|
args: [
|
|
148
229
|
'lipsync', '--port', lipPort,
|
|
149
230
|
...(has('--rhubarb') ? ['--rhubarb', rhubarb] : []),
|
|
150
231
|
...opts('--portrait').flatMap((p) => ['--portrait', p]),
|
|
151
232
|
...pass('--wav2lip-dir'), ...pass('--wav2lip-ckpt'),
|
|
152
233
|
...pass('--sadtalker-dir'), ...pass('--python'), ...pass('--cache-dir'),
|
|
234
|
+
// --veo animates the portrait through Vertex (once, then cached) so the
|
|
235
|
+
// narrator moves while you author; it is the one bridge flag that spends
|
|
236
|
+
// money, so it is opt-in here exactly as it is on `decklight lipsync`
|
|
237
|
+
...(has('--veo') ? ['--veo'] : []),
|
|
238
|
+
...pass('--veo-project'), ...pass('--veo-model'),
|
|
239
|
+
...pass('--veo-seconds'), ...pass('--veo-prompt'), ...pass('--veo-location'),
|
|
240
|
+
...pass('--veo-face-y'),
|
|
153
241
|
],
|
|
154
242
|
url: `http://127.0.0.1:${lipPort}`,
|
|
155
243
|
});
|
|
156
244
|
}
|
|
157
245
|
|
|
158
|
-
|
|
246
|
+
// Reported, not passed through. The phone remote moved to `present`
|
|
247
|
+
// (PRESENT#REMOTE), and a flag that quietly did nothing would leave someone
|
|
248
|
+
// holding a phone that never connects. devMain is what prints and exits —
|
|
249
|
+
// the plan stays pure so a test can ask what it decided.
|
|
250
|
+
const gone = ['--remote', '--host'].filter((f) => args.some((a) => a === f || a.startsWith(f + '=')));
|
|
251
|
+
return { deck, run, skip, gone, agents: detectAgents({ env, hasBin }).map((a) => a.name) };
|
|
159
252
|
}
|
|
160
253
|
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Should author OFFER the tts setup wizard instead of just printing the skip
|
|
256
|
+
* line? Only when the skip is the fixable kind — no engine configured, no
|
|
257
|
+
* project to run the default cloud engine with — never when a flag chose the
|
|
258
|
+
* outcome (--no-tts, an unknown engine, a malformed --project: the user's
|
|
259
|
+
* hand is on the wheel, and the skip line already names the fix).
|
|
260
|
+
*/
|
|
261
|
+
/** The voice is skipped only for want of a model, and we know how to fetch it. */
|
|
262
|
+
export const voiceModelOffer = (plan) => {
|
|
263
|
+
const s = plan.skip.find((x) => x.name === 'voice');
|
|
264
|
+
return s?.download ? s : null;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export const voiceSetupOffer = (plan) => {
|
|
268
|
+
const s = plan.skip.find((x) => x.name === 'voice');
|
|
269
|
+
return s && /needs a GCP project/.test(s.why) ? s : null;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// inGitRepo lives in git.mjs now; re-exported so importers (and the tests) keep
|
|
273
|
+
// finding it where dev grew it.
|
|
274
|
+
export { inGitRepo } from './git.mjs';
|
|
275
|
+
import { inGitRepo } from './git.mjs';
|
|
168
276
|
|
|
169
277
|
const COLORS = { deck: '\x1b[36m', voice: '\x1b[35m', lips: '\x1b[33m' };
|
|
170
278
|
const DIM = '\x1b[2m';
|
|
@@ -173,16 +281,25 @@ const RESET = '\x1b[0m';
|
|
|
173
281
|
export async function devMain(args) {
|
|
174
282
|
if (args.includes('--help') || args.includes('-h')) { console.log(USAGE); return; }
|
|
175
283
|
|
|
176
|
-
let plan = planServices({ args });
|
|
284
|
+
let plan = planServices({ args, saved: loadTtsConfig() });
|
|
285
|
+
if (plan.gone.length) {
|
|
286
|
+
console.error(`decklight author no longer takes ${plan.gone.join(' or ')} — the phone remote moved to \`decklight present\`.`);
|
|
287
|
+
console.error(' A clicker used to cost you an editing server on the LAN: /edit/notes, /edit/layout and');
|
|
288
|
+
console.error(' /edit/agent were reachable from the same run you were not watching. present has no edit');
|
|
289
|
+
console.error(' surface to widen, so that is where it lives.');
|
|
290
|
+
console.error(`\n decklight present ${plan.deck ?? '<deck.html>'} --remote`);
|
|
291
|
+
process.exitCode = 2;
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
177
294
|
const deck = plan.deck;
|
|
178
295
|
if (!deck) {
|
|
179
|
-
console.error('decklight
|
|
296
|
+
console.error('decklight author needs a deck: decklight author <deck.html>\n');
|
|
180
297
|
console.error(USAGE);
|
|
181
298
|
process.exitCode = 1;
|
|
182
299
|
return;
|
|
183
300
|
}
|
|
184
301
|
if (!existsSync(deck)) {
|
|
185
|
-
console.error(`decklight
|
|
302
|
+
console.error(`decklight author: no such deck: ${deck}`);
|
|
186
303
|
process.exitCode = 1;
|
|
187
304
|
return;
|
|
188
305
|
}
|
|
@@ -194,13 +311,80 @@ export async function devMain(args) {
|
|
|
194
311
|
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
195
312
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
196
313
|
const answer = await rl.question(' no git repository here — create one and auto-commit the deck as you edit? [Y/n] ');
|
|
314
|
+
const yes = !/^n/i.test(answer.trim());
|
|
315
|
+
args = [...args, yes ? '--git' : '--no-git'];
|
|
316
|
+
// Only while we are ALREADY setting git up, and only when an agent could
|
|
317
|
+
// actually drive edits, offer the boundary that suits agent work. A
|
|
318
|
+
// session in an existing repository gains no new question — that is the
|
|
319
|
+
// one thing this must not cost, so `--git-mode agent` is how you reach it
|
|
320
|
+
// there.
|
|
321
|
+
if (yes && !args.includes('--git-mode') && detectAgents().length) {
|
|
322
|
+
const mode = await rl.question(" commit once per agent edit, with the agent's own message, instead of on a timer? [y/N] ");
|
|
323
|
+
if (/^y/i.test(mode.trim())) args = [...args, '--git-mode', 'agent'];
|
|
324
|
+
}
|
|
197
325
|
rl.close();
|
|
198
|
-
|
|
199
|
-
else plan = planServices({ args: [...args, '--no-git'] });
|
|
326
|
+
plan = planServices({ args, saved: loadTtsConfig() });
|
|
200
327
|
} else {
|
|
201
328
|
console.log(' git: no repository here — pass --git to create one and auto-commit the deck');
|
|
202
329
|
}
|
|
203
330
|
}
|
|
331
|
+
// piper is installed and chosen, but its voice model is not on disk. The
|
|
332
|
+
// download is ~120 MB, so it is ASKED FOR, never silent — and only on a TTY,
|
|
333
|
+
// so CI and pipes keep the skip line exactly as it was. Accepting re-plans,
|
|
334
|
+
// so the bridge joins `run` and comes up in this same session.
|
|
335
|
+
{
|
|
336
|
+
const offer = voiceModelOffer(plan);
|
|
337
|
+
if (offer && process.stdin.isTTY && process.stdout.isTTY) {
|
|
338
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
339
|
+
try {
|
|
340
|
+
console.log(` ${offer.why}`);
|
|
341
|
+
const answer = await rl.question(' download it now? [Y/n] ');
|
|
342
|
+
if (!/^n/i.test(answer.trim())) {
|
|
343
|
+
const { bin, args: dlArgs } = offer.download;
|
|
344
|
+
const r = spawnSync(bin, dlArgs, { stdio: 'inherit' });
|
|
345
|
+
if (r.status === 0) plan = planServices({ args });
|
|
346
|
+
else console.log(' download failed — the voice stays skipped');
|
|
347
|
+
}
|
|
348
|
+
} finally { rl.close(); }
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
// The voice would be skipped for the one reason setup can fix: nothing is
|
|
352
|
+
// configured. Offer the guided setup (TTY only — headless runs keep the
|
|
353
|
+
// skip line exactly as it was); a completed setup re-plans, so the bridge
|
|
354
|
+
// joins `run` and comes up in this same session.
|
|
355
|
+
if (voiceSetupOffer(plan) && process.stdin.isTTY && process.stdout.isTTY) {
|
|
356
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
357
|
+
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] ');
|
|
359
|
+
if (!/^n/i.test(answer.trim())) {
|
|
360
|
+
const result = await runSetupWizard({ ask: (q) => rl.question(q) });
|
|
361
|
+
if (result) {
|
|
362
|
+
// the wizard's test synthesis may hold a resident engine (piper);
|
|
363
|
+
// author runs the bridge as its own child process, so let it go
|
|
364
|
+
result.engine.synth.close?.();
|
|
365
|
+
plan = planServices({ args, saved: result.config });
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
} finally { rl.close(); }
|
|
369
|
+
}
|
|
370
|
+
// The edit port might already be held — often an earlier decklight session
|
|
371
|
+
// left running. Resolved here, with author's OWN stdin, because the edit
|
|
372
|
+
// child below is spawned with its stdin piped (not a terminal) and could
|
|
373
|
+
// never ask on its own.
|
|
374
|
+
const editSvc = plan.run.find((s) => s.name === 'edit');
|
|
375
|
+
if (editSvc) {
|
|
376
|
+
const portIdx = editSvc.args.indexOf('--port');
|
|
377
|
+
const editPort = Number(editSvc.args[portIdx + 1]);
|
|
378
|
+
if (await isPortOpen(editPort)) {
|
|
379
|
+
const askTty = process.stdin.isTTY && process.stdout.isTTY;
|
|
380
|
+
let rl;
|
|
381
|
+
const ask = askTty ? (q) => (rl ??= createInterface({ input: process.stdin, output: process.stdout })).question(q) : undefined;
|
|
382
|
+
const freshPort = await resolvePortConflict(editPort, { ask, log: console.log });
|
|
383
|
+
rl?.close();
|
|
384
|
+
editSvc.args[portIdx + 1] = String(freshPort);
|
|
385
|
+
editSvc.url = `http://127.0.0.1:${freshPort}/${deck}`;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
204
388
|
const { run, skip, agents } = plan;
|
|
205
389
|
|
|
206
390
|
const tty = process.stdout.isTTY;
|
|
@@ -224,8 +408,13 @@ export async function devMain(args) {
|
|
|
224
408
|
};
|
|
225
409
|
|
|
226
410
|
for (const svc of run) {
|
|
227
|
-
|
|
228
|
-
|
|
411
|
+
// stdin is a pipe author never writes to — it is the leash (see supervise.mjs).
|
|
412
|
+
// Holding it open is what tells the child we are still here; losing it is
|
|
413
|
+
// how the child finds out we are not, even when we were SIGKILLed and
|
|
414
|
+
// never reached shutdown() below.
|
|
415
|
+
const child = spawn(process.execPath, [svc.entry, ...svc.args], {
|
|
416
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
417
|
+
env: leashEnv(),
|
|
229
418
|
});
|
|
230
419
|
children.set(svc.name, child);
|
|
231
420
|
pipe(child.stdout, svc.tag, process.stdout);
|
|
@@ -235,8 +424,8 @@ export async function devMain(args) {
|
|
|
235
424
|
children.delete(svc.name);
|
|
236
425
|
if (shuttingDown) return;
|
|
237
426
|
if (svc.name === 'edit') {
|
|
238
|
-
// the deck server is the one service
|
|
239
|
-
console.error(`${paint(svc.tag)} exited (${code}) — stopping decklight
|
|
427
|
+
// the deck server is the one service author cannot run without
|
|
428
|
+
console.error(`${paint(svc.tag)} exited (${code}) — stopping decklight author`);
|
|
240
429
|
shutdown(code ?? 1);
|
|
241
430
|
} else {
|
|
242
431
|
console.error(`${paint(svc.tag)} exited (${code}) — carrying on without it; the deck degrades on its own`);
|
|
@@ -263,4 +452,4 @@ export async function devMain(args) {
|
|
|
263
452
|
process.on('SIGTERM', () => shutdown(0));
|
|
264
453
|
}
|
|
265
454
|
|
|
266
|
-
if (import.meta.url
|
|
455
|
+
if (isMain(import.meta.url)) devMain(process.argv.slice(2));
|