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.
Files changed (138) hide show
  1. package/PLATFORM.md +707 -0
  2. package/README.md +226 -150
  3. package/SPEC.md +803 -888
  4. package/cli/agent-review.mjs +246 -0
  5. package/cli/agents.mjs +35 -9
  6. package/cli/associate.mjs +12 -12
  7. package/cli/audit.mjs +42 -10
  8. package/cli/banner.mjs +41 -17
  9. package/cli/bundle-audio.mjs +190 -0
  10. package/cli/bundle-module.mjs +95 -0
  11. package/cli/bundle.mjs +439 -35
  12. package/cli/cast.mjs +48 -12
  13. package/cli/check-fixes.mjs +186 -0
  14. package/cli/check.mjs +988 -0
  15. package/cli/clone-deck.mjs +179 -0
  16. package/cli/commands.mjs +345 -0
  17. package/cli/comments.mjs +64 -18
  18. package/cli/commit-flow.mjs +51 -22
  19. package/cli/commit-message.mjs +51 -74
  20. package/cli/commit-split.mjs +601 -0
  21. package/cli/deck-refs.mjs +64 -0
  22. package/cli/deck-routes.mjs +67 -0
  23. package/cli/deckfile.mjs +3 -5
  24. package/cli/decklight.mjs +68 -289
  25. package/cli/design-system-deps.mjs +209 -0
  26. package/cli/design-system-edit.mjs +194 -0
  27. package/cli/design-system-refs.mjs +666 -0
  28. package/cli/design-system.mjs +497 -0
  29. package/cli/doctor.mjs +115 -0
  30. package/cli/edit-git.mjs +353 -0
  31. package/cli/edit-handover.mjs +551 -0
  32. package/cli/edit-look.mjs +631 -0
  33. package/cli/edit-slides.mjs +683 -0
  34. package/cli/edit.mjs +2585 -855
  35. package/cli/enhance.mjs +485 -0
  36. package/cli/extension.mjs +10 -10
  37. package/cli/font-refs.mjs +273 -0
  38. package/cli/font.mjs +246 -0
  39. package/cli/git-tree.mjs +1 -1
  40. package/cli/git.mjs +78 -11
  41. package/cli/import.mjs +56 -10
  42. package/cli/init.mjs +407 -236
  43. package/cli/library.mjs +127 -0
  44. package/cli/loader.mjs +3 -1
  45. package/cli/marketplace-autocheck.mjs +200 -0
  46. package/cli/marketplace.mjs +460 -29
  47. package/cli/narrate.mjs +251 -0
  48. package/cli/open-browser.mjs +63 -0
  49. package/cli/open.mjs +961 -0
  50. package/cli/pdf.mjs +64 -17
  51. package/cli/pkg.mjs +44 -2
  52. package/cli/plugin.mjs +43 -41
  53. package/cli/port-conflict.mjs +53 -23
  54. package/cli/pptx-export.mjs +63 -27
  55. package/cli/publish.mjs +8 -4
  56. package/cli/qr.mjs +1 -1
  57. package/cli/record.mjs +85 -23
  58. package/cli/remote.mjs +43 -17
  59. package/cli/restore.mjs +11 -4
  60. package/cli/review-ref.mjs +125 -0
  61. package/cli/review-remote.mjs +92 -48
  62. package/cli/review-routes.mjs +254 -0
  63. package/cli/review-store.mjs +47 -7
  64. package/cli/review-submit.mjs +47 -57
  65. package/cli/runtime-link.mjs +560 -0
  66. package/cli/serve.mjs +236 -45
  67. package/cli/setup.mjs +112 -0
  68. package/cli/sign.mjs +1 -1
  69. package/cli/skill-content.mjs +229 -35
  70. package/cli/skills.mjs +353 -26
  71. package/cli/start.mjs +110 -0
  72. package/cli/supervise.mjs +6 -6
  73. package/cli/theme-refs.mjs +527 -0
  74. package/cli/theme.mjs +181 -137
  75. package/cli/trust.mjs +83 -0
  76. package/cli/units.mjs +112 -47
  77. package/cli/update-check.mjs +1 -5
  78. package/cli/upgrade.mjs +194 -28
  79. package/cli/upstream.mjs +4 -3
  80. package/cli/util.mjs +4 -4
  81. package/cli/wizard.mjs +6 -6
  82. package/dist/build-info.json +1 -1
  83. package/dist/decklight.css +1533 -59
  84. package/dist/decklight.js +258 -115
  85. package/dist/decklight.js.map +4 -4
  86. package/docs/GLOSSARY.md +141 -0
  87. package/docs/architecture.svg +17 -17
  88. package/package.json +4 -2
  89. package/themes/README.md +9 -8
  90. package/themes/reveal-solarized.css +10 -0
  91. package/tools/args.mjs +20 -0
  92. package/tools/atomic-write.mjs +48 -0
  93. package/tools/brand-palette.mjs +717 -0
  94. package/tools/bridge.mjs +1 -1
  95. package/tools/build-groups.mjs +42 -0
  96. package/tools/color.mjs +48 -0
  97. package/tools/deck-html.mjs +396 -11
  98. package/tools/design-system-format.mjs +778 -0
  99. package/tools/design-system-migrations.mjs +207 -0
  100. package/tools/elevenlabs-tts.mjs +110 -17
  101. package/tools/exec.mjs +11 -3
  102. package/tools/extension-check.mjs +31 -7
  103. package/tools/font-format.mjs +190 -0
  104. package/tools/font-stacks.mjs +24 -0
  105. package/tools/gemini-tts.mjs +3 -0
  106. package/tools/lipsync-config.mjs +103 -0
  107. package/tools/lipsync-engines.mjs +205 -2
  108. package/tools/lipsync-server.mjs +264 -41
  109. package/tools/lipsync.mjs +37 -18
  110. package/tools/local-voice.mjs +32 -42
  111. package/tools/narration-manifest.mjs +270 -0
  112. package/tools/narration-synth.mjs +416 -0
  113. package/tools/pptx.mjs +776 -19
  114. package/tools/publish-targets.mjs +1 -1
  115. package/tools/publish-voices.mjs +3 -3
  116. package/tools/recording-impact.mjs +7 -3
  117. package/tools/render-theme.mjs +33 -0
  118. package/tools/review-anchor.mjs +28 -12
  119. package/tools/semver.mjs +40 -0
  120. package/tools/sentences.mjs +180 -0
  121. package/tools/shot.mjs +14 -7
  122. package/tools/site-clip.mjs +114 -0
  123. package/tools/site-voices.mjs +232 -0
  124. package/tools/template-theme.mjs +1 -1
  125. package/tools/test-impact.mjs +17 -10
  126. package/tools/theme-check.mjs +30 -3
  127. package/tools/tts-cache.mjs +4 -3
  128. package/tools/tts-engines.mjs +38 -20
  129. package/tools/tts-setup.mjs +7 -7
  130. package/tools/video-options.mjs +34 -0
  131. package/tools/video.mjs +530 -54
  132. package/tools/voiceover-server.mjs +185 -104
  133. package/tools/voiceover.mjs +119 -261
  134. package/tools/zip.mjs +1 -1
  135. package/cli/dev.mjs +0 -623
  136. package/cli/present.mjs +0 -853
  137. package/cli/review.mjs +0 -361
  138. package/tools/publish-site-voices.mjs +0 -75
@@ -0,0 +1,246 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * The agent review (Check deck…'s *Review deck with agent…*, SPEC PRESENTING):
6
+ * the local agent reads the deck and says where it could be better, on the
7
+ * questions a rule cannot answer and a reader can.
8
+ *
9
+ * `decklight check` counts what can be counted: a clipped slide, a crowded
10
+ * one, a build that drifts from its notes. Whether a figure has a source
11
+ * behind it, whether the notes say more than the bullets, whether a title
12
+ * states a point, whether a list wants to be a diagram: those take reading,
13
+ * and an agent is a reader the author already has open.
14
+ *
15
+ * Shaped like `enhance` (cli/enhance.mjs), on purpose. The agent runs
16
+ * READ-ONLY, a few slides at a time; decklight builds the prompt, and every
17
+ * answer is checked before anything is shown: a finding on a slide it was not
18
+ * asked about, under a rule nobody named, or with nothing to say is dropped,
19
+ * never repaired. Only the author's own `f` on a finding touches the file,
20
+ * and that is an ordinary A edit (one undo entry, one commit).
21
+ */
22
+
23
+ import { agentAsk, agentUnavailable, detectAgents } from './agents.mjs';
24
+ import { ask, unwrapAnswer, ENHANCE_CONCURRENCY } from './enhance.mjs';
25
+ import {
26
+ NOTES_ASIDE, cleanNotes, isHiddenSection, sectionBodies, sectionInner, slideHeading, slideText,
27
+ } from '../tools/deck-html.mjs';
28
+ import { fingerprint } from '../tools/review-anchor.mjs';
29
+
30
+ /**
31
+ * The rules, in the order findings are listed. Each `ask` is what the prompt
32
+ * says, word for word; `label` is what Check deck… calls it. A rule is added
33
+ * here and nowhere else: the prompt, the check on the answer and the panel all
34
+ * read this list.
35
+ */
36
+ export const REVIEW_RULES = [
37
+ {
38
+ id: 'unsourced-figure',
39
+ label: 'figure without a source',
40
+ ask: 'The slide states a figure, a date, a percentage, a ranking or a quotation, and no source listed for the slide backs it '
41
+ + '(there is none, or the ones listed are plainly about something else). Name the figure. Do not flag general knowledge '
42
+ + 'or the deck\'s own product facts, and never invent what a source says.',
43
+ },
44
+ {
45
+ id: 'thin-voiceover',
46
+ label: 'voiceover missing or thin',
47
+ ask: 'The slide has no speaker notes, or its notes only read the slide\'s own words back. The notes are what the presenter '
48
+ + 'SAYS: they should carry what the slide does not, such as the reason, the example, the consequence. Say what is missing.',
49
+ },
50
+ {
51
+ id: 'topic-title',
52
+ label: 'title is a topic',
53
+ ask: 'The title names a topic ("Results", "Architecture", "Next steps") where it could state the slide\'s point '
54
+ + '("Latency halved after the cache"). Skip title slides, chapter dividers and closing slides. Propose the title.',
55
+ },
56
+ {
57
+ id: 'better-as-visual',
58
+ label: 'clearer as a diagram or table',
59
+ ask: 'The slide writes as bullets something that has a shape: a process or sequence (a diagram, revealed step by step), '
60
+ + 'or a comparison across the same attributes (a table). Skip slides that already have a diagram or a table. Say which shape.',
61
+ },
62
+ ];
63
+ const RULE_IDS = new Set(REVIEW_RULES.map((r) => r.id));
64
+ const ruleRank = (id) => REVIEW_RULES.findIndex((r) => r.id === id);
65
+
66
+ /** How many slides one ask covers: enough to see the deck's voice, few enough to read closely. */
67
+ export const REVIEW_BATCH = 6;
68
+ /** How long one batch may take: a reading of six slides, not a rewrite. */
69
+ export const REVIEW_TIMEOUT_MS = 180_000;
70
+ /** What a message or a fix may run to; the panel shows one line of it. */
71
+ const MESSAGE_MAX = 160;
72
+ const FIX_MAX = 400;
73
+ /** A slide's own text, cut where it stops helping the agent and starts costing the prompt. */
74
+ const TEXT_MAX = 1200;
75
+
76
+ const clip = (s, n) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
77
+ const SOURCES_ASIDE = /<aside\b[^>]*\bclass\s*=\s*["'][^"']*\bsources\b[^"']*["'][^>]*>([\s\S]*?)<\/aside>/i;
78
+ const plain = (html) => slideText(html);
79
+
80
+ /** The sources aside, as lines an agent reads: `owner: platform-team`, `Annual report (report.pdf#page=12): pp. 12–14`. */
81
+ function sourcesOf(inner) {
82
+ const aside = SOURCES_ASIDE.exec(inner)?.[1];
83
+ if (!aside) return [];
84
+ const facts = [...aside.matchAll(/<dt\b[^>]*>([\s\S]*?)<\/dt>\s*<dd\b[^>]*>([\s\S]*?)<\/dd>/gi)]
85
+ .map(([, k, v]) => `${plain(k)}: ${plain(v)}`);
86
+ const links = [...aside.matchAll(/<li\b[^>]*>([\s\S]*?)<\/li>/gi)].flatMap(([, li]) => {
87
+ const a = /<a\b[^>]*\bhref\s*=\s*["']([^"']*)["'][^>]*>([\s\S]*?)<\/a>/i.exec(li);
88
+ if (!a) return [];
89
+ const title = plain(a[2]);
90
+ const note = plain(li.replace(a[0], ' ')).replace(/^[\s—–-]+/, '');
91
+ return [`${title} (${a[1]})${note ? `: ${note}` : ''}`];
92
+ });
93
+ return [...facts, ...links];
94
+ }
95
+
96
+ /**
97
+ * What the agent is shown of each visible slide, and the fingerprint a
98
+ * finding keeps of it: `{ slide, title, text, notes, sources, hasDiagram, hasTable, fp }`.
99
+ * The fingerprint covers the notes too: a thin voiceover is fixed in the notes,
100
+ * and a fixed slide must stop being flagged.
101
+ */
102
+ export function reviewSlides(html) {
103
+ return sectionBodies(String(html ?? '')).flatMap((body, i) => {
104
+ if (isHiddenSection(body)) return [];
105
+ const inner = sectionInner(body);
106
+ const notes = cleanNotes(NOTES_ASIDE.exec(inner)?.[1] ?? '').trim();
107
+ const text = slideText(inner);
108
+ return [{
109
+ slide: i + 1,
110
+ title: slideHeading(inner, i),
111
+ text: clip(text, TEXT_MAX),
112
+ notes,
113
+ sources: sourcesOf(inner),
114
+ hasDiagram: /<svg\b/i.test(inner.replace(/<div\b[^>]*class="[^"]*\b(chart|terminal)\b[\s\S]*?<\/div>/gi, '')),
115
+ hasTable: /<table\b/i.test(inner),
116
+ fp: fingerprint(`${text}\n${notes}`),
117
+ }];
118
+ });
119
+ }
120
+
121
+ /** The ask for one batch: the rules, the deck's outline for context, the slides, and the answer's exact shape. */
122
+ export function reviewPrompt(batch, outline) {
123
+ const rules = REVIEW_RULES.map((r) => `- \`${r.id}\`: ${r.ask}`).join('\n');
124
+ const deck = outline.map((s) => `${s.slide}. ${s.title}`).join('\n');
125
+ const slides = batch.map((s) => [
126
+ `### Slide ${s.slide}: ${s.title}`,
127
+ `On the slide: ${s.text || '(nothing but the title)'}`,
128
+ `Speaker notes: ${s.notes || '(none)'}`,
129
+ `Sources listed: ${s.sources.length ? s.sources.join(' · ') : '(none)'}`,
130
+ `Has a diagram: ${s.hasDiagram ? 'yes' : 'no'} · has a table: ${s.hasTable ? 'yes' : 'no'}`,
131
+ ].join('\n')).join('\n\n');
132
+ return `# Review these slides
133
+
134
+ You are reviewing slides of a presentation for its author. Read only what is
135
+ below; do not open, edit or create any file. Answer with JSON and nothing else.
136
+
137
+ ## Flag only these, and only where they clearly apply
138
+
139
+ ${rules}
140
+
141
+ ## The whole deck, for context
142
+
143
+ ${deck}
144
+
145
+ ## The slides to review
146
+
147
+ ${slides}
148
+
149
+ ## Your answer
150
+
151
+ A JSON array, one object per problem found, each
152
+ \`{"slide": <number>, "rule": "<one of the ids above>", "message": "<what is wrong, one sentence to the author, under ${MESSAGE_MAX} characters>", "fix": "<one concrete instruction that would fix it on this slide>"}\`.
153
+ At most one object per slide and rule. Only the slides listed above. If nothing
154
+ applies, answer \`[]\`. Never guess what a source says.
155
+ `;
156
+ }
157
+
158
+ /**
159
+ * The findings in an answer, checked: `{ findings }`, or `{ why }` when the
160
+ * answer is not a list at all. Never throws. An item is kept only if it names
161
+ * a slide of `batch`, a known rule, and says something; the first per slide
162
+ * and rule wins. Each kept finding carries its slide's title and fingerprint.
163
+ */
164
+ export function parseReview(answer, batch) {
165
+ let t = unwrapAnswer(answer);
166
+ // an agent that talks before its JSON: the outermost array, if there is one
167
+ if (!t.startsWith('[')) {
168
+ const a = t.indexOf('['), b = t.lastIndexOf(']');
169
+ if (a !== -1 && b > a) t = t.slice(a, b + 1);
170
+ }
171
+ let items;
172
+ try { items = JSON.parse(t); } catch { return { why: 'the agent did not answer with JSON' }; }
173
+ if (!Array.isArray(items)) return { why: 'the agent did not answer with a list' };
174
+ const bySlide = new Map(batch.map((s) => [s.slide, s]));
175
+ const seen = new Set();
176
+ const findings = [];
177
+ for (const it of items) {
178
+ if (!it || typeof it !== 'object') continue;
179
+ const s = bySlide.get(Number(it.slide));
180
+ const message = typeof it.message === 'string' ? it.message.replace(/\s+/g, ' ').trim() : '';
181
+ const fix = typeof it.fix === 'string' ? it.fix.replace(/\s+/g, ' ').trim() : '';
182
+ if (!s || !RULE_IDS.has(it.rule) || !message || !fix) continue;
183
+ const key = `${s.slide}|${it.rule}`;
184
+ if (seen.has(key)) continue;
185
+ seen.add(key);
186
+ findings.push({ slide: s.slide, title: s.title, fp: s.fp, rule: it.rule, message: clip(message, MESSAGE_MAX), fix: clip(fix, FIX_MAX) });
187
+ }
188
+ return { findings };
189
+ }
190
+
191
+ const order = (a, b) => a.slide - b.slide || ruleRank(a.rule) - ruleRank(b.rule);
192
+
193
+ /**
194
+ * Review the deck in `html`: batches of `REVIEW_BATCH` slides, a few at a
195
+ * time, each through a read-only ask. Resolves to `{ findings, failed }`,
196
+ * `failed` being `[{ slides, why }]` for a batch that timed out or answered
197
+ * nothing usable. Throws only when there is no agent to ask at all. `signal`
198
+ * stops it: the asks in flight are killed and no batch after them is asked.
199
+ */
200
+ export async function reviewDeck(html, {
201
+ agent = null, cwd = process.cwd(), env = process.env, timeoutMs = REVIEW_TIMEOUT_MS,
202
+ concurrency = ENHANCE_CONCURRENCY, resolveAgent = agentAsk, exec = ask, onBatch = () => {}, signal = null,
203
+ } = {}) {
204
+ if (!resolveAgent(agent, 'x', { env })) throw new Error(agentUnavailable(agent, detectAgents({ env })));
205
+ const slides = reviewSlides(html);
206
+ const outline = slides.map(({ slide, title }) => ({ slide, title }));
207
+ const batches = [];
208
+ for (let i = 0; i < slides.length; i += REVIEW_BATCH) batches.push(slides.slice(i, i + REVIEW_BATCH));
209
+ const findings = [];
210
+ const failed = [];
211
+ let next = 0, done = 0;
212
+ const worker = async () => {
213
+ while (next < batches.length && !signal?.aborted) {
214
+ const batch = batches[next++];
215
+ const cmd = resolveAgent(agent, reviewPrompt(batch, outline), { env });
216
+ const out = cmd ? await exec(cmd, cwd, timeoutMs, signal) : null;
217
+ const r = out == null ? { why: 'the agent did not answer in time' } : parseReview(out, batch);
218
+ if (r.findings) findings.push(...r.findings);
219
+ else failed.push({ slides: batch.map((s) => s.slide), why: r.why });
220
+ onBatch({ done: ++done, of: batches.length, found: findings.length });
221
+ }
222
+ };
223
+ await Promise.all(Array.from({ length: Math.min(concurrency, batches.length) }, worker));
224
+ return { findings: findings.sort(order), failed: failed.sort((a, b) => a.slides[0] - b.slides[0]) };
225
+ }
226
+
227
+ /**
228
+ * The findings that still hold in the deck as it is NOW, each on the slide it
229
+ * now sits at: matched by fingerprint, so a slide that moved keeps its
230
+ * finding and a slide that was edited (fixed, or rewritten) drops it. A
231
+ * finding about a slide that changed is a finding about text that no longer
232
+ * exists.
233
+ */
234
+ export function currentFindings(html, findings) {
235
+ const now = new Map();
236
+ for (const s of reviewSlides(html)) if (!now.has(s.fp)) now.set(s.fp, s);
237
+ return (findings ?? []).flatMap((f) => {
238
+ const s = now.get(f.fp);
239
+ return s ? [{ ...f, slide: s.slide, title: s.title }] : [];
240
+ }).sort(order);
241
+ }
242
+
243
+ /** The instruction the A agent is given to fix one finding (`f` in Check deck…). */
244
+ export const fixPrompt = (f) => `On slide ${f.slide} ("${f.title}"), fix this one review finding and nothing else. `
245
+ + `The problem: ${f.message} What to do: ${f.fix}`
246
+ + (f.rule === 'unsourced-figure' ? ' Add a source only if you can open and read it; otherwise say so in the speaker notes instead of inventing one.' : '');
package/cli/agents.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright 2026 Gilles Philippart
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- // The AI-agent roster for `decklight author` — which coding agents this machine
4
+ // The AI-agent roster for `decklight <deck>` — which coding agents this machine
5
5
  // can run, and how to hand one a single editing task without a TTY.
6
6
  //
7
7
  // Every entry is a one-shot, non-interactive invocation: the agent gets the
@@ -34,7 +34,17 @@ export const AGENTS = [
34
34
  // (which requires --verbose) narrates the run as it happens — each tool
35
35
  // call is a line — so the deck's chip can say WHAT the agent is doing
36
36
  // instead of only how long it has been doing it.
37
- args: (prompt) => ['-p', prompt, '--permission-mode', 'acceptEdits',
37
+ // --allowedTools: acceptEdits covers the file, not the shell, and the
38
+ // skill asks the agent to render the deck (`npx decklight pdf …`) to
39
+ // check nothing overflows before it is done. Only decklight's own CLI
40
+ // is allowed; everything else still needs a permission it has no TTY
41
+ // to ask for, which is the point.
42
+ // --add-dir: claude reads only inside the project unless told, and a
43
+ // migration's skill lives in a marketplace checkout under ~/.decklight
44
+ // (#893): each folder a job must read is named, and nothing more.
45
+ args: (prompt, deck, { dirs = [] } = {}) => ['-p', prompt, '--permission-mode', 'acceptEdits',
46
+ '--allowedTools', 'Bash(npx decklight:*)', 'Bash(decklight:*)',
47
+ ...dirs.flatMap((d) => ['--add-dir', d]),
38
48
  '--output-format', 'stream-json', '--verbose'],
39
49
  stream: 'claude-json',
40
50
  // no --permission-mode: an ASK is read-only by construction, and a
@@ -285,9 +295,9 @@ export function agentUnavailable(name, roster, home = configHome(),
285
295
  const have = roster.length
286
296
  ? `available here: ${roster.map((a) => a.name).join(', ')}`
287
297
  : 'no agent CLI is detected on this machine';
288
- if (!name) return `${have} — install one (claude, codex, bob, …), or: decklight agent add <name>`;
298
+ if (!name) return `${have} — install one (claude, codex, bob, …), or: decklight library add agent <name>`;
289
299
  const entry = AGENTS.find((a) => a.name === name) ?? installedAgents(home).find((a) => a.name === name);
290
- if (!entry) return `no agent named "${name}" — ${have}; a marketplace can teach decklight a new one: decklight agent add ${name}`;
300
+ if (!entry) return `no agent named "${name}" — ${have}; a marketplace can teach decklight a new one: decklight library add agent ${name}`;
291
301
  // Found but not runnable is its own answer, and it names the reason rather
292
302
  // than the symptom: telling someone their agent "is not on PATH" while
293
303
  // `where claude` prints a path is how #307 stayed invisible.
@@ -296,7 +306,7 @@ export function agentUnavailable(name, roster, home = configHome(),
296
306
  return `"${name}" is installed at ${where}, but decklight cannot run it as a program: `
297
307
  + 'that file is a batch shim and the script it runs cannot be found. '
298
308
  + 'decklight will not hand your prompt to cmd.exe instead — reinstall the agent, '
299
- + `or point one at its real entry point: decklight agent add ${name}`;
309
+ + `or point one at its real entry point: decklight library add agent ${name}`;
300
310
  }
301
311
  return `"${name}" is known but its command is not on PATH — install it, or pick another (${have})`;
302
312
  }
@@ -304,8 +314,10 @@ export function agentUnavailable(name, roster, home = configHome(),
304
314
  /**
305
315
  * The exact spawn for one editing task: `name` picks the agent (or the first
306
316
  * detected one when omitted), `instruction` is the user's ask, `deck` the
307
- * file it should edit. Returns { bin, args, label } or null when the agent
308
- * isn't available.
317
+ * file it should edit, `dirs` folders outside the project it must be able to
318
+ * read (an agent that confines its reads to the project is given them; one
319
+ * whose sandbox already reads anywhere ignores them). Returns { bin, args,
320
+ * label } or null when the agent isn't available.
309
321
  */
310
322
  /**
311
323
  * The same agent, asked a QUESTION rather than told to edit (SPEC `PRESENTING`).
@@ -339,7 +351,10 @@ export function agentAsk(name, prompt, { env = process.env, hasBin = canRun, hom
339
351
  };
340
352
  }
341
353
 
342
- export function agentCommand(name, instruction, deck, { env = process.env, hasBin = canRun, home, spec = spawnSpec } = {}) {
354
+ /** 1 → first, 2 → second … for a sentence an agent reads. */
355
+ const ordinal = (n) => (n === 1 ? 'first' : n === 2 ? 'second' : n === 3 ? 'third' : `${n}th`);
356
+
357
+ export function agentCommand(name, instruction, deck, { env = process.env, hasBin = canRun, home, spec = spawnSpec, slide = null, dirs = [] } = {}) {
343
358
  const roster = detectAgents({ env, hasBin, home });
344
359
  // Precedence, matching how every other saved choice resolves (PRESENTING):
345
360
  // an explicit name > the remembered preference > the first detected agent.
@@ -357,6 +372,17 @@ export function agentCommand(name, instruction, deck, { env = process.env, hasBi
357
372
  'Preserve the deck\'s existing narration config (the `narration` key of ' +
358
373
  'Decklight.init, which points at recorded audio) and any `data-narration-*` ' +
359
374
  'attributes on sections, unless the change is explicitly about them. ' +
375
+ // WHERE the presenter is: "this slide" in an ask means the slide on
376
+ // screen, and an agent that cannot resolve it asks which one — a round
377
+ // trip for a word the page already knew.
378
+ (Number.isInteger(slide) && slide > 0
379
+ ? `The presenter is on slide ${slide}, the ${ordinal(slide)} top-level <section> of the file: "this slide" means that one. `
380
+ : '') +
381
+ // The commit is decklight's: the server that started this agent commits
382
+ // its edit under its own summary when it finishes (PRESENTING, agent
383
+ // mode). The skill tells an agent that opened the deck on its own to call
384
+ // the commit route; one started by A must not, or the edit lands twice.
385
+ 'decklight started you and will commit your edit itself when you finish, under your summary: do not call the commit route. ' +
360
386
  `Apply this change, editing the file in place: ${instruction}`;
361
387
  // The spawn spec, not the bare name: on Windows an npm-installed agent is a
362
388
  // batch shim, and `prefix` is the script node has to be handed for the
@@ -365,7 +391,7 @@ export function agentCommand(name, instruction, deck, { env = process.env, hasBi
365
391
  const how = spec(agent.bin, { env }) ?? { bin: agent.bin, prefix: [] };
366
392
  return {
367
393
  bin: how.bin,
368
- args: [...how.prefix, ...agent.args(prompt, deck)],
394
+ args: [...how.prefix, ...agent.args(prompt, deck, { dirs })],
369
395
  label: agent.label,
370
396
  name: agent.name,
371
397
  // which stream dialect stdout speaks, if any — the server's activity
package/cli/associate.mjs CHANGED
@@ -3,14 +3,14 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
5
  /**
6
- * `decklight associate` — make a double-clicked `.decklight` open in `present`
6
+ * `decklight associate` — make a double-clicked `.decklight` open in `--no-trust`
7
7
  * (MARKETPLACE.md DECK_FILE#ASSOC).
8
8
  *
9
9
  * Without this, the container's whole point leaks away: the person who receives
10
10
  * a deck double-clicks it, the OS has no idea what it is, and they end up
11
11
  * either renaming it to `.html` (which works — the container degrades on
12
12
  * purpose — but skips every check) or looking at a download dialog. The file
13
- * association is what makes `present` the default way in rather than the way in
13
+ * association is what makes `--no-trust` the default way in rather than the way in
14
14
  * for people who already read the docs.
15
15
  *
16
16
  * Three platforms, three unrelated mechanisms, and the honest summary is that
@@ -47,7 +47,7 @@ const CLI = path.join(HERE, 'decklight.mjs');
47
47
 
48
48
  const USAGE = `usage: decklight associate [--uninstall] [--print]
49
49
 
50
- wires a double-clicked ${DECK_EXT} file to \`decklight present\`, so a deck
50
+ wires a double-clicked ${DECK_EXT} file to \`decklight <file> --no-trust\`, so a deck
51
51
  someone sent you opens verified instead of raw in a browser.
52
52
 
53
53
  --uninstall remove what this command installed
@@ -69,7 +69,7 @@ const USAGE = `usage: decklight associate [--uninstall] [--print]
69
69
 
70
70
  /**
71
71
  * The launcher runs the CLI through the same node that is running now.
72
- * `%f` (single local file) rather than `%F`: present takes one deck, and a
72
+ * `%f` (single local file) rather than `%F`: the no-trust mode takes one deck, and a
73
73
  * multi-select that silently presented the first would be worse than one that
74
74
  * opens two windows.
75
75
  */
@@ -86,8 +86,8 @@ export function linuxFiles(home = homedir(), node = process.execPath, cli = CLI)
86
86
  text: `[Desktop Entry]
87
87
  Type=Application
88
88
  Name=Decklight
89
- Comment=Play a Decklight deck, verified and read-only
90
- Exec=${node} ${cli} present %f
89
+ Comment=Play a Decklight deck, verified and without trust
90
+ Exec=${node} ${cli} %f --no-trust
91
91
  Terminal=true
92
92
  NoDisplay=true
93
93
  MimeType=${MIME_TYPE};
@@ -153,13 +153,13 @@ export function darwinFiles(home = homedir(), node = process.execPath, cli = CLI
153
153
  {
154
154
  path: join(app, 'Contents/MacOS/decklight'),
155
155
  mode: 0o755,
156
- // Through Terminal, because present is a server that prints the label and
156
+ // Through Terminal, because the no-trust mode is a server that prints the label and
157
157
  // then keeps running: launching it with no visible output would leave
158
158
  // someone staring at a bouncing icon while the thing they need to read
159
159
  // scrolls past in a log nobody opens.
160
160
  //
161
161
  // The deck path is the filename of a file someone *sent*, and this
162
- // script runs before `present` checks a byte — so it must never be
162
+ // script runs before `--no-trust` checks a byte — so it must never be
163
163
  // spliced into the `do script` text, where a quote in the name becomes
164
164
  // shell. It rides as an osascript argument the whole way and is quoted
165
165
  // by AppleScript's `quoted form of` at the last moment. The install
@@ -167,7 +167,7 @@ export function darwinFiles(home = homedir(), node = process.execPath, cli = CLI
167
167
  // JSON.stringify, the same escaping the Keynote import script uses.
168
168
  text: `#!/bin/sh
169
169
  # Generated by \`decklight associate\`. Opens the double-clicked deck in
170
- # \`decklight present\`, in a Terminal window so its output is readable.
170
+ # \`decklight <file> --no-trust\`, in a Terminal window so its output is readable.
171
171
  # The deck path stays an argument the whole way down (Finder → $1 →
172
172
  # osascript argv → quoted form of): a filename is data, never code.
173
173
  deck="$1"
@@ -175,7 +175,7 @@ deck="$1"
175
175
  dir=$(dirname "$deck")
176
176
  osascript - "$dir" "$deck" <<'DECKLIGHT_LAUNCH'
177
177
  on run argv
178
- set cmd to "cd " & quoted form of item 1 of argv & " && " & quoted form of ${JSON.stringify(node)} & " " & quoted form of ${JSON.stringify(cli)} & " present " & quoted form of item 2 of argv
178
+ set cmd to "cd " & quoted form of item 1 of argv & " && " & quoted form of ${JSON.stringify(node)} & " " & quoted form of ${JSON.stringify(cli)} & " " & quoted form of item 2 of argv & " --no-trust"
179
179
  tell application "Terminal" to do script cmd
180
180
  tell application "Terminal" to activate
181
181
  end run
@@ -195,7 +195,7 @@ export function windowsCommands(node = process.execPath, cli = CLI) {
195
195
  ['reg', 'add', `${key}\\${DECK_EXT}`, '/v', 'Content Type', '/d', MIME_TYPE, '/f'],
196
196
  ['reg', 'add', `${key}\\Decklight.Deck`, '/ve', '/d', 'Decklight presentation', '/f'],
197
197
  ['reg', 'add', `${key}\\Decklight.Deck\\shell\\open\\command`, '/ve', '/d',
198
- `"${node}" "${cli}" present "%1"`, '/f'],
198
+ `"${node}" "${cli}" "%1" --no-trust`, '/f'],
199
199
  ];
200
200
  }
201
201
 
@@ -279,7 +279,7 @@ export async function associateMain(args = process.argv.slice(2)) {
279
279
  '-f', path.join(homedir(), 'Applications/Decklight.app')]);
280
280
  }
281
281
 
282
- console.log(`double-clicking a ${DECK_EXT} now opens: decklight present`);
282
+ console.log(`double-clicking a ${DECK_EXT} now opens: decklight <file> --no-trust`);
283
283
  return 0;
284
284
  }
285
285
 
package/cli/audit.mjs CHANGED
@@ -34,6 +34,7 @@ import { createHash } from 'node:crypto';
34
34
  import path from 'node:path';
35
35
  import { scripts, headStyles } from './upgrade.mjs';
36
36
  import { PKG_ROOT, inlineRuntime } from './pkg.mjs';
37
+ import { configVersion, isDeck } from './runtime-link.mjs';
37
38
 
38
39
  const sha256 = (s) => createHash('sha256').update(s).digest('hex');
39
40
 
@@ -123,7 +124,9 @@ const definesRuntime = (s) => /(?:\bvar\s+|\bwindow\.)Decklight\s*=/.test(s.inne
123
124
  */
124
125
  export function classifyScripts(html) {
125
126
  const all = scripts(html);
126
- const marked = all.find((s) => /\bdata-decklight-runtime\b/i.test(s.attrs));
127
+ // the MARKED block is an embedded one: init marks a linked deck's <script src>
128
+ // with the same attribute (#517), and that is the engine by reference, below
129
+ const marked = all.find((s) => /\bdata-decklight-runtime\b/i.test(s.attrs) && !/\bsrc\s*=/i.test(s.attrs));
127
130
  // Unmarked decks (bundle writes a bare <script>): the runtime is the block
128
131
  // defining Decklight before the init call — upgrade's fallback, so the two
129
132
  // commands always agree on which block is the engine.
@@ -134,6 +137,9 @@ export function classifyScripts(html) {
134
137
  for (let i = initAt - 1; i >= 0; i--) {
135
138
  if (!/\bsrc\s*=/i.test(all[i].attrs) && definesRuntime(all[i])) { fallback = all[i]; break; }
136
139
  }
140
+ // no init call at all — a bundled deck as data (#520) boots from its
141
+ // configuration block, so the engine is simply the block defining it
142
+ if (initAt === -1) fallback = all.find((s) => !/\bsrc\s*=/i.test(s.attrs) && definesRuntime(s)) ?? null;
137
143
  }
138
144
  const runtimeBlock = marked ?? fallback;
139
145
 
@@ -141,14 +147,15 @@ export function classifyScripts(html) {
141
147
  const type = /\btype\s*=\s*["']([^"']+)["']/i.exec(s.attrs)?.[1]?.toLowerCase() ?? '';
142
148
  const src = /\bsrc\s*=\s*["']([^"']+)["']/i.exec(s.attrs)?.[1] ?? null;
143
149
  // start/end are the block's byte range in `html` — carried so a caller can
144
- // act on a block, not merely name it (PRESENT#STRICT splices on them).
150
+ // act on a block, not merely name it (NO_TRUST#STRICT splices on them).
145
151
  const at = { line: lineAt(html, s.start), bytes: s.inner.length, start: s.start, end: s.end };
146
152
  if (s === runtimeBlock) return { kind: 'runtime', ...at, inner: s.inner };
147
153
  if (src) {
148
154
  // a source deck loads dist/decklight.js by reference; anything else with
149
155
  // a src is a third party and is named as one
150
156
  return /(^|\/)decklight(\.min)?\.js(\?|#|$)/i.test(src)
151
- ? { kind: 'runtime-src', ...at, src }
157
+ // the version the deck says it was written for (init / upgrade --link write it)
158
+ ? { kind: 'runtime-src', ...at, src, written: /\bdata-decklight-version\s*=\s*["']([^"']+)["']/i.exec(s.attrs)?.[1] ?? null }
152
159
  : { kind: 'external', ...at, src, snippet: src };
153
160
  }
154
161
  // Data, not findings. A JSON block is inert until the runtime reads it —
@@ -167,8 +174,10 @@ export function classifyScripts(html) {
167
174
  }
168
175
 
169
176
  function dataSubtype(attrs) {
177
+ if (/\bdata-decklight-config\b/i.test(attrs)) return 'config';
170
178
  if (/\bdata-decklight-visemes\b/i.test(attrs)) return 'visemes';
171
179
  if (/\bdata-decklight-voices\b/i.test(attrs)) return 'voice manifest';
180
+ if (/\bdata-decklight-audio\b/i.test(attrs)) return 'narration audio';
172
181
  return 'cast';
173
182
  }
174
183
 
@@ -201,13 +210,13 @@ const blankInner = (html, re) =>
201
210
  /**
202
211
  * Executable ATTRIBUTES — what no `<script>` scan can see.
203
212
  *
204
- * `script-src 'unsafe-inline'` (which a bundled deck forces, cli/present.mjs)
213
+ * `script-src 'unsafe-inline'` (which a bundled deck forces, cli/edit.mjs)
205
214
  * does not only permit script blocks: it is exactly what lets an inline
206
215
  * `onerror=` handler or a `javascript:` href run too. A deck's canonical shape
207
216
  * contains neither — content is markup, behaviour lives in the runtime — so
208
217
  * every one found is named, the same way an unaccounted block is.
209
218
  *
210
- * Named, in the one scan the label and the stripper share (PRESENT#STRICT):
219
+ * Named, in the one scan the label and the stripper share (NO_TRUST#STRICT):
211
220
  * - `on*` handler attributes carrying a value (`onerror=`, `onclick=`, …)
212
221
  * - URL attributes (href, src, action, formaction, xlink:href, data) whose
213
222
  * value resolves to `javascript:` or `data:text/html`
@@ -273,7 +282,7 @@ export function executableAttributes(html) {
273
282
  }
274
283
 
275
284
  /**
276
- * The whole label, as data. `present` prints it; `--check` exits on it.
285
+ * The whole label, as data. the no-trust mode prints it; `--check` exits on it.
277
286
  *
278
287
  * `runtime.state` is deliberately three-valued. A version this install does not
279
288
  * have cannot be hash-checked here at all, and saying so is the honest answer —
@@ -299,7 +308,27 @@ export function auditDeck(html, { installed = installedRuntime() } = {}) {
299
308
  } else if (rtSrc) {
300
309
  // A source deck's engine is a separate file this audit never sees. Naming
301
310
  // that limit beats hashing the empty <script> tag and reporting a match.
302
- runtime = { kind: 'external', version, src: rtSrc.src, state: 'not-inlined' };
311
+ // A linked runtime is whatever this install serves (#517): the one thing
312
+ // the file can say is which version it was WRITTEN for, and the one thing
313
+ // worth flagging is a different major — behaviour may have moved.
314
+ const written = rtSrc.written ?? version ?? null;
315
+ const serves = installed?.version ?? null;
316
+ const major = (v) => String(v ?? '').split('.')[0];
317
+ runtime = { kind: 'external', version: written, src: rtSrc.src, state: 'not-inlined', installedVersion: serves,
318
+ majorMismatch: !!(written && serves && major(written) !== major(serves)) };
319
+ } else if (isDeck(html)) {
320
+ // A deck as data (#520): no runtime in the file at all, which is the best
321
+ // thing the label can say — presenting it runs THIS install's runtime
322
+ // against the file's content, never anything the file brought. The one
323
+ // thing the file records is the version it was written for, in its
324
+ // configuration block, compared the way a linked deck's is.
325
+ const written = configVersion(html);
326
+ const serves = installed?.version ?? null;
327
+ const major = (v) => String(v ?? '').split('.')[0];
328
+ runtime = { kind: 'none', version: written, state: 'data', installedVersion: serves,
329
+ majorMismatch: !!(written && serves && major(written) !== major(serves)),
330
+ // whether the file executes anything at all — the line reads differently
331
+ scripts: blocks.some((b) => b.kind !== 'data' && b.kind !== 'template') || handlers.length > 0 };
303
332
  } else {
304
333
  runtime = { kind: 'missing', version, state: 'not-found' };
305
334
  }
@@ -323,10 +352,10 @@ export function auditDeck(html, { installed = installedRuntime() } = {}) {
323
352
  }
324
353
 
325
354
  /**
326
- * The same inventory, with the unaccounted blocks taken out (PRESENT#STRICT).
355
+ * The same inventory, with the unaccounted blocks taken out (NO_TRUST#STRICT).
327
356
  *
328
357
  * Pure: it takes HTML and returns HTML. Nothing here touches the filesystem,
329
- * which is the whole design — `present` strips on the way OUT, so the deck you
358
+ * which is the whole design — the no-trust mode strips on the way OUT, so the deck you
330
359
  * were sent is still the deck you were sent, byte for byte, and you can hand
331
360
  * the same file to someone else or diff it against the original.
332
361
  *
@@ -383,7 +412,10 @@ const RUNTIME_LINE = {
383
412
  differs: (r) => `runtime ${r.version ?? '(unversioned)'} — sha256 ${r.hash.slice(0, 12)}, DIFFERS from this install's build of ${r.installedVersion}`,
384
413
  'other-version': (r) => `runtime ${r.version} — sha256 ${r.hash.slice(0, 12)}, not comparable here (this install ships ${r.installedVersion})`,
385
414
  uncheckable: (r) => `runtime ${r.version ?? '(unversioned)'} — sha256 ${r.hash.slice(0, 12)}, no installed build to compare against`,
386
- 'not-inlined': (r) => `runtime ${r.version ?? '(unknown version)'} — loaded from ${r.src}, not inlined, so not hashed here`,
415
+ 'not-inlined': (r) => `runtime linked from ${r.src} — written for ${r.version ?? 'an unrecorded version'}, served as this install's ${r.installedVersion ?? 'build'}`
416
+ + (r.majorMismatch ? ' — a different MAJOR; behaviour may differ (decklight upgrade records the deck as written for this one)' : ''),
417
+ data: (r) => `${r.scripts ? 'no runtime in this file' : 'no script in this file'} — the runtime is the one this install serves (${r.installedVersion ?? 'unbuilt'}); written for ${r.version ?? 'an unrecorded version'}`
418
+ + (r.majorMismatch ? ' — a different MAJOR; behaviour may differ (decklight upgrade records the deck as written for this one)' : ''),
387
419
  'not-found': () => 'no decklight runtime found in this file',
388
420
  };
389
421