decklight 0.9.0 → 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 +44 -3
- package/README.md +7 -5
- package/SPEC.md +100 -31
- package/cli/agent-review.mjs +5 -4
- package/cli/agents.mjs +11 -5
- package/cli/bundle-audio.mjs +10 -3
- package/cli/bundle-module.mjs +95 -0
- package/cli/bundle.mjs +58 -6
- package/cli/cast.mjs +41 -5
- package/cli/check-fixes.mjs +186 -0
- package/cli/check.mjs +32 -5
- package/cli/commit-flow.mjs +7 -3
- package/cli/commit-message.mjs +1 -1
- package/cli/commit-split.mjs +2 -2
- package/cli/deck-refs.mjs +8 -3
- package/cli/design-system-refs.mjs +263 -6
- package/cli/design-system.mjs +82 -14
- package/cli/edit-git.mjs +2 -2
- package/cli/edit-handover.mjs +129 -23
- package/cli/edit-look.mjs +248 -5
- package/cli/edit.mjs +504 -58
- package/cli/enhance.mjs +12 -10
- package/cli/git.mjs +13 -0
- package/cli/init.mjs +8 -3
- package/cli/marketplace-autocheck.mjs +200 -0
- package/cli/marketplace.mjs +250 -13
- package/cli/narrate.mjs +78 -3
- package/cli/open.mjs +24 -6
- package/cli/pdf.mjs +27 -8
- package/cli/pptx-export.mjs +7 -4
- package/cli/record.mjs +73 -13
- package/cli/remote.mjs +32 -6
- package/cli/serve.mjs +2 -2
- package/cli/skill-content.mjs +40 -3
- package/cli/skills.mjs +247 -3
- package/cli/theme-refs.mjs +14 -2
- package/cli/units.mjs +75 -7
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +429 -32
- package/dist/decklight.js +169 -123
- package/dist/decklight.js.map +4 -4
- package/package.json +1 -1
- package/tools/design-system-format.mjs +25 -0
- package/tools/design-system-migrations.mjs +207 -0
- package/tools/exec.mjs +10 -2
- package/tools/narration-manifest.mjs +77 -3
- package/tools/site-clip.mjs +114 -0
- package/tools/video.mjs +69 -6
package/cli/pdf.mjs
CHANGED
|
@@ -140,13 +140,21 @@ export const slideCount = (html) => sectionBodies(html).filter((b) => !isHiddenS
|
|
|
140
140
|
|
|
141
141
|
const KB = (n) => (n < 1024 * 1024 ? `${Math.round(n / 1024)} KB` : `${(n / 1048576).toFixed(1)} MB`);
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
// `signal` stops Chrome mid-print (the edit server's stop route): it throws the
|
|
144
|
+
// AbortError, and leaves no half-written PDF behind.
|
|
145
|
+
export async function pdfMain(args = [], { signal = null } = {}) {
|
|
144
146
|
if (args.includes('--help') || args.includes('-h')) { console.log(USAGE); return 0; }
|
|
145
147
|
const { opt } = argReader(args);
|
|
146
148
|
const deck = args.find((a) => !a.startsWith('-') && /\.html?$/i.test(a));
|
|
147
149
|
if (!deck) { console.error(`decklight pdf: needs a deck\n\n${USAGE}`); return 1; }
|
|
148
150
|
const src = resolve(deck);
|
|
149
151
|
if (!existsSync(src)) { console.error(`decklight pdf: no such deck: ${deck}`); return 1; }
|
|
152
|
+
// The deck is served from its folder (below), and the render server never
|
|
153
|
+
// serves a dotfile: Chrome would print its 403 as one blank page
|
|
154
|
+
if (basename(src).startsWith('.')) {
|
|
155
|
+
console.error(`decklight pdf: ${basename(src)} is a dotfile, and a deck is rendered by serving it, which never serves a name that starts with a dot — copy or rename it without the dot`);
|
|
156
|
+
return 1;
|
|
157
|
+
}
|
|
150
158
|
|
|
151
159
|
const variant = args.includes('--notes') ? 'notes' : args.includes('--handout') ? 'handout' : '';
|
|
152
160
|
if (args.includes('--notes') && args.includes('--handout')) {
|
|
@@ -169,13 +177,13 @@ export async function pdfMain(args = []) {
|
|
|
169
177
|
const url = printUrl(`${server.origin}/${relative(root, src).split(sep).join('/')}`, { theme, gen, variant });
|
|
170
178
|
const shared = chromeArgs(`--virtual-time-budget=${wait}`);
|
|
171
179
|
try {
|
|
172
|
-
return await printDeck({ src, out, url, bin, shared, variant, theme });
|
|
180
|
+
return await printDeck({ src, out, url, bin, shared, variant, theme, signal });
|
|
173
181
|
} finally {
|
|
174
182
|
await server.close();
|
|
175
183
|
}
|
|
176
184
|
}
|
|
177
185
|
|
|
178
|
-
async function printDeck({ src, out, url, bin, shared, variant, theme }) {
|
|
186
|
+
async function printDeck({ src, out, url, bin, shared, variant, theme, signal }) {
|
|
179
187
|
|
|
180
188
|
// Chrome is AWAITED, never `run`: the in-process render server above has
|
|
181
189
|
// to answer the browser it launched (the deadlock pptx documents), and the
|
|
@@ -189,8 +197,11 @@ async function printDeck({ src, out, url, bin, shared, variant, theme }) {
|
|
|
189
197
|
let html = '';
|
|
190
198
|
try {
|
|
191
199
|
html = await runAsync(bin, [...shared, '--dump-dom', url],
|
|
192
|
-
{ encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, timeout: CODEC_MS, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
|
|
193
|
-
} catch {
|
|
200
|
+
{ encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, timeout: CODEC_MS, signal, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
|
|
201
|
+
} catch (e) {
|
|
202
|
+
if (e.name === 'AbortError') throw e;
|
|
203
|
+
// the print pass below is the one that must succeed
|
|
204
|
+
}
|
|
194
205
|
const slides = slideCount(html);
|
|
195
206
|
console.error(`pdf: rendering ${basename(src)}?print${variant ? `=${variant}` : ''}${theme ? ` · theme ${theme}` : ''}`
|
|
196
207
|
+ `${slides ? ` — ${slides} slides, builds complete, casts expanded` : ''}`);
|
|
@@ -198,8 +209,9 @@ async function printDeck({ src, out, url, bin, shared, variant, theme }) {
|
|
|
198
209
|
rmSync(out, { force: true }); // never leave a stale PDF looking like a fresh one
|
|
199
210
|
try {
|
|
200
211
|
await runAsync(bin, [...shared, '--no-pdf-header-footer', `--print-to-pdf=${out}`, url],
|
|
201
|
-
{ maxBuffer: 32 * 1024 * 1024, timeout: CODEC_MS, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
|
|
212
|
+
{ maxBuffer: 32 * 1024 * 1024, timeout: CODEC_MS, signal, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
|
|
202
213
|
} catch (e) {
|
|
214
|
+
if (e.name === 'AbortError') { rmSync(out, { force: true }); throw e; }
|
|
203
215
|
console.error(`decklight pdf: Chrome failed — ${String(e.message ?? e).split('\n')[0]}`);
|
|
204
216
|
return 1;
|
|
205
217
|
}
|
|
@@ -217,11 +229,18 @@ async function printDeck({ src, out, url, bin, shared, variant, theme }) {
|
|
|
217
229
|
}
|
|
218
230
|
const buf = readFileSync(out);
|
|
219
231
|
const pages = pdfPageCount(buf);
|
|
220
|
-
|
|
232
|
+
// No slides in the rendered page is no deck at all (a refused or broken
|
|
233
|
+
// load): held to the file's own count, so the mismatch below is said
|
|
234
|
+
let written = 0;
|
|
235
|
+
if (!slides) {
|
|
236
|
+
try { written = slideCount(readFileSync(src, 'utf8')); } catch { written = 0; }
|
|
237
|
+
if (written) console.error(`pdf: ⚠ the rendered page had no slides, the file has ${written}: the deck did not load`);
|
|
238
|
+
}
|
|
239
|
+
const want = slides || written ? expectedPages(slides || written, variant) : 0;
|
|
221
240
|
const geometry = variant === 'handout' ? 'portrait, 3 slides a page' : variant === 'notes' ? 'slide + notes per page' : '1280×720 (16:9)';
|
|
222
241
|
console.log(`${out} · ${pages || '?'} pages · ${geometry} · ${KB(buf.length)}`);
|
|
223
242
|
if (want && pages && pages !== want) {
|
|
224
|
-
console.error(`pdf: ⚠ expected ${want} pages for ${slides} slides${variant ? ` (${variant})` : ''}, got ${pages}`);
|
|
243
|
+
console.error(`pdf: ⚠ expected ${want} pages for ${slides || written} slides${variant ? ` (${variant})` : ''}, got ${pages}`);
|
|
225
244
|
}
|
|
226
245
|
return 0;
|
|
227
246
|
}
|
package/cli/pptx-export.mjs
CHANGED
|
@@ -70,11 +70,13 @@ const titleOf = (html, file) => cleanNotes(/<title>([\s\S]*?)<\/title>/i.exec(ht
|
|
|
70
70
|
* cause was one import. tools/shot.mjs carries the same warning above the same
|
|
71
71
|
* call; test/pptx-render.mjs is what now notices.
|
|
72
72
|
*/
|
|
73
|
-
export async function chromeShot(bin, argv,
|
|
74
|
-
await runAsync(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout, why: 'Chrome did not finish rendering a slide — it is probably waiting on a resource it cannot reach' });
|
|
73
|
+
export async function chromeShot(bin, argv, { signal } = {}, { timeout = CODEC_MS } = {}) {
|
|
74
|
+
await runAsync(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout, signal, why: 'Chrome did not finish rendering a slide — it is probably waiting on a resource it cannot reach' });
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
// `signal` stops it between slides and mid-slide (the edit server's stop
|
|
78
|
+
// route): it throws the AbortError, and no file is written.
|
|
79
|
+
export async function pptxMain(args = [], { render = chromeShot, log = console.error, onSlide = null, signal = null } = {}) {
|
|
78
80
|
if (args.includes('--help') || args.includes('-h')) { console.log(USAGE); return 0; }
|
|
79
81
|
const { opt } = argReader(args);
|
|
80
82
|
const deck = args.find((a) => !a.startsWith('-') && /\.html?$/i.test(a));
|
|
@@ -124,6 +126,7 @@ export async function pptxMain(args = [], { render = chromeShot, log = console.e
|
|
|
124
126
|
log(`pptx: rendering ${basename(src)} — ${count} slides at 1280×720, builds complete`
|
|
125
127
|
+ (total > count ? ` · ${total - count} hidden, skipped` : ''));
|
|
126
128
|
for (const [i, n] of shown.entries()) {
|
|
129
|
+
signal?.throwIfAborted();
|
|
127
130
|
// Position in the FILE being written, not in the deck — a caller showing
|
|
128
131
|
// "slide 3 of 5" means the third of five pictures, and a hidden slide in
|
|
129
132
|
// between would make the deck's own numbering count past the end.
|
|
@@ -135,7 +138,7 @@ export async function pptxMain(args = [], { render = chromeShot, log = console.e
|
|
|
135
138
|
await render(bin, chromeArgs(
|
|
136
139
|
'--hide-scrollbars', '--window-size=1280,720', `--virtual-time-budget=${wait}`,
|
|
137
140
|
`--screenshot=${png}`, `${server.origin}${deckPath}${renderQuery}#/${n}/999`,
|
|
138
|
-
), { n, png });
|
|
141
|
+
), { n, png, signal });
|
|
139
142
|
if (!existsSync(png) || statSync(png).size === 0) { log(`decklight pptx: slide ${n} did not render — try a longer --wait`); return 1; }
|
|
140
143
|
slides.push({ png: readFileSync(png), notes: notes[n - 1] });
|
|
141
144
|
}
|
package/cli/record.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
// decklight narrate --mic — capture the deck's narration in YOUR voice.
|
|
6
6
|
//
|
|
7
|
-
// decklight narrate --mic <deck.html> [--port 8788] [--dir
|
|
7
|
+
// decklight narrate --mic <deck.html> [--port 8788] [--dir voices/me] [--no-open]
|
|
8
8
|
//
|
|
9
9
|
// WHY THIS IS A COMMAND AND NOT JUST A KEY. The recorder itself lives in the
|
|
10
10
|
// deck (V → Record this deck… → With your voice…): it has to, because the notes, the builds and the microphone are
|
|
@@ -30,19 +30,34 @@ import { argReader, firstPositional, isMain } from '../tools/args.mjs';
|
|
|
30
30
|
import { runMain, wrongRecorder } from './util.mjs';
|
|
31
31
|
import { exitWhenOrphaned } from './supervise.mjs';
|
|
32
32
|
|
|
33
|
-
const USAGE = `usage: decklight narrate --mic <deck.html> [--port 8788] [--dir
|
|
33
|
+
const USAGE = `usage: decklight narrate --mic <deck.html> [--port 8788] [--dir voices/me] [--slides a-b [--beats k-l]] [--takes slide|beat] [--countdown N] [--remote] [--no-open]
|
|
34
34
|
serves the deck over http://127.0.0.1 and opens it with the voice recorder up
|
|
35
35
|
|
|
36
36
|
the deck reads you its notes one [click] beat at a time; → ends a beat, which
|
|
37
37
|
both closes that file and reveals the next build — so your voice paces the
|
|
38
|
-
deck exactly as it will when you present it
|
|
38
|
+
deck exactly as it will when you present it. A slide is one take by default:
|
|
39
|
+
→ cuts the beat without stopping, and the recording runs on into the next.
|
|
40
|
+
E edits the words of the beat on screen, saved to the deck's notes, and
|
|
41
|
+
records it again
|
|
39
42
|
|
|
40
43
|
--port N port to serve on (taken? moves to the next free one) [8788]
|
|
41
|
-
--dir NAME folder to write into, relative to the deck
|
|
42
|
-
narration.files, else voiceover]
|
|
44
|
+
--dir NAME folder to write into, relative to the deck [voices/me]
|
|
43
45
|
--slides a-b re-record only this range (1-based, inclusive; "7" for one
|
|
44
46
|
slide). Every other slide's files are left untouched, so a
|
|
45
47
|
fluffed beat costs one slide and not the whole deck
|
|
48
|
+
--beats k-l with --slides naming one slide: re-record only these beats of it
|
|
49
|
+
("3" for one). The other beats' files are left byte for byte, and
|
|
50
|
+
slide-NN.wav is rebuilt from all of them. The recorder's card can
|
|
51
|
+
also start from any beat: ← → pick it before you press Enter
|
|
52
|
+
--takes slide|beat one take per slide, read straight through, or per beat,
|
|
53
|
+
each counted in and retaken on its own
|
|
54
|
+
[the recorder card's one take choice: per slide, remembered]
|
|
55
|
+
--countdown N seconds of count-in before each take, 0 for none (0-9)
|
|
56
|
+
[the recorder card's count-in: 3 s, 1 s or off, remembered]
|
|
57
|
+
--remote the phone remote too, so recording needs no keyboard: its next
|
|
58
|
+
ends a beat and its retake redoes one, and a tap is not in the
|
|
59
|
+
take the way a keystroke is. The recorder's card shows the QR;
|
|
60
|
+
off this machine only the remote answers, as with decklight <deck> --remote
|
|
46
61
|
--no-open don't launch a browser — print the URL and wait
|
|
47
62
|
|
|
48
63
|
writes <dir>/slide-NN.wav (the whole slide) and <dir>/slide-NN-KK.wav (one
|
|
@@ -85,10 +100,13 @@ export function dirProblem(name) {
|
|
|
85
100
|
* record against the slides your audience will see, at the build they will see
|
|
86
101
|
* them at.
|
|
87
102
|
*/
|
|
88
|
-
export function recordUrl(port, deckUrl, dir, slides) {
|
|
103
|
+
export function recordUrl(port, deckUrl, dir, slides, beats, countdown, takes) {
|
|
89
104
|
const q = ['record',
|
|
90
105
|
...(dir ? [`dir=${encodeURIComponent(dir)}`] : []),
|
|
91
|
-
...(slides ? [`slides=${encodeURIComponent(slides)}`] : [])
|
|
106
|
+
...(slides ? [`slides=${encodeURIComponent(slides)}`] : []),
|
|
107
|
+
...(beats ? [`beats=${encodeURIComponent(beats)}`] : []),
|
|
108
|
+
...(countdown != null ? [`countdown=${countdown}`] : []),
|
|
109
|
+
...(takes ? [`takes=${takes}`] : [])].join('&');
|
|
92
110
|
return `http://127.0.0.1:${port}${deckUrl}?${q}`;
|
|
93
111
|
}
|
|
94
112
|
|
|
@@ -111,6 +129,39 @@ export function slidesProblem(range) {
|
|
|
111
129
|
return null;
|
|
112
130
|
}
|
|
113
131
|
|
|
132
|
+
/**
|
|
133
|
+
* `3` or `3-4` with `--slides` naming one slide → null; anything else → a
|
|
134
|
+
* message. Beats are counted per slide, so a range of slides has no beat 3 to
|
|
135
|
+
* name. Whether the slide HAS that many beats is the runtime's to say (it
|
|
136
|
+
* reads the notes), and the card says it with the count.
|
|
137
|
+
*/
|
|
138
|
+
export function beatsProblem(beats, slides) {
|
|
139
|
+
if (beats === undefined || beats === null) return null;
|
|
140
|
+
const m = /^(\d+)(?:-(\d+))?$/.exec(String(beats).trim());
|
|
141
|
+
if (!m) return `--beats must be k-l or a single beat number (got "${beats}")`;
|
|
142
|
+
const from = Number(m[1]);
|
|
143
|
+
const to = m[2] ? Number(m[2]) : from;
|
|
144
|
+
if (from < 1) return '--beats is 1-based — there is no beat 0';
|
|
145
|
+
if (to < from) return `--beats ${beats} ends before it starts`;
|
|
146
|
+
const one = /^(\d+)(?:-(\d+))?$/.exec(String(slides ?? '').trim());
|
|
147
|
+
if (!one || (one[2] && one[2] !== one[1])) {
|
|
148
|
+
return `--beats needs --slides to name one slide, since beats are counted per slide (--slides 6 --beats ${beats})`;
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** `--countdown`: whole seconds, 0 to 9; anything else → a message. */
|
|
154
|
+
export function countdownProblem(value) {
|
|
155
|
+
if (value === undefined || value === null) return null;
|
|
156
|
+
return /^\d$/.test(String(value).trim()) ? null : `--countdown is whole seconds from 0 (none) to 9 (got "${value}")`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** `--takes`: `slide` or `beat`; anything else → a message. */
|
|
160
|
+
export function takesProblem(value) {
|
|
161
|
+
if (value === undefined || value === null) return null;
|
|
162
|
+
return ['slide', 'beat'].includes(value) ? null : `--takes is slide or beat (got "${value}")`;
|
|
163
|
+
}
|
|
164
|
+
|
|
114
165
|
export async function recordMain(args, { open = openUrl, out = process.stdout, onListen = null } = {}) {
|
|
115
166
|
if (args.includes('--help') || args.includes('-h') || !args.filter((a) => !a.startsWith('-')).length) {
|
|
116
167
|
out.write(USAGE);
|
|
@@ -119,11 +170,14 @@ export async function recordMain(args, { open = openUrl, out = process.stdout, o
|
|
|
119
170
|
const { opt } = argReader(args);
|
|
120
171
|
const dir = opt('--dir');
|
|
121
172
|
const slides = opt('--slides');
|
|
122
|
-
|
|
173
|
+
const beats = opt('--beats');
|
|
174
|
+
const countdown = opt('--countdown');
|
|
175
|
+
const takes = opt('--takes');
|
|
176
|
+
for (const bad of [dirProblem(dir), slidesProblem(slides), beatsProblem(beats, slides), countdownProblem(countdown), takesProblem(takes)]) {
|
|
123
177
|
if (bad) { process.stderr.write(`decklight narrate --mic: ${bad}\n`); return 2; }
|
|
124
178
|
}
|
|
125
179
|
|
|
126
|
-
const deck = firstPositional(args, ['--dir', '--slides', '--port']);
|
|
180
|
+
const deck = firstPositional(args, ['--dir', '--slides', '--beats', '--countdown', '--takes', '--port']);
|
|
127
181
|
// Before the server, not after: this used to serve the YAML file, print a
|
|
128
182
|
// URL and open a browser on it, with no error anywhere.
|
|
129
183
|
const mixedUp = wrongRecorder('narrate', deck);
|
|
@@ -131,7 +185,10 @@ export async function recordMain(args, { open = openUrl, out = process.stdout, o
|
|
|
131
185
|
let started;
|
|
132
186
|
// `--no-git`, always: recording is not editing, and a take that happens to
|
|
133
187
|
// coincide with the autocommit cadence has no business creating a commit.
|
|
134
|
-
|
|
188
|
+
// `--remote` passes through untouched: the edit server owns the LAN
|
|
189
|
+
// listener, the token and the line that prints its URL (NO_TRUST#REMOTE).
|
|
190
|
+
const remote = args.includes('--remote');
|
|
191
|
+
await editMain([deck, '--port', String(opt('--port', 8788)), '--no-git', ...(remote ? ['--remote'] : [])], {
|
|
135
192
|
// the same seam editMain offers, passed through: this server outlives the
|
|
136
193
|
// call (it is the whole point), so a caller that is not a terminal — a
|
|
137
194
|
// test — needs a handle to close it
|
|
@@ -141,11 +198,14 @@ export async function recordMain(args, { open = openUrl, out = process.stdout, o
|
|
|
141
198
|
// missing or outside the served root — say nothing on top of it.
|
|
142
199
|
if (!started) return process.exitCode ?? 1;
|
|
143
200
|
|
|
144
|
-
const url = recordUrl(started.port, started.deckUrl, dir, slides);
|
|
201
|
+
const url = recordUrl(started.port, started.deckUrl, dir, slides, beats, countdown == null ? null : Number(countdown), takes);
|
|
145
202
|
out.write(`decklight narrate --mic on ${url}\n`);
|
|
146
203
|
out.write(' V → Record this deck… → With your voice… opens the recorder · → ends a beat and reveals the next build · Esc stops\n');
|
|
147
|
-
out.write(
|
|
148
|
-
|
|
204
|
+
if (remote) out.write(' the phone remote is on: scan the QR on the recorder\'s card; next ends a beat, retake redoes it\n');
|
|
205
|
+
out.write(` files land in ${dir ?? 'voices/me'}, next to the deck.`
|
|
206
|
+
+ `${dir ? '' : ' Recording again refreshes it.'}`
|
|
207
|
+
+ `${slides ? ` Only slide${/-/.test(slides) ? 's' : ''} ${slides}${beats ? `, beat${/-/.test(beats) ? 's' : ''} ${beats}` : ''}.` : ''}`
|
|
208
|
+
+ ' Ctrl-C when you are done.\n');
|
|
149
209
|
if (!args.includes('--no-open')) await open(url, { out, what: url });
|
|
150
210
|
return 0;
|
|
151
211
|
}
|
package/cli/remote.mjs
CHANGED
|
@@ -16,7 +16,9 @@ import { escapeHtml, isLoopback, sseChannel } from './serve.mjs';
|
|
|
16
16
|
/**
|
|
17
17
|
* The phone controller page (#39): a clicker, NOT a second screen — SPEC NON_GOALS
|
|
18
18
|
* rules out multiplex/follow-along, so this renders no slides, only two big
|
|
19
|
-
* targets and the position readout.
|
|
19
|
+
* targets and the position readout. While the voice recorder is capturing a
|
|
20
|
+
* beat (`narrate --mic --remote`, #848) prev gives its place to retake and the
|
|
21
|
+
* readout says which beat. Self-contained by necessity: the phone is
|
|
20
22
|
* off-loopback, and every asset it could reference is one more thing the token
|
|
21
23
|
* would have to guard. It carries the token it was opened with into both its
|
|
22
24
|
* POSTs and its SSE subscription.
|
|
@@ -37,6 +39,12 @@ export function remoteControllerHtml(deckName) {
|
|
|
37
39
|
.deck { font-weight: 400; opacity: .6; font-size: .8rem; }
|
|
38
40
|
.pos { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
|
|
39
41
|
main { flex: 1; display: grid; grid-template-rows: 1fr 1fr; gap: .6rem; padding: .6rem; }
|
|
42
|
+
.rec { display: none; color: #ff6b6b; font-size: .85rem; letter-spacing: .04em; }
|
|
43
|
+
#retake { display: none; }
|
|
44
|
+
body.recording .rec { display: block; }
|
|
45
|
+
body.recording #prev { display: none; }
|
|
46
|
+
body.recording #retake { display: block; background: #3a2226; }
|
|
47
|
+
body.recording header { border-bottom-color: #5a2a2f; }
|
|
40
48
|
button { font: inherit; font-size: 2rem; border: 0; border-radius: 1rem; color: #eee;
|
|
41
49
|
background: #26262b; touch-action: manipulation; }
|
|
42
50
|
button:active { background: #3a3a44; }
|
|
@@ -46,17 +54,21 @@ export function remoteControllerHtml(deckName) {
|
|
|
46
54
|
<body>
|
|
47
55
|
<header>
|
|
48
56
|
<div class="deck">${escapeHtml(deckName)}</div>
|
|
57
|
+
<div class="rec" id="rec">● recording</div>
|
|
49
58
|
<div class="pos" id="pos">—</div>
|
|
50
59
|
</header>
|
|
51
60
|
<main>
|
|
52
61
|
<button id="next" aria-label="next">▼ next</button>
|
|
53
62
|
<button id="prev" aria-label="previous">▲ prev</button>
|
|
63
|
+
<button id="retake" aria-label="retake this beat">↺ retake</button>
|
|
54
64
|
</main>
|
|
55
65
|
<footer id="state">connecting…</footer>
|
|
56
66
|
<script>
|
|
57
67
|
var t = new URLSearchParams(location.search).get('t') || '';
|
|
58
68
|
var q = t ? '?t=' + encodeURIComponent(t) : '';
|
|
59
69
|
var pos = document.getElementById('pos');
|
|
70
|
+
var rec = document.getElementById('rec');
|
|
71
|
+
var next = document.getElementById('next');
|
|
60
72
|
var state = document.getElementById('state');
|
|
61
73
|
function send(key) {
|
|
62
74
|
return fetch('/deck/remote/key' + q, {
|
|
@@ -64,11 +76,21 @@ export function remoteControllerHtml(deckName) {
|
|
|
64
76
|
body: JSON.stringify({ key: key }),
|
|
65
77
|
}).catch(function () { state.textContent = 'offline'; });
|
|
66
78
|
}
|
|
67
|
-
|
|
79
|
+
next.onclick = function () { send('next'); };
|
|
68
80
|
document.getElementById('prev').onclick = function () { send('prev'); };
|
|
81
|
+
document.getElementById('retake').onclick = function () { send('retake'); };
|
|
69
82
|
var es = new EventSource('/deck/remote/events' + q);
|
|
70
83
|
es.addEventListener('pos', function (e) {
|
|
71
|
-
try {
|
|
84
|
+
try {
|
|
85
|
+
var p = JSON.parse(e.data);
|
|
86
|
+
// the voice recorder is capturing a beat: say which, so the phone is
|
|
87
|
+
// usable without looking at the laptop, and offer retake in prev's place
|
|
88
|
+
var r = p.rec;
|
|
89
|
+
document.body.classList.toggle('recording', !!r);
|
|
90
|
+
rec.textContent = r ? '● recording · beat ' + r.beat + ' of ' + r.of : '● recording';
|
|
91
|
+
pos.textContent = r ? 'slide ' + r.slide + ' / ' + p.n : p.i + ' / ' + p.n;
|
|
92
|
+
next.textContent = r ? '▼ next beat' : '▼ next';
|
|
93
|
+
} catch (err) {}
|
|
72
94
|
});
|
|
73
95
|
es.onopen = function () { state.textContent = 'connected'; };
|
|
74
96
|
es.onerror = function () { state.textContent = 'reconnecting…'; };
|
|
@@ -123,7 +145,9 @@ export function createRemoteRelay({ deckName, token, remoteUrl, relayToDeck, dec
|
|
|
123
145
|
}
|
|
124
146
|
if (req.method === 'POST' && url.pathname === '/deck/remote/key') {
|
|
125
147
|
const { key } = JSON.parse(body);
|
|
126
|
-
|
|
148
|
+
// `retake` means something only while the voice recorder is capturing
|
|
149
|
+
// a beat (#848); the deck ignores it anywhere else
|
|
150
|
+
if (key !== 'next' && key !== 'prev' && key !== 'retake') throw new Error('bad payload');
|
|
127
151
|
// relayed as a named event on the stream the deck ALREADY listens to —
|
|
128
152
|
// no second socket, no WebSockets anywhere in this codebase
|
|
129
153
|
relayToDeck('remote', { key });
|
|
@@ -137,9 +161,11 @@ export function createRemoteRelay({ deckName, token, remoteUrl, relayToDeck, dec
|
|
|
137
161
|
if (!isLoopback(req.socket?.remoteAddress)) {
|
|
138
162
|
return json(403, { ok: false, error: 'position reports come from the deck, not the phone' });
|
|
139
163
|
}
|
|
140
|
-
const { i, n } = JSON.parse(body);
|
|
164
|
+
const { i, n, rec = null } = JSON.parse(body);
|
|
141
165
|
if (!Number.isInteger(i) || !Number.isInteger(n)) throw new Error('bad payload');
|
|
142
|
-
|
|
166
|
+
// the beat the voice recorder is capturing, or null (#848)
|
|
167
|
+
if (rec !== null && !['slide', 'beat', 'of'].every((k) => Number.isInteger(rec?.[k]))) throw new Error('bad payload');
|
|
168
|
+
lastPos = { i, n, rec: rec && { slide: rec.slide, beat: rec.beat, of: rec.of } };
|
|
143
169
|
pushPos();
|
|
144
170
|
return json(200, { ok: true });
|
|
145
171
|
}
|
package/cli/serve.mjs
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import { createServer } from 'node:http';
|
|
15
15
|
import { readFileSync, existsSync, statSync, createReadStream } from 'node:fs';
|
|
16
|
-
import { resolve, extname, sep } from 'node:path';
|
|
16
|
+
import { resolve, extname, sep, dirname, basename } from 'node:path';
|
|
17
17
|
import { timingSafeEqual } from 'node:crypto';
|
|
18
18
|
import { networkInterfaces } from 'node:os';
|
|
19
19
|
import { createInterface } from 'node:readline/promises';
|
|
@@ -283,7 +283,7 @@ export function staticFiles(root, { index = '/index.html', html: rewriteHtml = n
|
|
|
283
283
|
// is a page; everything else streams below.
|
|
284
284
|
if (type === MIME['.html']) {
|
|
285
285
|
const text = readFileSync(file).toString('utf8');
|
|
286
|
-
const body = Buffer.from(linkReferences(linkRuntime(rewriteHtml ? rewriteHtml(text, file) : text)), 'utf8');
|
|
286
|
+
const body = Buffer.from(linkReferences(linkRuntime(rewriteHtml ? rewriteHtml(text, file) : text), { dir: dirname(file), deck: basename(file) }), 'utf8');
|
|
287
287
|
const want = rangeOf(req.headers.range, body.length);
|
|
288
288
|
if (want && !want.satisfiable) {
|
|
289
289
|
res.writeHead(416, { 'content-range': `bytes */${body.length}` });
|
package/cli/skill-content.mjs
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import fs from 'node:fs';
|
|
17
|
+
import os from 'node:os';
|
|
17
18
|
import path from 'node:path';
|
|
18
19
|
|
|
19
20
|
// Imported and re-exported, not redefined: the package root has one
|
|
@@ -227,7 +228,11 @@ role and still nests like its slot. \`decklight check\` says \`off-role\` (a
|
|
|
227
228
|
colour that is not a role, with the nearest one), \`off-palette-literal\` (on a
|
|
228
229
|
brand without roles) and \`theme-off-brand\` (a configured theme outside the
|
|
229
230
|
brand); \`"brandThemesOnly": false\` is the author's way out, never yours to
|
|
230
|
-
add (BRAND_PALETTE and DESIGN_SYSTEM_ROLES in the reference).
|
|
231
|
+
add (BRAND_PALETTE and DESIGN_SYSTEM_ROLES in the reference). \`check\` says
|
|
232
|
+
\`ds-behind\` when the deck was written for an older major of its design
|
|
233
|
+
system: migrate it (\`decklight design-system migrate <ref> <deck>\`, or the
|
|
234
|
+
skill the warning names) rather than fixing each renamed name by hand
|
|
235
|
+
(DESIGN_SYSTEM_MIGRATIONS).
|
|
231
236
|
|
|
232
237
|
Speaker notes drive both live narration and the transcript/caption
|
|
233
238
|
features, so write them even for decks that will only ever be read: split
|
|
@@ -258,6 +263,14 @@ not "⌘"). To rewrite terse notes that way when asked, \`decklight enhance
|
|
|
258
263
|
deck.html --spoken --slides 3\` does it with the same checks on the beats and
|
|
259
264
|
the pauses.
|
|
260
265
|
|
|
266
|
+
**Installed marketplace skills sit beside this one.** \`decklight library add
|
|
267
|
+
skill <name>\` installs a skill from a marketplace into
|
|
268
|
+
\`~/.decklight/skills/<name>/SKILL.md\` (\`$DECKLIGHT_HOME/skills/\` when that is
|
|
269
|
+
set) and copies it next to this skill. When a task is one a skill there
|
|
270
|
+
describes — migrating a deck to a new major version of its design system, say —
|
|
271
|
+
list that directory, read the SKILL.md whose \`description\` fits, and follow
|
|
272
|
+
it together with this contract.
|
|
273
|
+
|
|
261
274
|
**Commit your own changes when an edit server is running.** It snapshots
|
|
262
275
|
silently and commits only when told; you are not an agent it started, so
|
|
263
276
|
after each logical change:
|
|
@@ -291,7 +304,7 @@ export const AGENTS_MARKER = '<!-- decklight:skill -->';
|
|
|
291
304
|
* marker pair lets `init`/`skills` refresh the block in place instead of
|
|
292
305
|
* appending a duplicate.
|
|
293
306
|
*/
|
|
294
|
-
export function agentsSection(referenceHref = '.claude/skills/decklight/reference.md') {
|
|
307
|
+
export function agentsSection(referenceHref = '.claude/skills/decklight/reference.md', { librarySkills = [] } = {}) {
|
|
295
308
|
return `${AGENTS_MARKER}
|
|
296
309
|
${SKILL_STAMP()}
|
|
297
310
|
## Decklight decks
|
|
@@ -327,13 +340,37 @@ change you finish rather than leaving it to the timer's generic \`autosave\`:
|
|
|
327
340
|
-d '{"message":"what this change did"}'\`. No server listening means no
|
|
328
341
|
authoring session — skip it and carry on.
|
|
329
342
|
|
|
330
|
-
Hit a Decklight bug? Run \`npx decklight@latest report-bug\` for the environment
|
|
343
|
+
${librarySkillLines(librarySkills)}Hit a Decklight bug? Run \`npx decklight@latest report-bug\` for the environment
|
|
331
344
|
facts, then ask the user what happened, what they expected, and the smallest
|
|
332
345
|
repro — and show them the whole issue before filing anything.
|
|
333
346
|
${AGENTS_MARKER}
|
|
334
347
|
`;
|
|
335
348
|
}
|
|
336
349
|
|
|
350
|
+
/** A path as an agent should read it on this machine: `~/…` under $HOME. */
|
|
351
|
+
export function homePath(file) {
|
|
352
|
+
const home = os.homedir();
|
|
353
|
+
return home && file.startsWith(home + path.sep) ? `~${file.slice(home.length)}` : file;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* The installed marketplace skills (`librarySkills` in units.mjs), one line
|
|
358
|
+
* each, for an agent that reads AGENTS.md and nothing else (#880): no
|
|
359
|
+
* directory of skills is indexed for it, so the line is the only way it
|
|
360
|
+
* learns one exists. Nothing installed, no paragraph.
|
|
361
|
+
*/
|
|
362
|
+
function librarySkillLines(skills) {
|
|
363
|
+
if (!skills.length) return '';
|
|
364
|
+
// `- <name>: <description> Read <path>.` — a description is a sentence of its own
|
|
365
|
+
const sentence = (d) => (d ? `${d.replace(/\s+/g, ' ').trim()}${/[.!?]$/.test(d.trim()) ? '' : '.'} ` : '');
|
|
366
|
+
const lines = skills.map((s) => `- ${s.name}: ${sentence(s.description)}Read \`${homePath(path.join(s.path, 'SKILL.md'))}\`.`);
|
|
367
|
+
return `Installed marketplace skills (\`decklight library add skill\`). Before a task
|
|
368
|
+
one of them describes, read its SKILL.md and follow it:
|
|
369
|
+
${lines.join('\n')}
|
|
370
|
+
|
|
371
|
+
`;
|
|
372
|
+
}
|
|
373
|
+
|
|
337
374
|
/**
|
|
338
375
|
* The `decklight-report-bug` skill (#73): the conversational half of filing a
|
|
339
376
|
* bug, which the print-and-exit CLI deliberately does not do.
|