decklight 0.8.0 → 0.9.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 +666 -0
- package/README.md +224 -150
- package/SPEC.md +732 -886
- package/cli/agent-review.mjs +245 -0
- package/cli/agents.mjs +25 -5
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +183 -0
- package/cli/bundle.mjs +383 -31
- package/cli/cast.mjs +7 -7
- package/cli/check.mjs +961 -0
- package/cli/clone-deck.mjs +179 -0
- package/cli/commands.mjs +345 -0
- package/cli/comments.mjs +64 -18
- package/cli/commit-flow.mjs +44 -19
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +59 -0
- package/cli/deck-routes.mjs +67 -0
- package/cli/deckfile.mjs +3 -5
- package/cli/decklight.mjs +68 -289
- package/cli/design-system-deps.mjs +209 -0
- package/cli/design-system-edit.mjs +194 -0
- package/cli/design-system-refs.mjs +409 -0
- package/cli/design-system.mjs +429 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +445 -0
- package/cli/edit-look.mjs +388 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2126 -842
- package/cli/enhance.mjs +483 -0
- package/cli/extension.mjs +10 -10
- package/cli/font-refs.mjs +273 -0
- package/cli/font.mjs +246 -0
- package/cli/git-tree.mjs +1 -1
- package/cli/git.mjs +65 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +400 -234
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace.mjs +215 -21
- package/cli/narrate.mjs +176 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +943 -0
- package/cli/pdf.mjs +41 -13
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +71 -26
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +14 -12
- package/cli/remote.mjs +11 -11
- package/cli/restore.mjs +11 -4
- package/cli/review-ref.mjs +125 -0
- package/cli/review-remote.mjs +92 -48
- package/cli/review-routes.mjs +254 -0
- package/cli/review-store.mjs +47 -7
- package/cli/review-submit.mjs +47 -57
- package/cli/runtime-link.mjs +560 -0
- package/cli/serve.mjs +235 -44
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +190 -33
- package/cli/skills.mjs +107 -24
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +515 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +39 -42
- package/cli/update-check.mjs +1 -5
- package/cli/upgrade.mjs +194 -28
- package/cli/upstream.mjs +4 -3
- package/cli/util.mjs +4 -4
- package/cli/wizard.mjs +6 -6
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +1126 -49
- package/dist/decklight.js +212 -115
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +141 -0
- package/docs/architecture.svg +17 -17
- package/package.json +4 -2
- package/themes/README.md +9 -8
- package/themes/reveal-solarized.css +10 -0
- package/tools/args.mjs +20 -0
- package/tools/atomic-write.mjs +48 -0
- package/tools/brand-palette.mjs +717 -0
- package/tools/bridge.mjs +1 -1
- package/tools/build-groups.mjs +42 -0
- package/tools/color.mjs +48 -0
- package/tools/deck-html.mjs +396 -11
- package/tools/design-system-format.mjs +753 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +35 -2
- package/tools/extension-check.mjs +31 -7
- package/tools/font-format.mjs +190 -0
- package/tools/font-stacks.mjs +24 -0
- package/tools/gemini-tts.mjs +3 -0
- package/tools/lipsync-config.mjs +103 -0
- package/tools/lipsync-engines.mjs +205 -2
- package/tools/lipsync-server.mjs +264 -41
- package/tools/lipsync.mjs +37 -18
- package/tools/local-voice.mjs +32 -42
- package/tools/narration-manifest.mjs +196 -0
- package/tools/narration-synth.mjs +416 -0
- package/tools/pptx.mjs +776 -19
- package/tools/publish-targets.mjs +1 -1
- package/tools/publish-voices.mjs +3 -3
- package/tools/recording-impact.mjs +7 -3
- package/tools/render-theme.mjs +33 -0
- package/tools/review-anchor.mjs +28 -12
- package/tools/semver.mjs +40 -0
- package/tools/sentences.mjs +180 -0
- package/tools/shot.mjs +14 -7
- package/tools/site-voices.mjs +232 -0
- package/tools/template-theme.mjs +1 -1
- package/tools/test-impact.mjs +19 -10
- package/tools/theme-check.mjs +30 -3
- package/tools/tts-cache.mjs +4 -3
- package/tools/tts-engines.mjs +38 -20
- package/tools/tts-setup.mjs +7 -7
- package/tools/video-options.mjs +34 -0
- package/tools/video.mjs +461 -48
- package/tools/voiceover-server.mjs +185 -104
- package/tools/voiceover.mjs +119 -261
- package/tools/zip.mjs +1 -1
- package/cli/dev.mjs +0 -623
- package/cli/present.mjs +0 -853
- package/cli/review.mjs +0 -361
- package/tools/publish-site-voices.mjs +0 -75
|
@@ -0,0 +1,245 @@
|
|
|
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.
|
|
198
|
+
*/
|
|
199
|
+
export async function reviewDeck(html, {
|
|
200
|
+
agent = null, cwd = process.cwd(), env = process.env, timeoutMs = REVIEW_TIMEOUT_MS,
|
|
201
|
+
concurrency = ENHANCE_CONCURRENCY, resolveAgent = agentAsk, exec = ask, onBatch = () => {},
|
|
202
|
+
} = {}) {
|
|
203
|
+
if (!resolveAgent(agent, 'x', { env })) throw new Error(agentUnavailable(agent, detectAgents({ env })));
|
|
204
|
+
const slides = reviewSlides(html);
|
|
205
|
+
const outline = slides.map(({ slide, title }) => ({ slide, title }));
|
|
206
|
+
const batches = [];
|
|
207
|
+
for (let i = 0; i < slides.length; i += REVIEW_BATCH) batches.push(slides.slice(i, i + REVIEW_BATCH));
|
|
208
|
+
const findings = [];
|
|
209
|
+
const failed = [];
|
|
210
|
+
let next = 0, done = 0;
|
|
211
|
+
const worker = async () => {
|
|
212
|
+
while (next < batches.length) {
|
|
213
|
+
const batch = batches[next++];
|
|
214
|
+
const cmd = resolveAgent(agent, reviewPrompt(batch, outline), { env });
|
|
215
|
+
const out = cmd ? await exec(cmd, cwd, timeoutMs) : null;
|
|
216
|
+
const r = out == null ? { why: 'the agent did not answer in time' } : parseReview(out, batch);
|
|
217
|
+
if (r.findings) findings.push(...r.findings);
|
|
218
|
+
else failed.push({ slides: batch.map((s) => s.slide), why: r.why });
|
|
219
|
+
onBatch({ done: ++done, of: batches.length, found: findings.length });
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, batches.length) }, worker));
|
|
223
|
+
return { findings: findings.sort(order), failed: failed.sort((a, b) => a.slides[0] - b.slides[0]) };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* The findings that still hold in the deck as it is NOW, each on the slide it
|
|
228
|
+
* now sits at: matched by fingerprint, so a slide that moved keeps its
|
|
229
|
+
* finding and a slide that was edited (fixed, or rewritten) drops it. A
|
|
230
|
+
* finding about a slide that changed is a finding about text that no longer
|
|
231
|
+
* exists.
|
|
232
|
+
*/
|
|
233
|
+
export function currentFindings(html, findings) {
|
|
234
|
+
const now = new Map();
|
|
235
|
+
for (const s of reviewSlides(html)) if (!now.has(s.fp)) now.set(s.fp, s);
|
|
236
|
+
return (findings ?? []).flatMap((f) => {
|
|
237
|
+
const s = now.get(f.fp);
|
|
238
|
+
return s ? [{ ...f, slide: s.slide, title: s.title }] : [];
|
|
239
|
+
}).sort(order);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** The instruction the A agent is given to fix one finding (`f` in Check deck…). */
|
|
243
|
+
export const fixPrompt = (f) => `On slide ${f.slide} ("${f.title}"), fix this one review finding and nothing else. `
|
|
244
|
+
+ `The problem: ${f.message} What to do: ${f.fix}`
|
|
245
|
+
+ (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
|
|
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,13 @@ 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
|
+
// --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.
|
|
37
42
|
args: (prompt) => ['-p', prompt, '--permission-mode', 'acceptEdits',
|
|
43
|
+
'--allowedTools', 'Bash(npx decklight:*)', 'Bash(decklight:*)',
|
|
38
44
|
'--output-format', 'stream-json', '--verbose'],
|
|
39
45
|
stream: 'claude-json',
|
|
40
46
|
// no --permission-mode: an ASK is read-only by construction, and a
|
|
@@ -285,9 +291,9 @@ export function agentUnavailable(name, roster, home = configHome(),
|
|
|
285
291
|
const have = roster.length
|
|
286
292
|
? `available here: ${roster.map((a) => a.name).join(', ')}`
|
|
287
293
|
: 'no agent CLI is detected on this machine';
|
|
288
|
-
if (!name) return `${have} — install one (claude, codex, bob, …), or: decklight
|
|
294
|
+
if (!name) return `${have} — install one (claude, codex, bob, …), or: decklight library add agent <name>`;
|
|
289
295
|
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
|
|
296
|
+
if (!entry) return `no agent named "${name}" — ${have}; a marketplace can teach decklight a new one: decklight library add agent ${name}`;
|
|
291
297
|
// Found but not runnable is its own answer, and it names the reason rather
|
|
292
298
|
// than the symptom: telling someone their agent "is not on PATH" while
|
|
293
299
|
// `where claude` prints a path is how #307 stayed invisible.
|
|
@@ -296,7 +302,7 @@ export function agentUnavailable(name, roster, home = configHome(),
|
|
|
296
302
|
return `"${name}" is installed at ${where}, but decklight cannot run it as a program: `
|
|
297
303
|
+ 'that file is a batch shim and the script it runs cannot be found. '
|
|
298
304
|
+ 'decklight will not hand your prompt to cmd.exe instead — reinstall the agent, '
|
|
299
|
-
+ `or point one at its real entry point: decklight
|
|
305
|
+
+ `or point one at its real entry point: decklight library add agent ${name}`;
|
|
300
306
|
}
|
|
301
307
|
return `"${name}" is known but its command is not on PATH — install it, or pick another (${have})`;
|
|
302
308
|
}
|
|
@@ -339,7 +345,10 @@ export function agentAsk(name, prompt, { env = process.env, hasBin = canRun, hom
|
|
|
339
345
|
};
|
|
340
346
|
}
|
|
341
347
|
|
|
342
|
-
|
|
348
|
+
/** 1 → first, 2 → second … for a sentence an agent reads. */
|
|
349
|
+
const ordinal = (n) => (n === 1 ? 'first' : n === 2 ? 'second' : n === 3 ? 'third' : `${n}th`);
|
|
350
|
+
|
|
351
|
+
export function agentCommand(name, instruction, deck, { env = process.env, hasBin = canRun, home, spec = spawnSpec, slide = null } = {}) {
|
|
343
352
|
const roster = detectAgents({ env, hasBin, home });
|
|
344
353
|
// Precedence, matching how every other saved choice resolves (PRESENTING):
|
|
345
354
|
// an explicit name > the remembered preference > the first detected agent.
|
|
@@ -357,6 +366,17 @@ export function agentCommand(name, instruction, deck, { env = process.env, hasBi
|
|
|
357
366
|
'Preserve the deck\'s existing narration config (the `narration` key of ' +
|
|
358
367
|
'Decklight.init, which points at recorded audio) and any `data-narration-*` ' +
|
|
359
368
|
'attributes on sections, unless the change is explicitly about them. ' +
|
|
369
|
+
// WHERE the presenter is: "this slide" in an ask means the slide on
|
|
370
|
+
// screen, and an agent that cannot resolve it asks which one — a round
|
|
371
|
+
// trip for a word the page already knew.
|
|
372
|
+
(Number.isInteger(slide) && slide > 0
|
|
373
|
+
? `The presenter is on slide ${slide}, the ${ordinal(slide)} top-level <section> of the file: "this slide" means that one. `
|
|
374
|
+
: '') +
|
|
375
|
+
// The commit is decklight's: the server that started this agent commits
|
|
376
|
+
// its edit under its own summary when it finishes (PRESENTING, agent
|
|
377
|
+
// mode). The skill tells an agent that opened the deck on its own to call
|
|
378
|
+
// the commit route; one started by A must not, or the edit lands twice.
|
|
379
|
+
'decklight started you and will commit your edit itself when you finish, under your summary: do not call the commit route. ' +
|
|
360
380
|
`Apply this change, editing the file in place: ${instruction}`;
|
|
361
381
|
// The spawn spec, not the bare name: on Windows an npm-installed agent is a
|
|
362
382
|
// batch shim, and `prefix` is the script node has to be handed for the
|
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 `
|
|
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 `
|
|
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
|
|
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`:
|
|
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
|
|
90
|
-
Exec=${node} ${cli}
|
|
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
|
|
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 `
|
|
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
|
|
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)} & "
|
|
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}"
|
|
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
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
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/
|
|
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 (
|
|
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.
|
|
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
|
|
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 (
|
|
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 —
|
|
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 ?? '
|
|
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
|
|