@netnodeag/kraftwerk 0.82.0 → 0.83.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 (77) hide show
  1. package/README.md +175 -0
  2. package/dist/cli/init.js +1 -0
  3. package/dist/cli/kraftwerk.js +3 -0
  4. package/dist/cli/presentations.d.ts +2 -0
  5. package/dist/cli/presentations.js +261 -0
  6. package/dist/client/routes.d.ts +18 -0
  7. package/dist/client/routes.js +18 -0
  8. package/dist/config.d.ts +16 -0
  9. package/dist/config.js +10 -2
  10. package/dist/core/boards.d.ts +14 -1
  11. package/dist/core/boards.js +34 -1
  12. package/dist/core/chat/context.js +11 -2
  13. package/dist/core/git.js +3 -1
  14. package/dist/core/presentations/browser.d.ts +43 -0
  15. package/dist/core/presentations/browser.js +53 -0
  16. package/dist/core/presentations/builtin.d.ts +3 -0
  17. package/dist/core/presentations/builtin.js +142 -0
  18. package/dist/core/presentations/chart.d.ts +34 -0
  19. package/dist/core/presentations/chart.js +159 -0
  20. package/dist/core/presentations/deck.d.ts +63 -0
  21. package/dist/core/presentations/deck.js +198 -0
  22. package/dist/core/presentations/export.d.ts +21 -0
  23. package/dist/core/presentations/export.js +75 -0
  24. package/dist/core/presentations/html.d.ts +135 -0
  25. package/dist/core/presentations/html.js +389 -0
  26. package/dist/core/presentations/index.d.ts +252 -0
  27. package/dist/core/presentations/index.js +753 -0
  28. package/dist/core/presentations/layout.d.ts +47 -0
  29. package/dist/core/presentations/layout.js +147 -0
  30. package/dist/core/presentations/markdown.d.ts +49 -0
  31. package/dist/core/presentations/markdown.js +158 -0
  32. package/dist/core/presentations/merge.d.ts +26 -0
  33. package/dist/core/presentations/merge.js +28 -0
  34. package/dist/core/presentations/presence.d.ts +31 -0
  35. package/dist/core/presentations/presence.js +131 -0
  36. package/dist/core/presentations/render.d.ts +33 -0
  37. package/dist/core/presentations/render.js +318 -0
  38. package/dist/core/presentations/slots.d.ts +33 -0
  39. package/dist/core/presentations/slots.js +114 -0
  40. package/dist/core/presentations/template.d.ts +253 -0
  41. package/dist/core/presentations/template.js +141 -0
  42. package/dist/core/presentations/versions.d.ts +30 -0
  43. package/dist/core/presentations/versions.js +75 -0
  44. package/dist/core/refs.d.ts +1 -1
  45. package/dist/core/refs.js +9 -1
  46. package/dist/core/search.d.ts +10 -0
  47. package/dist/core/search.js +6 -0
  48. package/dist/core/settings.d.ts +2 -0
  49. package/dist/core/settings.js +12 -1
  50. package/dist/core/trash.d.ts +1 -1
  51. package/dist/server/api/index.d.ts +62 -1
  52. package/dist/server/api/index.js +2 -0
  53. package/dist/server/api/presentations.d.ts +66 -0
  54. package/dist/server/api/presentations.js +185 -0
  55. package/dist/server/api/socket.js +24 -1
  56. package/dist/server/api/workspace.d.ts +5 -0
  57. package/dist/server/api/workspace.js +2 -0
  58. package/package.json +6 -2
  59. package/schema/kraftwerk.schema.json +18 -0
  60. package/web/dist/assets/{dist-DvkrCSGL.js → dist-5-ibIscm.js} +1 -1
  61. package/web/dist/assets/{dist-Bie1ebP9.js → dist-5lgY5B-M.js} +1 -1
  62. package/web/dist/assets/{dist-BuwdjX6z.js → dist-BJaPgnhj.js} +1 -1
  63. package/web/dist/assets/{dist-C_rJjRj7.js → dist-Bar1_NBq.js} +1 -1
  64. package/web/dist/assets/{dist-DtUB2Uu2.js → dist-BxCxboU8.js} +1 -1
  65. package/web/dist/assets/dist-CDitSY16.js +1 -0
  66. package/web/dist/assets/{dist-C16bXf8c.js → dist-CRXT8IL6.js} +1 -1
  67. package/web/dist/assets/{dist-CH73jsgO.js → dist-CXRjiHpl.js} +1 -1
  68. package/web/dist/assets/{dist-BBFUIftm.js → dist-CpnB7MfK.js} +1 -1
  69. package/web/dist/assets/{dist-C0ve4Tka.js → dist-D1VK1YdB.js} +1 -1
  70. package/web/dist/assets/{dist-CDUZdAAS.js → dist-D52LvyO8.js} +1 -1
  71. package/web/dist/assets/{editor-3z92i0tV.js → editor-HCNTXWWs.js} +3 -3
  72. package/web/dist/assets/index-Dnlu16AL.css +2 -0
  73. package/web/dist/assets/index-kwWnQOhD.js +473 -0
  74. package/web/dist/index.html +2 -2
  75. package/web/dist/assets/dist-DYICNp09.js +0 -1
  76. package/web/dist/assets/index-DRhNELK_.js +0 -232
  77. package/web/dist/assets/index-unGEux3Y.css +0 -2
@@ -0,0 +1,753 @@
1
+ import { promises as fs } from "node:fs";
2
+ import path from "node:path";
3
+ import { presentationsRootFor, resolveWorkspace } from "../../config.js";
4
+ import { changed } from "../changes.js";
5
+ import { workspaceRoot } from "../context.js";
6
+ import { newestMtime } from "../mtime.js";
7
+ import { openProjects, safeProjectSlug } from "../projects.js";
8
+ import { SLUG_RE, slugify } from "../slug.js";
9
+ import { moveToTrash } from "../trash.js";
10
+ import { parseDeck, serializeDeck, starterDeck } from "./deck.js";
11
+ import { setSlot } from "./slots.js";
12
+ import { listVersions, readVersion, snapshot } from "./versions.js";
13
+ import { PPTX_MIME, slidePng, slidePngs, toPdf, toPptx } from "./export.js";
14
+ import { hasHtml, renderDeck } from "./render.js";
15
+ import { slideView, standaloneHtml, stageHeight } from "./html.js";
16
+ import { browserProblem, withDeckPage } from "./browser.js";
17
+ import { STAGE_W } from "./layout.js";
18
+ import { createWriteStream } from "node:fs";
19
+ import { pipeline } from "node:stream/promises";
20
+ import { CANVAS, DEFAULT_CSS, DEFAULT_TEMPLATE, defaultSlotOf, templateColors, defaultTemplateYaml, loadWorkspaceTemplates, templateSummary, TEMPLATES_DIR, TEMPLATE_FILE } from "./template.js";
21
+ export { parseDeck, serializeDeck } from "./deck.js";
22
+ export { slotsOf, joinSlots, getSlot, setSlot, DEFAULT_SLOT } from "./slots.js";
23
+ export { parseMarkdown } from "./markdown.js";
24
+ export { renderDeck } from "./render.js";
25
+ export { DEFAULT_TEMPLATE, parseTemplate, defaultTemplateYaml, CANVAS } from "./template.js";
26
+ export { PPTX_MIME, toPdf, toPptx } from "./export.js";
27
+ export { slideView, stageCss, slideHtml, standaloneHtml } from "./html.js";
28
+ /**
29
+ * Presentations: slide decks as folders, one per deck — deck.md (the
30
+ * slides, Slidev-style markdown), assets/ (pictures), exports/ (what
31
+ * `render` wrote). A project's decks live in projects/<p>/presentations/,
32
+ * the workspace's under the presentations root; templates under
33
+ * <root>/templates/<slug>/template.yml (+ theme.css, fonts, pictures).
34
+ * Slides are HTML (html.ts): the editor, present mode, the thumbnails, the
35
+ * HTML file and — through a headless browser (browser.ts) — the PNGs and
36
+ * the PDF are all the same render. The PowerPoint file is a native model
37
+ * of the same slots (render.ts), its HTML pieces drawn as pictures.
38
+ * Agents write deck.md and look at `render --png`.
39
+ */
40
+ export const DECK_FILE = "deck.md";
41
+ export const ASSETS_DIR = "assets";
42
+ export const EXPORTS_DIR = "exports";
43
+ export const COMMENTS_FILE = "comments.json";
44
+ const PRESENTATIONS_DIR = "presentations";
45
+ /* ---------- root ---------- */
46
+ export async function openPresentations() {
47
+ let project;
48
+ try {
49
+ project = await resolveWorkspace(workspaceRoot());
50
+ }
51
+ catch (err) {
52
+ return { error: err.message };
53
+ }
54
+ const root = presentationsRootFor(project);
55
+ if (!root)
56
+ return { off: true, error: "presentations are off (enable them in settings or add `presentations:` to kraftwerk.yml)" };
57
+ return { project, root };
58
+ }
59
+ /** Make sure the workspace presentations root exists; runs when the feature is switched on. */
60
+ export async function ensurePresentationsRoot() {
61
+ const opened = await openPresentations();
62
+ if (opened.root)
63
+ await fs.mkdir(opened.root, { recursive: true });
64
+ }
65
+ async function requireRoot() {
66
+ const opened = await openPresentations();
67
+ if (!opened.root)
68
+ throw new Error(opened.error ?? "presentations are off");
69
+ return opened.root;
70
+ }
71
+ export function safeDeckSlug(slug) {
72
+ if (!SLUG_RE.test(slug) || slug === TEMPLATES_DIR)
73
+ throw new Error(`invalid presentation name "${slug}"`);
74
+ return slug;
75
+ }
76
+ /** The folder a deck lives in: inside its project (projects must be on) or under the workspace root. */
77
+ export async function deckDir(ref) {
78
+ const root = await requireRoot();
79
+ const name = safeDeckSlug(ref.name);
80
+ if (!ref.project)
81
+ return path.join(root, name);
82
+ const projects = await openProjects();
83
+ if (!projects.root)
84
+ throw new Error(projects.error ?? "projects are off");
85
+ const dir = path.join(projects.root, safeProjectSlug(ref.project));
86
+ if (!(await fs.stat(path.join(dir, "project.yml")).catch(() => null)))
87
+ throw new Error(`no project "${ref.project}"`);
88
+ return path.join(dir, PRESENTATIONS_DIR, name);
89
+ }
90
+ /** The folder of a deck that exists (its deck.md is there); throws "no presentation …" otherwise. */
91
+ export async function existingDeckDir(ref) {
92
+ const dir = await deckDir(ref);
93
+ if (!(await fs.stat(path.join(dir, DECK_FILE)).catch(() => null)))
94
+ throw new Error(`no presentation "${deckKey(ref)}"`);
95
+ return dir;
96
+ }
97
+ /** "<project>/<name>" or "<name>". */
98
+ export const deckKey = (ref) => (ref.project ? `${ref.project}/${ref.name}` : ref.name);
99
+ export function parseDeckRef(text) {
100
+ const parts = text.trim().split("/").filter(Boolean);
101
+ if (parts.length === 1)
102
+ return { name: safeDeckSlug(parts[0]) };
103
+ if (parts.length === 2)
104
+ return { project: safeProjectSlug(parts[0]), name: safeDeckSlug(parts[1]) };
105
+ throw new Error(`invalid presentation reference "${text}" (expected <name> or <project>/<name>)`);
106
+ }
107
+ /* ---------- templates ---------- */
108
+ export async function listTemplates() {
109
+ const opened = await openPresentations();
110
+ if (!opened.root)
111
+ return [templateSummary(DEFAULT_TEMPLATE)];
112
+ const { templates, errors } = await loadWorkspaceTemplates(opened.root);
113
+ return [templateSummary(DEFAULT_TEMPLATE), ...templates.map(templateSummary), ...errors];
114
+ }
115
+ async function templateFor(slug) {
116
+ const want = (slug ?? "default").trim() || "default";
117
+ if (want === DEFAULT_TEMPLATE.slug)
118
+ return { template: DEFAULT_TEMPLATE };
119
+ const opened = await openPresentations();
120
+ if (opened.root) {
121
+ const { templates, errors } = await loadWorkspaceTemplates(opened.root);
122
+ const found = templates.find((t) => t.slug === want);
123
+ if (found)
124
+ return { template: found };
125
+ const broken = errors.find((t) => t.slug === want);
126
+ if (broken)
127
+ return { template: DEFAULT_TEMPLATE, warning: `template "${want}" cannot be used (${broken.error}); rendered with "default"` };
128
+ }
129
+ return { template: DEFAULT_TEMPLATE, warning: `unknown template "${want}"; rendered with "default"` };
130
+ }
131
+ /** A template with its theme CSS whose relative URLs (fonts, pictures) point where `fileUrl` says. */
132
+ export function stageTemplateOf(t, fileUrl) {
133
+ return {
134
+ slug: t.slug,
135
+ name: t.name,
136
+ size: t.size,
137
+ fonts: t.fonts,
138
+ colors: templateColors(t),
139
+ layouts: t.layouts,
140
+ ...(t.default ? { default: t.default } : {}),
141
+ css: rewriteUrls(t.cssText ?? "", fileUrl),
142
+ snippets: t.snippets ?? [],
143
+ };
144
+ }
145
+ const rewriteUrls = (css, to) => css.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g, (m, _q, u) => (/^(data:|https?:|\/|#|\{\{)/i.test(u.trim()) ? m : `url("${to(u.trim().replace(/^\.\//, ""))}")`));
146
+ const MIME = {
147
+ ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".svg": "image/svg+xml", ".webp": "image/webp", ".avif": "image/avif",
148
+ ".woff": "font/woff", ".woff2": "font/woff2", ".ttf": "font/ttf", ".otf": "font/otf", ".css": "text/css", ".json": "application/json",
149
+ ".mp4": "video/mp4", ".webm": "video/webm", ".pdf": "application/pdf", ".txt": "text/plain",
150
+ };
151
+ export const mimeOf = (file) => MIME[path.extname(file).toLowerCase()] ?? "application/octet-stream";
152
+ /** A file inside `dir` named by a relative path; null when it escapes the folder, is hidden or does not exist. */
153
+ async function fileInside(dir, rel) {
154
+ const clean = rel.replace(/^\.\//, "").split("?")[0];
155
+ if (!clean || /^[a-z]+:/i.test(clean) || clean.startsWith("/") || clean.split(/[\\/]/).some((p) => p === ".." || p.startsWith(".")))
156
+ return null;
157
+ const abs = path.resolve(dir, clean);
158
+ if (!abs.startsWith(dir + path.sep))
159
+ return null;
160
+ const st = await fs.stat(abs).catch(() => null);
161
+ return st?.isFile() ? abs : null;
162
+ }
163
+ /** A file of a workspace template (its fonts, its logo); the built-in one has none. */
164
+ export async function templateFile(slug, rel) {
165
+ const { template } = await templateFor(slug);
166
+ if (template.slug !== slug || !template.path)
167
+ return null;
168
+ const abs = await fileInside(path.dirname(template.path), rel);
169
+ return abs ? { path: abs, mime: mimeOf(abs) } : null;
170
+ }
171
+ /** A file of a deck (its pictures under assets/); deck.md and exports are reached otherwise. */
172
+ export async function deckFile(ref, rel) {
173
+ const abs = await fileInside(await deckDir(ref), rel);
174
+ return abs ? { path: abs, mime: mimeOf(abs) } : null;
175
+ }
176
+ /** The built-in template and the workspace's usable ones, for the HTML renderer. */
177
+ async function allThemes(fileUrl) {
178
+ const opened = await openPresentations();
179
+ const list = [DEFAULT_TEMPLATE, ...(opened.root ? (await loadWorkspaceTemplates(opened.root)).templates : [])];
180
+ return list.map((t) => stageTemplateOf(t, fileUrl(t)));
181
+ }
182
+ /** Write the built-in template as a workspace template to edit. */
183
+ export async function initTemplate(slug) {
184
+ const root = await requireRoot();
185
+ const name = safeDeckSlug(slug);
186
+ const dir = path.join(root, TEMPLATES_DIR, name);
187
+ const file = path.join(dir, TEMPLATE_FILE);
188
+ if (await fs.stat(file).catch(() => null))
189
+ throw new Error(`template "${name}" already exists: ${file}`);
190
+ await fs.mkdir(dir, { recursive: true });
191
+ await fs.writeFile(file, defaultTemplateYaml().replace(/^name: .*$/m, `name: ${name}`), { flag: "wx" });
192
+ // The theme beside it: the default look to change (fonts and pictures go next to it, named by relative URLs).
193
+ await fs.writeFile(path.join(dir, "theme.css"), DEFAULT_CSS, { flag: "wx" }).catch(() => { });
194
+ changed();
195
+ return file;
196
+ }
197
+ /* ---------- reads ---------- */
198
+ async function deckSlugsIn(dir) {
199
+ const entries = await fs.readdir(dir, { withFileTypes: true }).catch(() => []);
200
+ const out = [];
201
+ for (const e of entries) {
202
+ if (!e.isDirectory() || !SLUG_RE.test(e.name) || e.name === TEMPLATES_DIR)
203
+ continue;
204
+ if (await fs.stat(path.join(dir, e.name, DECK_FILE)).catch(() => null))
205
+ out.push(e.name);
206
+ }
207
+ return out.sort();
208
+ }
209
+ async function readSummary(ref, dir) {
210
+ const file = path.join(dir, DECK_FILE);
211
+ const raw = await fs.readFile(file, "utf8");
212
+ const st = await fs.stat(file).catch(() => null);
213
+ const base = { ...ref, path: dir, ...(st ? { updatedAt: new Date(st.mtimeMs).toISOString() } : {}) };
214
+ try {
215
+ const deck = parseDeck(raw);
216
+ return { ...base, title: deck.title || ref.name, template: deck.template, slides: deck.slides.length };
217
+ }
218
+ catch (err) {
219
+ return { ...base, title: ref.name, template: "default", slides: 0, error: err.message };
220
+ }
221
+ }
222
+ /** The decks of a project, or the workspace decks when no project is given. */
223
+ export async function listDecks(project) {
224
+ const opened = await openPresentations();
225
+ if (!opened.root)
226
+ return { enabled: false, presentations: [], error: opened.error };
227
+ let dir;
228
+ if (project) {
229
+ const projects = await openProjects();
230
+ if (!projects.root)
231
+ return { enabled: true, root: opened.root, presentations: [], error: projects.error };
232
+ dir = path.join(projects.root, safeProjectSlug(project), PRESENTATIONS_DIR);
233
+ }
234
+ else
235
+ dir = opened.root;
236
+ const presentations = await Promise.all((await deckSlugsIn(dir)).map((name) => readSummary({ ...(project ? { project } : {}), name }, path.join(dir, name))));
237
+ return { enabled: true, root: opened.root, presentations };
238
+ }
239
+ /** Every deck of the workspace: the workspace ones first, then each project's. */
240
+ export async function listAllDecks() {
241
+ const opened = await openPresentations();
242
+ if (!opened.root)
243
+ return [];
244
+ const out = (await listDecks()).presentations;
245
+ const projects = await openProjects();
246
+ if (projects.root) {
247
+ const slugs = (await fs.readdir(projects.root, { withFileTypes: true }).catch(() => [])).filter((e) => e.isDirectory() && SLUG_RE.test(e.name)).map((e) => e.name);
248
+ for (const p of slugs)
249
+ out.push(...(await listDecks(p).catch(() => ({ presentations: [] }))).presentations);
250
+ }
251
+ return out;
252
+ }
253
+ async function filesIn(dir) {
254
+ const entries = await fs.readdir(dir, { withFileTypes: true }).catch(() => []);
255
+ return entries.filter((e) => e.isFile() && !e.name.startsWith(".")).map((e) => e.name).sort();
256
+ }
257
+ /* ---------- comments ---------- */
258
+ async function readComments(dir) {
259
+ const raw = await fs.readFile(path.join(dir, COMMENTS_FILE), "utf8").catch(() => null);
260
+ if (!raw)
261
+ return [];
262
+ try {
263
+ const data = JSON.parse(raw);
264
+ return Array.isArray(data.comments) ? data.comments.filter((c) => c && typeof c.id === "string" && typeof c.text === "string").map((c) => ({ ...c, replies: Array.isArray(c.replies) ? c.replies : [] })) : [];
265
+ }
266
+ catch {
267
+ return [];
268
+ }
269
+ }
270
+ const writeComments = async (dir, comments) => {
271
+ await fs.writeFile(path.join(dir, COMMENTS_FILE), `${JSON.stringify({ comments: comments.map(({ n: _n, ...c }) => c) }, null, 2)}\n`);
272
+ changed();
273
+ };
274
+ /** Comments with the number of the slide they are on now (slides move; their ids do not). */
275
+ const numbered = (comments, deck) => {
276
+ const at = new Map(deck.slides.map((s, i) => [String(s.extra?.id ?? ""), i + 1]));
277
+ return comments.map((c) => ({ ...c, ...(at.has(c.slide) ? { n: at.get(c.slide) } : {}) }));
278
+ };
279
+ const newId = () => Math.random().toString(36).slice(2, 8);
280
+ /** A comment on slide `n` (1-based), on one of its boxes when `slot` is given. The slide gets an id the first time. */
281
+ export async function addComment(ref, input) {
282
+ const text = (input.text ?? "").trim();
283
+ if (!text)
284
+ throw new Error("a comment needs text");
285
+ const dir = await deckDir(ref);
286
+ const file = path.join(dir, DECK_FILE);
287
+ const raw = await fs.readFile(file, "utf8").catch(() => null);
288
+ if (raw === null)
289
+ throw new Error(`no presentation "${deckKey(ref)}"`);
290
+ const deck = parseDeck(raw);
291
+ const slide = deck.slides[input.slide - 1];
292
+ if (!slide)
293
+ throw new Error(`no slide ${input.slide} (the deck has ${deck.slides.length})`);
294
+ let id = typeof slide.extra?.id === "string" ? slide.extra.id : "";
295
+ if (!id) {
296
+ id = `s${newId()}`;
297
+ slide.extra = { id, ...slide.extra };
298
+ await fs.writeFile(file, serializeDeck(deck));
299
+ }
300
+ const comment = { id: `c${newId()}`, slide: id, ...(input.slot ? { slot: input.slot } : {}), author: input.author, text, at: new Date().toISOString(), replies: [] };
301
+ await writeComments(dir, [...(await readComments(dir)), comment]);
302
+ return { ...comment, n: input.slide };
303
+ }
304
+ /** Resolve or reopen a comment, or answer it. */
305
+ export async function updateComment(ref, id, input) {
306
+ const dir = await deckDir(ref);
307
+ const all = await readComments(dir);
308
+ const c = all.find((x) => x.id === id);
309
+ if (!c)
310
+ throw new Error(`no comment "${id}"`);
311
+ if (typeof input.resolved === "boolean")
312
+ c.resolved = input.resolved || undefined;
313
+ if (input.reply?.trim())
314
+ c.replies.push({ author: input.author, text: input.reply.trim(), at: new Date().toISOString() });
315
+ await writeComments(dir, all);
316
+ return c;
317
+ }
318
+ export async function deleteComment(ref, id) {
319
+ const dir = await deckDir(ref);
320
+ const all = await readComments(dir);
321
+ if (!all.some((c) => c.id === id))
322
+ throw new Error(`no comment "${id}"`);
323
+ await writeComments(dir, all.filter((c) => c.id !== id));
324
+ }
325
+ /** The deck's earlier versions, newest first. */
326
+ export async function deckVersions(ref) {
327
+ return listVersions(await existingDeckDir(ref));
328
+ }
329
+ export async function deckVersion(ref, id) {
330
+ return readVersion(await existingDeckDir(ref), id);
331
+ }
332
+ export async function listComments(ref) {
333
+ const dir = await deckDir(ref);
334
+ const raw = await fs.readFile(path.join(dir, DECK_FILE), "utf8").catch(() => null);
335
+ if (raw === null)
336
+ throw new Error(`no presentation "${deckKey(ref)}"`);
337
+ return numbered(await readComments(dir), parseDeck(raw));
338
+ }
339
+ export async function getDeck(ref) {
340
+ const dir = await deckDir(ref);
341
+ const file = path.join(dir, DECK_FILE);
342
+ const raw = await fs.readFile(file, "utf8").catch(() => null);
343
+ if (raw === null)
344
+ return null;
345
+ const summary = await readSummary(ref, dir);
346
+ const templates = await listTemplates();
347
+ const assets = (await filesIn(path.join(dir, ASSETS_DIR))).map((f) => `${ASSETS_DIR}/${f}`);
348
+ const exports = await filesIn(path.join(dir, EXPORTS_DIR));
349
+ const webUrl = (t) => (rel) => `{{base}}/api/presentations/templates/${t.slug}/file?path=${encodeURIComponent(rel)}`;
350
+ if (summary.error) {
351
+ return { ...summary, deck: { title: ref.name, template: "default", meta: {}, slides: [] }, source: raw, warnings: [{ slide: 0, level: "error", message: `deck.md cannot be read: ${summary.error}` }], layouts: layoutsOf(DEFAULT_TEMPLATE), canvas: CANVAS[DEFAULT_TEMPLATE.size], colors: templateColors(DEFAULT_TEMPLATE), theme: stageTemplateOf(DEFAULT_TEMPLATE, webUrl(DEFAULT_TEMPLATE)), themes: await allThemes(webUrl), templates, assets, exports, comments: [] };
352
+ }
353
+ const rendered = await render(ref);
354
+ return { ...summary, deck: rendered.deck, source: raw, warnings: rendered.warnings, layouts: layoutsOf(rendered.template), canvas: CANVAS[rendered.deck.size ?? rendered.template.size], colors: templateColors(rendered.template), theme: stageTemplateOf(rendered.template, webUrl(rendered.template)), themes: await allThemes(webUrl), templates, assets, exports, comments: numbered(await readComments(dir), rendered.deck) };
355
+ }
356
+ const layoutsOf = (t) => Object.entries(t.layouts).map(([name, l]) => {
357
+ const dflt = defaultSlotOf(l);
358
+ return {
359
+ name,
360
+ ...(l.description ? { description: l.description } : {}),
361
+ ...(dflt ? { default: dflt } : {}),
362
+ slots: Object.entries(l.slots).map(([slot, s]) => ({
363
+ name: slot,
364
+ kind: s.kind,
365
+ x: s.x,
366
+ y: s.y,
367
+ w: s.w,
368
+ h: s.h,
369
+ ...(s.size ? { size: s.size } : {}),
370
+ ...(s.bold ? { bold: true } : {}),
371
+ ...(s.italic ? { italic: true } : {}),
372
+ ...(s.align ? { align: s.align } : {}),
373
+ ...(s.valign ? { valign: s.valign } : {}),
374
+ ...(s.color ? { color: s.color } : {}),
375
+ ...(s.required ? { required: true } : {}),
376
+ ...(s.placeholder ? { placeholder: s.placeholder } : {}),
377
+ })),
378
+ };
379
+ });
380
+ async function requireDeck(ref) {
381
+ const d = await getDeck(ref);
382
+ if (!d)
383
+ throw new Error(`no presentation "${deckKey(ref)}"`);
384
+ return d;
385
+ }
386
+ /** A deck by "<project>/<name>" or "<name>". */
387
+ export async function findDeck(reference) {
388
+ const ref = parseDeckRef(reference);
389
+ const dir = await deckDir(ref).catch(() => null);
390
+ if (!dir || !(await fs.stat(path.join(dir, DECK_FILE)).catch(() => null)))
391
+ return null;
392
+ return readSummary(ref, dir);
393
+ }
394
+ const cache = new Map();
395
+ async function stampOf(dir, template) {
396
+ const deck = await fs.stat(path.join(dir, DECK_FILE)).catch(() => null);
397
+ const assets = await newestMtime(path.join(dir, ASSETS_DIR));
398
+ const tpl = template.path ? await fs.stat(template.path).catch(() => null) : null;
399
+ return `${deck?.mtimeMs ?? 0}:${deck?.size ?? 0}:${assets}:${tpl?.mtimeMs ?? 0}`;
400
+ }
401
+ /** Reads a slide's pictures from the deck folder, and from nowhere else. */
402
+ const assetsOf = (dir) => ({
403
+ read: async (src) => {
404
+ const clean = src.replace(/^\.\//, "").split("?")[0];
405
+ if (/^[a-z]+:/i.test(clean) || clean.startsWith("/") || clean.split(/[\\/]/).includes(".."))
406
+ return null;
407
+ const abs = path.resolve(dir, clean);
408
+ if (!abs.startsWith(dir + path.sep))
409
+ return null;
410
+ const bytes = await fs.readFile(abs).catch(() => null);
411
+ return bytes ? new Uint8Array(bytes) : null;
412
+ },
413
+ });
414
+ /** The deck rendered into its PowerPoint model, cached until deck.md, an asset or the template changes. */
415
+ export async function render(ref) {
416
+ const dir = await deckDir(ref);
417
+ const raw = await fs.readFile(path.join(dir, DECK_FILE), "utf8").catch(() => null);
418
+ if (raw === null)
419
+ throw new Error(`no presentation "${deckKey(ref)}"`);
420
+ const deck = parseDeck(raw);
421
+ const { template, warning } = await templateFor(deck.template);
422
+ const stamp = await stampOf(dir, template);
423
+ const key = `${dir}`;
424
+ const hit = cache.get(key);
425
+ if (hit && hit.stamp === stamp)
426
+ return hit;
427
+ const rendered = await renderDeck(deck, template, assetsOf(dir));
428
+ if (warning)
429
+ rendered.warnings.unshift({ slide: 0, level: "error", message: warning });
430
+ const entry = { ...rendered, stamp, deck, template };
431
+ cache.set(key, entry);
432
+ return entry;
433
+ }
434
+ /** One slide as PNG (1-based `n`). */
435
+ export async function deckSlidePng(ref, n, width = 1280, hide) {
436
+ const r = await render(ref);
437
+ if (!Number.isInteger(n) || n < 1 || n > r.deck.slides.length)
438
+ throw new Error(`no slide ${n} (the deck has ${r.deck.slides.length})`);
439
+ if (!hide)
440
+ return slidePng(r.pres, n - 1, width);
441
+ // The slide without one slot's content: what the editor shows under the text being typed in place. Rendered alone, not cached.
442
+ const slide = r.deck.slides[n - 1];
443
+ const layout = r.template.layouts[slide.layout ?? ""] ?? r.template.layouts[r.template.default ?? "content"] ?? Object.values(r.template.layouts)[0];
444
+ const bare = { ...slide, content: setSlot(slide.content, hide, "", layout ? defaultSlotOf(layout) : undefined) };
445
+ const one = await renderDeck({ ...r.deck, slides: [bare] }, r.template, assetsOf(await deckDir(ref)));
446
+ return slidePng(one.pres, 0, width);
447
+ }
448
+ const dataUrl = async (abs) => `data:${mimeOf(abs)};base64,${(await fs.readFile(abs)).toString("base64")}`;
449
+ /** The deck as one self-contained HTML file: pictures and the theme's fonts inlined. */
450
+ export async function deckHtml(ref) {
451
+ const dir = await deckDir(ref);
452
+ const r = await render(ref);
453
+ const tplDir = r.template.path ? path.dirname(r.template.path) : null;
454
+ // The theme's files first (fonts, logos), as data URLs.
455
+ const inlined = new Map();
456
+ if (tplDir)
457
+ for (const m of (r.template.cssText ?? "").matchAll(/url\(\s*['"]?([^'")]+)['"]?\s*\)/g)) {
458
+ const rel = m[1].trim().replace(/^\.\//, "");
459
+ const abs = await fileInside(tplDir, rel);
460
+ if (abs)
461
+ inlined.set(rel, await dataUrl(abs));
462
+ }
463
+ const stage = stageTemplateOf(r.template, (rel) => inlined.get(rel) ?? rel);
464
+ // Every picture the slides name.
465
+ const pics = new Map();
466
+ for (const s of r.deck.slides)
467
+ for (const m of s.content.matchAll(/(?:\]\(|src=["'])((?!https?:|data:)[^)"'\s]+)/g)) {
468
+ const abs = await fileInside(dir, m[1]);
469
+ if (abs && !pics.has(m[1]))
470
+ pics.set(m[1], await dataUrl(abs));
471
+ }
472
+ const html = standaloneHtml({ title: r.deck.title, slides: r.deck.slides, ...(r.deck.numbers === false ? { numbers: false } : {}), ...(r.deck.css ? { css: inlineAssets(r.deck.css, pics) } : {}) }, stage, { asset: (src) => pics.get(src.replace(/^\.\//, "")) ?? pics.get(src) ?? src });
473
+ return { html: inlineAssets(html, pics), deck: r.deck, template: r.template, stage };
474
+ }
475
+ /** `src="assets/x.png"` written by hand in a slot's HTML also becomes a data URL. */
476
+ const inlineAssets = (html, pics) => html.replace(/(?<![\w-])(src=["']|url\(["']?)(assets\/[^"')\s]+)/g, (m, lead, rel) => (pics.has(rel) ? lead + pics.get(rel) : m));
477
+ /** The pictures of the slots PowerPoint cannot carry (HTML, embeds), drawn by the browser; null without one. */
478
+ async function htmlSlotPictures(ref) {
479
+ const { html, deck, stage } = await deckHtml(ref);
480
+ const wanted = [];
481
+ deck.slides.forEach((s, i) => {
482
+ for (const v of slideView(s, stage, { asset: (x) => x }).slots)
483
+ if ((v.kind === "html" || v.kind === "embed" || (v.md && hasHtml(v.md))) && (v.html || v.embed))
484
+ wanted.push({ slide: i + 1, slot: v.name });
485
+ });
486
+ if (!wanted.length)
487
+ return new Map();
488
+ return withDeckPage(html, { width: STAGE_W, height: stageHeight(stage.size) }, async (page) => {
489
+ const out = new Map();
490
+ for (const w of wanted) {
491
+ const shot = await page.locator(`section.deck-slide:nth-of-type(${w.slide}) [data-slot="${w.slot}"]`).nth(0).screenshot({ type: "png", omitBackground: true }).catch(() => null);
492
+ if (shot)
493
+ out.set(`${w.slide}:${w.slot}`, new Uint8Array(shot));
494
+ }
495
+ return out;
496
+ });
497
+ }
498
+ /** Every slide as PNG from the HTML (1600 px wide); null without a browser. */
499
+ async function browserPngs(ref) {
500
+ const { html, deck, stage } = await deckHtml(ref);
501
+ return withDeckPage(html, { width: STAGE_W, height: stageHeight(stage.size) }, async (page) => {
502
+ const out = [];
503
+ for (let i = 0; i < deck.slides.length; i++)
504
+ out.push(new Uint8Array(await page.locator("section.deck-slide").nth(i).screenshot({ type: "png" })));
505
+ return out;
506
+ });
507
+ }
508
+ /** The deck as PDF from the HTML, one slide a page; null without a browser. */
509
+ async function browserPdf(ref) {
510
+ const { html, stage } = await deckHtml(ref);
511
+ const h = stageHeight(stage.size);
512
+ return withDeckPage(html, { width: STAGE_W, height: h }, async (page) => new Uint8Array(await page.pdf({ width: `${STAGE_W}px`, height: `${h}px`, printBackground: true, preferCSSPageSize: true })));
513
+ }
514
+ /** The PowerPoint file: the native model, its HTML pieces as the browser draws them (placeholders without one). */
515
+ async function pptxBytes(ref) {
516
+ const r = await render(ref);
517
+ const pictures = await htmlSlotPictures(ref);
518
+ const warnings = [...r.warnings];
519
+ if (pictures === null)
520
+ warnings.unshift({ slide: 0, level: "warning", message: `HTML pieces are placeholders in the PowerPoint file: ${browserProblem()}` });
521
+ if (!pictures?.size)
522
+ return { bytes: await toPptx(r.pres), warnings };
523
+ const fresh = await renderDeck(r.deck, r.template, assetsOf(await deckDir(ref)), { images: pictures });
524
+ return { bytes: await toPptx(fresh.pres), warnings };
525
+ }
526
+ /** Write the deck's PPTX, PDF, slide PNGs or HTML into exports/ (or `outDir`). */
527
+ export async function exportDeck(ref, format, opts = {}) {
528
+ const dir = await deckDir(ref);
529
+ const r = await render(ref);
530
+ const out = opts.outDir ? path.resolve(opts.outDir) : path.join(dir, EXPORTS_DIR);
531
+ await fs.mkdir(out, { recursive: true });
532
+ const files = [];
533
+ let warnings = r.warnings;
534
+ const fallback = (what) => ({ slide: 0, level: "warning", message: `${what} drawn from the PowerPoint model, not the HTML: ${browserProblem()}` });
535
+ if (format === "pptx") {
536
+ const file = path.join(out, `${ref.name}.pptx`);
537
+ const p = await pptxBytes(ref);
538
+ await fs.writeFile(file, p.bytes);
539
+ warnings = p.warnings;
540
+ files.push(file);
541
+ }
542
+ else if (format === "html") {
543
+ const file = path.join(out, `${ref.name}.html`);
544
+ await fs.writeFile(file, (await deckHtml(ref)).html);
545
+ files.push(file);
546
+ }
547
+ else if (format === "pdf") {
548
+ const file = path.join(out, `${ref.name}.pdf`);
549
+ const pdf = await browserPdf(ref);
550
+ if (!pdf)
551
+ warnings = [fallback("PDF"), ...warnings];
552
+ await fs.writeFile(file, pdf ?? toPdf(r.pres, r.deck.size ?? r.template.size, opts.width));
553
+ files.push(file);
554
+ }
555
+ else {
556
+ const slides = path.join(out, "slides");
557
+ await fs.rm(slides, { recursive: true, force: true });
558
+ await fs.mkdir(slides, { recursive: true });
559
+ const shots = await browserPngs(ref);
560
+ if (!shots)
561
+ warnings = [fallback("slide images"), ...warnings];
562
+ const pngs = shots ?? slidePngs(r.pres, opts.width ?? 1280);
563
+ for (const [i, png] of pngs.entries()) {
564
+ const file = path.join(slides, `${String(i + 1).padStart(2, "0")}.png`);
565
+ await fs.writeFile(file, png);
566
+ files.push(file);
567
+ }
568
+ }
569
+ changed();
570
+ return { files, warnings };
571
+ }
572
+ /** The bytes of an export for a download, without writing exports/. */
573
+ export async function exportBytes(ref, format) {
574
+ if (format === "pptx")
575
+ return { bytes: (await pptxBytes(ref)).bytes, mime: PPTX_MIME, filename: `${ref.name}.pptx` };
576
+ if (format === "html")
577
+ return { bytes: new TextEncoder().encode((await deckHtml(ref)).html), mime: "text/html; charset=utf-8", filename: `${ref.name}.html` };
578
+ const r = await render(ref);
579
+ return { bytes: (await browserPdf(ref)) ?? toPdf(r.pres, r.deck.size ?? r.template.size), mime: "application/pdf", filename: `${ref.name}.pdf` };
580
+ }
581
+ /* ---------- writes ---------- */
582
+ export async function createDeck(input) {
583
+ const title = (input.title ?? "").trim();
584
+ if (!title)
585
+ throw new Error("title is required");
586
+ const name = safeDeckSlug((input.slug ?? "").trim() || slugify(title) || "deck");
587
+ const ref = { ...(input.project ? { project: safeProjectSlug(input.project) } : {}), name };
588
+ const dir = await deckDir(ref);
589
+ if (await fs.stat(dir).catch(() => null))
590
+ throw new Error(`presentation "${deckKey(ref)}" already exists`);
591
+ let source;
592
+ if (typeof input.source === "string" && input.source.trim()) {
593
+ const deck = parseDeck(input.source);
594
+ if (!deck.title)
595
+ deck.title = title;
596
+ if (input.template)
597
+ deck.template = input.template;
598
+ source = serializeDeck(deck);
599
+ }
600
+ else
601
+ source = serializeDeck(starterDeck(title, (input.template ?? "default").trim() || "default"));
602
+ await fs.mkdir(path.join(dir, ASSETS_DIR), { recursive: true });
603
+ await fs.writeFile(path.join(dir, DECK_FILE), source, { flag: "wx" });
604
+ changed();
605
+ return (await getDeck(ref));
606
+ }
607
+ /** A save made over a deck.md that changed since the caller read it (an agent, another window). */
608
+ export class StaleDeckError extends Error {
609
+ current;
610
+ constructor(current) {
611
+ super("the presentation changed since you loaded it");
612
+ this.current = current;
613
+ }
614
+ }
615
+ export async function saveDeck(ref, input) {
616
+ const dir = await deckDir(ref);
617
+ const file = path.join(dir, DECK_FILE);
618
+ const raw = await fs.readFile(file, "utf8").catch(() => null);
619
+ if (raw === null)
620
+ throw new Error(`no presentation "${deckKey(ref)}"`);
621
+ if (input.base) {
622
+ const st = await fs.stat(file);
623
+ const now = new Date(st.mtimeMs).toISOString();
624
+ if (now !== input.base)
625
+ throw new StaleDeckError(now);
626
+ }
627
+ let next;
628
+ if (typeof input.source === "string") {
629
+ parseDeck(input.source); // must parse; the normalised form is not forced on a hand-written file
630
+ next = input.source.endsWith("\n") ? input.source : `${input.source}\n`;
631
+ }
632
+ else {
633
+ const deck = parseDeck(raw);
634
+ if (input.title !== undefined)
635
+ deck.title = String(input.title).trim() || deck.title;
636
+ if (input.template !== undefined)
637
+ deck.template = String(input.template).trim() || "default";
638
+ if (input.size !== undefined) {
639
+ if (input.size === "16:9" || input.size === "4:3")
640
+ deck.size = input.size;
641
+ else
642
+ delete deck.size;
643
+ }
644
+ if (input.numbers !== undefined) {
645
+ if (input.numbers === false)
646
+ deck.numbers = false;
647
+ else
648
+ delete deck.numbers;
649
+ }
650
+ if (input.slides !== undefined) {
651
+ if (!Array.isArray(input.slides))
652
+ throw new Error("slides must be a list");
653
+ deck.slides = input.slides.map((s) => ({
654
+ ...(s.layout ? { layout: String(s.layout) } : {}),
655
+ ...(s.notes?.trim() ? { notes: String(s.notes).trim() } : {}),
656
+ ...(s.background ? { background: String(s.background) } : {}),
657
+ ...(s.transition ? { transition: String(s.transition) } : {}),
658
+ extra: s.extra && typeof s.extra === "object" ? s.extra : {},
659
+ content: String(s.content ?? ""),
660
+ }));
661
+ }
662
+ next = serializeDeck(deck);
663
+ }
664
+ if (next !== raw)
665
+ await snapshot(dir, raw);
666
+ await fs.writeFile(file, next);
667
+ changed();
668
+ return (await getDeck(ref));
669
+ }
670
+ const ASSET_EXT = /\.(png|jpe?g|gif)$/i;
671
+ const MAX_ASSET_BYTES = 25 * 1024 * 1024;
672
+ /** Save an uploaded picture into the deck's assets/ (png, jpg, gif; 25 MB). Returns the path a slide references: `assets/<name>`. */
673
+ export async function saveAsset(ref, name, body) {
674
+ const dir = await deckDir(ref);
675
+ if (!(await fs.stat(path.join(dir, DECK_FILE)).catch(() => null)))
676
+ throw new Error(`no presentation "${deckKey(ref)}"`);
677
+ const clean = path.basename(name).replace(/[^\w.-]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
678
+ if (!ASSET_EXT.test(clean))
679
+ throw new Error("a picture must be a .png, .jpg or .gif file");
680
+ const assets = path.join(dir, ASSETS_DIR);
681
+ await fs.mkdir(assets, { recursive: true });
682
+ let final = clean;
683
+ for (let i = 2; await fs.stat(path.join(assets, final)).catch(() => null); i++)
684
+ final = clean.replace(/(\.[^.]+)$/, `-${i}$1`);
685
+ const tmp = path.join(assets, `.upload-${process.pid}-${Date.now()}`);
686
+ let size = 0;
687
+ body.on("data", (c) => {
688
+ size += c.length;
689
+ if (size > MAX_ASSET_BYTES)
690
+ body.destroy(new Error("picture too large (25 MB at most)"));
691
+ });
692
+ try {
693
+ await pipeline(body, createWriteStream(tmp));
694
+ if (size === 0)
695
+ throw new Error("empty file");
696
+ await fs.rename(tmp, path.join(assets, final));
697
+ }
698
+ catch (err) {
699
+ await fs.rm(tmp, { force: true });
700
+ throw err;
701
+ }
702
+ changed();
703
+ return { path: `${ASSETS_DIR}/${final}`, size };
704
+ }
705
+ /** Move the deck folder, assets and exports included, to the trash. */
706
+ export async function deleteDeck(ref) {
707
+ const d = await requireDeck(ref);
708
+ await moveToTrash("presentations", deckKey(ref), d.path);
709
+ cache.delete(d.path);
710
+ changed();
711
+ }
712
+ /* ---------- context for chats and agents ---------- */
713
+ const cliScope = (ref) => (ref.project ? `--project ${ref.project}` : "");
714
+ /**
715
+ * The "## Presentations" block of a project chat (its decks) or the
716
+ * workspace's: what exists, the file format in short, and the CLI.
717
+ */
718
+ export async function presentationsContext(project) {
719
+ const view = await listDecks(project).catch(() => ({ enabled: false, presentations: [] }));
720
+ if (!view.enabled)
721
+ return "";
722
+ const scope = project ? `--project ${project}` : "";
723
+ const list = view.presentations.length
724
+ ? (await Promise.all(view.presentations.map(async (p) => {
725
+ const open = (await readComments(p.path).catch(() => [])).filter((c) => !c.resolved).length;
726
+ return `- ${p.name}: "${p.title}" (${p.slides} slides, template ${p.template})${open ? `, ${open} open comment${open === 1 ? "" : "s"}` : ""}${p.error ? ` — broken: ${p.error}` : ""}`;
727
+ }))).join("\n")
728
+ : "(none yet)";
729
+ // The themes in use, with the pieces and the classes their CSS defines: what an agent reaches for in a slot's HTML.
730
+ const used = [...new Set(view.presentations.map((p) => p.template))];
731
+ const themeLines = [];
732
+ for (const slug of used.length ? used : ["default"]) {
733
+ const { template } = await templateFor(slug);
734
+ const classes = [...new Set([...(template.cssText ?? "").matchAll(/(?:^|[\s,}])\.([a-z][\w-]*)/g)].map((m) => m[1]))].filter((c) => !/^(deck-|layout-|slot-|kind-)/.test(c)).slice(0, 40);
735
+ themeLines.push(`- theme ${template.slug}${template.path ? ` (${path.dirname(template.path)})` : " (built in)"}: pieces ${template.snippets.map((x) => x.name).join(", ") || "none"}; classes ${classes.map((c) => `.${c}`).join(" ") || "none"}`);
736
+ }
737
+ return (`## Presentations${project ? "" : " (workspace)"}\n` +
738
+ `Slide decks are folders with a deck.md: headmatter (title, template, optional css), slides separated by \`---\` lines, an optional YAML block after the separator with \`layout:\` and \`slots:\`. ` +
739
+ `Content before the first \`::slot::\` marker is the title (a leading heading) and the layout's body; named slots are \`::left::\`, \`::image::\`, \`::chart::\` …; \`::notes::\` are the speaker notes. ` +
740
+ `Slides render as HTML in the template's theme (what the editor, present mode, PDF and PNG show), so a slot may hold markdown, raw HTML (the theme's classes: cards, kpis, flow, timeline, callout, compare, cols, statement), a picture \`![caption](assets/file.png)\`, a table, or a fenced \`chart\` block (YAML: kind column|bar|line|pie|doughnut|area, categories, series with name and values). ` +
741
+ `A slide may move or restyle a layout slot, or add boxes of its own, in its YAML head: \`slots: {title: {y: 1.4, size: 40}, box1: {kind: html, x: 1, y: 2, w: 4, h: 2}}\` filled by \`::box1::\` (kinds: text, markdown, image, chart, table, html, embed — embed is a URL or a whole page with scripts, sandboxed; box keys also: color, fill, font, align, valign, bold, italic, underline, rotate, radius, border, borderColor, shadow, opacity, z, fit). Positions are inches on a 10 × 5.625 canvas. \`background:\` takes a color or a picture (assets/x.jpg); \`hidden: true\` keeps a slide out of present mode and the exports.\n` +
742
+ `${list}\n` +
743
+ `${themeLines.join("\n")}\n` +
744
+ `Work with the CLI (${scope ? `${scope} on every command` : "no --project: these are the workspace decks"}):\n` +
745
+ `- \`npx kraftwerk presentations create "<title>" ${scope} --template default\` makes the folder; then write its deck.md directly (it prints the path) and put pictures into assets/\n` +
746
+ `- \`npx kraftwerk presentations show <name> ${scope}\` prints the layouts of the template with their slots, the theme's pieces, and every warning (empty required slot, unknown layout, missing image)\n` +
747
+ `- \`npx kraftwerk presentations check <name> ${scope}\` fails on errors; \`presentations render <name> --png ${scope}\` writes exports/slides/NN.png from the HTML — look at them to judge your slides, then fix the markdown\n` +
748
+ `- Comments: \`npx kraftwerk presentations comments <name> ${scope}\` lists the open ones (slide, box, author); when you have dealt with one, \`presentations resolve <name> <id> --reply "<what you changed>" ${scope}\`; \`presentations comment <name> <slide> "<text>" ${scope}\` leaves one for the humans.\n` +
749
+ `- \`npx kraftwerk presentations render <name> --pptx|--pdf|--html ${scope}\` writes the files a human will open; \`presentations templates\` lists the templates; a template is templates/<slug>/template.yml + theme.css (\`templates init <slug>\` copies the default).\n` +
750
+ `\`presentation:<name>\` in a message, a task's refs or a note points at one of these decks (open the folder it names); link a deck from a task with \`npx kraftwerk tasks set <n> --refs <the existing refs>,presentation:<name>\` (it replaces the list) and write \`presentation:<name>\` in your answers so people can click through.\n` +
751
+ `Keep one message per slide, title slides on the \`title\` layout, never more than six bullets in a body; prefer the theme's pieces over hand-made styling. The humans see the same render you do.`);
752
+ }
753
+ export { cliScope as presentationCliScope };