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,497 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright 2026 Gilles Philippart
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
// decklight design-system — the design-system unit (SPEC DESIGN_SYSTEMS).
|
|
6
|
+
//
|
|
7
|
+
// decklight design-system gate <dir>
|
|
8
|
+
// decklight design-system add|remove <name@marketplace> <deck.html>
|
|
9
|
+
// decklight design-system list [<deck.html>]
|
|
10
|
+
// decklight design-system migrate <name@marketplace> <deck.html>
|
|
11
|
+
// decklight design-system templates <name@marketplace>
|
|
12
|
+
//
|
|
13
|
+
// `check` is the admission gate a catalog's own CI runs, in the mould of
|
|
14
|
+
// `decklight library gate transform` and `decklight theme gate`: a valid package
|
|
15
|
+
// prints what it holds and exits 0; a broken or unsafe one names the file,
|
|
16
|
+
// the line and the rule for every problem, and exits 1. Every rule lives in
|
|
17
|
+
// tools/design-system-format.mjs, which is pure — this file only reads a
|
|
18
|
+
// directory into the shape it takes.
|
|
19
|
+
//
|
|
20
|
+
// A deck depends on a design system by REFERENCE (cli/design-system-refs.mjs):
|
|
21
|
+
// `add` writes `designSystems` (and the shared `themeSources`) into its
|
|
22
|
+
// configuration block, after the package passes `check`; every server serves
|
|
23
|
+
// it from the marketplace checkout. Nothing is ever installed into
|
|
24
|
+
// ~/.decklight/ — the ledger only remembers which version a deck took.
|
|
25
|
+
|
|
26
|
+
import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
27
|
+
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
28
|
+
import { argReader, isMain } from '../tools/args.mjs';
|
|
29
|
+
import { checkPackage, DESIGN_SYSTEM_API_VERSION, ASSET_EXTENSIONS } from '../tools/design-system-format.mjs';
|
|
30
|
+
import { THEMES_DIR } from './pkg.mjs';
|
|
31
|
+
|
|
32
|
+
const USAGE = `usage: decklight design-system <add|remove|list|templates|apply|migrate|gate> …
|
|
33
|
+
|
|
34
|
+
decklight design-system add <name@marketplace> <deck.html> [--no-recommended] [--apply|--no-apply]
|
|
35
|
+
reference a design system from a deck — after the package passes check;
|
|
36
|
+
the deck gains one entry in its configuration block, never the package.
|
|
37
|
+
The themes and fonts it recommends come with it, in the same edit, each
|
|
38
|
+
through its own gate (--no-recommended: the design system alone). Then
|
|
39
|
+
it offers to APPLY its look — the deck's theme and font — asking on a
|
|
40
|
+
terminal, suggesting --apply otherwise; --apply / --no-apply decide.
|
|
41
|
+
EXAMPLE: decklight design-system add acme@acme-mkt talk.html
|
|
42
|
+
|
|
43
|
+
decklight design-system apply <name@marketplace> <deck.html>
|
|
44
|
+
give a deck the look a design system it uses was drawn for: its first
|
|
45
|
+
recommended theme and font (bringing any that are missing)
|
|
46
|
+
|
|
47
|
+
decklight design-system migrate <name@marketplace> <deck.html>
|
|
48
|
+
move a deck written for an older version onto the one this machine
|
|
49
|
+
serves: the renames its migrations declare (roles, tokens, classes,
|
|
50
|
+
themes — whole names, in the deck and the stylesheets it links), then the
|
|
51
|
+
version the deck records. A removed name with no successor is a
|
|
52
|
+
judgement call: the migration's skill makes it, not this command.
|
|
53
|
+
|
|
54
|
+
decklight design-system remove <name@marketplace> <deck.html>
|
|
55
|
+
drop the reference; the package stays in its marketplace, and so do the
|
|
56
|
+
themes and fonts it brought — other slides may use them (it lists them)
|
|
57
|
+
|
|
58
|
+
decklight design-system list [<deck.html>]
|
|
59
|
+
what a deck references (and the version it took against the catalog's);
|
|
60
|
+
with no deck, every design system the registered marketplaces offer —
|
|
61
|
+
from the cache alone, works on a plane
|
|
62
|
+
|
|
63
|
+
decklight design-system templates <name@marketplace>
|
|
64
|
+
the package's templates and their slots — the names a slide writes
|
|
65
|
+
|
|
66
|
+
decklight design-system gate <dir>
|
|
67
|
+
the marketplace admission gate for a design-system package — its manifest,
|
|
68
|
+
stylesheet, templates and assets, held to the format's rules (SPEC
|
|
69
|
+
DESIGN_SYSTEMS). Prints what the package holds and exits 0, or names the
|
|
70
|
+
file, the line and the rule for every problem and exits 1.
|
|
71
|
+
EXAMPLE: decklight design-system gate systems/acme
|
|
72
|
+
|
|
73
|
+
A design system is a directory:
|
|
74
|
+
design-system.json apiVersion (${DESIGN_SYSTEM_API_VERSION}), name, version (semver), title,
|
|
75
|
+
styles ("design-system.css"), templates ("templates.html")
|
|
76
|
+
+ description, tokenPrefix (default "--<name>-"),
|
|
77
|
+
palette [{ group, label, token }] or { colors: { <name>:
|
|
78
|
+
{ label, weights: { "100": "#hex" … "1000" } } } } with
|
|
79
|
+
themes [{ name, title, mode, tokens }] (SPEC BRAND_PALETTE),
|
|
80
|
+
recommendedThemes, migrations { "<version>": { skill,
|
|
81
|
+
roles, tokens, classes, themes } } (SPEC DESIGN_SYSTEM_MIGRATIONS)
|
|
82
|
+
design-system.css prefixed tokens and per-template rules; url()s relative to it
|
|
83
|
+
templates.html inert <template data-template="…"> blocks, with data-slot containers
|
|
84
|
+
assets/… ${ASSET_EXTENSIONS.join(' · ')}
|
|
85
|
+
|
|
86
|
+
A deck references a design system rather than copying it; every server
|
|
87
|
+
serves it from the marketplace on this machine, never the network.`;
|
|
88
|
+
|
|
89
|
+
/** Files whose TEXT the rules read; everything else is checked by extension and size. */
|
|
90
|
+
const TEXT = /\.(json|css|html|svg)$/i;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A package directory as `checkPackage` takes it. Every file under `dir`,
|
|
94
|
+
* by its /-separated relative path. A symlink that resolves outside the
|
|
95
|
+
* package is a problem of its own — nothing a deck is served may come from
|
|
96
|
+
* outside the directory it was admitted as.
|
|
97
|
+
*/
|
|
98
|
+
export function readPackage(dir) {
|
|
99
|
+
const root = realpathSync(resolve(dir));
|
|
100
|
+
const files = new Map();
|
|
101
|
+
const escapes = [];
|
|
102
|
+
const walk = (abs) => {
|
|
103
|
+
for (const name of readdirSync(abs).sort()) {
|
|
104
|
+
if (name === '.git') continue;
|
|
105
|
+
const full = join(abs, name);
|
|
106
|
+
const rel = relative(root, full).split(sep).join('/');
|
|
107
|
+
let target = full;
|
|
108
|
+
if (lstatSync(full).isSymbolicLink()) {
|
|
109
|
+
try { target = realpathSync(full); } catch { escapes.push(rel); continue; }
|
|
110
|
+
if (target !== root && !target.startsWith(root + sep)) { escapes.push(rel); continue; }
|
|
111
|
+
}
|
|
112
|
+
const st = statSync(target);
|
|
113
|
+
if (st.isDirectory()) { walk(full); continue; }
|
|
114
|
+
files.set(rel, { size: st.size, ...(TEXT.test(name) ? { text: readFileSync(target, 'utf8') } : {}) });
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
walk(root);
|
|
118
|
+
const manifest = files.get('design-system.json')?.text ?? null;
|
|
119
|
+
return { manifest, files, escapes };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** A package, checked — the gate's whole verdict, with symlink escapes folded in. */
|
|
123
|
+
export function checkDir(dir) {
|
|
124
|
+
const { manifest, files, escapes } = readPackage(dir);
|
|
125
|
+
if (manifest === null) {
|
|
126
|
+
return { ok: false, problems: [{ file: 'design-system.json', rule: 'file-missing', msg: 'no design-system.json at the package root — this is not a design system' }], warnings: [], summary: {} };
|
|
127
|
+
}
|
|
128
|
+
// the themes decklight ships: a brand theme may not take one's name, and a
|
|
129
|
+
// recommended one is held to the palette (SPEC BRAND_PALETTE)
|
|
130
|
+
let shippedThemes = [];
|
|
131
|
+
try { shippedThemes = readdirSync(THEMES_DIR).filter((f) => f.endsWith('.css')).map((f) => f.slice(0, -4)); } catch { /* no themes dir: nothing to compare against */ }
|
|
132
|
+
const recommendedThemeCss = {};
|
|
133
|
+
try {
|
|
134
|
+
for (const t of JSON.parse(manifest).recommendedThemes ?? []) {
|
|
135
|
+
const name = String(t).split('@')[0];
|
|
136
|
+
if (shippedThemes.includes(name)) recommendedThemeCss[name] = readFileSync(join(THEMES_DIR, `${name}.css`), 'utf8');
|
|
137
|
+
}
|
|
138
|
+
} catch { /* an unparseable manifest is the check's to report */ }
|
|
139
|
+
const r = checkPackage({ manifest, files, shippedThemes, recommendedThemeCss });
|
|
140
|
+
for (const rel of escapes) {
|
|
141
|
+
r.problems.push({ file: rel, rule: 'file-outside', msg: 'a symlink that resolves outside the package — a design system reaches only its own files' });
|
|
142
|
+
}
|
|
143
|
+
r.ok = r.problems.length === 0;
|
|
144
|
+
// what a server needs from a passing package, read once here: the parsed
|
|
145
|
+
// manifest, and the templates text it inlines into the page
|
|
146
|
+
try { r.manifest = JSON.parse(manifest); } catch { r.manifest = null; }
|
|
147
|
+
r.templatesHtml = typeof r.manifest?.templates === 'string' ? files.get(r.manifest.templates)?.text ?? null : null;
|
|
148
|
+
return r;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const where = (p) => `${p.file}${p.line ? ` line ${p.line}` : ''}`;
|
|
152
|
+
const kb = (n) => (n < 1024 * 1024 ? `${Math.max(1, Math.round(n / 1024))} KB` : `${(n / 1024 / 1024).toFixed(1)} MB`);
|
|
153
|
+
|
|
154
|
+
/** The report, as the lines to print. */
|
|
155
|
+
export function reportLines(dir, r) {
|
|
156
|
+
const s = r.summary ?? {};
|
|
157
|
+
const out = [];
|
|
158
|
+
if (!r.ok) {
|
|
159
|
+
out.push(`✘ ${s.name ?? dir} — ${r.problems.length} problem${r.problems.length === 1 ? '' : 's'}, not admitted`);
|
|
160
|
+
for (const p of r.problems) out.push(` ${where(p)}: ${p.msg} [${p.rule}]`);
|
|
161
|
+
} else {
|
|
162
|
+
out.push(`✔ ${s.name} — design system ${s.version}, api ${s.apiVersion}`);
|
|
163
|
+
out.push(` design-system.json ${s.title}${s.palette ? ` — palette of ${s.palette}` : ''}`
|
|
164
|
+
+ `${s.recommendedThemes?.length ? ` · recommends ${s.recommendedThemes.join(', ')}` : ''}`);
|
|
165
|
+
out.push(` stylesheet ${s.tokens.length} token${s.tokens.length === 1 ? '' : 's'} (${s.prefix}…)`);
|
|
166
|
+
if (s.baseStyles?.elements?.length) {
|
|
167
|
+
out.push(` base styles ${s.baseStyles.elements.join(', ')} — a slide without a template takes the brand's look for these`);
|
|
168
|
+
}
|
|
169
|
+
const templates = s.templates ?? [];
|
|
170
|
+
out.push(` templates ${templates.length} template${templates.length === 1 ? '' : 's'}${templates.length ? ':' : ''}`);
|
|
171
|
+
for (const l of templates) {
|
|
172
|
+
const slots = l.slots.map((x) => `${x.name}${x.required ? '*' : ''}${x.default ? '†' : ''}`).join(', ');
|
|
173
|
+
out.push(` ${l.id} (${slots || 'no slots'})`);
|
|
174
|
+
}
|
|
175
|
+
if (templates.some((l) => l.slots.length)) out.push(' * required · † takes unslotted content');
|
|
176
|
+
const roles = s.brand?.roles ?? [];
|
|
177
|
+
if (roles.length) {
|
|
178
|
+
const groups = {};
|
|
179
|
+
for (const r of roles) groups[r.group] = (groups[r.group] ?? 0) + 1;
|
|
180
|
+
out.push(` roles ${roles.length} role${roles.length === 1 ? '' : 's'} — ${Object.entries(groups).map(([g, n]) => `${g} ${n}`).join(', ')}`
|
|
181
|
+
+ ` · ${Object.keys(s.brand.contract ?? {}).length} contract token${Object.keys(s.brand.contract ?? {}).length === 1 ? '' : 's'} read from them`);
|
|
182
|
+
}
|
|
183
|
+
for (const t of s.brand?.themes ?? []) {
|
|
184
|
+
const via = Object.keys(t.viaRole ?? {}).length;
|
|
185
|
+
out.push(` theme ${t.name} (${t.mode}) — ${t.stated.length} token${t.stated.length === 1 ? '' : 's'} stated${via ? ` (${via} through roles)` : ''}, ${t.chosen.length} chosen from the palette`
|
|
186
|
+
+ `${roles.length ? `, every role set` : ''}`);
|
|
187
|
+
}
|
|
188
|
+
for (const m of s.migrations ?? []) {
|
|
189
|
+
out.push(` migration ${m.version} — ${m.renames} rename${m.renames === 1 ? '' : 's'}${m.skill ? ` · skill ${m.skill}` : ''}`);
|
|
190
|
+
}
|
|
191
|
+
const assets = s.assets ?? [];
|
|
192
|
+
const byExt = {};
|
|
193
|
+
for (const a of assets) byExt[a.ext] = (byExt[a.ext] ?? 0) + 1;
|
|
194
|
+
out.push(` assets ${assets.length} file${assets.length === 1 ? '' : 's'}`
|
|
195
|
+
+ `${assets.length ? ` — ${Object.entries(byExt).map(([e, n]) => `${n} ${e}`).join(', ')} · ${kb(assets.reduce((t, a) => t + a.size, 0))}` : ''}`);
|
|
196
|
+
}
|
|
197
|
+
// declared overrides of the theme contract, printed on every run — the way a
|
|
198
|
+
// theme's rule-exception: is — so they stay reviewable
|
|
199
|
+
for (const e of r.summary?.exceptions ?? []) out.push(` ds-exception ${e.token}: ${e.reason}`);
|
|
200
|
+
for (const w of r.warnings ?? []) out.push(` ⚠ ${where(w)}: ${w.msg}`);
|
|
201
|
+
// what the engine made up or stood in for, said so a brand reviewer sees it
|
|
202
|
+
for (const n of r.summary?.notes ?? []) out.push(` · ${n.msg} [${n.rule}]`);
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async function checkMain(args) {
|
|
207
|
+
const [dir] = args.filter((a) => !a.startsWith('-'));
|
|
208
|
+
if (!dir) { console.error(`decklight design-system gate: needs a package directory\n\n${USAGE}`); return 1; }
|
|
209
|
+
if (!existsSync(dir)) { console.error(`decklight design-system gate: no such directory: ${dir}`); return 1; }
|
|
210
|
+
if (!statSync(dir).isDirectory()) {
|
|
211
|
+
console.error(`decklight design-system gate: ${dir} is a file — a design system is a directory holding design-system.json`);
|
|
212
|
+
return 1;
|
|
213
|
+
}
|
|
214
|
+
const r = checkDir(dir);
|
|
215
|
+
for (const line of reportLines(dir, r)) console.log(line);
|
|
216
|
+
return r.ok ? 0 : 1;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** The deck path and its text, or a refusal printed as-is. */
|
|
220
|
+
function readDeckArg(cmd, deck) {
|
|
221
|
+
if (!deck) { console.error(`decklight design-system ${cmd}: needs a deck\n\n${USAGE}`); return null; }
|
|
222
|
+
const path = resolve(deck);
|
|
223
|
+
if (!existsSync(path)) { console.error(`decklight design-system ${cmd}: no such deck: ${deck}`); return null; }
|
|
224
|
+
return { path, html: readFileSync(path, 'utf8') };
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** The catalogs this machine has fetched, for resolving a bare or qualified name. */
|
|
228
|
+
async function catalogs() {
|
|
229
|
+
const { configHome, loadRegistry, loadCatalog } = await import('./marketplace.mjs');
|
|
230
|
+
const out = {};
|
|
231
|
+
for (const name of Object.keys(loadRegistry(configHome()).marketplaces ?? {})) {
|
|
232
|
+
const c = loadCatalog(name);
|
|
233
|
+
if (c?.ok) out[name] = c.manifest;
|
|
234
|
+
}
|
|
235
|
+
return out;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async function addMain(args, on) {
|
|
239
|
+
const cmd = on ? 'add' : 'remove';
|
|
240
|
+
const [ref, deck] = args.filter((a) => !a.startsWith('-'));
|
|
241
|
+
if (!ref) { console.error(`decklight design-system ${cmd}: needs a design system and a deck\n\n${USAGE}`); return 1; }
|
|
242
|
+
const d = readDeckArg(cmd, deck);
|
|
243
|
+
if (!d) return 1;
|
|
244
|
+
const { MarketplaceError, resolveEntry, recordInstall, loadRegistry, configHome } = await import('./marketplace.mjs');
|
|
245
|
+
const { resolveDesignSystemRef, setDesignSystem, designSystemRefs, recordVersionIfCurrent } = await import('./design-system-refs.mjs');
|
|
246
|
+
const { refForDeck, writeFileAtomic } = { ...(await import('./theme-refs.mjs')), ...(await import('../tools/atomic-write.mjs')) };
|
|
247
|
+
try {
|
|
248
|
+
if (!on) {
|
|
249
|
+
// the deck's own spelling of the reference wins, whatever this machine calls it
|
|
250
|
+
const hit = designSystemRefs(d.html).find((r) => r.ref === ref || r.name === ref);
|
|
251
|
+
if (!hit) {
|
|
252
|
+
const has = designSystemRefs(d.html).map((r) => r.ref);
|
|
253
|
+
console.error(`decklight design-system remove: ${ref} is not referenced by ${deck}${has.length ? ` — it uses ${has.join(', ')}` : ' — it uses no design system'}`);
|
|
254
|
+
return 1;
|
|
255
|
+
}
|
|
256
|
+
const out = setDesignSystem(d.html, hit.ref, false);
|
|
257
|
+
if (out.changed) writeFileAtomic(d.path, out.html);
|
|
258
|
+
console.log(out.changed ? `dropped ${hit.ref} from ${deck} — the package stays in its marketplace` : `${hit.ref} was not referenced by ${deck}`);
|
|
259
|
+
// what it brought stays: other slides, or another design system, may use it
|
|
260
|
+
const r = resolveDesignSystemRef(hit);
|
|
261
|
+
const manifest = r.dir ? checkDir(r.dir).manifest : null;
|
|
262
|
+
if (manifest) {
|
|
263
|
+
const { planRecommended } = await import('./design-system-deps.mjs');
|
|
264
|
+
const kept = planRecommended(out.html, { manifest, local: r.local }).items.filter((it) => it.status === 'already');
|
|
265
|
+
if (kept.length) {
|
|
266
|
+
console.log(' still in the deck — the themes and fonts it brought (the deck\'s theme and font are unchanged):');
|
|
267
|
+
for (const it of kept) console.log(` ${it.kind} ${it.ref} — decklight ${it.kind} remove ${it.ref} ${deck}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return 0;
|
|
271
|
+
}
|
|
272
|
+
let qualified = ref;
|
|
273
|
+
try { qualified = resolveEntry(ref, await catalogs()).qualified; } catch (e) { if (!(e instanceof MarketplaceError)) throw e; console.error(`decklight design-system add: ${e.message}`); return 1; }
|
|
274
|
+
const r = resolveDesignSystemRef(qualified);
|
|
275
|
+
if (!r.dir) { console.error(`decklight design-system add: ${r.ref} — ${r.missing}`); return 1; }
|
|
276
|
+
// the gate first: a package that fails leaves the deck byte-for-byte as it was
|
|
277
|
+
const verdict = checkDir(r.dir);
|
|
278
|
+
if (!verdict.ok) {
|
|
279
|
+
for (const line of reportLines(r.dir, verdict)) console.error(line);
|
|
280
|
+
console.error(`\ndecklight design-system add: ${r.ref} was NOT referenced — the package fails the check above`);
|
|
281
|
+
return 1;
|
|
282
|
+
}
|
|
283
|
+
const deckRef = refForDeck(d.html, r.name, r.local, r.source ?? null);
|
|
284
|
+
const out = setDesignSystem(d.html, deckRef, true, { source: r.source ?? null, version: verdict.manifest.version });
|
|
285
|
+
// a deck that already used it and records no version takes this one —
|
|
286
|
+
// unless it still uses names a migration renamed, which `migrate` moves first
|
|
287
|
+
if (!out.changed) out.html = recordVersionIfCurrent(out.html, deckRef, verdict.manifest, dirname(d.path));
|
|
288
|
+
// its themes and fonts, in the SAME string — one write, one edit
|
|
289
|
+
const recommended = !args.includes('--no-recommended');
|
|
290
|
+
const deps = await import('./design-system-deps.mjs');
|
|
291
|
+
const plan = deps.planRecommended(out.html, { manifest: verdict.manifest, local: r.local });
|
|
292
|
+
let html = recommended ? deps.writePlan(out.html, plan) : out.html;
|
|
293
|
+
let look = deps.lookOf(html, recommended ? plan : { ...plan, items: plan.items.filter((it) => it.status === 'already' || it.status === 'stack') });
|
|
294
|
+
const decide = args.includes('--apply') ? true : args.includes('--no-apply') || !recommended ? false : null;
|
|
295
|
+
if (decide && look.differs) html = deps.applyLook(html, look);
|
|
296
|
+
if (html !== d.html) writeFileAtomic(d.path, html);
|
|
297
|
+
const commit = loadRegistry(configHome()).marketplaces?.[r.local]?.commit ?? null;
|
|
298
|
+
recordInstall({ type: 'design-system', name: r.name, marketplace: r.local, version: r.entry.version ?? null, commit });
|
|
299
|
+
if (recommended) for (const inst of deps.plannedInstalls(plan)) recordInstall(inst);
|
|
300
|
+
const v = verdict.summary.version ? ` ${verdict.summary.version}` : '';
|
|
301
|
+
const { deckDesignSystemVersions } = await import('./design-system-refs.mjs');
|
|
302
|
+
const took = deckDesignSystemVersions(html)[deckRef];
|
|
303
|
+
console.log(out.changed
|
|
304
|
+
? `${deck} now uses ${deckRef}${v} — ${verdict.summary.title}; every server links it from the marketplace on this machine`
|
|
305
|
+
: took ? `${deck} already uses ${deckRef} — written for ${took}${took !== verdict.summary.version ? `; this machine serves ${verdict.summary.version} (decklight design-system migrate ${deckRef} ${deck})` : ''}`
|
|
306
|
+
: `${deck} already uses ${deckRef} — it uses names from before ${verdict.summary.version}: decklight design-system migrate ${deckRef} ${deck}`);
|
|
307
|
+
if (recommended) for (const line of deps.planLines(plan)) console.log(line);
|
|
308
|
+
else if (plan.items.some((it) => it.status === 'add')) {
|
|
309
|
+
console.log(' --no-recommended: not added — what it recommends:');
|
|
310
|
+
for (const it of plan.items.filter((x) => x.status === 'add')) console.log(` ${it.kind} ${it.ref} — decklight ${it.kind} add ${it.ref} ${deck}`);
|
|
311
|
+
}
|
|
312
|
+
if (look.differs) {
|
|
313
|
+
const phrase = deps.lookPhrase(look, plan);
|
|
314
|
+
if (decide) console.log(`applied ${look.title}'s look — ${phrase}`);
|
|
315
|
+
else if (decide === null && process.stdin.isTTY && process.stdout.isTTY) {
|
|
316
|
+
const { createInterface } = await import('node:readline/promises');
|
|
317
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
318
|
+
const answer = (await rl.question(`Apply ${look.title}'s look — ${phrase}? [Y/n] `)).trim().toLowerCase();
|
|
319
|
+
rl.close();
|
|
320
|
+
if (answer === '' || answer === 'y' || answer === 'yes') {
|
|
321
|
+
writeFileAtomic(d.path, deps.applyLook(readFileSync(d.path, 'utf8'), look));
|
|
322
|
+
console.log(`applied — ${phrase}`);
|
|
323
|
+
} else console.log(`kept the deck's look — decklight design-system apply ${deckRef} ${deck} applies it later`);
|
|
324
|
+
} else if (decide === null) {
|
|
325
|
+
console.log(`${look.title} was drawn for ${phrase} — add --apply to switch, or: decklight design-system apply ${deckRef} ${deck}`);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
// a recommendation that could not come is a warning, never a failure: the templates work without it
|
|
329
|
+
return 0;
|
|
330
|
+
} catch (e) {
|
|
331
|
+
if (e instanceof MarketplaceError) { console.error(`decklight design-system ${cmd}: ${e.message}`); return 1; }
|
|
332
|
+
throw e;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
async function listMain(args) {
|
|
337
|
+
const [deck] = args.filter((a) => !a.startsWith('-'));
|
|
338
|
+
const { marketplaceDesignSystems, designSystemRefs, resolveDesignSystemRef, deckDesignSystemVersions } = await import('./design-system-refs.mjs');
|
|
339
|
+
const { semverCompare } = await import('./marketplace.mjs');
|
|
340
|
+
const { majorOf } = await import('../tools/design-system-migrations.mjs');
|
|
341
|
+
const { markedSources } = await import('./theme-refs.mjs');
|
|
342
|
+
if (deck) {
|
|
343
|
+
const d = readDeckArg('list', deck);
|
|
344
|
+
if (!d) return 1;
|
|
345
|
+
const refs = designSystemRefs(d.html);
|
|
346
|
+
if (!refs.length) { console.log(`${deck} uses no design system — decklight design-system add <name@marketplace> ${deck}`); return 0; }
|
|
347
|
+
const sources = markedSources(d.html);
|
|
348
|
+
// the version the DECK took, against the catalog's — never this machine's
|
|
349
|
+
// ledger, which knows nothing of a deck written elsewhere (SPEC DESIGN_SYSTEM_MIGRATIONS)
|
|
350
|
+
const took = deckDesignSystemVersions(d.html);
|
|
351
|
+
for (const ref of refs) {
|
|
352
|
+
const r = resolveDesignSystemRef(ref, undefined, { source: sources[ref.marketplace] ?? null });
|
|
353
|
+
const had = took[ref.ref] ?? null;
|
|
354
|
+
const now = r.entry?.version ?? null;
|
|
355
|
+
const newer = had && now && semverCompare(now, had) > 0;
|
|
356
|
+
const major = newer && majorOf(had) !== null && majorOf(had) < majorOf(now);
|
|
357
|
+
const ver = newer ? ` ${had} → ${now}${major ? ' (major: migrate)' : ''}` : had ? ` ${had}` : now ? ` ${now} (the deck records no version)` : '';
|
|
358
|
+
console.log(`${ref.ref}${ver}${r.missing ? ` — missing: ${r.missing}` : r.title ? ` — ${r.title}` : ''}`);
|
|
359
|
+
}
|
|
360
|
+
return 0;
|
|
361
|
+
}
|
|
362
|
+
const { systems, stale, unfetched } = marketplaceDesignSystems();
|
|
363
|
+
if (!systems.length) console.log('no registered marketplace offers a design system');
|
|
364
|
+
for (const s of systems) {
|
|
365
|
+
console.log(`${s.qualified}${s.version ? ` ${s.version}` : ''}${s.description ? ` — ${s.description}` : ''}${s.missing ? ` (${s.missing})` : ''}`);
|
|
366
|
+
}
|
|
367
|
+
for (const m of unfetched) console.log(` ${m} has not been fetched yet — decklight marketplace update ${m}`);
|
|
368
|
+
for (const m of stale) console.log(` ${m}'s cached catalog could not be read — decklight marketplace update ${m}`);
|
|
369
|
+
return 0;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
async function templatesMain(args) {
|
|
373
|
+
const [ref] = args.filter((a) => !a.startsWith('-'));
|
|
374
|
+
if (!ref) { console.error(`decklight design-system templates: needs a design system (name@marketplace)\n\n${USAGE}`); return 1; }
|
|
375
|
+
const { resolveEntry, MarketplaceError } = await import('./marketplace.mjs');
|
|
376
|
+
const { resolveDesignSystemRef, packageVerdict } = await import('./design-system-refs.mjs');
|
|
377
|
+
let qualified = ref;
|
|
378
|
+
try { qualified = resolveEntry(ref, await catalogs()).qualified; } catch (e) { if (!(e instanceof MarketplaceError)) throw e; console.error(`decklight design-system templates: ${e.message}`); return 1; }
|
|
379
|
+
const r = resolveDesignSystemRef(qualified);
|
|
380
|
+
if (!r.dir) { console.error(`decklight design-system templates: ${r.ref} — ${r.missing}`); return 1; }
|
|
381
|
+
const v = packageVerdict(r.dir);
|
|
382
|
+
if (!v.ok) { console.error(`decklight design-system templates: ${r.ref} — ${v.why}`); return 1; }
|
|
383
|
+
console.log(`${r.ref} — ${v.manifest.title} ${v.manifest.version}: ${v.summary.templates.length} template${v.summary.templates.length === 1 ? '' : 's'}`);
|
|
384
|
+
for (const l of v.summary.templates) {
|
|
385
|
+
console.log(` ${v.manifest.name}/${l.id}${l.title && l.title !== l.id ? ` — ${l.title}` : ''}`);
|
|
386
|
+
for (const slot of l.slots) {
|
|
387
|
+
console.log(` ${slot.name}${slot.required ? ' (required)' : ''}${slot.default ? ' (takes unslotted content)' : ''}${slot.hint ? ` — ${slot.hint}` : ''}`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
console.log(`\n a slide: <section data-template="${v.manifest.name}/<template>"> with children carrying data-slot="<slot>"`);
|
|
391
|
+
return 0;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* `design-system apply`: the look a design system the deck already uses was
|
|
396
|
+
* drawn for — its recommended theme and font, bringing any that are missing,
|
|
397
|
+
* in one edit. Idempotent: a deck already wearing it is left as it is.
|
|
398
|
+
*/
|
|
399
|
+
async function applyMain(args) {
|
|
400
|
+
const [ref, deck] = args.filter((a) => !a.startsWith('-'));
|
|
401
|
+
if (!ref) { console.error(`decklight design-system apply: needs a design system and a deck\n\n${USAGE}`); return 1; }
|
|
402
|
+
const d = readDeckArg('apply', deck);
|
|
403
|
+
if (!d) return 1;
|
|
404
|
+
const { designSystemRefs, resolveDesignSystemRef, recordVersionIfCurrent } = await import('./design-system-refs.mjs');
|
|
405
|
+
const { markedSources } = await import('./theme-refs.mjs');
|
|
406
|
+
const { writeFileAtomic } = await import('../tools/atomic-write.mjs');
|
|
407
|
+
const { recordInstall } = await import('./marketplace.mjs');
|
|
408
|
+
const hit = designSystemRefs(d.html).find((r) => r.ref === ref || r.name === ref);
|
|
409
|
+
if (!hit) { console.error(`decklight design-system apply: ${deck} does not use ${ref} — decklight design-system add ${ref} ${deck}`); return 1; }
|
|
410
|
+
const r = resolveDesignSystemRef(hit, undefined, { source: markedSources(d.html)[hit.marketplace] ?? null });
|
|
411
|
+
if (!r.dir) { console.error(`decklight design-system apply: ${hit.ref} — ${r.missing}`); return 1; }
|
|
412
|
+
const verdict = checkDir(r.dir);
|
|
413
|
+
if (!verdict.ok) { console.error(`decklight design-system apply: ${hit.ref} no longer passes its check — decklight design-system gate ${r.dir}`); return 1; }
|
|
414
|
+
const deps = await import('./design-system-deps.mjs');
|
|
415
|
+
const plan = deps.planRecommended(d.html, { manifest: verdict.manifest, local: r.local });
|
|
416
|
+
let html = deps.writePlan(recordVersionIfCurrent(d.html, hit.ref, verdict.manifest, dirname(d.path)), plan);
|
|
417
|
+
const look = deps.lookOf(html, plan);
|
|
418
|
+
// recorded even when the deck is left as it is: one already there may be
|
|
419
|
+
// one the catalog has a newer version of, and the ledger is where that goes
|
|
420
|
+
for (const inst of deps.plannedInstalls(plan)) recordInstall(inst);
|
|
421
|
+
// "already there" is noise here, unless it just recorded a newer version
|
|
422
|
+
const lines = deps.planLines({ ...plan, items: plan.items.filter((it) => it.status !== 'already' || it.recorded) });
|
|
423
|
+
if (!look.theme && !look.font) { console.log(`${hit.ref} recommends no theme or font this deck can apply`); return 0; }
|
|
424
|
+
if (!look.differs && html === d.html) {
|
|
425
|
+
for (const line of lines) console.log(line);
|
|
426
|
+
console.log(`${deck} already wears ${look.title}'s look`);
|
|
427
|
+
return 0;
|
|
428
|
+
}
|
|
429
|
+
html = deps.applyLook(html, look);
|
|
430
|
+
writeFileAtomic(d.path, html);
|
|
431
|
+
for (const line of lines) console.log(line);
|
|
432
|
+
console.log(look.differs ? `applied ${look.title}'s look — ${deps.lookPhrase(look, plan)}` : `${deck} already wore ${look.title}'s look`);
|
|
433
|
+
return 0;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* `design-system migrate` (SPEC DESIGN_SYSTEM_MIGRATIONS): the renames the
|
|
438
|
+
* package declares since the version the deck records, applied as whole
|
|
439
|
+
* names to the deck and to the stylesheets it links beside it, and the
|
|
440
|
+
* recorded version moved to the one this machine serves. Every file is
|
|
441
|
+
* renamed in memory before any is written. What a rename cannot decide — a
|
|
442
|
+
* name removed with no successor — is the migration's skill's, and said.
|
|
443
|
+
*/
|
|
444
|
+
async function migrateMain(args) {
|
|
445
|
+
const [ref, deck] = args.filter((a) => !a.startsWith('-'));
|
|
446
|
+
if (!ref) { console.error(`decklight design-system migrate: needs a design system and a deck\n\n${USAGE}`); return 1; }
|
|
447
|
+
const d = readDeckArg('migrate', deck);
|
|
448
|
+
if (!d) return 1;
|
|
449
|
+
const { planMigration, migrationLines } = await import('./design-system-refs.mjs');
|
|
450
|
+
const { writeFileAtomic } = await import('../tools/atomic-write.mjs');
|
|
451
|
+
const plan = planMigration(d.html, dirname(d.path), ref);
|
|
452
|
+
if (plan.error) { console.error(`decklight design-system migrate: ${plan.error.replace(/^the deck/, deck)}`); return 1; }
|
|
453
|
+
if (!plan.changed) { console.log(`${deck} is already on ${plan.ref} ${plan.version} — nothing to migrate`); return 0; }
|
|
454
|
+
for (const x of plan.sheets) writeFileAtomic(x.path, x.text);
|
|
455
|
+
if (plan.html !== d.html) writeFileAtomic(d.path, plan.html);
|
|
456
|
+
const { placedSkill, placeSkill, skillPlaces, skillPlaceAnswer, skillPlaceQuestion } = await import('./skills.mjs');
|
|
457
|
+
const placed = (s) => placedSkill(s);
|
|
458
|
+
for (const line of migrationLines(plan, deck, { placed })) console.log(line);
|
|
459
|
+
// On a terminal, a skill the agent does not have yet is offered, every
|
|
460
|
+
// project first. An agent running this (the edit server's Migrate) has no
|
|
461
|
+
// TTY, and its server asked the author before it started (#893).
|
|
462
|
+
const missing = plan.status.skills.filter((s) => !placed(s));
|
|
463
|
+
if (missing.length && process.stdin.isTTY && process.stdout.isTTY) {
|
|
464
|
+
const { createInterface } = await import('node:readline/promises');
|
|
465
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
466
|
+
try {
|
|
467
|
+
for (const s of missing) {
|
|
468
|
+
const where = skillPlaceAnswer(await rl.question(skillPlaceQuestion(s, skillPlaces(s))));
|
|
469
|
+
if (!where) continue;
|
|
470
|
+
try {
|
|
471
|
+
const { lines } = await placeSkill(s, { global: where === 'global', ref: plan.marketplace ? `${s}@${plan.marketplace}` : s });
|
|
472
|
+
for (const line of lines) console.log(` ${line}`);
|
|
473
|
+
} catch (e) { console.error(` could not install ${s}: ${e.message}`); }
|
|
474
|
+
}
|
|
475
|
+
} finally { rl.close(); }
|
|
476
|
+
}
|
|
477
|
+
return 0;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
export async function designSystemMain(args = []) {
|
|
481
|
+
const sub = args[0];
|
|
482
|
+
if (!sub || sub === '--help' || sub === '-h' || sub === 'help') { console.log(USAGE); return sub ? 0 : 1; }
|
|
483
|
+
const rest = args.slice(1);
|
|
484
|
+
if (rest.includes('--help') || rest.includes('-h')) { console.log(USAGE); return 0; }
|
|
485
|
+
argReader(rest);
|
|
486
|
+
if (sub === 'gate' || sub === 'check') return checkMain(rest); // `check` still answers, unadvertised: a catalog's CI may run it
|
|
487
|
+
if (sub === 'add') return addMain(rest, true);
|
|
488
|
+
if (sub === 'remove') return addMain(rest, false);
|
|
489
|
+
if (sub === 'list') return listMain(rest);
|
|
490
|
+
if (sub === 'templates') return templatesMain(rest);
|
|
491
|
+
if (sub === 'apply') return applyMain(rest);
|
|
492
|
+
if (sub === 'migrate') return migrateMain(rest);
|
|
493
|
+
console.error(`decklight design-system: unknown subcommand "${sub}" — add, remove, apply, migrate, list, templates, check\n\n${USAGE}`);
|
|
494
|
+
return 1;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if (isMain(import.meta.url)) process.exit(await designSystemMain(process.argv.slice(2)));
|
package/cli/doctor.mjs
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* decklight doctor — what this machine can do, and how to make it do the rest.
|
|
6
|
+
*
|
|
7
|
+
* Every optional capability used to announce itself only by failing: you
|
|
8
|
+
* learned Chrome was missing when `pdf` said so, node-pty when `cast` refused,
|
|
9
|
+
* ffmpeg after `video` had rendered every frame. This asks all of it up front,
|
|
10
|
+
* and for each thing missing says two things the refusals never did together —
|
|
11
|
+
* which commands it unlocks, and the one line that installs it.
|
|
12
|
+
*
|
|
13
|
+
* It is an inventory, like the ingredients label: no score, no verdict, exit 0.
|
|
14
|
+
* A machine with none of the optional pieces is a perfectly good machine for
|
|
15
|
+
* writing and presenting a deck, and the output should read that way.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { findChrome } from '../tools/chrome.mjs';
|
|
19
|
+
import { detectAgents, whichBin } from './agents.mjs';
|
|
20
|
+
import { resolves } from './report-bug.mjs';
|
|
21
|
+
import { loadLipsyncConfig, videoSetup, SETUP_HINT } from '../tools/lipsync-config.mjs';
|
|
22
|
+
|
|
23
|
+
/** The package manager's install line for `name`, per platform. */
|
|
24
|
+
export function installLine(name, platform = process.platform) {
|
|
25
|
+
if (platform === 'darwin') return `brew install ${name}`;
|
|
26
|
+
if (platform === 'win32') return `winget install ${name}`;
|
|
27
|
+
return `sudo apt install ${name}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The rows, pure over what was found. Every input is injectable so the table
|
|
32
|
+
* for a machine with nothing on it can be checked from a machine with
|
|
33
|
+
* everything, and the other way round.
|
|
34
|
+
*/
|
|
35
|
+
export function diagnose({
|
|
36
|
+
platform = process.platform,
|
|
37
|
+
which = (bin) => whichBin(bin),
|
|
38
|
+
has = resolves,
|
|
39
|
+
chrome = findChrome(),
|
|
40
|
+
agents = detectAgents().map((a) => a.label),
|
|
41
|
+
lipsync = loadLipsyncConfig(),
|
|
42
|
+
videoCheck = (cfg) => videoSetup(cfg),
|
|
43
|
+
} = {}) {
|
|
44
|
+
const bin = (name) => which(name);
|
|
45
|
+
const rows = [];
|
|
46
|
+
const row = (label, found, unlocks, fix) => rows.push({ label, ok: !!found, found: found || null, unlocks, fix });
|
|
47
|
+
|
|
48
|
+
row('Chrome', chrome, 'pdf · pptx · video · screenshots · the headless render checks',
|
|
49
|
+
'install Google Chrome or Chromium, or point $CHROME at one');
|
|
50
|
+
const ffmpeg = bin('ffmpeg'), ffprobe = bin('ffprobe');
|
|
51
|
+
row('ffmpeg', ffmpeg && ffprobe ? ffmpeg : null, 'video (a narrated mp4 of the deck)',
|
|
52
|
+
installLine('ffmpeg', platform));
|
|
53
|
+
row('git', bin('git'), 'snapshots and commits in write mode · history · restore · publish · review submit',
|
|
54
|
+
installLine('git', platform));
|
|
55
|
+
row('gh', bin('gh'), "init's GitHub remote offer · review submit --pr",
|
|
56
|
+
installLine('gh', platform));
|
|
57
|
+
row('node-pty + js-yaml', has('node-pty') && has('js-yaml') ? 'installed' : null,
|
|
58
|
+
'cast · refresh (recording a terminal in a real PTY)',
|
|
59
|
+
'npm install -g decklight --include=optional (node-pty builds a native module: needs a C toolchain)');
|
|
60
|
+
row('sigstore', has('sigstore') ? 'installed' : null, 'bundle --sign · publish (signed by default)',
|
|
61
|
+
'npm install -g decklight --include=optional');
|
|
62
|
+
row('an AI agent', agents.length ? agents.join(', ') : null,
|
|
63
|
+
'A in write mode (ask an agent to edit the deck) · agent-written commit subjects',
|
|
64
|
+
'install one: claude (npm i -g @anthropic-ai/claude-code), codex, gemini, copilot, aider …');
|
|
65
|
+
const local = platform === 'darwin' ? 'say (built in)' : platform === 'win32' ? 'Windows speech (built in)' : null;
|
|
66
|
+
row('a local voice', local ?? (bin('piper') ? 'piper' : null), 'narration with no account and no network',
|
|
67
|
+
'uv tool install piper-tts (or a cloud engine: decklight setup voice)');
|
|
68
|
+
row('rhubarb', bin('rhubarb'), 'lipsync (mouth shapes for the talking-head character)',
|
|
69
|
+
'https://github.com/DanielSWolf/rhubarb-lip-sync/releases — put the binary on PATH');
|
|
70
|
+
// Neural video is not a binary on PATH but a checkout, its checkpoint, the
|
|
71
|
+
// Python that has its packages, and a portrait — what `lipsync --save`
|
|
72
|
+
// remembers (tools/lipsync-config.mjs). Read the same way the bridge reads it.
|
|
73
|
+
const video = lipsync && (lipsync.wav2lipDir || lipsync.sadtalkerDir) ? videoCheck(lipsync) : null;
|
|
74
|
+
row('neural video', video?.engines.length ? `${video.engines.join(', ')} · ${(lipsync.portraits ?? []).length} portrait(s)` : null,
|
|
75
|
+
'the talking-head character with your own face (Wav2Lip or SadTalker, offline)',
|
|
76
|
+
video ? video.problems.join(' · ') || 'set up, but not ready' : `clone Wav2Lip, then: ${SETUP_HINT}`);
|
|
77
|
+
return rows;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The table, as lines. Marks are text, so a log and a terminal read the same. */
|
|
81
|
+
export function formatDoctor(rows, { color = false } = {}) {
|
|
82
|
+
const GREEN = '\x1b[32m', DIM = '\x1b[2m', RESET = '\x1b[0m';
|
|
83
|
+
const paint = (s, c) => (color ? `${c}${s}${RESET}` : s);
|
|
84
|
+
const width = Math.max(...rows.map((r) => r.label.length)) + 2;
|
|
85
|
+
const lines = ['decklight doctor — what this machine can do', ''];
|
|
86
|
+
for (const r of rows) {
|
|
87
|
+
const mark = r.ok ? paint('ok', GREEN) : paint('--', DIM);
|
|
88
|
+
lines.push(` ${mark} ${r.label.padEnd(width)}${r.ok ? r.found : 'not found'}`);
|
|
89
|
+
lines.push(` ${paint(r.unlocks, DIM)}`);
|
|
90
|
+
if (!r.ok) lines.push(` ${paint('→ ' + r.fix, DIM)}`);
|
|
91
|
+
}
|
|
92
|
+
const missing = rows.filter((r) => !r.ok).length;
|
|
93
|
+
lines.push('');
|
|
94
|
+
lines.push(missing
|
|
95
|
+
? `${rows.length - missing} of ${rows.length} present. Writing and presenting a deck needs none of the missing ones.`
|
|
96
|
+
: `everything present — every command has what it needs`);
|
|
97
|
+
return lines;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const HELP = `decklight doctor — what this machine can do
|
|
101
|
+
|
|
102
|
+
Usage:
|
|
103
|
+
decklight doctor
|
|
104
|
+
|
|
105
|
+
Checks for Chrome, ffmpeg, git, gh, the optional npm dependencies, a coding
|
|
106
|
+
agent, a local voice and rhubarb, and for each one missing says which commands
|
|
107
|
+
it unlocks and the line that installs it. Reads PATH and the filesystem only:
|
|
108
|
+
no network, nothing written, exit 0 either way.`;
|
|
109
|
+
|
|
110
|
+
export async function doctorMain(argv = process.argv.slice(2)) {
|
|
111
|
+
if (argv.includes('--help') || argv.includes('-h')) { console.log(HELP); return 0; }
|
|
112
|
+
const color = !!process.stdout.isTTY && !process.env.NO_COLOR;
|
|
113
|
+
for (const line of formatDoctor(diagnose(), { color })) console.log(line);
|
|
114
|
+
return 0;
|
|
115
|
+
}
|