htmlcraft 0.0.0-stage → 0.1.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.
@@ -0,0 +1,254 @@
1
+ ---
2
+ name: htmlcraft
3
+ description: Create, edit, validate, preview, and export self-contained HTML presentation decks in the htmlcraft (htmldeck/v1) format. Use when asked to build slides, turn an outline or notes into a deck, edit an existing .html deck, work with slide order, speaker notes, or transitions, or drive the htmlcraft MCP server or CLI. Not for .pptx or other Office formats.
4
+ ---
5
+
6
+ # htmlcraft
7
+
8
+ An htmlcraft deck is one self-contained HTML file. Slides are ordinary DOM
9
+ elements, styling is ordinary CSS, and every object keeps a stable id so the
10
+ visual editor and MCP tools can address it. The HTML file is the source of
11
+ truth: there is no sidecar project file.
12
+
13
+ ## When to use this skill
14
+
15
+ - Create a new presentation from an outline, document, or rough notes.
16
+ - Edit an existing deck: text, styling, slides, notes, transitions, or order.
17
+ - Validate a deck before sharing or exporting.
18
+ - Open the visual editor for human review, or export to standalone HTML, PDF,
19
+ or one PNG per slide.
20
+ - Automate deck work through the htmlcraft MCP server (`htmlcraft-mcp` or
21
+ `htmlcraft mcp`) or the `htmlcraft` CLI.
22
+
23
+ Do not use this skill for `.pptx`/PowerPoint files, video, or real-time
24
+ collaboration. v1 supports static HTML decks and HTML, PDF, and PNG export.
25
+
26
+ ## Choose a workflow
27
+
28
+ **MCP-first (preferred when a tool-capable agent is available).** Use the
29
+ `htmlcraft` MCP server. Read the contract resource once, create or inspect the
30
+ deck, mutate in small steps, validate, and only then open or export. The tool
31
+ surface is documented in [references/mcp-tools.md](references/mcp-tools.md).
32
+
33
+ **CLI fallback.** Use `htmlcraft` when MCP is not available or a script needs an
34
+ exit code. The CLI talks to the same files and contract.
35
+
36
+ Both workflows are safe to mix: MCP writes are atomic and revision-checked.
37
+ The editor receives host revision events over SSE. A clean editor applies
38
+ external or MCP changes automatically; unsaved edits surface a conflict banner
39
+ with reload or overwrite choices. A save based on an old revision returns
40
+ 409/conflict.
41
+
42
+ ## Contract at a glance
43
+
44
+ - Document: `<!doctype html>`, a non-empty `<title>`, and at least one slide.
45
+ Keep the deck self-contained (no build step, no external stylesheet needed).
46
+ - Deck wrapper: `<main data-ppt-deck>` is conventional; slides are its
47
+ `[data-slide-id]` descendants.
48
+ - Slide: `<section class="slide" data-slide-id="s1" data-width="1600"
49
+ data-height="900">`. Ids must be unique and non-empty.
50
+ - Canvas: `data-width`/`data-height` are positive pixel numbers. Omit both for
51
+ 1600x900. Keep every slide on the same canvas size.
52
+ - Objects: each top-level content child of a slide (text block, image, shape,
53
+ table, figure) is an editable object. Give it `data-ppt-el="e1"`; ids are
54
+ unique within the slide and stable over time. Nested `data-ppt-el` ids are
55
+ allowed but must still be unique in that slide.
56
+ - Notes: `<aside data-ppt-notes hidden>Talk track</aside>` must be a direct
57
+ child of its slide.
58
+ - Transitions: optional `data-ppt-transition` on a slide; one of `none`,
59
+ `fade`, or `slide`.
60
+ - Runtime: multi-slide decks include exactly one
61
+ `<script data-ppt-runtime="1">...</script>` with the real runtime body, not
62
+ an empty marker. `create_deck` and `htmlcraft new` write it for you.
63
+ - Charts: a figure with `data-ppt-chart='{"type":"bar","labels":["Q1"],"series":[{"name":"USD","values":[12]}]}'`
64
+ holding valid JSON. The rendered SVG is derived from that attribute.
65
+ - Assets: use `data:` URIs or absolute URLs. Relative asset paths are flagged
66
+ by validation and do not travel with an exported file. `add_image` embeds a
67
+ local file as a data URL; remote URLs are never fetched.
68
+ - No editor artifacts: never write `data-ppt-editing` or
69
+ `data-ppt-frame-slide` into the file.
70
+
71
+ Full details and validation diagnostics are in
72
+ [references/contract.md](references/contract.md).
73
+
74
+ ## Starter template
75
+
76
+ For a runnable starter, copy [examples/basic.html](examples/basic.html) or let
77
+ MCP `create_deck` / `htmlcraft new` generate the deck. Both include the real
78
+ presentation runtime. The skeleton below abbreviates that script body so the
79
+ structure stays readable: replace the placeholder with the runtime from
80
+ `examples/basic.html` before presenting the file.
81
+
82
+ ```html
83
+ <!doctype html>
84
+ <html lang="en">
85
+ <head>
86
+ <meta charset="utf-8">
87
+ <meta name="viewport" content="width=device-width, initial-scale=1">
88
+ <title>My deck</title>
89
+ <style>
90
+ html, body { margin: 0; padding: 0; background: #0b0d12; }
91
+ .slide {
92
+ width: 1600px;
93
+ height: 900px;
94
+ position: relative;
95
+ overflow: hidden;
96
+ background: #f7f5ef;
97
+ color: #17181c;
98
+ font-family: Inter, ui-sans-serif, system-ui, sans-serif;
99
+ }
100
+ .title { position: absolute; left: 140px; top: 160px; margin: 0; font-size: 96px; }
101
+ .body { position: absolute; left: 140px; top: 340px; margin: 0; font-size: 32px; }
102
+ </style>
103
+ </head>
104
+ <body>
105
+ <main data-ppt-deck>
106
+ <section class="slide" data-slide-id="s1" data-width="1600" data-height="900">
107
+ <h1 class="title" data-ppt-el="e1">My deck</h1>
108
+ <p class="body" data-ppt-el="e2">Replace this text with the opening message.</p>
109
+ <aside data-ppt-notes hidden>Say hello and state the goal of the deck.</aside>
110
+ </section>
111
+ <section class="slide" data-slide-id="s2" data-width="1600" data-height="900" data-ppt-transition="fade">
112
+ <h2 class="title" data-ppt-el="e3" style="font-size: 64px;">Next slide</h2>
113
+ <p class="body" data-ppt-el="e4">Each top-level element is an editable object.</p>
114
+ </section>
115
+ </main>
116
+ <script data-ppt-runtime="1">/* copy the real runtime body from examples/basic.html */</script>
117
+ </body>
118
+ </html>
119
+ ```
120
+
121
+ **The runtime marker must contain the real runtime source.** Validation only
122
+ checks for a `<script data-ppt-runtime="1">` marker; it does not inspect the
123
+ script body. A deck saved with the comment above still passes validation but
124
+ will not present. Create decks with `htmlcraft new` or MCP `create_deck`, or copy
125
+ the full runtime from [examples/basic.html](examples/basic.html).
126
+
127
+ ## MCP workflow
128
+
129
+ 1. Learn the contract. Call `get_deck_contract` or read the
130
+ `htmlcraft://contract` and `htmlcraft://authoring` resources. Read
131
+ `htmlcraft://example` when you need a working reference deck.
132
+ 2. Create or inspect.
133
+ - New deck: `create_deck` with `path`, `title`, and `slides`. It never
134
+ overwrites an existing file.
135
+ - Existing deck: `get_outline` first, then `read_slide` or `get_element`
136
+ before replacing anything. Never guess slide or object ids.
137
+ 3. Mutate in small steps, one tool call per change. Use `add_slide`,
138
+ `set_text`, `set_style`, `add_element`, `add_image`, `add_table`,
139
+ `update_chart`, `set_slide_background`, `set_notes`, `set_transition`, and
140
+ the other mutation tools listed in the tool reference.
141
+ 4. Validate after a batch of edits with `validate_deck`. Fix every reported
142
+ error before moving on. Warnings are advisory but should be reviewed.
143
+ 5. For human review, call `open_editor` and give the returned
144
+ `http://127.0.0.1:<port>/?token=...` URL to the user. Do not open it
145
+ yourself unless asked.
146
+ 6. Re-read after conflicts. A mutation can fail with `code: "conflict"` when
147
+ someone edited the file after your last read or write. Call `get_outline`,
148
+ reconcile the change, and retry. Never bypass a conflict by overwriting the
149
+ whole file.
150
+ 7. Export with `export_deck` and `format: "html"` for a self-contained
151
+ `.export.html` file, or `format: "pdf"` / `"png"` for rendered output. PDF
152
+ and PNG need a system Chrome, Edge, or Chromium (or `HTMLCRAFT_CHROMIUM`).
153
+
154
+ Every mutation returns a new `revision`. Reads return the revision they
155
+ observed. Pass no revision explicitly: the MCP server tracks the last
156
+ read/written revision per file and compares it before writing.
157
+
158
+ ## CLI fallback
159
+
160
+ ```bash
161
+ htmlcraft new deck.html --title "Quarterly review" --slides 3
162
+ htmlcraft validate deck.html # exit 0 valid, 1 invalid
163
+ htmlcraft validate deck.html --json
164
+ htmlcraft outline deck.html # human summary
165
+ htmlcraft outline deck.html --json
166
+ htmlcraft open deck.html # prints HTMLCRAFT_URL=http://127.0.0.1:...
167
+ htmlcraft open deck.html --no-browser --port 0
168
+ htmlcraft stop deck.html # stop one host
169
+ htmlcraft stop --all # stop every live host
170
+ htmlcraft export deck.html --format html --out dist/deck.html
171
+ htmlcraft export deck.html --format pdf --out dist/deck.pdf
172
+ htmlcraft export deck.html --format png --out dist/png
173
+ htmlcraft mcp # same stdio server as htmlcraft-mcp
174
+ ```
175
+
176
+ PDF and PNG export launch a system Chrome, Edge, or Chromium; set
177
+ `HTMLCRAFT_CHROMIUM` to an executable path when auto-discovery fails. `--out` is
178
+ a file for `html`/`pdf` and a directory for `png`.
179
+
180
+ `open` reuses a host only when two probes pass: the authenticated health
181
+ endpoint accepts the deck and the editor shell at `/d/<deck-name>` is the built
182
+ editor. A new host reuses the deck's recorded token and port, so the tokenized
183
+ URL stays valid across a restart until `htmlcraft stop` rotates the token; a
184
+ stale-build replacement rotates it too, because `open` stops the broken host
185
+ first, so a URL bookmarked before the replacement needs the newly printed one.
186
+ An explicit `--port` wins, and `--port 0` forces a fresh ephemeral port instead
187
+ of the recorded one. A `stale-build` host (health OK, editor broken) is stopped
188
+ and replaced on the recorded port by the next `open`. If a recorded host times
189
+ out or fails health with a 5xx, or its shell probe times out, `open` refuses to
190
+ start a second host and exits 1; retry or stop the recorded session first.
191
+
192
+ `stop --all` prunes registry entries whose recorded process has exited. When it
193
+ cleans only stale entries it prints `Removed <n> stale editor session(s).` and
194
+ exits 0; a truly empty registry still exits 1 with `No live editor sessions.`
195
+
196
+ ## Examples
197
+
198
+ All examples are complete decks validated by the CLI and contain the real
199
+ runtime script.
200
+
201
+ - [examples/basic.html](examples/basic.html) - text objects, speaker notes,
202
+ `fade` and `slide` transition attributes, runtime.
203
+ - [examples/table-chart.html](examples/table-chart.html) - a real table and a
204
+ chart whose JSON lives in `data-ppt-chart`.
205
+ - [examples/notes-transitions.html](examples/notes-transitions.html) - notes
206
+ on every slide and all three transition values.
207
+
208
+ Validate them with:
209
+
210
+ ```bash
211
+ htmlcraft validate skills/htmlcraft/examples/basic.html
212
+ ```
213
+
214
+ ## Authoring rules that prevent rework
215
+
216
+ - Use a fixed canvas and absolutely position top-level objects. Validation
217
+ warns (`fixed-layout`) for `position: fixed` and full-height `100vh`,
218
+ `100dvh`, `100svh`, or `100lvh`; those may not export reliably. Other
219
+ viewport units are not detected but still scale with the browser window, so
220
+ avoid them for layout.
221
+ - Put styling in a `<style>` block or inline `style` attributes. CSS
222
+ animations, inline SVG, flex/grid inside an object, and web fonts via
223
+ absolute URLs are welcome.
224
+ - Do not build layout with JavaScript. Scripts other than the runtime are
225
+ reported by validation and do not run in the editor.
226
+ - Keep text in real text nodes. `set_text` writes escaped text; use
227
+ `set_element_html` only when you deliberately need markup.
228
+ - Set explicit `data-ppt-el` ids on new top-level objects so later calls have a
229
+ stable handle.
230
+ - Use `data:` or absolute URLs for images and fonts. A relative path produces
231
+ the `relative-asset` warning.
232
+ - Keep chart JSON small and valid. `data-ppt-chart` is parsed during
233
+ validation.
234
+ - Run `validate_deck` / `htmlcraft validate` before exporting or handing the deck
235
+ to a person.
236
+
237
+ ## Troubleshooting
238
+
239
+ Start with [references/troubleshooting.md](references/troubleshooting.md). It
240
+ maps validation codes, MCP error codes, and CLI messages to fixes. The most
241
+ common issues are a missing or duplicated slide id, a relative asset path, an
242
+ invalid transition value, invalid chart JSON, a stale target after someone else
243
+ edited the deck, and a conflict that requires a re-read.
244
+
245
+ ## References
246
+
247
+ - [references/contract.md](references/contract.md) - the full htmldeck/v1
248
+ contract and validation rules.
249
+ - [references/authoring.md](references/authoring.md) - editor-friendly
250
+ authoring, styling freedom, and round-trip rules.
251
+ - [references/mcp-tools.md](references/mcp-tools.md) - every MCP tool,
252
+ resource, and error code.
253
+ - [references/troubleshooting.md](references/troubleshooting.md) - symptom to
254
+ fix for validation, MCP, and CLI failures.