@netnodeag/kraftwerk 0.82.0 → 0.84.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/README.md +212 -11
- package/dist/cli/init.js +1 -0
- package/dist/cli/kraftwerk.js +3 -0
- package/dist/cli/presentations.d.ts +2 -0
- package/dist/cli/presentations.js +261 -0
- package/dist/client/routes.d.ts +18 -0
- package/dist/client/routes.js +18 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.js +10 -2
- package/dist/core/boards.d.ts +14 -1
- package/dist/core/boards.js +34 -1
- package/dist/core/chat/context.js +11 -2
- package/dist/core/git.js +3 -1
- package/dist/core/presentations/browser.d.ts +43 -0
- package/dist/core/presentations/browser.js +53 -0
- package/dist/core/presentations/builtin.d.ts +3 -0
- package/dist/core/presentations/builtin.js +142 -0
- package/dist/core/presentations/chart.d.ts +34 -0
- package/dist/core/presentations/chart.js +159 -0
- package/dist/core/presentations/deck.d.ts +63 -0
- package/dist/core/presentations/deck.js +198 -0
- package/dist/core/presentations/export.d.ts +21 -0
- package/dist/core/presentations/export.js +75 -0
- package/dist/core/presentations/html.d.ts +135 -0
- package/dist/core/presentations/html.js +389 -0
- package/dist/core/presentations/index.d.ts +252 -0
- package/dist/core/presentations/index.js +753 -0
- package/dist/core/presentations/layout.d.ts +47 -0
- package/dist/core/presentations/layout.js +147 -0
- package/dist/core/presentations/markdown.d.ts +49 -0
- package/dist/core/presentations/markdown.js +158 -0
- package/dist/core/presentations/merge.d.ts +26 -0
- package/dist/core/presentations/merge.js +28 -0
- package/dist/core/presentations/presence.d.ts +31 -0
- package/dist/core/presentations/presence.js +131 -0
- package/dist/core/presentations/render.d.ts +33 -0
- package/dist/core/presentations/render.js +318 -0
- package/dist/core/presentations/slots.d.ts +33 -0
- package/dist/core/presentations/slots.js +114 -0
- package/dist/core/presentations/template.d.ts +253 -0
- package/dist/core/presentations/template.js +141 -0
- package/dist/core/presentations/versions.d.ts +30 -0
- package/dist/core/presentations/versions.js +75 -0
- package/dist/core/refs.d.ts +1 -1
- package/dist/core/refs.js +9 -1
- package/dist/core/search.d.ts +10 -0
- package/dist/core/search.js +6 -0
- package/dist/core/settings.d.ts +2 -0
- package/dist/core/settings.js +12 -1
- package/dist/core/trash.d.ts +1 -1
- package/dist/server/api/index.d.ts +62 -1
- package/dist/server/api/index.js +2 -0
- package/dist/server/api/presentations.d.ts +66 -0
- package/dist/server/api/presentations.js +185 -0
- package/dist/server/api/socket.js +24 -1
- package/dist/server/api/workspace.d.ts +5 -0
- package/dist/server/api/workspace.js +2 -0
- package/package.json +6 -2
- package/schema/kraftwerk.schema.json +18 -0
- package/web/dist/assets/{dist-BBFUIftm.js → dist-3Yr8mX0X.js} +1 -1
- package/web/dist/assets/{dist-DtUB2Uu2.js → dist-BVzRayNB.js} +1 -1
- package/web/dist/assets/{dist-BuwdjX6z.js → dist-BdYm_4II.js} +1 -1
- package/web/dist/assets/{dist-C16bXf8c.js → dist-Bf3GuzEk.js} +1 -1
- package/web/dist/assets/{dist-Bie1ebP9.js → dist-DGymUpLv.js} +1 -1
- package/web/dist/assets/{dist-CH73jsgO.js → dist-DIvdTMOT.js} +1 -1
- package/web/dist/assets/{dist-DvkrCSGL.js → dist-DchG_zAX.js} +1 -1
- package/web/dist/assets/{dist-C0ve4Tka.js → dist-Dt9RqYvy.js} +1 -1
- package/web/dist/assets/dist-m1b2E3aJ.js +1 -0
- package/web/dist/assets/{dist-C_rJjRj7.js → dist-mxFa618U.js} +1 -1
- package/web/dist/assets/{dist-CDUZdAAS.js → dist-xXM6FJLm.js} +1 -1
- package/web/dist/assets/{editor-3z92i0tV.js → editor-DYDCHRgT.js} +3 -3
- package/web/dist/assets/index-CvvZzwHR.js +473 -0
- package/web/dist/assets/index-JhhhmD7T.css +2 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/dist-DYICNp09.js +0 -1
- package/web/dist/assets/index-DRhNELK_.js +0 -232
- package/web/dist/assets/index-unGEux3Y.css +0 -2
package/dist/config.d.ts
CHANGED
|
@@ -153,6 +153,20 @@ export declare const BOARDS_DEFAULT_ROOT = "kraftwerk-data/boards";
|
|
|
153
153
|
/** Absolute workspace boards root when the feature is on, undefined otherwise. */
|
|
154
154
|
export declare function boardsRootFor(project: ResolvedWorkspace): string | undefined;
|
|
155
155
|
export type EntityKind = (typeof ENTITY_KINDS)[number];
|
|
156
|
+
/**
|
|
157
|
+
* Presentations: slide decks as folders (deck.md, assets/, exports/) under a
|
|
158
|
+
* project (projects/<p>/presentations/) or the workspace root below. Part of
|
|
159
|
+
* the workspace and synced by the workspace git.
|
|
160
|
+
*/
|
|
161
|
+
export interface PresentationsConfig {
|
|
162
|
+
/** false keeps the block but turns the feature off. Default: true. */
|
|
163
|
+
enabled?: boolean;
|
|
164
|
+
/** Where the workspace decks (and templates/) live, relative to the project root. Default: kraftwerk-data/presentations */
|
|
165
|
+
root?: string;
|
|
166
|
+
}
|
|
167
|
+
export declare const PRESENTATIONS_DEFAULT_ROOT = "kraftwerk-data/presentations";
|
|
168
|
+
/** Absolute workspace presentations root when the feature is on, undefined otherwise. */
|
|
169
|
+
export declare function presentationsRootFor(project: ResolvedWorkspace): string | undefined;
|
|
156
170
|
/** Where a kind's files live when its `root` is not set. */
|
|
157
171
|
export declare const entityDefaultRoot: (kind: EntityKind) => string;
|
|
158
172
|
/** Absolute root of a kind when its feature is on, undefined otherwise. */
|
|
@@ -237,6 +251,8 @@ export interface WorkspaceConfig {
|
|
|
237
251
|
events?: EntitiesConfig;
|
|
238
252
|
/** Boards: tasks as folders in columns, per project and workspace-wide. Absent = off. */
|
|
239
253
|
boards?: BoardsConfig;
|
|
254
|
+
/** Presentations: slide decks as folders, per project and workspace-wide. Absent = off. */
|
|
255
|
+
presentations?: PresentationsConfig;
|
|
240
256
|
/** The machine's cloud record lists this workspace. Absent = listed; `enabled: false` leaves it out. */
|
|
241
257
|
cloud?: CloudConfig;
|
|
242
258
|
}
|
package/dist/config.js
CHANGED
|
@@ -105,6 +105,14 @@ export function boardsRootFor(project) {
|
|
|
105
105
|
return undefined;
|
|
106
106
|
return path.resolve(project.root, b.root ?? BOARDS_DEFAULT_ROOT);
|
|
107
107
|
}
|
|
108
|
+
export const PRESENTATIONS_DEFAULT_ROOT = "kraftwerk-data/presentations";
|
|
109
|
+
/** Absolute workspace presentations root when the feature is on, undefined otherwise. */
|
|
110
|
+
export function presentationsRootFor(project) {
|
|
111
|
+
const b = project.config.presentations;
|
|
112
|
+
if (!b || b.enabled === false)
|
|
113
|
+
return undefined;
|
|
114
|
+
return path.resolve(project.root, b.root ?? PRESENTATIONS_DEFAULT_ROOT);
|
|
115
|
+
}
|
|
108
116
|
/** Where a kind's files live when its `root` is not set. */
|
|
109
117
|
export const entityDefaultRoot = (kind) => `kraftwerk-data/${kind}`;
|
|
110
118
|
/** Absolute root of a kind when its feature is on, undefined otherwise. */
|
|
@@ -249,7 +257,7 @@ export async function addWorkspaceId(configPath) {
|
|
|
249
257
|
await writeFile(configPath, out);
|
|
250
258
|
return id;
|
|
251
259
|
}
|
|
252
|
-
const KNOWN_KEYS = ["id", "name", "slug", "icon", "color", "port", "workflows", "output", "knowledge", "agents", "skills", "switcher", "git", "repos", "vibeables", "projects", "contacts", "places", "events", "boards", "cloud"];
|
|
260
|
+
const KNOWN_KEYS = ["id", "name", "slug", "icon", "color", "port", "workflows", "output", "knowledge", "agents", "skills", "switcher", "git", "repos", "vibeables", "projects", "contacts", "places", "events", "boards", "presentations", "cloud"];
|
|
253
261
|
/**
|
|
254
262
|
* Keys an older kraftwerk understood and this one ignores, so the files
|
|
255
263
|
* that still carry them keep loading: `public:` and `tunnel:` (the
|
|
@@ -316,7 +324,7 @@ async function loadConfig(configPath) {
|
|
|
316
324
|
config[key] = {};
|
|
317
325
|
validateRootBlock(configPath, "vibeables", config[key]);
|
|
318
326
|
}
|
|
319
|
-
else if (key === "projects" || key === "contacts" || key === "places" || key === "events") {
|
|
327
|
+
else if (key === "projects" || key === "contacts" || key === "places" || key === "events" || key === "presentations") {
|
|
320
328
|
if (config[key] === null)
|
|
321
329
|
config[key] = {};
|
|
322
330
|
validateRootBlock(configPath, key, config[key]);
|
package/dist/core/boards.d.ts
CHANGED
|
@@ -252,5 +252,18 @@ export declare function noteTaskFile(reference: string, what: "added" | "removed
|
|
|
252
252
|
* and the unassigned ones in the pick column.
|
|
253
253
|
*/
|
|
254
254
|
export declare function boardsContext(project: string | undefined, actor: string, agent?: string): Promise<string>;
|
|
255
|
-
/**
|
|
255
|
+
/** A task that links something, as the linked thing's page lists it. */
|
|
256
|
+
export interface LinkingTask {
|
|
257
|
+
ref: string;
|
|
258
|
+
number: number;
|
|
259
|
+
title: string;
|
|
260
|
+
status: string;
|
|
261
|
+
assignee?: string;
|
|
262
|
+
board: string;
|
|
263
|
+
project?: string;
|
|
264
|
+
/** The task's page (a hash route). */
|
|
265
|
+
href: string;
|
|
266
|
+
}
|
|
267
|
+
/** Every task whose refs name the token (presentation:town-hall), across the workspace's boards. */
|
|
268
|
+
export declare function tasksReferencing(token: string): Promise<LinkingTask[]>;
|
|
256
269
|
export declare function taskContext(reference: string): Promise<string>;
|
package/dist/core/boards.js
CHANGED
|
@@ -7,7 +7,7 @@ import { getOutputDir, workspaceRoot } from "./context.js";
|
|
|
7
7
|
import { mergeDays } from "./journal.js";
|
|
8
8
|
import { newestMtime } from "./mtime.js";
|
|
9
9
|
import { openProjects, safeProjectSlug } from "./projects.js";
|
|
10
|
-
import { findRefs } from "./refs.js";
|
|
10
|
+
import { findRefs, resolveTokens } from "./refs.js";
|
|
11
11
|
import { SLUG_RE, slugify } from "./slug.js";
|
|
12
12
|
import { moveToTrash } from "./trash.js";
|
|
13
13
|
/**
|
|
@@ -917,6 +917,38 @@ export async function boardsContext(project, actor, agent) {
|
|
|
917
917
|
return blocks.join("\n\n");
|
|
918
918
|
}
|
|
919
919
|
/** The block a session gets when it was opened for one task: the task, its files and its whole log. */
|
|
920
|
+
/** The task's refs for its agent: each target with its label, a deck with its folder and how to open it. */
|
|
921
|
+
async function linkedBlock(refs) {
|
|
922
|
+
const parsed = refs.flatMap((r) => findRefs(r)).map((r) => ({ kind: r.kind, slug: r.slug }));
|
|
923
|
+
if (!parsed.length)
|
|
924
|
+
return "";
|
|
925
|
+
const resolved = await resolveTokens(parsed).catch(() => []);
|
|
926
|
+
const { listAllDecks, presentationCliScope } = await import("./presentations/index.js");
|
|
927
|
+
const decks = resolved.some((r) => r.kind === "presentations") ? await listAllDecks().catch(() => []) : [];
|
|
928
|
+
const lines = resolved.map((r) => {
|
|
929
|
+
if (!r.found)
|
|
930
|
+
return `- ${r.token} — not found (renamed or removed?)`;
|
|
931
|
+
const deck = r.kind === "presentations" ? decks.find((d) => d.name === r.slug) : undefined;
|
|
932
|
+
return deck
|
|
933
|
+
? `- ${r.token} — "${deck.title}"${deck.project ? ` in project ${deck.project}` : ""}, ${deck.slides} slides, folder ${deck.path} (\`npx kraftwerk presentations show ${deck.name}${deck.project ? ` ${presentationCliScope({ name: deck.name, project: deck.project })}` : ""}\`)`
|
|
934
|
+
: `- ${r.token}${r.label ? ` — ${r.label}` : ""}`;
|
|
935
|
+
});
|
|
936
|
+
return `\n### Linked\n${lines.join("\n")}\n`;
|
|
937
|
+
}
|
|
938
|
+
/** Every task whose refs name the token (presentation:town-hall), across the workspace's boards. */
|
|
939
|
+
export async function tasksReferencing(token) {
|
|
940
|
+
const out = [];
|
|
941
|
+
for (const b of await listAllBoards().catch(() => [])) {
|
|
942
|
+
const detail = await getBoard(b).catch(() => null);
|
|
943
|
+
for (const t of detail?.items ?? []) {
|
|
944
|
+
if (!t.refs.includes(token))
|
|
945
|
+
continue;
|
|
946
|
+
const base = b.project ? `/projects/${b.project}/boards/${b.board}` : `/boards/${b.board}`;
|
|
947
|
+
out.push({ ref: t.ref, number: t.number, title: t.title, status: t.status, ...(t.assignee ? { assignee: t.assignee } : {}), board: b.board, ...(b.project ? { project: b.project } : {}), href: `${base}/${t.slug}` });
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return out;
|
|
951
|
+
}
|
|
920
952
|
export async function taskContext(reference) {
|
|
921
953
|
const t = await findTask(reference);
|
|
922
954
|
if (!t)
|
|
@@ -928,6 +960,7 @@ export async function taskContext(reference) {
|
|
|
928
960
|
`Board ${boardKey(ref)}${board ? ` (columns: ${cols})` : ""}; status ${t.status}${t.assignee ? `, assigned to ${t.assignee}` : ""}${t.due ? `, due ${t.due}` : ""}. Folder: ${t.path}\n` +
|
|
929
961
|
(board?.notes.trim() ? `Board rules: ${board.notes.trim()}\n` : "") +
|
|
930
962
|
`\n### task.md\n${t.notes.trim() || "(no description — ask the user what done looks like and write it with `tasks set <n> --notes-file`)"}\n` +
|
|
963
|
+
(await linkedBlock(t.refs)) +
|
|
931
964
|
`\n### Files\n${t.fileList.length ? t.fileList.map((f) => `- ${f}`).join("\n") : "(none yet)"}\n` +
|
|
932
965
|
`\n### Log (newest first)\n${t.log.trim() || "(empty)"}\n\n` +
|
|
933
966
|
`Work it through the CLI (${cliBoard(ref)}, the number ${t.number} names the task): \`npx kraftwerk tasks move ${t.number} progress ${cliBoard(ref)}\` when you start, ` +
|
|
@@ -9,6 +9,7 @@ import { listVibeables, vibeableStatus, VIBEABLE_CONFIG_FILE } from "../vibeable
|
|
|
9
9
|
import { projectContext } from "../projects.js";
|
|
10
10
|
import { entitiesContext } from "../entities.js";
|
|
11
11
|
import { boardsContext, taskContext } from "../boards.js";
|
|
12
|
+
import { presentationsContext } from "../presentations/index.js";
|
|
12
13
|
import { unattendedTimeoutLabel } from "./permissions.js";
|
|
13
14
|
import { getChannel } from "../channels.js";
|
|
14
15
|
import { JOURNAL_FILE, journalExcerpt, readJournal } from "../journal.js";
|
|
@@ -396,7 +397,7 @@ export async function scopeContext(meta, seat) {
|
|
|
396
397
|
const agent = seat.harness;
|
|
397
398
|
// The repositories block reads every clone from git, so it runs alongside
|
|
398
399
|
// the rest instead of adding its spawns to the first prompt's latency.
|
|
399
|
-
const [base, repos, vibe, skills, channel, project, entities, boards] = await Promise.all([
|
|
400
|
+
const [base, repos, vibe, skills, channel, project, entities, boards, decks] = await Promise.all([
|
|
400
401
|
baseScopeContext(scope, agent),
|
|
401
402
|
scope.kind === "agent" || scope.kind === "kraftwerk" ? reposContext() : Promise.resolve(""),
|
|
402
403
|
meta.vibeable ? vibeableContext(meta.vibeable, meta.cwd) : Promise.resolve(""),
|
|
@@ -414,13 +415,21 @@ export async function scopeContext(meta, seat) {
|
|
|
414
415
|
.then((xs) => xs.filter(Boolean).join("\n\n"))
|
|
415
416
|
.catch(() => "")
|
|
416
417
|
: Promise.resolve(""),
|
|
418
|
+
// Presentations: a project chat sees the project's decks; an agent the workspace's, plus its project's when filed under one.
|
|
419
|
+
scope.kind === "project"
|
|
420
|
+
? presentationsContext(scope.slug).catch(() => "")
|
|
421
|
+
: scope.kind === "agent"
|
|
422
|
+
? Promise.all([presentationsContext(undefined), meta.project ? presentationsContext(meta.project) : Promise.resolve("")])
|
|
423
|
+
.then((xs) => xs.filter(Boolean).join("\n\n"))
|
|
424
|
+
.catch(() => "")
|
|
425
|
+
: Promise.resolve(""),
|
|
417
426
|
]);
|
|
418
427
|
// Every session has a scratch folder of its own (core/temp.ts), named by its absolute path: a run chat or a
|
|
419
428
|
// vibeable session works in another folder than the workspace root. The block comes after the files blocks it refers to.
|
|
420
429
|
const temp = await sessionTemp(meta.id).catch(() => null);
|
|
421
430
|
// "Work on this" from a task page: the chat is tagged with the task (meta.task) and reads it like the agent's own task session would.
|
|
422
431
|
const task = meta.task && !(scope.kind === "agent" && scope.task === meta.task) ? await taskContext(meta.task).catch(() => "") : "";
|
|
423
|
-
return [base, channel, project, boards, task, repos, entities, vibe, temp ? tempContext(temp.abs) : "", RENDERING_BLOCK, skillsBlock(skills)].filter(Boolean).join("\n\n");
|
|
432
|
+
return [base, channel, project, boards, task, decks, repos, entities, vibe, temp ? tempContext(temp.abs) : "", RENDERING_BLOCK, skillsBlock(skills)].filter(Boolean).join("\n\n");
|
|
424
433
|
}
|
|
425
434
|
/** The channel block a member agent gets once per process: who is here, how turns work, how to hand over. */
|
|
426
435
|
async function channelContext(slug, self) {
|
package/dist/core/git.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { realpathSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { boardsRootFor, ENTITY_KINDS, entitiesRootFor, projectsRootFor, reposRootFor, resolveWorkspace, vibeablesRootFor, isSafeGitName } from "../config.js";
|
|
4
|
+
import { boardsRootFor, presentationsRootFor, ENTITY_KINDS, entitiesRootFor, projectsRootFor, reposRootFor, resolveWorkspace, vibeablesRootFor, isSafeGitName } from "../config.js";
|
|
5
5
|
import { ENV_FILE } from "../runner/docker.js";
|
|
6
6
|
import { getOutputDir, workspaceRoot } from "./context.js";
|
|
7
7
|
import { perWorkspace, workspaceOpen } from "./workspace.js";
|
|
@@ -243,6 +243,8 @@ function scopeFor({ project, repoRoot }) {
|
|
|
243
243
|
...ENTITY_KINDS.map((kind) => entitiesRootFor(project, kind)),
|
|
244
244
|
// Workspace boards: tasks, logs and their files (project boards sit inside the projects root).
|
|
245
245
|
boardsRootFor(project),
|
|
246
|
+
// Workspace presentations: decks, their assets and templates (project decks sit inside the projects root).
|
|
247
|
+
presentationsRootFor(project),
|
|
246
248
|
// Workspace files: shared material, versioned (files over 25 MB ignore themselves, see files.ts).
|
|
247
249
|
path.resolve(project.root, "kraftwerk-data/files"),
|
|
248
250
|
project.configPath,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A headless browser for the exports that need the HTML drawn: slide PNGs
|
|
3
|
+
* (what an agent looks at), the PDF, and the HTML pieces of a PowerPoint
|
|
4
|
+
* file. playwright-core drives it — its own downloaded Chromium when the
|
|
5
|
+
* machine has one (`npx playwright install chromium`), else the installed
|
|
6
|
+
* Google Chrome. Without either, callers fall back to the PowerPoint
|
|
7
|
+
* model's raster (core/presentations/export.ts) and say so.
|
|
8
|
+
*/
|
|
9
|
+
type Page = {
|
|
10
|
+
setViewportSize(s: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
goto(url: string, o?: {
|
|
15
|
+
waitUntil?: "load" | "networkidle";
|
|
16
|
+
}): Promise<unknown>;
|
|
17
|
+
emulateMedia(o: {
|
|
18
|
+
media: "print" | "screen";
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
locator(sel: string): {
|
|
21
|
+
nth(i: number): {
|
|
22
|
+
screenshot(o?: {
|
|
23
|
+
type?: "png";
|
|
24
|
+
omitBackground?: boolean;
|
|
25
|
+
}): Promise<Buffer>;
|
|
26
|
+
};
|
|
27
|
+
count(): Promise<number>;
|
|
28
|
+
};
|
|
29
|
+
pdf(o: Record<string, unknown>): Promise<Buffer>;
|
|
30
|
+
evaluate<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
31
|
+
};
|
|
32
|
+
/** Why the last launch failed (for the fallback's warning). */
|
|
33
|
+
export declare const browserProblem: () => string;
|
|
34
|
+
/**
|
|
35
|
+
* Open a standalone deck HTML (from html.ts) in print layout — every slide
|
|
36
|
+
* stacked at its stage size, no scaling — and hand the page over. Null
|
|
37
|
+
* when no browser can be started.
|
|
38
|
+
*/
|
|
39
|
+
export declare function withDeckPage<T>(html: string, size: {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
}, fn: (page: Page) => Promise<T>): Promise<T | null>;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
let reason = "";
|
|
6
|
+
/** Why the last launch failed (for the fallback's warning). */
|
|
7
|
+
export const browserProblem = () => reason;
|
|
8
|
+
async function launch() {
|
|
9
|
+
let pw;
|
|
10
|
+
try {
|
|
11
|
+
pw = (await import("playwright-core"));
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
reason = "playwright-core is not installed";
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const errors = [];
|
|
18
|
+
for (const opts of [{}, { channel: "chrome" }, { channel: "msedge" }]) {
|
|
19
|
+
try {
|
|
20
|
+
return await pw.chromium.launch({ headless: true, ...opts });
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
errors.push(err.message.split("\n")[0]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
reason = `no browser to render with (run \`npx playwright install chromium\` or install Google Chrome): ${errors[0] ?? ""}`;
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Open a standalone deck HTML (from html.ts) in print layout — every slide
|
|
31
|
+
* stacked at its stage size, no scaling — and hand the page over. Null
|
|
32
|
+
* when no browser can be started.
|
|
33
|
+
*/
|
|
34
|
+
export async function withDeckPage(html, size, fn) {
|
|
35
|
+
const browser = await launch();
|
|
36
|
+
if (!browser)
|
|
37
|
+
return null;
|
|
38
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "kraftwerk-deck-"));
|
|
39
|
+
const file = path.join(dir, "deck.html");
|
|
40
|
+
try {
|
|
41
|
+
await fs.writeFile(file, html);
|
|
42
|
+
const page = await browser.newPage();
|
|
43
|
+
await page.setViewportSize(size);
|
|
44
|
+
await page.emulateMedia({ media: "print" });
|
|
45
|
+
await page.goto(pathToFileURL(file).href, { waitUntil: "load" });
|
|
46
|
+
await page.evaluate(() => document.fonts.ready.then(() => true));
|
|
47
|
+
return await fn(page);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
await browser.close().catch(() => { });
|
|
51
|
+
await fs.rm(dir, { recursive: true, force: true }).catch(() => { });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Template } from "./template.js";
|
|
2
|
+
export declare const DEFAULT_CSS = "/* kraftwerk default theme: the slides' look. Scoped to the slide; every class here can be used in a slot's HTML. */\n.eyebrow { text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600; }\n.statement { letter-spacing: -0.02em; line-height: 1.15; }\n.muted { color: var(--c-muted); }\n.accent { color: var(--c-accent); }\n.small { font-size: 0.8em; }\n\n.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 0.9em; }\n.card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 0.5em; padding: 0.9em 1em; }\n.card h3 { font-size: 1em; margin: 0 0 0.3em; }\n.card p { color: var(--c-muted); font-size: 0.82em; line-height: 1.35; }\n.card .num { display: block; font-size: 1.6em; font-weight: 700; color: var(--c-accent); line-height: 1; margin-bottom: 0.35em; letter-spacing: -0.02em; }\n\n.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 1.2em; }\n.kpi { border-top: 3px solid var(--c-accent); padding-top: 0.5em; }\n.kpi strong { display: block; font-family: var(--font-heading); font-size: 2.4em; line-height: 1; letter-spacing: -0.03em; }\n.kpi span { display: block; margin-top: 0.35em; color: var(--c-muted); font-size: 0.8em; }\n\n.flow { display: flex; align-items: stretch; gap: 0.6em; }\n.flow .arrow { align-self: center; color: var(--c-muted); font-size: 1.3em; }\n.box { flex: 1; border-radius: 0.5em; padding: 0.8em 0.9em; font-weight: 600; display: flex; flex-direction: column; justify-content: center; font-size: 0.9em; }\n.box small { display: block; font-weight: 400; color: var(--c-muted); font-size: 0.8em; margin-top: 0.25em; }\n.box.ghost { border: 1px dashed #c3c2b7; color: var(--c-muted); }\n.box.solid { border: 1px solid var(--c-line); background: var(--c-surface); }\n.box.accent { border: 1px solid var(--c-accent); background: color-mix(in srgb, var(--c-accent) 10%, transparent); }\n\n.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 1.6em; }\n.cols h3 { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-accent); margin-bottom: 0.4em; }\n.cols p { font-size: 0.9em; }\n\n.timeline { list-style: none; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.8em; border-top: 2px solid var(--c-line); }\n.timeline li { position: relative; padding-top: 0.9em; margin: 0; }\n.timeline li::before { content: \"\"; position: absolute; top: -0.42em; left: 0; width: 0.7em; height: 0.7em; border-radius: 50%; background: var(--c-accent); }\n.timeline b { display: block; color: var(--c-accent); }\n.timeline span { display: block; font-size: 0.82em; color: var(--c-muted); margin-top: 0.2em; }\n\n.callout { border-left: 4px solid var(--c-accent); background: color-mix(in srgb, var(--c-accent) 8%, transparent); padding: 0.7em 1em; border-radius: 0 0.4em 0.4em 0; }\n.pill { display: inline-block; border: 1px solid var(--c-line); border-radius: 999px; padding: 0.15em 0.65em; font-size: 0.75em; color: var(--c-muted); }\n.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2em; }\n.compare > div { border-radius: 0.5em; padding: 0.9em 1em; background: var(--c-surface); border: 1px solid var(--c-line); }\n.compare > div:last-child { border-color: var(--c-accent); }\n.compare h3 { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.5em; }\n\n/* The slide number, bottom right, on every slide but the title and section slides. */\n&[data-nn]:not(.layout-title):not(.layout-section)::after { content: attr(data-nn); position: absolute; right: 72px; bottom: 30px; font-size: 18px; color: var(--c-muted); font-variant-numeric: tabular-nums; }\n";
|
|
3
|
+
export declare const DEFAULT_TEMPLATE: Template;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in template: a calm, light look (warm page, ink, one accent,
|
|
3
|
+
* hairlines) with ten layouts on a 16:9 canvas, the theme CSS that styles
|
|
4
|
+
* the HTML slides, and snippets for the editor's insert menu. Workspace
|
|
5
|
+
* templates copy its shape (`kraftwerk presentations templates init`).
|
|
6
|
+
*/
|
|
7
|
+
const slot = (kind, x, y, w, h, more = {}) => ({ kind, x, y, w, h, ...more });
|
|
8
|
+
/** The head of a content slide: the title, a small label at the right, a hairline under both. */
|
|
9
|
+
const head = () => ({
|
|
10
|
+
slots: {
|
|
11
|
+
title: slot("text", 0.44, 0.28, 7.3, 0.8, { size: 24, bold: true, font: "heading", color: "text", valign: "bottom", placeholder: "Title" }),
|
|
12
|
+
eyebrow: slot("text", 7.74, 0.28, 1.82, 0.8, { size: 9, color: "muted", align: "right", valign: "bottom", class: "eyebrow", placeholder: "Label" }),
|
|
13
|
+
},
|
|
14
|
+
shapes: [{ kind: "rect", x: 0.54, y: 1.12, w: 8.92, h: 0.012, fill: "line" }],
|
|
15
|
+
});
|
|
16
|
+
const withHead = (description, slots, extra = {}) => {
|
|
17
|
+
const h = head();
|
|
18
|
+
return { description, shapes: h.shapes, slots: { ...h.slots, ...slots }, ...extra };
|
|
19
|
+
};
|
|
20
|
+
export const DEFAULT_CSS = `/* kraftwerk default theme: the slides' look. Scoped to the slide; every class here can be used in a slot's HTML. */
|
|
21
|
+
.eyebrow { text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600; }
|
|
22
|
+
.statement { letter-spacing: -0.02em; line-height: 1.15; }
|
|
23
|
+
.muted { color: var(--c-muted); }
|
|
24
|
+
.accent { color: var(--c-accent); }
|
|
25
|
+
.small { font-size: 0.8em; }
|
|
26
|
+
|
|
27
|
+
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 0.9em; }
|
|
28
|
+
.card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 0.5em; padding: 0.9em 1em; }
|
|
29
|
+
.card h3 { font-size: 1em; margin: 0 0 0.3em; }
|
|
30
|
+
.card p { color: var(--c-muted); font-size: 0.82em; line-height: 1.35; }
|
|
31
|
+
.card .num { display: block; font-size: 1.6em; font-weight: 700; color: var(--c-accent); line-height: 1; margin-bottom: 0.35em; letter-spacing: -0.02em; }
|
|
32
|
+
|
|
33
|
+
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 1.2em; }
|
|
34
|
+
.kpi { border-top: 3px solid var(--c-accent); padding-top: 0.5em; }
|
|
35
|
+
.kpi strong { display: block; font-family: var(--font-heading); font-size: 2.4em; line-height: 1; letter-spacing: -0.03em; }
|
|
36
|
+
.kpi span { display: block; margin-top: 0.35em; color: var(--c-muted); font-size: 0.8em; }
|
|
37
|
+
|
|
38
|
+
.flow { display: flex; align-items: stretch; gap: 0.6em; }
|
|
39
|
+
.flow .arrow { align-self: center; color: var(--c-muted); font-size: 1.3em; }
|
|
40
|
+
.box { flex: 1; border-radius: 0.5em; padding: 0.8em 0.9em; font-weight: 600; display: flex; flex-direction: column; justify-content: center; font-size: 0.9em; }
|
|
41
|
+
.box small { display: block; font-weight: 400; color: var(--c-muted); font-size: 0.8em; margin-top: 0.25em; }
|
|
42
|
+
.box.ghost { border: 1px dashed #c3c2b7; color: var(--c-muted); }
|
|
43
|
+
.box.solid { border: 1px solid var(--c-line); background: var(--c-surface); }
|
|
44
|
+
.box.accent { border: 1px solid var(--c-accent); background: color-mix(in srgb, var(--c-accent) 10%, transparent); }
|
|
45
|
+
|
|
46
|
+
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 1.6em; }
|
|
47
|
+
.cols h3 { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-accent); margin-bottom: 0.4em; }
|
|
48
|
+
.cols p { font-size: 0.9em; }
|
|
49
|
+
|
|
50
|
+
.timeline { list-style: none; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.8em; border-top: 2px solid var(--c-line); }
|
|
51
|
+
.timeline li { position: relative; padding-top: 0.9em; margin: 0; }
|
|
52
|
+
.timeline li::before { content: ""; position: absolute; top: -0.42em; left: 0; width: 0.7em; height: 0.7em; border-radius: 50%; background: var(--c-accent); }
|
|
53
|
+
.timeline b { display: block; color: var(--c-accent); }
|
|
54
|
+
.timeline span { display: block; font-size: 0.82em; color: var(--c-muted); margin-top: 0.2em; }
|
|
55
|
+
|
|
56
|
+
.callout { border-left: 4px solid var(--c-accent); background: color-mix(in srgb, var(--c-accent) 8%, transparent); padding: 0.7em 1em; border-radius: 0 0.4em 0.4em 0; }
|
|
57
|
+
.pill { display: inline-block; border: 1px solid var(--c-line); border-radius: 999px; padding: 0.15em 0.65em; font-size: 0.75em; color: var(--c-muted); }
|
|
58
|
+
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2em; }
|
|
59
|
+
.compare > div { border-radius: 0.5em; padding: 0.9em 1em; background: var(--c-surface); border: 1px solid var(--c-line); }
|
|
60
|
+
.compare > div:last-child { border-color: var(--c-accent); }
|
|
61
|
+
.compare h3 { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.5em; }
|
|
62
|
+
|
|
63
|
+
/* The slide number, bottom right, on every slide but the title and section slides. */
|
|
64
|
+
&[data-nn]:not(.layout-title):not(.layout-section)::after { content: attr(data-nn); position: absolute; right: 72px; bottom: 30px; font-size: 18px; color: var(--c-muted); font-variant-numeric: tabular-nums; }
|
|
65
|
+
`;
|
|
66
|
+
export const DEFAULT_TEMPLATE = {
|
|
67
|
+
slug: "default",
|
|
68
|
+
name: "Default",
|
|
69
|
+
builtin: true,
|
|
70
|
+
size: "16:9",
|
|
71
|
+
fonts: { heading: "Helvetica Neue", body: "Helvetica Neue" },
|
|
72
|
+
colors: { background: "#F9F9F7", surface: "#FFFFFF", text: "#161310", muted: "#6F6D67", accent: "#0284C7", onAccent: "#FFFFFF", line: "#E1E0D9" },
|
|
73
|
+
default: "content",
|
|
74
|
+
cssText: DEFAULT_CSS,
|
|
75
|
+
layouts: {
|
|
76
|
+
title: {
|
|
77
|
+
description: "Opening slide: a big title with a line above and a footer",
|
|
78
|
+
shapes: [{ kind: "rect", x: 0.54, y: 4.72, w: 8.92, h: 0.012, fill: "line" }],
|
|
79
|
+
slots: {
|
|
80
|
+
kicker: slot("text", 0.44, 1.45, 9.12, 0.5, { size: 13, color: "muted", placeholder: "What this is about" }),
|
|
81
|
+
title: slot("text", 0.44, 1.95, 9.12, 1.75, { size: 50, bold: true, font: "heading", color: "text", valign: "top", required: true, class: "statement", placeholder: "Title" }),
|
|
82
|
+
subtitle: slot("text", 0.44, 3.7, 9.12, 0.6, { size: 16, color: "muted", placeholder: "Subtitle" }),
|
|
83
|
+
foot: slot("text", 0.44, 4.8, 9.12, 0.5, { size: 10, color: "muted", placeholder: "Who · where · when" }),
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
section: {
|
|
87
|
+
description: "Divider between parts, on dark",
|
|
88
|
+
background: "text",
|
|
89
|
+
shapes: [{ kind: "rect", x: 0.54, y: 2.1, w: 0.9, h: 0.05, fill: "accent" }],
|
|
90
|
+
slots: {
|
|
91
|
+
eyebrow: slot("text", 0.44, 1.6, 9.12, 0.45, { size: 11, color: "accent", class: "eyebrow", placeholder: "Part 1" }),
|
|
92
|
+
title: slot("text", 0.44, 2.3, 9.12, 1.4, { size: 40, bold: true, font: "heading", color: "background", valign: "top", required: true, class: "statement", placeholder: "Section title" }),
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
content: withHead("Title and a body of text, lists or HTML", {
|
|
96
|
+
body: slot("markdown", 0.44, 1.32, 9.12, 3.95, { size: 15, color: "text", required: true, placeholder: "The slide's text, lists or a table" }),
|
|
97
|
+
}),
|
|
98
|
+
statement: {
|
|
99
|
+
description: "One sentence that carries the slide",
|
|
100
|
+
shapes: [],
|
|
101
|
+
slots: {
|
|
102
|
+
eyebrow: slot("text", 0.44, 1.2, 9.12, 0.45, { size: 11, color: "accent", class: "eyebrow", placeholder: "In one sentence" }),
|
|
103
|
+
title: slot("text", 0.44, 1.7, 8.4, 2.6, { size: 34, bold: true, font: "heading", color: "text", valign: "top", required: true, class: "statement", placeholder: "The statement" }),
|
|
104
|
+
note: slot("markdown", 0.44, 4.4, 9.12, 0.85, { size: 13, color: "muted", placeholder: "Why it matters" }),
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
"two-column": withHead("Title with a left and a right column", {
|
|
108
|
+
left: slot("markdown", 0.44, 1.32, 4.46, 3.95, { size: 14, color: "text", required: true }),
|
|
109
|
+
right: slot("markdown", 5.1, 1.32, 4.46, 3.95, { size: 14, color: "text", required: true }),
|
|
110
|
+
}),
|
|
111
|
+
image: withHead("Title, text on the left, a picture on the right", {
|
|
112
|
+
body: slot("markdown", 0.44, 1.32, 4.1, 3.95, { size: 14, color: "text" }),
|
|
113
|
+
image: slot("image", 4.74, 1.32, 4.82, 3.95, { required: true, placeholder: "" }),
|
|
114
|
+
}),
|
|
115
|
+
chart: withHead("Title, a chart, a caption below it", {
|
|
116
|
+
chart: slot("chart", 0.44, 1.32, 9.12, 3.45, { size: 11, required: true, placeholder: "```chart\nkind: column\ncategories: [Q1, Q2]\nseries:\n - name: Revenue\n values: [120, 180]\n```" }),
|
|
117
|
+
caption: slot("text", 0.44, 4.82, 9.12, 0.45, { size: 10, color: "muted", placeholder: "Source or takeaway" }),
|
|
118
|
+
}),
|
|
119
|
+
table: withHead("Title and a table", {
|
|
120
|
+
table: slot("table", 0.44, 1.32, 9.12, 3.95, { size: 13, color: "text", required: true, placeholder: "| Item | Value |\n|---|---|\n| Pages | 120 |" }),
|
|
121
|
+
}),
|
|
122
|
+
quote: {
|
|
123
|
+
description: "A quotation and who said it",
|
|
124
|
+
background: "surface",
|
|
125
|
+
shapes: [{ kind: "rect", x: 0.7, y: 1.45, w: 0.06, h: 2.4, fill: "accent" }],
|
|
126
|
+
slots: {
|
|
127
|
+
quote: slot("text", 1.0, 1.4, 8.2, 2.1, { size: 28, italic: true, font: "heading", color: "text", valign: "middle", required: true, class: "statement", placeholder: "The quote" }),
|
|
128
|
+
attribution: slot("text", 1.0, 3.55, 8.2, 0.5, { size: 13, color: "muted", placeholder: "Who said it" }),
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
blank: { description: "The whole canvas as one body (HTML welcome)", shapes: [], slots: { body: slot("markdown", 0.44, 0.35, 9.12, 4.95, { size: 15, color: "text", required: true }) } },
|
|
132
|
+
},
|
|
133
|
+
snippets: [
|
|
134
|
+
{ name: "Cards", description: "Three cards with a number, a heading and a line", kind: "html", w: 9.12, h: 2.2, content: '<div class="cards">\n <div class="card"><span class="num">01</span><h3>First</h3><p>What it is and why it matters.</p></div>\n <div class="card"><span class="num">02</span><h3>Second</h3><p>What it is and why it matters.</p></div>\n <div class="card"><span class="num">03</span><h3>Third</h3><p>What it is and why it matters.</p></div>\n</div>' },
|
|
135
|
+
{ name: "Key figures", description: "Big numbers with a label", kind: "html", w: 9.12, h: 1.6, content: '<div class="kpis">\n <div class="kpi"><strong>120</strong><span>pages migrated</span></div>\n <div class="kpi"><strong>5 min</strong><span>to publish a text</span></div>\n <div class="kpi"><strong>−60%</strong><span>time per text</span></div>\n</div>' },
|
|
136
|
+
{ name: "Flow", description: "Boxes from left to right with arrows", kind: "html", w: 9.12, h: 1.6, content: '<div class="flow">\n <div class="box ghost">Sources<small>CSV, Excel</small></div>\n <div class="arrow">→</div>\n <div class="box accent">We build this<small>import, checks, API</small></div>\n <div class="arrow">→</div>\n <div class="box solid">Channels<small>web, newsletter, social</small></div>\n</div>' },
|
|
137
|
+
{ name: "Timeline", description: "Points on a line, left to right", kind: "html", w: 9.12, h: 1.4, content: '<ol class="timeline">\n <li><b>December</b><span>Website</span></li>\n <li><b>January</b><span>Newsletter, LinkedIn</span></li>\n <li><b>February</b><span>Review with the same texts</span></li>\n</ol>' },
|
|
138
|
+
{ name: "Before / after", description: "Two boxes side by side", kind: "html", w: 9.12, h: 2.2, content: '<div class="compare">\n <div><h3>Today</h3><p>Every text is copied by hand into four tools.</p></div>\n <div><h3>With the change</h3><p>Written once, published everywhere.</p></div>\n</div>' },
|
|
139
|
+
{ name: "Columns", description: "Three columns with a small heading", kind: "html", w: 9.12, h: 2, content: '<div class="cols">\n <div><h3>For</h3><p>Who it serves.</p></div>\n <div><h3>Not now</h3><p>What stays out.</p></div>\n <div><h3>Next</h3><p>What follows.</p></div>\n</div>' },
|
|
140
|
+
{ name: "Callout", description: "A highlighted note", kind: "html", w: 6, h: 1, content: '<div class="callout"><strong>Note:</strong> the one thing to remember.</div>' },
|
|
141
|
+
],
|
|
142
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Series colors, shared by the HTML chart and the PPTX one so both look alike: the template's accent, then fixed extras. */
|
|
2
|
+
export declare const chartPalette: (accent?: string) => string[];
|
|
3
|
+
/**
|
|
4
|
+
* Charts as SVG for the HTML slides: column, bar, line, area, pie and
|
|
5
|
+
* doughnut from the same `chart` block the PowerPoint export turns into a
|
|
6
|
+
* native chart. Pure — the web editor bundles it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CHART_KINDS: readonly ["column", "bar", "line", "pie", "doughnut", "area"];
|
|
9
|
+
export type ChartKind = (typeof CHART_KINDS)[number];
|
|
10
|
+
export interface ChartData {
|
|
11
|
+
kind: ChartKind;
|
|
12
|
+
title?: string;
|
|
13
|
+
categories: string[];
|
|
14
|
+
series: {
|
|
15
|
+
name: string;
|
|
16
|
+
values: number[];
|
|
17
|
+
}[];
|
|
18
|
+
}
|
|
19
|
+
/** A chart block's YAML (fenced or bare) read and checked; throws with what is wrong. */
|
|
20
|
+
export declare function parseChart(source: string): ChartData;
|
|
21
|
+
/** The chart as an SVG string sized w × h (the slot's box in px), in the theme's palette and text colors. */
|
|
22
|
+
export declare function chartSvg(c: ChartData, w: number, h: number, look: {
|
|
23
|
+
palette: string[];
|
|
24
|
+
text: string;
|
|
25
|
+
muted: string;
|
|
26
|
+
line: string;
|
|
27
|
+
fontSize: number;
|
|
28
|
+
}): string;
|
|
29
|
+
/**
|
|
30
|
+
* A chart written back as its block: what the editor's data grid saves.
|
|
31
|
+
* Compact and in the order people read it (kind, title, categories,
|
|
32
|
+
* series); `fenced` keeps the ```chart fence the slot had.
|
|
33
|
+
*/
|
|
34
|
+
export declare function chartSource(c: ChartData, fenced: boolean): string;
|