decklight 0.4.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.
- package/README.md +12 -3
- package/SPEC.md +98 -17
- package/cli/agents.mjs +170 -17
- package/cli/commit-message.mjs +350 -0
- package/cli/decklight.mjs +16 -0
- package/cli/dev.mjs +35 -13
- package/cli/edit.mjs +149 -13
- package/cli/git.mjs +348 -0
- package/cli/history.mjs +145 -0
- package/cli/init.mjs +162 -2
- package/cli/marketplace.mjs +123 -17
- package/cli/port-conflict.mjs +41 -6
- package/cli/present.mjs +297 -12
- package/cli/report-bug.mjs +9 -1
- package/cli/restore.mjs +120 -4
- package/cli/serve.mjs +24 -0
- package/cli/skill-content.mjs +14 -5
- package/cli/theme.mjs +78 -11
- package/cli/update-check.mjs +156 -0
- package/cli/upstream.mjs +256 -0
- package/cli/wizard.mjs +184 -16
- package/dist/decklight.css +290 -2
- package/dist/decklight.js +68 -65
- package/dist/decklight.js.map +4 -4
- package/package.json +5 -3
- package/tools/deck-html.mjs +34 -0
- package/tools/local-voice.mjs +33 -2
- package/tools/tts-engines.mjs +195 -9
- package/tools/tts-setup.mjs +1 -8
- package/tools/video.mjs +106 -25
- package/tools/voiceover-server.mjs +95 -4
- package/tools/voiceover.mjs +66 -18
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
|
|
@@ -129,8 +131,16 @@ const { version } = JSON.parse(
|
|
|
129
131
|
);
|
|
130
132
|
|
|
131
133
|
if (!cmd || cmd === '--help' || cmd === '-h') globalHelp();
|
|
134
|
+
// A newer decklight than the one npx pinned (#314). Read from a cache the last
|
|
135
|
+
// run left behind — never a fetch on this path — and written to stderr like the
|
|
136
|
+
// banner below, for the same reason: piped output stays clean.
|
|
137
|
+
const { updateNotice, refreshInBackground } = await import('./update-check.mjs');
|
|
138
|
+
const notice = updateNotice(version);
|
|
139
|
+
refreshInBackground();
|
|
140
|
+
|
|
132
141
|
if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
|
|
133
142
|
process.stdout.write(`decklight ${version}\n`);
|
|
143
|
+
if (notice) process.stderr.write(`${notice}\n`);
|
|
134
144
|
process.exit(0);
|
|
135
145
|
}
|
|
136
146
|
if (cmd === 'help') {
|
|
@@ -142,6 +152,7 @@ if (cmd === 'help') {
|
|
|
142
152
|
// every real command announces the version it runs as — on stderr, so piped
|
|
143
153
|
// output (export, bundle) stays clean
|
|
144
154
|
process.stderr.write(`decklight ${version}\n`);
|
|
155
|
+
if (notice) process.stderr.write(`${notice}\n`);
|
|
145
156
|
|
|
146
157
|
// When a parent supervises us (author runs the deck server and the bridges), go when it
|
|
147
158
|
// goes — a SIGKILLed parent never gets to reap its children. No-op otherwise.
|
|
@@ -272,6 +283,11 @@ switch (cmd) {
|
|
|
272
283
|
process.exitCode = await restoreMain(rest);
|
|
273
284
|
break;
|
|
274
285
|
}
|
|
286
|
+
case 'history': {
|
|
287
|
+
const { historyMain } = await import('./history.mjs');
|
|
288
|
+
process.exitCode = await historyMain(rest);
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
275
291
|
case 'author':
|
|
276
292
|
case 'dev': { // permanent hidden alias — the pre-rename name; works forever, documented nowhere
|
|
277
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,
|
|
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 (
|
|
194
|
+
} else if (status.reason === 'unknown') {
|
|
174
195
|
skip.push({ name: 'voice', why: `unknown --tts-engine '${ttsEngine}' — use ${TTS_ENGINES.join(', ')}` });
|
|
175
|
-
} else if (
|
|
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 (
|
|
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
|
|
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 ${
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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
|
}
|
package/cli/edit.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// `edit` out loud — author spawns this module directly:
|
|
8
8
|
//
|
|
9
9
|
// node cli/edit.mjs <deck.html> [--port 8788] [--git | --no-git]
|
|
10
|
-
// [--commit-every <seconds>] [--agent <name>]
|
|
10
|
+
// [--commit-every <seconds>] [--agent <name>] [--commit-messages]
|
|
11
11
|
//
|
|
12
12
|
// It binds 127.0.0.1 and nothing else. The phone remote used to be here behind
|
|
13
13
|
// `--remote`, which meant a clicker cost you an editing server on the LAN;
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
// `decklight author` asks interactively before passing --git down.
|
|
47
47
|
|
|
48
48
|
import { createServer } from 'node:http';
|
|
49
|
-
import { readFileSync, writeFileSync, watch, existsSync } from 'node:fs';
|
|
49
|
+
import { readFileSync, writeFileSync, mkdirSync, watch, existsSync } from 'node:fs';
|
|
50
50
|
import { resolve, sep, basename } from 'node:path';
|
|
51
51
|
import { spawn } from 'node:child_process';
|
|
52
52
|
import { agentCommand, detectAgents, agentUnavailable, preferredAgent, setPreferredAgent } from './agents.mjs';
|
|
53
53
|
import { exitWhenOrphaned } from './supervise.mjs';
|
|
54
54
|
import { argReader, isMain } from '../tools/args.mjs';
|
|
55
55
|
import { NOTES_ASIDE, locateSlide, sectionChildRanges } from '../tools/deck-html.mjs';
|
|
56
|
-
import { deckHistory, restoreDeck, deckAt, withBaseHref } from './restore.mjs';
|
|
56
|
+
import { deckHistory, decorateHistory, restoreDeck, deckAt, withBaseHref } from './restore.mjs';
|
|
57
57
|
import { escapeHtml, sseChannel, staticFiles, listenTakingOverIfNeeded, allowEditRequest } from './serve.mjs';
|
|
58
58
|
import { configureEngine, loadCredentials, forgetCredentials, redactAnswers, validateSchema, provenance, BRIDGE_ADDR, CONFIGURED, UNREACHABLE, PREREQUISITE } from './wizard.mjs';
|
|
59
59
|
|
|
@@ -197,13 +197,14 @@ export function createHistory(limit = 200) {
|
|
|
197
197
|
// The plumbing lives in git.mjs now; imported for editMain's use below and
|
|
198
198
|
// re-exported so long-standing importers (init, the tests) keep finding it
|
|
199
199
|
// where edit grew it.
|
|
200
|
-
import { inGitRepo, createRepo, STARTER_GITIGNORE, gitAutocommit, resolveGitMode, shouldCommit, commitSubject, oneline } from './git.mjs';
|
|
200
|
+
import { inGitRepo, createRepo, STARTER_GITIGNORE, gitAutocommit, lastCommitSha, resolveGitMode, shouldCommit, commitSubject, exitPushLine, oneline, remoteLine, remoteState, unpushed } from './git.mjs';
|
|
201
|
+
import { describeCommit, messagesLine } from './commit-message.mjs';
|
|
201
202
|
export { inGitRepo, createRepo, STARTER_GITIGNORE, gitAutocommit };
|
|
202
203
|
|
|
203
204
|
export async function editMain(args) {
|
|
204
205
|
if (args.includes('--help') || args.includes('-h') || !args.filter((a) => !a.startsWith('-')).length) {
|
|
205
206
|
console.log(`usage: node cli/edit.mjs <deck.html> [--port 8788] [--git | --no-git]
|
|
206
|
-
[--commit-every <seconds>] [--agent <name>]
|
|
207
|
+
[--commit-every <seconds>] [--agent <name>] [--commit-messages]
|
|
207
208
|
serves the cwd, live-reloads the deck on change, and accepts edits from the
|
|
208
209
|
player: notes (right-click a slide's background), per-slide layout (L/⇧L),
|
|
209
210
|
element edit mode (E, then right-click an element), undo/redo (Z/⇧Z), agent asks (A)
|
|
@@ -260,6 +261,41 @@ export async function editMain(args) {
|
|
|
260
261
|
const noGit = args.includes('--no-git');
|
|
261
262
|
const wantGit = args.includes('--git');
|
|
262
263
|
const commitEvery = Math.max(5, Number(opt('--commit-every', 300)) || 300);
|
|
264
|
+
// --commit-messages: an agent writes the subject decklight would otherwise
|
|
265
|
+
// template. Opt-in, because it sends the deck's diffs to whichever agent CLI
|
|
266
|
+
// is installed and most of them are cloud-backed — a permission decklight
|
|
267
|
+
// does not infer from what happens to be on PATH.
|
|
268
|
+
const wantMessages = args.includes('--commit-messages');
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Every commit decklight authors ITSELF goes through here — the cadence, the
|
|
272
|
+
* session bookends, the save that clears the way before an agent edit.
|
|
273
|
+
*
|
|
274
|
+
* One funnel, because the amend has to happen right after the commit while
|
|
275
|
+
* the sha is still the tip, and a second call site that forgot to ask would
|
|
276
|
+
* silently be the one that keeps saying "autosave". Commits made from an
|
|
277
|
+
* AGENT'S OWN message do not come through here: they already say what
|
|
278
|
+
* happened, and asking an agent to rewrite an agent's sentence is a call
|
|
279
|
+
* that buys nothing.
|
|
280
|
+
*
|
|
281
|
+
* The describe is deliberately unawaited. The commit has landed by the time
|
|
282
|
+
* this returns, which is the whole contract of autocommit — the subject is
|
|
283
|
+
* an improvement that arrives late or not at all.
|
|
284
|
+
*/
|
|
285
|
+
function ownCommit(message) {
|
|
286
|
+
const made = message === undefined
|
|
287
|
+
? gitAutocommit(deckPath, root)
|
|
288
|
+
: gitAutocommit(deckPath, root, message);
|
|
289
|
+
if (!made) return false;
|
|
290
|
+
const sha = lastCommitSha;
|
|
291
|
+
if (wantMessages && sha) {
|
|
292
|
+
const template = message ?? `decklight: autosave ${basename(deckPath)}`;
|
|
293
|
+
describeCommit({ cwd: root, sha, deckPath, template, agent: agentPref })
|
|
294
|
+
.then((subject) => { if (subject) console.log(` git: subject → "${subject}"`); })
|
|
295
|
+
.catch(() => { /* the commit stands; the wording was the optional part */ });
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
263
299
|
// timer (default, unchanged) · agent (one commit per agent edit) · off
|
|
264
300
|
const gitMode = resolveGitMode(args);
|
|
265
301
|
let gitOn = false;
|
|
@@ -274,21 +310,34 @@ export async function editMain(args) {
|
|
|
274
310
|
}
|
|
275
311
|
if (inGitRepo(root)) {
|
|
276
312
|
gitOn = true;
|
|
277
|
-
|
|
313
|
+
ownCommit(`decklight: start editing ${basename(deckPath)}`);
|
|
278
314
|
// The cadence is the backstop, and it runs in agent mode too: an agent
|
|
279
315
|
// job only ever sees edits IT made, so hand edits — and any agent driven
|
|
280
316
|
// from outside the A flow — would otherwise reach git only via the
|
|
281
317
|
// Ctrl-C bookend, which a crash skips. It is held back while a job is in
|
|
282
318
|
// flight so nothing commits a half-finished agent run.
|
|
283
319
|
setInterval(() => {
|
|
284
|
-
if (shouldCommit(gitMode, { kind: 'timer', agentBusy: !!agentJob }))
|
|
320
|
+
if (shouldCommit(gitMode, { kind: 'timer', agentBusy: !!agentJob })) ownCommit();
|
|
285
321
|
}, commitEvery * 1000).unref();
|
|
286
322
|
console.log(gitMode === 'agent'
|
|
287
323
|
? ` git: committing ${deckRel} once per agent edit with the agent's own message, every ${commitEvery}s otherwise (and on Ctrl-C)`
|
|
288
324
|
: ` git: auto-committing ${deckRel} every ${commitEvery}s (and on Ctrl-C)`);
|
|
289
325
|
}
|
|
290
326
|
}
|
|
291
|
-
const finalCommit = () => {
|
|
327
|
+
const finalCommit = () => {
|
|
328
|
+
if (!gitOn) return;
|
|
329
|
+
// Not ownCommit: this runs inside the SIGINT handler and the process exits
|
|
330
|
+
// immediately after, so there is no later for an amend to arrive in. The
|
|
331
|
+
// bookend keeps its literal subject, which is true anyway.
|
|
332
|
+
gitAutocommit(deckPath, root, `decklight: stop editing ${basename(deckPath)}`);
|
|
333
|
+
// The last moment anyone is looking. Synchronous and fetch-free on purpose:
|
|
334
|
+
// this runs inside the SIGINT handler, and a network call there would hang
|
|
335
|
+
// a Ctrl-C — the worst possible place to hang.
|
|
336
|
+
try {
|
|
337
|
+
const line = exitPushLine(remoteState(root));
|
|
338
|
+
if (line) console.log(line);
|
|
339
|
+
} catch { /* a reminder is never worth failing an exit over */ }
|
|
340
|
+
};
|
|
292
341
|
process.on('SIGINT', () => { finalCommit(); process.exit(0); });
|
|
293
342
|
process.on('SIGTERM', () => { finalCommit(); process.exit(0); });
|
|
294
343
|
|
|
@@ -306,6 +355,14 @@ export async function editMain(args) {
|
|
|
306
355
|
if (agentPref && !agents.some((a) => a.name === agentPref)) {
|
|
307
356
|
console.log(` agent: ${agentUnavailable(agentPref, agents)}`);
|
|
308
357
|
}
|
|
358
|
+
// Said out loud, every session it is on: this is the switch that starts
|
|
359
|
+
// sending the deck somewhere, and a capability nobody is reminded of is one
|
|
360
|
+
// they stop counting on being off. Printed HERE rather than up with the other
|
|
361
|
+
// git lines because it names the agent, and the roster is only resolved now.
|
|
362
|
+
if (gitOn && wantMessages) {
|
|
363
|
+
const who = agents.find((a) => a.name === agentPref) ?? agents[0];
|
|
364
|
+
console.log(` ${messagesLine(who?.name ?? null)}`);
|
|
365
|
+
}
|
|
309
366
|
|
|
310
367
|
// ── live reload: watch the deck, broadcast SSE (debounced — editors fire
|
|
311
368
|
// multiple fs events per save) ─────────────────────────────────────────
|
|
@@ -450,7 +507,7 @@ export async function editMain(args) {
|
|
|
450
507
|
// under the agent's message, and a history that misattributes authorship is
|
|
451
508
|
// worse than one that only says "autosave".
|
|
452
509
|
if (gitOn && shouldCommit(gitMode, { kind: 'bookend' })
|
|
453
|
-
&&
|
|
510
|
+
&& ownCommit(`decklight: save before ${cmd.name} edits ${basename(deckPath)}`)) {
|
|
454
511
|
console.log(' git: committed your outstanding changes first');
|
|
455
512
|
}
|
|
456
513
|
const before = readDeck();
|
|
@@ -517,6 +574,9 @@ export async function editMain(args) {
|
|
|
517
574
|
return json(200, {
|
|
518
575
|
ok: true, deck: deckUrl, name: basename(deckPath),
|
|
519
576
|
...history.counts(), git: gitOn,
|
|
577
|
+
// What the player's one push nudge reads. Computed once, like everything
|
|
578
|
+
// else on ping: the toast is threshold-driven, not live.
|
|
579
|
+
remote: gitOn ? remoteState(root) : null,
|
|
520
580
|
agents: agents.map((a) => ({ name: a.name, label: a.label })),
|
|
521
581
|
// which one A reaches for, so the picker opens on it rather than
|
|
522
582
|
// defaulting to the first detected agent every session (#125)
|
|
@@ -534,8 +594,31 @@ export async function editMain(args) {
|
|
|
534
594
|
// historical revisions of the deck, which is nobody else's business.
|
|
535
595
|
if (req.method === 'GET' && url.pathname === '/edit/history') {
|
|
536
596
|
if (!gitOn) return json(409, { ok: false, error: 'git is off for this session — there is no history' });
|
|
537
|
-
try {
|
|
538
|
-
|
|
597
|
+
try {
|
|
598
|
+
// One round trip serves the whole overlay: the commits, which of them
|
|
599
|
+
// exist nowhere but this machine, and where the branch stands. All of
|
|
600
|
+
// it is a LOCAL read — `unpushed` and `@{u}` read remote-tracking
|
|
601
|
+
// refs, so opening the history never touches the network (SPEC
|
|
602
|
+
// PRESENTING).
|
|
603
|
+
// `slides` is what that version WAS, `add`/`del` what it CHANGED —
|
|
604
|
+
// the two questions a hash and a subject cannot answer, and the ones
|
|
605
|
+
// that tell "tightened the wording" apart from "cut four slides"
|
|
606
|
+
// before you restore it rather than after.
|
|
607
|
+
const entries = decorateHistory(deckHistory(deckPath, root), deckPath, root);
|
|
608
|
+
const remote = remoteState(root);
|
|
609
|
+
// `pushed` is null for "not a question worth answering here", and the
|
|
610
|
+
// two cases are different: git could not tell us, or there is no
|
|
611
|
+
// remote at all — in which case EVERY commit is unpushed and marking
|
|
612
|
+
// all of them is a wall of arrows saying what the footer says once.
|
|
613
|
+
const local = ['no-remote', 'ambiguous-remote'].includes(remote.state) ? null : unpushed(root);
|
|
614
|
+
const set = local ? new Set(local) : null;
|
|
615
|
+
for (const e of entries) e.pushed = set ? !set.has(e.full) : null;
|
|
616
|
+
// The LINE is computed here, not in the player: cli/git.mjs is Node
|
|
617
|
+
// (it spawns git), the runtime has zero dependencies and cannot
|
|
618
|
+
// import it, and duplicating the wording in the browser is how the
|
|
619
|
+
// four places that talk about unpushed work start disagreeing.
|
|
620
|
+
return json(200, { ok: true, entries, remote: { ...remote, line: remoteLine(remote) } });
|
|
621
|
+
} catch (e) { return json(500, { ok: false, error: oneline(e) }); }
|
|
539
622
|
}
|
|
540
623
|
if (req.method === 'GET' && url.pathname === '/edit/at') {
|
|
541
624
|
if (!gitOn) return json(409, { ok: false, error: 'git is off for this session' });
|
|
@@ -587,6 +670,51 @@ export async function editMain(args) {
|
|
|
587
670
|
console.log(` ${dir} → ${JSON.stringify(history.counts())}`);
|
|
588
671
|
return json(200, { ok: true, ...history.counts() });
|
|
589
672
|
}
|
|
673
|
+
// ── ⇧V offline recordings (PRESENTING) ───────────────────────────────
|
|
674
|
+
// The player used to hand every stitched slide to the browser's DOWNLOAD
|
|
675
|
+
// path, which is why a deck's voice arrived as thirty slide-NN.wav in
|
|
676
|
+
// whatever folder the OS calls Downloads — never the deck's, and on
|
|
677
|
+
// Windows not even near it. `bundle` only ever looks NEXT TO THE DECK, so
|
|
678
|
+
// the recording was finished and in the wrong place, and the last step
|
|
679
|
+
// was moving files by hand. In author mode the server that already owns
|
|
680
|
+
// the deck file writes them itself.
|
|
681
|
+
//
|
|
682
|
+
// Ahead of the shared body read below because this body is BINARY and
|
|
683
|
+
// megabytes of it: a slide of speech is ~48 kB a second, so the string
|
|
684
|
+
// concat and its 1 MB ceiling would both be wrong.
|
|
685
|
+
if (req.method === 'POST' && url.pathname === '/edit/record') {
|
|
686
|
+
const slide = Number(url.searchParams.get('slide'));
|
|
687
|
+
const kind = url.searchParams.get('kind');
|
|
688
|
+
if (!Number.isInteger(slide) || slide < 1 || slide > 9999) return json(400, { ok: false, error: 'bad slide' });
|
|
689
|
+
if (kind !== 'wav' && kind !== 'visemes') return json(400, { ok: false, error: 'bad kind' });
|
|
690
|
+
// The player names the FOLDER (its own `narration.files`, so a recorded
|
|
691
|
+
// set lands where that deck already plays from) and nothing else: the
|
|
692
|
+
// file name is built here, so no request can choose one. The folder is
|
|
693
|
+
// contained to the served root by the same rule staticFiles reads by —
|
|
694
|
+
// and `..`, absolute paths and Windows drive letters are refused before
|
|
695
|
+
// it, because `resolve` would happily swallow all three.
|
|
696
|
+
const want = url.searchParams.get('dir') || 'voiceover';
|
|
697
|
+
const bad = want.length > 200 || /^[/\\]/.test(want) || /^[a-zA-Z]:/.test(want)
|
|
698
|
+
|| want.split(/[/\\]/).includes('..');
|
|
699
|
+
const dir = bad ? null : resolve(deckPath, '..', want);
|
|
700
|
+
if (!dir || (!dir.startsWith(root + sep) && dir !== root)) {
|
|
701
|
+
return json(400, { ok: false, error: 'the recording folder must sit inside the deck\'s own directory' });
|
|
702
|
+
}
|
|
703
|
+
const name = `slide-${String(slide).padStart(2, '0')}.${kind === 'wav' ? 'wav' : 'visemes.json'}`;
|
|
704
|
+
const chunks = [];
|
|
705
|
+
let size = 0;
|
|
706
|
+
for await (const chunk of req) {
|
|
707
|
+
size += chunk.length;
|
|
708
|
+
if (size > 64e6) return json(413, { ok: false, error: 'recording too large' });
|
|
709
|
+
chunks.push(chunk);
|
|
710
|
+
}
|
|
711
|
+
try {
|
|
712
|
+
mkdirSync(dir, { recursive: true });
|
|
713
|
+
writeFileSync(resolve(dir, name), Buffer.concat(chunks));
|
|
714
|
+
} catch (e) { return json(500, { ok: false, error: oneline(e) }); }
|
|
715
|
+
console.log(` recorded ${want}/${name} (${Math.round(size / 1024)} kB)`);
|
|
716
|
+
return json(200, { ok: true, dir: want, file: name });
|
|
717
|
+
}
|
|
590
718
|
let body = '';
|
|
591
719
|
if (req.method === 'POST') {
|
|
592
720
|
for await (const chunk of req) { body += chunk; if (body.length > 1e6) throw new Error('too large'); }
|
|
@@ -726,8 +854,16 @@ export async function editMain(args) {
|
|
|
726
854
|
}
|
|
727
855
|
// Redacted on the way out, always — the response is the one place a key
|
|
728
856
|
// could leak back into a page, a devtools log, or a screen recording.
|
|
729
|
-
console.log(` wizard: ${engine} configured (${r.file})`);
|
|
730
|
-
|
|
857
|
+
console.log(` wizard: ${engine} configured (${r.file} — ${r.protection.label})`);
|
|
858
|
+
// A key that could not be restricted is worth an extra line, at the
|
|
859
|
+
// moment it is stored rather than in a doc nobody reads (#308): what
|
|
860
|
+
// decklight says about a credential and what is true of it on disk
|
|
861
|
+
// have to be the same sentence.
|
|
862
|
+
if (r.protection.state !== 'private') {
|
|
863
|
+
console.log(` wizard: decklight could NOT restrict that file to your account — ${r.protection.label}`);
|
|
864
|
+
if (r.protection.why) console.log(` the system said: ${r.protection.why}`);
|
|
865
|
+
}
|
|
866
|
+
return json(200, { ok: true, state: r.state, engine, stored: r.stored, protection: r.protection.label });
|
|
731
867
|
}
|
|
732
868
|
if (req.method === 'POST' && url.pathname === '/edit/wizard/forget') {
|
|
733
869
|
const { engine } = JSON.parse(body);
|