decklight 0.2.0 → 0.3.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.
Files changed (137) hide show
  1. package/README.md +69 -31
  2. package/SPEC.md +855 -80
  3. package/cli/agents.mjs +113 -9
  4. package/cli/associate.mjs +279 -0
  5. package/cli/audit.mjs +424 -0
  6. package/cli/bundle.mjs +174 -46
  7. package/cli/deckfile.mjs +233 -0
  8. package/cli/decklight.mjs +201 -8
  9. package/cli/dev.mjs +244 -55
  10. package/cli/edit.mjs +564 -107
  11. package/cli/extension.mjs +108 -0
  12. package/cli/git.mjs +141 -0
  13. package/cli/import.mjs +398 -0
  14. package/cli/init.mjs +421 -116
  15. package/cli/loader.mjs +263 -0
  16. package/cli/marketplace.mjs +730 -0
  17. package/cli/pdf.mjs +156 -0
  18. package/cli/pkg.mjs +69 -0
  19. package/cli/plugin.mjs +646 -0
  20. package/cli/port-conflict.mjs +94 -0
  21. package/cli/present.mjs +560 -0
  22. package/cli/publish.mjs +342 -0
  23. package/cli/qr.mjs +334 -0
  24. package/cli/rec.mjs +5 -8
  25. package/cli/remote.mjs +149 -0
  26. package/cli/report-bug.mjs +97 -0
  27. package/cli/restore.mjs +174 -0
  28. package/cli/serve.mjs +247 -0
  29. package/cli/sign.mjs +216 -0
  30. package/cli/skill-content.mjs +222 -0
  31. package/cli/skills.mjs +338 -0
  32. package/cli/supervise.mjs +57 -0
  33. package/cli/theme.mjs +201 -0
  34. package/cli/units.mjs +488 -0
  35. package/cli/upgrade.mjs +250 -0
  36. package/cli/util.mjs +90 -0
  37. package/cli/wizard.mjs +432 -0
  38. package/cli/zip.mjs +121 -0
  39. package/dist/decklight.css +716 -29
  40. package/dist/decklight.js +198 -125
  41. package/dist/decklight.js.map +4 -4
  42. package/docs/architecture.svg +1 -1
  43. package/package.json +5 -4
  44. package/themes/README.md +6 -4
  45. package/themes/aurora.css +1 -1
  46. package/themes/berry.css +1 -1
  47. package/themes/carbon.css +1 -1
  48. package/themes/citrus.css +1 -1
  49. package/themes/coastal.css +1 -1
  50. package/themes/cosmos.css +1 -1
  51. package/themes/dune.css +1 -1
  52. package/themes/eclipse.css +1 -1
  53. package/themes/ember.css +1 -1
  54. package/themes/fjord.css +1 -1
  55. package/themes/gallery.html +3 -11
  56. package/themes/glacier.css +1 -1
  57. package/themes/graphite.css +1 -1
  58. package/themes/harvest.css +1 -1
  59. package/themes/ibm-modern.css +1 -1
  60. package/themes/ink.css +1 -1
  61. package/themes/latte.css +1 -1
  62. package/themes/linen.css +1 -1
  63. package/themes/meadow.css +1 -1
  64. package/themes/metropolis.css +1 -1
  65. package/themes/midnight.css +1 -1
  66. package/themes/mint.css +1 -1
  67. package/themes/moss.css +1 -1
  68. package/themes/obsidian.css +1 -1
  69. package/themes/orchid.css +1 -1
  70. package/themes/packs.json +2 -30
  71. package/themes/paper.css +1 -1
  72. package/themes/peony.css +1 -1
  73. package/themes/porcelain.css +1 -1
  74. package/themes/reveal-beige.css +1 -1
  75. package/themes/reveal-black.css +1 -1
  76. package/themes/reveal-blood.css +1 -1
  77. package/themes/reveal-dracula.css +1 -1
  78. package/themes/reveal-league.css +1 -1
  79. package/themes/reveal-moon.css +1 -1
  80. package/themes/reveal-night.css +1 -1
  81. package/themes/reveal-serif.css +1 -1
  82. package/themes/reveal-simple.css +1 -1
  83. package/themes/reveal-sky.css +1 -1
  84. package/themes/reveal-solarized.css +1 -1
  85. package/themes/reveal-white.css +1 -1
  86. package/themes/sepia.css +1 -1
  87. package/themes/seriph.css +1 -1
  88. package/themes/slate.css +1 -1
  89. package/themes/storm.css +1 -1
  90. package/themes/synthwave.css +1 -1
  91. package/themes/velvet.css +1 -1
  92. package/themes/yamabuki.css +1 -1
  93. package/tools/args.mjs +32 -0
  94. package/tools/bridge.mjs +30 -0
  95. package/tools/chrome.mjs +11 -2
  96. package/tools/color.mjs +110 -0
  97. package/tools/deck-html.mjs +138 -0
  98. package/tools/elevenlabs-tts.mjs +248 -0
  99. package/tools/escape.mjs +40 -0
  100. package/tools/extension-check-runner.mjs +41 -0
  101. package/tools/extension-check.mjs +266 -0
  102. package/tools/gemini-tts.mjs +25 -3
  103. package/tools/lipsync-engines.mjs +81 -0
  104. package/tools/lipsync-server.mjs +78 -37
  105. package/tools/lipsync.mjs +36 -21
  106. package/tools/local-voice.mjs +209 -0
  107. package/tools/ooxml.mjs +151 -0
  108. package/tools/pptx.mjs +320 -0
  109. package/tools/publish-site-voices.mjs +2 -1
  110. package/tools/publish-targets.mjs +143 -0
  111. package/tools/publish-voices.mjs +230 -0
  112. package/tools/shot.mjs +91 -47
  113. package/tools/theme-check.mjs +139 -0
  114. package/tools/tts-engines.mjs +270 -41
  115. package/tools/tts-setup.mjs +257 -0
  116. package/tools/veo.mjs +204 -0
  117. package/tools/video.mjs +316 -0
  118. package/tools/voiceover-server.mjs +163 -54
  119. package/tools/voiceover.mjs +24 -7
  120. package/tools/zip.mjs +143 -0
  121. package/docs/demo.svg +0 -124
  122. package/themes/aliens.css +0 -87
  123. package/themes/apple2.css +0 -129
  124. package/themes/blade-runner.css +0 -86
  125. package/themes/c64.css +0 -88
  126. package/themes/friends.css +0 -85
  127. package/themes/gameboy.css +0 -121
  128. package/themes/genesis.css +0 -87
  129. package/themes/godfather.css +0 -85
  130. package/themes/ibm-oldschool.css +0 -87
  131. package/themes/miami-vice.css +0 -87
  132. package/themes/pulp-fiction.css +0 -87
  133. package/themes/severance.css +0 -85
  134. package/themes/snes.css +0 -85
  135. package/themes/star-wars.css +0 -88
  136. package/themes/stranger-things.css +0 -87
  137. package/themes/terminator.css +0 -87
package/cli/loader.mjs ADDED
@@ -0,0 +1,263 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * The loader (MARKETPLACE.md `EXTENSIONS#LOADER`) — runs an installed
6
+ * build-time transform against a deck's own source, an installed import
7
+ * adapter against a source file's bytes (`EXTENSIONS#ADAPTEREXEC`), or an
8
+ * installed speech engine's factory (`ENGINES#TTS`).
9
+ *
10
+ * All three are Node code, installed by `cli/units.mjs` like any other unit,
11
+ * but running one is a different capability from installing one (SPEC
12
+ * `EXTENSIONS_TRANSFORMS`, `EXTENSIONS_ADAPTERS`, `ENGINE_UNITS`): dynamic
13
+ * `import()`, in the SAME process as `bundle`/`import`/the bridge — no
14
+ * subprocess, no VM sandbox. That is not a gap; MARKETPLACE.md `EXTENSIONS`
15
+ * already decided the trust model for build-time code (the installer is the
16
+ * risk-bearer, same as Claude's own plugin marketplace), so isolating any of
17
+ * them from the process that invoked it would defend against a threat this
18
+ * design already accepted.
19
+ *
20
+ * The engine is the odd one of the three and is kept deliberately separate
21
+ * below rather than folded into `runCodeModuleAt`: a transform and an adapter
22
+ * are both `(input, opts) → string`, while an engine is a FACTORY whose
23
+ * return value is an object the bridge then calls repeatedly. Sharing a
24
+ * runner would have meant a `kind` flag choosing between two unrelated
25
+ * validations, which is two functions wearing one name.
26
+ *
27
+ * `apiVersion` compat is a LOADER question, not an install-time one (SPEC
28
+ * `UNIT_COMPAT`): the shape check in `marketplace.mjs` only proves the field
29
+ * is a positive integer, never against what this decklight implements — a
30
+ * catalog may be written against a newer contract than the one reading it.
31
+ * Whether a given unit can actually RUN here is settled the moment it is
32
+ * about to be, by comparing its declared `apiVersion` against that unit
33
+ * KIND's own ceiling — `TRANSFORM_API_VERSION` for a transform,
34
+ * `IMPORTER_API_VERSION` for an adapter, `ENGINE_API_VERSION` for an engine,
35
+ * three separate counters because the three calling conventions move on their
36
+ * own schedules (SPEC `EXTENSIONS_ADAPTERS`, `ENGINE_UNITS`). That number is
37
+ * not persisted onto the installed
38
+ * `.mjs` file — there is nowhere on a single file to put it — so it is
39
+ * re-read from the catalog cache, exactly the way `adapterFor` re-reads an
40
+ * importer's `extensions` rather than duplicating it into the library.
41
+ */
42
+
43
+ import { pathToFileURL } from 'node:url';
44
+ import { join } from 'node:path';
45
+ import { findUnit, catalogEntriesOfType, UNIT_TYPES } from './units.mjs';
46
+ import {
47
+ configHome, TRANSFORM_API_VERSION, IMPORTER_API_VERSION,
48
+ ENGINE_API_VERSION, ENGINE_CAPABILITIES,
49
+ } from './marketplace.mjs';
50
+
51
+ /** A failure with a message for a human — always names the unit, never a stack. */
52
+ export class LoaderError extends Error {}
53
+
54
+ /**
55
+ * Find an installed unit of `type` and check its cached `apiVersion` against
56
+ * `ceiling`, naming `type` in every refusal — the shared half of
57
+ * `resolveTransform`/`resolveImporter`.
58
+ *
59
+ * `unit.path` is a single `.mjs` file for a `single`-shaped type (a
60
+ * transform) but a DIRECTORY for a multi-`files` one (an importer, whose
61
+ * install seam also fetches an optional `README`, say) — `UNIT_TYPES` is
62
+ * what tells the two apart, so `path` here is always the actual module to
63
+ * `import()`, never a directory dynamic `import()` refuses outright.
64
+ */
65
+ function resolveCodeUnit(type, name, ceiling, home) {
66
+ const unit = findUnit(type, name, home);
67
+ if (!unit) {
68
+ throw new LoaderError(`no ${type} "${name}" installed`
69
+ + ` (decklight ${type} add ${name}, decklight ${type} list)`);
70
+ }
71
+ const t = UNIT_TYPES[type];
72
+ const modulePath = t.single ? unit.path : join(unit.path, t.files[0]);
73
+ const entry = catalogEntriesOfType(type, home).find((e) => e.name === name);
74
+ if (entry && entry.apiVersion > ceiling) {
75
+ throw new LoaderError(`${type} "${name}" needs apiVersion ${entry.apiVersion},`
76
+ + ` this decklight only implements up to ${ceiling} — upgrade decklight to use it`);
77
+ }
78
+ return { name, path: modulePath, checked: !!entry };
79
+ }
80
+
81
+ /**
82
+ * Find an installed transform and check what the catalog cache says about
83
+ * its `apiVersion`. Returns `{ name, path }`; throws `LoaderError` when the
84
+ * transform is not installed, or when a cached catalog entry names an
85
+ * `apiVersion` this decklight does not implement.
86
+ *
87
+ * A transform with no matching cached catalog entry (the marketplace it came
88
+ * from was since removed, or it was dropped into the library by hand) has no
89
+ * `apiVersion` to check against — it is still run, since refusing an
90
+ * explicitly-named, already-installed transform over metadata that merely
91
+ * went missing would be a surprise this design's trust model does not ask
92
+ * for; `runTransform` reports that in `checked` for the caller to note.
93
+ */
94
+ export function resolveTransform(name, home = configHome()) {
95
+ return resolveCodeUnit('transform', name, TRANSFORM_API_VERSION, home);
96
+ }
97
+
98
+ /** The same resolution as `resolveTransform`, for an installed import adapter
99
+ * against `IMPORTER_API_VERSION` (SPEC `EXTENSIONS_ADAPTERS`). */
100
+ export function resolveImporter(name, home = configHome()) {
101
+ return resolveCodeUnit('importer', name, IMPORTER_API_VERSION, home);
102
+ }
103
+
104
+ /**
105
+ * The same resolution again for an installed speech engine, against
106
+ * `ENGINE_API_VERSION` — plus the one check the other two kinds have no
107
+ * equivalent of: `capability`.
108
+ *
109
+ * A catalog may legitimately declare an engine for an affordance this
110
+ * decklight does not run yet (`marketplace.mjs` accepts the field on shape
111
+ * alone, deliberately), so the refusal has to happen here, where it can name
112
+ * the single engine and what it claimed rather than invalidating the catalog
113
+ * it arrived in. An engine with no cached entry is run unchecked, exactly as
114
+ * a transform in that position is.
115
+ */
116
+ export function resolveEngine(name, home = configHome()) {
117
+ const unit = resolveCodeUnit('engine', name, ENGINE_API_VERSION, home);
118
+ const entry = catalogEntriesOfType('engine', home).find((e) => e.name === name);
119
+ if (entry?.capability && !ENGINE_CAPABILITIES.includes(entry.capability)) {
120
+ throw new LoaderError(`engine "${name}" is a ${entry.capability} engine,`
121
+ + ` and this decklight only runs: ${ENGINE_CAPABILITIES.join(', ')}`);
122
+ }
123
+ return unit;
124
+ }
125
+
126
+ /**
127
+ * Run a code-carrying unit's module at a given path against `input`,
128
+ * collapsing every failure shape into one clean, `label`-naming
129
+ * `LoaderError` — no default export, an export that is not a function, a
130
+ * thrown/rejected value, a non-string return, never a raw stack trace. The
131
+ * shared half of `runTransformAt`/`runImporterAt`, since the mechanics (a
132
+ * default-export function taking `(input, opts)` and returning a string) are
133
+ * identical whether `input` is HTML or a source file's bytes — only the
134
+ * vocabulary a refusal names differs.
135
+ */
136
+ async function runCodeModuleAt(modulePath, input, label, { kind, hint }) {
137
+ let mod;
138
+ try {
139
+ mod = await import(pathToFileURL(modulePath).href);
140
+ } catch (e) {
141
+ throw new LoaderError(`${kind} "${label}" failed to load — ${e.message}`);
142
+ }
143
+ if (typeof mod.default !== 'function') {
144
+ throw new LoaderError(`${kind} "${label}" has no default export function (${hint})`);
145
+ }
146
+ let out;
147
+ try {
148
+ out = await mod.default(input, {});
149
+ } catch (e) {
150
+ throw new LoaderError(`${kind} "${label}" threw: ${e.message}`);
151
+ }
152
+ if (typeof out !== 'string') {
153
+ throw new LoaderError(`${kind} "${label}" must return a string (returned ${typeof out})`);
154
+ }
155
+ return out;
156
+ }
157
+
158
+ /**
159
+ * Run a transform module at a given path against `html` (SPEC
160
+ * `EXTENSIONS_TRANSFORMS`). Split out from `runTransform` so
161
+ * `tools/extension-check.mjs` can run a bare FILE the same way, without an
162
+ * installed unit or a catalog behind it.
163
+ */
164
+ export async function runTransformAt(modulePath, html, label) {
165
+ return runCodeModuleAt(modulePath, html, label, {
166
+ kind: 'transform',
167
+ hint: 'SPEC EXTENSIONS_TRANSFORMS: export default async function transform(html, opts)',
168
+ });
169
+ }
170
+
171
+ /** Run an import adapter module at a given path against `bytes` (SPEC
172
+ * `EXTENSIONS_ADAPTERS`) — the adapter half of `runTransformAt`. */
173
+ export async function runImporterAt(modulePath, bytes, label) {
174
+ return runCodeModuleAt(modulePath, bytes, label, {
175
+ kind: 'importer',
176
+ hint: 'SPEC EXTENSIONS_ADAPTERS: export default async function importAdapter(bytes, opts)',
177
+ });
178
+ }
179
+
180
+ /**
181
+ * Run one installed transform against `html` (SPEC `EXTENSIONS_TRANSFORMS`).
182
+ * `opts` is reserved and empty in v1 — nothing populates it yet.
183
+ */
184
+ export async function runTransform(name, html, home = configHome()) {
185
+ const unit = resolveTransform(name, home);
186
+ const out = await runTransformAt(unit.path, html, name);
187
+ return { html: out, checked: unit.checked };
188
+ }
189
+
190
+ /**
191
+ * Run one installed import adapter against a source file's `bytes` (SPEC
192
+ * `EXTENSIONS_ADAPTERS`) — the adapter half of `runTransform`, called from
193
+ * `cli/import.mjs` once `sourceKind` finds no built-in reader for a file but
194
+ * a cached catalog entry names an installed adapter for its extension.
195
+ */
196
+ export async function runImporter(name, bytes, home = configHome()) {
197
+ const unit = resolveImporter(name, home);
198
+ const html = await runImporterAt(unit.path, bytes, name);
199
+ return { html, checked: unit.checked };
200
+ }
201
+
202
+ /**
203
+ * Load a speech-engine module at a given path and call its factory (SPEC
204
+ * `ENGINE_UNITS`). Split from `loadEngine` the way `runTransformAt` is split
205
+ * from `runTransform`, so a bare file can be checked without an install
206
+ * behind it.
207
+ *
208
+ * Unlike a transform, what comes back is not a string but the object the
209
+ * bridge will SPEAK with, so the shape is checked here, once, at load — the
210
+ * alternative is a missing `synth` surfacing as a crash on the first sentence
211
+ * of a talk. Only the fields the bridge actually requires are mandatory:
212
+ * `name`, a `voices` array, and a callable `synth`. `stylable` defaults to
213
+ * false because a plugin that has no delivery-instruction channel and forgets
214
+ * to say so must not have the tone step offered for it (the picker skips it
215
+ * on `stylable: false`, and a roster the bridge cannot pronounce is exactly
216
+ * the silent lie SPEC `PRESENTING` refuses).
217
+ */
218
+ export async function loadEngineAt(modulePath, label, opts = {}) {
219
+ let mod;
220
+ try {
221
+ mod = await import(pathToFileURL(modulePath).href);
222
+ } catch (e) {
223
+ throw new LoaderError(`engine "${label}" failed to load — ${e.message}`);
224
+ }
225
+ if (typeof mod.default !== 'function') {
226
+ throw new LoaderError(`engine "${label}" has no default export function`
227
+ + ' (SPEC ENGINE_UNITS: export default function createEngine(opts))');
228
+ }
229
+ let engine;
230
+ try {
231
+ engine = await mod.default(opts);
232
+ } catch (e) {
233
+ throw new LoaderError(`engine "${label}" threw while starting: ${e.message}`);
234
+ }
235
+ if (!engine || typeof engine !== 'object') {
236
+ throw new LoaderError(`engine "${label}" must return an engine object (returned ${typeof engine})`);
237
+ }
238
+ if (typeof engine.synth !== 'function') {
239
+ throw new LoaderError(`engine "${label}" returned no synth() — there is nothing to speak with`);
240
+ }
241
+ if (!Array.isArray(engine.voices) && typeof engine.listVoices !== 'function') {
242
+ throw new LoaderError(`engine "${label}" returned neither a voices array nor listVoices()`
243
+ + ' — the picker would have no roster to offer');
244
+ }
245
+ return {
246
+ ...engine,
247
+ name: typeof engine.name === 'string' && engine.name ? engine.name : label,
248
+ voices: Array.isArray(engine.voices) ? engine.voices : [],
249
+ stylable: engine.stylable === true,
250
+ };
251
+ }
252
+
253
+ /**
254
+ * Load one installed speech engine, ready for the bridge to speak with.
255
+ * `opts` is the same option bag `tools/tts-engines.mjs`'s own `createEngine`
256
+ * takes, passed through untouched — an installed engine reads what it needs
257
+ * (`voice`, `model`, `lang`) and ignores the rest, exactly as the built-ins do.
258
+ */
259
+ export async function loadEngine(name, opts = {}, home = configHome()) {
260
+ const unit = resolveEngine(name, home);
261
+ const engine = await loadEngineAt(unit.path, name, opts);
262
+ return { ...engine, installed: true, checked: unit.checked };
263
+ }