decklight 0.8.1 → 0.10.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/PLATFORM.md +707 -0
- package/README.md +226 -150
- package/SPEC.md +803 -888
- package/cli/agent-review.mjs +246 -0
- package/cli/agents.mjs +35 -9
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +190 -0
- package/cli/bundle-module.mjs +95 -0
- package/cli/bundle.mjs +439 -35
- package/cli/cast.mjs +48 -12
- package/cli/check-fixes.mjs +186 -0
- package/cli/check.mjs +988 -0
- package/cli/clone-deck.mjs +179 -0
- package/cli/commands.mjs +345 -0
- package/cli/comments.mjs +64 -18
- package/cli/commit-flow.mjs +51 -22
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +64 -0
- package/cli/deck-routes.mjs +67 -0
- package/cli/deckfile.mjs +3 -5
- package/cli/decklight.mjs +68 -289
- package/cli/design-system-deps.mjs +209 -0
- package/cli/design-system-edit.mjs +194 -0
- package/cli/design-system-refs.mjs +666 -0
- package/cli/design-system.mjs +497 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +551 -0
- package/cli/edit-look.mjs +631 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2585 -855
- package/cli/enhance.mjs +485 -0
- package/cli/extension.mjs +10 -10
- package/cli/font-refs.mjs +273 -0
- package/cli/font.mjs +246 -0
- package/cli/git-tree.mjs +1 -1
- package/cli/git.mjs +78 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +407 -236
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace-autocheck.mjs +200 -0
- package/cli/marketplace.mjs +460 -29
- package/cli/narrate.mjs +251 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +961 -0
- package/cli/pdf.mjs +64 -17
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +63 -27
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +85 -23
- package/cli/remote.mjs +43 -17
- package/cli/restore.mjs +11 -4
- package/cli/review-ref.mjs +125 -0
- package/cli/review-remote.mjs +92 -48
- package/cli/review-routes.mjs +254 -0
- package/cli/review-store.mjs +47 -7
- package/cli/review-submit.mjs +47 -57
- package/cli/runtime-link.mjs +560 -0
- package/cli/serve.mjs +236 -45
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +229 -35
- package/cli/skills.mjs +353 -26
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +527 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +112 -47
- package/cli/update-check.mjs +1 -5
- package/cli/upgrade.mjs +194 -28
- package/cli/upstream.mjs +4 -3
- package/cli/util.mjs +4 -4
- package/cli/wizard.mjs +6 -6
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +1533 -59
- package/dist/decklight.js +258 -115
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +141 -0
- package/docs/architecture.svg +17 -17
- package/package.json +4 -2
- package/themes/README.md +9 -8
- package/themes/reveal-solarized.css +10 -0
- package/tools/args.mjs +20 -0
- package/tools/atomic-write.mjs +48 -0
- package/tools/brand-palette.mjs +717 -0
- package/tools/bridge.mjs +1 -1
- package/tools/build-groups.mjs +42 -0
- package/tools/color.mjs +48 -0
- package/tools/deck-html.mjs +396 -11
- package/tools/design-system-format.mjs +778 -0
- package/tools/design-system-migrations.mjs +207 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +11 -3
- package/tools/extension-check.mjs +31 -7
- package/tools/font-format.mjs +190 -0
- package/tools/font-stacks.mjs +24 -0
- package/tools/gemini-tts.mjs +3 -0
- package/tools/lipsync-config.mjs +103 -0
- package/tools/lipsync-engines.mjs +205 -2
- package/tools/lipsync-server.mjs +264 -41
- package/tools/lipsync.mjs +37 -18
- package/tools/local-voice.mjs +32 -42
- package/tools/narration-manifest.mjs +270 -0
- package/tools/narration-synth.mjs +416 -0
- package/tools/pptx.mjs +776 -19
- package/tools/publish-targets.mjs +1 -1
- package/tools/publish-voices.mjs +3 -3
- package/tools/recording-impact.mjs +7 -3
- package/tools/render-theme.mjs +33 -0
- package/tools/review-anchor.mjs +28 -12
- package/tools/semver.mjs +40 -0
- package/tools/sentences.mjs +180 -0
- package/tools/shot.mjs +14 -7
- package/tools/site-clip.mjs +114 -0
- package/tools/site-voices.mjs +232 -0
- package/tools/template-theme.mjs +1 -1
- package/tools/test-impact.mjs +17 -10
- package/tools/theme-check.mjs +30 -3
- package/tools/tts-cache.mjs +4 -3
- package/tools/tts-engines.mjs +38 -20
- package/tools/tts-setup.mjs +7 -7
- package/tools/video-options.mjs +34 -0
- package/tools/video.mjs +530 -54
- package/tools/voiceover-server.mjs +185 -104
- package/tools/voiceover.mjs +119 -261
- package/tools/zip.mjs +1 -1
- package/cli/dev.mjs +0 -623
- package/cli/present.mjs +0 -853
- package/cli/review.mjs +0 -361
- package/tools/publish-site-voices.mjs +0 -75
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// `decklight <git url>` — open a deck straight from its repository.
|
|
5
|
+
//
|
|
6
|
+
// The URL is the one people actually paste: the repository, or a GitHub link
|
|
7
|
+
// to the deck file itself. It is cloned IN FULL (history is what `H` shows and
|
|
8
|
+
// what makes a restore possible — a snapshot would open a deck with no past),
|
|
9
|
+
// the deck inside it is found or named, and from there it is `decklight
|
|
10
|
+
// author <local path>` exactly as before, in a directory that is already a
|
|
11
|
+
// repository — so autocommit, history and the upstream check all work from
|
|
12
|
+
// the first keystroke, and nothing here ever pushes.
|
|
13
|
+
//
|
|
14
|
+
// Only an explicit URL counts. `owner/repo` shorthand is not accepted: a
|
|
15
|
+
// mistyped `slides/q3.html` reads exactly like one, and the honest answer to a
|
|
16
|
+
// path that does not exist is "no such deck", not a clone attempt.
|
|
17
|
+
|
|
18
|
+
import { execFileSync } from 'node:child_process';
|
|
19
|
+
import { existsSync, readdirSync, readFileSync, rmSync, statSync } from 'node:fs';
|
|
20
|
+
import { basename, join, relative, resolve } from 'node:path';
|
|
21
|
+
import { refProblem } from './marketplace.mjs';
|
|
22
|
+
import { oneline } from './git.mjs';
|
|
23
|
+
import { isDeck } from './runtime-link.mjs';
|
|
24
|
+
|
|
25
|
+
const GIT_URL = /^(git@|ssh:\/\/|git:\/\/|file:\/\/|https?:\/\/)/;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A git URL as author reads it, or null for anything that is a path.
|
|
29
|
+
*
|
|
30
|
+
* A GitHub link to a FILE (`/blob/<branch>/<path>`) names the repository, the
|
|
31
|
+
* branch and the deck in one go; `/tree/<branch>` names the branch. A
|
|
32
|
+
* `#path` fragment on any URL names the deck inside. `--branch` on the command
|
|
33
|
+
* line outranks what the link said.
|
|
34
|
+
*/
|
|
35
|
+
export function parseDeckSource(spec, { branch = null } = {}) {
|
|
36
|
+
if (typeof spec !== 'string' || !GIT_URL.test(spec)) return null;
|
|
37
|
+
let url = spec;
|
|
38
|
+
let deck = null;
|
|
39
|
+
let ref = null;
|
|
40
|
+
const hash = url.indexOf('#');
|
|
41
|
+
if (hash >= 0) { deck = url.slice(hash + 1) || null; url = url.slice(0, hash); }
|
|
42
|
+
const gh = /^https:\/\/github\.com\/([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:\/(blob|tree)\/([^/]+)(?:\/(.*))?)?\/?$/.exec(url);
|
|
43
|
+
if (gh) {
|
|
44
|
+
const [, owner, repo, kind, atRef, path] = gh;
|
|
45
|
+
url = `https://github.com/${owner}/${repo}.git`;
|
|
46
|
+
if (atRef) ref = atRef;
|
|
47
|
+
if (kind === 'blob' && path) deck = deck ?? path;
|
|
48
|
+
}
|
|
49
|
+
if (branch) ref = branch;
|
|
50
|
+
const bad = ref && refProblem(ref);
|
|
51
|
+
if (bad) throw new Error(`--branch ${ref} ${bad}`);
|
|
52
|
+
const name = basename(url.replace(/\/+$/, '')).replace(/\.git$/, '') || 'deck';
|
|
53
|
+
return { url, ref, deck, name };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Two spellings of one remote: with or without `.git`, with or without a trailing slash. */
|
|
57
|
+
const sameRemote = (a, b) => a.replace(/\.git$/, '').replace(/\/+$/, '') === b.replace(/\.git$/, '').replace(/\/+$/, '');
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Clone `source` into `into` (default: `./<repo name>`), or open it if it is
|
|
61
|
+
* already there. Returns { dir, reused, ref }.
|
|
62
|
+
*
|
|
63
|
+
* ONE CLONE PER REPOSITORY, whichever command asked: `open`, `--no-trust` and
|
|
64
|
+
* `--no-trust` all clone to the same `./<repo name>` and reuse it after. And a
|
|
65
|
+
* command run from INSIDE that clone — `cd talk && decklight <url> --no-trust` —
|
|
66
|
+
* means this clone, not `talk/talk`: the working directory is used when it is
|
|
67
|
+
* already a clone of the same remote.
|
|
68
|
+
*
|
|
69
|
+
* A directory that already exists is opened only when it is a clone of THIS
|
|
70
|
+
* remote — anything else is refused rather than written into: "talk" being
|
|
71
|
+
* taken by an unrelated folder is a fact to report, not a reason to pick
|
|
72
|
+
* `talk-2` on somebody's behalf. Opening an existing clone does no network
|
|
73
|
+
* write and no pull: the no-trust mode's upstream check is what says if it is behind.
|
|
74
|
+
*/
|
|
75
|
+
export function cloneDeck(source, { into = null, cwd = process.cwd(), exec = execFileSync, env = process.env } = {}) {
|
|
76
|
+
const dir = resolve(cwd, into ?? source.name);
|
|
77
|
+
const git = (args, opts = {}) => String(exec('git', args, {
|
|
78
|
+
cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 120_000,
|
|
79
|
+
// never a password prompt: an unreachable private repo is an answer, not a hang
|
|
80
|
+
env: { ...env, GIT_TERMINAL_PROMPT: '0' }, ...opts,
|
|
81
|
+
})).trim();
|
|
82
|
+
if (!into) {
|
|
83
|
+
let top = null, here = null;
|
|
84
|
+
try { top = git(['rev-parse', '--show-toplevel']); here = git(['remote', 'get-url', 'origin']); } catch { /* not in a clone */ }
|
|
85
|
+
if (top && here && sameRemote(here, source.url)) return { dir: top, reused: true, ref: null };
|
|
86
|
+
}
|
|
87
|
+
if (existsSync(dir)) {
|
|
88
|
+
let origin = null;
|
|
89
|
+
try { origin = git(['remote', 'get-url', 'origin'], { cwd: dir }); } catch { /* not a repo, or no origin */ }
|
|
90
|
+
if (!origin || !sameRemote(origin, source.url)) {
|
|
91
|
+
throw new Error(`${dir} already exists and is not a clone of ${source.url}${origin ? ` (its origin is ${origin})` : ''} — pass --into <dir>`);
|
|
92
|
+
}
|
|
93
|
+
return { dir, reused: true, ref: null };
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
git(['clone', '--quiet', ...(source.ref ? ['--branch', source.ref] : []), source.url, dir]);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
throw new Error(`git clone ${source.url}${source.ref ? ` --branch ${source.ref}` : ''} failed — ${oneline(e)}`);
|
|
99
|
+
}
|
|
100
|
+
// A clone that checked out NOTHING: the remote's HEAD names a branch that
|
|
101
|
+
// does not exist there — a repository whose default branch was renamed, or
|
|
102
|
+
// a bare repo initialised on one name and pushed on another. Left in place
|
|
103
|
+
// it would read as "no decklight deck", and a retry would find it "already
|
|
104
|
+
// cloned"; so it is removed, and the branches that DO exist are named.
|
|
105
|
+
try { git(['rev-parse', '-q', '--verify', 'HEAD'], { cwd: dir }); } catch {
|
|
106
|
+
let branches = [];
|
|
107
|
+
try { branches = git(['branch', '-r', '--format=%(refname:short)'], { cwd: dir }).split('\n').map((b) => b.replace(/^origin\//, '')).filter((b) => b && b !== 'HEAD'); } catch { /* none to name */ }
|
|
108
|
+
rmSync(dir, { recursive: true, force: true });
|
|
109
|
+
throw new Error(`${source.url} checked out nothing — its default branch is missing there. Pass --branch`
|
|
110
|
+
+ (branches.length ? `: ${branches.join(', ')}` : ' <name>'));
|
|
111
|
+
}
|
|
112
|
+
return { dir, reused: false, ref: source.ref };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* A deck argument that is a repository URL, as the deck on disk — cloned, or
|
|
117
|
+
* the clone already here — for every command that opens a deck: `open`,
|
|
118
|
+
* `--no-trust`, `--no-trust`. Null when `spec` is not a git URL (a path: the caller
|
|
119
|
+
* carries on as it always did). Throws with a sentence for anything that went
|
|
120
|
+
* wrong; the caller prefixes its own name.
|
|
121
|
+
*
|
|
122
|
+
* It says which happened — a clone is a fact worth knowing even when the deck
|
|
123
|
+
* pick fails after it, because it is where the next try opens — and when a
|
|
124
|
+
* reused clone is on another branch than the link asked for, it says that too
|
|
125
|
+
* and names the command, rather than switching somebody's working tree for
|
|
126
|
+
* them.
|
|
127
|
+
*/
|
|
128
|
+
export function deckFromUrl(spec, { branch = null, into = null, cwd = process.cwd(),
|
|
129
|
+
say = (line) => process.stderr.write(`${line}\n`), exec = execFileSync, env = process.env } = {}) {
|
|
130
|
+
const source = parseDeckSource(spec, { branch });
|
|
131
|
+
if (!source) return null;
|
|
132
|
+
const { dir, reused } = cloneDeck(source, { into, cwd, exec, env });
|
|
133
|
+
const at = relative(cwd, dir) || '.';
|
|
134
|
+
say(reused ? ` already cloned — opening ${at}` : ` cloned ${source.url}${source.ref ? ` (${source.ref})` : ''} → ${at}`);
|
|
135
|
+
if (reused && source.ref) {
|
|
136
|
+
let on = null;
|
|
137
|
+
try { on = String(exec('git', ['branch', '--show-current'], { cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })).trim(); } catch { /* detached, or not git */ }
|
|
138
|
+
if (on && on !== source.ref) say(` note: ${at} is on ${on}, not ${source.ref} — git -C ${at} switch ${source.ref}`);
|
|
139
|
+
}
|
|
140
|
+
return { source, dir, reused, deckPath: findDeck(dir, source.deck) };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const SKIP = new Set(['node_modules', '.git', 'dist', 'voiceover', 'voices']);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The deck inside a clone: the one named, else the ONE file that is a deck.
|
|
147
|
+
* Two candidates are a question for the person, not a guess — the error names
|
|
148
|
+
* them so the answer is a `#path` away.
|
|
149
|
+
*
|
|
150
|
+
* "Is a deck" is `isDeck` — a `class="decklight"` element, the one marker
|
|
151
|
+
* every other command goes by. It used to be "calls Decklight.init", which a
|
|
152
|
+
* deck that is DATA (#520, every deck `init` writes since) never does: a
|
|
153
|
+
* repository of 0.9.0 decks cloned fine and then had "no decklight deck" in it.
|
|
154
|
+
*/
|
|
155
|
+
export function findDeck(dir, named = null, { depth = 3 } = {}) {
|
|
156
|
+
if (named) {
|
|
157
|
+
if (/^[/\\]|^[a-zA-Z]:|(^|[/\\])\.\.([/\\]|$)/.test(named)) throw new Error(`the deck must be named relative to the repository, not ${named}`);
|
|
158
|
+
const p = resolve(dir, named);
|
|
159
|
+
if (!existsSync(p) || !statSync(p).isFile()) throw new Error(`no ${named} in ${dir}`);
|
|
160
|
+
return p;
|
|
161
|
+
}
|
|
162
|
+
const found = [];
|
|
163
|
+
const walk = (d, level) => {
|
|
164
|
+
let entries = [];
|
|
165
|
+
try { entries = readdirSync(d, { withFileTypes: true }); } catch { return; }
|
|
166
|
+
for (const e of entries) {
|
|
167
|
+
if (e.isDirectory()) { if (level < depth && !SKIP.has(e.name) && !e.name.startsWith('.')) walk(join(d, e.name), level + 1); continue; }
|
|
168
|
+
if (!/\.html?$/i.test(e.name)) continue;
|
|
169
|
+
let text = '';
|
|
170
|
+
try { text = readFileSync(join(d, e.name), 'utf8'); } catch { continue; }
|
|
171
|
+
if (isDeck(text)) found.push(join(d, e.name));
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
walk(dir, 0);
|
|
175
|
+
if (found.length === 1) return found[0];
|
|
176
|
+
const rel = (p) => p.slice(dir.length + 1).split('\\').join('/');
|
|
177
|
+
if (!found.length) throw new Error(`no decklight deck in ${dir} — no .html file there has a class="decklight" element`);
|
|
178
|
+
throw new Error(`${found.length} decks in ${dir} — name one: append #<path> to the URL\n ${found.map(rel).join('\n ')}`);
|
|
179
|
+
}
|
package/cli/commands.mjs
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The command roster — the one table `decklight <command>` dispatches from.
|
|
6
|
+
*
|
|
7
|
+
* It used to be a 200-line switch in decklight.mjs, one `case` per command,
|
|
8
|
+
* each repeating the same dynamic import and differing only in whether it
|
|
9
|
+
* assigned the return value to `process.exitCode`. Adding a command meant a
|
|
10
|
+
* new case, a new help paragraph, and remembering which of the two return
|
|
11
|
+
* conventions the new main followed. Now it is one row here and one paragraph
|
|
12
|
+
* in GLOBAL_HELP below, and test/commands.test.mjs holds the two in step: a
|
|
13
|
+
* command in the table that the help does not list fails the suite, and so
|
|
14
|
+
* does a paragraph for a command that does not exist.
|
|
15
|
+
*
|
|
16
|
+
* A row is `{ module, main }` — the module (relative to this directory) and
|
|
17
|
+
* the exported async main to call. The main receives the remaining argv and
|
|
18
|
+
* may return an exit code; a main that returns nothing exits 0 unless it
|
|
19
|
+
* throws (a CommandError prints as a refusal, anything else as a bug — see
|
|
20
|
+
* cli/util.mjs). Two optional fields cover the exceptions:
|
|
21
|
+
*
|
|
22
|
+
* args(rest, cmd) the argument list to call the main with, when it is not
|
|
23
|
+
* simply `[rest]` — the unit commands pass their own name
|
|
24
|
+
* alias this name is another command, spelled differently; the
|
|
25
|
+
* row it names is dispatched and the alias stays out of help
|
|
26
|
+
* spawn a script to run in a child process instead of importing
|
|
27
|
+
* (tools/voiceover.mjs parses argv and exits at load)
|
|
28
|
+
*/
|
|
29
|
+
export const COMMANDS = {
|
|
30
|
+
init: { module: './init.mjs', main: 'initMain' },
|
|
31
|
+
skills: { module: './skills.mjs', main: 'skillsMain' },
|
|
32
|
+
cast: { module: './cast.mjs', main: 'castMain' },
|
|
33
|
+
// `cast refresh` and `cast export` are castMain's own subcommands. They
|
|
34
|
+
// used to be top-level `refresh` and `export` too, and a top-level `export`
|
|
35
|
+
// meaning asciicast sat beside the deck's Export & share meaning PDF and
|
|
36
|
+
// video (ROADMAP section 4).
|
|
37
|
+
bundle: { module: './bundle.mjs', main: 'bundleMain' },
|
|
38
|
+
restore: { module: './restore.mjs', main: 'restoreMain' },
|
|
39
|
+
history: { module: './history.mjs', main: 'historyMain' },
|
|
40
|
+
upgrade: { module: './upgrade.mjs', main: 'upgradeMain' },
|
|
41
|
+
pdf: { module: './pdf.mjs', main: 'pdfMain' },
|
|
42
|
+
pptx: { module: './pptx-export.mjs', main: 'pptxMain' },
|
|
43
|
+
import: { module: './import.mjs', main: 'importMain' },
|
|
44
|
+
theme: { module: './theme.mjs', main: 'themeMain' },
|
|
45
|
+
publish: { module: './publish.mjs', main: 'publishMain' },
|
|
46
|
+
marketplace: { module: './marketplace.mjs', main: 'marketplaceMain' },
|
|
47
|
+
// Everything installed into YOUR library, one grammar (cli/library.mjs):
|
|
48
|
+
// it replaced seven commands, one per kind (ROADMAP section 4).
|
|
49
|
+
library: { module: './library.mjs', main: 'libraryMain' },
|
|
50
|
+
'design-system': { module: './design-system.mjs', main: 'designSystemMain' },
|
|
51
|
+
font: { module: './font.mjs', main: 'fontMain' },
|
|
52
|
+
// The two bridges `decklight <deck>` starts. Still runnable (write mode
|
|
53
|
+
// spawns them; a file:// deck talks to one run on its own) but `hidden`:
|
|
54
|
+
// what a person types is `setup voice|face` (ROADMAP section 4).
|
|
55
|
+
tts: { module: '../tools/voiceover-server.mjs', main: 'ttsMain', hidden: true },
|
|
56
|
+
lipsync: { module: '../tools/lipsync-server.mjs', main: 'lipsyncMain', hidden: true },
|
|
57
|
+
setup: { module: './setup.mjs', main: 'setupMain' },
|
|
58
|
+
video: { module: '../tools/video.mjs', main: 'videoMain' },
|
|
59
|
+
// THE command: `decklight <deck.html | url> [--no-trust]`. Reached through
|
|
60
|
+
// routeForPath, never typed as a word, and listed nowhere (`hidden`): the
|
|
61
|
+
// deck is the command.
|
|
62
|
+
open: { module: './open.mjs', main: 'openMain', hidden: true },
|
|
63
|
+
// the deck's narration into a folder, by an engine or by you (--mic): one
|
|
64
|
+
// command for what `voiceover` and `record` did (cli/narrate.mjs)
|
|
65
|
+
narrate: { module: './narrate.mjs', main: 'narrateMain' },
|
|
66
|
+
enhance: { module: './enhance.mjs', main: 'enhanceMain' },
|
|
67
|
+
comments: { module: './comments.mjs', main: 'commentsMain' },
|
|
68
|
+
associate: { module: './associate.mjs', main: 'associateMain' },
|
|
69
|
+
'report-bug': { module: './report-bug.mjs', main: 'reportBugMain' },
|
|
70
|
+
doctor: { module: './doctor.mjs', main: 'doctorMain' },
|
|
71
|
+
trust: { module: './trust.mjs', main: 'trustMain' },
|
|
72
|
+
check: { module: './check.mjs', main: 'checkMain' },
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** The row a command name dispatches to, aliases followed, or null. */
|
|
76
|
+
export function resolveCommand(name) {
|
|
77
|
+
const row = COMMANDS[name];
|
|
78
|
+
if (!row) return null;
|
|
79
|
+
return row.alias ? COMMANDS[row.alias] ?? null : row;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The commands `decklight help` lists, in help order — aliases excluded. */
|
|
83
|
+
export const listedCommands = () => [...GLOBAL_HELP.slice(GLOBAL_HELP.indexOf('Commands:\n'))
|
|
84
|
+
.matchAll(/^ ([a-z-]+) +\S/gm)].map((m) => m[1]);
|
|
85
|
+
|
|
86
|
+
/** The one-line description GLOBAL_HELP opens a command's paragraph with. */
|
|
87
|
+
export function commandSummary(name) {
|
|
88
|
+
const m = new RegExp(`^ ${name} +(\\S.*)$`, 'm').exec(GLOBAL_HELP.slice(GLOBAL_HELP.indexOf('Commands:\n')));
|
|
89
|
+
return m ? m[1].trim() : '';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The journey, in order: make a deck, work on it, show it, bring one in, hand
|
|
94
|
+
* it over. What a bare `decklight` and an unknown command print, because a
|
|
95
|
+
* newcomer who typed the wrong thing does not need the other thirty commands
|
|
96
|
+
* on screen to find the right one — they need these six and a way to the rest.
|
|
97
|
+
*/
|
|
98
|
+
export const START_COMMANDS = ['init', 'check', 'import', 'bundle', 'publish', 'doctor'];
|
|
99
|
+
|
|
100
|
+
/** One line each, written to fit a terminal — GLOBAL_HELP's paragraphs wrap. */
|
|
101
|
+
const SHORT = {
|
|
102
|
+
init: 'start a deck here, plus the skill that teaches an AI agent to write it',
|
|
103
|
+
check: 'lint one deck headlessly: what is clipped, crowded, missing or out of step, one exit code',
|
|
104
|
+
import: 'bring a PowerPoint, Keynote or Google Slides deck across',
|
|
105
|
+
bundle: 'one self-contained HTML file to hand over',
|
|
106
|
+
publish: 'bundle and push to GitHub Pages, Netlify, Vercel or a folder',
|
|
107
|
+
doctor: 'what this machine can do, and the install line for what it cannot',
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export function shortHelp() {
|
|
111
|
+
const width = Math.max(...START_COMMANDS.map((c) => c.length)) + 2;
|
|
112
|
+
const rows = START_COMMANDS.map((c) => ` ${c.padEnd(width)}${SHORT[c] ?? commandSummary(c)}`);
|
|
113
|
+
const more = listedCommands().filter((c) => !START_COMMANDS.includes(c) && c !== 'help' && c !== 'version').length;
|
|
114
|
+
return `decklight — author, record, and package Decklight presentations
|
|
115
|
+
|
|
116
|
+
Usage:
|
|
117
|
+
decklight <deck.html | url> open a deck: live reload, edits from the browser, an AI agent on A
|
|
118
|
+
decklight <deck> --no-trust open it in no-trust mode: the safe way in for a deck you did not write
|
|
119
|
+
decklight <talk.pptx> bring a PowerPoint, Keynote or Google Slides deck across
|
|
120
|
+
decklight in a directory: start a deck here, or pick one to open
|
|
121
|
+
decklight <command> [options] (decklight <command> --help for its flags)
|
|
122
|
+
|
|
123
|
+
Commands:
|
|
124
|
+
${rows.join('\n')}
|
|
125
|
+
|
|
126
|
+
decklight help every command (${more} more), one paragraph each
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* What a FILE means as the first argument — the verb the argument implies.
|
|
132
|
+
*
|
|
133
|
+
* `decklight talk.html` was "unknown command", which is the least useful
|
|
134
|
+
* answer to the most natural thing to type. A deck opens in write mode, a
|
|
135
|
+
* `.decklight` container is somebody else's deck and plays without trust, an
|
|
136
|
+
* Office file or a Slides URL is something to import, a YAML script is a
|
|
137
|
+
* terminal cast to record. A REPOSITORY is a deck to open too: `open`
|
|
138
|
+
* clones it and opens the deck inside (#514), so `decklight <repo url>` is the
|
|
139
|
+
* whole command. Unknown kinds return null and stay unknown commands; a file
|
|
140
|
+
* that does not exist still routes, so the refusal names the file ("no such
|
|
141
|
+
* deck: talk.html") instead of the word.
|
|
142
|
+
*/
|
|
143
|
+
/**
|
|
144
|
+
* Does this name a git repository? Only the shapes that cannot be anything
|
|
145
|
+
* else: the git transports (`git@host:…`, `ssh://`, `git://`), a URL ending in
|
|
146
|
+
* `.git`, and a repository — or a branch or file in one — on the three hosts
|
|
147
|
+
* whose URLs say so (`github.com/owner/repo`, `…/tree/<branch>`,
|
|
148
|
+
* `…/blob/<branch>/<path>`). A web page is not a repository, so an arbitrary
|
|
149
|
+
* https URL stays an unknown command rather than a clone attempt.
|
|
150
|
+
*/
|
|
151
|
+
export function isRepoUrl(arg) {
|
|
152
|
+
const a = String(arg ?? '').replace(/#.*$/, '');
|
|
153
|
+
if (/^(git@[\w.-]+:|ssh:\/\/|git:\/\/)/i.test(a)) return true;
|
|
154
|
+
if (/^(https?|file):\/\/.+\.git\/?$/i.test(a)) return true;
|
|
155
|
+
return /^https:\/\/(github\.com|gitlab\.com|bitbucket\.org)\/[\w.-]+\/[\w.-]+(\/(tree|blob|-\/tree|-\/blob|src)\/.*)?\/?$/i.test(a);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function routeForPath(arg) {
|
|
159
|
+
const a = String(arg ?? '');
|
|
160
|
+
if (/^https?:\/\/docs\.google\.com\/presentation\//i.test(a)) return 'import';
|
|
161
|
+
if (isRepoUrl(a)) return 'open';
|
|
162
|
+
if (a.startsWith('-')) return null;
|
|
163
|
+
const ext = /\.([a-z0-9]+)$/i.exec(a)?.[1]?.toLowerCase();
|
|
164
|
+
if (!ext) return null;
|
|
165
|
+
if (ext === 'html' || ext === 'htm') return 'open';
|
|
166
|
+
if (ext === 'decklight') return 'open'; // a container is without trust by nature: open.mjs says so
|
|
167
|
+
if (ext === 'pptx' || ext === 'key' || ext === 'keynote') return 'import';
|
|
168
|
+
if (ext === 'yaml' || ext === 'yml') return 'cast';
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The word people reach for that is not the command's name. Every entry here
|
|
174
|
+
* is a guess somebody would plausibly type; the values are the roster's names.
|
|
175
|
+
*/
|
|
176
|
+
export const SYNONYMS = {
|
|
177
|
+
edit: 'open', serve: 'open', run: 'open', watch: 'open', write: 'open', dev: 'open',
|
|
178
|
+
preview: 'open', play: 'open', show: 'open', view: 'open', open: 'open',
|
|
179
|
+
new: 'init', create: 'init', scaffold: 'init', make: 'init',
|
|
180
|
+
build: 'bundle', pack: 'bundle', flatten: 'bundle',
|
|
181
|
+
deploy: 'publish', ship: 'publish', pages: 'publish',
|
|
182
|
+
convert: 'import', pptx2html: 'import',
|
|
183
|
+
env: 'doctor', diagnose: 'doctor', lint: 'check', verify: 'check', validate: 'check',
|
|
184
|
+
update: 'upgrade', undo: 'restore', log: 'history',
|
|
185
|
+
themes: 'theme', plugins: 'library', voices: 'library', engines: 'library',
|
|
186
|
+
plugin: 'library', importer: 'library', transform: 'library', engine: 'library',
|
|
187
|
+
voice: 'library', agent: 'library', extension: 'library', install: 'library',
|
|
188
|
+
record: 'narrate', voiceover: 'narrate', narration: 'narrate', mic: 'narrate',
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/** Levenshtein distance, for the typo half of did-you-mean. */
|
|
192
|
+
function editDistance(a, b) {
|
|
193
|
+
const prev = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
194
|
+
for (let i = 1; i <= a.length; i++) {
|
|
195
|
+
let diag = prev[0];
|
|
196
|
+
prev[0] = i;
|
|
197
|
+
for (let j = 1; j <= b.length; j++) {
|
|
198
|
+
const tmp = prev[j];
|
|
199
|
+
prev[j] = Math.min(prev[j] + 1, prev[j - 1] + 1, diag + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
200
|
+
diag = tmp;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return prev[b.length];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The command somebody who typed `name` most likely meant, or null.
|
|
208
|
+
*
|
|
209
|
+
* Synonyms first — `edit` is not a typo of `open`, it is the word for it —
|
|
210
|
+
* then a unique prefix (`pub` → publish), then a name within two edits. Two,
|
|
211
|
+
* not three: `cast` and `past` are one apart, `cast` and `pdf` are four, and
|
|
212
|
+
* the useful distance is the one that catches a slipped finger and never an
|
|
213
|
+
* unrelated word.
|
|
214
|
+
*/
|
|
215
|
+
export function suggestCommand(name) {
|
|
216
|
+
const n = String(name ?? '').toLowerCase();
|
|
217
|
+
if (!n || COMMANDS[n]) return null;
|
|
218
|
+
if (SYNONYMS[n]) return SYNONYMS[n];
|
|
219
|
+
const names = Object.keys(COMMANDS).filter((c) => !COMMANDS[c].alias && !COMMANDS[c].hidden);
|
|
220
|
+
const prefixed = names.filter((c) => c.startsWith(n));
|
|
221
|
+
if (n.length >= 2 && prefixed.length === 1) return prefixed[0];
|
|
222
|
+
// How many slips a word can absorb depends on how long it is: two in
|
|
223
|
+
// `bundel`, one in `pdff`, none in `p` — which is within two of `pdf` and
|
|
224
|
+
// meant nothing of the kind.
|
|
225
|
+
const budget = n.length >= 5 ? 2 : n.length >= 3 ? 1 : 0;
|
|
226
|
+
let best = null, bestD = budget + 1;
|
|
227
|
+
for (const c of names) {
|
|
228
|
+
const d = editDistance(n, c);
|
|
229
|
+
if (d < bestD) { best = c; bestD = d; }
|
|
230
|
+
}
|
|
231
|
+
return best;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export const GLOBAL_HELP = `decklight — author, record, and package Decklight presentations
|
|
235
|
+
|
|
236
|
+
Usage:
|
|
237
|
+
decklight <deck.html | repository url> [--no-trust] [--port 8788] [--git | --no-git] [--agent <name>] …
|
|
238
|
+
open a deck. Write mode by default: live reload, every edit from the browser written
|
|
239
|
+
to the file, the bridges this machine can run, an AI agent on A, one Ctrl-C.
|
|
240
|
+
--no-trust is the same server in no-trust mode: every edit route refuses, the deck is
|
|
241
|
+
served from its own directory under a CSP header, and what the file will execute is
|
|
242
|
+
listed before it runs — the way in for a deck you did not write, and where --strict and
|
|
243
|
+
--audit live. The phone remote (--remote) and comments (M) work in either mode.
|
|
244
|
+
A repository URL is cloned (in full) and the deck inside opened. A .decklight
|
|
245
|
+
container is without trust by nature. (decklight <deck> --help for every flag)
|
|
246
|
+
decklight <command> [options] (decklight <command> --help for full flags)
|
|
247
|
+
|
|
248
|
+
Commands:
|
|
249
|
+
init scaffold a starter deck — slides plus a configuration block, no runtime in the
|
|
250
|
+
file — plus an agent skill (.claude/skills/decklight/, AGENTS.md); --inline embeds it
|
|
251
|
+
EXAMPLE: decklight init "My Deck"
|
|
252
|
+
skills install the Decklight authoring skill for AI agents (Claude, Codex, OpenCode, IBM Bob)
|
|
253
|
+
EXAMPLE: decklight skills claude codex (or --all, or omit to use detected agents)
|
|
254
|
+
EXAMPLE: decklight skills --global (install into each agent's config home, every project)
|
|
255
|
+
EXAMPLE: decklight skills claude --pack (zip it to upload in your claude.ai skill settings)
|
|
256
|
+
cast record a truthful terminal cast by running a YAML command script in a real PTY
|
|
257
|
+
(this records a TERMINAL — decklight narrate --mic records your VOICE)
|
|
258
|
+
EXAMPLE: decklight cast deck.term.yaml -o deck.cast.json
|
|
259
|
+
EXAMPLE: decklight cast refresh casts/ (re-run each cast's script; rewrite the ones that drifted)
|
|
260
|
+
EXAMPLE: decklight cast export demo.cast.json && agg demo.cast demo.gif (asciicast v2)
|
|
261
|
+
bundle flatten a deck into ONE self-contained HTML file (runtime, themes, casts, images inlined)
|
|
262
|
+
EXAMPLE: decklight bundle demo/showcase.html --themes midnight,graphite
|
|
263
|
+
EXAMPLE: decklight bundle deck.html --all --title "My Course" (merge the whole playlist into one file)
|
|
264
|
+
restore list the commits that touched a deck, and put it back to any of them
|
|
265
|
+
EXAMPLE: decklight restore deck.html (list)
|
|
266
|
+
EXAMPLE: decklight restore deck.html a1b2c3d (restore, as a new commit on top)
|
|
267
|
+
history what decklight committed, and which commits are only on this machine
|
|
268
|
+
EXAMPLE: decklight history deck.html
|
|
269
|
+
upgrade bring a self-contained deck's embedded runtime + themes up to the installed version, in place;
|
|
270
|
+
--link turns the embed back into slides plus a configuration block (the reverse of bundle)
|
|
271
|
+
EXAMPLE: decklight upgrade deck.html --dry-run (see what would change; drop the flag to apply)
|
|
272
|
+
pdf render the deck to a PDF — one slide per page, at its own size, in its theme
|
|
273
|
+
EXAMPLE: decklight pdf deck.html (writes deck.pdf; --theme exports in another)
|
|
274
|
+
EXAMPLE: decklight pdf deck.html --handout (three a page, ruled; --notes is your copy)
|
|
275
|
+
pptx write a PowerPoint file — every slide as a picture, its notes as notes (lossy on purpose)
|
|
276
|
+
EXAMPLE: decklight pptx deck.html (for the people around you who still ask for the file)
|
|
277
|
+
import convert an existing PowerPoint, Keynote or Google Slides deck into a decklight deck
|
|
278
|
+
EXAMPLE: decklight import "Q3 Review.pptx" (also .key on macOS, or a Slides URL)
|
|
279
|
+
theme validate a theme file against the token contract, or mark one for a deck to carry
|
|
280
|
+
EXAMPLE: decklight theme gate nord-deep.css
|
|
281
|
+
EXAMPLE: decklight theme add nord-deep@acme-themes talk.html
|
|
282
|
+
publish bundle a deck and push it to GitHub Pages — deck to shareable URL in one command
|
|
283
|
+
EXAMPLE: decklight publish deck.html (prints https://owner.github.io/repo/)
|
|
284
|
+
marketplace register catalogs (git repos with .decklight/marketplace.json) — registered, not fetched
|
|
285
|
+
EXAMPLE: decklight marketplace add owner/repo (or a git URL, or a local path)
|
|
286
|
+
EXAMPLE: decklight marketplace list (offline-safe: reads only the cache)
|
|
287
|
+
library what this machine installs from a marketplace for its own use — plugins, skills,
|
|
288
|
+
import adapters, build-time transforms, speech engines, voices, agents — one grammar:
|
|
289
|
+
add, remove, list, and gate (the admission gate a marketplace's CI runs); nothing travels in a deck
|
|
290
|
+
EXAMPLE: decklight library add plugin timer (then: decklight talk.html)
|
|
291
|
+
EXAMPLE: decklight library add engine azure-tts (then: decklight talk.html --tts-engine azure-tts)
|
|
292
|
+
EXAMPLE: decklight library list (every kind, or name one)
|
|
293
|
+
EXAMPLE: decklight library gate transform grammar-check.mjs
|
|
294
|
+
design-system a company's tokens, art and slide templates, referenced by a deck and served from
|
|
295
|
+
the marketplace on this machine — add/remove/list/templates/apply, and gate, the admission gate
|
|
296
|
+
EXAMPLE: decklight design-system add acme@acme-mkt talk.html
|
|
297
|
+
EXAMPLE: decklight design-system templates acme@acme-mkt (the slots a slide fills)
|
|
298
|
+
EXAMPLE: decklight design-system gate systems/acme (a catalog's CI gate)
|
|
299
|
+
font a typeface's files and licence, referenced by a deck so its faces travel with it —
|
|
300
|
+
served from the marketplace on this machine, carried by bundle; add/remove/list, and gate
|
|
301
|
+
EXAMPLE: decklight font add inter@type-mkt talk.html --use (and open in it)
|
|
302
|
+
EXAMPLE: decklight font gate fonts/inter (a catalog's CI gate)
|
|
303
|
+
setup set up this machine's voice and face once — the answers are saved, and every deck
|
|
304
|
+
you open uses them
|
|
305
|
+
EXAMPLE: decklight setup voice (which engine, what it needs, one test sentence)
|
|
306
|
+
EXAMPLE: decklight setup face --portrait me=me.jpg --wav2lip-dir ~/Wav2Lip --wav2lip-ckpt …
|
|
307
|
+
video render the deck to ONE narrated mp4 — a still per slide, held for its narration audio
|
|
308
|
+
EXAMPLE: decklight video deck.html -o deck.mp4 (add --voiceover to synthesize first)
|
|
309
|
+
EXAMPLE: decklight video deck.html --slides 5-9 --voiceover (just those slides, voiced)
|
|
310
|
+
EXAMPLE: decklight video deck.html --format webm --quality high --subtitles file
|
|
311
|
+
narrate the deck's narration into a folder beside it, one file per slide and per [click]
|
|
312
|
+
beat: an engine reads the notes, or you do into the microphone (--mic), and
|
|
313
|
+
→ ends a beat AND reveals the next build (decklight cast records a terminal)
|
|
314
|
+
EXAMPLE: decklight narrate talk.html --engine chirp --voice Achernar
|
|
315
|
+
EXAMPLE: decklight narrate talk.html --mic (serves it: a microphone needs 127.0.0.1)
|
|
316
|
+
EXAMPLE: decklight narrate talk.html --slides 7 (just that slide, either way)
|
|
317
|
+
EXAMPLE: decklight narrate talk.html --face (the character's lip-sync, no bridge needed)
|
|
318
|
+
enhance add ElevenLabs v4 audio tags ([thoughtful], [sighs]) to the voiceover script, with the
|
|
319
|
+
prompt ElevenLabs publishes for it — your agent drafts, decklight checks no word changed
|
|
320
|
+
EXAMPLE: decklight enhance talk.html --slides 3 (or --all; --dry-run to only look)
|
|
321
|
+
comments what reviewers said, resolved against the deck as it is now — a comment
|
|
322
|
+
whose slide moved is found anyway, and one whose slide is gone is still shown;
|
|
323
|
+
a reviewer leaves them with M in a deck opened either way (--no-trust for one
|
|
324
|
+
they were sent), and \`comments submit\` pushes them to a review/<you>-<date> branch
|
|
325
|
+
EXAMPLE: decklight comments talk.html (--import to take in a reviewer's file,
|
|
326
|
+
--incoming to see what reviews are waiting on the remote)
|
|
327
|
+
EXAMPLE: decklight comments submit talk.html (--pr opens a pull request)
|
|
328
|
+
associate wire double-clicking a .decklight file to decklight <file> (without trust by nature)
|
|
329
|
+
EXAMPLE: decklight associate (per-user, no admin rights; --uninstall undoes it)
|
|
330
|
+
trust list the decks whose script you said you trust, or forget one so decklight <deck> asks again
|
|
331
|
+
EXAMPLE: decklight trust list
|
|
332
|
+
EXAMPLE: decklight trust forget talk.html (the next open asks again)
|
|
333
|
+
report-bug gather the version + environment facts a Decklight bug report needs, and the issue URL
|
|
334
|
+
EXAMPLE: decklight report-bug (prints and exits — nothing is sent anywhere)
|
|
335
|
+
doctor what this machine can do — Chrome, ffmpeg, git, the optional deps, the agents on PATH —
|
|
336
|
+
and, for each thing missing, which commands it unlocks and the line that installs it
|
|
337
|
+
EXAMPLE: decklight doctor
|
|
338
|
+
check lint ONE deck headlessly and say, per slide, what you would otherwise only find by
|
|
339
|
+
looking — clipped content, a crowded slide, an asset that is not on disk, [click] beats
|
|
340
|
+
that do not line up with the builds; exit 1 on an error (an agent after every edit,
|
|
341
|
+
you before a talk); in the deck, the palette's Check deck… lists the same
|
|
342
|
+
EXAMPLE: decklight check deck.html (--json for an agent, --no-render without Chrome)
|
|
343
|
+
help show this help, or a command's help: decklight help bundle
|
|
344
|
+
version print the installed version (also --version / -v)
|
|
345
|
+
`;
|