@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.
Files changed (77) hide show
  1. package/README.md +212 -11
  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-BBFUIftm.js → dist-3Yr8mX0X.js} +1 -1
  61. package/web/dist/assets/{dist-DtUB2Uu2.js → dist-BVzRayNB.js} +1 -1
  62. package/web/dist/assets/{dist-BuwdjX6z.js → dist-BdYm_4II.js} +1 -1
  63. package/web/dist/assets/{dist-C16bXf8c.js → dist-Bf3GuzEk.js} +1 -1
  64. package/web/dist/assets/{dist-Bie1ebP9.js → dist-DGymUpLv.js} +1 -1
  65. package/web/dist/assets/{dist-CH73jsgO.js → dist-DIvdTMOT.js} +1 -1
  66. package/web/dist/assets/{dist-DvkrCSGL.js → dist-DchG_zAX.js} +1 -1
  67. package/web/dist/assets/{dist-C0ve4Tka.js → dist-Dt9RqYvy.js} +1 -1
  68. package/web/dist/assets/dist-m1b2E3aJ.js +1 -0
  69. package/web/dist/assets/{dist-C_rJjRj7.js → dist-mxFa618U.js} +1 -1
  70. package/web/dist/assets/{dist-CDUZdAAS.js → dist-xXM6FJLm.js} +1 -1
  71. package/web/dist/assets/{editor-3z92i0tV.js → editor-DYDCHRgT.js} +3 -3
  72. package/web/dist/assets/index-CvvZzwHR.js +473 -0
  73. package/web/dist/assets/index-JhhhmD7T.css +2 -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
package/README.md CHANGED
@@ -260,6 +260,7 @@ kraftwerk devices # paired devices (a phone, another compu
260
260
  kraftwerk remote on|off|pair # reach this machine from anywhere through the relay, end to end encrypted
261
261
  kraftwerk projects # goal-scoped project folders; projects create|show|link|log|remove
262
262
  kraftwerk boards|tasks # task boards per project or workspace; tasks create|show|move|assign|log|pick|remove
263
+ kraftwerk presentations # slide decks (HTML slides, themes, PPTX/PDF/HTML export) per project or workspace; show|create|check|render|remove|templates
263
264
  kraftwerk contacts|places|events # who, where and when, one Markdown file each; … show|create|set|remove, events --from/--to
264
265
  kraftwerk ref <kind:slug> # resolve a reference (contact:anna-meier, project:relaunch, …); --file <md> resolves every one in a file
265
266
  kraftwerk trash # what was deleted; trash restore|purge <id>, trash empty
@@ -597,9 +598,12 @@ Links are one-directional lists of slugs. A target that does not exist is
597
598
  shown as "not found" on the project page and told to the agent, never an
598
599
  error — the same rule an agent's knowledge list follows.
599
600
 
600
- **Working in a project is chat.** The Projects screen lists the projects,
601
- the chats of the selected one, and the thread; opening a project opens its
602
- latest chat. A session scoped to a project starts with the brief, the
601
+ **Working in a project is chat.** Opening a project shows its overview:
602
+ a box to start a new session — with the project's assistant, or with any
603
+ agent picked under the box — and the recent sessions, each with a menu to
604
+ rename or delete it. An open session is named next to the project's title
605
+ ("Project / Session"); the title leads back to the overview, and the
606
+ project's context stays beside both. A session scoped to a project starts with the brief, the
603
607
  current state, the records, every link with how to reach it, and the rule
604
608
  for keeping the project current: `state.md` is rewritten at the end of a
605
609
  session that changed something, so the next session (by anyone) continues
@@ -610,10 +614,35 @@ directory stays the workspace root, so linked repositories and knowledge
610
614
  are reachable by path; opening a vibeable moves it into the app folder as
611
615
  in any chat.
612
616
 
613
- **In the rail.** The agents linked to a project and its apps (the linked
614
- vibeables) are listed under the project. Pin an app from the vibeables tab
615
- of the project's context column, or unpin it there; clicking it in the rail
616
- opens the project with the app beside its chat (`#/projects/<slug>?app=<vibeable>`).
617
+ **Artifacts.** The rail's third row, under Chat, lists everything made in the
618
+ workspace and its projects — apps, presentations, boards, contacts, places
619
+ and events — newest first, with the project each belongs to. A tile per
620
+ enabled kind makes a new one; chips filter by kind; the search matches
621
+ titles. A row opens the thing where it lives.
622
+
623
+ **Chat** (Ralv) works like a project's overview: the rail's "Chat" row shows a composer that
624
+ starts a chat with Ralv (or, from the picker, with a specific agent, which
625
+ opens in that agent's sessions) and Ralv's recent chats. An open chat is
626
+ named next to the workspace's title; there are no tabs.
627
+
628
+ **An agent** works the same way: clicking it in the rail shows a composer
629
+ that starts a session with that agent and its recent sessions, each with
630
+ the project it is filed under. An open session is named next to the
631
+ agent's name, which leads back; there are no tabs.
632
+
633
+ **In the rail.** Home, Chat, Artifacts, the projects and the agents —
634
+ nothing else. Boards and presentations are on the Artifacts page (and in a
635
+ project's context column); channels open from a project's recents or
636
+ `#/channels`. A project is one row, with nothing under it. Its agents
637
+ are in the overview's session picker, and every recent session names who it
638
+ is with (the assistant, an agent, or coworkers). Its apps (the linked
639
+ vibeables) are cards on the overview, between the composer and the recents:
640
+ pin an app from the apps tab of the project's context column, or unpin it
641
+ there; a card opens the project with the app at full size
642
+ (`#/projects/<slug>?app=<vibeable>`). The project's boards and presentations
643
+ are tabs of the context column — the boards tab shows each board as its
644
+ columns side by side, the presentations tab lists the decks with a "new
645
+ presentation".
617
646
 
618
647
  **Coworkers.** "Add coworker" on a project chat works as on an agent
619
648
  session: the chat becomes a channel whose members are the agents you pick,
@@ -686,6 +715,180 @@ workspace never starts the same work twice. Only a human moves a task into a
686
715
  done column; `tasks assign <n> human` clears the assignee and puts the task
687
716
  into Review.
688
717
 
718
+ ## Presentations
719
+
720
+ Turn on `presentations:` in `kraftwerk.yml` (or the checkbox in settings)
721
+ and every project can have slide decks, and the workspace its own:
722
+
723
+ ```yaml
724
+ presentations:
725
+ root: kraftwerk-data/presentations # default; the workspace's decks and templates (a project's decks live in projects/<slug>/presentations/)
726
+ ```
727
+
728
+ ```
729
+ projects/<slug>/presentations/<name>/deck.md # the slides: markdown (and HTML) on a template's layouts
730
+ projects/<slug>/presentations/<name>/assets/ # the pictures the slides show
731
+ projects/<slug>/presentations/<name>/exports/ # what `render` wrote: .pptx, .pdf, .html, slides/NN.png
732
+ kraftwerk-data/presentations/<name>/… # workspace decks, same shape
733
+ kraftwerk-data/presentations/templates/<slug>/ # your own themes: template.yml, theme.css, fonts and pictures beside them
734
+ ```
735
+
736
+ A deck is one markdown file. The headmatter names the title, the template
737
+ and, optionally, CSS of the deck's own; a `---` line starts the next slide,
738
+ and an optional YAML block right after it sets the slide's `layout:` (and
739
+ `background:`, `slots:`). The content before the first `::slot::` marker is
740
+ the slide's title (a leading heading) and body; `::left::`, `::image::`,
741
+ `::chart::`, … fill the layout's named slots, `::notes::` are the speaker
742
+ notes. A slot holds markdown, raw HTML, a picture (`![caption](assets/x.png)`),
743
+ a table, or a fenced `chart` block (YAML: `kind` column | bar | line | pie |
744
+ doughnut | area, `categories`, `series` with `name` and `values`).
745
+
746
+ ```markdown
747
+ ---
748
+ title: Why we move to NodeHive
749
+ template: netnode
750
+ layout: title
751
+ ---
752
+ # Why we move to NodeHive
753
+ ::subtitle::
754
+ Content pipeline review · November 2026
755
+ ::notes::
756
+ Open with the migration timeline.
757
+
758
+ ---
759
+ layout: content
760
+ slots:
761
+ title: { size: 30 }
762
+ figures: { kind: html, x: 0.44, y: 3.2, w: 9.12, h: 1.6 }
763
+ ---
764
+ # One source, every channel
765
+ - Editors write **once**, in markdown
766
+ - Every channel reads the same API
767
+ ::figures::
768
+ <div class="kpis"><div class="kpi"><strong>−60%</strong><span>time per text</span></div></div>
769
+ ```
770
+
771
+ **Slides are HTML.** The editor, the thumbnails, present mode, the HTML
772
+ file, the PDF and the PNGs all show the same live HTML in the template's
773
+ theme; PDF and PNG are printed from it by a headless browser (Playwright's
774
+ Chromium when installed, else the installed Chrome; without either the
775
+ PowerPoint model's raster stands in, with a warning). The PowerPoint file
776
+ is a native model of the same slots — text, lists, pictures, native charts
777
+ and tables stay editable — its HTML pieces placed as pictures of
778
+ themselves. A slide may move or restyle a layout's slot, or add boxes of
779
+ its own, in its `slots:` (positions in inches on a 10 × 5.625 canvas);
780
+ kinds are `text`, `markdown`, `image`, `chart`, `table`, `html` and
781
+ `embed` (a URL, or a whole page with scripts, run sandboxed).
782
+
783
+ **The design** is the template: `template.yml` names the canvas, fonts,
784
+ colors, layouts (slots placed in inches, decorations behind them) and
785
+ snippets — the theme's ready-made pieces (cards, key figures, a flow, a
786
+ timeline …) for the editor's insert menu — and `theme.css` styles the
787
+ slides, scoped to them (`:root` means the slide; `@font-face` fonts sit
788
+ beside the file). `kraftwerk presentations templates init <slug>` copies
789
+ the built-in one to start from; the deck's own `css:` goes on top for one
790
+ deck. What a slot cannot show (an empty required slot, an unknown layout,
791
+ a missing picture, a broken chart block) is a warning with the slide and
792
+ the slot, in the editor, in `show` and in `check`.
793
+
794
+ ```
795
+ kraftwerk presentations [--project <p>] [--all] # the decks; presentations show|create|check|render|remove
796
+ kraftwerk presentations create "<title>" --project relaunch [--template netnode] [--from deck.md]
797
+ kraftwerk presentations show nodehive-pitch --project relaunch # slides, the template's layouts and slots, its pieces, the warnings
798
+ kraftwerk presentations check nodehive-pitch --project relaunch # exit 1 on errors
799
+ kraftwerk presentations render nodehive-pitch --project relaunch --png --pdf --pptx --html [--out <dir>]
800
+ kraftwerk presentations templates [init <slug>]
801
+ ```
802
+
803
+ **The editor** (`#/projects/<slug>/presentations/<name>`) is the slide
804
+ itself, live, and works like ChatGPT's presentation editor:
805
+
806
+ - **Slides.** A numbered strip (drag to reorder; right click to duplicate,
807
+ hide, move or delete), a grid of all slides, a new slide from a picture of
808
+ each layout, zoom from fit to 150 %. Hidden slides stay in the deck and
809
+ out of present mode and the exports.
810
+ - **On the slide.** Every slot is a box: click to select, ⇧-click or drag a
811
+ frame for several, drag to move with guides to the slide's edges and
812
+ middle and to the other boxes, resize from the corners (⇧ keeps the
813
+ proportions), rotate from the handle below, nudge with the arrows,
814
+ ⌘C/⌘V/⌘D, Delete, ⌘Z/⇧⌘Z. A double click types into a box where it
815
+ stands in the slide's own fonts, or opens the source of HTML, charts and
816
+ embeds beside the slide, which follows as you type.
817
+ - **Format.** The bar over a box sets font, size, bold, italic, alignment
818
+ and color; the Format panel adds position, rotation, alignment to the
819
+ slide, underline and strikethrough, text and fill colors (the theme's or
820
+ any), corners, border, shadow, opacity and how a picture fits; several
821
+ boxes align to each other; right click orders the layers. With nothing
822
+ selected it sets the slide's background, a color or a picture.
823
+ - **Insert.** Text, a picture (uploaded into `assets/`, or dropped onto
824
+ the slide), a chart, a table, shapes (rectangle, rounded, circle, line,
825
+ arrow, star), HTML, an embed, and the theme's pieces.
826
+ - **Design.** The design panel switches the theme with a preview of the
827
+ slide in each and takes CSS for this deck; slides carry their number
828
+ (`data-n`, `data-nn`, `data-of`) for the theme to show.
829
+ - **Agent.** "Ask an agent" under the slide opens a chat docked beside the
830
+ deck with the deck and the slide named; the agent edits `deck.md` and the
831
+ slide changes in front of you (the server watches an open deck's folder,
832
+ so an agent's save shows at once). "ask" on a box has one-click
833
+ requests: shorten, rewrite clearer, bullet points, make it a chart,
834
+ translate to English or German, speaker notes, or something else.
835
+ - **From a brief.** A new deck can start from what it is about, typed or
836
+ from notes files (md, txt, csv, json, html, yaml): the agent beside it
837
+ answers with the outline, then writes the slides in the theme while you
838
+ watch.
839
+ - **Review.** Comments on a slide or on one box (right click → Comment…,
840
+ or the comments button): a pin on the box, a count on the slide and in
841
+ the bar, answers, resolve and reopen. They live in `comments.json` beside
842
+ `deck.md`, pointing at the slide's `id:` (given when its first comment
843
+ lands), so they follow the slide when it moves. Agents read and resolve
844
+ them: `kraftwerk presentations comments|comment|resolve`.
845
+ - **Share.** Copy a link to the editor or to present mode (for anyone who
846
+ reaches this workspace: paired devices, members), or download the deck
847
+ as one HTML file that opens anywhere.
848
+ - **Several editors.** A person, an agent and another window can work on
849
+ one deck: every save names the version it was made on, a save over a
850
+ newer file is refused (409) and the editor merges slide by slide — both
851
+ sides' changes stay; a slide changed on both sides keeps theirs and says
852
+ so (⌘Z brings yours back).
853
+ - **Charts.** A chart opens as a data grid beside the slide: kind, title,
854
+ a row per category, a column per series (add, rename, remove); the
855
+ source tab shows the same block as YAML.
856
+ - **Version history.** Earlier versions of the deck are kept in
857
+ `.history/` beside `deck.md`: before saves (once a minute while you edit)
858
+ and whenever an agent or a tool changes the file; the newest 50 stay.
859
+ The history panel shows each version's slides and restores one as an
860
+ ordinary edit (⌘Z takes it back).
861
+ - **Transitions.** Each slide comes in with a fade (the default), a slide,
862
+ a zoom or a cut (`transition:` in its head, or the Format panel with
863
+ nothing selected); present mode and the HTML file play them, the
864
+ PowerPoint file gets fade, push and zoom.
865
+ - **Linked from tasks and chats.** A task's links (its `refs:`) take a
866
+ deck from a list; the chip opens it, and the agent working the task
867
+ gets the deck's folder with the task. In a chat, `presentation:` offers
868
+ the decks and the sent `presentation:<name>` links to the deck. The
869
+ deck's share menu copies that reference and lists the tasks that link
870
+ it.
871
+ - **Slide numbers.** On by default, drawn by the theme bottom right
872
+ (not on title and section slides). The Format panel with nothing
873
+ selected turns them off for the deck (`numbers: false` in the
874
+ headmatter) or for one slide (`number: false` in its head). The
875
+ PowerPoint file carries them as slide-number fields, so they keep
876
+ counting when slides move there.
877
+ - **Who else is here.** Everyone with the deck open (other people, other
878
+ tabs) shows as an avatar in the bar and a dot on the slide they are on;
879
+ the box they have selected is outlined in their color with their name.
880
+ Click an avatar to go to their slide. It lives in memory only and
881
+ follows the live connection: a closed tab is gone at once.
882
+ - **Present.** `…/present[/<n>]` full screen (arrows, space, Escape, N for
883
+ the notes, F for fullscreen, a clock); `…/presenter[/<n>]` is the
884
+ presenter view with the current and the next slide, the notes and the
885
+ clock. PowerPoint, PDF and HTML download from the bar.
886
+
887
+ **Agents and the deck.** A project chat and every agent see the project's
888
+ decks in their context with the format, the theme's pieces and the
889
+ commands; agents write `deck.md` directly, put pictures into `assets/`, and
890
+ look at the slide images `render --png` writes before handing the deck over.
891
+
689
892
  ## Contacts, places and events
690
893
 
691
894
  Who, where and when, kept by the workspace itself so people and agents can
@@ -850,8 +1053,7 @@ same colleague next week, whichever chat you open.
850
1053
  question it asked, plus failures nobody has opened yet, is one list
851
1054
  (`GET /api/attention`), oldest first, each item with its owner: the agent,
852
1055
  the project or the channel. The rail puts a red count on every row that
853
- leads there: the agent, the project (its own chats and its agents'), the
854
- channel, Ralv, and the projects header while folded. The bell lists these
1056
+ leads there: the agent, the project (its own chats and its agents'), Ralv, and the projects header while folded. The bell lists these
855
1057
  items under "needs you", grouped by owner, with finished runs and routines
856
1058
  below as "updates". **next** in the top bar (⌥N) opens the next waiting
857
1059
  item where it lives: the chat, scrolled to the card, which lights up, with
@@ -861,8 +1063,7 @@ Notification titles name the owner first ("🦊 Lisa needs approval").
861
1063
  Under each agent's name the rail shows what it is doing now: waiting for
862
1064
  you (an approval or a question, with a red light), working (in which chat,
863
1065
  for how long, with a pulsing light), the next routine due within a day and
864
- a half, or when it was last active (`GET /api/agent-status`). Agents linked
865
- to a project are listed under the project too.
1066
+ a half, or when it was last active (`GET /api/agent-status`).
866
1067
 
867
1068
  A chat keeps the agent's own session. The ACP session id is stored with the
868
1069
  chat (`sessions` in `meta.json`), and the next process — after an inspector
package/dist/cli/init.js CHANGED
@@ -35,6 +35,7 @@ skills: ${DATA_DIR}/skills # workspace skills (shared instruction packag
35
35
  # places: # addresses and points of interest, one Markdown file each under ${DATA_DIR}/places — referenced as place:<slug> (uncomment to enable)
36
36
  # events: # dated one-off entries with place, contacts and project, one Markdown file each under ${DATA_DIR}/events — referenced as event:<slug> (uncomment to enable)
37
37
  # boards: # tasks as folders in columns (Draft, Todo, In progress, Review, Done) per project and under ${DATA_DIR}/boards — agents are woken when a task is assigned to them (uncomment to enable)
38
+ # presentations: # slide decks as folders (deck.md + assets) per project and under ${DATA_DIR}/presentations — rendered from a template into PPTX, PDF and slide images (uncomment to enable)
38
39
  # cloud: # the daemon registers this MACHINE with the kraftwerk cloud and lists this workspace (\`kraftwerk login\` claims the machine)
39
40
  # enabled: false # uncomment both lines to leave this workspace out (\`kraftwerk cloud off\` turns the cloud off for the whole machine)
40
41
  `;
@@ -14,6 +14,7 @@ import { runInit } from "./init.js";
14
14
  import { registerKnowledgeCommands } from "./knowledge.js";
15
15
  import { registerProjectCommands } from "./projects.js";
16
16
  import { registerBoardCommands } from "./boards.js";
17
+ import { registerPresentationCommands } from "./presentations.js";
17
18
  import { registerContactCommands, registerEventCommands, registerPlaceCommands, registerRefCommand } from "./entities.js";
18
19
  import { registerWorkspaceCommands } from "./workspaces.js";
19
20
  import { registerRepoCommands } from "./repos.js";
@@ -46,6 +47,7 @@ import { runUi } from "./ui.js";
46
47
  * kraftwerk workspaces ... known workspaces on this machine (list/start/stop/forget)
47
48
  * kraftwerk projects ... goal-scoped project folders (list/create/show/link/log/remove)
48
49
  * kraftwerk boards|tasks ... task boards per project or workspace: list/show/create; tasks list/show/create/move/assign/log/pick/remove
50
+ * kraftwerk presentations ... slide decks per project or workspace: list/show/create/check/render/remove/templates
49
51
  * kraftwerk contacts|places|events who, where and when: one Markdown file each (list/show/create/set/remove)
50
52
  * kraftwerk ref <kind:slug> resolve a reference (contact:anna-meier) or every one in a file
51
53
  * kraftwerk vibeables ... small apps built live in a chat (list/create/remove)
@@ -307,6 +309,7 @@ registerRoutineCommands(program);
307
309
  registerWorkspaceCommands(program);
308
310
  registerProjectCommands(program);
309
311
  registerBoardCommands(program);
312
+ registerPresentationCommands(program);
310
313
  registerContactCommands(program);
311
314
  registerPlaceCommands(program);
312
315
  registerEventCommands(program);
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerPresentationCommands(program: Command): void;
@@ -0,0 +1,261 @@
1
+ import chalk from "chalk";
2
+ import Table from "cli-table3";
3
+ import { readFile } from "node:fs/promises";
4
+ import { createDeck, deleteDeck, exportDeck, getDeck, addComment, listComments, updateComment, initTemplate, listAllDecks, listDecks, listTemplates, } from "../core/presentations/index.js";
5
+ import { initContext as prepare } from "./routines.js";
6
+ import { fmtAgo } from "./workspaces.js";
7
+ /**
8
+ * kraftwerk presentations [list] [--project <slug>] [--all] [--json]
9
+ * kraftwerk presentations show <name> [--project <slug>] [--json] the slides, the template's layouts and slots, the warnings
10
+ * kraftwerk presentations create "<title>" [--project <slug>] [--slug <s>] [--template <t>] [--from <deck.md>]
11
+ * kraftwerk presentations check <name> [--project <slug>] warnings; exits 1 on errors
12
+ * kraftwerk presentations render <name> --pptx|--pdf|--png|--html [--out <dir>] [--width <px>] [--project <slug>]
13
+ * kraftwerk presentations comments <name> [--all] | comment <name> <slide> "<text>" [--slot <box>] | resolve <name> <id> [--reply "<text>"]
14
+ * kraftwerk presentations remove <name> [--project <slug>]
15
+ * kraftwerk presentations templates [--json]; templates init <slug> the templates; a copy of the built-in one to edit
16
+ *
17
+ * Agents write deck.md directly (show prints the folder) and look at the
18
+ * PNGs `render --png` writes. The CLI talks to core, not to the server.
19
+ */
20
+ const die = (msg) => {
21
+ console.error(chalk.red(msg));
22
+ process.exit(1);
23
+ };
24
+ const refOf = (name, project) => ({ ...(project?.trim() ? { project: project.trim() } : {}), name: name.trim() });
25
+ const printWarnings = (warnings) => {
26
+ for (const w of warnings) {
27
+ const where = `${w.slide ? `slide ${w.slide}` : "deck"}${w.slot ? ` · ${w.slot}` : ""}`;
28
+ console.log(`${w.level === "error" ? chalk.red("error") : chalk.yellow("warn ")} ${chalk.dim(where)} ${w.message}`);
29
+ }
30
+ };
31
+ function printDeck(d) {
32
+ console.log(`${chalk.bold(d.title)} ${chalk.dim(`(${d.project ? `${d.project}/` : ""}${d.name}, template ${d.template}, ${d.slides} slides)`)}`);
33
+ console.log(chalk.dim(`folder: ${d.path}`));
34
+ if (d.error)
35
+ console.log(chalk.red(`deck.md: ${d.error}`));
36
+ console.log(`\n${chalk.bold("slides")}`);
37
+ d.deck.slides.forEach((s, i) => {
38
+ const first = s.content.split("\n").find((l) => l.trim())?.replace(/^#+\s*/, "") ?? "";
39
+ console.log(` ${chalk.cyan(String(i + 1).padStart(3))} ${chalk.dim(`[${s.layout ?? "default"}]`)} ${first}${s.notes ? chalk.dim(" · notes") : ""}`);
40
+ });
41
+ console.log(`\n${chalk.bold("layouts")} ${chalk.dim(`of template ${d.template}`)}`);
42
+ for (const l of d.layouts)
43
+ console.log(` ${chalk.cyan(l.name.padEnd(12))} ${l.slots.map((s) => `${s.name}${s.required ? "*" : ""}:${s.kind}`).join(" ")}${l.description ? chalk.dim(` ${l.description}`) : ""}`);
44
+ if (d.theme.snippets.length)
45
+ console.log(`\n${chalk.bold("pieces")} ${chalk.dim(`of the theme (HTML for a slot; \`presentations show --json\` has the markup)`)}\n${d.theme.snippets.map((x) => ` ${chalk.cyan(x.name.padEnd(14))} ${chalk.dim(x.description ?? "")}`).join("\n")}`);
46
+ if (d.assets.length)
47
+ console.log(`\n${chalk.bold("assets")}\n${d.assets.map((a) => ` ${a}`).join("\n")}`);
48
+ if (d.exports.length)
49
+ console.log(`\n${chalk.bold("exports")}\n${d.exports.map((a) => ` exports/${a}`).join("\n")}`);
50
+ console.log(`\n${chalk.bold("warnings")}${d.warnings.length ? "" : chalk.dim(" (none)")}`);
51
+ printWarnings(d.warnings);
52
+ }
53
+ export function registerPresentationCommands(program) {
54
+ const cmd = program.command("presentations").alias("decks").description("Slide decks of a project or the workspace: list, show, create, check, render, remove, templates");
55
+ cmd
56
+ .command("list", { isDefault: true })
57
+ .description("List the decks: the workspace's, a project's (--project), or every one (--all)")
58
+ .option("--project <slug>", "A project's decks")
59
+ .option("--all", "Every deck of the workspace and its projects")
60
+ .option("--json", "Machine-readable output")
61
+ .action(async (opts) => {
62
+ await prepare();
63
+ const view = opts.all ? { enabled: true, presentations: await listAllDecks() } : await listDecks(opts.project);
64
+ if (opts.json) {
65
+ console.log(JSON.stringify(view, null, 2));
66
+ return;
67
+ }
68
+ if (!view.enabled)
69
+ die(("error" in view && view.error) || "presentations are off");
70
+ if ("error" in view && view.error)
71
+ die(view.error);
72
+ if (view.presentations.length === 0) {
73
+ console.log(chalk.dim(`No presentations ${opts.project ? `in project ${opts.project}` : opts.all ? "anywhere" : "in the workspace"} yet — \`kraftwerk presentations create "<title>"${opts.project ? ` --project ${opts.project}` : ""}\` starts one.`));
74
+ return;
75
+ }
76
+ const table = new Table({ head: ["deck", "where", "slides", "template", "changed"].map((h) => chalk.bold(h)) });
77
+ for (const p of view.presentations) {
78
+ table.push([`${chalk.cyan(p.title)}\n${chalk.dim(p.name)}`, p.project ? `project ${p.project}` : chalk.dim("workspace"), p.error ? chalk.red(p.error) : String(p.slides), p.template, chalk.dim(fmtAgo(p.updatedAt))]);
79
+ }
80
+ console.log(table.toString());
81
+ });
82
+ cmd
83
+ .command("show")
84
+ .description("One deck: its slides, the template's layouts and slots, the warnings")
85
+ .argument("<name>", "Deck name")
86
+ .option("--project <slug>", "The project the deck belongs to")
87
+ .option("--json", "Machine-readable output")
88
+ .action(async (name, opts) => {
89
+ await prepare();
90
+ const d = await getDeck(refOf(name, opts.project)).catch((err) => die(err.message));
91
+ if (!d)
92
+ return die(`no presentation "${name}"`);
93
+ if (opts.json)
94
+ console.log(JSON.stringify(d, null, 2));
95
+ else
96
+ printDeck(d);
97
+ });
98
+ cmd
99
+ .command("create")
100
+ .description("Create a deck: a starter deck.md, or one from a markdown file (--from)")
101
+ .argument("<title>", "Deck title")
102
+ .option("--project <slug>", "Create it in a project")
103
+ .option("--slug <name>", "Folder name (default: from the title)")
104
+ .option("--template <slug>", "Template (default: default)")
105
+ .option("--from <file>", "A deck.md to start from")
106
+ .option("--json", "Machine-readable output")
107
+ .action(async (title, opts) => {
108
+ await prepare();
109
+ const source = opts.from ? await readFile(opts.from, "utf8").catch(() => die(`cannot read ${opts.from}`)) : undefined;
110
+ const d = await createDeck({ ...(opts.project ? { project: opts.project } : {}), title, ...(opts.slug ? { slug: opts.slug } : {}), ...(opts.template ? { template: opts.template } : {}), ...(source ? { source } : {}) }).catch((err) => die(err.message));
111
+ if (opts.json) {
112
+ console.log(JSON.stringify(d, null, 2));
113
+ return;
114
+ }
115
+ console.log(`${chalk.green("created")} ${chalk.bold(d.title)} ${chalk.dim(`(${d.project ? `${d.project}/` : ""}${d.name})`)}`);
116
+ console.log(chalk.dim(`write ${d.path}/deck.md, pictures into ${d.path}/assets/`));
117
+ printWarnings(d.warnings);
118
+ });
119
+ cmd
120
+ .command("check")
121
+ .description("Check a deck against its template: every warning; exits 1 when there are errors")
122
+ .argument("<name>", "Deck name")
123
+ .option("--project <slug>", "The project the deck belongs to")
124
+ .option("--json", "Machine-readable output")
125
+ .action(async (name, opts) => {
126
+ await prepare();
127
+ const d = await getDeck(refOf(name, opts.project)).catch((err) => die(err.message));
128
+ if (!d)
129
+ return die(`no presentation "${name}"`);
130
+ if (opts.json)
131
+ console.log(JSON.stringify({ name: d.name, project: d.project, slides: d.slides, warnings: d.warnings }, null, 2));
132
+ else if (d.warnings.length === 0)
133
+ console.log(`${chalk.green("ok")} ${d.slides} slides, no warnings`);
134
+ else
135
+ printWarnings(d.warnings);
136
+ if (d.warnings.some((w) => w.level === "error"))
137
+ process.exit(1);
138
+ });
139
+ cmd
140
+ .command("render")
141
+ .description("Write the deck as PPTX, PDF, slide PNGs or one HTML file into its exports/ folder (or --out)")
142
+ .argument("<name>", "Deck name")
143
+ .option("--project <slug>", "The project the deck belongs to")
144
+ .option("--pptx", "PowerPoint file")
145
+ .option("--pdf", "PDF, one page per slide")
146
+ .option("--png", "One PNG per slide (exports/slides/NN.png) — look at them")
147
+ .option("--html", "One self-contained HTML file: present it in any browser, print it to PDF")
148
+ .option("--out <dir>", "Write there instead of exports/")
149
+ .option("--width <px>", "Image width for --png and --pdf (default 1280 / 1600)")
150
+ .option("--json", "Machine-readable output")
151
+ .action(async (name, opts) => {
152
+ await prepare();
153
+ const formats = ["pptx", "pdf", "png", "html"].filter((f) => opts[f]);
154
+ if (formats.length === 0)
155
+ die("say what to write: --pptx, --pdf, --png and/or --html");
156
+ const width = opts.width ? Number(opts.width) : undefined;
157
+ if (width !== undefined && !(width >= 160 && width <= 3840))
158
+ die("--width must be between 160 and 3840");
159
+ const files = [];
160
+ let warnings = [];
161
+ for (const format of formats) {
162
+ const r = await exportDeck(refOf(name, opts.project), format, { ...(opts.out ? { outDir: opts.out } : {}), ...(width ? { width } : {}) }).catch((err) => die(err.message));
163
+ files.push(...r.files);
164
+ warnings = r.warnings;
165
+ }
166
+ if (opts.json) {
167
+ console.log(JSON.stringify({ files, warnings }, null, 2));
168
+ return;
169
+ }
170
+ for (const f of files)
171
+ console.log(`${chalk.green("wrote")} ${f}`);
172
+ printWarnings(warnings);
173
+ });
174
+ /** Who writes: the session's actor (an agent), else human:user. */
175
+ const actor = () => (process.env.KRAFTWERK_ACTOR ?? "").trim() || "human:user";
176
+ cmd
177
+ .command("comments")
178
+ .description("The comments on a deck's slides and boxes: the open ones, or --all")
179
+ .argument("<name>", "Deck name")
180
+ .option("--project <slug>", "The project the deck belongs to")
181
+ .option("--all", "Resolved ones too")
182
+ .option("--json", "Machine-readable output")
183
+ .action(async (name, opts) => {
184
+ await prepare();
185
+ const all = await listComments(refOf(name, opts.project)).catch((err) => die(err.message));
186
+ const shown = opts.all ? all : all.filter((c) => !c.resolved);
187
+ if (opts.json) {
188
+ console.log(JSON.stringify({ comments: shown }, null, 2));
189
+ return;
190
+ }
191
+ if (!shown.length) {
192
+ console.log(chalk.dim(opts.all ? "no comments" : "no open comments"));
193
+ return;
194
+ }
195
+ for (const c of shown) {
196
+ console.log(`${chalk.cyan(c.id)} ${chalk.dim(`slide ${c.n ?? "?"}${c.slot ? ` · ${c.slot}` : ""} · ${c.author} · ${c.at.slice(0, 16).replace("T", " ")}${c.resolved ? " · resolved" : ""}`)}\n ${c.text}`);
197
+ for (const r of c.replies)
198
+ console.log(` ${chalk.dim(`↳ ${r.author}:`)} ${r.text}`);
199
+ }
200
+ });
201
+ cmd
202
+ .command("comment")
203
+ .description("Comment on slide n of a deck, or on one of its boxes (--slot)")
204
+ .argument("<name>", "Deck name")
205
+ .argument("<slide>", "Slide number")
206
+ .argument("<text>", "The comment")
207
+ .option("--project <slug>", "The project the deck belongs to")
208
+ .option("--slot <box>", "The box it is about")
209
+ .action(async (name, slide, text, opts) => {
210
+ await prepare();
211
+ const c = await addComment(refOf(name, opts.project), { slide: Number(slide), text, author: actor(), ...(opts.slot ? { slot: opts.slot } : {}) }).catch((err) => die(err.message));
212
+ console.log(`${chalk.green("commented")} ${c.id} on slide ${c.n}`);
213
+ });
214
+ cmd
215
+ .command("resolve")
216
+ .description("Resolve a comment, answering it with --reply")
217
+ .argument("<name>", "Deck name")
218
+ .argument("<id>", "Comment id (from `presentations comments`)")
219
+ .option("--project <slug>", "The project the deck belongs to")
220
+ .option("--reply <text>", "What was done about it")
221
+ .option("--reopen", "Open it again instead")
222
+ .action(async (name, id, opts) => {
223
+ await prepare();
224
+ await updateComment(refOf(name, opts.project), id, { resolved: !opts.reopen, author: actor(), ...(opts.reply ? { reply: opts.reply } : {}) }).catch((err) => die(err.message));
225
+ console.log(`${chalk.green(opts.reopen ? "reopened" : "resolved")} ${id}`);
226
+ });
227
+ cmd
228
+ .command("remove")
229
+ .description("Move a deck to the trash")
230
+ .argument("<name>", "Deck name")
231
+ .option("--project <slug>", "The project the deck belongs to")
232
+ .action(async (name, opts) => {
233
+ await prepare();
234
+ await deleteDeck(refOf(name, opts.project)).catch((err) => die(err.message));
235
+ console.log(`${chalk.green("removed")} ${name} ${chalk.dim("(in the trash)")}`);
236
+ });
237
+ const templates = cmd.command("templates").description("The templates: the built-in one and the workspace's (templates/<slug>/template.yml under the presentations root)");
238
+ templates
239
+ .command("list", { isDefault: true })
240
+ .description("List the templates with their layouts")
241
+ .option("--json", "Machine-readable output")
242
+ .action(async (opts) => {
243
+ await prepare();
244
+ const list = await listTemplates();
245
+ if (opts.json) {
246
+ console.log(JSON.stringify({ templates: list }, null, 2));
247
+ return;
248
+ }
249
+ for (const t of list)
250
+ console.log(`${chalk.cyan(t.slug.padEnd(14))} ${t.error ? chalk.red(t.error) : `${t.name} ${chalk.dim(`(${t.size}; layouts: ${t.layouts.join(", ")})`)}`}${t.builtin ? chalk.dim(" built-in") : t.path ? chalk.dim(` ${t.path}`) : ""}`);
251
+ });
252
+ templates
253
+ .command("init")
254
+ .description("Write a copy of the built-in template as a workspace template to edit")
255
+ .argument("<slug>", "Template name")
256
+ .action(async (slug) => {
257
+ await prepare();
258
+ const file = await initTemplate(slug).catch((err) => die(err.message));
259
+ console.log(`${chalk.green("wrote")} ${file}`);
260
+ });
261
+ }
@@ -110,6 +110,24 @@ export declare const ROUTES: {
110
110
  readonly "places.get": readonly ["GET", "/api/places/:slug"];
111
111
  readonly "places.list": readonly ["GET", "/api/places"];
112
112
  readonly "places.save": readonly ["PUT", "/api/places/:slug"];
113
+ readonly "presentations.comment": readonly ["POST", "/api/presentations/:name/comments"];
114
+ readonly "presentations.commentDelete": readonly ["DELETE", "/api/presentations/:name/comments/:id"];
115
+ readonly "presentations.commentSave": readonly ["PUT", "/api/presentations/:name/comments/:id"];
116
+ readonly "presentations.create": readonly ["POST", "/api/presentations"];
117
+ readonly "presentations.delete": readonly ["DELETE", "/api/presentations/:name"];
118
+ readonly "presentations.export": readonly ["GET", "/api/presentations/:name/export", "raw"];
119
+ readonly "presentations.file": readonly ["GET", "/api/presentations/:name/file", "raw"];
120
+ readonly "presentations.get": readonly ["GET", "/api/presentations/:name"];
121
+ readonly "presentations.history": readonly ["GET", "/api/presentations/:name/history"];
122
+ readonly "presentations.links": readonly ["GET", "/api/presentations/:name/links"];
123
+ readonly "presentations.list": readonly ["GET", "/api/presentations"];
124
+ readonly "presentations.presence": readonly ["POST", "/api/presentations/:name/presence"];
125
+ readonly "presentations.save": readonly ["PUT", "/api/presentations/:name"];
126
+ readonly "presentations.slide": readonly ["GET", "/api/presentations/:name/slides/:n", "raw"];
127
+ readonly "presentations.templateFile": readonly ["GET", "/api/presentations/templates/:slug/file", "raw"];
128
+ readonly "presentations.templates": readonly ["GET", "/api/presentations/templates"];
129
+ readonly "presentations.upload": readonly ["POST", "/api/presentations/:name/assets", "upload"];
130
+ readonly "presentations.version": readonly ["GET", "/api/presentations/:name/history/:id"];
113
131
  readonly "projects.create": readonly ["POST", "/api/projects"];
114
132
  readonly "projects.delete": readonly ["DELETE", "/api/projects/:slug"];
115
133
  readonly "projects.get": readonly ["GET", "/api/projects/:slug"];
@@ -111,6 +111,24 @@ export const ROUTES = {
111
111
  "places.get": ["GET", "/api/places/:slug"],
112
112
  "places.list": ["GET", "/api/places"],
113
113
  "places.save": ["PUT", "/api/places/:slug"],
114
+ "presentations.comment": ["POST", "/api/presentations/:name/comments"],
115
+ "presentations.commentDelete": ["DELETE", "/api/presentations/:name/comments/:id"],
116
+ "presentations.commentSave": ["PUT", "/api/presentations/:name/comments/:id"],
117
+ "presentations.create": ["POST", "/api/presentations"],
118
+ "presentations.delete": ["DELETE", "/api/presentations/:name"],
119
+ "presentations.export": ["GET", "/api/presentations/:name/export", "raw"],
120
+ "presentations.file": ["GET", "/api/presentations/:name/file", "raw"],
121
+ "presentations.get": ["GET", "/api/presentations/:name"],
122
+ "presentations.history": ["GET", "/api/presentations/:name/history"],
123
+ "presentations.links": ["GET", "/api/presentations/:name/links"],
124
+ "presentations.list": ["GET", "/api/presentations"],
125
+ "presentations.presence": ["POST", "/api/presentations/:name/presence"],
126
+ "presentations.save": ["PUT", "/api/presentations/:name"],
127
+ "presentations.slide": ["GET", "/api/presentations/:name/slides/:n", "raw"],
128
+ "presentations.templateFile": ["GET", "/api/presentations/templates/:slug/file", "raw"],
129
+ "presentations.templates": ["GET", "/api/presentations/templates"],
130
+ "presentations.upload": ["POST", "/api/presentations/:name/assets", "upload"],
131
+ "presentations.version": ["GET", "/api/presentations/:name/history/:id"],
114
132
  "projects.create": ["POST", "/api/projects"],
115
133
  "projects.delete": ["DELETE", "/api/projects/:slug"],
116
134
  "projects.get": ["GET", "/api/projects/:slug"],